@ordewell/core 0.5.4 → 0.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/IFileSystem-BkPX7mLD.d.mts +76 -0
  2. package/dist/IFileSystem-C0l-4MGT.d.ts +76 -0
  3. package/dist/{ModeResolver-Dkig8ghQ.d.ts → ModeResolver--16lh7dS.d.mts} +1 -1
  4. package/dist/{ModeResolver-DVJ7HV3k.d.mts → ModeResolver-CjpG5Wli.d.ts} +1 -1
  5. package/dist/Task-Dyxp67s2.d.mts +2086 -0
  6. package/dist/Task-Dyxp67s2.d.ts +2086 -0
  7. package/dist/{chunk-T2S5O36I.mjs → chunk-C44UWIAD.mjs} +6 -6
  8. package/dist/chunk-C44UWIAD.mjs.map +1 -0
  9. package/dist/{chunk-JVMDEHRQ.mjs → chunk-EDGUFCIR.mjs} +77 -37
  10. package/dist/chunk-EDGUFCIR.mjs.map +1 -0
  11. package/dist/{chunk-XWOUIA6A.mjs → chunk-JBEFAJ2W.mjs} +2 -2
  12. package/dist/chunk-ROVYWEBI.mjs +2115 -0
  13. package/dist/chunk-ROVYWEBI.mjs.map +1 -0
  14. package/dist/index.d.mts +1647 -758
  15. package/dist/index.d.ts +1647 -758
  16. package/dist/index.js +9301 -4857
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +6222 -2968
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/order-labels.d.mts +3 -1
  21. package/dist/order-labels.d.ts +3 -1
  22. package/dist/{parsing-DRp4dPC0.d.mts → parsing-DPEpAszP.d.mts} +11 -3
  23. package/dist/{parsing-CF_grC29.d.ts → parsing-EcmCsF1y.d.ts} +11 -3
  24. package/dist/parsing.d.mts +5 -3
  25. package/dist/parsing.d.ts +5 -3
  26. package/dist/parsing.js.map +1 -1
  27. package/dist/parsing.mjs +2 -2
  28. package/dist/plan-utils-BAvW3hvl.d.mts +877 -0
  29. package/dist/plan-utils-BMyEiDKv.d.ts +877 -0
  30. package/dist/plan-utils.d.mts +5 -4
  31. package/dist/plan-utils.d.ts +5 -4
  32. package/dist/plan-utils.js +956 -8
  33. package/dist/plan-utils.js.map +1 -1
  34. package/dist/plan-utils.mjs +47 -7
  35. package/dist/testing.d.mts +57 -5
  36. package/dist/testing.d.ts +57 -5
  37. package/dist/testing.js +96 -2
  38. package/dist/testing.js.map +1 -1
  39. package/dist/testing.mjs +94 -2
  40. package/dist/testing.mjs.map +1 -1
  41. package/package.json +2 -1
  42. package/skills/grilling/SKILL.md +6 -16
  43. package/skills/improve-codebase-architecture/SKILL.md +1 -1
  44. package/dist/ApprovalPolicy-BVhGdECT.d.mts +0 -79
  45. package/dist/ApprovalPolicy-BVhGdECT.d.ts +0 -79
  46. package/dist/ITerminalRunner-Bd-vAJnw.d.ts +0 -561
  47. package/dist/ITerminalRunner-ByeoLF57.d.mts +0 -561
  48. package/dist/Task-BxQkPlXO.d.mts +0 -664
  49. package/dist/Task-BxQkPlXO.d.ts +0 -664
  50. package/dist/chunk-GWPIYDQW.mjs +0 -945
  51. package/dist/chunk-GWPIYDQW.mjs.map +0 -1
  52. package/dist/chunk-JVMDEHRQ.mjs.map +0 -1
  53. package/dist/chunk-T2S5O36I.mjs.map +0 -1
  54. package/dist/plan-utils-CkNbqAmS.d.ts +0 -329
  55. package/dist/plan-utils-CtB3_Ovf.d.mts +0 -329
  56. /package/dist/{chunk-XWOUIA6A.mjs.map → chunk-JBEFAJ2W.mjs.map} +0 -0
package/dist/testing.mjs CHANGED
@@ -2,9 +2,12 @@ import {
2
2
  SELF_REPO,
3
3
  handoffOf,
4
4
  integrationBranchFor
5
- } from "./chunk-T2S5O36I.mjs";
5
+ } from "./chunk-C44UWIAD.mjs";
6
6
 
7
7
  // src/testing.ts
8
+ async function flushMicrotasks(rounds = 20) {
9
+ for (let i = 0; i < rounds; i += 1) await Promise.resolve();
10
+ }
8
11
  function fakeConfig(overrides = {}) {
9
12
  return {
10
13
  aiProvider: "openrouter",
@@ -91,6 +94,90 @@ var FakeTerminalSession = class {
91
94
  for (const cb of this.exitCbs) cb(code);
92
95
  }
93
96
  };
97
+ var FakeStructuredSession = class extends FakeTerminalSession {
98
+ constructor(id = "s1", taskId = "t1", sessionId = "native-1") {
99
+ super(id, taskId);
100
+ this.sessionId = sessionId;
101
+ }
102
+ sessionId;
103
+ transport = "structured";
104
+ state = "working";
105
+ messages = [];
106
+ /** Every message a turn was started with, in order. */
107
+ delivered = [];
108
+ interrupts = 0;
109
+ messageCount = 0;
110
+ turnEndCbs = [];
111
+ eventCbs = [];
112
+ write(text) {
113
+ super.write(text);
114
+ const message = text.trim();
115
+ if (message) this.sendMessage(message);
116
+ }
117
+ turnState() {
118
+ return this.state;
119
+ }
120
+ onTurnEnd(cb) {
121
+ this.turnEndCbs.push(cb);
122
+ }
123
+ onEvent(cb) {
124
+ this.eventCbs.push(cb);
125
+ }
126
+ sendMessage(text) {
127
+ this.messageCount += 1;
128
+ const id = `msg-${this.messageCount}`;
129
+ if (this.state === "idle") this.deliver(text);
130
+ else this.messages.push({ id, text });
131
+ return id;
132
+ }
133
+ removeQueued(id) {
134
+ const before = this.messages.length;
135
+ this.messages = this.messages.filter((m) => m.id !== id);
136
+ return this.messages.length < before;
137
+ }
138
+ queued() {
139
+ return this.messages.map((m) => ({ ...m }));
140
+ }
141
+ async interrupt() {
142
+ this.interrupts += 1;
143
+ if (this.state === "working") this.emitTurnEnd("interrupted");
144
+ }
145
+ nativeSessionId() {
146
+ return this.sessionId;
147
+ }
148
+ /** Every answer this session was given, in order. */
149
+ answers = [];
150
+ openPermissions = /* @__PURE__ */ new Set();
151
+ /** The runner asks to use a tool, as `StructuredSession` announces it. */
152
+ requestPermission(id, name, input, suggestions = []) {
153
+ this.openPermissions.add(id);
154
+ this.emitEvent({ type: "permission_request", id, name, detail: JSON.stringify(input), input, suggestions });
155
+ }
156
+ /** The runner gives up on a request, as an interrupt makes it. */
157
+ withdrawPermission(id) {
158
+ if (this.openPermissions.delete(id)) this.emitEvent({ type: "permission_withdrawn", id });
159
+ }
160
+ answerPermission(id, decision) {
161
+ if (!this.openPermissions.delete(id)) return false;
162
+ this.answers.push({ id, decision });
163
+ this.emitEvent({ type: "permission_decided", id, decision });
164
+ return true;
165
+ }
166
+ emitEvent(event) {
167
+ for (const cb of this.eventCbs) cb(event);
168
+ }
169
+ emitTurnEnd(reason) {
170
+ const next = this.messages.shift();
171
+ if (!next) this.state = "idle";
172
+ for (const cb of this.turnEndCbs) cb(reason);
173
+ if (next) this.deliver(next.text);
174
+ }
175
+ deliver(text) {
176
+ this.state = "working";
177
+ this.delivered.push(text);
178
+ this.emitEvent({ type: "turn_start", text });
179
+ }
180
+ };
94
181
  var FakeWorktreeIsolation = class {
95
182
  availability = { active: true };
96
183
  /** The repo paths `startRun` groups: a group of one at `.` unless set. */
@@ -112,6 +199,8 @@ var FakeWorktreeIsolation = class {
112
199
  /** Set to make `discard` / `sweep` throw after logging the call. */
113
200
  discardError = null;
114
201
  sweepError = null;
202
+ /** What `pruneOrphans` reports as kept back from the sweep. */
203
+ keptOnPrune = [];
115
204
  /** Per task id; a task not listed integrates as `merged`. */
116
205
  outcomes = /* @__PURE__ */ new Map();
117
206
  /** Per task id, what `verifyRepair` finds; a task not listed passes. */
@@ -238,6 +327,7 @@ var FakeWorktreeIsolation = class {
238
327
  }
239
328
  async pruneOrphans() {
240
329
  this.log({ op: "pruneOrphans" });
330
+ return { kept: [...this.keptOnPrune] };
241
331
  }
242
332
  async reviewDiff() {
243
333
  this.log({ op: "reviewDiff" });
@@ -257,9 +347,11 @@ var FakeWorktreeIsolation = class {
257
347
  }
258
348
  };
259
349
  export {
350
+ FakeStructuredSession,
260
351
  FakeTerminalSession,
261
352
  FakeWorktreeIsolation,
262
353
  fakeConfig,
263
- fakeFileSystem
354
+ fakeFileSystem,
355
+ flushMicrotasks
264
356
  };
265
357
  //# sourceMappingURL=testing.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/testing.ts"],"sourcesContent":["import type { IConfig } from './interfaces/IConfig';\nimport type { IFileSystem, ToolOutcome } from './interfaces/IFileSystem';\nimport type { ITerminalSession } from './interfaces/ITerminalRunner';\nimport type {\n IsolationAvailability,\n IsolationHandoff,\n IsolationMergeResult,\n IsolationOutcome,\n IsolationRun,\n IntegrationDisposal,\n PreparedTask,\n IWorktreeIsolation,\n RepairEvidence,\n} from './interfaces/IWorktreeIsolation';\nimport type { Task } from './models/Task';\nimport { handoffOf, integrationBranchFor, SELF_REPO } from './services/isolationRecord';\n\nexport function fakeConfig(overrides: Partial<IConfig> = {}): IConfig {\n return {\n aiProvider: 'openrouter',\n apiKey: 'sk-test',\n planningModel: 'test-model',\n enabledRunners: ['claude-code'],\n maxParallelSessions: 3,\n researchEnabled: false,\n researchMaxSteps: 10,\n researchMaxFileSize: 100_000,\n openAiBaseUrl: 'https://api.openai.com/v1',\n openAiApiKey: '',\n openrouterKey: '',\n geminiKey: '',\n openaiCompatibleBaseUrl: '',\n openaiCompatibleApiKey: '',\n orchestratorModel: '',\n researchSubagentModel: '',\n geminiModel: '',\n planMapEnabled: true,\n autonomousMode: true,\n // Off so an orchestrator built without an injected isolation never runs\n // real git against whatever repository the tests happen to run in.\n worktreeIsolation: false,\n workspaceRepos: [],\n worktreeLinks: [],\n // Off so a scripted conflict stays a conflict unless a test opts into repairing it.\n conflictRepairAttempts: 0,\n approvalMode: 'ask',\n approvalPreApproved: [],\n setProviderModelLists: () => {},\n getProviderBaseUrl: () => '',\n getProviderApiKey: () => '',\n ...overrides,\n };\n}\n\nconst EMPTY_OUTCOME: ToolOutcome = { success: false, output: '', truncated: false };\n\n/**\n * A complete {@link IFileSystem} stub. Lives here rather than in each package's\n * test folder so adding a tool to the interface is one edit, not one per suite.\n */\nexport function fakeFileSystem(overrides: Partial<IFileSystem> = {}): IFileSystem {\n return {\n readFile: async () => EMPTY_OUTCOME,\n readFiles: async () => EMPTY_OUTCOME,\n glob: async () => EMPTY_OUTCOME,\n grep: async () => EMPTY_OUTCOME,\n findSymbol: async () => EMPTY_OUTCOME,\n listDir: async () => EMPTY_OUTCOME,\n bash: async () => EMPTY_OUTCOME,\n getWorkspaceRoot: () => '/workspace',\n ...overrides,\n };\n}\n\nexport class FakeTerminalSession implements ITerminalSession {\n private outputCbs: Array<(text: string) => void> = [];\n private exitCbs: Array<(code: number) => void> = [];\n output = '';\n written: string[] = [];\n killed = false;\n\n constructor(public id = 's1', public taskId = 't1') {}\n\n onOutput(cb: (text: string) => void): void { this.outputCbs.push(cb); }\n onExit(cb: (code: number) => void): void { this.exitCbs.push(cb); }\n kill(): void { this.killed = true; }\n getOutput(): string { return this.output; }\n write(text: string): void { this.written.push(text); }\n\n emitOutput(text: string): void {\n this.output += text;\n for (const cb of this.outputCbs) cb(text);\n }\n emitExit(code: number): void {\n for (const cb of this.exitCbs) cb(code);\n }\n}\n\nexport type FakeIsolationCall =\n | { op: 'isActive'; workspaceRoot: string }\n | { op: 'stash'; workspaceRoot: string }\n | { op: 'startRun'; workspaceRoot: string }\n | { op: 'prepare' | 'reopen' | 'verifyRepair'; taskId: string }\n | { op: 'integrate'; taskId: string }\n | { op: 'release'; taskId: string; keep: boolean }\n | { op: 'handoff' | 'pruneOrphans' | 'reviewDiff' | 'mergeIntoCheckedOut' | 'sweep' }\n | { op: 'discard'; integration: IntegrationDisposal };\n\n/**\n * An in-memory {@link IWorktreeIsolation} for scheduling tests: no git, no\n * filesystem. Every call is logged in `calls`; `prepare` hands back a\n * deterministic fake cwd. Set `availability` to exercise the fallbacks, `outcomes`\n * to script a conflict, and `holdIntegration` to keep a task un-integrated so a\n * test can observe that its dependents wait. `repos` makes the run a group of\n * several; `changes` and `stopsIn` say which of them a task changes and where\n * its landing stops. `repairEvidence` scripts what a conflict repair's\n * evidence check finds.\n */\nexport class FakeWorktreeIsolation implements IWorktreeIsolation {\n availability: IsolationAvailability = { active: true };\n /** The repo paths `startRun` groups: a group of one at `.` unless set. */\n repos: string[] = [SELF_REPO];\n /** Per task id, the repos it changes; every repo of the group when not listed. */\n changes = new Map<string, string[]>();\n /** Per task id, the repo its landing stops in when its outcome is not `merged`; its first changed repo when not listed. */\n stopsIn = new Map<string, string>();\n /** Per task id, the files a `conflict` outcome names; empty when not listed. */\n conflictFiles = new Map<string, string[]>();\n /** What `mergeIntoCheckedOut` answers. */\n mergeResult: IsolationMergeResult = { outcome: 'merged' };\n /** What `startRun` shares and `prepare` copies, to exercise their notices. */\n shared: string[] = [];\n sharedRepos: string[] = [];\n copied: string[] = [];\n /** Set to make `startRun` throw, as git does when no repo of the group can be isolated. */\n startRunError: Error | null = null;\n /** Set to make `discard` / `sweep` throw after logging the call. */\n discardError: Error | null = null;\n sweepError: Error | null = null;\n /** Per task id; a task not listed integrates as `merged`. */\n outcomes = new Map<string, IsolationOutcome>();\n /** Per task id, what `verifyRepair` finds; a task not listed passes. */\n repairEvidence = new Map<string, RepairEvidence>();\n calls: FakeIsolationCall[] = [];\n private holds = new Map<string, Promise<void>>();\n private runCount = 0;\n\n private log(call: FakeIsolationCall): void { this.calls.push(call); }\n\n /** Task ids in the order `op` was called for them. */\n taskIdsFor(op: 'prepare' | 'reopen' | 'verifyRepair' | 'integrate' | 'release'): string[] {\n return this.calls.flatMap((c) => (c.op === op && 'taskId' in c ? [c.taskId] : []));\n }\n\n /** Make `integrate` for this task wait until the returned function is called. */\n holdIntegration(taskId: string): () => void {\n let open!: () => void;\n this.holds.set(taskId, new Promise<void>((resolve) => { open = resolve; }));\n return open;\n }\n\n async isActive(workspaceRoot: string): Promise<IsolationAvailability> {\n this.log({ op: 'isActive', workspaceRoot });\n return this.availability;\n }\n\n /** Like git: once the tracked changes are stashed, the tree is no longer dirty. */\n async stash(workspaceRoot: string): Promise<void> {\n this.log({ op: 'stash', workspaceRoot });\n if (!this.availability.active && this.availability.reason === 'dirty') this.availability = { active: true };\n }\n\n async startRun(workspaceRoot: string): Promise<IsolationRun> {\n this.log({ op: 'startRun', workspaceRoot });\n if (this.startRunError) throw this.startRunError;\n const id = `run${++this.runCount}`;\n return {\n id,\n workspaceRoot,\n repos: this.repos.map((repo) => ({\n path: repo, root: `${workspaceRoot}/${repo}`.replace(/\\/\\.$/, ''), baseRef: 'base0000', baseBranch: 'main', integrationBranch: integrationBranchFor(id),\n })),\n shared: [...this.shared],\n sharedRepos: [...this.sharedRepos],\n tasks: {},\n };\n }\n\n async prepare(task: Task, run: IsolationRun): Promise<PreparedTask> {\n this.log({ op: 'prepare', taskId: task.id });\n const name = `${task.order}-${task.id}`;\n const cwd = `/fake-worktrees/${run.id}/${name}`;\n const branch = `ordewell/${run.id}/${name}`;\n run.tasks[task.id] = {\n taskId: task.id, order: task.order, title: task.title, branch, workspace: cwd, status: 'active',\n repos: Object.fromEntries(run.repos.map((r) => [r.path, { worktree: r.path === SELF_REPO ? cwd : `${cwd}/${r.path}`, linked: [] }])),\n };\n return { cwd, branch, copied: [...this.copied] };\n }\n\n /** Like git: the same cwd, each changed repo's tip recorded, the repair counted. */\n async reopen(task: Task, run: IsolationRun): Promise<PreparedTask> {\n this.log({ op: 'reopen', taskId: task.id });\n const record = run.tasks[task.id];\n if (record?.status !== 'conflict') throw new Error(`Task ${task.order} has no conflict to repair`);\n const changed = Object.entries(record.repos).filter(([repo, entry]) => entry.changed || repo === record.conflictRepo).map(([repo]) => repo);\n const files = (record.conflictFiles ?? []).map((file) => (record.conflictRepo && record.conflictRepo !== SELF_REPO ? `${record.conflictRepo}/${file}` : file));\n record.repairs = (record.repairs ?? 0) + 1;\n record.repairBase = Object.fromEntries(changed.map((repo) => [repo, `tip-${repo}`]));\n record.repairedFiles = [...new Set([...(record.repairedFiles ?? []), ...files])];\n record.status = 'repairing';\n return { cwd: record.workspace, branch: record.branch, copied: [] };\n }\n\n async verifyRepair(task: Task, _run: IsolationRun): Promise<RepairEvidence> {\n this.log({ op: 'verifyRepair', taskId: task.id });\n return this.repairEvidence.get(task.id) ?? { ok: true };\n }\n\n /** Like git: the landing is recorded and persisted before the (held) merge, and cleared once it settles. */\n async integrate(task: Task, run: IsolationRun, persist: () => void = () => undefined): Promise<IsolationOutcome> {\n this.log({ op: 'integrate', taskId: task.id });\n const record = run.tasks[task.id];\n if (!record) return 'failed';\n const changed = this.changes.get(task.id) ?? run.repos.map((r) => r.path);\n for (const [repo, entry] of Object.entries(record.repos)) entry.changed = changed.includes(repo) || (entry.changed ?? false);\n if (changed.length > 0) {\n run.landing = { taskId: task.id, tips: Object.fromEntries(changed.map((repo) => [repo, `tip-${repo}`])) };\n persist();\n }\n await this.holds.get(task.id);\n delete run.landing;\n const outcome = this.outcomes.get(task.id) ?? 'merged';\n record.status = outcome;\n delete record.repairBase;\n if (outcome === 'merged') {\n delete record.conflictRepo;\n delete record.conflictFiles;\n } else {\n record.conflictRepo = this.stopsIn.get(task.id) ?? changed[0] ?? SELF_REPO;\n const files = this.conflictFiles.get(task.id);\n if (files) record.conflictFiles = files;\n else delete record.conflictFiles;\n }\n return outcome;\n }\n\n async release(run: IsolationRun, taskId: string, opts: { keep: boolean }): Promise<void> {\n this.log({ op: 'release', taskId, keep: opts.keep });\n const record = run.tasks[taskId];\n if (!opts.keep) delete run.tasks[taskId];\n else if (record?.status === 'active') record.status = 'kept';\n else if (record?.status === 'repairing') {\n record.status = 'conflict';\n delete record.repairBase;\n }\n }\n\n async handoff(run: IsolationRun): Promise<IsolationHandoff> {\n this.log({ op: 'handoff' });\n return handoffOf(run);\n }\n\n async pruneOrphans(): Promise<void> { this.log({ op: 'pruneOrphans' }); }\n async reviewDiff(): Promise<string> { this.log({ op: 'reviewDiff' }); return ''; }\n async mergeIntoCheckedOut(): Promise<IsolationMergeResult> { this.log({ op: 'mergeIntoCheckedOut' }); return this.mergeResult; }\n async discard(_run: IsolationRun, opts: { integration: IntegrationDisposal }): Promise<void> {\n this.log({ op: 'discard', integration: opts.integration });\n if (this.discardError) throw this.discardError;\n }\n async sweep(): Promise<void> {\n this.log({ op: 'sweep' });\n if (this.sweepError) throw this.sweepError;\n }\n}\n"],"mappings":";;;;;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":[]}
1
+ {"version":3,"sources":["../src/testing.ts"],"sourcesContent":["import type { IConfig } from './interfaces/IConfig';\nimport type { IFileSystem, ToolOutcome } from './interfaces/IFileSystem';\nimport type { ITerminalSession, QueuedTaskMessage, StructuredEvent, StructuredSessionCapability, StructuredTurnEnd } from './interfaces/ITerminalRunner';\nimport type { ApprovalDecision } from './interfaces/IApproval';\nimport type {\n IsolationAvailability,\n IsolationHandoff,\n IsolationMergeResult,\n IsolationOutcome,\n IsolationPruneResult,\n IsolationRun,\n IntegrationDisposal,\n PreparedTask,\n IWorktreeIsolation,\n RepairEvidence,\n} from './interfaces/IWorktreeIsolation';\nimport type { Task } from './models/Task';\nimport { handoffOf, integrationBranchFor, SELF_REPO } from './services/isolationRecord';\n\n/**\n * Let an already-queued promise chain run to its next await before asserting,\n * without a wall-clock sleep. For a chain whose length is not known, drain the\n * microtask queue repeatedly. Only helps a chain that does not wait on a timer.\n */\nexport async function flushMicrotasks(rounds = 20): Promise<void> {\n for (let i = 0; i < rounds; i += 1) await Promise.resolve();\n}\n\nexport function fakeConfig(overrides: Partial<IConfig> = {}): IConfig {\n return {\n aiProvider: 'openrouter',\n apiKey: 'sk-test',\n planningModel: 'test-model',\n enabledRunners: ['claude-code'],\n maxParallelSessions: 3,\n researchEnabled: false,\n researchMaxSteps: 10,\n researchMaxFileSize: 100_000,\n openAiBaseUrl: 'https://api.openai.com/v1',\n openAiApiKey: '',\n openrouterKey: '',\n geminiKey: '',\n openaiCompatibleBaseUrl: '',\n openaiCompatibleApiKey: '',\n orchestratorModel: '',\n researchSubagentModel: '',\n geminiModel: '',\n planMapEnabled: true,\n autonomousMode: true,\n // Off so an orchestrator built without an injected isolation never runs\n // real git against whatever repository the tests happen to run in.\n worktreeIsolation: false,\n workspaceRepos: [],\n worktreeLinks: [],\n // Off so a scripted conflict stays a conflict unless a test opts into repairing it.\n conflictRepairAttempts: 0,\n approvalMode: 'ask',\n approvalPreApproved: [],\n setProviderModelLists: () => {},\n getProviderBaseUrl: () => '',\n getProviderApiKey: () => '',\n ...overrides,\n };\n}\n\nconst EMPTY_OUTCOME: ToolOutcome = { success: false, output: '', truncated: false };\n\n/**\n * A complete {@link IFileSystem} stub. Lives here rather than in each package's\n * test folder so adding a tool to the interface is one edit, not one per suite.\n */\nexport function fakeFileSystem(overrides: Partial<IFileSystem> = {}): IFileSystem {\n return {\n readFile: async () => EMPTY_OUTCOME,\n readFiles: async () => EMPTY_OUTCOME,\n glob: async () => EMPTY_OUTCOME,\n grep: async () => EMPTY_OUTCOME,\n findSymbol: async () => EMPTY_OUTCOME,\n listDir: async () => EMPTY_OUTCOME,\n bash: async () => EMPTY_OUTCOME,\n getWorkspaceRoot: () => '/workspace',\n ...overrides,\n };\n}\n\nexport class FakeTerminalSession implements ITerminalSession {\n private outputCbs: Array<(text: string) => void> = [];\n private exitCbs: Array<(code: number) => void> = [];\n output = '';\n written: string[] = [];\n killed = false;\n\n constructor(public id = 's1', public taskId = 't1') {}\n\n onOutput(cb: (text: string) => void): void { this.outputCbs.push(cb); }\n onExit(cb: (code: number) => void): void { this.exitCbs.push(cb); }\n kill(): void { this.killed = true; }\n getOutput(): string { return this.output; }\n write(text: string): void { this.written.push(text); }\n\n emitOutput(text: string): void {\n this.output += text;\n for (const cb of this.outputCbs) cb(text);\n }\n emitExit(code: number): void {\n for (const cb of this.exitCbs) cb(code);\n }\n}\n\n/**\n * A {@link FakeTerminalSession} that is feature-detected as structured\n * (ADR-0018): the turn, queue and native-session calls a test drives, with\n * no protocol behind them. It queues and delivers as `StructuredSession`\n * does — a message to an idle session starts a turn at once, one sent\n * mid-turn goes out as that turn ends, without passing through idle.\n */\nexport class FakeStructuredSession extends FakeTerminalSession implements StructuredSessionCapability {\n readonly transport = 'structured' as const;\n state: 'working' | 'idle' = 'working';\n messages: QueuedTaskMessage[] = [];\n /** Every message a turn was started with, in order. */\n delivered: string[] = [];\n interrupts = 0;\n private messageCount = 0;\n private turnEndCbs: Array<(reason: StructuredTurnEnd) => void> = [];\n private eventCbs: Array<(event: StructuredEvent) => void> = [];\n\n constructor(id = 's1', taskId = 't1', public sessionId: string | null = 'native-1') {\n super(id, taskId);\n }\n\n override write(text: string): void {\n super.write(text);\n const message = text.trim();\n if (message) this.sendMessage(message);\n }\n\n turnState(): 'working' | 'idle' { return this.state; }\n onTurnEnd(cb: (reason: StructuredTurnEnd) => void): void { this.turnEndCbs.push(cb); }\n onEvent(cb: (event: StructuredEvent) => void): void { this.eventCbs.push(cb); }\n sendMessage(text: string): string {\n this.messageCount += 1;\n const id = `msg-${this.messageCount}`;\n if (this.state === 'idle') this.deliver(text);\n else this.messages.push({ id, text });\n return id;\n }\n removeQueued(id: string): boolean {\n const before = this.messages.length;\n this.messages = this.messages.filter((m) => m.id !== id);\n return this.messages.length < before;\n }\n queued(): QueuedTaskMessage[] { return this.messages.map((m) => ({ ...m })); }\n async interrupt(): Promise<void> {\n this.interrupts += 1;\n if (this.state === 'working') this.emitTurnEnd('interrupted');\n }\n nativeSessionId(): string | null { return this.sessionId; }\n\n /** Every answer this session was given, in order. */\n answers: Array<{ id: string; decision: ApprovalDecision }> = [];\n private readonly openPermissions = new Set<string>();\n\n /** The runner asks to use a tool, as `StructuredSession` announces it. */\n requestPermission(id: string, name: string, input: Record<string, unknown>, suggestions: unknown[] = []): void {\n this.openPermissions.add(id);\n this.emitEvent({ type: 'permission_request', id, name, detail: JSON.stringify(input), input, suggestions });\n }\n /** The runner gives up on a request, as an interrupt makes it. */\n withdrawPermission(id: string): void {\n if (this.openPermissions.delete(id)) this.emitEvent({ type: 'permission_withdrawn', id });\n }\n answerPermission(id: string, decision: ApprovalDecision): boolean {\n if (!this.openPermissions.delete(id)) return false;\n this.answers.push({ id, decision });\n this.emitEvent({ type: 'permission_decided', id, decision });\n return true;\n }\n\n emitEvent(event: StructuredEvent): void {\n for (const cb of this.eventCbs) cb(event);\n }\n emitTurnEnd(reason: StructuredTurnEnd): void {\n const next = this.messages.shift();\n if (!next) this.state = 'idle';\n for (const cb of this.turnEndCbs) cb(reason);\n if (next) this.deliver(next.text);\n }\n\n private deliver(text: string): void {\n this.state = 'working';\n this.delivered.push(text);\n this.emitEvent({ type: 'turn_start', text });\n }\n}\n\nexport type FakeIsolationCall =\n | { op: 'isActive'; workspaceRoot: string }\n | { op: 'stash'; workspaceRoot: string }\n | { op: 'startRun'; workspaceRoot: string }\n | { op: 'prepare' | 'reopen' | 'verifyRepair'; taskId: string }\n | { op: 'integrate'; taskId: string }\n | { op: 'release'; taskId: string; keep: boolean }\n | { op: 'handoff' | 'pruneOrphans' | 'reviewDiff' | 'mergeIntoCheckedOut' | 'sweep' }\n | { op: 'discard'; integration: IntegrationDisposal };\n\n/**\n * An in-memory {@link IWorktreeIsolation} for scheduling tests: no git, no\n * filesystem. Every call is logged in `calls`; `prepare` hands back a\n * deterministic fake cwd. Set `availability` to exercise the fallbacks, `outcomes`\n * to script a conflict, and `holdIntegration` to keep a task un-integrated so a\n * test can observe that its dependents wait. `repos` makes the run a group of\n * several; `changes` and `stopsIn` say which of them a task changes and where\n * its landing stops. `repairEvidence` scripts what a conflict repair's\n * evidence check finds.\n */\nexport class FakeWorktreeIsolation implements IWorktreeIsolation {\n availability: IsolationAvailability = { active: true };\n /** The repo paths `startRun` groups: a group of one at `.` unless set. */\n repos: string[] = [SELF_REPO];\n /** Per task id, the repos it changes; every repo of the group when not listed. */\n changes = new Map<string, string[]>();\n /** Per task id, the repo its landing stops in when its outcome is not `merged`; its first changed repo when not listed. */\n stopsIn = new Map<string, string>();\n /** Per task id, the files a `conflict` outcome names; empty when not listed. */\n conflictFiles = new Map<string, string[]>();\n /** What `mergeIntoCheckedOut` answers. */\n mergeResult: IsolationMergeResult = { outcome: 'merged' };\n /** What `startRun` shares and `prepare` copies, to exercise their notices. */\n shared: string[] = [];\n sharedRepos: string[] = [];\n copied: string[] = [];\n /** Set to make `startRun` throw, as git does when no repo of the group can be isolated. */\n startRunError: Error | null = null;\n /** Set to make `discard` / `sweep` throw after logging the call. */\n discardError: Error | null = null;\n sweepError: Error | null = null;\n /** What `pruneOrphans` reports as kept back from the sweep. */\n keptOnPrune: IsolationPruneResult['kept'] = [];\n /** Per task id; a task not listed integrates as `merged`. */\n outcomes = new Map<string, IsolationOutcome>();\n /** Per task id, what `verifyRepair` finds; a task not listed passes. */\n repairEvidence = new Map<string, RepairEvidence>();\n calls: FakeIsolationCall[] = [];\n private holds = new Map<string, Promise<void>>();\n private runCount = 0;\n\n private log(call: FakeIsolationCall): void { this.calls.push(call); }\n\n /** Task ids in the order `op` was called for them. */\n taskIdsFor(op: 'prepare' | 'reopen' | 'verifyRepair' | 'integrate' | 'release'): string[] {\n return this.calls.flatMap((c) => (c.op === op && 'taskId' in c ? [c.taskId] : []));\n }\n\n /** Make `integrate` for this task wait until the returned function is called. */\n holdIntegration(taskId: string): () => void {\n let open!: () => void;\n this.holds.set(taskId, new Promise<void>((resolve) => { open = resolve; }));\n return open;\n }\n\n async isActive(workspaceRoot: string): Promise<IsolationAvailability> {\n this.log({ op: 'isActive', workspaceRoot });\n return this.availability;\n }\n\n /** Like git: once the tracked changes are stashed, the tree is no longer dirty. */\n async stash(workspaceRoot: string): Promise<void> {\n this.log({ op: 'stash', workspaceRoot });\n if (!this.availability.active && this.availability.reason === 'dirty') this.availability = { active: true };\n }\n\n async startRun(workspaceRoot: string): Promise<IsolationRun> {\n this.log({ op: 'startRun', workspaceRoot });\n if (this.startRunError) throw this.startRunError;\n const id = `run${++this.runCount}`;\n return {\n id,\n workspaceRoot,\n repos: this.repos.map((repo) => ({\n path: repo, root: `${workspaceRoot}/${repo}`.replace(/\\/\\.$/, ''), baseRef: 'base0000', baseBranch: 'main', integrationBranch: integrationBranchFor(id),\n })),\n shared: [...this.shared],\n sharedRepos: [...this.sharedRepos],\n tasks: {},\n };\n }\n\n async prepare(task: Task, run: IsolationRun): Promise<PreparedTask> {\n this.log({ op: 'prepare', taskId: task.id });\n const name = `${task.order}-${task.id}`;\n const cwd = `/fake-worktrees/${run.id}/${name}`;\n const branch = `ordewell/${run.id}/${name}`;\n run.tasks[task.id] = {\n taskId: task.id, order: task.order, title: task.title, branch, workspace: cwd, status: 'active',\n repos: Object.fromEntries(run.repos.map((r) => [r.path, { worktree: r.path === SELF_REPO ? cwd : `${cwd}/${r.path}`, linked: [] }])),\n };\n return { cwd, branch, copied: [...this.copied] };\n }\n\n /** Like git: the same cwd, each changed repo's tip recorded, the repair counted. */\n async reopen(task: Task, run: IsolationRun): Promise<PreparedTask> {\n this.log({ op: 'reopen', taskId: task.id });\n const record = run.tasks[task.id];\n if (record?.status !== 'conflict') throw new Error(`Task ${task.order} has no conflict to repair`);\n const changed = Object.entries(record.repos).filter(([repo, entry]) => entry.changed || repo === record.conflictRepo).map(([repo]) => repo);\n const files = (record.conflictFiles ?? []).map((file) => (record.conflictRepo && record.conflictRepo !== SELF_REPO ? `${record.conflictRepo}/${file}` : file));\n record.repairs = (record.repairs ?? 0) + 1;\n record.repairBase = Object.fromEntries(changed.map((repo) => [repo, `tip-${repo}`]));\n record.repairedFiles = [...new Set([...(record.repairedFiles ?? []), ...files])];\n record.status = 'repairing';\n return { cwd: record.workspace, branch: record.branch, copied: [] };\n }\n\n async verifyRepair(task: Task, _run: IsolationRun): Promise<RepairEvidence> {\n this.log({ op: 'verifyRepair', taskId: task.id });\n return this.repairEvidence.get(task.id) ?? { ok: true };\n }\n\n /** Like git: the landing is recorded and persisted before the (held) merge, and cleared once it settles. */\n async integrate(task: Task, run: IsolationRun, persist: () => void = () => undefined): Promise<IsolationOutcome> {\n this.log({ op: 'integrate', taskId: task.id });\n const record = run.tasks[task.id];\n if (!record) return 'failed';\n const changed = this.changes.get(task.id) ?? run.repos.map((r) => r.path);\n for (const [repo, entry] of Object.entries(record.repos)) entry.changed = changed.includes(repo) || (entry.changed ?? false);\n if (changed.length > 0) {\n run.landing = { taskId: task.id, tips: Object.fromEntries(changed.map((repo) => [repo, `tip-${repo}`])) };\n persist();\n }\n await this.holds.get(task.id);\n delete run.landing;\n const outcome = this.outcomes.get(task.id) ?? 'merged';\n record.status = outcome;\n delete record.repairBase;\n if (outcome === 'merged') {\n delete record.conflictRepo;\n delete record.conflictFiles;\n } else {\n record.conflictRepo = this.stopsIn.get(task.id) ?? changed[0] ?? SELF_REPO;\n const files = this.conflictFiles.get(task.id);\n if (files) record.conflictFiles = files;\n else delete record.conflictFiles;\n }\n return outcome;\n }\n\n async release(run: IsolationRun, taskId: string, opts: { keep: boolean }): Promise<void> {\n this.log({ op: 'release', taskId, keep: opts.keep });\n const record = run.tasks[taskId];\n if (!opts.keep) delete run.tasks[taskId];\n else if (record?.status === 'active') record.status = 'kept';\n else if (record?.status === 'repairing') {\n record.status = 'conflict';\n delete record.repairBase;\n }\n }\n\n async handoff(run: IsolationRun): Promise<IsolationHandoff> {\n this.log({ op: 'handoff' });\n return handoffOf(run);\n }\n\n async pruneOrphans(): Promise<IsolationPruneResult> {\n this.log({ op: 'pruneOrphans' });\n return { kept: [...this.keptOnPrune] };\n }\n async reviewDiff(): Promise<string> { this.log({ op: 'reviewDiff' }); return ''; }\n async mergeIntoCheckedOut(): Promise<IsolationMergeResult> { this.log({ op: 'mergeIntoCheckedOut' }); return this.mergeResult; }\n async discard(_run: IsolationRun, opts: { integration: IntegrationDisposal }): Promise<void> {\n this.log({ op: 'discard', integration: opts.integration });\n if (this.discardError) throw this.discardError;\n }\n async sweep(): Promise<void> {\n this.log({ op: 'sweep' });\n if (this.sweepError) throw this.sweepError;\n }\n}\n"],"mappings":";;;;;;;AAwBA,eAAsB,gBAAgB,SAAS,IAAmB;AAChE,WAAS,IAAI,GAAG,IAAI,QAAQ,KAAK,EAAG,OAAM,QAAQ,QAAQ;AAC5D;AAEO,SAAS,WAAW,YAA8B,CAAC,GAAY;AACpE,SAAO;AAAA,IACL,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,eAAe;AAAA,IACf,gBAAgB,CAAC,aAAa;AAAA,IAC9B,qBAAqB;AAAA,IACrB,iBAAiB;AAAA,IACjB,kBAAkB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E,IAAI,WAAW,QAAQ,MAAM,KAAK,KAAK,CAAC;AACnD,UAAM,SAAS,IAAI,MAAM,MAAM;AAC/B,QAAI,CAAC,KAAK,KAAM,QAAO,IAAI,MAAM,MAAM;AAAA,aAC9B,QAAQ,WAAW,SAAU,QAAO,SAAS;AAAA,aAC7C,QAAQ,WAAW,aAAa;AACvC,aAAO,SAAS;AAChB,aAAO,OAAO;AAAA,IAChB;AAAA,EACF;AAAA,EAEA,MAAM,QAAQ,KAA8C;AAC1D,SAAK,IAAI,EAAE,IAAI,UAAU,CAAC;AAC1B,WAAO,UAAU,GAAG;AAAA,EACtB;AAAA,EAEA,MAAM,eAA8C;AAClD,SAAK,IAAI,EAAE,IAAI,eAAe,CAAC;AAC/B,WAAO,EAAE,MAAM,CAAC,GAAG,KAAK,WAAW,EAAE;AAAA,EACvC;AAAA,EACA,MAAM,aAA8B;AAAE,SAAK,IAAI,EAAE,IAAI,aAAa,CAAC;AAAG,WAAO;AAAA,EAAI;AAAA,EACjF,MAAM,sBAAqD;AAAE,SAAK,IAAI,EAAE,IAAI,sBAAsB,CAAC;AAAG,WAAO,KAAK;AAAA,EAAa;AAAA,EAC/H,MAAM,QAAQ,MAAoB,MAA2D;AAC3F,SAAK,IAAI,EAAE,IAAI,WAAW,aAAa,KAAK,YAAY,CAAC;AACzD,QAAI,KAAK,aAAc,OAAM,KAAK;AAAA,EACpC;AAAA,EACA,MAAM,QAAuB;AAC3B,SAAK,IAAI,EAAE,IAAI,QAAQ,CAAC;AACxB,QAAI,KAAK,WAAY,OAAM,KAAK;AAAA,EAClC;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ordewell/core",
3
- "version": "0.5.4",
3
+ "version": "0.5.6",
4
4
  "description": "Ordewell core — planner, orchestrator, runners and verification engine.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Alessandro Costanzo Ciano",
@@ -85,6 +85,7 @@
85
85
  "prepublishOnly": "npm run build",
86
86
  "watch": "tsup src/index.ts --watch --sourcemap",
87
87
  "test": "vitest run",
88
+ "test:coverage": "vitest run --coverage",
88
89
  "lint": "eslint src --ext .ts",
89
90
  "typecheck": "tsc --noEmit"
90
91
  },
@@ -4,28 +4,18 @@ description: Grill the user relentlessly about a plan, decision, or idea. Use wh
4
4
  disable-model-invocation: true
5
5
  ---
6
6
 
7
- Interview the user relentlessly until you reach a shared understanding. Map this as a **design tree**: every decision branches into the decisions that hang off it.
7
+ Interview the user relentlessly until you reach a shared understanding. Map this as a **design tree**: every decision branches into the decisions that hang off it. Walk the tree one branch at a time, resolving each decision before the ones that depend on it.
8
8
 
9
- Work the tree in **rounds**. The **frontier** is every decision whose prerequisites are already settled: the questions you can ask _now_ without guessing at answers you haven't heard yet. Ask the whole frontier in one round: number each question and give your recommended answer. Then wait for the user's answers before the next round.
9
+ **Ask exactly one question per message.** Never batch, number, or stack several questions, and never tack a second question onto the first, even if you already know what you'd ask next. Then stop and wait for the user's answer. Which question comes next depends on that answer, so anything you queue up now is a guess at an answer you haven't heard.
10
10
 
11
- Format a round like so:
11
+ Format each question like so:
12
12
 
13
-
14
- ❓ **Q1** - **<question title>**: <question body, might be multiple paragraphs, including multiple choices>
15
-
16
- ➡️ <your recommended answer>
17
-
18
- ---
19
-
20
- ❓ **Q2** - **<question title>**: <question body, might be multiple paragraphs, including multiple choices>
13
+ ❓ **<question title>**: <question body, might be multiple paragraphs, including multiple choices>
21
14
 
22
15
  ➡️ <your recommended answer>
23
16
 
24
-
25
- Each round the user answers reshapes the tree: settled decisions push the frontier outward and unblock questions that depended on them. Recompute the frontier and ask the next round. A question whose answer depends on another question still open in this round belongs to a _later_ round, not this one.
26
-
27
- Finding _facts_ is your job, never the user's. When a frontier question needs a fact from the environment, explore the workspace yourself with your own read-only tools, and, where a research subagent is available to you, delegate exploration to it instead of reading everything inline. Don't block on it: a running exploration is an unsettled prerequisite, so only the questions downstream of it wait for it to report back; ask the rest of the frontier now. The _decisions_ are the user's — put each to them and wait.
17
+ Finding _facts_ is your job, never the user's. When a question needs a fact from the environment, explore the workspace yourself with your own read-only tools, and, where a research subagent is available to you, delegate exploration to it instead of reading everything inline. Don't ask the user for anything you could look up yourself. The _decisions_ are the user's: put each to them and wait.
28
18
 
29
19
  The goal is a shared understanding sharp enough to decompose into independently demoable slices: questions about slice boundaries, dependencies between slices, and what's out of scope are legitimate branches of the design tree, not distractions from it.
30
20
 
31
- The session is done when the frontier is empty: every branch of the design tree visited, nothing left silently assumed. An empty frontier doesn't end the session — it means you now propose a prose outline of vertical tracer-bullet slices, the same outline-before-JSON step you'd reach at the end of any research phase. Do not emit the task plan JSON until the user has confirmed that outline.
21
+ The session is done when every branch of the design tree has been visited and nothing is left silently assumed. That doesn't end the session on its own: you now propose a prose outline of vertical tracer-bullet slices, the same outline-before-JSON step you'd reach at the end of any research phase. Do not emit the task plan JSON until the user has confirmed that outline.
@@ -44,7 +44,7 @@ Ask: **how many of these should become tasks?** Default, unless told otherwise:
44
44
 
45
45
  ### 3. Resolve open questions per selected candidate
46
46
 
47
- For each candidate going into the plan, settle whatever a runner would otherwise have to guess: the target seam, what sits behind it, what's explicitly out of scope, which tests survive. Interview only where the answer is genuinely unclear for that candidate — number the open questions, give your recommended answer, wait for the user before the next round. Don't grill a candidate that's already unambiguous.
47
+ For each candidate going into the plan, settle whatever a runner would otherwise have to guess: the target seam, what sits behind it, what's explicitly out of scope, which tests survive. Interview only where the answer is genuinely unclear for that candidate — ask one question at a time, give your recommended answer, wait for the user before the next question. Don't grill a candidate that's already unambiguous.
48
48
 
49
49
  If the user rejects a candidate with a load-bearing reason ("not now, that would break the plugin API"), offer: _"Want a one-line ADR task recording this, so a future run of this skill doesn't re-suggest it?"_ Only offer when the reason would actually be needed by a future run to avoid re-suggesting the same thing; skip ephemeral reasons ("not worth it right now") and self-evident ones.
50
50
 
@@ -1,79 +0,0 @@
1
- /**
2
- * The planner's single approval seam. Every capability that reaches beyond the
3
- * default read-only, in-workspace envelope — a path outside the workspace root,
4
- * a shell command outside the auto-allowed set, a URL fetch — routes through
5
- * one `request()` so the policy has exactly one owner (the same "one repair
6
- * owner" shape as PlanRepair).
7
- *
8
- * Surfaces supply the human channel. VS Code answers with a modal; the web
9
- * server currently has no prompt UI, so it denies unless the scope was
10
- * pre-approved through config. Denial is always a visible, actionable tool
11
- * result — never a silent success.
12
- */
13
- type ApprovalKind = 'external_path' | 'shell_command' | 'url_fetch';
14
- interface ApprovalRequest {
15
- kind: ApprovalKind;
16
- /** The concrete thing being asked about: an absolute path, a command line, a URL. */
17
- subject: string;
18
- /**
19
- * What a grant covers. Approving remembers this, not `subject`, so reading a
20
- * second file from an already-approved directory does not prompt again.
21
- */
22
- scope: string;
23
- /** One-line context for the prompt. */
24
- detail?: string;
25
- }
26
- interface IApproval {
27
- request(req: ApprovalRequest): Promise<boolean>;
28
- }
29
- /** Denies everything. The safe default when a surface wires no approval channel. */
30
- declare const DENY_ALL: IApproval;
31
-
32
- /**
33
- * Decides whether one out-of-envelope capability may run, and remembers the
34
- * answer for the rest of the session.
35
- *
36
- * Grants are keyed on {@link ApprovalRequest.scope}, never on the concrete
37
- * subject: approving a read of `/tmp/foo/a.log` grants `/tmp/foo/*`, and
38
- * approving `az group list` grants `az group`. Without that, a planner doing
39
- * real research would prompt on every single call and the feature would be
40
- * unusable.
41
- *
42
- * `mode` is the policy floor:
43
- * ask consult the human channel; no channel means deny (headless, web)
44
- * allow grant everything the tier system did not already refuse
45
- * deny grant nothing beyond `preApproved`
46
- *
47
- * Note the ordering: `preApproved` is honored under every mode including
48
- * `deny`, because it is an explicit operator decision rather than a default.
49
- */
50
- type ApprovalMode = 'ask' | 'allow' | 'deny';
51
- interface ApprovalPolicyOptions {
52
- mode?: ApprovalMode;
53
- /** Scopes granted up front from config. A trailing `*` matches by prefix. */
54
- preApproved?: string[];
55
- /** The human channel. Absent means there is nobody to ask. */
56
- ask?: (req: ApprovalRequest) => Promise<boolean>;
57
- /** Called whenever a decision is reached, for surfacing in a UI or a log. */
58
- onDecision?: (req: ApprovalRequest, granted: boolean, source: ApprovalSource) => void;
59
- }
60
- type ApprovalSource = 'pre-approved' | 'remembered' | 'mode' | 'asked' | 'no-channel';
61
- declare class ApprovalPolicy implements IApproval {
62
- private readonly mode;
63
- private readonly preApproved;
64
- private readonly asker?;
65
- private readonly onDecision?;
66
- private readonly granted;
67
- private readonly refused;
68
- /** One in-flight ask per scope: a parallel tool round must not prompt twice for the same thing. */
69
- private readonly inFlight;
70
- private generation;
71
- constructor(opts?: ApprovalPolicyOptions);
72
- request(req: ApprovalRequest): Promise<boolean>;
73
- /** Scopes the user has granted this session — for display and for persistence. */
74
- grantedScopes(): string[];
75
- /** Drop every session-scoped decision. Called on session reset. */
76
- reset(): void;
77
- }
78
-
79
- export { type ApprovalKind as A, DENY_ALL as D, type IApproval as I, type ApprovalMode as a, ApprovalPolicy as b, type ApprovalPolicyOptions as c, type ApprovalRequest as d, type ApprovalSource as e };
@@ -1,79 +0,0 @@
1
- /**
2
- * The planner's single approval seam. Every capability that reaches beyond the
3
- * default read-only, in-workspace envelope — a path outside the workspace root,
4
- * a shell command outside the auto-allowed set, a URL fetch — routes through
5
- * one `request()` so the policy has exactly one owner (the same "one repair
6
- * owner" shape as PlanRepair).
7
- *
8
- * Surfaces supply the human channel. VS Code answers with a modal; the web
9
- * server currently has no prompt UI, so it denies unless the scope was
10
- * pre-approved through config. Denial is always a visible, actionable tool
11
- * result — never a silent success.
12
- */
13
- type ApprovalKind = 'external_path' | 'shell_command' | 'url_fetch';
14
- interface ApprovalRequest {
15
- kind: ApprovalKind;
16
- /** The concrete thing being asked about: an absolute path, a command line, a URL. */
17
- subject: string;
18
- /**
19
- * What a grant covers. Approving remembers this, not `subject`, so reading a
20
- * second file from an already-approved directory does not prompt again.
21
- */
22
- scope: string;
23
- /** One-line context for the prompt. */
24
- detail?: string;
25
- }
26
- interface IApproval {
27
- request(req: ApprovalRequest): Promise<boolean>;
28
- }
29
- /** Denies everything. The safe default when a surface wires no approval channel. */
30
- declare const DENY_ALL: IApproval;
31
-
32
- /**
33
- * Decides whether one out-of-envelope capability may run, and remembers the
34
- * answer for the rest of the session.
35
- *
36
- * Grants are keyed on {@link ApprovalRequest.scope}, never on the concrete
37
- * subject: approving a read of `/tmp/foo/a.log` grants `/tmp/foo/*`, and
38
- * approving `az group list` grants `az group`. Without that, a planner doing
39
- * real research would prompt on every single call and the feature would be
40
- * unusable.
41
- *
42
- * `mode` is the policy floor:
43
- * ask consult the human channel; no channel means deny (headless, web)
44
- * allow grant everything the tier system did not already refuse
45
- * deny grant nothing beyond `preApproved`
46
- *
47
- * Note the ordering: `preApproved` is honored under every mode including
48
- * `deny`, because it is an explicit operator decision rather than a default.
49
- */
50
- type ApprovalMode = 'ask' | 'allow' | 'deny';
51
- interface ApprovalPolicyOptions {
52
- mode?: ApprovalMode;
53
- /** Scopes granted up front from config. A trailing `*` matches by prefix. */
54
- preApproved?: string[];
55
- /** The human channel. Absent means there is nobody to ask. */
56
- ask?: (req: ApprovalRequest) => Promise<boolean>;
57
- /** Called whenever a decision is reached, for surfacing in a UI or a log. */
58
- onDecision?: (req: ApprovalRequest, granted: boolean, source: ApprovalSource) => void;
59
- }
60
- type ApprovalSource = 'pre-approved' | 'remembered' | 'mode' | 'asked' | 'no-channel';
61
- declare class ApprovalPolicy implements IApproval {
62
- private readonly mode;
63
- private readonly preApproved;
64
- private readonly asker?;
65
- private readonly onDecision?;
66
- private readonly granted;
67
- private readonly refused;
68
- /** One in-flight ask per scope: a parallel tool round must not prompt twice for the same thing. */
69
- private readonly inFlight;
70
- private generation;
71
- constructor(opts?: ApprovalPolicyOptions);
72
- request(req: ApprovalRequest): Promise<boolean>;
73
- /** Scopes the user has granted this session — for display and for persistence. */
74
- grantedScopes(): string[];
75
- /** Drop every session-scoped decision. Called on session reset. */
76
- reset(): void;
77
- }
78
-
79
- export { type ApprovalKind as A, DENY_ALL as D, type IApproval as I, type ApprovalMode as a, ApprovalPolicy as b, type ApprovalPolicyOptions as c, type ApprovalRequest as d, type ApprovalSource as e };