burnoff 0.0.0-stage → 1.1.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/.github/workflows/burnoff-pr-gate.yml +75 -0
- package/LICENSE +21 -0
- package/README.md +179 -2
- package/bin/burnoff.mjs +461 -0
- package/hooks/hook-io.mjs +587 -0
- package/hooks/hooks.json +12 -0
- package/hooks/post-tool-use.mjs +118 -0
- package/hooks/pre-tool-use.mjs +149 -0
- package/package.json +43 -4
- package/src/ci/ci-gate.mjs +323 -0
- package/src/ci/pr-cost.mjs +735 -0
- package/src/ci/team-digest.mjs +123 -0
- package/src/cli/audit.mjs +265 -0
- package/src/cli/doctor.mjs +267 -0
- package/src/cli/init.mjs +393 -0
- package/src/cli/startup-audit.mjs +2348 -0
- package/src/config/catalog.json +1017 -0
- package/src/config/loader.mjs +702 -0
- package/src/config/paths.mjs +226 -0
- package/src/config/policy.mjs +265 -0
- package/src/config/pricing.mjs +1022 -0
- package/src/config/uncached-attribution.mjs +719 -0
- package/src/guards/loop-breaker.mjs +559 -0
- package/src/guards/post-tool-engine.mjs +594 -0
- package/src/guards/pre-tool-engine.mjs +615 -0
- package/src/guards/read-clamp.mjs +744 -0
- package/src/guards/shell-guard.mjs +1166 -0
- package/src/ipc/daemon.mjs +273 -0
- package/src/ipc/fast-client.mjs +198 -0
- package/src/ipc/protocol.mjs +142 -0
- package/src/storage/atomic-io.mjs +151 -0
- package/src/storage/file-lock.mjs +250 -0
- package/src/storage/fts5-archive.mjs +733 -0
- package/src/storage/jsonl-parser.mjs +943 -0
- package/src/storage/ledger.mjs +1148 -0
- package/src/storage/sqlite-client.mjs +588 -0
|
@@ -0,0 +1,735 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file src/ci/pr-cost.mjs
|
|
3
|
+
* Git Branch & PR Token/USD Cost Attribution (`burnoff-pr-attribution/v1`).
|
|
4
|
+
*
|
|
5
|
+
* Correlates `git log <base>..HEAD --numstat` commits with Claude Code session steps
|
|
6
|
+
* and Burnoff ledger entries without leaking OS home directories or `.claude/settings.local.json`.
|
|
7
|
+
* Zero runtime dependencies, zero license gates, zero network calls.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { execFileSync } from 'node:child_process';
|
|
11
|
+
import fs from 'node:fs';
|
|
12
|
+
import os from 'node:os';
|
|
13
|
+
import path from 'node:path';
|
|
14
|
+
import { getHomeDir } from '../config/paths.mjs';
|
|
15
|
+
import { DEFAULT_UNMAPPED_CACHED_WEIGHT, valuateCall } from '../config/pricing.mjs';
|
|
16
|
+
import { attributeUncachedTokens } from '../config/uncached-attribution.mjs';
|
|
17
|
+
import { readLedgerEntries } from '../storage/ledger.mjs';
|
|
18
|
+
import {
|
|
19
|
+
discoverClaudeCodeSessions,
|
|
20
|
+
parseTranscriptIncremental
|
|
21
|
+
} from '../storage/jsonl-parser.mjs';
|
|
22
|
+
|
|
23
|
+
export const PR_ATTRIBUTION_FORMAT = 'burnoff-pr-attribution/v1';
|
|
24
|
+
|
|
25
|
+
const RING0_DETECTORS = new Set(['DET-01', 'DET-02', 'DET-03', 'DET-04', 'DET-05']);
|
|
26
|
+
|
|
27
|
+
function isExcludedLocalToolPath(relPath = '') {
|
|
28
|
+
const norm = String(relPath || '').replace(/\\/g, '/').replace(/^\.\//, '').toLowerCase();
|
|
29
|
+
return norm === '.claude/settings.local.json' || norm.endsWith('/.claude/settings.local.json');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function sanitizeRelativeRepoPath(rawPath = '', cwd = '') {
|
|
33
|
+
const input = String(rawPath || '').trim();
|
|
34
|
+
if (!input) return '';
|
|
35
|
+
let normalized = input.replace(/\\/g, '/');
|
|
36
|
+
if (cwd) {
|
|
37
|
+
const abs = path.isAbsolute(input) ? input : path.resolve(cwd, input);
|
|
38
|
+
const rel = path.relative(cwd, abs).replace(/\\/g, '/');
|
|
39
|
+
if (rel && !rel.startsWith('..') && !path.isAbsolute(rel)) {
|
|
40
|
+
normalized = rel;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const homeNorm = String(os.homedir() || '').replace(/\\/g, '/').replace(/\/+$/, '');
|
|
44
|
+
if (homeNorm && normalized.toLowerCase().startsWith(`${homeNorm.toLowerCase()}/`)) {
|
|
45
|
+
normalized = normalized.slice(homeNorm.length + 1);
|
|
46
|
+
}
|
|
47
|
+
normalized = normalized
|
|
48
|
+
.replace(/^[A-Za-z]:\/Users\/[^/]+\//i, '')
|
|
49
|
+
.replace(/^\/Users\/[^/]+\//i, '')
|
|
50
|
+
.replace(/^\/home\/[^/]+\//i, '')
|
|
51
|
+
.replace(/^file:\/\/\//i, '')
|
|
52
|
+
.replace(/^\.\//, '');
|
|
53
|
+
return normalized;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function readProviderUsageExportUsd(providerUsagePath) {
|
|
57
|
+
if (!providerUsagePath || typeof providerUsagePath !== 'string') return null;
|
|
58
|
+
const abs = path.resolve(providerUsagePath);
|
|
59
|
+
if (!fs.existsSync(abs)) {
|
|
60
|
+
throw new Error(`Provider usage export not found: ${abs}`);
|
|
61
|
+
}
|
|
62
|
+
const parsed = JSON.parse(fs.readFileSync(abs, 'utf8'));
|
|
63
|
+
const numField = (obj) => {
|
|
64
|
+
if (!obj || typeof obj !== 'object') return null;
|
|
65
|
+
for (const k of ['totalCostUsd', 'total_cost_usd', 'costUsd', 'cost_usd', 'amountUsd', 'amount_usd']) {
|
|
66
|
+
if (obj[k] !== undefined && obj[k] !== null && Number.isFinite(Number(obj[k]))) {
|
|
67
|
+
return Number(obj[k]);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
};
|
|
72
|
+
const direct = numField(parsed);
|
|
73
|
+
if (direct !== null) return direct;
|
|
74
|
+
|
|
75
|
+
const list = Array.isArray(parsed)
|
|
76
|
+
? parsed
|
|
77
|
+
: Array.isArray(parsed?.records)
|
|
78
|
+
? parsed.records
|
|
79
|
+
: Array.isArray(parsed?.usage)
|
|
80
|
+
? parsed.usage
|
|
81
|
+
: Array.isArray(parsed?.data)
|
|
82
|
+
? parsed.data
|
|
83
|
+
: null;
|
|
84
|
+
if (!list) return null;
|
|
85
|
+
|
|
86
|
+
let total = 0;
|
|
87
|
+
let found = false;
|
|
88
|
+
for (const item of list) {
|
|
89
|
+
const v = numField(item);
|
|
90
|
+
if (v !== null) {
|
|
91
|
+
total += v;
|
|
92
|
+
found = true;
|
|
93
|
+
} else if (Array.isArray(item?.results)) {
|
|
94
|
+
for (const r of item.results) {
|
|
95
|
+
const rv = numField(r);
|
|
96
|
+
if (rv !== null) {
|
|
97
|
+
total += rv;
|
|
98
|
+
found = true;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return found ? Number(total.toFixed(4)) : null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function parseGitLogNumstat(rawText = '', cwd = '') {
|
|
107
|
+
const commits = [];
|
|
108
|
+
let current = null;
|
|
109
|
+
|
|
110
|
+
for (const line of String(rawText || '').split(/\r?\n/)) {
|
|
111
|
+
if (!line.trim()) continue;
|
|
112
|
+
if (line.startsWith('COMMIT|')) {
|
|
113
|
+
const parts = line.split('|');
|
|
114
|
+
const sha = parts[1] || '';
|
|
115
|
+
const timestampIso = parts[2] || '';
|
|
116
|
+
const author = parts[3] || '';
|
|
117
|
+
const subject = parts.slice(4).join('|').trim();
|
|
118
|
+
const parsedMs = Date.parse(timestampIso);
|
|
119
|
+
current = {
|
|
120
|
+
sha,
|
|
121
|
+
shortSha: sha.slice(0, 7),
|
|
122
|
+
timestampIso,
|
|
123
|
+
timestampMs: Number.isFinite(parsedMs) ? parsedMs : 0,
|
|
124
|
+
author,
|
|
125
|
+
subject,
|
|
126
|
+
files: [],
|
|
127
|
+
totalAdditions: 0,
|
|
128
|
+
totalDeletions: 0,
|
|
129
|
+
totalLoc: 0
|
|
130
|
+
};
|
|
131
|
+
commits.push(current);
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if (!current) continue;
|
|
135
|
+
const numMatch = line.match(/^(\d+|-)\t(\d+|-)\t(.+)$/);
|
|
136
|
+
if (numMatch) {
|
|
137
|
+
const additions = numMatch[1] === '-' ? 0 : Number(numMatch[1]);
|
|
138
|
+
const deletions = numMatch[2] === '-' ? 0 : Number(numMatch[2]);
|
|
139
|
+
const filePath = sanitizeRelativeRepoPath(numMatch[3], cwd);
|
|
140
|
+
current.files.push({ filePath, additions, deletions });
|
|
141
|
+
current.totalAdditions += additions;
|
|
142
|
+
current.totalDeletions += deletions;
|
|
143
|
+
current.totalLoc += additions + deletions;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return commits;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Runs local read-only `git log <base>..<head> --numstat` cleanly without shell expansion.
|
|
152
|
+
*/
|
|
153
|
+
export function collectGitBranchCommits(
|
|
154
|
+
cwd,
|
|
155
|
+
{ base = 'main', head = 'HEAD', maxCommits = 100, fallbackToRecent = true } = {}
|
|
156
|
+
) {
|
|
157
|
+
const repoDir = path.resolve(cwd || process.cwd());
|
|
158
|
+
const formatArg = '--format=COMMIT|%H|%aI|%an|%s';
|
|
159
|
+
|
|
160
|
+
const runGit = (revRangeArgs) =>
|
|
161
|
+
execFileSync('git', ['log', ...revRangeArgs, formatArg, '--numstat', '-n', String(maxCommits)], {
|
|
162
|
+
cwd: repoDir,
|
|
163
|
+
encoding: 'utf8',
|
|
164
|
+
stdio: ['ignore', 'pipe', 'pipe']
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
try {
|
|
168
|
+
const raw = runGit([`${base}..${head}`]);
|
|
169
|
+
return {
|
|
170
|
+
ok: true,
|
|
171
|
+
base,
|
|
172
|
+
head,
|
|
173
|
+
fallbackUsed: false,
|
|
174
|
+
commits: parseGitLogNumstat(raw, repoDir)
|
|
175
|
+
};
|
|
176
|
+
} catch (rangeErr) {
|
|
177
|
+
if (!fallbackToRecent) {
|
|
178
|
+
return { ok: false, base, head, commits: [], error: rangeErr?.message || String(rangeErr) };
|
|
179
|
+
}
|
|
180
|
+
try {
|
|
181
|
+
const rawFallback = runGit([head]);
|
|
182
|
+
return {
|
|
183
|
+
ok: true,
|
|
184
|
+
base,
|
|
185
|
+
head,
|
|
186
|
+
fallbackUsed: true,
|
|
187
|
+
commits: parseGitLogNumstat(rawFallback, repoDir)
|
|
188
|
+
};
|
|
189
|
+
} catch (headErr) {
|
|
190
|
+
return {
|
|
191
|
+
ok: false,
|
|
192
|
+
base,
|
|
193
|
+
head,
|
|
194
|
+
fallbackUsed: false,
|
|
195
|
+
commits: [],
|
|
196
|
+
error: headErr?.message || String(headErr)
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function extractStepFields(step = {}, cwd = '') {
|
|
203
|
+
const usage = step.tokenUsage || {};
|
|
204
|
+
const inTok = Number(
|
|
205
|
+
step.uncachedTokens ??
|
|
206
|
+
step.uncachedInputTokens ??
|
|
207
|
+
step.freshInputTokens ??
|
|
208
|
+
step.inputTokens ??
|
|
209
|
+
step.input_tokens ??
|
|
210
|
+
usage.freshInputTokens ??
|
|
211
|
+
usage.inputTokens ??
|
|
212
|
+
0
|
|
213
|
+
);
|
|
214
|
+
const cacheWrite5mTok = Number(
|
|
215
|
+
step.cacheWrite5mTokens ??
|
|
216
|
+
step.write5mTokens ??
|
|
217
|
+
step.cache_write_5m_tokens ??
|
|
218
|
+
step.cacheCreationEphemeral5mInputTokens ??
|
|
219
|
+
usage.cacheWrite5mTokens ??
|
|
220
|
+
usage.cacheCreationEphemeral5mInputTokens ??
|
|
221
|
+
0
|
|
222
|
+
);
|
|
223
|
+
const cacheWrite1hTok = Number(
|
|
224
|
+
step.cacheWrite1hTokens ??
|
|
225
|
+
step.write1hTokens ??
|
|
226
|
+
step.cache_write_1h_tokens ??
|
|
227
|
+
step.cacheCreationEphemeral1hInputTokens ??
|
|
228
|
+
usage.cacheWrite1hTokens ??
|
|
229
|
+
usage.cacheCreationEphemeral1hInputTokens ??
|
|
230
|
+
0
|
|
231
|
+
);
|
|
232
|
+
const cacheCreationTok = Number(
|
|
233
|
+
step.cacheCreationTokens ?? step.cache_creation_input_tokens ?? usage.cacheCreationTokens ?? 0
|
|
234
|
+
);
|
|
235
|
+
const cacheWriteTok = Math.max(cacheCreationTok, cacheWrite5mTok + cacheWrite1hTok);
|
|
236
|
+
const cacheReadTok = Number(
|
|
237
|
+
step.cacheReadTokens ?? step.cache_read_input_tokens ?? usage.cacheReadTokens ?? 0
|
|
238
|
+
);
|
|
239
|
+
const outTok =
|
|
240
|
+
Number(step.outputTokens ?? step.output_tokens ?? usage.outputTokens ?? 0) +
|
|
241
|
+
Number(step.thinkingTokens ?? step.thinking_tokens ?? usage.thinkingTokens ?? 0);
|
|
242
|
+
const hasExplicitWaste =
|
|
243
|
+
step.wasteTokens !== undefined || step.wastedTokens !== undefined;
|
|
244
|
+
const wasteTok = Number(step.wasteTokens ?? step.wastedTokens ?? 0);
|
|
245
|
+
const rawTs = step.timestampMs ?? step.createdAt ?? step.created_at ?? step.timestamp ?? null;
|
|
246
|
+
const tsMs = typeof rawTs === 'number' ? rawTs : rawTs ? Date.parse(String(rawTs)) : NaN;
|
|
247
|
+
|
|
248
|
+
const filesTouched = new Set();
|
|
249
|
+
const explicitFile = step.filePath || step.path || step.targetFile;
|
|
250
|
+
if (explicitFile) {
|
|
251
|
+
const clean = sanitizeRelativeRepoPath(explicitFile, cwd);
|
|
252
|
+
if (clean) filesTouched.add(clean);
|
|
253
|
+
}
|
|
254
|
+
const calls = Array.isArray(step.toolCalls)
|
|
255
|
+
? step.toolCalls
|
|
256
|
+
: Array.isArray(step.tool_calls)
|
|
257
|
+
? step.tool_calls
|
|
258
|
+
: [];
|
|
259
|
+
for (const c of calls) {
|
|
260
|
+
const args = c?.args || c?.parameters || c?.Arguments || c?.input || {};
|
|
261
|
+
const fp = args.file_path || args.Path || args.path || args.TargetFile || args.AbsolutePath;
|
|
262
|
+
if (fp) {
|
|
263
|
+
const clean = sanitizeRelativeRepoPath(fp, cwd);
|
|
264
|
+
if (clean) filesTouched.add(clean);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const detector = String(step.detector || step.detectorId || '').toUpperCase();
|
|
269
|
+
const isRing0 =
|
|
270
|
+
Boolean(step.ring0Violation) ||
|
|
271
|
+
Boolean(step.blocked && RING0_DETECTORS.has(detector)) ||
|
|
272
|
+
(step.decision === 'deny' && RING0_DETECTORS.has(detector));
|
|
273
|
+
|
|
274
|
+
return {
|
|
275
|
+
model: step.model || step.modelId || usage.model || null,
|
|
276
|
+
label: step.label || null,
|
|
277
|
+
sessionId: step.sessionId || step.conv || 'default',
|
|
278
|
+
stepIndex: step.stepIndex ?? null,
|
|
279
|
+
inTok,
|
|
280
|
+
cacheWrite5mTok,
|
|
281
|
+
cacheWrite1hTok,
|
|
282
|
+
cacheCreationTok,
|
|
283
|
+
cacheWriteTok,
|
|
284
|
+
cacheReadTok,
|
|
285
|
+
outTok,
|
|
286
|
+
wasteTok,
|
|
287
|
+
hasExplicitWaste,
|
|
288
|
+
totalTok: inTok + cacheWriteTok + cacheReadTok + outTok,
|
|
289
|
+
tsMs: Number.isFinite(tsMs) ? tsMs : null,
|
|
290
|
+
hadCompactionBefore: Boolean(step.hadCompactionBefore),
|
|
291
|
+
isCompactSummary: Boolean(step.isCompactSummary),
|
|
292
|
+
isCompactionBoundary: Boolean(step.isCompactionBoundary),
|
|
293
|
+
isSidechain: Boolean(step.isSidechain),
|
|
294
|
+
entrypoint: step.entrypoint || null,
|
|
295
|
+
shapeHash: step.shapeHash || null,
|
|
296
|
+
cacheTtlTier: step.cacheTtlTier || (cacheWrite1hTok > 0 ? '1h' : '5m'),
|
|
297
|
+
filesTouched: Array.from(filesTouched),
|
|
298
|
+
isRing0
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function computeStepCostUsd(inTok, cacheReadTok, outTok, pricePerMillionUsd = 3.0, cacheWriteTok = 0) {
|
|
303
|
+
return (
|
|
304
|
+
(inTok * 1.0 + cacheWriteTok * 1.25 + cacheReadTok * DEFAULT_UNMAPPED_CACHED_WEIGHT + outTok * 5.0) /
|
|
305
|
+
1_000_000
|
|
306
|
+
) * pricePerMillionUsd;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function computeStepUsdWithModel(st, pricePerMillionUsd, hasExplicitPriceOverride) {
|
|
310
|
+
if (!hasExplicitPriceOverride && st?.model) {
|
|
311
|
+
const val = valuateCall({
|
|
312
|
+
model: st.model,
|
|
313
|
+
label: st.label,
|
|
314
|
+
timestampMs: st.tsMs,
|
|
315
|
+
uncachedTokens: st.inTok,
|
|
316
|
+
cachedTokens: st.cacheReadTok,
|
|
317
|
+
cacheWrite5mTokens: st.cacheWrite5mTok,
|
|
318
|
+
cacheWrite1hTokens: st.cacheWrite1hTok,
|
|
319
|
+
cacheCreationTokens: st.cacheCreationTok,
|
|
320
|
+
outputTokens: st.outTok
|
|
321
|
+
});
|
|
322
|
+
if (val.totalEstimatedUsd !== null) return val.totalEstimatedUsd;
|
|
323
|
+
}
|
|
324
|
+
return computeStepCostUsd(st.inTok, st.cacheReadTok, st.outTok, pricePerMillionUsd, st.cacheWriteTok);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Builds Git branch / PR token and USD attribution report.
|
|
329
|
+
*/
|
|
330
|
+
export function buildPrCostAttribution(options = {}) {
|
|
331
|
+
const cwd = path.resolve(options.cwd || process.cwd());
|
|
332
|
+
const homeDir = options.homeDir || getHomeDir();
|
|
333
|
+
const base = String(options.base || 'main');
|
|
334
|
+
const head = String(options.head || 'HEAD');
|
|
335
|
+
const hasExplicitPriceOverride = options.pricePerMillionUsd !== undefined && options.pricePerMillionUsd !== null;
|
|
336
|
+
const pricePerMillionUsd = Number(options.pricePerMillionUsd || 3.0);
|
|
337
|
+
|
|
338
|
+
let commits = Array.isArray(options.commits) ? options.commits : null;
|
|
339
|
+
let fallbackUsed = false;
|
|
340
|
+
if (!commits) {
|
|
341
|
+
const gitRes = collectGitBranchCommits(cwd, {
|
|
342
|
+
base,
|
|
343
|
+
head,
|
|
344
|
+
fallbackToRecent: options.fallbackToRecent !== false
|
|
345
|
+
});
|
|
346
|
+
if (!gitRes.ok) {
|
|
347
|
+
return { ok: false, error: gitRes.error, base, head };
|
|
348
|
+
}
|
|
349
|
+
commits = gitRes.commits;
|
|
350
|
+
fallbackUsed = gitRes.fallbackUsed;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
const rawSteps = [];
|
|
354
|
+
let sessionCount = 0;
|
|
355
|
+
if (Array.isArray(options.steps)) {
|
|
356
|
+
rawSteps.push(...options.steps);
|
|
357
|
+
sessionCount = Math.max(sessionCount, options.steps.length > 0 ? 1 : 0);
|
|
358
|
+
}
|
|
359
|
+
if (Array.isArray(options.sessions)) {
|
|
360
|
+
sessionCount = Math.max(sessionCount, options.sessions.length);
|
|
361
|
+
for (const sess of options.sessions) {
|
|
362
|
+
if (Array.isArray(sess?.steps)) rawSteps.push(...sess.steps);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
if (!Array.isArray(options.steps) && !Array.isArray(options.sessions) && options.readSessions !== false) {
|
|
366
|
+
const maxSessions = Math.max(1, Number(options.maxSessions ?? 20));
|
|
367
|
+
const discovered = discoverClaudeCodeSessions(homeDir, { cwd }).slice(0, maxSessions);
|
|
368
|
+
sessionCount = discovered.length;
|
|
369
|
+
for (const meta of discovered) {
|
|
370
|
+
const parsed = parseTranscriptIncremental(meta.filePath, { homeDir });
|
|
371
|
+
if (Array.isArray(parsed?.steps)) {
|
|
372
|
+
rawSteps.push(
|
|
373
|
+
...parsed.steps.map((st) => ({
|
|
374
|
+
...st,
|
|
375
|
+
sessionId: st.sessionId || meta.sessionId || 'default'
|
|
376
|
+
}))
|
|
377
|
+
);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
const normalizedSteps = rawSteps.map((s) => extractStepFields(s, cwd));
|
|
382
|
+
|
|
383
|
+
const rawLedger = Array.isArray(options.ledgerEntries)
|
|
384
|
+
? options.ledgerEntries
|
|
385
|
+
: options.readLedger !== false
|
|
386
|
+
? readLedgerEntries({ homeDir, cwd })
|
|
387
|
+
: [];
|
|
388
|
+
|
|
389
|
+
const validTimestamps = commits.map((c) => c.timestampMs).filter((t) => Number.isFinite(t) && t > 0);
|
|
390
|
+
const minCommitMs = validTimestamps.length ? Math.min(...validTimestamps) : -Infinity;
|
|
391
|
+
const maxCommitMs = validTimestamps.length ? Math.max(...validTimestamps) : Infinity;
|
|
392
|
+
|
|
393
|
+
const sortedCommits = [...commits]
|
|
394
|
+
.map((c, origIdx) => ({
|
|
395
|
+
...c,
|
|
396
|
+
origIdx,
|
|
397
|
+
files: (Array.isArray(c.files) ? c.files : [])
|
|
398
|
+
.map((f) => ({
|
|
399
|
+
filePath: sanitizeRelativeRepoPath(f.filePath, cwd),
|
|
400
|
+
additions: Number(f.additions || 0),
|
|
401
|
+
deletions: Number(f.deletions || 0)
|
|
402
|
+
}))
|
|
403
|
+
.filter((f) => f.filePath && !isExcludedLocalToolPath(f.filePath))
|
|
404
|
+
}))
|
|
405
|
+
.sort((a, b) => (a.timestampMs || 0) - (b.timestampMs || 0));
|
|
406
|
+
|
|
407
|
+
for (const c of sortedCommits) {
|
|
408
|
+
if (!c.totalLoc) {
|
|
409
|
+
c.totalAdditions = c.files.reduce((s, f) => s + f.additions, 0);
|
|
410
|
+
c.totalDeletions = c.files.reduce((s, f) => s + f.deletions, 0);
|
|
411
|
+
c.totalLoc = c.totalAdditions + c.totalDeletions;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
const matchingLedger = rawLedger.filter((entry) => {
|
|
416
|
+
if (entry?.cwd && path.resolve(String(entry.cwd)) !== cwd) return false;
|
|
417
|
+
const rawTs = entry.timestamp ?? entry.ts ?? null;
|
|
418
|
+
const tsMs = typeof rawTs === 'number' ? rawTs : rawTs ? Date.parse(String(rawTs)) : NaN;
|
|
419
|
+
if (!Number.isFinite(tsMs) || !validTimestamps.length) return true;
|
|
420
|
+
return tsMs >= minCommitMs - 30 * 60 * 1000 && tsMs <= maxCommitMs + 15 * 60 * 1000;
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
const ledgerSavedUsd = matchingLedger.reduce((s, e) => s + Number(e.savedUSD ?? e.savedUsd ?? 0), 0);
|
|
424
|
+
const ledgerRing0Count = matchingLedger.filter(
|
|
425
|
+
(e) =>
|
|
426
|
+
Boolean(e?.ring0Violation) ||
|
|
427
|
+
RING0_DETECTORS.has(String(e?.detectorId || e?.detector || '').toUpperCase()) ||
|
|
428
|
+
String(e?.category || '').toUpperCase() === 'RING0_VIOLATION_BLOCKED'
|
|
429
|
+
).length;
|
|
430
|
+
|
|
431
|
+
const commitBuckets = new Map(sortedCommits.map((_, idx) => [idx, []]));
|
|
432
|
+
const totalBranchLoc = sortedCommits.reduce((s, c) => s + Math.max(1, c.totalLoc || 0), 0);
|
|
433
|
+
|
|
434
|
+
let unmatchedIn = 0;
|
|
435
|
+
let unmatchedWrite = 0;
|
|
436
|
+
let unmatchedCache = 0;
|
|
437
|
+
let unmatchedOut = 0;
|
|
438
|
+
let unmatchedUsd = 0;
|
|
439
|
+
let unmatchedWaste = 0;
|
|
440
|
+
let unmatchedRing0 = 0;
|
|
441
|
+
const matchedAttrSteps = [];
|
|
442
|
+
|
|
443
|
+
for (const st of normalizedSteps) {
|
|
444
|
+
let assignedIdx = -1;
|
|
445
|
+
|
|
446
|
+
if (st.tsMs !== null && validTimestamps.length > 0) {
|
|
447
|
+
const windowStart = minCommitMs - 30 * 60 * 1000;
|
|
448
|
+
const windowEnd = maxCommitMs + 15 * 60 * 1000;
|
|
449
|
+
if (st.tsMs < windowStart || st.tsMs > windowEnd) {
|
|
450
|
+
continue;
|
|
451
|
+
}
|
|
452
|
+
for (let i = 0; i < sortedCommits.length; i++) {
|
|
453
|
+
const prevMs = i > 0 ? sortedCommits[i - 1].timestampMs : windowStart;
|
|
454
|
+
const curMs =
|
|
455
|
+
i === sortedCommits.length - 1
|
|
456
|
+
? Math.max(sortedCommits[i].timestampMs, windowEnd)
|
|
457
|
+
: sortedCommits[i].timestampMs;
|
|
458
|
+
if (st.tsMs >= prevMs && st.tsMs <= curMs) {
|
|
459
|
+
assignedIdx = i;
|
|
460
|
+
break;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
if (assignedIdx === -1 && st.filesTouched.length > 0 && sortedCommits.length > 0) {
|
|
466
|
+
assignedIdx = sortedCommits.findIndex((c) =>
|
|
467
|
+
c.files.some((cf) => st.filesTouched.includes(cf.filePath))
|
|
468
|
+
);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
if (assignedIdx >= 0) {
|
|
472
|
+
commitBuckets.get(assignedIdx).push(st);
|
|
473
|
+
if (!st.hasExplicitWaste) matchedAttrSteps.push(st);
|
|
474
|
+
} else if (sortedCommits.length > 0 && st.tsMs === null) {
|
|
475
|
+
unmatchedIn += st.inTok;
|
|
476
|
+
unmatchedWrite += st.cacheWriteTok;
|
|
477
|
+
unmatchedCache += st.cacheReadTok;
|
|
478
|
+
unmatchedOut += st.outTok;
|
|
479
|
+
unmatchedUsd += computeStepUsdWithModel(st, pricePerMillionUsd, hasExplicitPriceOverride);
|
|
480
|
+
unmatchedWaste += st.wasteTok;
|
|
481
|
+
if (st.isRing0) unmatchedRing0 += 1;
|
|
482
|
+
if (!st.hasExplicitWaste) matchedAttrSteps.push(st);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
let inferredPreventableWaste = 0;
|
|
487
|
+
if (matchedAttrSteps.length >= 2) {
|
|
488
|
+
const attrCalls = matchedAttrSteps.map((st, idx) => ({
|
|
489
|
+
conv: st.sessionId || 'default',
|
|
490
|
+
idx: st.stepIndex ?? idx,
|
|
491
|
+
model: st.model || 'claude-sonnet-5-5',
|
|
492
|
+
freshInputTokens: st.inTok,
|
|
493
|
+
cacheCreationTokens: st.cacheWriteTok,
|
|
494
|
+
cacheCreationEphemeral5mInputTokens: st.cacheWrite5mTok,
|
|
495
|
+
cacheCreationEphemeral1hInputTokens: st.cacheWrite1hTok,
|
|
496
|
+
cacheReadTokens: st.cacheReadTok,
|
|
497
|
+
outputTokens: st.outTok,
|
|
498
|
+
createdAt: st.tsMs,
|
|
499
|
+
hadCompactionBefore: st.hadCompactionBefore,
|
|
500
|
+
isCompactSummary: st.isCompactSummary,
|
|
501
|
+
isCompactionBoundary: st.isCompactionBoundary,
|
|
502
|
+
isSidechain: st.isSidechain,
|
|
503
|
+
entrypoint: st.entrypoint,
|
|
504
|
+
shapeHash: st.shapeHash,
|
|
505
|
+
cacheTtlTier: st.cacheTtlTier
|
|
506
|
+
}));
|
|
507
|
+
const wasteAttr = attributeUncachedTokens(attrCalls);
|
|
508
|
+
inferredPreventableWaste =
|
|
509
|
+
Number(wasteAttr?.buckets?.idle_ttl_miss?.tokens || 0) +
|
|
510
|
+
Number(wasteAttr?.buckets?.model_or_effort_switch?.tokens || 0) +
|
|
511
|
+
Number(wasteAttr?.buckets?.unexplained_prefix_reset?.subBuckets?.actionable_prefix_reset?.tokens || 0) +
|
|
512
|
+
Number(wasteAttr?.buckets?.compaction_rebuild?.claude55CompactCacheMiss?.tokens || 0);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
const fileAggMap = new Map();
|
|
516
|
+
let sumIn = 0;
|
|
517
|
+
let sumWrite = 0;
|
|
518
|
+
let sumCache = 0;
|
|
519
|
+
let sumOut = 0;
|
|
520
|
+
let sumCostUsd = 0;
|
|
521
|
+
let sumWaste = 0;
|
|
522
|
+
let sumRing0 = unmatchedRing0 + ledgerRing0Count;
|
|
523
|
+
|
|
524
|
+
const commitRows = sortedCommits.map((c, idx) => {
|
|
525
|
+
const bucket = commitBuckets.get(idx) || [];
|
|
526
|
+
const locShare = totalBranchLoc > 0 ? Math.max(1, c.totalLoc || 0) / totalBranchLoc : 0;
|
|
527
|
+
|
|
528
|
+
const cIn = bucket.reduce((s, st) => s + st.inTok, 0) + Math.round(unmatchedIn * locShare);
|
|
529
|
+
const cWrite = bucket.reduce((s, st) => s + st.cacheWriteTok, 0) + Math.round(unmatchedWrite * locShare);
|
|
530
|
+
const cCache = bucket.reduce((s, st) => s + st.cacheReadTok, 0) + Math.round(unmatchedCache * locShare);
|
|
531
|
+
const cOut = bucket.reduce((s, st) => s + st.outTok, 0) + Math.round(unmatchedOut * locShare);
|
|
532
|
+
const cWaste = bucket.reduce((s, st) => s + st.wasteTok, 0) + Math.round(unmatchedWaste * locShare);
|
|
533
|
+
const cRing0 = bucket.filter((st) => st.isRing0).length;
|
|
534
|
+
const cTotal = cIn + cWrite + cCache + cOut;
|
|
535
|
+
const cDenom = cIn + cWrite + cCache;
|
|
536
|
+
const cHitPct = cDenom > 0 ? Math.round((cCache / cDenom) * 100) : 0;
|
|
537
|
+
const rawBucketUsd =
|
|
538
|
+
bucket.reduce((s, st) => s + computeStepUsdWithModel(st, pricePerMillionUsd, hasExplicitPriceOverride), 0) +
|
|
539
|
+
unmatchedUsd * locShare;
|
|
540
|
+
const cCostUsd = Number(rawBucketUsd.toFixed(4));
|
|
541
|
+
|
|
542
|
+
sumIn += cIn;
|
|
543
|
+
sumWrite += cWrite;
|
|
544
|
+
sumCache += cCache;
|
|
545
|
+
sumOut += cOut;
|
|
546
|
+
sumCostUsd += rawBucketUsd;
|
|
547
|
+
sumWaste += cWaste;
|
|
548
|
+
sumRing0 += cRing0;
|
|
549
|
+
|
|
550
|
+
const fileLocSum = c.files.reduce((s, f) => s + Math.max(1, f.additions + f.deletions), 0);
|
|
551
|
+
for (const f of c.files) {
|
|
552
|
+
const share = fileLocSum > 0 ? Math.max(1, f.additions + f.deletions) / fileLocSum : 0;
|
|
553
|
+
const cur = fileAggMap.get(f.filePath) || {
|
|
554
|
+
filePath: f.filePath,
|
|
555
|
+
commits: 0,
|
|
556
|
+
additions: 0,
|
|
557
|
+
deletions: 0,
|
|
558
|
+
attributedTokens: 0,
|
|
559
|
+
estimatedCostUsd: 0
|
|
560
|
+
};
|
|
561
|
+
cur.commits += 1;
|
|
562
|
+
cur.additions += f.additions;
|
|
563
|
+
cur.deletions += f.deletions;
|
|
564
|
+
cur.attributedTokens += Math.round(cTotal * share);
|
|
565
|
+
cur.estimatedCostUsd = Number((cur.estimatedCostUsd + cCostUsd * share).toFixed(4));
|
|
566
|
+
fileAggMap.set(f.filePath, cur);
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
return {
|
|
570
|
+
sha: c.sha,
|
|
571
|
+
shortSha: c.shortSha,
|
|
572
|
+
timestampIso: c.timestampIso,
|
|
573
|
+
author: c.author,
|
|
574
|
+
subject: c.subject,
|
|
575
|
+
filesChanged: c.files.length,
|
|
576
|
+
additions: c.totalAdditions,
|
|
577
|
+
deletions: c.totalDeletions,
|
|
578
|
+
attributedTokens: cTotal,
|
|
579
|
+
inputTokens: cIn,
|
|
580
|
+
cacheWriteTokens: cWrite,
|
|
581
|
+
cacheReadTokens: cCache,
|
|
582
|
+
outputTokens: cOut,
|
|
583
|
+
wasteTokens: cWaste,
|
|
584
|
+
cacheHitPct: cHitPct,
|
|
585
|
+
estimatedCostUsd: cCostUsd,
|
|
586
|
+
ring0Violations: cRing0
|
|
587
|
+
};
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
if (inferredPreventableWaste > 0 && commitRows.length > 0) {
|
|
591
|
+
const totalInputForShare = commitRows.reduce((s, r) => s + Math.max(1, r.inputTokens + r.cacheWriteTokens), 0);
|
|
592
|
+
let distributed = 0;
|
|
593
|
+
for (let i = 0; i < commitRows.length; i++) {
|
|
594
|
+
const shareTok =
|
|
595
|
+
i === commitRows.length - 1
|
|
596
|
+
? Math.max(0, inferredPreventableWaste - distributed)
|
|
597
|
+
: Math.round(
|
|
598
|
+
(inferredPreventableWaste * Math.max(1, commitRows[i].inputTokens + commitRows[i].cacheWriteTokens)) /
|
|
599
|
+
totalInputForShare
|
|
600
|
+
);
|
|
601
|
+
commitRows[i].wasteTokens += shareTok;
|
|
602
|
+
distributed += shareTok;
|
|
603
|
+
}
|
|
604
|
+
sumWaste += inferredPreventableWaste;
|
|
605
|
+
} else if (inferredPreventableWaste > 0) {
|
|
606
|
+
sumWaste += inferredPreventableWaste;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
const totalTokens = sumIn + sumWrite + sumCache + sumOut;
|
|
610
|
+
const cacheDenom = sumIn + sumWrite + sumCache;
|
|
611
|
+
const cacheHitPct = cacheDenom > 0 ? Math.round((sumCache / cacheDenom) * 100) : 0;
|
|
612
|
+
const estimatedCostUsd = Number(sumCostUsd.toFixed(4));
|
|
613
|
+
const wasteRatioPct = totalTokens > 0 ? Math.round((sumWaste / totalTokens) * 100) : 0;
|
|
614
|
+
const uniqueFiles = new Set(commitRows.flatMap((_, idx) => sortedCommits[idx].files.map((f) => f.filePath)));
|
|
615
|
+
const totalAdditions = sortedCommits.reduce((s, c) => s + c.totalAdditions, 0);
|
|
616
|
+
const totalDeletions = sortedCommits.reduce((s, c) => s + c.totalDeletions, 0);
|
|
617
|
+
const totalLoc = totalAdditions + totalDeletions;
|
|
618
|
+
const usdPer100Loc = totalLoc > 0 ? Number(((estimatedCostUsd / totalLoc) * 100).toFixed(4)) : 0;
|
|
619
|
+
|
|
620
|
+
const topCostFiles = Array.from(fileAggMap.values())
|
|
621
|
+
.filter((f) => f.filePath && !isExcludedLocalToolPath(f.filePath))
|
|
622
|
+
.sort((a, b) => b.attributedTokens - a.attributedTokens || b.estimatedCostUsd - a.estimatedCostUsd)
|
|
623
|
+
.slice(0, 10);
|
|
624
|
+
|
|
625
|
+
let reconciledCostUsd = null;
|
|
626
|
+
let attributionVariancePct = null;
|
|
627
|
+
if (options.providerUsagePath) {
|
|
628
|
+
try {
|
|
629
|
+
const rawProviderUsd = readProviderUsageExportUsd(options.providerUsagePath);
|
|
630
|
+
if (typeof rawProviderUsd === 'number' && Number.isFinite(rawProviderUsd)) {
|
|
631
|
+
reconciledCostUsd = Number(rawProviderUsd.toFixed(4));
|
|
632
|
+
attributionVariancePct =
|
|
633
|
+
reconciledCostUsd > 0
|
|
634
|
+
? Number((((estimatedCostUsd - reconciledCostUsd) / reconciledCostUsd) * 100).toFixed(2))
|
|
635
|
+
: 0;
|
|
636
|
+
}
|
|
637
|
+
} catch (err) {
|
|
638
|
+
return {
|
|
639
|
+
ok: false,
|
|
640
|
+
error: err?.message || String(err),
|
|
641
|
+
base,
|
|
642
|
+
head
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
return {
|
|
648
|
+
ok: true,
|
|
649
|
+
format: PR_ATTRIBUTION_FORMAT,
|
|
650
|
+
generatedAt: new Date().toISOString(),
|
|
651
|
+
base,
|
|
652
|
+
head,
|
|
653
|
+
fallbackUsed,
|
|
654
|
+
summary: {
|
|
655
|
+
sessionCount,
|
|
656
|
+
totalCommits: commitRows.length,
|
|
657
|
+
totalFilesChanged: uniqueFiles.size,
|
|
658
|
+
totalAdditions,
|
|
659
|
+
totalDeletions,
|
|
660
|
+
totalLoc,
|
|
661
|
+
totalInputTokens: sumIn,
|
|
662
|
+
totalCacheWriteTokens: sumWrite,
|
|
663
|
+
totalCacheReadTokens: sumCache,
|
|
664
|
+
totalOutputTokens: sumOut,
|
|
665
|
+
totalTokens,
|
|
666
|
+
cacheHitPct,
|
|
667
|
+
estimatedCostUsd,
|
|
668
|
+
reconciledCostUsd,
|
|
669
|
+
attributionVariancePct,
|
|
670
|
+
estimatedSavedUsd: Number(ledgerSavedUsd.toFixed(4)),
|
|
671
|
+
estimatedWasteTokens: sumWaste,
|
|
672
|
+
wasteRatioPct,
|
|
673
|
+
ring0Violations: sumRing0,
|
|
674
|
+
usdPer100Loc
|
|
675
|
+
},
|
|
676
|
+
commits: commitRows,
|
|
677
|
+
topCostFiles
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* Formats PR cost attribution as clean PR comment Markdown with zero local paths.
|
|
683
|
+
*/
|
|
684
|
+
export function formatPrAttributionMarkdown(report = {}) {
|
|
685
|
+
const s = report.summary || {};
|
|
686
|
+
const lines = [
|
|
687
|
+
`### Burnoff PR Token & Cost Attribution (\`${report.base || 'main'}..${report.head || 'HEAD'}\`)`,
|
|
688
|
+
'',
|
|
689
|
+
'| Metric | Value |',
|
|
690
|
+
'| :--- | :--- |',
|
|
691
|
+
`| **Commits / Files Changed** | \`${s.totalCommits ?? 0}\` commits · \`${s.totalFilesChanged ?? 0}\` files (\`+${s.totalAdditions ?? 0} / -${s.totalDeletions ?? 0}\`) |`,
|
|
692
|
+
`| **Total Attributed Tokens** | \`${((s.totalTokens || 0) / 1000).toFixed(1)}k\` |`,
|
|
693
|
+
`| **Cache Hit Rate** | \`${s.cacheHitPct ?? 0}%\` |`,
|
|
694
|
+
`| **Estimated PR AI Cost** | \`$${Number(s.estimatedCostUsd || 0).toFixed(4)}\` (\`$${Number(s.usdPer100Loc || 0).toFixed(4)} / 100 LOC\`) |`,
|
|
695
|
+
...(typeof s.reconciledCostUsd === 'number'
|
|
696
|
+
? [
|
|
697
|
+
`| **Provider Reconciled Cost** | \`$${s.reconciledCostUsd.toFixed(4)}\` (\`${(s.attributionVariancePct || 0) >= 0 ? '+' : ''}${s.attributionVariancePct ?? 0}%\` variance) |`
|
|
698
|
+
]
|
|
699
|
+
: []),
|
|
700
|
+
`| **Preventable Waste Ratio** | \`${s.wasteRatioPct ?? 0}%\` (\`${((s.estimatedWasteTokens || 0) / 1000).toFixed(1)}k\` tok) |`,
|
|
701
|
+
`| **Estimated Saved USD** | \`$${Number(s.estimatedSavedUsd || 0).toFixed(4)}\` |`,
|
|
702
|
+
`| **Ring-0 Violations** | \`${s.ring0Violations ?? 0}\` |`
|
|
703
|
+
];
|
|
704
|
+
|
|
705
|
+
const cleanFiles = (Array.isArray(report.topCostFiles) ? report.topCostFiles : [])
|
|
706
|
+
.map((f) => ({ ...f, filePath: sanitizeRelativeRepoPath(f.filePath) }))
|
|
707
|
+
.filter((f) => f.filePath && !isExcludedLocalToolPath(f.filePath));
|
|
708
|
+
if (cleanFiles.length > 0) {
|
|
709
|
+
lines.push('', '#### Top Cost-Driver Files', '', '| File | LOC Changed | Attributed Tokens | Est. Cost |', '| :--- | :---: | :---: | :---: |');
|
|
710
|
+
for (const f of cleanFiles) {
|
|
711
|
+
lines.push(
|
|
712
|
+
`| \`${f.filePath}\` | \`+${f.additions}/-${f.deletions}\` | \`${(f.attributedTokens / 1000).toFixed(1)}k\` | \`$${Number(f.estimatedCostUsd || 0).toFixed(4)}\` |`
|
|
713
|
+
);
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
if (Array.isArray(report.commits) && report.commits.length > 0) {
|
|
718
|
+
lines.push('', '#### Commit Attribution Breakdown', '', '| Commit | Subject | Tokens | Cache Hit | Est. Cost |', '| :--- | :--- | :---: | :---: | :---: |');
|
|
719
|
+
for (const c of report.commits) {
|
|
720
|
+
lines.push(
|
|
721
|
+
`| \`${c.shortSha}\` | ${String(c.subject || '').replace(/\|/g, '\\|')} | \`${(c.attributedTokens / 1000).toFixed(1)}k\` | \`${c.cacheHitPct}%\` | \`$${Number(c.estimatedCostUsd || 0).toFixed(4)}\` |`
|
|
722
|
+
);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
return lines.join('\n') + '\n';
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
export default {
|
|
730
|
+
PR_ATTRIBUTION_FORMAT,
|
|
731
|
+
sanitizeRelativeRepoPath,
|
|
732
|
+
collectGitBranchCommits,
|
|
733
|
+
buildPrCostAttribution,
|
|
734
|
+
formatPrAttributionMarkdown
|
|
735
|
+
};
|