altimate-receipts 0.6.2 → 0.8.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/dist/{chunk-OQJHGUIN.js → chunk-6QULLAVH.js} +2 -2
- package/dist/chunk-NPYC3NGR.js +859 -0
- package/dist/chunk-NPYC3NGR.js.map +1 -0
- package/dist/{chunk-72Y2GS7I.js → chunk-SGVU3CGP.js} +330 -23
- package/dist/chunk-SGVU3CGP.js.map +1 -0
- package/dist/cli.js +98 -114
- package/dist/cli.js.map +1 -1
- package/dist/index.js +4 -222
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.js +2 -2
- package/package.json +1 -1
- package/schema/agent-execution-receipt-v1.json +303 -58
- package/dist/chunk-5R6W4W4R.js +0 -607
- package/dist/chunk-5R6W4W4R.js.map +0 -1
- package/dist/chunk-72Y2GS7I.js.map +0 -1
- /package/dist/{chunk-OQJHGUIN.js.map → chunk-6QULLAVH.js.map} +0 -0
package/dist/cli.js
CHANGED
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
CHECK_CATALOG,
|
|
4
|
-
|
|
4
|
+
authoredBranch,
|
|
5
|
+
branchShas,
|
|
5
6
|
canonicalize,
|
|
6
|
-
changedFiles,
|
|
7
7
|
checkForId,
|
|
8
8
|
compareToTranscript,
|
|
9
9
|
copyToClipboard,
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
eventKey,
|
|
11
|
+
gitInvocations,
|
|
12
12
|
rederiveFromTranscript,
|
|
13
13
|
renderShareMarkdown,
|
|
14
|
+
shaWindow,
|
|
14
15
|
sliceByBranch,
|
|
15
|
-
toDsseEnvelope
|
|
16
|
-
|
|
16
|
+
toDsseEnvelope,
|
|
17
|
+
visibleMergeFindings
|
|
18
|
+
} from "./chunk-NPYC3NGR.js";
|
|
17
19
|
import {
|
|
18
20
|
computeTrends,
|
|
19
21
|
deriveTargets,
|
|
20
22
|
renderTrends,
|
|
21
23
|
upsertTrendsSection
|
|
22
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-6QULLAVH.js";
|
|
23
25
|
import {
|
|
24
26
|
agentIds,
|
|
25
27
|
anyDetected,
|
|
28
|
+
applyDiffScope,
|
|
26
29
|
buildReceipt,
|
|
30
|
+
changedFiles,
|
|
27
31
|
collectGuardrails,
|
|
28
32
|
cwdAtFirstGit,
|
|
29
33
|
deriveFindings,
|
|
@@ -31,9 +35,11 @@ import {
|
|
|
31
35
|
formatCostAlways,
|
|
32
36
|
formatTokens,
|
|
33
37
|
getVersion,
|
|
38
|
+
inDiff,
|
|
34
39
|
inRepo,
|
|
35
40
|
listSessions,
|
|
36
41
|
loadSession,
|
|
42
|
+
narrowEffort,
|
|
37
43
|
redact,
|
|
38
44
|
redactReceipt,
|
|
39
45
|
renderCard,
|
|
@@ -43,11 +49,12 @@ import {
|
|
|
43
49
|
selectForBranch,
|
|
44
50
|
selectSummary,
|
|
45
51
|
upsertGuardrailsSection,
|
|
46
|
-
verifyBundle
|
|
47
|
-
|
|
52
|
+
verifyBundle,
|
|
53
|
+
windowedEffort
|
|
54
|
+
} from "./chunk-SGVU3CGP.js";
|
|
48
55
|
|
|
49
56
|
// src/cli.ts
|
|
50
|
-
import { spawnSync as
|
|
57
|
+
import { spawnSync as spawnSync4 } from "child_process";
|
|
51
58
|
import {
|
|
52
59
|
existsSync as existsSync4,
|
|
53
60
|
mkdirSync as mkdirSync3,
|
|
@@ -234,37 +241,6 @@ function pushReceiptRef(slug, remote = "origin", cwd) {
|
|
|
234
241
|
return git2(["push", remote, `+${ref}:${ref}`], { cwd }).ok;
|
|
235
242
|
}
|
|
236
243
|
|
|
237
|
-
// src/trace/gitCommand.ts
|
|
238
|
-
var WRAPPERS = /* @__PURE__ */ new Set(["command", "exec", "nohup", "time", "env"]);
|
|
239
|
-
var GIT_VALUE_FLAGS = /* @__PURE__ */ new Set(["-C", "-c", "--git-dir", "--work-tree", "--exec-path"]);
|
|
240
|
-
function gitInvocations(command) {
|
|
241
|
-
const blanked = command.replace(/\\["']/g, " ").replace(/'[^']*'/g, " ").replace(/"[^"]*"/g, " ");
|
|
242
|
-
const out = [];
|
|
243
|
-
for (const simple of blanked.split(/(?:&&|\|\||[;|\n])/)) {
|
|
244
|
-
const tokens = simple.trim().split(/\s+/).filter(Boolean);
|
|
245
|
-
let i = 0;
|
|
246
|
-
while (i < tokens.length && (/^[A-Za-z_][A-Za-z0-9_]*=/.test(tokens[i]) || WRAPPERS.has(tokens[i]))) {
|
|
247
|
-
i++;
|
|
248
|
-
}
|
|
249
|
-
if (tokens[i] !== "git") {
|
|
250
|
-
continue;
|
|
251
|
-
}
|
|
252
|
-
i++;
|
|
253
|
-
while (i < tokens.length && tokens[i].startsWith("-")) {
|
|
254
|
-
const flag = tokens[i];
|
|
255
|
-
i++;
|
|
256
|
-
if (GIT_VALUE_FLAGS.has(flag)) {
|
|
257
|
-
i++;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
const sub = tokens[i];
|
|
261
|
-
if (sub) {
|
|
262
|
-
out.push({ sub, rest: tokens.slice(i + 1) });
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
return out;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
244
|
// src/hook/settingsMerge.ts
|
|
269
245
|
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
270
246
|
import { dirname, join as join2 } from "path";
|
|
@@ -1146,72 +1122,6 @@ function renderHandoffMarkdown(h) {
|
|
|
1146
1122
|
`;
|
|
1147
1123
|
}
|
|
1148
1124
|
|
|
1149
|
-
// src/trace/commitMatch.ts
|
|
1150
|
-
import { spawnSync as spawnSync4 } from "child_process";
|
|
1151
|
-
var SHA_CAP = 200;
|
|
1152
|
-
function branchShas(base, cwd) {
|
|
1153
|
-
if (!base) {
|
|
1154
|
-
return [];
|
|
1155
|
-
}
|
|
1156
|
-
const r = spawnSync4("git", ["log", `--max-count=${SHA_CAP}`, "--format=%H", `${base}..HEAD`], {
|
|
1157
|
-
encoding: "utf8",
|
|
1158
|
-
cwd
|
|
1159
|
-
});
|
|
1160
|
-
if (r.status !== 0) {
|
|
1161
|
-
return [];
|
|
1162
|
-
}
|
|
1163
|
-
return r.stdout.split("\n").filter((s) => /^[0-9a-f]{40}$/.test(s));
|
|
1164
|
-
}
|
|
1165
|
-
var HEX_RUN = /\b[0-9a-f]{7,40}\b/g;
|
|
1166
|
-
function commandOf(input) {
|
|
1167
|
-
if (typeof input === "string") {
|
|
1168
|
-
const t = input.trim();
|
|
1169
|
-
if (t.startsWith("{")) {
|
|
1170
|
-
try {
|
|
1171
|
-
return commandOf(JSON.parse(t));
|
|
1172
|
-
} catch {
|
|
1173
|
-
return input;
|
|
1174
|
-
}
|
|
1175
|
-
}
|
|
1176
|
-
return input;
|
|
1177
|
-
}
|
|
1178
|
-
if (input && typeof input === "object") {
|
|
1179
|
-
const o = input;
|
|
1180
|
-
for (const key of ["command", "cmd"]) {
|
|
1181
|
-
const v = o[key];
|
|
1182
|
-
if (typeof v === "string") {
|
|
1183
|
-
return v;
|
|
1184
|
-
}
|
|
1185
|
-
if (Array.isArray(v)) {
|
|
1186
|
-
return v.filter((t) => typeof t === "string").join(" ");
|
|
1187
|
-
}
|
|
1188
|
-
}
|
|
1189
|
-
}
|
|
1190
|
-
return "";
|
|
1191
|
-
}
|
|
1192
|
-
function isGitWrite(command) {
|
|
1193
|
-
return gitInvocations(command).some((g) => g.sub === "commit" || g.sub === "push");
|
|
1194
|
-
}
|
|
1195
|
-
function authoredBranch(spans, shas) {
|
|
1196
|
-
if (shas.length === 0) {
|
|
1197
|
-
return false;
|
|
1198
|
-
}
|
|
1199
|
-
for (const s of spans) {
|
|
1200
|
-
if (s.kind !== "tool" || typeof s.output !== "string") {
|
|
1201
|
-
continue;
|
|
1202
|
-
}
|
|
1203
|
-
if (!isGitWrite(commandOf(s.input))) {
|
|
1204
|
-
continue;
|
|
1205
|
-
}
|
|
1206
|
-
for (const token of s.output.match(HEX_RUN) ?? []) {
|
|
1207
|
-
if (shas.some((full) => full.startsWith(token))) {
|
|
1208
|
-
return true;
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
}
|
|
1212
|
-
return false;
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
1125
|
// src/cli.ts
|
|
1216
1126
|
var HELP = `
|
|
1217
1127
|
\u{1F9FE} receipts \u2014 proof, not vibes
|
|
@@ -1558,7 +1468,7 @@ Run a coding-agent session first, then try again.
|
|
|
1558
1468
|
return 0;
|
|
1559
1469
|
}
|
|
1560
1470
|
function git4(args) {
|
|
1561
|
-
const r =
|
|
1471
|
+
const r = spawnSync4("git", args, { encoding: "utf8" });
|
|
1562
1472
|
return r.status === 0 ? r.stdout.trim() : "";
|
|
1563
1473
|
}
|
|
1564
1474
|
var PR_SELECT_SCAN = 150;
|
|
@@ -1654,7 +1564,17 @@ Build the branch with a coding agent first, or run \`receipts --list\`.
|
|
|
1654
1564
|
scope = { kind: "diff", base: diff.base, files: diff.files };
|
|
1655
1565
|
scopeNote = `diff vs ${diff.base} (${diff.files.length} file${diff.files.length === 1 ? "" : "s"})`;
|
|
1656
1566
|
const slice = sliceByBranch(session, branch);
|
|
1657
|
-
|
|
1567
|
+
let eff = narrowEffort(slice ? deriveSpans(slice) : null, diff.files);
|
|
1568
|
+
if (!eff) {
|
|
1569
|
+
const shas = branchShas(diff.base);
|
|
1570
|
+
const win = shaWindow(derived.spans, shas);
|
|
1571
|
+
if (win) {
|
|
1572
|
+
eff = windowedEffort(derived, diff.files, win);
|
|
1573
|
+
if (eff) {
|
|
1574
|
+
scope.shas = shas;
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1658
1578
|
if (eff) {
|
|
1659
1579
|
derived = { ...derived, diffCostUsd: eff.cost, diffTokens: eff.tokens, diffTurns: eff.turns };
|
|
1660
1580
|
scope.branch = branch;
|
|
@@ -1672,6 +1592,70 @@ Build the branch with a coding agent first, or run \`receipts --list\`.
|
|
|
1672
1592
|
}
|
|
1673
1593
|
}
|
|
1674
1594
|
const receipt = redactReceipt(await buildReceipt(scopedSession, derived, findings, { scope }));
|
|
1595
|
+
const p = receipt.predicate;
|
|
1596
|
+
if (repoRoot && scope.kind === "diff") {
|
|
1597
|
+
const slug = branch.replace(/[/\\]/g, "-");
|
|
1598
|
+
let priorRaw = null;
|
|
1599
|
+
try {
|
|
1600
|
+
priorRaw = readReceiptRef(slug, repoRoot);
|
|
1601
|
+
if (priorRaw == null) {
|
|
1602
|
+
const f = join7(repoRoot, ".receipts", `${slug}.json`);
|
|
1603
|
+
priorRaw = existsSync4(f) ? readFileSync6(f, "utf8") : null;
|
|
1604
|
+
}
|
|
1605
|
+
} catch {
|
|
1606
|
+
priorRaw = null;
|
|
1607
|
+
}
|
|
1608
|
+
if (priorRaw != null) {
|
|
1609
|
+
try {
|
|
1610
|
+
const prev = JSON.parse(priorRaw).predicate;
|
|
1611
|
+
const sameSession = prev.session?.startedAt === p.session.startedAt && prev.session?.agent === p.session.agent;
|
|
1612
|
+
if (p.evidence.diffCostUsd != null) {
|
|
1613
|
+
const priorUsd = sameSession ? prev.prEffort?.priorUsd ?? 0 : prev.prEffort?.totalUsd ?? prev.evidence.diffCostUsd ?? 0;
|
|
1614
|
+
const sessions = sameSession ? prev.prEffort?.sessions ?? 1 : (prev.prEffort?.sessions ?? 1) + 1;
|
|
1615
|
+
if (priorUsd > 0) {
|
|
1616
|
+
p.prEffort = {
|
|
1617
|
+
priorUsd: Math.round(priorUsd * 100) / 100,
|
|
1618
|
+
totalUsd: Math.round((priorUsd + p.evidence.diffCostUsd) * 100) / 100,
|
|
1619
|
+
sessions
|
|
1620
|
+
};
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
const prevVisible = visibleMergeFindings(prev.findings ?? []);
|
|
1624
|
+
const currVisible = visibleMergeFindings(p.findings);
|
|
1625
|
+
const currKeys = new Set(currVisible.map(eventKey));
|
|
1626
|
+
const prevKeys = new Set(prevVisible.map(eventKey));
|
|
1627
|
+
const clearedNow = prevVisible.filter((f) => !currKeys.has(eventKey(f))).map((f) => ({ title: f.title, ...f.filePath ? { filePath: f.filePath } : {} }));
|
|
1628
|
+
const newCount = currVisible.filter((f) => !prevKeys.has(eventKey(f))).length;
|
|
1629
|
+
const base = prev.prHistory?.length ? prev.prHistory : [
|
|
1630
|
+
{
|
|
1631
|
+
push: 1,
|
|
1632
|
+
...prev.session?.endedAt ? { endedAt: prev.session.endedAt } : {},
|
|
1633
|
+
new: prevVisible.length,
|
|
1634
|
+
cleared: 0,
|
|
1635
|
+
open: prevVisible.length,
|
|
1636
|
+
...prev.evidence.diffCostUsd != null ? { costUsd: prev.evidence.diffCostUsd } : {}
|
|
1637
|
+
}
|
|
1638
|
+
];
|
|
1639
|
+
const sha = git4(["rev-parse", "--short=7", "HEAD"]) || void 0;
|
|
1640
|
+
const last = base[base.length - 1];
|
|
1641
|
+
const sameHead = !!sha && last.sha === sha;
|
|
1642
|
+
const entry2 = {
|
|
1643
|
+
push: sameHead ? last.push : last.push + 1,
|
|
1644
|
+
...sha ? { sha } : {},
|
|
1645
|
+
...p.session.endedAt ? { endedAt: p.session.endedAt } : {},
|
|
1646
|
+
new: newCount,
|
|
1647
|
+
cleared: clearedNow.length,
|
|
1648
|
+
open: currVisible.length,
|
|
1649
|
+
...p.evidence.diffCostUsd != null ? { costUsd: p.evidence.diffCostUsd } : {}
|
|
1650
|
+
};
|
|
1651
|
+
p.prHistory = [...sameHead ? base.slice(0, -1) : base, entry2].slice(-10);
|
|
1652
|
+
if (clearedNow.length) {
|
|
1653
|
+
p.prCleared = clearedNow;
|
|
1654
|
+
}
|
|
1655
|
+
} catch {
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1675
1659
|
const json = `${JSON.stringify(receipt, null, 2)}
|
|
1676
1660
|
`;
|
|
1677
1661
|
const store = (opts.store || process.env.RECEIPTS_STORE || (repoRoot ? settingsStore(repoRoot) ?? settingsStore(primaryCheckout(repoRoot) ?? "") : void 0) || "commit").toLowerCase();
|
|
@@ -2211,12 +2195,12 @@ function openAdoptionPr(written, lines) {
|
|
|
2211
2195
|
);
|
|
2212
2196
|
return;
|
|
2213
2197
|
}
|
|
2214
|
-
if (
|
|
2198
|
+
if (spawnSync4("git", ["checkout", "-b", ADOPT_BRANCH], { encoding: "utf8" }).status !== 0) {
|
|
2215
2199
|
lines.push(`receipts init: could not create branch ${ADOPT_BRANCH} \u2014 commit manually.`);
|
|
2216
2200
|
return;
|
|
2217
2201
|
}
|
|
2218
|
-
|
|
2219
|
-
const commit =
|
|
2202
|
+
spawnSync4("git", ["add", "--", ...written], { encoding: "utf8" });
|
|
2203
|
+
const commit = spawnSync4(
|
|
2220
2204
|
"git",
|
|
2221
2205
|
["commit", "-m", "chore: adopt receipts \u2014 zero-install agent-work verification"],
|
|
2222
2206
|
{ encoding: "utf8" }
|
|
@@ -2228,7 +2212,7 @@ function openAdoptionPr(written, lines) {
|
|
|
2228
2212
|
return;
|
|
2229
2213
|
}
|
|
2230
2214
|
lines.push(`receipts init: committed ${written.length} file(s) on ${ADOPT_BRANCH}.`);
|
|
2231
|
-
const push =
|
|
2215
|
+
const push = spawnSync4("git", ["push", "-u", "origin", ADOPT_BRANCH], { encoding: "utf8" });
|
|
2232
2216
|
if (push.status !== 0) {
|
|
2233
2217
|
lines.push(
|
|
2234
2218
|
"receipts init: push failed (no remote / auth?) \u2014 push the branch and open a PR manually."
|
|
@@ -2236,7 +2220,7 @@ function openAdoptionPr(written, lines) {
|
|
|
2236
2220
|
return;
|
|
2237
2221
|
}
|
|
2238
2222
|
lines.push(`receipts init: pushed ${ADOPT_BRANCH}.`);
|
|
2239
|
-
const gh =
|
|
2223
|
+
const gh = spawnSync4(
|
|
2240
2224
|
"gh",
|
|
2241
2225
|
[
|
|
2242
2226
|
"pr",
|