Repository navigation
feat(check): scope a check to the files a unified diff changes with --diff[=<file>] - #741
Conversation
…unified diff changes
|
@claude /review |
|
Claude finished @aibex-agent[bot]'s task in 1m 15s —— View job Review complete
Review mode: incremental — read 0 prior review thread(s) before reviewing. This is the first review of this PR; there is nothing previously raised to classify as addressed or still open. SummaryThis is a docs-only OpenSpec proposal ( The proposal and design are well-reasoned and consistent with each other: whole-file scope (no changed-lines mode), reading a diff rather than invoking git, the [New] One concrete defect found: in No other inconsistencies, gaps, or ambiguities found in the delta specs, design doc, or tasks breakdown. Per the PR description, this draft intentionally carries only the proposal — implementation, changeset, and archive are meant to land before it leaves draft — so the above is the only item to clean up before that happens. Review status: complete |
| #### Scenario: The token after a bare --diff is a path, not a diff file | ||
|
|
||
| - **WHEN** a user runs `taskless check --diff change.patch` with a diff piped on stdin | ||
| - **THEN** `change.patch` SHALL be read as a positional path, not as the diff | ||
| - **AND** the CLI SHALL exit 1 with `INVALID_INPUT` because a diff and positional paths were given together |
There was a problem hiding this comment.
[New] This "Scenario: The token after a bare --diff is a path, not a diff file" block duplicates the one at lines 94-99 verbatim (same WHEN/THEN), except it drops the final **AND** SHALL NOT report the run as clean bullet that the first copy has. Looks like a copy-paste leftover from editing — one of the two should be removed, and if the dropped bullet was an intentional edit, the surviving copy should keep it rather than silently losing it.
There was a problem hiding this comment.
Fixed in e933a41. My edit had replaced a line that occurs twice, so the scenario was inserted twice and the first copy took the "SHALL NOT report the run as clean" clause from the scenario above it. The duplicate is gone and that clause is back on "Output that is not a unified diff".
…its neighbour's clause
|
@claude /review |
|
Claude finished @aibex-agent[bot]'s task in 5m 11s —— View job Review complete
Review mode: incremental — read 1 prior review thread(s) before reviewing. The one prior thread (duplicated "token after a bare --diff" scenario in SummaryThis PR implements Two concrete issues found, both [New]:
No other correctness, security, or test-adequacy issues found. The argv-scanning changes (optional-value flags), the exclusion/notice plumbing, and the refusal ordering in Review status: complete |
| text = | ||
| diffSource.kind === "stdin" | ||
| ? await readStdin() | ||
| : await readFile(resolve(diffSource.path), "utf8"); |
There was a problem hiding this comment.
[New] resolve(diffSource.path) resolves against process.cwd(), not against the command's own cwd (resolve(args.dir ?? process.cwd()), line 365). Every other path this command reads — the positionals handled by classifyPaths — is resolved against that cwd (see classifyPaths(cwd, positionalPaths) → resolve(resolvedCwd, rawPath) at lines 116-129). --diff=<file> is the one path argument that skips it.
Concretely: taskless check --dir ../other-project --diff=patch.diff where patch.diff lives inside ../other-project resolves the file against the invoking shell's cwd instead of ../other-project, so it won't be found and the run is refused with INVALID_INPUT ("Could not read the diff from …") even though the file exists at the path the user reasonably meant. This isn't covered by check-diff.test.ts, which only exercises an already-absolute --diff=<file> path, so the mismatch doesn't surface there.
If relative-to-shell-cwd is the intended behavior (plausible, since the diff is often piped/redirected from the invoking shell rather than the project under --dir), it'd be worth a one-line comment saying so and a test pinning it; otherwise this should resolve against cwd like everything else.
There was a problem hiding this comment.
Fixed in 957578b. It now resolves against the project directory (--dir), the same way --from does in feedback and report, with a test that passes a relative --diff=change.patch together with --dir from another working directory.
| `entitlement` with an empty `withheld` does not fail the run. | ||
|
|
||
| <!-- on-demand --> | ||
| ## Diff scope |
There was a problem hiding this comment.
[New] This new "Diff scope" section tells the agent to pipe a diff into check --diff, but step 2 above (lines 50-61, unedited by this PR) still says: "or, against a git diff: run git diff --name-only main...HEAD as its own call, then pass the paths it printed" into check --json src/foo.ts src/deleted.ts as positional arguments.
That's exactly the pattern this whole PR exists to move away from: per the PR description, positional paths from git diff --name-only don't get the .taskless/ exclusion this feature adds, so an upkeep PR that adds a rule (and lands its own tests/fail fixture) would turn its own diff check red if an agent follows the still-present step-2 guidance instead of the new --diff flag documented here. tasks.md (2026-12-05-check-diff-scope) task 3.3 explicitly calls for "keeping the existing one-command-per-call path-list guidance for agents" in this file, but the surviving text is the specific git diff --name-only-for-diff-scoping example, not just the general "pass a list of paths positionally" pattern — those are different things, and the recipe now recommends both for the same "check a diff" use case.
Worth updating step 2's diff bullet to point at --diff instead (or at least note that --diff is now the preferred way to scope to a diff, and that positional paths from a diff don't get the .taskless//.git/ exclusion).
There was a problem hiding this comment.
Fixed in 957578b. Step 2's diff bullet now has the agent run git diff --no-ext-diff --no-color main...HEAD as its own call, save the output to .taskless/.tmp-diff.patch (gitignored, like the other .tmp-* scratch files), and run check --json --diff=.taskless/.tmp-diff.patch, and it notes that --diff skips .taskless/ while a path list does not. Piping isn't an option for an agent under the one-command-per-call rule. The standing cli-agent scenario that required the --name-only path list is updated to match.
…recipe's diff step at --diff
taskless check --diffreads a unified diff (stdin, or a file through--diff=<file>) and checks every file it adds or modifies, whole. The CLI never runs git.Why: the old diff recipe expanded
$(git diff --name-only ...)into the command line, and positional paths skip the.taskless/exclusion. Measured here: the files ofsg/no-evalandvale/no-em-dashes, passed that way, reported 6 errors and exit 1, all from the rules' owntests/failfixtures. An upkeep PR that adds a rule produces exactly that diff, so it would have turned its own diff check red.What landed:
src/util/unified-diff.ts: a header-only parser. Hunks are consumed by their line counts, so an added line reading+++ b/xis never a header. Handlesa//b/and mnemonici//w/prefixes, renames, binaries, deletions, C-quoted paths, and the tab git appends to a path with a space. Tested against fixturesgit diff --stagedwrote.check --diff[=<file>]: the value comes only from=(a new optional-value class in the shared argv scanner), socheck --diff src/a.tsreads the path as a path and refuses the pair. Diff paths go through the existing path classification, then skip.taskless/and.git/, named in a notice. An empty diff exits 0. Refused withINVALID_INPUT: input with no file headers, a terminal on stdin, a diff with paths, an unreadable file.ciandhookspipegit diff --no-ext-diff --no-color --relative ...intocheck --diff;checkdocuments it in an on-demand section (the topic was at its 8 KiB budget). README updated.patch: this adds surface and breaks no existing call. The=-only syntax for every value flag, the breaking part, is a separate change.Verified:
pnpm typecheck,pnpm lint, full suite (3501 passed), plus a realgit diff --stagedpiped end to end, and the terminal-stdin refusal under a pseudo-terminal. Archived; the pre-archive scenario count shows no scenario dropped (cli-check 118 → 132, cli-agent 99 → 101).