* 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
161 lines
4.4 KiB
Markdown
161 lines
4.4 KiB
Markdown
<purpose>
|
|
Capture an idea, task, or issue that surfaces during a GSD session as a structured todo for later work. Enables "thought → capture → continue" flow without losing context.
|
|
</purpose>
|
|
|
|
<required_reading>
|
|
Read all files referenced by the invoking prompt's execution_context before starting.
|
|
</required_reading>
|
|
|
|
<process>
|
|
|
|
<step name="init_context">
|
|
Load todo context:
|
|
|
|
```bash
|
|
INIT=$(gsd-sdk query init.todos)
|
|
if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
|
|
```
|
|
|
|
Extract from init JSON: `commit_docs`, `date`, `timestamp`, `todo_count`, `todos`, `pending_dir`, `todos_dir_exists`.
|
|
|
|
Ensure directories exist:
|
|
```bash
|
|
mkdir -p .planning/todos/pending .planning/todos/completed
|
|
```
|
|
|
|
Note existing areas from the todos array for consistency in infer_area step.
|
|
</step>
|
|
|
|
<step name="extract_content">
|
|
**With arguments:** Use as the title/focus.
|
|
- `/gsd-add-todo Add auth token refresh` → title = "Add auth token refresh"
|
|
|
|
**Without arguments:** Analyze recent conversation to extract:
|
|
- The specific problem, idea, or task discussed
|
|
- Relevant file paths mentioned
|
|
- Technical details (error messages, line numbers, constraints)
|
|
|
|
Formulate:
|
|
- `title`: 3-10 word descriptive title (action verb preferred)
|
|
- `problem`: What's wrong or why this is needed
|
|
- `solution`: Approach hints or "TBD" if just an idea
|
|
- `files`: Relevant paths with line numbers from conversation
|
|
</step>
|
|
|
|
<step name="infer_area">
|
|
Infer area from file paths:
|
|
|
|
| Path pattern | Area |
|
|
|--------------|------|
|
|
| `src/api/*`, `api/*` | `api` |
|
|
| `src/components/*`, `src/ui/*` | `ui` |
|
|
| `src/auth/*`, `auth/*` | `auth` |
|
|
| `src/db/*`, `database/*` | `database` |
|
|
| `tests/*`, `__tests__/*` | `testing` |
|
|
| `docs/*` | `docs` |
|
|
| `.planning/*` | `planning` |
|
|
| `scripts/*`, `bin/*` | `tooling` |
|
|
| No files or unclear | `general` |
|
|
|
|
Use existing area from step 2 if similar match exists.
|
|
</step>
|
|
|
|
<step name="check_duplicates">
|
|
```bash
|
|
# Search for key words from title in existing todos
|
|
grep -l -i "[key words from title]" .planning/todos/pending/*.md 2>/dev/null || true
|
|
```
|
|
|
|
If potential duplicate found:
|
|
1. Read the existing todo
|
|
2. Compare scope
|
|
|
|
|
|
**Text mode (`workflow.text_mode: true` in config or `--text` flag):** Set `TEXT_MODE=true` if `--text` is present in `$ARGUMENTS` OR `text_mode` from init JSON is `true`. When TEXT_MODE is active, replace every `AskUserQuestion` call with a plain-text numbered list and ask the user to type their choice number. This is required for non-Claude runtimes (OpenAI Codex, Gemini CLI, etc.) where `AskUserQuestion` is not available.
|
|
If overlapping, use AskUserQuestion:
|
|
- header: "Duplicate?"
|
|
- question: "Similar todo exists: [title]. What would you like to do?"
|
|
- options:
|
|
- "Skip" — keep existing todo
|
|
- "Replace" — update existing with new context
|
|
- "Add anyway" — create as separate todo
|
|
</step>
|
|
|
|
<step name="create_file">
|
|
Use values from init context: `timestamp` and `date` are already available.
|
|
|
|
Generate slug for the title:
|
|
```bash
|
|
slug=$(gsd-sdk query generate-slug "$title" --raw)
|
|
```
|
|
|
|
Write to `.planning/todos/pending/${date}-${slug}.md`:
|
|
|
|
```markdown
|
|
---
|
|
created: [timestamp]
|
|
title: [title]
|
|
area: [area]
|
|
files:
|
|
- [file:lines]
|
|
---
|
|
|
|
## Problem
|
|
|
|
[problem description - enough context for future Claude to understand weeks later]
|
|
|
|
## Solution
|
|
|
|
[approach hints or "TBD"]
|
|
```
|
|
</step>
|
|
|
|
<step name="update_state">
|
|
If `.planning/STATE.md` exists:
|
|
|
|
1. Use `todo_count` from init context (or re-run `init todos` if count changed)
|
|
2. Update "### Pending Todos" under "## Accumulated Context"
|
|
</step>
|
|
|
|
<step name="git_commit">
|
|
Commit the todo and any updated state:
|
|
|
|
```bash
|
|
gsd-sdk query commit "docs: capture todo - [title]" --files .planning/todos/pending/[filename] .planning/STATE.md
|
|
```
|
|
|
|
Tool respects `commit_docs` config and gitignore automatically.
|
|
|
|
Confirm: "Committed: docs: capture todo - [title]"
|
|
</step>
|
|
|
|
<step name="confirm">
|
|
```
|
|
Todo saved: .planning/todos/pending/[filename]
|
|
|
|
[title]
|
|
Area: [area]
|
|
Files: [count] referenced
|
|
|
|
---
|
|
|
|
Would you like to:
|
|
|
|
1. Continue with current work
|
|
2. Add another todo
|
|
3. View all todos (/gsd-check-todos)
|
|
```
|
|
</step>
|
|
|
|
</process>
|
|
|
|
<success_criteria>
|
|
- [ ] Directory structure exists
|
|
- [ ] Todo file created with valid frontmatter
|
|
- [ ] Problem section has enough context for future Claude
|
|
- [ ] No duplicates (checked and resolved)
|
|
- [ ] Area consistent with existing todos
|
|
- [ ] STATE.md updated if exists
|
|
- [ ] Todo and state committed to git
|
|
</success_criteria>
|