mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-02 23:14:33 +01:00
* fix(preamble): completeness means complete coverage with minimal code (GSTA-96) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * feat(preamble): tier 2+ skills load the shared preamble once per session (GSTA-96) Every tier 2+ SKILL.md inlined the same ~23 KB preamble. It now renders once per host into sections/preamble.md beside each tier 2+ SKILL.md; the SKILL.md keeps a pointer that asks for the Read only when the file's id is not already in context. Only sections byte-identical to the shared render move, so every skill keeps exactly its pre-hoist paragraphs (verified across all 41 skills). Parity caps for ten skills raised to their measured unions (owner-approved, Garry 2026-10-25: "do it"); 63 size pins lowered and 26 deleted. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(paid-select): a generated sections/preamble.md takes its skill template's identity in the PR planner (GSTA-96) screen-summary failed on #3434 with 'PR profile requires full validation' for nine skills whose only paid coverage is periodic: their new sections/preamble.md had no dependency identity, while the SKILL.md beside it inherits its template's. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test(section-manifest): the shared sections/preamble.md renders from the hoist resolver, not a section template (GSTA-96) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: pre-landing review fixes (CHANGELOG says 3 characters shorter; model-overlays guards the coverage half) The completeness section shrank by 3 characters (5 bytes), matching the 89 pins lowered by 3. The default-copy test pinned only the minimal-code half; an expectMentions check now fails if the full-coverage or never-excuses-a-gap clause is dropped. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: pre-landing review fixes (model-overlays binds smaller diff to equal coverage) The default-copy check now also fails if 'on equal coverage' is dropped from the smaller-diff rule (which would tell models to prefer the smaller diff unconditionally) or if the no-impossible-state-checks clause is removed. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: CHANGELOG lists the model-overlays coverage checks The [Unreleased] Tests bullet now says the default-copy test checks both halves of the rule (full coverage of the requirement; smaller diff only at equal coverage; no impossible-state checks; never excuses a gap), matching88e3cc0and44eacaf. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: plan-ceo-review and ETHOS say completeness means coverage, not more code Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: pre-landing review fixes (CEO bullet bounds code by accepted scope; tests bind each completeness rule) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: cover the shared-preamble hoist (ship Step 7) Adds test/preamble-hoist.test.ts (tier 1 unchanged; tier 2+ SKILL.md plus sections/preamble.md reproduces the pre-hoist preamble; pointer position and id) and two gen-skill-docs-checks cases (one shared preamble per host, beside every pointer and named by its id; preamble artifact kind). Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: pre-landing review fixes (ship Step 9.4) - setup: follow a symlinked sections/ dir in the carved-pointer status check - touchfiles: select preamble-hoist.ts alongside every preamble.ts entry - section-manifest: exempt sections/preamble.md only for skills whose SKILL.md carries the shared-preamble pointer - skill-size-budget: growth ceiling measures SKILL.md plus its shared preamble - host-conformance: tolerate a missing sections/ dir, as setup does - skill-validation: read bin/gstack-skill-start directly - skill-fixture: error messages and docblocks name the actual boundary (harness-version non-behavioral note updated) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: describe the size-budget growth check's startup measure (ship Step 9.4, pass 2) The growth ceiling now measures SKILL.md plus the shared preamble, the same measure as the shrink floor; the docblock said SKILL.md only. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: CHANGELOG says simplification.md quotes the old rule and CLAUDE.md restates the new one Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: CHANGELOG lists the hoist tests and the growth-ceiling measure (ship Step 9.4) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: cover the symlinked sections/ status check and the ETHOS house-rule quote (ship Step 7) host-conformance: --status still finds a broken bare sections/ pointer when a carved Claude skill's installed sections/ is a directory symlink (fails at the pre-repair0e5d11fd9). gen-skill-docs: the house rule review/specialists/ simplification.md quotes from ETHOS.md still appears in ETHOS.md. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: describe the shared preamble file (ship Step 14.5 docs audit) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: the shared-preamble skip needs the skill's own Read; digest and first-run intro say complete coverage, minimal code (GSTA-96) The pointer skipped the shared file when any text carrying its id was in context, so a page or file with that heading could stand in for the anti-spoofing rules (security, red team and adversarial review, ship run 2). It now requires the skill's own earlier Read. The digest's Boil the Ocean bullet and the first-run intro still said 'AI makes completeness cheap, so do the complete thing' (docs audit blocker); both now carry Garry's 'complete coverage, minimal code' (2026-10-25: '1/ yes fix this'). Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: pin the shared-preamble provenance skip and the new Boil the Ocean wording (ship Step 7) preamble-hoist: on every host, tier and render option the pointer allows the skip only when the skill's own Read is in context. agents-digest and gstack-skill-start: the digest bullet and the lake intro say complete coverage, minimal code, never the retired phrasing. Each fails at9af36d010. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: describe the provenance skip where the docs still described the id-only one (ship Step 9.4) The preamble-hoist.ts docblock and ARCHITECTURE.md still said the shared preamble is re-read only when its id is absent; since2acf1a44athe pointer requires the skill's own earlier Read of the file. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: CHANGELOG lists the provenance-pointer and Boil the Ocean wording tests (ship Step 13) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * revert(digest): keep the agents digest at main's bytes; an unstamped head cannot change a release output (GSTA-96) CI 'Check VERSION is not stale vs queue' classified #3434 as stamped because it touched agents-digest/gstack-AGENTS.md (a release_outputs path), while regenerating only the generator fails the digest freshness test. The first-run intro rewording stays. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: voice judge reads the hoisted preamble; register ETHOS.md on its reader cases Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: refresh the claude ship golden the main merge took from main (ship Step 5 preflight) The1a4dcaf07merge resolved test/fixtures/golden/claude-ship-SKILL.md to main's pre-hoist bytes. The golden is a copy of ship/SKILL.md; regenerated with bun scripts/gen-ship-goldens.ts (pregate regen: REGEN_STALE). Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: pr-dependencies' unplaceable-file example uses SECURITY.md now that ETHOS.md is mapped6183ca8aeregistered ETHOS.md on its reader cases in touchfiles-data.ts, so a PR touching only ETHOS.md plans in pr mode and no longer restores the full gate. The fail-closed test and the real-unknown label check now use SECURITY.md, which is tracked and unmapped; the assertions are unchanged. CHANGELOG names the third test file. (CI free shard 7 at 7c21720ac; remote pregate shard 6.) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: host path-leak checks read the moved shared preamble too; name SHARED_PREAMBLE_FILE (ship review pass 2) The external-host path-leak assertions in gen-skill-docs.test.ts (Codex, Factory) and host-config.test.ts (Copilot, Antigravity) read SKILL.md alone, so a Claude path that moved into sections/preamble.md with the hoist went unchecked. They now read the skill's startup text through readSkillStartup. workflow-judge-input and host-conformance use the SHARED_PREAMBLE_FILE constant instead of a bare 'preamble.md' literal, and preamble.ts's header describes the hoisted composition. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: CHANGELOG token savings name the per-skill skip and the autoplan follow-up (ship review pass 2) The pointer's skip is bound to the skill's own copy of sections/preamble.md, so "every later one saves about 5,800" holds per skill, not per session, and /autoplan's skip list and the inline /office-hours loader do not yet skip the pointer section. The entry now says so instead of claiming the full /autoplan saving. Adding the skip entry grows size-pinned skills, so it is a follow-up. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: corpus budget measures startup bytes; carve-safety counts shared preamble as uncarved (ship review pass 2) skill-size-budget's growth ceiling and shrink floor already measured SKILL.md plus sections/preamble.md, but the total-corpus check still summed hoisted SKILL.md bytes against the pre-hoist baseline, hiding about 0.9 MB of headroom. It now sums the same startup bytes (3,114,885 -> 2,590,484, x0.832); the unreachable SKILL.md-missing fallback is gone. auq-format-always-loaded's carve-safety guard treated any sections/ dir as carved, so every skill with only the shared preamble ran it and its sanity check passed on preamble.md. It now uses setup --status's rule: a section other than the shared preamble. Those skills keep the per-skill checks. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: remaining SKILL.md-only negatives read the shared preamble too (ship review pass 3) The parameterized external-host path-leak smoke test, the two Codex .claude path checks and both vestigial-handshake negatives read SKILL.md alone, so text that moved into sections/preamble.md went unchecked. They now read readSkillStartup. preamble.ts's header no longer says tier 1 renders through generatePreamble(). Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: ratchet skeleton caps and eager context ceilings down after the hoist (ship review pass 3) The hoist moved about 22 KB out of every tier 2+ SKILL.md, which left each hoisted maxSkeletonBytes cap and each eagerPerInvocation ceiling roughly 22 KB / 5-6K tokens slack. The 20 hoisted skeleton caps now sit at the post-hoist skeleton plus their pre-hoist headroom, and 42 context-budget ceilings take the recaptured (lower) values. Nothing was raised: the four ceilings the recapture would have raised keep their old values. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: preamble-hoist's section splitter closes a fence only on a bare delimiter (ship Step 11) Inside an open fence, a line such as "```bash" is content in CommonMark, but splitSections treated it as the closing fence, so a later "## " line in the same block could split a section mid-code-block and hoist half of it. A closing delimiter now needs nothing but whitespace after it. Every host's render is unchanged (gen-skill-docs --dry-run FRESH on all twelve hosts). Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: skill-startup.ts is a global, pinned harness file like skill-fixture.ts (ship review pass 3) skill-fixture.ts is a global touchfile pinned in scripts/harness-version.json because it reshapes the skill content most E2E suites read, and it now builds that content through test/helpers/skill-startup.ts. That helper was in neither list, so a later edit to it would change fixture inputs without the harness-version guard and select only 27 keys. It is now global and pinned, recorded non-behavioral (its fixtures are byte-identical to the pre-hoist output). ARCHITECTURE.md and the CHANGELOG stop calling the pointer id a content id: it hashes the shared text before host rewrites. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: CHANGELOG matches the merged skip lists and the baseline diff (ship review, run 4) The headline still called the autoplan and inline /office-hours skip entries a follow-up, but the main merge added them; it now says the loaded skills skip their shared Read. The #3451 sentence is dropped, because that fix shipped in v1.91.237.0 and is recorded there. The typecheck baseline line says the TS2769 entry was re-keyed for the 'preamble' artifact kind with its count unchanged, not fixed and lowered. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: pin the pointer entry in the loader skip lists; drop a carve-safety tautology (ship review, run 4) A new INVOKE_SKILL test checks that plan-ceo-review's inline /office-hours skip list and autoplan's section skip list both name the shared-preamble pointer heading, and that office-hours and the four plan reviews carry it. The carve-safety "sanity" assertion repeated the predicate discoverSkills() now uses to set sectionsDir, so it could never fail; it is removed. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: gstack-doctor finds the Codex model patch in the hoisted shared preamble (ship Step 11, run 4) The doctor's patch row grepped only the Codex review SKILL.md for the "Model-Specific Behavioral Patch (" heading. The hoist moves that section into sections/preamble.md, so the required row (for ship, review, the plan reviews, office-hours, investigate and more) would fail on every correct post-hoist Codex install and block install.sh's "gstack: ok". It now checks the SKILL.md and then its shared preamble and names the file it found. A new doctor test covers a hoisted render. preamble-hoist's variantSubsections also returns null when no subsection differs, instead of emitting a replacing heading with no subsections. Every host's render is unchanged. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test(docsync): fixtureDocs installs the generated sections/preamble.md (hunk taken from #3472) A generated skill that loads the shared preamble names sections/preamble.md as a required asset before skill start, and a spawned document-release child blocks on its absence, so docsync-spawned stayed red on every #3434 screen. fixtureDocs now copies that file when the generated skill has it. This single hunk is taken unchanged from gstack#3472 (head2e3f7ba1, GSTA-107), which trains ahead of #3434, so the train merge sees identical lines. Nothing else from #3472 is included. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: CHANGELOG notes the docsync fixture hunk taken from #3472 Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: CHANGELOG names the post-merge context-budget ratchet (captain hoisted) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test(auq): planted skill fixtures resolve the shared preamble like an install (GSTA-96) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test(plan-format): mode menu delivers its question without output-harvesting wording (GSTA-96) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs(changelog): record the v1.91.270.0 merge values (GSTA-96) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test(auq): parallel-capture contract expects the planted skill with its sections path mapped (GSTA-96) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs(changelog): record the v1.91.273.0 merge re-measurements (GSTA-96) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs(changelog): restore the released entries the previous commit truncated (GSTA-96) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs(changelog): end two sentences the prose gate flags (GSTA-96) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --------- Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
400 lines
24 KiB
TypeScript
400 lines
24 KiB
TypeScript
/**
|
|
* Host conformance kit (docs/ADDING_A_HOST.md "Certify your host").
|
|
*
|
|
* Runs the real ./setup into a clean temp HOME for every installable host in
|
|
* hosts/index.ts and checks the install contract: the host's discovery
|
|
* directory gets its skills, no other host's directory is created or changed,
|
|
* no skill name is duplicated, the registry row is published, and
|
|
* ./setup --status reports it. Upgrade cases start from the previous
|
|
* release's on-disk layout (the same links, no registry, the marker in
|
|
* ~/.gstack) and from a project-vendored copy that captured the global Codex
|
|
* namespace (#2879). Instruction-only hosts must change nothing.
|
|
*/
|
|
import { afterAll, afterEach, describe, expect, test } from 'bun:test';
|
|
import { accessSync, chmodSync, existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';
|
|
import { join } from 'node:path';
|
|
import { ALL_HOST_CONFIGS } from '../hosts/index';
|
|
import { cleanupFixtures, cleanupSeed, makeFixture, makeSource, put, registryRows, runSetup, setVersion, tree } from './helpers/install-fixture';
|
|
import { expectTokens } from './helpers/prompt-structure';
|
|
import { readSkillStartup, SHARED_PREAMBLE_FILE } from './helpers/skill-startup';
|
|
|
|
afterEach(cleanupFixtures);
|
|
afterAll(cleanupSeed);
|
|
|
|
/** Skills directory each installable host discovers (global scope). */
|
|
const DISCOVERY: Record<string, string> = {
|
|
claude: '.claude/skills',
|
|
codex: '.codex/skills',
|
|
kiro: '.kiro/skills',
|
|
factory: '.factory/skills',
|
|
opencode: '.config/opencode/skills',
|
|
cursor: '.cursor/skills',
|
|
copilot: '.copilot/skills',
|
|
agy: '.gemini/antigravity-cli/skills',
|
|
};
|
|
/** Every directory any host (or a shared agents layout) reads; .gemini/skills is Gemini CLI's. */
|
|
const ALL_DISCOVERY_DIRS = [...Object.values(DISCOVERY), '.agents/skills', '.copilot/skills', '.hermes/skills', '.gemini/skills'];
|
|
|
|
const installable = ALL_HOST_CONFIGS.filter(c => c.tier !== 'instruction-only').map(c => c.name);
|
|
const instructionOnly = ALL_HOST_CONFIGS.filter(c => c.tier === 'instruction-only').map(c => c.name);
|
|
|
|
function skillNames(dir: string): string[] {
|
|
const names: string[] = [];
|
|
for (const entry of readdirSync(dir)) {
|
|
const md = join(dir, entry, 'SKILL.md');
|
|
if (!existsSync(md)) continue;
|
|
const m = readFileSync(md, 'utf8').match(/^name:\s*(\S+)/m);
|
|
if (m) names.push(m[1]);
|
|
}
|
|
return names;
|
|
}
|
|
|
|
/** Every SKILL.md under dir that is itself a symlink; linked directories are not entered (INV-3). */
|
|
function symlinkedSkillMds(dir: string): string[] {
|
|
const found: string[] = [];
|
|
for (const name of readdirSync(dir)) {
|
|
const p = join(dir, name);
|
|
const st = lstatSync(p);
|
|
if (st.isSymbolicLink()) { if (name === 'SKILL.md') found.push(p); continue; }
|
|
if (st.isDirectory()) found.push(...symlinkedSkillMds(p));
|
|
}
|
|
return found;
|
|
}
|
|
|
|
/**
|
|
* Section pointers in installed SKILL.md files that do not resolve to a
|
|
* readable file (INV-3, ENG-1). A pointer is "Read `<path>/sections/<f>.md`",
|
|
* optionally "relative to the installed `<skill>` SKILL.md directory". A bare
|
|
* `sections/...` pointer counts in a carved skill (sections/ installed, or a
|
|
* **STOP.** line); prefixed ones count everywhere. Same rule as ./setup --status.
|
|
*/
|
|
function brokenSectionPointers(dest: string, runtimeRoot: string, home: string): string[] {
|
|
const readable = (p: string) => { try { accessSync(p); return true; } catch { return false; } };
|
|
const broken: string[] = [];
|
|
for (const skill of readdirSync(dest)) {
|
|
const dir = join(dest, skill);
|
|
if (!existsSync(join(dir, 'SKILL.md'))) continue;
|
|
for (const line of readFileSync(join(dir, 'SKILL.md'), 'utf8').split('\n')) {
|
|
const stop = line.includes('**STOP.**');
|
|
for (const [, tok, rel] of line.matchAll(/Read `([^` ]*sections\/[A-Za-z0-9._-]+\.md)`((?: relative to the installed (?:`[^`]+`\/?)+)?)/g)) {
|
|
const names = [...rel.matchAll(/`([^`]+)`/g)].map(m => m[1]);
|
|
let targets: string[];
|
|
if (tok.startsWith('sections/')) {
|
|
if (names.length) targets = names.map(n => join(dest, n, tok));
|
|
else if ((existsSync(join(dir, 'sections')) && readdirSync(join(dir, 'sections'), { withFileTypes: true }).some(e => e.name.endsWith('.md') && e.name !== SHARED_PREAMBLE_FILE)) || stop) targets = [join(dir, tok)];
|
|
else continue;
|
|
} else if (tok.startsWith('$GSTACK_ROOT/')) targets = [join(runtimeRoot, tok.slice('$GSTACK_ROOT/'.length))];
|
|
else if (tok.startsWith('~/')) targets = [join(home, tok.slice(2))];
|
|
else if (tok.startsWith('/')) targets = [tok];
|
|
else if (tok.startsWith('../')) targets = [join(dir, tok)];
|
|
else continue;
|
|
if (!targets.some(readable)) broken.push(`${skill}: ${tok}`);
|
|
}
|
|
}
|
|
}
|
|
return [...new Set(broken)];
|
|
}
|
|
|
|
describe.skipIf(process.platform === 'win32')('host conformance kit', () => {
|
|
test('the kit covers every installable host', () => {
|
|
expect(Object.keys(DISCOVERY).sort()).toEqual([...installable].sort());
|
|
});
|
|
|
|
for (const host of installable) {
|
|
test(`${host}: installs only into its own discovery directory, registers, and reports`, () => {
|
|
const f = makeFixture();
|
|
const src = makeSource(f, join(f.dir, 'gstack'));
|
|
const r = runSetup(f, join(src, 'setup'), ['--host', host]);
|
|
expect(r.status, r.stdout + r.stderr).toBe(0);
|
|
|
|
const dest = join(f.home, DISCOVERY[host]);
|
|
const names = skillNames(dest);
|
|
expect(names.length, `${host} skills in ${dest}`).toBeGreaterThan(20);
|
|
expect(new Set(names).size, `duplicate skill names in ${dest}`).toBe(names.length);
|
|
for (const other of ALL_DISCOVERY_DIRS.filter(d => d !== DISCOVERY[host])) {
|
|
expect(existsSync(join(f.home, other)), `${host} install created ${other}`).toBe(false);
|
|
}
|
|
if (host !== 'claude') {
|
|
for (const name of readdirSync(dest).filter(n => n.startsWith('gstack-'))) {
|
|
const md = join(dest, name, 'SKILL.md');
|
|
if (existsSync(md)) expect(readSkillStartup(md), `${host}/${name} carries Claude paths`).not.toContain('~/.claude/skills/gstack');
|
|
}
|
|
}
|
|
// #2906: /cso skips the shared preamble, so it names its launcher by the
|
|
// host's literal install path; that path must reach this install's bin/.
|
|
const cso = ['cso', 'gstack-cso'].find(n => existsSync(join(dest, n, 'SKILL.md')));
|
|
expect(cso, `${host} cso skill`).toBeDefined();
|
|
const launcher = readFileSync(join(dest, cso!, 'SKILL.md'), 'utf8').match(/Use `([^`]+)\/gstack-cso-launcher\[\.exe\]`/);
|
|
expect(launcher, `${host} cso names its launcher`).not.toBeNull();
|
|
expect(realpathSync(launcher![1].replace(/^~(?=\/)/, f.home)), `${host} cso launcher dir`).toBe(realpathSync(join(src, 'bin')));
|
|
const rows = registryRows(f);
|
|
expect(rows.map(row => [row[0], row[1], row[3], row[5], row[6]])).toEqual([[host, 'global', dest, realpathSync(src), readFileSync(join(src, 'VERSION'), 'utf8').trim()]]);
|
|
expect(r.stdout + r.stderr).toMatch(new RegExp(`Install summary:[\\s\\S]*\\b${host}\\s+\\S+\\s+global\\s+installed`));
|
|
expect(r.stdout.trim().split('\n').at(-1)).toBe(`gstack ready (${host})`);
|
|
|
|
const status = runSetup(f, join(src, 'setup'), ['--status']);
|
|
expect(status.status).toBe(0);
|
|
expect(status.stdout).toMatch(new RegExp(`\\b${host}\\s+${ALL_HOST_CONFIGS.find(c => c.name === host)!.tier}\\s+global\\s+current`));
|
|
|
|
// C5 (#2651): OpenCode's builtin /review shadows the review skill, so
|
|
// /gstack-review loads it by the name the skill tool knows.
|
|
if (host === 'opencode') expect(readFileSync(join(f.home, '.config/opencode/commands/gstack-review.md'), 'utf8')).toContain('Load the `review` skill with the skill tool');
|
|
|
|
// INV-3 install-level checks (C2, C3, ENG-1, ENG-14).
|
|
if (host !== 'claude') {
|
|
const runtimeRoot = rows[0][4];
|
|
expect(symlinkedSkillMds(dest), `${host}: symlinked SKILL.md files (Codex skips them)`).toEqual([]);
|
|
for (const bin of ['design/dist/design', 'make-pdf/dist/pdf']) {
|
|
expect(existsSync(join(runtimeRoot, bin)), `${host} runtime root ${bin}`).toBe(true);
|
|
}
|
|
expect(brokenSectionPointers(dest, runtimeRoot, f.home), `${host}: unresolved section pointers`).toEqual([]);
|
|
expect(status.stdout).toMatch(new RegExp(`\\n ${host} global: router is a real file; section links: \\d+ checked, all resolve\\n`));
|
|
}
|
|
if (host === 'codex') expect(existsSync(join(src, '.agents/skills/gstack/design/dist/design')), 'agents sidecar design/dist').toBe(true);
|
|
}, 60_000);
|
|
}
|
|
|
|
test('opencode: every skill gets a managed /gstack-* command on the build agent; user commands survive (#2629)', () => {
|
|
const f = makeFixture();
|
|
const src = makeSource(f, join(f.dir, 'gstack'));
|
|
const commands = join(f.home, '.config/opencode/commands');
|
|
put(join(commands, 'gstack-review.md'), 'my own review command\n');
|
|
put(join(commands, 'gstack-retired.md'), '---\n---\n<!-- gstack-managed command (./setup --host opencode): edits are overwritten -->\nold\n');
|
|
expect(runSetup(f, join(src, 'setup'), ['--host', 'opencode']).status).toBe(0);
|
|
const ship = readFileSync(join(commands, 'gstack-ship.md'), 'utf8');
|
|
expect(ship).toMatch(/^---\ndescription: "[^"]+"\nagent: build\nsubtask: false\n---\n/);
|
|
// The skill tool loads by frontmatter name, not directory name (#2651).
|
|
expectTokens(ship, ['`ship`'], 'ship');
|
|
expect(ship).toContain('$ARGUMENTS');
|
|
expect(readFileSync(join(commands, 'gstack-review.md'), 'utf8')).toBe('my own review command\n');
|
|
expect(existsSync(join(commands, 'gstack-retired.md'))).toBe(false);
|
|
const un = Bun.spawnSync(['bash', join(src, 'bin/gstack-uninstall'), '--force', '--keep-state'], { cwd: f.home, env: f.env, timeout: 30_000 });
|
|
expect(un.exitCode).toBe(0);
|
|
expect(readdirSync(commands)).toEqual(['gstack-review.md']);
|
|
}, 60_000);
|
|
|
|
test.each(instructionOnly)('%s (instruction-only): truthful instructions, nothing written', (host) => {
|
|
const f = makeFixture();
|
|
const src = makeSource(f, join(f.dir, 'gstack'));
|
|
const before = tree(f.home);
|
|
const r = runSetup(f, join(src, 'setup'), ['--host', host]);
|
|
expect(r.status).toBe(0);
|
|
expect(tree(f.home)).toEqual(before);
|
|
expect(r.stdout).not.toMatch(/gstack ready|Install summary/);
|
|
}, 30_000);
|
|
|
|
test('--status is read-only and lists unregistered installs from before the registry', () => {
|
|
const f = makeFixture();
|
|
const src = makeSource(f, join(f.dir, 'gstack'));
|
|
expect(runSetup(f, join(src, 'setup'), ['--host', 'codex']).status).toBe(0);
|
|
rmSync(join(f.home, '.gstack/installs.tsv'));
|
|
const before = tree(f.dir);
|
|
const status = runSetup(f, join(src, 'setup'), ['--status']);
|
|
expect(status.status).toBe(0);
|
|
expect(tree(f.dir)).toEqual(before);
|
|
expect(status.stdout).toMatch(/codex\s+experimental\s+global\s+unregistered/);
|
|
expect(status.stdout).toContain(`register it: cd ${realpathSync(src)} && ./setup --host codex`);
|
|
}, 60_000);
|
|
|
|
test('--status names a symlinked router and a broken section link per host (C3)', () => {
|
|
const f = makeFixture();
|
|
const src = makeSource(f, join(f.dir, 'gstack'));
|
|
expect(runSetup(f, join(src, 'setup'), ['--host', 'codex']).status).toBe(0);
|
|
const router = join(f.home, '.codex/skills/gstack/SKILL.md');
|
|
rmSync(router);
|
|
symlinkSync(join(src, '.agents/skills/gstack/SKILL.md'), router);
|
|
rmSync(join(src, '.agents/skills/gstack-qa/sections/scope.md'));
|
|
const status = runSetup(f, join(src, 'setup'), ['--status']);
|
|
// A1: broken section links make --status exit 1 instead of always 0.
|
|
expect(status.status).toBe(1);
|
|
expect(status.stderr).toContain('broken section links');
|
|
expect(status.stdout).toMatch(/codex global: router is a symlink, which Codex skips\. Fix: cd \S+ && \.\/setup --host codex; section links: [1-9]\d* of \d+ broken \(first: [^)]*\)\. Fix: cd /);
|
|
}, 60_000);
|
|
|
|
// Generated by /ship Step 7 coverage audit (GSTA-96).
|
|
// Value: protects=--status still checks bare sections/ pointers in a carved Claude skill whose installed sections/ is a directory symlink;
|
|
// fails_when=the carved-skill probe stops following a symlinked sections/ dir, so a missing section reads as "all resolve";
|
|
// why_new=the all-host status check above asserts external hosts only; the C3 case breaks a codex pointer that names its skill;
|
|
// seam=none; no_claim=non-Linux link layouts (Windows copies real files; this suite skips win32)
|
|
test('--status checks a carved Claude skill\'s bare section pointers through its symlinked sections/', () => {
|
|
const f = makeFixture();
|
|
const src = makeSource(f, join(f.dir, 'gstack'));
|
|
expect(runSetup(f, join(src, 'setup'), ['--host', 'claude']).status).toBe(0);
|
|
const sections = join(f.home, '.claude/skills/autoplan/sections');
|
|
expect(lstatSync(sections).isSymbolicLink(), sections).toBe(true);
|
|
expect(readFileSync(join(f.home, '.claude/skills/autoplan/SKILL.md'), 'utf8')).toContain('Read `sections/unattended.md`, end here');
|
|
rmSync(join(src, 'autoplan/sections/unattended.md'));
|
|
const status = runSetup(f, join(src, 'setup'), ['--status']);
|
|
expect(status.status, status.stdout + status.stderr).toBe(1);
|
|
expect(status.stdout).toMatch(/claude global: [^\n]*section links: [1-9]\d* of \d+ broken \(first: autoplan\/SKILL\.md names sections\/unattended\.md\)/);
|
|
}, 60_000);
|
|
|
|
test('upgrade from the previous release layout refreshes every installed host (#1925)', () => {
|
|
const f = makeFixture();
|
|
const src = makeSource(f, join(f.home, '.claude/skills/gstack'), '1.91.12.0');
|
|
for (const host of ['claude', 'codex']) expect(runSetup(f, join(src, 'setup'), ['--host', host]).status).toBe(0);
|
|
// v1.91.13.0 and earlier: same links, no registry, marker in ~/.gstack.
|
|
rmSync(join(f.home, '.gstack/installs.tsv'));
|
|
setVersion(src, '1.91.14.0');
|
|
// C3: a hand edit to the router copy is saved under the state root before
|
|
// the runtime root is replaced, and the refresh rewrites the copy.
|
|
const router = join(f.home, '.codex/skills/gstack/SKILL.md');
|
|
expect(lstatSync(router).isSymbolicLink()).toBe(false);
|
|
writeFileSync(router, readFileSync(router, 'utf8') + '\nmy local note\n');
|
|
|
|
const oldUpgrade = runSetup(f, join(src, 'setup'), []);
|
|
expect(oldUpgrade.status).toBe(0);
|
|
expect(registryRows(f).map(r => r[0])).toEqual(['claude']);
|
|
|
|
const upgrade = runSetup(f, join(src, 'setup'), ['--refresh-registered']);
|
|
expect(upgrade.status, upgrade.stdout + upgrade.stderr).toBe(0);
|
|
expect(upgrade.stdout).toContain(`Refreshing registered gstack installs from source: ${realpathSync(src)}`);
|
|
expect(upgrade.stdout).toMatch(/Upgrade summary:\n[\s\S]*claude\s+full\s+global\s+unchanged\s+1\.91\.14\.0[\s\S]*codex\s+experimental\s+global\s+installed\s+1\.91\.14\.0/);
|
|
expect(upgrade.stdout.trim().split('\n').at(-1)).toBe('gstack ready (claude, codex)');
|
|
expect(registryRows(f).map(r => [r[0], r[6]]).sort()).toEqual([['claude', '1.91.14.0'], ['codex', '1.91.14.0']]);
|
|
// The refreshed Codex install runs the new checkout's render.
|
|
expect(realpathSync(join(f.home, '.codex/skills/gstack-review/SKILL.md'))).toBe(join(realpathSync(src), '.agents/skills/gstack-review/SKILL.md'));
|
|
expect(readFileSync(router, 'utf8')).toBe(readFileSync(join(src, '.agents/skills/gstack/SKILL.md'), 'utf8'));
|
|
const saved = upgrade.stdout.match(/saved your edited (\S+) to (\S+) /);
|
|
expect(saved, upgrade.stdout).not.toBeNull();
|
|
expect(saved![1]).toBe(router);
|
|
expect(saved![2].startsWith(join(f.home, '.gstack/backups/skill-copies/'))).toBe(true);
|
|
expect(readFileSync(saved![2], 'utf8')).toEndWith('\nmy local note\n');
|
|
expect(upgrade.stdout).toContain(`refreshed SKILL.md copies in ${join(f.home, '.codex/skills/gstack')}: SKILL.md gstack-upgrade/SKILL.md office-hours/SKILL.md`);
|
|
}, 90_000);
|
|
|
|
test('a Codex namespace captured by a vendored project copy is reported, never repointed (#2879)', () => {
|
|
const f = makeFixture();
|
|
const global = makeSource(f, join(f.home, '.claude/skills/gstack'));
|
|
const project = join(f.dir, 'proj');
|
|
mkdirSync(join(project, '.git'), { recursive: true });
|
|
const vendored = makeSource(f, join(project, '.claude/skills/gstack'), '1.80.0.0');
|
|
// Pre-fix capture: the vendored copy registered itself globally.
|
|
expect(runSetup(f, join(vendored, 'setup'), ['--host', 'codex', '--global']).status).toBe(0);
|
|
rmSync(join(f.home, '.gstack/installs.tsv'));
|
|
const codexBefore = tree(join(f.home, '.codex'));
|
|
|
|
const status = runSetup(f, join(global, 'setup'), ['--status']);
|
|
expect(status.stdout).toContain(`captured by the project-vendored copy at ${realpathSync(vendored)} (#2879)`);
|
|
const upgrade = runSetup(f, join(global, 'setup'), ['--refresh-registered']);
|
|
expect(upgrade.status, upgrade.stdout + upgrade.stderr).toBe(0);
|
|
expect(upgrade.stdout).toMatch(/codex\s+experimental\s+global\s+skipped/);
|
|
expect(upgrade.stdout).toContain('choose: refresh it there');
|
|
expect(tree(join(f.home, '.codex'))).toEqual(codexBefore);
|
|
}, 90_000);
|
|
|
|
test('a host that fails mid-upgrade keeps its last install and gets a retry command', () => {
|
|
const f = makeFixture();
|
|
const src = makeSource(f, join(f.home, '.claude/skills/gstack'), '1.91.12.0');
|
|
for (const host of ['claude', 'codex']) expect(runSetup(f, join(src, 'setup'), ['--host', host]).status).toBe(0);
|
|
setVersion(src, '1.91.14.0');
|
|
const codexBefore = tree(join(f.home, '.codex'));
|
|
// Break only the Codex arm: its skills directory refuses writes.
|
|
chmodSync(join(f.home, '.codex/skills'), 0o555);
|
|
let upgrade;
|
|
try {
|
|
upgrade = runSetup(f, join(src, 'setup'), ['--refresh-registered']);
|
|
} finally {
|
|
chmodSync(join(f.home, '.codex/skills'), 0o755);
|
|
}
|
|
expect(upgrade.status).toBe(1);
|
|
expect(upgrade.stdout).toContain('NOT every install was refreshed');
|
|
expect(upgrade.stdout).toMatch(/claude\s+full\s+global\s+updated\s+1\.91\.12\.0 -> 1\.91\.14\.0/);
|
|
expect(upgrade.stdout).toMatch(/codex\s+experimental\s+global\s+failed/);
|
|
expect(upgrade.stdout).toContain(`Retry: cd ${realpathSync(src)} && ./setup --host codex`);
|
|
expect(tree(join(f.home, '.codex'))).toEqual(codexBefore);
|
|
expect(registryRows(f).find(r => r[0] === 'codex')![6]).toBe('1.91.12.0');
|
|
}, 90_000);
|
|
|
|
test('first run from the published instructions ends in a skill that starts', () => {
|
|
const f = makeFixture();
|
|
// README: git clone … ~/.claude/skills/gstack && cd ~/.claude/skills/gstack && ./setup
|
|
const src = makeSource(f, join(f.home, '.claude/skills/gstack'));
|
|
const r = runSetup(f, join(src, 'setup'), [], { cwd: src });
|
|
expect(r.status, r.stdout + r.stderr).toBe(0);
|
|
expect(r.stdout).toContain('Chromium install skipped by request');
|
|
const skill = readFileSync(join(f.home, '.claude/skills/office-hours/SKILL.md'), 'utf8');
|
|
const fence = skill.slice(skill.indexOf('## Preamble')).match(/```bash\n([\s\S]*?)\n```/)![1];
|
|
const work = join(f.dir, 'repo');
|
|
mkdirSync(work);
|
|
const start = Bun.spawnSync(['bash', '-c', fence], { cwd: work, env: { ...f.env }, timeout: 30_000 });
|
|
const out = start.stdout.toString();
|
|
expect(out, start.stderr.toString()).toContain('SKILL_START_PROTO: 1');
|
|
expect(out).not.toContain('SKILL_START: unavailable');
|
|
expect(readdirSync(work)).toEqual([]);
|
|
// The default root serves the committed render.
|
|
expect(registryRows(f).map(row => row[8])).toEqual(['committed']);
|
|
expect(existsSync(join(f.home, '.gstack/render/installs'))).toBe(false);
|
|
}, 90_000);
|
|
|
|
// #1882 / #2763: an install outside ~/.claude/skills/gstack serves skills
|
|
// rendered for its own root, with the one literal start line worktree-
|
|
// isolated Claude Code runs (a plain path: a root with a space is named
|
|
// through an alias), and never touches another install or the tracked render.
|
|
test('renamed, vendored and space-in-path installs start skills from their own root (#1882)', () => {
|
|
const f = makeFixture();
|
|
const renamed = makeSource(f, join(f.home, '.claude/skills/gstack-dev'));
|
|
const project = join(f.dir, 'my proj');
|
|
mkdirSync(join(project, '.git'), { recursive: true });
|
|
const vendored = makeSource(f, join(project, '.claude/skills/gstack'));
|
|
for (const [src, cwd] of [[renamed, renamed], [vendored, project]]) {
|
|
const r = runSetup(f, join(src, 'setup'), [], { cwd });
|
|
expect(r.status, r.stdout + r.stderr).toBe(0);
|
|
expect(r.stderr).not.toContain('could not render skills');
|
|
}
|
|
const fence = (text: string, heading: string) => text.slice(text.indexOf(heading)).match(/```bash\n([\s\S]*?)\n```/)![1];
|
|
const renders = new Set<string>();
|
|
for (const [skills, root] of [[join(f.home, '.claude/skills'), renamed], [join(project, '.claude/skills'), vendored]]) {
|
|
const row = registryRows(f).find(r => r[0] === 'claude' && r[3] === skills)!;
|
|
expect(row[4]).toBe(root);
|
|
const render = row[8];
|
|
expect(render).toStartWith(join(f.home, '.gstack/render/installs/claude-'));
|
|
renders.add(render);
|
|
const md = join(skills, 'review/SKILL.md');
|
|
expect(realpathSync(md)).toBe(join(realpathSync(render), 'review/SKILL.md'));
|
|
const text = readSkillStartup(md);
|
|
expect(text).not.toContain('~/.claude/skills/gstack/');
|
|
const start = fence(text, '## Preamble');
|
|
const named = start.slice(0, start.indexOf('/bin/gstack-skill-start'));
|
|
expect(start).toBe(`${named}/bin/gstack-skill-start --skill "review" --model "claude"`);
|
|
expect(named).toMatch(/^\/[A-Za-z0-9_.@+\/-]+$/);
|
|
expect(realpathSync(named)).toBe(realpathSync(root));
|
|
expect(named === root).toBe(!/\s/.test(root));
|
|
expect(fence(text, '## Context Recovery')).toBe(`${named}/bin/gstack-context-recovery`);
|
|
const work = mkdtempSync(join(f.dir, 'work-'));
|
|
const run = Bun.spawnSync(['bash', '-c', start], { cwd: work, env: f.env, timeout: 30_000 });
|
|
expect(run.stdout.toString(), run.stderr.toString()).toContain('SKILL_START_PROTO: 1');
|
|
expect(Bun.spawnSync(['bash', '-c', fence(text, '## Context Recovery')], { cwd: work, env: f.env, timeout: 30_000 }).exitCode).toBe(0);
|
|
}
|
|
expect(renders.size).toBe(2);
|
|
// The tracked render stays portable; no default install was created.
|
|
expect(readFileSync(join(renamed, 'review/SKILL.md'), 'utf8')).toContain('~/.claude/skills/gstack/bin/gstack-skill-start --skill "review"');
|
|
expect(existsSync(join(f.home, '.claude/skills/gstack'))).toBe(false);
|
|
// A later relink keeps serving the recorded render.
|
|
const relink = Bun.spawnSync(['bash', join(renamed, 'bin/gstack-relink')], { cwd: f.home, env: f.env, timeout: 60_000 });
|
|
expect(relink.exitCode, relink.stderr.toString()).toBe(0);
|
|
expect(realpathSync(join(f.home, '.claude/skills/review/SKILL.md')).startsWith(realpathSync(join(f.home, '.gstack/render/installs')))).toBe(true);
|
|
}, 120_000);
|
|
|
|
test('CLAUDE_CONFIG_DIR and CODEX_HOME installs name their own roots (#1882, #2906)', () => {
|
|
const f = makeFixture();
|
|
const config = join(f.dir, 'claude-config');
|
|
const codexHome = join(f.dir, 'codex-home');
|
|
const env = { CLAUDE_CONFIG_DIR: config, CODEX_HOME: codexHome };
|
|
const src = makeSource(f, join(config, 'skills/gstack'));
|
|
for (const host of ['claude', 'codex']) {
|
|
const r = runSetup(f, join(src, 'setup'), ['--host', host], { cwd: src, env });
|
|
expect(r.status, r.stdout + r.stderr).toBe(0);
|
|
}
|
|
const claude = readFileSync(join(config, 'skills/review/SKILL.md'), 'utf8');
|
|
expect(claude).toContain(`\n${src}/bin/gstack-skill-start --skill "review" --model "claude"\n`);
|
|
const codex = readFileSync(join(codexHome, 'skills/gstack-review/SKILL.md'), 'utf8');
|
|
expect(codex).toContain(`GSTACK_ROOT="${codexHome}/skills/gstack"`);
|
|
expect(readFileSync(join(codexHome, 'skills/gstack-cso/SKILL.md'), 'utf8')).toContain(`Use \`${codexHome}/skills/gstack/bin/gstack-cso-launcher[.exe]\``);
|
|
expect(realpathSync(join(codexHome, 'skills/gstack/bin'))).toBe(realpathSync(join(src, 'bin')));
|
|
const rows = registryRows(f);
|
|
expect(rows.map(r => [r[0], r[8].startsWith(join(f.home, '.gstack/render/installs/'))]).sort()).toEqual([['claude', true], ['codex', true]]);
|
|
for (const dir of ['.claude', '.codex']) expect(existsSync(join(f.home, dir)), dir).toBe(false);
|
|
}, 120_000);
|
|
});
|