kodelyth-ecc 1.5.9 → 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 +455 -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 +286 -4
  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/evolve.md ADDED
@@ -0,0 +1,303 @@
1
+ # Self-evolving memory
2
+
3
+ > Phase 3.4 of the Devil Roadmap. Closes the learning loop on the BM25 memory system. Repeated memory hits become draft skills. Repeated routing misses become proposed routing-rule additions. Nothing is ever auto-applied.
4
+
5
+ ---
6
+
7
+ ## Why this exists
8
+
9
+ ECC already has:
10
+
11
+ - A BM25 memory store (`scripts/memory/store.js`)
12
+ - An auto-recall hook that surfaces relevant memories on every `UserPromptSubmit`
13
+
14
+ What it didn't have, until 3.4: a way for those signals to feed back into the toolkit's own structure. If the same memory keeps getting surfaced across sessions, that memory is doing real work — it should graduate to a `SKILL.md`. If users keep submitting prompts that match no memory at all, that's a routing gap — the routing rule should grow.
15
+
16
+ The 3.4 surface formalizes both loops while preserving the **never auto-commit** rule.
17
+
18
+ ---
19
+
20
+ ## Two signal streams
21
+
22
+ ### 1. Memory reuse (→ skill-upgrade proposals)
23
+
24
+ Every time `auto-recall.js` surfaces a memory to the user, it bumps a counter:
25
+
26
+ ```jsonc
27
+ // ~/.kodelyth/evolve/reuse.json
28
+ {
29
+ "byMemory": {
30
+ "<memoryId>": {
31
+ "count": 7,
32
+ "sessions": ["s1", "s2", "s3", ...],
33
+ "projects": ["/path/to/proj-a", "/path/to/proj-b"],
34
+ "firstSurfaced": "2026-04-30T...",
35
+ "lastSurfaced": "2026-05-10T..."
36
+ }
37
+ },
38
+ "lastUpdated": "2026-05-10T..."
39
+ }
40
+ ```
41
+
42
+ Counter semantics:
43
+
44
+ - **Per-memory, per-session**: surfacing the same memory ten times in one session counts ONCE. Matches the existing "never re-surface the same memory twice in a session" rule of `auto-recall.js`.
45
+ - **Cross-session**: each fresh session bumps the count by exactly one.
46
+ - **Idempotent**: replaying a session does not double-count.
47
+
48
+ Default threshold: count ≥ 3 AND sessions ≥ 2 → eligible for skill-upgrade proposal.
49
+
50
+ ### 2. Routing misses (→ routing-addition proposals)
51
+
52
+ When `shouldRecall(prompt)` is true (substantive prompt, ≥12 chars, ≥2 meaningful tokens, not a slash command) AND BM25 recall returns zero matches, the prompt is logged:
53
+
54
+ ```jsonl
55
+ // ~/.kodelyth/evolve/routing-misses.jsonl (append-only)
56
+ {"hash":"abc...","prompt":"...","tokens":["..."],"session_id":"...","project":"...","recorded_at":"..."}
57
+ ```
58
+
59
+ Stored prompts are capped at 1000 chars. Top tokens are extracted at write time so analysis is cheap.
60
+
61
+ Default threshold: cluster count ≥ 3 AND distinct prompts ≥ 2 → eligible for routing-addition proposal.
62
+
63
+ ---
64
+
65
+ ## CLI
66
+
67
+ ### `kodelyth-ecc evolve stats`
68
+
69
+ Snapshot of recorded signals. No proposals generated.
70
+
71
+ ```
72
+ Kodelyth ECC — self-evolving memory stats
73
+ reuse:
74
+ memories tracked: 14
75
+ total surfaces: 42
76
+ last updated: 2026-05-10T17:23:00.000Z
77
+ top reused:
78
+ • efe17d650917e445 count=7 sessions=5
79
+ • a91ce2034d8b1234 count=5 sessions=4
80
+ routing misses:
81
+ total: 18
82
+ unique prompts: 11
83
+ top clusters:
84
+ • count=4 tokens=[feature, flag, gradual, rollout]
85
+ • count=3 tokens=[migration, postgres, downtime, zero]
86
+ ```
87
+
88
+ ### `kodelyth-ecc evolve analyze`
89
+
90
+ Apply thresholds and write proposals. Idempotent — same evidence produces the same proposal ID, so re-running never duplicates.
91
+
92
+ | Flag | Default | Effect |
93
+ |---|---|---|
94
+ | `--reuse-min N` | 3 | minimum total surface count |
95
+ | `--reuse-min-sessions N` | 2 | minimum distinct sessions |
96
+ | `--miss-min N` | 3 | minimum miss-cluster total |
97
+ | `--miss-min-distinct N` | 2 | minimum distinct prompts in cluster |
98
+ | `--json` | off | full report instead of pretty summary |
99
+
100
+ ### `kodelyth-ecc evolve list [--status pending|accepted|rejected|applied]`
101
+
102
+ Show proposals. Filter by status. Pretty output uses ⏸ ✓ ✗ ★ marks for the four states.
103
+
104
+ ### `kodelyth-ecc evolve show <id>`
105
+
106
+ Print the full proposed file content + evidence. **Always preview before accepting.**
107
+
108
+ ### `kodelyth-ecc evolve accept <id> [--root DIR] [--overwrite]`
109
+
110
+ Write the proposed `diff` to its `target_path` under `--root`. Refuses to overwrite an existing file unless `--overwrite` is explicit. Marks the proposal `accepted` with the absolute `applied_path` written to the audit trail.
111
+
112
+ **The CLI does not stage, does not commit, does not push.** Review the draft, edit, commit by hand.
113
+
114
+ ### `kodelyth-ecc evolve reject <id> [--note "..."]`
115
+
116
+ Mark a proposal `rejected`. The optional `--note` is preserved in the audit trail for future reference.
117
+
118
+ ---
119
+
120
+ ## Proposal anatomy
121
+
122
+ Both proposal kinds share a structure:
123
+
124
+ ```jsonc
125
+ {
126
+ "id": "skill-2537cb787a", // deterministic over evidence
127
+ "type": "skill-upgrade", // or "routing-addition"
128
+ "evidence": {
129
+ "memoryId": "efe17d650917e445",
130
+ "reuseCount": 7,
131
+ "sessions": ["s1", "s2", "s3", "s4", "s5"],
132
+ "firstSurfaced": "...",
133
+ "lastSurfaced": "..."
134
+ },
135
+ "proposal": {
136
+ "kind": "create-skill", // or "add-routing-entry"
137
+ "target_path": "skills/<slug>/SKILL.md", // for skill-upgrade
138
+ "diff": "<full markdown content>",
139
+ "rationale": "Memory '...' surfaced 7x across 5 sessions ..."
140
+ },
141
+ "status": "pending", // pending | accepted | rejected | applied
142
+ "created_at": "...",
143
+ "timestamp": "...",
144
+ "applied_path": null // set on accept
145
+ }
146
+ ```
147
+
148
+ ### Skill-upgrade diff (sample)
149
+
150
+ ```markdown
151
+ ---
152
+ name: <slug-from-problem>
153
+ description: <problem text> (auto-derived from memory <id> after repeated reuse)
154
+ origin: kodelyth-evolve
155
+ language: typescript
156
+ tags:
157
+ - <memory tags>
158
+ ---
159
+
160
+ # Skill: <slug>
161
+
162
+ > **Auto-derived draft.** Generated by `kodelyth-ecc evolve` after this memory
163
+ > was surfaced repeatedly across multiple sessions. Review, refine, and rename
164
+ > before committing.
165
+
166
+ ## Problem
167
+ <memory.problem>
168
+
169
+ ## Approach
170
+ <memory.approach>
171
+
172
+ ## Gotchas
173
+ <memory.gotchas if any>
174
+
175
+ ## When to invoke
176
+ _Replace this section with explicit trigger conditions._
177
+
178
+ ## Origin
179
+ - Memory id: `<id>`
180
+ - Captured at: <timestamp>
181
+ - Auto-promoted by Phase 3.4 self-evolving memory.
182
+ ```
183
+
184
+ ### Routing-addition diff (sample)
185
+
186
+ ```markdown
187
+ <!-- proposed addition to rules/common/agent-intent-routing.md -->
188
+ <!-- review by hand, decide on tier + agent, then merge -->
189
+
190
+ ### TODO-agent — covers prompts about <token>, <token>, <token>
191
+
192
+ Trigger if the user mentions `<t1>`, `<t2>`, `<t3>`.
193
+
194
+ | Signal | Real human phrasing |
195
+ |---|---|
196
+ | repeated unrouted prompt cluster | <tokens> |
197
+
198
+ **Origin:** Phase 3.4 self-evolving memory — N prompts in this cluster were
199
+ submitted with no memory match and (presumably) no specialist routing.
200
+
201
+ Recent samples:
202
+ - "<sample 1>"
203
+ - "<sample 2>"
204
+ - "<sample 3>"
205
+
206
+ _(Pick the right tier in `rules/common/agent-intent-routing.md` before merging.
207
+ Do NOT commit this block as-is — replace `TODO-agent` with the real agent name
208
+ and slot under the correct priority tier.)_
209
+ ```
210
+
211
+ The `TODO-agent` placeholder is intentional. Even if you accept and commit verbatim, the rule won't route any real traffic — it's a no-op until you fill in the agent name.
212
+
213
+ ---
214
+
215
+ ## Storage layout
216
+
217
+ ```
218
+ ~/.kodelyth/evolve/ ← override with $KODELYTH_EVOLVE_DIR
219
+ ├── reuse.json ← per-memory reuse counters
220
+ ├── routing-misses.jsonl ← append-only miss log
221
+ └── proposals.jsonl ← append-only proposal events
222
+ ```
223
+
224
+ `proposals.jsonl` is append-only. Every state transition is a new event. Reading collapses to "latest state per id" while preserving the full history for audit.
225
+
226
+ ---
227
+
228
+ ## Worked example
229
+
230
+ ```bash
231
+ # 1) Use ECC normally for a few weeks. The auto-recall hook records signals.
232
+ # 2) Eventually run:
233
+ $ npx kodelyth-ecc evolve stats
234
+ ... shows current signal volume ...
235
+
236
+ # 3) Generate proposals.
237
+ $ npx kodelyth-ecc evolve analyze
238
+ ✓ analyzed signals
239
+ reuse entries scanned: 14
240
+ miss entries scanned: 11
241
+ proposals generated: 3
242
+ new proposals (added): 3
243
+
244
+ Run 'kodelyth-ecc evolve list' to review.
245
+
246
+ # 4) See what's pending.
247
+ $ npx kodelyth-ecc evolve list
248
+ Kodelyth ECC — self-evolving memory proposals (3)
249
+ ⏸ [pending] skill-2537cb787a skill-upgrade
250
+ target: skills/tailwind-v4-arbitrary-values/SKILL.md
251
+ why: Memory '...' surfaced 7x across 5 sessions ...
252
+ ⏸ [pending] route-13d976a554 routing-addition
253
+ target: rules/common/agent-intent-routing.md
254
+ why: 4 substantive prompts (4 distinct) clustered on tokens [...]
255
+
256
+ # 5) Inspect the skill draft.
257
+ $ npx kodelyth-ecc evolve show skill-2537cb787a
258
+ ... full markdown + evidence ...
259
+
260
+ # 6) Accept it. Writes to disk. NEVER commits.
261
+ $ npx kodelyth-ecc evolve accept skill-2537cb787a
262
+ ✓ accepted skill-2537cb787a
263
+ draft written: /path/to/repo/skills/tailwind-v4-arbitrary-values/SKILL.md
264
+
265
+ Review the draft. When you're happy with it, commit it.
266
+
267
+ # 7) Reject the routing one — already covered.
268
+ $ npx kodelyth-ecc evolve reject route-13d976a554 --note "covered by debug-detective"
269
+ ✗ rejected route-13d976a554 (note: covered by debug-detective)
270
+ ```
271
+
272
+ ---
273
+
274
+ ## Hard rules
275
+
276
+ 1. **NEVER auto-apply.** `accept` writes a draft. The user reviews, edits, commits.
277
+ 2. **NEVER overwrite without `--overwrite`.** Even on accept of a stale proposal.
278
+ 3. **NEVER block the recall hook.** All evolve recording is wrapped in try/catch and lazy-required.
279
+ 4. **NEVER auto-route a `TODO-agent` proposal.** The placeholder is intentional.
280
+ 5. **Idempotent IDs.** Stable evidence → stable proposal ID. Re-running `analyze` never duplicates.
281
+ 6. **Append-only proposal log.** Every state change is a new event. Full audit trail preserved.
282
+
283
+ ---
284
+
285
+ ## Composition with other phases
286
+
287
+ | Pair | Effect |
288
+ |---|---|
289
+ | BM25 memory store | Source of reuse signals. |
290
+ | `/memory remember` | Manually captured memories that get reused → skill proposals. |
291
+ | `rules/common/agent-intent-routing.md` | Direct target for routing-addition proposals. |
292
+ | Phase 2.7 swarm | Repeated swarm tasks reusing the same memories → those memories become skills the swarm picker can choose automatically. |
293
+ | Phase 2.8 replay | Replay bundles re-trigger reuse signals when the same memory is surfaced again. |
294
+ | Phase 2.10 token-budget hook | Promoting memories → skills means cheaper recalls. |
295
+
296
+ ---
297
+
298
+ ## See also
299
+
300
+ - `skills/self-evolving-memory/SKILL.md` — explicit-invocation skill
301
+ - `commands/memory-evolve.md` — `/memory-evolve` slash command
302
+ - `scripts/evolve/{stats,analyze,proposals}.js` — pure-function implementation
303
+ - `hooks/memory/auto-recall.js` — signal capture (Phase 3.4 augmentation)
@@ -0,0 +1,167 @@
1
+ # Kodelyth ECC — MCP Client Mode
2
+
3
+ The other half of the MCP story. While `npx kodelyth-ecc mcp` (Phase 2.1) **serves** ECC to any MCP-compatible client, MCP client mode lets ECC **consume** any external MCP server — Stripe, GitHub, Postgres, Redis, Brave, Filesystem, Shopify, Sentry, anything.
4
+
5
+ > **Phase 2.5 of the [Devil Roadmap](../README.md).** This makes ECC the MCP **hub**, not just a node. Local-only registry. Zero telemetry. Same SDK as the server side.
6
+
7
+ ---
8
+
9
+ ## Quick start
10
+
11
+ ### 1. Register an external MCP server
12
+
13
+ ```bash
14
+ # Public servers (no env vars needed)
15
+ npx kodelyth-ecc mcp-add brave -- npx -y @modelcontextprotocol/server-brave-search
16
+ npx kodelyth-ecc mcp-add filesystem -- npx -y @modelcontextprotocol/server-filesystem /Users/me/notes
17
+
18
+ # Servers that need credentials
19
+ npx kodelyth-ecc mcp-add github \
20
+ --env GITHUB_PERSONAL_ACCESS_TOKEN=ghp_... \
21
+ --desc "ECC project ops on github" \
22
+ -- npx -y @modelcontextprotocol/server-github
23
+
24
+ npx kodelyth-ecc mcp-add postgres \
25
+ --env DB_URL=postgres://localhost/myapp \
26
+ -- npx -y @modelcontextprotocol/server-postgres
27
+
28
+ npx kodelyth-ecc mcp-add stripe \
29
+ --env STRIPE_API_KEY=sk_... \
30
+ -- npx -y @stripe/mcp
31
+ ```
32
+
33
+ The registry is stored at `~/.kodelyth/mcp-clients.json` (override with `KODELYTH_MCP_CLIENT_DIR`).
34
+
35
+ ### 2. Inspect a registered server
36
+
37
+ ```bash
38
+ npx kodelyth-ecc mcp-list # all registered
39
+ npx kodelyth-ecc mcp-tools github # tools the server exposes
40
+ npx kodelyth-ecc mcp-resources filesystem # resources
41
+ npx kodelyth-ecc mcp-prompts brave # prompts
42
+ ```
43
+
44
+ ### 3. Call a tool
45
+
46
+ ```bash
47
+ # No args:
48
+ npx kodelyth-ecc mcp-call github list_repos
49
+
50
+ # JSON args:
51
+ npx kodelyth-ecc mcp-call github create_issue \
52
+ --json '{"owner":"sifxprime","repo":"kodelyth-ecc","title":"hi from ECC"}'
53
+
54
+ npx kodelyth-ecc mcp-call postgres query \
55
+ --json '{"sql":"SELECT count(*) FROM users"}'
56
+ ```
57
+
58
+ ### 4. Unregister
59
+
60
+ ```bash
61
+ npx kodelyth-ecc mcp-remove github
62
+ ```
63
+
64
+ ---
65
+
66
+ ## CLI surface
67
+
68
+ | Command | Description |
69
+ |---|---|
70
+ | `mcp-add <name> [--env K=V] [--desc "..."] -- <command> [args...]` | Register an external server. |
71
+ | `mcp-list` | List registered servers. |
72
+ | `mcp-remove <name>` | Unregister. |
73
+ | `mcp-tools <name>` | List tools exposed by the server. |
74
+ | `mcp-resources <name>` | List resources. |
75
+ | `mcp-prompts <name>` | List prompts. |
76
+ | `mcp-call <name> <tool> [--json '{"arg":"value"}']` | Call a tool with JSON arguments. |
77
+
78
+ The `--` separator before the command is mandatory in `mcp-add` so the registry can disambiguate flags belonging to ECC from flags meant for the external server.
79
+
80
+ ---
81
+
82
+ ## Programmatic use
83
+
84
+ The same registry powers in-session agent tool calls. Inside an ECC agent or skill, require the client library:
85
+
86
+ ```js
87
+ const client = require('kodelyth-ecc/scripts/mcp/client.js');
88
+
89
+ // Open a stable connection.
90
+ const session = await client.connect('github');
91
+ const out = await session.client.callTool({
92
+ name: 'create_issue',
93
+ arguments: { owner: 'sifxprime', repo: 'kodelyth-ecc', title: 'auto-issue' },
94
+ });
95
+ await session.close();
96
+
97
+ // Or one-shot:
98
+ const tools = await client.listTools('postgres');
99
+ const stats = await client.callTool('redis', 'set', { key: 'k', value: 'v' });
100
+ ```
101
+
102
+ Every call spawns a fresh stdio subprocess; there's no long-lived process pool. This is intentional — failed servers don't poison subsequent calls, and credentials live only in the per-call env.
103
+
104
+ ---
105
+
106
+ ## Registry shape
107
+
108
+ ```json
109
+ {
110
+ "servers": {
111
+ "github": {
112
+ "name": "github",
113
+ "command": "npx",
114
+ "args": ["-y", "@modelcontextprotocol/server-github"],
115
+ "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_..." },
116
+ "description": "ECC project ops on github",
117
+ "added_at": "2026-05-10T10:48:00.690Z"
118
+ }
119
+ }
120
+ }
121
+ ```
122
+
123
+ You can hand-edit the file. Reserved name patterns: alphanumeric, dash, underscore.
124
+
125
+ ---
126
+
127
+ ## Pairing with the rest of ECC
128
+
129
+ | Pairs with | How |
130
+ |---|---|
131
+ | **Phase 2.1 — MCP server** | The two halves complete each other. ECC serves to any framework AND consumes from any provider. |
132
+ | **Phase 2.10 — prompt-injection-guard** | Tool responses from external MCP servers are scanned for indirect injection on `PostToolUse:mcp__*` (opt in via `KODELYTH_PI_GUARD=warn|block`). |
133
+ | **Phase 2.4 — cost-aware model router** | Tool responses are part of the session token-budget when the safety hook is enabled. |
134
+ | **kodelyth-memory** | Capture interesting tool responses as memories with `kodelyth-ecc remember "..." --approach "..."`. |
135
+
136
+ ---
137
+
138
+ ## Privacy & safety
139
+
140
+ - **No network egress from this client** — it only spawns subprocesses you registered.
141
+ - **Credentials live in the registry file.** Treat `~/.kodelyth/mcp-clients.json` like a secrets file. `chmod 600` is recommended on shared machines.
142
+ - **External servers can do whatever the user gives them permission to do** — register only servers you trust.
143
+ - **Pair with `prompt-injection-guard`** to scan tool responses for indirect injection before agents act on them.
144
+
145
+ ---
146
+
147
+ ## Troubleshooting
148
+
149
+ **"Kodelyth MCP client requires `@modelcontextprotocol/sdk`"** — run `npm install @modelcontextprotocol/sdk` once, or rerun via `npx -y kodelyth-ecc ...`.
150
+
151
+ **"MCP server X is not registered"** — `mcp-list` shows nothing because the registry lives at `~/.kodelyth/mcp-clients.json` (or `$KODELYTH_MCP_CLIENT_DIR`). Re-run `mcp-add`.
152
+
153
+ **Server hangs on connect** — the external server probably needs env vars you didn't pass. Re-add with `--env KEY=VAL`.
154
+
155
+ **Tool call returns `isError: true`** — the external server rejected the call. Inspect the `content[0].text` for the underlying error message; it's typed exactly as the spec.
156
+
157
+ ---
158
+
159
+ ## Roadmap interactions
160
+
161
+ - **Phase 2.6 — sandbox layer** will wrap external MCP servers in Docker/firejail isolation by default.
162
+ - **Phase 2.3 — local dashboard** will show live MCP traffic per registered server (count, latency, errors).
163
+ - **Phase 2.9 — SLSA/SBOM** will publish provenance for the ECC server side and let `supply-chain-auditor` verify external server packages.
164
+
165
+ ---
166
+
167
+ Built into [Kodelyth ECC](../README.md). MIT licensed. PRs welcome.
package/docs/mcp.md ADDED
@@ -0,0 +1,178 @@
1
+ # Kodelyth ECC — MCP Server
2
+
3
+ The Kodelyth ECC MCP (Model Context Protocol) server is the **universal adapter** that lets any MCP-compatible client consume the full ECC stack: 70 agents, 194 skills, 97 commands, 14 rules, 3 power bundles, and the local BM25 self-learning memory.
4
+
5
+ If you've ever wished LangGraph, AutoGen, CrewAI, OpenAI Agents SDK, Claude Desktop, or any other agent framework could speak ECC natively — this is that bridge.
6
+
7
+ Local-only, zero telemetry, stdio transport.
8
+
9
+ ---
10
+
11
+ ## Quick start
12
+
13
+ ### 1. Run the server
14
+
15
+ ```bash
16
+ # From npm (recommended):
17
+ npx kodelyth-ecc mcp
18
+
19
+ # From this repo:
20
+ node scripts/mcp/server.js
21
+ ```
22
+
23
+ The server speaks JSON-RPC over **stdio**. It stays alive until stdin closes.
24
+
25
+ You'll see one stderr banner on boot, e.g.:
26
+
27
+ ```
28
+ [kodelyth-mcp] ready · 1.7.0 · 16 tools · 6 prompts · 365 resources
29
+ ```
30
+
31
+ ### 2. Wire it into your MCP client
32
+
33
+ #### Claude Desktop (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS)
34
+
35
+ ```json
36
+ {
37
+ "mcpServers": {
38
+ "kodelyth-ecc": {
39
+ "command": "npx",
40
+ "args": ["-y", "kodelyth-ecc", "mcp"]
41
+ }
42
+ }
43
+ }
44
+ ```
45
+
46
+ #### Cursor / Windsurf / any MCP-aware IDE
47
+
48
+ Use the same `command` + `args` pattern under whatever the IDE's MCP server config key is.
49
+
50
+ #### Programmatic clients (LangGraph, AutoGen, CrewAI, OpenAI Agents SDK, custom)
51
+
52
+ Spawn the server as a subprocess and connect via the official MCP client SDK for your language. The transport is **stdio JSON-RPC** — every spec-compliant client supports it.
53
+
54
+ ---
55
+
56
+ ## What it exposes
57
+
58
+ ### Tools (16)
59
+
60
+ | Name | Purpose |
61
+ |---|---|
62
+ | `route_intent` | Suggest the best ECC agent for a user message via token-overlap. Pair with the `routing-rule` prompt for full tier-based routing. |
63
+ | `list_agents` | List every ECC agent (name, description, relpath). |
64
+ | `list_skills` | List every ECC skill. |
65
+ | `list_commands` | List every slash command. |
66
+ | `list_rules` | List every rule file in `rules/common/`. |
67
+ | `list_bundles` | List the power bundles (indie-hacker, red-team, enterprise). |
68
+ | `get_agent` | Fetch the full markdown body of one agent. |
69
+ | `get_skill` | Fetch the full markdown body of one skill. |
70
+ | `get_command` | Fetch the full markdown body of one slash command (with or without leading `/`). |
71
+ | `get_rule` | Fetch a rule file body. |
72
+ | `get_bundle` | Fetch a bundle cheat sheet body. |
73
+ | `recall_memory` | BM25 search across the local Kodelyth memory store. |
74
+ | `capture_memory` | Append a new memory entry (problem + approach + tags). |
75
+ | `memory_stats` | Summary of the local memory store. |
76
+ | `catalog_stats` | Summary of how many agents/skills/commands/rules/bundles are loaded. |
77
+ | `audit_skill_match` | Suggest skills whose description/body overlap a task — useful for deciding which skills to attach as context. |
78
+
79
+ All tool results follow the MCP `{ content: [{ type: 'text', text: ... }], isError? }` shape. Most return JSON-encoded payloads inside the text channel.
80
+
81
+ ### Prompts (6)
82
+
83
+ Prompts let clients summon canonical ECC context blocks by name, no tool call needed.
84
+
85
+ | Name | Returns |
86
+ |---|---|
87
+ | `routing-rule` | The full ECC intent routing rule (10-tier priority system). |
88
+ | `agents-overview` | Compact list of all 70 agents with one-line descriptions. |
89
+ | `skills-overview` | Compact list of all 194 skills. |
90
+ | `commands-overview` | Compact list of all 97 slash commands. |
91
+ | `handoff-chains` | The `agent-handoff` skill body — standard multi-agent chains for new feature, bug fix, refactor, incident, etc. |
92
+ | `devil-mode` | The `/devil-mode` parallel command — fires the adversarial red-team crew. |
93
+
94
+ ### Resources (365)
95
+
96
+ Every agent, skill, command, rule, and bundle is also addressable as an MCP resource:
97
+
98
+ ```
99
+ kodelyth://agents/<name>
100
+ kodelyth://skills/<name>
101
+ kodelyth://commands/<name>
102
+ kodelyth://rules/<name>
103
+ kodelyth://bundles/<name>
104
+ ```
105
+
106
+ All resources are `text/markdown`. Use `resources/list` to discover, `resources/read` to fetch.
107
+
108
+ ---
109
+
110
+ ## Example session
111
+
112
+ ```jsonc
113
+ // → client
114
+ { "jsonrpc": "2.0", "id": 1, "method": "initialize",
115
+ "params": { "protocolVersion": "2024-11-05", "capabilities": {},
116
+ "clientInfo": { "name": "my-client", "version": "0.1.0" } } }
117
+
118
+ // ← server
119
+ { "jsonrpc": "2.0", "id": 1, "result": {
120
+ "protocolVersion": "2024-11-05",
121
+ "capabilities": { "tools": {}, "resources": {}, "prompts": {} },
122
+ "serverInfo": { "name": "kodelyth-ecc", "version": "1.7.0" } } }
123
+
124
+ // → client
125
+ { "jsonrpc": "2.0", "id": 2, "method": "tools/call",
126
+ "params": { "name": "route_intent",
127
+ "arguments": { "message": "production is down and i don't know why",
128
+ "top_k": 3 } } }
129
+
130
+ // ← server (paraphrased)
131
+ { "result": { "content": [{ "type": "text", "text":
132
+ "{ \"suggestions\": [
133
+ { \"agent\": \"incident-commander\", ... },
134
+ { \"agent\": \"debug-detective\", ... },
135
+ { \"agent\": \"silent-failure-hunter\", ... }
136
+ ] }" }] } }
137
+ ```
138
+
139
+ ---
140
+
141
+ ## Design notes
142
+
143
+ - **Pure file reads + memory passthrough.** The server adds no LLM calls of its own. It surfaces ECC context; your client's model decides what to do with it.
144
+ - **No telemetry, no network egress.** stdio only. Local memory only. Reads from this repo's checked-in markdown.
145
+ - **Lazy SDK load.** The MCP SDK is an `optionalDependency` so installs work without it; the `mcp` subcommand prints a friendly install hint if missing.
146
+ - **Cached catalog.** Agent/skill/command lists are cached in-process after first read for sub-millisecond subsequent calls.
147
+ - **Memory store is project-aware.** `recall_memory` accepts an optional `project_root` to scope BM25 results to memories captured against that project, falling back to global memories if scoped results are sparse.
148
+
149
+ ---
150
+
151
+ ## Privacy & safety
152
+
153
+ - The server only reads files under this package and the local memory directory (default `~/.kodelyth/memory/`, override via `KODELYTH_MEMORY_DIR`).
154
+ - It writes only when the client invokes `capture_memory`.
155
+ - No network calls. No analytics. No phone-home.
156
+ - The server never executes arbitrary commands or code. Tools that surface code (`get_agent`, etc.) return markdown documentation, not executable instructions.
157
+
158
+ ---
159
+
160
+ ## Troubleshooting
161
+
162
+ **"Kodelyth MCP server requires `@modelcontextprotocol/sdk`"** — run `npm install @modelcontextprotocol/sdk` once, or rerun via `npx -y kodelyth-ecc mcp` to let npm fetch optional deps.
163
+
164
+ **Empty results from `recall_memory` on a fresh memory store** — BM25 needs a few documents before IDF scores rise above the default `minScore` floor. Capture 2-3 memories first.
165
+
166
+ **Resources missing in your client UI** — some MCP clients render only tools and prompts. Resources are still queryable via `resources/list`.
167
+
168
+ ---
169
+
170
+ ## Roadmap interactions
171
+
172
+ - **Phase 2.5 — MCP client mode** will add the inverse: ECC agents consuming external MCP servers (Stripe, GitHub, Postgres, Brave, etc.) — making ECC the MCP **hub**, not just a node.
173
+ - **Phase 2.3 — local dashboard** will visualize live MCP traffic so you can see which tools/prompts/resources clients hit, in real time.
174
+ - **Phase 2.10 — prompt-injection guardrail** will sit in front of MCP responses to scrub jailbreak patterns before they reach client models.
175
+
176
+ ---
177
+
178
+ Built into [Kodelyth ECC](../README.md). MIT licensed. PRs welcome.