@zhuan-ai/zhuanspec 1.3.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 +22 -0
- package/README.md +461 -0
- package/README.zh.md +434 -0
- package/bin/zhuanspec.js +3 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +356 -0
- package/dist/commands/artifact-workflow.d.ts +13 -0
- package/dist/commands/artifact-workflow.js +916 -0
- package/dist/commands/change.d.ts +35 -0
- package/dist/commands/change.js +277 -0
- package/dist/commands/completion.d.ts +72 -0
- package/dist/commands/completion.js +221 -0
- package/dist/commands/config.d.ts +8 -0
- package/dist/commands/config.js +198 -0
- package/dist/commands/show.d.ts +14 -0
- package/dist/commands/show.js +132 -0
- package/dist/commands/spec.d.ts +15 -0
- package/dist/commands/spec.js +225 -0
- package/dist/commands/validate.d.ts +24 -0
- package/dist/commands/validate.js +294 -0
- package/dist/core/archive.d.ts +30 -0
- package/dist/core/archive.js +438 -0
- package/dist/core/artifact-graph/graph.d.ts +56 -0
- package/dist/core/artifact-graph/graph.js +141 -0
- package/dist/core/artifact-graph/index.d.ts +7 -0
- package/dist/core/artifact-graph/index.js +13 -0
- package/dist/core/artifact-graph/instruction-loader.d.ts +134 -0
- package/dist/core/artifact-graph/instruction-loader.js +180 -0
- package/dist/core/artifact-graph/resolver.d.ts +61 -0
- package/dist/core/artifact-graph/resolver.js +187 -0
- package/dist/core/artifact-graph/schema.d.ts +13 -0
- package/dist/core/artifact-graph/schema.js +108 -0
- package/dist/core/artifact-graph/state.d.ts +12 -0
- package/dist/core/artifact-graph/state.js +54 -0
- package/dist/core/artifact-graph/types.d.ts +45 -0
- package/dist/core/artifact-graph/types.js +43 -0
- package/dist/core/completions/command-registry.d.ts +7 -0
- package/dist/core/completions/command-registry.js +362 -0
- package/dist/core/completions/completion-provider.d.ts +60 -0
- package/dist/core/completions/completion-provider.js +102 -0
- package/dist/core/completions/factory.d.ts +51 -0
- package/dist/core/completions/factory.js +57 -0
- package/dist/core/completions/generators/zsh-generator.d.ts +58 -0
- package/dist/core/completions/generators/zsh-generator.js +319 -0
- package/dist/core/completions/installers/zsh-installer.d.ts +136 -0
- package/dist/core/completions/installers/zsh-installer.js +449 -0
- package/dist/core/completions/types.d.ts +78 -0
- package/dist/core/completions/types.js +2 -0
- package/dist/core/config-schema.d.ts +76 -0
- package/dist/core/config-schema.js +200 -0
- package/dist/core/config.d.ts +16 -0
- package/dist/core/config.js +29 -0
- package/dist/core/configurators/agents.d.ts +8 -0
- package/dist/core/configurators/agents.js +15 -0
- package/dist/core/configurators/base.d.ts +7 -0
- package/dist/core/configurators/base.js +2 -0
- package/dist/core/configurators/claude.d.ts +8 -0
- package/dist/core/configurators/claude.js +15 -0
- package/dist/core/configurators/cline.d.ts +8 -0
- package/dist/core/configurators/cline.js +15 -0
- package/dist/core/configurators/codebuddy.d.ts +8 -0
- package/dist/core/configurators/codebuddy.js +15 -0
- package/dist/core/configurators/costrict.d.ts +8 -0
- package/dist/core/configurators/costrict.js +15 -0
- package/dist/core/configurators/iflow.d.ts +8 -0
- package/dist/core/configurators/iflow.js +15 -0
- package/dist/core/configurators/qoder.d.ts +30 -0
- package/dist/core/configurators/qoder.js +42 -0
- package/dist/core/configurators/qwen.d.ts +24 -0
- package/dist/core/configurators/qwen.js +37 -0
- package/dist/core/configurators/registry.d.ts +9 -0
- package/dist/core/configurators/registry.js +43 -0
- package/dist/core/configurators/slash/amazon-q.d.ts +9 -0
- package/dist/core/configurators/slash/amazon-q.js +46 -0
- package/dist/core/configurators/slash/antigravity.d.ts +9 -0
- package/dist/core/configurators/slash/antigravity.js +23 -0
- package/dist/core/configurators/slash/auggie.d.ts +9 -0
- package/dist/core/configurators/slash/auggie.js +31 -0
- package/dist/core/configurators/slash/base.d.ts +19 -0
- package/dist/core/configurators/slash/base.js +69 -0
- package/dist/core/configurators/slash/claude.d.ts +9 -0
- package/dist/core/configurators/slash/claude.js +37 -0
- package/dist/core/configurators/slash/cline.d.ts +9 -0
- package/dist/core/configurators/slash/cline.js +23 -0
- package/dist/core/configurators/slash/codebuddy.d.ts +9 -0
- package/dist/core/configurators/slash/codebuddy.js +37 -0
- package/dist/core/configurators/slash/codex.d.ts +14 -0
- package/dist/core/configurators/slash/codex.js +109 -0
- package/dist/core/configurators/slash/costrict.d.ts +9 -0
- package/dist/core/configurators/slash/costrict.js +31 -0
- package/dist/core/configurators/slash/crush.d.ts +9 -0
- package/dist/core/configurators/slash/crush.js +37 -0
- package/dist/core/configurators/slash/cursor.d.ts +9 -0
- package/dist/core/configurators/slash/cursor.js +37 -0
- package/dist/core/configurators/slash/factory.d.ts +10 -0
- package/dist/core/configurators/slash/factory.js +35 -0
- package/dist/core/configurators/slash/gemini.d.ts +9 -0
- package/dist/core/configurators/slash/gemini.js +22 -0
- package/dist/core/configurators/slash/github-copilot.d.ts +9 -0
- package/dist/core/configurators/slash/github-copilot.js +34 -0
- package/dist/core/configurators/slash/iflow.d.ts +9 -0
- package/dist/core/configurators/slash/iflow.js +37 -0
- package/dist/core/configurators/slash/kilocode.d.ts +9 -0
- package/dist/core/configurators/slash/kilocode.js +17 -0
- package/dist/core/configurators/slash/opencode.d.ts +12 -0
- package/dist/core/configurators/slash/opencode.js +72 -0
- package/dist/core/configurators/slash/qoder.d.ts +35 -0
- package/dist/core/configurators/slash/qoder.js +76 -0
- package/dist/core/configurators/slash/qwen.d.ts +32 -0
- package/dist/core/configurators/slash/qwen.js +49 -0
- package/dist/core/configurators/slash/registry.d.ts +8 -0
- package/dist/core/configurators/slash/registry.js +75 -0
- package/dist/core/configurators/slash/roocode.d.ts +9 -0
- package/dist/core/configurators/slash/roocode.js +23 -0
- package/dist/core/configurators/slash/toml-base.d.ts +10 -0
- package/dist/core/configurators/slash/toml-base.js +53 -0
- package/dist/core/configurators/slash/windsurf.d.ts +9 -0
- package/dist/core/configurators/slash/windsurf.js +23 -0
- package/dist/core/converters/json-converter.d.ts +6 -0
- package/dist/core/converters/json-converter.js +51 -0
- package/dist/core/global-config.d.ts +39 -0
- package/dist/core/global-config.js +115 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +3 -0
- package/dist/core/init.d.ts +60 -0
- package/dist/core/init.js +861 -0
- package/dist/core/list.d.ts +9 -0
- package/dist/core/list.js +171 -0
- package/dist/core/parsers/change-parser.d.ts +13 -0
- package/dist/core/parsers/change-parser.js +193 -0
- package/dist/core/parsers/markdown-parser.d.ts +22 -0
- package/dist/core/parsers/markdown-parser.js +187 -0
- package/dist/core/parsers/requirement-blocks.d.ts +37 -0
- package/dist/core/parsers/requirement-blocks.js +201 -0
- package/dist/core/project-config.d.ts +34 -0
- package/dist/core/project-config.js +79 -0
- package/dist/core/schemas/base.schema.d.ts +13 -0
- package/dist/core/schemas/base.schema.js +13 -0
- package/dist/core/schemas/change.schema.d.ts +73 -0
- package/dist/core/schemas/change.schema.js +31 -0
- package/dist/core/schemas/index.d.ts +4 -0
- package/dist/core/schemas/index.js +4 -0
- package/dist/core/schemas/spec.schema.d.ts +18 -0
- package/dist/core/schemas/spec.schema.js +15 -0
- package/dist/core/skill-discovery.d.ts +24 -0
- package/dist/core/skill-discovery.js +153 -0
- package/dist/core/specs-apply.d.ts +73 -0
- package/dist/core/specs-apply.js +384 -0
- package/dist/core/styles/palette.d.ts +7 -0
- package/dist/core/styles/palette.js +8 -0
- package/dist/core/templates/agents-root-stub.d.ts +2 -0
- package/dist/core/templates/agents-root-stub.js +17 -0
- package/dist/core/templates/agents-template.d.ts +2 -0
- package/dist/core/templates/agents-template.js +706 -0
- package/dist/core/templates/claude-template.d.ts +2 -0
- package/dist/core/templates/claude-template.js +2 -0
- package/dist/core/templates/cline-template.d.ts +2 -0
- package/dist/core/templates/cline-template.js +2 -0
- package/dist/core/templates/costrict-template.d.ts +2 -0
- package/dist/core/templates/costrict-template.js +2 -0
- package/dist/core/templates/index.d.ts +17 -0
- package/dist/core/templates/index.js +37 -0
- package/dist/core/templates/project-template.d.ts +8 -0
- package/dist/core/templates/project-template.js +32 -0
- package/dist/core/templates/skill-templates.d.ts +103 -0
- package/dist/core/templates/skill-templates.js +2131 -0
- package/dist/core/templates/slash-command-templates.d.ts +4 -0
- package/dist/core/templates/slash-command-templates.js +81 -0
- package/dist/core/update.d.ts +4 -0
- package/dist/core/update.js +88 -0
- package/dist/core/validation/constants.d.ts +34 -0
- package/dist/core/validation/constants.js +40 -0
- package/dist/core/validation/types.d.ts +18 -0
- package/dist/core/validation/types.js +2 -0
- package/dist/core/validation/validator.d.ts +33 -0
- package/dist/core/validation/validator.js +409 -0
- package/dist/core/view.d.ts +8 -0
- package/dist/core/view.js +168 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/utils/change-metadata.d.ts +47 -0
- package/dist/utils/change-metadata.js +130 -0
- package/dist/utils/change-utils.d.ts +51 -0
- package/dist/utils/change-utils.js +100 -0
- package/dist/utils/file-system.d.ts +19 -0
- package/dist/utils/file-system.js +177 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/interactive.d.ts +18 -0
- package/dist/utils/interactive.js +21 -0
- package/dist/utils/item-discovery.d.ts +4 -0
- package/dist/utils/item-discovery.js +72 -0
- package/dist/utils/match.d.ts +3 -0
- package/dist/utils/match.js +22 -0
- package/dist/utils/shell-detection.d.ts +20 -0
- package/dist/utils/shell-detection.js +41 -0
- package/dist/utils/task-progress.d.ts +8 -0
- package/dist/utils/task-progress.js +36 -0
- package/package.json +81 -0
- package/schemas/spec-driven/schema.yaml +205 -0
- package/schemas/spec-driven/templates/design.md +19 -0
- package/schemas/spec-driven/templates/proposal.md +43 -0
- package/schemas/spec-driven/templates/spec.md +8 -0
- package/schemas/spec-driven/templates/tasks.md +25 -0
- package/schemas/tdd/schema.yaml +213 -0
- package/schemas/tdd/templates/docs.md +0 -0
- package/schemas/tdd/templates/implementation.md +11 -0
- package/schemas/tdd/templates/spec.md +11 -0
- package/schemas/tdd/templates/test.md +11 -0
- package/scripts/postinstall.js +147 -0
|
@@ -0,0 +1,2131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Skill Templates
|
|
3
|
+
*
|
|
4
|
+
* Templates for generating Agent Skills compatible with:
|
|
5
|
+
* - Claude Code
|
|
6
|
+
* - Cursor (Settings → Rules → Import Settings)
|
|
7
|
+
* - Windsurf
|
|
8
|
+
* - Other Agent Skills-compatible editors
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Template for zhuanspec-new-change skill
|
|
12
|
+
* Based on /opsx:new command
|
|
13
|
+
*/
|
|
14
|
+
export function getNewChangeSkillTemplate() {
|
|
15
|
+
return {
|
|
16
|
+
name: 'zhuanspec-new-change',
|
|
17
|
+
description: 'Start a new ZhuanSpec change using the experimental artifact workflow. Use when the user wants to create a new feature, fix, or modification with a structured step-by-step approach.',
|
|
18
|
+
instructions: `Start a new change using the experimental artifact-driven approach.
|
|
19
|
+
|
|
20
|
+
**Input**: The user's request should include a change name (kebab-case) OR a description of what they want to build.
|
|
21
|
+
|
|
22
|
+
**Steps**
|
|
23
|
+
|
|
24
|
+
1. **If no clear input provided, ask what they want to build**
|
|
25
|
+
|
|
26
|
+
Use the **AskUserQuestion tool** (open-ended, no preset options) to ask:
|
|
27
|
+
> "What change do you want to work on? Describe what you want to build or fix."
|
|
28
|
+
|
|
29
|
+
From their description, derive a kebab-case name (e.g., "add user authentication" → \`add-user-auth\`).
|
|
30
|
+
|
|
31
|
+
**IMPORTANT**: Do NOT proceed without understanding what the user wants to build.
|
|
32
|
+
|
|
33
|
+
2. **Select a workflow schema**
|
|
34
|
+
|
|
35
|
+
Run \`zhuanspec schemas --json\` to get available schemas with descriptions.
|
|
36
|
+
|
|
37
|
+
Use the **AskUserQuestion tool** to let the user choose a workflow:
|
|
38
|
+
- Present each schema with its description
|
|
39
|
+
- Mark \`spec-driven\` as "(default)" if it's available
|
|
40
|
+
- Example options: "spec-driven - proposal → specs → design → tasks (default)", "tdd - tests → implementation → docs"
|
|
41
|
+
|
|
42
|
+
If user doesn't have a preference, default to \`spec-driven\`.
|
|
43
|
+
|
|
44
|
+
3. **Create the change directory**
|
|
45
|
+
\`\`\`bash
|
|
46
|
+
zhuanspec new change "<name>" --schema "<selected-schema>"
|
|
47
|
+
\`\`\`
|
|
48
|
+
This creates a scaffolded change at \`zhuanspec/changes/<name>/\` with the selected schema.
|
|
49
|
+
|
|
50
|
+
4. **Show the artifact status**
|
|
51
|
+
\`\`\`bash
|
|
52
|
+
zhuanspec status --change "<name>"
|
|
53
|
+
\`\`\`
|
|
54
|
+
This shows which artifacts need to be created and which are ready (dependencies satisfied).
|
|
55
|
+
|
|
56
|
+
5. **Get instructions for the first artifact**
|
|
57
|
+
The first artifact depends on the schema (e.g., \`proposal\` for spec-driven, \`spec\` for tdd).
|
|
58
|
+
Check the status output to find the first artifact with status "ready".
|
|
59
|
+
\`\`\`bash
|
|
60
|
+
zhuanspec instructions <first-artifact-id> --change "<name>"
|
|
61
|
+
\`\`\`
|
|
62
|
+
This outputs the template and context for creating the first artifact.
|
|
63
|
+
|
|
64
|
+
6. **STOP and wait for user direction**
|
|
65
|
+
|
|
66
|
+
**Output**
|
|
67
|
+
|
|
68
|
+
After completing the steps, summarize:
|
|
69
|
+
- Change name and location
|
|
70
|
+
- Selected schema/workflow and its artifact sequence
|
|
71
|
+
- Current status (0/N artifacts complete)
|
|
72
|
+
- The template for the first artifact
|
|
73
|
+
- Prompt: "Ready to create the first artifact? Just describe what this change is about and I'll draft it, or ask me to continue."
|
|
74
|
+
|
|
75
|
+
**Guardrails**
|
|
76
|
+
- Do NOT create any artifacts yet - just show the instructions
|
|
77
|
+
- Do NOT advance beyond showing the first artifact template
|
|
78
|
+
- If the name is invalid (not kebab-case), ask for a valid name
|
|
79
|
+
- If a change with that name already exists, suggest continuing that change instead
|
|
80
|
+
- Always pass --schema to preserve the user's workflow choice`
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Template for zhuanspec-continue-change skill
|
|
85
|
+
* Based on /opsx:continue command
|
|
86
|
+
*/
|
|
87
|
+
export function getContinueChangeSkillTemplate() {
|
|
88
|
+
return {
|
|
89
|
+
name: 'zhuanspec-continue-change',
|
|
90
|
+
description: 'Continue working on an ZhuanSpec change by creating the next artifact. Use when the user wants to progress their change, create the next artifact, or continue their workflow.',
|
|
91
|
+
instructions: `Continue working on a change by creating the next artifact.
|
|
92
|
+
|
|
93
|
+
**Input**: Optionally specify a change name. If omitted, MUST prompt for available changes.
|
|
94
|
+
|
|
95
|
+
**Steps**
|
|
96
|
+
|
|
97
|
+
1. **If no change name provided, prompt for selection**
|
|
98
|
+
|
|
99
|
+
Run \`zhuanspec list --json\` to get available changes sorted by most recently modified. Then use the **AskUserQuestion tool** to let the user select which change to work on.
|
|
100
|
+
|
|
101
|
+
Present the top 3-4 most recently modified changes as options, showing:
|
|
102
|
+
- Change name
|
|
103
|
+
- Schema (from \`schema\` field if present, otherwise "spec-driven")
|
|
104
|
+
- Status (e.g., "0/5 tasks", "complete", "no tasks")
|
|
105
|
+
- How recently it was modified (from \`lastModified\` field)
|
|
106
|
+
|
|
107
|
+
Mark the most recently modified change as "(Recommended)" since it's likely what the user wants to continue.
|
|
108
|
+
|
|
109
|
+
**IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
|
|
110
|
+
|
|
111
|
+
2. **Check current status**
|
|
112
|
+
\`\`\`bash
|
|
113
|
+
zhuanspec status --change "<name>" --json
|
|
114
|
+
\`\`\`
|
|
115
|
+
Parse the JSON to understand current state. The response includes:
|
|
116
|
+
- \`schemaName\`: The workflow schema being used (e.g., "spec-driven", "tdd")
|
|
117
|
+
- \`artifacts\`: Array of artifacts with their status ("done", "ready", "blocked")
|
|
118
|
+
- \`isComplete\`: Boolean indicating if all artifacts are complete
|
|
119
|
+
|
|
120
|
+
3. **Act based on status**:
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
**If all artifacts are complete (\`isComplete: true\`)**:
|
|
125
|
+
- Congratulate the user
|
|
126
|
+
- Show final status including the schema used
|
|
127
|
+
- Suggest: "All artifacts created! You can now implement this change or archive it."
|
|
128
|
+
- STOP
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
**If artifacts are ready to create** (status shows artifacts with \`status: "ready"\`):
|
|
133
|
+
- Pick the FIRST artifact with \`status: "ready"\` from the status output
|
|
134
|
+
- Get its instructions:
|
|
135
|
+
\`\`\`bash
|
|
136
|
+
zhuanspec instructions <artifact-id> --change "<name>" --json
|
|
137
|
+
\`\`\`
|
|
138
|
+
- Parse the JSON to get template, dependencies, and what it unlocks
|
|
139
|
+
- **Create the artifact file** using the template as a starting point:
|
|
140
|
+
- Read any completed dependency files for context
|
|
141
|
+
- Fill in the template based on context and user's goals
|
|
142
|
+
- Write to the output path specified in instructions
|
|
143
|
+
- Show what was created and what's now unlocked
|
|
144
|
+
- STOP after creating ONE artifact
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
**If no artifacts are ready (all blocked)**:
|
|
149
|
+
- This shouldn't happen with a valid schema
|
|
150
|
+
- Show status and suggest checking for issues
|
|
151
|
+
|
|
152
|
+
4. **After creating an artifact, show progress**
|
|
153
|
+
\`\`\`bash
|
|
154
|
+
zhuanspec status --change "<name>"
|
|
155
|
+
\`\`\`
|
|
156
|
+
|
|
157
|
+
**Output**
|
|
158
|
+
|
|
159
|
+
After each invocation, show:
|
|
160
|
+
- Which artifact was created
|
|
161
|
+
- Schema workflow being used
|
|
162
|
+
- Current progress (N/M complete)
|
|
163
|
+
- What artifacts are now unlocked
|
|
164
|
+
- Prompt: "Want to continue? Just ask me to continue or tell me what to do next."
|
|
165
|
+
|
|
166
|
+
**Artifact Creation Guidelines**
|
|
167
|
+
|
|
168
|
+
The artifact types and their purpose depend on the schema. Use the \`instruction\` field from the instructions output to understand what to create.
|
|
169
|
+
|
|
170
|
+
Common artifact patterns:
|
|
171
|
+
|
|
172
|
+
**spec-driven schema** (proposal → specs → design → tasks):
|
|
173
|
+
- **proposal.md**: Ask user about the change if not clear. Fill in Why, What Changes, Capabilities, Impact.
|
|
174
|
+
- The Capabilities section is critical - each capability listed will need a spec file.
|
|
175
|
+
- **specs/*.md**: Create one spec per capability listed in the proposal.
|
|
176
|
+
- **design.md**: Document technical decisions, architecture, and implementation approach.
|
|
177
|
+
- **tasks.md**: Break down implementation into checkboxed tasks.
|
|
178
|
+
|
|
179
|
+
**tdd schema** (spec → tests → implementation → docs):
|
|
180
|
+
- **spec.md**: Feature specification defining what to build.
|
|
181
|
+
- **tests/*.test.ts**: Write tests BEFORE implementation (TDD red phase).
|
|
182
|
+
- **src/*.ts**: Implement to make tests pass (TDD green phase).
|
|
183
|
+
- **docs/*.md**: Document the implemented feature.
|
|
184
|
+
|
|
185
|
+
For other schemas, follow the \`instruction\` field from the CLI output.
|
|
186
|
+
|
|
187
|
+
**Guardrails**
|
|
188
|
+
- Create ONE artifact per invocation
|
|
189
|
+
- Always read dependency artifacts before creating a new one
|
|
190
|
+
- Never skip artifacts or create out of order
|
|
191
|
+
- If context is unclear, use **AskUserQuestion tool** with preset options to clarify before creating
|
|
192
|
+
- Verify the artifact file exists after writing before marking progress
|
|
193
|
+
- Use the schema's artifact sequence, don't assume specific artifact names`
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Template for zhuanspec-apply-change skill
|
|
198
|
+
* For implementing tasks from a completed (or in-progress) change
|
|
199
|
+
*/
|
|
200
|
+
export function getApplyChangeSkillTemplate() {
|
|
201
|
+
return {
|
|
202
|
+
name: 'zhuanspec-apply-change',
|
|
203
|
+
description: 'Implement tasks from an ZhuanSpec change. Use when the user wants to start implementing, continue implementation, or work through tasks.',
|
|
204
|
+
instructions: `Implement tasks from an ZhuanSpec change.
|
|
205
|
+
|
|
206
|
+
**Input**: Optionally specify a change name. If omitted, MUST prompt for available changes.
|
|
207
|
+
|
|
208
|
+
**Steps**
|
|
209
|
+
|
|
210
|
+
1. **If no change name provided, prompt for selection**
|
|
211
|
+
|
|
212
|
+
Run \`zhuanspec list --json\` to get available changes. Use the **AskUserQuestion tool** to let the user select.
|
|
213
|
+
|
|
214
|
+
Show changes that are implementation-ready (have tasks artifact).
|
|
215
|
+
Include the schema used for each change if available.
|
|
216
|
+
Mark changes with incomplete tasks as "(In Progress)".
|
|
217
|
+
|
|
218
|
+
**IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
|
|
219
|
+
|
|
220
|
+
2. **Check status to understand the schema**
|
|
221
|
+
\`\`\`bash
|
|
222
|
+
zhuanspec status --change "<name>" --json
|
|
223
|
+
\`\`\`
|
|
224
|
+
Parse the JSON to understand:
|
|
225
|
+
- \`schemaName\`: The workflow being used (e.g., "spec-driven", "tdd")
|
|
226
|
+
- Which artifact contains the tasks (typically "tasks" for spec-driven, check status for others)
|
|
227
|
+
|
|
228
|
+
3. **Get apply instructions**
|
|
229
|
+
|
|
230
|
+
\`\`\`bash
|
|
231
|
+
zhuanspec instructions apply --change "<name>" --json
|
|
232
|
+
\`\`\`
|
|
233
|
+
|
|
234
|
+
This returns:
|
|
235
|
+
- Context file paths (varies by schema - could be proposal/specs/design/tasks or spec/tests/implementation/docs)
|
|
236
|
+
- Progress (total, complete, remaining)
|
|
237
|
+
- Task list with status
|
|
238
|
+
- Dynamic instruction based on current state
|
|
239
|
+
|
|
240
|
+
**Handle states:**
|
|
241
|
+
- If \`state: "blocked"\` (missing artifacts): show message, suggest using zhuanspec-continue-change
|
|
242
|
+
- If \`state: "all_done"\`: proceed to code review step (see step 8)
|
|
243
|
+
- Otherwise: proceed to implementation
|
|
244
|
+
|
|
245
|
+
4. **Read context files**
|
|
246
|
+
|
|
247
|
+
Read the files listed in \`contextFiles\` from the apply instructions output.
|
|
248
|
+
The files depend on the schema being used:
|
|
249
|
+
- **spec-driven**: proposal, specs, design, tasks
|
|
250
|
+
- **tdd**: spec, tests, implementation, docs
|
|
251
|
+
- Other schemas: follow the contextFiles from CLI output
|
|
252
|
+
|
|
253
|
+
5. **Show current progress**
|
|
254
|
+
|
|
255
|
+
Display:
|
|
256
|
+
- Schema being used
|
|
257
|
+
- Progress: "N/M tasks complete"
|
|
258
|
+
- Remaining tasks overview
|
|
259
|
+
- Dynamic instruction from CLI
|
|
260
|
+
|
|
261
|
+
6. **Implement tasks (loop until done or blocked)**
|
|
262
|
+
|
|
263
|
+
For each pending task:
|
|
264
|
+
- Show which task is being worked on
|
|
265
|
+
- Parse the task text for \`@skill\` tags (format: \`@skill:name1,name2\`)
|
|
266
|
+
- If \`@skill\` tags found, invoke the corresponding skill(s) for guidance before making changes
|
|
267
|
+
- Make the code changes required
|
|
268
|
+
- Keep changes minimal and focused
|
|
269
|
+
- Mark task complete in the tasks file: \`- [ ]\` → \`- [x]\`
|
|
270
|
+
- Continue to next task
|
|
271
|
+
|
|
272
|
+
**Pause if:**
|
|
273
|
+
- Task is unclear → use **AskUserQuestion tool** with preset options to clarify (never ask for free-text input)
|
|
274
|
+
- Implementation reveals a design issue → suggest updating artifacts
|
|
275
|
+
- Error or blocker encountered → report and wait for guidance
|
|
276
|
+
- User interrupts
|
|
277
|
+
|
|
278
|
+
7. **On completion or pause, show status**
|
|
279
|
+
|
|
280
|
+
Display:
|
|
281
|
+
- Tasks completed this session
|
|
282
|
+
- Overall progress: "N/M tasks complete"
|
|
283
|
+
- If all done: proceed to code review step (step 8)
|
|
284
|
+
- If paused: explain why and wait for guidance
|
|
285
|
+
|
|
286
|
+
8. **Code Review (when all tasks complete)**
|
|
287
|
+
|
|
288
|
+
**WHEN** all tasks are complete (\`state: "all_done"\`):
|
|
289
|
+
|
|
290
|
+
a. **Prompt for code review**
|
|
291
|
+
|
|
292
|
+
Use the **AskUserQuestion tool** with options:
|
|
293
|
+
- "是,进行代码审查" / "Yes, perform code review"
|
|
294
|
+
- "跳过,直接归档" / "Skip, proceed to archive"
|
|
295
|
+
|
|
296
|
+
Wait for user selection before proceeding.
|
|
297
|
+
|
|
298
|
+
b. **If user selects "Yes, perform code review"**:
|
|
299
|
+
|
|
300
|
+
1. **Read code files related to the change**
|
|
301
|
+
- Based on context files from apply instructions
|
|
302
|
+
- Scan the change directory for code files (e.g., \`*.java\`, \`*.ts\`, \`*.py\`, etc.)
|
|
303
|
+
- Read all relevant code files that were modified or created for this change
|
|
304
|
+
|
|
305
|
+
2. **Perform code review**
|
|
306
|
+
|
|
307
|
+
Review code for:
|
|
308
|
+
- **Code standards and conventions compliance**: naming, formatting, structure
|
|
309
|
+
- **Logic correctness**: edge cases, error handling, business logic
|
|
310
|
+
- **Performance issues**: inefficient algorithms, unnecessary operations, potential bottlenecks
|
|
311
|
+
- **Security concerns**: input validation, authentication, authorization, data exposure
|
|
312
|
+
- **Best practices adherence**: design patterns, SOLID principles, maintainability
|
|
313
|
+
|
|
314
|
+
**For Java code specifically**, pay special attention to:
|
|
315
|
+
- Java-specific patterns and conventions (e.g., builder pattern, factory pattern)
|
|
316
|
+
- Common Java pitfalls:
|
|
317
|
+
- Null handling (NullPointerException prevention)
|
|
318
|
+
- Exception handling (proper try-catch, resource management)
|
|
319
|
+
- Resource management (try-with-resources, closing streams/connections)
|
|
320
|
+
- Performance considerations:
|
|
321
|
+
- Collections usage (ArrayList vs LinkedList, HashMap vs TreeMap)
|
|
322
|
+
- Streams vs loops (when to use each)
|
|
323
|
+
- Concurrency (thread safety, synchronization)
|
|
324
|
+
|
|
325
|
+
3. **Generate review report**
|
|
326
|
+
|
|
327
|
+
Create a structured report listing:
|
|
328
|
+
- **Issues found** (if any):
|
|
329
|
+
- Severity (Critical, High, Medium, Low)
|
|
330
|
+
- Location (file path and line number)
|
|
331
|
+
- Description
|
|
332
|
+
- Suggestion for improvement
|
|
333
|
+
- **Suggestions for improvement** (even if no critical issues)
|
|
334
|
+
- **Positive findings** (good practices observed)
|
|
335
|
+
|
|
336
|
+
4. **Handle review results**
|
|
337
|
+
|
|
338
|
+
- **If issues are found**:
|
|
339
|
+
|
|
340
|
+
Display the review report with all issues.
|
|
341
|
+
|
|
342
|
+
Use **AskUserQuestion tool** with options:
|
|
343
|
+
- "是,现在修复" / "Yes, fix now"
|
|
344
|
+
- "稍后修复" / "Fix later"
|
|
345
|
+
- "跳过" / "Skip"
|
|
346
|
+
|
|
347
|
+
- If user chooses "Yes, fix now": proceed with fixing the issues one by one
|
|
348
|
+
- If user chooses "Fix later" or "Skip": continue to archive workflow
|
|
349
|
+
|
|
350
|
+
- **If no issues are found**:
|
|
351
|
+
|
|
352
|
+
Display: "代码审查完成,未发现问题。" (or "Code review complete. No issues found.")
|
|
353
|
+
Proceed to suggest archive workflow.
|
|
354
|
+
|
|
355
|
+
c. **If user selects "Skip, proceed to archive"**:
|
|
356
|
+
|
|
357
|
+
Skip the code review step.
|
|
358
|
+
Proceed directly to suggesting archive workflow.
|
|
359
|
+
The workflow SHALL NOT be blocked.
|
|
360
|
+
|
|
361
|
+
**Output During Implementation**
|
|
362
|
+
|
|
363
|
+
\`\`\`
|
|
364
|
+
## Implementing: <change-name> (schema: <schema-name>)
|
|
365
|
+
|
|
366
|
+
Working on task 3/7: <task description>
|
|
367
|
+
[...implementation happening...]
|
|
368
|
+
✓ Task complete
|
|
369
|
+
|
|
370
|
+
Working on task 4/7: <task description>
|
|
371
|
+
[...implementation happening...]
|
|
372
|
+
✓ Task complete
|
|
373
|
+
\`\`\`
|
|
374
|
+
|
|
375
|
+
**Output On Completion**
|
|
376
|
+
|
|
377
|
+
\`\`\`
|
|
378
|
+
## Implementation Complete
|
|
379
|
+
|
|
380
|
+
**Change:** <change-name>
|
|
381
|
+
**Schema:** <schema-name>
|
|
382
|
+
**Progress:** 7/7 tasks complete ✓
|
|
383
|
+
|
|
384
|
+
### Completed This Session
|
|
385
|
+
- [x] Task 1
|
|
386
|
+
- [x] Task 2
|
|
387
|
+
...
|
|
388
|
+
|
|
389
|
+
All tasks complete! Ready for code review or archive.
|
|
390
|
+
\`\`\`
|
|
391
|
+
|
|
392
|
+
**Output After Code Review (Issues Found)**
|
|
393
|
+
|
|
394
|
+
\`\`\`
|
|
395
|
+
## Code Review Complete
|
|
396
|
+
|
|
397
|
+
**Change:** <change-name>
|
|
398
|
+
**Schema:** <schema-name>
|
|
399
|
+
|
|
400
|
+
### Issues Found
|
|
401
|
+
|
|
402
|
+
**Critical:**
|
|
403
|
+
- [File: path/to/file.java:42] Description of critical issue
|
|
404
|
+
- Suggestion: How to fix
|
|
405
|
+
|
|
406
|
+
**High:**
|
|
407
|
+
- [File: path/to/file.java:58] Description of high priority issue
|
|
408
|
+
- Suggestion: How to fix
|
|
409
|
+
|
|
410
|
+
**Medium:**
|
|
411
|
+
- [File: path/to/file.java:73] Description of medium priority issue
|
|
412
|
+
- Suggestion: How to fix
|
|
413
|
+
|
|
414
|
+
### Positive Findings
|
|
415
|
+
- Good use of try-with-resources for resource management
|
|
416
|
+
- Clear variable naming conventions
|
|
417
|
+
- Proper exception handling
|
|
418
|
+
|
|
419
|
+
发现了一些问题。是否现在修复?
|
|
420
|
+
\`\`\`
|
|
421
|
+
|
|
422
|
+
**Output After Code Review (No Issues)**
|
|
423
|
+
|
|
424
|
+
\`\`\`
|
|
425
|
+
## Code Review Complete
|
|
426
|
+
|
|
427
|
+
**Change:** <change-name>
|
|
428
|
+
**Schema:** <schema-name>
|
|
429
|
+
|
|
430
|
+
代码审查完成,未发现问题。
|
|
431
|
+
|
|
432
|
+
Ready to archive this change.
|
|
433
|
+
\`\`\`
|
|
434
|
+
|
|
435
|
+
**Output On Pause (Issue Encountered)**
|
|
436
|
+
|
|
437
|
+
\`\`\`
|
|
438
|
+
## Implementation Paused
|
|
439
|
+
|
|
440
|
+
**Change:** <change-name>
|
|
441
|
+
**Schema:** <schema-name>
|
|
442
|
+
**Progress:** 4/7 tasks complete
|
|
443
|
+
|
|
444
|
+
### Issue Encountered
|
|
445
|
+
<description of the issue>
|
|
446
|
+
|
|
447
|
+
**Options:**
|
|
448
|
+
1. <option 1>
|
|
449
|
+
2. <option 2>
|
|
450
|
+
3. Other approach
|
|
451
|
+
|
|
452
|
+
What would you like to do?
|
|
453
|
+
\`\`\`
|
|
454
|
+
|
|
455
|
+
**Guardrails**
|
|
456
|
+
- Keep going through tasks until done or blocked
|
|
457
|
+
- Always read context files before starting (from the apply instructions output)
|
|
458
|
+
- If task is ambiguous, use **AskUserQuestion tool** with preset options to clarify before implementing
|
|
459
|
+
- If implementation reveals issues, pause and suggest artifact updates
|
|
460
|
+
- Keep code changes minimal and scoped to each task
|
|
461
|
+
- Update task checkbox immediately after completing each task
|
|
462
|
+
- Pause on errors, blockers, or unclear requirements - don't guess
|
|
463
|
+
- Use contextFiles from CLI output, don't assume specific file names
|
|
464
|
+
|
|
465
|
+
**Fluid Workflow Integration**
|
|
466
|
+
|
|
467
|
+
This skill supports the "actions on a change" model:
|
|
468
|
+
|
|
469
|
+
- **Can be invoked anytime**: Before all artifacts are done (if tasks exist), after partial implementation, interleaved with other actions
|
|
470
|
+
- **Allows artifact updates**: If implementation reveals design issues, suggest updating artifacts - not phase-locked, work fluidly`
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Template for zhuanspec-ff-change skill
|
|
475
|
+
* Fast-forward through artifact creation
|
|
476
|
+
*/
|
|
477
|
+
export function getFfChangeSkillTemplate() {
|
|
478
|
+
return {
|
|
479
|
+
name: 'zhuanspec-ff-change',
|
|
480
|
+
description: 'Fast-forward through ZhuanSpec artifact creation. Use when the user wants to quickly create all artifacts needed for implementation without stepping through each one individually.',
|
|
481
|
+
instructions: `Fast-forward through artifact creation - generate everything needed to start implementation in one go.
|
|
482
|
+
|
|
483
|
+
**Input**: The user's request should include a change name (kebab-case) OR a description of what they want to build.
|
|
484
|
+
|
|
485
|
+
**Steps**
|
|
486
|
+
|
|
487
|
+
1. **If no clear input provided, ask what they want to build**
|
|
488
|
+
|
|
489
|
+
Use the **AskUserQuestion tool** (open-ended, no preset options) to ask:
|
|
490
|
+
> "What change do you want to work on? Describe what you want to build or fix."
|
|
491
|
+
|
|
492
|
+
From their description, derive a kebab-case name (e.g., "add user authentication" → \`add-user-auth\`).
|
|
493
|
+
|
|
494
|
+
**IMPORTANT**: Do NOT proceed without understanding what the user wants to build.
|
|
495
|
+
|
|
496
|
+
2. **Create the change directory**
|
|
497
|
+
\`\`\`bash
|
|
498
|
+
zhuanspec new change "<name>"
|
|
499
|
+
\`\`\`
|
|
500
|
+
This creates a scaffolded change at \`zhuanspec/changes/<name>/\`.
|
|
501
|
+
|
|
502
|
+
3. **Get the artifact build order**
|
|
503
|
+
\`\`\`bash
|
|
504
|
+
zhuanspec status --change "<name>" --json
|
|
505
|
+
\`\`\`
|
|
506
|
+
Parse the JSON to get:
|
|
507
|
+
- \`applyRequires\`: array of artifact IDs needed before implementation (e.g., \`["tasks"]\`)
|
|
508
|
+
- \`artifacts\`: list of all artifacts with their status and dependencies
|
|
509
|
+
|
|
510
|
+
4. **Create artifacts in sequence until apply-ready**
|
|
511
|
+
|
|
512
|
+
Use the **TodoWrite tool** to track progress through the artifacts.
|
|
513
|
+
|
|
514
|
+
Loop through artifacts in dependency order (artifacts with no pending dependencies first):
|
|
515
|
+
|
|
516
|
+
a. **For each artifact that is \`ready\` (dependencies satisfied)**:
|
|
517
|
+
- Get instructions:
|
|
518
|
+
\`\`\`bash
|
|
519
|
+
zhuanspec instructions <artifact-id> --change "<name>" --json
|
|
520
|
+
\`\`\`
|
|
521
|
+
- The instructions JSON includes:
|
|
522
|
+
- \`template\`: The template content to use
|
|
523
|
+
- \`instruction\`: Schema-specific guidance for this artifact type
|
|
524
|
+
- \`outputPath\`: Where to write the artifact
|
|
525
|
+
- \`dependencies\`: Completed artifacts to read for context
|
|
526
|
+
- Read any completed dependency files for context
|
|
527
|
+
- Create the artifact file following the schema's \`instruction\`
|
|
528
|
+
- Show brief progress: "✓ Created <artifact-id>"
|
|
529
|
+
|
|
530
|
+
b. **Continue until all \`applyRequires\` artifacts are complete**
|
|
531
|
+
- After creating each artifact, re-run \`zhuanspec status --change "<name>" --json\`
|
|
532
|
+
- Check if every artifact ID in \`applyRequires\` has \`status: "done"\` in the artifacts array
|
|
533
|
+
- Stop when all \`applyRequires\` artifacts are done
|
|
534
|
+
|
|
535
|
+
c. **If an artifact requires user input** (unclear context):
|
|
536
|
+
- Use **AskUserQuestion tool** with preset options to clarify (never ask for free-text input)
|
|
537
|
+
- Then continue with creation
|
|
538
|
+
|
|
539
|
+
5. **Show final status**
|
|
540
|
+
\`\`\`bash
|
|
541
|
+
zhuanspec status --change "<name>"
|
|
542
|
+
\`\`\`
|
|
543
|
+
|
|
544
|
+
**Output**
|
|
545
|
+
|
|
546
|
+
After completing all artifacts, summarize:
|
|
547
|
+
- Change name and location
|
|
548
|
+
- List of artifacts created with brief descriptions
|
|
549
|
+
- What's ready: "All artifacts created! Ready for implementation."
|
|
550
|
+
- Prompt: "Run \`/opsx:apply\` or ask me to implement to start working on the tasks."
|
|
551
|
+
|
|
552
|
+
**Artifact Creation Guidelines**
|
|
553
|
+
|
|
554
|
+
- Follow the \`instruction\` field from \`zhuanspec instructions\` for each artifact type
|
|
555
|
+
- The schema defines what each artifact should contain - follow it
|
|
556
|
+
- Read dependency artifacts for context before creating new ones
|
|
557
|
+
- Use the \`template\` as a starting point, filling in based on context
|
|
558
|
+
|
|
559
|
+
**Guardrails**
|
|
560
|
+
- Create ALL artifacts needed for implementation (as defined by schema's \`apply.requires\`)
|
|
561
|
+
- Always read dependency artifacts before creating a new one
|
|
562
|
+
- If context is critically unclear, use **AskUserQuestion tool** with preset options to clarify - but prefer making reasonable decisions to keep momentum
|
|
563
|
+
- If a change with that name already exists, suggest continuing that change instead
|
|
564
|
+
- Verify each artifact file exists after writing before proceeding to next`
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* Template for zhuanspec-sync-specs skill
|
|
569
|
+
* For syncing delta specs from a change to main specs (agent-driven)
|
|
570
|
+
*/
|
|
571
|
+
export function getSyncSpecsSkillTemplate() {
|
|
572
|
+
return {
|
|
573
|
+
name: 'zhuanspec-sync-specs',
|
|
574
|
+
description: 'Sync delta specs from a change to main specs. Use when the user wants to update main specs with changes from a delta spec, without archiving the change.',
|
|
575
|
+
instructions: `Sync delta specs from a change to main specs.
|
|
576
|
+
|
|
577
|
+
This is an **agent-driven** operation - you will read delta specs and directly edit main specs to apply the changes. This allows intelligent merging (e.g., adding a scenario without copying the entire requirement).
|
|
578
|
+
|
|
579
|
+
**Input**: Optionally specify a change name. If omitted, MUST prompt for available changes.
|
|
580
|
+
|
|
581
|
+
**Steps**
|
|
582
|
+
|
|
583
|
+
1. **If no change name provided, prompt for selection**
|
|
584
|
+
|
|
585
|
+
Run \`zhuanspec list --json\` to get available changes. Use the **AskUserQuestion tool** to let the user select.
|
|
586
|
+
|
|
587
|
+
Show changes that have delta specs (under \`specs/\` directory).
|
|
588
|
+
|
|
589
|
+
**IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
|
|
590
|
+
|
|
591
|
+
2. **Find delta specs**
|
|
592
|
+
|
|
593
|
+
Look for delta spec files in \`zhuanspec/changes/<name>/specs/*/spec.md\`.
|
|
594
|
+
|
|
595
|
+
Each delta spec file contains sections like:
|
|
596
|
+
- \`## ADDED Requirements\` - New requirements to add
|
|
597
|
+
- \`## MODIFIED Requirements\` - Changes to existing requirements
|
|
598
|
+
- \`## REMOVED Requirements\` - Requirements to remove
|
|
599
|
+
- \`## RENAMED Requirements\` - Requirements to rename (FROM:/TO: format)
|
|
600
|
+
|
|
601
|
+
If no delta specs found, inform user and stop.
|
|
602
|
+
|
|
603
|
+
3. **For each delta spec, apply changes to main specs**
|
|
604
|
+
|
|
605
|
+
For each capability with a delta spec at \`zhuanspec/changes/<name>/specs/<capability>/spec.md\`:
|
|
606
|
+
|
|
607
|
+
a. **Read the delta spec** to understand the intended changes
|
|
608
|
+
|
|
609
|
+
b. **Read the main spec** at \`zhuanspec/specs/<capability>/spec.md\` (may not exist yet)
|
|
610
|
+
|
|
611
|
+
c. **Apply changes intelligently**:
|
|
612
|
+
|
|
613
|
+
**ADDED Requirements:**
|
|
614
|
+
- If requirement doesn't exist in main spec → add it
|
|
615
|
+
- If requirement already exists → update it to match (treat as implicit MODIFIED)
|
|
616
|
+
|
|
617
|
+
**MODIFIED Requirements:**
|
|
618
|
+
- Find the requirement in main spec
|
|
619
|
+
- Apply the changes - this can be:
|
|
620
|
+
- Adding new scenarios (don't need to copy existing ones)
|
|
621
|
+
- Modifying existing scenarios
|
|
622
|
+
- Changing the requirement description
|
|
623
|
+
- Preserve scenarios/content not mentioned in the delta
|
|
624
|
+
|
|
625
|
+
**REMOVED Requirements:**
|
|
626
|
+
- Remove the entire requirement block from main spec
|
|
627
|
+
|
|
628
|
+
**RENAMED Requirements:**
|
|
629
|
+
- Find the FROM requirement, rename to TO
|
|
630
|
+
|
|
631
|
+
d. **Create new main spec** if capability doesn't exist yet:
|
|
632
|
+
- Create \`zhuanspec/specs/<capability>/spec.md\`
|
|
633
|
+
- Add Purpose section (can be brief, mark as TBD)
|
|
634
|
+
- Add Requirements section with the ADDED requirements
|
|
635
|
+
|
|
636
|
+
4. **Show summary**
|
|
637
|
+
|
|
638
|
+
After applying all changes, summarize:
|
|
639
|
+
- Which capabilities were updated
|
|
640
|
+
- What changes were made (requirements added/modified/removed/renamed)
|
|
641
|
+
|
|
642
|
+
**Delta Spec Format Reference**
|
|
643
|
+
|
|
644
|
+
\`\`\`markdown
|
|
645
|
+
## ADDED Requirements
|
|
646
|
+
|
|
647
|
+
### Requirement: New Feature
|
|
648
|
+
The system SHALL do something new.
|
|
649
|
+
|
|
650
|
+
#### Scenario: Basic case
|
|
651
|
+
- **WHEN** user does X
|
|
652
|
+
- **THEN** system does Y
|
|
653
|
+
|
|
654
|
+
## MODIFIED Requirements
|
|
655
|
+
|
|
656
|
+
### Requirement: Existing Feature
|
|
657
|
+
#### Scenario: New scenario to add
|
|
658
|
+
- **WHEN** user does A
|
|
659
|
+
- **THEN** system does B
|
|
660
|
+
|
|
661
|
+
## REMOVED Requirements
|
|
662
|
+
|
|
663
|
+
### Requirement: Deprecated Feature
|
|
664
|
+
|
|
665
|
+
## RENAMED Requirements
|
|
666
|
+
|
|
667
|
+
- FROM: \`### Requirement: Old Name\`
|
|
668
|
+
- TO: \`### Requirement: New Name\`
|
|
669
|
+
\`\`\`
|
|
670
|
+
|
|
671
|
+
**Key Principle: Intelligent Merging**
|
|
672
|
+
|
|
673
|
+
Unlike programmatic merging, you can apply **partial updates**:
|
|
674
|
+
- To add a scenario, just include that scenario under MODIFIED - don't copy existing scenarios
|
|
675
|
+
- The delta represents *intent*, not a wholesale replacement
|
|
676
|
+
- Use your judgment to merge changes sensibly
|
|
677
|
+
|
|
678
|
+
**Output On Success**
|
|
679
|
+
|
|
680
|
+
\`\`\`
|
|
681
|
+
## Specs Synced: <change-name>
|
|
682
|
+
|
|
683
|
+
Updated main specs:
|
|
684
|
+
|
|
685
|
+
**<capability-1>**:
|
|
686
|
+
- Added requirement: "New Feature"
|
|
687
|
+
- Modified requirement: "Existing Feature" (added 1 scenario)
|
|
688
|
+
|
|
689
|
+
**<capability-2>**:
|
|
690
|
+
- Created new spec file
|
|
691
|
+
- Added requirement: "Another Feature"
|
|
692
|
+
|
|
693
|
+
Main specs are now updated. The change remains active - archive when implementation is complete.
|
|
694
|
+
\`\`\`
|
|
695
|
+
|
|
696
|
+
**Guardrails**
|
|
697
|
+
- Read both delta and main specs before making changes
|
|
698
|
+
- Preserve existing content not mentioned in delta
|
|
699
|
+
- If something is unclear, use **AskUserQuestion tool** with preset options to clarify
|
|
700
|
+
- Show what you're changing as you go
|
|
701
|
+
- The operation should be idempotent - running twice should give same result`
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* Template for zhuanspec-propose-change skill
|
|
706
|
+
* One-step workflow: create change + generate all planning artifacts
|
|
707
|
+
*/
|
|
708
|
+
export function getProposeChangeSkillTemplate() {
|
|
709
|
+
return {
|
|
710
|
+
name: 'zhuanspec-propose-change',
|
|
711
|
+
description: 'Create a complete ZhuanSpec change proposal in one step. Use when the user wants to propose a new feature, fix, or modification. Generates proposal, specs, design, and tasks all at once.',
|
|
712
|
+
instructions: `Create a complete change proposal in one step - proposal, specs, design, and tasks.
|
|
713
|
+
|
|
714
|
+
**Input**: The user's request should describe what they want to build or change. Can include a change name (kebab-case) or a natural language description.
|
|
715
|
+
|
|
716
|
+
**Steps**
|
|
717
|
+
|
|
718
|
+
1. **强制澄清检查(必须首先执行,不可跳过)**
|
|
719
|
+
|
|
720
|
+
Before creating anything, analyze the user's request for ambiguity:
|
|
721
|
+
|
|
722
|
+
a. **先查阅现有来源**:
|
|
723
|
+
- 审查 \`zhuanspec/project.md\` 了解项目约定
|
|
724
|
+
- 运行 \`zhuanspec list\` 和 \`zhuanspec list --specs\` 了解当前状态
|
|
725
|
+
- 检查相关代码和文档
|
|
726
|
+
|
|
727
|
+
b. **识别模糊点**(仅在无法从现有来源确定时询问):
|
|
728
|
+
- 范围是否明确?
|
|
729
|
+
- 技术选择是否明确?
|
|
730
|
+
- 优先级是否明确?
|
|
731
|
+
- 验收标准是否明确?
|
|
732
|
+
- 实现细节是否明确?
|
|
733
|
+
|
|
734
|
+
c. **如果发现模糊点**,使用 **AskUserQuestion tool** 以选项式交互提问:
|
|
735
|
+
- 每个问题提供 2-5 个预设选项
|
|
736
|
+
- 严禁要求用户手动输入大段文字
|
|
737
|
+
- 必须等待用户回答后才继续
|
|
738
|
+
|
|
739
|
+
d. 只有所有模糊点都明确后,才继续后续步骤。
|
|
740
|
+
|
|
741
|
+
2. **Derive change name**
|
|
742
|
+
|
|
743
|
+
From the user's description, derive a kebab-case name (e.g., "add user authentication" → \`add-user-auth\`).
|
|
744
|
+
Name should be: verb-first, descriptive, unique (check with \`zhuanspec list\`).
|
|
745
|
+
|
|
746
|
+
3. **Create the change directory**
|
|
747
|
+
\`\`\`bash
|
|
748
|
+
zhuanspec new change "<name>"
|
|
749
|
+
\`\`\`
|
|
750
|
+
|
|
751
|
+
4. **Create all planning artifacts in sequence**
|
|
752
|
+
|
|
753
|
+
Use the **TodoWrite tool** to track progress.
|
|
754
|
+
|
|
755
|
+
a. **Get artifact build order**:
|
|
756
|
+
\`\`\`bash
|
|
757
|
+
zhuanspec status --change "<name>" --json
|
|
758
|
+
\`\`\`
|
|
759
|
+
|
|
760
|
+
b. **For each artifact in dependency order** (proposal → specs → design → tasks):
|
|
761
|
+
- Get instructions: \`zhuanspec instructions <artifact-id> --change "<name>" --json\`
|
|
762
|
+
- Read any completed dependency files for context
|
|
763
|
+
- **For proposal artifact**: When filling Skill Mapping section, analyze each skill's description and match based on actual functionality (not just module names). Simple changes like enum modifications should map to general coding standards, not architecture-level skills.
|
|
764
|
+
- **For tasks artifact only**: Before creating tasks.md, run \`zhuanspec skills list --json\` to discover available skills with their descriptions. For each task, read skill descriptions carefully and annotate with \`@skill:<real-skill-name>\` tags only when there's a clear semantic match between the task's functionality and the skill's purpose. Supports multiple: \`@skill:name1,name2\`.
|
|
765
|
+
- Create the artifact following the schema's instruction
|
|
766
|
+
- Show brief progress: "✓ Created <artifact-id>"
|
|
767
|
+
|
|
768
|
+
c. **Artifact creation guidelines**:
|
|
769
|
+
- **proposal.md**: Fill in Why, What Changes, Capabilities, Impact based on clarified requirements. For Skill Mapping, match based on skill descriptions, not module names.
|
|
770
|
+
- **specs/\\*/spec.md**: Create one spec per capability using ADDED/MODIFIED/REMOVED format with Scenarios
|
|
771
|
+
- **design.md**: Only if needed (cross-cutting changes, new dependencies, security/performance)
|
|
772
|
+
- **tasks.md**: Break into small, verifiable tasks with checkboxes. Annotate with @skill tags based on semantic matching of skill descriptions to task functionality.
|
|
773
|
+
|
|
774
|
+
5. **Validate the change**
|
|
775
|
+
\`\`\`bash
|
|
776
|
+
zhuanspec validate <name> --strict
|
|
777
|
+
\`\`\`
|
|
778
|
+
Fix any validation errors before presenting.
|
|
779
|
+
|
|
780
|
+
6. **Present the complete proposal**
|
|
781
|
+
|
|
782
|
+
Show summary:
|
|
783
|
+
- Change name and location
|
|
784
|
+
- Proposal overview (Why + What Changes)
|
|
785
|
+
- Affected capabilities
|
|
786
|
+
- Task count
|
|
787
|
+
- Prompt: "提案已创建,请审核后确认是否开始实施。"
|
|
788
|
+
|
|
789
|
+
**Output**
|
|
790
|
+
|
|
791
|
+
\`\`\`
|
|
792
|
+
## Proposal Created: <change-name>
|
|
793
|
+
|
|
794
|
+
**Location:** zhuanspec/changes/<name>/
|
|
795
|
+
|
|
796
|
+
✓ proposal.md — Why and What Changes
|
|
797
|
+
✓ specs/ — Requirements and scenarios
|
|
798
|
+
✓ design.md — Technical approach (if needed)
|
|
799
|
+
✓ tasks.md — Implementation checklist (N tasks)
|
|
800
|
+
|
|
801
|
+
Ready for review. Run \`/zhuanspec:apply\` to start implementation.
|
|
802
|
+
\`\`\`
|
|
803
|
+
|
|
804
|
+
**Guardrails**
|
|
805
|
+
- MUST complete clarification before creating any files
|
|
806
|
+
- Create ALL planning artifacts in one invocation
|
|
807
|
+
- Do NOT start implementation - only create planning docs
|
|
808
|
+
- Validate with --strict before presenting
|
|
809
|
+
- If validation fails, fix and re-validate`
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
/**
|
|
813
|
+
* Template for zhuanspec-explore skill
|
|
814
|
+
* For exploration before committing to a change
|
|
815
|
+
*/
|
|
816
|
+
export function getExploreSkillTemplate() {
|
|
817
|
+
return {
|
|
818
|
+
name: 'zhuanspec-explore',
|
|
819
|
+
description: 'Explore ideas and investigate the codebase before creating a ZhuanSpec change. Use when requirements are unclear, the user wants to compare approaches, or needs to investigate before committing to a plan.',
|
|
820
|
+
instructions: `Explore ideas, investigate problems, and clarify requirements before committing to a change.
|
|
821
|
+
|
|
822
|
+
**Input**: A topic, question, or area the user wants to explore.
|
|
823
|
+
|
|
824
|
+
**Purpose**: Help the user think through ideas without creating any formal artifacts. This is the "thinking" phase before the "doing" phase.
|
|
825
|
+
|
|
826
|
+
**Steps**
|
|
827
|
+
|
|
828
|
+
1. **Understand what to explore**
|
|
829
|
+
|
|
830
|
+
If the topic is vague, use **AskUserQuestion tool** with options to narrow scope:
|
|
831
|
+
- "性能优化" / "Performance optimization"
|
|
832
|
+
- "架构改进" / "Architecture improvement"
|
|
833
|
+
- "新功能可行性" / "New feature feasibility"
|
|
834
|
+
- "技术债务" / "Technical debt"
|
|
835
|
+
|
|
836
|
+
2. **Investigate the codebase**
|
|
837
|
+
|
|
838
|
+
Based on the topic:
|
|
839
|
+
- Search for relevant code patterns (\`rg\`, \`ls\`, file reads)
|
|
840
|
+
- Review existing specs: \`zhuanspec list --specs\`
|
|
841
|
+
- Check active changes: \`zhuanspec list\`
|
|
842
|
+
- Read project conventions: \`zhuanspec/project.md\`
|
|
843
|
+
- Analyze code structure, dependencies, and patterns
|
|
844
|
+
|
|
845
|
+
3. **Present findings**
|
|
846
|
+
|
|
847
|
+
Provide a structured analysis:
|
|
848
|
+
- **Current State**: What exists now, how it works
|
|
849
|
+
- **Options**: Multiple approaches with pros/cons
|
|
850
|
+
- **Recommendation**: Suggested approach with reasoning
|
|
851
|
+
- **Impact**: What would need to change, estimated scope
|
|
852
|
+
|
|
853
|
+
4. **Guide next steps**
|
|
854
|
+
|
|
855
|
+
Use **AskUserQuestion tool** to offer:
|
|
856
|
+
- "创建变更提案" / "Create a change proposal" → suggest \`/zhuanspec:propose\`
|
|
857
|
+
- "继续探索其他方面" / "Explore another aspect"
|
|
858
|
+
- "不需要变更" / "No change needed"
|
|
859
|
+
|
|
860
|
+
**Output Format**
|
|
861
|
+
|
|
862
|
+
\`\`\`
|
|
863
|
+
## Exploration: <topic>
|
|
864
|
+
|
|
865
|
+
### Current State
|
|
866
|
+
[What exists, how it works]
|
|
867
|
+
|
|
868
|
+
### Options
|
|
869
|
+
1. **Option A**: [description]
|
|
870
|
+
- Pros: ...
|
|
871
|
+
- Cons: ...
|
|
872
|
+
2. **Option B**: [description]
|
|
873
|
+
- Pros: ...
|
|
874
|
+
- Cons: ...
|
|
875
|
+
|
|
876
|
+
### Recommendation
|
|
877
|
+
[Suggested approach and why]
|
|
878
|
+
|
|
879
|
+
### Estimated Impact
|
|
880
|
+
- Files affected: ~N
|
|
881
|
+
- Complexity: Low/Medium/High
|
|
882
|
+
- Risk: Low/Medium/High
|
|
883
|
+
|
|
884
|
+
Ready to proceed? Run \`/zhuanspec:propose\` to create a formal proposal.
|
|
885
|
+
\`\`\`
|
|
886
|
+
|
|
887
|
+
**Guardrails**
|
|
888
|
+
- Do NOT create any artifacts (no proposal, specs, tasks)
|
|
889
|
+
- Do NOT modify any code
|
|
890
|
+
- Focus on investigation and analysis only
|
|
891
|
+
- Present multiple options when possible
|
|
892
|
+
- Be honest about unknowns and risks
|
|
893
|
+
- If the user wants to proceed, guide them to /zhuanspec:propose`
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Template for zhuanspec-verify skill
|
|
898
|
+
* For verifying implementation matches artifacts
|
|
899
|
+
*/
|
|
900
|
+
export function getVerifySkillTemplate() {
|
|
901
|
+
return {
|
|
902
|
+
name: 'zhuanspec-verify',
|
|
903
|
+
description: 'Verify that implementation matches ZhuanSpec change artifacts. Use when the user wants to check if code matches specs, validate implementation quality, or review before archiving.',
|
|
904
|
+
instructions: `Verify that implementation matches the change artifacts across three dimensions: completeness, correctness, and coherence.
|
|
905
|
+
|
|
906
|
+
**Input**: Optionally specify a change name. If omitted, prompt for selection.
|
|
907
|
+
|
|
908
|
+
**Steps**
|
|
909
|
+
|
|
910
|
+
1. **Select change to verify**
|
|
911
|
+
|
|
912
|
+
If no change name provided:
|
|
913
|
+
- Run \`zhuanspec list --json\` to get available changes
|
|
914
|
+
- Use **AskUserQuestion tool** to let user select
|
|
915
|
+
- Prefer changes with completed tasks
|
|
916
|
+
|
|
917
|
+
2. **Load change context**
|
|
918
|
+
|
|
919
|
+
Read all artifacts:
|
|
920
|
+
- \`proposal.md\` — understanding intent and scope
|
|
921
|
+
- \`specs/*/spec.md\` — requirements and scenarios
|
|
922
|
+
- \`design.md\` — technical decisions (if exists)
|
|
923
|
+
- \`tasks.md\` — implementation checklist
|
|
924
|
+
|
|
925
|
+
3. **Check Completeness**
|
|
926
|
+
|
|
927
|
+
a. **Task completion**: Parse tasks.md, count checked vs unchecked
|
|
928
|
+
b. **Requirement coverage**: For each requirement in specs:
|
|
929
|
+
- Search codebase for implementation evidence
|
|
930
|
+
- Check if scenarios have corresponding test coverage
|
|
931
|
+
c. **Report**: List requirements with/without implementation evidence
|
|
932
|
+
|
|
933
|
+
4. **Check Correctness**
|
|
934
|
+
|
|
935
|
+
a. **Spec intent match**: For each requirement:
|
|
936
|
+
- Read the requirement and its scenarios
|
|
937
|
+
- Find the implementation code
|
|
938
|
+
- Verify the implementation matches the spec intent
|
|
939
|
+
b. **Edge cases**: Check if scenarios' edge cases are handled
|
|
940
|
+
c. **Error handling**: Verify error states match spec definitions
|
|
941
|
+
d. **Report**: List any mismatches between spec and implementation
|
|
942
|
+
|
|
943
|
+
5. **Check Coherence**
|
|
944
|
+
|
|
945
|
+
a. **Design alignment**: If design.md exists:
|
|
946
|
+
- Verify design decisions are reflected in code structure
|
|
947
|
+
- Check naming conventions match design.md
|
|
948
|
+
- Verify architectural patterns are followed
|
|
949
|
+
b. **Consistency**: Check code follows project conventions
|
|
950
|
+
c. **Report**: List inconsistencies
|
|
951
|
+
|
|
952
|
+
6. **Generate verification report**
|
|
953
|
+
|
|
954
|
+
**Output Format**
|
|
955
|
+
|
|
956
|
+
\`\`\`
|
|
957
|
+
## Verification: <change-name>
|
|
958
|
+
|
|
959
|
+
### COMPLETENESS
|
|
960
|
+
✓ All N tasks in tasks.md are checked
|
|
961
|
+
✓ M/K requirements have implementation evidence
|
|
962
|
+
⚠ Scenario "XXX" not covered by tests
|
|
963
|
+
|
|
964
|
+
### CORRECTNESS
|
|
965
|
+
✓ Implementation matches spec intent
|
|
966
|
+
✓ Edge cases handled
|
|
967
|
+
⚠ Error state "XXX" not matching spec
|
|
968
|
+
|
|
969
|
+
### COHERENCE
|
|
970
|
+
✓ Design decisions reflected in code
|
|
971
|
+
✓ Naming conventions consistent
|
|
972
|
+
⚠ Design mentions "XXX" but implementation uses "YYY"
|
|
973
|
+
|
|
974
|
+
### SUMMARY
|
|
975
|
+
─────────────────────────────
|
|
976
|
+
Critical issues: N
|
|
977
|
+
Warnings: N
|
|
978
|
+
Ready to archive: Yes/No (with warnings)
|
|
979
|
+
|
|
980
|
+
### Recommendations
|
|
981
|
+
1. [Actionable suggestion]
|
|
982
|
+
2. [Actionable suggestion]
|
|
983
|
+
\`\`\`
|
|
984
|
+
|
|
985
|
+
**Severity Levels**
|
|
986
|
+
- **Critical**: Implementation contradicts spec or missing required behavior
|
|
987
|
+
- **Warning**: Suboptimal but functional, or missing test coverage
|
|
988
|
+
- **Suggestion**: Could be improved but acceptable
|
|
989
|
+
|
|
990
|
+
**Guardrails**
|
|
991
|
+
- Do NOT modify any code during verification
|
|
992
|
+
- Report findings objectively
|
|
993
|
+
- Verify won't block archive - only surfaces issues
|
|
994
|
+
- If codebase is too large, focus on files related to the change
|
|
995
|
+
- Use grep/search to find implementation evidence, don't guess`
|
|
996
|
+
};
|
|
997
|
+
}
|
|
998
|
+
/**
|
|
999
|
+
* Template for /opsx:propose slash command
|
|
1000
|
+
*/
|
|
1001
|
+
export function getOpsxProposeCommandTemplate() {
|
|
1002
|
+
return {
|
|
1003
|
+
name: 'OPSX: Propose',
|
|
1004
|
+
description: 'Create a complete change proposal with all planning artifacts in one step',
|
|
1005
|
+
category: 'Workflow',
|
|
1006
|
+
tags: ['workflow', 'proposal', 'planning'],
|
|
1007
|
+
content: `Create a complete change proposal in one step.
|
|
1008
|
+
|
|
1009
|
+
**Input**: The argument after \`/opsx:propose\` is a change name (kebab-case) or a description of what the user wants to build.
|
|
1010
|
+
|
|
1011
|
+
**Workflow**: This command combines the creation of a change directory with fast-forward artifact generation.
|
|
1012
|
+
|
|
1013
|
+
**Steps**
|
|
1014
|
+
|
|
1015
|
+
1. **Mandatory clarification checkpoint**
|
|
1016
|
+
|
|
1017
|
+
- Review \`zhuanspec/project.md\`, run \`zhuanspec list\` and \`zhuanspec list --specs\`
|
|
1018
|
+
- Analyze user request for ambiguity (scope, tech choices, priorities, acceptance criteria)
|
|
1019
|
+
- If any unclear aspects found, use **AskUserQuestion tool** with preset options to clarify
|
|
1020
|
+
- Do NOT proceed until all ambiguities are resolved
|
|
1021
|
+
|
|
1022
|
+
2. **Derive change name** from input (kebab-case, verb-first, unique)
|
|
1023
|
+
|
|
1024
|
+
3. **Create change**: \`zhuanspec new change "<name>"\`
|
|
1025
|
+
|
|
1026
|
+
4. **Generate all planning artifacts** in dependency order:
|
|
1027
|
+
- For each artifact: \`zhuanspec instructions <id> --change "<name>" --json\`
|
|
1028
|
+
- Read dependencies, create artifact, show progress
|
|
1029
|
+
- Artifacts: proposal.md → specs/ → design.md (if needed) → tasks.md
|
|
1030
|
+
|
|
1031
|
+
5. **Validate**: \`zhuanspec validate <name> --strict\`
|
|
1032
|
+
|
|
1033
|
+
6. **Present** the complete proposal for review
|
|
1034
|
+
|
|
1035
|
+
**Output**
|
|
1036
|
+
|
|
1037
|
+
\`\`\`
|
|
1038
|
+
## Proposal Created: <change-name>
|
|
1039
|
+
|
|
1040
|
+
✓ proposal.md
|
|
1041
|
+
✓ specs/
|
|
1042
|
+
✓ design.md (if applicable)
|
|
1043
|
+
✓ tasks.md
|
|
1044
|
+
|
|
1045
|
+
Ready for implementation. Run \`/opsx:apply\` to begin.
|
|
1046
|
+
\`\`\`
|
|
1047
|
+
|
|
1048
|
+
**Guardrails**
|
|
1049
|
+
- Complete clarification before creating files
|
|
1050
|
+
- Create all planning artifacts in one step
|
|
1051
|
+
- Do NOT implement code - only planning docs
|
|
1052
|
+
- Validate before presenting`
|
|
1053
|
+
};
|
|
1054
|
+
}
|
|
1055
|
+
/**
|
|
1056
|
+
* Template for /opsx:explore slash command
|
|
1057
|
+
*/
|
|
1058
|
+
export function getOpsxExploreCommandTemplate() {
|
|
1059
|
+
return {
|
|
1060
|
+
name: 'OPSX: Explore',
|
|
1061
|
+
description: 'Think through ideas before committing to a change',
|
|
1062
|
+
category: 'Workflow',
|
|
1063
|
+
tags: ['workflow', 'exploration', 'planning'],
|
|
1064
|
+
content: `Explore ideas, investigate problems, and clarify requirements before committing to a change.
|
|
1065
|
+
|
|
1066
|
+
**Input**: The argument after \`/opsx:explore\` is a topic or question to investigate.
|
|
1067
|
+
|
|
1068
|
+
**Steps**
|
|
1069
|
+
|
|
1070
|
+
1. Understand what to explore (narrow scope if needed via AskUserQuestion)
|
|
1071
|
+
2. Investigate codebase: search code, review specs, check active changes
|
|
1072
|
+
3. Present structured findings: Current State, Options with pros/cons, Recommendation
|
|
1073
|
+
4. Guide next steps: offer to create proposal or continue exploring
|
|
1074
|
+
|
|
1075
|
+
**Output**
|
|
1076
|
+
|
|
1077
|
+
Structured analysis with options, recommendation, and estimated impact.
|
|
1078
|
+
No artifacts are created - this is the thinking phase before doing.
|
|
1079
|
+
|
|
1080
|
+
**Guardrails**
|
|
1081
|
+
- Do NOT create artifacts or modify code
|
|
1082
|
+
- Present multiple options when possible
|
|
1083
|
+
- Be honest about unknowns
|
|
1084
|
+
- Guide to \`/opsx:propose\` when ready to proceed`
|
|
1085
|
+
};
|
|
1086
|
+
}
|
|
1087
|
+
/**
|
|
1088
|
+
* Template for /opsx:verify slash command
|
|
1089
|
+
*/
|
|
1090
|
+
export function getOpsxVerifyCommandTemplate() {
|
|
1091
|
+
return {
|
|
1092
|
+
name: 'OPSX: Verify',
|
|
1093
|
+
description: 'Validate implementation matches change artifacts',
|
|
1094
|
+
category: 'Workflow',
|
|
1095
|
+
tags: ['workflow', 'verification', 'quality'],
|
|
1096
|
+
content: `Verify implementation matches change artifacts across three dimensions.
|
|
1097
|
+
|
|
1098
|
+
**Input**: Optionally specify \`--change <name>\` after \`/opsx:verify\`.
|
|
1099
|
+
|
|
1100
|
+
**Steps**
|
|
1101
|
+
|
|
1102
|
+
1. Select change to verify (prompt if not specified)
|
|
1103
|
+
2. Load all artifacts (proposal, specs, design, tasks)
|
|
1104
|
+
3. Check **Completeness**: tasks done, requirements implemented, scenarios covered
|
|
1105
|
+
4. Check **Correctness**: implementation matches spec intent, edge cases handled
|
|
1106
|
+
5. Check **Coherence**: design decisions reflected in code, patterns consistent
|
|
1107
|
+
6. Generate structured verification report
|
|
1108
|
+
|
|
1109
|
+
**Output**
|
|
1110
|
+
|
|
1111
|
+
Structured report with:
|
|
1112
|
+
- Completeness, Correctness, Coherence sections
|
|
1113
|
+
- Issues categorized as Critical/Warning/Suggestion
|
|
1114
|
+
- Summary with archive readiness
|
|
1115
|
+
- Actionable recommendations
|
|
1116
|
+
|
|
1117
|
+
**Guardrails**
|
|
1118
|
+
- Do NOT modify code during verification
|
|
1119
|
+
- Report findings objectively
|
|
1120
|
+
- Won't block archive, only surfaces issues`
|
|
1121
|
+
};
|
|
1122
|
+
}
|
|
1123
|
+
/**
|
|
1124
|
+
* Template for /opsx:new slash command
|
|
1125
|
+
*/
|
|
1126
|
+
export function getOpsxNewCommandTemplate() {
|
|
1127
|
+
return {
|
|
1128
|
+
name: 'OPSX: New',
|
|
1129
|
+
description: 'Start a new change using the experimental artifact workflow (OPSX)',
|
|
1130
|
+
category: 'Workflow',
|
|
1131
|
+
tags: ['workflow', 'artifacts', 'experimental'],
|
|
1132
|
+
content: `Start a new change using the experimental artifact-driven approach.
|
|
1133
|
+
|
|
1134
|
+
**Input**: The argument after \`/opsx:new\` is the change name (kebab-case), OR a description of what the user wants to build.
|
|
1135
|
+
|
|
1136
|
+
**Steps**
|
|
1137
|
+
|
|
1138
|
+
1. **If no input provided, ask what they want to build**
|
|
1139
|
+
|
|
1140
|
+
Use the **AskUserQuestion tool** (open-ended, no preset options) to ask:
|
|
1141
|
+
> "What change do you want to work on? Describe what you want to build or fix."
|
|
1142
|
+
|
|
1143
|
+
From their description, derive a kebab-case name (e.g., "add user authentication" → \`add-user-auth\`).
|
|
1144
|
+
|
|
1145
|
+
**IMPORTANT**: Do NOT proceed without understanding what the user wants to build.
|
|
1146
|
+
|
|
1147
|
+
2. **Select a workflow schema**
|
|
1148
|
+
|
|
1149
|
+
Run \`zhuanspec schemas --json\` to get available schemas with descriptions.
|
|
1150
|
+
|
|
1151
|
+
Use the **AskUserQuestion tool** to let the user choose a workflow:
|
|
1152
|
+
- Present each schema with its description
|
|
1153
|
+
- Mark \`spec-driven\` as "(default)" if it's available
|
|
1154
|
+
- Example options: "spec-driven - proposal → specs → design → tasks (default)", "tdd - tests → implementation → docs"
|
|
1155
|
+
|
|
1156
|
+
If user doesn't have a preference, default to \`spec-driven\`.
|
|
1157
|
+
|
|
1158
|
+
3. **Create the change directory**
|
|
1159
|
+
\`\`\`bash
|
|
1160
|
+
zhuanspec new change "<name>" --schema "<selected-schema>"
|
|
1161
|
+
\`\`\`
|
|
1162
|
+
This creates a scaffolded change at \`zhuanspec/changes/<name>/\` with the selected schema.
|
|
1163
|
+
|
|
1164
|
+
4. **Show the artifact status**
|
|
1165
|
+
\`\`\`bash
|
|
1166
|
+
zhuanspec status --change "<name>"
|
|
1167
|
+
\`\`\`
|
|
1168
|
+
This shows which artifacts need to be created and which are ready (dependencies satisfied).
|
|
1169
|
+
|
|
1170
|
+
5. **Get instructions for the first artifact**
|
|
1171
|
+
The first artifact depends on the schema. Check the status output to find the first artifact with status "ready".
|
|
1172
|
+
\`\`\`bash
|
|
1173
|
+
zhuanspec instructions <first-artifact-id> --change "<name>"
|
|
1174
|
+
\`\`\`
|
|
1175
|
+
This outputs the template and context for creating the first artifact.
|
|
1176
|
+
|
|
1177
|
+
6. **STOP and wait for user direction**
|
|
1178
|
+
|
|
1179
|
+
**Output**
|
|
1180
|
+
|
|
1181
|
+
After completing the steps, summarize:
|
|
1182
|
+
- Change name and location
|
|
1183
|
+
- Selected schema/workflow and its artifact sequence
|
|
1184
|
+
- Current status (0/N artifacts complete)
|
|
1185
|
+
- The template for the first artifact
|
|
1186
|
+
- Prompt: "Ready to create the first artifact? Run \`/opsx:continue\` or just describe what this change is about and I'll draft it."
|
|
1187
|
+
|
|
1188
|
+
**Guardrails**
|
|
1189
|
+
- Do NOT create any artifacts yet - just show the instructions
|
|
1190
|
+
- Do NOT advance beyond showing the first artifact template
|
|
1191
|
+
- If the name is invalid (not kebab-case), ask for a valid name
|
|
1192
|
+
- If a change with that name already exists, suggest using \`/opsx:continue\` instead
|
|
1193
|
+
- Always pass --schema to preserve the user's workflow choice`
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1196
|
+
/**
|
|
1197
|
+
* Template for /opsx:continue slash command
|
|
1198
|
+
*/
|
|
1199
|
+
export function getOpsxContinueCommandTemplate() {
|
|
1200
|
+
return {
|
|
1201
|
+
name: 'OPSX: Continue',
|
|
1202
|
+
description: 'Continue working on a change - create the next artifact (Experimental)',
|
|
1203
|
+
category: 'Workflow',
|
|
1204
|
+
tags: ['workflow', 'artifacts', 'experimental'],
|
|
1205
|
+
content: `Continue working on a change by creating the next artifact.
|
|
1206
|
+
|
|
1207
|
+
**Input**: Optionally specify \`--change <name>\` after \`/opsx:continue\`. If omitted, MUST prompt for available changes.
|
|
1208
|
+
|
|
1209
|
+
**Steps**
|
|
1210
|
+
|
|
1211
|
+
1. **If no change name provided, prompt for selection**
|
|
1212
|
+
|
|
1213
|
+
Run \`zhuanspec list --json\` to get available changes sorted by most recently modified. Then use the **AskUserQuestion tool** to let the user select which change to work on.
|
|
1214
|
+
|
|
1215
|
+
Present the top 3-4 most recently modified changes as options, showing:
|
|
1216
|
+
- Change name
|
|
1217
|
+
- Schema (from \`schema\` field if present, otherwise "spec-driven")
|
|
1218
|
+
- Status (e.g., "0/5 tasks", "complete", "no tasks")
|
|
1219
|
+
- How recently it was modified (from \`lastModified\` field)
|
|
1220
|
+
|
|
1221
|
+
Mark the most recently modified change as "(Recommended)" since it's likely what the user wants to continue.
|
|
1222
|
+
|
|
1223
|
+
**IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
|
|
1224
|
+
|
|
1225
|
+
2. **Check current status**
|
|
1226
|
+
\`\`\`bash
|
|
1227
|
+
zhuanspec status --change "<name>" --json
|
|
1228
|
+
\`\`\`
|
|
1229
|
+
Parse the JSON to understand current state. The response includes:
|
|
1230
|
+
- \`schemaName\`: The workflow schema being used (e.g., "spec-driven", "tdd")
|
|
1231
|
+
- \`artifacts\`: Array of artifacts with their status ("done", "ready", "blocked")
|
|
1232
|
+
- \`isComplete\`: Boolean indicating if all artifacts are complete
|
|
1233
|
+
|
|
1234
|
+
3. **Act based on status**:
|
|
1235
|
+
|
|
1236
|
+
---
|
|
1237
|
+
|
|
1238
|
+
**If all artifacts are complete (\`isComplete: true\`)**:
|
|
1239
|
+
- Congratulate the user
|
|
1240
|
+
- Show final status including the schema used
|
|
1241
|
+
- Suggest: "All artifacts created! You can now implement this change or archive it."
|
|
1242
|
+
- STOP
|
|
1243
|
+
|
|
1244
|
+
---
|
|
1245
|
+
|
|
1246
|
+
**If artifacts are ready to create** (status shows artifacts with \`status: "ready"\`):
|
|
1247
|
+
- Pick the FIRST artifact with \`status: "ready"\` from the status output
|
|
1248
|
+
- Get its instructions:
|
|
1249
|
+
\`\`\`bash
|
|
1250
|
+
zhuanspec instructions <artifact-id> --change "<name>" --json
|
|
1251
|
+
\`\`\`
|
|
1252
|
+
- Parse the JSON to get template, dependencies, and what it unlocks
|
|
1253
|
+
- **Create the artifact file** using the template as a starting point:
|
|
1254
|
+
- Read any completed dependency files for context
|
|
1255
|
+
- Fill in the template based on context and user's goals
|
|
1256
|
+
- Write to the output path specified in instructions
|
|
1257
|
+
- Show what was created and what's now unlocked
|
|
1258
|
+
- STOP after creating ONE artifact
|
|
1259
|
+
|
|
1260
|
+
---
|
|
1261
|
+
|
|
1262
|
+
**If no artifacts are ready (all blocked)**:
|
|
1263
|
+
- This shouldn't happen with a valid schema
|
|
1264
|
+
- Show status and suggest checking for issues
|
|
1265
|
+
|
|
1266
|
+
4. **After creating an artifact, show progress**
|
|
1267
|
+
\`\`\`bash
|
|
1268
|
+
zhuanspec status --change "<name>"
|
|
1269
|
+
\`\`\`
|
|
1270
|
+
|
|
1271
|
+
**Output**
|
|
1272
|
+
|
|
1273
|
+
After each invocation, show:
|
|
1274
|
+
- Which artifact was created
|
|
1275
|
+
- Schema workflow being used
|
|
1276
|
+
- Current progress (N/M complete)
|
|
1277
|
+
- What artifacts are now unlocked
|
|
1278
|
+
- Prompt: "Run \`/opsx:continue\` to create the next artifact"
|
|
1279
|
+
|
|
1280
|
+
**Artifact Creation Guidelines**
|
|
1281
|
+
|
|
1282
|
+
The artifact types and their purpose depend on the schema. Use the \`instruction\` field from the instructions output to understand what to create.
|
|
1283
|
+
|
|
1284
|
+
Common artifact patterns:
|
|
1285
|
+
|
|
1286
|
+
**spec-driven schema** (proposal → specs → design → tasks):
|
|
1287
|
+
- **proposal.md**: Ask user about the change if not clear. Fill in Why, What Changes, Capabilities, Impact.
|
|
1288
|
+
- The Capabilities section is critical - each capability listed will need a spec file.
|
|
1289
|
+
- **specs/*.md**: Create one spec per capability listed in the proposal.
|
|
1290
|
+
- **design.md**: Document technical decisions, architecture, and implementation approach.
|
|
1291
|
+
- **tasks.md**: Break down implementation into checkboxed tasks.
|
|
1292
|
+
|
|
1293
|
+
**tdd schema** (spec → tests → implementation → docs):
|
|
1294
|
+
- **spec.md**: Feature specification defining what to build.
|
|
1295
|
+
- **tests/*.test.ts**: Write tests BEFORE implementation (TDD red phase).
|
|
1296
|
+
- **src/*.ts**: Implement to make tests pass (TDD green phase).
|
|
1297
|
+
- **docs/*.md**: Document the implemented feature.
|
|
1298
|
+
|
|
1299
|
+
For other schemas, follow the \`instruction\` field from the CLI output.
|
|
1300
|
+
|
|
1301
|
+
**Guardrails**
|
|
1302
|
+
- Create ONE artifact per invocation
|
|
1303
|
+
- Always read dependency artifacts before creating a new one
|
|
1304
|
+
- Never skip artifacts or create out of order
|
|
1305
|
+
- If context is unclear, use **AskUserQuestion tool** with preset options to clarify before creating
|
|
1306
|
+
- Verify the artifact file exists after writing before marking progress
|
|
1307
|
+
- Use the schema's artifact sequence, don't assume specific artifact names`
|
|
1308
|
+
};
|
|
1309
|
+
}
|
|
1310
|
+
/**
|
|
1311
|
+
* Template for /opsx:apply slash command
|
|
1312
|
+
*/
|
|
1313
|
+
export function getOpsxApplyCommandTemplate() {
|
|
1314
|
+
return {
|
|
1315
|
+
name: 'OPSX: Apply',
|
|
1316
|
+
description: 'Implement tasks from an ZhuanSpec change (Experimental)',
|
|
1317
|
+
category: 'Workflow',
|
|
1318
|
+
tags: ['workflow', 'artifacts', 'experimental'],
|
|
1319
|
+
content: `Implement tasks from an ZhuanSpec change.
|
|
1320
|
+
|
|
1321
|
+
**Input**: Optionally specify \`--change <name>\` after \`/opsx:apply\`. If omitted, MUST prompt for available changes.
|
|
1322
|
+
|
|
1323
|
+
**Steps**
|
|
1324
|
+
|
|
1325
|
+
1. **If no change name provided, prompt for selection**
|
|
1326
|
+
|
|
1327
|
+
Run \`zhuanspec list --json\` to get available changes. Use the **AskUserQuestion tool** to let the user select.
|
|
1328
|
+
|
|
1329
|
+
Show changes that are implementation-ready (have tasks artifact).
|
|
1330
|
+
Include the schema used for each change if available.
|
|
1331
|
+
Mark changes with incomplete tasks as "(In Progress)".
|
|
1332
|
+
|
|
1333
|
+
**IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
|
|
1334
|
+
|
|
1335
|
+
2. **Check status to understand the schema**
|
|
1336
|
+
\`\`\`bash
|
|
1337
|
+
zhuanspec status --change "<name>" --json
|
|
1338
|
+
\`\`\`
|
|
1339
|
+
Parse the JSON to understand:
|
|
1340
|
+
- \`schemaName\`: The workflow being used (e.g., "spec-driven", "tdd")
|
|
1341
|
+
- Which artifact contains the tasks (typically "tasks" for spec-driven, check status for others)
|
|
1342
|
+
|
|
1343
|
+
3. **Get apply instructions**
|
|
1344
|
+
|
|
1345
|
+
\`\`\`bash
|
|
1346
|
+
zhuanspec instructions apply --change "<name>" --json
|
|
1347
|
+
\`\`\`
|
|
1348
|
+
|
|
1349
|
+
This returns:
|
|
1350
|
+
- Context file paths (varies by schema)
|
|
1351
|
+
- Progress (total, complete, remaining)
|
|
1352
|
+
- Task list with status
|
|
1353
|
+
- Dynamic instruction based on current state
|
|
1354
|
+
|
|
1355
|
+
**Handle states:**
|
|
1356
|
+
- If \`state: "blocked"\` (missing artifacts): show message, suggest using \`/opsx:continue\`
|
|
1357
|
+
- If \`state: "all_done"\`: proceed to code review step (see step 8)
|
|
1358
|
+
- Otherwise: proceed to implementation
|
|
1359
|
+
|
|
1360
|
+
4. **Read context files**
|
|
1361
|
+
|
|
1362
|
+
Read the files listed in \`contextFiles\` from the apply instructions output.
|
|
1363
|
+
The files depend on the schema being used:
|
|
1364
|
+
- **spec-driven**: proposal, specs, design, tasks
|
|
1365
|
+
- **tdd**: spec, tests, implementation, docs
|
|
1366
|
+
- Other schemas: follow the contextFiles from CLI output
|
|
1367
|
+
|
|
1368
|
+
5. **Show current progress**
|
|
1369
|
+
|
|
1370
|
+
Display:
|
|
1371
|
+
- Schema being used
|
|
1372
|
+
- Progress: "N/M tasks complete"
|
|
1373
|
+
- Remaining tasks overview
|
|
1374
|
+
- Dynamic instruction from CLI
|
|
1375
|
+
|
|
1376
|
+
6. **Implement tasks (loop until done or blocked)**
|
|
1377
|
+
|
|
1378
|
+
For each pending task:
|
|
1379
|
+
- Show which task is being worked on
|
|
1380
|
+
- Parse the task text for \`@skill\` tags (format: \`@skill:name1,name2\`)
|
|
1381
|
+
- If \`@skill\` tags found, invoke the corresponding skill(s) for guidance before making changes
|
|
1382
|
+
- Make the code changes required
|
|
1383
|
+
- Keep changes minimal and focused
|
|
1384
|
+
- Mark task complete in the tasks file: \`- [ ]\` → \`- [x]\`
|
|
1385
|
+
- Continue to next task
|
|
1386
|
+
|
|
1387
|
+
**Pause if:**
|
|
1388
|
+
- Task is unclear → use **AskUserQuestion tool** with preset options to clarify (never ask for free-text input)
|
|
1389
|
+
- Implementation reveals a design issue → suggest updating artifacts
|
|
1390
|
+
- Error or blocker encountered → report and wait for guidance
|
|
1391
|
+
- User interrupts
|
|
1392
|
+
|
|
1393
|
+
7. **On completion or pause, show status**
|
|
1394
|
+
|
|
1395
|
+
Display:
|
|
1396
|
+
- Tasks completed this session
|
|
1397
|
+
- Overall progress: "N/M tasks complete"
|
|
1398
|
+
- If all done: proceed to code review step (step 8)
|
|
1399
|
+
- If paused: explain why and wait for guidance
|
|
1400
|
+
|
|
1401
|
+
8. **Code Review (when all tasks complete)**
|
|
1402
|
+
|
|
1403
|
+
**WHEN** all tasks are complete (\`state: "all_done"\`):
|
|
1404
|
+
|
|
1405
|
+
a. **Prompt for code review**
|
|
1406
|
+
|
|
1407
|
+
Use the **AskUserQuestion tool** with options:
|
|
1408
|
+
- "是,进行代码审查" / "Yes, perform code review"
|
|
1409
|
+
- "跳过,直接归档" / "Skip, proceed to archive"
|
|
1410
|
+
|
|
1411
|
+
Wait for user selection before proceeding.
|
|
1412
|
+
|
|
1413
|
+
b. **If user selects "Yes, perform code review"**:
|
|
1414
|
+
|
|
1415
|
+
1. **Read code files related to the change**
|
|
1416
|
+
- Based on context files from apply instructions
|
|
1417
|
+
- Scan the change directory for code files (e.g., \`*.java\`, \`*.ts\`, \`*.py\`, etc.)
|
|
1418
|
+
- Read all relevant code files that were modified or created for this change
|
|
1419
|
+
|
|
1420
|
+
2. **Perform code review**
|
|
1421
|
+
|
|
1422
|
+
Review code for:
|
|
1423
|
+
- **Code standards and conventions compliance**: naming, formatting, structure
|
|
1424
|
+
- **Logic correctness**: edge cases, error handling, business logic
|
|
1425
|
+
- **Performance issues**: inefficient algorithms, unnecessary operations, potential bottlenecks
|
|
1426
|
+
- **Security concerns**: input validation, authentication, authorization, data exposure
|
|
1427
|
+
- **Best practices adherence**: design patterns, SOLID principles, maintainability
|
|
1428
|
+
|
|
1429
|
+
**For Java code specifically**, pay special attention to:
|
|
1430
|
+
- Java-specific patterns and conventions (e.g., builder pattern, factory pattern)
|
|
1431
|
+
- Common Java pitfalls:
|
|
1432
|
+
- Null handling (NullPointerException prevention)
|
|
1433
|
+
- Exception handling (proper try-catch, resource management)
|
|
1434
|
+
- Resource management (try-with-resources, closing streams/connections)
|
|
1435
|
+
- Performance considerations:
|
|
1436
|
+
- Collections usage (ArrayList vs LinkedList, HashMap vs TreeMap)
|
|
1437
|
+
- Streams vs loops (when to use each)
|
|
1438
|
+
- Concurrency (thread safety, synchronization)
|
|
1439
|
+
|
|
1440
|
+
3. **Generate review report**
|
|
1441
|
+
|
|
1442
|
+
Create a structured report listing:
|
|
1443
|
+
- **Issues found** (if any):
|
|
1444
|
+
- Severity (Critical, High, Medium, Low)
|
|
1445
|
+
- Location (file path and line number)
|
|
1446
|
+
- Description
|
|
1447
|
+
- Suggestion for improvement
|
|
1448
|
+
- **Suggestions for improvement** (even if no critical issues)
|
|
1449
|
+
- **Positive findings** (good practices observed)
|
|
1450
|
+
|
|
1451
|
+
4. **Handle review results**
|
|
1452
|
+
|
|
1453
|
+
- **If issues are found**:
|
|
1454
|
+
|
|
1455
|
+
Display the review report with all issues.
|
|
1456
|
+
|
|
1457
|
+
Use **AskUserQuestion tool** with options:
|
|
1458
|
+
- "是,现在修复" / "Yes, fix now"
|
|
1459
|
+
- "稍后修复" / "Fix later"
|
|
1460
|
+
- "跳过" / "Skip"
|
|
1461
|
+
|
|
1462
|
+
- If user chooses "Yes, fix now": proceed with fixing the issues one by one
|
|
1463
|
+
- If user chooses "Fix later" or "Skip": continue to archive workflow
|
|
1464
|
+
|
|
1465
|
+
- **If no issues are found**:
|
|
1466
|
+
|
|
1467
|
+
Display: "代码审查完成,未发现问题。" (or "Code review complete. No issues found.")
|
|
1468
|
+
Proceed to suggest archive workflow.
|
|
1469
|
+
|
|
1470
|
+
c. **If user selects "Skip, proceed to archive"**:
|
|
1471
|
+
|
|
1472
|
+
Skip the code review step.
|
|
1473
|
+
Proceed directly to suggesting archive workflow.
|
|
1474
|
+
The workflow SHALL NOT be blocked.
|
|
1475
|
+
|
|
1476
|
+
**Output During Implementation**
|
|
1477
|
+
|
|
1478
|
+
\`\`\`
|
|
1479
|
+
## Implementing: <change-name> (schema: <schema-name>)
|
|
1480
|
+
|
|
1481
|
+
Working on task 3/7: <task description>
|
|
1482
|
+
[...implementation happening...]
|
|
1483
|
+
✓ Task complete
|
|
1484
|
+
|
|
1485
|
+
Working on task 4/7: <task description>
|
|
1486
|
+
[...implementation happening...]
|
|
1487
|
+
✓ Task complete
|
|
1488
|
+
\`\`\`
|
|
1489
|
+
|
|
1490
|
+
**Output On Completion**
|
|
1491
|
+
|
|
1492
|
+
\`\`\`
|
|
1493
|
+
## Implementation Complete
|
|
1494
|
+
|
|
1495
|
+
**Change:** <change-name>
|
|
1496
|
+
**Schema:** <schema-name>
|
|
1497
|
+
**Progress:** 7/7 tasks complete ✓
|
|
1498
|
+
|
|
1499
|
+
### Completed This Session
|
|
1500
|
+
- [x] Task 1
|
|
1501
|
+
- [x] Task 2
|
|
1502
|
+
...
|
|
1503
|
+
|
|
1504
|
+
All tasks complete! Ready for code review or archive.
|
|
1505
|
+
\`\`\`
|
|
1506
|
+
|
|
1507
|
+
**Output After Code Review (Issues Found)**
|
|
1508
|
+
|
|
1509
|
+
\`\`\`
|
|
1510
|
+
## Code Review Complete
|
|
1511
|
+
|
|
1512
|
+
**Change:** <change-name>
|
|
1513
|
+
**Schema:** <schema-name>
|
|
1514
|
+
|
|
1515
|
+
### Issues Found
|
|
1516
|
+
|
|
1517
|
+
**Critical:**
|
|
1518
|
+
- [File: path/to/file.java:42] Description of critical issue
|
|
1519
|
+
- Suggestion: How to fix
|
|
1520
|
+
|
|
1521
|
+
**High:**
|
|
1522
|
+
- [File: path/to/file.java:58] Description of high priority issue
|
|
1523
|
+
- Suggestion: How to fix
|
|
1524
|
+
|
|
1525
|
+
**Medium:**
|
|
1526
|
+
- [File: path/to/file.java:73] Description of medium priority issue
|
|
1527
|
+
- Suggestion: How to fix
|
|
1528
|
+
|
|
1529
|
+
### Positive Findings
|
|
1530
|
+
- Good use of try-with-resources for resource management
|
|
1531
|
+
- Clear variable naming conventions
|
|
1532
|
+
- Proper exception handling
|
|
1533
|
+
|
|
1534
|
+
发现了一些问题。是否现在修复?
|
|
1535
|
+
\`\`\`
|
|
1536
|
+
|
|
1537
|
+
**Output After Code Review (No Issues)**
|
|
1538
|
+
|
|
1539
|
+
\`\`\`
|
|
1540
|
+
## Code Review Complete
|
|
1541
|
+
|
|
1542
|
+
**Change:** <change-name>
|
|
1543
|
+
**Schema:** <schema-name>
|
|
1544
|
+
|
|
1545
|
+
代码审查完成,未发现问题。
|
|
1546
|
+
|
|
1547
|
+
Ready to archive this change.
|
|
1548
|
+
\`\`\`
|
|
1549
|
+
|
|
1550
|
+
**Output On Pause (Issue Encountered)**
|
|
1551
|
+
|
|
1552
|
+
\`\`\`
|
|
1553
|
+
## Implementation Paused
|
|
1554
|
+
|
|
1555
|
+
**Change:** <change-name>
|
|
1556
|
+
**Schema:** <schema-name>
|
|
1557
|
+
**Progress:** 4/7 tasks complete
|
|
1558
|
+
|
|
1559
|
+
### Issue Encountered
|
|
1560
|
+
<description of the issue>
|
|
1561
|
+
|
|
1562
|
+
**Options:**
|
|
1563
|
+
1. <option 1>
|
|
1564
|
+
2. <option 2>
|
|
1565
|
+
3. Other approach
|
|
1566
|
+
|
|
1567
|
+
What would you like to do?
|
|
1568
|
+
\`\`\`
|
|
1569
|
+
|
|
1570
|
+
**Guardrails**
|
|
1571
|
+
- Keep going through tasks until done or blocked
|
|
1572
|
+
- Always read context files before starting (from the apply instructions output)
|
|
1573
|
+
- If task is ambiguous, use **AskUserQuestion tool** with preset options to clarify before implementing
|
|
1574
|
+
- If implementation reveals issues, pause and suggest artifact updates
|
|
1575
|
+
- Keep code changes minimal and scoped to each task
|
|
1576
|
+
- Update task checkbox immediately after completing each task
|
|
1577
|
+
- Pause on errors, blockers, or unclear requirements - don't guess
|
|
1578
|
+
- Use contextFiles from CLI output, don't assume specific file names
|
|
1579
|
+
|
|
1580
|
+
**Fluid Workflow Integration**
|
|
1581
|
+
|
|
1582
|
+
This skill supports the "actions on a change" model:
|
|
1583
|
+
|
|
1584
|
+
- **Can be invoked anytime**: Before all artifacts are done (if tasks exist), after partial implementation, interleaved with other actions
|
|
1585
|
+
- **Allows artifact updates**: If implementation reveals design issues, suggest updating artifacts - not phase-locked, work fluidly`
|
|
1586
|
+
};
|
|
1587
|
+
}
|
|
1588
|
+
/**
|
|
1589
|
+
* Template for /opsx:ff slash command
|
|
1590
|
+
*/
|
|
1591
|
+
export function getOpsxFfCommandTemplate() {
|
|
1592
|
+
return {
|
|
1593
|
+
name: 'OPSX: Fast Forward',
|
|
1594
|
+
description: 'Create a change and generate all artifacts needed for implementation in one go',
|
|
1595
|
+
category: 'Workflow',
|
|
1596
|
+
tags: ['workflow', 'artifacts', 'experimental'],
|
|
1597
|
+
content: `Fast-forward through artifact creation - generate everything needed to start implementation.
|
|
1598
|
+
|
|
1599
|
+
**Input**: The argument after \`/opsx:ff\` is the change name (kebab-case), OR a description of what the user wants to build.
|
|
1600
|
+
|
|
1601
|
+
**Steps**
|
|
1602
|
+
|
|
1603
|
+
1. **If no input provided, ask what they want to build**
|
|
1604
|
+
|
|
1605
|
+
Use the **AskUserQuestion tool** (open-ended, no preset options) to ask:
|
|
1606
|
+
> "What change do you want to work on? Describe what you want to build or fix."
|
|
1607
|
+
|
|
1608
|
+
From their description, derive a kebab-case name (e.g., "add user authentication" → \`add-user-auth\`).
|
|
1609
|
+
|
|
1610
|
+
**IMPORTANT**: Do NOT proceed without understanding what the user wants to build.
|
|
1611
|
+
|
|
1612
|
+
2. **Create the change directory**
|
|
1613
|
+
\`\`\`bash
|
|
1614
|
+
zhuanspec new change "<name>"
|
|
1615
|
+
\`\`\`
|
|
1616
|
+
This creates a scaffolded change at \`zhuanspec/changes/<name>/\`.
|
|
1617
|
+
|
|
1618
|
+
3. **Get the artifact build order**
|
|
1619
|
+
\`\`\`bash
|
|
1620
|
+
zhuanspec status --change "<name>" --json
|
|
1621
|
+
\`\`\`
|
|
1622
|
+
Parse the JSON to get:
|
|
1623
|
+
- \`applyRequires\`: array of artifact IDs needed before implementation (e.g., \`["tasks"]\`)
|
|
1624
|
+
- \`artifacts\`: list of all artifacts with their status and dependencies
|
|
1625
|
+
|
|
1626
|
+
4. **Create artifacts in sequence until apply-ready**
|
|
1627
|
+
|
|
1628
|
+
Use the **TodoWrite tool** to track progress through the artifacts.
|
|
1629
|
+
|
|
1630
|
+
Loop through artifacts in dependency order (artifacts with no pending dependencies first):
|
|
1631
|
+
|
|
1632
|
+
a. **For each artifact that is \`ready\` (dependencies satisfied)**:
|
|
1633
|
+
- Get instructions:
|
|
1634
|
+
\`\`\`bash
|
|
1635
|
+
zhuanspec instructions <artifact-id> --change "<name>" --json
|
|
1636
|
+
\`\`\`
|
|
1637
|
+
- The instructions JSON includes:
|
|
1638
|
+
- \`template\`: The template content to use
|
|
1639
|
+
- \`instruction\`: Schema-specific guidance for this artifact type
|
|
1640
|
+
- \`outputPath\`: Where to write the artifact
|
|
1641
|
+
- \`dependencies\`: Completed artifacts to read for context
|
|
1642
|
+
- Read any completed dependency files for context
|
|
1643
|
+
- Create the artifact file following the schema's \`instruction\`
|
|
1644
|
+
- Show brief progress: "✓ Created <artifact-id>"
|
|
1645
|
+
|
|
1646
|
+
b. **Continue until all \`applyRequires\` artifacts are complete**
|
|
1647
|
+
- After creating each artifact, re-run \`zhuanspec status --change "<name>" --json\`
|
|
1648
|
+
- Check if every artifact ID in \`applyRequires\` has \`status: "done"\` in the artifacts array
|
|
1649
|
+
- Stop when all \`applyRequires\` artifacts are done
|
|
1650
|
+
|
|
1651
|
+
c. **If an artifact requires user input** (unclear context):
|
|
1652
|
+
- Use **AskUserQuestion tool** with preset options to clarify (never ask for free-text input)
|
|
1653
|
+
- Then continue with creation
|
|
1654
|
+
|
|
1655
|
+
5. **Show final status**
|
|
1656
|
+
\`\`\`bash
|
|
1657
|
+
zhuanspec status --change "<name>"
|
|
1658
|
+
\`\`\`
|
|
1659
|
+
|
|
1660
|
+
**Output**
|
|
1661
|
+
|
|
1662
|
+
After completing all artifacts, summarize:
|
|
1663
|
+
- Change name and location
|
|
1664
|
+
- List of artifacts created with brief descriptions
|
|
1665
|
+
- What's ready: "All artifacts created! Ready for implementation."
|
|
1666
|
+
- Prompt: "Run \`/opsx:apply\` to start implementing."
|
|
1667
|
+
|
|
1668
|
+
**Artifact Creation Guidelines**
|
|
1669
|
+
|
|
1670
|
+
- Follow the \`instruction\` field from \`zhuanspec instructions\` for each artifact type
|
|
1671
|
+
- The schema defines what each artifact should contain - follow it
|
|
1672
|
+
- Read dependency artifacts for context before creating new ones
|
|
1673
|
+
- Use the \`template\` as a starting point, filling in based on context
|
|
1674
|
+
|
|
1675
|
+
**Guardrails**
|
|
1676
|
+
- Create ALL artifacts needed for implementation (as defined by schema's \`apply.requires\`)
|
|
1677
|
+
- Always read dependency artifacts before creating a new one
|
|
1678
|
+
- If context is critically unclear, use **AskUserQuestion tool** with preset options to clarify - but prefer making reasonable decisions to keep momentum
|
|
1679
|
+
- If a change with that name already exists, ask if user wants to continue it or create a new one
|
|
1680
|
+
- Verify each artifact file exists after writing before proceeding to next`
|
|
1681
|
+
};
|
|
1682
|
+
}
|
|
1683
|
+
/**
|
|
1684
|
+
* Template for zhuanspec-archive-change skill
|
|
1685
|
+
* For archiving completed changes in the experimental workflow
|
|
1686
|
+
*/
|
|
1687
|
+
export function getArchiveChangeSkillTemplate() {
|
|
1688
|
+
return {
|
|
1689
|
+
name: 'zhuanspec-archive-change',
|
|
1690
|
+
description: 'Archive a completed change in the experimental workflow. Use when the user wants to finalize and archive a change after implementation is complete.',
|
|
1691
|
+
instructions: `Archive a completed change in the experimental workflow.
|
|
1692
|
+
|
|
1693
|
+
**Input**: Optionally specify a change name. If omitted, MUST prompt for available changes.
|
|
1694
|
+
|
|
1695
|
+
**Steps**
|
|
1696
|
+
|
|
1697
|
+
1. **If no change name provided, prompt for selection**
|
|
1698
|
+
|
|
1699
|
+
Run \`zhuanspec list --json\` to get available changes. Use the **AskUserQuestion tool** to let the user select.
|
|
1700
|
+
|
|
1701
|
+
Show only active changes (not already archived).
|
|
1702
|
+
Include the schema used for each change if available.
|
|
1703
|
+
|
|
1704
|
+
**IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
|
|
1705
|
+
|
|
1706
|
+
2. **Check artifact completion status**
|
|
1707
|
+
|
|
1708
|
+
Run \`zhuanspec status --change "<name>" --json\` to check artifact completion.
|
|
1709
|
+
|
|
1710
|
+
Parse the JSON to understand:
|
|
1711
|
+
- \`schemaName\`: The workflow being used
|
|
1712
|
+
- \`artifacts\`: List of artifacts with their status (\`done\` or other)
|
|
1713
|
+
|
|
1714
|
+
**If any artifacts are not \`done\`:**
|
|
1715
|
+
- Display warning listing incomplete artifacts
|
|
1716
|
+
- Use **AskUserQuestion tool** to confirm user wants to proceed
|
|
1717
|
+
- Proceed if user confirms
|
|
1718
|
+
|
|
1719
|
+
3. **Check task completion status**
|
|
1720
|
+
|
|
1721
|
+
Read the tasks file (typically \`tasks.md\`) to check for incomplete tasks.
|
|
1722
|
+
|
|
1723
|
+
Count tasks marked with \`- [ ]\` (incomplete) vs \`- [x]\` (complete).
|
|
1724
|
+
|
|
1725
|
+
**If incomplete tasks found:**
|
|
1726
|
+
- Display warning showing count of incomplete tasks
|
|
1727
|
+
- Use **AskUserQuestion tool** to confirm user wants to proceed
|
|
1728
|
+
- Proceed if user confirms
|
|
1729
|
+
|
|
1730
|
+
**If no tasks file exists:** Proceed without task-related warning.
|
|
1731
|
+
|
|
1732
|
+
4. **Check if delta specs need syncing**
|
|
1733
|
+
|
|
1734
|
+
Check if \`specs/\` directory exists in the change with spec files.
|
|
1735
|
+
|
|
1736
|
+
**If delta specs exist, perform a quick sync check:**
|
|
1737
|
+
|
|
1738
|
+
a. **For each delta spec** at \`zhuanspec/changes/<name>/specs/<capability>/spec.md\`:
|
|
1739
|
+
- Extract requirement names (lines matching \`### Requirement: <name>\`)
|
|
1740
|
+
- Note which sections exist (ADDED, MODIFIED, REMOVED)
|
|
1741
|
+
|
|
1742
|
+
b. **Check corresponding main spec** at \`zhuanspec/specs/<capability>/spec.md\`:
|
|
1743
|
+
- If main spec doesn't exist → needs sync
|
|
1744
|
+
- If main spec exists, check if ADDED requirement names appear in it
|
|
1745
|
+
- If any ADDED requirements are missing from main spec → needs sync
|
|
1746
|
+
|
|
1747
|
+
c. **Report findings:**
|
|
1748
|
+
|
|
1749
|
+
**If sync needed:**
|
|
1750
|
+
\`\`\`
|
|
1751
|
+
⚠️ Delta specs may not be synced:
|
|
1752
|
+
- specs/auth/spec.md → Main spec missing requirement "Token Refresh"
|
|
1753
|
+
- specs/api/spec.md → Main spec doesn't exist yet
|
|
1754
|
+
|
|
1755
|
+
Would you like to sync now before archiving?
|
|
1756
|
+
\`\`\`
|
|
1757
|
+
- Use **AskUserQuestion tool** with options: "Sync now", "Archive without syncing"
|
|
1758
|
+
- If user chooses sync, execute /opsx:sync logic (use the zhuanspec-sync-specs skill)
|
|
1759
|
+
|
|
1760
|
+
**If already synced (all requirements found):**
|
|
1761
|
+
- Proceed without prompting (specs appear to be in sync)
|
|
1762
|
+
|
|
1763
|
+
**If no delta specs exist:** Proceed without sync-related checks.
|
|
1764
|
+
|
|
1765
|
+
5. **Perform the archive**
|
|
1766
|
+
|
|
1767
|
+
Create the archive directory if it doesn't exist:
|
|
1768
|
+
\`\`\`bash
|
|
1769
|
+
mkdir -p zhuanspec/changes/archive
|
|
1770
|
+
\`\`\`
|
|
1771
|
+
|
|
1772
|
+
Generate target name using current date: \`YYYY-MM-DD-<change-name>\`
|
|
1773
|
+
|
|
1774
|
+
**Check if target already exists:**
|
|
1775
|
+
- If yes: Fail with error, suggest renaming existing archive or using different date
|
|
1776
|
+
- If no: Move the change directory to archive
|
|
1777
|
+
|
|
1778
|
+
\`\`\`bash
|
|
1779
|
+
mv zhuanspec/changes/<name> zhuanspec/changes/archive/YYYY-MM-DD-<name>
|
|
1780
|
+
\`\`\`
|
|
1781
|
+
|
|
1782
|
+
6. **Display summary**
|
|
1783
|
+
|
|
1784
|
+
Show archive completion summary including:
|
|
1785
|
+
- Change name
|
|
1786
|
+
- Schema that was used
|
|
1787
|
+
- Archive location
|
|
1788
|
+
- Whether specs were synced (if applicable)
|
|
1789
|
+
- Note about any warnings (incomplete artifacts/tasks)
|
|
1790
|
+
|
|
1791
|
+
**Output On Success**
|
|
1792
|
+
|
|
1793
|
+
\`\`\`
|
|
1794
|
+
## Archive Complete
|
|
1795
|
+
|
|
1796
|
+
**Change:** <change-name>
|
|
1797
|
+
**Schema:** <schema-name>
|
|
1798
|
+
**Archived to:** zhuanspec/changes/archive/YYYY-MM-DD-<name>/
|
|
1799
|
+
**Specs:** ✓ Synced to main specs (or "No delta specs" or "⚠️ Not synced")
|
|
1800
|
+
|
|
1801
|
+
All artifacts complete. All tasks complete.
|
|
1802
|
+
\`\`\`
|
|
1803
|
+
|
|
1804
|
+
**Guardrails**
|
|
1805
|
+
- Always prompt for change selection if not provided
|
|
1806
|
+
- Use artifact graph (zhuanspec status --json) for completion checking
|
|
1807
|
+
- Don't block archive on warnings - just inform and confirm
|
|
1808
|
+
- Preserve .zhuanspec.yaml when moving to archive (it moves with the directory)
|
|
1809
|
+
- Show clear summary of what happened
|
|
1810
|
+
- If sync is requested, use zhuanspec-sync-specs approach (agent-driven)
|
|
1811
|
+
- Quick sync check: look for requirement names in delta specs, verify they exist in main specs`
|
|
1812
|
+
};
|
|
1813
|
+
}
|
|
1814
|
+
/**
|
|
1815
|
+
* Template for /opsx:sync slash command
|
|
1816
|
+
*/
|
|
1817
|
+
export function getOpsxSyncCommandTemplate() {
|
|
1818
|
+
return {
|
|
1819
|
+
name: 'OPSX: Sync',
|
|
1820
|
+
description: 'Sync delta specs from a change to main specs',
|
|
1821
|
+
category: 'Workflow',
|
|
1822
|
+
tags: ['workflow', 'specs', 'experimental'],
|
|
1823
|
+
content: `Sync delta specs from a change to main specs.
|
|
1824
|
+
|
|
1825
|
+
This is an **agent-driven** operation - you will read delta specs and directly edit main specs to apply the changes. This allows intelligent merging (e.g., adding a scenario without copying the entire requirement).
|
|
1826
|
+
|
|
1827
|
+
**Input**: Optionally specify \`--change <name>\` after \`/opsx:sync\`. If omitted, MUST prompt for available changes.
|
|
1828
|
+
|
|
1829
|
+
**Steps**
|
|
1830
|
+
|
|
1831
|
+
1. **If no change name provided, prompt for selection**
|
|
1832
|
+
|
|
1833
|
+
Run \`zhuanspec list --json\` to get available changes. Use the **AskUserQuestion tool** to let the user select.
|
|
1834
|
+
|
|
1835
|
+
Show changes that have delta specs (under \`specs/\` directory).
|
|
1836
|
+
|
|
1837
|
+
**IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
|
|
1838
|
+
|
|
1839
|
+
2. **Find delta specs**
|
|
1840
|
+
|
|
1841
|
+
Look for delta spec files in \`zhuanspec/changes/<name>/specs/*/spec.md\`.
|
|
1842
|
+
|
|
1843
|
+
Each delta spec file contains sections like:
|
|
1844
|
+
- \`## ADDED Requirements\` - New requirements to add
|
|
1845
|
+
- \`## MODIFIED Requirements\` - Changes to existing requirements
|
|
1846
|
+
- \`## REMOVED Requirements\` - Requirements to remove
|
|
1847
|
+
- \`## RENAMED Requirements\` - Requirements to rename (FROM:/TO: format)
|
|
1848
|
+
|
|
1849
|
+
If no delta specs found, inform user and stop.
|
|
1850
|
+
|
|
1851
|
+
3. **For each delta spec, apply changes to main specs**
|
|
1852
|
+
|
|
1853
|
+
For each capability with a delta spec at \`zhuanspec/changes/<name>/specs/<capability>/spec.md\`:
|
|
1854
|
+
|
|
1855
|
+
a. **Read the delta spec** to understand the intended changes
|
|
1856
|
+
|
|
1857
|
+
b. **Read the main spec** at \`zhuanspec/specs/<capability>/spec.md\` (may not exist yet)
|
|
1858
|
+
|
|
1859
|
+
c. **Apply changes intelligently**:
|
|
1860
|
+
|
|
1861
|
+
**ADDED Requirements:**
|
|
1862
|
+
- If requirement doesn't exist in main spec → add it
|
|
1863
|
+
- If requirement already exists → update it to match (treat as implicit MODIFIED)
|
|
1864
|
+
|
|
1865
|
+
**MODIFIED Requirements:**
|
|
1866
|
+
- Find the requirement in main spec
|
|
1867
|
+
- Apply the changes - this can be:
|
|
1868
|
+
- Adding new scenarios (don't need to copy existing ones)
|
|
1869
|
+
- Modifying existing scenarios
|
|
1870
|
+
- Changing the requirement description
|
|
1871
|
+
- Preserve scenarios/content not mentioned in the delta
|
|
1872
|
+
|
|
1873
|
+
**REMOVED Requirements:**
|
|
1874
|
+
- Remove the entire requirement block from main spec
|
|
1875
|
+
|
|
1876
|
+
**RENAMED Requirements:**
|
|
1877
|
+
- Find the FROM requirement, rename to TO
|
|
1878
|
+
|
|
1879
|
+
d. **Create new main spec** if capability doesn't exist yet:
|
|
1880
|
+
- Create \`zhuanspec/specs/<capability>/spec.md\`
|
|
1881
|
+
- Add Purpose section (can be brief, mark as TBD)
|
|
1882
|
+
- Add Requirements section with the ADDED requirements
|
|
1883
|
+
|
|
1884
|
+
4. **Show summary**
|
|
1885
|
+
|
|
1886
|
+
After applying all changes, summarize:
|
|
1887
|
+
- Which capabilities were updated
|
|
1888
|
+
- What changes were made (requirements added/modified/removed/renamed)
|
|
1889
|
+
|
|
1890
|
+
**Delta Spec Format Reference**
|
|
1891
|
+
|
|
1892
|
+
\`\`\`markdown
|
|
1893
|
+
## ADDED Requirements
|
|
1894
|
+
|
|
1895
|
+
### Requirement: New Feature
|
|
1896
|
+
The system SHALL do something new.
|
|
1897
|
+
|
|
1898
|
+
#### Scenario: Basic case
|
|
1899
|
+
- **WHEN** user does X
|
|
1900
|
+
- **THEN** system does Y
|
|
1901
|
+
|
|
1902
|
+
## MODIFIED Requirements
|
|
1903
|
+
|
|
1904
|
+
### Requirement: Existing Feature
|
|
1905
|
+
#### Scenario: New scenario to add
|
|
1906
|
+
- **WHEN** user does A
|
|
1907
|
+
- **THEN** system does B
|
|
1908
|
+
|
|
1909
|
+
## REMOVED Requirements
|
|
1910
|
+
|
|
1911
|
+
### Requirement: Deprecated Feature
|
|
1912
|
+
|
|
1913
|
+
## RENAMED Requirements
|
|
1914
|
+
|
|
1915
|
+
- FROM: \`### Requirement: Old Name\`
|
|
1916
|
+
- TO: \`### Requirement: New Name\`
|
|
1917
|
+
\`\`\`
|
|
1918
|
+
|
|
1919
|
+
**Key Principle: Intelligent Merging**
|
|
1920
|
+
|
|
1921
|
+
Unlike programmatic merging, you can apply **partial updates**:
|
|
1922
|
+
- To add a scenario, just include that scenario under MODIFIED - don't copy existing scenarios
|
|
1923
|
+
- The delta represents *intent*, not a wholesale replacement
|
|
1924
|
+
- Use your judgment to merge changes sensibly
|
|
1925
|
+
|
|
1926
|
+
**Output On Success**
|
|
1927
|
+
|
|
1928
|
+
\`\`\`
|
|
1929
|
+
## Specs Synced: <change-name>
|
|
1930
|
+
|
|
1931
|
+
Updated main specs:
|
|
1932
|
+
|
|
1933
|
+
**<capability-1>**:
|
|
1934
|
+
- Added requirement: "New Feature"
|
|
1935
|
+
- Modified requirement: "Existing Feature" (added 1 scenario)
|
|
1936
|
+
|
|
1937
|
+
**<capability-2>**:
|
|
1938
|
+
- Created new spec file
|
|
1939
|
+
- Added requirement: "Another Feature"
|
|
1940
|
+
|
|
1941
|
+
Main specs are now updated. The change remains active - archive when implementation is complete.
|
|
1942
|
+
\`\`\`
|
|
1943
|
+
|
|
1944
|
+
**Guardrails**
|
|
1945
|
+
- Read both delta and main specs before making changes
|
|
1946
|
+
- Preserve existing content not mentioned in delta
|
|
1947
|
+
- If something is unclear, use **AskUserQuestion tool** with preset options to clarify
|
|
1948
|
+
- Show what you're changing as you go
|
|
1949
|
+
- The operation should be idempotent - running twice should give same result`
|
|
1950
|
+
};
|
|
1951
|
+
}
|
|
1952
|
+
/**
|
|
1953
|
+
* Template for /opsx:archive slash command
|
|
1954
|
+
*/
|
|
1955
|
+
export function getOpsxArchiveCommandTemplate() {
|
|
1956
|
+
return {
|
|
1957
|
+
name: 'OPSX: Archive',
|
|
1958
|
+
description: 'Archive a completed change in the experimental workflow',
|
|
1959
|
+
category: 'Workflow',
|
|
1960
|
+
tags: ['workflow', 'archive', 'experimental'],
|
|
1961
|
+
content: `Archive a completed change in the experimental workflow.
|
|
1962
|
+
|
|
1963
|
+
**Input**: Optionally specify \`--change <name>\` after \`/opsx:archive\`. If omitted, MUST prompt for available changes.
|
|
1964
|
+
|
|
1965
|
+
**Steps**
|
|
1966
|
+
|
|
1967
|
+
1. **If no change name provided, prompt for selection**
|
|
1968
|
+
|
|
1969
|
+
Run \`zhuanspec list --json\` to get available changes. Use the **AskUserQuestion tool** to let the user select.
|
|
1970
|
+
|
|
1971
|
+
Show only active changes (not already archived).
|
|
1972
|
+
Include the schema used for each change if available.
|
|
1973
|
+
|
|
1974
|
+
**IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
|
|
1975
|
+
|
|
1976
|
+
2. **Check artifact completion status**
|
|
1977
|
+
|
|
1978
|
+
Run \`zhuanspec status --change "<name>" --json\` to check artifact completion.
|
|
1979
|
+
|
|
1980
|
+
Parse the JSON to understand:
|
|
1981
|
+
- \`schemaName\`: The workflow being used
|
|
1982
|
+
- \`artifacts\`: List of artifacts with their status (\`done\` or other)
|
|
1983
|
+
|
|
1984
|
+
**If any artifacts are not \`done\`:**
|
|
1985
|
+
- Display warning listing incomplete artifacts
|
|
1986
|
+
- Prompt user for confirmation to continue
|
|
1987
|
+
- Proceed if user confirms
|
|
1988
|
+
|
|
1989
|
+
3. **Check task completion status**
|
|
1990
|
+
|
|
1991
|
+
Read the tasks file (typically \`tasks.md\`) to check for incomplete tasks.
|
|
1992
|
+
|
|
1993
|
+
Count tasks marked with \`- [ ]\` (incomplete) vs \`- [x]\` (complete).
|
|
1994
|
+
|
|
1995
|
+
**If incomplete tasks found:**
|
|
1996
|
+
- Display warning showing count of incomplete tasks
|
|
1997
|
+
- Prompt user for confirmation to continue
|
|
1998
|
+
- Proceed if user confirms
|
|
1999
|
+
|
|
2000
|
+
**If no tasks file exists:** Proceed without task-related warning.
|
|
2001
|
+
|
|
2002
|
+
4. **Check if delta specs need syncing**
|
|
2003
|
+
|
|
2004
|
+
Check if \`specs/\` directory exists in the change with spec files.
|
|
2005
|
+
|
|
2006
|
+
**If delta specs exist, perform a quick sync check:**
|
|
2007
|
+
|
|
2008
|
+
a. **For each delta spec** at \`zhuanspec/changes/<name>/specs/<capability>/spec.md\`:
|
|
2009
|
+
- Extract requirement names (lines matching \`### Requirement: <name>\`)
|
|
2010
|
+
- Note which sections exist (ADDED, MODIFIED, REMOVED)
|
|
2011
|
+
|
|
2012
|
+
b. **Check corresponding main spec** at \`zhuanspec/specs/<capability>/spec.md\`:
|
|
2013
|
+
- If main spec doesn't exist → needs sync
|
|
2014
|
+
- If main spec exists, check if ADDED requirement names appear in it
|
|
2015
|
+
- If any ADDED requirements are missing from main spec → needs sync
|
|
2016
|
+
|
|
2017
|
+
c. **Report findings:**
|
|
2018
|
+
|
|
2019
|
+
**If sync needed:**
|
|
2020
|
+
\`\`\`
|
|
2021
|
+
⚠️ Delta specs may not be synced:
|
|
2022
|
+
- specs/auth/spec.md → Main spec missing requirement "Token Refresh"
|
|
2023
|
+
- specs/api/spec.md → Main spec doesn't exist yet
|
|
2024
|
+
|
|
2025
|
+
Would you like to sync now before archiving?
|
|
2026
|
+
\`\`\`
|
|
2027
|
+
- Use **AskUserQuestion tool** with options: "Sync now", "Archive without syncing"
|
|
2028
|
+
- If user chooses sync, execute \`/opsx:sync\` logic
|
|
2029
|
+
|
|
2030
|
+
**If already synced (all requirements found):**
|
|
2031
|
+
- Proceed without prompting (specs appear to be in sync)
|
|
2032
|
+
|
|
2033
|
+
**If no delta specs exist:** Proceed without sync-related checks.
|
|
2034
|
+
|
|
2035
|
+
5. **Perform the archive**
|
|
2036
|
+
|
|
2037
|
+
Create the archive directory if it doesn't exist:
|
|
2038
|
+
\`\`\`bash
|
|
2039
|
+
mkdir -p zhuanspec/changes/archive
|
|
2040
|
+
\`\`\`
|
|
2041
|
+
|
|
2042
|
+
Generate target name using current date: \`YYYY-MM-DD-<change-name>\`
|
|
2043
|
+
|
|
2044
|
+
**Check if target already exists:**
|
|
2045
|
+
- If yes: Fail with error, suggest renaming existing archive or using different date
|
|
2046
|
+
- If no: Move the change directory to archive
|
|
2047
|
+
|
|
2048
|
+
\`\`\`bash
|
|
2049
|
+
mv zhuanspec/changes/<name> zhuanspec/changes/archive/YYYY-MM-DD-<name>
|
|
2050
|
+
\`\`\`
|
|
2051
|
+
|
|
2052
|
+
6. **Display summary**
|
|
2053
|
+
|
|
2054
|
+
Show archive completion summary including:
|
|
2055
|
+
- Change name
|
|
2056
|
+
- Schema that was used
|
|
2057
|
+
- Archive location
|
|
2058
|
+
- Spec sync status (synced / not synced / no delta specs)
|
|
2059
|
+
- Note about any warnings (incomplete artifacts/tasks)
|
|
2060
|
+
|
|
2061
|
+
**Output On Success**
|
|
2062
|
+
|
|
2063
|
+
\`\`\`
|
|
2064
|
+
## Archive Complete
|
|
2065
|
+
|
|
2066
|
+
**Change:** <change-name>
|
|
2067
|
+
**Schema:** <schema-name>
|
|
2068
|
+
**Archived to:** zhuanspec/changes/archive/YYYY-MM-DD-<name>/
|
|
2069
|
+
**Specs:** ✓ Synced to main specs
|
|
2070
|
+
|
|
2071
|
+
All artifacts complete. All tasks complete.
|
|
2072
|
+
\`\`\`
|
|
2073
|
+
|
|
2074
|
+
**Output On Success (No Delta Specs)**
|
|
2075
|
+
|
|
2076
|
+
\`\`\`
|
|
2077
|
+
## Archive Complete
|
|
2078
|
+
|
|
2079
|
+
**Change:** <change-name>
|
|
2080
|
+
**Schema:** <schema-name>
|
|
2081
|
+
**Archived to:** zhuanspec/changes/archive/YYYY-MM-DD-<name>/
|
|
2082
|
+
**Specs:** No delta specs
|
|
2083
|
+
|
|
2084
|
+
All artifacts complete. All tasks complete.
|
|
2085
|
+
\`\`\`
|
|
2086
|
+
|
|
2087
|
+
**Output On Success With Warnings**
|
|
2088
|
+
|
|
2089
|
+
\`\`\`
|
|
2090
|
+
## Archive Complete (with warnings)
|
|
2091
|
+
|
|
2092
|
+
**Change:** <change-name>
|
|
2093
|
+
**Schema:** <schema-name>
|
|
2094
|
+
**Archived to:** zhuanspec/changes/archive/YYYY-MM-DD-<name>/
|
|
2095
|
+
**Specs:** ⚠️ Not synced
|
|
2096
|
+
|
|
2097
|
+
**Warnings:**
|
|
2098
|
+
- Archived with 2 incomplete artifacts
|
|
2099
|
+
- Archived with 3 incomplete tasks
|
|
2100
|
+
- Delta specs were not synced (user chose to skip)
|
|
2101
|
+
|
|
2102
|
+
Review the archive if this was not intentional.
|
|
2103
|
+
\`\`\`
|
|
2104
|
+
|
|
2105
|
+
**Output On Error (Archive Exists)**
|
|
2106
|
+
|
|
2107
|
+
\`\`\`
|
|
2108
|
+
## Archive Failed
|
|
2109
|
+
|
|
2110
|
+
**Change:** <change-name>
|
|
2111
|
+
**Target:** zhuanspec/changes/archive/YYYY-MM-DD-<name>/
|
|
2112
|
+
|
|
2113
|
+
Target archive directory already exists.
|
|
2114
|
+
|
|
2115
|
+
**Options:**
|
|
2116
|
+
1. Rename the existing archive
|
|
2117
|
+
2. Delete the existing archive if it's a duplicate
|
|
2118
|
+
3. Wait until a different date to archive
|
|
2119
|
+
\`\`\`
|
|
2120
|
+
|
|
2121
|
+
**Guardrails**
|
|
2122
|
+
- Always prompt for change selection if not provided
|
|
2123
|
+
- Use artifact graph (zhuanspec status --json) for completion checking
|
|
2124
|
+
- Don't block archive on warnings - just inform and confirm
|
|
2125
|
+
- Preserve .zhuanspec.yaml when moving to archive (it moves with the directory)
|
|
2126
|
+
- Quick sync check: look for requirement names in delta specs, verify they exist in main specs
|
|
2127
|
+
- Show clear summary of what happened
|
|
2128
|
+
- If sync is requested, use /opsx:sync approach (agent-driven)`
|
|
2129
|
+
};
|
|
2130
|
+
}
|
|
2131
|
+
//# sourceMappingURL=skill-templates.js.map
|