gsd-pi 2.29.0-dev.49d972f → 2.29.0-dev.4c155ee
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/README.md +24 -17
- package/dist/headless.js +4 -0
- package/dist/resources/extensions/bg-shell/process-manager.ts +13 -0
- package/dist/resources/extensions/gsd/auto-dashboard.ts +217 -65
- package/dist/resources/extensions/gsd/auto-dispatch.ts +32 -3
- package/dist/resources/extensions/gsd/auto-post-unit.ts +44 -12
- package/dist/resources/extensions/gsd/auto-prompts.ts +40 -17
- package/dist/resources/extensions/gsd/auto-recovery.ts +2 -1
- package/dist/resources/extensions/gsd/auto-start.ts +18 -32
- package/dist/resources/extensions/gsd/auto-worktree.ts +21 -182
- package/dist/resources/extensions/gsd/auto.ts +2 -9
- package/dist/resources/extensions/gsd/captures.ts +4 -10
- package/dist/resources/extensions/gsd/commands-handlers.ts +2 -1
- package/dist/resources/extensions/gsd/commands-prefs-wizard.ts +44 -14
- package/dist/resources/extensions/gsd/commands-workflow-templates.ts +544 -0
- package/dist/resources/extensions/gsd/commands.ts +55 -2
- package/dist/resources/extensions/gsd/detection.ts +2 -1
- package/dist/resources/extensions/gsd/doctor-checks.ts +49 -1
- package/dist/resources/extensions/gsd/doctor-types.ts +3 -1
- package/dist/resources/extensions/gsd/forensics.ts +2 -2
- package/dist/resources/extensions/gsd/git-service.ts +3 -2
- package/dist/resources/extensions/gsd/gitignore.ts +9 -63
- package/dist/resources/extensions/gsd/gsd-db.ts +1 -165
- package/dist/resources/extensions/gsd/guided-flow.ts +8 -5
- package/dist/resources/extensions/gsd/index.ts +3 -3
- package/dist/resources/extensions/gsd/md-importer.ts +3 -2
- package/dist/resources/extensions/gsd/mechanical-completion.ts +430 -0
- package/dist/resources/extensions/gsd/migrate/command.ts +3 -2
- package/dist/resources/extensions/gsd/migrate/writer.ts +2 -1
- package/dist/resources/extensions/gsd/migrate-external.ts +123 -0
- package/dist/resources/extensions/gsd/paths.ts +24 -2
- package/dist/resources/extensions/gsd/post-unit-hooks.ts +6 -5
- package/dist/resources/extensions/gsd/preferences-models.ts +7 -1
- package/dist/resources/extensions/gsd/preferences-validation.ts +2 -1
- package/dist/resources/extensions/gsd/preferences.ts +10 -5
- package/dist/resources/extensions/gsd/prompts/discuss-headless.md +4 -2
- package/dist/resources/extensions/gsd/prompts/guided-discuss-milestone.md +1 -1
- package/dist/resources/extensions/gsd/prompts/plan-milestone.md +26 -2
- package/dist/resources/extensions/gsd/prompts/plan-slice.md +15 -1
- package/dist/resources/extensions/gsd/prompts/workflow-start.md +28 -0
- package/dist/resources/extensions/gsd/repo-identity.ts +148 -0
- package/dist/resources/extensions/gsd/resource-version.ts +99 -0
- package/dist/resources/extensions/gsd/session-forensics.ts +4 -3
- package/dist/resources/extensions/gsd/tests/activity-log.test.ts +2 -2
- package/dist/resources/extensions/gsd/tests/auto-recovery.test.ts +3 -3
- package/dist/resources/extensions/gsd/tests/auto-worktree.test.ts +0 -58
- package/dist/resources/extensions/gsd/tests/doctor-runtime.test.ts +3 -4
- package/dist/resources/extensions/gsd/tests/extension-selector-separator.test.ts +60 -38
- package/dist/resources/extensions/gsd/tests/feature-branch-lifecycle-integration.test.ts +5 -18
- package/dist/resources/extensions/gsd/tests/git-service.test.ts +10 -37
- package/dist/resources/extensions/gsd/tests/knowledge.test.ts +4 -4
- package/dist/resources/extensions/gsd/tests/mechanical-completion.test.ts +356 -0
- package/dist/resources/extensions/gsd/tests/plan-slice-prompt.test.ts +1 -0
- package/dist/resources/extensions/gsd/tests/token-profile.test.ts +14 -16
- package/dist/resources/extensions/gsd/tests/workflow-templates.test.ts +173 -0
- package/dist/resources/extensions/gsd/triage-resolution.ts +2 -1
- package/dist/resources/extensions/gsd/types.ts +2 -0
- package/dist/resources/extensions/gsd/workflow-templates/bugfix.md +87 -0
- package/dist/resources/extensions/gsd/workflow-templates/dep-upgrade.md +74 -0
- package/dist/resources/extensions/gsd/workflow-templates/full-project.md +41 -0
- package/dist/resources/extensions/gsd/workflow-templates/hotfix.md +45 -0
- package/dist/resources/extensions/gsd/workflow-templates/refactor.md +83 -0
- package/dist/resources/extensions/gsd/workflow-templates/registry.json +85 -0
- package/dist/resources/extensions/gsd/workflow-templates/security-audit.md +73 -0
- package/dist/resources/extensions/gsd/workflow-templates/small-feature.md +81 -0
- package/dist/resources/extensions/gsd/workflow-templates/spike.md +69 -0
- package/dist/resources/extensions/gsd/workflow-templates.ts +241 -0
- package/dist/resources/extensions/gsd/worktree-command.ts +1 -11
- package/dist/resources/extensions/gsd/worktree-manager.ts +3 -2
- package/dist/resources/extensions/gsd/worktree.ts +42 -5
- package/dist/resources/extensions/mcp-client/index.ts +459 -0
- package/dist/resources/skills/create-gsd-extension/SKILL.md +87 -0
- package/dist/resources/skills/create-gsd-extension/references/compaction-session-control.md +77 -0
- package/dist/resources/skills/create-gsd-extension/references/custom-commands.md +139 -0
- package/dist/resources/skills/create-gsd-extension/references/custom-rendering.md +108 -0
- package/dist/resources/skills/create-gsd-extension/references/custom-tools.md +183 -0
- package/dist/resources/skills/create-gsd-extension/references/custom-ui.md +490 -0
- package/dist/resources/skills/create-gsd-extension/references/events-reference.md +126 -0
- package/dist/resources/skills/create-gsd-extension/references/extension-lifecycle.md +64 -0
- package/dist/resources/skills/create-gsd-extension/references/extensionapi-reference.md +75 -0
- package/dist/resources/skills/create-gsd-extension/references/extensioncontext-reference.md +53 -0
- package/dist/resources/skills/create-gsd-extension/references/key-rules-gotchas.md +36 -0
- package/dist/resources/skills/create-gsd-extension/references/mode-behavior.md +32 -0
- package/dist/resources/skills/create-gsd-extension/references/model-provider-management.md +89 -0
- package/dist/resources/skills/create-gsd-extension/references/packaging-distribution.md +55 -0
- package/dist/resources/skills/create-gsd-extension/references/remote-execution-overrides.md +90 -0
- package/dist/resources/skills/create-gsd-extension/references/state-management.md +70 -0
- package/dist/resources/skills/create-gsd-extension/references/system-prompt-modification.md +52 -0
- package/dist/resources/skills/create-gsd-extension/templates/extension-skeleton.ts +51 -0
- package/dist/resources/skills/create-gsd-extension/templates/stateful-tool-skeleton.ts +143 -0
- package/dist/resources/skills/create-gsd-extension/workflows/add-capability.md +57 -0
- package/dist/resources/skills/create-gsd-extension/workflows/create-extension.md +156 -0
- package/dist/resources/skills/create-gsd-extension/workflows/debug-extension.md +74 -0
- package/dist/resources/skills/create-skill/SKILL.md +184 -0
- package/dist/resources/skills/create-skill/references/api-security.md +226 -0
- package/dist/resources/skills/create-skill/references/be-clear-and-direct.md +531 -0
- package/dist/resources/skills/create-skill/references/common-patterns.md +595 -0
- package/dist/resources/skills/create-skill/references/core-principles.md +437 -0
- package/dist/resources/skills/create-skill/references/executable-code.md +175 -0
- package/dist/resources/skills/create-skill/references/gsd-skill-ecosystem.md +68 -0
- package/dist/resources/skills/create-skill/references/iteration-and-testing.md +474 -0
- package/dist/resources/skills/create-skill/references/recommended-structure.md +168 -0
- package/dist/resources/skills/create-skill/references/skill-structure.md +372 -0
- package/dist/resources/skills/create-skill/references/use-xml-tags.md +466 -0
- package/dist/resources/skills/create-skill/references/using-scripts.md +113 -0
- package/dist/resources/skills/create-skill/references/using-templates.md +112 -0
- package/dist/resources/skills/create-skill/references/workflows-and-validation.md +510 -0
- package/dist/resources/skills/create-skill/templates/router-skill.md +73 -0
- package/dist/resources/skills/create-skill/templates/simple-skill.md +33 -0
- package/dist/resources/skills/create-skill/workflows/add-reference.md +96 -0
- package/dist/resources/skills/create-skill/workflows/add-script.md +93 -0
- package/dist/resources/skills/create-skill/workflows/add-template.md +74 -0
- package/dist/resources/skills/create-skill/workflows/add-workflow.md +120 -0
- package/dist/resources/skills/create-skill/workflows/audit-skill.md +148 -0
- package/dist/resources/skills/create-skill/workflows/create-new-skill.md +196 -0
- package/dist/resources/skills/create-skill/workflows/get-guidance.md +121 -0
- package/dist/resources/skills/create-skill/workflows/upgrade-to-router.md +161 -0
- package/dist/resources/skills/create-skill/workflows/verify-skill.md +204 -0
- package/dist/resources/skills/react-best-practices/SKILL.md +1 -1
- package/package.json +1 -1
- package/packages/native/dist/native.d.ts +2 -0
- package/packages/native/dist/native.js +19 -5
- package/packages/native/src/native.ts +23 -9
- package/packages/pi-coding-agent/dist/core/extensions/loader.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/loader.js +13 -0
- package/packages/pi-coding-agent/dist/core/extensions/loader.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/client.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/client.js +3 -0
- package/packages/pi-coding-agent/dist/core/lsp/client.js.map +1 -1
- package/packages/pi-coding-agent/src/core/extensions/loader.ts +13 -0
- package/packages/pi-coding-agent/src/core/lsp/client.ts +3 -0
- package/src/resources/extensions/bg-shell/process-manager.ts +13 -0
- package/src/resources/extensions/gsd/auto-dashboard.ts +217 -65
- package/src/resources/extensions/gsd/auto-dispatch.ts +32 -3
- package/src/resources/extensions/gsd/auto-post-unit.ts +44 -12
- package/src/resources/extensions/gsd/auto-prompts.ts +40 -17
- package/src/resources/extensions/gsd/auto-recovery.ts +2 -1
- package/src/resources/extensions/gsd/auto-start.ts +18 -32
- package/src/resources/extensions/gsd/auto-worktree.ts +21 -182
- package/src/resources/extensions/gsd/auto.ts +2 -9
- package/src/resources/extensions/gsd/captures.ts +4 -10
- package/src/resources/extensions/gsd/commands-handlers.ts +2 -1
- package/src/resources/extensions/gsd/commands-prefs-wizard.ts +44 -14
- package/src/resources/extensions/gsd/commands-workflow-templates.ts +544 -0
- package/src/resources/extensions/gsd/commands.ts +55 -2
- package/src/resources/extensions/gsd/detection.ts +2 -1
- package/src/resources/extensions/gsd/doctor-checks.ts +49 -1
- package/src/resources/extensions/gsd/doctor-types.ts +3 -1
- package/src/resources/extensions/gsd/forensics.ts +2 -2
- package/src/resources/extensions/gsd/git-service.ts +3 -2
- package/src/resources/extensions/gsd/gitignore.ts +9 -63
- package/src/resources/extensions/gsd/gsd-db.ts +1 -165
- package/src/resources/extensions/gsd/guided-flow.ts +8 -5
- package/src/resources/extensions/gsd/index.ts +3 -3
- package/src/resources/extensions/gsd/md-importer.ts +3 -2
- package/src/resources/extensions/gsd/mechanical-completion.ts +430 -0
- package/src/resources/extensions/gsd/migrate/command.ts +3 -2
- package/src/resources/extensions/gsd/migrate/writer.ts +2 -1
- package/src/resources/extensions/gsd/migrate-external.ts +123 -0
- package/src/resources/extensions/gsd/paths.ts +24 -2
- package/src/resources/extensions/gsd/post-unit-hooks.ts +6 -5
- package/src/resources/extensions/gsd/preferences-models.ts +7 -1
- package/src/resources/extensions/gsd/preferences-validation.ts +2 -1
- package/src/resources/extensions/gsd/preferences.ts +10 -5
- package/src/resources/extensions/gsd/prompts/discuss-headless.md +4 -2
- package/src/resources/extensions/gsd/prompts/guided-discuss-milestone.md +1 -1
- package/src/resources/extensions/gsd/prompts/plan-milestone.md +26 -2
- package/src/resources/extensions/gsd/prompts/plan-slice.md +15 -1
- package/src/resources/extensions/gsd/prompts/workflow-start.md +28 -0
- package/src/resources/extensions/gsd/repo-identity.ts +148 -0
- package/src/resources/extensions/gsd/resource-version.ts +99 -0
- package/src/resources/extensions/gsd/session-forensics.ts +4 -3
- package/src/resources/extensions/gsd/tests/activity-log.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +3 -3
- package/src/resources/extensions/gsd/tests/auto-worktree.test.ts +0 -58
- package/src/resources/extensions/gsd/tests/doctor-runtime.test.ts +3 -4
- package/src/resources/extensions/gsd/tests/extension-selector-separator.test.ts +60 -38
- package/src/resources/extensions/gsd/tests/feature-branch-lifecycle-integration.test.ts +5 -18
- package/src/resources/extensions/gsd/tests/git-service.test.ts +10 -37
- package/src/resources/extensions/gsd/tests/knowledge.test.ts +4 -4
- package/src/resources/extensions/gsd/tests/mechanical-completion.test.ts +356 -0
- package/src/resources/extensions/gsd/tests/plan-slice-prompt.test.ts +1 -0
- package/src/resources/extensions/gsd/tests/token-profile.test.ts +14 -16
- package/src/resources/extensions/gsd/tests/workflow-templates.test.ts +173 -0
- package/src/resources/extensions/gsd/triage-resolution.ts +2 -1
- package/src/resources/extensions/gsd/types.ts +2 -0
- package/src/resources/extensions/gsd/workflow-templates/bugfix.md +87 -0
- package/src/resources/extensions/gsd/workflow-templates/dep-upgrade.md +74 -0
- package/src/resources/extensions/gsd/workflow-templates/full-project.md +41 -0
- package/src/resources/extensions/gsd/workflow-templates/hotfix.md +45 -0
- package/src/resources/extensions/gsd/workflow-templates/refactor.md +83 -0
- package/src/resources/extensions/gsd/workflow-templates/registry.json +85 -0
- package/src/resources/extensions/gsd/workflow-templates/security-audit.md +73 -0
- package/src/resources/extensions/gsd/workflow-templates/small-feature.md +81 -0
- package/src/resources/extensions/gsd/workflow-templates/spike.md +69 -0
- package/src/resources/extensions/gsd/workflow-templates.ts +241 -0
- package/src/resources/extensions/gsd/worktree-command.ts +1 -11
- package/src/resources/extensions/gsd/worktree-manager.ts +3 -2
- package/src/resources/extensions/gsd/worktree.ts +42 -5
- package/src/resources/extensions/mcp-client/index.ts +459 -0
- package/src/resources/skills/create-gsd-extension/SKILL.md +87 -0
- package/src/resources/skills/create-gsd-extension/references/compaction-session-control.md +77 -0
- package/src/resources/skills/create-gsd-extension/references/custom-commands.md +139 -0
- package/src/resources/skills/create-gsd-extension/references/custom-rendering.md +108 -0
- package/src/resources/skills/create-gsd-extension/references/custom-tools.md +183 -0
- package/src/resources/skills/create-gsd-extension/references/custom-ui.md +490 -0
- package/src/resources/skills/create-gsd-extension/references/events-reference.md +126 -0
- package/src/resources/skills/create-gsd-extension/references/extension-lifecycle.md +64 -0
- package/src/resources/skills/create-gsd-extension/references/extensionapi-reference.md +75 -0
- package/src/resources/skills/create-gsd-extension/references/extensioncontext-reference.md +53 -0
- package/src/resources/skills/create-gsd-extension/references/key-rules-gotchas.md +36 -0
- package/src/resources/skills/create-gsd-extension/references/mode-behavior.md +32 -0
- package/src/resources/skills/create-gsd-extension/references/model-provider-management.md +89 -0
- package/src/resources/skills/create-gsd-extension/references/packaging-distribution.md +55 -0
- package/src/resources/skills/create-gsd-extension/references/remote-execution-overrides.md +90 -0
- package/src/resources/skills/create-gsd-extension/references/state-management.md +70 -0
- package/src/resources/skills/create-gsd-extension/references/system-prompt-modification.md +52 -0
- package/src/resources/skills/create-gsd-extension/templates/extension-skeleton.ts +51 -0
- package/src/resources/skills/create-gsd-extension/templates/stateful-tool-skeleton.ts +143 -0
- package/src/resources/skills/create-gsd-extension/workflows/add-capability.md +57 -0
- package/src/resources/skills/create-gsd-extension/workflows/create-extension.md +156 -0
- package/src/resources/skills/create-gsd-extension/workflows/debug-extension.md +74 -0
- package/src/resources/skills/create-skill/SKILL.md +184 -0
- package/src/resources/skills/create-skill/references/api-security.md +226 -0
- package/src/resources/skills/create-skill/references/be-clear-and-direct.md +531 -0
- package/src/resources/skills/create-skill/references/common-patterns.md +595 -0
- package/src/resources/skills/create-skill/references/core-principles.md +437 -0
- package/src/resources/skills/create-skill/references/executable-code.md +175 -0
- package/src/resources/skills/create-skill/references/gsd-skill-ecosystem.md +68 -0
- package/src/resources/skills/create-skill/references/iteration-and-testing.md +474 -0
- package/src/resources/skills/create-skill/references/recommended-structure.md +168 -0
- package/src/resources/skills/create-skill/references/skill-structure.md +372 -0
- package/src/resources/skills/create-skill/references/use-xml-tags.md +466 -0
- package/src/resources/skills/create-skill/references/using-scripts.md +113 -0
- package/src/resources/skills/create-skill/references/using-templates.md +112 -0
- package/src/resources/skills/create-skill/references/workflows-and-validation.md +510 -0
- package/src/resources/skills/create-skill/templates/router-skill.md +73 -0
- package/src/resources/skills/create-skill/templates/simple-skill.md +33 -0
- package/src/resources/skills/create-skill/workflows/add-reference.md +96 -0
- package/src/resources/skills/create-skill/workflows/add-script.md +93 -0
- package/src/resources/skills/create-skill/workflows/add-template.md +74 -0
- package/src/resources/skills/create-skill/workflows/add-workflow.md +120 -0
- package/src/resources/skills/create-skill/workflows/audit-skill.md +148 -0
- package/src/resources/skills/create-skill/workflows/create-new-skill.md +196 -0
- package/src/resources/skills/create-skill/workflows/get-guidance.md +121 -0
- package/src/resources/skills/create-skill/workflows/upgrade-to-router.md +161 -0
- package/src/resources/skills/create-skill/workflows/verify-skill.md +204 -0
- package/src/resources/skills/react-best-practices/SKILL.md +1 -1
- package/dist/resources/extensions/gsd/auto-worktree-sync.ts +0 -199
- package/dist/resources/extensions/gsd/tests/worktree-db-integration.test.ts +0 -205
- package/dist/resources/extensions/gsd/tests/worktree-db.test.ts +0 -442
- package/dist/resources/extensions/mcporter/index.ts +0 -525
- package/src/resources/extensions/gsd/auto-worktree-sync.ts +0 -199
- package/src/resources/extensions/gsd/tests/worktree-db-integration.test.ts +0 -205
- package/src/resources/extensions/gsd/tests/worktree-db.test.ts +0 -442
- package/src/resources/extensions/mcporter/index.ts +0 -525
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Workflow: Get Guidance on Skill Design
|
|
2
|
+
|
|
3
|
+
<required_reading>
|
|
4
|
+
**Read these reference files NOW:**
|
|
5
|
+
1. references/core-principles.md
|
|
6
|
+
2. references/recommended-structure.md
|
|
7
|
+
</required_reading>
|
|
8
|
+
|
|
9
|
+
<process>
|
|
10
|
+
## Step 1: Understand the Problem Space
|
|
11
|
+
|
|
12
|
+
Ask the user:
|
|
13
|
+
- What task or domain are you trying to support?
|
|
14
|
+
- Is this something you do repeatedly?
|
|
15
|
+
- What makes it complex enough to need a skill?
|
|
16
|
+
|
|
17
|
+
## Step 2: Determine If a Skill Is Right
|
|
18
|
+
|
|
19
|
+
**Create a skill when:**
|
|
20
|
+
- Task is repeated across multiple sessions
|
|
21
|
+
- Domain knowledge doesn't change frequently
|
|
22
|
+
- Complex enough to benefit from structure
|
|
23
|
+
- Would save significant time if automated
|
|
24
|
+
|
|
25
|
+
**Don't create a skill when:**
|
|
26
|
+
- One-off task (just do it directly)
|
|
27
|
+
- Changes constantly (will be outdated quickly)
|
|
28
|
+
- Too simple (overhead isn't worth it)
|
|
29
|
+
- Better as a slash command (user-triggered, no context needed)
|
|
30
|
+
|
|
31
|
+
Share this assessment with user.
|
|
32
|
+
|
|
33
|
+
## Step 3: Map the Workflows
|
|
34
|
+
|
|
35
|
+
Ask: "What are the different things someone might want to do with this skill?"
|
|
36
|
+
|
|
37
|
+
Common patterns:
|
|
38
|
+
- Create / Read / Update / Delete
|
|
39
|
+
- Build / Debug / Ship
|
|
40
|
+
- Setup / Use / Troubleshoot
|
|
41
|
+
- Import / Process / Export
|
|
42
|
+
|
|
43
|
+
Each distinct workflow = potential workflow file.
|
|
44
|
+
|
|
45
|
+
## Step 4: Identify Domain Knowledge
|
|
46
|
+
|
|
47
|
+
Ask: "What knowledge is needed regardless of which workflow?"
|
|
48
|
+
|
|
49
|
+
This becomes references:
|
|
50
|
+
- API patterns
|
|
51
|
+
- Best practices
|
|
52
|
+
- Common examples
|
|
53
|
+
- Configuration details
|
|
54
|
+
|
|
55
|
+
## Step 5: Draft the Structure
|
|
56
|
+
|
|
57
|
+
Based on answers, recommend structure:
|
|
58
|
+
|
|
59
|
+
**If 1 workflow, simple knowledge:**
|
|
60
|
+
```
|
|
61
|
+
skill-name/
|
|
62
|
+
└── SKILL.md (everything in one file)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**If 2+ workflows, shared knowledge:**
|
|
66
|
+
```
|
|
67
|
+
skill-name/
|
|
68
|
+
├── SKILL.md (router)
|
|
69
|
+
├── workflows/
|
|
70
|
+
│ ├── workflow-a.md
|
|
71
|
+
│ └── workflow-b.md
|
|
72
|
+
└── references/
|
|
73
|
+
└── shared-knowledge.md
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Step 6: Identify Essential Principles
|
|
77
|
+
|
|
78
|
+
Ask: "What rules should ALWAYS apply, no matter which workflow?"
|
|
79
|
+
|
|
80
|
+
These become `<essential_principles>` in SKILL.md.
|
|
81
|
+
|
|
82
|
+
Examples:
|
|
83
|
+
- "Always verify before reporting success"
|
|
84
|
+
- "Never store credentials in code"
|
|
85
|
+
- "Ask before making destructive changes"
|
|
86
|
+
|
|
87
|
+
## Step 7: Present Recommendation
|
|
88
|
+
|
|
89
|
+
Summarize:
|
|
90
|
+
- Recommended structure (simple vs router pattern)
|
|
91
|
+
- List of workflows
|
|
92
|
+
- List of references
|
|
93
|
+
- Essential principles
|
|
94
|
+
|
|
95
|
+
Ask: "Does this structure make sense? Ready to build it?"
|
|
96
|
+
|
|
97
|
+
If yes → offer to switch to "Create a new skill" workflow
|
|
98
|
+
If no → clarify and iterate
|
|
99
|
+
</process>
|
|
100
|
+
|
|
101
|
+
<decision_framework>
|
|
102
|
+
## Quick Decision Framework
|
|
103
|
+
|
|
104
|
+
| Situation | Recommendation |
|
|
105
|
+
|-----------|----------------|
|
|
106
|
+
| Single task, repeat often | Simple skill |
|
|
107
|
+
| Multiple related tasks | Router + workflows |
|
|
108
|
+
| Complex domain, many patterns | Router + workflows + references |
|
|
109
|
+
| User-triggered, fresh context | Slash command, not skill |
|
|
110
|
+
| One-off task | No skill needed |
|
|
111
|
+
</decision_framework>
|
|
112
|
+
|
|
113
|
+
<success_criteria>
|
|
114
|
+
Guidance is complete when:
|
|
115
|
+
- [ ] User understands if they need a skill
|
|
116
|
+
- [ ] Structure is recommended and explained
|
|
117
|
+
- [ ] Workflows are identified
|
|
118
|
+
- [ ] References are identified
|
|
119
|
+
- [ ] Essential principles are identified
|
|
120
|
+
- [ ] User is ready to build (or decided not to)
|
|
121
|
+
</success_criteria>
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# Workflow: Upgrade Skill to Router Pattern
|
|
2
|
+
|
|
3
|
+
<required_reading>
|
|
4
|
+
**Read these reference files NOW:**
|
|
5
|
+
1. references/recommended-structure.md
|
|
6
|
+
2. references/skill-structure.md
|
|
7
|
+
</required_reading>
|
|
8
|
+
|
|
9
|
+
<process>
|
|
10
|
+
## Step 1: Select the Skill
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
ls ~/.claude/skills/
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Present numbered list, ask: "Which skill should be upgraded to the router pattern?"
|
|
17
|
+
|
|
18
|
+
## Step 2: Verify It Needs Upgrading
|
|
19
|
+
|
|
20
|
+
Read the skill:
|
|
21
|
+
```bash
|
|
22
|
+
cat ~/.claude/skills/{skill-name}/SKILL.md
|
|
23
|
+
ls ~/.claude/skills/{skill-name}/
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Already a router?** (has workflows/ and intake question)
|
|
27
|
+
→ Tell user it's already using router pattern, offer to add workflows instead
|
|
28
|
+
|
|
29
|
+
**Simple skill that should stay simple?** (under 200 lines, single workflow)
|
|
30
|
+
→ Explain that router pattern may be overkill, ask if they want to proceed anyway
|
|
31
|
+
|
|
32
|
+
**Good candidate for upgrade:**
|
|
33
|
+
- Over 200 lines
|
|
34
|
+
- Multiple distinct use cases
|
|
35
|
+
- Essential principles that shouldn't be skipped
|
|
36
|
+
- Growing complexity
|
|
37
|
+
|
|
38
|
+
## Step 3: Identify Components
|
|
39
|
+
|
|
40
|
+
Analyze the current skill and identify:
|
|
41
|
+
|
|
42
|
+
1. **Essential principles** - Rules that apply to ALL use cases
|
|
43
|
+
2. **Distinct workflows** - Different things a user might want to do
|
|
44
|
+
3. **Reusable knowledge** - Patterns, examples, technical details
|
|
45
|
+
|
|
46
|
+
Present findings:
|
|
47
|
+
```
|
|
48
|
+
## Analysis
|
|
49
|
+
|
|
50
|
+
**Essential principles I found:**
|
|
51
|
+
- [Principle 1]
|
|
52
|
+
- [Principle 2]
|
|
53
|
+
|
|
54
|
+
**Distinct workflows I identified:**
|
|
55
|
+
- [Workflow A]: [description]
|
|
56
|
+
- [Workflow B]: [description]
|
|
57
|
+
|
|
58
|
+
**Knowledge that could be references:**
|
|
59
|
+
- [Reference topic 1]
|
|
60
|
+
- [Reference topic 2]
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Ask: "Does this breakdown look right? Any adjustments?"
|
|
64
|
+
|
|
65
|
+
## Step 4: Create Directory Structure
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
mkdir -p ~/.claude/skills/{skill-name}/workflows
|
|
69
|
+
mkdir -p ~/.claude/skills/{skill-name}/references
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Step 5: Extract Workflows
|
|
73
|
+
|
|
74
|
+
For each identified workflow:
|
|
75
|
+
|
|
76
|
+
1. Create `workflows/{workflow-name}.md`
|
|
77
|
+
2. Add required_reading section (references it needs)
|
|
78
|
+
3. Add process section (steps from original skill)
|
|
79
|
+
4. Add success_criteria section
|
|
80
|
+
|
|
81
|
+
## Step 6: Extract References
|
|
82
|
+
|
|
83
|
+
For each identified reference topic:
|
|
84
|
+
|
|
85
|
+
1. Create `references/{reference-name}.md`
|
|
86
|
+
2. Move relevant content from original skill
|
|
87
|
+
3. Structure with semantic XML tags
|
|
88
|
+
|
|
89
|
+
## Step 7: Rewrite SKILL.md as Router
|
|
90
|
+
|
|
91
|
+
Replace SKILL.md with router structure:
|
|
92
|
+
|
|
93
|
+
```markdown
|
|
94
|
+
---
|
|
95
|
+
name: {skill-name}
|
|
96
|
+
description: {existing description}
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
<essential_principles>
|
|
100
|
+
[Extracted principles - inline, cannot be skipped]
|
|
101
|
+
</essential_principles>
|
|
102
|
+
|
|
103
|
+
<intake>
|
|
104
|
+
**Ask the user:**
|
|
105
|
+
|
|
106
|
+
What would you like to do?
|
|
107
|
+
1. [Workflow A option]
|
|
108
|
+
2. [Workflow B option]
|
|
109
|
+
...
|
|
110
|
+
|
|
111
|
+
**Wait for response before proceeding.**
|
|
112
|
+
</intake>
|
|
113
|
+
|
|
114
|
+
<routing>
|
|
115
|
+
| Response | Workflow |
|
|
116
|
+
|----------|----------|
|
|
117
|
+
| 1, "keywords" | `workflows/workflow-a.md` |
|
|
118
|
+
| 2, "keywords" | `workflows/workflow-b.md` |
|
|
119
|
+
</routing>
|
|
120
|
+
|
|
121
|
+
<reference_index>
|
|
122
|
+
[List all references by category]
|
|
123
|
+
</reference_index>
|
|
124
|
+
|
|
125
|
+
<workflows_index>
|
|
126
|
+
| Workflow | Purpose |
|
|
127
|
+
|----------|---------|
|
|
128
|
+
| workflow-a.md | [What it does] |
|
|
129
|
+
| workflow-b.md | [What it does] |
|
|
130
|
+
</workflows_index>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Step 8: Verify Nothing Was Lost
|
|
134
|
+
|
|
135
|
+
Compare original skill content against new structure:
|
|
136
|
+
- [ ] All principles preserved (now inline)
|
|
137
|
+
- [ ] All procedures preserved (now in workflows)
|
|
138
|
+
- [ ] All knowledge preserved (now in references)
|
|
139
|
+
- [ ] No orphaned content
|
|
140
|
+
|
|
141
|
+
## Step 9: Test
|
|
142
|
+
|
|
143
|
+
Invoke the upgraded skill:
|
|
144
|
+
- Does intake question appear?
|
|
145
|
+
- Does each routing option work?
|
|
146
|
+
- Do workflows load correct references?
|
|
147
|
+
- Does behavior match original skill?
|
|
148
|
+
|
|
149
|
+
Report any issues.
|
|
150
|
+
</process>
|
|
151
|
+
|
|
152
|
+
<success_criteria>
|
|
153
|
+
Upgrade is complete when:
|
|
154
|
+
- [ ] workflows/ directory created with workflow files
|
|
155
|
+
- [ ] references/ directory created (if needed)
|
|
156
|
+
- [ ] SKILL.md rewritten as router
|
|
157
|
+
- [ ] Essential principles inline in SKILL.md
|
|
158
|
+
- [ ] All original content preserved
|
|
159
|
+
- [ ] Intake question routes correctly
|
|
160
|
+
- [ ] Tested and working
|
|
161
|
+
</success_criteria>
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# Workflow: Verify Skill Content Accuracy
|
|
2
|
+
|
|
3
|
+
<required_reading>
|
|
4
|
+
**Read these reference files NOW:**
|
|
5
|
+
1. references/skill-structure.md
|
|
6
|
+
</required_reading>
|
|
7
|
+
|
|
8
|
+
<purpose>
|
|
9
|
+
Audit checks structure. **Verify checks truth.**
|
|
10
|
+
|
|
11
|
+
Skills contain claims about external things: APIs, CLI tools, frameworks, services. These change over time. This workflow checks if a skill's content is still accurate.
|
|
12
|
+
</purpose>
|
|
13
|
+
|
|
14
|
+
<process>
|
|
15
|
+
## Step 1: Select the Skill
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
ls ~/.claude/skills/
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Present numbered list, ask: "Which skill should I verify for accuracy?"
|
|
22
|
+
|
|
23
|
+
## Step 2: Read and Categorize
|
|
24
|
+
|
|
25
|
+
Read the entire skill (SKILL.md + workflows/ + references/):
|
|
26
|
+
```bash
|
|
27
|
+
cat ~/.claude/skills/{skill-name}/SKILL.md
|
|
28
|
+
cat ~/.claude/skills/{skill-name}/workflows/*.md 2>/dev/null
|
|
29
|
+
cat ~/.claude/skills/{skill-name}/references/*.md 2>/dev/null
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Categorize by primary dependency type:
|
|
33
|
+
|
|
34
|
+
| Type | Examples | Verification Method |
|
|
35
|
+
|------|----------|---------------------|
|
|
36
|
+
| **API/Service** | manage-stripe, manage-gohighlevel | Context7 + WebSearch |
|
|
37
|
+
| **CLI Tools** | build-macos-apps (xcodebuild, swift) | Run commands |
|
|
38
|
+
| **Framework** | build-iphone-apps (SwiftUI, UIKit) | Context7 for docs |
|
|
39
|
+
| **Integration** | setup-stripe-payments | WebFetch + Context7 |
|
|
40
|
+
| **Pure Process** | create-agent-skills | No external deps |
|
|
41
|
+
|
|
42
|
+
Report: "This skill is primarily [type]-based. I'll verify using [method]."
|
|
43
|
+
|
|
44
|
+
## Step 3: Extract Verifiable Claims
|
|
45
|
+
|
|
46
|
+
Scan skill content and extract:
|
|
47
|
+
|
|
48
|
+
**CLI Tools mentioned:**
|
|
49
|
+
- Tool names (xcodebuild, swift, npm, etc.)
|
|
50
|
+
- Specific flags/options documented
|
|
51
|
+
- Expected output patterns
|
|
52
|
+
|
|
53
|
+
**API Endpoints:**
|
|
54
|
+
- Service names (Stripe, Meta, etc.)
|
|
55
|
+
- Specific endpoints documented
|
|
56
|
+
- Authentication methods
|
|
57
|
+
- SDK versions
|
|
58
|
+
|
|
59
|
+
**Framework Patterns:**
|
|
60
|
+
- Framework names (SwiftUI, React, etc.)
|
|
61
|
+
- Specific APIs/patterns documented
|
|
62
|
+
- Version-specific features
|
|
63
|
+
|
|
64
|
+
**File Paths/Structures:**
|
|
65
|
+
- Expected project structures
|
|
66
|
+
- Config file locations
|
|
67
|
+
|
|
68
|
+
Present: "Found X verifiable claims to check."
|
|
69
|
+
|
|
70
|
+
## Step 4: Verify by Type
|
|
71
|
+
|
|
72
|
+
### For CLI Tools
|
|
73
|
+
```bash
|
|
74
|
+
# Check tool exists
|
|
75
|
+
which {tool-name}
|
|
76
|
+
|
|
77
|
+
# Check version
|
|
78
|
+
{tool-name} --version
|
|
79
|
+
|
|
80
|
+
# Verify documented flags work
|
|
81
|
+
{tool-name} --help | grep "{documented-flag}"
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### For API/Service Skills
|
|
85
|
+
Use Context7 to fetch current documentation:
|
|
86
|
+
```
|
|
87
|
+
mcp__context7__resolve-library-id: {service-name}
|
|
88
|
+
mcp__context7__get-library-docs: {library-id}, topic: {relevant-topic}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Compare skill's documented patterns against current docs:
|
|
92
|
+
- Are endpoints still valid?
|
|
93
|
+
- Has authentication changed?
|
|
94
|
+
- Are there deprecated methods being used?
|
|
95
|
+
|
|
96
|
+
### For Framework Skills
|
|
97
|
+
Use Context7:
|
|
98
|
+
```
|
|
99
|
+
mcp__context7__resolve-library-id: {framework-name}
|
|
100
|
+
mcp__context7__get-library-docs: {library-id}, topic: {specific-api}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Check:
|
|
104
|
+
- Are documented APIs still current?
|
|
105
|
+
- Have patterns changed?
|
|
106
|
+
- Are there newer recommended approaches?
|
|
107
|
+
|
|
108
|
+
### For Integration Skills
|
|
109
|
+
WebSearch for recent changes:
|
|
110
|
+
```
|
|
111
|
+
"[service name] API changes 2025"
|
|
112
|
+
"[service name] breaking changes"
|
|
113
|
+
"[service name] deprecated endpoints"
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Then Context7 for current SDK patterns.
|
|
117
|
+
|
|
118
|
+
### For Services with Status Pages
|
|
119
|
+
WebFetch official docs/changelog if available.
|
|
120
|
+
|
|
121
|
+
## Step 5: Generate Freshness Report
|
|
122
|
+
|
|
123
|
+
Present findings:
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
## Verification Report: {skill-name}
|
|
127
|
+
|
|
128
|
+
### ✅ Verified Current
|
|
129
|
+
- [Claim]: [Evidence it's still accurate]
|
|
130
|
+
|
|
131
|
+
### ⚠️ May Be Outdated
|
|
132
|
+
- [Claim]: [What changed / newer info found]
|
|
133
|
+
→ Current: [what docs now say]
|
|
134
|
+
|
|
135
|
+
### ❌ Broken / Invalid
|
|
136
|
+
- [Claim]: [Why it's wrong]
|
|
137
|
+
→ Fix: [What it should be]
|
|
138
|
+
|
|
139
|
+
### ℹ️ Could Not Verify
|
|
140
|
+
- [Claim]: [Why verification wasn't possible]
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
**Overall Status:** [Fresh / Needs Updates / Significantly Stale]
|
|
144
|
+
**Last Verified:** [Today's date]
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Step 6: Offer Updates
|
|
148
|
+
|
|
149
|
+
If issues found:
|
|
150
|
+
|
|
151
|
+
"Found [N] items that need updating. Would you like me to:"
|
|
152
|
+
|
|
153
|
+
1. **Update all** - Apply all corrections
|
|
154
|
+
2. **Review each** - Show each change before applying
|
|
155
|
+
3. **Just the report** - No changes
|
|
156
|
+
|
|
157
|
+
If updating:
|
|
158
|
+
- Make changes based on verified current information
|
|
159
|
+
- Add verification date comment if appropriate
|
|
160
|
+
- Report what was updated
|
|
161
|
+
|
|
162
|
+
## Step 7: Suggest Verification Schedule
|
|
163
|
+
|
|
164
|
+
Based on skill type, recommend:
|
|
165
|
+
|
|
166
|
+
| Skill Type | Recommended Frequency |
|
|
167
|
+
|------------|----------------------|
|
|
168
|
+
| API/Service | Every 1-2 months |
|
|
169
|
+
| Framework | Every 3-6 months |
|
|
170
|
+
| CLI Tools | Every 6 months |
|
|
171
|
+
| Pure Process | Annually |
|
|
172
|
+
|
|
173
|
+
"This skill should be re-verified in approximately [timeframe]."
|
|
174
|
+
</process>
|
|
175
|
+
|
|
176
|
+
<verification_shortcuts>
|
|
177
|
+
## Quick Verification Commands
|
|
178
|
+
|
|
179
|
+
**Check if CLI tool exists and get version:**
|
|
180
|
+
```bash
|
|
181
|
+
which {tool} && {tool} --version
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**Context7 pattern for any library:**
|
|
185
|
+
```
|
|
186
|
+
1. resolve-library-id: "{library-name}"
|
|
187
|
+
2. get-library-docs: "{id}", topic: "{specific-feature}"
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
**WebSearch patterns:**
|
|
191
|
+
- Breaking changes: "{service} breaking changes 2025"
|
|
192
|
+
- Deprecations: "{service} deprecated API"
|
|
193
|
+
- Current best practices: "{framework} best practices 2025"
|
|
194
|
+
</verification_shortcuts>
|
|
195
|
+
|
|
196
|
+
<success_criteria>
|
|
197
|
+
Verification is complete when:
|
|
198
|
+
- [ ] Skill categorized by dependency type
|
|
199
|
+
- [ ] Verifiable claims extracted
|
|
200
|
+
- [ ] Each claim checked with appropriate method
|
|
201
|
+
- [ ] Freshness report generated
|
|
202
|
+
- [ ] Updates applied (if requested)
|
|
203
|
+
- [ ] User knows when to re-verify
|
|
204
|
+
</success_criteria>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
2
|
+
name: react-best-practices
|
|
3
3
|
description: React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.
|
|
4
4
|
license: MIT
|
|
5
5
|
metadata:
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Worktree ↔ project root state synchronization for auto-mode.
|
|
3
|
-
*
|
|
4
|
-
* When auto-mode runs inside a worktree, dispatch-critical state files
|
|
5
|
-
* (.gsd/ metadata) diverge between the worktree (where work happens)
|
|
6
|
-
* and the project root (where startAutoMode reads initial state on restart).
|
|
7
|
-
* Without syncing, restarting auto-mode reads stale state from the project
|
|
8
|
-
* root and re-dispatches already-completed units.
|
|
9
|
-
*
|
|
10
|
-
* Also contains resource staleness detection and stale worktree escape.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { existsSync, mkdirSync, readFileSync, cpSync, unlinkSync, readdirSync } from "node:fs";
|
|
14
|
-
import { loadJsonFileOrNull } from "./json-persistence.js";
|
|
15
|
-
import { join, sep as pathSep } from "node:path";
|
|
16
|
-
import { homedir } from "node:os";
|
|
17
|
-
import { safeCopy, safeCopyRecursive } from "./safe-fs.js";
|
|
18
|
-
import { atomicWriteSync } from "./atomic-write.js";
|
|
19
|
-
|
|
20
|
-
// ─── Project Root → Worktree Sync ─────────────────────────────────────────
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Sync milestone artifacts from project root INTO worktree before deriveState.
|
|
24
|
-
* Covers the case where the LLM wrote artifacts to the main repo filesystem
|
|
25
|
-
* (e.g. via absolute paths) but the worktree has stale data. Also deletes
|
|
26
|
-
* gsd.db in the worktree so it rebuilds from fresh disk state (#853).
|
|
27
|
-
* Non-fatal — sync failure should never block dispatch.
|
|
28
|
-
*/
|
|
29
|
-
export function syncProjectRootToWorktree(projectRoot: string, worktreePath: string, milestoneId: string | null): void {
|
|
30
|
-
if (!worktreePath || !projectRoot || worktreePath === projectRoot) return;
|
|
31
|
-
if (!milestoneId) return;
|
|
32
|
-
|
|
33
|
-
const prGsd = join(projectRoot, ".gsd");
|
|
34
|
-
const wtGsd = join(worktreePath, ".gsd");
|
|
35
|
-
|
|
36
|
-
// Copy milestone directory from project root to worktree if the project root
|
|
37
|
-
// has newer artifacts (e.g. slices that don't exist in the worktree yet)
|
|
38
|
-
safeCopyRecursive(join(prGsd, "milestones", milestoneId), join(wtGsd, "milestones", milestoneId))
|
|
39
|
-
|
|
40
|
-
// Copy living documents from project root to worktree so agents have the
|
|
41
|
-
// latest decisions, requirements, project state, and knowledge.
|
|
42
|
-
for (const doc of ["DECISIONS.md", "REQUIREMENTS.md", "PROJECT.md", "KNOWLEDGE.md"]) {
|
|
43
|
-
safeCopy(join(prGsd, doc), join(wtGsd, doc), { force: true });
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Delete worktree gsd.db so it rebuilds from the freshly synced files.
|
|
47
|
-
// Stale DB rows are the root cause of the infinite skip loop (#853).
|
|
48
|
-
try {
|
|
49
|
-
const wtDb = join(wtGsd, "gsd.db");
|
|
50
|
-
if (existsSync(wtDb)) {
|
|
51
|
-
unlinkSync(wtDb);
|
|
52
|
-
}
|
|
53
|
-
} catch { /* non-fatal */ }
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// ─── Worktree → Project Root Sync ─────────────────────────────────────────
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Sync dispatch-critical .gsd/ state files from worktree to project root.
|
|
60
|
-
* Only runs when inside an auto-worktree (worktreePath differs from projectRoot).
|
|
61
|
-
* Copies: STATE.md + active milestone directory (roadmap, slice plans, task summaries).
|
|
62
|
-
* Non-fatal — sync failure should never block dispatch.
|
|
63
|
-
*/
|
|
64
|
-
export function syncStateToProjectRoot(worktreePath: string, projectRoot: string, milestoneId: string | null): void {
|
|
65
|
-
if (!worktreePath || !projectRoot || worktreePath === projectRoot) return;
|
|
66
|
-
if (!milestoneId) return;
|
|
67
|
-
|
|
68
|
-
const wtGsd = join(worktreePath, ".gsd");
|
|
69
|
-
const prGsd = join(projectRoot, ".gsd");
|
|
70
|
-
|
|
71
|
-
// 1. STATE.md — the quick-glance status used by initial deriveState()
|
|
72
|
-
safeCopy(join(wtGsd, "STATE.md"), join(prGsd, "STATE.md"), { force: true })
|
|
73
|
-
|
|
74
|
-
// 2. Milestone directory — ROADMAP, slice PLANs, task summaries
|
|
75
|
-
// Copy the entire milestone .gsd subtree so deriveState reads current checkboxes
|
|
76
|
-
safeCopyRecursive(join(wtGsd, "milestones", milestoneId), join(prGsd, "milestones", milestoneId), { force: true })
|
|
77
|
-
|
|
78
|
-
// 3. Merge completed-units.json (set-union of both locations)
|
|
79
|
-
// Prevents already-completed units from being re-dispatched after crash/restart.
|
|
80
|
-
const srcKeysFile = join(wtGsd, "completed-units.json");
|
|
81
|
-
const dstKeysFile = join(prGsd, "completed-units.json");
|
|
82
|
-
if (existsSync(srcKeysFile)) {
|
|
83
|
-
try {
|
|
84
|
-
const srcKeys: string[] = JSON.parse(readFileSync(srcKeysFile, "utf8"));
|
|
85
|
-
let dstKeys: string[] = [];
|
|
86
|
-
if (existsSync(dstKeysFile)) {
|
|
87
|
-
try { dstKeys = JSON.parse(readFileSync(dstKeysFile, "utf8")); } catch { /* ignore corrupt dst */ }
|
|
88
|
-
}
|
|
89
|
-
const merged = [...new Set([...dstKeys, ...srcKeys])];
|
|
90
|
-
atomicWriteSync(dstKeysFile, JSON.stringify(merged, null, 2));
|
|
91
|
-
} catch { /* non-fatal */ }
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// 4. Runtime records — unit dispatch state used by selfHealRuntimeRecords().
|
|
95
|
-
// Without this, a crash during a unit leaves the runtime record only in the
|
|
96
|
-
// worktree. If the next session resolves basePath before worktree re-entry,
|
|
97
|
-
// selfHeal can't find or clear the stale record (#769).
|
|
98
|
-
safeCopyRecursive(join(wtGsd, "runtime", "units"), join(prGsd, "runtime", "units"), { force: true })
|
|
99
|
-
|
|
100
|
-
// 5. Living documents — decisions, requirements, project description, knowledge.
|
|
101
|
-
// Agents update these during slice execution. Without syncing, a new session
|
|
102
|
-
// reads stale copies from the project root, losing architectural decisions,
|
|
103
|
-
// requirement status updates, and accumulated knowledge (#1168).
|
|
104
|
-
for (const doc of ["DECISIONS.md", "REQUIREMENTS.md", "PROJECT.md", "KNOWLEDGE.md"]) {
|
|
105
|
-
safeCopy(join(wtGsd, doc), join(prGsd, doc), { force: true });
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// ─── Resource Staleness ───────────────────────────────────────────────────
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Read the resource version (semver) from the managed-resources manifest.
|
|
113
|
-
* Uses gsdVersion instead of syncedAt so that launching a second session
|
|
114
|
-
* doesn't falsely trigger staleness (#804).
|
|
115
|
-
*/
|
|
116
|
-
function isManifestWithVersion(data: unknown): data is { gsdVersion: string } {
|
|
117
|
-
return data !== null && typeof data === "object" && "gsdVersion" in data! && typeof (data as Record<string, unknown>).gsdVersion === "string";
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export function readResourceVersion(): string | null {
|
|
121
|
-
const agentDir = process.env.GSD_CODING_AGENT_DIR || join(homedir(), ".gsd", "agent");
|
|
122
|
-
const manifestPath = join(agentDir, "managed-resources.json");
|
|
123
|
-
const manifest = loadJsonFileOrNull(manifestPath, isManifestWithVersion);
|
|
124
|
-
return manifest?.gsdVersion ?? null;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Check if managed resources have been updated since session start.
|
|
129
|
-
* Returns a warning message if stale, null otherwise.
|
|
130
|
-
*/
|
|
131
|
-
export function checkResourcesStale(versionOnStart: string | null): string | null {
|
|
132
|
-
if (versionOnStart === null) return null;
|
|
133
|
-
const current = readResourceVersion();
|
|
134
|
-
if (current === null) return null;
|
|
135
|
-
if (current !== versionOnStart) {
|
|
136
|
-
return "GSD resources were updated since this session started. Restart gsd to load the new code.";
|
|
137
|
-
}
|
|
138
|
-
return null;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// ─── Stale Worktree Escape ────────────────────────────────────────────────
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Detect and escape a stale worktree cwd (#608).
|
|
145
|
-
*
|
|
146
|
-
* After milestone completion + merge, the worktree directory is removed but
|
|
147
|
-
* the process cwd may still point inside `.gsd/worktrees/<MID>/`.
|
|
148
|
-
* When a new session starts, `process.cwd()` is passed as `base` to startAuto
|
|
149
|
-
* and all subsequent writes land in the wrong directory. This function detects
|
|
150
|
-
* that scenario and chdir back to the project root.
|
|
151
|
-
*
|
|
152
|
-
* Returns the corrected base path.
|
|
153
|
-
*/
|
|
154
|
-
export function escapeStaleWorktree(base: string): string {
|
|
155
|
-
const marker = `${pathSep}.gsd${pathSep}worktrees${pathSep}`;
|
|
156
|
-
const idx = base.indexOf(marker);
|
|
157
|
-
if (idx === -1) return base;
|
|
158
|
-
|
|
159
|
-
// base is inside .gsd/worktrees/<something> — extract the project root
|
|
160
|
-
const projectRoot = base.slice(0, idx);
|
|
161
|
-
try {
|
|
162
|
-
process.chdir(projectRoot);
|
|
163
|
-
} catch {
|
|
164
|
-
// If chdir fails, return the original — caller will handle errors downstream
|
|
165
|
-
return base;
|
|
166
|
-
}
|
|
167
|
-
return projectRoot;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Clean stale runtime unit files for completed milestones.
|
|
172
|
-
*
|
|
173
|
-
* After restart, stale runtime/units/*.json from prior milestones can
|
|
174
|
-
* cause deriveState to resume the wrong milestone (#887). Removes files
|
|
175
|
-
* for milestones that have a SUMMARY (fully complete).
|
|
176
|
-
*/
|
|
177
|
-
export function cleanStaleRuntimeUnits(
|
|
178
|
-
gsdRootPath: string,
|
|
179
|
-
hasMilestoneSummary: (mid: string) => boolean,
|
|
180
|
-
): number {
|
|
181
|
-
const runtimeUnitsDir = join(gsdRootPath, "runtime", "units");
|
|
182
|
-
if (!existsSync(runtimeUnitsDir)) return 0;
|
|
183
|
-
|
|
184
|
-
let cleaned = 0;
|
|
185
|
-
try {
|
|
186
|
-
for (const file of readdirSync(runtimeUnitsDir)) {
|
|
187
|
-
if (!file.endsWith(".json")) continue;
|
|
188
|
-
const midMatch = file.match(/(M\d+(?:-[a-z0-9]{6})?)/);
|
|
189
|
-
if (!midMatch) continue;
|
|
190
|
-
if (hasMilestoneSummary(midMatch[1])) {
|
|
191
|
-
try {
|
|
192
|
-
unlinkSync(join(runtimeUnitsDir, file));
|
|
193
|
-
cleaned++;
|
|
194
|
-
} catch { /* non-fatal */ }
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
} catch { /* non-fatal */ }
|
|
198
|
-
return cleaned;
|
|
199
|
-
}
|