kodelyth-ecc 1.4.0 → 1.5.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.
@@ -1,101 +1,196 @@
1
1
  # Hook Reference
2
2
 
3
- Hooks run automatically in the background after install. Zero configuration required.
3
+ Hooks run automatically in the background. Zero configuration required after install.
4
4
 
5
5
  ---
6
6
 
7
- ## How Hooks Work
8
-
9
- Hooks are lifecycle triggers that fire before or after Claude Code actions:
7
+ ## Hook Types
10
8
 
11
9
  | Type | When it fires |
12
- |------|--------------|
13
- | `PreToolUse` | Before a tool executes |
10
+ |---|---|
11
+ | `SessionStart` | At the beginning of every AI session |
12
+ | `UserPromptSubmit` | Before the AI processes each message you type |
13
+ | `PreToolUse` | Before a tool (Bash, Edit, Write, etc.) executes |
14
14
  | `PostToolUse` | After a tool executes |
15
- | `Stop` | When the session ends |
15
+ | `Stop` | When the AI session ends |
16
+
17
+ ---
18
+
19
+ ## Memory Hooks (v1.4.0+)
20
+
21
+ These three hooks form the self-learning memory system. All are async, non-blocking, and exit 0 on any error.
22
+
23
+ ### `hooks/memory/inject-start.js`
16
24
 
17
- Hooks never block the user — they run async and notify when relevant.
25
+ **Type:** SessionStart
26
+ **Hook ID:** `kodelyth:session:start:memory-inject`
27
+
28
+ Fires at the start of every session. Reads the session's working directory, searches your memory store for relevant past solutions, and injects them as `additionalContext` into the session before the first prompt.
29
+
30
+ **What it injects:**
31
+ - Your recent patterns and tag associations
32
+ - Recent project-specific memories (last 3)
33
+ - Query-relevant memories (scored by BM25, top 5)
34
+
35
+ **Structure:** Stable prefix (patterns + recent project mems) → variable suffix (query-relevant). The stable prefix is designed to hit Anthropic's 5-minute prompt cache.
36
+
37
+ **Behavior on empty memory:** Outputs nothing — doesn't inject an empty block.
18
38
 
19
39
  ---
20
40
 
21
- ## Core Hooks (always active)
41
+ ### `hooks/memory/auto-recall.js`
42
+
43
+ **Type:** UserPromptSubmit
44
+ **Hook ID:** `kodelyth:user-prompt:memory-auto-recall`
45
+
46
+ Fires before the AI processes each message you type (Claude Code only — other platforms don't currently expose a `UserPromptSubmit` hook).
22
47
 
23
- | Hook | Trigger | What it does |
24
- |------|---------|-------------|
25
- | Session start | Session begins | Loads context from previous session |
26
- | Pre-commit | `git commit` | Catches `console.log`, secrets, bad commit messages |
27
- | Quality gate | After any file edit | Runs type checks + formatting |
28
- | Git push reminder | Before `git push` | Prompts for review |
29
- | Config protection | Config file edits | Blocks weakening linter/formatter settings |
30
- | Cost tracker | End of session | Logs token usage per session |
31
- | Desktop notify | Long task completes | macOS notification when Claude finishes |
32
- | MCP health check | Before MCP call | Validates MCP servers are reachable |
48
+ **Smart skip filters:**
49
+ - Empty prompt → skip
50
+ - Trivial responses (`ok`, `yes`, `no`, `thanks`, `cool`, `done`, `great`, `got it`, `sure`, `k`) → skip
51
+ - Agent/command invocations (`use X`, `@agent`, `/command`, `invoke X`) skip
52
+ - Prompts under 12 characters skip
53
+ - Fewer than 2 meaningful tokens after stop-word removal skip
54
+
55
+ **Repeat suppression:** Tracks which memory IDs were surfaced in the current session (`session-surfaced-<sessionId>.json`). Never surfaces the same memory twice in one session.
56
+
57
+ **Threshold:** `MIN_SCORE = 1.0` (higher than session-start inject auto-recall is selective).
58
+
59
+ **Output format:** JSON with `additionalContext` (markdown block) and `meta` (source, session ID, recalled count).
33
60
 
34
61
  ---
35
62
 
36
- ## Kodelyth Hooks (v1.1.0)
63
+ ### `hooks/memory/capture-stop.js`
37
64
 
38
- ### `test-reminder`
65
+ **Type:** Stop
66
+ **Hook ID:** `kodelyth:stop:memory-capture`
39
67
 
40
- **Trigger:** After any code file is edited without touching a test file
68
+ Fires when the session ends. Finds the latest Claude session JSONL file, runs the heuristic extractor (`scripts/memory/extract.js`) over it, and writes learning candidates to `~/.kodelyth/memory/pending-review.jsonl`.
41
69
 
42
- **What it does:** Flags that tests may need to be written or updated
70
+ **Important:** This hook NEVER auto-stores anything. It only extracts candidates. You review and confirm before anything enters the memory store.
43
71
 
72
+ **What it extracts:** Looks for message pairs where the AI used `SUCCESS_PHRASES` (worked, fixed, resolved, solved) and `FAILURE_PHRASES` (failed, broken, error, doesn't work), plus explicit problem/solution structure. Scores candidates on length, specificity, and context quality.
73
+
74
+ **Advisory output:** Prints a message to stderr like:
44
75
  ```
45
- [test-reminder] Code edited but no test file was touched.
46
- Consider: Does this change need test coverage?
76
+ [kodelyth-memory] 2 learning candidate(s) pending review. Run /memory review-pending.
47
77
  ```
48
78
 
49
79
  ---
50
80
 
51
- ### `smart-suggest`
81
+ ## Quality Gate Hooks (v1.1.0+)
82
+
83
+ ### `hooks/test-reminder`
84
+
85
+ **Type:** PostToolUse — Edit, Write, MultiEdit
86
+ **Hook ID:** `kodelyth:post-tool:edit:test-reminder`
52
87
 
53
- **Trigger:** After each Claude Code response
88
+ After editing a code file, checks if a corresponding test file was also touched in the session. If not, posts a non-blocking reminder box to stderr.
54
89
 
55
- **What it does:** Detects signals in the session and suggests the next logical agent
90
+ **Language coverage:** `.ts`, `.tsx`, `.js`, `.jsx`, `.py`, `.go`, `.rs`, `.java`, `.rb`, `.php`
56
91
 
57
- Examples:
58
- - Sees a bug → suggests `debug-detective`
59
- - Sees API changes → suggests `api-guardian`
60
- - Sees frontend code → suggests `ux-reviewer`
61
- - Sees security-sensitive code → suggests `security-reviewer`
92
+ **Timeout:** 5 seconds (async, never delays tool execution)
93
+
94
+ **Disable:**
95
+ ```bash
96
+ export ECC_DISABLED_HOOKS=kodelyth:test-reminder
97
+ ```
62
98
 
63
99
  ---
64
100
 
65
- ### `branch-name-check`
101
+ ### `hooks/smart-suggest`
102
+
103
+ **Type:** Stop
104
+ **Hook ID:** `kodelyth:stop:smart-suggest`
66
105
 
67
- **Trigger:** Before `git checkout -b` (creating a new branch)
106
+ After each AI response, analyzes session signals and suggests the next logical agent. Eight detection rules:
68
107
 
69
- **What it does:** Blocks branches that don't follow the naming convention
108
+ | Signal | Suggestion |
109
+ |---|---|
110
+ | Error keywords in response | → debug-detective |
111
+ | "Looks good" / approval phrases | → code-reviewer |
112
+ | Migration or upgrade terms | → migration-guide |
113
+ | API endpoint changes | → api-guardian |
114
+ | Performance concerns | → performance-optimizer |
115
+ | Test failures | → tdd-guide |
116
+ | Security-sensitive code | → security-reviewer |
117
+ | Git operation just completed | → code-reviewer |
70
118
 
71
- **Valid patterns:**
119
+ **Output:** Non-blocking advisory to stderr. Never interrupts the session.
120
+
121
+ **Disable:**
122
+ ```bash
123
+ export ECC_DISABLED_HOOKS=kodelyth:smart-suggest
72
124
  ```
73
- feat/add-user-auth
74
- fix/login-redirect-loop
125
+
126
+ ---
127
+
128
+ ### `hooks/branch-name-check`
129
+
130
+ **Type:** PreToolUse — Bash
131
+ **Hook ID:** `kodelyth:pre-tool:bash:branch-name`
132
+
133
+ Intercepts `git checkout -b` and `git switch -c` commands. Validates the branch name against:
134
+
135
+ ```
136
+ ^(feat|fix|chore|docs|refactor|test|perf|ci|hotfix|release|experiment|spike|wip)\/[a-z0-9][a-z0-9-._/]{1,60}$
137
+ ```
138
+
139
+ Valid examples:
140
+ ```
141
+ feat/add-stripe-webhooks
142
+ fix/auth-token-expiry
75
143
  chore/update-dependencies
76
144
  refactor/extract-payment-service
77
- docs/api-reference-update
78
- test/coverage-auth-module
79
145
  ```
80
146
 
81
- **Blocked patterns:**
82
- ```
83
- my-branch
84
- update
85
- wip
86
- temp123
87
- NEW_FEATURE
147
+ **On violation:** Blocks with exit code 2, clear explanation, and valid examples shown.
148
+
149
+ **Disable:**
150
+ ```bash
151
+ export ECC_DISABLED_HOOKS=kodelyth:branch-name
88
152
  ```
89
153
 
90
154
  ---
91
155
 
92
- ## Hook File Location
156
+ ## Hook Configuration
93
157
 
94
- After install:
158
+ All hooks are registered in `~/.claude/hooks/hooks.json`. After install, it contains entries for all three memory hooks plus the quality gate hooks.
95
159
 
160
+ **View registered hooks:**
161
+ ```bash
162
+ cat ~/.claude/hooks/hooks.json
96
163
  ```
97
- ~/.claude/hooks/hooks.json ← Claude Code
98
- .agent/rules/ ← Google Antigravity (rules-based, no hook engine)
164
+
165
+ **Disable multiple hooks:**
166
+ ```bash
167
+ export ECC_DISABLED_HOOKS=kodelyth:smart-suggest,kodelyth:test-reminder,kodelyth:branch-name
99
168
  ```
100
169
 
101
- Note: Google Antigravity does not have a hook execution engine. Hook behavior for Antigravity is approximated via always-on rules in `.agent/rules/kodelyth-always-on.md`.
170
+ **Disable all ECC hooks:**
171
+ ```bash
172
+ export ECC_DISABLED_HOOKS=kodelyth:all
173
+ ```
174
+
175
+ ---
176
+
177
+ ## Hook Safety Design
178
+
179
+ All ECC hooks follow these rules:
180
+
181
+ 1. **Always exit 0** — hooks never block a session or tool execution due to an error
182
+ 2. **Timeout 5 seconds** — hooks that take longer are killed
183
+ 3. **Async only** — hooks run in background, never synchronously blocking tool execution
184
+ 4. **Stderr for advisories** — hook output goes to stderr, never stdout (which the AI reads)
185
+ 5. **Stdin for context** — hooks receive session context as JSON on stdin
186
+ 6. **No auto-modification** — hooks never modify files without explicit user confirmation
187
+
188
+ ---
189
+
190
+ ## Writing Custom Hooks
191
+
192
+ Hook ID naming convention: `kodelyth:{phase}:{matcher}:{name}`
193
+
194
+ Example phases: `session`, `user-prompt`, `pre-tool`, `post-tool`, `stop`
195
+
196
+ See [CONTRIBUTING.md](https://github.com/sifxprime/kodelyth-ecc/blob/main/CONTRIBUTING.md) for the hook script template and all safety requirements.
@@ -2,125 +2,206 @@
2
2
 
3
3
  ---
4
4
 
5
- ## Claude Code
5
+ ## Requirements
6
6
 
7
- ### macOS / Linux (one-liner)
7
+ - **Node.js 18+** (all install methods except manual git clone)
8
+ - Any supported AI coding platform (see [Platform Support](Platform-Support))
9
+
10
+ ---
11
+
12
+ ## Method 1 — npx (Recommended)
13
+
14
+ Runs from anywhere. No clone required.
8
15
 
9
16
  ```bash
10
- curl -fsSL https://raw.githubusercontent.com/sifxprime/kodelyth-ecc/main/install.sh | bash
17
+ npx kodelyth-ecc
11
18
  ```
12
19
 
13
- ### Or clone and install manually
20
+ **With a specific target:**
14
21
 
15
22
  ```bash
16
- git clone https://github.com/sifxprime/kodelyth-ecc.git
17
- cd kodelyth-ecc
18
- ./install.sh
23
+ npx kodelyth-ecc --target windsurf-project
24
+ npx kodelyth-ecc --target cursor-project
25
+ npx kodelyth-ecc --target antigravity
19
26
  ```
20
27
 
21
- ### Windows (PowerShell)
28
+ **With a language profile:**
22
29
 
23
- ```powershell
24
- git clone https://github.com/sifxprime/kodelyth-ecc.git
25
- cd kodelyth-ecc
26
- .\install.ps1
30
+ ```bash
31
+ npx kodelyth-ecc --profile nextjs
32
+ npx kodelyth-ecc --profile fullstack --target claude-home
27
33
  ```
28
34
 
29
- When complete, you will see:
35
+ ---
36
+
37
+ ## Method 2 — curl (macOS / Linux)
30
38
 
31
- ```
32
- ARMED AND OPERATIONAL.
39
+ ```bash
40
+ curl -fsSL https://raw.githubusercontent.com/sifxprime/kodelyth-ecc/main/install.sh | bash
33
41
  ```
34
42
 
35
- Agents are now available globally in every Claude Code session.
43
+ **With options:**
44
+
45
+ ```bash
46
+ curl -fsSL https://raw.githubusercontent.com/sifxprime/kodelyth-ecc/main/install.sh | bash -s -- --target windsurf-home
47
+ curl -fsSL https://raw.githubusercontent.com/sifxprime/kodelyth-ecc/main/install.sh | bash -s -- --profile python-api
48
+ ```
36
49
 
37
50
  ---
38
51
 
39
- ## Google Antigravity
52
+ ## Method 3 — PowerShell (Windows)
40
53
 
41
- ```bash
42
- git clone https://github.com/sifxprime/kodelyth-ecc.git
43
- cd kodelyth-ecc
44
- ./install.sh --target antigravity
54
+ ```powershell
55
+ irm https://raw.githubusercontent.com/sifxprime/kodelyth-ecc/main/install.ps1 | iex
45
56
  ```
46
57
 
47
- This installs everything into your project's `.agent/` directory:
58
+ **With options:**
48
59
 
60
+ ```powershell
61
+ & ([scriptblock]::Create((irm https://raw.githubusercontent.com/sifxprime/kodelyth-ecc/main/install.ps1))) --target windsurf-project
49
62
  ```
50
- your-project/
51
- └── .agent/
52
- ├── rules/ ← coding standards + always-on ECC behavior
53
- ├── workflows/ ← 79 slash commands
54
- └── skills/ ← all 53 agents
63
+
64
+ ---
65
+
66
+ ## Method 4 GitHub (no npm registry)
67
+
68
+ ```bash
69
+ npx github:sifxprime/kodelyth-ecc
55
70
  ```
56
71
 
57
- The file `.agent/rules/kodelyth-always-on.md` loads ECC behavior automatically every session no prompt required.
72
+ Use this if you prefer to pull directly from the repository without going through npm.
58
73
 
59
74
  ---
60
75
 
61
- ## Other Platforms
76
+ ## Install Targets
77
+
78
+ | Target | Installs to | Platform |
79
+ |---|---|---|
80
+ | `claude-home` | `~/.claude/` | Claude Code (global) |
81
+ | `antigravity` | `~/.config/google-gemini/` | Google Antigravity |
82
+ | `windsurf-project` | `.windsurf/` + `.windsurfrules` | Windsurf (project) |
83
+ | `windsurf-home` | `~/.codeium/windsurf/` | Windsurf (global) |
84
+ | `cursor-project` | `.cursor/` | Cursor (project) |
85
+ | `codex-home` | `~/.codex/` | Codex CLI |
86
+ | `opencode` | `~/.opencode/` | OpenCode |
62
87
 
63
- | Platform | Command |
64
- |----------|---------|
65
- | Cursor | `./install.sh --target cursor-project` |
66
- | Codex CLI | `./install.sh --target codex-home` |
67
- | OpenCode | `./install.sh --target opencode` |
88
+ If you don't specify `--target`, the installer detects your platform and asks.
68
89
 
69
90
  ---
70
91
 
71
- ## Install Profiles (Language Bundles)
92
+ ## Install Profiles
72
93
 
73
- Pre-built rule bundles for common stacks:
94
+ Profiles add language-specific rule modules on top of the base install.
95
+
96
+ | Profile | Languages added |
97
+ |---|---|
98
+ | `--profile nextjs` | TypeScript |
99
+ | `--profile python-api` | Python |
100
+ | `--profile fullstack` | TypeScript + Python + Go |
101
+ | `--profile mobile` | Kotlin + Swift |
102
+ | `--profile backend` | Go + Python + Java |
103
+
104
+ ---
105
+
106
+ ## What the Installer Does
107
+
108
+ 1. Detects or accepts target platform
109
+ 2. Creates target directory if it doesn't exist
110
+ 3. Copies agents, skills, commands, hooks, and rules
111
+ 4. Sets up memory hook entries in `hooks.json`
112
+ 5. Installs language modules if `--profile` is set
113
+ 6. Writes install state to `kodelyth-ecc-install-state.json`
114
+ 7. Prints confirmation with component counts
115
+
116
+ ---
117
+
118
+ ## After Install — Claude Code
119
+
120
+ Verify the install:
121
+
122
+ ```bash
123
+ ls ~/.claude/agents/ | wc -l # should be 59+
124
+ ls ~/.claude/hooks/memory/ # should show 3 hook files
125
+ cat ~/.claude/hooks/hooks.json # verify memory hooks are registered
126
+ ```
127
+
128
+ Run tests:
74
129
 
75
130
  ```bash
76
- ./install.sh --profile nextjs # TypeScript + React + Next.js
77
- ./install.sh --profile python-api # Python + Django/FastAPI
78
- ./install.sh --profile fullstack # TypeScript + Python + Go
79
- ./install.sh --profile mobile # Kotlin + Swift
80
- ./install.sh --profile backend # Go + Python + Java
131
+ cd /path/to/kodelyth-ecc && npm test # 47 tests, all passing
81
132
  ```
82
133
 
83
134
  ---
84
135
 
85
- ## After Install — First Steps
136
+ ## After Install — Windsurf
86
137
 
87
- ### Claude Code
138
+ For `windsurf-project`, a `.windsurfrules` file is generated in the current directory. Cascade loads this file automatically.
139
+
140
+ For `windsurf-home`, rules are installed globally and apply to all projects.
141
+
142
+ ---
143
+
144
+ ## After Install — Antigravity
145
+
146
+ Rules are flattened (no subdirectories) to match Antigravity's required format. The `.agent/` layout is generated:
88
147
 
89
148
  ```
90
- /kodelyth-quickstart
149
+ .agent/rules/ → 16 rule files (flattened)
150
+ .agent/workflows/ → 80 command workflows
151
+ .agent/skills/ → 59 agent definitions
91
152
  ```
92
153
 
93
- This loads the plain-language getting-started guide.
154
+ ---
94
155
 
95
- ### Google Antigravity
156
+ ## Memory System Setup
96
157
 
97
- Type in any project:
158
+ The memory system activates automatically after install. On first session:
98
159
 
160
+ 1. `inject-start.js` runs but finds no memories yet — that's fine
161
+ 2. You do your work
162
+ 3. `capture-stop.js` runs at session end and extracts candidates to `~/.kodelyth/memory/pending-review.jsonl`
163
+ 4. Review candidates: `/memory review-pending` or `node scripts/memory/cli.js list`
164
+ 5. Confirm what to store: `/memory remember "title" --approach "..." --tags tag1,tag2`
165
+ 6. Future sessions inject and auto-recall what you stored
166
+
167
+ **Override memory location:**
168
+
169
+ ```bash
170
+ export KODELYTH_MEMORY_DIR=/path/to/your/memory
99
171
  ```
100
- /kodelyth-quickstart
101
- ```
102
172
 
103
- Or just start working — kodelyth-always-on.md auto-loads ECC behavior every session.
173
+ ---
174
+
175
+ ## Updating
176
+
177
+ Re-run the same install command. The installer is idempotent — existing files are overwritten with the latest version.
178
+
179
+ ```bash
180
+ npx kodelyth-ecc@latest
181
+ ```
104
182
 
105
183
  ---
106
184
 
107
- ## What Gets Installed
185
+ ## Uninstalling
108
186
 
109
- ### Claude Code (`~/.claude/`)
187
+ Remove the installed directories:
110
188
 
111
- | Source | Destination |
112
- |--------|------------|
113
- | `agents/` | `~/.claude/agents/` |
114
- | `skills/` | `~/.claude/skills/` |
115
- | `hooks/hooks.json` | `~/.claude/hooks/` |
116
- | `rules/` | `~/.claude/rules/` |
117
- | `commands/` | `~/.claude/commands/` |
189
+ ```bash
190
+ # Claude Code
191
+ rm -rf ~/.claude/agents ~/.claude/skills ~/.claude/commands ~/.claude/hooks/memory
192
+ rm -f ~/.claude/rules/common/agent-intent-routing.md
193
+ rm -f ~/.claude/rules/common/memory-protocol.md
118
194
 
119
- ### Antigravity (`.agent/` in project root)
195
+ # Memory data (separate only remove if you want to clear memory)
196
+ rm -rf ~/.kodelyth/memory/
197
+ ```
198
+
199
+ ---
200
+
201
+ ## CI / Non-interactive Environments
120
202
 
121
- | Source | Destination |
122
- |--------|------------|
123
- | `agents/` | `.agent/skills/` |
124
- | `commands/` | `.agent/workflows/` |
125
- | `rules/` | `.agent/rules/` |
126
- | Kodelyth skills (flattened) | `.agent/rules/` |
203
+ The installer detects non-interactive environments (no `/dev/tty`) and auto-accepts defaults. Set `--target` explicitly to avoid prompts:
204
+
205
+ ```bash
206
+ npx kodelyth-ecc --target claude-home --profile fullstack
207
+ ```