Commit ebae8a1
authored
feat: add dosu hooks for Claude Code knowledge injection (#74)
* feat: add dosu hooks for Claude Code knowledge injection
Turns the validated prototype into a production 'dosu hooks' command surface that injects Dosu knowledge into Claude Code automatically and non-blockingly.
- user-prompt-submit: create a knowledge ticket (fire-and-forget) + inject a short 'lookup started' note
- post-tool-use: poll (cooldown-throttled) and inject the route map exactly once
- stop (opt-in): non-blocking last-chance delivery
- install/uninstall/doctor for claude-code; writes a bare 'dosu hooks <event>' command into .claude/settings.local.json only (never tracked config)
- in-CLI fake ticket API + unit/integration tests; silent-no-op-on-failure so a hook never disrupts the agent
- save nudge when the server reports a knowledge gap (save_recommended)
* fix: guard Stop against bare save-nudge and tighten installer detection
Review follow-ups on the dosu hooks surface:
- Stop hook only blocks for real knowledge; a knowledge-gap ticket (empty context) is consumed but not blocked on, so the agent is never held open just for a save nudge
- isDosuHookCommand requires 'dosu' to be the command name (optionally path-prefixed), not merely an argument — so a user hook whose argument contains 'dosu hooks' is no longer misidentified and deleted on uninstall
- fake-server: handle mid-stream request errors so a socket error can't crash the dev server
* chore: drop the test-only fake ticket server (not shipped)
fake-server.ts + its two tests were test/dev-only infra: no production code imported them, so they were already tree-shaken out of the published bundle (bin/dosu.js). Removing them slims the changeset with zero behavior change. Unit tests still cover the hook runtime + the §3.6 wire-contract parsing, and coverage stays above the 95/90/80/95 gate (95.23/90.55/98.11/95.23).
* refactor: self-document hooks install/uninstall and validate the agent
Constrain the <agent> positional to the supported set (claude-code) via
commander .choices() so an unknown agent fails fast with a clear message,
and add --help examples for install/uninstall.
* refactor: drop plan/MVP/demo references from hooks comments and messages
Strip 'plan §x' comment references, the 'The MVP supports' wording in
user-facing errors (now 'Supported agents/scopes'), and demo/lineage notes.
Behavior unchanged except the reworded error strings.
---------
Co-authored-by: Caspian Zhao <user.name>1 parent 4a88ac1 commit ebae8a1
12 files changed
Lines changed: 2006 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
112 | 132 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
36 | 48 | | |
37 | 49 | | |
38 | 50 | | |
| |||
44 | 56 | | |
45 | 57 | | |
46 | 58 | | |
47 | | - | |
48 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
49 | 63 | | |
50 | 64 | | |
51 | 65 | | |
| |||
242 | 256 | | |
243 | 257 | | |
244 | 258 | | |
| 259 | + | |
245 | 260 | | |
246 | 261 | | |
247 | 262 | | |
| |||
0 commit comments