From b3d1b870f22b0f324cf38558eb71921235ff90c9 Mon Sep 17 00:00:00 2001 From: Tom Boucher Date: Mon, 6 Jul 2026 10:39:34 -0400 Subject: [PATCH] fix(#1575): repo-layout test checks git tracking not filesystem existence MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AGENTS.md is legitimately created by gsd install copilot (issue #786) when the installer runs inside a repo checkout. The file may exist on disk — that is expected. The test must verify it is not git-tracked, not that it is absent from the working tree. Uses git ls-files --error-unmatch instead of fs.existsSync. --- tests/repo-layout.test.cjs | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/tests/repo-layout.test.cjs b/tests/repo-layout.test.cjs index eb6465df9..61a95c8d0 100644 --- a/tests/repo-layout.test.cjs +++ b/tests/repo-layout.test.cjs @@ -20,22 +20,36 @@ const test = require('node:test'); const assert = require('node:assert/strict'); const fs = require('fs'); const path = require('path'); +const { execFileSync } = require('child_process'); const ROOT = path.resolve(__dirname, '..'); -test('repo-layout: root AGENTS.md is absent — no ad-hoc AI instruction file committed alongside CONTEXT.md', () => { - const agentsMdPath = path.join(ROOT, 'AGENTS.md'); +test('repo-layout: root AGENTS.md is not git-tracked — no ad-hoc AI instruction file committed alongside CONTEXT.md', () => { + // The installer legitimately writes AGENTS.md to process.cwd() when + // `gsd install copilot` runs inside a repo checkout (issue #786). The file + // may exist on disk — that's expected after a local install. What must NOT + // happen is committing it to git, where editors and AI tools would silently + // pick up the installer-generated stub instead of CONTEXT.md. + let tracked; + try { + execFileSync('git', ['ls-files', '--error-unmatch', 'AGENTS.md'], { + cwd: ROOT, encoding: 'utf8', stdio: 'pipe', + }); + tracked = true; + } catch { + tracked = false; + } assert.equal( - fs.existsSync(agentsMdPath), + tracked, false, [ - 'root AGENTS.md must not be committed.', + 'root AGENTS.md must not be git-tracked.', 'This file is written by `gsd install copilot` (bin/install.js, local Copilot path, issue #786)', - 'when the installer runs inside a repo checkout.', + 'when the installer runs inside a repo checkout — its presence on disk is fine,', + 'but it must never be committed.', 'The repository source of truth for architecture and contributor guidance is', 'CONTEXT.md and docs/adr/ — not an installer-generated instruction stub.', - 'Run `gsd uninstall copilot` to remove the artefact, then verify it is gitignored', - 'before re-running the install in this checkout.', + 'Run `git rm --cached AGENTS.md` to untrack it if accidentally staged.', ].join(' '), ); });