Skip to content

feat: add multi-agent orchestration workflow with dispec-driven schema#790

Open
pformoso-deus-ai wants to merge 7 commits intoFission-AI:mainfrom
pabloformoso:feat/multiagent-workflow
Open

feat: add multi-agent orchestration workflow with dispec-driven schema#790
pformoso-deus-ai wants to merge 7 commits intoFission-AI:mainfrom
pabloformoso:feat/multiagent-workflow

Conversation

@pformoso-deus-ai
Copy link

@pformoso-deus-ai pformoso-deus-ai commented Mar 2, 2026

Summary

Adds a multi-agent orchestration workflow that enables distributing OpenSpec changes across multiple AI agents for parallel execution.

  • New dispec-driven schema: Extends the default workflow with dependencies.md (dependency analysis) and distribution.md (agent work packages) artifacts for planning parallel agent work
  • /opsx:multiagent workflow: Analyzes a change's tasks and specs, builds a dependency graph, and generates a distribution plan that assigns work packages to agents with clear boundaries
  • /opsx:multiagent-apply workflow: Orchestrates a Claude Code agent team to implement the distribution plan in parallel, with coordination and conflict resolution
  • Build fix: Handles GitHub-based npm dependency installation in build.js

Motivation

Complex changes often have independent task groups that can be worked on simultaneously. This workflow automates the analysis, planning, and execution of parallel agent work — reducing wall-clock time for large changes while maintaining spec coherence.

Related: #435 (Collaboration & Orchestration)

What's included

Area Files
Schema schemas/dispec-driven/schema.yaml + 6 templates
Workflows src/core/templates/workflows/multiagent.ts, multiagent-apply.ts
Core support Registration in init.ts, profiles.ts, skill-generation.ts, tool-detection.ts, skill-templates.ts
Tests dispec-driven.test.ts, multiagent-apply.test.ts, updated parity tests
Docs Change artifacts in openspec/changes/add-multiagent-apply-workflow/
Build GitHub git dep handling in build.js

Test plan

  • All existing tests pass (18 pre-existing failures in zsh-installer.test.ts are unrelated — reproducible on upstream/main)
  • New dispec-driven.test.ts validates schema artifact graph and ordering
  • New multiagent-apply.test.ts validates workflow template generation
  • Skill template parity tests updated for new workflows
  • Manual: run /opsx:multiagent on a change with multiple tasks to verify distribution plan generation
  • Manual: run /opsx:multiagent-apply to verify agent team orchestration

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • Added multi-agent orchestration workflows to plan and distribute work across multiple AI agents.
    • Enable parallel task execution through coordinated agent teams.
    • Introduced documentation templates for dependency analysis and work distribution planning.
  • Tests

    • Added comprehensive test coverage for new multi-agent workflows and artifact types.

pformoso-deus-ai and others added 6 commits March 2, 2026 12:00
Add a new built-in schema for distributed spec-driven development that
extends the standard workflow with dependency analysis and task
distribution artifacts, enabling multi-agent parallel execution.

New schema (dispec-driven) with 6 artifacts:
  proposal → specs → design → tasks → dependencies → distribution

New /opsx:multiagent slash command drives the end-to-end workflow,
including agent count selection and token cost warnings.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add a new skill that bridges the dispec-driven distribution plan to
Claude Code agent team execution. The skill reads distribution.md and
orchestrates TeamCreate, TaskCreate, and Agent spawning with worktree
isolation for parallel implementation.

Also fixes the existing /opsx:multiagent skill:
- Replace deprecated TodoWrite with TaskCreate/TaskUpdate
- Update output to reference /opsx:multiagent-apply
- Update distribution.md template with real team primitives
- Update dispec-driven schema apply instruction for multi-agent flow

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…nges

Archive fix-opencode-commands-directory and graceful-status-no-changes
since both have been implemented and merged.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
npm v11's git dep preparation runs `prepare` before node_modules exist
in the temp clone directory. This causes TypeScript compilation to fail.

Changes:
- build.js: skip build gracefully when node_modules absent, use
  node directly instead of pnpm for npm compatibility
- package.json: add `prepack` hook for pack-phase build, make
  postinstall non-fatal (|| true) to handle stale CWD after temp
  dir cleanup

Install from GitHub with:
  npm pack github:user/repo#branch
  npm install -g ./fission-ai-openspec-1.2.0.tgz

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a3df4cd and fa01bbe.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (4)
  • schemas/dispec-driven/schema.yaml
  • schemas/dispec-driven/templates/distribution.md
  • src/core/templates/workflows/multiagent.ts
  • test/core/templates/skill-templates-parity.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/core/templates/workflows/multiagent.ts
  • test/core/templates/skill-templates-parity.test.ts

📝 Walkthrough

Walkthrough

This PR introduces a multi-agent orchestration framework featuring a new dispec-driven schema with six artifacts (proposal, specs, design, tasks, dependencies, distribution) that enables distributed task execution across Claude Code agent teams. It adds two workflows: /opsx:multiagent for planning and /opsx:multiagent-apply for execution, along with comprehensive templates and system registrations.

Changes

Cohort / File(s) Summary
Dispec-Driven Schema & Artifacts
schemas/dispec-driven/schema.yaml, schemas/dispec-driven/templates/*
New schema definition for distributed spec-driven workflows with six artifact types (proposal, specs, design, tasks, dependencies, distribution), cross-artifact dependencies, multi-agent apply orchestration, and structured guidance on ownership, parallelism, and agent assignment.
Multiagent Workflow Templates
src/core/templates/workflows/multiagent.ts, src/core/templates/workflows/multiagent-apply.ts
Two new TypeScript modules exporting template factory functions (SkillTemplate and CommandTemplate) for multiagent planning and apply workflows, containing comprehensive multi-step instructions.
Template Registration & Exports
src/core/templates/skill-templates.ts, src/core/shared/skill-generation.ts
New exports of multiagent template getters and registrations in skill/command template registries with dirNames and workflow IDs for multiagent and multiagent-apply.
Workflow Registration
src/core/profiles.ts, src/core/init.ts, src/core/profile-sync-drift.ts, src/core/shared/tool-detection.ts
Updates to ALL\_WORKFLOWS, WORKFLOW\_TO\_SKILL\_DIR mappings, SKILL\_NAMES, and COMMAND\_IDS constants to recognize multiagent and multiagent-apply as valid workflows and commands.
Change Proposal Documentation
.changeset/multiagent-workflow.md, openspec/changes/add-multiagent-apply-workflow/*
Changeset entry and comprehensive design documentation (proposal.md, design.md, specification templates) describing the multiagent-apply workflow rationale, architecture decisions, and risks.
Test Coverage
test/core/artifact-graph/dispec-driven.test.ts, test/core/templates/multiagent-apply.test.ts, test/core/templates/skill-templates-parity.test.ts, test/core/profiles.test.ts, test/core/shared/*
New and updated test suites validating schema structure, dependency integrity, artifact progression, template content (e.g., TaskCreate/TaskUpdate references, no TodoWrite), and registration consistency.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • TabishB

Poem

🐰 Multiple agents hoppity-hop,
Distributing tasks that never stop,
Dependencies mapped like carrot rows,
TeamCreate, TaskCreate in ordered flows! 🥕
A dispec-driven feast for teams so spry!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: introducing a multi-agent orchestration workflow with a dispec-driven schema. It is concise, clear, and directly reflects the primary feature being added.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (6)
src/core/profile-sync-drift.ts (1)

14-28: Consider consolidating duplicate WORKFLOW_TO_SKILL_DIR mapping.

This constant is duplicated in src/core/init.ts (lines 63-77). Both files must be kept in sync when adding new workflows. Consider extracting this mapping to a shared location (e.g., a constants file or re-exporting from one module) to ensure consistency and reduce maintenance burden.

Note: The typing here (Record<WorkflowId, string>) is stricter than in init.ts (Record<string, string>), which provides better compile-time safety.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/core/profile-sync-drift.ts` around lines 14 - 28, WORKFLOW_TO_SKILL_DIR
is duplicated and should be centralized: create a shared constant module (e.g.,
export WORKFLOW_TO_SKILL_DIR from a new/shared constants file) and import it
from both profile-sync-drift and init, preserving the stricter typing
Record<WorkflowId, string>; ensure you export the WorkflowId type or import it
into the shared module so the mapping uses the same type, replace the local
declarations in src/core/profile-sync-drift and src/core/init.ts with imports
from the new module, and run type checks to confirm no regressions.
test/core/templates/multiagent-apply.test.ts (1)

68-71: Add positive primitive assertions for command content.

This test currently only checks exclusion of TodoWrite; consider also asserting TeamCreate, TaskCreate, and TaskUpdate presence for stronger regression protection.

Suggested test addition
   it('should not reference TodoWrite', () => {
     const template = getOpsxMultiagentApplyCommandTemplate();
     expect(template.content).not.toContain('TodoWrite');
   });
+
+  it('should include required team/task primitives', () => {
+    const template = getOpsxMultiagentApplyCommandTemplate();
+    expect(template.content).toContain('TeamCreate');
+    expect(template.content).toContain('TaskCreate');
+    expect(template.content).toContain('TaskUpdate');
+  });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/core/templates/multiagent-apply.test.ts` around lines 68 - 71, The test
only asserts that 'TodoWrite' is absent; add positive assertions to also verify
the command template includes expected primitives by checking that
getOpsxMultiagentApplyCommandTemplate().content contains 'TeamCreate',
'TaskCreate', and 'TaskUpdate'. Update the test (the it block using
getOpsxMultiagentApplyCommandTemplate and template.content) to add
expect(...).toContain(...) checks for those three symbols to provide stronger
regression protection.
test/core/shared/skill-generation.test.ts (1)

11-13: Reduce repeated hardcoded template-count literals.

Using a shared constant here will make future workflow additions less error-prone.

Refactor example
+const EXPECTED_TEMPLATE_COUNT = 13;
+
 describe('skill-generation', () => {
   describe('getSkillTemplates', () => {
     it('should return all 13 skill templates', () => {
       const templates = getSkillTemplates();
-      expect(templates).toHaveLength(13);
+      expect(templates).toHaveLength(EXPECTED_TEMPLATE_COUNT);
     });
@@
   describe('getCommandTemplates', () => {
     it('should return all 13 command templates', () => {
       const templates = getCommandTemplates();
-      expect(templates).toHaveLength(13);
+      expect(templates).toHaveLength(EXPECTED_TEMPLATE_COUNT);
     });
@@
   describe('getCommandContents', () => {
     it('should return all 13 command contents', () => {
       const contents = getCommandContents();
-      expect(contents).toHaveLength(13);
+      expect(contents).toHaveLength(EXPECTED_TEMPLATE_COUNT);
     });

Also applies to: 93-95, 149-151

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/core/shared/skill-generation.test.ts` around lines 11 - 13, The tests in
skill-generation.test.ts use repeated hardcoded numbers (e.g.,
expect(...).toHaveLength(13)) making future changes brittle; update the tests to
reference a shared constant instead: either export the templates array or a
SKILL_TEMPLATES_COUNT (or SKILL_TEMPLATES.length) from the module that
implements getSkillTemplates() and replace hardcoded literals in the tests (all
occurrences around the getSkillTemplates checks) with that exported value so the
assertions derive from the single source of truth.
src/core/templates/workflows/multiagent-apply.ts (1)

47-51: Make file-ownership conflict detection an explicit preflight step.

Guardrails require conflict handling, but the step-by-step flow should explicitly perform that check before TeamCreate.

Instruction-flow tweak
  Extract from `distribution.md`:
  - Agent count and names
  - Each agent's assigned task IDs, file ownership, execution order
  - Cross-agent dependency table
+ - Validate no overlapping writable file ownership across agents
+
+ If conflicts exist:
+ - Warn the user with the conflicting files/agents
+ - Ask whether to proceed or reassign
+ - Stop before `TeamCreate` if user does not approve

Also applies to: 134-141

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/core/templates/workflows/multiagent-apply.ts` around lines 47 - 51, Add
an explicit preflight step that runs file-ownership conflict detection and
resolves/blocks conflicts before invoking TeamCreate in the multi-agent apply
workflow; locate the sequence around TeamCreate in multiagent-apply.ts and
insert a guarded "FileOwnershipPreflight" (or similar) action that reads the
extracted distribution info (agent count/names, assigned task IDs, file
ownership, execution order, cross-agent dependency table) and fails fast or
surfaces conflicts to the caller, and apply the same insertion/guarding logic
where the flow duplicates at the other spot referenced (the block corresponding
to lines 134-141) so file-ownership conflicts are always checked prior to
TeamCreate.
schemas/dispec-driven/schema.yaml (1)

3-3: Update the schema description to reflect parallel specs/design dependencies.

Current text implies strict sequencing, but the declared graph allows specs and design in parallel after proposal. Consider wording like proposal → (specs + design) → tasks → dependencies → distribution.

📝 Suggested edit
-description: Distributed spec-driven workflow - proposal → specs → design → tasks → dependencies → distribution
+description: Distributed spec-driven workflow - proposal → (specs + design) → tasks → dependencies → distribution

Based on learnings: In the OpenSpec spec-driven schema, specs and design artifacts are parallel dependencies that both depend only on proposal.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@schemas/dispec-driven/schema.yaml` at line 3, Update the "description" field
in the schema (the line currently reading "Distributed spec-driven workflow -
proposal → specs → design → tasks → dependencies → distribution") to reflect
that "specs" and "design" are parallel dependencies of "proposal" (e.g., change
to "Distributed spec-driven workflow - proposal → (specs + design) → tasks →
dependencies → distribution"); locate the description key in the schema.yaml and
replace the sequencing text so it explicitly shows specs and design as parallel
artifacts that both depend only on proposal.
src/core/templates/workflows/multiagent.ts (1)

13-126: Extract a single shared body constant to prevent skill/command drift.

The instruction text is duplicated across instructions and content; this is brittle and conflicts with the shared-body intent.

♻️ Refactor sketch
+const MULTIAGENT_BODY = `Plan and distribute a change across multiple AI agents for parallel execution.
+...
+`;
+
 export function getOpsxMultiagentSkillTemplate(): SkillTemplate {
   return {
     name: 'openspec-multiagent',
     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.',
-    instructions: `Plan and distribute a change across multiple AI agents for parallel execution.
-...`,
+    instructions: MULTIAGENT_BODY,
     license: 'MIT',
     compatibility: 'Requires openspec CLI.',
     metadata: { author: 'openspec', version: '1.0' },
   };
 }
@@
 export function getOpsxMultiagentCommandTemplate(): CommandTemplate {
   return {
@@
-    content: `Plan and distribute a change across multiple AI agents for parallel execution.
-...`
+    content: MULTIAGENT_BODY
   };
 }

Also applies to: 139-252

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/core/templates/workflows/multiagent.ts` around lines 13 - 126, The
instructions and content fields (the multi-agent workflow text duplicated in the
template's instructions and content properties) should be consolidated into a
single shared constant and referenced from both places to avoid drift; create a
constant (e.g., SHARED_WORKFLOW_BODY or MULTIAGENT_SHARED_BODY) containing the
full instruction text, replace the duplicated literal strings used for the
"instructions" and "content" properties in the exported template object with
references to that constant, and ensure any future edits update only the
constant; update symbols: the template's instructions property, content
property, and the exported object (the multiagent template definition) to use
the new shared constant.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@openspec/changes/add-multiagent-apply-workflow/dependencies.md`:
- Around line 98-100: The Text DAG shows task 3.3 connected to the path toward
7.7, which conflicts with the Dependency Matrix that lists 7.7 as depending only
on 3.1 and 3.2; update the DAG so task 3.3 ("Update output section reference")
is not shown as feeding into 7.7, or alternatively update the Dependency Matrix
to include 3.3 if it truly is a dependency; make the change consistently in the
Text DAG visualization and the Dependency Matrix entries (referencing tasks 3.3
and 7.7 and the Dependency Matrix row currently mentioning 7.7) so both
representations match.

In `@openspec/changes/add-multiagent-apply-workflow/distribution.md`:
- Around line 102-104: The dependency for Task 7.5 is inconsistent between the
two sections: one lists it as blocked by tasks 2.1–2.3 while the other lists
2.2–2.3; update both occurrences so they match (choose the correct dependency
set, e.g., 2.1–2.3) to ensure the `TaskUpdate addBlockedBy` wiring is generated
consistently for Task 7.5 and likewise make the same correction in the other
affected occurrence referenced in the doc.

In `@schemas/dispec-driven/templates/dependencies.md`:
- Around line 30-37: The fenced code block containing the ASCII dependency graph
(the triple-backtick block starting at the comment's ASCII representation) lacks
a language tag and triggers MD040; update that fence to include a language tag
(e.g., "text") so the block becomes a typed fenced code block (```text ... ```),
leaving the ASCII content unchanged.

In `@schemas/dispec-driven/templates/distribution.md`:
- Around line 21-48: The template hard-codes two agent cards ("Agent 1:" and
"Agent 2:") so plans for 3–5 agents are incomplete; change distribution.md to
render a repeatable agent card block instead of duplicated static headings by
replacing the two fixed sections with a single templated/repeatable block that
iterates over an agents collection and emits the headings and placeholders
("**Tasks:**", "**File ownership:**", "**Execution order:**", "**Cross-agent
dependencies:**") for each agent; ensure the iteration uses the repo's
templating syntax (e.g., the existing template engine/variable name for agents)
and includes an index or agent.name to label each card (e.g., "Agent {{index}}:"
or "Agent {{agent.name}}:") so any N agents are supported.

In `@src/core/templates/workflows/multiagent.ts`:
- Around line 77-86: The AskUserQuestion handling for the distribution artifact
currently only special-cases selecting 1 agent; update the prompt parsing logic
that handles the agent-count response (the AskUserQuestion handling for the
distribution artifact and the identical block used later around the multi-agent
selection) to explicitly validate the numeric choice: if the user selects 1 keep
the existing /opsx:propose suggestion, if they select a value outside the
allowed 2..5 range (including >5) return a clear message recommending the valid
range (e.g., "Please choose between 2 and 5 agents; 3 is recommended") and
reprompt the AskUserQuestion rather than proceeding, and only accept/continue
when a valid 2,3,4 or 5 selection is made; apply this validation change to both
the first distribution prompt handler and the duplicate block later in the file.

---

Nitpick comments:
In `@schemas/dispec-driven/schema.yaml`:
- Line 3: Update the "description" field in the schema (the line currently
reading "Distributed spec-driven workflow - proposal → specs → design → tasks →
dependencies → distribution") to reflect that "specs" and "design" are parallel
dependencies of "proposal" (e.g., change to "Distributed spec-driven workflow -
proposal → (specs + design) → tasks → dependencies → distribution"); locate the
description key in the schema.yaml and replace the sequencing text so it
explicitly shows specs and design as parallel artifacts that both depend only on
proposal.

In `@src/core/profile-sync-drift.ts`:
- Around line 14-28: WORKFLOW_TO_SKILL_DIR is duplicated and should be
centralized: create a shared constant module (e.g., export WORKFLOW_TO_SKILL_DIR
from a new/shared constants file) and import it from both profile-sync-drift and
init, preserving the stricter typing Record<WorkflowId, string>; ensure you
export the WorkflowId type or import it into the shared module so the mapping
uses the same type, replace the local declarations in
src/core/profile-sync-drift and src/core/init.ts with imports from the new
module, and run type checks to confirm no regressions.

In `@src/core/templates/workflows/multiagent-apply.ts`:
- Around line 47-51: Add an explicit preflight step that runs file-ownership
conflict detection and resolves/blocks conflicts before invoking TeamCreate in
the multi-agent apply workflow; locate the sequence around TeamCreate in
multiagent-apply.ts and insert a guarded "FileOwnershipPreflight" (or similar)
action that reads the extracted distribution info (agent count/names, assigned
task IDs, file ownership, execution order, cross-agent dependency table) and
fails fast or surfaces conflicts to the caller, and apply the same
insertion/guarding logic where the flow duplicates at the other spot referenced
(the block corresponding to lines 134-141) so file-ownership conflicts are
always checked prior to TeamCreate.

In `@src/core/templates/workflows/multiagent.ts`:
- Around line 13-126: The instructions and content fields (the multi-agent
workflow text duplicated in the template's instructions and content properties)
should be consolidated into a single shared constant and referenced from both
places to avoid drift; create a constant (e.g., SHARED_WORKFLOW_BODY or
MULTIAGENT_SHARED_BODY) containing the full instruction text, replace the
duplicated literal strings used for the "instructions" and "content" properties
in the exported template object with references to that constant, and ensure any
future edits update only the constant; update symbols: the template's
instructions property, content property, and the exported object (the multiagent
template definition) to use the new shared constant.

In `@test/core/shared/skill-generation.test.ts`:
- Around line 11-13: The tests in skill-generation.test.ts use repeated
hardcoded numbers (e.g., expect(...).toHaveLength(13)) making future changes
brittle; update the tests to reference a shared constant instead: either export
the templates array or a SKILL_TEMPLATES_COUNT (or SKILL_TEMPLATES.length) from
the module that implements getSkillTemplates() and replace hardcoded literals in
the tests (all occurrences around the getSkillTemplates checks) with that
exported value so the assertions derive from the single source of truth.

In `@test/core/templates/multiagent-apply.test.ts`:
- Around line 68-71: The test only asserts that 'TodoWrite' is absent; add
positive assertions to also verify the command template includes expected
primitives by checking that getOpsxMultiagentApplyCommandTemplate().content
contains 'TeamCreate', 'TaskCreate', and 'TaskUpdate'. Update the test (the it
block using getOpsxMultiagentApplyCommandTemplate and template.content) to add
expect(...).toContain(...) checks for those three symbols to provide stronger
regression protection.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between afdca0d and a3df4cd.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (42)
  • .changeset/multiagent-workflow.md
  • build.js
  • openspec/changes/add-multiagent-apply-workflow/.openspec.yaml
  • openspec/changes/add-multiagent-apply-workflow/dependencies.md
  • openspec/changes/add-multiagent-apply-workflow/design.md
  • openspec/changes/add-multiagent-apply-workflow/distribution.md
  • openspec/changes/add-multiagent-apply-workflow/proposal.md
  • openspec/changes/add-multiagent-apply-workflow/specs/command-generation/spec.md
  • openspec/changes/add-multiagent-apply-workflow/specs/multiagent-apply/spec.md
  • openspec/changes/add-multiagent-apply-workflow/tasks.md
  • openspec/changes/archive/2025-02-28-fix-opencode-commands-directory/.openspec.yaml
  • openspec/changes/archive/2025-02-28-fix-opencode-commands-directory/design.md
  • openspec/changes/archive/2025-02-28-fix-opencode-commands-directory/proposal.md
  • openspec/changes/archive/2025-02-28-fix-opencode-commands-directory/specs/command-generation/spec.md
  • openspec/changes/archive/2025-02-28-fix-opencode-commands-directory/tasks.md
  • openspec/changes/archive/2025-02-28-graceful-status-no-changes/.openspec.yaml
  • openspec/changes/archive/2025-02-28-graceful-status-no-changes/design.md
  • openspec/changes/archive/2025-02-28-graceful-status-no-changes/proposal.md
  • openspec/changes/archive/2025-02-28-graceful-status-no-changes/specs/graceful-status-empty/spec.md
  • openspec/changes/archive/2025-02-28-graceful-status-no-changes/tasks.md
  • package.json
  • schemas/dispec-driven/schema.yaml
  • schemas/dispec-driven/templates/dependencies.md
  • schemas/dispec-driven/templates/design.md
  • schemas/dispec-driven/templates/distribution.md
  • schemas/dispec-driven/templates/proposal.md
  • schemas/dispec-driven/templates/spec.md
  • schemas/dispec-driven/templates/tasks.md
  • src/core/init.ts
  • src/core/profile-sync-drift.ts
  • src/core/profiles.ts
  • src/core/shared/skill-generation.ts
  • src/core/shared/tool-detection.ts
  • src/core/templates/skill-templates.ts
  • src/core/templates/workflows/multiagent-apply.ts
  • src/core/templates/workflows/multiagent.ts
  • test/core/artifact-graph/dispec-driven.test.ts
  • test/core/profiles.test.ts
  • test/core/shared/skill-generation.test.ts
  • test/core/shared/tool-detection.test.ts
  • test/core/templates/multiagent-apply.test.ts
  • test/core/templates/skill-templates-parity.test.ts

Comment on lines +98 to +100
[3.1] ──┐
[3.2] ──┼──────────────→ [7.7]
[3.3] │
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Minor inconsistency in Text DAG.

The Text DAG shows task 3.3 connected to the arrow leading to 7.7, but the Dependency Matrix (line 26) specifies that task 7.7 only depends on tasks 3.1 and 3.2 ("Verifies TodoWrite removal"). If 3.3 ("Update output section reference") is not a dependency of 7.7, the DAG visualization may be misleading.

📝 Suggested fix
 [3.1] ──┐
-[3.2] ──┼──────────────→ [7.7]
-[3.3]   │
+[3.2] ──┴──────────────→ [7.7]
+
+[3.3]
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@openspec/changes/add-multiagent-apply-workflow/dependencies.md` around lines
98 - 100, The Text DAG shows task 3.3 connected to the path toward 7.7, which
conflicts with the Dependency Matrix that lists 7.7 as depending only on 3.1 and
3.2; update the DAG so task 3.3 ("Update output section reference") is not shown
as feeding into 7.7, or alternatively update the Dependency Matrix to include
3.3 if it truly is a dependency; make the change consistently in the Text DAG
visualization and the Dependency Matrix entries (referencing tasks 3.3 and 7.7
and the Dependency Matrix row currently mentioning 7.7) so both representations
match.

Comment on lines +102 to +104
- 7.3, 7.5 blocked by Agent 1 completing tasks 2.1–2.3
- 7.4 blocked by Agent 1 completing task 2.4
- 7.7 blocked by Agent 2 completing tasks 3.1–3.2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Align Task 7.5 dependency definitions across sections.

Line 102 says 7.5 is blocked by 2.1–2.3, but Line 134 says 2.2–2.3. Keep this consistent to avoid incorrect TaskUpdate addBlockedBy wiring.

Suggested doc fix
- - 7.3, 7.5 blocked by Agent 1 completing tasks 2.1–2.3
+ - 7.3 blocked by Agent 1 completing tasks 2.1–2.3
+ - 7.5 blocked by Agent 1 completing tasks 2.2–2.3

Also applies to: 134-135

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@openspec/changes/add-multiagent-apply-workflow/distribution.md` around lines
102 - 104, The dependency for Task 7.5 is inconsistent between the two sections:
one lists it as blocked by tasks 2.1–2.3 while the other lists 2.2–2.3; update
both occurrences so they match (choose the correct dependency set, e.g.,
2.1–2.3) to ensure the `TaskUpdate addBlockedBy` wiring is generated
consistently for Task 7.5 and likewise make the same correction in the other
affected occurrence referenced in the doc.

Comment on lines +30 to +37
```
<!-- ASCII representation of the dependency graph
Example:
[1.1] ──→ [2.1] ──→ [3.1]
[1.2] ──→ [2.2] ──→ [3.2]
-->
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add a language tag to the fenced block to satisfy markdownlint.

Line 30 currently uses an untyped fence, which triggers MD040.

✏️ Suggested patch
-```
+```text
 <!-- ASCII representation of the dependency graph
      Example:
      [1.1] ──→ [2.1] ──→ [3.1]
                   ↓
      [1.2] ──→ [2.2] ──→ [3.2]
 -->
</details>

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 markdownlint-cli2 (0.21.0)</summary>

[warning] 30-30: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

</details>

</details>

<details>
<summary>🤖 Prompt for AI Agents</summary>

Verify each finding against the current code and only fix it if needed.

In @schemas/dispec-driven/templates/dependencies.md around lines 30 - 37, The
fenced code block containing the ASCII dependency graph (the triple-backtick
block starting at the comment's ASCII representation) lacks a language tag and
triggers MD040; update that fence to include a language tag (e.g., "text") so
the block becomes a typed fenced code block (text ... ), leaving the ASCII
content unchanged.


</details>

<!-- fingerprinting:phantom:poseidon:hawk -->

<!-- This is an auto-generated comment by CodeRabbit -->

Comment on lines +21 to +48
### Agent 1: <!-- agent name/focus area -->

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

**File ownership:**
<!-- Files this agent is responsible for -->

**Execution order:**
<!-- Order respecting dependencies -->

**Cross-agent dependencies:**
<!-- Tasks from other agents this agent must wait for -->

### Agent 2: <!-- agent name/focus area -->

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

**File ownership:**
<!-- Files this agent is responsible for -->

**Execution order:**
<!-- Order respecting dependencies -->

**Cross-agent dependencies:**
<!-- Tasks from other agents this agent must wait for -->

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Make assignment cards repeatable for N agents (not fixed to two).

The template currently hard-codes only two agent cards, but the workflow supports larger teams. This causes incomplete plans when users choose 3–5 agents.

♻️ Suggested template refactor
 ## Agent Assignments

-### Agent 1: <!-- agent name/focus area -->
+<!-- Copy this assignment card once per configured agent (1..N). -->
+### Agent <N>: <!-- agent name/focus area -->
 
 **Tasks:**
 <!-- List assigned task IDs -->
 
 **File ownership:**
 <!-- Files this agent is responsible for -->
 
 **Execution order:**
 <!-- Order respecting dependencies -->
 
 **Cross-agent dependencies:**
 <!-- Tasks from other agents this agent must wait for -->
-
-### Agent 2: <!-- agent name/focus area -->
-
-**Tasks:**
-<!-- List assigned task IDs -->
-
-**File ownership:**
-<!-- Files this agent is responsible for -->
-
-**Execution order:**
-<!-- Order respecting dependencies -->
-
-**Cross-agent dependencies:**
-<!-- Tasks from other agents this agent must wait for -->
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
### Agent 1: <!-- agent name/focus area -->
**Tasks:**
<!-- List assigned task IDs -->
**File ownership:**
<!-- Files this agent is responsible for -->
**Execution order:**
<!-- Order respecting dependencies -->
**Cross-agent dependencies:**
<!-- Tasks from other agents this agent must wait for -->
### Agent 2: <!-- agent name/focus area -->
**Tasks:**
<!-- List assigned task IDs -->
**File ownership:**
<!-- Files this agent is responsible for -->
**Execution order:**
<!-- Order respecting dependencies -->
**Cross-agent dependencies:**
<!-- Tasks from other agents this agent must wait for -->
## Agent Assignments
<!-- Copy this assignment card once per configured agent (1..N). -->
### Agent <N>: <!-- agent name/focus area -->
**Tasks:**
<!-- List assigned task IDs -->
**File ownership:**
<!-- Files this agent is responsible for -->
**Execution order:**
<!-- Order respecting dependencies -->
**Cross-agent dependencies:**
<!-- Tasks from other agents this agent must wait for -->
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@schemas/dispec-driven/templates/distribution.md` around lines 21 - 48, The
template hard-codes two agent cards ("Agent 1:" and "Agent 2:") so plans for 3–5
agents are incomplete; change distribution.md to render a repeatable agent card
block instead of duplicated static headings by replacing the two fixed sections
with a single templated/repeatable block that iterates over an agents collection
and emits the headings and placeholders ("**Tasks:**", "**File ownership:**",
"**Execution order:**", "**Cross-agent dependencies:**") for each agent; ensure
the iteration uses the repo's templating syntax (e.g., the existing template
engine/variable name for agents) and includes an index or agent.name to label
each card (e.g., "Agent {{index}}:" or "Agent {{agent.name}}:") so any N agents
are supported.

@greptile-apps
Copy link

greptile-apps bot commented Mar 2, 2026

Greptile Summary

Added multi-agent orchestration workflow for distributing OpenSpec changes across parallel AI agents. Introduces the dispec-driven schema with dependency analysis and distribution planning artifacts, /opsx:multiagent workflow for creating distribution plans, and /opsx:multiagent-apply workflow for orchestrating Claude Code agent teams using TeamCreate, Agent tool with worktree isolation, and TaskUpdate primitives.

Key additions:

  • New dispec-driven schema with 6-artifact workflow: proposal → specs → design → tasks → dependencies → distribution
  • /opsx:multiagent creates distribution plans with agent assignments and file ownership
  • /opsx:multiagent-apply orchestrates parallel agent execution with coordination and conflict resolution
  • Build fix for GitHub-based npm dependency installation
  • Comprehensive test coverage for schema artifact graph and workflow templates
  • All integration points properly registered (init.ts, profiles.ts, skill-generation.ts, tool-detection.ts)

Implementation quality:

  • TodoWrite properly replaced with TaskCreate/TaskUpdate throughout
  • Worktree isolation ensures no file conflicts between agents
  • Token cost warnings included in workflow instructions
  • Tests updated from 11 to 13 workflows with proper parity checks
  • Schema validation ensures distribution artifact completes before apply phase

Confidence Score: 5/5

  • Safe to merge with high confidence
  • Well-architected feature with comprehensive test coverage, proper integration across all system touchpoints, and thoughtful error handling. The build.js fix properly handles edge cases for GitHub dependency installation. All deprecated references (TodoWrite) have been replaced with current primitives. Tests validate schema structure, artifact dependencies, and workflow template generation.
  • No files require special attention

Important Files Changed

Filename Overview
schemas/dispec-driven/schema.yaml Added comprehensive multi-agent workflow schema with 6 artifacts (proposal → specs → design → tasks → dependencies → distribution) for parallel execution planning
src/core/templates/workflows/multiagent.ts Added /opsx:multiagent workflow for creating distribution plans, properly replaced TodoWrite with TaskCreate/TaskUpdate
src/core/templates/workflows/multiagent-apply.ts Added /opsx:multiagent-apply workflow to orchestrate Claude Code agent teams with TeamCreate, Agent tool, and TaskUpdate primitives
build.js Added node_modules check to handle GitHub git dependency installation gracefully by skipping build during prepare phase
package.json Updated build scripts to use build.js directly, added prepack hook, and made postinstall non-fatal with
test/core/artifact-graph/dispec-driven.test.ts Added comprehensive test coverage for dispec-driven schema artifact graph, dependency chain, and build order validation
test/core/templates/multiagent-apply.test.ts Added test coverage for multiagent-apply templates, validates TeamCreate, TaskCreate, TaskUpdate, and worktree isolation references

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    Start([User runs /opsx:multiagent]) --> CreateChange[Create change with dispec-driven schema]
    CreateChange --> Proposal[Create proposal.md]
    Proposal --> ParallelPhase{Parallel Phase}
    ParallelPhase --> Specs[Create specs/]
    ParallelPhase --> Design[Create design.md]
    Specs --> Tasks[Create tasks.md]
    Design --> Tasks
    Tasks --> Dependencies[Analyze dependencies.md]
    Dependencies --> Distribution[Generate distribution.md<br/>with agent assignments]
    Distribution --> Ready{Ready for<br/>implementation?}
    Ready -->|Yes| ApplyStart([User runs /opsx:multiagent-apply])
    Ready -->|No| Proposal
    
    ApplyStart --> Validate[Validate dispec-driven schema<br/>and distribution complete]
    Validate --> TokenWarning[Show token cost warning<br/>N agents = N× cost]
    TokenWarning --> Confirm{User<br/>confirms?}
    Confirm -->|No| End1([Cancelled])
    Confirm -->|Yes| TeamCreate[TeamCreate with change name]
    TeamCreate --> TaskCreate[TaskCreate for all tasks<br/>with dependencies]
    TaskCreate --> SpawnAgents[Spawn Agent teammates<br/>with worktree isolation]
    SpawnAgents --> Monitor[Monitor TaskList<br/>and agent messages]
    Monitor --> AllDone{All tasks<br/>complete?}
    AllDone -->|No| Monitor
    AllDone -->|Yes| Shutdown[Send shutdown_request<br/>to all agents]
    Shutdown --> End2([Implementation complete])
Loading

Last reviewed commit: a3df4cd

Copy link
Collaborator

@alfred-openspec alfred-openspec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Architecture Review — Alfred (OpenSpec maintainer bot)

Thanks for this contribution, @pformoso-deus-ai! This is a well-structured PR with solid architectural thinking. The design doc is particularly well done — it clearly lays out alternatives considered and trade-offs. A few things to address before this can merge:

✅ What looks great

  • Natural extension of spec-drivendispec-driven adds dependencies + distribution on top of the existing 4-artifact chain. The dependency graph (proposal → specs/design parallel → tasks → dependencies → distribution) is correct and well-tested.
  • Separate skill for multiagent-apply — Right call. These are fundamentally different concerns.
  • Shared MULTIAGENT_APPLY_INSTRUCTIONS constant in multiagent-apply.ts — Good pattern, avoids skill/command template drift.
  • Comprehensive testsdispec-driven.test.ts validates full workflow progression. Parity hashes updated.
  • Dogfooding — Using dispec-driven schema for its own change artifacts. 🎯
  • Not in CORE_WORKFLOWS — Correctly experimental, won't affect new users.

🔴 Should fix before merge

1. Build system changes should be a separate PR (commits 4-5)

The build.js node_modules guard, prepare/prepack/postinstall script changes are fixing a real issue (GitHub git dep installation) but they touch the build pipeline, which is a different review/rollback concern from the feature work. Recommend splitting these into their own PR.

In particular, "postinstall": "node scripts/postinstall.js || true" suppresses all postinstall errors, not just the stale CWD case. If the script has a legitimate failure, this swallows it silently. Consider a more targeted approach.

2. package-lock.json version bump 1.1.1 → 1.2.0

Version should be managed by changesets at release time. Committing the bump in a feature PR will cause merge conflicts with any other in-flight PR.

3. Instruction body duplication in multiagent.ts

The skill instructions and command content are ~120 lines of duplicated text. multiagent-apply.ts already does this right with a shared constant. Extract to const MULTIAGENT_INSTRUCTIONS and reference from both functions — same pattern you used in the apply file.

🟡 Minor suggestions

4. Schema description (line 3 of schema.yaml): Shows proposal → specs → design → tasks → ... but specs and design are actually parallel (both depend only on proposal). Suggest: proposal → (specs + design) → tasks → dependencies → distribution.

5. distribution.md template hardcodes 2 agent cards but the instruction says "Recommend 3-5 agents." Consider making it more generic or adding a note about adding cards for additional agents.

6. Agent count validation: The AskUserQuestion for distribution only handles the "1 agent" case (→ suggest /opsx:propose). No handling for >5 or <2 selections.

Overall

This is a high-quality contribution with genuine architectural thinking. The core schema + workflow design is sound. Address the build system separation and the multiagent.ts body duplication, and this should be good to merge. 🚀

pformoso-deus-ai added a commit to pabloformoso/OpenSpec that referenced this pull request Mar 2, 2026
- Extract MULTIAGENT_INSTRUCTIONS shared constant in multiagent.ts to
  eliminate ~120 lines of duplication between skill and command templates
- Fix dispec-driven schema description to reflect parallel artifact flow:
  proposal → (specs + design) → tasks → dependencies → distribution
- Replace hardcoded 2-agent template in distribution.md with a generic
  repeatable card (recommended 3-5 agents)
- Add "2 agents" option and validation for <2 / >5 agent selections
- Revert build system changes (build.js guard, package.json scripts,
  package-lock.json version bump) to be submitted as a separate PR
- Update parity test hashes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Extract MULTIAGENT_INSTRUCTIONS shared constant in multiagent.ts to
  eliminate ~120 lines of duplication between skill and command templates
- Fix dispec-driven schema description to reflect parallel artifact flow:
  proposal → (specs + design) → tasks → dependencies → distribution
- Replace hardcoded 2-agent template in distribution.md with a generic
  repeatable card (recommended 3-5 agents)
- Add "2 agents" option and validation for <2 / >5 agent selections
- Revert build system changes (build.js guard, package.json scripts,
  package-lock.json version bump) to be submitted as a separate PR
- Update parity test hashes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
pformoso-deus-ai added a commit to pabloformoso/OpenSpec that referenced this pull request Mar 3, 2026
@pabloformoso
Copy link

I separated the system build to PR 792, and amend this one based on the feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants