Repository navigation
feat: audit --fix writes the missing paths into workflow filters - #21
Conversation
There was a problem hiding this comment.
Looks good. src/fix.ts re-parses every edit and requires the result to equal the original document with only that paths list changed. Anything else is left alone and reported, so a mis-edit is unlikely to land silently. Text edits never go through a shell, which follows the untrusted-input rule. I found no blocking issues.
Not verified: I didn't run the build or tests, and I didn't diff the rebuilt dist/ against the source.
Minor, non-blocking: in flow lists, lastIndexOf(']') can match a ] inside a trailing comment. The re-parse check catches this and the finding is reported as "left", so the cost is a missed fix, not a bad edit.
There was a problem hiding this comment.
Looks good. The re-parse check (only the targeted paths list may differ) is a solid safety net, and the CLI is gated properly (--fix rejected outside audit). I couldn't run the build or tests here, so I judged from the diff.
Non-blocking notes:
fixAudit(src/cli.ts) callswriteFileSynconjoin(top, file). Per AGENTS.md, repo contents are untrusted: a workflow file that is a symlink pointing outside the repo would be written through. Consider skipping symlinks (lstatSync).fixOnenormalizes mixed line endings to a singleeol(lines.join(eol)), and the re-parse can't detect that. This could produce a larger diff than "edits only the paths list" promises.- Appending
dir/**to the end of a list that contains!negatedpatterns changes the filter's meaning, because order matters in GitHub path filters. The parse check can't see this. Consider inserting before the first!entry, or skipping the fix when the list contains negations. fix.addalready present returns the text unchanged and is counted as "fixed", which slightly inflates the summary count.
Summary
dynamic-monorepo audit # reports drifted on.*.paths filters +dynamic-monorepo audit --fix # writes the missing entries, edits nothing elseWhy: maintainers merge our path-filter fixes but often won't add a third-party action ("we avoid third-party actions in CI", devlint/GitWand#210).
--fixgives them the result with no CI dependency, and every fix PR can say how to rerun it.Evidence
--fixrejected outsideaudit.tsc, build andvitest: 129 passed, 1 skipped.Every edited workflow still parses, and only lines inside
paths:were added. A flow list ([...]) is rewritten on its one line.Merge danger
Door: two-way (CLI flag only; the Action is unchanged).
Blast radius: CLI users who pass
--fix.