* test(#3133): global Claude @-references must resolve on tilde, not $HOME Regression for #3133: on a global Claude install, _applyRuntimeRewrites rewrites @~/.claude/... -> @$HOME/.claude/..., but Claude Code does not expand $HOME in @-file references, so the include silently resolves to nothing and the skill loads an empty execution_context. Rows 1/2/6/9 fail RED on next; rows 3-5/7-8 guard #1284 (shell $HOME), local redirect, #3503 (no homedir leak), and non-Claude isolation. * fix(#3133): keep global Claude @-references on tilde, not $HOME On a global Claude install, _applyRuntimeRewrites rewrote every @~/.claude/ include to @$HOME/.claude/ because computePathPrefix returns the $HOME form for shell-context correctness (#1284: ~ does not expand inside double quotes). Claude Code does not expand $HOME in @-file references, so the rewritten include silently resolved to nothing and skills loaded an empty execution_context. Add a normalization pass in the claude case: when the prefix is the $HOME (global) form, restore @$HOME/.claude/ -> @~/.claude/ (the form Claude expands and the shipped tarball uses). Shell contexts keep $HOME; local installs (absolute prefix) are unaffected; computePathPrefix is untouched (all its tests stay green). * test(#3133): fix row 9 assertion — drop end-of-string anchor Row 9's regex used $ (end-of-string) but a realistic @-ref line ends with a newline, so the anchor could not match. The fix under test produces the correct @~/.claude/gsd-core/references/ui-brand.md tail; only the assertion was wrong. Drop the anchor and assert the tail + no @$HOME. * docs(#3133): add changeset * docs(#3133): backfill changeset PR number (3393) --------- Co-authored-by: sim <sim@local>
This commit is contained in:
@@ -2744,6 +2744,18 @@ function _applyRuntimeRewrites(content, runtime, pathPrefix, isGlobal = false, a
|
||||
content = content.replace(/~\/\.claude\//g, pathPrefix);
|
||||
content = content.replace(/\$HOME\/\.claude\//g, pathPrefix);
|
||||
content = content.replace(/\.\/\.claude\//g, `./${dirName}/`);
|
||||
// #3133: Claude Code expands `~` and absolute paths in @-file references
|
||||
// but NOT `$HOME`. computePathPrefix returns the $HOME/.claude/ form for
|
||||
// global installs under $HOME (correct for double-quoted shell commands —
|
||||
// `~` does not expand inside double quotes, causing MODULE_NOT_FOUND,
|
||||
// #1284), so the substitutions above rewrite @~/.claude/… → @$HOME/.claude/…
|
||||
// which silently resolves to nothing and leaves skills with an empty
|
||||
// execution_context. Restore the tilde form Claude expands (the form the
|
||||
// shipped tarball uses). Local installs use an absolute pathPrefix (already
|
||||
// @-resolvable) and are unaffected — the guard fires only for the $HOME form.
|
||||
if (pathPrefix.startsWith('$HOME')) {
|
||||
content = content.replace(/@\$HOME\/\.claude\//g, '@~/.claude/');
|
||||
}
|
||||
content = processAttribution(content, attribution);
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user