| 28 | |
| 29 | // Answers for the pad CLI, keyed by its first words. |
| 30 | function cliAnswer(argv: readonly string[], calls: string[][]) { |
| 31 | const a = argv.slice(1).filter((x) => x !== '--format' && x !== 'json') |
| 32 | calls.push(a) |
| 33 | const key = a.slice(0, 2).join(' ') |
| 34 | const out: Record<string, unknown> = { |
| 35 | 'bootstrap': { workspace: { slug: 'demo', name: 'Demo' } }, |
| 36 | 'project dashboard': DASHBOARD, |
| 37 | 'project ready': { count: 1, results: [{ item_ref: 'TASK-8', item_title: 'Write docs', collection: 'tasks', reason: 'high priority' }] }, |
| 38 | 'project activity': [{ id: 'a1', action: 'commented', actor_name: 'Dave', metadata: '{"agent":"wren"}', item_ref: 'TASK-7', item_title: 'Fix the login bug', created_at: new Date().toISOString() }], |
| 39 | 'collection list': COLLECTIONS, |
| 40 | 'item show': ITEM, |
| 41 | 'item comments': [{ body: 'Started on it.', agent_name: 'wren', created_at: new Date().toISOString() }], |
| 42 | 'item list': [{ ref: 'TASK-7', title: 'Fix the login bug', fields: { status: 'in-progress' } }, { ref: 'TASK-9', title: 'Tidy', fields: { status: 'open' } }], |
| 43 | 'item search': { results: [{ item: { ref: 'TASK-7', title: 'Fix the login bug', fields: { status: 'in-progress' } }, rank: 1, snippet: '' }] }, |
| 44 | 'item update': { ref: a[2] }, |
| 45 | 'item comment': { ok: true }, |
| 46 | 'item create': { ref: 'TASK-10', title: a[3] }, |
| 47 | 'server info': { config: { base_url: 'http://pad.lan:7777/' } }, |
| 48 | } |
| 49 | const k = a[0] === 'bootstrap' ? 'bootstrap' : key |
| 50 | return { exitCode: 0, stdout: JSON.stringify(out[k] ?? {}), stderr: '' } |
| 51 | } |
| 52 | |
| 53 | function stubs(on: any, opts: { cli?: boolean; mcp?: boolean; linked?: boolean; onFill?: (t: string) => void; claudeRuns?: string[][]; copied?: string[]; tomlUrl?: string } = {}) { |
| 54 | const cli = opts.cli !== false |