kodelyth-ecc 1.5.10 → 1.7.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.
Files changed (123) hide show
  1. package/.github/workflows/publish.yml +19 -0
  2. package/AGENTS.md +1 -1
  3. package/CHANGELOG.md +447 -0
  4. package/CLAUDE.md +48 -16
  5. package/README.md +265 -81
  6. package/VERSION +1 -1
  7. package/actions/ecc-review/README.md +243 -0
  8. package/actions/ecc-review/action.yml +158 -0
  9. package/actions/ecc-review/post-comment.js +171 -0
  10. package/actions/ecc-review/run-review.js +285 -0
  11. package/agents/backdoor-hunter.md +260 -0
  12. package/agents/chaos-engineer.md +251 -0
  13. package/agents/code-stealer-detector.md +228 -0
  14. package/agents/jailbreak-tester.md +222 -0
  15. package/agents/license-violation-finder.md +212 -0
  16. package/agents/prompt-injection-hunter.md +126 -0
  17. package/agents/secret-hunter.md +209 -0
  18. package/agents/supply-chain-auditor.md +195 -0
  19. package/bin/kodelyth-ecc.js +875 -1
  20. package/bundles/enterprise.md +172 -0
  21. package/bundles/indie-hacker.md +106 -0
  22. package/bundles/red-team.md +138 -0
  23. package/cat +0 -0
  24. package/commands/dashboard.md +67 -0
  25. package/commands/devil-mode.md +121 -0
  26. package/commands/memory-evolve.md +71 -0
  27. package/commands/replay.md +61 -0
  28. package/commands/route-model.md +48 -0
  29. package/commands/swarm.md +68 -0
  30. package/commands/verify-supply-chain.md +59 -0
  31. package/docs/dashboard.md +211 -0
  32. package/docs/evolve.md +303 -0
  33. package/docs/mcp-clients.md +167 -0
  34. package/docs/mcp.md +178 -0
  35. package/docs/replay.md +244 -0
  36. package/docs/supply-chain.md +207 -0
  37. package/docs/swarm.md +243 -0
  38. package/hooks/hooks.json +52 -0
  39. package/hooks/memory/auto-recall.js +29 -1
  40. package/hooks/safety/README.md +124 -0
  41. package/hooks/safety/lib/patterns.js +179 -0
  42. package/hooks/safety/prompt-injection-guard.js +179 -0
  43. package/hooks/safety/token-budget.js +229 -0
  44. package/install.ps1 +199 -2
  45. package/install.sh +285 -3
  46. package/package.json +30 -4
  47. package/rules/common/agent-intent-routing.md +182 -0
  48. package/rules/common/cost-aware-model-routing.md +152 -0
  49. package/scripts/dashboard/data.js +353 -0
  50. package/scripts/dashboard/server.js +324 -0
  51. package/scripts/dashboard/static/index.html +645 -0
  52. package/scripts/evolve/analyze.js +303 -0
  53. package/scripts/evolve/proposals.js +162 -0
  54. package/scripts/evolve/stats.js +219 -0
  55. package/scripts/mcp/catalog.js +244 -0
  56. package/scripts/mcp/client.js +181 -0
  57. package/scripts/mcp/prompts.js +133 -0
  58. package/scripts/mcp/resources.js +94 -0
  59. package/scripts/mcp/server.js +153 -0
  60. package/scripts/mcp/tools.js +465 -0
  61. package/scripts/replay/bundle.js +191 -0
  62. package/scripts/replay/replay.js +107 -0
  63. package/scripts/router/classify.js +232 -0
  64. package/scripts/supply-chain/manifest.js +154 -0
  65. package/scripts/supply-chain/sbom.js +202 -0
  66. package/scripts/supply-chain/verify.js +102 -0
  67. package/scripts/swarm/build-plan.js +193 -0
  68. package/skills/cost-aware-model-routing/SKILL.md +153 -0
  69. package/skills/kodelyth-quickstart/SKILL.md +7 -0
  70. package/skills/observability-dashboard/SKILL.md +119 -0
  71. package/skills/self-evolving-memory/SKILL.md +175 -0
  72. package/skills/session-replay/SKILL.md +199 -0
  73. package/skills/supply-chain-verification/SKILL.md +201 -0
  74. package/skills/swarm-orchestrator/SKILL.md +177 -0
  75. package/social/card-install.svg +1 -1
  76. package/social/facebook-group/POST.md +121 -0
  77. package/social/facebook-group/fb-1-3am-debug.png +0 -0
  78. package/social/facebook-group/fb-1-3am-debug.svg +97 -0
  79. package/social/facebook-group/fb-2-cpu-upgrade.png +0 -0
  80. package/social/facebook-group/fb-2-cpu-upgrade.svg +132 -0
  81. package/social/facebook-group/fb-3-before-after.png +0 -0
  82. package/social/facebook-group/fb-3-before-after.svg +94 -0
  83. package/social/facebook-v150.svg +5 -5
  84. package/social/github-social-preview.svg +119 -100
  85. package/social/readme-hero.svg +11 -11
  86. package/social/section-agents.svg +57 -0
  87. package/social/section-author.svg +54 -0
  88. package/social/section-dashboard.svg +59 -0
  89. package/social/section-devil.svg +54 -0
  90. package/social/section-hooks.svg +51 -0
  91. package/social/section-install.svg +42 -0
  92. package/social/section-learning.svg +52 -0
  93. package/social/section-mcp.svg +46 -0
  94. package/social/section-memory.svg +57 -0
  95. package/social/section-parallel.svg +72 -0
  96. package/social/section-routing.svg +51 -0
  97. package/social/x-card-agents-grid.svg +6 -6
  98. package/tests/dashboard/data.test.js +235 -0
  99. package/tests/dashboard/server.test.js +240 -0
  100. package/tests/evolve/analyze.test.js +169 -0
  101. package/tests/evolve/proposals.test.js +173 -0
  102. package/tests/evolve/stats.test.js +159 -0
  103. package/tests/mcp/catalog.test.js +98 -0
  104. package/tests/mcp/client.test.js +109 -0
  105. package/tests/mcp/resources-prompts.test.js +70 -0
  106. package/tests/mcp/tools.test.js +159 -0
  107. package/tests/replay/bundle.test.js +181 -0
  108. package/tests/replay/replay.test.js +131 -0
  109. package/tests/router/classify.test.js +164 -0
  110. package/tests/safety/patterns.test.js +94 -0
  111. package/tests/safety/prompt-injection-guard.test.js +111 -0
  112. package/tests/safety/token-budget.test.js +119 -0
  113. package/tests/supply-chain/manifest.test.js +147 -0
  114. package/tests/supply-chain/sbom.test.js +170 -0
  115. package/tests/supply-chain/verify.test.js +146 -0
  116. package/tests/swarm/build-plan.test.js +188 -0
  117. package/wiki/Agent-Reference.md +58 -7
  118. package/wiki/FAQ.md +204 -7
  119. package/wiki/Home.md +104 -28
  120. package/wiki/Hook-Reference.md +1 -1
  121. package/wiki/Installation-Guide.md +109 -6
  122. package/wiki/Platform-Support.md +239 -25
  123. package/wiki/Skill-Reference.md +101 -6
package/docs/replay.md ADDED
@@ -0,0 +1,244 @@
1
+ # Kodelyth ECC — Session Replay
2
+
3
+ Bundle, share, and re-run swarm sessions for regression testing, reproducible bug reports, and A/B testing across harnesses, agents, and base refs.
4
+
5
+ > **Phase 2.8 of the [Devil Roadmap](../README.md).** Companion to the swarm orchestrator (Phase 2.7) — every swarm coordination dir is portable, replayable, and diff-friendly.
6
+
7
+ ---
8
+
9
+ ## Why replay
10
+
11
+ Three concrete wins:
12
+
13
+ 1. **Reproducible bug reports.** Bundle a buggy swarm into a single JSON file, ship to maintainers. They `replay --execute` locally and see the same agent behavior.
14
+ 2. **Regression testing.** Save a known-good baseline. After an agent prompt rev, replay against the new agent and diff handoffs. Did quality regress?
15
+ 3. **Model A/B testing.** Same task, two harnesses. Side-by-side handoff comparison reveals which model handles the swarm better for your codebase.
16
+
17
+ ---
18
+
19
+ ## CLI
20
+
21
+ | Command | Purpose |
22
+ |---|---|
23
+ | `kodelyth-ecc session-export <session> [flags]` | Bundle a coordination dir to JSON. |
24
+ | `kodelyth-ecc session-import <bundle.json> [flags]` | Restore a bundle to a coordination dir. |
25
+ | `kodelyth-ecc replay <bundle\|session> [flags]` | Re-run a session with variations. |
26
+
27
+ ### `session-export`
28
+
29
+ ```bash
30
+ kodelyth-ecc session-export <session> \
31
+ [--out file.json] \
32
+ [--task "..."] [--agents a,b,c] [--harness claude] [--base-ref HEAD] \
33
+ [--coord-root <dir>]
34
+ ```
35
+
36
+ | Flag | Description |
37
+ |---|---|
38
+ | `<session>` | Required. Directory name under `.orchestration/`. |
39
+ | `--out` | Output JSON path. Default: `.orchestration/<session>.bundle.json`. |
40
+ | `--task "..."` | Enrich `meta.task` for cleaner replays. |
41
+ | `--agents a,b,c` | Enrich `meta.agents`. |
42
+ | `--harness <h>` | Enrich `meta.harness`. |
43
+ | `--base-ref <ref>` | Enrich `meta.base_ref`. |
44
+ | `--coord-root` | Where to look for coordination dirs (default: `<repo>/.orchestration`). |
45
+
46
+ ### `session-import`
47
+
48
+ ```bash
49
+ kodelyth-ecc session-import <bundle.json> \
50
+ [--target <dir>] [--overwrite] \
51
+ [--coord-root <dir>]
52
+ ```
53
+
54
+ | Flag | Description |
55
+ |---|---|
56
+ | `<bundle.json>` | Required. Bundle to restore. |
57
+ | `--target` | Output directory. Default: `.orchestration/<session-from-bundle>`. |
58
+ | `--overwrite` | Replace any existing target dir. |
59
+
60
+ ### `replay`
61
+
62
+ ```bash
63
+ kodelyth-ecc replay <bundle.json|session-name> \
64
+ [--harness h] [--agents a,b,c] [--base-ref ref] [--session NAME] [--replace] \
65
+ [--execute|--write-only|--json]
66
+ ```
67
+
68
+ | Flag | Description |
69
+ |---|---|
70
+ | `<target>` | Required. Bundle file (ends in `.json`) or session name in `.orchestration/`. |
71
+ | `--harness` | Override launcher harness. |
72
+ | `--agents` | Replace the agent list. |
73
+ | `--base-ref` | Branch base for replay worktrees. |
74
+ | `--session` | Override auto-generated `-replay-N` name. |
75
+ | `--replace` | Tear down any existing session/worktrees with the same names. |
76
+ | `--execute` | Actually spawn worktrees + tmux + agents. |
77
+ | `--write-only` | Just materialize coordination files. |
78
+ | `--json` | Print plan + planConfig. |
79
+
80
+ Default mode is **dry-run**. Always inspect first.
81
+
82
+ ---
83
+
84
+ ## Bundle format
85
+
86
+ Stable schema `kodelyth.session-bundle/v1`. Single JSON file:
87
+
88
+ ```json
89
+ {
90
+ "schema": "kodelyth.session-bundle/v1",
91
+ "session": "swarm-2026-05-10-4a",
92
+ "exported_at": "2026-05-10T17:30:00Z",
93
+ "exported_by": "kodelyth-ecc@1.7.0",
94
+ "meta": {
95
+ "task": "audit oauth flow",
96
+ "agents": ["security-reviewer", "code-reviewer", "pair-programmer", "tdd-guide"],
97
+ "harness": "claude",
98
+ "base_ref": "HEAD"
99
+ },
100
+ "workers": [
101
+ { "slug": "code-reviewer", "task": "...", "handoff": "...", "status": "..." },
102
+ { "slug": "pair-programmer", "task": "...", "handoff": "...", "status": "..." },
103
+ { "slug": "security-reviewer", "task": "...", "handoff": "...", "status": "..." },
104
+ { "slug": "tdd-guide", "task": "...", "handoff": "...", "status": "..." }
105
+ ]
106
+ }
107
+ ```
108
+
109
+ Pure JSON. No archives, no binaries. Diff-friendly for `git diff` review of regression bundles.
110
+
111
+ ---
112
+
113
+ ## How replay reconstructs the task
114
+
115
+ 1. **Prefer `meta.task`** if the bundle was exported with `--task "..."`.
116
+ 2. **Fallback: parse the first worker's `task.md`** for the `## Shared Task` section (the agent-shaped header from `scripts/swarm/build-plan.js`).
117
+ 3. **Final fallback: parse the orchestrator's own `## Objective` block** (works for hand-written tasks).
118
+
119
+ This means replay works even on bundles that pre-date the `--task` flag — the heuristic recovers the shared task from the first worker.
120
+
121
+ ---
122
+
123
+ ## Replay variations
124
+
125
+ | Want to test | Flags |
126
+ |---|---|
127
+ | Same task, different model | `--harness claude` vs `--harness codex` (or vary `KODELYTH_ROUTER_*`) |
128
+ | Same task, different agents | `--agents new1,new2,new3` |
129
+ | Same task, new code | `--base-ref refactor-branch` |
130
+ | Custom session name | `--session my-replay-1` |
131
+ | Inspect plan only | (default — dry-run) |
132
+ | Just write coordination files | `--write-only` |
133
+ | Full execute | `--execute` |
134
+
135
+ ---
136
+
137
+ ## Hard rules
138
+
139
+ 1. **Never `--execute` without inspecting the dry-run.** Worktrees mutate disk.
140
+ 2. **Replays are auto-named** (`-replay-N`) to avoid collisions. Don't manually reuse the origin name.
141
+ 3. **Bundles are public artifacts** — strip secrets before sharing externally. Use `opensource-sanitizer` if needed.
142
+ 4. **A/B comparisons require human review.** Never auto-pick a "winner" between two replays.
143
+ 5. **Don't replay across incompatible base refs.** A swarm built against `main` may break if replayed against `feature-branch` with conflicting changes.
144
+
145
+ ---
146
+
147
+ ## Pairing with the rest of ECC
148
+
149
+ | Pairs with | How |
150
+ |---|---|
151
+ | **2.7 swarm orchestrator** | Replay only works on swarm coordination dirs. The two ship together. |
152
+ | **2.4 cost router** | Vary `KODELYTH_ROUTER_*` env vars across replays for A/B model tests. |
153
+ | **2.10 token-budget hook** | Replays open new sessions with fresh budgets — no spillover from the origin. |
154
+ | **2.5 MCP client mode** | Replays inherit the same MCP registry, so tool calls reproduce. |
155
+ | **opensource-sanitizer** | Run on a bundle before sharing externally. |
156
+
157
+ ---
158
+
159
+ ## Examples
160
+
161
+ ### Reproducible bug report
162
+
163
+ ```bash
164
+ # 1. Capture the buggy run
165
+ npx kodelyth-ecc swarm --task "..." --execute
166
+
167
+ # 2. After it finishes, export with rich meta
168
+ npx kodelyth-ecc session-export swarm-2026-05-10-4a \
169
+ --task "..." --agents code-reviewer,security-reviewer --harness claude \
170
+ --out bug-report.bundle.json
171
+
172
+ # 3. Strip secrets if needed
173
+ # (manually edit bug-report.bundle.json)
174
+
175
+ # 4. Ship to maintainers
176
+ gh issue create --body "Reproducer attached: bug-report.bundle.json"
177
+ ```
178
+
179
+ ### Model A/B test
180
+
181
+ ```bash
182
+ # Run with claude
183
+ npx kodelyth-ecc swarm --task "refactor payments module" --agents 4 --harness claude --execute
184
+ npx kodelyth-ecc session-export swarm-... --out claude-run.bundle.json
185
+
186
+ # Replay with codex against the same task
187
+ npx kodelyth-ecc replay claude-run.bundle.json --harness codex --execute
188
+ npx kodelyth-ecc session-export swarm-...-replay-1 --out codex-run.bundle.json
189
+
190
+ # Compare handoffs
191
+ diff <(jq -r '.workers[] | "\(.slug):\n\(.handoff)"' claude-run.bundle.json) \
192
+ <(jq -r '.workers[] | "\(.slug):\n\(.handoff)"' codex-run.bundle.json)
193
+ ```
194
+
195
+ ### Regression check after agent rev
196
+
197
+ ```bash
198
+ # 1. Save a baseline.
199
+ npx kodelyth-ecc session-export swarm-baseline --out baseline.bundle.json
200
+
201
+ # 2. After updating an agent prompt, replay.
202
+ npx kodelyth-ecc replay baseline.bundle.json --execute
203
+ npx kodelyth-ecc session-export swarm-baseline-replay-1 --out replay.bundle.json
204
+
205
+ # 3. Inspect the diff manually — has quality regressed?
206
+ diff <(jq -r '.workers[] | "\(.slug)\n\(.handoff)"' baseline.bundle.json) \
207
+ <(jq -r '.workers[] | "\(.slug)\n\(.handoff)"' replay.bundle.json)
208
+ ```
209
+
210
+ ---
211
+
212
+ ## Programmatic use
213
+
214
+ ```js
215
+ const bundleLib = require('kodelyth-ecc/scripts/replay/bundle.js');
216
+ const replayLib = require('kodelyth-ecc/scripts/replay/replay.js');
217
+ const { buildOrchestrationPlan, executePlan } = require('kodelyth-ecc/scripts/lib/tmux-worktree-orchestrator.js');
218
+
219
+ // Read a bundle
220
+ const bundle = bundleLib.readBundle('./oauth-audit.bundle.json');
221
+
222
+ // Build a replay plan with overrides
223
+ const planConfig = replayLib.buildReplayPlanConfig(bundle, {
224
+ harness: 'codex',
225
+ baseRef: 'main',
226
+ });
227
+
228
+ // Execute
229
+ const plan = buildOrchestrationPlan(planConfig);
230
+ const result = executePlan(plan);
231
+ console.log(`replay started: ${result.sessionName}`);
232
+ ```
233
+
234
+ ---
235
+
236
+ ## Roadmap interactions
237
+
238
+ - **Phase 2.3 — local dashboard** will surface replay history and side-by-side handoff diffs for the same task across runs.
239
+ - **Phase 2.6 — sandbox layer** will isolate replay execution in Docker so re-running an external bundle doesn't trust the source.
240
+ - **Phase 2.2 — SWE-Bench harness** will use bundle replay as its evaluation primitive.
241
+
242
+ ---
243
+
244
+ Built into [Kodelyth ECC](../README.md). MIT licensed.
@@ -0,0 +1,207 @@
1
+ # Supply chain — SBOM, manifest, SLSA provenance
2
+
3
+ > Phase 2.9 of the Devil Roadmap. Every kodelyth-ecc release ships with three independent supply-chain artifacts so any consumer (audit team, downstream agent, security tool) can answer "where does this code come from, can I trust it, and has it been tampered" without trusting kodelyth-ecc.
4
+
5
+ ---
6
+
7
+ ## What ships with every release
8
+
9
+ | Artifact | Format | Where to find it | Issued by |
10
+ |---|---|---|---|
11
+ | **SLSA build provenance** | sigstore-signed npm provenance | npmjs.com/package/kodelyth-ecc → "Provenance" tab | npm + GitHub OIDC (`npm publish --provenance`) |
12
+ | **CycloneDX SBOM** | CycloneDX 1.5 JSON | GitHub release page → `kodelyth-ecc-sbom.cdx.json` | `kodelyth-ecc sbom` |
13
+ | **Content manifest** | sha256 manifest JSON | GitHub release page → `kodelyth-ecc-manifest.json` | `kodelyth-ecc manifest` |
14
+
15
+ All three are emitted by `.github/workflows/publish.yml` on every tagged release.
16
+
17
+ ---
18
+
19
+ ## CLI
20
+
21
+ ### `kodelyth-ecc sbom`
22
+
23
+ ```
24
+ kodelyth-ecc sbom [--root DIR] [--out FILE] [--json]
25
+ ```
26
+
27
+ Generates a CycloneDX 1.5 software bill of materials.
28
+
29
+ | Field | Source | Notes |
30
+ |---|---|---|
31
+ | `metadata.component` | `package.json` | The kodelyth-ecc package itself |
32
+ | `components[]` | `package-lock.json` v3 | One entry per locked dependency, including dev + transitive |
33
+ | `purl` | `pkg:npm/<name>@<version>` | scoped packages keep the leading `@` |
34
+ | `licenses` | lockfile `license` | normalized to CycloneDX shape |
35
+ | `hashes` | npm SRI (`integrity`) | base64 → hex, algo mapped to `SHA-256/384/512` |
36
+ | `dependencies[]` | root entry's `dependencies` + `optionalDependencies` | Direct edges only |
37
+ | `serialNumber` | `urn:uuid:<sha256("name@version|timestamp")>` | Stable for same inputs |
38
+
39
+ **Pure function. No network. No exec.**
40
+
41
+ ### `kodelyth-ecc manifest`
42
+
43
+ ```
44
+ kodelyth-ecc manifest [--root DIR] [--out FILE] [--json]
45
+ ```
46
+
47
+ Generates a sha256 content manifest of every shipped asset.
48
+
49
+ ```json
50
+ {
51
+ "schema": "kodelyth.content-manifest/v1",
52
+ "package": "kodelyth-ecc",
53
+ "pkg_version": "1.7.0",
54
+ "generated_at": "2026-05-10T17:00:00Z",
55
+ "file_count": 730,
56
+ "digest": "20813125…",
57
+ "files": [
58
+ { "path": "agents/code-reviewer.md", "size": 4521, "sha256": "…" }
59
+ ]
60
+ }
61
+ ```
62
+
63
+ Walks: `agents/`, `skills/`, `commands/`, `rules/`, `hooks/`, `scripts/`, `bin/`, `parallel-commands/`, `bundles/`, plus root files (`package.json`, `README.md`, `CHANGELOG.md`, `VERSION`, `install.sh`, `install.ps1`).
64
+
65
+ Skips: `node_modules/`, `.git/`, `.DS_Store`, `__pycache__/`, `*.pyc`.
66
+
67
+ The top-level `digest` is the sha256 over the deterministic JSON of `files[]`. Two runs against the same source state produce the same digest.
68
+
69
+ ### `kodelyth-ecc verify`
70
+
71
+ ```
72
+ kodelyth-ecc verify [--root DIR] [--manifest FILE] [--json]
73
+ ```
74
+
75
+ Compares disk against the manifest:
76
+
77
+ | Category | Means | Fails verify? |
78
+ |---|---|---|
79
+ | `ok` | sha256 matches | No |
80
+ | `modified` | hash differs | **Yes** |
81
+ | `missing` | not on disk | **Yes** |
82
+ | `extra` | on disk but not in manifest | No (advisory) |
83
+
84
+ Exits `0` on `ok=true`, `1` otherwise. With `--json`, prints the full report:
85
+
86
+ ```json
87
+ {
88
+ "ok": false,
89
+ "summary": { "total_in_manifest": 730, "ok": 729, "modified": 1, "missing": 0, "extra": 0 },
90
+ "details": {
91
+ "ok": ["agents/api-guardian.md", …],
92
+ "modified": [{ "path": "agents/code-reviewer.md", "expected_sha256": "…", "actual_sha256": "…" }],
93
+ "missing": [],
94
+ "extra": []
95
+ }
96
+ }
97
+ ```
98
+
99
+ ---
100
+
101
+ ## Verifying a downstream install
102
+
103
+ ```bash
104
+ # 1) Download the manifest from the GitHub release that matches your installed version.
105
+ gh release download v1.7.0 -p kodelyth-ecc-manifest.json -O /tmp/manifest.json
106
+
107
+ # 2) Run verify against your installed copy.
108
+ npx kodelyth-ecc verify --root "$(npm root -g)/kodelyth-ecc" --manifest /tmp/manifest.json
109
+ ```
110
+
111
+ Or, if you cloned the repo:
112
+
113
+ ```bash
114
+ cd ~/path/to/kodelyth-ecc
115
+ node bin/kodelyth-ecc.js verify --manifest /tmp/manifest.json
116
+ ```
117
+
118
+ A successful run looks like:
119
+
120
+ ```
121
+ Kodelyth ECC supply-chain verify
122
+ package: kodelyth-ecc@1.7.0
123
+ manifest digest: 20813125baad127bb578e4cbad6b72e2c4721d71cd236b6c039e7c155cd322ef
124
+ files in manifest: 730
125
+ ✓ ok: 730
126
+ ✗ modified: 0
127
+ ✗ missing: 0
128
+ ⚠ extra: 0 (advisory)
129
+
130
+ ✓ verify OK
131
+ ```
132
+
133
+ ---
134
+
135
+ ## SLSA provenance
136
+
137
+ `.github/workflows/publish.yml` runs `npm publish --provenance --access public`. This requires `id-token: write` (set on the job) and uses GitHub's OIDC token to sign a sigstore-backed provenance statement that:
138
+
139
+ 1. Pins the workflow file SHA + commit SHA that produced the build.
140
+ 2. Pins the GitHub repo + ref.
141
+ 3. Pins the npm package name + version.
142
+
143
+ Result: **SLSA Level 3** by npm's published criteria (hosted build platform, signed provenance, verifiable from npm registry metadata).
144
+
145
+ To verify a downloaded tarball matches the npm-published provenance:
146
+
147
+ ```bash
148
+ npm audit signatures kodelyth-ecc
149
+ # or
150
+ npm view kodelyth-ecc --json | jq .dist.signatures
151
+ ```
152
+
153
+ ---
154
+
155
+ ## Programmatic API
156
+
157
+ ```js
158
+ const { generateSBOM } = require('kodelyth-ecc/scripts/supply-chain/sbom.js');
159
+ const { generateManifest } = require('kodelyth-ecc/scripts/supply-chain/manifest.js');
160
+ const { verifyAgainstManifest } = require('kodelyth-ecc/scripts/supply-chain/verify.js');
161
+
162
+ const bom = generateSBOM({ rootDir });
163
+ const manifest = generateManifest({ rootDir });
164
+ const report = verifyAgainstManifest({ rootDir, manifest });
165
+ ```
166
+
167
+ All three are pure functions. Safe to call from a CI step, an MCP tool, or any external automation. They never spawn subprocesses, never make network calls, and never write to disk.
168
+
169
+ ---
170
+
171
+ ## When to call which surface
172
+
173
+ | Situation | Use |
174
+ |---|---|
175
+ | Compliance team wants an SBOM for Dependency-Track / Snyk ingestion | `sbom --out` |
176
+ | Need to ship a tamper-detection seal with a release artifact | `manifest --out` |
177
+ | Validating a downstream install hasn't been edited | `verify` |
178
+ | CI gate that should fail on tamper | `verify --json` + script that checks `.ok` |
179
+ | Reproducibility check between two release archives | `manifest` on both, diff `digest` |
180
+
181
+ ---
182
+
183
+ ## Composition with other phases
184
+
185
+ | Pair | Effect |
186
+ |---|---|
187
+ | **2.7 swarm + verify** | Run `verify` as a pre-flight before spawning workers. Refuse to spawn from a tampered toolkit. |
188
+ | **2.8 replay + manifest** | Embed the manifest digest of the producing toolkit into a session bundle. Replays then verify they're being run by the same toolkit version. |
189
+ | **2.10 safety hooks + verify** | The token-budget hook can read the manifest digest at session start to surface a "you're running tampered tooling" warning. |
190
+ | **2.1 MCP server + verify** | Expose `verify` as an MCP tool. Downstream agents can call it before trusting any other ECC tool's output. |
191
+
192
+ ---
193
+
194
+ ## Hard rules
195
+
196
+ 1. Treat the manifest published with a release as authoritative. **Do not** regenerate locally and pretend it's the same.
197
+ 2. **Do not** suppress a non-zero exit from `verify` in CI. Modified or missing files mean a tamper or a partial install — both are blocking.
198
+ 3. **Do not** include `node_modules/` or `.git/` in the manifest. The skip list is in `scripts/supply-chain/manifest.js`; extend deliberately if needed.
199
+ 4. **Do not** store secrets in any file under the shipped directory list. Anything that's manifested gets its sha256 published.
200
+
201
+ ---
202
+
203
+ ## See also
204
+
205
+ - `skills/supply-chain-verification/SKILL.md` — explicit-invocation skill
206
+ - `commands/verify-supply-chain.md` — `/verify-supply-chain` slash command
207
+ - `.github/workflows/publish.yml` — release pipeline (npm provenance + SBOM + manifest upload)
package/docs/swarm.md ADDED
@@ -0,0 +1,243 @@
1
+ # Kodelyth ECC — Swarm Orchestrator
2
+
3
+ Run N ECC specialist agents in parallel inside isolated git worktrees, coordinated by a tmux session.
4
+
5
+ > **Phase 2.7 of the [Devil Roadmap](../README.md).** Promotes the existing tmux-worktree orchestrator infrastructure to a first-class CLI surface. The generalized form of `/devil-mode` — pick any task, pick any agents, get N panes ready to attach.
6
+
7
+ ---
8
+
9
+ ## Why swarm
10
+
11
+ A single specialist agent has tunnel vision. A pre-flight production change usually needs:
12
+
13
+ - Code quality review (`code-reviewer`)
14
+ - Security audit (`security-reviewer`)
15
+ - API contract check (`api-guardian`)
16
+ - Test coverage check (`tdd-guide`)
17
+ - UX/a11y pass (`ux-reviewer`)
18
+ - Performance check (`performance-optimizer`)
19
+ - Doc update (`doc-updater`)
20
+ - Release readiness (`release-captain`)
21
+
22
+ Sequential = 2 hours. Parallel = 15 minutes. Each runs in its own git worktree so their changes don't collide; their handoffs merge into one folder for human review.
23
+
24
+ ---
25
+
26
+ ## CLI quick reference
27
+
28
+ ```bash
29
+ # Auto-pick from task signals
30
+ npx kodelyth-ecc swarm --task "audit oauth flow for security regressions" --agents 4
31
+
32
+ # Explicit agent list
33
+ npx kodelyth-ecc swarm \
34
+ --task "ship v2.0" \
35
+ --agents release-captain,security-reviewer,e2e-runner,code-reviewer \
36
+ --execute
37
+
38
+ # Power-user plan.json
39
+ npx kodelyth-ecc swarm --plan plan.json --execute
40
+ ```
41
+
42
+ | Flag | Description |
43
+ |---|---|
44
+ | `--task "..."` | Required (unless using `--plan`). The shared task all workers receive. |
45
+ | `--agents N` | Smart-pick N specialists from task signals + baseline + rotation. |
46
+ | `--agents name1,name2,...` | Explicit agent list. |
47
+ | `--harness <h>` | `claude` / `codex` / `opencode` / `windsurf` / `echo`. Default `claude`. |
48
+ | `--launcher-cmd "<tmpl>"` | Custom launcher template (overrides `--harness`). |
49
+ | `--seed <path>` | Overlay a path from the main repo into each worktree. Repeatable. |
50
+ | `--session <name>` | Override the auto-generated tmux session name. |
51
+ | `--worktree-root <dir>` | Where to create worktrees. Default: parent of repo. |
52
+ | `--coordination-root <dir>` | Where to write coordination files. Default: `<repo>/.orchestration/`. |
53
+ | `--base-ref <ref>` | Branch base for all worktrees. Default: `HEAD`. |
54
+ | `--replace` | Tear down any existing session/worktrees/branches with the same names. |
55
+ | `--execute` | Actually create worktrees + tmux + launch. |
56
+ | `--write-only` | Just write coordination files. |
57
+ | `--json` | Print the full plan as JSON. |
58
+ | `--plan plan.json` | Use a hand-written plan (skips auto-build). |
59
+
60
+ Default mode is **dry-run** — prints a summary and does NOT spawn anything. Always inspect first.
61
+
62
+ ---
63
+
64
+ ## Smart agent picking
65
+
66
+ When you pass `--agents N` (a number), the swarm picks specialists in this priority order:
67
+
68
+ ### 1. Signal-driven (highest priority)
69
+
70
+ Task text is scanned for 14 signal classes. Each match adds a specialist. Examples:
71
+
72
+ | Task contains | Picks |
73
+ |---|---|
74
+ | `security`, `auth`, `vuln`, `cve`, `injection`, `owasp` | `security-reviewer` |
75
+ | `perf`, `slow`, `p99`, `latency`, `bottleneck` | `performance-optimizer` |
76
+ | `load test`, `stress test`, `capacity`, `k6` | `load-tester` |
77
+ | `architect`, `design`, `ADR`, `RFC`, `trade-off` | `architect` |
78
+ | `api`, `endpoint`, `contract`, `breaking change` | `api-guardian` |
79
+ | `test`, `tdd`, `coverage`, `spec` | `tdd-guide` |
80
+ | `refactor`, `tech debt`, `code smell` | `refactor-cleaner` |
81
+ | `ux`, `accessibility`, `wcag`, `a11y` | `ux-reviewer` |
82
+ | `doc`, `readme`, `guide`, `tutorial` | `doc-updater` |
83
+ | `release`, `ship`, `tag`, `semver` | `release-captain` |
84
+ | `incident`, `outage`, `down`, `P0`, `P1` | `incident-commander` |
85
+ | `debug`, `why is`, `stack trace`, `silent fail` | `debug-detective` |
86
+ | `database`, `sql`, `postgres`, `index`, `n+1` | `database-reviewer` |
87
+ | `devil-mode`, `adversarial`, `red team` | `prompt-injection-hunter` |
88
+
89
+ ### 2. Baseline anchors
90
+
91
+ `code-reviewer` and `pair-programmer` are added if not already picked — every task benefits from generalist eyes.
92
+
93
+ ### 3. Rotation fill
94
+
95
+ If we still need more, fills from a tuned default rotation:
96
+
97
+ | Count | Rotation |
98
+ |---|---|
99
+ | 4 | code-reviewer, security-reviewer, pair-programmer, tdd-guide |
100
+ | 6 | + performance-optimizer, api-guardian |
101
+ | 8 | + ux-reviewer, doc-updater |
102
+
103
+ You can always override the picker with `--agents code-reviewer,security-reviewer,architect`.
104
+
105
+ ---
106
+
107
+ ## Coordination protocol
108
+
109
+ Each worker gets three files in `<coord-root>/<session>/<worker-slug>/`:
110
+
111
+ ### `task.md` (auto-generated)
112
+
113
+ Agent-shaped task with required handoff sections:
114
+
115
+ ```
116
+ # <agent> — swarm task
117
+
118
+ You are running as the ECC `<agent>` specialist in a parallel swarm. Other agents
119
+ are running the same shared task in sibling worktrees. Stay strictly inside your
120
+ specialty — do not duplicate what other agents will cover. Produce a focused
121
+ handoff that names exactly which findings are yours and yours alone.
122
+
123
+ ## Shared Task
124
+ <your task>
125
+
126
+ ## Required handoff sections
127
+ 1. Summary
128
+ 2. Files Changed
129
+ 3. Validation
130
+ 4. Remaining Risks
131
+ ```
132
+
133
+ ### `handoff.md` (worker fills in)
134
+
135
+ Where the worker's output lands. Watched by the launcher.
136
+
137
+ ### `status.md` (launcher updates)
138
+
139
+ `running` / `completed` / `failed` plus timestamp + branch + worktree path.
140
+
141
+ Monitor a swarm in flight:
142
+
143
+ ```bash
144
+ # All worker statuses
145
+ cat .orchestration/<session>/*/status.md
146
+
147
+ # Specific handoff
148
+ cat .orchestration/<session>/security-reviewer/handoff.md
149
+ ```
150
+
151
+ ---
152
+
153
+ ## Harness adapters
154
+
155
+ | `--harness` | Launcher template |
156
+ |---|---|
157
+ | `claude` | `claude --print --dangerously-skip-permissions "$(cat {task_file_sh})" 2>&1 \| tee -a {handoff_file_sh}; ...` |
158
+ | `codex` | `bash {repo_root}/scripts/orchestrate-codex-worker.sh {task_file_sh} {handoff_file_sh} {status_file_sh}` |
159
+ | `opencode` | `opencode run --task-file {task_file_sh} --output {handoff_file_sh} --status {status_file_sh}` |
160
+ | `windsurf` | `windsurf-cli run --task-file {task_file_sh} --output {handoff_file_sh}` |
161
+ | `echo` | `printf 'demo {worker_slug}\n' >> {handoff_file_sh}; printf 'state: completed\n' >> {status_file_sh}` |
162
+
163
+ Custom harness via `--launcher-cmd`. Available placeholders:
164
+
165
+ ```
166
+ {worker_name} {worker_slug} {session_name} {repo_root}
167
+ {worktree_path} {branch_name} {task_file} {handoff_file} {status_file}
168
+ ```
169
+
170
+ Suffix with `_sh` for shell-quoted variants: `{task_file_sh}`, `{handoff_file_sh}`, etc.
171
+
172
+ ---
173
+
174
+ ## Worktree lifecycle
175
+
176
+ 1. **Pre-flight** — verify `git rev-parse --is-inside-work-tree` and `tmux -V`.
177
+ 2. **Cleanup** — if `--replace`, tear down any existing session, worktrees, branches.
178
+ 3. **Materialize** — write coordination files for every worker.
179
+ 4. **Branch + worktree** — `git worktree add -b orchestrator-<session>-<slug> <path> <base-ref>`.
180
+ 5. **Seed overlay** — copy any `--seed` paths into each worktree.
181
+ 6. **Tmux session** — `tmux new-session -d -s <session> -n orchestrator -c <repo>`.
182
+ 7. **Per-worker pane** — `tmux split-window` + `select-pane` + `send-keys` to launch.
183
+
184
+ On failure, automatic rollback removes worktrees, branches, and the tmux session in reverse order.
185
+
186
+ Manually clean up later:
187
+
188
+ ```bash
189
+ tmux kill-session -t <session>
190
+ git worktree list # verify
191
+ git worktree remove <path>
192
+ git branch -D orchestrator-<session>-<slug>
193
+ rm -rf .orchestration/<session>
194
+ ```
195
+
196
+ ---
197
+
198
+ ## Pairing with the rest of ECC
199
+
200
+ | Pairs with | How |
201
+ |---|---|
202
+ | **`/devil-mode`** | Devil-mode is a hardcoded swarm of adversarial agents. Swarm generalizes it. |
203
+ | **Phase 2.4 cost router** | Each worker classifies its own task tier; security/incident workers force hard. |
204
+ | **Phase 2.10 token-budget hook** | Each worker has its own token budget — one rogue worker can't blow the cap. |
205
+ | **Phase 2.5 MCP client mode** | Workers can call registered external MCP servers (github, postgres, brave, redis). |
206
+ | **kodelyth-memory** | Save the merged handoff bundle: `kodelyth-ecc remember "..." --approach "..."`. |
207
+ | **`release-captain`** | After a swarm, run `release-captain` to merge the best work and ship. |
208
+
209
+ ---
210
+
211
+ ## Hard rules
212
+
213
+ 1. **Never `--execute` without inspecting the dry-run first.** Worktree creation mutates the repo.
214
+ 2. **Don't mix incompatible agents.** `release-captain` + `migration-guide` in the same swarm produces conflicting handoffs.
215
+ 3. **Cap N at 8 for a single repo.** Past 8, worktree contention + pane crowding hurts.
216
+ 4. **Never share tmux sessions.** Use `--session NAME` explicitly when running multiple swarms.
217
+ 5. **Always human-merge handoffs.** Don't auto-apply changes from N parallel agents.
218
+
219
+ ---
220
+
221
+ ## Troubleshooting
222
+
223
+ **`tmux session already exists`** — pass `--replace` to tear it down, or `--session <new-name>`.
224
+
225
+ **`Worker X is missing a launcherCommand`** — pass `--harness <name>` or `--launcher-cmd "<template>"`.
226
+
227
+ **`seedPaths entries must stay inside repoRoot`** — the seed must be a subpath of the repo, not an absolute external path.
228
+
229
+ **Worktrees have stale state** — `--replace` cleans them. Or manually: `git worktree prune --expire now`.
230
+
231
+ **A worker stalled** — `tmux attach -t <session>` and inspect its pane. Or `cat .orchestration/<session>/<slug>/status.md`.
232
+
233
+ ---
234
+
235
+ ## Roadmap interactions
236
+
237
+ - **Phase 2.3 — local dashboard** will surface live swarm status (running / completed / failed per worker, latency, token usage).
238
+ - **Phase 2.6 — sandbox layer** will optionally Docker-isolate each worker.
239
+ - **Phase 2.8 — replay** will let you replay a finished swarm from its coordination files.
240
+
241
+ ---
242
+
243
+ Built into [Kodelyth ECC](../README.md). MIT licensed.