Files
gstack/test/dev-setup-fresh-clone.test.ts
T
Garry Tanandcapy-ai[bot] 2fae1d78d6 Remove the /cso security audit skill, since a plain audit request finds more (#4833)
/cso is gone: the skill, its native helper programs, scanner images, CI
jobs, docs and the rest of its tests. Upgrading removes gstack's own
`/cso` entries and old helper files, and leaves a skill of your own
named `cso` alone.

Why: on 52 real security advisories, plainly asking the agent to audit
the code caught more than /cso (13 vs 7 on particle-1; 12 vs 8 of 51 on
Claude Opus 5.5, within the margin of error).

To do: nothing. Optional cleanup of old scanner images and reports is in
the changelog entry.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Review-Finding: p1/outside-voice#1 reader=outside-voice
Review-Finding: p1/outside-voice#2 reader=outside-voice
Review-Finding: p1/adversarial-native#1 reader=adversarial-native
Review-Finding: p1/adversarial-native#2 reader=adversarial-native
2026-11-25 21:59:08 +00:00

84 lines
4.5 KiB
TypeScript

import { afterAll, afterEach, describe, expect, test } from 'bun:test';
import { spawnSync } from 'node:child_process';
import { readlinkSync, symlinkSync } from 'node:fs';
import { join } from 'node:path';
import { cleanupFixtures, cleanupSeed, fixtureMkdirSync, makeFixture, makeSource, put, tree } from './helpers/install-fixture';
afterEach(cleanupFixtures);
afterAll(cleanupSeed);
const stubBun = (f: ReturnType<typeof makeFixture>) => put(join(f.commands, 'bun'), `#!/usr/bin/env bash
case "$*" in
install|'install --production --frozen-lockfile') exit 0 ;;
'run build') echo 'Unexpected build in a dev-setup fixture' >&2; exit 90 ;;
*) exec '${process.execPath}' "$@" ;;
esac
`, 0o755);
const freshClone = (rel = 'gstack') => {
const f = makeFixture();
stubBun(f);
const source = makeSource(f, join(f.dir, rel));
const init = spawnSync('git', ['init', '-q', source], { encoding: 'utf8', timeout: 30_000 });
if (init.status !== 0) throw new Error(init.stderr);
return { f, source };
};
describe.skipIf(process.platform === 'win32')('bin/dev-setup in a fresh gstack clone', () => {
test('links gstack into its own .claude and .agents skills and exits 0', () => {
const { f, source } = freshClone();
for (let run = 0; run < 2; run++) {
const result = spawnSync('bash', [join(source, 'bin/dev-setup')], { cwd: source, env: f.env, encoding: 'utf8', timeout: 120_000, input: '' });
expect(result.stderr).not.toContain('overlaps the source tree');
expect(result.status, result.stdout + result.stderr).toBe(0);
expect(readlinkSync(join(source, '.claude/skills/gstack'))).toBe(source);
expect(readlinkSync(join(source, '.agents/skills/gstack'))).toBe(source);
}
}, 240_000);
test('a user project whose .agents/skills resolves to the checkout\'s own .agents/skills is still refused', () => {
const { f, source } = freshClone('project/vendor/gstack');
const project = join(f.dir, 'project');
fixtureMkdirSync(join(source, '.agents/skills'), { recursive: true });
fixtureMkdirSync(join(project, '.claude/skills'), { recursive: true });
fixtureMkdirSync(join(project, '.agents'));
symlinkSync(source, join(project, '.claude/skills/gstack'), 'dir');
symlinkSync(join(source, '.agents/skills'), join(project, '.agents/skills'), 'dir');
const before = tree(f.dir);
const result = spawnSync('bash', [join(project, '.claude/skills/gstack/setup'), '--host', 'codex', '--no-team', '--no-plan-tune-hooks', '--no-timeline-stop-hook'], {
cwd: project, env: f.env, encoding: 'utf8', timeout: 60_000, input: '',
});
expect(result.status, result.stdout + result.stderr).toBe(1);
expect(result.stderr).toContain(`overlaps the source tree at ${source}`);
expect(tree(f.dir)).toEqual(before);
}, 90_000);
test('the checkout itself is still refused when its .agents/skills aliases the source root', () => {
const { f, source } = freshClone();
fixtureMkdirSync(join(source, '.claude/skills'), { recursive: true });
fixtureMkdirSync(join(source, '.agents'));
symlinkSync(source, join(source, '.claude/skills/gstack'), 'dir');
symlinkSync(source, join(source, '.agents/skills'), 'dir');
const before = tree(f.dir);
const result = spawnSync('bash', [join(source, '.claude/skills/gstack/setup'), '--host', 'codex', '--no-team', '--no-plan-tune-hooks', '--no-timeline-stop-hook'], {
cwd: source, env: f.env, encoding: 'utf8', timeout: 60_000, input: '',
});
expect(result.status, result.stdout + result.stderr).toBe(1);
expect(result.stderr).toContain('overlaps the source tree');
expect(tree(f.dir)).toEqual(before);
}, 90_000);
test('setup --host codex from the checkout\'s own layout is still refused by the Codex preflight, without writes', () => {
const { f, source } = freshClone();
const devSetup = spawnSync('bash', [join(source, 'bin/dev-setup')], { cwd: source, env: f.env, encoding: 'utf8', timeout: 120_000, input: '' });
expect(devSetup.status, devSetup.stdout + devSetup.stderr).toBe(0);
const before = tree(f.dir);
const result = spawnSync('bash', [join(source, '.claude/skills/gstack/setup'), '--host', 'codex', '--no-team', '--no-plan-tune-hooks', '--no-timeline-stop-hook'], {
cwd: source, env: f.env, encoding: 'utf8', timeout: 60_000, input: '',
});
expect(result.status, result.stdout + result.stderr).toBe(1);
expect(result.stderr).toContain(`Refusing: Codex sidecar root write overlaps source or escapes its namespace: ${join(source, '.agents/skills/gstack')}`);
expect(tree(f.dir)).toEqual(before);
}, 240_000);
});