Skip to content

Commit c77a573

Browse files
Revert "refactor: address PR Fission-AI#790 review feedback"
This reverts commit 9b10d02.
1 parent 9b10d02 commit c77a573

File tree

7 files changed

+154
-24
lines changed

7 files changed

+154
-24
lines changed

build.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ import { execFileSync } from 'child_process';
44
import { existsSync, rmSync } from 'fs';
55
import { createRequire } from 'module';
66

7+
// When npm installs from a git dep (github:user/repo#branch), it runs
8+
// `prepare` before node_modules exist. Skip gracefully and let `prepack`
9+
// handle the build during the pack phase where deps are available.
10+
if (!existsSync('node_modules')) {
11+
console.log('⏭️ Skipping build (node_modules not yet available)');
12+
process.exit(0);
13+
}
14+
715
const require = createRequire(import.meta.url);
816

917
const runTsc = (args = []) => {

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@
4848
"test:ui": "vitest --ui",
4949
"test:coverage": "vitest --coverage",
5050
"test:postinstall": "node scripts/postinstall.js",
51-
"prepare": "pnpm run build",
51+
"prepare": "node build.js",
52+
"prepack": "node build.js",
5253
"prepublishOnly": "pnpm run build",
53-
"postinstall": "node scripts/postinstall.js",
54+
"postinstall": "node scripts/postinstall.js || true",
5455
"check:pack-version": "node scripts/pack-version-check.mjs",
5556
"release": "pnpm run release:ci",
5657
"release:ci": "pnpm run check:pack-version && pnpm exec changeset publish",

schemas/dispec-driven/schema.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: dispec-driven
22
version: 1
3-
description: Distributed spec-driven workflow - proposal → (specs + design) → tasks → dependencies → distribution
3+
description: Distributed spec-driven workflow - proposal → specs design → tasks → dependencies → distribution
44
artifacts:
55
- id: proposal
66
generates: proposal.md

schemas/dispec-driven/templates/distribution.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,21 @@
1818

1919
## Agent Assignments
2020

21-
<!-- Repeat this card for each agent (recommended: 3-5 agents) -->
21+
### Agent 1: <!-- agent name/focus area -->
2222

23-
### Agent N: <!-- agent name/focus area -->
23+
**Tasks:**
24+
<!-- List assigned task IDs -->
25+
26+
**File ownership:**
27+
<!-- Files this agent is responsible for -->
28+
29+
**Execution order:**
30+
<!-- Order respecting dependencies -->
31+
32+
**Cross-agent dependencies:**
33+
<!-- Tasks from other agents this agent must wait for -->
34+
35+
### Agent 2: <!-- agent name/focus area -->
2436

2537
**Tasks:**
2638
<!-- List assigned task IDs -->

src/core/templates/workflows/multiagent.ts

Lines changed: 123 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
*/
77
import type { SkillTemplate, CommandTemplate } from '../types.js';
88

9-
const MULTIAGENT_INSTRUCTIONS = `Plan and distribute a change across multiple AI agents for parallel execution.
9+
export function getOpsxMultiagentSkillTemplate(): SkillTemplate {
10+
return {
11+
name: 'openspec-multiagent',
12+
description: 'Plan and distribute a change across multiple AI agents for parallel execution. Use when the user wants to break down a complex change into tasks that can be worked on simultaneously by a team of agents.',
13+
instructions: `Plan and distribute a change across multiple AI agents for parallel execution.
1014
1115
I'll create a change with artifacts:
1216
- proposal.md (what & why)
@@ -20,11 +24,11 @@ When ready to implement, run /opsx:multiagent-apply
2024
2125
---
2226
23-
**Input**: The argument after \`/opsx:multiagent\` is the change name (kebab-case), OR a description of what the user wants to build.
27+
**Input**: The user's request should include a change name (kebab-case) OR a description of what they want to build.
2428
2529
**Steps**
2630
27-
1. **If no input provided, ask what they want to build**
31+
1. **If no clear input provided, ask what they want to build**
2832
2933
Use the **AskUserQuestion tool** (open-ended, no preset options) to ask:
3034
> "What change do you want to work on? Describe what you want to build or fix."
@@ -74,13 +78,11 @@ When ready to implement, run /opsx:multiagent-apply
7478
> "How many agents do you want to distribute tasks across? (Recommended: 3-5)"
7579
7680
With options:
77-
- "2 agents" - Minimum viable parallelism
7881
- "3 agents (Recommended)" - Good balance of parallelism and coordination
7982
- "4 agents" - More parallelism, moderate coordination
8083
- "5 agents" - Maximum parallelism, higher coordination overhead
8184
82-
If the user selects fewer than 2, suggest using \`/opsx:propose\` instead for a simpler single-agent workflow.
83-
If the user requests more than 5, warn about coordination overhead and recommend 3-5 agents.
85+
If the user selects 1 agent, suggest using \`/opsx:propose\` instead for a simpler single-agent workflow.
8486
8587
c. **Continue until all \`applyRequires\` artifacts are complete**
8688
- After creating each artifact, re-run \`openspec status --change "<name>" --json\`
@@ -121,13 +123,7 @@ After completing all artifacts, summarize:
121123
- Always read dependency artifacts before creating a new one
122124
- If context is critically unclear, ask the user - but prefer making reasonable decisions to keep momentum
123125
- If a change with that name already exists, ask if user wants to continue it or create a new one
124-
- Verify each artifact file exists after writing before proceeding to next`;
125-
126-
export function getOpsxMultiagentSkillTemplate(): SkillTemplate {
127-
return {
128-
name: 'openspec-multiagent',
129-
description: 'Plan and distribute a change across multiple AI agents for parallel execution. Use when the user wants to break down a complex change into tasks that can be worked on simultaneously by a team of agents.',
130-
instructions: MULTIAGENT_INSTRUCTIONS,
126+
- Verify each artifact file exists after writing before proceeding to next`,
131127
license: 'MIT',
132128
compatibility: 'Requires openspec CLI.',
133129
metadata: { author: 'openspec', version: '1.0' },
@@ -140,6 +136,119 @@ export function getOpsxMultiagentCommandTemplate(): CommandTemplate {
140136
description: 'Plan and distribute a change across multiple AI agents for parallel execution',
141137
category: 'Workflow',
142138
tags: ['workflow', 'artifacts', 'multiagent', 'experimental'],
143-
content: MULTIAGENT_INSTRUCTIONS,
139+
content: `Plan and distribute a change across multiple AI agents for parallel execution.
140+
141+
I'll create a change with artifacts:
142+
- proposal.md (what & why)
143+
- specs/ (detailed specifications)
144+
- design.md (how, with parallelism considerations)
145+
- tasks.md (implementation steps with file ownership)
146+
- dependencies.md (task dependency analysis)
147+
- distribution.md (agent assignment plan)
148+
149+
When ready to implement, run /opsx:multiagent-apply
150+
151+
---
152+
153+
**Input**: The argument after \`/opsx:multiagent\` is the change name (kebab-case), OR a description of what the user wants to build.
154+
155+
**Steps**
156+
157+
1. **If no input provided, ask what they want to build**
158+
159+
Use the **AskUserQuestion tool** (open-ended, no preset options) to ask:
160+
> "What change do you want to work on? Describe what you want to build or fix."
161+
162+
From their description, derive a kebab-case name (e.g., "add user authentication" → \`add-user-auth\`).
163+
164+
**IMPORTANT**: Do NOT proceed without understanding what the user wants to build.
165+
166+
2. **Create the change directory**
167+
\`\`\`bash
168+
openspec new change "<name>" --schema dispec-driven
169+
\`\`\`
170+
This creates a scaffolded change at \`openspec/changes/<name>/\` with \`.openspec.yaml\` using the dispec-driven schema.
171+
172+
3. **Get the artifact build order**
173+
\`\`\`bash
174+
openspec status --change "<name>" --json
175+
\`\`\`
176+
Parse the JSON to get:
177+
- \`applyRequires\`: array of artifact IDs needed before implementation (e.g., \`["distribution"]\`)
178+
- \`artifacts\`: list of all artifacts with their status and dependencies
179+
180+
4. **Create artifacts in sequence until apply-ready**
181+
182+
Use **TaskCreate** and **TaskUpdate** tools to track progress through the artifacts.
183+
184+
Loop through artifacts in dependency order (artifacts with no pending dependencies first):
185+
186+
a. **For each artifact that is \`ready\` (dependencies satisfied)**:
187+
- Get instructions:
188+
\`\`\`bash
189+
openspec instructions <artifact-id> --change "<name>" --json
190+
\`\`\`
191+
- The instructions JSON includes:
192+
- \`context\`: Project background (constraints for you - do NOT include in output)
193+
- \`rules\`: Artifact-specific rules (constraints for you - do NOT include in output)
194+
- \`template\`: The structure to use for your output file
195+
- \`instruction\`: Schema-specific guidance for this artifact type
196+
- \`outputPath\`: Where to write the artifact
197+
- \`dependencies\`: Completed artifacts to read for context
198+
- Read any completed dependency files for context
199+
- Create the artifact file using \`template\` as the structure
200+
- Apply \`context\` and \`rules\` as constraints - but do NOT copy them into the file
201+
- Show brief progress: "Created <artifact-id>"
202+
203+
b. **For the distribution artifact**: Use the **AskUserQuestion tool** to ask:
204+
> "How many agents do you want to distribute tasks across? (Recommended: 3-5)"
205+
206+
With options:
207+
- "3 agents (Recommended)" - Good balance of parallelism and coordination
208+
- "4 agents" - More parallelism, moderate coordination
209+
- "5 agents" - Maximum parallelism, higher coordination overhead
210+
211+
If the user selects 1 agent, suggest using \`/opsx:propose\` instead for a simpler single-agent workflow.
212+
213+
c. **Continue until all \`applyRequires\` artifacts are complete**
214+
- After creating each artifact, re-run \`openspec status --change "<name>" --json\`
215+
- Check if every artifact ID in \`applyRequires\` has \`status: "done"\` in the artifacts array
216+
- Stop when all \`applyRequires\` artifacts are done
217+
218+
d. **If an artifact requires user input** (unclear context):
219+
- Use **AskUserQuestion tool** to clarify
220+
- Then continue with creation
221+
222+
5. **Show final status**
223+
\`\`\`bash
224+
openspec status --change "<name>"
225+
\`\`\`
226+
227+
**Output**
228+
229+
After completing all artifacts, summarize:
230+
- Change name and location
231+
- List of artifacts created with brief descriptions
232+
- **Agent assignment summary**: Which tasks go to which agent
233+
- **Token cost warning**: Remind that N agents ≈ N× token usage
234+
- What's ready: "All artifacts created! Ready for multi-agent implementation."
235+
- Prompt: "Run \`/opsx:multiagent-apply\` to orchestrate a Claude Code agent team for parallel implementation."
236+
237+
**Artifact Creation Guidelines**
238+
239+
- Follow the \`instruction\` field from \`openspec instructions\` for each artifact type
240+
- The schema defines what each artifact should contain - follow it
241+
- Read dependency artifacts for context before creating new ones
242+
- Use \`template\` as the structure for your output file - fill in its sections
243+
- **IMPORTANT**: \`context\` and \`rules\` are constraints for YOU, not content for the file
244+
- Do NOT copy \`<context>\`, \`<rules>\`, \`<project_context>\` blocks into the artifact
245+
- These guide what you write, but should never appear in the output
246+
247+
**Guardrails**
248+
- Create ALL artifacts needed for implementation (as defined by schema's \`apply.requires\`)
249+
- Always read dependency artifacts before creating a new one
250+
- If context is critically unclear, ask the user - but prefer making reasonable decisions to keep momentum
251+
- If a change with that name already exists, ask if user wants to continue it or create a new one
252+
- Verify each artifact file exists after writing before proceeding to next`
144253
};
145254
}

test/core/templates/skill-templates-parity.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ const EXPECTED_FUNCTION_HASHES: Record<string, string> = {
5656
getOpsxVerifyCommandTemplate: '9b4d3ca422553b7534764eb3a009da87a051612c5238e9baab294c7b1233e9a2',
5757
getOpsxProposeSkillTemplate: 'd67f937d44650e9c61d2158c865309fbab23cb3f50a3d4868a640a97776e3999',
5858
getOpsxProposeCommandTemplate: '41ad59b37eafd7a161bab5c6e41997a37368f9c90b194451295ede5cd42e4d46',
59-
getOpsxMultiagentSkillTemplate: '9f0869a754c0f316c76d0970d886cbf96ebd073c5ba62278a6b6707d3535ccf4',
60-
getOpsxMultiagentCommandTemplate: '353b3dc822145884acd27f33ed692b36f4b9d75349f350bb6ca9cbce01562892',
59+
getOpsxMultiagentSkillTemplate: 'd0f5057cdd58d2cd3ae917e916a36a376cd4d956e53c337d1af9efcb01414a07',
60+
getOpsxMultiagentCommandTemplate: '84c01236b6d55342a8786d5c2904cb0b5dd45cc9cbd2f81e82e1334d2c24e433',
6161
getOpsxMultiagentApplySkillTemplate: 'b90f8d481511a1c0d69651f2b7116166d044d12acfcc1fd9e336e4636cedfa05',
6262
getOpsxMultiagentApplyCommandTemplate: '046abe3e18f86a807e79fd1f399a9105cae93106d1448b1a989d57623baed4c6',
6363
getFeedbackSkillTemplate: 'd7d83c5f7fc2b92fe8f4588a5bf2d9cb315e4c73ec19bcd5ef28270906319a0d',
@@ -75,7 +75,7 @@ const EXPECTED_GENERATED_SKILL_CONTENT_HASHES: Record<string, string> = {
7575
'openspec-verify-change': '30d07c6f7051965f624f5964db51844ec17c7dfd05f0da95281fe0ca73616326',
7676
'openspec-onboard': 'dbce376cf895f3fe4f63b4bce66d258c35b7b8884ac746670e5e35fabcefd255',
7777
'openspec-propose': '20e36dabefb90e232bad0667292bd5007ec280f8fc4fc995dbc4282bf45a22e7',
78-
'openspec-multiagent': '4aeb273e34f9b4ac7385bc636ca4ddbd401b43afd2f9834eda76790617f5aa9c',
78+
'openspec-multiagent': 'e061c1d547c7fa8e647fb91fc80d236fe7751f3e180dd06914ee519bb9148695',
7979
'openspec-multiagent-apply': '55300df760099dca2f7e965d63d9bd75b7e2152b35638f9ac66a4f516d167204',
8080
};
8181

0 commit comments

Comments
 (0)