Commit cc2067a
fix(plugin): slug regex + script path resolution for npm install (v0.8.2)
Two critical bugs discovered during real-user flow simulation — both
block adopt/doctor from working in any non-dev install layout.
**Bug 1 — slug regex** (adopt.js): memoryDir used `cwd.replace(/\//g, '-')`
which only handled forward slashes. Claude Code's actual slug convention
is every non-alphanumeric-non-hyphen char → `-`. For the common dev path
`/mnt/data_ssd/...` this caused the underscore to be preserved, producing
`-mnt-data_ssd-...` instead of the actual `-mnt-data-ssd-...` dir name.
Result: adopt always reported "Memory dir not found" for the user's own
project. Test coverage gap: existing tests used underscore-free paths.
Fix: cwd.replace(/[^a-zA-Z0-9-]/g, '-'). Added 1 test covering
underscores, dots (double-dash from `/.`), case preservation, trailing
version numbers. All 77 tests pass (was 76).
**Bug 2 — script path resolution** (main.rs): run_node_script looked
only at exe_dir/../../ and exe_dir/../ for claude-plugin/scripts/. In
npm install layout, the binary lives in
node_modules/@sdsrs/code-graph-<plat>/ but claude-plugin/ is in the
sibling main pkg node_modules/@sdsrs/code-graph/ — unreachable via
relative-from-exe. Same issue for auto-update-cache binaries at
~/.cache/code-graph/bin/. Affected adopt/unadopt (new) AND the
pre-existing doctor subcommand.
Fix: first consult $_FIND_BINARY_ROOT env var (set by bin/cli.js npm
wrapper to main pkg root) before relative-from-exe. Dev mode still
works via candidate 2 (exe_dir/../../). Error message now lists all
candidates searched so users can self-diagnose install issues.
E2E verification:
- Direct binary from repo root: adopt succeeds for actual user cwd
- cli.js wrapper + auto-update-cache binary: adopt.js located via
$_FIND_BINARY_ROOT, slug correct, flow reaches memoryDir check
- Quiet mode MCP instructions: 338 chars (unchanged from v0.8.1)
- session-init.js quiet: mapInjected=false (unchanged)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent fbb0e6e commit cc2067a
File tree
13 files changed
+63
-22
lines changed- .claude-plugin
- claude-plugin
- .claude-plugin
- scripts
- npm
- darwin-arm64
- darwin-x64
- linux-arm64
- linux-x64
- win32-x64
- src
13 files changed
+63
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
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 | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
16 | 19 | | |
17 | | - | |
| 20 | + | |
18 | 21 | | |
19 | 22 | | |
20 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
29 | 47 | | |
30 | 48 | | |
31 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
0 commit comments