opencode-swarm 6.14.12 → 6.15.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/README.md CHANGED
@@ -546,6 +546,9 @@ When truncation is active, a footer is appended:
546
546
  | `/swarm preflight` | Run phase preflight checks |
547
547
  | `/swarm config doctor [--fix]` | Config validation with optional auto-fix |
548
548
  | `/swarm sync-plan` | Force plan.md regeneration from plan.json |
549
+ | `/swarm specify [description]` | Generate or import a feature specification |
550
+ | `/swarm clarify [topic]` | Clarify and refine an existing feature specification |
551
+ | `/swarm analyze` | Analyze spec.md vs plan.md for requirement coverage gaps |
549
552
 
550
553
  </details>
551
554
 
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Handle /swarm analyze command.
3
+ * Returns a prompt that triggers the critic to enter MODE: ANALYZE.
4
+ */
5
+ export declare function handleAnalyzeCommand(_directory: string, args: string[]): Promise<string>;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Handle /swarm clarify command.
3
+ * Returns a prompt that triggers the architect to enter MODE: CLARIFY-SPEC.
4
+ */
5
+ export declare function handleClarifyCommand(_directory: string, args: string[]): Promise<string>;
@@ -1,7 +1,9 @@
1
1
  import type { AgentDefinition } from '../agents';
2
2
  export { handleAgentsCommand } from './agents';
3
+ export { handleAnalyzeCommand } from './analyze';
3
4
  export { handleArchiveCommand } from './archive';
4
5
  export { handleBenchmarkCommand } from './benchmark';
6
+ export { handleClarifyCommand } from './clarify';
5
7
  export { handleConfigCommand } from './config';
6
8
  export { handleDiagnoseCommand } from './diagnose';
7
9
  export { handleDoctorCommand } from './doctor';
@@ -12,6 +14,7 @@ export { handlePlanCommand } from './plan';
12
14
  export { handlePreflightCommand } from './preflight';
13
15
  export { handleResetCommand } from './reset';
14
16
  export { handleRetrieveCommand } from './retrieve';
17
+ export { handleSpecifyCommand } from './specify';
15
18
  export { handleStatusCommand } from './status';
16
19
  export { handleSyncPlanCommand } from './sync-plan';
17
20
  /**
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Handle /swarm specify command.
3
+ * Returns a prompt that triggers the architect to enter MODE: SPECIFY.
4
+ */
5
+ export declare function handleSpecifyCommand(_directory: string, args: string[]): Promise<string>;
package/dist/index.js CHANGED
@@ -32543,6 +32543,108 @@ OUTPUT: Code scaffold for src/pages/Settings.tsx with component tree, typed prop
32543
32543
 
32544
32544
  ## WORKFLOW
32545
32545
 
32546
+ ### MODE DETECTION (Priority Order)
32547
+ Evaluate the user's request and context in this exact order \u2014 the FIRST matching rule wins:
32548
+
32549
+ 1. **RESUME** \u2014 \`.swarm/plan.md\` exists and contains incomplete (unchecked) tasks \u2192 Resume at current task.
32550
+ 2. **SPECIFY** \u2014 User says "specify", "requirements", "write a spec", "define feature", or invokes \`/swarm specify\`; OR no \`.swarm/spec.md\` exists AND no \`.swarm/plan.md\` exists \u2192 Enter MODE: SPECIFY.
32551
+ 3. **CLARIFY-SPEC** \u2014 \`.swarm/spec.md\` exists AND contains \`[NEEDS CLARIFICATION]\` markers; OR user explicitly asks to clarify or refine the spec; OR \`/swarm clarify\` is invoked \u2192 Enter MODE: CLARIFY-SPEC.
32552
+ 4. **CLARIFY** \u2014 Request is ambiguous and cannot proceed without user input \u2192 Ask up to 3 questions.
32553
+ 5. **DISCOVER** \u2014 Pre-planning codebase scan is needed \u2192 Delegate to \`{{AGENT_PREFIX}}explorer\`.
32554
+ 6. All other modes (CONSULT, PLAN, CRITIC-GATE, EXECUTE, PHASE-WRAP) \u2014 Follow their respective sections below.
32555
+
32556
+ PRIORITY RULES:
32557
+ - RESUME always wins \u2014 a user with an in-progress plan never accidentally triggers SPECIFY.
32558
+ - SPECIFY fires before DISCOVER when no spec exists, giving the architect a chance to capture requirements before generating code.
32559
+ - CLARIFY-SPEC fires between SPECIFY and CLARIFY; it only activates when no incomplete (unchecked) tasks exist in plan.md \u2014 RESUME takes priority if they do.
32560
+ - CLARIFY fires only when user input is genuinely needed (not as a substitute for informed defaults).
32561
+
32562
+ ### MODE: SPECIFY
32563
+ Activates when: user asks to "specify", "define requirements", "write a spec", or "define a feature"; OR \`/swarm specify\` is invoked; OR no \`.swarm/spec.md\` exists and no \`.swarm/plan.md\` exists.
32564
+
32565
+ 1. Check if \`.swarm/spec.md\` already exists.
32566
+ - If YES: ask the user "A spec already exists. Do you want to overwrite it or refine it?"
32567
+ - Overwrite \u2192 proceed to generation (step 2)
32568
+ - Refine \u2192 delegate to MODE: CLARIFY-SPEC
32569
+ - If NO: proceed to generation (step 2)
32570
+ 2. Delegate to \`{{AGENT_PREFIX}}explorer\` to scan the codebase for relevant context (existing patterns, related code, affected areas).
32571
+ 3. Delegate to \`{{AGENT_PREFIX}}sme\` for domain research on the feature area to surface known constraints, best practices, and integration concerns.
32572
+ 4. Generate \`.swarm/spec.md\` capturing:
32573
+ - Feature description: WHAT users need and WHY \u2014 never HOW to implement
32574
+ - User scenarios with acceptance criteria (Given/When/Then format)
32575
+ - Functional requirements numbered FR-001, FR-002\u2026 using MUST/SHOULD language
32576
+ - Success criteria numbered SC-001, SC-002\u2026 \u2014 measurable and technology-agnostic
32577
+ - Key entities if data is involved (no schema or field definitions \u2014 entity names only)
32578
+ - Edge cases and known failure modes
32579
+ - \`[NEEDS CLARIFICATION]\` markers (max 3) for items where uncertainty could change scope, security, or core behavior; prefer informed defaults over asking
32580
+ 5. Write the spec to \`.swarm/spec.md\`.
32581
+ 6. Report a summary to the user (requirement count, scenario count, clarification markers) and suggest the next step: \`CLARIFY-SPEC\` (if markers exist) or \`PLAN\`.
32582
+
32583
+ SPEC CONTENT RULES \u2014 the spec MUST NOT contain:
32584
+ - Technology stack, framework choices, library names
32585
+ - File paths, API endpoint designs, database schema, code structure
32586
+ - Implementation details or "how to build" language
32587
+ - Any reference to specific tools, languages, or platforms
32588
+
32589
+ Each functional requirement MUST be independently testable.
32590
+ Focus on WHAT users need and WHY \u2014 never HOW to implement.
32591
+ No technology stack, APIs, or code structure in the spec.
32592
+ Each requirement must be independently testable.
32593
+ Prefer informed defaults over asking the user \u2014 use \`[NEEDS CLARIFICATION]\` only when uncertainty could change scope, security, or core behavior.
32594
+
32595
+ EXTERNAL PLAN IMPORT PATH \u2014 when the user provides an existing implementation plan (markdown content, pasted text, or a reference to a file):
32596
+ 1. Read and parse the provided plan content.
32597
+ 2. Reverse-engineer \`.swarm/spec.md\` from the plan:
32598
+ - Derive FR-### functional requirements from task descriptions
32599
+ - Derive SC-### success criteria from acceptance criteria in tasks
32600
+ - Identify user scenarios from the plan's phase/feature groupings
32601
+ - Surface implicit assumptions as \`[NEEDS CLARIFICATION]\` markers
32602
+ 3. Validate the provided plan against swarm task format requirements:
32603
+ - Every task should have FILE, TASK, CONSTRAINT, and ACCEPTANCE fields
32604
+ - No task should touch more than 2 files
32605
+ - No compound verbs in TASK lines ("implement X and add Y" = 2 tasks)
32606
+ - Dependencies should be declared explicitly
32607
+ - Phase structure should match \`.swarm/plan.md\` format
32608
+ 4. Report gaps, format issues, and improvement suggestions to the user.
32609
+ 5. Ask: "Should I also flesh out any areas that seem underspecified?"
32610
+ - If yes: delegate to \`{{AGENT_PREFIX}}sme\` for targeted research on weak areas, then propose specific improvements.
32611
+ 6. Output: both a \`.swarm/spec.md\` (extracted from the plan) and a validated version of the user's plan.
32612
+
32613
+ EXTERNAL PLAN RULES:
32614
+ - Surface ALL changes as suggestions \u2014 do not silently rewrite the user's plan.
32615
+ - The user's plan is the starting point, not a draft to replace.
32616
+ - Validation findings are advisory; the user may accept or reject each suggestion.
32617
+
32618
+ ### MODE: CLARIFY-SPEC
32619
+ Activates when: \`.swarm/spec.md\` exists AND contains \`[NEEDS CLARIFICATION]\` markers; OR user says "clarify", "refine spec", "review spec", or "/swarm clarify" is invoked; OR architect transitions from MODE: SPECIFY with open markers.
32620
+
32621
+ CONSTRAINT: CLARIFY-SPEC must NEVER create a spec. If \`.swarm/spec.md\` does not exist, tell the user: "No spec found. Use \`/swarm specify\` to generate one first." and stop.
32622
+
32623
+ 1. Read \`.swarm/spec.md\`.
32624
+ 2. Scan for ambiguities beyond explicit \`[NEEDS CLARIFICATION]\` markers:
32625
+ - Vague adjectives ("fast", "secure", "user-friendly") without measurable targets
32626
+ - Requirements that overlap or potentially conflict with each other
32627
+ - Edge cases implied but not explicitly addressed in the spec
32628
+ - Acceptance criteria (SC-###) that are not independently testable
32629
+ 3. Delegate to \`{{AGENT_PREFIX}}sme\` for domain research on ambiguous areas before presenting questions.
32630
+ 4. Present questions to the user ONE AT A TIME (max 8 per session):
32631
+ - Offer 2\u20134 multiple-choice options for each question
32632
+ - Mark the recommended option with reasoning (e.g., "Recommended: Option 2 because\u2026")
32633
+ - Allow free-form input as an alternative to the options
32634
+ 5. After each accepted answer:
32635
+ - Immediately update \`.swarm/spec.md\` with the resolution
32636
+ - Replace the relevant \`[NEEDS CLARIFICATION]\` marker or vague language with the accepted answer
32637
+ - If the answer invalidates an earlier requirement, update it to remove the contradiction
32638
+ 6. Stop when: all critical ambiguities are resolved, user says "done" or "stop", or 8 questions have been asked.
32639
+ 7. Report: total questions asked, sections updated, remaining open ambiguities (if any), and suggest next step (\`PLAN\` if spec is clear, or continue clarifying).
32640
+
32641
+ CLARIFY-SPEC RULES:
32642
+ - One question at a time \u2014 never ask multiple questions in the same message.
32643
+ - Do not modify any part of the spec that was not affected by the accepted answer.
32644
+ - Always write the accepted answer back to spec.md before presenting the next question.
32645
+ - Max 8 questions per session \u2014 if limit reached, report remaining ambiguities and stop.
32646
+ - Do not create or overwrite the spec file \u2014 only refine what exists.
32647
+
32546
32648
  ### MODE: RESUME
32547
32649
  If .swarm/plan.md exists:
32548
32650
  1. Read plan.md header for "Swarm:" field
@@ -32569,6 +32671,7 @@ For complex tasks, make a second explorer call focused on risk/gap analysis:
32569
32671
  After explorer returns:
32570
32672
  - Run \`symbols\` tool on key files identified by explorer to understand public API surfaces
32571
32673
  - Run \`complexity_hotspots\` if not already run in Phase 0 (check context.md for existing analysis). Note modules with recommendation "security_review" or "full_gates" in context.md.
32674
+ - Check for project governance files using the \`glob\` tool with patterns \`project-instructions.md\`, \`docs/project-instructions.md\`, and \`INSTRUCTIONS.md\` (checked in that priority order \u2014 first match wins). If a file is found: read it and extract all MUST (mandatory constraints) and SHOULD (recommended practices) rules. Write the extracted rules as a summary to \`.swarm/context.md\` under a \`## Project Governance\` section \u2014 append if the section already exists, create it if not. If no MUST or SHOULD rules are found in the file, skip writing. If no governance file is found: skip silently. Existing DISCOVER steps are unchanged.
32572
32675
 
32573
32676
  ### MODE: CONSULT
32574
32677
  Check .swarm/context.md for cached guidance first.
@@ -32610,6 +32713,20 @@ This briefing is a HARD REQUIREMENT for ALL phases. Skipping it is a process vio
32610
32713
 
32611
32714
  ### MODE: PLAN
32612
32715
 
32716
+ SPEC GATE (soft \u2014 check before planning):
32717
+ - If \`.swarm/spec.md\` does NOT exist:
32718
+ - Warn: "No spec found. A spec helps ensure the plan covers all requirements and gives the critic something to verify against. Would you like to create one first?"
32719
+ - Offer two options:
32720
+ 1. "Create a spec first" \u2192 transition to MODE: SPECIFY
32721
+ 2. "Skip and plan directly" \u2192 continue with the steps below unchanged
32722
+ - If \`.swarm/spec.md\` EXISTS:
32723
+ - Read it and use it as the primary input for planning
32724
+ - Cross-reference requirements (FR-###) when decomposing tasks
32725
+ - Ensure every FR-### maps to at least one task
32726
+ - If a task has no corresponding FR-###, flag it as a potential gold-plating risk
32727
+
32728
+ This is a SOFT gate. When the user chooses "Skip and plan directly", proceed to the steps below exactly as before \u2014 do NOT modify any planning behavior.
32729
+
32613
32730
  Use the \`save_plan\` tool to create the implementation plan. Required parameters:
32614
32731
  - \`title\`: The real project name from the spec (NOT a placeholder like [Project])
32615
32732
  - \`swarm_id\`: The swarm identifier (e.g. "mega", "local", "paid")
@@ -32836,7 +32953,8 @@ Use the evidence manager tool to write a bundle at \`retro-{N}\` (where N is the
32836
32953
  3. Update context.md
32837
32954
  4. Write retrospective evidence: record phase_number, total_tool_calls, coder_revisions, reviewer_rejections, test_failures, security_findings, integration_issues, task_count, task_complexity, top_rejection_reasons, lessons_learned to .swarm/evidence/ via the evidence manager. Reset Phase Metrics in context.md to 0.
32838
32955
  4.5. Run \`evidence_check\` to verify all completed tasks have required evidence (review + test). If gaps found, note in retrospective lessons_learned. Optionally run \`pkg_audit\` if dependencies were modified during this phase. Optionally run \`schema_drift\` if API routes were modified during this phase.
32839
- 5. Run \`sbom_generate\` with scope='changed' to capture post-implementation dependency snapshot (saved to .swarm/evidence/sbom/). This is a non-blocking step - always proceeds to summary.
32956
+ 5. Run \`sbom_generate\` with scope='changed' to capture post-implementation dependency snapshot (saved to \`.swarm/evidence/sbom/\`). This is a non-blocking step - always proceeds to summary.
32957
+ 5.5. If \`.swarm/spec.md\` exists: delegate {{AGENT_PREFIX}}critic with DRIFT-CHECK context \u2014 include phase number, list of completed task IDs and descriptions, and evidence path (\`.swarm/evidence/\`). If SIGNIFICANT DRIFT is returned: surface as a warning to the user before proceeding. If spec.md does not exist: skip silently.
32840
32958
  6. Summarize to user
32841
32959
  7. Ask: "Ready for Phase [N+1]?"
32842
32960
 
@@ -32982,6 +33100,7 @@ REVIEW CHECKLIST:
32982
33100
  - Risk: Are high-risk changes identified? Is there a rollback path?
32983
33101
  - AI-Slop Detection: Does the plan contain vague filler ("robust", "comprehensive", "leverage") without concrete specifics?
32984
33102
  - Task Atomicity: Does any single task touch 2+ files or contain compound verbs ("implement X and add Y and update Z")? Flag as MAJOR \u2014 oversized tasks blow coder's context and cause downstream gate failures. Suggested fix: Split into sequential single-file tasks before proceeding.
33103
+ - Governance Compliance (conditional): If \`.swarm/context.md\` contains a \`## Project Governance\` section, read the MUST and SHOULD rules and validate the plan against them. MUST rule violations are CRITICAL severity. SHOULD rule violations are recommendation-level (note them but do not block approval). If no \`## Project Governance\` section exists in context.md, skip this check silently.
32985
33104
 
32986
33105
  OUTPUT FORMAT:
32987
33106
  VERDICT: APPROVED | NEEDS_REVISION | REJECTED
@@ -32997,7 +33116,99 @@ RULES:
32997
33116
  - MINOR issues can be noted but don't block APPROVED
32998
33117
  - No code writing
32999
33118
  - Don't reject for style/formatting \u2014 focus on substance
33000
- - If the plan is fundamentally sound with only minor concerns, APPROVE it`;
33119
+ - If the plan is fundamentally sound with only minor concerns, APPROVE it
33120
+
33121
+ ---
33122
+
33123
+ ### MODE: ANALYZE
33124
+ Activates when: user says "analyze", "check spec", "analyze spec vs plan", or \`/swarm analyze\` is invoked.
33125
+
33126
+ Note: ANALYZE produces a coverage report \u2014 its verdict vocabulary is distinct from the plan review above.
33127
+ CLEAN = all MUST FR-### have covering tasks; GAPS FOUND = one or more FR-### have no covering task; DRIFT DETECTED = spec\u2013plan terminology or scope divergence found.
33128
+ ANALYZE uses CRITICAL/HIGH/MEDIUM/LOW severity (not CRITICAL/MAJOR/MINOR used by plan review).
33129
+
33130
+ INPUT: \`.swarm/spec.md\` (requirements) and \`.swarm/plan.md\` (tasks). If either file is missing, report which is absent and stop \u2014 do not attempt analysis with incomplete input.
33131
+
33132
+ STEPS:
33133
+ 1. Read \`.swarm/spec.md\`. Extract all FR-### functional requirements and SC-### success criteria.
33134
+ 2. Read \`.swarm/plan.md\`. Extract all tasks with their IDs and descriptions.
33135
+ 3. Map requirements to tasks:
33136
+ - For each FR-###: find the task(s) whose description mentions or addresses it (semantic match, not exact phrase).
33137
+ - Partial coverage counts: a task that partially addresses a requirement is counted as covering it.
33138
+ - Build a two-column coverage table: FR-### \u2192 [task IDs that cover it].
33139
+ 4. Flag GAPS \u2014 requirements with no covering task:
33140
+ - FR-### with MUST language and no covering task: CRITICAL severity.
33141
+ - FR-### with SHOULD language and no covering task: HIGH severity.
33142
+ - SC-### with no covering task: HIGH severity (untestable success criteria = unverifiable requirement).
33143
+ 5. Flag GOLD-PLATING \u2014 tasks with no corresponding requirement:
33144
+ - Exclude: project setup, CI configuration, documentation, testing infrastructure.
33145
+ - Tasks doing work not tied to any FR-### or SC-###: MEDIUM severity.
33146
+ 6. Check terminology consistency: flag terms used differently across spec.md and plan.md (e.g., "user" vs "account" for the same entity): LOW severity.
33147
+ 7. Validate task format compliance:
33148
+ - Tasks missing FILE, TASK, CONSTRAINT, or ACCEPTANCE fields: LOW severity.
33149
+ - Tasks with compound verbs: LOW severity.
33150
+
33151
+ OUTPUT FORMAT:
33152
+ VERDICT: CLEAN | GAPS FOUND | DRIFT DETECTED
33153
+ COVERAGE TABLE: [FR-### | Covering Tasks \u2014 list up to top 10; if more than 10 items, show "showing 10 of N" and note total count]
33154
+ GAPS: [top 10 gaps with severity \u2014 if more than 10 items, show "showing 10 of N"]
33155
+ GOLD-PLATING: [top 10 gold-plating findings \u2014 if more than 10 items, show "showing 10 of N"]
33156
+ TERMINOLOGY DRIFT: [top 10 inconsistencies \u2014 if more than 10 items, show "showing 10 of N"]
33157
+ SUMMARY: [1-2 sentence overall assessment]
33158
+
33159
+ ANALYZE RULES:
33160
+ - READ-ONLY: do not create, modify, or delete any file during analysis.
33161
+ - Report only \u2014 no plan edits, no spec edits.
33162
+ - Partial coverage counts as coverage (do not penalize partially addressed requirements).
33163
+ - Report the highest-severity findings first within each section.
33164
+ - If both spec.md and plan.md are present but empty, report CLEAN with a note that both files are empty.
33165
+
33166
+ ---
33167
+
33168
+ ### MODE: DRIFT-CHECK
33169
+ Activates when: Architect delegates critic with DRIFT-CHECK context after completing a phase.
33170
+
33171
+ Note: ANALYZE detects spec-execution divergence after implementation \u2014 distinct from plan-review (APPROVED/NEEDS_REVISION/REJECTED) and ANALYZE (CLEAN/GAPS FOUND/DRIFT DETECTED).
33172
+ DRIFT-CHECK uses CRITICAL/HIGH/MEDIUM/LOW severity (not CRITICAL/MAJOR/MINOR used by plan review).
33173
+
33174
+ SIGNIFICANT DRIFT verdict = at least one CRITICAL or HIGH finding.
33175
+ MINOR DRIFT verdict = only MEDIUM or LOW findings.
33176
+ CLEAN verdict = no findings.
33177
+
33178
+ INPUT: Phase number (provided in TASK description as "DRIFT-CHECK phase N"). If not provided, ask the user for the phase number before proceeding.
33179
+
33180
+ EDGE CASES:
33181
+ - spec.md is missing: report "spec.md is missing \u2014 DRIFT-CHECK requires a spec to compare against" and stop.
33182
+ - plan.md is missing: report "plan.md is missing \u2014 cannot identify completed tasks for this phase" and stop.
33183
+ - Evidence files are missing: note the absence in the report but proceed with available data.
33184
+ - Invalid phase number (no tasks found for that phase): report "no tasks found for phase N" and stop.
33185
+
33186
+ STEPS:
33187
+ 1. Read \`.swarm/spec.md\`. Extract all FR-### requirements relevant to the phase being checked.
33188
+ 2. Read \`.swarm/plan.md\`. Extract all tasks marked complete ([x]) for the specified phase.
33189
+ 3. Read evidence files in \`.swarm/evidence/\` for the phase (retrospective, review outputs, test outputs).
33190
+ 4. For each completed task: compare what was implemented (from evidence) against the FR-### requirements it was supposed to address. Look for:
33191
+ - Scope additions: task implemented more than the FR-### required.
33192
+ - Scope omissions: task implemented less than the FR-### required.
33193
+ - Assumption changes: task used a different approach that may affect other requirements.
33194
+ 5. Classify each finding by severity:
33195
+ - CRITICAL: core requirement not implemented, or implementation contradicts requirement.
33196
+ - HIGH: significant scope addition or omission that affects other requirements.
33197
+ - MEDIUM: minor scope difference unlikely to affect other requirements.
33198
+ - LOW: stylistic or naming inconsistency between spec and implementation.
33199
+ 6. Produce the full drift report in your response. The Architect will save it to \`.swarm/evidence/phase-{N}-drift.md\`.
33200
+
33201
+ OUTPUT FORMAT:
33202
+ VERDICT: CLEAN | MINOR DRIFT | SIGNIFICANT DRIFT
33203
+ FINDINGS: [list findings with severity, task ID, FR-### reference, description]
33204
+ SUMMARY: [1-2 sentence assessment]
33205
+
33206
+ DRIFT-CHECK RULES:
33207
+ - Advisory: DRIFT-CHECK does NOT block phase transitions. It surfaces information for the Architect and user.
33208
+ - READ-ONLY: do not create, modify, or delete any file.
33209
+ - Output the full report in your response \u2014 do not attempt to write files directly.
33210
+ - If no spec.md exists, stop immediately and report the missing file.
33211
+ - Do not modify the spec.md or plan.md based on findings.`;
33001
33212
  function createCriticAgent(model, customPrompt, customAppendPrompt) {
33002
33213
  let prompt = CRITIC_PROMPT;
33003
33214
  if (customPrompt) {
@@ -33396,7 +33607,17 @@ RULES:
33396
33607
  - Be specific: exact names, paths, parameters, versions
33397
33608
  - Be concise: under 1500 characters
33398
33609
  - Be actionable: info Coder can use directly
33399
- - No code writing`;
33610
+ - No code writing
33611
+
33612
+ RESEARCH CACHING:
33613
+ Before fetching any URL or performing external research, check \`.swarm/context.md\` for a \`## Research Sources\` section.
33614
+ - If \`.swarm/context.md\` does not exist or the \`## Research Sources\` section is absent: proceed with fresh research.
33615
+ - If the URL or topic is listed there: reuse the cached summary \u2014 do not fetch the URL again.
33616
+ - If not listed (cache miss): fetch the URL, produce your normal response, then append this line at the end of your response:
33617
+ CACHE-UPDATE: \`[YYYY-MM-DD] [URL or topic]: [1-2 sentence summary]\`
33618
+ The Architect will save this line to \`.swarm/context.md\` under \`## Research Sources\`.
33619
+ - Cache bypass: if the user explicitly requests fresh research ("re-fetch", "ignore cache", "latest"): skip the cache check and fetch directly; still include the CACHE-UPDATE line.
33620
+ - Do NOT write to any file \u2014 SME is read-only. Cache persistence is the Architect's responsibility.`;
33400
33621
  function createSMEAgent(model, customPrompt, customAppendPrompt) {
33401
33622
  let prompt = SME_PROMPT;
33402
33623
  if (customPrompt) {
@@ -34554,6 +34775,15 @@ function handleAgentsCommand(agents, guardrails) {
34554
34775
  `);
34555
34776
  }
34556
34777
 
34778
+ // src/commands/analyze.ts
34779
+ async function handleAnalyzeCommand(_directory, args2) {
34780
+ const description = args2.join(" ").trim();
34781
+ if (description) {
34782
+ return `[MODE: ANALYZE] ${description}`;
34783
+ }
34784
+ return "[MODE: ANALYZE] Please analyze the spec against the plan using MODE: ANALYZE.";
34785
+ }
34786
+
34557
34787
  // src/commands/archive.ts
34558
34788
  init_manager();
34559
34789
  async function handleArchiveCommand(directory, args2) {
@@ -35123,6 +35353,15 @@ async function handleBenchmarkCommand(directory, args2) {
35123
35353
  `);
35124
35354
  }
35125
35355
 
35356
+ // src/commands/clarify.ts
35357
+ async function handleClarifyCommand(_directory, args2) {
35358
+ const description = args2.join(" ").trim();
35359
+ if (description) {
35360
+ return `[MODE: CLARIFY-SPEC] ${description}`;
35361
+ }
35362
+ return "[MODE: CLARIFY-SPEC] Please enter MODE: CLARIFY-SPEC and clarify the existing spec.";
35363
+ }
35364
+
35126
35365
  // src/commands/config.ts
35127
35366
  import * as os2 from "os";
35128
35367
  import * as path8 from "path";
@@ -36020,6 +36259,15 @@ ${error93 instanceof Error ? error93.message : String(error93)}`;
36020
36259
  }
36021
36260
  }
36022
36261
 
36262
+ // src/commands/specify.ts
36263
+ async function handleSpecifyCommand(_directory, args2) {
36264
+ const description = args2.join(" ").trim();
36265
+ if (description) {
36266
+ return `[MODE: SPECIFY] ${description}`;
36267
+ }
36268
+ return "[MODE: SPECIFY] Please enter MODE: SPECIFY and generate a spec for this project.";
36269
+ }
36270
+
36023
36271
  // src/hooks/extractors.ts
36024
36272
  function extractCurrentPhase(planContent) {
36025
36273
  if (!planContent) {
@@ -36472,7 +36720,10 @@ var HELP_TEXT = [
36472
36720
  "- `/swarm benchmark [--cumulative] [--ci-gate]` \u2014 Show performance metrics",
36473
36721
  "- `/swarm export` \u2014 Export plan and context as JSON",
36474
36722
  "- `/swarm reset --confirm` \u2014 Clear swarm state files",
36475
- "- `/swarm retrieve <id>` \u2014 Retrieve full output from a summary"
36723
+ "- `/swarm retrieve <id>` \u2014 Retrieve full output from a summary",
36724
+ "- `/swarm clarify [topic]` \u2014 Clarify and refine an existing feature specification",
36725
+ "- `/swarm analyze` \u2014 Analyze spec.md vs plan.md for requirement coverage gaps",
36726
+ "- `/swarm specify [description]` \u2014 Generate or import a feature specification"
36476
36727
  ].join(`
36477
36728
  `);
36478
36729
  function createSwarmCommandHandler(directory, agents) {
@@ -36540,6 +36791,15 @@ function createSwarmCommandHandler(directory, agents) {
36540
36791
  case "retrieve":
36541
36792
  text = await handleRetrieveCommand(directory, args2);
36542
36793
  break;
36794
+ case "clarify":
36795
+ text = await handleClarifyCommand(directory, args2);
36796
+ break;
36797
+ case "analyze":
36798
+ text = await handleAnalyzeCommand(directory, args2);
36799
+ break;
36800
+ case "specify":
36801
+ text = await handleSpecifyCommand(directory, args2);
36802
+ break;
36543
36803
  default:
36544
36804
  text = HELP_TEXT;
36545
36805
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-swarm",
3
- "version": "6.14.12",
3
+ "version": "6.15.0",
4
4
  "description": "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",