SPB Git

Repository Public

scenario.ts 2.5 KB 47 lines typescript

1/** The multi-turn scripted mission of the crash suite: parallel reads, write, edit, shell, commit, a question, criteria, finish. */2import type { ScriptItem } from '../../src/testkit/index.js';34export const SCENARIO_FILES: Record<string, string> = {5  'a.txt': 'alpha\n',6  'src/calc.js': 'export const add = (a, b) => a - b;\n',7};8export const SCENARIO_CRITERIA = ['add() adds', 'the work is committed'];9export const SCENARIO_ANSWER = 'Yes, go ahead.';1011export const SCENARIO: ScriptItem[] = [12  {13    text: 'Reading the workspace.',14    calls: [15      { name: 'read_file', input: { path: 'a.txt', offset: null, limit: null } },16      { name: 'read_file', input: { path: 'src/calc.js', offset: null, limit: null } },17      { name: 'list_dir', input: { path: '.', depth: null } },18    ],19  },20  {21    text: 'Fixing the bug and taking notes.',22    calls: [23      { name: 'write_file', input: { path: 'notes.md', content: '# Notes\nadd() subtracted instead of adding.\n' } },24      { name: 'edit_file', input: { path: 'src/calc.js', oldString: 'a - b', newString: 'a + b', replaceAll: null } },25    ],26  },27  // An observable, NON-idempotent effect: a second execution would leave two lines (and print 2).28  { calls: [{ name: 'shell', input: { command: 'echo tick >> counter.log && wc -l < counter.log | tr -d " "', timeoutSec: null } }] },29  { calls: [{ name: 'git_commit', input: { message: 'Fix add()', paths: null } }] },30  { calls: [{ name: 'ask_owner', input: { question: 'The fix is committed. May I mark the mission done?', options: null } }] },31  {32    calls: [33      { name: 'update_criteria', input: { updates: [{ id: 'c1', passes: true, evidence: 'src/calc.js now returns a + b' }, { id: 'c2', passes: true, evidence: 'git_commit: Fix add()' }] } },34      { name: 'git_status', input: {} },35    ],36  },37  { calls: [{ name: 'finish', input: { status: 'done', summary: 'Fixed add() and committed it.', reason: null, evidence: [{ criterion: 'c1', kind: 'file', detail: 'src/calc.js' }], openQuestions: [] } }] },38];3940const STOP = { name: 'finish', input: { status: 'partial', summary: 'Stopping.', reason: 'test', evidence: [], openQuestions: [] } };41/** Non-idempotent calls: a push (has a reconcile probe) and a shell command with network access (has none). */42export const SCENARIOS: Record<string, ScriptItem[]> = {43  main: SCENARIO,44  push: [{ calls: [{ name: 'git_push', input: { remote: null, branch: null } }] }, { calls: [STOP] }],45  netshell: [{ calls: [{ name: 'shell', input: { command: 'echo tick >> counter.log', timeoutSec: null } }] }, { calls: [STOP] }],46};47
Files main
Menu

Theme