mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-10 23:19:09 +02:00
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:
co-authored by
Claude Fable 5
parent
3e7251a2e6
commit
e6dfc46e7a
@@ -0,0 +1,51 @@
|
||||
import { describe, test, expect } from 'bun:test';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
// #1656 / #1715 (regression of #785): a tilde inside double quotes never
|
||||
// expands — `_BIN="~/.claude/..."` silently resolves to a literal ./~ path,
|
||||
// so the Artifacts Sync and telemetry-finalize blocks were dead code in every
|
||||
// generated skill. The resolvers now emit $HOME-based paths; this tripwire
|
||||
// fails the suite if a quoted-tilde assignment ever reappears in generated
|
||||
// output.
|
||||
|
||||
const ROOT = path.resolve(import.meta.dir, '..');
|
||||
const QUOTED_TILDE_ASSIGN = /=\s*"~\//;
|
||||
|
||||
function generatedDocs(): string[] {
|
||||
const out: string[] = [];
|
||||
for (const entry of fs.readdirSync(ROOT, { withFileTypes: true })) {
|
||||
if (!entry.isDirectory() || entry.name.startsWith('.') || entry.name === 'node_modules') continue;
|
||||
const skill = path.join(ROOT, entry.name, 'SKILL.md');
|
||||
if (fs.existsSync(skill)) out.push(skill);
|
||||
const sections = path.join(ROOT, entry.name, 'sections');
|
||||
if (fs.existsSync(sections)) {
|
||||
for (const f of fs.readdirSync(sections)) {
|
||||
if (f.endsWith('.md')) out.push(path.join(sections, f));
|
||||
}
|
||||
}
|
||||
}
|
||||
const rootSkill = path.join(ROOT, 'SKILL.md');
|
||||
if (fs.existsSync(rootSkill)) out.push(rootSkill);
|
||||
return out;
|
||||
}
|
||||
|
||||
describe('quoted-tilde assignments (#1656/#1715)', () => {
|
||||
test('no generated doc assigns a double-quoted tilde path', () => {
|
||||
const violations: string[] = [];
|
||||
for (const file of generatedDocs()) {
|
||||
const lines = fs.readFileSync(file, 'utf-8').split('\n');
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
if (QUOTED_TILDE_ASSIGN.test(lines[i])) {
|
||||
violations.push(`${path.relative(ROOT, file)}:${i + 1}: ${lines[i].trim()}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
expect(violations).toEqual([]);
|
||||
});
|
||||
|
||||
test('detector self-check: the pre-fix shape is caught', () => {
|
||||
expect(QUOTED_TILDE_ASSIGN.test('_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"')).toBe(true);
|
||||
expect(QUOTED_TILDE_ASSIGN.test('_BIN="$HOME/.claude/skills/gstack/bin/x"')).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user