Commit 217c35f
committed
v0.1 W2: ClaudeCodeSurface install/uninstall + settings.json merge
Implements W2 of the v0.1 milestone (#2). Per design.md §3.1, §5, §7:
- klasp-agents-claude::hook_template — three-line bash shim with the
`# klasp:managed` marker and `KLASP_GATE_SCHEMA=N` export, parameterised
by schema version so the contract test (W3) can verify the binary and
fixture stay in lockstep.
- klasp-agents-claude::settings — surgical serde_json-based merge that
preserves every sibling key in `.claude/settings.json`, idempotent on
exact `command` match. Inverse `unmerge_hook_entry` cleans up empty
matchers so install→uninstall round-trips a fresh repo to `{}`.
- klasp-agents-claude::surface — `ClaudeCodeSurface` impl of
`klasp_core::AgentSurface`. Marker-comment idempotency check, atomic
writes via tempfile, chmod 0o755 (Unix). `MarkerConflict` unless
`--force` when an existing hook lacks our marker.
- klasp/src/registry — `SurfaceRegistry` with `ClaudeCodeSurface`
pre-registered. Lives in the binary crate so klasp-core stays free of
per-agent dependencies (relevant for the v0.3 plugin model).
- klasp/src/cmd/install + uninstall — CLI wiring per design §5: filter
surfaces by `--agent` and `detect()`, build `InstallContext`, dispatch.
Tests:
- 19 unit tests in settings.rs (empty-input, sibling preservation,
idempotency, malformed JSON, shape errors, uninstall round-trip)
- 3 integration tests against a realistic fallow-shaped fixture
(proves fallow's hook entry survives byte-for-byte)
- 8 integration tests in klasp/tests/install_claude_code.rs (install,
re-install no-op, dry-run, sibling preservation, marker-conflict
refusal, --force overwrite, uninstall, uninstall dry-run)
- 2 insta snapshot tests of the rendered hook script (v1 + v7 to
exercise schema-version interpolation)
The hook entry's `command` resolves `${CLAUDE_PROJECT_DIR}` at hook
execution time, so the same `.claude/settings.json` works regardless of
the cwd Claude is invoked from.
Closes #2.1 parent 4e8de12 commit 217c35f
17 files changed
Lines changed: 1703 additions & 23 deletions
File tree
- klasp-agents-claude
- src
- tests
- fixtures
- snapshots
- klasp
- src
- cmd
- tests
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
| 3 | + | |
8 | 4 | | |
9 | | - | |
10 | | - | |
11 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
12 | 8 | | |
13 | | - | |
14 | | - | |
15 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
0 commit comments