mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-02 15:04:37 +01:00
* fix(eval-plan): per-arm pilot projection and --seat-metered arms (#3653) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(autoplan): guard tolerates Claude Code's cwd-reset footer and recovers after an unreadable init (#3651) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: pre-landing review fixes (journal reader strips the cwd-reset footer; an init with no text block no longer locks the session) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: journal reader skips a failed or unreadable init, as invocation() does Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * feat(autoplan): --ceo-only runs the CEO review alone with zero questions (GST-537) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test(eval-plan): all-seat pilot, single-attempt arm and --seat-metered CLI wiring Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(eval-plan): summed deviation adds arm deviations, matching the summed band (arms share rows) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: pre-landing review fixes (test pins an unpriced seat-metered arm) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: pre-landing review fixes (seat-metered declaration fixed per --out, price row still required, a real charge settles as spent) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: pre-landing review fixes Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: classify autoplan-ceo-only in the Codex host metadata Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: a seat-metered arm that settles a charge is projected as a priced arm Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: select autoplan-ceo-only on the skills it runs; say it needs Claude Code Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs(skills): /eval-plan --seat-metered and per-arm projection Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(eval-plan): skill prose stays under its context budget and carries no $N token Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: run autoplan-ceo-only in the marathon lane Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs(skills): a seat-metered arm leaves the seat set once it settles a charge Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: changelog entry for /autoplan --ceo-only Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs(autoplan): init_failed covers unreadable init output and the cwd-reset line (#3651) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: count the autoplan-ceo-only paid file in the shard inventory Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test(autoplan): #3651 tests pass the test-code type ratchet Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(dx): CAP finding titles carry a one-line description (GBRA-223 claim 2) The DX error contract told both autoplan DX voices to title capped findings exactly CAP4:<path>:<item>, so gates, tasks and reconcile saw a bare code. The title is now CAP4:<path>:<item> <what fails>; the grader already parses that shape. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(autoplan): reconcile pairs same-file findings that carry no line (GBRA-223 claim 1) Plan reviews name files, rarely lines, and reconcile associated by location only when both findings had a line, so findings both voices raised on one file were filed new and native-only. A same-file pair with a missing line is now associated as unverified (basis file), never confirmed; a CAP code no longer counts in title comparison. DRIVER.md names submit --reconcile. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(autoplan): open Critical and High findings reach the gate as apply items (GBRA-223 claim 3) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(autoplan): a spend cap binds on every unattended host; --estimate-usd persists; DRIVER names --usage-usd (GBRA-223 claim 4) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(autoplan): run binds complete api results, names a truncated response, --max-tokens; DRIVER documents run (GBRA-223 claim 6) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * feat(autoplan): carry an item-by-item answer when the later gate asks nothing new (GBRA-223 claim 7) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(dx): trim the compact error contract so plan-devex-review stays under its size pin Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: pre-landing review fixes (p1b applies finding fixes, api attempts reserve no host default, cross-file title pairing, paired severity counted) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: review fixes (priced api reservations, no file-only twins, two-pass pairing, partial replies keep p1-dependent defaults open, outside refusal degrades) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * P7: record whose words answered a gate (--words-by agent:<id>), never carry an agent's own words, import each row under its own answerer (GEVA-2) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: review pass 2 (p1b needs --rec-hash after recommend; api calls send the output limit they reserve for) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * changelog: fragment for the /autoplan field-report wave (GST-672) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: captain record notes --words-by agent attribution Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: follow finding apply items in approval-class and Captain flow tests; bind run-api limit to DEFAULT_MAX_TOKENS Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * wave autoplan: lower the gemini plan-devex-review pin to its exact size after #3781's DX trim Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(autoplan): CAP titles on different paths never match by title in reconcile or confirm rounds (wave review) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(autoplan): a truncated api call settles its cost and a retry is admitted afresh against the cap Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(autoplan): an applied finding stays open until the revised plan is reviewed; a shared location alone never twins two findings Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(approval): a plan gate answered in an agent's own words is not owner approval Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(gate): a new answer replaces the earlier answer's authorship and words Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(autoplan): a failed api call with no usage keeps its attempt open; reservations price the bound prompt (wave fix-check) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(autoplan): a spend cap fails closed: only a call refused before sending keeps its attempt; a sent call with unknown usage settles at its reservation Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs(autoplan): the 16384 output default applies to both providers; changelog for the wave's integrator fixes Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs(autoplan): how run settles a failed api call; changelog scopes it to the native voice Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(autoplan): a spend cap fails closed on every exit of run; an unpriced model reserves the default once a cap is set Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs(autoplan): every sent call settles; an unpriced model under a cap reserves the default Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs(autoplan): DRIVER and help say a cap reserves in any session kind and how run settles a sent call 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>
133 lines
8.3 KiB
TypeScript
Executable File
133 lines
8.3 KiB
TypeScript
Executable File
#!/usr/bin/env -S bun --no-env-file --config=/dev/null
|
|
/**
|
|
* gstack-outside-voice — run the outside voice through one pluggable runner (plan B3).
|
|
*
|
|
* gstack-outside-voice run --runner codex-cli|api|host-subagent --prompt <file> --out <file>
|
|
* [--model <id>] [--result <file>] [--native-model <id>] [--fallback <runner>]
|
|
* [--gate review|structured|spec|proposal] [--timeout-ms N] [--max-tokens N] [--cwd <dir>] [--json]
|
|
* gstack-outside-voice runners [--model <id>] [--json] the runner table: capabilities and availability here
|
|
* gstack-outside-voice family <model-id> the model's family (same-family rule)
|
|
*
|
|
* Logic: lib/outside-voice-runner.ts (adapters), lib/outside-voice-api.ts (api
|
|
* transport), lib/outside-review-result.ts (verdict). Codes: lib/result-codes.ts.
|
|
* Writes <out> (the review text) and <out>.meta.json (the terminal result).
|
|
* codex_reviews=disabled or an unreadable config refuses before any runner
|
|
* starts: not_run consent_missing, exit 3 (lib/outside-consent.ts).
|
|
*/
|
|
import * as fs from 'node:fs';
|
|
import * as path from 'node:path';
|
|
import { EXIT, exitTableHelp } from '../lib/headless-artifacts';
|
|
import type { OutsideGate } from '../lib/outside-review-result';
|
|
import { RUNNER_IDS, createRunner, familyConflict, modelFamily, outsideStatusLine, runnerTable, selectRunner, type RunnerId } from '../lib/outside-voice-runner';
|
|
import { outsideConsent } from '../lib/outside-consent';
|
|
import { apiTimeoutMs } from '../lib/outside-voice-api';
|
|
import { resultLine } from '../lib/result-codes';
|
|
|
|
const HELP = `gstack-outside-voice — one outside voice, three runners (docs/unattended.md)
|
|
|
|
run --runner <r> --prompt <file> --out <file> [--model <id>] [--result <file>] [--native-model <id>]
|
|
[--fallback <r>] [--gate review|structured|spec|proposal] [--timeout-ms N] [--max-tokens N] [--cwd <dir>] [--json]
|
|
runners [--model <id>] [--json] the runner table: id, capabilities, available here
|
|
family <model-id> print the model family (anthropic, openai, google, ...)
|
|
|
|
Runners: codex-cli (repository review via codex exec), api (supplied-input review via
|
|
OPENAI_API_KEY/ANTHROPIC_API_KEY; needs --model), host-subagent (binds --result from a
|
|
cross-family subagent the host ran; needs --model). --max-tokens caps the api runner's output
|
|
(Anthropic default 16384; its default time limit grows with it); a response cut off at the limit
|
|
is unavailable (truncated). --native-model enforces the same-family
|
|
rule. GSTACK_OUTSIDE_RUNNER names the fallback when --fallback is absent.
|
|
Prints OUTSIDE_STATUS: <status> provider=<runner> model=<id> family=<f> and writes <out>.meta.json.
|
|
codex_reviews=disabled (or an unreadable config) refuses every runner before it starts:
|
|
OUTSIDE_STATUS: not_run reason=consent_missing, exit 3. Enable: gstack-config set codex_reviews enabled.
|
|
${exitTableHelp()}`;
|
|
|
|
function flag(args: string[], name: string): string | undefined {
|
|
const i = args.indexOf(name);
|
|
return i >= 0 ? args[i + 1] : undefined;
|
|
}
|
|
function usage(message: string): number {
|
|
process.stderr.write(`gstack-outside-voice: ${message}\n${HELP}\n`);
|
|
return EXIT.usage;
|
|
}
|
|
const isRunner = (v: string | undefined): v is RunnerId => !!v && (RUNNER_IDS as readonly string[]).includes(v);
|
|
|
|
async function main(argv: string[]): Promise<number> {
|
|
const [cmd, ...rest] = argv;
|
|
const json = rest.includes('--json');
|
|
if (!cmd || cmd === '--help' || cmd === '-h' || cmd === 'help') { process.stdout.write(HELP + '\n'); return cmd ? EXIT.ok : EXIT.usage; }
|
|
|
|
if (cmd === 'family') {
|
|
const model = rest[0];
|
|
if (!model) return usage('family needs <model-id>');
|
|
process.stdout.write(`${modelFamily(model)}\n`);
|
|
return EXIT.ok;
|
|
}
|
|
if (cmd === 'runners') {
|
|
const table = runnerTable({ model: flag(rest, '--model'), resultFile: flag(rest, '--result') });
|
|
if (json) process.stdout.write(JSON.stringify(table) + '\n');
|
|
else for (const r of table) process.stdout.write(`${r.available ? 'READY' : 'UNAVAILABLE'} ${r.id} access=${r.capabilities.repository_access} label="${r.capabilities.label}"${r.reason ? ` (${r.reason})` : ''}\n`);
|
|
return EXIT.ok;
|
|
}
|
|
if (cmd !== 'run') return usage(`unknown command ${cmd}`);
|
|
|
|
const requested = flag(rest, '--runner');
|
|
const promptFile = flag(rest, '--prompt');
|
|
const outFile = flag(rest, '--out');
|
|
if (!isRunner(requested)) return usage(`--runner must be one of ${RUNNER_IDS.join(', ')}`);
|
|
if (!promptFile || !outFile) return usage('run needs --prompt <file> --out <file>');
|
|
if (!fs.existsSync(promptFile)) return usage(`prompt file not found: ${promptFile}`);
|
|
const gate = (flag(rest, '--gate') ?? 'review') as OutsideGate;
|
|
if (!['review', 'structured', 'spec', 'proposal'].includes(gate)) return usage('--gate must be review, structured, spec or proposal');
|
|
const maxTokensText = flag(rest, '--max-tokens');
|
|
const maxTokens = maxTokensText === undefined ? undefined : Number(maxTokensText);
|
|
if (maxTokens !== undefined && (!Number.isInteger(maxTokens) || maxTokens <= 0)) return usage('--max-tokens needs a positive integer');
|
|
const timeoutText = flag(rest, '--timeout-ms');
|
|
const timeoutMs = timeoutText === undefined ? undefined : Number(timeoutText);
|
|
if (timeoutMs !== undefined && (!Number.isInteger(timeoutMs) || timeoutMs <= 0)) return usage('--timeout-ms needs a positive integer');
|
|
const fallbackText = flag(rest, '--fallback') ?? process.env.GSTACK_OUTSIDE_RUNNER;
|
|
if (fallbackText !== undefined && !isRunner(fallbackText)) return usage(`--fallback must be one of ${RUNNER_IDS.join(', ')}`);
|
|
const model = flag(rest, '--model');
|
|
const nativeModel = flag(rest, '--native-model');
|
|
const cwd = path.resolve(flag(rest, '--cwd') ?? process.cwd());
|
|
const resultFile = flag(rest, '--result');
|
|
|
|
if (model && nativeModel) {
|
|
const conflict = familyConflict(model, nativeModel);
|
|
if (conflict) { process.stderr.write(resultLine('gstack-outside-voice run', 'MODEL_FAMILY_CONFLICT', conflict) + '\n'); return EXIT.refused; }
|
|
}
|
|
const consent = outsideConsent({ userInvoked: false });
|
|
if (!consent.allowed) {
|
|
const result = { status: 'not_run', reason: 'consent_missing', runner: requested, detail: consent.lines[0] };
|
|
fs.mkdirSync(path.dirname(path.resolve(outFile)), { recursive: true });
|
|
fs.writeFileSync(`${path.resolve(outFile)}.meta.json`, JSON.stringify(result, null, 2) + '\n');
|
|
process.stderr.write(consent.lines.join('\n') + '\n');
|
|
if (json) process.stdout.write(JSON.stringify(result) + '\n');
|
|
else process.stdout.write(`OUTSIDE_STATUS: not_run reason=consent_missing provider=${requested}\n`);
|
|
return EXIT.refused;
|
|
}
|
|
const choice = selectRunner(requested, { model, resultFile }, fallbackText);
|
|
if (!choice.runner) {
|
|
process.stderr.write(resultLine('gstack-outside-voice run', 'OUTSIDE_RUNNER_UNAVAILABLE', choice.reason) + '\n');
|
|
if (requested === 'codex-cli') process.stderr.write('Codex outside review unavailable: codex-cli not ready and no other runner configured. Missing coverage.\n');
|
|
return EXIT.refused;
|
|
}
|
|
if (choice.note) process.stderr.write(`${choice.note}\n`);
|
|
const runner = createRunner(choice.runner);
|
|
const stop = () => runner.cancel();
|
|
process.on('SIGTERM', stop);
|
|
process.on('SIGINT', stop);
|
|
const result = await runner.run({ promptFile: path.resolve(promptFile), outFile: path.resolve(outFile), model, timeoutMs: timeoutMs ?? (choice.runner === 'api' ? apiTimeoutMs(maxTokens) : 300_000), cwd, gate, maxTokens, resultFile: resultFile ? path.resolve(resultFile) : undefined });
|
|
fs.mkdirSync(path.dirname(path.resolve(outFile)), { recursive: true });
|
|
fs.writeFileSync(`${path.resolve(outFile)}.meta.json`, JSON.stringify(result, null, 2) + '\n');
|
|
if (json) process.stdout.write(JSON.stringify(result) + '\n');
|
|
else {
|
|
if (result.verdict) process.stdout.write(`VERDICT: ${result.verdict.verdict}\nFINDINGS: ${result.verdict.findings.highest ?? 'none'}\n`);
|
|
process.stdout.write(outsideStatusLine(result) + '\n');
|
|
}
|
|
if (result.status === 'completed' || result.status === 'unverified') return EXIT.ok;
|
|
if (result.reason || result.detail) process.stderr.write(`gstack-outside-voice run: ${result.runner} ${result.status}${result.reason ? ` (${result.reason})` : ''}${result.detail ? `: ${result.detail}` : ''}\n`);
|
|
return EXIT.fail;
|
|
}
|
|
|
|
process.exitCode = await main(process.argv.slice(2));
|