@eltonssouza/development-utility-kit 0.10.1 → 0.12.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,394 +0,0 @@
1
- # Honcho Memory
2
-
3
- Persistent cross-session memory for Claude Code, anchored on **Honcho v3 self-hosted**. Memories survive across sessions, projects, and machines. When relevant, they are injected automatically into the system prompt of every turn through the `[HONCHO MEMORY]` block, so the user does not have to re-explain preferences.
4
-
5
- The integration runs as a pair of Claude Code hooks (`UserPromptSubmit` and `Stop`) and degrades gracefully: if the Honcho server is offline, the hook times out, returns exit 0, and Claude proceeds without the memory block. The main flow never blocks.
6
-
7
- Audience: Java/Angular developers who want the assistant to "remember" style rules, stack decisions, and feature context without reopening documents every session.
8
-
9
- ---
10
-
11
- ## Flow overview
12
-
13
- ```
14
- user prompt
15
- |
16
- v
17
- UserPromptSubmit hook (on-prompt-submit.js)
18
- |
19
- |-- trigger detected? ("lembra que", "remember that", "never ...", "always ...")
20
- | |
21
- | v
22
- | SAVE explicit (POST /v3/.../messages, metadata.type = "explicit")
23
- |
24
- |-- hybrid search in Promise.all (timeoutMs default = 450ms)
25
- | |
26
- | |-- peer-scoped (POST /peers/{peer}/search) -> cross-project explicit + inferred
27
- | |-- session-scoped (POST /sessions/{id}/messages/list) -> project-context
28
- |
29
- |-- merge by relevance, cap topN + 2000 chars
30
- |
31
- v
32
- stdout: [HONCHO MEMORY] ... [/HONCHO MEMORY] -> injected into system prompt
33
- |
34
- v
35
- Claude responds
36
- |
37
- v
38
- Stop hook (on-stop.js)
39
- |
40
- v
41
- extracts feature/sprint from CLAUDE.md + git log -3
42
- |
43
- v
44
- SAVE project-context (POST /v3/.../messages, metadata.type = "project-context")
45
- ```
46
-
47
- Hooks are registered in `~/.claude/settings.json` (global), pointing to `C:/development/tools/development-utility-kit/.claude/skills/honcho-memory/hooks/`. Forward-slash paths — accepted by the Claude Code hook runner on Windows.
48
-
49
- ---
50
-
51
- ## Memory types
52
-
53
- The `type` metadata on every message saved to Honcho controls scope, source and visibility.
54
-
55
- | Type | Scope | Source | When it is created |
56
- |---|---|---|---|
57
- | `explicit` | Peer (cross-project) | User | Triggered by verbal patterns ("lembra que", "remember that", "memoriza", "never ...", "always ...") |
58
- | `inferred` | Peer (cross-project) | Automatic hook (v2) | **Disabled by default in v1** — stub for `PLAN_honcho-inference.md`. When `inferenceEnabled: true`, `on-stop.js` only writes `HONCHO_INFO` to stderr and proceeds without inference |
59
- | `project-context` | Session (1 per CWD) | `Stop` hook | At the end of each turn, extracts active feature/sprint from `CLAUDE.md` + last 3 commits |
60
-
61
- The `session ID` is derived deterministically: `sha256(CWD)[:16]`. Each directory is a unique bucket and never rotates — every `project-context` memory for `C:/dev/source/projects/foo/` accumulates in the same session indefinitely.
62
-
63
- ---
64
-
65
- ## Automatic triggers
66
-
67
- Five patterns in the user prompt trigger an **immediate explicit save**, before any search. The save happens with `metadata.type = "explicit"` and `metadata.source = "user"`.
68
-
69
- | Pattern | Language | Example |
70
- |---|---|---|
71
- | `lembra que` | PT | "lembra que prefiro records imutáveis em DTOs Java" |
72
- | `remember that` | EN | "remember that I prefer immutable records" |
73
- | `memoriza` | PT | "memoriza: usar OnPush em todos os componentes Angular" |
74
- | `never ` (start of line) | EN | "never use var in TypeScript" |
75
- | `always ` (start of line) | EN | "always add JSDoc to public methods" |
76
-
77
- Detection is case-insensitive. Matching is done against `prompt.toLowerCase()`.
78
-
79
- Trigger-saved memories are **peer-scoped** — they surface in searches from any project that uses the same `peerName` in `config.json`.
80
-
81
- ---
82
-
83
- ## CLI subcommands
84
-
85
- The CLI lives at `.claude/skills/honcho-memory/scripts/cli.js` and runs via `bun`. The subcommands are also what the user invokes in chat (the skill detects the `/honcho <verb>` pattern and routes to the script).
86
-
87
- ```bash
88
- bun run .claude/skills/honcho-memory/scripts/cli.js <subcommand> [args]
89
- ```
90
-
91
- ### `/honcho save <text>`
92
-
93
- Saves an explicit memory immediately. Prints the message ID.
94
-
95
- ```text
96
- $ /honcho save "prefer Testcontainers in integration, never H2"
97
- saved: msg_01HXY7K9AB...
98
- type: explicit
99
- peer: elton
100
- ```
101
-
102
- ### `/honcho search <query>`
103
-
104
- Peer-scoped semantic search. Returns top-N (default 5) relevant memories. Soft-deleted memories are excluded.
105
-
106
- ```text
107
- $ /honcho search "java DTO"
108
- 1. [explicit | 2026-05-12] Prefer immutable records for DTOs in Java
109
- 2. [explicit | 2026-04-30] Never expose JPA entities directly through the API
110
- 3. [project-context | 2026-05-20] Sprint 3 — refactor backend DTOs to records
111
- ```
112
-
113
- ### `/honcho list`
114
-
115
- Lists every memory in the current session (filtered by `sha256(CWD)[:16]`). Soft-deleted memories do not appear.
116
-
117
- ```text
118
- $ /honcho list
119
- session: a1b2c3d4e5f60718
120
- total: 12 memories
121
-
122
- [project-context | 2026-05-27] Active feature: honcho-memory Sprint 3
123
- [project-context | 2026-05-26] PLAN_honcho-inference seed for v2
124
- [explicit | 2026-05-12] Prefer immutable records for DTOs in Java
125
- ...
126
- ```
127
-
128
- ### `/honcho forget <id>`
129
-
130
- Soft-delete via `PUT`, not `DELETE`. The record stays in the database but is excluded from all future searches and listings.
131
-
132
- ```text
133
- $ /honcho forget msg_01HXY7K9AB
134
- soft-deleted: msg_01HXY7K9AB
135
- method: PUT
136
- endpoint: /v3/workspaces/claude_code/sessions/.../messages/msg_01HXY7K9AB
137
- body: { "metadata": { "deleted": true } }
138
- ```
139
-
140
- Calling `/honcho forget` without an ID returns exit code 1 with usage info.
141
-
142
- ### `/honcho status`
143
-
144
- Shows connection state, count of memories in the current session, config version, and flags.
145
-
146
- ```text
147
- $ /honcho status
148
- connection: OK
149
- endpoint: https://honcho.pazzne.cloud
150
- workspace: claude_code
151
- peer: elton
152
- session: a1b2c3d4e5f60718
153
-
154
- config version: 0.1.0
155
- enabled: true
156
- inferenceEnabled: false
157
- topN: 5
158
- timeoutMs: 450
159
-
160
- session memories: 12
161
- peer memories (sample): 47
162
- ```
163
-
164
- When the server is offline, returns `connection: FAIL` with the reason (timeout, 5xx, DNS).
165
-
166
- ### `/honcho setup`
167
-
168
- Interactive wizard. Verifies connection, reads legacy `memory/*.md` files, shows preview, asks for confirmation, backs up originals to `memory/backup-YYYYMMDD/`, migrates to Honcho and archives the original `.md` files. Idempotent — running it multiple times is safe.
169
-
170
- Dry-run (no writes):
171
-
172
- ```bash
173
- bun run .claude/skills/honcho-memory/scripts/setup.js --dry-run
174
- ```
175
-
176
- ---
177
-
178
- ## The `[HONCHO MEMORY]` block
179
-
180
- When relevant memories exist, the hook writes the block below to stdout. Claude Code consumes that stdout as a system prompt extension for the current turn.
181
-
182
- ```
183
- [HONCHO MEMORY]
184
- type: explicit | project: my-project | 2026-05-26T10:00:00Z
185
- Prefer immutable records for DTOs in Java
186
-
187
- type: project-context | project: development-utility-kit | 2026-05-26T09:00:00Z
188
- Active feature: honcho-memory-skill Sprint 3
189
- [/HONCHO MEMORY]
190
- ```
191
-
192
- Rules:
193
-
194
- - `[HONCHO MEMORY]` and `[/HONCHO MEMORY]` tags are always present (even with an empty list)
195
- - Limit: `topN` memories (default 5)
196
- - Limit: 2,000 characters total — overflow is trimmed
197
- - Ordering: by semantic search relevance (peer) + chronological descending (session)
198
- - Deduplicated by ID before merging
199
-
200
- ---
201
-
202
- ## Configuration
203
-
204
- Config file path:
205
-
206
- - Windows: `C:\Users\<user>\.honcho\config.json`
207
- - macOS/Linux: `~/.honcho/config.json`
208
-
209
- Full structure:
210
-
211
- ```json
212
- {
213
- "apiKey": "<bearer-token — never logged, never committed>",
214
- "peerName": "elton",
215
- "workspace": "claude_code",
216
- "endpoint": {
217
- "baseUrl": "https://honcho.pazzne.cloud"
218
- },
219
- "enabled": true,
220
- "logging": false,
221
- "inferenceEnabled": false,
222
- "topN": 5,
223
- "timeoutMs": 450
224
- }
225
- ```
226
-
227
- Fields:
228
-
229
- | Field | Type | Default | Description |
230
- |---|---|---|---|
231
- | `apiKey` | string | — | Bearer token for authenticating with the Honcho server. Never appears in stdout, stderr or logs. **Never commit.** |
232
- | `peerName` | string | — | Logical user identity in Honcho. `explicit` and `inferred` memories are visible to this peer cross-project |
233
- | `workspace` | string | `claude_code` | Server namespace — multi-tenant separation |
234
- | `endpoint.baseUrl` | string | — | Honcho v3 server base URL |
235
- | `enabled` | boolean | `true` | If `false`, the hook returns immediately without calling the server |
236
- | `logging` | boolean | `false` | Stub for future verbose logging |
237
- | `inferenceEnabled` | boolean | `false` | Stub — when `true`, `on-stop.js` only writes `HONCHO_INFO: inference deferred to v2 PLAN, see PLAN_honcho-inference.md` to stderr |
238
- | `topN` | number | `5` | Cap on memories included in the block |
239
- | `timeoutMs` | number | `450` | Global hook operation timeout. Above this, returns exit 0 with no block |
240
-
241
- ### Env var overrides
242
-
243
- Environment variables take precedence over `config.json` — useful for testing and CI.
244
-
245
- | Env var | Effect |
246
- |---|---|
247
- | `HONCHO_DRY_RUN=1` | Skip real Honcho calls; emit telemetry JSON to stdout for diagnostics |
248
- | `HONCHO_BASE_URL` | Override `endpoint.baseUrl` |
249
- | `HONCHO_TIMEOUT_MS` | Override `timeoutMs` in ms |
250
- | `HONCHO_INFERENCE_ENABLED=true` | Enable the inference stub in `on-stop.js` (writes `HONCHO_INFO`) |
251
-
252
- ---
253
-
254
- ## Initial setup
255
-
256
- Run the interactive wizard:
257
-
258
- ```bash
259
- bun run .claude/skills/honcho-memory/scripts/setup.js
260
- ```
261
-
262
- Steps:
263
-
264
- 1. Verifies connectivity to the Honcho server
265
- 2. Reads legacy `memory/*.md` files, if present
266
- 3. Displays a preview/diff of what will be migrated
267
- 4. Asks for explicit confirmation
268
- 5. Backs up originals to `memory/backup-YYYYMMDD/`
269
- 6. Migrates each `.md` file as an `explicit` message in Honcho
270
- 7. Archives the original `.md` files
271
-
272
- Idempotent — running it more than once does not duplicate. If the server is offline, the wizard aborts with a clear message without touching files.
273
-
274
- Dry-run for diagnostics:
275
-
276
- ```bash
277
- bun run .claude/skills/honcho-memory/scripts/setup.js --dry-run
278
- ```
279
-
280
- ---
281
-
282
- ## Self-hosting Honcho v3
283
-
284
- Honcho v3 is an open-source semantic memory server. The harness does not include the server — it expects it to be reachable at an endpoint (cloud, your own VPS, local container). Consult the official Honcho project documentation for Docker Compose, PostgreSQL/pgvector schema, and auth setup.
285
-
286
- Endpoints used (verified in v3.0.6):
287
-
288
- | Operation | Method | Path |
289
- |---|---|---|
290
- | Create/get session | POST/GET | `/v3/workspaces/{ws}/sessions` |
291
- | Save memory (batch) | POST | `/v3/workspaces/{ws}/sessions/{session}/messages` |
292
- | Soft-delete | PUT | `/v3/workspaces/{ws}/sessions/{session}/messages/{id}` |
293
- | Peer-scoped search | POST | `/v3/workspaces/{ws}/peers/{peer}/search` |
294
- | List session messages | POST | `/v3/workspaces/{ws}/sessions/{session}/messages/list` |
295
- | Delete session (nuke) | DELETE | `/v3/workspaces/{ws}/sessions/{session}` |
296
- | OpenAPI spec | GET | `/openapi.json` (root, not `/v3/openapi.json`) |
297
-
298
- Full catalog in `.claude/skills/honcho-memory/docs/api-endpoints-verified.md`.
299
-
300
- ---
301
-
302
- ## Failure behavior (graceful degradation)
303
-
304
- Scenarios and responses:
305
-
306
- | Scenario | Hook response |
307
- |---|---|
308
- | Honcho offline (DNS, connection refused) | `HONCHO_WARN: <reason>` on stderr, empty stdout, exit 0 |
309
- | HTTP 5xx | `HONCHO_WARN: 5xx <body>` on stderr, empty stdout, exit 0 |
310
- | Timeout (default 450ms) | `HONCHO_WARN: timeout after 450ms` on stderr, empty stdout, exit 0 |
311
- | Missing config | `HONCHO_WARN: config not found` on stderr, empty stdout, exit 0 |
312
- | `enabled: false` in config | No warning, empty stdout, exit 0 |
313
- | Invalid API key (401) | `HONCHO_WARN: 401 unauthorized` on stderr, empty stdout, exit 0 |
314
-
315
- In **every** case Claude Code proceeds normally — no `[HONCHO MEMORY]` block, but no flow disruption.
316
-
317
- Diagnostic telemetry (in `HONCHO_DRY_RUN=1` mode or when future logging is enabled): stdout JSON with `{ peerSearchExecuted, sessionListExecuted, savedExplicit, timedOut, elapsedMs }`.
318
-
319
- ---
320
-
321
- ## Best practices
322
-
323
- ### Use "remember that" for stack preferences
324
-
325
- Style preferences, architectural patterns and stack decisions are perfect candidates. They apply cross-project and rarely change.
326
-
327
- ```text
328
- remember that I prefer immutable records for DTOs in Java
329
- remember that I always use Testcontainers, never H2 in integration tests
330
- remember that I want OnPush change detection on every Angular component
331
- ```
332
-
333
- ### Do NOT use Honcho for secrets
334
-
335
- Tokens, passwords, API keys, personal data should never go to Honcho. The Honcho `apiKey` itself is already on disk in `config.json` — do not pipe further secrets through the `[HONCHO MEMORY]` block.
336
-
337
- ### Run `/honcho list` periodically
338
-
339
- Audit what is saved. Old, contradictory or wrong memories can influence responses. Clean up with `/honcho forget`.
340
-
341
- ### Project-specific memories -> `project-context`
342
-
343
- Cross-project preferences: `explicit`. Current feature/sprint state: `project-context` (the `Stop` hook handles that automatically; no need to save manually).
344
-
345
- ### Do not lean on inference (yet)
346
-
347
- `inferenceEnabled` is a stub in v1. Keep it `false`. v2 (`PLAN_honcho-inference.md`) will bring LLM-based inference — until then, explicit saves are the reliable path.
348
-
349
- ---
350
-
351
- ## Troubleshooting
352
-
353
- ### `/honcho status` returns FAIL
354
-
355
- 1. Check that `~/.honcho/config.json` exists and contains valid JSON
356
- 2. Check `endpoint.baseUrl` — `curl -I <url>/openapi.json` should return 200
357
- 3. Validate `apiKey` — a wrong key returns `connection: FAIL — 401 unauthorized`
358
- 4. Is the Honcho server running? Container up, port exposed, no firewall
359
-
360
- ### `[HONCHO MEMORY]` block does not appear in the prompt
361
-
362
- 1. Hook registered? Check `~/.claude/settings.json` for a `UserPromptSubmit` entry pointing to `on-prompt-submit.js`
363
- 2. Is `bun` on PATH? The hook uses `bun run`
364
- 3. Restart the Claude Code session — hooks are loaded at startup
365
- 4. `enabled: false` or missing `apiKey` in config forces empty stdout even with the hook active
366
- 5. Run `HONCHO_DRY_RUN=1` manually and inspect the telemetry JSON
367
-
368
- ### Old memories keep reappearing
369
-
370
- 1. Verify they are indeed saved as `inferred` — that type would only be produced by v2, so it should not exist in v1
371
- 2. Use `/honcho list` + `/honcho forget <id>` to clean them out
372
- 3. If `inferenceEnabled` is `true`, switch it to `false` — it does not run inference, but the flag may be consumed by future routines
373
-
374
- ### Slow hook, sluggish prompt
375
-
376
- 1. `timeoutMs` too high. Default is 450ms; values > 1000ms are overkill. Lower it
377
- 2. Network latency to the Honcho server? Consider hosting closer
378
- 3. `topN` too high and the search payload slow? Lower to 3-5
379
-
380
- ### Setup wizard hangs
381
-
382
- 1. Run `--dry-run` first to validate read without write
383
- 2. Check permissions on `memory/` — the wizard must create `memory/backup-YYYYMMDD/`
384
- 3. If it hangs during migration, it is most likely server latency — interrupt, validate with `/honcho status`, re-run
385
-
386
- ---
387
-
388
- ## Cross-references
389
-
390
- - [Hooks reference](hooks-reference) — details on the `UserPromptSubmit` and `Stop` events that fire the honcho-memory scripts
391
- - [Architecture overview](architecture-overview) — where memory plugs into the broader pipeline
392
- - `.claude/skills/honcho-memory/SKILL.md` — canonical skill source
393
- - `.claude/skills/honcho-memory/docs/api-endpoints-verified.md` — full Honcho v3 endpoint catalog
394
- - `PLAN_honcho-inference.md` — future plan for LLM-based inference (v2)