From 760554d0acb8dab251b17da12fb89297ea3e505a Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Sat, 29 Aug 2026 05:42:57 +0000 Subject: [PATCH] test(digest): pin the script-anchored explainer path; catch declaration-prefixed writers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Asserts $SOURCE_GSTACK_DIR/agents-digest path and forbids $(pwd)/agents-digest (the cycle-1 fix was revertible without failing anything). - The laundered-assignment arm now matches local/export/declare/readonly/typeset prefixed assignments — the likeliest in-function writer shape in setup. Co-Authored-By: Claude Fable 5 --- test/agents-digest.test.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/agents-digest.test.ts b/test/agents-digest.test.ts index 1446fbb87..f3181663f 100644 --- a/test/agents-digest.test.ts +++ b/test/agents-digest.test.ts @@ -56,8 +56,11 @@ describe('agents-digest', () => { test('setup never copies the digest onto a user AGENTS.md (print-path only)', () => { const setup = fs.readFileSync(path.join(ROOT, 'setup'), 'utf-8'); - // The explainer arms print the digest path… - expect(setup).toContain('agents-digest/gstack-AGENTS.md'); + // The explainer arms print the digest path, anchored to the script's own + // directory — a $(pwd)-relative path prints a nonexistent file whenever + // setup is invoked from anywhere but the repo root. + expect(setup).toContain('$SOURCE_GSTACK_DIR/agents-digest/gstack-AGENTS.md'); + expect(setup).not.toMatch(/\$\(pwd\)\/agents-digest/); // …and no line may write to an AGENTS.md destination. Covers direct // write verbs (cp/ln/mv/tee/install/rsync/dd/truncate), > and >> // redirects, and the laundered form (dest="$proj/AGENTS.md"; … > "$dest") @@ -69,7 +72,7 @@ describe('agents-digest', () => { .filter((l) => /(^|\s|\|)(cp|ln|mv|tee|install|rsync|dd|truncate)\s[^#]*AGENTS\.md/.test(l) || />{1,2}\s*"?[^"\s]*AGENTS\.md/.test(l) - || /^\s*\w+=[^#]*\/AGENTS\.md/.test(l)); + || /^\s*(?:(?:local|export|declare|readonly|typeset)\s+)?\w+=[^#]*\/AGENTS\.md/.test(l)); expect(writers).toEqual([]); });