Skip to content

fix(skill-preamble): use $HOME instead of literal ~ in quoted bin paths (#1656) - #1692

Closed
0xDevNinja wants to merge 2 commits into
garrytan:mainfrom
0xDevNinja:fix/1656-tilde-quoted-string-brain-sync
Closed

0xDevNinja wants to merge 2 commits into
garrytan:mainfrom
0xDevNinja:fix/1656-tilde-quoted-string-brain-sync

Conversation

@0xDevNinja

Copy link
Copy Markdown
Contributor

Summary

  • scripts/resolvers/preamble/generate-brain-sync-block.ts emits _BRAIN_SYNC_BIN="${binDir}/gstack-brain-sync" and _BRAIN_CONFIG_BIN="${binDir}/gstack-config". For the Claude host binDir is ~/.claude/skills/gstack/bin, so the rendered assignments hold a literal ~. Tilde inside double quotes is never expanded.
  • scripts/resolvers/preamble/generate-preamble-bash.ts has the same shape on line 55 — [ -x "${binDir}/gstack-telemetry-log" ] — the -x test then always returns false on Claude hosts.
  • The surrounding 2>/dev/null || true swallows ENOENT, so the artifacts-sync preamble silently no-ops in 48 generated SKILL.md files (/context-save, /context-restore, /autoplan, /codex, etc.). Cross-machine artifact handoff never pushes.
  • Normalize ctx.paths.binDir to $HOME/... form before interpolating into the quoted contexts. Env-var hosts (Codex, Hermes, etc.) whose binDir is already $GSTACK_BIN are untouched — only the ~/... prefix is rewritten.

Fixes #1656. Same defect class as #785 / #843 (which targeted browseDir / designDir); this PR is the matching fix on the brain-sync surface.

Why this shape

  • Local TS rewrite inside the two affected resolvers, not a global change to scripts/resolvers/types.ts. PR fix: use $HOME instead of ~ for browse/design binary paths #843 already proposes a global swap on browseDir / designDir; doing the same swap on binDir from this PR would silently conflict with anyone else touching types.ts. The local pattern keeps the diff narrow and reversible.
  • Static invariants land in test/skill-validation.test.ts. Two new tests fail loudly if any generated SKILL.md re-introduces ="~/ or [ -x "~/. Existing skills are now clean (grep returns 0 hits), so the invariants pass.

Diff shape

  • 2 resolver files: +18 / -3
  • 1 test file: +59
  • 47 regenerated SKILL.md files (no manual edits; produced by bun run gen:skill-docs)

Tests

bun test test/skill-validation.test.ts
# 331 pass, 0 fail (existing 329 + 2 new invariants)

bun test test/skill-validation.test.ts test/gen-skill-docs.test.ts
# 711 pass, 7 fail

The 7 failures are the pre-existing --dry-run freshness check cases on non-Claude hosts that reproduce on upstream/main with this branch's changes stashed — unrelated.

Verification

Sample lines from the regenerated context-save/SKILL.md:

68:    if [ "$_TEL" != "off" ] && [ -x "$HOME/.claude/skills/gstack/bin/gstack-telemetry-log" ]; then
369: _BRAIN_SYNC_BIN="$HOME/.claude/skills/gstack/bin/gstack-brain-sync"
370: _BRAIN_CONFIG_BIN="$HOME/.claude/skills/gstack/bin/gstack-config"

grep -rEl '_BRAIN_SYNC_BIN="~/|_BRAIN_CONFIG_BIN="~/|-x "~/' */SKILL.md SKILL.md returns 0 files post-patch.

@time-attack

time-attack commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

@0xDevNinja Please rewrite this to include the newer generated outputs and tests proving these commands activate safely with $HOME paths.

- The artifacts-sync preamble assigned `_BRAIN_SYNC_BIN="~/.claude/..."`
  and the telemetry block `-x`-tested the same path; tilde inside double
  quotes is literal, so 42+ SKILL.md files silently no-op'd brain-sync
- `2>/dev/null || true` swallowed the ENOENT, so users never saw failure
  while cross-machine artifact handoff quietly never pushed
- Normalize `ctx.paths.binDir` to `$HOME/...` form for env-var-host (Codex
  etc.) paths, untouched
- Add static invariants `="~/` and `[ -x "~/` so the pattern can't
  regress under future resolver edits

Fixes garrytan#1656. Same shape as garrytan#785 / garrytan#843, different surface (binDir,
not browseDir/designDir).
Rebase onto current main picked up two skills added since this branch
was cut (diagram, spec) whose generated SKILL.md still carried the
literal-tilde quoted assignments. Regenerated via bun run gen:skill-docs
with the $HOME-normalized resolvers from this branch; the existing
static invariants in test/skill-validation.test.ts scan every generated
SKILL.md, so they cover these files from now on.

Refs garrytan#1656.
@0xDevNinja
0xDevNinja force-pushed the fix/1656-tilde-quoted-string-brain-sync branch from 25a390e to 8c21134 Compare July 16, 2026 09:14
@0xDevNinja

Copy link
Copy Markdown
Contributor Author

rebased onto current main and regenerated. the rebase picked up two skills added since this branch was cut (diagram, spec) whose SKILL.md still had the literal-tilde assignments — regenerated both, zero ="~/ instances remain across all generated files. the static invariants already in test/skill-validation.test.ts scan every generated SKILL.md, so newly added skills are covered automatically from here. 333 pass.

@capy-ai

capy-ai Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Thank you for this fix! The bug it addresses (#1656) has since been fixed on main and the issue is closed, so I'm closing this PR as done. Re-verified against current main (v1.91.12.0). If you think part of your change is still missing, reply and we'll reopen. Really appreciate the contribution.

@capy-ai capy-ai Bot closed this Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tilde-in-quoted-string disables brain-sync silently across 42 SKILL.md files (regression of #785)

2 participants