@voxslopuli/openagentsy 0.0.0-stage → 0.2.0
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/LICENSE +674 -0
- package/README.md +21 -2
- package/dist/adapter-dependency.test.d.ts +2 -0
- package/dist/adapter-dependency.test.d.ts.map +1 -0
- package/dist/adapter-dependency.test.js +51 -0
- package/dist/adapter-dependency.test.js.map +1 -0
- package/dist/commands/approve.d.ts +63 -0
- package/dist/commands/approve.d.ts.map +1 -0
- package/dist/commands/approve.js +218 -0
- package/dist/commands/approve.js.map +1 -0
- package/dist/commands/approve.test.d.ts +2 -0
- package/dist/commands/approve.test.d.ts.map +1 -0
- package/dist/commands/approve.test.js +219 -0
- package/dist/commands/approve.test.js.map +1 -0
- package/dist/commands/audit.d.ts +74 -0
- package/dist/commands/audit.d.ts.map +1 -0
- package/dist/commands/audit.js +230 -0
- package/dist/commands/audit.js.map +1 -0
- package/dist/commands/audit.test.d.ts +2 -0
- package/dist/commands/audit.test.d.ts.map +1 -0
- package/dist/commands/audit.test.js +194 -0
- package/dist/commands/audit.test.js.map +1 -0
- package/dist/commands/board.d.ts +33 -0
- package/dist/commands/board.d.ts.map +1 -0
- package/dist/commands/board.js +65 -0
- package/dist/commands/board.js.map +1 -0
- package/dist/commands/build.d.ts +17 -0
- package/dist/commands/build.d.ts.map +1 -0
- package/dist/commands/build.js +145 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/conformance.d.ts +31 -0
- package/dist/commands/conformance.d.ts.map +1 -0
- package/dist/commands/conformance.js +57 -0
- package/dist/commands/conformance.js.map +1 -0
- package/dist/commands/conformance.test.d.ts +2 -0
- package/dist/commands/conformance.test.d.ts.map +1 -0
- package/dist/commands/conformance.test.js +74 -0
- package/dist/commands/conformance.test.js.map +1 -0
- package/dist/commands/doctor.d.ts +132 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +768 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/doctor.test.d.ts +2 -0
- package/dist/commands/doctor.test.d.ts.map +1 -0
- package/dist/commands/doctor.test.js +329 -0
- package/dist/commands/doctor.test.js.map +1 -0
- package/dist/commands/ledger.d.ts +109 -0
- package/dist/commands/ledger.d.ts.map +1 -0
- package/dist/commands/ledger.js +286 -0
- package/dist/commands/ledger.js.map +1 -0
- package/dist/commands/ledger.test.d.ts +2 -0
- package/dist/commands/ledger.test.d.ts.map +1 -0
- package/dist/commands/ledger.test.js +238 -0
- package/dist/commands/ledger.test.js.map +1 -0
- package/dist/commands/lessons.d.ts +73 -0
- package/dist/commands/lessons.d.ts.map +1 -0
- package/dist/commands/lessons.js +97 -0
- package/dist/commands/lessons.js.map +1 -0
- package/dist/commands/lessons.test.d.ts +2 -0
- package/dist/commands/lessons.test.d.ts.map +1 -0
- package/dist/commands/lessons.test.js +146 -0
- package/dist/commands/lessons.test.js.map +1 -0
- package/dist/commands/models.d.ts +49 -0
- package/dist/commands/models.d.ts.map +1 -0
- package/dist/commands/models.js +125 -0
- package/dist/commands/models.js.map +1 -0
- package/dist/commands/report.d.ts +57 -0
- package/dist/commands/report.d.ts.map +1 -0
- package/dist/commands/report.js +164 -0
- package/dist/commands/report.js.map +1 -0
- package/dist/commands/report.test.d.ts +2 -0
- package/dist/commands/report.test.d.ts.map +1 -0
- package/dist/commands/report.test.js +294 -0
- package/dist/commands/report.test.js.map +1 -0
- package/dist/commands/scope.d.ts +34 -0
- package/dist/commands/scope.d.ts.map +1 -0
- package/dist/commands/scope.js +78 -0
- package/dist/commands/scope.js.map +1 -0
- package/dist/commands/scope.test.d.ts +2 -0
- package/dist/commands/scope.test.d.ts.map +1 -0
- package/dist/commands/scope.test.js +98 -0
- package/dist/commands/scope.test.js.map +1 -0
- package/dist/commands/setup.d.ts +31 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +93 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/waivers.d.ts +47 -0
- package/dist/commands/waivers.d.ts.map +1 -0
- package/dist/commands/waivers.js +68 -0
- package/dist/commands/waivers.js.map +1 -0
- package/dist/commands/waivers.test.d.ts +2 -0
- package/dist/commands/waivers.test.d.ts.map +1 -0
- package/dist/commands/waivers.test.js +64 -0
- package/dist/commands/waivers.test.js.map +1 -0
- package/dist/generate/agent.d.ts +19 -0
- package/dist/generate/agent.d.ts.map +1 -0
- package/dist/generate/agent.js +35 -0
- package/dist/generate/agent.js.map +1 -0
- package/dist/generate/agent.test.d.ts +2 -0
- package/dist/generate/agent.test.d.ts.map +1 -0
- package/dist/generate/agent.test.js +245 -0
- package/dist/generate/agent.test.js.map +1 -0
- package/dist/generate/commands.d.ts +15 -0
- package/dist/generate/commands.d.ts.map +1 -0
- package/dist/generate/commands.js +59 -0
- package/dist/generate/commands.js.map +1 -0
- package/dist/generate/lock.d.ts +18 -0
- package/dist/generate/lock.d.ts.map +1 -0
- package/dist/generate/lock.js +26 -0
- package/dist/generate/lock.js.map +1 -0
- package/dist/generate/prompt.d.ts +11 -0
- package/dist/generate/prompt.d.ts.map +1 -0
- package/dist/generate/prompt.js +114 -0
- package/dist/generate/prompt.js.map +1 -0
- package/dist/generate/prompt.test.d.ts +2 -0
- package/dist/generate/prompt.test.d.ts.map +1 -0
- package/dist/generate/prompt.test.js +59 -0
- package/dist/generate/prompt.test.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +448 -0
- package/dist/index.js.map +1 -0
- package/dist/index.test.d.ts +2 -0
- package/dist/index.test.d.ts.map +1 -0
- package/dist/index.test.js +237 -0
- package/dist/index.test.js.map +1 -0
- package/dist/opencode.d.ts +29 -0
- package/dist/opencode.d.ts.map +1 -0
- package/dist/opencode.js +125 -0
- package/dist/opencode.js.map +1 -0
- package/dist/plugin-bundle.test.d.ts +2 -0
- package/dist/plugin-bundle.test.d.ts.map +1 -0
- package/dist/plugin-bundle.test.js +43 -0
- package/dist/plugin-bundle.test.js.map +1 -0
- package/dist/plugin.d.ts +11 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +46 -0
- package/dist/plugin.js.map +1 -0
- package/dist/quality-skills.test.d.ts +2 -0
- package/dist/quality-skills.test.d.ts.map +1 -0
- package/dist/quality-skills.test.js +141 -0
- package/dist/quality-skills.test.js.map +1 -0
- package/dist/report/footprint.d.ts +12 -0
- package/dist/report/footprint.d.ts.map +1 -0
- package/dist/report/footprint.js +121 -0
- package/dist/report/footprint.js.map +1 -0
- package/dist/report/ledger.d.ts +27 -0
- package/dist/report/ledger.d.ts.map +1 -0
- package/dist/report/ledger.js +197 -0
- package/dist/report/ledger.js.map +1 -0
- package/dist/report/oversight.d.ts +21 -0
- package/dist/report/oversight.d.ts.map +1 -0
- package/dist/report/oversight.js +146 -0
- package/dist/report/oversight.js.map +1 -0
- package/dist/report/policy-firing.test.d.ts +2 -0
- package/dist/report/policy-firing.test.d.ts.map +1 -0
- package/dist/report/policy-firing.test.js +68 -0
- package/dist/report/policy-firing.test.js.map +1 -0
- package/dist/report/scope.d.ts +64 -0
- package/dist/report/scope.d.ts.map +1 -0
- package/dist/report/scope.js +146 -0
- package/dist/report/scope.js.map +1 -0
- package/dist/who.d.ts +9 -0
- package/dist/who.d.ts.map +1 -0
- package/dist/who.js +11 -0
- package/dist/who.js.map +1 -0
- package/package.json +54 -4
- package/plugin/openagentsy.js +39478 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { access } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { closeLedger, detectCacheMiss, detectNoProgressAtPath, emptyLedgerExport, ledgerExport, ledgerPath, openLedger, recordOutcome, recordWasteRows, scanRefsTrailers, scanReverts, scanTaskTransitions, wasteByKind, wasteTotals, } from '@openagentsy/ledger';
|
|
4
|
+
export async function runLedger(stateRoot) {
|
|
5
|
+
const databasePath = ledgerPath(stateRoot);
|
|
6
|
+
// A project that has no ledger yet has nothing to show, and reading it
|
|
7
|
+
// should not create one.
|
|
8
|
+
const exists = await access(databasePath).then(() => true, () => false);
|
|
9
|
+
if (!exists) {
|
|
10
|
+
return {
|
|
11
|
+
root: stateRoot,
|
|
12
|
+
databasePath,
|
|
13
|
+
exists: false,
|
|
14
|
+
counters: emptyLedgerExport(),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const db = openLedger(stateRoot);
|
|
18
|
+
try {
|
|
19
|
+
return { root: stateRoot, databasePath, exists: true, counters: ledgerExport(db) };
|
|
20
|
+
}
|
|
21
|
+
finally {
|
|
22
|
+
closeLedger(db);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** A price, or the word for a price nobody knows. */
|
|
26
|
+
function money(usd) {
|
|
27
|
+
return usd === null ? 'unpriced' : `$${usd.toFixed(4)}`;
|
|
28
|
+
}
|
|
29
|
+
function field(label, value) {
|
|
30
|
+
return ` ${label.padEnd(12)}${value}`;
|
|
31
|
+
}
|
|
32
|
+
/** The number of tokens, with the thousands separated. */
|
|
33
|
+
function tokens(value) {
|
|
34
|
+
return value.toLocaleString('en-US');
|
|
35
|
+
}
|
|
36
|
+
export function formatLedgerReport(report) {
|
|
37
|
+
const lines = [];
|
|
38
|
+
const counters = report.counters;
|
|
39
|
+
lines.push('ledger');
|
|
40
|
+
lines.push(field('database', `${report.databasePath} ${report.exists ? 'found' : 'missing'}`));
|
|
41
|
+
lines.push(field('messages', String(counters.totals.messages)));
|
|
42
|
+
lines.push(field('tokens', tokens(counters.totals.tokens)));
|
|
43
|
+
lines.push(field('cost', money(counters.totals.usd)));
|
|
44
|
+
lines.push(field('unpriced', `${counters.totals.unpricedMessages} message(s)`));
|
|
45
|
+
lines.push('');
|
|
46
|
+
lines.push('by role');
|
|
47
|
+
if (counters.byRole.length === 0) {
|
|
48
|
+
lines.push(' (none)');
|
|
49
|
+
}
|
|
50
|
+
for (const role of counters.byRole) {
|
|
51
|
+
lines.push(` ${role.role.padEnd(14)}${tokens(role.tokens).padStart(10)} ${money(role.usd)}`);
|
|
52
|
+
}
|
|
53
|
+
lines.push('');
|
|
54
|
+
lines.push('by task');
|
|
55
|
+
if (counters.byTask.length === 0) {
|
|
56
|
+
lines.push(' (none)');
|
|
57
|
+
}
|
|
58
|
+
for (const task of counters.byTask) {
|
|
59
|
+
lines.push(` ${task.taskId.padEnd(14)}${tokens(task.tokens).padStart(10)} ${money(task.usd)}`);
|
|
60
|
+
}
|
|
61
|
+
lines.push('');
|
|
62
|
+
lines.push('waste');
|
|
63
|
+
lines.push(field('tokens', `${tokens(counters.waste.tokens)} (${counters.waste.percentage.toFixed(1)}%)`));
|
|
64
|
+
lines.push('');
|
|
65
|
+
lines.push('outcomes');
|
|
66
|
+
lines.push(field('tasks', `${counters.outcomes.tasksCompleted} completed, ${counters.outcomes.tasksScrapped} scrapped`));
|
|
67
|
+
lines.push(field('commits', `${counters.outcomes.commits} commit(s), ${counters.outcomes.prsMerged} merged`));
|
|
68
|
+
lines.push(field('per task', counters.tokensPerCompletedTask === null
|
|
69
|
+
? 'unpriced'
|
|
70
|
+
: `${tokens(counters.tokensPerCompletedTask)} tokens`));
|
|
71
|
+
lines.push('');
|
|
72
|
+
lines.push('offload');
|
|
73
|
+
lines.push(field('messages', `${counters.offload.messages} message(s), ${tokens(counters.offload.tokens)} tokens`));
|
|
74
|
+
lines.push(field('cost', money(counters.offload.usd)));
|
|
75
|
+
return `${lines.join('\n')}\n`;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The board of a project, at the path the board keeps it.
|
|
79
|
+
*/
|
|
80
|
+
function boardPath(stateRoot) {
|
|
81
|
+
return join(stateRoot, '.openagentsy', 'board.sqlite');
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Find the waste that can be found without the event bridge, and say what
|
|
85
|
+
* the waste is.
|
|
86
|
+
*/
|
|
87
|
+
export async function runLedgerWaste(stateRoot, options = {}) {
|
|
88
|
+
const since = options.since ?? '30 days ago';
|
|
89
|
+
const instant = instantOf(since);
|
|
90
|
+
const db = openLedger(stateRoot);
|
|
91
|
+
try {
|
|
92
|
+
const candidates = [
|
|
93
|
+
...detectCacheMiss(db, {
|
|
94
|
+
...(options.dataDir === undefined ? {} : { dataDir: options.dataDir }),
|
|
95
|
+
since: instant,
|
|
96
|
+
}),
|
|
97
|
+
...detectNoProgressAtPath(db, boardPath(stateRoot), {
|
|
98
|
+
since: instant,
|
|
99
|
+
...(options.leadAgent === undefined ? {} : { leadAgent: options.leadAgent }),
|
|
100
|
+
}),
|
|
101
|
+
];
|
|
102
|
+
const written = recordWasteRows(db, candidates);
|
|
103
|
+
return {
|
|
104
|
+
root: stateRoot,
|
|
105
|
+
written,
|
|
106
|
+
byKind: wasteByKind(db),
|
|
107
|
+
totals: wasteTotals(db),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
finally {
|
|
111
|
+
closeLedger(db);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* The reverted code of the repository, found on demand (§6.4).
|
|
116
|
+
*
|
|
117
|
+
* A command and not a daemon: it walks the history of the repository once,
|
|
118
|
+
* when a person or the Lead asks for it. The tokens of a signal are the
|
|
119
|
+
* builder tokens of the task the commit named, times the share of the lines
|
|
120
|
+
* that were taken back.
|
|
121
|
+
*
|
|
122
|
+
* The history is the workspace's: it is the branch the session works on. The
|
|
123
|
+
* ledger the signals are written into is the state root's.
|
|
124
|
+
*/
|
|
125
|
+
export async function runLedgerScanReverts(roots, options = {}) {
|
|
126
|
+
const since = options.since ?? '30 days ago';
|
|
127
|
+
const db = openLedger(roots.stateRoot);
|
|
128
|
+
try {
|
|
129
|
+
const candidates = scanReverts(roots.workspace, since, {
|
|
130
|
+
tokensForTask: builderTokens(db),
|
|
131
|
+
});
|
|
132
|
+
const written = recordWasteRows(db, candidates);
|
|
133
|
+
return {
|
|
134
|
+
root: roots.workspace,
|
|
135
|
+
since,
|
|
136
|
+
found: candidates.length,
|
|
137
|
+
written,
|
|
138
|
+
tokens: candidates.reduce((sum, row) => sum + row.tokens, 0),
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
finally {
|
|
142
|
+
closeLedger(db);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* The tokens the builders of a task spent.
|
|
147
|
+
*
|
|
148
|
+
* The ledger holds the tokens per message and the task each message was
|
|
149
|
+
* made for, so the sum of the builder rows of a task is what its reverts
|
|
150
|
+
* cost.
|
|
151
|
+
*/
|
|
152
|
+
function builderTokens(db) {
|
|
153
|
+
const rows = db
|
|
154
|
+
.query(`SELECT task_id, SUM(input + output + reasoning + cache_write) AS tokens
|
|
155
|
+
FROM usage WHERE task_id IS NOT NULL AND role = 'builder' GROUP BY task_id`)
|
|
156
|
+
.all();
|
|
157
|
+
const map = new Map();
|
|
158
|
+
for (const row of rows)
|
|
159
|
+
map.set(row.task_id, Number(row.tokens ?? 0));
|
|
160
|
+
return (taskId) => map.get(taskId) ?? 0;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* The outcomes of the work (§6.5).
|
|
164
|
+
*
|
|
165
|
+
* Two scanners run here: the `Refs:` trailers of the commits, and the task
|
|
166
|
+
* transitions — but only when the caller injects a reader for the tasks
|
|
167
|
+
* store. The ledger does not import that store, so the command runs without
|
|
168
|
+
* the task transitions until whoever knows the store injects a reader.
|
|
169
|
+
*
|
|
170
|
+
* The history is the workspace's, and the ledger the outcomes are written
|
|
171
|
+
* into is the state root's.
|
|
172
|
+
*/
|
|
173
|
+
export async function runLedgerOutcomes(roots, options = {}) {
|
|
174
|
+
const since = options.since ?? '30 days ago';
|
|
175
|
+
const db = openLedger(roots.stateRoot);
|
|
176
|
+
try {
|
|
177
|
+
const candidates = [
|
|
178
|
+
...scanRefsTrailers(roots.workspace, since),
|
|
179
|
+
...(options.taskReader === undefined
|
|
180
|
+
? []
|
|
181
|
+
: await scanTaskTransitions(roots.workspace, instantOf(since), options.taskReader)),
|
|
182
|
+
];
|
|
183
|
+
let written = 0;
|
|
184
|
+
for (const candidate of candidates) {
|
|
185
|
+
if (recordOutcome(db, candidate))
|
|
186
|
+
written += 1;
|
|
187
|
+
}
|
|
188
|
+
const rows = db
|
|
189
|
+
.query('SELECT kind, COUNT(*) AS count FROM outcome GROUP BY kind ORDER BY kind')
|
|
190
|
+
.all();
|
|
191
|
+
return {
|
|
192
|
+
root: roots.workspace,
|
|
193
|
+
since,
|
|
194
|
+
found: candidates.length,
|
|
195
|
+
written,
|
|
196
|
+
taskTransitions: options.taskReader !== undefined,
|
|
197
|
+
byKind: rows.map((row) => ({ kind: String(row.kind), count: Number(row.count) })),
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
finally {
|
|
201
|
+
closeLedger(db);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/** The length of a unit the relative form of `--since` uses. */
|
|
205
|
+
const RELATIVE_UNITS = {
|
|
206
|
+
second: 1000,
|
|
207
|
+
minute: 60_000,
|
|
208
|
+
hour: 3_600_000,
|
|
209
|
+
day: 86_400_000,
|
|
210
|
+
week: 604_800_000,
|
|
211
|
+
month: 2_592_000_000,
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* The instant a `--since` names, and the empty string when it names none.
|
|
215
|
+
*
|
|
216
|
+
* A date is a moment, and a relative phrase like "30 days ago" is a moment
|
|
217
|
+
* too — git understands the phrase, and the scanners that compare
|
|
218
|
+
* timestamps need it as a timestamp.
|
|
219
|
+
*/
|
|
220
|
+
function instantOf(since) {
|
|
221
|
+
const parsed = Date.parse(since);
|
|
222
|
+
if (Number.isFinite(parsed))
|
|
223
|
+
return new Date(parsed).toISOString();
|
|
224
|
+
const relative = /^(\d+)\s+([a-z]+)\s+ago$/.exec(since);
|
|
225
|
+
const amount = Number(relative?.[1]);
|
|
226
|
+
const unit = relative?.[2];
|
|
227
|
+
const ms = unit === undefined ? undefined : RELATIVE_UNITS[unit];
|
|
228
|
+
if (ms === undefined || !Number.isFinite(amount))
|
|
229
|
+
return '';
|
|
230
|
+
return new Date(Date.now() - amount * ms).toISOString();
|
|
231
|
+
}
|
|
232
|
+
/** The waste report, as a person reads it. */
|
|
233
|
+
export function formatWasteReport(report) {
|
|
234
|
+
const lines = [];
|
|
235
|
+
lines.push('waste');
|
|
236
|
+
lines.push(field('written', `${report.written} new signal(s)`));
|
|
237
|
+
lines.push(field('tokens', `${tokens(report.totals.tokens)} (${report.totals.percentage.toFixed(1)}%)`));
|
|
238
|
+
lines.push('');
|
|
239
|
+
if (report.byKind.length === 0) {
|
|
240
|
+
lines.push(' (none)');
|
|
241
|
+
}
|
|
242
|
+
for (const kind of report.byKind) {
|
|
243
|
+
lines.push(` ${kind.kind.padEnd(16)}${tokens(kind.tokens).padStart(10)} ${kind.count} signal(s) ${kind.percentage.toFixed(1)}%`);
|
|
244
|
+
}
|
|
245
|
+
return `${lines.join('\n')}\n`;
|
|
246
|
+
}
|
|
247
|
+
/** The head of a scan report: its title and the fields every scan has. */
|
|
248
|
+
function scanHead(title, fields) {
|
|
249
|
+
const lines = [title];
|
|
250
|
+
for (const [label, value] of fields)
|
|
251
|
+
lines.push(field(label, value));
|
|
252
|
+
return lines;
|
|
253
|
+
}
|
|
254
|
+
/** The revert report, as a person reads it. */
|
|
255
|
+
export function formatScanRevertsReport(report) {
|
|
256
|
+
const lines = scanHead('scan-reverts', [
|
|
257
|
+
['since', report.since],
|
|
258
|
+
['found', `${report.found} commit(s)`],
|
|
259
|
+
['written', `${report.written} signal(s)`],
|
|
260
|
+
['tokens', tokens(report.tokens)],
|
|
261
|
+
]);
|
|
262
|
+
return `${lines.join('\n')}\n`;
|
|
263
|
+
}
|
|
264
|
+
/** The outcome report, as a person reads it. */
|
|
265
|
+
export function formatOutcomesReport(report) {
|
|
266
|
+
const lines = scanHead('outcomes', [
|
|
267
|
+
['since', report.since],
|
|
268
|
+
['found', `${report.found} outcome(s)`],
|
|
269
|
+
['written', `${report.written} outcome(s)`],
|
|
270
|
+
[
|
|
271
|
+
'tasks',
|
|
272
|
+
report.taskTransitions
|
|
273
|
+
? 'task transitions scanned'
|
|
274
|
+
: 'task transitions not scanned (no reader injected)',
|
|
275
|
+
],
|
|
276
|
+
]);
|
|
277
|
+
lines.push('');
|
|
278
|
+
if (report.byKind.length === 0) {
|
|
279
|
+
lines.push(' (none)');
|
|
280
|
+
}
|
|
281
|
+
for (const kind of report.byKind) {
|
|
282
|
+
lines.push(` ${kind.kind.padEnd(16)}${kind.count}`);
|
|
283
|
+
}
|
|
284
|
+
return `${lines.join('\n')}\n`;
|
|
285
|
+
}
|
|
286
|
+
//# sourceMappingURL=ledger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ledger.js","sourceRoot":"","sources":["../../src/commands/ledger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EACL,WAAW,EACX,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EAEjB,YAAY,EACZ,UAAU,EACV,UAAU,EACV,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,mBAAmB,EAInB,WAAW,EACX,WAAW,GACZ,MAAM,qBAAqB,CAAC;AAqB7B,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,SAAiB;IAC/C,MAAM,YAAY,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;IAC3C,uEAAuE;IACvE,yBAAyB;IACzB,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC,IAAI,CAC5C,GAAG,EAAE,CAAC,IAAI,EACV,GAAG,EAAE,CAAC,KAAK,CACZ,CAAC;IACF,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO;YACL,IAAI,EAAE,SAAS;YACf,YAAY;YACZ,MAAM,EAAE,KAAK;YACb,QAAQ,EAAE,iBAAiB,EAAE;SAC9B,CAAC;IACJ,CA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AACjC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ledger.test.d.ts","sourceRoot":"","sources":["../../src/commands/ledger.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { mkdirSync } from 'node:fs';
|
|
2
|
+
import { mkdtemp, rm, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { closeDatabase, createRecord, migrate, openDatabase, } from '@openagentsy/core';
|
|
6
|
+
import { closeLedger, openLedger, recordAssistantMessage, runGit } from '@openagentsy/ledger';
|
|
7
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
8
|
+
import { formatLedgerReport, formatOutcomesReport, formatScanRevertsReport, formatWasteReport, runLedger, runLedgerOutcomes, runLedgerScanReverts, runLedgerWaste, } from './ledger.js';
|
|
9
|
+
let root;
|
|
10
|
+
/** The two roots of a project that is its own state root. */
|
|
11
|
+
function rootsOf(root) {
|
|
12
|
+
return { workspace: root, stateRoot: root };
|
|
13
|
+
}
|
|
14
|
+
beforeEach(async () => {
|
|
15
|
+
root = await mkdtemp(join(tmpdir(), 'openagentsy-ledger-cli-'));
|
|
16
|
+
});
|
|
17
|
+
afterEach(async () => {
|
|
18
|
+
await rm(root, { recursive: true, force: true });
|
|
19
|
+
});
|
|
20
|
+
const CTX = {
|
|
21
|
+
rootSessionId: 'ses_1',
|
|
22
|
+
role: 'builder',
|
|
23
|
+
ts: '2026-10-26T10:00:00.000Z',
|
|
24
|
+
};
|
|
25
|
+
function seed() {
|
|
26
|
+
const db = openLedger(root);
|
|
27
|
+
try {
|
|
28
|
+
recordAssistantMessage(db, {
|
|
29
|
+
id: 'msg_1',
|
|
30
|
+
sessionID: 'ses_1',
|
|
31
|
+
providerID: 'anthropic',
|
|
32
|
+
modelID: 'claude-sonnet-4-5',
|
|
33
|
+
tokens: { input: 100, output: 40, reasoning: 10, cache: { read: 900, write: 5 } },
|
|
34
|
+
cost: 0.5,
|
|
35
|
+
}, CTX);
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
closeLedger(db);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
describe('the ledger command', () => {
|
|
42
|
+
it('shows nothing for a project without a ledger, and creates no file', async () => {
|
|
43
|
+
const report = await runLedger(root);
|
|
44
|
+
expect(report.exists).toBe(false);
|
|
45
|
+
expect(report.counters.totals.messages).toBe(0);
|
|
46
|
+
expect(formatLedgerReport(report)).toContain('missing');
|
|
47
|
+
});
|
|
48
|
+
it('shows the counters of a ledger', async () => {
|
|
49
|
+
seed();
|
|
50
|
+
const report = await runLedger(root);
|
|
51
|
+
expect(report.exists).toBe(true);
|
|
52
|
+
expect(report.counters.totals.messages).toBe(1);
|
|
53
|
+
expect(report.counters.totals.tokens).toBe(155);
|
|
54
|
+
expect(report.counters.totals.usd).toBe(0.5);
|
|
55
|
+
const text = formatLedgerReport(report);
|
|
56
|
+
expect(text).toContain('builder');
|
|
57
|
+
expect(text).toContain('$0.5000');
|
|
58
|
+
});
|
|
59
|
+
it('shows an unpriced message as unpriced, not as zero', async () => {
|
|
60
|
+
seed();
|
|
61
|
+
const db = openLedger(root);
|
|
62
|
+
try {
|
|
63
|
+
recordAssistantMessage(db, {
|
|
64
|
+
id: 'msg_2',
|
|
65
|
+
sessionID: 'ses_1',
|
|
66
|
+
providerID: 'anthropic',
|
|
67
|
+
modelID: 'claude-sonnet-4-5',
|
|
68
|
+
tokens: { input: 10, output: 5 },
|
|
69
|
+
}, { ...CTX, role: 'lead' });
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
closeLedger(db);
|
|
73
|
+
}
|
|
74
|
+
const report = await runLedger(root);
|
|
75
|
+
expect(report.counters.totals.unpricedMessages).toBe(1);
|
|
76
|
+
expect(formatLedgerReport(report)).toContain('unpriced');
|
|
77
|
+
});
|
|
78
|
+
it('exports the counters and nothing else', async () => {
|
|
79
|
+
seed();
|
|
80
|
+
const report = await runLedger(root);
|
|
81
|
+
expect(report.counters.schema).toBe('openagentsy.ledger/v1');
|
|
82
|
+
const json = JSON.stringify(report.counters);
|
|
83
|
+
expect(json).not.toContain('msg_1');
|
|
84
|
+
expect(json).not.toContain('ses_1');
|
|
85
|
+
expect(json).not.toContain('claude-sonnet-4-5');
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
/** A board of the shape the board writes, for the no-progress detector. */
|
|
89
|
+
function seedBoard() {
|
|
90
|
+
const dir = join(root, '.openagentsy');
|
|
91
|
+
mkdirSync(dir, { recursive: true });
|
|
92
|
+
const db = openDatabase(join(dir, 'board.sqlite'));
|
|
93
|
+
try {
|
|
94
|
+
migrate(db);
|
|
95
|
+
createRecord(db, {
|
|
96
|
+
bean: 'bean',
|
|
97
|
+
kind: 'status',
|
|
98
|
+
from: 'agentsy',
|
|
99
|
+
action: 'the Lead wrote down where it was',
|
|
100
|
+
state: 'nothing came of the round',
|
|
101
|
+
confidence: 'verified',
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
closeDatabase(db);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/** A Lead message in the ledger. */
|
|
109
|
+
function seedLead() {
|
|
110
|
+
const db = openLedger(root);
|
|
111
|
+
try {
|
|
112
|
+
recordAssistantMessage(db, {
|
|
113
|
+
id: 'l1',
|
|
114
|
+
sessionID: 'ses_lead',
|
|
115
|
+
providerID: 'anthropic',
|
|
116
|
+
modelID: 'claude-sonnet-4-5',
|
|
117
|
+
tokens: { input: 1000, output: 0 },
|
|
118
|
+
}, { rootSessionId: 'ses_lead', role: 'lead', ts: '2026-01-01T00:00:00.000Z' });
|
|
119
|
+
}
|
|
120
|
+
finally {
|
|
121
|
+
closeLedger(db);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/** A builder message of a task, for the token share of a revert. */
|
|
125
|
+
function seedBuilder(target, taskId) {
|
|
126
|
+
const db = openLedger(target);
|
|
127
|
+
try {
|
|
128
|
+
recordAssistantMessage(db, {
|
|
129
|
+
id: 'b1',
|
|
130
|
+
sessionID: 'ses_builder',
|
|
131
|
+
providerID: 'anthropic',
|
|
132
|
+
modelID: 'claude-sonnet-4-5',
|
|
133
|
+
tokens: { input: 2000, output: 0 },
|
|
134
|
+
}, {
|
|
135
|
+
rootSessionId: 'ses_builder',
|
|
136
|
+
role: 'builder',
|
|
137
|
+
activeTaskId: taskId,
|
|
138
|
+
ts: '2026-01-01T00:00:00.000Z',
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
finally {
|
|
142
|
+
closeLedger(db);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/** A repository with a commit that was taken back and one that was not. */
|
|
146
|
+
async function seedRepo() {
|
|
147
|
+
const repo = await mkdtemp(join(tmpdir(), 'openagentsy-cli-repo-'));
|
|
148
|
+
const git = (...args) => {
|
|
149
|
+
const result = runGit(repo, [
|
|
150
|
+
'-c',
|
|
151
|
+
'user.email=test@example.com',
|
|
152
|
+
'-c',
|
|
153
|
+
'user.name=Test',
|
|
154
|
+
'-c',
|
|
155
|
+
'commit.gpgsign=false',
|
|
156
|
+
...args,
|
|
157
|
+
]);
|
|
158
|
+
if (!result.ok)
|
|
159
|
+
throw new Error(result.stderr);
|
|
160
|
+
};
|
|
161
|
+
git('init', '-q');
|
|
162
|
+
git('config', 'user.email', 'test@example.com');
|
|
163
|
+
git('config', 'user.name', 'Test');
|
|
164
|
+
git('config', 'commit.gpgsign', 'false');
|
|
165
|
+
await writeFile(join(repo, 'f.txt'), 'alpha\nbeta\n');
|
|
166
|
+
git('add', 'f.txt');
|
|
167
|
+
git('commit', '-q', '-m', 'feat: add the file\n\nRefs: task-1');
|
|
168
|
+
await writeFile(join(repo, 'f.txt'), 'gamma\n');
|
|
169
|
+
git('add', 'f.txt');
|
|
170
|
+
git('commit', '-q', '-m', 'chore: rewrite the file');
|
|
171
|
+
return repo;
|
|
172
|
+
}
|
|
173
|
+
describe('the waste command', () => {
|
|
174
|
+
it('finds the round of the Lead that went nowhere and says what the waste is', async () => {
|
|
175
|
+
seedBoard();
|
|
176
|
+
seedLead();
|
|
177
|
+
const empty = await mkdtemp(join(tmpdir(), 'openagentsy-cli-empty-'));
|
|
178
|
+
const report = await runLedgerWaste(root, { dataDir: empty, leadAgent: 'agentsy' });
|
|
179
|
+
expect(report.written).toBe(1);
|
|
180
|
+
expect(report.byKind.find((kind) => kind.kind === 'no_progress')?.tokens).toBe(1000);
|
|
181
|
+
expect(report.totals.tokens).toBe(1000);
|
|
182
|
+
const text = formatWasteReport(report);
|
|
183
|
+
expect(text).toContain('no_progress');
|
|
184
|
+
expect(text).toContain('100.0%');
|
|
185
|
+
});
|
|
186
|
+
it('says nothing when there is no board to read', async () => {
|
|
187
|
+
const empty = await mkdtemp(join(tmpdir(), 'openagentsy-cli-empty-'));
|
|
188
|
+
const report = await runLedgerWaste(root, { dataDir: empty });
|
|
189
|
+
expect(report.written).toBe(0);
|
|
190
|
+
expect(report.byKind).toHaveLength(0);
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
describe('the scan-reverts command', () => {
|
|
194
|
+
it('finds the code that was taken back and writes it down', async () => {
|
|
195
|
+
const repo = await seedRepo();
|
|
196
|
+
seedBuilder(repo, 'task-1');
|
|
197
|
+
const report = await runLedgerScanReverts(rootsOf(repo), { since: '30 days ago' });
|
|
198
|
+
expect(report.found).toBe(1);
|
|
199
|
+
expect(report.written).toBe(1);
|
|
200
|
+
expect(report.tokens).toBe(2000);
|
|
201
|
+
expect(formatScanRevertsReport(report)).toContain('scan-reverts');
|
|
202
|
+
const db = openLedger(repo);
|
|
203
|
+
try {
|
|
204
|
+
const row = db.query('SELECT kind, tokens FROM waste').get();
|
|
205
|
+
expect(row.kind).toBe('reverted_code');
|
|
206
|
+
expect(row.tokens).toBe(2000);
|
|
207
|
+
}
|
|
208
|
+
finally {
|
|
209
|
+
closeLedger(db);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
describe('the outcomes command', () => {
|
|
214
|
+
it('finds the commits that name a task and writes them down', async () => {
|
|
215
|
+
const repo = await seedRepo();
|
|
216
|
+
const report = await runLedgerOutcomes(rootsOf(repo), { since: '30 days ago' });
|
|
217
|
+
expect(report.found).toBe(1);
|
|
218
|
+
expect(report.written).toBe(1);
|
|
219
|
+
expect(report.byKind.find((kind) => kind.kind === 'commit')?.count).toBe(1);
|
|
220
|
+
expect(formatOutcomesReport(report)).toContain('commit');
|
|
221
|
+
const db = openLedger(repo);
|
|
222
|
+
try {
|
|
223
|
+
const row = db.query('SELECT kind, task_id FROM outcome').get();
|
|
224
|
+
expect(row.kind).toBe('commit');
|
|
225
|
+
expect(row.task_id).toBe('task-1');
|
|
226
|
+
}
|
|
227
|
+
finally {
|
|
228
|
+
closeLedger(db);
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
it('writes the outcome once, however often it runs', async () => {
|
|
232
|
+
const repo = await seedRepo();
|
|
233
|
+
await runLedgerOutcomes(rootsOf(repo), { since: '30 days ago' });
|
|
234
|
+
const report = await runLedgerOutcomes(rootsOf(repo), { since: '30 days ago' });
|
|
235
|
+
expect(report.written).toBe(0);
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
//# sourceMappingURL=ledger.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ledger.test.js","sourceRoot":"","sources":["../../src/commands/ledger.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,aAAa,EACb,YAAY,EACZ,OAAO,EACP,YAAY,G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AAoB,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAEzD,MAAM,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;QAC5B,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC,GAAG,EAG5D,CAAC;YACF,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAChC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACrC,CAAC;gBAAS,CAAC;YACT,WAAW,CAAC,EAAE,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gDAAgD,EAAE,KAAK,IAAI,EAAE;QAC9D,MAAM,IAAI,GAAG,MAAM,QAAQ,EAAE,CAAC;QAC9B,MAAM,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC;QACjE,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC;QAChF,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { type EvalResult, type LessonState, type ObserveOutcome } from '@openagentsy/hooks';
|
|
2
|
+
import { deciderBy } from '../who.js';
|
|
3
|
+
export { deciderBy };
|
|
4
|
+
/**
|
|
5
|
+
* The lesson commands.
|
|
6
|
+
*
|
|
7
|
+
* `/oa lessons` is the inbox: the lessons that are waiting for a person,
|
|
8
|
+
* with the ones that happened most often first. `/oa lesson <id>
|
|
9
|
+
* validate|apply|reject|observe` records the decision, and the decision is
|
|
10
|
+
* the person's: the command runs as the person, so `decidedBy` is the human.
|
|
11
|
+
*
|
|
12
|
+
* The lessons are the state root's: they are what the project learned, and
|
|
13
|
+
* a worktree of the project has the same lessons as the project.
|
|
14
|
+
*/
|
|
15
|
+
/** One lesson, as the inbox shows it. */
|
|
16
|
+
export type LessonSummary = {
|
|
17
|
+
id: string;
|
|
18
|
+
state: LessonState;
|
|
19
|
+
summary: string;
|
|
20
|
+
occurrences: number;
|
|
21
|
+
kind: string;
|
|
22
|
+
sessions: number;
|
|
23
|
+
updated_at: string;
|
|
24
|
+
};
|
|
25
|
+
/** The inbox. */
|
|
26
|
+
export type LessonsReport = {
|
|
27
|
+
root: string;
|
|
28
|
+
lessons: LessonSummary[];
|
|
29
|
+
/** How many lessons are waiting for a decision. */
|
|
30
|
+
awaiting: number;
|
|
31
|
+
/** How many lessons the store holds, the waiting ones and the history. */
|
|
32
|
+
total: number;
|
|
33
|
+
};
|
|
34
|
+
/** What a decision did. */
|
|
35
|
+
export type LessonDecisionReport = {
|
|
36
|
+
ok: boolean;
|
|
37
|
+
id: string;
|
|
38
|
+
state: string;
|
|
39
|
+
reason: string;
|
|
40
|
+
hint?: string;
|
|
41
|
+
};
|
|
42
|
+
/** What the caller knows about the decision. */
|
|
43
|
+
export type LessonDecisionOptions = {
|
|
44
|
+
/** Who decided. The person running the command. */
|
|
45
|
+
decidedBy?: string;
|
|
46
|
+
/** Why. */
|
|
47
|
+
reason?: string;
|
|
48
|
+
/** The change the decision names. */
|
|
49
|
+
changeRef?: string;
|
|
50
|
+
/** The state an observation lands in. */
|
|
51
|
+
outcome?: ObserveOutcome;
|
|
52
|
+
/** The proof the decision rests on. */
|
|
53
|
+
evalResult?: EvalResult;
|
|
54
|
+
/** The file the proof is in. The content of an eval result file. */
|
|
55
|
+
evalResultPath?: string;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* The inbox.
|
|
59
|
+
*/
|
|
60
|
+
export declare function runLessons(stateRoot: string): Promise<LessonsReport>;
|
|
61
|
+
/**
|
|
62
|
+
* The inbox, as it is read.
|
|
63
|
+
*/
|
|
64
|
+
export declare function formatLessonsReport(report: LessonsReport): string;
|
|
65
|
+
/**
|
|
66
|
+
* Record a decision.
|
|
67
|
+
*/
|
|
68
|
+
export declare function runLessonDecision(stateRoot: string, id: string, action: string, options?: LessonDecisionOptions): Promise<LessonDecisionReport>;
|
|
69
|
+
/**
|
|
70
|
+
* The decision, as it is read.
|
|
71
|
+
*/
|
|
72
|
+
export declare function formatLessonDecision(report: LessonDecisionReport): string;
|
|
73
|
+
//# sourceMappingURL=lessons.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lessons.d.ts","sourceRoot":"","sources":["../../src/commands/lessons.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,UAAU,EAGf,KAAK,WAAW,EAEhB,KAAK,cAAc,EAGpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,CAAC;AAErB;;;;;;;;;;GAUG;AAEH,yCAAyC;AACzC,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,WAAW,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,iBAAiB;AACjB,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,mDAAmD;IACnD,QAAQ,EAAE,MAAM,CAAC;IACjB,0EAA0E;IAC1E,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,2BAA2B;AAC3B,MAAM,MAAM,oBAAoB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