@yemi33/minions 0.1.1

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.
Files changed (54) hide show
  1. package/CHANGELOG.md +819 -0
  2. package/LICENSE +21 -0
  3. package/README.md +598 -0
  4. package/agents/dallas/charter.md +56 -0
  5. package/agents/lambert/charter.md +67 -0
  6. package/agents/ralph/charter.md +45 -0
  7. package/agents/rebecca/charter.md +57 -0
  8. package/agents/ripley/charter.md +47 -0
  9. package/bin/minions.js +467 -0
  10. package/config.template.json +28 -0
  11. package/dashboard.html +4822 -0
  12. package/dashboard.js +2623 -0
  13. package/docs/auto-discovery.md +416 -0
  14. package/docs/blog-first-successful-dispatch.md +128 -0
  15. package/docs/command-center.md +156 -0
  16. package/docs/demo/01-dashboard-overview.gif +0 -0
  17. package/docs/demo/02-command-center.gif +0 -0
  18. package/docs/demo/03-work-items.gif +0 -0
  19. package/docs/demo/04-plan-docchat.gif +0 -0
  20. package/docs/demo/05-prd-progress.gif +0 -0
  21. package/docs/demo/06-inbox-metrics.gif +0 -0
  22. package/docs/deprecated.json +83 -0
  23. package/docs/distribution.md +96 -0
  24. package/docs/engine-restart.md +92 -0
  25. package/docs/human-vs-automated.md +108 -0
  26. package/docs/index.html +221 -0
  27. package/docs/plan-lifecycle.md +140 -0
  28. package/docs/self-improvement.md +344 -0
  29. package/engine/ado-mcp-wrapper.js +42 -0
  30. package/engine/ado.js +383 -0
  31. package/engine/check-status.js +23 -0
  32. package/engine/cli.js +754 -0
  33. package/engine/consolidation.js +417 -0
  34. package/engine/github.js +331 -0
  35. package/engine/lifecycle.js +1113 -0
  36. package/engine/llm.js +116 -0
  37. package/engine/queries.js +677 -0
  38. package/engine/shared.js +397 -0
  39. package/engine/spawn-agent.js +151 -0
  40. package/engine.js +3227 -0
  41. package/minions.js +556 -0
  42. package/package.json +48 -0
  43. package/playbooks/ask.md +49 -0
  44. package/playbooks/build-and-test.md +155 -0
  45. package/playbooks/explore.md +64 -0
  46. package/playbooks/fix.md +57 -0
  47. package/playbooks/implement-shared.md +68 -0
  48. package/playbooks/implement.md +95 -0
  49. package/playbooks/plan-to-prd.md +104 -0
  50. package/playbooks/plan.md +99 -0
  51. package/playbooks/review.md +68 -0
  52. package/playbooks/test.md +75 -0
  53. package/playbooks/verify.md +190 -0
  54. package/playbooks/work-item.md +74 -0
@@ -0,0 +1,344 @@
1
+ # Self-Improvement Loop
2
+
3
+ How the minions learns from its own work and gets better over time.
4
+
5
+ ## Overview
6
+
7
+ The minions has six self-improvement mechanisms that form a continuous feedback loop:
8
+
9
+ ```
10
+ Agent completes task
11
+
12
+ ├─ 1. Learnings Inbox → notes.md (all future agents see it)
13
+ ├─ 2. Per-Agent History → history.md (agent sees its own past)
14
+ ├─ 3. Review Feedback Loop → author gets reviewer's findings
15
+ └─ 4. Quality Metrics → engine/metrics.json (tracks performance)
16
+ ```
17
+
18
+ ## 1. Learnings Inbox → notes.md
19
+
20
+ **The core loop.** Every playbook instructs agents to write findings to `notes/inbox/`. The engine consolidates these into `notes.md`, which is injected into every future playbook prompt.
21
+
22
+ ### Flow
23
+
24
+ ```
25
+ Agent finishes task
26
+ → writes notes/inbox/<agent>-<date>.md
27
+ → engine checks inbox on next tick (~60s)
28
+ → consolidateInbox() fires (threshold: 5 files)
29
+ → spawns Claude Haiku for LLM-powered summarization
30
+ → Haiku reads all inbox notes + existing notes.md
31
+ → produces deduplicated, categorized digest
32
+ → digest appended to notes.md
33
+ → originals moved to notes/archive/
34
+ → notes.md injected into every future agent prompt
35
+ ```
36
+
37
+ ### LLM-Powered Consolidation (Primary)
38
+
39
+ The engine spawns Claude Haiku to read all inbox notes and produce a smart digest. Haiku is chosen for speed (~10s) and low cost while being capable enough for summarization.
40
+
41
+ **What Haiku does:**
42
+ - Reads full content of every inbox note (up to 8KB each)
43
+ - Cross-references against existing notes.md to avoid repeating known knowledge
44
+ - Extracts only actionable insights: patterns, conventions, gotchas, build results, architectural decisions
45
+ - Deduplicates — if multiple agents report the same finding, merges into one entry
46
+ - Groups by category: Patterns & Conventions, Build & Test Results, PR Review Findings, Bugs & Gotchas, Architecture Notes, Action Items
47
+ - Attributes each insight to the source agent(s)
48
+ - Writes a descriptive title summarizing what was learned
49
+
50
+ **Example output:**
51
+ ```markdown
52
+ ### 2026-03-13: PR-4964594 Build & Lint Analysis
53
+ **By:** Engine (LLM-consolidated)
54
+
55
+ #### Build & Test Results
56
+ - **Build and tests passing** for progression UI feature _(rebecca)_
57
+
58
+ #### Bugs & Gotchas
59
+ - **Barrel file violation**: index.ts under src/features/progression/ violates no-barrel-files rule — use concrete paths _(rebecca)_
60
+ - **11 lint errors**: unnecessary conditionals and missing curly braces in progressionAtoms.ts and ProgressionCard.tsx _(rebecca)_
61
+
62
+ #### Patterns & Conventions
63
+ - **Jotai for local state**: appropriate for synchronous UI state in Bebop features _(rebecca)_
64
+
65
+ _Processed 1 note, 4 insights extracted, 1 duplicate removed._
66
+ ```
67
+
68
+ **Async execution:** The LLM call doesn't block the engine tick loop. A `_consolidationInFlight` flag prevents concurrent runs.
69
+
70
+ **Timeout:** 3 minutes max. If Haiku doesn't respond, the engine kills the process and falls back to regex.
71
+
72
+ ### Regex Fallback Consolidation
73
+
74
+ If the LLM call fails (timeout, error, malformed output), the engine falls back to pattern-matching extraction:
75
+
76
+ - **Numbered items**: `1. **Bold key**: explanation` — captured via regex
77
+ - **Bullet items**: `- **Bold key**: explanation` — captured via regex
78
+ - **Important lines**: standalone sentences containing must/never/always/convention/pattern/gotcha
79
+ - **Deduplication**: fingerprint-based (lowercased, stripped, 70% word overlap threshold)
80
+ - **Cross-reference**: checks against existing notes.md to skip known insights
81
+
82
+ Fallback entries are labeled `**By:** Engine (regex fallback)` so you can tell which method was used.
83
+
84
+ ### Auto-Pruning
85
+
86
+ When `notes.md` exceeds 50KB, the engine prunes old consolidation sections, keeping the header and last 8 consolidations. This prevents the file from growing unbounded while retaining recent institutional knowledge.
87
+
88
+ ## 2. Per-Agent History
89
+
90
+ Each agent maintains a `history.md` file that tracks its last 20 tasks. This is injected into the agent's system prompt so it knows what it did recently.
91
+
92
+ ### Flow
93
+
94
+ ```
95
+ Agent finishes task
96
+ → engine calls updateAgentHistory()
97
+ → prepends entry to agents/<name>/history.md
98
+ → trims to 20 entries
99
+ → next time agent spawns: history.md injected into system prompt
100
+ ```
101
+
102
+ ### What's tracked per entry
103
+
104
+ - Timestamp
105
+ - Task description
106
+ - Type (implement, review, fix, explore)
107
+ - Result (success/error)
108
+ - Project name
109
+ - Branch name
110
+ - Dispatch ID
111
+
112
+ ### Why it matters
113
+
114
+ Without history, an agent has no memory. It might:
115
+ - Re-explore code it already explored yesterday
116
+ - Repeat mistakes it made last session
117
+ - Not know that it already has a PR open for a similar feature
118
+
119
+ With history, the agent sees "I already implemented M005 yesterday (success)" and can build on that context.
120
+
121
+ ## 3. Review Feedback Loop
122
+
123
+ When a reviewer (e.g., Ripley) reviews a PR and writes findings, the engine automatically creates a feedback file for the PR author (e.g., Dallas) in the inbox.
124
+
125
+ ### Flow
126
+
127
+ ```
128
+ Ripley reviews Dallas's PR
129
+ → writes notes/inbox/ripley-review-pr123-2026-03-12.md
130
+ → engine detects review completion
131
+ → updatePrAfterReview() runs
132
+ → createReviewFeedbackForAuthor() runs
133
+ → creates notes/inbox/feedback-dallas-from-ripley-pr123-2026-03-12.md
134
+ → next consolidation: feedback appears in notes.md
135
+ → Dallas's next task: he sees what Ripley flagged
136
+ ```
137
+
138
+ ### What the feedback file contains
139
+
140
+ ```markdown
141
+ # Review Feedback for Dallas
142
+
143
+ **PR:** PR-123 — Add retry logic
144
+ **Reviewer:** Ripley
145
+ **Date:** 2026-03-12
146
+
147
+ ## What the reviewer found
148
+ <full content of Ripley's review>
149
+
150
+ ## Action Required
151
+ Read this feedback carefully. When you work on similar tasks
152
+ in the future, avoid the patterns flagged here.
153
+ ```
154
+
155
+ ### Why it matters
156
+
157
+ Without this, review findings only exist in the inbox file under the reviewer's name. The author never explicitly sees them unless they happen to read the consolidated notes.md. The feedback loop ensures the author gets a direct, targeted learning from every review.
158
+
159
+ ## 4. Human Feedback on PRs
160
+
161
+ Humans can leave comments on ADO PRs containing `@minions` to trigger fix tasks. The engine polls PR threads every ~6 minutes and dispatches fixes to the PR's author agent.
162
+
163
+ ### Flow
164
+
165
+ ```
166
+ Human comments on PR with "@minions fix the error handling here"
167
+ → pollPrHumanComments() detects new @minions comment
168
+ → sets pr.humanFeedback.pendingFix = true with comment text
169
+ → discoverFromPrs() sees pendingFix flag
170
+ → dispatches fix task to PR author agent
171
+ → author agent fixes and pushes
172
+ → PR goes back into normal review cycle
173
+ ```
174
+
175
+ ### How it works
176
+
177
+ - **Trigger:** If you're the only human commenter, **any** comment triggers a fix. If multiple humans are commenting, `@minions` keyword is required to avoid noise
178
+ - **Agent detection:** Comments matching `/\bMinions\s*\(/i` are skipped (agent signature pattern)
179
+ - **Dedup:** Only comments newer than `pr.humanFeedback.lastProcessedCommentDate` are processed
180
+ - **Multiple comments:** All new `@minions` comments are concatenated into a single fix task
181
+ - **After fix:** `pendingFix` is cleared; PR re-enters normal review cycle
182
+
183
+ ## 5. Quality Metrics
184
+
185
+ The engine tracks per-agent performance metrics in `engine/metrics.json`. Updated after every task completion and PR review.
186
+
187
+ ### Metrics tracked
188
+
189
+ | Metric | Updated when |
190
+ |--------|-------------|
191
+ | `tasksCompleted` | Agent exits with code 0 |
192
+ | `tasksErrored` | Agent exits with non-zero code |
193
+ | `prsCreated` | Agent completes an implement task |
194
+ | `prsApproved` | Reviewer approves the agent's PR |
195
+ | `prsRejected` | Reviewer requests changes on the agent's PR |
196
+ | `reviewsDone` | Agent completes a review task |
197
+ | `lastTask` | Every completion |
198
+ | `lastCompleted` | Every completion |
199
+
200
+ ### Where metrics are visible
201
+
202
+ - **CLI:** `node engine.js status` shows a metrics table
203
+ - **Dashboard:** "Agent Metrics" section with approval rates color-coded (green ≥70%, red <70%)
204
+
205
+ ### Sample output
206
+
207
+ ```
208
+ Metrics:
209
+ Agent Done Err PRs Approved Rejected Reviews
210
+ ----------------------------------------------------------
211
+ dallas 12 1 8 6 (75%) 2 0
212
+ ripley 0 0 0 0 (-) 0 10
213
+ ralph 5 0 4 3 (75%) 1 0
214
+ rebecca 3 0 2 2 (100%) 0 0
215
+ lambert 2 0 0 0 (-) 0 4
216
+ ```
217
+
218
+ ### Future use
219
+
220
+ Metrics are currently informational — displayed in status and dashboard. Planned uses:
221
+ - **Routing adaptation:** If an agent's approval rate drops below a threshold, deprioritize them for implementation tasks
222
+ - **Auto-escalation:** If an agent errors 3 times in a row, pause their dispatch and alert
223
+ - **Capacity planning:** Track throughput per agent to optimize `maxConcurrent`
224
+
225
+ ## How It All Connects
226
+
227
+ ```
228
+ ┌──────────────────────┐
229
+ │ notes.md │
230
+ │ (institutional │
231
+ │ knowledge) │
232
+ └──────┬───────────────┘
233
+ │ injected into every playbook
234
+
235
+ ┌──────────┐ ┌──────────────────┐ ┌──────────┐
236
+ │ history │──injects──│ Agent works │──writes──→│ inbox/ │
237
+ │ .md │ │ on task │ │ *.md │
238
+ │ (past │ └────────┬─────────┘ └────┬─────┘
239
+ │ tasks) │ │ │
240
+ └──────────┘ │ on completion │ consolidateInbox()
241
+ ▲ ▼ ▼
242
+ │ ┌──────────────────┐ ┌──────────┐
243
+ └─updateHistory───│ Engine │─prune──→│decisions │
244
+ │ post-hooks │ │ .md │
245
+ └────────┬─────────┘ └──────────┘
246
+
247
+ ┌───────────┼───────────┐
248
+ ▼ ▼ ▼
249
+ ┌──────────┐ ┌──────────┐ ┌──────────┐
250
+ │ metrics │ │ feedback │ │ history │
251
+ │ .json │ │ for │ │ .md │
252
+ │ │ │ author │ │ updated │
253
+ └──────────┘ └──────────┘ └──────────┘
254
+ ```
255
+
256
+ ## 6. Skills — Agent-Discovered Workflows
257
+
258
+ When an agent discovers a repeatable multi-step procedure, it can save it as a **skill** — a structured, reusable workflow compatible with Claude Code's skill system. Skills are stored in two locations:
259
+
260
+ - **Minions-wide:** `~/.minions/skills/<name>.md` — shared across all agents, no PR required
261
+ - **Project-specific:** `<project>/.claude/skills/<name>/SKILL.md` — scoped to one repo, requires a PR
262
+
263
+ ### Flow
264
+
265
+ ```
266
+ Agent discovers repeatable pattern during task
267
+ → writes skills/<name>.md with frontmatter (name, description, trigger, allowed-tools)
268
+ → engine detects new skill files on next tick
269
+ → builds skill index (name + trigger + file path)
270
+ → index injected into every agent's system prompt
271
+ → future agents see "Available Skills" and follow matching ones
272
+ → skills are also invocable via Claude Code's /skill-name command
273
+ ```
274
+
275
+ ### Skill Format
276
+
277
+ ```markdown
278
+ ---
279
+ name: fix-yarn-lock-conflict
280
+ description: Resolves yarn.lock merge conflicts by regenerating the lockfile
281
+ trigger: when merging branches that both modified yarn.lock
282
+ allowed-tools: Bash, Read, Write
283
+ author: dallas
284
+ created: 2026-03-12
285
+ project: any
286
+ ---
287
+
288
+ # Skill: Fix Yarn Lock Conflicts
289
+
290
+ ## When to Use
291
+ When a git merge or rebase produces conflicts in yarn.lock.
292
+
293
+ ## Steps
294
+ 1. Delete yarn.lock
295
+ 2. Run `yarn install` to regenerate
296
+ 3. Stage the new yarn.lock
297
+ 4. Continue the merge/rebase
298
+
299
+ ## Notes
300
+ - Never manually edit yarn.lock
301
+ - Always run `yarn build` after regenerating to verify
302
+ ```
303
+
304
+ ### How it differs from notes.md
305
+
306
+ | | notes.md | Skills |
307
+ |---|---|---|
308
+ | **Format** | Free-form prose, appended by engine | Structured with frontmatter, one file per workflow |
309
+ | **Granularity** | Rules, conventions, findings | Step-by-step procedures |
310
+ | **Authored by** | Engine (consolidation) | Agents directly |
311
+ | **Trigger** | Always injected (all context) | Agent matches trigger to current situation |
312
+ | **Lifespan** | Grows forever (pruned at 50KB) | Permanent, individually editable |
313
+ | **Claude Code** | Not directly invocable | Invocable via `/skill-name` |
314
+
315
+ ### When agents should create skills
316
+
317
+ - Multi-step procedures they had to figure out (build setup, deployment, migration)
318
+ - Error recovery patterns (how to fix a specific class of failure)
319
+ - Project-specific workflows that aren't documented elsewhere
320
+ - Cross-repo coordination steps
321
+
322
+ ## Configuration
323
+
324
+ | Setting | Default | What it controls |
325
+ |---------|---------|-----------------|
326
+ | `engine.inboxConsolidateThreshold` | 5 | Files needed before consolidation triggers |
327
+ | Consolidation model | Haiku | LLM used for summarization (fast, cheap) |
328
+ | LLM process kill timeout | 3 min (180,000ms) | Max time for LLM call before killing process and falling back to regex |
329
+ | Stale flag auto-reset | 5 min (300,000ms) | `_consolidationInFlight` flag auto-resets after this duration to unblock future runs |
330
+ | notes.md max size | 50KB | Auto-prunes old sections above this |
331
+ | Agent history entries | 20 | Max entries kept in history.md |
332
+ | Metrics file | `engine/metrics.json` | Auto-created on first completion |
333
+
334
+ ## Files
335
+
336
+ | File | Purpose | Written by |
337
+ |------|---------|-----------|
338
+ | `notes/inbox/*.md` | Agent findings drop-box | Agents |
339
+ | `notes/archive/*.md` | Archived inbox files | Engine (consolidation) |
340
+ | `notes.md` | Accumulated team knowledge | Engine (consolidation) |
341
+ | `agents/<name>/history.md` | Per-agent task history | Engine (post-completion) |
342
+ | `engine/metrics.json` | Quality metrics per agent | Engine (post-completion + review) |
343
+ | `notes/inbox/feedback-*.md` | Review feedback for authors | Engine (post-review) |
344
+
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Wrapper for @azure-devops/mcp that fetches an ADO token via azureauth
4
+ * broker (no browser popup) and sets AZURE_DEVOPS_EXT_PAT before launching
5
+ * the MCP server.
6
+ */
7
+ const { execSync, spawn } = require('child_process');
8
+ const path = require('path');
9
+
10
+ // Fetch token via azureauth broker (corp tool, no browser)
11
+ let token;
12
+ try {
13
+ token = execSync('azureauth ado token --mode broker --output token --timeout 1', {
14
+ encoding: 'utf8',
15
+ timeout: 30000,
16
+ windowsHide: true,
17
+ }).trim();
18
+ } catch (e) {
19
+ // Broker failed — do NOT fall back to web mode (opens browser in automated context)
20
+ process.stderr.write('ado-mcp-wrapper: Broker auth failed: ' + e.message + '\n');
21
+ process.stderr.write('ado-mcp-wrapper: Run "azureauth ado token --mode web" manually to refresh\n');
22
+ process.exit(1);
23
+ }
24
+
25
+ // Launch the actual MCP server with the token in env
26
+ const args = process.argv.slice(2);
27
+ const child = spawn(process.platform === 'win32' ? 'npx.cmd' : 'npx', [
28
+ '-y',
29
+ '--registry=https://registry.npmjs.org/',
30
+ '@azure-devops/mcp@latest',
31
+ ...args
32
+ ], {
33
+ stdio: 'inherit',
34
+ env: { ...process.env, AZURE_DEVOPS_EXT_PAT: token },
35
+ windowsHide: true,
36
+ });
37
+
38
+ child.on('exit', (code) => process.exit(code || 0));
39
+ child.on('error', (err) => {
40
+ process.stderr.write('ado-mcp-wrapper: ' + err.message + '\n');
41
+ process.exit(1);
42
+ });