fix(preamble): quoted tilde made Artifacts Sync and telemetry-finalize dead code in 49 skills

A tilde inside double quotes never expands, so the generated
`_BRAIN_SYNC_BIN="~/..."` assignments resolved to a literal ./~ path and
the Artifacts Sync + telemetry-finalize blocks silently no-op'd in every
skill that carried them (regression of #785). The preamble resolvers now
emit $HOME-based paths; all generated SKILL.md files regenerate identically
from the fixed templates, and a static tripwire fails the suite if a
quoted-tilde assignment ever reappears in generated output.

Fixes #1656, #1715.

Contributed by @jawadakram20 (PR #2333).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Garry Tan
2026-08-14 20:20:55 -07:00
co-authored by Claude Fable 5
parent 3e7251a2e6
commit e6dfc46e7a
53 changed files with 329 additions and 255 deletions
+21
View File
@@ -16,6 +16,27 @@ export interface HostPaths {
makePdfDir: string;
}
/**
* Make a host path safe to interpolate INSIDE DOUBLE QUOTES in generated bash.
*
* Tilde-based hosts (Claude, factory) resolve to paths like
* `~/.claude/skills/gstack/bin`. Bash only performs tilde expansion when the
* `~` is UNQUOTED, so `"~/.claude/..."` is a literal relative path that never
* resolves. A `[ -x "~/..." ]` test is therefore always false and a
* `"~/..." --flag` invocation always fails — the surrounding block silently
* becomes dead code rather than erroring.
*
* Env-var hosts already use `$GSTACK_BIN`, which expands correctly when
* quoted, so they pass through untouched.
*
* Use this ONLY where the path lands inside double quotes. Unquoted
* interpolations (`${ctx.paths.binDir}/gstack-slug`) expand fine as-is and are
* left alone so generated docs keep the more readable `~`.
*/
export function quoteSafePath(hostPath: string): string {
return hostPath.startsWith('~/') ? `$HOME/${hostPath.slice(2)}` : hostPath;
}
/**
* HOST_PATHS — derived from host configs.
* Each config's globalRoot/localSkillRoot determines the path structure.