kodelyth-ecc 2.4.4 → 2.4.5

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/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  All notable changes to Kodelyth ECC are documented here.
4
4
 
5
+ ## v2.4.5 — Real-user audit: auto-capture never captured anything (July 2026)
6
+
7
+ Third "installed but dummy" feature found in the audit — and the biggest. **The entire memory-capture side was dead.**
8
+
9
+ ### Fixed
10
+
11
+ - **`scripts/memory/extract.js` mined ZERO candidates from real transcripts.** Real Claude Code transcript events nest `role`, `content`, and tool calls under `.message` (e.g. `event.message.role`, `content[].type === 'tool_use'`). `extractCandidates()` read flat `ev.role` / `ev.tool_name` / `ev.tool_input`, so it skipped every event and never captured a single memory. The 52 memories in the store came from seeds and MCP `capture_memory` — the automatic Stop-hook capture had **never worked** on real data.
12
+ - **Fix**: `readTranscript()` now normalizes every raw event to the flat shape downstream code expects — resolving `role` from `message.role`, surfacing the first `tool_use` as `tool_name`/`tool_input`, and exposing `tool_result` output for success scoring. Verified: a real transcript now mines **12 candidates** (was 0); the full `capture-stop` hook queues 3 to `pending-review.jsonl` end-to-end.
13
+ - **Bonus quality fix**: `approach` extraction now finds the last assistant message *with text*, skipping trailing `tool_use`/`tool_result` events that carry no explanation. Previously a fix followed by a tool call produced an empty approach and got dropped.
14
+
15
+ ### Added
16
+
17
+ - **`tests/memory/extract.test.js`** — `extract.js` was completely untested, which is exactly how this shipped. New tests cover: nested-message mining, no-success-signal → no capture, legacy flat shape still works, and empty/malformed safety.
18
+
19
+ ### Impact
20
+
21
+ Memory now works **both ways** for real users: recall (fixed in 2.4.3) AND capture (fixed here). Before this session, a fresh install's memory system was effectively write-nothing / read-crash.
22
+
5
23
  ## v2.4.4 — Real-user audit: prompt-injection guard was a silent no-op (July 2026)
6
24
 
7
25
  Phase 1 of the real-user audit — firing every hook with realistic input instead of fixtures. Found a second "installed but dummy" feature.
package/VERSION CHANGED
@@ -1 +1 @@
1
- 2.4.4
1
+ 2.4.5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kodelyth-ecc",
3
- "version": "2.4.4",
3
+ "version": "2.4.5",
4
4
  "description": "Production-grade AI coding toolkit — 70 agents (incl. devil-mode adversarial crew), 194 skills, 97 commands, parallel multi-agent commands, semantic intent routing, self-learning memory, and a built-in MCP server (16 tools / 6 prompts / 377 resources) that bridges to Claude Desktop, LangGraph, AutoGen, CrewAI, and OpenAI Agents SDK. Works with Claude Code, Windsurf, Cursor, Codex, Antigravity, OpenCode, Cline, RooCode, Aider, Kimi, and Gemini CLI.",
5
5
  "author": "Kodelyth <github.com/sifxprime>",
6
6
  "license": "MIT",
@@ -36,12 +36,54 @@ const FAILURE_PHRASES = [
36
36
  /\bsame error\b/i,
37
37
  ];
38
38
 
39
+ // Real Claude Code transcript events nest role/content/tool info under
40
+ // `.message`; tool calls live as `content[].type === 'tool_use'` and tool
41
+ // results come back in the next user message as `content[].type === 'tool_result'`.
42
+ // Downstream code reads flat `ev.role`, `ev.tool_name`, `ev.tool_input`,
43
+ // `ev.content` — so we normalise every raw event to that flat shape. Without
44
+ // this, extractCandidates() skips every event and auto-capture never fires.
45
+ function normalizeEvent(raw) {
46
+ if (!raw || typeof raw !== 'object') return null;
47
+ const msg = raw.message && typeof raw.message === 'object' ? raw.message : null;
48
+
49
+ // role: prefer message.role, fall back to the top-level `type` (user/assistant)
50
+ const role = (msg && msg.role) || (raw.role) ||
51
+ (raw.type === 'user' || raw.type === 'assistant' ? raw.type : undefined);
52
+
53
+ // content: keep whatever extractText already understands (string | array | message)
54
+ const content = (msg && msg.content !== undefined) ? msg.content : raw.content;
55
+
56
+ const out = { ...raw, role, content };
57
+
58
+ // tool_use: surface the FIRST tool call in an assistant message as
59
+ // ev.tool_name / ev.tool_input so the flat readers see it.
60
+ if (Array.isArray(content)) {
61
+ const toolUse = content.find(c => c && c.type === 'tool_use');
62
+ if (toolUse) {
63
+ out.tool_name = toolUse.name;
64
+ out.tool_input = toolUse.input || {};
65
+ }
66
+ // tool_result carries command output (exit codes, "tests passed", etc.)
67
+ const toolResult = content.find(c => c && c.type === 'tool_result');
68
+ if (toolResult && !out.tool_name) {
69
+ const rc = toolResult.content;
70
+ out._toolResultText = typeof rc === 'string'
71
+ ? rc
72
+ : Array.isArray(rc) ? rc.map(x => (typeof x === 'string' ? x : x?.text || '')).join('\n') : '';
73
+ }
74
+ }
75
+ return out;
76
+ }
77
+
39
78
  function readTranscript(jsonlPath) {
40
79
  if (!fs.existsSync(jsonlPath)) return [];
41
80
  const lines = fs.readFileSync(jsonlPath, 'utf8').split('\n').filter(Boolean);
42
81
  const events = [];
43
82
  for (const line of lines) {
44
- try { events.push(JSON.parse(line)); } catch { /* skip malformed */ }
83
+ try {
84
+ const norm = normalizeEvent(JSON.parse(line));
85
+ if (norm) events.push(norm);
86
+ } catch { /* skip malformed */ }
45
87
  }
46
88
  return events;
47
89
  }
@@ -49,11 +91,15 @@ function readTranscript(jsonlPath) {
49
91
  function extractText(event) {
50
92
  if (typeof event.content === 'string') return event.content;
51
93
  if (Array.isArray(event.content)) {
52
- return event.content
94
+ const text = event.content
53
95
  .filter(c => c && (c.type === 'text' || typeof c.text === 'string'))
54
96
  .map(c => c.text || '')
55
97
  .join('\n');
98
+ if (text) return text;
99
+ // tool_result content (command output) — used for success scoring
100
+ if (event._toolResultText) return event._toolResultText;
56
101
  }
102
+ if (event._toolResultText) return event._toolResultText;
57
103
  if (event.message?.content) return extractText({ content: event.message.content });
58
104
  return '';
59
105
  }
@@ -148,8 +194,15 @@ function extractCandidates(jsonlPath) {
148
194
  .filter(Boolean)
149
195
  )).slice(0, 5);
150
196
 
151
- const lastAssistant = window.reverse().find(e => e.role === 'assistant');
152
- const approach = lastAssistant ? extractText(lastAssistant).slice(0, 600) : null;
197
+ // Find the last assistant message that actually has TEXT — skip trailing
198
+ // tool_use/tool_result events which carry no explanation of the fix.
199
+ const reversed = window.slice().reverse();
200
+ let approach = null;
201
+ for (const e of reversed) {
202
+ if (e.role !== 'assistant') continue;
203
+ const t = extractText(e).trim();
204
+ if (t) { approach = t.slice(0, 600); break; }
205
+ }
153
206
 
154
207
  if (!problem || !approach) continue;
155
208