GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — opencode-swarm/docs/planning.md at main · ZaxbyHub/opencode-swarm

Expand file tree

/

planning.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
505 lines (353 loc) · 34 KB
/

planning.md

Copy path

File metadata and controls

505 lines (353 loc) · 34 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

Pre-Swarm Planning

The Point

The swarm is an execution engine. Good plan in, good code out. Bad plan in, wasted API calls while the Critic tries to salvage it.

Every cycle the Architect spends figuring out what to build is a cycle not spent building. Do your planning in free web chat interfaces before you ever open OpenCode.


How It Works

Use multiple AI models (their free web tiers) to debate and poke holes in a single implementation plan. Different models have different blind spots — Claude might approve something Gemini flags as conflicting with a library's actual behavior, or Perplexity might surface a recent CVE the others missed.

A plan that survives scrutiny from 3-6 models is stronger than anything one model produces alone. Once it's solid, drop it in your project and let the Architect run.


Steps

1. Snapshot Your Codebase

Use gitingest to dump your entire codebase into a single text file. This gives every model the same context.

For new projects, just gather your requirements, architecture notes, and stack decisions.

2. Brief Every Model on the Swarm

Paste the opencode-swarm README into each model. The README covers the workflow, task format, and QA gates — that's all they need to structure a plan correctly. You don't need the full plugin codebase unless you're planning changes to the swarm itself.

Each model needs to know:

  • The Architect delegates all coding to the Coder — it never writes code itself
  • Each task runs through a full 15-step QA gate
  • Tasks must be atomic: one file, one concern, one logical change
  • Tasks need description, files_touched, and verifiable acceptance fields; use depends and fr_refs when applicable
  • The Critic reviews the plan before implementation starts

Task Field Reference

Every task handed to the Architect should provide these save_plan fields. The Architect persists them; .swarm/plan.md is generated afterward.

Field Required Good Example Bad Example
files_touched Yes for coding tasks ["src/auth/login.ts"] [] or an absolute path
description Yes Add email format validation to the login handler Update login and add tests (compound)
acceptance Recommended Rejects emails missing @; existing tests pass It works (not verifiable)
depends When needed ["1.1", "1.2"] An undeclared or circular task ID

Rules:

  • description must be a single imperative sentence with no "and" connecting two actions.
  • acceptance must be specific enough for the test engineer to write a verification test.
  • Put actionable constraints in the description or acceptance text; do not rely on a field the save_plan schema does not persist.

Task paths have runtime significance beyond documentation. Author each coding task through save_plan with files_touched: ["path/from/project/root"]. Coder preflight resolves scope in the exact order active declare_scope binding > plan files_touched > complete FILE: lines; every lower-precedence source that is present must be a subset of the authoritative source. Missing scope fails with SCOPE_NOT_DECLARED, and disagreement fails with SCOPE_CONFLICT, before the coder starts. Bindings are specific to the workspace, plan generation, task, parent session, and Task call; worktree lanes derive fresh child-root authority.

With Epic Mode enabled (epic.mode.enabled: true), declared scopes also decide whether a plan is epic-sized (epic.sizing.min_scope_coverage, default 80% of pending tasks with a scope) and which tasks share a wave; save_plan then returns epic_shaping suggestions (declare-scope, narrow-scope, extract-prerequisite, isolate-hot-file, split-task, merge-tasks), each as a concrete save_plan patch. Precise, narrow files_touched lists yield wider waves.

files_touched accepts normalized project-relative files or directories. Include generated outputs and lockfiles that the task will write. On a plan revision, omission preserves the existing task scope, while an explicit empty array clears it. save_plan rejects absolute paths, parent-traversal components, empty entries, control characters, entries over 4,096 UTF-8 bytes, and aggregate scope text over 1 MiB. The ledger remains authoritative; .swarm/plan.md only displays a safely quoted, deterministic projection of the saved list.

When scope preflight fails:

  • SCOPE_CONFLICT: reconcile the named explicit/plan/FILE: sets, update stale plan data through save_plan, then redeclare the exact list with replace_existing: true.
  • SCOPE_BINDING_EXPIRED or SCOPE_BINDING_AMBIGUOUS: re-read the task and redeclare its exact intended list with replace_existing: true.
  • SCOPE_BINDING_STORE_OVERLOADED: finish or expire terminal tasks, then retry declare_scope; the runtime will not choose from an incompletely scanned store.
  • SCOPE_WORKSPACE_MISMATCH: use the reported lane/worktree root as working_directory; paths stay relative to that root.
  • SCOPE_ROOT_ESCAPE: retry with the diagnostic's safe relative path only; never authorize an outside absolute path.
  • Effective-authority or verifier-config denial: redeclaration cannot override it. Assign the operation to the correct role or change the task.

Task Sizing

Size Definition Action
SMALL 1 file, 1 function or class Assign directly to plan
MEDIUM 1 file with multiple functions, or up to 2 files Plan as-is
LARGE More than 2 files, or compound concern Must be split before adding to plan

If you cannot state one description, one bounded files_touched list, and one verifiable acceptance criterion, the task is too large.


Task Workflow States

Each task in the swarm follows a per-task state machine. The Architect advances state as gates complete; update_task_status enforces the final transition. Understanding these states helps you write acceptance criteria that match what the swarm actually enforces.

State Meaning How It's Entered
idle Task not yet started Default state
coder_delegated An accepted coder mutation created fresh verification debt A coder settlement proves an in-scope mutation and rotates the workflow generation
pre_check_passed Automated gates passed pre_check_batch returns gates_passed: true. Recovery entry modes (audited, marked in the evidence): recover_rework_task writes a supervised stage_a_passed from rework_required (#2755), and /swarm recover or the recover_stage_a_task tool write a settlement-backed stage_a_passed from idle/blocked when a COMMITTED accepted settlement plus green post-settlement pre-check proof still justify Stage A (#2828)
reviewer_run Human-style review complete Reviewer delegation returns APPROVED
tests_run Verification tests passed Test engineer delegation returns PASS
rework_required Current-generation verification failed and same-task repair is required Stage A fails, or reviewer/test engineer returns a negative or malformed verdict. A TESTED SKIPPED verdict (tests not run) is the exception: it stays Stage B eligible for test-gate re-dispatch instead of entering rework_required (#2756)
blocked Task ended without completion and no verification debt remains update_task_status(status: 'blocked') commits the terminal transaction
closed A session ended with unfinished work; this is not successful completion /swarm close commits a plan-bound task_closed transition
complete Task fully complete update_task_status(status: 'completed') called

Enforcement rule: update_task_status with status: 'completed' is decided from durable evidence for the exact task and workflow generation. Session state and delegation history are diagnostic only. An empty/no-mutation coder attempt creates no review debt. Any safely attributed mutation rotates the generation and invalidates prior Stage A/B proof, including partial edits left by a failed or cancelled shared-root settlement; that failure enters rework_required. Stage A failure also moves the task to rework_required, where same-task repair remains callable.

closed never substitutes for complete: /swarm close preserves authoritative successful evidence and records unfinished work as closed. Resuming a closed task requires the same audited exact-state, exact-generation force-repair path used for other settled non-success states.

execution_profile.planning_profile selects planning ceremony. balanced is the normal default: durable QA/execution defaults are persisted and the architect asks only about material ambiguity or high-risk authorization. strict retains the full questionnaire, spec prerequisite, and checklist. Repositories with strict execution default to strict; locked legacy profiles without the field also resolve conservatively to strict. Locked plans may ratchet from balanced to strict, never the reverse. Explicit balanced and strict values remain distinct in plan hashes and Markdown; only the runtime resolver interprets an omitted locked legacy value as strict. On each architect turn, the persisted plan resolution supersedes the repository-default directive baked into the base prompt.


3. Generate a Draft Plan

Give one model your requirements + codebase snapshot. Ask for a structured draft matching the save_plan task fields. This is your starting point, not the final persisted plan.

Here is my codebase [paste gitingest]. Here is the opencode-swarm README
[paste README]. I need to implement [describe feature/change].

Generate a complete structured implementation plan for save_plan.
Every coding task must include id, description, files_touched, and acceptance.
Tasks must be atomic — one file, one concern. No task should touch more
than 2 primary source files. Include any generated outputs and lockfiles in
files_touched. No compound verbs in descriptions.

4. Cross-Examine With Other Models

Paste the draft into every other model you have. Ask each to tear it apart:

Here is an implementation plan for my project [paste plan]. Here is the
codebase context [paste gitingest]. Here is the swarm plugin that will
execute it [paste swarm README].

Review this plan and tell me:

1. Are any tasks too large or batching multiple concerns?
2. Are there missing dependencies between tasks?
3. Are acceptance criteria testable and specific?
4. Are there architectural risks or edge cases not addressed?
5. Does anything conflict with the existing codebase?

5. Iterate Until They Agree

Revise based on feedback, then repeat step 4. Keep going until every model signs off — no major objections, no missing pieces, no vague tasks.

This usually takes 2-4 rounds. If you can't converge after 4-5 rounds, your requirements are probably ambiguous. Fix those first.

6. Final Validation Checklist

Before handing off to the Architect:

  • Every coding task has id, description, non-empty files_touched, and acceptance
  • No task touches more than 2 files
  • No task description contains "and" connecting two separate actions
  • Dependencies are declared explicitly (depends: ["X.Y"])
  • Phase and task IDs match the save_plan schema
  • Acceptance criteria are specific enough for the test engineer to verify
  • Security-sensitive files (auth, crypto, config, env) are flagged so the security reviewer gate triggers

7. Hand Off

Give the reviewed task structure to the Architect and have it persist the plan through save_plan (including each coding task's files_touched). Do not hand-edit .swarm/plan.md; it is a derived view of the authoritative ledger.

Persist this reviewed plan with save_plan, then implement it. Follow phases sequentially.
Run bun test after each phase. Report progress after each completed task.

Model Recommendations

Free tiers are fine for planning. 3-4 models is enough for most work; 5-6 for complex stuff.

Model Good At Free Access
Claude Reasoning, catching logical gaps claude.ai
Gemini Finding undocumented edge cases gemini.google.com
ChatGPT Broad knowledge, task decomposition chatgpt.com
Perplexity Research-backed, API/library questions perplexity.ai
Qwen Different training data, catches different things chat.qwen.ai
Deepseek Code architecture reasoning chat.deepseek.com

How to Tell It's Working

Converging — feedback shifts from "this task is missing X" to minor wording nitpicks. All models can trace every requirement to a task. No one finds uncovered files.

Not converging — models recommend contradictory approaches, each round surfaces new structural problems, or they disagree on whether the codebase even supports the approach. If tasks keep getting bigger ("this should really be one task covering A, B, and C"), that's a red flag too.


Cost

Activity API Cost
Multi-model planning in web chat $0
Swarm execution of a solid plan Low — clear tasks, few retries
Swarm execution of a vague plan High — Critic cycles, retries, gate failures

1-2 hours of free planning routinely saves 3-5x that in execution costs.


Spec Kit

GitHub Spec Kit automates a similar workflow (spec → plan → tasks) using AI agents in your editor. It's faster. The manual multi-model approach gives you more control and makes cross-model disagreements visible, which matters more for complex or security-sensitive work.

Both produce the same input: a structured plan the Architect persists through save_plan before execution.


TL;DR

  1. gitingest your codebase + grab the swarm README
  2. Generate a draft plan with one model
  3. Cross-examine with 3-5 other models
  4. Iterate until convergence (2-4 rounds)
  5. Run the validation checklist
  6. Drop plan.md into .swarm/ and start the Architect

Planning cost: $0 | Planning time: 1-2 hours | Payoff: fewer retries, lower API spend


The Built-In Spec Pipeline

If you prefer to plan inside OpenCode rather than in a separate tool, the swarm has a built-in spec pipeline. It guides you from raw requirements through a validated spec to a complete implementation plan — all without leaving your current session.

The Three Commands

Command When to Use What It Does
/swarm specify [description] You have a feature idea but no spec yet Generates .swarm/spec.md with FR-### requirements, SC-### success criteria, and user scenarios
/swarm clarify [topic] Your spec has [NEEDS CLARIFICATION] markers or vague language Asks targeted questions one at a time, updates spec.md after each accepted answer
/swarm analyze You have both a spec and a plan and want a coverage check Maps FR-### requirements to plan tasks, flags gaps (untasked requirements) and gold-plating (untasked work)
`/swarm sdd status validate project`

The Workflow

Starting from scratch:

  1. /swarm specify <feature description> → architect generates spec.md
  2. If spec has [NEEDS CLARIFICATION] markers → /swarm clarify enters clarification mode; persist accepted answers through canonical spec_write. Clarify mode alone does not clear spec drift.
  3. Tell the architect to start planning → PLAN mode reads spec.md, optionally offers General Council advisory input when council.general.enabled is configured, and cross-references FR-### automatically
  4. Optionally /swarm analyze after planning to verify coverage

Importing an existing plan: If you already have a plan (e.g. from a prior tool or another session), you can use /swarm specify with the plan pasted in — the architect will reverse-engineer a spec from it, validate the plan's format, and surface any gaps.

Using OpenSpec-compatible artifacts: Keep current requirements in openspec/specs/**/spec.md and pending deltas in openspec/changes/*/specs/**/spec.md. When .swarm/spec.md is absent, planning, spec hashing, drift checks, linting, and requirement coverage use an effective Swarm spec projected from those artifacts. Run /swarm sdd validate before planning and /swarm sdd project --overwrite when you want to materialize the projection into .swarm/spec.md (first projection omits --overwrite; re-projecting an existing file requires it). The projected .swarm/spec.md includes a scaffold ## Success Criteria section — fill in the SC-### placeholders with concrete success criteria before planning.

Using Spec-Kit artifacts: When your repository has a .specify/ marker directory and specs/<feature-dir>/spec.md files, /swarm sdd project auto-detects the Spec-Kit layout and projects the feature into .swarm/spec.md. Use --feature <id> when multiple feature directories exist; see Spec-Kit SDD support below for detection rules, feature selection, source precedence, and validation details.

Without a spec: When you enter PLAN mode without an effective spec (confirmed via /swarm sdd status), the architect offers to create one first or skip. If you skip the offer, save_plan will reject with SPEC_REQUIRED — PLAN will diagnose the situation via /swarm sdd status, guide you through materializing an effective spec with explicit consent steps, and stop if you decline. To bypass the spec gate entirely, set SWARM_SKIP_SPEC_GATE=1 in your environment (tests and CI only).

Using General Council before planning: When council.general.enabled is true and web search is available (searchProvider: "keenable" needs no key; Tavily, Brave or SpecStream need a configured API key), MODE: PLAN asks whether to use the three-agent General Council before save_plan. If accepted, the architect gathers current external context, records the council consensus/disagreements in .swarm/context.md, and uses that input before writing the plan and before critic pre-plan review.

Spec-Kit SDD support

Starting with issue #1228, /swarm sdd detects and projects GitHub Spec-Kit artifacts alongside OpenSpec, so teams already using Spec-Kit can enforce their existing specs with the Swarm drift gate without rewriting anything.

Detection

A Spec-Kit layout is identified by two conditions being true simultaneously:

  • A .specify/ marker directory at the repository root, and
  • One or more specs/<feature-dir>/spec.md files. Any non-symlink directory directly under specs/ that contains a spec.md is detected as a feature; the NNN- numbering prefix (e.g. 001-my-feature) is Spec-Kit convention, not an enforced rule.

A repository that has a specs/ directory but no .specify/ marker is not treated as Spec-Kit. /swarm sdd status reports the Spec-Kit source in a dedicated section, separate from the OpenSpec output.

Projection

/swarm sdd project projects Spec-Kit features into .swarm/spec.md:

/swarm sdd project                                              # auto-detect; ALL features when several exist
/swarm sdd project --feature 001-my-feature                  # ONE feature (v1 single-feature form)
/swarm sdd project --feature all                             # explicit alias for the multi-feature default
/swarm sdd project --source speckit --feature 001-my-feature  # explicit when both layouts are present
/swarm sdd project --overwrite                                # overwrite existing .swarm/spec.md

--feature <id> takes the full feature directory name (e.g. 001-my-feature) and selects exactly ONE feature (an error with --source openspec or --source swarm). --feature all is accepted by project only. A feature whose spec.md yields no parsable requirements refuses the whole projection (named) rather than silently dropping it.

Id-identity model (feature-scoped). When ONE feature is selected (explicitly or by single-feature auto-detect), original bare FR-### identifiers are preserved unchanged — byte-identical to the v1 projection. When MULTIPLE features project together, requirement ids are FEATURE-SCOPED: <featureId>/FR-### (e.g. 001-login/FR-001). Spec-Kit restarts FR-001 in every feature, so this is the only form that keeps two features' FR-001 distinct through drift scoring and coverage — a flat renumbering (002-x/FR-001 → FR-047) was rejected because drift reports would cite ids the user's source does not contain (a traceability disconnect: the report could not be walked back to the spec line). The trade-off: plan and digest text should cite either the full namespaced id or the bare FR-###; drift scoring treats a bare plan reference as covering every feature's same-numbered requirement (never a false MAJOR_DRIFT), while a namespaced reference stays feature-precise. When a requirement carries no explicit identifier, a stable one is synthesized per feature — re-running the same source produces an identical projection. The resulting .swarm/spec.md is treated identically to an OpenSpec projection by all downstream tools: drift verification, lint, and requirement coverage apply with no source-specific handling. The projected spec also includes a scaffold ## Success Criteria section (one per feature in multi-feature mode) with placeholder SC-### identifiers and [NEEDS CLARIFICATION] markers — fill these in with concrete success criteria before planning.

Source precedence

When resolving which source feeds planning and drift enforcement:

  1. Native .swarm/spec.md present — always used, regardless of --source.
  2. --source <openspec|speckit> — explicit selection (applied after the native-spec check).
  3. SWARM_SDD_SOURCE (environment variable) and then sdd.source in .opencode/opencode-swarm.json (or the user config) — the same values as --source, for non-interactive and project-pinned selection. A selection from either is final: if that provider yields no spec the repo is not re-auto-detected, and a one-time advisory in /swarm diagnose names the selection. An unrecognized SWARM_SDD_SOURCE value is reported once and ignored; an invalid sdd.source is a config validation error like any other invalid key (reported by the loader and /swarm doctor; when a user-level config exists the loader's fail-secure recovery discards the project config until it is fixed), and the SDD resolver independently buffers its own advisory and falls through to auto-detect (since the #3354 fix the resolver derives its answer from the same loader pipeline, so a project config the loader discarded — another invalid key, or a refused prototype-pollution payload such as __proto__ — can no longer supply sdd.source; every acceptance the loader performs, including stripped-key recovery and legacy-Epic migration, still supplies its source). The /swarm sdd commands honor the same selection, and status reports where it came from.
  4. Auto-detect (nothing selected):
    • Only Spec-Kit detected → Spec-Kit projection used.
    • Only OpenSpec detected → OpenSpec projection used (unchanged behavior).
    • Both detected, nothing selected — the two paths differ by layer. For library consumers (planning/drift), readEffectiveSpecSync returns no effective spec and logs a single ambiguity warning, so drift enforcement degrades to advisory rather than guessing. The /swarm sdd commands (status, validate, project) treat the same situation as a hard error, naming both sources and requiring --source (or SWARM_SDD_SOURCE / sdd.source) to disambiguate.

--source swarm is accepted by status and validate but is rejected by project — the native .swarm/spec.md does not require projection.

Validation (read-only)

/swarm sdd validate inspects Spec-Kit artifacts and reports structural problems without modifying any file:

  • Required sections — ## Functional Requirements and ## Success Criteria must be present in spec.md.
  • Task references — Each checkbox task line that carries a T### id (e.g. - [ ] T001 …) must also carry a [US#] user-story tag or an FR-### requirement id; such task lines with neither are flagged. Lines without a T### id are not task lines and are not checked.
  • Zero functional requirements — A feature whose spec.md yields no parsable functional requirements is surfaced as a structural problem. Requirements include both explicit FR-### lines and id-less obligation bullets under ## Functional Requirements (which are assigned synthesized ids); the problem fires only when neither form is present.

--source speckit and --feature <id> apply to validate by the same rules as project.

tasks.md check-off round trip (opt-in)

Swarm can check off Spec-Kit tasks in the SOURCE tasks.md (- [ ] → - [x]) when a plan task completes — opt-in, OFF by default (enable speckit_checkoff.enabled in the plugin config; it is a no-op for native and OpenSpec sources). Projection captures a check-off ledger at .swarm/speckit-checkoff-ledger.json mapping each T### to its requirement refs: explicit FR-### references on the task line, plus the story-index mapping ([US n] maps to the feature's n-th requirement in projection order). Safety semantics: only the matched task line's checkbox bytes change (line endings and every other byte are preserved — byte parity); a user edit between read and write is reconciled, never clobbered; a task the user reopened ([x] → [ ]) is reported and never re-checked; a regenerated/renumbered tasks.md (ledger digest mismatch) refuses all writes for that feature until the next /swarm sdd project rebuilds the ledger; writes are atomic under a cross-process lock; a completion matching tasks in several features checks each and reports per-feature rows; a completion matching nothing reports unmatched. Writing specs/<feature>/tasks.md (outside .swarm/) is a deliberate, issue-mandated exception to runtime-state containment — it is the user's own artifact being round-tripped, and the gate + safety semantics above bound it.

Spec Format

The spec lives at .swarm/spec.md. It contains:

  • Functional requirements numbered FR-001, FR-002… — what users need, written with MUST/SHOULD language
  • Success criteria numbered SC-001, SC-002… — measurable, technology-agnostic outcomes
  • User scenarios with Given/When/Then acceptance criteria
  • [NEEDS CLARIFICATION] markers for areas where uncertainty could change scope

The spec deliberately contains NO technology choices, file paths, or implementation details. It captures what and why, not how — leaving HOW to the plan.

Relationship to the Existing Multi-Model Approach

The built-in spec pipeline is an alternative path, not a replacement. The multi-model planning approach using external tools (Claude.ai, ChatGPT) remains fully supported and is often the right choice for complex features where you want to iterate on requirements before opening OpenCode.

Use the built-in pipeline when:

  • You want a fast spec without switching tools
  • Your requirements are clear enough to capture in one session
  • You're extending an existing codebase where the spec can be grounded in the current code

Multi-Language Projects

OpenCode Swarm v6.16+ automatically detects project languages by scanning for language-specific marker files (e.g., package.json, Cargo.toml, go.mod, pubspec.yaml) and file extensions. No configuration is required for single-language projects.

Auto-Detection

Language detection runs transparently during tool execution. The detectProjectLanguages(projectDir) function returns active profiles sorted by tier. Tier 1 languages (TypeScript/JS, Python, Rust, Go) have the richest tool coverage; Tier 2 and Tier 3 languages have progressively lighter coverage.

Monorepo Support

For monorepos with multiple language subdirectories, all detected languages are activated. Tool commands run for each detected ecosystem independently — a Go + TypeScript monorepo runs both go test and bun test, for example.

Profile-Driven Tool Resolution

Each language profile specifies its own build commands, test frameworks, lint tools, audit command, and SAST rules. The swarm picks the highest-priority tool whose binary is on PATH. If no binary is found, the step is skipped with a soft warning — the pipeline continues.

Optional External Tools

Some tools require manual installation and are not bundled:

Tool Language Install
govulncheck Go (Tier 1) go install golang.org/x/vuln/cmd/govulncheck@latest
ktlint Kotlin Download from ktlint releases
bundle-audit Ruby gem install bundler-audit
cppcheck C / C++ brew install cppcheck or apt install cppcheck
swiftlint Swift brew install swiftlint

Missing binaries produce a soft warning only — the pipeline never hard-fails on a missing tool.

Language-Specific Prompt Injection

The coder and reviewer agents automatically receive language-specific constraints and review checklists derived from the task's target file paths. See Swarm Briefing for LLMs for details.


Curator Integration

The Curator is a background analysis system that provides phase-level intelligence across the project lifecycle. It is enabled by default; set curator.enabled = false in .opencode/opencode-swarm.json to disable it.

How the Curator Hooks into Execution

The Curator integrates at three points in the swarm execution pipeline:

1. Phase Monitor Init (src/hooks/phase-monitor.ts)

On the first phase of a project, the phase-monitor hook detects that lastSeenPhase is transitioning from null and calls runCuratorInit. This initializes .swarm/curator-summary.json with a baseline entry and persists the init briefing to .swarm/curator-briefing.md.

// Fires once, on first-phase detection
if (curatorConfig.enabled && curatorConfig.init_enabled) {
  await runCuratorInit(directory, curatorConfig);
  // Briefing is persisted to .swarm/curator-briefing.md
}

The init call is wrapped in try/catch — if the Curator fails to initialize, the phase-monitor continues normally.

2. Phase Complete Pipeline (src/tools/phase-complete.ts)

After each phase completes (and after the standard curateAndStoreSwarm() call), the Curator pipeline runs:

  1. runCuratorPhase — Collects phase events from the event bus, runs compliance checks, and produces a CuratorPhaseResult.
  2. applyCuratorKnowledgeUpdates — Merges the phase result's knowledge recommendations into .swarm/curator-summary.json. Recommendation persistence deduplicates the complete stable semantic payload, keeps the newest occurrence, and caps the array at 200 entries.
  3. runCriticDriftCheck — Compares planned vs. actual decisions, writes a drift report to .swarm/drift-report-phase-N.json.
  4. Compliance surfacing — If compliance observations exist and suppress_warnings is false, they are added to the return value's warnings array (max 5).

The entire pipeline is wrapped in a single try/catch and gated on curatorConfig.enabled && curatorConfig.phase_enabled. If any step throws, phase_complete is never blocked.

3. Knowledge Injector (src/hooks/knowledge-injector.ts)

At the start of each phase, the knowledge-injector hook injects both drift reports and curator briefing:

Drift injection:

  1. Calls readPriorDriftReports(directory) to load all drift reports sorted ascending by phase.
  2. Takes the last entry (most recent phase).
  3. Calls buildDriftInjectionText(report, drift_inject_max_chars) to format it.
  4. Prepends the result to cachedInjectionText.

Curator briefing injection:

  1. Reads .swarm/curator-briefing.md via readSwarmFileAsync.
  2. Truncates to 500 characters.
  3. Prepends as <curator_briefing> tag to cachedInjectionText.

Important: Both drift reports and curator briefing are injected even when no knowledge entries exist. The injection logic was restructured to run before the entries.length === 0 check.

Drift Report Format

Drift reports live at .swarm/drift-report-phase-N.json and follow the DriftReport interface:

interface DriftReport {
  schema_version: 1;
  phase: number;
  timestamp: string;          // ISO 8601
  alignment: 'ALIGNED' | 'MINOR_DRIFT' | 'MAJOR_DRIFT' | 'OFF_SPEC';
  drift_score: number;        // 0.0 (aligned) to 1.0 (completely off-spec)
  first_deviation: {
    phase: number;
    task: string;
    description: string;
  } | null;
  compounding_effects: string[];
  corrections: string[];      // Recommended course corrections
  requirements_checked: number;
  requirements_satisfied: number;
  scope_additions: string[];
  injection_summary: string;  // Truncated summary for architect context injection
}

Configuration Quick Reference

Field Default Effect
enabled true Master switch; set to false to disable Curator activity
init_enabled true Run curator init on first phase
phase_enabled true Run phase analysis + drift check after each phase
postmortem_enabled true Run curator postmortem analysis during closeout
max_summary_tokens 2000 Cap on curator summary size
min_knowledge_confidence 0.7 Minimum confidence for knowledge entry inclusion
drift_inject_max_chars 500 Max chars of drift text injected into architect context
llm_timeout_ms 300000 Timeout for curator init and phase LLM calls
skill_generation_enabled true Enable curator-generated skill candidate output
skill_generation_mode draft Write generated skill candidates as drafts by default
min_skill_confidence 0.7 Minimum confidence for generated skill candidates
min_skill_confirmations 2 Minimum confirmations before skill promotion

See the Curator section in README.md for full configuration details.

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.