@yemi33/minions 0.1.1884 → 0.1.1886

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
@@ -6,6 +6,8 @@ Zero dependencies — uses only Node.js built-in modules.
6
6
 
7
7
  Inspired by and initially scaffolded from [Brady Gaster's Squad](https://bradygaster.github.io/squad/).
8
8
 
9
+ 📚 **Documentation:** see [docs/README.md](docs/README.md) for the full audience-grouped docs index.
10
+
9
11
  ## Prerequisites
10
12
 
11
13
  - **Node.js** 18+ (LTS recommended)
@@ -40,6 +42,41 @@ git clone https://github.com/yemi33/minions.git ~/.minions
40
42
  node ~/.minions/minions.js init
41
43
  ```
42
44
 
45
+ ## CLI Reference
46
+
47
+ | Command | Description |
48
+ |---------|-------------|
49
+ | `minions init` | Bootstrap `~/.minions/` with default agents and config |
50
+ | `minions update` | Update to latest version (npm update + apply) |
51
+ | `minions version` | Show installed vs package version |
52
+ | `minions doctor` | Check prerequisites and runtime health |
53
+ | `minions scan [dir] [depth]` | Scan for git repos and multi-select to add (default: ~, depth 3) |
54
+ | `minions add <dir>` | Link a single project (auto-detects settings from git, prompts to confirm) |
55
+ | `minions remove <dir-or-name> [--keep-data \| --purge --force]` | Unlink a project: cancels pending work items, drains dispatch + kills active agents, cleans worktrees, disables linked schedules, archives `projects/<name>/` to `projects/.archived/<name>-YYYYMMDD/`. Use `--keep-data` to leave the data dir in place, or `--purge --force` to delete it. |
56
+ | `minions list` | List all linked projects with descriptions |
57
+ | `minions restart` | Start engine and dashboard together (recommended after reboot) |
58
+ | `minions start` | Start engine daemon (ticks every 60s, auto-syncs MCP servers) |
59
+ | `minions stop` | Stop the engine |
60
+ | `minions status` | Show agents, projects, dispatch queue, quality metrics |
61
+ | `minions pause` / `resume` | Pause/resume dispatching |
62
+ | `minions dispatch` | Force a dispatch cycle |
63
+ | `minions discover` | Dry-run work discovery |
64
+ | `minions queue` | Show dispatch queue (pending, active, completed) |
65
+ | `minions sources` | Show work source status per project |
66
+ | `minions work <title> [opts]` | Add to central work queue |
67
+ | `minions spawn <agent> <prompt>` | Manually spawn an agent |
68
+ | `minions plan <file\|text> [proj]` | Run a plan |
69
+ | `minions kill` | Kill all active agents and reset their dispatches to pending |
70
+ | `minions complete <dispatch-id>` | Manually mark a dispatch as completed |
71
+ | `minions config set-cli <R> [--model M]` | Persist the default runtime/model without starting the engine |
72
+ | `minions mcp-sync` | Sync MCP servers from `~/.claude.json` |
73
+ | `minions cleanup` | Run cleanup manually (temp files, worktrees, zombies) |
74
+ | `minions dash` | Open dashboard (starts if not already running, port 7331) |
75
+ | `minions nuke --confirm` | Factory reset runtime state and reset config to defaults |
76
+ | `minions uninstall --confirm` | Remove Minions state and uninstall the npm package |
77
+
78
+ You can also run scripts directly: `node ~/.minions/engine.js start`, `node ~/.minions/dashboard.js`, etc.
79
+
43
80
  ## Upgrading
44
81
 
45
82
  ```bash
@@ -64,6 +101,8 @@ minions init --force
64
101
 
65
102
  ## Quick Start
66
103
 
104
+ > **New contributor?** Walk through [docs/onboarding.md](docs/onboarding.md) first — an 8-step, first-30-minutes guide from clone → doctor → init → add → dashboard tour → first dispatch → first plan → first PR review, with debugging pointers.
105
+
67
106
  ```bash
68
107
  # 1. Init + scan — finds all git repos on your machine, multi-select to add
69
108
  minions init
@@ -120,41 +159,6 @@ To give the minions its first task, open the dashboard Command Center and add a
120
159
  minions work "Explore the codebase and document the architecture"
121
160
  ```
122
161
 
123
- ## CLI Reference
124
-
125
- | Command | Description |
126
- |---------|-------------|
127
- | `minions init` | Bootstrap `~/.minions/` with default agents and config |
128
- | `minions update` | Update to latest version (npm update + apply) |
129
- | `minions version` | Show installed vs package version |
130
- | `minions doctor` | Check prerequisites and runtime health |
131
- | `minions scan [dir] [depth]` | Scan for git repos and multi-select to add (default: ~, depth 3) |
132
- | `minions add <dir>` | Link a single project (auto-detects settings from git, prompts to confirm) |
133
- | `minions remove <dir-or-name> [--keep-data \| --purge --force]` | Unlink a project: cancels pending work items, drains dispatch + kills active agents, cleans worktrees, disables linked schedules, archives `projects/<name>/` to `projects/.archived/<name>-YYYYMMDD/`. Use `--keep-data` to leave the data dir in place, or `--purge --force` to delete it. |
134
- | `minions list` | List all linked projects with descriptions |
135
- | `minions restart` | Start engine and dashboard together (recommended after reboot) |
136
- | `minions start` | Start engine daemon (ticks every 60s, auto-syncs MCP servers) |
137
- | `minions stop` | Stop the engine |
138
- | `minions status` | Show agents, projects, dispatch queue, quality metrics |
139
- | `minions pause` / `resume` | Pause/resume dispatching |
140
- | `minions dispatch` | Force a dispatch cycle |
141
- | `minions discover` | Dry-run work discovery |
142
- | `minions queue` | Show dispatch queue (pending, active, completed) |
143
- | `minions sources` | Show work source status per project |
144
- | `minions work <title> [opts]` | Add to central work queue |
145
- | `minions spawn <agent> <prompt>` | Manually spawn an agent |
146
- | `minions plan <file\|text> [proj]` | Run a plan |
147
- | `minions kill` | Kill all active agents and reset their dispatches to pending |
148
- | `minions complete <dispatch-id>` | Manually mark a dispatch as completed |
149
- | `minions config set-cli <R> [--model M]` | Persist the default runtime/model without starting the engine |
150
- | `minions mcp-sync` | Sync MCP servers from `~/.claude.json` |
151
- | `minions cleanup` | Run cleanup manually (temp files, worktrees, zombies) |
152
- | `minions dash` | Open dashboard (starts if not already running, port 7331) |
153
- | `minions nuke --confirm` | Factory reset runtime state and reset config to defaults |
154
- | `minions uninstall --confirm` | Remove Minions state and uninstall the npm package |
155
-
156
- You can also run scripts directly: `node ~/.minions/engine.js start`, `node ~/.minions/dashboard.js`, etc.
157
-
158
162
  ## Architecture
159
163
 
160
164
  ```
@@ -214,7 +218,7 @@ You can also run scripts directly: `node ~/.minions/engine.js start`, `node ~/.m
214
218
 
215
219
  - **Auto-discovers work** from plans (`plans/*.json`), pull requests, and work queues across all linked projects
216
220
  - **Plan pipeline** — `/plan` spawns a plan agent, chains to plan-to-prd, produces `plans/{project}-{date}.json` with `status: "awaiting-approval"`. Supports shared-branch and parallel strategies.
217
- - **Human approval gate** — plans require approval before materializing as work items. Dashboard provides Approve / Discuss & Revise / Reject. Discussion launches an interactive Claude Code session.
221
+ - **Human approval gate** — plans require approval before materializing as work items. Dashboard provides Approve / Discuss & Revise / Reject. Discussion launches an interactive Command Center session via the configured runtime CLI (`config.engine.ccCli`).
218
222
  - **Dispatches AI agents** (Claude CLI) with full project context, git worktrees, and MCP server access
219
223
  - **Routes intelligently** — fixes first, then reviews, then implementation, matched to agent strengths
220
224
  - **LLM-powered consolidation** — Claude Haiku summarizes notes (threshold: 5 files). Regex fallback. Source references required.
@@ -649,34 +653,43 @@ To move to a new machine: `npm install -g @yemi33/minions && minions init --forc
649
653
  minions.js <- Unified CLI entry point (npm package)
650
654
  minions.js <- Project management: init, add, remove, list
651
655
  engine.js <- Engine daemon + orchestrator
652
- engine/
653
- shared.js <- Shared utilities: IO, process spawning, config helpers
654
- queries.js <- Read-only state queries (used by engine + dashboard)
655
- cli.js <- CLI command handlers (start, stop, status, plan, etc.)
656
- lifecycle.js <- Post-completion hooks, plan chaining, PR sync, metrics
657
- consolidation.js <- Haiku-powered inbox consolidation, knowledge base
658
- ado.js <- ADO token management, PR polling, PR reconciliation
659
- llm.js <- callLLM() with session resume, trackEngineUsage()
660
- spawn-agent.js <- Agent spawn wrapper (resolves claude cli.js)
661
- preflight.js <- Prerequisite checks (Node, Git, Claude CLI, API key)
662
- scheduler.js <- Cron-style scheduled task discovery
663
- pipeline.js <- Multi-stage pipeline orchestration
664
- meeting.js <- Meeting creation, rounds, conclusion
665
- cleanup.js <- Worktree + temp file cleanup
666
- timeout.js <- Agent timeout and orphan detection
667
- cooldown.js <- Dispatch cooldown with exponential backoff
668
- github.js <- GitHub PR polling, comment polling, reconciliation
669
- routing.js <- Agent routing and temp agent management
670
- dispatch.js <- Dispatch queue mutations (add, complete, retry)
671
- ado-mcp-wrapper.js <- ADO MCP authentication wrapper
672
- check-status.js <- Quick status check without full engine load
673
- control.json <- running/paused/stopped (runtime, generated)
674
- dispatch.json <- pending/active/completed queue (runtime, generated)
675
- log.json <- Audit trail, capped at 2500 (runtime, generated)
676
- metrics.json <- Per-agent quality metrics (runtime, generated)
677
- cooldowns.json <- Dispatch cooldown tracking (runtime, generated)
678
- schedule-runs.json <- Last-run timestamps for scheduled tasks (runtime, generated)
679
- pipeline-runs.json <- Pipeline run history per pipeline (runtime, generated)
656
+ engine/ <- See CLAUDE.md "Key Modules" table for per-file roles
657
+ # Core orchestration
658
+ shared.js queries.js cli.js
659
+ lifecycle.js dispatch.js cooldown.js
660
+ timeout.js steering.js recovery.js
661
+ pre-dispatch-eval.js
662
+ # Discovery, routing, playbooks
663
+ routing.js playbook.js cleanup.js
664
+ # Knowledge / consolidation
665
+ consolidation.js kb-sweep.js
666
+ # LLM + runtime adapters
667
+ llm.js model-discovery.js spawn-agent.js
668
+ runtimes/ <- Per-runtime CLI adapters (claude, copilot, etc.)
669
+ # Lifecycle helpers
670
+ preflight.js restart-health.js scheduler.js
671
+ pipeline.js meeting.js
672
+ # Project + feature management
673
+ projects.js project-discovery.js features.js
674
+ watches.js watch-actions.js
675
+ # Repo-host integrations
676
+ github.js issues.js
677
+ ado.js ado-token.js ado-mcp-wrapper.js
678
+ ado-status.js check-status.js
679
+ # Notifications
680
+ teams.js teams-cards.js
681
+ # Runtime state (generated, gitignored)
682
+ control.json <- running/paused/stopped
683
+ dispatch.json <- pending/active/completed queue
684
+ log.json <- audit trail, capped at 2500
685
+ metrics.json <- per-agent quality + runtime metrics
686
+ cooldowns.json <- dispatch cooldown tracking
687
+ schedule-runs.json <- last-run timestamps for scheduled tasks
688
+ pipeline-runs.json <- pipeline run history per pipeline
689
+ watches.json <- persistent watch jobs
690
+ completions/ <- per-dispatch agent completion JSON reports
691
+ <runtime>-caps.json <- adapter capability cache (claude-caps.json, copilot-caps.json, …)
692
+ <runtime>-models.json <- adapter model catalog cache
680
693
  dashboard.js <- Web dashboard server
681
694
  dashboard/
682
695
  layout.html <- Page layout shell with sidebar navigation
@@ -730,6 +743,7 @@ To move to a new machine: `npm install -g @yemi33/minions && minions init --forc
730
743
  inbox/ <- Agent findings drop-box (generated)
731
744
  archive/ <- Processed inbox files (generated)
732
745
  docs/
746
+ README.md <- Docs index (grouped by audience)
733
747
  auto-discovery.md <- Auto-discovery pipeline docs
734
748
  self-improvement.md <- Self-improvement loop docs
735
749
  plan-lifecycle.md <- Full plan pipeline: plan → PRD → implement → verify
package/docs/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Minions Documentation Index
2
+
3
+ A navigable index of every Markdown file under `docs/`. Entries are grouped by audience.
4
+
5
+ ## User-facing
6
+
7
+ Hands-on stories and distribution guides for people running or evaluating Minions.
8
+
9
+ - [blog-first-successful-dispatch.md](blog-first-successful-dispatch.md) — Narrative walkthrough of the first end-to-end agent dispatch and the seven failed spawn attempts that preceded it.
10
+ - [distribution.md](distribution.md) — How Minions is published as the `@yemi33/minions` npm package and what the two-repo (origin / personal) sync strips.
11
+
12
+ ## Contributor-facing
13
+
14
+ Architecture, design proposals, and lifecycle references for people working on the engine, dashboard, or playbooks.
15
+
16
+ - [command-center.md](command-center.md) — Command Center (CC) chat panel: persistent Sonnet sessions, `--resume` semantics, system-prompt invalidation, and per-tab session storage.
17
+ - [copilot-cli-schema.md](copilot-cli-schema.md) — Behavior and schema reference for the GitHub Copilot CLI adapter (capability flags, stdin vs `-p`, model discovery, effort levels).
18
+ - [design-state-storage.md](design-state-storage.md) — Design proposal evaluating five database options for replacing Minions' file-based JSON state; recommends `node:sqlite` as the medium-term target.
19
+ - [plan-lifecycle.md](plan-lifecycle.md) — Full plan pipeline from `/plan` through PRD materialization, dispatch with dependency gating, verify task, and human archive.
20
+ - [pr-review-fix-loop.md](pr-review-fix-loop.md) — How the engine moves a PR from creation through review, fix dispatch, and re-review, including stale-status guards.
21
+ - [rfc-completion-json.md](rfc-completion-json.md) — RFC for replacing stdout regex-scraping with a structured `completion.json` control-plane protocol.
22
+ - [self-improvement.md](self-improvement.md) — The six self-improvement mechanisms (learnings inbox, per-agent history, review feedback, quality metrics, etc.) that form Minions' continuous feedback loop.
23
+
24
+ ## Operations
25
+
26
+ Operational runbooks for engine operators, fleet maintainers, and Teams integrators.
27
+
28
+ - [auto-discovery.md](auto-discovery.md) — Auto-discovery and execution pipeline: the per-tick orchestration loop and the four work-discovery sources.
29
+ - [engine-restart.md](engine-restart.md) — How agents survive an engine restart: state persistence, the 20-minute startup grace period, and orphan reattachment via PID files and `live-output.log`.
30
+ - [human-vs-automated.md](human-vs-automated.md) — Quick reference table of which features humans start, run, decide, and recover, and the two human approval gates.
31
+ - [teams-production.md](teams-production.md) — Three deployment options (Azure App Service, Container Apps, self-hosted VM) for migrating the Teams bot from a Dev Tunnel to a stable HTTPS endpoint.
32
+ - [teams-setup.md](teams-setup.md) — End-to-end guide for connecting Minions to Microsoft Teams via Azure Bot Framework and a Dev Tunnel.
33
+
34
+ ---
35
+
36
+ **Adding a new doc?** Drop the file in `docs/` and add a one-line entry above under the right audience group. Keep entries alphabetical within each group.
@@ -0,0 +1,97 @@
1
+ # Distribution & Publishing
2
+
3
+ > **ARCHIVED 2026-05-12.** This document describes a defunct two-repo "personal vs. origin" architecture (`yemishin_microsoft/minions` → `yemi33/minions`) and a manual `/sync-to-personal` workflow that no longer exists. The current model is single-repo: `yemi33/minions` publishes itself to npm via `.github/workflows/publish.yml` on every push to `master`. The doc also incorrectly claims package contents are gated by a `files` field in `package.json` — they are actually gated by `.npmignore`. Kept for historical reference; do not follow these steps.
4
+
5
+ Minions is distributed as an npm package (`@yemi33/minions`) from a sanitized copy of the main repo.
6
+
7
+ ## Two-Repo Architecture
8
+
9
+ | Repo | Purpose | What's included |
10
+ |------|---------|----------------|
11
+ | **origin** (`yemishin_microsoft/minions`) | Full working repo with all session state | Everything — history, notes, decisions, work items, CLAUDE.md |
12
+ | **personal** (`yemi33/minions`) | Clean distribution for others | Engine, dashboard, playbooks, charters, skills, docs, npm package files |
13
+
14
+ ## What Gets Stripped
15
+
16
+ These files are removed during sync to personal:
17
+
18
+ | Category | Pattern | Reason |
19
+ |----------|---------|--------|
20
+ | Agent history | `agents/*/history.md` | Session-specific task logs |
21
+ | Notes archive | `notes/archive/*` | Historical agent findings |
22
+ | Notes inbox | `notes/inbox/*` | Pending agent findings |
23
+ | Notes summary | `notes.md` | Consolidated knowledge (runtime) |
24
+ | Work items | `work-items.json` | Runtime dispatch tracking |
25
+ | Project instructions | `CLAUDE.md` | Org-specific context |
26
+
27
+ ## npm Package
28
+
29
+ **Package:** `@yemi33/minions`
30
+ **Registry:** https://www.npmjs.com/package/@yemi33/minions
31
+
32
+ ### What's in the package
33
+
34
+ Controlled by the `files` field in `package.json`:
35
+ - `bin/minions.js` — CLI entry point
36
+ - `engine.js`, `dashboard.js`, `dashboard/` (fragments), `minions.js` — core scripts
37
+ - `engine/spawn-agent.js`, `engine/ado-mcp-wrapper.js` — engine helpers
38
+ - `agents/*/charter.md` — agent role definitions
39
+ - `playbooks/*.md` — task templates
40
+ - `config.template.json` — starter config
41
+ - `routing.md`, `team.md` — editable team config
42
+ - `skills/`, `docs/` — documentation and workflows
43
+
44
+ ### How `minions init` works
45
+
46
+ 1. Copies all package files from `node_modules/@yemi33/minions/` to `~/.minions/`
47
+ 2. Creates `config.json` from `config.template.json` if it doesn't exist
48
+ 3. Creates runtime directories (`engine/`, `notes/inbox/`, `notes/archive/`, etc.)
49
+ 4. Runs `minions.js init` to populate config with default agents
50
+ 5. On `--force`, overwrites `.js` and `.html` files but preserves user-modified `.md` files
51
+
52
+ ### How updates work
53
+
54
+ - Users run `npm update -g @yemi33/minions` then `minions init --force` to update engine code
55
+ - `npx @yemi33/minions` always fetches the latest version
56
+
57
+ ## Auto-Publishing
58
+
59
+ A GitHub Action on the personal repo auto-publishes to npm on every push to master.
60
+
61
+ ### How it works
62
+
63
+ 1. Push to `yemi33/minions` master triggers `.github/workflows/publish.yml`
64
+ 2. Action queries npm for the current published version
65
+ 3. Bumps patch version (e.g., `0.1.5` → `0.1.6`)
66
+ 4. Publishes to npm with the new version
67
+ 5. Commits the version bump back to the repo with `[skip ci]` to prevent loops
68
+
69
+ ### Why version comes from npm, not the repo
70
+
71
+ The sync-to-personal workflow force-pushes, which overwrites any version bump commits from previous action runs. So the action reads the latest version from the npm registry and bumps from there.
72
+
73
+ ### Setup requirements
74
+
75
+ - `NPM_TOKEN` secret on `yemi33/minions` — a granular access token with publish permissions and 2FA bypass enabled
76
+ - The workflow file (`.github/workflows/publish.yml`) is gitignored on the org repo and force-added during sync
77
+
78
+ ## Sync Workflow
79
+
80
+ Run `/sync-to-personal` or manually:
81
+
82
+ ```bash
83
+ # 1. Create dist branch, strip files, add workflow, force-push
84
+ git checkout -b dist-clean
85
+ git rm --cached agents/*/history.md notes.md work-items.json CLAUDE.md
86
+ git rm -r --cached notes/archive/ notes/inbox/ notes/
87
+ # ... add .gitkeep files, .gitignore entries, workflow file
88
+ git add -f .github/workflows/publish.yml
89
+ git commit -m "Strip for distribution"
90
+ git push personal dist-clean:master --force
91
+
92
+ # 2. Return to master
93
+ git checkout master
94
+ git branch -D dist-clean
95
+ ```
96
+
97
+
@@ -1,5 +1,7 @@
1
1
  # Auto-Discovery & Execution Pipeline
2
2
 
3
+ > Last verified: 2026-05-12 against `engine.js` `tickInner()` (lines 4439-4750).
4
+
3
5
  How the minions engine finds work and dispatches agents automatically.
4
6
 
5
7
  ## The Tick Loop
@@ -8,16 +10,27 @@ The engine runs a tick every 60 seconds (configurable via `config.json` → `eng
8
10
 
9
11
  ```
10
12
  tick()
11
- 1. checkTimeouts() Enforce runtime limits and stale-orphan cleanup
12
- 2. consolidateInbox() Merge learnings into notes.md (Haiku-powered)
13
- 2.5 runCleanup() Periodic cleanup (every 10 ticks ≈ 10min)
14
- 2.6 pollPrStatus() Poll ADO + GitHub for build, review, merge status (wall-clock cadence from prPollStatusEvery × tickInterval, default ≈ 12min)
15
- 2.7 pollPrHumanComments() Poll PR threads for human @minions comments (wall-clock cadence from prPollCommentsEvery × tickInterval, default ≈ 12min)
16
- 3. discoverWork() Scan ALL linked projects for new tasks
17
- 4. updateSnapshot() Write identity/now.md
18
- 5. dispatch Spawn agents for pending items (up to maxConcurrent)
13
+ 1. checkTimeouts() Enforce runtime limits and stale-orphan cleanup
14
+ 1a. checkSteering() Drain steering messages queued by the dashboard
15
+ 1b. checkIdleThreshold() Notify on excessive agent idleness
16
+ 1c. meetingTimeouts() Advance round-based meetings whose timer fired
17
+ 2. consolidateInbox() Merge learnings into notes.md (Haiku-powered)
18
+ 2.5 runCleanup() Periodic cleanup (every 10 ticks 10min)
19
+ 2.55 checkWatches() Persistent watch jobs (every 3 tick-equivalents)
20
+ 2.6 pollPrStatus() Poll ADO + GitHub for build, review, merge status (wall-clock cadence from prPollStatusEvery × tickInterval, default ≈ 12min)
21
+ processPendingRebases() Run any rebase work queued from the previous tick
22
+ syncPrdFromPrs() Backfill PRD item status from active PRs
23
+ checkPlanCompletion() Mark plans completed when all features done/in-pr
24
+ 2.7 pollPrHumanComments() Poll PR threads for human @minions comments (wall-clock cadence from prPollCommentsEvery × tickInterval, default ≈ 12min)
25
+ reconcilePrs() (ADO+GH) Reconciliation sweep (runs regardless of poll flags)
26
+ 2.9 stallRecovery() Auto-retry failed items blocking pending deps (every 20 ticks)
27
+ 3. discoverWork() Scan ALL linked projects for new tasks
28
+ 4. updateSnapshot() Write identity/now.md
29
+ 5. dispatch Spawn agents for pending items (up to maxConcurrent)
19
30
  ```
20
31
 
32
+ > When `control.state === 'stopping'`, only steps 1–1c run; discovery and dispatch are skipped while live agents drain.
33
+
21
34
  ## Work Discovery
22
35
 
23
36
  `discoverWork()` iterates every project in `config.projects[]` and runs four core discovery sources: pull requests, per-project work items, central work items, and pipeline/scheduled tasks. Results are prioritized: fixes > reviews > implements > work-items.
@@ -0,0 +1,215 @@
1
+ # Completion Reports
2
+
3
+ Every Minions agent ends its dispatch by writing a JSON completion report. The report is the engine's primary, machine-readable signal that the work item is finished and is the source of truth for status, retry decisions, dashboard surfaces, and downstream automation. Fenced ` ```completion ` blocks in stdout are still parsed as a compatibility fallback, but the JSON file always wins when both exist.
4
+
5
+ This document is the canonical schema. Playbooks should cross-link here instead of restating the field list.
6
+
7
+ ## Where the report is written
8
+
9
+ The engine injects the absolute path two ways before spawning each agent:
10
+
11
+ - `MINIONS_COMPLETION_REPORT` environment variable
12
+ - The same path appears in the rendered playbook prompt
13
+
14
+ Path shape (resolved by `shared.dispatchCompletionReportPath()` in `engine/shared.js`):
15
+
16
+ ```
17
+ <MINIONS_DIR>/engine/completions/<dispatch-id>.json
18
+ ```
19
+
20
+ The agent must write the JSON to that exact path before exiting. Any character outside `[a-zA-Z0-9._-]` in the dispatch id is replaced with `-` by the engine when computing the path.
21
+
22
+ ## Top-level schema
23
+
24
+ ```json
25
+ {
26
+ "status": "success",
27
+ "summary": "what changed and how it was validated",
28
+ "verdict": null,
29
+ "pr": "PR id/url or N/A",
30
+ "failure_class": "N/A",
31
+ "retryable": false,
32
+ "needs_rerun": false,
33
+ "noop": false,
34
+ "artifacts": [
35
+ {"type": "pr", "path": "https://github.com/owner/repo/pull/123", "title": "PR-123"}
36
+ ]
37
+ }
38
+ ```
39
+
40
+ ### Required fields
41
+
42
+ | Field | Type | Notes |
43
+ |---|---|---|
44
+ | `status` | string | One of `success`, `partial`, `failed`. Aliases `done` / `complete` are accepted on read for `success`. The engine refuses to mark a work item done without a status. |
45
+ | `summary` | string | Short prose describing what changed and how it was validated. Truncated to 500 chars in dashboard surfaces (`engine/queries.js`). Do not summarize validation as "tests passed" — name the commands that ran. |
46
+ | `verdict` | string \| null | Required for review tasks: `approved` or `changes-requested`. `null` for non-review tasks. Aliases: `approve`, `request_changes`, `changes_requested`. |
47
+ | `pr` | string | PR URL, `PR-<number>`, or `N/A`. The engine uses this to attach the PR to the work item; missing-PR detection treats anything other than a recognizable URL/PR id as missing unless `noop: true` is set. |
48
+ | `failure_class` | string | One of the `failure_class` enum values below, or `N/A`. Drives retry policy in `engine/dispatch.js` and recovery routing in `engine/recovery.js`. |
49
+ | `retryable` | boolean | `true` if the engine should auto-retry the dispatch on failure. Overrides the default per-class retry policy when present. |
50
+ | `needs_rerun` | boolean | `true` if the same work needs to be re-dispatched (vs. retried). Used by build-fix and review-fix loops. |
51
+ | `artifacts` | array | Durable artifacts the agent created or updated; surfaces in the dashboard work-item detail modal. See [Artifacts](#artifacts). |
52
+
53
+ ### Optional fields
54
+
55
+ | Field | Type | Notes |
56
+ |---|---|---|
57
+ | `noop` | boolean | Canonical no-op signal. See [No-op semantics](#no-op-semantics). |
58
+ | `noopReason` | string | Human-readable rationale shown when `noop: true`. Falls back to `summary` if absent. |
59
+ | `files_changed` | string \| array | Comma-separated list (or array) of key files changed. |
60
+ | `tests` | string | `pass`, `fail`, `skipped`, `N/A`, or a free-form note like `skipped — relying on PR pipeline`. |
61
+ | `pending` | string | Any remaining work, or `none`. |
62
+
63
+ ## `failure_class` enum
64
+
65
+ Defined in `engine/shared.js` as `FAILURE_CLASS`. Use the canonical hyphenated string.
66
+
67
+ | Value | When to use | Default escalation |
68
+ |---|---|---|
69
+ | `config-error` | CLI not found, exit code 78, malformed config | Never retry |
70
+ | `permission-blocked` | Trust gate, permission denied, auth failure | Never retry |
71
+ | `merge-conflict` | Git merge conflict in worktree or dependency | Retry same agent |
72
+ | `build-failure` | Compilation, lint, or test failure introduced by the agent | Retry same agent |
73
+ | `timeout` | Hard runtime timeout or stale-orphan timeout | Retry with fresh session |
74
+ | `empty-output` | Agent produced no meaningful output | Flag for human review |
75
+ | `spawn-error` | Process failed to start or crashed immediately | Retry with fresh session |
76
+ | `network-error` | API rate limit, DNS, connectivity | Default retry logic |
77
+ | `out-of-context` | Context window exhausted | Flag for human review |
78
+ | `max-turns` | Claude CLI `error_max_turns` — work in progress | Retry same agent |
79
+ | `unknown` | Unclassified failure | Default retry logic |
80
+
81
+ Use `"N/A"` when `status` is `success` or `partial` without a failure.
82
+
83
+ ## No-op semantics
84
+
85
+ A no-op completion declares that the agent correctly **declined** to do the work — the change was already shipped on master, the dispatch premise was wrong, the flagged review comment was an author-note, etc.
86
+
87
+ To signal a no-op:
88
+
89
+ ```json
90
+ {
91
+ "status": "success",
92
+ "summary": "PR #2372 Linux CI fix already shipped by parallel agent — nothing to do",
93
+ "pr": "N/A",
94
+ "noop": true,
95
+ "noopReason": "Fix already on master at commit abc1234"
96
+ }
97
+ ```
98
+
99
+ Engine behavior when `noop: true` (`engine/lifecycle.js` `parseCompletionNoop` + `runPostCompletionHooks`):
100
+
101
+ - The work item is marked `done` with the rationale stored as `_noopReason` (visible in the dashboard).
102
+ - The PR-attachment contract is **skipped**, so an empty `pr` field will not be flagged as a silent failure or auto-retried.
103
+ - Any non-success `status` combined with `noop: true` is treated as a contradiction and falls through to the normal contract.
104
+
105
+ Without `noop: true`, an empty PR field will be flagged as a missing-PR-attachment failure and auto-retried up to `ENGINE_DEFAULTS.maxRetries` times.
106
+
107
+ ## `retryable` and `needs_rerun`
108
+
109
+ Both default to `false`. Together they let the agent override the engine's default retry policy:
110
+
111
+ - `retryable: true` — engine should treat the failure as transient and re-dispatch (subject to `maxRetries` and the per-class escalation policy).
112
+ - `retryable: false` — engine should not auto-retry; the failure is terminal for this dispatch.
113
+ - `needs_rerun: true` — even on `status: success`, the same work item should be re-dispatched (used by review-fix and build-fix loops where one pass cannot complete the work).
114
+
115
+ When the agent sets either field, it overrides the per-`failure_class` default in `isRetryableFailureReason()` (`engine/dispatch.js`).
116
+
117
+ ## Artifacts
118
+
119
+ `artifacts` is an array of objects with this shape:
120
+
121
+ ```json
122
+ {"type": "pr", "path": "https://github.com/owner/repo/pull/123", "title": "PR-123: Stale HEAD guard"}
123
+ ```
124
+
125
+ | Field | Type | Notes |
126
+ |---|---|---|
127
+ | `type` | string | One of `note`, `plan`, `prd`, `pr`, `file`. |
128
+ | `path` | string | Relative repo path, absolute path, or URL. |
129
+ | `title` | string | Short label used in the dashboard list. |
130
+
131
+ The dashboard caps the rendered list at 20 artifacts per report (`engine/queries.js`). Include every durable artifact you created or updated — PRs, plan/PRD files, key source files, inbox notes — so the work-item detail modal can show them.
132
+
133
+ ## Validation and source-of-truth precedence
134
+
135
+ The engine reads completion signals in this order (`engine/lifecycle.js`):
136
+
137
+ 1. The JSON report at `MINIONS_COMPLETION_REPORT` — primary.
138
+ 2. A fenced ` ```completion ` block in the agent's stdout — fallback only.
139
+ 3. Process exit code and stdout heuristics — last-resort recovery.
140
+
141
+ If the JSON report exists and is well-formed, the engine ignores the fenced block. If the JSON is missing or malformed (logged as a warning), the engine falls back to the fenced block, then to stdout parsing.
142
+
143
+ ## Examples
144
+
145
+ ### Successful implement
146
+
147
+ ```json
148
+ {
149
+ "status": "success",
150
+ "summary": "Added stale-HEAD guard to push step in spawn-agent.js; verified with new unit test test/unit/spawn-agent.test.js (4632 passed, 0 failed)",
151
+ "verdict": null,
152
+ "pr": "https://github.com/yemi33/minions/pull/2360",
153
+ "failure_class": "N/A",
154
+ "retryable": false,
155
+ "needs_rerun": false,
156
+ "artifacts": [
157
+ {"type": "pr", "path": "https://github.com/yemi33/minions/pull/2360", "title": "PR-2360"},
158
+ {"type": "file", "path": "engine/spawn-agent.js", "title": "Stale-HEAD guard"},
159
+ {"type": "file", "path": "test/unit/spawn-agent.test.js", "title": "New unit test"}
160
+ ]
161
+ }
162
+ ```
163
+
164
+ ### Successful review
165
+
166
+ ```json
167
+ {
168
+ "status": "success",
169
+ "summary": "Verified completeRun sweep is inside mutateJsonFileLocked callback and pre-existing terminal stages are preserved.",
170
+ "verdict": "approved",
171
+ "pr": "https://github.com/yemi33/minions/pull/2313",
172
+ "failure_class": "N/A",
173
+ "retryable": false,
174
+ "needs_rerun": false,
175
+ "artifacts": [
176
+ {"type": "pr", "path": "https://github.com/yemi33/minions/pull/2313", "title": "PR-2313"}
177
+ ]
178
+ }
179
+ ```
180
+
181
+ ### Failed build
182
+
183
+ ```json
184
+ {
185
+ "status": "failed",
186
+ "summary": "test/unit.test.js — c-c-multi-tab.test.js:409 fails on stale _joinCcPromptParts 4-arg signature; needs master rebase.",
187
+ "verdict": null,
188
+ "pr": "N/A",
189
+ "failure_class": "build-failure",
190
+ "retryable": true,
191
+ "needs_rerun": false,
192
+ "artifacts": []
193
+ }
194
+ ```
195
+
196
+ ### No-op
197
+
198
+ ```json
199
+ {
200
+ "status": "success",
201
+ "summary": "Fix already shipped on master at commit eb2e7230 by parallel agent.",
202
+ "pr": "N/A",
203
+ "noop": true,
204
+ "noopReason": "Linux CI fix already on master before this dispatch started"
205
+ }
206
+ ```
207
+
208
+ ## Related
209
+
210
+ - `engine/shared.js` — `FAILURE_CLASS`, `COMPLETION_FIELDS`, `dispatchCompletionReportPath()`
211
+ - `engine/lifecycle.js` — `parseCompletionReportFile()`, `parseCompletionNoop()`, `enforcePrAttachmentContract()`
212
+ - `engine/dispatch.js` — `isRetryableFailureReason()`, `writeFailedAgentReport()`
213
+ - `engine/recovery.js` — per-`failure_class` recovery recipes
214
+ - `docs/rfc-completion-json.md` — original RFC describing the protocol's design
215
+ - `playbooks/shared-rules.md` — the per-task "Completion Reports" instruction every playbook inherits
@@ -1,17 +1,17 @@
1
1
  # Distribution & Publishing
2
2
 
3
- Minions is distributed as an npm package (`@yemi33/minions`) from a sanitized copy of the main repo.
3
+ Minions is distributed as an npm package (`@yemi33/minions`) from a sanitized package boundary.
4
4
 
5
- ## Two-Repo Architecture
5
+ ## Distribution Boundary
6
6
 
7
- | Repo | Purpose | What's included |
7
+ | Surface | Purpose | What's included |
8
8
  |------|---------|----------------|
9
- | **origin** (`yemishin_microsoft/minions`) | Full working repo with all session state | Everything — history, notes, decisions, work items, CLAUDE.md |
10
- | **personal** (`yemi33/minions`) | Clean distribution for others | Engine, dashboard, playbooks, charters, skills, docs, npm package files |
9
+ | **source repository** | Private development and automation | Working code, project history, and release workflows |
10
+ | **npm package** (`@yemi33/minions`) | Public installation for users | Engine, dashboard, playbooks, charters, skills, docs, and package files |
11
11
 
12
12
  ## What Gets Stripped
13
13
 
14
- These files are removed during sync to personal:
14
+ These files are excluded from published packages:
15
15
 
16
16
  | Category | Pattern | Reason |
17
17
  |----------|---------|--------|
@@ -71,25 +71,9 @@ The sync-to-personal workflow force-pushes, which overwrites any version bump co
71
71
  ### Setup requirements
72
72
 
73
73
  - `NPM_TOKEN` secret on `yemi33/minions` — a granular access token with publish permissions and 2FA bypass enabled
74
- - The workflow file (`.github/workflows/publish.yml`) is gitignored on the org repo and force-added during sync
74
+ - The workflow file (`.github/workflows/publish.yml`) is not included in the npm package
75
75
 
76
76
  ## Sync Workflow
77
77
 
78
- Run `/sync-to-personal` or manually:
79
-
80
- ```bash
81
- # 1. Create dist branch, strip files, add workflow, force-push
82
- git checkout -b dist-clean
83
- git rm --cached agents/*/history.md notes.md work-items.json CLAUDE.md
84
- git rm -r --cached notes/archive/ notes/inbox/ notes/
85
- # ... add .gitkeep files, .gitignore entries, workflow file
86
- git add -f .github/workflows/publish.yml
87
- git commit -m "Strip for distribution"
88
- git push personal dist-clean:master --force
89
-
90
- # 2. Return to master
91
- git checkout master
92
- git branch -D dist-clean
93
- ```
94
-
78
+ Repository and package publishing automation should keep private repository names, tokens, runtime state, and internal-only metadata out of public docs and public package contents.
95
79
 
@@ -1,5 +1,7 @@
1
1
  # Engine Restart & Agent Survival
2
2
 
3
+ > Last verified: 2026-05-12 against `engine.js` (`engineRestartGraceUntil`, line 161) and `engine/shared.js` `ENGINE_DEFAULTS` (`restartGracePeriod: 1200000`, `heartbeatTimeout: 300000`, `agentTimeout: 18000000`).
4
+
3
5
  ## The Problem
4
6
 
5
7
  When the engine restarts, it loses its in-memory process handles (`activeProcesses` Map). Claude CLI agents spawned before the restart may still be running as OS processes, but the engine can't monitor their process state, detect exit codes, or manage their lifecycle. Stale-orphan detection keeps these dispatch records from staying active forever after the restart grace period expires.