fix(#2767): pass paths via --files to gsd-sdk query commit + lint guard (#2781)

* fix(#2767): pass paths via --files to gsd-sdk query commit + lint guard

Workflows, agents, commands, and references passed file paths positionally
to `gsd-sdk query commit`, which silently appended them to the commit
subject and triggered the `.planning/` wholesale-stage fallback in
sdk/src/query/commit.ts:136. Regression of #733/#798.

Inserted `--files` before the path list at every site (81 invocations
across 50 files). Added tests/bug-2767-gsd-sdk-commit-files-flag.test.cjs
as a permanent lint that scans every shipped .md file and asserts each
`gsd-sdk query commit[-to-subrepo]` invocation either uses `--files` or
carries no path arguments.

Closes #2767

* test(#2767): replace source-grep with behavioral SDK test

The original test walked every shipped .md file and regex-tokenized
`gsd-sdk query commit` invocations to assert `--files` was present.
CONTRIBUTING.md prohibits this source-grep pattern.

Rewrite as behavioral SDK tests against `sdk/dist/cli.js` over a real
tmp git project (createTempGitProject helper). Cover both the
well-formed (`--files <paths>`) form — clean subject, exactly-staged
files, .planning/ left untouched — and the buggy positional form,
asserting the documented misbehavior (paths leak into subject + the
`.planning/` wholesale-stage fallback at commit.ts:136). Also asserts
`commit-to-subrepo` rejects when `--files` is omitted (commit.ts:258).

The doc-lint is retained as a supplementary defense-in-depth guard
since agent-prompt markdown invocations cannot be exercised end-to-end
— but it is no longer the primary contract.

* docs(#2767): correct contradictory --files guidance in zh-CN/en docs + fix test docstring
This commit is contained in:
Tom Boucher
2026-04-27 12:31:43 -04:00
committed by GitHub
parent 3ac3a2ae70
commit 54e6da3126
51 changed files with 385 additions and 82 deletions

View File

@@ -345,6 +345,7 @@ Use `gsd-sdk query commit` with conventional format (message first, then every s
```bash
gsd-sdk query commit \
"fix({padded_phase}): {finding_id} {short_description}" \
--files \
{all_modified_files}
```
@@ -354,7 +355,7 @@ Examples:
**Multiple files:** List ALL modified files after the message (space-separated):
```bash
gsd-sdk query commit "fix(02): CR-01 ..." \
gsd-sdk query commit "fix(02): CR-01 ..." --files \
src/api/auth.ts src/types/user.ts tests/auth.test.ts
```

View File

@@ -1168,7 +1168,7 @@ Root cause: {root_cause}"
Then commit planning docs via CLI (respects `commit_docs` config automatically):
```bash
gsd-sdk query commit "docs: resolve debug {slug}" .planning/debug/resolved/{slug}.md
gsd-sdk query commit "docs: resolve debug {slug}" --files .planning/debug/resolved/{slug}.md
```
**Append to knowledge base:**
@@ -1199,7 +1199,7 @@ Then append the entry:
Commit the knowledge base update alongside the resolved session:
```bash
gsd-sdk query commit "docs: update debug knowledge base with {slug}" .planning/debug/knowledge-base.md
gsd-sdk query commit "docs: update debug knowledge base with {slug}" --files .planning/debug/knowledge-base.md
```
Report completion and offer next steps.

View File

@@ -563,7 +563,7 @@ gsd-sdk query state.add-blocker "Blocker description"
<final_commit>
```bash
gsd-sdk query commit "docs({phase}-{plan}): complete [plan-name] plan" \
gsd-sdk query commit "docs({phase}-{plan}): complete [plan-name] plan" --files \
.planning/phases/XX-name/{phase}-{plan}-SUMMARY.md .planning/STATE.md .planning/ROADMAP.md .planning/REQUIREMENTS.md
```

View File

@@ -755,7 +755,7 @@ Write to: `$PHASE_DIR/$PADDED_PHASE-RESEARCH.md`
## Step 7: Commit Research (optional)
```bash
gsd-sdk query commit "docs($PHASE): research phase domain" "$PHASE_DIR/$PADDED_PHASE-RESEARCH.md"
gsd-sdk query commit "docs($PHASE): research phase domain" --files "$PHASE_DIR/$PADDED_PHASE-RESEARCH.md"
```
## Step 8: Return Structured Result

View File

@@ -1136,7 +1136,7 @@ Plans:
<step name="git_commit">
```bash
gsd-sdk query commit "docs($PHASE): create phase plan" \
gsd-sdk query commit "docs($PHASE): create phase plan" --files \
.planning/phases/$PHASE-*/$PHASE-*-PLAN.md .planning/ROADMAP.md
```
</step>

View File

@@ -139,7 +139,7 @@ Write to `.planning/research/SUMMARY.md`
The 4 parallel researcher agents write files but do NOT commit. You commit everything together.
```bash
gsd-sdk query commit "docs: complete project research" .planning/research/
gsd-sdk query commit "docs: complete project research" --files .planning/research/
```
## Step 8: Return Summary

View File

@@ -292,7 +292,7 @@ Fill all sections. Write to `$PHASE_DIR/$PADDED_PHASE-UI-SPEC.md`.
## Step 6: Commit (optional)
```bash
gsd-sdk query commit "docs($PHASE): UI design contract" "$PHASE_DIR/$PADDED_PHASE-UI-SPEC.md"
gsd-sdk query commit "docs($PHASE): UI design contract" --files "$PHASE_DIR/$PADDED_PHASE-UI-SPEC.md"
```
## Step 7: Return Structured Result