altimate-receipts 0.6.2 → 0.7.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-5R6W4W4R.js → chunk-FTKMO26V.js} +170 -10
- package/dist/chunk-FTKMO26V.js.map +1 -0
- package/dist/{chunk-OQJHGUIN.js → chunk-MSPULJEI.js} +2 -2
- package/dist/{chunk-72Y2GS7I.js → chunk-ZORGM2DA.js} +1 -1
- package/dist/chunk-ZORGM2DA.js.map +1 -0
- package/dist/cli.js +57 -109
- package/dist/cli.js.map +1 -1
- package/dist/index.js +18 -8
- 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 +241 -58
- package/dist/chunk-5R6W4W4R.js.map +0 -1
- package/dist/chunk-72Y2GS7I.js.map +0 -1
- /package/dist/{chunk-OQJHGUIN.js.map → chunk-MSPULJEI.js.map} +0 -0
package/dist/cli.js
CHANGED
|
@@ -2,24 +2,29 @@
|
|
|
2
2
|
import {
|
|
3
3
|
CHECK_CATALOG,
|
|
4
4
|
applyDiffScope,
|
|
5
|
+
authoredBranch,
|
|
6
|
+
branchShas,
|
|
5
7
|
canonicalize,
|
|
6
8
|
changedFiles,
|
|
7
9
|
checkForId,
|
|
8
10
|
compareToTranscript,
|
|
9
11
|
copyToClipboard,
|
|
12
|
+
gitInvocations,
|
|
10
13
|
inDiff,
|
|
11
14
|
narrowEffort,
|
|
12
15
|
rederiveFromTranscript,
|
|
13
16
|
renderShareMarkdown,
|
|
17
|
+
shaWindow,
|
|
14
18
|
sliceByBranch,
|
|
15
|
-
toDsseEnvelope
|
|
16
|
-
|
|
19
|
+
toDsseEnvelope,
|
|
20
|
+
windowedEffort
|
|
21
|
+
} from "./chunk-FTKMO26V.js";
|
|
17
22
|
import {
|
|
18
23
|
computeTrends,
|
|
19
24
|
deriveTargets,
|
|
20
25
|
renderTrends,
|
|
21
26
|
upsertTrendsSection
|
|
22
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-MSPULJEI.js";
|
|
23
28
|
import {
|
|
24
29
|
agentIds,
|
|
25
30
|
anyDetected,
|
|
@@ -44,10 +49,10 @@ import {
|
|
|
44
49
|
selectSummary,
|
|
45
50
|
upsertGuardrailsSection,
|
|
46
51
|
verifyBundle
|
|
47
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-ZORGM2DA.js";
|
|
48
53
|
|
|
49
54
|
// src/cli.ts
|
|
50
|
-
import { spawnSync as
|
|
55
|
+
import { spawnSync as spawnSync4 } from "child_process";
|
|
51
56
|
import {
|
|
52
57
|
existsSync as existsSync4,
|
|
53
58
|
mkdirSync as mkdirSync3,
|
|
@@ -234,37 +239,6 @@ function pushReceiptRef(slug, remote = "origin", cwd) {
|
|
|
234
239
|
return git2(["push", remote, `+${ref}:${ref}`], { cwd }).ok;
|
|
235
240
|
}
|
|
236
241
|
|
|
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
242
|
// src/hook/settingsMerge.ts
|
|
269
243
|
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
270
244
|
import { dirname, join as join2 } from "path";
|
|
@@ -1146,72 +1120,6 @@ function renderHandoffMarkdown(h) {
|
|
|
1146
1120
|
`;
|
|
1147
1121
|
}
|
|
1148
1122
|
|
|
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
1123
|
// src/cli.ts
|
|
1216
1124
|
var HELP = `
|
|
1217
1125
|
\u{1F9FE} receipts \u2014 proof, not vibes
|
|
@@ -1558,7 +1466,7 @@ Run a coding-agent session first, then try again.
|
|
|
1558
1466
|
return 0;
|
|
1559
1467
|
}
|
|
1560
1468
|
function git4(args) {
|
|
1561
|
-
const r =
|
|
1469
|
+
const r = spawnSync4("git", args, { encoding: "utf8" });
|
|
1562
1470
|
return r.status === 0 ? r.stdout.trim() : "";
|
|
1563
1471
|
}
|
|
1564
1472
|
var PR_SELECT_SCAN = 150;
|
|
@@ -1654,7 +1562,17 @@ Build the branch with a coding agent first, or run \`receipts --list\`.
|
|
|
1654
1562
|
scope = { kind: "diff", base: diff.base, files: diff.files };
|
|
1655
1563
|
scopeNote = `diff vs ${diff.base} (${diff.files.length} file${diff.files.length === 1 ? "" : "s"})`;
|
|
1656
1564
|
const slice = sliceByBranch(session, branch);
|
|
1657
|
-
|
|
1565
|
+
let eff = narrowEffort(slice ? deriveSpans(slice) : null, diff.files);
|
|
1566
|
+
if (!eff) {
|
|
1567
|
+
const shas = branchShas(diff.base);
|
|
1568
|
+
const win = shaWindow(derived.spans, shas);
|
|
1569
|
+
if (win) {
|
|
1570
|
+
eff = windowedEffort(derived, diff.files, win);
|
|
1571
|
+
if (eff) {
|
|
1572
|
+
scope.shas = shas;
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1658
1576
|
if (eff) {
|
|
1659
1577
|
derived = { ...derived, diffCostUsd: eff.cost, diffTokens: eff.tokens, diffTurns: eff.turns };
|
|
1660
1578
|
scope.branch = branch;
|
|
@@ -1672,6 +1590,36 @@ Build the branch with a coding agent first, or run \`receipts --list\`.
|
|
|
1672
1590
|
}
|
|
1673
1591
|
}
|
|
1674
1592
|
const receipt = redactReceipt(await buildReceipt(scopedSession, derived, findings, { scope }));
|
|
1593
|
+
const p = receipt.predicate;
|
|
1594
|
+
if (p.evidence.diffCostUsd != null && repoRoot) {
|
|
1595
|
+
const slug = branch.replace(/[/\\]/g, "-");
|
|
1596
|
+
let priorRaw = null;
|
|
1597
|
+
try {
|
|
1598
|
+
priorRaw = readReceiptRef(slug, repoRoot);
|
|
1599
|
+
if (priorRaw == null) {
|
|
1600
|
+
const f = join7(repoRoot, ".receipts", `${slug}.json`);
|
|
1601
|
+
priorRaw = existsSync4(f) ? readFileSync6(f, "utf8") : null;
|
|
1602
|
+
}
|
|
1603
|
+
} catch {
|
|
1604
|
+
priorRaw = null;
|
|
1605
|
+
}
|
|
1606
|
+
if (priorRaw != null) {
|
|
1607
|
+
try {
|
|
1608
|
+
const prev = JSON.parse(priorRaw).predicate;
|
|
1609
|
+
const sameSession = prev.session?.startedAt === p.session.startedAt && prev.session?.agent === p.session.agent;
|
|
1610
|
+
const priorUsd = sameSession ? prev.prEffort?.priorUsd ?? 0 : prev.prEffort?.totalUsd ?? prev.evidence.diffCostUsd ?? 0;
|
|
1611
|
+
const sessions = sameSession ? prev.prEffort?.sessions ?? 1 : (prev.prEffort?.sessions ?? 1) + 1;
|
|
1612
|
+
if (priorUsd > 0) {
|
|
1613
|
+
p.prEffort = {
|
|
1614
|
+
priorUsd: Math.round(priorUsd * 100) / 100,
|
|
1615
|
+
totalUsd: Math.round((priorUsd + p.evidence.diffCostUsd) * 100) / 100,
|
|
1616
|
+
sessions
|
|
1617
|
+
};
|
|
1618
|
+
}
|
|
1619
|
+
} catch {
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1675
1623
|
const json = `${JSON.stringify(receipt, null, 2)}
|
|
1676
1624
|
`;
|
|
1677
1625
|
const store = (opts.store || process.env.RECEIPTS_STORE || (repoRoot ? settingsStore(repoRoot) ?? settingsStore(primaryCheckout(repoRoot) ?? "") : void 0) || "commit").toLowerCase();
|
|
@@ -2211,12 +2159,12 @@ function openAdoptionPr(written, lines) {
|
|
|
2211
2159
|
);
|
|
2212
2160
|
return;
|
|
2213
2161
|
}
|
|
2214
|
-
if (
|
|
2162
|
+
if (spawnSync4("git", ["checkout", "-b", ADOPT_BRANCH], { encoding: "utf8" }).status !== 0) {
|
|
2215
2163
|
lines.push(`receipts init: could not create branch ${ADOPT_BRANCH} \u2014 commit manually.`);
|
|
2216
2164
|
return;
|
|
2217
2165
|
}
|
|
2218
|
-
|
|
2219
|
-
const commit =
|
|
2166
|
+
spawnSync4("git", ["add", "--", ...written], { encoding: "utf8" });
|
|
2167
|
+
const commit = spawnSync4(
|
|
2220
2168
|
"git",
|
|
2221
2169
|
["commit", "-m", "chore: adopt receipts \u2014 zero-install agent-work verification"],
|
|
2222
2170
|
{ encoding: "utf8" }
|
|
@@ -2228,7 +2176,7 @@ function openAdoptionPr(written, lines) {
|
|
|
2228
2176
|
return;
|
|
2229
2177
|
}
|
|
2230
2178
|
lines.push(`receipts init: committed ${written.length} file(s) on ${ADOPT_BRANCH}.`);
|
|
2231
|
-
const push =
|
|
2179
|
+
const push = spawnSync4("git", ["push", "-u", "origin", ADOPT_BRANCH], { encoding: "utf8" });
|
|
2232
2180
|
if (push.status !== 0) {
|
|
2233
2181
|
lines.push(
|
|
2234
2182
|
"receipts init: push failed (no remote / auth?) \u2014 push the branch and open a PR manually."
|
|
@@ -2236,7 +2184,7 @@ function openAdoptionPr(written, lines) {
|
|
|
2236
2184
|
return;
|
|
2237
2185
|
}
|
|
2238
2186
|
lines.push(`receipts init: pushed ${ADOPT_BRANCH}.`);
|
|
2239
|
-
const gh =
|
|
2187
|
+
const gh = spawnSync4(
|
|
2240
2188
|
"gh",
|
|
2241
2189
|
[
|
|
2242
2190
|
"pr",
|