@andorra-labs/code 0.1.9 → 0.1.11
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.
- package/README.md +28 -208
- package/THIRD_PARTY_NOTICES.md +15 -0
- package/dist/src/agent-execution.js +56 -0
- package/dist/src/app-server/protocol.d.ts +109 -1
- package/dist/src/app-server/protocol.js +8 -1
- package/dist/src/app-server.d.ts +59 -1
- package/dist/src/app-server.js +418 -63
- package/dist/src/auth/index.d.ts +1 -1
- package/dist/src/auth/index.js +1 -1
- package/dist/src/auth/store.d.ts +17 -1
- package/dist/src/auth/store.js +25 -2
- package/dist/src/automation-service.js +1 -1
- package/dist/src/browser-session.d.ts +8 -0
- package/dist/src/browser-session.js +27 -1
- package/dist/src/browser-ui/app.js +255 -33
- package/dist/src/browser-ui/index.html +9 -9
- package/dist/src/browser-ui/style.css +110 -65
- package/dist/src/browser-ui/tokens.css +27 -26
- package/dist/src/cli.js +10 -5
- package/dist/src/coding-tools.d.ts +24 -0
- package/dist/src/coding-tools.js +71 -8
- package/dist/src/command-screens.js +1 -1
- package/dist/src/commands.d.ts +1 -1
- package/dist/src/commands.js +2 -2
- package/dist/src/completion-gates.d.ts +42 -7
- package/dist/src/completion-gates.js +55 -9
- package/dist/src/completion.d.ts +9 -1
- package/dist/src/completion.js +20 -2
- package/dist/src/dashboard-view.js +2 -2
- package/dist/src/deadline.js +4 -0
- package/dist/src/decision/checks.js +1 -1
- package/dist/src/file-diff.d.ts +105 -0
- package/dist/src/file-diff.js +244 -0
- package/dist/src/graph-manager-chat.js +4 -4
- package/dist/src/graph-runner.js +39 -2
- package/dist/src/graph-sync.d.ts +8 -0
- package/dist/src/graph-sync.js +54 -3
- package/dist/src/graph-tool.js +1 -1
- package/dist/src/graph-ui/app.js +303 -129
- package/dist/src/graph-ui/controls.css +43 -22
- package/dist/src/graph-ui/controls.js +31 -1
- package/dist/src/graph-ui/embed.js +56 -7
- package/dist/src/graph-ui/icons.js +5 -0
- package/dist/src/graph-ui/index.html +3 -3
- package/dist/src/graph-ui/manager-state.js +2 -2
- package/dist/src/graph-ui/manager.css +19 -18
- package/dist/src/graph-ui/manager.js +5 -5
- package/dist/src/graph-ui/skill-picker.js +5 -5
- package/dist/src/graph-ui/studio-canvas.js +16 -16
- package/dist/src/graph-ui/studio.css +18 -15
- package/dist/src/graph-ui/studio.js +99 -42
- package/dist/src/graph-ui/style.css +125 -80
- package/dist/src/graph-ui/theme.js +2 -2
- package/dist/src/graph-ui/tokens.css +33 -29
- package/dist/src/graphs.d.ts +10 -3
- package/dist/src/graphs.js +15 -4
- package/dist/src/mcp.d.ts +75 -0
- package/dist/src/mcp.js +240 -8
- package/dist/src/membership-errors.d.ts +7 -1
- package/dist/src/membership-errors.js +9 -3
- package/dist/src/provider-keys.d.ts +5 -1
- package/dist/src/provider-keys.js +7 -3
- package/dist/src/provider-settings.d.ts +4 -1
- package/dist/src/provider-settings.js +46 -5
- package/dist/src/pull-requests.d.ts +42 -6
- package/dist/src/pull-requests.js +11 -3
- package/dist/src/qa/guidance.js +6 -19
- package/dist/src/qa/index.d.ts +0 -2
- package/dist/src/qa/index.js +0 -2
- package/dist/src/qa/profile/QaProfile.d.ts +5 -1
- package/dist/src/qa/profile/QaProfile.js +6 -2
- package/dist/src/qa/tools.d.ts +19 -1
- package/dist/src/qa/tools.js +20 -145
- package/dist/src/react-runtime.js +134 -16
- package/dist/src/read-document-doc.d.ts +20 -0
- package/dist/src/read-document-doc.js +524 -0
- package/dist/src/read-document-docx.d.ts +21 -0
- package/dist/src/read-document-docx.js +584 -0
- package/dist/src/read-document-text.d.ts +29 -0
- package/dist/src/read-document-text.js +67 -0
- package/dist/src/read-document-tool.d.ts +48 -0
- package/dist/src/read-document-tool.js +162 -0
- package/dist/src/read-document.d.ts +78 -0
- package/dist/src/read-document.js +353 -0
- package/dist/src/read-image.d.ts +29 -2
- package/dist/src/read-image.js +42 -17
- package/dist/src/remote/engine-pool.js +18 -6
- package/dist/src/runtime.d.ts +19 -0
- package/dist/src/runtime.js +10 -1
- package/dist/src/screen-selection.d.ts +38 -0
- package/dist/src/screen-selection.js +103 -0
- package/dist/src/session-changes.d.ts +122 -0
- package/dist/src/session-changes.js +804 -0
- package/dist/src/side-panel.d.ts +6 -1
- package/dist/src/side-panel.js +12 -10
- package/dist/src/skills/bundled/create-skill/SKILL.md +1 -1
- package/dist/src/skills/bundled/diagram/SKILL.md +1 -1
- package/dist/src/skills/bundled/graph-manager/SKILL.md +37 -3
- package/dist/src/skills/bundled/graph-manager/patterns.md +27 -0
- package/dist/src/skills/bundled/provenance.json +4 -4
- package/dist/src/skills/runtime-skills.js +3 -3
- package/dist/src/stall-recovery.d.ts +15 -0
- package/dist/src/stall-recovery.js +17 -0
- package/dist/src/telemetry/schema.d.ts +1 -1
- package/dist/src/telemetry/schema.js +1 -2
- package/dist/src/terminal-ui.d.ts +64 -20
- package/dist/src/terminal-ui.js +312 -82
- package/dist/src/time-limit.d.ts +53 -0
- package/dist/src/time-limit.js +79 -0
- package/dist/src/tool-diff-stats.d.ts +9 -0
- package/dist/src/tool-diff-stats.js +20 -0
- package/dist/src/tool-names.d.ts +1 -1
- package/dist/src/tool-result-filter.js +1 -1
- package/dist/src/tools.js +118 -9
- package/dist/src/transcript.d.ts +11 -0
- package/dist/src/transcript.js +15 -3
- package/dist/src/types.d.ts +12 -0
- package/dist/src/usage-analytics.d.ts +3 -1
- package/dist/src/usage-analytics.js +16 -2
- package/package.json +6 -26
- package/dist/src/qa/api/http-runner.d.ts +0 -3
- package/dist/src/qa/api/http-runner.js +0 -47
- package/dist/src/qa/git/ChangeDetector.d.ts +0 -26
- package/dist/src/qa/git/ChangeDetector.js +0 -177
- package/dist/src/qa/git/DiffReviewer.d.ts +0 -28
- package/dist/src/qa/git/DiffReviewer.js +0 -115
- package/dist/src/qa/orchestrator/ChangeClassifier.d.ts +0 -14
- package/dist/src/qa/orchestrator/ChangeClassifier.js +0 -28
- package/dist/src/qa/orchestrator/MergeGate.d.ts +0 -14
- package/dist/src/qa/orchestrator/MergeGate.js +0 -40
- package/dist/src/qa/orchestrator/QaOrchestrator.d.ts +0 -79
- package/dist/src/qa/orchestrator/QaOrchestrator.js +0 -373
- package/dist/src/qa/runners/CommandRunner.d.ts +0 -22
- package/dist/src/qa/runners/CommandRunner.js +0 -96
- package/dist/src/qa/runners/TestRunner.d.ts +0 -21
- package/dist/src/qa/runners/TestRunner.js +0 -66
- package/dist/src/qa/runtime/RuntimeSmoke.d.ts +0 -11
- package/dist/src/qa/runtime/RuntimeSmoke.js +0 -78
- package/dist/src/qa/runtime-detect.d.ts +0 -10
- package/dist/src/qa/runtime-detect.js +0 -72
- package/dist/src/qa/security/DependencyScanner.d.ts +0 -19
- package/dist/src/qa/security/DependencyScanner.js +0 -167
- package/dist/src/qa/security/SecretScanner.d.ts +0 -3
- package/dist/src/qa/security/SecretScanner.js +0 -55
- package/docs/README.md +0 -36
- package/docs/agents/README.md +0 -62
- package/docs/agents/install-for-agents.md +0 -56
- package/docs/agents/mcp-server.md +0 -212
- package/docs/agents/subagent-mode.md +0 -149
- package/docs/concepts/README.md +0 -47
- package/docs/concepts/jev-actionable-routing.md +0 -113
- package/docs/concepts/jev-decision-thresholds.md +0 -412
- package/docs/concepts/jev-efficiency.md +0 -217
- package/docs/concepts/jev-eval-2026-11-01.md +0 -78
- package/docs/concepts/limits.md +0 -52
- package/docs/concepts/memory.md +0 -10
- package/docs/concepts/security.md +0 -50
- package/docs/concepts/workspace-instructions.md +0 -29
- package/docs/getting-started/README.md +0 -82
- package/docs/getting-started/accounts.md +0 -78
- package/docs/getting-started/configure-providers.md +0 -132
- package/docs/guides/README.md +0 -13
- package/docs/guides/browser.md +0 -39
- package/docs/guides/desktop-app.md +0 -414
- package/docs/guides/extensions.md +0 -102
- package/docs/guides/graph-builder.md +0 -116
- package/docs/guides/headless.md +0 -46
- package/docs/guides/tui.md +0 -75
- package/docs/guides/update.md +0 -70
- package/docs/guides/web-search.md +0 -51
- package/docs/guides/windows-code-signing.md +0 -319
- package/docs/llms.txt +0 -45
- package/docs/reference/README.md +0 -7
- package/docs/reference/cli.md +0 -76
- package/docs/reference/config.md +0 -91
- package/docs/reference/slash-commands.md +0 -59
- package/docs/superpowers/plans/2026-11-01-claude-console-sign-in.md +0 -111
- package/docs/superpowers/plans/2026-11-01-jev-node-opt-in.md +0 -910
- package/docs/superpowers/plans/2026-11-02-workflow-pane.md +0 -398
- package/docs/superpowers/plans/2026-11-06-graph-soft-delete.md +0 -125
- package/docs/superpowers/plans/2026-11-09-orchestrator-delegation.md +0 -295
- package/docs/superpowers/plans/2026-11-13-graph-manager-chat.md +0 -203
- package/docs/superpowers/plans/2026-11-14-jev-fair-use-pricing.md +0 -79
- package/docs/superpowers/specs/2026-10-31-work-line-summary-design.md +0 -50
- package/docs/superpowers/specs/2026-11-01-claude-console-sign-in-design.md +0 -176
- package/docs/superpowers/specs/2026-11-01-jev-node-opt-in-design.md +0 -164
- package/docs/superpowers/specs/2026-11-01-pr-section-design.md +0 -111
- package/docs/superpowers/specs/2026-11-02-workflow-pane-design.md +0 -130
- package/docs/superpowers/specs/2026-11-06-bundled-skills-design.md +0 -206
- package/docs/superpowers/specs/2026-11-09-orchestrator-delegation-design.md +0 -291
- package/docs/superpowers/specs/2026-11-13-graph-manager-chat-design.md +0 -182
- package/docs/superpowers/specs/2026-11-14-jev-fair-use-pricing-design.md +0 -156
- package/scripts/jev-efficiency-eval.mjs +0 -187
- package/scripts/jev-efficiency-live.mjs +0 -193
- package/scripts/zcode-engine-replay.mjs +0 -223
- package/tests/agent-centric-mcp-test-plan.md +0 -208
- package/tests/analytics-settings-test-plan.md +0 -165
- package/tests/browser-cli-smoke.mjs +0 -276
- package/tests/browser-test-plan.md +0 -280
- package/tests/chat-side-panel-test-plan.md +0 -309
- package/tests/decision-engine-test-plan.md +0 -163
- package/tests/default-active-jev-test-plan.md +0 -85
- package/tests/harness-extensions-test-plan.md +0 -113
- package/tests/jev-all-decisions-test-plan.md +0 -156
- package/tests/jev-efficiency/criteria.json +0 -158
- package/tests/jev-efficiency/workloads.mjs +0 -242
- package/tests/jev-efficiency-test-plan.md +0 -198
- package/tests/permissions-sandbox-probe.mjs +0 -74
- package/tests/permissions-test-plan.md +0 -191
- package/tests/product-telemetry-test-plan.md +0 -536
- package/tests/thinking-stream-preview-test-plan.md +0 -136
- package/tests/zcode-react-engine-test-plan.md +0 -396
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** One screen cell, 1-based like the terminal's own mouse reports. */
|
|
2
|
+
export interface ScreenCell {
|
|
3
|
+
row: number;
|
|
4
|
+
column: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* A drag selection in screen coordinates.
|
|
8
|
+
*
|
|
9
|
+
* `limit` is the last column the selection may reach: a drag that starts in the chat column stops
|
|
10
|
+
* at its edge, so the side panel drawn beside it is never copied along with the transcript.
|
|
11
|
+
*/
|
|
12
|
+
export interface ScreenSelection {
|
|
13
|
+
anchor: ScreenCell;
|
|
14
|
+
head: ScreenCell;
|
|
15
|
+
limit?: number;
|
|
16
|
+
}
|
|
17
|
+
/** The selection's two ends in reading order. */
|
|
18
|
+
export declare function orderedSelection(selection: ScreenSelection): [ScreenCell, ScreenCell];
|
|
19
|
+
/** Whether the selection covers nothing but the cell it started on. */
|
|
20
|
+
export declare function emptySelection(selection: ScreenSelection): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The inclusive column span the selection covers on one row, or undefined when it misses the row.
|
|
23
|
+
*
|
|
24
|
+
* A selection reads like text: the first row runs from its start to the edge, the last row from
|
|
25
|
+
* the edge to its end, and every row between is taken whole.
|
|
26
|
+
*/
|
|
27
|
+
export declare function selectedSpan(selection: ScreenSelection, row: number): [number, number] | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Draw one row with the selected columns in reverse video.
|
|
30
|
+
*
|
|
31
|
+
* The row keeps its own colors. Reverse video is re-asserted after every escape inside the span,
|
|
32
|
+
* because a color reset there would otherwise end the highlight early.
|
|
33
|
+
*/
|
|
34
|
+
export declare function highlightRow(line: string, from: number, to: number): string;
|
|
35
|
+
/** The plain text the selection covers, one line per screen row, trailing blanks dropped. */
|
|
36
|
+
export declare function selectedText(rows: readonly string[], selection: ScreenSelection): string;
|
|
37
|
+
/** The run of non-blank cells under a cell, as a selection; undefined on blank space. */
|
|
38
|
+
export declare function wordAt(rows: readonly string[], cell: ScreenCell): ScreenSelection | undefined;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import stringWidth from 'string-width';
|
|
2
|
+
const segmenter = new Intl.Segmenter(undefined, { granularity: 'grapheme' });
|
|
3
|
+
/** A CSI sequence (colors, cursor moves) or an OSC string, matched at the start of the text. */
|
|
4
|
+
const ESCAPE = /^(?:\x1b\[[0-?]*[ -/]*[@-~]|\x1b\][^\x07\x1b]*(?:\x07|\x1b\\))/;
|
|
5
|
+
/**
|
|
6
|
+
* Split one drawn row into escape sequences and graphemes, each grapheme with the columns it covers.
|
|
7
|
+
*
|
|
8
|
+
* A zero-width grapheme takes the column of the cell before it, so it travels with that cell.
|
|
9
|
+
*/
|
|
10
|
+
function pieces(line) {
|
|
11
|
+
const result = [];
|
|
12
|
+
let column = 1, rest = line;
|
|
13
|
+
while (rest) {
|
|
14
|
+
const escape = ESCAPE.exec(rest);
|
|
15
|
+
if (escape) {
|
|
16
|
+
result.push({ text: escape[0], escape: true, from: column, to: column - 1 });
|
|
17
|
+
rest = rest.slice(escape[0].length);
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const next = rest.indexOf('\x1b', 1);
|
|
21
|
+
const run = rest.startsWith('\x1b') ? rest.slice(0, 1) : next < 0 ? rest : rest.slice(0, next);
|
|
22
|
+
rest = rest.slice(run.length);
|
|
23
|
+
for (const { segment } of segmenter.segment(run)) {
|
|
24
|
+
const width = stringWidth(segment);
|
|
25
|
+
if (width === 0)
|
|
26
|
+
result.push({ text: segment, escape: false, from: column - 1, to: column - 1 });
|
|
27
|
+
else {
|
|
28
|
+
result.push({ text: segment, escape: false, from: column, to: column + width - 1 });
|
|
29
|
+
column += width;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
/** The selection's two ends in reading order. */
|
|
36
|
+
export function orderedSelection(selection) {
|
|
37
|
+
const { anchor, head } = selection;
|
|
38
|
+
return anchor.row < head.row || (anchor.row === head.row && anchor.column <= head.column) ? [anchor, head] : [head, anchor];
|
|
39
|
+
}
|
|
40
|
+
/** Whether the selection covers nothing but the cell it started on. */
|
|
41
|
+
export function emptySelection(selection) {
|
|
42
|
+
return selection.anchor.row === selection.head.row && selection.anchor.column === selection.head.column;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The inclusive column span the selection covers on one row, or undefined when it misses the row.
|
|
46
|
+
*
|
|
47
|
+
* A selection reads like text: the first row runs from its start to the edge, the last row from
|
|
48
|
+
* the edge to its end, and every row between is taken whole.
|
|
49
|
+
*/
|
|
50
|
+
export function selectedSpan(selection, row) {
|
|
51
|
+
const [start, end] = orderedSelection(selection);
|
|
52
|
+
if (row < start.row || row > end.row)
|
|
53
|
+
return undefined;
|
|
54
|
+
const edge = selection.limit ?? Number.MAX_SAFE_INTEGER;
|
|
55
|
+
const from = row === start.row ? start.column : 1, to = Math.min(edge, row === end.row ? end.column : edge);
|
|
56
|
+
return from <= to ? [from, to] : undefined;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Draw one row with the selected columns in reverse video.
|
|
60
|
+
*
|
|
61
|
+
* The row keeps its own colors. Reverse video is re-asserted after every escape inside the span,
|
|
62
|
+
* because a color reset there would otherwise end the highlight early.
|
|
63
|
+
*/
|
|
64
|
+
export function highlightRow(line, from, to) {
|
|
65
|
+
let out = '', inside = false;
|
|
66
|
+
for (const piece of pieces(line)) {
|
|
67
|
+
if (piece.escape) {
|
|
68
|
+
out += piece.text + (inside ? '\x1b[7m' : '');
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const selected = piece.to >= from && piece.from <= to;
|
|
72
|
+
if (selected !== inside) {
|
|
73
|
+
out += selected ? '\x1b[7m' : '\x1b[27m';
|
|
74
|
+
inside = selected;
|
|
75
|
+
}
|
|
76
|
+
out += piece.text;
|
|
77
|
+
}
|
|
78
|
+
return inside ? out + '\x1b[27m' : out;
|
|
79
|
+
}
|
|
80
|
+
/** The plain text the selection covers, one line per screen row, trailing blanks dropped. */
|
|
81
|
+
export function selectedText(rows, selection) {
|
|
82
|
+
const [start, end] = orderedSelection(selection);
|
|
83
|
+
const lines = [];
|
|
84
|
+
for (let row = start.row; row <= end.row; row++) {
|
|
85
|
+
const span = selectedSpan(selection, row);
|
|
86
|
+
const text = span ? pieces(rows[row - 1] ?? '').filter(piece => !piece.escape && piece.to >= span[0] && piece.from <= span[1]).map(piece => piece.text).join('') : '';
|
|
87
|
+
lines.push(text.trimEnd());
|
|
88
|
+
}
|
|
89
|
+
return lines.join('\n');
|
|
90
|
+
}
|
|
91
|
+
/** The run of non-blank cells under a cell, as a selection; undefined on blank space. */
|
|
92
|
+
export function wordAt(rows, cell) {
|
|
93
|
+
const cells = pieces(rows[cell.row - 1] ?? '').filter(piece => !piece.escape && piece.to >= piece.from);
|
|
94
|
+
const at = cells.findIndex(piece => piece.from <= cell.column && piece.to >= cell.column);
|
|
95
|
+
if (at < 0 || !/\S/u.test(cells[at].text))
|
|
96
|
+
return undefined;
|
|
97
|
+
let first = at, last = at;
|
|
98
|
+
while (first > 0 && /\S/u.test(cells[first - 1].text))
|
|
99
|
+
first--;
|
|
100
|
+
while (last < cells.length - 1 && /\S/u.test(cells[last + 1].text))
|
|
101
|
+
last++;
|
|
102
|
+
return { anchor: { row: cell.row, column: cells[first].from }, head: { row: cell.row, column: cells[last].to } };
|
|
103
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { AppServerSessionChanges, AppServerSessionChangesKept, AppServerSessionChangesUndone, AppServerSessionFileChange } from './app-server/protocol.js';
|
|
2
|
+
/**
|
|
3
|
+
* The files an agent changed in a session since the person last reviewed them, with Keep and Undo.
|
|
4
|
+
*
|
|
5
|
+
* Every write an agent makes to a workspace file passes one function (`atomicWrite` in `tools.ts`), and a
|
|
6
|
+
* delegated change lands through one more (`applyLanding`). Both report here, before and after: before, so
|
|
7
|
+
* the content the file held can be kept as its baseline the first time the agent touches it; after, so the
|
|
8
|
+
* store knows what the agent's write left. Between two reviews the baseline never moves — a file edited ten
|
|
9
|
+
* times has one entry, and its diff is the file's whole change, not the last call's.
|
|
10
|
+
*
|
|
11
|
+
* Keep makes the file as it is the new baseline: it leaves the pending set and its stored original is
|
|
12
|
+
* dropped. Undo puts the baseline back — the earlier content, or no file at all for one the agent created,
|
|
13
|
+
* or the file again for one a landing removed — but only while the file is still what the agent left: a file
|
|
14
|
+
* something else changed afterwards is reported as a conflict instead of being overwritten, unless the
|
|
15
|
+
* caller asks with `force`.
|
|
16
|
+
*
|
|
17
|
+
* The record lives in the configuration home beside the session (`session-changes/<id>/`), not in the
|
|
18
|
+
* workspace and not in Git: it works for a folder that is no repository, needs no index, and survives an
|
|
19
|
+
* app restart and a resumed session. Engines sharing a home can all read and change it — the desktop runs a
|
|
20
|
+
* process per task and browses with another — so every change happens under the session's store lock, and
|
|
21
|
+
* the revision it carries orders every answer and event across those processes.
|
|
22
|
+
*/
|
|
23
|
+
/** Past this size a file's earlier content is not kept: the change is listed, and Undo refuses the file. */
|
|
24
|
+
export declare const BASELINE_BYTE_LIMIT: number;
|
|
25
|
+
/** Diff lines `list` returns per file unless asked for another bound. */
|
|
26
|
+
export declare const LIST_DIFF_LINES = 200;
|
|
27
|
+
/** The most diff lines one answer may ask for per file. */
|
|
28
|
+
export declare const MAX_DIFF_LINES = 20000;
|
|
29
|
+
/** Session ids name files, so only the characters a session id is made of are accepted. */
|
|
30
|
+
export declare function sessionChangesId(id: string): string;
|
|
31
|
+
export declare const sessionChangesRoot: (home: string) => string;
|
|
32
|
+
/**
|
|
33
|
+
* One write (or one landing of several files) as the review record sees it.
|
|
34
|
+
*
|
|
35
|
+
* The write's own mutation of the disk happens between `begin` and `commit`, and those hold the session's
|
|
36
|
+
* review lock — the one Keep and Undo take — so an Undo can never observe a file, have an agent write land on
|
|
37
|
+
* it, and then restore over that write: either the Undo finishes first and the write lands on the restored
|
|
38
|
+
* file (and is recorded against it), or the write lands first and the Undo sees it.
|
|
39
|
+
*
|
|
40
|
+
* - `begin` takes the lock and reads what each file holds now, which becomes its original the first time it
|
|
41
|
+
* changes. Call it right before the mutation, after anything that can wait on a person (an approval).
|
|
42
|
+
* - `commit` records what the mutation left and releases the lock; `abort` releases it for a write that did
|
|
43
|
+
* not land. Exactly one of them must follow a `begin` that resolved.
|
|
44
|
+
*
|
|
45
|
+
* None of them may fail the write: a record that cannot be made is a change the review does not list, not a
|
|
46
|
+
* lost edit. They reject only when the lock could not be taken (`begin`), which the writer treats as
|
|
47
|
+
* "write unrecorded".
|
|
48
|
+
*/
|
|
49
|
+
export interface FileWriteRecording {
|
|
50
|
+
begin(): Promise<void>;
|
|
51
|
+
commit(): Promise<void>;
|
|
52
|
+
abort(): Promise<void>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Where a run's tools report their writes. `beforeWrite` is called with the canonical paths a mutation will
|
|
56
|
+
* write or remove, before any folder is created for them; it answers nothing when none of the paths is one
|
|
57
|
+
* this recorder tracks.
|
|
58
|
+
*/
|
|
59
|
+
export interface FileChangeRecorder {
|
|
60
|
+
beforeWrite(targets: string | readonly string[]): Promise<FileWriteRecording | undefined>;
|
|
61
|
+
}
|
|
62
|
+
export declare class SessionChangeStore {
|
|
63
|
+
private readonly home;
|
|
64
|
+
private readonly baselineLimit;
|
|
65
|
+
private readonly beforeRestore?;
|
|
66
|
+
/**
|
|
67
|
+
* Both options exist for tests: `baselineLimit` is the size past which an original is not kept, and
|
|
68
|
+
* `beforeRestore` runs inside an Undo, under its lock, after it has checked the files and before it writes.
|
|
69
|
+
*/
|
|
70
|
+
constructor(home: string, options?: {
|
|
71
|
+
baselineLimit?: number;
|
|
72
|
+
beforeRestore?: () => Promise<void>;
|
|
73
|
+
beginMemory?: number;
|
|
74
|
+
});
|
|
75
|
+
/** Test seam: the bytes of originals one write holds in memory before the rest go to the store. */
|
|
76
|
+
private readonly beginMemory;
|
|
77
|
+
/**
|
|
78
|
+
* The recorder a run's tools report their writes to. Only files inside `root` (the run's workspace folder)
|
|
79
|
+
* are tracked: a delegated subagent writes in a worktree of its own, and its change reaches the workspace
|
|
80
|
+
* through the landing, which reports the files it lands.
|
|
81
|
+
*
|
|
82
|
+
* `review` answers, as a write lands, whether the person reviews this run's writes. A run that does not
|
|
83
|
+
* ask (Full Access) adds no file to the pending set: its writes are kept as they land, and nothing waits
|
|
84
|
+
* on a Keep. A file already pending from a reviewed write stays tracked, so its entry and its Undo still
|
|
85
|
+
* describe what is on disk.
|
|
86
|
+
*/
|
|
87
|
+
recorder(sessionId: string, workspace: string, onChange: (changes: AppServerSessionChanges) => void, onError?: (error: unknown) => void, review?: () => boolean): FileChangeRecorder;
|
|
88
|
+
/** Records what a landed write left, for each file it wrote. The caller holds the session's lock. */
|
|
89
|
+
private recordWrites;
|
|
90
|
+
/** Updates one file's entry in `state`; answers whether the pending set changed. */
|
|
91
|
+
private recordWrite;
|
|
92
|
+
/** The pending set as the last write, Keep or Undo left it, without reading the files. */
|
|
93
|
+
pending(sessionId: string): Promise<AppServerSessionChanges>;
|
|
94
|
+
/** Each pending file with its diff from the earlier content to the file as it is now, `maxLines` per file. */
|
|
95
|
+
list(sessionId: string, maxLines?: number): Promise<AppServerSessionChanges>;
|
|
96
|
+
/** One pending file with its diff, up to `maxLines`; null when the file is not pending. */
|
|
97
|
+
get(sessionId: string, relative: string, maxLines?: number): Promise<{
|
|
98
|
+
revision: number;
|
|
99
|
+
change: AppServerSessionFileChange | null;
|
|
100
|
+
}>;
|
|
101
|
+
/** A stored entry measured against the disk now; nothing when the file is back to its baseline. */
|
|
102
|
+
private fresh;
|
|
103
|
+
/** Accepts the named files (every pending file when `paths` is omitted): each leaves the pending set as it is. */
|
|
104
|
+
keep(sessionId: string, paths?: readonly string[]): Promise<AppServerSessionChangesKept>;
|
|
105
|
+
/**
|
|
106
|
+
* Restores the named files (every pending file when `paths` is omitted) to their content before the first
|
|
107
|
+
* unreviewed change. A file whose disk content is no longer what the agent left is a conflict: without
|
|
108
|
+
* `force` one such conflict reverts nothing, so a multi-file Undo never leaves the folder half restored by
|
|
109
|
+
* choice. A file whose original was too large to keep is reported and stays pending either way.
|
|
110
|
+
*
|
|
111
|
+
* The check and the restore run under the lock of every file restored, the lock any session's agent write
|
|
112
|
+
* holds from just before its rename until it is recorded (`FileWriteRecording`), so no write — of this
|
|
113
|
+
* session or another one editing the same folder — can land between them.
|
|
114
|
+
*/
|
|
115
|
+
undo(sessionId: string, paths?: readonly string[], force?: boolean): Promise<AppServerSessionChangesUndone>;
|
|
116
|
+
/** Undo of `targets`, whose file locks and the session's lock the caller holds. */
|
|
117
|
+
private undoLocked;
|
|
118
|
+
/** Puts one file back to its baseline. Refuses a path whose folders now lead outside the workspace. */
|
|
119
|
+
private restore;
|
|
120
|
+
/** Forgets the session's record and its stored originals, as a deleted session must. */
|
|
121
|
+
remove(sessionId: string): Promise<void>;
|
|
122
|
+
}
|