mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-12 19:44:48 +01:00
fix(capy): installer picks the loadout from the owner's agent_model preference when no model is named (GST-982)
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
9d9d4c31bb
commit
2914ff451a
5 files changed
+75
-8
No files matched your search
@@ -593,6 +593,59 @@ describe('gstack-capy-install: launch PATH, Bun reuse, CI pins, setup skip, verd
|
||||
expect(fs.existsSync(lite)).toBe(true);
|
||||
});
|
||||
|
||||
test('with no --model and no GSTACK_MODEL, the agent_model in the session preferences file picks the loadout (GST-982); GSTACK_MODEL still wins and a host preference serves full', () => {
|
||||
const f = fixture();
|
||||
script(path.join(f.root, 'bin/gstack-modules'), [
|
||||
'echo "modules $*" >> "$CAPY_LOG"',
|
||||
'model="${GSTACK_MODEL:-}" full=""; while [ $# -gt 0 ]; do case "$1" in --model) model="$2"; shift ;; --full-root) full="$2"; shift ;; esac; shift; done',
|
||||
'case "$model" in',
|
||||
' claude-opus-5-5) mkdir -p "$HOME/lite-0123456789ab"; echo "LOADOUT: lite model=claude-opus-5-5 source=model-flag digest=0123456789ab reused=no"; echo "SKILL_ROOT: $HOME/lite-0123456789ab" ;;',
|
||||
' *) echo "LOADOUT: full model=none source=GSTACK_MODEL reason=unmapped"; echo "SKILL_ROOT: $full" ;;',
|
||||
'esac',
|
||||
]);
|
||||
script(path.join(f.root, 'bin/gstack-models'), [
|
||||
'echo "models $* prefs=${GSTACK_PREFERENCES_FILE:-}" >> "$CAPY_LOG"',
|
||||
'case "$(sed -n "s/^agent_model: *//p" "${GSTACK_PREFERENCES_FILE:-/dev/null}" 2>/dev/null)" in',
|
||||
' opus) echo "agent: anthropic/claude-opus-5-5 (opus) - from agent_model in $GSTACK_PREFERENCES_FILE, the preferences file" ;;',
|
||||
' *) echo "agent: host - keep the running agent\'s own model and omit the model field (no preference set)" ;;',
|
||||
'esac',
|
||||
]);
|
||||
const prefs = path.join(f.home, 'drive-skill/preferences.yaml');
|
||||
write(prefs, 'agent_model: opus\n');
|
||||
const launchOf = (out: string) => out.match(/^GSTACK_LAUNCH_FILE: (.+)$/m)![1];
|
||||
const opus = run(f, ['--for', 'ship'], { GSTACK_PREFERENCES_FILE: prefs });
|
||||
expect(opus.status, opus.stdout + opus.stderr).toBe(0);
|
||||
expect(f.calls().filter(l => l.startsWith('modules '))).toEqual([`modules install --model claude-opus-5-5 --full-root ${f.home}/.claude/skills`]);
|
||||
expect(opus.stdout).toContain(`LOADOUT: lite model=claude-opus-5-5 source=preferences digest=0123456789ab reused=no\nSKILL_ROOT: ${f.home}/lite-0123456789ab\n`);
|
||||
expect(launchOf(opus.stdout)).toBe(verdicts(f)[0].replace(/\.json$/, '.loadout-lite-0123456789ab.env'));
|
||||
|
||||
const env = run(f, ['--for', 'ship'], { GSTACK_PREFERENCES_FILE: prefs, GSTACK_MODEL: 'claude-sonnet-5-5' });
|
||||
expect(env.status, env.stdout + env.stderr).toBe(0);
|
||||
expect(f.calls().filter(l => l.startsWith('modules ')).at(-1)).toBe(`modules install --full-root ${f.home}/.claude/skills`);
|
||||
expect(env.stdout).toContain('LOADOUT: full model=none source=GSTACK_MODEL reason=unmapped\n');
|
||||
|
||||
write(prefs, 'agent_model: host\n');
|
||||
const host = run(f, ['--for', 'ship'], { GSTACK_PREFERENCES_FILE: prefs });
|
||||
expect(host.status, host.stdout + host.stderr).toBe(0);
|
||||
expect(host.stdout).not.toMatch(/^(LOADOUT|SKILL_ROOT):/m);
|
||||
expect(launchOf(host.stdout)).toBe(verdicts(f)[0].replace(/\.json$/, '.env'));
|
||||
});
|
||||
|
||||
test('the first line of gstack-models resolve --role agent keeps the provider/model shape the installer reads (GST-982)', () => {
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'gst982-'));
|
||||
try {
|
||||
for (const [pref, want] of [['opus', /^agent: anthropic\/claude-opus-[0-9a-z.-]+ \(opus\) /], ['host', /^agent: host /]] as const) {
|
||||
const file = path.join(dir, `${pref}.yaml`);
|
||||
fs.writeFileSync(file, `agent_model: ${pref}\n`);
|
||||
const out = spawnSync(path.join(REPO, 'bin/gstack-models'), ['resolve', '--role', 'agent'], { encoding: 'utf8', timeout: 30_000, env: { ...process.env, GSTACK_PREFERENCES_FILE: file, GSTACK_STATE_ROOT: dir, GSTACK_HOME: dir } });
|
||||
expect(out.status, out.stderr).toBe(0);
|
||||
expect(out.stdout.split('\n')[0]).toMatch(want);
|
||||
}
|
||||
} finally {
|
||||
fs.rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test('the verdict file records checkout, HEAD, workflow, trailer and the Bun resolution, keyed by checkout and project; --check certifies without setup or downloads', () => {
|
||||
const f = fixture();
|
||||
const r = run(f, ['--for', 'autoplan']);
|
||||
|
||||
Reference in new issue
Block a user