From bb3acf98b3067ea305c8e50d46c3195a13697173 Mon Sep 17 00:00:00 2001 From: Paul Valladares <85648028+dreyfus92@users.noreply.github.com> Date: Thu, 19 Nov 2026 20:17:53 -0600 Subject: [PATCH 1/2] test(sync): check that git ignores synced skill links --- src/commands/sync.test.ts | 53 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/src/commands/sync.test.ts b/src/commands/sync.test.ts index b6a2dcc..4f26912 100644 --- a/src/commands/sync.test.ts +++ b/src/commands/sync.test.ts @@ -1,5 +1,6 @@ -import { lstat, readlink, realpath, symlink as fsSymlink } from 'node:fs/promises'; +import { lstat, readdir, readlink, realpath, symlink as fsSymlink } from 'node:fs/promises'; import { fileURLToPath } from 'node:url'; +import { x, type Output } from 'tinyexec'; import { describe, it, expect, vi } from 'vitest'; import { createFixture, createMocks } from '../test-utils/index.ts'; import { @@ -229,6 +230,56 @@ describe('sync', () => { ); }); + it('writes .gitignore entries that git applies to the skill links', async () => { + const fixture = await createFixture({ + project: { 'package.json': '{ "name": "my-app" }' }, + }); + const project = await realpath(fileURLToPath(new URL('project/', fixture.root))); + createMocks({ env: { INIT_CWD: project } }); + vi.spyOn(console, 'info').mockImplementation(() => {}); + // Keep the user's global and system git config (and its excludes file) out of the result. + const git = (args: string[]): PromiseLike => + x('git', args, { + nodeOptions: { + cwd: project, + env: { ...process.env, GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1' }, + }, + throwOnError: true, + }); + await git(['init', '--quiet']); + + await sync({ args: [] }); + + expect(await readdir(new URL('project/.agents/skills/', fixture.root))).toContain('lifecycle'); + const status = await git(['status', '--porcelain', '--untracked-files=all', '--', '.agents']); + expect(status.stdout).toBe(''); + }); + + it('rewrites .gitignore entries from older syncs and keeps content outside the block', async () => { + const fixture = await createFixture({ + project: { + 'package.json': '{ "name": "my-app" }', + '.gitignore': + 'node_modules\n\n# bsh:skills\n.agents/skills/lifecycle/\n.agents/skills/removed/\n# /bsh:skills\n\ndist\n', + }, + }); + const project = await realpath(fileURLToPath(new URL('project/', fixture.root))); + createMocks({ env: { INIT_CWD: project } }); + vi.spyOn(console, 'info').mockImplementation(() => {}); + + await sync({ args: [] }); + + const linked = (await readdir(new URL('project/.agents/skills/', fixture.root))).toSorted(); + const gitignore = await fixture.text('project/.gitignore'); + const match = /^node_modules\n\n# bsh:skills\n([\s\S]*)\n# \/bsh:skills\n\ndist\n$/.exec( + gitignore!, + ); + expect(match).not.toBeNull(); + expect(match![1]!.split('\n').toSorted()).toEqual( + linked.map((name) => `.agents/skills/${name}`), + ); + }); + it('removes the legacy skills directory once it is empty', async () => { const fixture = await createFixture({ project: { From dd69a08d691321a4b1797909edbb4c972eed36be Mon Sep 17 00:00:00 2001 From: Paul Valladares <85648028+dreyfus92@users.noreply.github.com> Date: Thu, 19 Nov 2026 20:19:31 -0600 Subject: [PATCH 2/2] fix(sync): ignore skill symlinks in .gitignore --- .changeset/sync-gitignore-symlinks.md | 5 +++++ src/commands/sync.test.ts | 2 +- src/commands/sync.ts | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/sync-gitignore-symlinks.md diff --git a/.changeset/sync-gitignore-symlinks.md b/.changeset/sync-gitignore-symlinks.md new file mode 100644 index 0000000..70c6bf6 --- /dev/null +++ b/.changeset/sync-gitignore-symlinks.md @@ -0,0 +1,5 @@ +--- +"@bomb.sh/tools": patch +--- + +`sync` CLI command writes `.gitignore` entries that match the skill symlinks it creates, so linked skills no longer show up as untracked. diff --git a/src/commands/sync.test.ts b/src/commands/sync.test.ts index 4f26912..faebf18 100644 --- a/src/commands/sync.test.ts +++ b/src/commands/sync.test.ts @@ -222,7 +222,7 @@ describe('sync', () => { expect(await fixture.text('project/skills/mine.md')).toBe('user-owned'); const gitignore = await fixture.text('project/.gitignore'); - expect(gitignore).toContain('.agents/skills/lifecycle/'); + expect(gitignore).toMatch(/^\.agents\/skills\/lifecycle$/m); expect(gitignore).not.toMatch(/^skills\//m); expect(await fixture.text('project/AGENTS.md')).toContain( diff --git a/src/commands/sync.ts b/src/commands/sync.ts index c94b80f..7d21dda 100644 --- a/src/commands/sync.ts +++ b/src/commands/sync.ts @@ -149,7 +149,8 @@ async function updateGitignore(options: { root: URL; skills: SkillInfo[] }): Pro const gitignorePath = new URL('.gitignore', root); let content = (await hfs.text(gitignorePath)) ?? ''; - const lines = skills.map((s) => `${SKILLS_DIR}${s.name}/`); + // No trailing slash: git treats a symlink as a file, and `dir/` only matches directories. + const lines = skills.map((s) => `${SKILLS_DIR}${s.name}`); const section = [GITIGNORE_START, ...lines, GITIGNORE_END].join('\n'); const startIdx = content.indexOf(GITIGNORE_START);