Files
msd-core/get-shit-done/workflows/next.md
Rezolv d3a79917fa feat: Phase 2 caller migration — gsd-sdk query in workflows, agents, commands (#2179)
* feat: Phase 2 caller migration — gsd-sdk query in workflows (#2122)

Cherry-picked orchestration rewrites from feat/sdk-foundation (#2008, 4018fee) onto current main, resolving conflicts to keep upstream worktree guards and post-merge test gate. SDK stub registry omitted (out of Phase 2 scope per #2122).

Refs: #2122 #2008
Made-with: Cursor

* docs: add gsd-sdk query migration blurb

Made-with: Cursor

* docs(workflows): extend Phase 2 gsd-sdk query caller migration

- Swap node gsd-tools.cjs for gsd-sdk query in review, plan-phase, execute-plan,
  ship, extract_learnings, ai-integration-phase, eval-review, next, thread
- Document graphify CJS-only in gsd-planner; dual-path in CLI-TOOLS and ARCHITECTURE
- Update tests: workstreams gsd-sdk path, thread frontmatter.get, workspace init.*,
  CRLF-safe autonomous frontmatter parse
- CHANGELOG: Phase 2 caller migration scope

Made-with: Cursor

* docs(phase2): USER-GUIDE + remaining gsd-sdk query call sites

- USER-GUIDE: dual-path CLI section; state validate/sync use full CJS path
- Commands: debug (config-get+tdd), quick (security note), intel Task prompt
- Agent: gsd-debug-session-manager resolve-model via jq
- Workflows: milestone-summary, forensics, next, complete-milestone/verify-work
  (audit-open CJS notes), discuss-phase, progress, verify-phase, add/insert/remove
  phase, transition, manager, quick workflow; remove-phase commit without --files
- Test: quick-session-management accepts frontmatter.get
- CHANGELOG: Phase 2 follow-up bullet

Made-with: Cursor

* docs(phase2): align gsd-sdk query examples in commands and agents

- init.* query names; frontmatter.get uses positional field name
- state.* handlers use positional args; commit uses positional paths
- CJS-only notes for from-gsd2 and graphify; learnings.query wording
- CHANGELOG: Phase 2 orchestration doc pass

Made-with: Cursor

* docs(phase2): normalize gsd-sdk query commit to positional file paths

- Strip --files from commit examples in workflows, references, commands
- Keep commit-to-subrepo ... --files (separate handler)
- git-planning-commit.md: document positional args
- Tests: new-project commit line, state.record-session, gates CRLF, roadmap.analyze
- CHANGELOG [Unreleased]

Made-with: Cursor

* feat(sdk): gsd-sdk query parity with gsd-tools and PR 2179 registry fixes

- Route query via longest-prefix match and dotted single-token expansion; fall back
  to runGsdToolsQuery (same argv as node gsd-tools.cjs) for full CLI coverage.
- Parse gsd-sdk query permissively so gsd-tools flags (--json, --verify, etc.) are
  not rejected by strict parseArgs.
- resolveGsdToolsPath: honor GSD_TOOLS_PATH; prefer bundled get-shit-done copy
  over project .claude installs; export runGsdToolsQuery from the SDK.
- Fix gsd-tools audit-open (core.output; pass object for --json JSON).
- Register summary-extract as alias of summary.extract; fix audit-fix workflow to
  call audit-uat instead of invalid init.audit-uat (PR review).

Updates QUERY-HANDLERS.md and CHANGELOG [Unreleased].

Made-with: Cursor

* fix(sdk): Phase 2 scope — Trek-e review (#2179, #2122)

- Remove gsd-sdk query passthrough to gsd-tools.cjs; drop GSD_TOOLS_PATH
- Consolidate argv routing in resolveQueryArgv(); update USAGE and QUERY-HANDLERS
- Surface @file: read failures in GSDTools.parseOutput
- execute-plan: defer Task Commit Protocol to gsd-executor
- stale-colon-refs: skip .planning/ and root CLAUDE.md (gitignored overlays)
- CHANGELOG [Unreleased]: maintainer review and routing notes

Made-with: Cursor
2026-04-15 22:46:31 -04:00

6.7 KiB

Detect current project state and automatically advance to the next logical GSD workflow step. Reads project state to determine: discuss → plan → execute → verify → complete progression.

<required_reading> Read all files referenced by the invoking prompt's execution_context before starting. </required_reading>

Read project state to determine current position:
# Get state snapshot
gsd-sdk query state.json 2>/dev/null || echo "{}"

Also read:

  • .planning/STATE.md — current phase, progress, plan counts
  • .planning/ROADMAP.md — milestone structure and phase list

Extract:

  • current_phase — which phase is active
  • plan_of / plans_total — plan execution progress
  • progress — overall percentage
  • status — active, paused, etc.

If no .planning/ directory exists:

No GSD project detected. Run `/gsd-new-project` to get started.

Exit.

Run hard-stop checks before routing. Exit on first hit unless `--force` was passed.

If --force flag was passed, skip all gates and the consecutive guard. Print a one-line warning: ⚠ --force: skipping safety gates Then proceed directly to determine_next_action.

Gate 1: Unresolved checkpoint Check if .planning/.continue-here.md exists:

[ -f .planning/.continue-here.md ]

If found:

⛔ Hard stop: Unresolved checkpoint

`.planning/.continue-here.md` exists — a previous session left
unfinished work that needs manual review before advancing.

Read the file, resolve the issue, then delete it to continue.
Use `--force` to bypass this check.

Exit (do not route).

Gate 2: Error state Check if STATE.md contains status: error or status: failed: If found:

⛔ Hard stop: Project in error state

STATE.md shows status: {status}. Resolve the error before advancing.
Run `/gsd-health` to diagnose, or manually fix STATE.md.
Use `--force` to bypass this check.

Exit.

Gate 3: Unchecked verification Check if the current phase has a VERIFICATION.md with any FAIL items that don't have overrides: If found:

⛔ Hard stop: Unchecked verification failures

VERIFICATION.md for phase {N} has {count} unresolved FAIL items.
Address the failures or add overrides before advancing to the next phase.
Use `--force` to bypass this check.

Exit.

Prior-phase completeness scan: After passing all three hard-stop gates, scan all phases that precede the current phase in ROADMAP.md order for incomplete work. For each prior phase number N, use gsd-sdk query find-phase <N> JSON (plans, summaries, incomplete_plans, etc.) to inspect that phase.

Detect three categories of incomplete work:

  1. Plans without summaries — a PLAN.md exists in a prior phase directory but no matching SUMMARY.md exists (execution started but not completed).
  2. Verification failures not overridden — a prior phase has a VERIFICATION.md with FAIL items that have no override annotation.
  3. CONTEXT.md without plans — a prior phase directory has a CONTEXT.md but no PLAN.md files (discussion happened, planning never ran).

If no incomplete prior work is found, continue to determine_next_action silently with no interruption.

If incomplete prior work is found, show a structured completeness report:

⚠ Prior phase has incomplete work

Phase {N} — "{name}" has unresolved items:
  • Plan {N}-{M} ({slug}): executed but no SUMMARY.md
  [... additional items ...]

Advancing before resolving these may cause:
  • Verification gaps — future phase verification won't have visibility into what prior phases shipped
  • Context loss — plans that ran without summaries leave no record for future agents

Options:
  [C] Continue and defer these items to backlog
  [S] Stop and resolve manually (recommended)
  [F] Force advance without recording deferral

Choice [S]:

If the user chooses "Stop" (S or Enter/default): Exit without routing.

If the user chooses "Continue and defer" (C):

  1. For each incomplete item, create a backlog entry in ROADMAP.md under ## Backlog using the existing 999.x numbering scheme:
### Phase 999.{N}: Follow-up — Phase {src} incomplete plans (BACKLOG)

**Goal:** Resolve plans that ran without producing summaries during Phase {src} execution
**Source phase:** {src}
**Deferred at:** {date} during /gsd-next advancement to Phase {dest}
**Plans:**
- [ ] {N}-{M}: {slug} (ran, no SUMMARY.md)
  1. Commit the deferral record:
gsd-sdk query commit "docs: defer incomplete Phase {src} items to backlog"
  1. Continue routing to determine_next_action immediately — no second prompt.

If the user chooses "Force" (F): Continue to determine_next_action without recording deferral.

Apply routing rules based on state:

Route 1: No phases exist yet → discuss If ROADMAP has phases but no phase directories exist on disk: → Next action: /gsd-discuss-phase <first-phase>

Route 2: Phase exists but has no CONTEXT.md or RESEARCH.md → discuss If the current phase directory exists but has neither CONTEXT.md nor RESEARCH.md: → Next action: /gsd-discuss-phase <current-phase>

Route 3: Phase has context but no plans → plan If the current phase has CONTEXT.md (or RESEARCH.md) but no PLAN.md files: → Next action: /gsd-plan-phase <current-phase>

Route 4: Phase has plans but incomplete summaries → execute If plans exist but not all have matching summaries: → Next action: /gsd-execute-phase <current-phase>

Route 5: All plans have summaries → verify and complete If all plans in the current phase have summaries: → Next action: /gsd-verify-work

Route 6: Phase complete, next phase exists → advance If the current phase is complete and the next phase exists in ROADMAP: → Next action: /gsd-discuss-phase <next-phase>

Route 7: All phases complete → complete milestone If all phases are complete: → Next action: /gsd-complete-milestone

Route 8: Paused → resume If STATE.md shows paused_at: → Next action: /gsd-resume-work

Display the determination:
## GSD Next

**Current:** Phase [N] — [name] | [progress]%
**Status:** [status description]

▶ **Next step:** `/gsd-[command] [args]`
  [One-line explanation of why this is the next step]

Then immediately invoke the determined command via SlashCommand. Do not ask for confirmation — the whole point of /gsd-next is zero-friction advancement.

<success_criteria>

  • Project state correctly detected
  • Next action correctly determined from routing rules
  • Command invoked immediately without user confirmation
  • Clear status shown before invoking </success_criteria>