gsd-remix 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +939 -0
- package/README.zh-CN.md +876 -0
- package/agents/gsd-advisor-researcher.md +127 -0
- package/agents/gsd-ai-researcher.md +133 -0
- package/agents/gsd-assumptions-analyzer.md +105 -0
- package/agents/gsd-code-fixer.md +517 -0
- package/agents/gsd-code-reviewer.md +371 -0
- package/agents/gsd-codebase-mapper.md +781 -0
- package/agents/gsd-debug-session-manager.md +314 -0
- package/agents/gsd-debugger.md +1452 -0
- package/agents/gsd-doc-classifier.md +168 -0
- package/agents/gsd-doc-synthesizer.md +204 -0
- package/agents/gsd-doc-verifier.md +217 -0
- package/agents/gsd-doc-writer.md +615 -0
- package/agents/gsd-domain-researcher.md +153 -0
- package/agents/gsd-eval-auditor.md +191 -0
- package/agents/gsd-eval-planner.md +154 -0
- package/agents/gsd-executor.md +603 -0
- package/agents/gsd-framework-selector.md +160 -0
- package/agents/gsd-integration-checker.md +470 -0
- package/agents/gsd-intel-updater.md +334 -0
- package/agents/gsd-nyquist-auditor.md +203 -0
- package/agents/gsd-pattern-mapper.md +335 -0
- package/agents/gsd-phase-researcher.md +841 -0
- package/agents/gsd-plan-checker.md +978 -0
- package/agents/gsd-planner.md +1251 -0
- package/agents/gsd-project-researcher.md +677 -0
- package/agents/gsd-research-synthesizer.md +247 -0
- package/agents/gsd-roadmapper.md +688 -0
- package/agents/gsd-security-auditor.md +155 -0
- package/agents/gsd-ui-auditor.md +495 -0
- package/agents/gsd-ui-checker.md +309 -0
- package/agents/gsd-ui-researcher.md +380 -0
- package/agents/gsd-user-profiler.md +171 -0
- package/agents/gsd-verifier.md +830 -0
- package/bin/install.js +7062 -0
- package/commands/gsd/add-backlog.md +79 -0
- package/commands/gsd/add-phase.md +43 -0
- package/commands/gsd/add-tests.md +41 -0
- package/commands/gsd/add-todo.md +47 -0
- package/commands/gsd/ai-integration-phase.md +36 -0
- package/commands/gsd/analyze-dependencies.md +34 -0
- package/commands/gsd/audit-fix.md +33 -0
- package/commands/gsd/audit-milestone.md +36 -0
- package/commands/gsd/audit-uat.md +24 -0
- package/commands/gsd/autonomous.md +46 -0
- package/commands/gsd/check-todos.md +45 -0
- package/commands/gsd/cleanup.md +23 -0
- package/commands/gsd/code-review-fix.md +52 -0
- package/commands/gsd/code-review.md +55 -0
- package/commands/gsd/complete-milestone.md +136 -0
- package/commands/gsd/debug.md +263 -0
- package/commands/gsd/discuss-phase.md +69 -0
- package/commands/gsd/do.md +30 -0
- package/commands/gsd/docs-update.md +48 -0
- package/commands/gsd/eval-review.md +32 -0
- package/commands/gsd/execute-phase.md +63 -0
- package/commands/gsd/explore.md +27 -0
- package/commands/gsd/extract_learnings.md +22 -0
- package/commands/gsd/fast.md +30 -0
- package/commands/gsd/forensics.md +56 -0
- package/commands/gsd/from-gsd2.md +47 -0
- package/commands/gsd/graphify.md +201 -0
- package/commands/gsd/health.md +22 -0
- package/commands/gsd/help.md +24 -0
- package/commands/gsd/import.md +37 -0
- package/commands/gsd/inbox.md +38 -0
- package/commands/gsd/ingest-docs.md +42 -0
- package/commands/gsd/insert-phase.md +32 -0
- package/commands/gsd/intel.md +179 -0
- package/commands/gsd/join-discord.md +19 -0
- package/commands/gsd/list-phase-assumptions.md +46 -0
- package/commands/gsd/list-workspaces.md +19 -0
- package/commands/gsd/manager.md +40 -0
- package/commands/gsd/map-codebase.md +71 -0
- package/commands/gsd/milestone-summary.md +51 -0
- package/commands/gsd/new-milestone.md +44 -0
- package/commands/gsd/new-project.md +46 -0
- package/commands/gsd/new-workspace.md +44 -0
- package/commands/gsd/next.md +28 -0
- package/commands/gsd/note.md +34 -0
- package/commands/gsd/pause-work.md +38 -0
- package/commands/gsd/plan-milestone-gaps.md +34 -0
- package/commands/gsd/plan-phase.md +52 -0
- package/commands/gsd/plan-review-convergence.md +52 -0
- package/commands/gsd/plant-seed.md +28 -0
- package/commands/gsd/pr-branch.md +25 -0
- package/commands/gsd/profile-user.md +46 -0
- package/commands/gsd/progress.md +25 -0
- package/commands/gsd/quick.md +173 -0
- package/commands/gsd/reapply-patches.md +331 -0
- package/commands/gsd/remove-phase.md +31 -0
- package/commands/gsd/remove-workspace.md +26 -0
- package/commands/gsd/research-phase.md +195 -0
- package/commands/gsd/resume-work.md +40 -0
- package/commands/gsd/review-backlog.md +62 -0
- package/commands/gsd/review.md +40 -0
- package/commands/gsd/scan.md +26 -0
- package/commands/gsd/secure-phase.md +35 -0
- package/commands/gsd/session-report.md +19 -0
- package/commands/gsd/set-profile.md +12 -0
- package/commands/gsd/settings.md +36 -0
- package/commands/gsd/ship.md +23 -0
- package/commands/gsd/sketch-wrap-up.md +31 -0
- package/commands/gsd/sketch.md +49 -0
- package/commands/gsd/spec-phase.md +62 -0
- package/commands/gsd/spike-wrap-up.md +31 -0
- package/commands/gsd/spike.md +46 -0
- package/commands/gsd/stats.md +18 -0
- package/commands/gsd/sync-skills.md +19 -0
- package/commands/gsd/thread.md +227 -0
- package/commands/gsd/ui-phase.md +34 -0
- package/commands/gsd/ui-review.md +32 -0
- package/commands/gsd/ultraplan-phase.md +33 -0
- package/commands/gsd/undo.md +34 -0
- package/commands/gsd/update.md +37 -0
- package/commands/gsd/validate-phase.md +35 -0
- package/commands/gsd/verify-work.md +38 -0
- package/commands/gsd/workstreams.md +69 -0
- package/get-shit-done/bin/gsd-tools.cjs +1263 -0
- package/get-shit-done/bin/lib/artifacts.cjs +52 -0
- package/get-shit-done/bin/lib/audit.cjs +757 -0
- package/get-shit-done/bin/lib/commands.cjs +1023 -0
- package/get-shit-done/bin/lib/config-schema.cjs +79 -0
- package/get-shit-done/bin/lib/config.cjs +463 -0
- package/get-shit-done/bin/lib/core.cjs +1794 -0
- package/get-shit-done/bin/lib/docs.cjs +267 -0
- package/get-shit-done/bin/lib/frontmatter.cjs +379 -0
- package/get-shit-done/bin/lib/graphify.cjs +494 -0
- package/get-shit-done/bin/lib/gsd2-import.cjs +511 -0
- package/get-shit-done/bin/lib/init.cjs +1878 -0
- package/get-shit-done/bin/lib/intel.cjs +639 -0
- package/get-shit-done/bin/lib/learnings.cjs +378 -0
- package/get-shit-done/bin/lib/milestone.cjs +283 -0
- package/get-shit-done/bin/lib/model-profiles.cjs +71 -0
- package/get-shit-done/bin/lib/phase.cjs +1058 -0
- package/get-shit-done/bin/lib/profile-output.cjs +1080 -0
- package/get-shit-done/bin/lib/profile-pipeline.cjs +539 -0
- package/get-shit-done/bin/lib/roadmap.cjs +523 -0
- package/get-shit-done/bin/lib/schema-detect.cjs +238 -0
- package/get-shit-done/bin/lib/security.cjs +504 -0
- package/get-shit-done/bin/lib/state.cjs +1649 -0
- package/get-shit-done/bin/lib/template.cjs +226 -0
- package/get-shit-done/bin/lib/uat.cjs +288 -0
- package/get-shit-done/bin/lib/verify.cjs +1184 -0
- package/get-shit-done/bin/lib/workstream.cjs +495 -0
- package/get-shit-done/bin/repair-sdk.cjs +177 -0
- package/get-shit-done/contexts/dev.md +21 -0
- package/get-shit-done/contexts/research.md +22 -0
- package/get-shit-done/contexts/review.md +22 -0
- package/get-shit-done/references/agent-contracts.md +79 -0
- package/get-shit-done/references/ai-evals.md +156 -0
- package/get-shit-done/references/ai-frameworks.md +186 -0
- package/get-shit-done/references/artifact-types.md +131 -0
- package/get-shit-done/references/autonomous-smart-discuss.md +277 -0
- package/get-shit-done/references/checkpoints.md +808 -0
- package/get-shit-done/references/common-bug-patterns.md +114 -0
- package/get-shit-done/references/context-budget.md +49 -0
- package/get-shit-done/references/continuation-format.md +253 -0
- package/get-shit-done/references/debugger-philosophy.md +76 -0
- package/get-shit-done/references/decimal-phase-calculation.md +64 -0
- package/get-shit-done/references/doc-conflict-engine.md +91 -0
- package/get-shit-done/references/domain-probes.md +125 -0
- package/get-shit-done/references/executor-examples.md +110 -0
- package/get-shit-done/references/few-shot-examples/plan-checker.md +73 -0
- package/get-shit-done/references/few-shot-examples/verifier.md +109 -0
- package/get-shit-done/references/gate-prompts.md +100 -0
- package/get-shit-done/references/gates.md +70 -0
- package/get-shit-done/references/git-integration.md +295 -0
- package/get-shit-done/references/git-planning-commit.md +40 -0
- package/get-shit-done/references/ios-scaffold.md +123 -0
- package/get-shit-done/references/mandatory-initial-read.md +2 -0
- package/get-shit-done/references/model-profile-resolution.md +38 -0
- package/get-shit-done/references/model-profiles.md +145 -0
- package/get-shit-done/references/phase-argument-parsing.md +61 -0
- package/get-shit-done/references/planner-antipatterns.md +89 -0
- package/get-shit-done/references/planner-gap-closure.md +62 -0
- package/get-shit-done/references/planner-reviews.md +39 -0
- package/get-shit-done/references/planner-revision.md +87 -0
- package/get-shit-done/references/planner-source-audit.md +73 -0
- package/get-shit-done/references/planning-config.md +460 -0
- package/get-shit-done/references/project-skills-discovery.md +19 -0
- package/get-shit-done/references/questioning.md +162 -0
- package/get-shit-done/references/revision-loop.md +97 -0
- package/get-shit-done/references/sketch-interactivity.md +41 -0
- package/get-shit-done/references/sketch-theme-system.md +94 -0
- package/get-shit-done/references/sketch-tooling.md +45 -0
- package/get-shit-done/references/sketch-variant-patterns.md +81 -0
- package/get-shit-done/references/tdd.md +330 -0
- package/get-shit-done/references/thinking-models-debug.md +44 -0
- package/get-shit-done/references/thinking-models-execution.md +50 -0
- package/get-shit-done/references/thinking-models-planning.md +62 -0
- package/get-shit-done/references/thinking-models-research.md +50 -0
- package/get-shit-done/references/thinking-models-verification.md +55 -0
- package/get-shit-done/references/thinking-partner.md +96 -0
- package/get-shit-done/references/ui-brand.md +160 -0
- package/get-shit-done/references/universal-anti-patterns.md +63 -0
- package/get-shit-done/references/user-profiling.md +681 -0
- package/get-shit-done/references/verification-overrides.md +227 -0
- package/get-shit-done/references/verification-patterns.md +612 -0
- package/get-shit-done/references/workstream-flag.md +111 -0
- package/get-shit-done/templates/AI-SPEC.md +246 -0
- package/get-shit-done/templates/DEBUG.md +169 -0
- package/get-shit-done/templates/README.md +76 -0
- package/get-shit-done/templates/SECURITY.md +61 -0
- package/get-shit-done/templates/UAT.md +265 -0
- package/get-shit-done/templates/UI-SPEC.md +100 -0
- package/get-shit-done/templates/VALIDATION.md +76 -0
- package/get-shit-done/templates/claude-md.md +145 -0
- package/get-shit-done/templates/codebase/architecture.md +255 -0
- package/get-shit-done/templates/codebase/concerns.md +310 -0
- package/get-shit-done/templates/codebase/conventions.md +307 -0
- package/get-shit-done/templates/codebase/integrations.md +280 -0
- package/get-shit-done/templates/codebase/stack.md +186 -0
- package/get-shit-done/templates/codebase/structure.md +285 -0
- package/get-shit-done/templates/codebase/testing.md +480 -0
- package/get-shit-done/templates/config.json +56 -0
- package/get-shit-done/templates/context.md +352 -0
- package/get-shit-done/templates/continue-here.md +78 -0
- package/get-shit-done/templates/copilot-instructions.md +7 -0
- package/get-shit-done/templates/debug-subagent-prompt.md +91 -0
- package/get-shit-done/templates/dev-preferences.md +21 -0
- package/get-shit-done/templates/discovery.md +146 -0
- package/get-shit-done/templates/discussion-log.md +63 -0
- package/get-shit-done/templates/milestone-archive.md +123 -0
- package/get-shit-done/templates/milestone.md +115 -0
- package/get-shit-done/templates/phase-prompt.md +610 -0
- package/get-shit-done/templates/planner-subagent-prompt.md +117 -0
- package/get-shit-done/templates/project.md +186 -0
- package/get-shit-done/templates/requirements.md +231 -0
- package/get-shit-done/templates/research-project/ARCHITECTURE.md +204 -0
- package/get-shit-done/templates/research-project/FEATURES.md +147 -0
- package/get-shit-done/templates/research-project/PITFALLS.md +200 -0
- package/get-shit-done/templates/research-project/STACK.md +120 -0
- package/get-shit-done/templates/research-project/SUMMARY.md +170 -0
- package/get-shit-done/templates/research.md +592 -0
- package/get-shit-done/templates/retrospective.md +54 -0
- package/get-shit-done/templates/roadmap.md +202 -0
- package/get-shit-done/templates/spec.md +307 -0
- package/get-shit-done/templates/state.md +184 -0
- package/get-shit-done/templates/summary-complex.md +59 -0
- package/get-shit-done/templates/summary-minimal.md +41 -0
- package/get-shit-done/templates/summary-standard.md +48 -0
- package/get-shit-done/templates/summary.md +248 -0
- package/get-shit-done/templates/user-profile.md +146 -0
- package/get-shit-done/templates/user-setup.md +311 -0
- package/get-shit-done/templates/verification-report.md +322 -0
- package/get-shit-done/workflows/add-phase.md +112 -0
- package/get-shit-done/workflows/add-tests.md +354 -0
- package/get-shit-done/workflows/add-todo.md +160 -0
- package/get-shit-done/workflows/ai-integration-phase.md +284 -0
- package/get-shit-done/workflows/analyze-dependencies.md +96 -0
- package/get-shit-done/workflows/audit-fix.md +175 -0
- package/get-shit-done/workflows/audit-milestone.md +340 -0
- package/get-shit-done/workflows/audit-uat.md +109 -0
- package/get-shit-done/workflows/autonomous.md +789 -0
- package/get-shit-done/workflows/check-todos.md +179 -0
- package/get-shit-done/workflows/cleanup.md +154 -0
- package/get-shit-done/workflows/code-review-fix.md +497 -0
- package/get-shit-done/workflows/code-review.md +515 -0
- package/get-shit-done/workflows/complete-milestone.md +847 -0
- package/get-shit-done/workflows/diagnose-issues.md +238 -0
- package/get-shit-done/workflows/discovery-phase.md +291 -0
- package/get-shit-done/workflows/discuss-phase-assumptions.md +670 -0
- package/get-shit-done/workflows/discuss-phase-power.md +308 -0
- package/get-shit-done/workflows/discuss-phase.md +1378 -0
- package/get-shit-done/workflows/do.md +110 -0
- package/get-shit-done/workflows/docs-update.md +1155 -0
- package/get-shit-done/workflows/eval-review.md +155 -0
- package/get-shit-done/workflows/execute-phase.md +1677 -0
- package/get-shit-done/workflows/execute-plan.md +533 -0
- package/get-shit-done/workflows/explore.md +141 -0
- package/get-shit-done/workflows/extract_learnings.md +242 -0
- package/get-shit-done/workflows/fast.md +105 -0
- package/get-shit-done/workflows/forensics.md +265 -0
- package/get-shit-done/workflows/graduation.md +195 -0
- package/get-shit-done/workflows/health.md +314 -0
- package/get-shit-done/workflows/help.md +667 -0
- package/get-shit-done/workflows/import.md +246 -0
- package/get-shit-done/workflows/inbox.md +387 -0
- package/get-shit-done/workflows/ingest-docs.md +328 -0
- package/get-shit-done/workflows/insert-phase.md +130 -0
- package/get-shit-done/workflows/list-phase-assumptions.md +178 -0
- package/get-shit-done/workflows/list-workspaces.md +56 -0
- package/get-shit-done/workflows/manager.md +365 -0
- package/get-shit-done/workflows/map-codebase.md +393 -0
- package/get-shit-done/workflows/milestone-summary.md +223 -0
- package/get-shit-done/workflows/new-milestone.md +611 -0
- package/get-shit-done/workflows/new-project.md +1391 -0
- package/get-shit-done/workflows/new-workspace.md +239 -0
- package/get-shit-done/workflows/next.md +220 -0
- package/get-shit-done/workflows/node-repair.md +92 -0
- package/get-shit-done/workflows/note.md +158 -0
- package/get-shit-done/workflows/pause-work.md +243 -0
- package/get-shit-done/workflows/plan-milestone-gaps.md +273 -0
- package/get-shit-done/workflows/plan-phase.md +1349 -0
- package/get-shit-done/workflows/plan-review-convergence.md +254 -0
- package/get-shit-done/workflows/plant-seed.md +172 -0
- package/get-shit-done/workflows/pr-branch.md +157 -0
- package/get-shit-done/workflows/profile-user.md +452 -0
- package/get-shit-done/workflows/progress.md +619 -0
- package/get-shit-done/workflows/quick.md +970 -0
- package/get-shit-done/workflows/remove-phase.md +155 -0
- package/get-shit-done/workflows/remove-workspace.md +92 -0
- package/get-shit-done/workflows/research-phase.md +89 -0
- package/get-shit-done/workflows/resume-project.md +326 -0
- package/get-shit-done/workflows/review.md +344 -0
- package/get-shit-done/workflows/scan.md +102 -0
- package/get-shit-done/workflows/secure-phase.md +166 -0
- package/get-shit-done/workflows/session-report.md +146 -0
- package/get-shit-done/workflows/settings.md +319 -0
- package/get-shit-done/workflows/ship.md +302 -0
- package/get-shit-done/workflows/sketch-wrap-up.md +283 -0
- package/get-shit-done/workflows/sketch.md +286 -0
- package/get-shit-done/workflows/spec-phase.md +262 -0
- package/get-shit-done/workflows/spike-wrap-up.md +281 -0
- package/get-shit-done/workflows/spike.md +362 -0
- package/get-shit-done/workflows/stats.md +60 -0
- package/get-shit-done/workflows/sync-skills.md +182 -0
- package/get-shit-done/workflows/transition.md +693 -0
- package/get-shit-done/workflows/ui-phase.md +323 -0
- package/get-shit-done/workflows/ui-review.md +190 -0
- package/get-shit-done/workflows/ultraplan-phase.md +189 -0
- package/get-shit-done/workflows/undo.md +314 -0
- package/get-shit-done/workflows/update.md +587 -0
- package/get-shit-done/workflows/validate-phase.md +176 -0
- package/get-shit-done/workflows/verify-phase.md +465 -0
- package/get-shit-done/workflows/verify-work.md +740 -0
- package/hooks/dist/gsd-check-update-worker.js +108 -0
- package/hooks/dist/gsd-check-update.js +64 -0
- package/hooks/dist/gsd-context-monitor.js +192 -0
- package/hooks/dist/gsd-phase-boundary.sh +28 -0
- package/hooks/dist/gsd-prompt-guard.js +97 -0
- package/hooks/dist/gsd-read-guard.js +82 -0
- package/hooks/dist/gsd-read-injection-scanner.js +152 -0
- package/hooks/dist/gsd-session-state.sh +34 -0
- package/hooks/dist/gsd-statusline.js +293 -0
- package/hooks/dist/gsd-validate-commit.sh +48 -0
- package/hooks/dist/gsd-workflow-guard.js +94 -0
- package/hooks/gsd-check-update-worker.js +108 -0
- package/hooks/gsd-check-update.js +64 -0
- package/hooks/gsd-context-monitor.js +192 -0
- package/hooks/gsd-phase-boundary.sh +28 -0
- package/hooks/gsd-prompt-guard.js +97 -0
- package/hooks/gsd-read-guard.js +82 -0
- package/hooks/gsd-read-injection-scanner.js +152 -0
- package/hooks/gsd-session-state.sh +34 -0
- package/hooks/gsd-statusline.js +293 -0
- package/hooks/gsd-validate-commit.sh +48 -0
- package/hooks/gsd-workflow-guard.js +94 -0
- package/package.json +59 -0
- package/scripts/base64-scan.sh +262 -0
- package/scripts/build-hooks.js +95 -0
- package/scripts/gen-inventory-manifest.cjs +109 -0
- package/scripts/prompt-injection-scan.sh +201 -0
- package/scripts/run-tests.cjs +33 -0
- package/scripts/secret-scan.sh +227 -0
- package/sdk/package-lock.json +1998 -0
- package/sdk/package.json +52 -0
- package/sdk/prompts/agents/gsd-executor.md +110 -0
- package/sdk/prompts/agents/gsd-phase-researcher.md +158 -0
- package/sdk/prompts/agents/gsd-plan-checker.md +160 -0
- package/sdk/prompts/agents/gsd-planner.md +214 -0
- package/sdk/prompts/agents/gsd-project-researcher.md +323 -0
- package/sdk/prompts/agents/gsd-research-synthesizer.md +237 -0
- package/sdk/prompts/agents/gsd-roadmapper.md +670 -0
- package/sdk/prompts/agents/gsd-verifier.md +159 -0
- package/sdk/prompts/templates/project.md +186 -0
- package/sdk/prompts/templates/requirements.md +231 -0
- package/sdk/prompts/templates/research-project/ARCHITECTURE.md +204 -0
- package/sdk/prompts/templates/research-project/FEATURES.md +147 -0
- package/sdk/prompts/templates/research-project/PITFALLS.md +200 -0
- package/sdk/prompts/templates/research-project/STACK.md +120 -0
- package/sdk/prompts/templates/research-project/SUMMARY.md +170 -0
- package/sdk/prompts/templates/roadmap.md +202 -0
- package/sdk/prompts/templates/state.md +175 -0
- package/sdk/prompts/workflows/discuss-phase.md +126 -0
- package/sdk/prompts/workflows/execute-plan.md +106 -0
- package/sdk/prompts/workflows/plan-phase.md +84 -0
- package/sdk/prompts/workflows/research-phase.md +45 -0
- package/sdk/prompts/workflows/verify-phase.md +142 -0
- package/sdk/src/assembled-prompts.test.ts +349 -0
- package/sdk/src/cli-transport.test.ts +388 -0
- package/sdk/src/cli-transport.ts +130 -0
- package/sdk/src/cli.test.ts +383 -0
- package/sdk/src/cli.ts +670 -0
- package/sdk/src/config.test.ts +168 -0
- package/sdk/src/config.ts +177 -0
- package/sdk/src/context-engine.test.ts +295 -0
- package/sdk/src/context-engine.ts +170 -0
- package/sdk/src/context-truncation.test.ts +163 -0
- package/sdk/src/context-truncation.ts +233 -0
- package/sdk/src/e2e.integration.test.ts +178 -0
- package/sdk/src/errors.ts +72 -0
- package/sdk/src/event-stream.test.ts +661 -0
- package/sdk/src/event-stream.ts +441 -0
- package/sdk/src/failure-memory.test.ts +457 -0
- package/sdk/src/failure-memory.ts +1324 -0
- package/sdk/src/golden/capture.ts +95 -0
- package/sdk/src/golden/fixtures/generate-slug.golden.json +1 -0
- package/sdk/src/golden/fixtures/profile-sample-sessions/demo-project/sample.jsonl +3 -0
- package/sdk/src/golden/fixtures/summary-extract-sample.md +26 -0
- package/sdk/src/golden/fixtures/uat-render-checkpoint-sample.md +15 -0
- package/sdk/src/golden/golden-integration-covered.ts +30 -0
- package/sdk/src/golden/golden-mutation-covered.ts +7 -0
- package/sdk/src/golden/golden-policy.test.ts +8 -0
- package/sdk/src/golden/golden-policy.ts +112 -0
- package/sdk/src/golden/golden.integration.test.ts +373 -0
- package/sdk/src/golden/init-golden-normalize.ts +15 -0
- package/sdk/src/golden/read-only-golden-rows.ts +77 -0
- package/sdk/src/golden/read-only-parity.integration.test.ts +125 -0
- package/sdk/src/golden/registry-canonical-commands.ts +31 -0
- package/sdk/src/gsd-tools.test.ts +409 -0
- package/sdk/src/gsd-tools.ts +595 -0
- package/sdk/src/headless-prompts.test.ts +159 -0
- package/sdk/src/index.ts +333 -0
- package/sdk/src/init-e2e.integration.test.ts +136 -0
- package/sdk/src/init-runner.test.ts +783 -0
- package/sdk/src/init-runner.ts +735 -0
- package/sdk/src/lifecycle-e2e.integration.test.ts +258 -0
- package/sdk/src/logger.test.ts +149 -0
- package/sdk/src/logger.ts +113 -0
- package/sdk/src/milestone-runner.test.ts +421 -0
- package/sdk/src/phase-prompt.test.ts +538 -0
- package/sdk/src/phase-prompt.ts +264 -0
- package/sdk/src/phase-runner-types.test.ts +421 -0
- package/sdk/src/phase-runner.integration.test.ts +377 -0
- package/sdk/src/phase-runner.test.ts +2333 -0
- package/sdk/src/phase-runner.ts +1203 -0
- package/sdk/src/plan-parser.test.ts +528 -0
- package/sdk/src/plan-parser.ts +427 -0
- package/sdk/src/prompt-builder.test.ts +306 -0
- package/sdk/src/prompt-builder.ts +193 -0
- package/sdk/src/prompt-sanitizer.test.ts +260 -0
- package/sdk/src/prompt-sanitizer.ts +71 -0
- package/sdk/src/query/QUERY-HANDLERS.md +317 -0
- package/sdk/src/query/audit-open.ts +722 -0
- package/sdk/src/query/check-auto-mode.test.ts +77 -0
- package/sdk/src/query/check-auto-mode.ts +50 -0
- package/sdk/src/query/check-completion.test.ts +113 -0
- package/sdk/src/query/check-completion.ts +182 -0
- package/sdk/src/query/check-gates.test.ts +103 -0
- package/sdk/src/query/check-gates.ts +112 -0
- package/sdk/src/query/check-ship-ready.test.ts +77 -0
- package/sdk/src/query/check-ship-ready.ts +103 -0
- package/sdk/src/query/check-verification-status.test.ts +143 -0
- package/sdk/src/query/check-verification-status.ts +160 -0
- package/sdk/src/query/commit.test.ts +202 -0
- package/sdk/src/query/commit.ts +301 -0
- package/sdk/src/query/config-gates.test.ts +89 -0
- package/sdk/src/query/config-gates.ts +69 -0
- package/sdk/src/query/config-mutation.test.ts +365 -0
- package/sdk/src/query/config-mutation.ts +497 -0
- package/sdk/src/query/config-query.test.ts +161 -0
- package/sdk/src/query/config-query.ts +190 -0
- package/sdk/src/query/context-history.test.ts +165 -0
- package/sdk/src/query/context-history.ts +467 -0
- package/sdk/src/query/decomposed-handlers.test.ts +365 -0
- package/sdk/src/query/detect-custom-files.ts +97 -0
- package/sdk/src/query/detect-phase-type.test.ts +105 -0
- package/sdk/src/query/detect-phase-type.ts +141 -0
- package/sdk/src/query/docs-init.ts +257 -0
- package/sdk/src/query/failure-capture.ts +58 -0
- package/sdk/src/query/frontmatter-array.test.ts +14 -0
- package/sdk/src/query/frontmatter-mutation.test.ts +259 -0
- package/sdk/src/query/frontmatter-mutation.ts +343 -0
- package/sdk/src/query/frontmatter.test.ts +281 -0
- package/sdk/src/query/frontmatter.ts +397 -0
- package/sdk/src/query/helpers.test.ts +426 -0
- package/sdk/src/query/helpers.ts +482 -0
- package/sdk/src/query/index.ts +586 -0
- package/sdk/src/query/init-complex.test.ts +232 -0
- package/sdk/src/query/init-complex.ts +578 -0
- package/sdk/src/query/init.test.ts +522 -0
- package/sdk/src/query/init.ts +1046 -0
- package/sdk/src/query/intel.test.ts +90 -0
- package/sdk/src/query/intel.ts +404 -0
- package/sdk/src/query/normalize-query-command.test.ts +50 -0
- package/sdk/src/query/normalize-query-command.ts +56 -0
- package/sdk/src/query/phase-lifecycle.test.ts +1126 -0
- package/sdk/src/query/phase-lifecycle.ts +1799 -0
- package/sdk/src/query/phase-list-queries.test.ts +88 -0
- package/sdk/src/query/phase-list-queries.ts +152 -0
- package/sdk/src/query/phase-ready.test.ts +65 -0
- package/sdk/src/query/phase-ready.ts +158 -0
- package/sdk/src/query/phase.test.ts +307 -0
- package/sdk/src/query/phase.ts +340 -0
- package/sdk/src/query/pipeline.test.ts +169 -0
- package/sdk/src/query/pipeline.ts +243 -0
- package/sdk/src/query/plan-execution-route.test.ts +166 -0
- package/sdk/src/query/plan-execution-route.ts +209 -0
- package/sdk/src/query/plan-task-structure.test.ts +65 -0
- package/sdk/src/query/plan-task-structure.ts +63 -0
- package/sdk/src/query/profile-extract-messages.ts +247 -0
- package/sdk/src/query/profile-output.ts +908 -0
- package/sdk/src/query/profile-questionnaire-data.ts +181 -0
- package/sdk/src/query/profile-sample.ts +184 -0
- package/sdk/src/query/profile-scan-sessions.ts +174 -0
- package/sdk/src/query/profile.test.ts +74 -0
- package/sdk/src/query/profile.ts +337 -0
- package/sdk/src/query/progress.test.ts +156 -0
- package/sdk/src/query/progress.ts +566 -0
- package/sdk/src/query/registry.test.ts +216 -0
- package/sdk/src/query/registry.ts +174 -0
- package/sdk/src/query/requirements-extract-from-plans.test.ts +58 -0
- package/sdk/src/query/requirements-extract-from-plans.ts +86 -0
- package/sdk/src/query/roadmap-update-plan-progress.ts +132 -0
- package/sdk/src/query/roadmap.test.ts +359 -0
- package/sdk/src/query/roadmap.ts +591 -0
- package/sdk/src/query/route-next-action.test.ts +61 -0
- package/sdk/src/query/route-next-action.ts +345 -0
- package/sdk/src/query/runtime-health.ts +7 -0
- package/sdk/src/query/schema-detect.ts +189 -0
- package/sdk/src/query/skill-manifest.ts +214 -0
- package/sdk/src/query/skills.test.ts +80 -0
- package/sdk/src/query/skills.ts +62 -0
- package/sdk/src/query/state-mutation.test.ts +450 -0
- package/sdk/src/query/state-mutation.ts +1444 -0
- package/sdk/src/query/state-project-load.ts +109 -0
- package/sdk/src/query/state.test.ts +347 -0
- package/sdk/src/query/state.ts +397 -0
- package/sdk/src/query/summary.test.ts +95 -0
- package/sdk/src/query/summary.ts +296 -0
- package/sdk/src/query/template.test.ts +180 -0
- package/sdk/src/query/template.ts +242 -0
- package/sdk/src/query/uat.test.ts +77 -0
- package/sdk/src/query/uat.ts +314 -0
- package/sdk/src/query/utils.test.ts +82 -0
- package/sdk/src/query/utils.ts +92 -0
- package/sdk/src/query/validate.test.ts +656 -0
- package/sdk/src/query/validate.ts +807 -0
- package/sdk/src/query/verify.test.ts +414 -0
- package/sdk/src/query/verify.ts +645 -0
- package/sdk/src/query/websearch.test.ts +31 -0
- package/sdk/src/query/websearch.ts +82 -0
- package/sdk/src/query/workspace.test.ts +119 -0
- package/sdk/src/query/workspace.ts +131 -0
- package/sdk/src/query/workstream.test.ts +51 -0
- package/sdk/src/query/workstream.ts +434 -0
- package/sdk/src/research-gate.test.ts +190 -0
- package/sdk/src/research-gate.ts +94 -0
- package/sdk/src/runtime-health.test.ts +176 -0
- package/sdk/src/runtime-health.ts +387 -0
- package/sdk/src/session-runner.test.ts +98 -0
- package/sdk/src/session-runner.ts +299 -0
- package/sdk/src/tool-scoping.test.ts +160 -0
- package/sdk/src/tool-scoping.ts +61 -0
- package/sdk/src/types.ts +917 -0
- package/sdk/src/workstream-utils.ts +33 -0
- package/sdk/src/ws-flag.test.ts +285 -0
- package/sdk/src/ws-transport.test.ts +161 -0
- package/sdk/src/ws-transport.ts +93 -0
- package/sdk/tsconfig.json +20 -0
|
@@ -0,0 +1,1878 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Init — Compound init commands for workflow bootstrapping
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const { execSync } = require('child_process');
|
|
8
|
+
const { loadConfig, resolveModelInternal, findPhaseInternal, getRoadmapPhaseInternal, pathExistsInternal, generateSlugInternal, getMilestoneInfo, getMilestonePhaseFilter, stripShippedMilestones, extractCurrentMilestone, normalizePhaseName, planningPaths, planningDir, planningRoot, toPosixPath, output, error, checkAgentsInstalled, phaseTokenMatches } = require('./core.cjs');
|
|
9
|
+
|
|
10
|
+
function getLatestCompletedMilestone(cwd) {
|
|
11
|
+
const milestonesPath = path.join(planningRoot(cwd), 'MILESTONES.md');
|
|
12
|
+
if (!fs.existsSync(milestonesPath)) return null;
|
|
13
|
+
|
|
14
|
+
try {
|
|
15
|
+
const content = fs.readFileSync(milestonesPath, 'utf-8');
|
|
16
|
+
const match = content.match(/^##\s+(v[\d.]+)\s+(.+?)\s+\(Shipped:/m);
|
|
17
|
+
if (!match) return null;
|
|
18
|
+
return {
|
|
19
|
+
version: match[1],
|
|
20
|
+
name: match[2].trim(),
|
|
21
|
+
};
|
|
22
|
+
} catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Inject `project_root` into an init result object.
|
|
29
|
+
* Workflows use this to prefix `.planning/` paths correctly when Claude's CWD
|
|
30
|
+
* differs from the project root (e.g., inside a sub-repo).
|
|
31
|
+
*/
|
|
32
|
+
function withProjectRoot(cwd, result) {
|
|
33
|
+
result.project_root = cwd;
|
|
34
|
+
// Inject agent installation status into all init outputs (#1371).
|
|
35
|
+
// Workflows that spawn named subagents use this to detect when agents
|
|
36
|
+
// are missing and would silently fall back to general-purpose.
|
|
37
|
+
const agentStatus = checkAgentsInstalled();
|
|
38
|
+
result.agents_installed = agentStatus.agents_installed;
|
|
39
|
+
result.missing_agents = agentStatus.missing_agents;
|
|
40
|
+
// Inject response_language into all init outputs (#1399).
|
|
41
|
+
// Workflows propagate this to subagent prompts so user-facing questions
|
|
42
|
+
// stay in the configured language across phase boundaries.
|
|
43
|
+
const config = loadConfig(cwd);
|
|
44
|
+
if (config.response_language) {
|
|
45
|
+
result.response_language = config.response_language;
|
|
46
|
+
}
|
|
47
|
+
// Inject project identity into all init outputs so handoff blocks
|
|
48
|
+
// can include project context for cross-session continuity.
|
|
49
|
+
if (config.project_code) {
|
|
50
|
+
result.project_code = config.project_code;
|
|
51
|
+
}
|
|
52
|
+
// Extract project title from PROJECT.md first H1 heading.
|
|
53
|
+
const projectMdPath = path.join(planningDir(cwd), 'PROJECT.md');
|
|
54
|
+
try {
|
|
55
|
+
if (fs.existsSync(projectMdPath)) {
|
|
56
|
+
const content = fs.readFileSync(projectMdPath, 'utf8');
|
|
57
|
+
const h1Match = content.match(/^#\s+(.+)$/m);
|
|
58
|
+
if (h1Match) {
|
|
59
|
+
result.project_title = h1Match[1].trim();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
} catch { /* intentionally empty */ }
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function cmdInitExecutePhase(cwd, phase, raw, options = {}) {
|
|
67
|
+
if (!phase) {
|
|
68
|
+
error('phase required for init execute-phase');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const config = loadConfig(cwd);
|
|
72
|
+
let phaseInfo = findPhaseInternal(cwd, phase);
|
|
73
|
+
const milestone = getMilestoneInfo(cwd);
|
|
74
|
+
|
|
75
|
+
const roadmapPhase = getRoadmapPhaseInternal(cwd, phase);
|
|
76
|
+
|
|
77
|
+
// If findPhaseInternal matched an archived phase from a prior milestone, but
|
|
78
|
+
// the phase exists in the current milestone's ROADMAP.md, ignore the archive
|
|
79
|
+
// match — we are initializing a new phase in the current milestone that
|
|
80
|
+
// happens to share a number with an archived one. Without this, phase_dir,
|
|
81
|
+
// phase_slug and related fields would point at artifacts from a previous
|
|
82
|
+
// milestone.
|
|
83
|
+
if (phaseInfo?.archived && roadmapPhase?.found) {
|
|
84
|
+
phaseInfo = null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Fallback to ROADMAP.md if no phase directory exists yet
|
|
88
|
+
if (!phaseInfo && roadmapPhase?.found) {
|
|
89
|
+
const phaseName = roadmapPhase.phase_name;
|
|
90
|
+
phaseInfo = {
|
|
91
|
+
found: true,
|
|
92
|
+
directory: null,
|
|
93
|
+
phase_number: roadmapPhase.phase_number,
|
|
94
|
+
phase_name: phaseName,
|
|
95
|
+
phase_slug: phaseName ? phaseName.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') : null,
|
|
96
|
+
plans: [],
|
|
97
|
+
summaries: [],
|
|
98
|
+
incomplete_plans: [],
|
|
99
|
+
has_research: false,
|
|
100
|
+
has_context: false,
|
|
101
|
+
has_verification: false,
|
|
102
|
+
has_reviews: false,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
const reqMatch = roadmapPhase?.section?.match(/^\*\*Requirements\*\*:[^\S\n]*([^\n]*)$/m);
|
|
106
|
+
const reqExtracted = reqMatch
|
|
107
|
+
? reqMatch[1].replace(/[\[\]]/g, '').split(',').map(s => s.trim()).filter(Boolean).join(', ')
|
|
108
|
+
: null;
|
|
109
|
+
const phase_req_ids = (reqExtracted && reqExtracted !== 'TBD') ? reqExtracted : null;
|
|
110
|
+
|
|
111
|
+
const result = {
|
|
112
|
+
// Models
|
|
113
|
+
executor_model: resolveModelInternal(cwd, 'gsd-executor'),
|
|
114
|
+
verifier_model: resolveModelInternal(cwd, 'gsd-verifier'),
|
|
115
|
+
|
|
116
|
+
// Config flags
|
|
117
|
+
tdd_mode: options.tdd || config.tdd_mode || false,
|
|
118
|
+
commit_docs: config.commit_docs,
|
|
119
|
+
sub_repos: config.sub_repos,
|
|
120
|
+
parallelization: config.parallelization,
|
|
121
|
+
context_window: config.context_window,
|
|
122
|
+
branching_strategy: config.branching_strategy,
|
|
123
|
+
phase_branch_template: config.phase_branch_template,
|
|
124
|
+
milestone_branch_template: config.milestone_branch_template,
|
|
125
|
+
verifier_enabled: config.verifier,
|
|
126
|
+
|
|
127
|
+
// Phase info
|
|
128
|
+
phase_found: !!phaseInfo,
|
|
129
|
+
phase_dir: phaseInfo?.directory || null,
|
|
130
|
+
phase_number: phaseInfo?.phase_number || null,
|
|
131
|
+
phase_name: phaseInfo?.phase_name || null,
|
|
132
|
+
phase_slug: phaseInfo?.phase_slug || null,
|
|
133
|
+
phase_req_ids,
|
|
134
|
+
|
|
135
|
+
// Plan inventory
|
|
136
|
+
plans: phaseInfo?.plans || [],
|
|
137
|
+
summaries: phaseInfo?.summaries || [],
|
|
138
|
+
incomplete_plans: phaseInfo?.incomplete_plans || [],
|
|
139
|
+
plan_count: phaseInfo?.plans?.length || 0,
|
|
140
|
+
incomplete_count: phaseInfo?.incomplete_plans?.length || 0,
|
|
141
|
+
|
|
142
|
+
// Branch name (pre-computed)
|
|
143
|
+
branch_name: config.branching_strategy === 'phase' && phaseInfo
|
|
144
|
+
? config.phase_branch_template
|
|
145
|
+
.replace('{project}', config.project_code || '')
|
|
146
|
+
.replace('{phase}', phaseInfo.phase_number)
|
|
147
|
+
.replace('{slug}', phaseInfo.phase_slug || 'phase')
|
|
148
|
+
: config.branching_strategy === 'milestone'
|
|
149
|
+
? config.milestone_branch_template
|
|
150
|
+
.replace('{milestone}', milestone.version)
|
|
151
|
+
.replace('{slug}', generateSlugInternal(milestone.name) || 'milestone')
|
|
152
|
+
: null,
|
|
153
|
+
|
|
154
|
+
// Milestone info
|
|
155
|
+
milestone_version: milestone.version,
|
|
156
|
+
milestone_name: milestone.name,
|
|
157
|
+
milestone_slug: generateSlugInternal(milestone.name),
|
|
158
|
+
|
|
159
|
+
// File existence
|
|
160
|
+
state_exists: fs.existsSync(path.join(planningDir(cwd), 'STATE.md')),
|
|
161
|
+
roadmap_exists: fs.existsSync(path.join(planningDir(cwd), 'ROADMAP.md')),
|
|
162
|
+
config_exists: fs.existsSync(path.join(planningDir(cwd), 'config.json')),
|
|
163
|
+
// File paths
|
|
164
|
+
state_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'STATE.md'))),
|
|
165
|
+
roadmap_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'ROADMAP.md'))),
|
|
166
|
+
config_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'config.json'))),
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
// Optional --validate: run state validation and include warnings (#1627)
|
|
170
|
+
if (options.validate) {
|
|
171
|
+
try {
|
|
172
|
+
const { cmdStateValidate } = require('./state.cjs');
|
|
173
|
+
// Capture validate output by temporarily redirecting
|
|
174
|
+
const statePath = path.join(planningDir(cwd), 'STATE.md');
|
|
175
|
+
if (fs.existsSync(statePath)) {
|
|
176
|
+
const stateContent = fs.readFileSync(statePath, 'utf-8');
|
|
177
|
+
const { stateExtractField } = require('./state.cjs');
|
|
178
|
+
const status = stateExtractField(stateContent, 'Status') || '';
|
|
179
|
+
result.state_validation_ran = true;
|
|
180
|
+
// Simple inline validation — check for obvious drift
|
|
181
|
+
const warnings = [];
|
|
182
|
+
const phasesPath = planningPaths(cwd).phases;
|
|
183
|
+
if (phaseInfo && phaseInfo.directory && fs.existsSync(path.join(cwd, phaseInfo.directory))) {
|
|
184
|
+
const files = fs.readdirSync(path.join(cwd, phaseInfo.directory));
|
|
185
|
+
const diskPlans = files.filter(f => f.match(/-PLAN\.md$/i)).length;
|
|
186
|
+
const totalPlansRaw = stateExtractField(stateContent, 'Total Plans in Phase');
|
|
187
|
+
const totalPlansInPhase = totalPlansRaw ? parseInt(totalPlansRaw, 10) : null;
|
|
188
|
+
if (totalPlansInPhase !== null && diskPlans !== totalPlansInPhase) {
|
|
189
|
+
warnings.push(`Plan count mismatch: STATE.md says ${totalPlansInPhase}, disk has ${diskPlans}`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
result.state_warnings = warnings;
|
|
193
|
+
}
|
|
194
|
+
} catch { /* intentionally empty */ }
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
output(withProjectRoot(cwd, result), raw);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function cmdInitPlanPhase(cwd, phase, raw, options = {}) {
|
|
201
|
+
if (!phase) {
|
|
202
|
+
error('phase required for init plan-phase');
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const config = loadConfig(cwd);
|
|
206
|
+
let phaseInfo = findPhaseInternal(cwd, phase);
|
|
207
|
+
|
|
208
|
+
const roadmapPhase = getRoadmapPhaseInternal(cwd, phase);
|
|
209
|
+
|
|
210
|
+
// If findPhaseInternal matched an archived phase from a prior milestone, but
|
|
211
|
+
// the phase exists in the current milestone's ROADMAP.md, ignore the archive
|
|
212
|
+
// match — we are planning a new phase in the current milestone that happens
|
|
213
|
+
// to share a number with an archived one. Without this, phase_dir,
|
|
214
|
+
// phase_slug, has_context and has_research would point at artifacts from a
|
|
215
|
+
// previous milestone.
|
|
216
|
+
if (phaseInfo?.archived && roadmapPhase?.found) {
|
|
217
|
+
phaseInfo = null;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Fallback to ROADMAP.md if no phase directory exists yet
|
|
221
|
+
if (!phaseInfo && roadmapPhase?.found) {
|
|
222
|
+
const phaseName = roadmapPhase.phase_name;
|
|
223
|
+
phaseInfo = {
|
|
224
|
+
found: true,
|
|
225
|
+
directory: null,
|
|
226
|
+
phase_number: roadmapPhase.phase_number,
|
|
227
|
+
phase_name: phaseName,
|
|
228
|
+
phase_slug: phaseName ? phaseName.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') : null,
|
|
229
|
+
plans: [],
|
|
230
|
+
summaries: [],
|
|
231
|
+
incomplete_plans: [],
|
|
232
|
+
has_research: false,
|
|
233
|
+
has_context: false,
|
|
234
|
+
has_verification: false,
|
|
235
|
+
has_reviews: false,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
const reqMatch = roadmapPhase?.section?.match(/^\*\*Requirements\*\*:[^\S\n]*([^\n]*)$/m);
|
|
239
|
+
const reqExtracted = reqMatch
|
|
240
|
+
? reqMatch[1].replace(/[\[\]]/g, '').split(',').map(s => s.trim()).filter(Boolean).join(', ')
|
|
241
|
+
: null;
|
|
242
|
+
const phase_req_ids = (reqExtracted && reqExtracted !== 'TBD') ? reqExtracted : null;
|
|
243
|
+
|
|
244
|
+
const result = {
|
|
245
|
+
// Models
|
|
246
|
+
researcher_model: resolveModelInternal(cwd, 'gsd-phase-researcher'),
|
|
247
|
+
planner_model: resolveModelInternal(cwd, 'gsd-planner'),
|
|
248
|
+
checker_model: resolveModelInternal(cwd, 'gsd-plan-checker'),
|
|
249
|
+
|
|
250
|
+
// Workflow flags
|
|
251
|
+
tdd_mode: options.tdd || config.tdd_mode || false,
|
|
252
|
+
research_enabled: config.research,
|
|
253
|
+
plan_checker_enabled: config.plan_checker,
|
|
254
|
+
nyquist_validation_enabled: config.nyquist_validation,
|
|
255
|
+
commit_docs: config.commit_docs,
|
|
256
|
+
text_mode: config.text_mode,
|
|
257
|
+
// Auto-advance config — included so workflows don't need separate config-get
|
|
258
|
+
// calls for these values, which causes infinite config-read loops on some models
|
|
259
|
+
// (e.g. Kimi K2.5). See #2192.
|
|
260
|
+
auto_advance: !!(config.auto_advance),
|
|
261
|
+
auto_chain_active: !!(config._auto_chain_active),
|
|
262
|
+
mode: config.mode || 'interactive',
|
|
263
|
+
|
|
264
|
+
// Phase info
|
|
265
|
+
phase_found: !!phaseInfo,
|
|
266
|
+
phase_dir: phaseInfo?.directory || null,
|
|
267
|
+
phase_number: phaseInfo?.phase_number || null,
|
|
268
|
+
phase_name: phaseInfo?.phase_name || null,
|
|
269
|
+
phase_slug: phaseInfo?.phase_slug || null,
|
|
270
|
+
padded_phase: phaseInfo?.phase_number ? normalizePhaseName(phaseInfo.phase_number) : null,
|
|
271
|
+
phase_req_ids,
|
|
272
|
+
|
|
273
|
+
// Existing artifacts
|
|
274
|
+
has_research: phaseInfo?.has_research || false,
|
|
275
|
+
has_context: phaseInfo?.has_context || false,
|
|
276
|
+
has_reviews: phaseInfo?.has_reviews || false,
|
|
277
|
+
has_plans: (phaseInfo?.plans?.length || 0) > 0,
|
|
278
|
+
plan_count: phaseInfo?.plans?.length || 0,
|
|
279
|
+
|
|
280
|
+
// Environment
|
|
281
|
+
planning_exists: fs.existsSync(planningDir(cwd)),
|
|
282
|
+
roadmap_exists: fs.existsSync(path.join(planningDir(cwd), 'ROADMAP.md')),
|
|
283
|
+
|
|
284
|
+
// File paths
|
|
285
|
+
state_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'STATE.md'))),
|
|
286
|
+
roadmap_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'ROADMAP.md'))),
|
|
287
|
+
requirements_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'REQUIREMENTS.md'))),
|
|
288
|
+
|
|
289
|
+
// Pattern mapper output (null until PATTERNS.md exists in phase dir)
|
|
290
|
+
patterns_path: null,
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
if (phaseInfo?.directory) {
|
|
294
|
+
// Find *-CONTEXT.md in phase directory
|
|
295
|
+
const phaseDirFull = path.join(cwd, phaseInfo.directory);
|
|
296
|
+
try {
|
|
297
|
+
const files = fs.readdirSync(phaseDirFull);
|
|
298
|
+
const contextFile = files.find(f => f.endsWith('-CONTEXT.md') || f === 'CONTEXT.md');
|
|
299
|
+
if (contextFile) {
|
|
300
|
+
result.context_path = toPosixPath(path.join(phaseInfo.directory, contextFile));
|
|
301
|
+
}
|
|
302
|
+
const researchFile = files.find(f => f.endsWith('-RESEARCH.md') || f === 'RESEARCH.md');
|
|
303
|
+
if (researchFile) {
|
|
304
|
+
result.research_path = toPosixPath(path.join(phaseInfo.directory, researchFile));
|
|
305
|
+
}
|
|
306
|
+
const verificationFile = files.find(f => f.endsWith('-VERIFICATION.md') || f === 'VERIFICATION.md');
|
|
307
|
+
if (verificationFile) {
|
|
308
|
+
result.verification_path = toPosixPath(path.join(phaseInfo.directory, verificationFile));
|
|
309
|
+
}
|
|
310
|
+
const uatFile = files.find(f => f.endsWith('-UAT.md') || f === 'UAT.md');
|
|
311
|
+
if (uatFile) {
|
|
312
|
+
result.uat_path = toPosixPath(path.join(phaseInfo.directory, uatFile));
|
|
313
|
+
}
|
|
314
|
+
const reviewsFile = files.find(f => f.endsWith('-REVIEWS.md') || f === 'REVIEWS.md');
|
|
315
|
+
if (reviewsFile) {
|
|
316
|
+
result.reviews_path = toPosixPath(path.join(phaseInfo.directory, reviewsFile));
|
|
317
|
+
}
|
|
318
|
+
const patternsFile = files.find(f => f.endsWith('-PATTERNS.md') || f === 'PATTERNS.md');
|
|
319
|
+
if (patternsFile) {
|
|
320
|
+
result.patterns_path = toPosixPath(path.join(phaseInfo.directory, patternsFile));
|
|
321
|
+
}
|
|
322
|
+
} catch { /* intentionally empty */ }
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// Optional --validate: run state validation and include warnings (#1627)
|
|
326
|
+
if (options.validate) {
|
|
327
|
+
try {
|
|
328
|
+
const statePath = path.join(planningDir(cwd), 'STATE.md');
|
|
329
|
+
if (fs.existsSync(statePath)) {
|
|
330
|
+
const { stateExtractField } = require('./state.cjs');
|
|
331
|
+
const stateContent = fs.readFileSync(statePath, 'utf-8');
|
|
332
|
+
const warnings = [];
|
|
333
|
+
result.state_validation_ran = true;
|
|
334
|
+
const totalPlansRaw = stateExtractField(stateContent, 'Total Plans in Phase');
|
|
335
|
+
const totalPlansInPhase = totalPlansRaw ? parseInt(totalPlansRaw, 10) : null;
|
|
336
|
+
if (totalPlansInPhase !== null && phaseInfo && totalPlansInPhase !== (phaseInfo.plans?.length || 0)) {
|
|
337
|
+
warnings.push(`Plan count mismatch: STATE.md says ${totalPlansInPhase}, disk has ${phaseInfo.plans?.length || 0}`);
|
|
338
|
+
}
|
|
339
|
+
result.state_warnings = warnings;
|
|
340
|
+
}
|
|
341
|
+
} catch { /* intentionally empty */ }
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
output(withProjectRoot(cwd, result), raw);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function cmdInitNewProject(cwd, raw) {
|
|
348
|
+
const config = loadConfig(cwd);
|
|
349
|
+
|
|
350
|
+
// Detect Brave Search API key availability
|
|
351
|
+
const homedir = require('os').homedir();
|
|
352
|
+
const braveKeyFile = path.join(homedir, '.gsd', 'brave_api_key');
|
|
353
|
+
const hasBraveSearch = !!(process.env.BRAVE_API_KEY || fs.existsSync(braveKeyFile));
|
|
354
|
+
|
|
355
|
+
// Detect Firecrawl API key availability
|
|
356
|
+
const firecrawlKeyFile = path.join(homedir, '.gsd', 'firecrawl_api_key');
|
|
357
|
+
const hasFirecrawl = !!(process.env.FIRECRAWL_API_KEY || fs.existsSync(firecrawlKeyFile));
|
|
358
|
+
|
|
359
|
+
// Detect Exa API key availability
|
|
360
|
+
const exaKeyFile = path.join(homedir, '.gsd', 'exa_api_key');
|
|
361
|
+
const hasExaSearch = !!(process.env.EXA_API_KEY || fs.existsSync(exaKeyFile));
|
|
362
|
+
|
|
363
|
+
// Detect existing code (cross-platform — no Unix `find` dependency)
|
|
364
|
+
let hasCode = false;
|
|
365
|
+
let hasPackageFile = false;
|
|
366
|
+
try {
|
|
367
|
+
const codeExtensions = new Set([
|
|
368
|
+
'.ts', '.js', '.py', '.go', '.rs', '.swift', '.java',
|
|
369
|
+
'.kt', '.kts', // Kotlin (Android, server-side)
|
|
370
|
+
'.c', '.cpp', '.h', // C/C++
|
|
371
|
+
'.cs', // C#
|
|
372
|
+
'.rb', // Ruby
|
|
373
|
+
'.php', // PHP
|
|
374
|
+
'.dart', // Dart (Flutter)
|
|
375
|
+
'.m', '.mm', // Objective-C / Objective-C++
|
|
376
|
+
'.scala', // Scala
|
|
377
|
+
'.groovy', // Groovy (Gradle build scripts)
|
|
378
|
+
'.lua', // Lua
|
|
379
|
+
'.r', '.R', // R
|
|
380
|
+
'.zig', // Zig
|
|
381
|
+
'.ex', '.exs', // Elixir
|
|
382
|
+
'.clj', // Clojure
|
|
383
|
+
]);
|
|
384
|
+
const skipDirs = new Set(['node_modules', '.git', '.planning', '.claude', '.codex', '__pycache__', 'target', 'dist', 'build']);
|
|
385
|
+
function findCodeFiles(dir, depth) {
|
|
386
|
+
if (depth > 3) return false;
|
|
387
|
+
let entries;
|
|
388
|
+
try { entries = fs.readdirSync(dir, { withFileTypes: true }); } catch { return false; }
|
|
389
|
+
for (const entry of entries) {
|
|
390
|
+
if (entry.isFile() && codeExtensions.has(path.extname(entry.name))) return true;
|
|
391
|
+
if (entry.isDirectory() && !skipDirs.has(entry.name)) {
|
|
392
|
+
if (findCodeFiles(path.join(dir, entry.name), depth + 1)) return true;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
return false;
|
|
396
|
+
}
|
|
397
|
+
hasCode = findCodeFiles(cwd, 0);
|
|
398
|
+
} catch { /* intentionally empty — best-effort detection */ }
|
|
399
|
+
|
|
400
|
+
hasPackageFile = pathExistsInternal(cwd, 'package.json') ||
|
|
401
|
+
pathExistsInternal(cwd, 'requirements.txt') ||
|
|
402
|
+
pathExistsInternal(cwd, 'Cargo.toml') ||
|
|
403
|
+
pathExistsInternal(cwd, 'go.mod') ||
|
|
404
|
+
pathExistsInternal(cwd, 'Package.swift') ||
|
|
405
|
+
pathExistsInternal(cwd, 'build.gradle') ||
|
|
406
|
+
pathExistsInternal(cwd, 'build.gradle.kts') ||
|
|
407
|
+
pathExistsInternal(cwd, 'pom.xml') ||
|
|
408
|
+
pathExistsInternal(cwd, 'Gemfile') ||
|
|
409
|
+
pathExistsInternal(cwd, 'composer.json') ||
|
|
410
|
+
pathExistsInternal(cwd, 'pubspec.yaml') ||
|
|
411
|
+
pathExistsInternal(cwd, 'CMakeLists.txt') ||
|
|
412
|
+
pathExistsInternal(cwd, 'Makefile') ||
|
|
413
|
+
pathExistsInternal(cwd, 'build.zig') ||
|
|
414
|
+
pathExistsInternal(cwd, 'mix.exs') ||
|
|
415
|
+
pathExistsInternal(cwd, 'project.clj');
|
|
416
|
+
|
|
417
|
+
const result = {
|
|
418
|
+
// Models
|
|
419
|
+
researcher_model: resolveModelInternal(cwd, 'gsd-project-researcher'),
|
|
420
|
+
synthesizer_model: resolveModelInternal(cwd, 'gsd-research-synthesizer'),
|
|
421
|
+
roadmapper_model: resolveModelInternal(cwd, 'gsd-roadmapper'),
|
|
422
|
+
|
|
423
|
+
// Config
|
|
424
|
+
commit_docs: config.commit_docs,
|
|
425
|
+
|
|
426
|
+
// Existing state
|
|
427
|
+
project_exists: pathExistsInternal(cwd, '.planning/PROJECT.md'),
|
|
428
|
+
has_codebase_map: pathExistsInternal(cwd, '.planning/codebase'),
|
|
429
|
+
planning_exists: pathExistsInternal(cwd, '.planning'),
|
|
430
|
+
|
|
431
|
+
// Brownfield detection
|
|
432
|
+
has_existing_code: hasCode,
|
|
433
|
+
has_package_file: hasPackageFile,
|
|
434
|
+
is_brownfield: hasCode || hasPackageFile,
|
|
435
|
+
needs_codebase_map: (hasCode || hasPackageFile) && !pathExistsInternal(cwd, '.planning/codebase'),
|
|
436
|
+
|
|
437
|
+
// Git state
|
|
438
|
+
has_git: pathExistsInternal(cwd, '.git'),
|
|
439
|
+
|
|
440
|
+
// Enhanced search
|
|
441
|
+
brave_search_available: hasBraveSearch,
|
|
442
|
+
firecrawl_available: hasFirecrawl,
|
|
443
|
+
exa_search_available: hasExaSearch,
|
|
444
|
+
|
|
445
|
+
// File paths
|
|
446
|
+
project_path: '.planning/PROJECT.md',
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
output(withProjectRoot(cwd, result), raw);
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
function cmdInitNewMilestone(cwd, raw) {
|
|
453
|
+
const config = loadConfig(cwd);
|
|
454
|
+
const milestone = getMilestoneInfo(cwd);
|
|
455
|
+
const latestCompleted = getLatestCompletedMilestone(cwd);
|
|
456
|
+
const phasesDir = path.join(planningDir(cwd), 'phases');
|
|
457
|
+
let phaseDirCount = 0;
|
|
458
|
+
|
|
459
|
+
try {
|
|
460
|
+
if (fs.existsSync(phasesDir)) {
|
|
461
|
+
// Bug #2445: filter phase dirs to current milestone only so stale dirs
|
|
462
|
+
// from a prior milestone that were not archived don't inflate the count.
|
|
463
|
+
const isDirInMilestone = getMilestonePhaseFilter(cwd);
|
|
464
|
+
phaseDirCount = fs.readdirSync(phasesDir, { withFileTypes: true })
|
|
465
|
+
.filter(entry => entry.isDirectory() && isDirInMilestone(entry.name))
|
|
466
|
+
.length;
|
|
467
|
+
}
|
|
468
|
+
} catch {}
|
|
469
|
+
|
|
470
|
+
const result = {
|
|
471
|
+
// Models
|
|
472
|
+
researcher_model: resolveModelInternal(cwd, 'gsd-project-researcher'),
|
|
473
|
+
synthesizer_model: resolveModelInternal(cwd, 'gsd-research-synthesizer'),
|
|
474
|
+
roadmapper_model: resolveModelInternal(cwd, 'gsd-roadmapper'),
|
|
475
|
+
|
|
476
|
+
// Config
|
|
477
|
+
commit_docs: config.commit_docs,
|
|
478
|
+
research_enabled: config.research,
|
|
479
|
+
|
|
480
|
+
// Current milestone
|
|
481
|
+
current_milestone: milestone.version,
|
|
482
|
+
current_milestone_name: milestone.name,
|
|
483
|
+
latest_completed_milestone: latestCompleted?.version || null,
|
|
484
|
+
latest_completed_milestone_name: latestCompleted?.name || null,
|
|
485
|
+
phase_dir_count: phaseDirCount,
|
|
486
|
+
phase_archive_path: latestCompleted ? toPosixPath(path.relative(cwd, path.join(planningRoot(cwd), 'milestones', `${latestCompleted.version}-phases`))) : null,
|
|
487
|
+
|
|
488
|
+
// File existence
|
|
489
|
+
project_exists: pathExistsInternal(cwd, '.planning/PROJECT.md'),
|
|
490
|
+
roadmap_exists: fs.existsSync(path.join(planningDir(cwd), 'ROADMAP.md')),
|
|
491
|
+
state_exists: fs.existsSync(path.join(planningDir(cwd), 'STATE.md')),
|
|
492
|
+
|
|
493
|
+
// File paths
|
|
494
|
+
project_path: '.planning/PROJECT.md',
|
|
495
|
+
roadmap_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'ROADMAP.md'))),
|
|
496
|
+
state_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'STATE.md'))),
|
|
497
|
+
};
|
|
498
|
+
|
|
499
|
+
output(withProjectRoot(cwd, result), raw);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
function cmdInitQuick(cwd, description, raw) {
|
|
503
|
+
const config = loadConfig(cwd);
|
|
504
|
+
const now = new Date();
|
|
505
|
+
const slug = description ? generateSlugInternal(description)?.substring(0, 40) : null;
|
|
506
|
+
|
|
507
|
+
// Generate collision-resistant quick task ID: YYMMDD-xxx
|
|
508
|
+
// xxx = 2-second precision blocks since midnight, encoded as 3-char Base36 (lowercase)
|
|
509
|
+
// Range: 000 (00:00:00) to xbz (23:59:58), guaranteed 3 chars for any time of day.
|
|
510
|
+
// Provides ~2s uniqueness window per user — practically collision-free across a team.
|
|
511
|
+
const yy = String(now.getFullYear()).slice(-2);
|
|
512
|
+
const mm = String(now.getMonth() + 1).padStart(2, '0');
|
|
513
|
+
const dd = String(now.getDate()).padStart(2, '0');
|
|
514
|
+
const dateStr = yy + mm + dd;
|
|
515
|
+
const secondsSinceMidnight = now.getHours() * 3600 + now.getMinutes() * 60 + now.getSeconds();
|
|
516
|
+
const timeBlocks = Math.floor(secondsSinceMidnight / 2);
|
|
517
|
+
const timeEncoded = timeBlocks.toString(36).padStart(3, '0');
|
|
518
|
+
const quickId = dateStr + '-' + timeEncoded;
|
|
519
|
+
const branchSlug = slug || 'quick';
|
|
520
|
+
const quickBranchName = config.quick_branch_template
|
|
521
|
+
? config.quick_branch_template
|
|
522
|
+
.replace('{num}', quickId)
|
|
523
|
+
.replace('{quick}', quickId)
|
|
524
|
+
.replace('{slug}', branchSlug)
|
|
525
|
+
: null;
|
|
526
|
+
|
|
527
|
+
const result = {
|
|
528
|
+
// Models
|
|
529
|
+
planner_model: resolveModelInternal(cwd, 'gsd-planner'),
|
|
530
|
+
executor_model: resolveModelInternal(cwd, 'gsd-executor'),
|
|
531
|
+
checker_model: resolveModelInternal(cwd, 'gsd-plan-checker'),
|
|
532
|
+
verifier_model: resolveModelInternal(cwd, 'gsd-verifier'),
|
|
533
|
+
|
|
534
|
+
// Config
|
|
535
|
+
commit_docs: config.commit_docs,
|
|
536
|
+
branch_name: quickBranchName,
|
|
537
|
+
|
|
538
|
+
// Quick task info
|
|
539
|
+
quick_id: quickId,
|
|
540
|
+
slug: slug,
|
|
541
|
+
description: description || null,
|
|
542
|
+
|
|
543
|
+
// Timestamps
|
|
544
|
+
date: now.toISOString().split('T')[0],
|
|
545
|
+
timestamp: now.toISOString(),
|
|
546
|
+
|
|
547
|
+
// Paths
|
|
548
|
+
quick_dir: '.planning/quick',
|
|
549
|
+
task_dir: slug ? `.planning/quick/${quickId}-${slug}` : null,
|
|
550
|
+
|
|
551
|
+
// File existence
|
|
552
|
+
roadmap_exists: fs.existsSync(path.join(planningDir(cwd), 'ROADMAP.md')),
|
|
553
|
+
planning_exists: fs.existsSync(planningRoot(cwd)),
|
|
554
|
+
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
output(withProjectRoot(cwd, result), raw);
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
function cmdInitResume(cwd, raw) {
|
|
561
|
+
const config = loadConfig(cwd);
|
|
562
|
+
|
|
563
|
+
// Check for interrupted agent
|
|
564
|
+
let interruptedAgentId = null;
|
|
565
|
+
try {
|
|
566
|
+
interruptedAgentId = fs.readFileSync(path.join(planningRoot(cwd), 'current-agent-id.txt'), 'utf-8').trim();
|
|
567
|
+
} catch { /* intentionally empty */ }
|
|
568
|
+
|
|
569
|
+
const result = {
|
|
570
|
+
// File existence
|
|
571
|
+
state_exists: fs.existsSync(path.join(planningDir(cwd), 'STATE.md')),
|
|
572
|
+
roadmap_exists: fs.existsSync(path.join(planningDir(cwd), 'ROADMAP.md')),
|
|
573
|
+
project_exists: pathExistsInternal(cwd, '.planning/PROJECT.md'),
|
|
574
|
+
planning_exists: fs.existsSync(planningRoot(cwd)),
|
|
575
|
+
|
|
576
|
+
// File paths
|
|
577
|
+
state_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'STATE.md'))),
|
|
578
|
+
roadmap_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'ROADMAP.md'))),
|
|
579
|
+
project_path: '.planning/PROJECT.md',
|
|
580
|
+
|
|
581
|
+
// Agent state
|
|
582
|
+
has_interrupted_agent: !!interruptedAgentId,
|
|
583
|
+
interrupted_agent_id: interruptedAgentId,
|
|
584
|
+
|
|
585
|
+
// Config
|
|
586
|
+
commit_docs: config.commit_docs,
|
|
587
|
+
};
|
|
588
|
+
|
|
589
|
+
output(withProjectRoot(cwd, result), raw);
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
function cmdInitVerifyWork(cwd, phase, raw) {
|
|
593
|
+
if (!phase) {
|
|
594
|
+
error('phase required for init verify-work');
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
const config = loadConfig(cwd);
|
|
598
|
+
let phaseInfo = findPhaseInternal(cwd, phase);
|
|
599
|
+
|
|
600
|
+
// If findPhaseInternal matched an archived phase from a prior milestone, but
|
|
601
|
+
// the phase exists in the current milestone's ROADMAP.md, ignore the archive
|
|
602
|
+
// match — same pattern as cmdInitPhaseOp.
|
|
603
|
+
if (phaseInfo?.archived) {
|
|
604
|
+
const roadmapPhase = getRoadmapPhaseInternal(cwd, phase);
|
|
605
|
+
if (roadmapPhase?.found) {
|
|
606
|
+
phaseInfo = null;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
// Fallback to ROADMAP.md if no phase directory exists yet
|
|
611
|
+
if (!phaseInfo) {
|
|
612
|
+
const roadmapPhase = getRoadmapPhaseInternal(cwd, phase);
|
|
613
|
+
if (roadmapPhase?.found) {
|
|
614
|
+
const phaseName = roadmapPhase.phase_name;
|
|
615
|
+
phaseInfo = {
|
|
616
|
+
found: true,
|
|
617
|
+
directory: null,
|
|
618
|
+
phase_number: roadmapPhase.phase_number,
|
|
619
|
+
phase_name: phaseName,
|
|
620
|
+
phase_slug: phaseName ? phaseName.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') : null,
|
|
621
|
+
plans: [],
|
|
622
|
+
summaries: [],
|
|
623
|
+
incomplete_plans: [],
|
|
624
|
+
has_research: false,
|
|
625
|
+
has_context: false,
|
|
626
|
+
has_verification: false,
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
const result = {
|
|
632
|
+
// Models
|
|
633
|
+
planner_model: resolveModelInternal(cwd, 'gsd-planner'),
|
|
634
|
+
checker_model: resolveModelInternal(cwd, 'gsd-plan-checker'),
|
|
635
|
+
|
|
636
|
+
// Config
|
|
637
|
+
commit_docs: config.commit_docs,
|
|
638
|
+
|
|
639
|
+
// Phase info
|
|
640
|
+
phase_found: !!phaseInfo,
|
|
641
|
+
phase_dir: phaseInfo?.directory || null,
|
|
642
|
+
phase_number: phaseInfo?.phase_number || null,
|
|
643
|
+
phase_name: phaseInfo?.phase_name || null,
|
|
644
|
+
|
|
645
|
+
// Existing artifacts
|
|
646
|
+
has_verification: phaseInfo?.has_verification || false,
|
|
647
|
+
};
|
|
648
|
+
|
|
649
|
+
output(withProjectRoot(cwd, result), raw);
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
function cmdInitPhaseOp(cwd, phase, raw) {
|
|
653
|
+
const config = loadConfig(cwd);
|
|
654
|
+
let phaseInfo = findPhaseInternal(cwd, phase);
|
|
655
|
+
|
|
656
|
+
// If the only disk match comes from an archived milestone, prefer the
|
|
657
|
+
// current milestone's ROADMAP entry so discuss-phase and similar flows
|
|
658
|
+
// don't attach to shipped work that reused the same phase number.
|
|
659
|
+
if (phaseInfo?.archived) {
|
|
660
|
+
const roadmapPhase = getRoadmapPhaseInternal(cwd, phase);
|
|
661
|
+
if (roadmapPhase?.found) {
|
|
662
|
+
const phaseName = roadmapPhase.phase_name;
|
|
663
|
+
phaseInfo = {
|
|
664
|
+
found: true,
|
|
665
|
+
directory: null,
|
|
666
|
+
phase_number: roadmapPhase.phase_number,
|
|
667
|
+
phase_name: phaseName,
|
|
668
|
+
phase_slug: phaseName ? phaseName.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') : null,
|
|
669
|
+
plans: [],
|
|
670
|
+
summaries: [],
|
|
671
|
+
incomplete_plans: [],
|
|
672
|
+
has_research: false,
|
|
673
|
+
has_context: false,
|
|
674
|
+
has_verification: false,
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
// Fallback to ROADMAP.md if no directory exists (e.g., Plans: TBD)
|
|
680
|
+
if (!phaseInfo) {
|
|
681
|
+
const roadmapPhase = getRoadmapPhaseInternal(cwd, phase);
|
|
682
|
+
if (roadmapPhase?.found) {
|
|
683
|
+
const phaseName = roadmapPhase.phase_name;
|
|
684
|
+
phaseInfo = {
|
|
685
|
+
found: true,
|
|
686
|
+
directory: null,
|
|
687
|
+
phase_number: roadmapPhase.phase_number,
|
|
688
|
+
phase_name: phaseName,
|
|
689
|
+
phase_slug: phaseName ? phaseName.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') : null,
|
|
690
|
+
plans: [],
|
|
691
|
+
summaries: [],
|
|
692
|
+
incomplete_plans: [],
|
|
693
|
+
has_research: false,
|
|
694
|
+
has_context: false,
|
|
695
|
+
has_verification: false,
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
const result = {
|
|
701
|
+
// Config
|
|
702
|
+
commit_docs: config.commit_docs,
|
|
703
|
+
brave_search: config.brave_search,
|
|
704
|
+
firecrawl: config.firecrawl,
|
|
705
|
+
exa_search: config.exa_search,
|
|
706
|
+
|
|
707
|
+
// Phase info
|
|
708
|
+
phase_found: !!phaseInfo,
|
|
709
|
+
phase_dir: phaseInfo?.directory || null,
|
|
710
|
+
phase_number: phaseInfo?.phase_number || null,
|
|
711
|
+
phase_name: phaseInfo?.phase_name || null,
|
|
712
|
+
phase_slug: phaseInfo?.phase_slug || null,
|
|
713
|
+
padded_phase: phaseInfo?.phase_number ? normalizePhaseName(phaseInfo.phase_number) : null,
|
|
714
|
+
|
|
715
|
+
// Existing artifacts
|
|
716
|
+
has_research: phaseInfo?.has_research || false,
|
|
717
|
+
has_context: phaseInfo?.has_context || false,
|
|
718
|
+
has_plans: (phaseInfo?.plans?.length || 0) > 0,
|
|
719
|
+
has_verification: phaseInfo?.has_verification || false,
|
|
720
|
+
has_reviews: phaseInfo?.has_reviews || false,
|
|
721
|
+
plan_count: phaseInfo?.plans?.length || 0,
|
|
722
|
+
|
|
723
|
+
// File existence
|
|
724
|
+
roadmap_exists: fs.existsSync(path.join(planningDir(cwd), 'ROADMAP.md')),
|
|
725
|
+
planning_exists: fs.existsSync(planningDir(cwd)),
|
|
726
|
+
|
|
727
|
+
// File paths
|
|
728
|
+
state_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'STATE.md'))),
|
|
729
|
+
roadmap_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'ROADMAP.md'))),
|
|
730
|
+
requirements_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'REQUIREMENTS.md'))),
|
|
731
|
+
};
|
|
732
|
+
|
|
733
|
+
if (phaseInfo?.directory) {
|
|
734
|
+
const phaseDirFull = path.join(cwd, phaseInfo.directory);
|
|
735
|
+
try {
|
|
736
|
+
const files = fs.readdirSync(phaseDirFull);
|
|
737
|
+
const contextFile = files.find(f => f.endsWith('-CONTEXT.md') || f === 'CONTEXT.md');
|
|
738
|
+
if (contextFile) {
|
|
739
|
+
result.context_path = toPosixPath(path.join(phaseInfo.directory, contextFile));
|
|
740
|
+
}
|
|
741
|
+
const researchFile = files.find(f => f.endsWith('-RESEARCH.md') || f === 'RESEARCH.md');
|
|
742
|
+
if (researchFile) {
|
|
743
|
+
result.research_path = toPosixPath(path.join(phaseInfo.directory, researchFile));
|
|
744
|
+
}
|
|
745
|
+
const verificationFile = files.find(f => f.endsWith('-VERIFICATION.md') || f === 'VERIFICATION.md');
|
|
746
|
+
if (verificationFile) {
|
|
747
|
+
result.verification_path = toPosixPath(path.join(phaseInfo.directory, verificationFile));
|
|
748
|
+
}
|
|
749
|
+
const uatFile = files.find(f => f.endsWith('-UAT.md') || f === 'UAT.md');
|
|
750
|
+
if (uatFile) {
|
|
751
|
+
result.uat_path = toPosixPath(path.join(phaseInfo.directory, uatFile));
|
|
752
|
+
}
|
|
753
|
+
const reviewsFile = files.find(f => f.endsWith('-REVIEWS.md') || f === 'REVIEWS.md');
|
|
754
|
+
if (reviewsFile) {
|
|
755
|
+
result.reviews_path = toPosixPath(path.join(phaseInfo.directory, reviewsFile));
|
|
756
|
+
}
|
|
757
|
+
} catch { /* intentionally empty */ }
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
output(withProjectRoot(cwd, result), raw);
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
function cmdInitTodos(cwd, area, raw) {
|
|
764
|
+
const config = loadConfig(cwd);
|
|
765
|
+
const now = new Date();
|
|
766
|
+
|
|
767
|
+
// List todos (reuse existing logic)
|
|
768
|
+
const pendingDir = path.join(planningDir(cwd), 'todos', 'pending');
|
|
769
|
+
let count = 0;
|
|
770
|
+
const todos = [];
|
|
771
|
+
|
|
772
|
+
try {
|
|
773
|
+
const files = fs.readdirSync(pendingDir).filter(f => f.endsWith('.md'));
|
|
774
|
+
for (const file of files) {
|
|
775
|
+
try {
|
|
776
|
+
const content = fs.readFileSync(path.join(pendingDir, file), 'utf-8');
|
|
777
|
+
const createdMatch = content.match(/^created:\s*(.+)$/m);
|
|
778
|
+
const titleMatch = content.match(/^title:\s*(.+)$/m);
|
|
779
|
+
const areaMatch = content.match(/^area:\s*(.+)$/m);
|
|
780
|
+
const todoArea = areaMatch ? areaMatch[1].trim() : 'general';
|
|
781
|
+
|
|
782
|
+
if (area && todoArea !== area) continue;
|
|
783
|
+
|
|
784
|
+
count++;
|
|
785
|
+
todos.push({
|
|
786
|
+
file,
|
|
787
|
+
created: createdMatch ? createdMatch[1].trim() : 'unknown',
|
|
788
|
+
title: titleMatch ? titleMatch[1].trim() : 'Untitled',
|
|
789
|
+
area: todoArea,
|
|
790
|
+
path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'todos', 'pending', file))),
|
|
791
|
+
});
|
|
792
|
+
} catch { /* intentionally empty */ }
|
|
793
|
+
}
|
|
794
|
+
} catch { /* intentionally empty */ }
|
|
795
|
+
|
|
796
|
+
const result = {
|
|
797
|
+
// Config
|
|
798
|
+
commit_docs: config.commit_docs,
|
|
799
|
+
|
|
800
|
+
// Timestamps
|
|
801
|
+
date: now.toISOString().split('T')[0],
|
|
802
|
+
timestamp: now.toISOString(),
|
|
803
|
+
|
|
804
|
+
// Todo inventory
|
|
805
|
+
todo_count: count,
|
|
806
|
+
todos,
|
|
807
|
+
area_filter: area || null,
|
|
808
|
+
|
|
809
|
+
// Paths
|
|
810
|
+
pending_dir: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'todos', 'pending'))),
|
|
811
|
+
completed_dir: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'todos', 'completed'))),
|
|
812
|
+
|
|
813
|
+
// File existence
|
|
814
|
+
planning_exists: fs.existsSync(planningDir(cwd)),
|
|
815
|
+
todos_dir_exists: fs.existsSync(path.join(planningDir(cwd), 'todos')),
|
|
816
|
+
pending_dir_exists: fs.existsSync(path.join(planningDir(cwd), 'todos', 'pending')),
|
|
817
|
+
};
|
|
818
|
+
|
|
819
|
+
output(withProjectRoot(cwd, result), raw);
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
function cmdInitMilestoneOp(cwd, raw) {
|
|
823
|
+
const config = loadConfig(cwd);
|
|
824
|
+
const milestone = getMilestoneInfo(cwd);
|
|
825
|
+
|
|
826
|
+
// Count phases
|
|
827
|
+
let phaseCount = 0;
|
|
828
|
+
let completedPhases = 0;
|
|
829
|
+
const phasesDir = path.join(planningDir(cwd), 'phases');
|
|
830
|
+
try {
|
|
831
|
+
const entries = fs.readdirSync(phasesDir, { withFileTypes: true });
|
|
832
|
+
const dirs = entries.filter(e => e.isDirectory()).map(e => e.name);
|
|
833
|
+
phaseCount = dirs.length;
|
|
834
|
+
|
|
835
|
+
// Count phases with summaries (completed)
|
|
836
|
+
for (const dir of dirs) {
|
|
837
|
+
try {
|
|
838
|
+
const phaseFiles = fs.readdirSync(path.join(phasesDir, dir));
|
|
839
|
+
const hasSummary = phaseFiles.some(f => f.endsWith('-SUMMARY.md') || f === 'SUMMARY.md');
|
|
840
|
+
if (hasSummary) completedPhases++;
|
|
841
|
+
} catch { /* intentionally empty */ }
|
|
842
|
+
}
|
|
843
|
+
} catch { /* intentionally empty */ }
|
|
844
|
+
|
|
845
|
+
// Check archive
|
|
846
|
+
const archiveDir = path.join(planningRoot(cwd), 'archive');
|
|
847
|
+
let archivedMilestones = [];
|
|
848
|
+
try {
|
|
849
|
+
archivedMilestones = fs.readdirSync(archiveDir, { withFileTypes: true })
|
|
850
|
+
.filter(e => e.isDirectory())
|
|
851
|
+
.map(e => e.name);
|
|
852
|
+
} catch { /* intentionally empty */ }
|
|
853
|
+
|
|
854
|
+
const result = {
|
|
855
|
+
// Config
|
|
856
|
+
commit_docs: config.commit_docs,
|
|
857
|
+
|
|
858
|
+
// Current milestone
|
|
859
|
+
milestone_version: milestone.version,
|
|
860
|
+
milestone_name: milestone.name,
|
|
861
|
+
milestone_slug: generateSlugInternal(milestone.name),
|
|
862
|
+
|
|
863
|
+
// Phase counts
|
|
864
|
+
phase_count: phaseCount,
|
|
865
|
+
completed_phases: completedPhases,
|
|
866
|
+
all_phases_complete: phaseCount > 0 && phaseCount === completedPhases,
|
|
867
|
+
|
|
868
|
+
// Archive
|
|
869
|
+
archived_milestones: archivedMilestones,
|
|
870
|
+
archive_count: archivedMilestones.length,
|
|
871
|
+
|
|
872
|
+
// File existence
|
|
873
|
+
project_exists: pathExistsInternal(cwd, '.planning/PROJECT.md'),
|
|
874
|
+
roadmap_exists: fs.existsSync(path.join(planningDir(cwd), 'ROADMAP.md')),
|
|
875
|
+
state_exists: fs.existsSync(path.join(planningDir(cwd), 'STATE.md')),
|
|
876
|
+
archive_exists: fs.existsSync(path.join(planningRoot(cwd), 'archive')),
|
|
877
|
+
phases_dir_exists: fs.existsSync(path.join(planningDir(cwd), 'phases')),
|
|
878
|
+
};
|
|
879
|
+
|
|
880
|
+
output(withProjectRoot(cwd, result), raw);
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
function cmdInitMapCodebase(cwd, raw) {
|
|
884
|
+
const config = loadConfig(cwd);
|
|
885
|
+
const now = new Date();
|
|
886
|
+
|
|
887
|
+
// Check for existing codebase maps
|
|
888
|
+
const codebaseDir = path.join(planningRoot(cwd), 'codebase');
|
|
889
|
+
let existingMaps = [];
|
|
890
|
+
try {
|
|
891
|
+
existingMaps = fs.readdirSync(codebaseDir).filter(f => f.endsWith('.md'));
|
|
892
|
+
} catch { /* intentionally empty */ }
|
|
893
|
+
|
|
894
|
+
const result = {
|
|
895
|
+
// Models
|
|
896
|
+
mapper_model: resolveModelInternal(cwd, 'gsd-codebase-mapper'),
|
|
897
|
+
|
|
898
|
+
// Config
|
|
899
|
+
commit_docs: config.commit_docs,
|
|
900
|
+
search_gitignored: config.search_gitignored,
|
|
901
|
+
parallelization: config.parallelization,
|
|
902
|
+
subagent_timeout: config.subagent_timeout,
|
|
903
|
+
|
|
904
|
+
// Timestamps
|
|
905
|
+
date: now.toISOString().split('T')[0],
|
|
906
|
+
timestamp: now.toISOString(),
|
|
907
|
+
|
|
908
|
+
// Paths
|
|
909
|
+
codebase_dir: '.planning/codebase',
|
|
910
|
+
|
|
911
|
+
// Existing maps
|
|
912
|
+
existing_maps: existingMaps,
|
|
913
|
+
has_maps: existingMaps.length > 0,
|
|
914
|
+
|
|
915
|
+
// File existence
|
|
916
|
+
planning_exists: pathExistsInternal(cwd, '.planning'),
|
|
917
|
+
codebase_dir_exists: pathExistsInternal(cwd, '.planning/codebase'),
|
|
918
|
+
};
|
|
919
|
+
|
|
920
|
+
output(withProjectRoot(cwd, result), raw);
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
function cmdInitManager(cwd, raw) {
|
|
924
|
+
const config = loadConfig(cwd);
|
|
925
|
+
const milestone = getMilestoneInfo(cwd);
|
|
926
|
+
|
|
927
|
+
// Use planningPaths for forward-compatibility with workstream scoping (#1268)
|
|
928
|
+
const paths = planningPaths(cwd);
|
|
929
|
+
|
|
930
|
+
// Validate prerequisites
|
|
931
|
+
if (!fs.existsSync(paths.roadmap)) {
|
|
932
|
+
error('No ROADMAP.md found. Run /gsd-new-milestone first.');
|
|
933
|
+
}
|
|
934
|
+
if (!fs.existsSync(paths.state)) {
|
|
935
|
+
error('No STATE.md found. Run /gsd-new-milestone first.');
|
|
936
|
+
}
|
|
937
|
+
const rawContent = fs.readFileSync(paths.roadmap, 'utf-8');
|
|
938
|
+
const content = extractCurrentMilestone(rawContent, cwd);
|
|
939
|
+
const phasesDir = paths.phases;
|
|
940
|
+
const isDirInMilestone = getMilestonePhaseFilter(cwd);
|
|
941
|
+
|
|
942
|
+
// Pre-compute directory listing once (avoids O(N) readdirSync per phase)
|
|
943
|
+
const _phaseDirEntries = (() => {
|
|
944
|
+
try {
|
|
945
|
+
return fs.readdirSync(phasesDir, { withFileTypes: true })
|
|
946
|
+
.filter(e => e.isDirectory())
|
|
947
|
+
.map(e => e.name);
|
|
948
|
+
} catch { return []; }
|
|
949
|
+
})();
|
|
950
|
+
|
|
951
|
+
// Pre-extract all checkbox states in a single pass (avoids O(N) regex per phase)
|
|
952
|
+
const _checkboxStates = new Map();
|
|
953
|
+
const _cbPattern = /-\s*\[(x| )\]\s*.*Phase\s+(\d+[A-Z]?(?:\.\d+)*)[:\s]/gi;
|
|
954
|
+
let _cbMatch;
|
|
955
|
+
while ((_cbMatch = _cbPattern.exec(content)) !== null) {
|
|
956
|
+
_checkboxStates.set(_cbMatch[2], _cbMatch[1].toLowerCase() === 'x');
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
const phasePattern = /#{2,4}\s*Phase\s+(\d+[A-Z]?(?:\.\d+)*)\s*:\s*([^\n]+)/gi;
|
|
960
|
+
const phases = [];
|
|
961
|
+
let match;
|
|
962
|
+
|
|
963
|
+
while ((match = phasePattern.exec(content)) !== null) {
|
|
964
|
+
const phaseNum = match[1];
|
|
965
|
+
const phaseName = match[2].replace(/\(INSERTED\)/i, '').trim();
|
|
966
|
+
|
|
967
|
+
const sectionStart = match.index;
|
|
968
|
+
const restOfContent = content.slice(sectionStart);
|
|
969
|
+
const nextHeader = restOfContent.match(/\n#{2,4}\s+Phase\s+\d/i);
|
|
970
|
+
const sectionEnd = nextHeader ? sectionStart + nextHeader.index : content.length;
|
|
971
|
+
const section = content.slice(sectionStart, sectionEnd);
|
|
972
|
+
|
|
973
|
+
const goalMatch = section.match(/\*\*Goal(?::\*\*|\*\*:)\s*([^\n]+)/i);
|
|
974
|
+
const goal = goalMatch ? goalMatch[1].trim() : null;
|
|
975
|
+
|
|
976
|
+
const dependsMatch = section.match(/\*\*Depends on(?::\*\*|\*\*:)\s*([^\n]+)/i);
|
|
977
|
+
const depends_on = dependsMatch ? dependsMatch[1].trim() : null;
|
|
978
|
+
|
|
979
|
+
const normalized = normalizePhaseName(phaseNum);
|
|
980
|
+
let diskStatus = 'no_directory';
|
|
981
|
+
let planCount = 0;
|
|
982
|
+
let summaryCount = 0;
|
|
983
|
+
let hasContext = false;
|
|
984
|
+
let hasResearch = false;
|
|
985
|
+
let lastActivity = null;
|
|
986
|
+
let isActive = false;
|
|
987
|
+
|
|
988
|
+
try {
|
|
989
|
+
const dirs = _phaseDirEntries.filter(isDirInMilestone);
|
|
990
|
+
const dirMatch = dirs.find(d => phaseTokenMatches(d, normalized));
|
|
991
|
+
|
|
992
|
+
if (dirMatch) {
|
|
993
|
+
const fullDir = path.join(phasesDir, dirMatch);
|
|
994
|
+
const phaseFiles = fs.readdirSync(fullDir);
|
|
995
|
+
planCount = phaseFiles.filter(f => f.endsWith('-PLAN.md') || f === 'PLAN.md').length;
|
|
996
|
+
summaryCount = phaseFiles.filter(f => f.endsWith('-SUMMARY.md') || f === 'SUMMARY.md').length;
|
|
997
|
+
hasContext = phaseFiles.some(f => f.endsWith('-CONTEXT.md') || f === 'CONTEXT.md');
|
|
998
|
+
hasResearch = phaseFiles.some(f => f.endsWith('-RESEARCH.md') || f === 'RESEARCH.md');
|
|
999
|
+
|
|
1000
|
+
if (summaryCount >= planCount && planCount > 0) diskStatus = 'complete';
|
|
1001
|
+
else if (summaryCount > 0) diskStatus = 'partial';
|
|
1002
|
+
else if (planCount > 0) diskStatus = 'planned';
|
|
1003
|
+
else if (hasResearch) diskStatus = 'researched';
|
|
1004
|
+
else if (hasContext) diskStatus = 'discussed';
|
|
1005
|
+
else diskStatus = 'empty';
|
|
1006
|
+
|
|
1007
|
+
// Activity detection: check most recent file mtime
|
|
1008
|
+
const now = Date.now();
|
|
1009
|
+
let newestMtime = 0;
|
|
1010
|
+
for (const f of phaseFiles) {
|
|
1011
|
+
try {
|
|
1012
|
+
const stat = fs.statSync(path.join(fullDir, f));
|
|
1013
|
+
if (stat.mtimeMs > newestMtime) newestMtime = stat.mtimeMs;
|
|
1014
|
+
} catch { /* intentionally empty */ }
|
|
1015
|
+
}
|
|
1016
|
+
if (newestMtime > 0) {
|
|
1017
|
+
lastActivity = new Date(newestMtime).toISOString();
|
|
1018
|
+
isActive = (now - newestMtime) < 300000; // 5 minutes
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
} catch { /* intentionally empty */ }
|
|
1022
|
+
|
|
1023
|
+
// Check ROADMAP checkbox status (pre-extracted above the loop)
|
|
1024
|
+
const roadmapComplete = _checkboxStates.get(phaseNum) || false;
|
|
1025
|
+
if (roadmapComplete && diskStatus !== 'complete') {
|
|
1026
|
+
diskStatus = 'complete';
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
phases.push({
|
|
1030
|
+
number: phaseNum,
|
|
1031
|
+
name: phaseName,
|
|
1032
|
+
goal,
|
|
1033
|
+
depends_on,
|
|
1034
|
+
disk_status: diskStatus,
|
|
1035
|
+
has_context: hasContext,
|
|
1036
|
+
has_research: hasResearch,
|
|
1037
|
+
plan_count: planCount,
|
|
1038
|
+
summary_count: summaryCount,
|
|
1039
|
+
roadmap_complete: roadmapComplete,
|
|
1040
|
+
last_activity: lastActivity,
|
|
1041
|
+
is_active: isActive,
|
|
1042
|
+
});
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
// Compute display names: truncate to keep table aligned
|
|
1046
|
+
const MAX_NAME_WIDTH = 20;
|
|
1047
|
+
for (const phase of phases) {
|
|
1048
|
+
if (phase.name.length > MAX_NAME_WIDTH) {
|
|
1049
|
+
phase.display_name = phase.name.slice(0, MAX_NAME_WIDTH - 1) + '…';
|
|
1050
|
+
} else {
|
|
1051
|
+
phase.display_name = phase.name;
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
// Dependency satisfaction: check if all depends_on phases are complete
|
|
1056
|
+
const completedNums = new Set(phases.filter(p => p.disk_status === 'complete').map(p => p.number));
|
|
1057
|
+
|
|
1058
|
+
// Also include phases from previously shipped milestones — they are all
|
|
1059
|
+
// complete by definition (a milestone only ships when all phases are done).
|
|
1060
|
+
// rawContent is the full ROADMAP.md (including <details>-wrapped shipped
|
|
1061
|
+
// milestone sections that extractCurrentMilestone strips out).
|
|
1062
|
+
const _allCompletedPattern = /-\s*\[x\]\s*.*Phase\s+(\d+[A-Z]?(?:\.\d+)*)[:\s]/gi;
|
|
1063
|
+
let _allMatch;
|
|
1064
|
+
while ((_allMatch = _allCompletedPattern.exec(rawContent)) !== null) {
|
|
1065
|
+
completedNums.add(_allMatch[1]);
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
for (const phase of phases) {
|
|
1069
|
+
if (!phase.depends_on || /^none$/i.test(phase.depends_on.trim())) {
|
|
1070
|
+
phase.deps_satisfied = true;
|
|
1071
|
+
} else {
|
|
1072
|
+
// Parse "Phase 1, Phase 3" or "1, 3" formats
|
|
1073
|
+
const depNums = phase.depends_on.match(/\d+(?:\.\d+)*/g) || [];
|
|
1074
|
+
phase.deps_satisfied = depNums.every(n => completedNums.has(n));
|
|
1075
|
+
phase.dep_phases = depNums;
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
// Compact dependency display for dashboard
|
|
1080
|
+
for (const phase of phases) {
|
|
1081
|
+
phase.deps_display = (phase.dep_phases && phase.dep_phases.length > 0)
|
|
1082
|
+
? phase.dep_phases.join(',')
|
|
1083
|
+
: '—';
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
for (const phase of phases) {
|
|
1087
|
+
phase.is_next_to_discuss =
|
|
1088
|
+
(phase.disk_status === 'empty' || phase.disk_status === 'no_directory') &&
|
|
1089
|
+
phase.deps_satisfied;
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
// Check for WAITING.json signal
|
|
1093
|
+
let waitingSignal = null;
|
|
1094
|
+
try {
|
|
1095
|
+
const waitingPath = path.join(cwd, '.planning', 'WAITING.json');
|
|
1096
|
+
if (fs.existsSync(waitingPath)) {
|
|
1097
|
+
waitingSignal = JSON.parse(fs.readFileSync(waitingPath, 'utf-8'));
|
|
1098
|
+
}
|
|
1099
|
+
} catch { /* intentionally empty */ }
|
|
1100
|
+
|
|
1101
|
+
// Compute recommended actions (execute > plan > discuss)
|
|
1102
|
+
// Skip BACKLOG phases (999.x numbering) — they are parked ideas, not active work
|
|
1103
|
+
const recommendedActions = [];
|
|
1104
|
+
for (const phase of phases) {
|
|
1105
|
+
if (phase.disk_status === 'complete') continue;
|
|
1106
|
+
if (/^999(?:\.|$)/.test(phase.number)) continue;
|
|
1107
|
+
|
|
1108
|
+
if (phase.disk_status === 'planned' && phase.deps_satisfied) {
|
|
1109
|
+
recommendedActions.push({
|
|
1110
|
+
phase: phase.number,
|
|
1111
|
+
phase_name: phase.name,
|
|
1112
|
+
action: 'execute',
|
|
1113
|
+
reason: `${phase.plan_count} plans ready, dependencies met`,
|
|
1114
|
+
command: `/gsd-execute-phase ${phase.number}`,
|
|
1115
|
+
});
|
|
1116
|
+
} else if (phase.disk_status === 'discussed' || phase.disk_status === 'researched') {
|
|
1117
|
+
recommendedActions.push({
|
|
1118
|
+
phase: phase.number,
|
|
1119
|
+
phase_name: phase.name,
|
|
1120
|
+
action: 'plan',
|
|
1121
|
+
reason: 'Context gathered, ready for planning',
|
|
1122
|
+
command: `/gsd-plan-phase ${phase.number}`,
|
|
1123
|
+
});
|
|
1124
|
+
} else if ((phase.disk_status === 'empty' || phase.disk_status === 'no_directory') && phase.is_next_to_discuss) {
|
|
1125
|
+
recommendedActions.push({
|
|
1126
|
+
phase: phase.number,
|
|
1127
|
+
phase_name: phase.name,
|
|
1128
|
+
action: 'discuss',
|
|
1129
|
+
reason: 'Unblocked, ready to gather context',
|
|
1130
|
+
command: `/gsd-discuss-phase ${phase.number}`,
|
|
1131
|
+
});
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
// Filter recommendations: no parallel execute/plan unless phases are independent
|
|
1136
|
+
// Two phases are "independent" if neither depends on the other (directly or transitively)
|
|
1137
|
+
const phaseMap = new Map(phases.map(p => [p.number, p]));
|
|
1138
|
+
|
|
1139
|
+
function reaches(from, to, visited = new Set()) {
|
|
1140
|
+
if (visited.has(from)) return false;
|
|
1141
|
+
visited.add(from);
|
|
1142
|
+
const p = phaseMap.get(from);
|
|
1143
|
+
if (!p || !p.dep_phases || p.dep_phases.length === 0) return false;
|
|
1144
|
+
if (p.dep_phases.includes(to)) return true;
|
|
1145
|
+
return p.dep_phases.some(dep => reaches(dep, to, visited));
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
function hasDepRelationship(numA, numB) {
|
|
1149
|
+
return reaches(numA, numB) || reaches(numB, numA);
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
// Detect phases with active work (file modified in last 5 min)
|
|
1153
|
+
const activeExecuting = phases.filter(p =>
|
|
1154
|
+
p.disk_status === 'partial' ||
|
|
1155
|
+
(p.disk_status === 'planned' && p.is_active)
|
|
1156
|
+
);
|
|
1157
|
+
const activePlanning = phases.filter(p =>
|
|
1158
|
+
p.is_active && (p.disk_status === 'discussed' || p.disk_status === 'researched')
|
|
1159
|
+
);
|
|
1160
|
+
|
|
1161
|
+
const filteredActions = recommendedActions.filter(action => {
|
|
1162
|
+
if (action.action === 'execute' && activeExecuting.length > 0) {
|
|
1163
|
+
// Only allow if independent of ALL actively-executing phases
|
|
1164
|
+
return activeExecuting.every(active => !hasDepRelationship(action.phase, active.number));
|
|
1165
|
+
}
|
|
1166
|
+
if (action.action === 'plan' && activePlanning.length > 0) {
|
|
1167
|
+
// Only allow if independent of ALL actively-planning phases
|
|
1168
|
+
return activePlanning.every(active => !hasDepRelationship(action.phase, active.number));
|
|
1169
|
+
}
|
|
1170
|
+
return true;
|
|
1171
|
+
});
|
|
1172
|
+
|
|
1173
|
+
// Exclude backlog phases (999.x) from completion accounting (#2129)
|
|
1174
|
+
const nonBacklogPhases = phases.filter(p => !/^999(?:\.|$)/.test(p.number));
|
|
1175
|
+
const completedCount = nonBacklogPhases.filter(p => p.disk_status === 'complete').length;
|
|
1176
|
+
|
|
1177
|
+
// Read manager flags from config (passthrough flags for each step)
|
|
1178
|
+
// Validate: flags must be CLI-safe (only --flags, alphanumeric, hyphens, spaces)
|
|
1179
|
+
const sanitizeFlags = (raw) => {
|
|
1180
|
+
const val = typeof raw === 'string' ? raw : '';
|
|
1181
|
+
if (!val) return '';
|
|
1182
|
+
// Allow only --flag patterns with alphanumeric/hyphen values separated by spaces
|
|
1183
|
+
const tokens = val.split(/\s+/).filter(Boolean);
|
|
1184
|
+
const safe = tokens.every(t => /^--[a-zA-Z0-9][-a-zA-Z0-9]*$/.test(t) || /^[a-zA-Z0-9][-a-zA-Z0-9_.]*$/.test(t));
|
|
1185
|
+
if (!safe) {
|
|
1186
|
+
process.stderr.write(`gsd-tools: warning: manager.flags contains invalid tokens, ignoring: ${val}\n`);
|
|
1187
|
+
return '';
|
|
1188
|
+
}
|
|
1189
|
+
return val;
|
|
1190
|
+
};
|
|
1191
|
+
const managerFlags = {
|
|
1192
|
+
discuss: sanitizeFlags(config.manager && config.manager.flags && config.manager.flags.discuss),
|
|
1193
|
+
plan: sanitizeFlags(config.manager && config.manager.flags && config.manager.flags.plan),
|
|
1194
|
+
execute: sanitizeFlags(config.manager && config.manager.flags && config.manager.flags.execute),
|
|
1195
|
+
};
|
|
1196
|
+
|
|
1197
|
+
const result = {
|
|
1198
|
+
milestone_version: milestone.version,
|
|
1199
|
+
milestone_name: milestone.name,
|
|
1200
|
+
phases,
|
|
1201
|
+
phase_count: phases.length,
|
|
1202
|
+
completed_count: completedCount,
|
|
1203
|
+
in_progress_count: phases.filter(p => ['partial', 'planned', 'discussed', 'researched'].includes(p.disk_status)).length,
|
|
1204
|
+
recommended_actions: filteredActions,
|
|
1205
|
+
waiting_signal: waitingSignal,
|
|
1206
|
+
all_complete: completedCount === nonBacklogPhases.length && nonBacklogPhases.length > 0,
|
|
1207
|
+
project_exists: pathExistsInternal(cwd, '.planning/PROJECT.md'),
|
|
1208
|
+
roadmap_exists: true,
|
|
1209
|
+
state_exists: true,
|
|
1210
|
+
manager_flags: managerFlags,
|
|
1211
|
+
};
|
|
1212
|
+
|
|
1213
|
+
output(withProjectRoot(cwd, result), raw);
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
function cmdInitProgress(cwd, raw) {
|
|
1217
|
+
try {
|
|
1218
|
+
const { pruneOrphanedWorktrees } = require('./core.cjs');
|
|
1219
|
+
pruneOrphanedWorktrees(cwd);
|
|
1220
|
+
} catch (_) {}
|
|
1221
|
+
const config = loadConfig(cwd);
|
|
1222
|
+
const milestone = getMilestoneInfo(cwd);
|
|
1223
|
+
|
|
1224
|
+
// Analyze phases — filter to current milestone and include ROADMAP-only phases
|
|
1225
|
+
const phasesDir = path.join(planningDir(cwd), 'phases');
|
|
1226
|
+
const phases = [];
|
|
1227
|
+
let currentPhase = null;
|
|
1228
|
+
let nextPhase = null;
|
|
1229
|
+
|
|
1230
|
+
// Build set of phases defined in ROADMAP for the current milestone
|
|
1231
|
+
const roadmapPhaseNums = new Set();
|
|
1232
|
+
const roadmapPhaseNames = new Map();
|
|
1233
|
+
try {
|
|
1234
|
+
const roadmapContent = extractCurrentMilestone(
|
|
1235
|
+
fs.readFileSync(path.join(planningDir(cwd), 'ROADMAP.md'), 'utf-8'), cwd
|
|
1236
|
+
);
|
|
1237
|
+
const headingPattern = /#{2,4}\s*Phase\s+(\d+[A-Z]?(?:\.\d+)*)\s*:\s*([^\n]+)/gi;
|
|
1238
|
+
let hm;
|
|
1239
|
+
while ((hm = headingPattern.exec(roadmapContent)) !== null) {
|
|
1240
|
+
roadmapPhaseNums.add(hm[1]);
|
|
1241
|
+
roadmapPhaseNames.set(hm[1], hm[2].replace(/\(INSERTED\)/i, '').trim());
|
|
1242
|
+
}
|
|
1243
|
+
} catch { /* intentionally empty */ }
|
|
1244
|
+
|
|
1245
|
+
const isDirInMilestone = getMilestonePhaseFilter(cwd);
|
|
1246
|
+
const seenPhaseNums = new Set();
|
|
1247
|
+
|
|
1248
|
+
try {
|
|
1249
|
+
const entries = fs.readdirSync(phasesDir, { withFileTypes: true });
|
|
1250
|
+
const dirs = entries.filter(e => e.isDirectory()).map(e => e.name)
|
|
1251
|
+
.filter(isDirInMilestone)
|
|
1252
|
+
.sort((a, b) => {
|
|
1253
|
+
const pa = a.match(/^(\d+[A-Z]?(?:\.\d+)*)/i);
|
|
1254
|
+
const pb = b.match(/^(\d+[A-Z]?(?:\.\d+)*)/i);
|
|
1255
|
+
if (!pa || !pb) return a.localeCompare(b);
|
|
1256
|
+
return parseInt(pa[1], 10) - parseInt(pb[1], 10);
|
|
1257
|
+
});
|
|
1258
|
+
|
|
1259
|
+
for (const dir of dirs) {
|
|
1260
|
+
const match = dir.match(/^(\d+[A-Z]?(?:\.\d+)*)-?(.*)/i);
|
|
1261
|
+
const phaseNumber = match ? match[1] : dir;
|
|
1262
|
+
const phaseName = match && match[2] ? match[2] : null;
|
|
1263
|
+
seenPhaseNums.add(phaseNumber.replace(/^0+/, '') || '0');
|
|
1264
|
+
|
|
1265
|
+
const phasePath = path.join(phasesDir, dir);
|
|
1266
|
+
const phaseFiles = fs.readdirSync(phasePath);
|
|
1267
|
+
|
|
1268
|
+
const plans = phaseFiles.filter(f => f.endsWith('-PLAN.md') || f === 'PLAN.md');
|
|
1269
|
+
const summaries = phaseFiles.filter(f => f.endsWith('-SUMMARY.md') || f === 'SUMMARY.md');
|
|
1270
|
+
const hasResearch = phaseFiles.some(f => f.endsWith('-RESEARCH.md') || f === 'RESEARCH.md');
|
|
1271
|
+
|
|
1272
|
+
const status = summaries.length >= plans.length && plans.length > 0 ? 'complete' :
|
|
1273
|
+
plans.length > 0 ? 'in_progress' :
|
|
1274
|
+
hasResearch ? 'researched' : 'pending';
|
|
1275
|
+
|
|
1276
|
+
const phaseInfo = {
|
|
1277
|
+
number: phaseNumber,
|
|
1278
|
+
name: phaseName,
|
|
1279
|
+
directory: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'phases', dir))),
|
|
1280
|
+
status,
|
|
1281
|
+
plan_count: plans.length,
|
|
1282
|
+
summary_count: summaries.length,
|
|
1283
|
+
has_research: hasResearch,
|
|
1284
|
+
};
|
|
1285
|
+
|
|
1286
|
+
phases.push(phaseInfo);
|
|
1287
|
+
|
|
1288
|
+
// Find current (first incomplete with plans) and next (first pending)
|
|
1289
|
+
if (!currentPhase && (status === 'in_progress' || status === 'researched')) {
|
|
1290
|
+
currentPhase = phaseInfo;
|
|
1291
|
+
}
|
|
1292
|
+
if (!nextPhase && status === 'pending') {
|
|
1293
|
+
nextPhase = phaseInfo;
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
} catch { /* intentionally empty */ }
|
|
1297
|
+
|
|
1298
|
+
// Add phases defined in ROADMAP but not yet scaffolded to disk
|
|
1299
|
+
for (const [num, name] of roadmapPhaseNames) {
|
|
1300
|
+
const stripped = num.replace(/^0+/, '') || '0';
|
|
1301
|
+
if (!seenPhaseNums.has(stripped)) {
|
|
1302
|
+
const phaseInfo = {
|
|
1303
|
+
number: num,
|
|
1304
|
+
name: name.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, ''),
|
|
1305
|
+
directory: null,
|
|
1306
|
+
status: 'not_started',
|
|
1307
|
+
plan_count: 0,
|
|
1308
|
+
summary_count: 0,
|
|
1309
|
+
has_research: false,
|
|
1310
|
+
};
|
|
1311
|
+
phases.push(phaseInfo);
|
|
1312
|
+
if (!nextPhase && !currentPhase) {
|
|
1313
|
+
nextPhase = phaseInfo;
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
// Re-sort phases by number after adding ROADMAP-only phases
|
|
1319
|
+
phases.sort((a, b) => parseInt(a.number, 10) - parseInt(b.number, 10));
|
|
1320
|
+
|
|
1321
|
+
// Check for paused work
|
|
1322
|
+
let pausedAt = null;
|
|
1323
|
+
try {
|
|
1324
|
+
const state = fs.readFileSync(path.join(planningDir(cwd), 'STATE.md'), 'utf-8');
|
|
1325
|
+
const pauseMatch = state.match(/\*\*Paused At:\*\*\s*(.+)/);
|
|
1326
|
+
if (pauseMatch) pausedAt = pauseMatch[1].trim();
|
|
1327
|
+
} catch { /* intentionally empty */ }
|
|
1328
|
+
|
|
1329
|
+
const result = {
|
|
1330
|
+
// Models
|
|
1331
|
+
executor_model: resolveModelInternal(cwd, 'gsd-executor'),
|
|
1332
|
+
planner_model: resolveModelInternal(cwd, 'gsd-planner'),
|
|
1333
|
+
|
|
1334
|
+
// Config
|
|
1335
|
+
commit_docs: config.commit_docs,
|
|
1336
|
+
|
|
1337
|
+
// Milestone
|
|
1338
|
+
milestone_version: milestone.version,
|
|
1339
|
+
milestone_name: milestone.name,
|
|
1340
|
+
|
|
1341
|
+
// Phase overview
|
|
1342
|
+
phases,
|
|
1343
|
+
phase_count: phases.length,
|
|
1344
|
+
completed_count: phases.filter(p => p.status === 'complete').length,
|
|
1345
|
+
in_progress_count: phases.filter(p => p.status === 'in_progress').length,
|
|
1346
|
+
|
|
1347
|
+
// Current state
|
|
1348
|
+
current_phase: currentPhase,
|
|
1349
|
+
next_phase: nextPhase,
|
|
1350
|
+
paused_at: pausedAt,
|
|
1351
|
+
has_work_in_progress: !!currentPhase,
|
|
1352
|
+
|
|
1353
|
+
// File existence
|
|
1354
|
+
project_exists: pathExistsInternal(cwd, '.planning/PROJECT.md'),
|
|
1355
|
+
roadmap_exists: fs.existsSync(path.join(planningDir(cwd), 'ROADMAP.md')),
|
|
1356
|
+
state_exists: fs.existsSync(path.join(planningDir(cwd), 'STATE.md')),
|
|
1357
|
+
// File paths
|
|
1358
|
+
state_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'STATE.md'))),
|
|
1359
|
+
roadmap_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'ROADMAP.md'))),
|
|
1360
|
+
project_path: '.planning/PROJECT.md',
|
|
1361
|
+
config_path: toPosixPath(path.relative(cwd, path.join(planningDir(cwd), 'config.json'))),
|
|
1362
|
+
};
|
|
1363
|
+
|
|
1364
|
+
output(withProjectRoot(cwd, result), raw);
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
/**
|
|
1368
|
+
* Detect child git repos in a directory (one level deep).
|
|
1369
|
+
* Returns array of { name, path, has_uncommitted } objects.
|
|
1370
|
+
*/
|
|
1371
|
+
function detectChildRepos(dir) {
|
|
1372
|
+
const repos = [];
|
|
1373
|
+
let entries;
|
|
1374
|
+
try { entries = fs.readdirSync(dir, { withFileTypes: true }); } catch { return repos; }
|
|
1375
|
+
for (const entry of entries) {
|
|
1376
|
+
if (!entry.isDirectory()) continue;
|
|
1377
|
+
if (entry.name.startsWith('.')) continue;
|
|
1378
|
+
const fullPath = path.join(dir, entry.name);
|
|
1379
|
+
const gitDir = path.join(fullPath, '.git');
|
|
1380
|
+
if (fs.existsSync(gitDir)) {
|
|
1381
|
+
let hasUncommitted = false;
|
|
1382
|
+
try {
|
|
1383
|
+
const status = execSync('git status --porcelain', { cwd: fullPath, encoding: 'utf8', timeout: 5000 });
|
|
1384
|
+
hasUncommitted = status.trim().length > 0;
|
|
1385
|
+
} catch { /* best-effort */ }
|
|
1386
|
+
repos.push({ name: entry.name, path: fullPath, has_uncommitted: hasUncommitted });
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
return repos;
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
function cmdInitNewWorkspace(cwd, raw) {
|
|
1393
|
+
const homedir = process.env.HOME || require('os').homedir();
|
|
1394
|
+
const defaultBase = path.join(homedir, 'gsd-workspaces');
|
|
1395
|
+
|
|
1396
|
+
// Detect child git repos for interactive selection
|
|
1397
|
+
const childRepos = detectChildRepos(cwd);
|
|
1398
|
+
|
|
1399
|
+
// Check if git worktree is available
|
|
1400
|
+
let worktreeAvailable = false;
|
|
1401
|
+
try {
|
|
1402
|
+
execSync('git --version', { encoding: 'utf8', timeout: 5000, stdio: 'pipe' });
|
|
1403
|
+
worktreeAvailable = true;
|
|
1404
|
+
} catch { /* no git at all */ }
|
|
1405
|
+
|
|
1406
|
+
const result = {
|
|
1407
|
+
default_workspace_base: defaultBase,
|
|
1408
|
+
child_repos: childRepos,
|
|
1409
|
+
child_repo_count: childRepos.length,
|
|
1410
|
+
worktree_available: worktreeAvailable,
|
|
1411
|
+
is_git_repo: pathExistsInternal(cwd, '.git'),
|
|
1412
|
+
cwd_repo_name: path.basename(cwd),
|
|
1413
|
+
};
|
|
1414
|
+
|
|
1415
|
+
output(withProjectRoot(cwd, result), raw);
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
function cmdInitListWorkspaces(cwd, raw) {
|
|
1419
|
+
const homedir = process.env.HOME || require('os').homedir();
|
|
1420
|
+
const defaultBase = path.join(homedir, 'gsd-workspaces');
|
|
1421
|
+
|
|
1422
|
+
const workspaces = [];
|
|
1423
|
+
if (fs.existsSync(defaultBase)) {
|
|
1424
|
+
let entries;
|
|
1425
|
+
try { entries = fs.readdirSync(defaultBase, { withFileTypes: true }); } catch { entries = []; }
|
|
1426
|
+
for (const entry of entries) {
|
|
1427
|
+
if (!entry.isDirectory()) continue;
|
|
1428
|
+
const wsPath = path.join(defaultBase, entry.name);
|
|
1429
|
+
const manifestPath = path.join(wsPath, 'WORKSPACE.md');
|
|
1430
|
+
if (!fs.existsSync(manifestPath)) continue;
|
|
1431
|
+
|
|
1432
|
+
let repoCount = 0;
|
|
1433
|
+
let hasProject = false;
|
|
1434
|
+
let strategy = 'unknown';
|
|
1435
|
+
try {
|
|
1436
|
+
const manifest = fs.readFileSync(manifestPath, 'utf8');
|
|
1437
|
+
const strategyMatch = manifest.match(/^Strategy:\s*(.+)$/m);
|
|
1438
|
+
if (strategyMatch) strategy = strategyMatch[1].trim();
|
|
1439
|
+
// Count table rows (lines starting with |, excluding header and separator)
|
|
1440
|
+
const tableRows = manifest.split('\n').filter(l => l.match(/^\|\s*\w/) && !l.includes('Repo') && !l.includes('---'));
|
|
1441
|
+
repoCount = tableRows.length;
|
|
1442
|
+
} catch { /* best-effort */ }
|
|
1443
|
+
hasProject = fs.existsSync(path.join(wsPath, '.planning', 'PROJECT.md'));
|
|
1444
|
+
|
|
1445
|
+
workspaces.push({
|
|
1446
|
+
name: entry.name,
|
|
1447
|
+
path: wsPath,
|
|
1448
|
+
repo_count: repoCount,
|
|
1449
|
+
strategy,
|
|
1450
|
+
has_project: hasProject,
|
|
1451
|
+
});
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
const result = {
|
|
1456
|
+
workspace_base: defaultBase,
|
|
1457
|
+
workspaces,
|
|
1458
|
+
workspace_count: workspaces.length,
|
|
1459
|
+
};
|
|
1460
|
+
|
|
1461
|
+
output(result, raw);
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
function cmdInitRemoveWorkspace(cwd, name, raw) {
|
|
1465
|
+
const homedir = process.env.HOME || require('os').homedir();
|
|
1466
|
+
const defaultBase = path.join(homedir, 'gsd-workspaces');
|
|
1467
|
+
|
|
1468
|
+
if (!name) {
|
|
1469
|
+
error('workspace name required for init remove-workspace');
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
const wsPath = path.join(defaultBase, name);
|
|
1473
|
+
const manifestPath = path.join(wsPath, 'WORKSPACE.md');
|
|
1474
|
+
|
|
1475
|
+
if (!fs.existsSync(wsPath)) {
|
|
1476
|
+
error(`Workspace not found: ${wsPath}`);
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
// Parse manifest for repo info
|
|
1480
|
+
const repos = [];
|
|
1481
|
+
let strategy = 'unknown';
|
|
1482
|
+
if (fs.existsSync(manifestPath)) {
|
|
1483
|
+
try {
|
|
1484
|
+
const manifest = fs.readFileSync(manifestPath, 'utf8');
|
|
1485
|
+
const strategyMatch = manifest.match(/^Strategy:\s*(.+)$/m);
|
|
1486
|
+
if (strategyMatch) strategy = strategyMatch[1].trim();
|
|
1487
|
+
|
|
1488
|
+
// Parse table rows for repo names and source paths
|
|
1489
|
+
const lines = manifest.split('\n');
|
|
1490
|
+
for (const line of lines) {
|
|
1491
|
+
const match = line.match(/^\|\s*(\S+)\s*\|\s*(\S+)\s*\|\s*(\S+)\s*\|\s*(\S+)\s*\|$/);
|
|
1492
|
+
if (match && match[1] !== 'Repo' && !match[1].includes('---')) {
|
|
1493
|
+
repos.push({ name: match[1], source: match[2], branch: match[3], strategy: match[4] });
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
} catch { /* best-effort */ }
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
// Check for uncommitted changes in workspace repos
|
|
1500
|
+
const dirtyRepos = [];
|
|
1501
|
+
for (const repo of repos) {
|
|
1502
|
+
const repoPath = path.join(wsPath, repo.name);
|
|
1503
|
+
if (!fs.existsSync(repoPath)) continue;
|
|
1504
|
+
try {
|
|
1505
|
+
const status = execSync('git status --porcelain', { cwd: repoPath, encoding: 'utf8', timeout: 5000, stdio: 'pipe' });
|
|
1506
|
+
if (status.trim().length > 0) {
|
|
1507
|
+
dirtyRepos.push(repo.name);
|
|
1508
|
+
}
|
|
1509
|
+
} catch { /* best-effort */ }
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
const result = {
|
|
1513
|
+
workspace_name: name,
|
|
1514
|
+
workspace_path: wsPath,
|
|
1515
|
+
has_manifest: fs.existsSync(manifestPath),
|
|
1516
|
+
strategy,
|
|
1517
|
+
repos,
|
|
1518
|
+
repo_count: repos.length,
|
|
1519
|
+
dirty_repos: dirtyRepos,
|
|
1520
|
+
has_dirty_repos: dirtyRepos.length > 0,
|
|
1521
|
+
};
|
|
1522
|
+
|
|
1523
|
+
output(result, raw);
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
/**
|
|
1527
|
+
* Build a formatted agent skills block for injection into Task() prompts.
|
|
1528
|
+
*
|
|
1529
|
+
* Reads `config.agent_skills[agentType]` and validates each skill path exists
|
|
1530
|
+
* within the project root. Returns a formatted `<agent_skills>` block or empty
|
|
1531
|
+
* string if no skills are configured.
|
|
1532
|
+
*
|
|
1533
|
+
* @param {object} config - Loaded project config
|
|
1534
|
+
* @param {string} agentType - The agent type (e.g., 'gsd-executor', 'gsd-planner')
|
|
1535
|
+
* @param {string} projectRoot - Absolute path to project root (for path validation)
|
|
1536
|
+
* @returns {string} Formatted skills block or empty string
|
|
1537
|
+
*/
|
|
1538
|
+
function buildAgentSkillsBlock(config, agentType, projectRoot) {
|
|
1539
|
+
const { validatePath } = require('./security.cjs');
|
|
1540
|
+
const os = require('os');
|
|
1541
|
+
const globalSkillsBase = path.join(os.homedir(), '.claude', 'skills');
|
|
1542
|
+
|
|
1543
|
+
if (!config || !config.agent_skills || !agentType) return '';
|
|
1544
|
+
|
|
1545
|
+
let skillPaths = config.agent_skills[agentType];
|
|
1546
|
+
if (!skillPaths) return '';
|
|
1547
|
+
|
|
1548
|
+
// Normalize single string to array
|
|
1549
|
+
if (typeof skillPaths === 'string') skillPaths = [skillPaths];
|
|
1550
|
+
if (!Array.isArray(skillPaths) || skillPaths.length === 0) return '';
|
|
1551
|
+
|
|
1552
|
+
const validPaths = [];
|
|
1553
|
+
for (const skillPath of skillPaths) {
|
|
1554
|
+
if (typeof skillPath !== 'string') continue;
|
|
1555
|
+
|
|
1556
|
+
// Support global: prefix for skills installed at ~/.claude/skills/ (#1992)
|
|
1557
|
+
if (skillPath.startsWith('global:')) {
|
|
1558
|
+
const skillName = skillPath.slice(7);
|
|
1559
|
+
// Explicit empty-name guard before regex for clearer error message
|
|
1560
|
+
if (!skillName) {
|
|
1561
|
+
process.stderr.write(`[agent-skills] WARNING: "global:" prefix with empty skill name — skipping\n`);
|
|
1562
|
+
continue;
|
|
1563
|
+
}
|
|
1564
|
+
// Sanitize: skill name must be alphanumeric, hyphens, or underscores only
|
|
1565
|
+
if (!/^[a-zA-Z0-9_-]+$/.test(skillName)) {
|
|
1566
|
+
process.stderr.write(`[agent-skills] WARNING: Invalid global skill name "${skillName}" — skipping\n`);
|
|
1567
|
+
continue;
|
|
1568
|
+
}
|
|
1569
|
+
const globalSkillDir = path.join(globalSkillsBase, skillName);
|
|
1570
|
+
const globalSkillMd = path.join(globalSkillDir, 'SKILL.md');
|
|
1571
|
+
if (!fs.existsSync(globalSkillMd)) {
|
|
1572
|
+
process.stderr.write(`[agent-skills] WARNING: Global skill not found at "~/.claude/skills/${skillName}/SKILL.md" — skipping\n`);
|
|
1573
|
+
continue;
|
|
1574
|
+
}
|
|
1575
|
+
// Symlink escape guard: validatePath resolves symlinks and enforces
|
|
1576
|
+
// containment within globalSkillsBase. Prevents a skill directory
|
|
1577
|
+
// symlinked to an arbitrary location from being injected (#1992).
|
|
1578
|
+
const pathCheck = validatePath(globalSkillMd, globalSkillsBase, { allowAbsolute: true });
|
|
1579
|
+
if (!pathCheck.safe) {
|
|
1580
|
+
process.stderr.write(`[agent-skills] WARNING: Global skill "${skillName}" failed path check (symlink escape?) — skipping\n`);
|
|
1581
|
+
continue;
|
|
1582
|
+
}
|
|
1583
|
+
validPaths.push({ ref: `${globalSkillDir}/SKILL.md`, display: `~/.claude/skills/${skillName}` });
|
|
1584
|
+
continue;
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
// Validate path safety — must resolve within project root
|
|
1588
|
+
const pathCheck = validatePath(skillPath, projectRoot);
|
|
1589
|
+
if (!pathCheck.safe) {
|
|
1590
|
+
process.stderr.write(`[agent-skills] WARNING: Skipping unsafe path "${skillPath}": ${pathCheck.error}\n`);
|
|
1591
|
+
continue;
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
// Check that the skill directory and SKILL.md exist
|
|
1595
|
+
const skillMdPath = path.join(projectRoot, skillPath, 'SKILL.md');
|
|
1596
|
+
if (!fs.existsSync(skillMdPath)) {
|
|
1597
|
+
process.stderr.write(`[agent-skills] WARNING: Skill not found at "${skillPath}/SKILL.md" — skipping\n`);
|
|
1598
|
+
continue;
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
validPaths.push({ ref: `${skillPath}/SKILL.md`, display: skillPath });
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1604
|
+
if (validPaths.length === 0) return '';
|
|
1605
|
+
|
|
1606
|
+
const lines = validPaths.map(p => `- @${p.ref}`).join('\n');
|
|
1607
|
+
return `<agent_skills>\nRead these user-configured skills:\n${lines}\n</agent_skills>`;
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
/**
|
|
1611
|
+
* Command: output the agent skills block for a given agent type.
|
|
1612
|
+
* Used by workflows: SKILLS=$(node "$TOOLS" agent-skills gsd-executor 2>/dev/null)
|
|
1613
|
+
*/
|
|
1614
|
+
function cmdAgentSkills(cwd, agentType, raw) {
|
|
1615
|
+
if (!agentType) {
|
|
1616
|
+
// No agent type — output empty string silently
|
|
1617
|
+
output('', raw, '');
|
|
1618
|
+
return;
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
const config = loadConfig(cwd);
|
|
1622
|
+
const block = buildAgentSkillsBlock(config, agentType, cwd);
|
|
1623
|
+
// Output raw text (not JSON) so workflows can embed it directly
|
|
1624
|
+
if (block) {
|
|
1625
|
+
process.stdout.write(block);
|
|
1626
|
+
}
|
|
1627
|
+
process.exit(0);
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1630
|
+
/**
|
|
1631
|
+
* Generate a skill manifest from a skills directory.
|
|
1632
|
+
*
|
|
1633
|
+
* Scans the canonical skill discovery roots and returns a normalized
|
|
1634
|
+
* inventory object with discovered skills, root metadata, and installation
|
|
1635
|
+
* summary flags. A legacy `skillsDir` override is still accepted for focused
|
|
1636
|
+
* scans, but the default mode is multi-root discovery.
|
|
1637
|
+
*
|
|
1638
|
+
* @param {string} cwd - Project root directory
|
|
1639
|
+
* @param {string|null} [skillsDir] - Optional absolute path to a specific skills directory
|
|
1640
|
+
* @returns {{
|
|
1641
|
+
* skills: Array<{name: string, description: string, triggers: string[], path: string, file_path: string, root: string, scope: string, installed: boolean, deprecated: boolean}>,
|
|
1642
|
+
* roots: Array<{root: string, path: string, scope: string, present: boolean, skill_count?: number, command_count?: number, deprecated?: boolean}>,
|
|
1643
|
+
* installation: { gsd_skills_installed: boolean, legacy_claude_commands_installed: boolean },
|
|
1644
|
+
* counts: { skills: number, roots: number }
|
|
1645
|
+
* }}
|
|
1646
|
+
*/
|
|
1647
|
+
function buildSkillManifest(cwd, skillsDir = null) {
|
|
1648
|
+
const { extractFrontmatter } = require('./frontmatter.cjs');
|
|
1649
|
+
const os = require('os');
|
|
1650
|
+
|
|
1651
|
+
const canonicalRoots = skillsDir ? [{
|
|
1652
|
+
root: path.resolve(skillsDir),
|
|
1653
|
+
path: path.resolve(skillsDir),
|
|
1654
|
+
scope: 'custom',
|
|
1655
|
+
present: fs.existsSync(skillsDir),
|
|
1656
|
+
kind: 'skills',
|
|
1657
|
+
}] : [
|
|
1658
|
+
{
|
|
1659
|
+
root: '.claude/skills',
|
|
1660
|
+
path: path.join(cwd, '.claude', 'skills'),
|
|
1661
|
+
scope: 'project',
|
|
1662
|
+
kind: 'skills',
|
|
1663
|
+
},
|
|
1664
|
+
{
|
|
1665
|
+
root: '.agents/skills',
|
|
1666
|
+
path: path.join(cwd, '.agents', 'skills'),
|
|
1667
|
+
scope: 'project',
|
|
1668
|
+
kind: 'skills',
|
|
1669
|
+
},
|
|
1670
|
+
{
|
|
1671
|
+
root: '.cursor/skills',
|
|
1672
|
+
path: path.join(cwd, '.cursor', 'skills'),
|
|
1673
|
+
scope: 'project',
|
|
1674
|
+
kind: 'skills',
|
|
1675
|
+
},
|
|
1676
|
+
{
|
|
1677
|
+
root: '.github/skills',
|
|
1678
|
+
path: path.join(cwd, '.github', 'skills'),
|
|
1679
|
+
scope: 'project',
|
|
1680
|
+
kind: 'skills',
|
|
1681
|
+
},
|
|
1682
|
+
{
|
|
1683
|
+
root: '.codex/skills',
|
|
1684
|
+
path: path.join(cwd, '.codex', 'skills'),
|
|
1685
|
+
scope: 'project',
|
|
1686
|
+
kind: 'skills',
|
|
1687
|
+
},
|
|
1688
|
+
{
|
|
1689
|
+
root: '~/.claude/skills',
|
|
1690
|
+
path: path.join(os.homedir(), '.claude', 'skills'),
|
|
1691
|
+
scope: 'global',
|
|
1692
|
+
kind: 'skills',
|
|
1693
|
+
},
|
|
1694
|
+
{
|
|
1695
|
+
root: '~/.codex/skills',
|
|
1696
|
+
path: path.join(os.homedir(), '.codex', 'skills'),
|
|
1697
|
+
scope: 'global',
|
|
1698
|
+
kind: 'skills',
|
|
1699
|
+
},
|
|
1700
|
+
{
|
|
1701
|
+
root: '.claude/get-shit-done/skills',
|
|
1702
|
+
path: path.join(os.homedir(), '.claude', 'get-shit-done', 'skills'),
|
|
1703
|
+
scope: 'import-only',
|
|
1704
|
+
kind: 'skills',
|
|
1705
|
+
deprecated: true,
|
|
1706
|
+
},
|
|
1707
|
+
{
|
|
1708
|
+
root: '.claude/commands/gsd',
|
|
1709
|
+
path: path.join(os.homedir(), '.claude', 'commands', 'gsd'),
|
|
1710
|
+
scope: 'legacy-commands',
|
|
1711
|
+
kind: 'commands',
|
|
1712
|
+
deprecated: true,
|
|
1713
|
+
},
|
|
1714
|
+
];
|
|
1715
|
+
|
|
1716
|
+
const skills = [];
|
|
1717
|
+
const roots = [];
|
|
1718
|
+
let legacyClaudeCommandsInstalled = false;
|
|
1719
|
+
for (const rootInfo of canonicalRoots) {
|
|
1720
|
+
const rootPath = rootInfo.path;
|
|
1721
|
+
const rootSummary = {
|
|
1722
|
+
root: rootInfo.root,
|
|
1723
|
+
path: rootPath,
|
|
1724
|
+
scope: rootInfo.scope,
|
|
1725
|
+
present: fs.existsSync(rootPath),
|
|
1726
|
+
deprecated: !!rootInfo.deprecated,
|
|
1727
|
+
};
|
|
1728
|
+
|
|
1729
|
+
if (!rootSummary.present) {
|
|
1730
|
+
roots.push(rootSummary);
|
|
1731
|
+
continue;
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1734
|
+
if (rootInfo.kind === 'commands') {
|
|
1735
|
+
let entries = [];
|
|
1736
|
+
try {
|
|
1737
|
+
entries = fs.readdirSync(rootPath, { withFileTypes: true });
|
|
1738
|
+
} catch {
|
|
1739
|
+
roots.push(rootSummary);
|
|
1740
|
+
continue;
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
const commandFiles = entries.filter(entry => entry.isFile() && entry.name.endsWith('.md'));
|
|
1744
|
+
rootSummary.command_count = commandFiles.length;
|
|
1745
|
+
if (rootSummary.command_count > 0) legacyClaudeCommandsInstalled = true;
|
|
1746
|
+
roots.push(rootSummary);
|
|
1747
|
+
continue;
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
let entries;
|
|
1751
|
+
try {
|
|
1752
|
+
entries = fs.readdirSync(rootPath, { withFileTypes: true });
|
|
1753
|
+
} catch {
|
|
1754
|
+
roots.push(rootSummary);
|
|
1755
|
+
continue;
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
let skillCount = 0;
|
|
1759
|
+
for (const entry of entries) {
|
|
1760
|
+
if (!entry.isDirectory()) continue;
|
|
1761
|
+
|
|
1762
|
+
const skillMdPath = path.join(rootPath, entry.name, 'SKILL.md');
|
|
1763
|
+
if (!fs.existsSync(skillMdPath)) continue;
|
|
1764
|
+
|
|
1765
|
+
let content;
|
|
1766
|
+
try {
|
|
1767
|
+
content = fs.readFileSync(skillMdPath, 'utf-8');
|
|
1768
|
+
} catch {
|
|
1769
|
+
continue;
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1772
|
+
const frontmatter = extractFrontmatter(content);
|
|
1773
|
+
const name = frontmatter.name || entry.name;
|
|
1774
|
+
const description = frontmatter.description || '';
|
|
1775
|
+
|
|
1776
|
+
// Extract trigger lines from body text (after frontmatter)
|
|
1777
|
+
const triggers = [];
|
|
1778
|
+
const bodyMatch = content.match(/^---[\s\S]*?---\s*\n([\s\S]*)$/);
|
|
1779
|
+
if (bodyMatch) {
|
|
1780
|
+
const body = bodyMatch[1];
|
|
1781
|
+
const triggerLines = body.match(/^TRIGGER\s+when:\s*(.+)$/gmi);
|
|
1782
|
+
if (triggerLines) {
|
|
1783
|
+
for (const line of triggerLines) {
|
|
1784
|
+
const m = line.match(/^TRIGGER\s+when:\s*(.+)$/i);
|
|
1785
|
+
if (m) triggers.push(m[1].trim());
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
|
|
1790
|
+
skills.push({
|
|
1791
|
+
name,
|
|
1792
|
+
description,
|
|
1793
|
+
triggers,
|
|
1794
|
+
path: entry.name,
|
|
1795
|
+
file_path: `${entry.name}/SKILL.md`,
|
|
1796
|
+
root: rootInfo.root,
|
|
1797
|
+
scope: rootInfo.scope,
|
|
1798
|
+
installed: rootInfo.scope !== 'import-only',
|
|
1799
|
+
deprecated: !!rootInfo.deprecated,
|
|
1800
|
+
});
|
|
1801
|
+
skillCount++;
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
rootSummary.skill_count = skillCount;
|
|
1805
|
+
roots.push(rootSummary);
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1808
|
+
skills.sort((a, b) => {
|
|
1809
|
+
const rootCmp = a.root.localeCompare(b.root);
|
|
1810
|
+
return rootCmp !== 0 ? rootCmp : a.name.localeCompare(b.name);
|
|
1811
|
+
});
|
|
1812
|
+
|
|
1813
|
+
const gsdSkillsInstalled = skills.some(skill => skill.name.startsWith('gsd-'));
|
|
1814
|
+
|
|
1815
|
+
return {
|
|
1816
|
+
skills,
|
|
1817
|
+
roots,
|
|
1818
|
+
installation: {
|
|
1819
|
+
gsd_skills_installed: gsdSkillsInstalled,
|
|
1820
|
+
legacy_claude_commands_installed: legacyClaudeCommandsInstalled,
|
|
1821
|
+
},
|
|
1822
|
+
counts: {
|
|
1823
|
+
skills: skills.length,
|
|
1824
|
+
roots: roots.length,
|
|
1825
|
+
},
|
|
1826
|
+
};
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1829
|
+
/**
|
|
1830
|
+
* Command: generate skill manifest JSON.
|
|
1831
|
+
*
|
|
1832
|
+
* Options:
|
|
1833
|
+
* --skills-dir <path> Optional absolute path to a single skills directory
|
|
1834
|
+
* --write Also write to .planning/skill-manifest.json
|
|
1835
|
+
*/
|
|
1836
|
+
function cmdSkillManifest(cwd, args, raw) {
|
|
1837
|
+
const skillsDirIdx = args.indexOf('--skills-dir');
|
|
1838
|
+
const skillsDir = skillsDirIdx >= 0 && args[skillsDirIdx + 1]
|
|
1839
|
+
? args[skillsDirIdx + 1]
|
|
1840
|
+
: null;
|
|
1841
|
+
|
|
1842
|
+
const manifest = buildSkillManifest(cwd, skillsDir);
|
|
1843
|
+
|
|
1844
|
+
// Optionally write to .planning/skill-manifest.json
|
|
1845
|
+
if (args.includes('--write')) {
|
|
1846
|
+
const planningDir = path.join(cwd, '.planning');
|
|
1847
|
+
if (fs.existsSync(planningDir)) {
|
|
1848
|
+
const manifestPath = path.join(planningDir, 'skill-manifest.json');
|
|
1849
|
+
fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2), 'utf-8');
|
|
1850
|
+
}
|
|
1851
|
+
}
|
|
1852
|
+
|
|
1853
|
+
output(manifest, raw);
|
|
1854
|
+
}
|
|
1855
|
+
|
|
1856
|
+
module.exports = {
|
|
1857
|
+
cmdInitExecutePhase,
|
|
1858
|
+
cmdInitPlanPhase,
|
|
1859
|
+
cmdInitNewProject,
|
|
1860
|
+
cmdInitNewMilestone,
|
|
1861
|
+
cmdInitQuick,
|
|
1862
|
+
cmdInitResume,
|
|
1863
|
+
cmdInitVerifyWork,
|
|
1864
|
+
cmdInitPhaseOp,
|
|
1865
|
+
cmdInitTodos,
|
|
1866
|
+
cmdInitMilestoneOp,
|
|
1867
|
+
cmdInitMapCodebase,
|
|
1868
|
+
cmdInitProgress,
|
|
1869
|
+
cmdInitManager,
|
|
1870
|
+
cmdInitNewWorkspace,
|
|
1871
|
+
cmdInitListWorkspaces,
|
|
1872
|
+
cmdInitRemoveWorkspace,
|
|
1873
|
+
detectChildRepos,
|
|
1874
|
+
buildAgentSkillsBlock,
|
|
1875
|
+
cmdAgentSkills,
|
|
1876
|
+
buildSkillManifest,
|
|
1877
|
+
cmdSkillManifest,
|
|
1878
|
+
};
|