refactor: extract check-todos, add-phase, update to thin orchestrators

Pattern: Command → workflow → gsd-tools
Token savings: ~150 chars per command

Ported from: get-shit-done-v2@213392b
This commit is contained in:
TÂCHES
2026-02-07 11:08:27 -06:00
parent 01ae939c01
commit 8f26bfa478
6 changed files with 616 additions and 577 deletions

View File

@@ -0,0 +1,178 @@
<purpose>
Add a new integer phase to the end of the current milestone in the roadmap. Automatically calculates next phase number, creates phase directory, and updates roadmap structure.
</purpose>
<required_reading>
Read all files referenced by the invoking prompt's execution_context before starting.
</required_reading>
<process>
<step name="parse_arguments">
Parse the command arguments:
- All arguments become the phase description
- Example: `/gsd:add-phase Add authentication` → description = "Add authentication"
- Example: `/gsd:add-phase Fix critical performance issues` → description = "Fix critical performance issues"
If no arguments provided:
```
ERROR: Phase description required
Usage: /gsd:add-phase <description>
Example: /gsd:add-phase Add authentication system
```
Exit.
</step>
<step name="load_roadmap">
Load the roadmap file:
```bash
node ~/.claude/get-shit-done/bin/gsd-tools.js verify-path-exists .planning/ROADMAP.md --raw
```
If false:
```
ERROR: No roadmap found (.planning/ROADMAP.md)
Run /gsd:new-project to initialize.
```
Exit.
Read roadmap content for parsing.
</step>
<step name="find_current_milestone">
Parse the roadmap to find the current milestone section:
1. Locate the "## Current Milestone:" heading
2. Extract milestone name and version
3. Identify all phases under this milestone (before next "---" separator or next milestone heading)
4. Parse existing phase numbers (including decimals if present)
Example structure:
```
## Current Milestone: v1.0 Foundation
### Phase 4: Focused Command System
### Phase 5: Path Routing & Validation
### Phase 6: Documentation & Distribution
```
</step>
<step name="calculate_next_phase">
Find the highest integer phase number in the current milestone:
1. Extract all phase numbers from phase headings (### Phase N:)
2. Filter to integer phases only (ignore decimals like 4.1, 4.2)
3. Find the maximum integer value
4. Add 1 to get the next phase number
Example: If phases are 4, 5, 5.1, 6 → next is 7
Format as two-digit: `printf "%02d" $next_phase`
</step>
<step name="generate_slug">
Convert the phase description to a kebab-case slug:
```bash
slug=$(node ~/.claude/get-shit-done/bin/gsd-tools.js generate-slug "$description" --raw)
```
Phase directory name: `{two-digit-phase}-{slug}`
Example: `07-add-authentication`
</step>
<step name="create_phase_directory">
Create the phase directory structure:
```bash
phase_dir=".planning/phases/${phase_num}-${slug}"
mkdir -p "$phase_dir"
```
Confirm: "Created directory: $phase_dir"
</step>
<step name="update_roadmap">
Add the new phase entry to the roadmap:
1. Find the insertion point (after last phase in current milestone, before "---" separator)
2. Insert new phase heading:
```
### Phase {N}: {Description}
**Goal:** [To be planned]
**Depends on:** Phase {N-1}
**Plans:** 0 plans
Plans:
- [ ] TBD (run /gsd:plan-phase {N} to break down)
**Details:**
[To be added during planning]
```
3. Write updated roadmap back to file
Preserve all other content exactly (formatting, spacing, other phases).
</step>
<step name="update_project_state">
Update STATE.md to reflect the new phase:
1. Read `.planning/STATE.md`
2. Under "## Current Position" → "**Next Phase:**" add reference to new phase
3. Under "## Accumulated Context" → "### Roadmap Evolution" add entry:
```
- Phase {N} added: {description}
```
If "Roadmap Evolution" section doesn't exist, create it.
</step>
<step name="completion">
Present completion summary:
```
Phase {N} added to current milestone:
- Description: {description}
- Directory: .planning/phases/{phase-num}-{slug}/
- Status: Not planned yet
Roadmap updated: .planning/ROADMAP.md
Project state updated: .planning/STATE.md
---
## ▶ Next Up
**Phase {N}: {description}**
`/gsd:plan-phase {N}`
<sub>`/clear` first → fresh context window</sub>
---
**Also available:**
- `/gsd:add-phase <description>` — add another phase
- Review roadmap
---
```
</step>
</process>
<success_criteria>
- [ ] Phase directory created: `.planning/phases/{NN}-{slug}/`
- [ ] Roadmap updated with new phase entry
- [ ] STATE.md updated with roadmap evolution note
- [ ] New phase appears at end of current milestone
- [ ] Next phase number calculated correctly (ignoring decimals)
- [ ] User informed of next steps
</success_criteria>

View File

@@ -0,0 +1,182 @@
<purpose>
List all pending todos, allow selection, load full context for the selected todo, and route to appropriate action.
</purpose>
<required_reading>
Read all files referenced by the invoking prompt's execution_context before starting.
</required_reading>
<process>
<step name="check_exist">
```bash
TODO_COUNT=$(node ~/.claude/get-shit-done/bin/gsd-tools.js list-todos --raw)
echo "Pending todos: $TODO_COUNT"
```
If count is 0:
```
No pending todos.
Todos are captured during work sessions with /gsd:add-todo.
---
Would you like to:
1. Continue with current phase (/gsd:progress)
2. Add a todo now (/gsd:add-todo)
```
Exit.
</step>
<step name="parse_filter">
Check for area filter in arguments:
- `/gsd:check-todos` → show all
- `/gsd:check-todos api` → filter to area:api only
</step>
<step name="list_todos">
```bash
# Get todos JSON
node ~/.claude/get-shit-done/bin/gsd-tools.js list-todos [area]
```
Parse JSON output and display as numbered list:
```
Pending Todos:
1. Add auth token refresh (api, 2d ago)
2. Fix modal z-index issue (ui, 1d ago)
3. Refactor database connection pool (database, 5h ago)
---
Reply with a number to view details, or:
- `/gsd:check-todos [area]` to filter by area
- `q` to exit
```
Format age as relative time from created timestamp.
</step>
<step name="handle_selection">
Wait for user to reply with a number.
If valid: load selected todo, proceed.
If invalid: "Invalid selection. Reply with a number (1-[N]) or `q` to exit."
</step>
<step name="load_context">
Read the todo file completely. Display:
```
## [title]
**Area:** [area]
**Created:** [date] ([relative time] ago)
**Files:** [list or "None"]
### Problem
[problem section content]
### Solution
[solution section content]
```
If `files` field has entries, read and briefly summarize each.
</step>
<step name="check_roadmap">
```bash
node ~/.claude/get-shit-done/bin/gsd-tools.js verify-path-exists .planning/ROADMAP.md --raw
```
If roadmap exists:
1. Check if todo's area matches an upcoming phase
2. Check if todo's files overlap with a phase's scope
3. Note any match for action options
</step>
<step name="offer_actions">
**If todo maps to a roadmap phase:**
Use AskUserQuestion:
- header: "Action"
- question: "This todo relates to Phase [N]: [name]. What would you like to do?"
- options:
- "Work on it now" — move to done, start working
- "Add to phase plan" — include when planning Phase [N]
- "Brainstorm approach" — think through before deciding
- "Put it back" — return to list
**If no roadmap match:**
Use AskUserQuestion:
- header: "Action"
- question: "What would you like to do with this todo?"
- options:
- "Work on it now" — move to done, start working
- "Create a phase" — /gsd:add-phase with this scope
- "Brainstorm approach" — think through before deciding
- "Put it back" — return to list
</step>
<step name="execute_action">
**Work on it now:**
```bash
mv ".planning/todos/pending/[filename]" ".planning/todos/done/"
```
Update STATE.md todo count. Present problem/solution context. Begin work or ask how to proceed.
**Add to phase plan:**
Note todo reference in phase planning notes. Keep in pending. Return to list or exit.
**Create a phase:**
Display: `/gsd:add-phase [description from todo]`
Keep in pending. User runs command in fresh context.
**Brainstorm approach:**
Keep in pending. Start discussion about problem and approaches.
**Put it back:**
Return to list_todos step.
</step>
<step name="update_state">
After any action that changes todo count:
```bash
node ~/.claude/get-shit-done/bin/gsd-tools.js list-todos --raw
```
Update STATE.md "### Pending Todos" section if exists.
</step>
<step name="git_commit">
If todo was moved to done/, commit the change:
```bash
git rm --cached .planning/todos/pending/[filename] 2>/dev/null || true
node ~/.claude/get-shit-done/bin/gsd-tools.js commit "docs: start work on todo - [title]" --files .planning/todos/done/[filename] .planning/STATE.md
```
Tool respects `commit_docs` config and gitignore automatically.
Confirm: "Committed: docs: start work on todo - [title]"
</step>
</process>
<success_criteria>
- [ ] All pending todos listed with title, area, age
- [ ] Area filter applied if specified
- [ ] Selected todo's full context loaded
- [ ] Roadmap context checked for phase match
- [ ] Appropriate actions offered
- [ ] Selected action executed
- [ ] STATE.md updated if todo count changed
- [ ] Changes committed to git (if todo moved to done/)
</success_criteria>

View File

@@ -0,0 +1,197 @@
<purpose>
Check for GSD updates via npm, display changelog for versions between installed and latest, obtain user confirmation, and execute clean installation with cache clearing.
</purpose>
<required_reading>
Read all files referenced by the invoking prompt's execution_context before starting.
</required_reading>
<process>
<step name="get_installed_version">
Detect whether GSD is installed locally or globally by checking both locations:
```bash
# Check local first (takes priority)
if [ -f "./.claude/get-shit-done/VERSION" ]; then
cat "./.claude/get-shit-done/VERSION"
echo "LOCAL"
elif [ -f ~/.claude/get-shit-done/VERSION ]; then
cat ~/.claude/get-shit-done/VERSION
echo "GLOBAL"
else
echo "UNKNOWN"
fi
```
Parse output:
- If last line is "LOCAL": installed version is first line, use `--local` flag for update
- If last line is "GLOBAL": installed version is first line, use `--global` flag for update
- If "UNKNOWN": proceed to install step (treat as version 0.0.0)
**If VERSION file missing:**
```
## GSD Update
**Installed version:** Unknown
Your installation doesn't include version tracking.
Running fresh install...
```
Proceed to install step (treat as version 0.0.0 for comparison).
</step>
<step name="check_latest_version">
Check npm for latest version:
```bash
npm view get-shit-done-cc version 2>/dev/null
```
**If npm check fails:**
```
Couldn't check for updates (offline or npm unavailable).
To update manually: `npx get-shit-done-cc --global`
```
Exit.
</step>
<step name="compare_versions">
Compare installed vs latest:
**If installed == latest:**
```
## GSD Update
**Installed:** X.Y.Z
**Latest:** X.Y.Z
You're already on the latest version.
```
Exit.
**If installed > latest:**
```
## GSD Update
**Installed:** X.Y.Z
**Latest:** A.B.C
You're ahead of the latest release (development version?).
```
Exit.
</step>
<step name="show_changes_and_confirm">
**If update available**, fetch and show what's new BEFORE updating:
1. Fetch changelog from GitHub raw URL
2. Extract entries between installed and latest versions
3. Display preview and ask for confirmation:
```
## GSD Update Available
**Installed:** 1.5.10
**Latest:** 1.5.15
### What's New
────────────────────────────────────────────────────────────
## [1.5.15] - 2026-01-20
### Added
- Feature X
## [1.5.14] - 2026-01-18
### Fixed
- Bug fix Y
────────────────────────────────────────────────────────────
⚠️ **Note:** The installer performs a clean install of GSD folders:
- `commands/gsd/` will be wiped and replaced
- `get-shit-done/` will be wiped and replaced
- `agents/gsd-*` files will be replaced
(Paths are relative to your install location: `~/.claude/` for global, `./.claude/` for local)
Your custom files in other locations are preserved:
- Custom commands not in `commands/gsd/` ✓
- Custom agents not prefixed with `gsd-` ✓
- Custom hooks ✓
- Your CLAUDE.md files ✓
If you've modified any GSD files directly, back them up first.
```
Use AskUserQuestion:
- Question: "Proceed with update?"
- Options:
- "Yes, update now"
- "No, cancel"
**If user cancels:** Exit.
</step>
<step name="run_update">
Run the update using the install type detected in step 1:
**If LOCAL install:**
```bash
npx get-shit-done-cc --local
```
**If GLOBAL install (or unknown):**
```bash
npx get-shit-done-cc --global
```
Capture output. If install fails, show error and exit.
Clear the update cache so statusline indicator disappears:
**If LOCAL install:**
```bash
rm -f ./.claude/cache/gsd-update-check.json
```
**If GLOBAL install:**
```bash
rm -f ~/.claude/cache/gsd-update-check.json
```
</step>
<step name="display_result">
Format completion message (changelog was already shown in confirmation step):
```
╔═══════════════════════════════════════════════════════════╗
║ GSD Updated: v1.5.10 → v1.5.15 ║
╚═══════════════════════════════════════════════════════════╝
⚠️ Restart Claude Code to pick up the new commands.
[View full changelog](https://github.com/glittercowboy/get-shit-done/blob/main/CHANGELOG.md)
```
</step>
</process>
<success_criteria>
- [ ] Installed version read correctly
- [ ] Latest version checked via npm
- [ ] Update skipped if already current
- [ ] Changelog fetched and displayed BEFORE update
- [ ] Clean install warning shown
- [ ] User confirmation obtained
- [ ] Update executed successfully
- [ ] Restart reminder shown
</success_criteria>