@openclaw/tokenjuice 2026.11.10-beta.3 → 2026.12.1-beta.1
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/node_modules/tokenjuice/README.md +133 -6
- package/node_modules/tokenjuice/dist/cli/main.d.ts +1 -2
- package/node_modules/tokenjuice/dist/cli/main.js +3 -18
- package/node_modules/tokenjuice/dist/core/analysis.js +7 -10
- package/node_modules/tokenjuice/dist/core/artifacts.d.ts +1 -1
- package/node_modules/tokenjuice/dist/core/artifacts.js +4 -3
- package/node_modules/tokenjuice/dist/core/command-identity.js +7 -6
- package/node_modules/tokenjuice/dist/core/compaction-metadata.d.ts +3 -2
- package/node_modules/tokenjuice/dist/core/compaction-metadata.js +2 -1
- package/node_modules/tokenjuice/dist/core/failure-summary.d.ts +7 -0
- package/node_modules/tokenjuice/dist/core/failure-summary.js +76 -0
- package/node_modules/tokenjuice/dist/core/inventory-safety.js +14 -6
- package/node_modules/tokenjuice/dist/core/reduce-utils.js +9 -7
- package/node_modules/tokenjuice/dist/core/reduce.js +32 -21
- package/node_modules/tokenjuice/dist/core/streamed-text-counter.d.ts +8 -0
- package/node_modules/tokenjuice/dist/core/streamed-text-counter.js +56 -0
- package/node_modules/tokenjuice/dist/core/text.d.ts +1 -0
- package/node_modules/tokenjuice/dist/core/text.js +22 -11
- package/node_modules/tokenjuice/dist/core/wrap-format.d.ts +3 -0
- package/node_modules/tokenjuice/dist/core/wrap-format.js +34 -0
- package/node_modules/tokenjuice/dist/core/wrap.js +55 -6
- package/node_modules/tokenjuice/dist/hosts/codex/index.js +37 -10
- package/node_modules/tokenjuice/dist/hosts/deepseek-harness/bundle/index.js +221 -79
- package/node_modules/tokenjuice/dist/hosts/deepseek-harness/bundle/package.json +1 -1
- package/node_modules/tokenjuice/dist/hosts/hermes/bundle/plugin.yaml +1 -1
- package/node_modules/tokenjuice/dist/hosts/hermes/bundle/tokenjuice_integrations/README.md +4 -2
- package/node_modules/tokenjuice/dist/hosts/hermes/bundle/tokenjuice_integrations/bridge.py +62 -5
- package/node_modules/tokenjuice/dist/hosts/openclaw/extension.js +7 -2
- package/node_modules/tokenjuice/dist/hosts/opencode/extension/runtime.js +221 -79
- package/node_modules/tokenjuice/dist/hosts/opencode/v2/bundle/index.js +221 -79
- package/node_modules/tokenjuice/dist/hosts/pi/extension/runtime.js +221 -79
- package/node_modules/tokenjuice/dist/python/README.md +1 -1
- package/node_modules/tokenjuice/dist/python/pyproject.toml +1 -1
- package/node_modules/tokenjuice/dist/python/tokenjuice_integrations/README.md +4 -2
- package/node_modules/tokenjuice/dist/python/tokenjuice_integrations/bridge.py +62 -5
- package/node_modules/tokenjuice/dist/rules/build/tsc.json +8 -3
- package/node_modules/tokenjuice/dist/rules/fixtures/build/tsc.fixture.json +6 -2
- package/node_modules/tokenjuice/dist/rules/install/bun-install.json +12 -4
- package/node_modules/tokenjuice/dist/rules/install/npm-ci.json +12 -4
- package/node_modules/tokenjuice/dist/rules/install/npm-install.json +12 -4
- package/node_modules/tokenjuice/dist/rules/install/pnpm-install.json +12 -4
- package/node_modules/tokenjuice/dist/rules/install/yarn-install.json +12 -4
- package/node_modules/tokenjuice/dist/rules/tests/pytest.json +8 -3
- package/node_modules/tokenjuice/dist/types.d.ts +3 -0
- package/node_modules/tokenjuice/package.json +5 -15
- package/package.json +5 -5
|
@@ -920,8 +920,8 @@ function isGhApiContentsDecodeCommand(command) {
|
|
|
920
920
|
}
|
|
921
921
|
return /\bgh\s+api\b/u.test(command) && /\/contents\//u.test(command) && /--jq(?:=|\s+)['"]?\.content['"]?/u.test(command) && /\|\s*base64\s+(?:-[dD]\b|--decode\b)/u.test(command);
|
|
922
922
|
}
|
|
923
|
-
function getMostDerivedCandidate(input) {
|
|
924
|
-
return
|
|
923
|
+
function getMostDerivedCandidate(input, candidates = deriveCommandMatchCandidates(input)) {
|
|
924
|
+
return candidates.reduce((best, candidate) => getSourcePriority(candidate.source) >= getSourcePriority(best.source) ? candidate : best);
|
|
925
925
|
}
|
|
926
926
|
function extractPipelineSourceCommand(command) {
|
|
927
927
|
let current = "";
|
|
@@ -958,8 +958,8 @@ function extractPipelineSourceCommand(command) {
|
|
|
958
958
|
}
|
|
959
959
|
return current.trim();
|
|
960
960
|
}
|
|
961
|
-
function getInspectionArgv(input) {
|
|
962
|
-
const candidate = getMostDerivedCandidate(input);
|
|
961
|
+
function getInspectionArgv(input, candidates = deriveCommandMatchCandidates(input)) {
|
|
962
|
+
const candidate = getMostDerivedCandidate(input, candidates);
|
|
963
963
|
if (candidate.argv.length > 0) {
|
|
964
964
|
return candidate.argv;
|
|
965
965
|
}
|
|
@@ -970,7 +970,8 @@ function getInspectionArgv(input) {
|
|
|
970
970
|
return sourceCommand ? tokenizeCommand(sourceCommand) : [];
|
|
971
971
|
}
|
|
972
972
|
function isFileContentInspectionCommand(input) {
|
|
973
|
-
|
|
973
|
+
const candidates = deriveCommandMatchCandidates(input);
|
|
974
|
+
return isFileContentInspectionArgv(getInspectionArgv(input, candidates)) || candidates.some((candidate) => isGhApiContentsDecodeCommand(candidate.command));
|
|
974
975
|
}
|
|
975
976
|
function isVerbatimRemoteInspectionCommand(command) {
|
|
976
977
|
const effectiveCommand = unwrapShellRunner({ command }) ?? command;
|
|
@@ -1296,6 +1297,9 @@ function isSafeRepositoryInventorySource(argv) {
|
|
|
1296
1297
|
}
|
|
1297
1298
|
function isRepositoryInventoryCommand(input) {
|
|
1298
1299
|
const argv = input.argv?.length ? getEffectiveCommandArgv(input) : getRepositoryInventorySourceArgv(input.command ?? "");
|
|
1300
|
+
return isRepositoryInventoryArgv(argv);
|
|
1301
|
+
}
|
|
1302
|
+
function isRepositoryInventoryArgv(argv) {
|
|
1299
1303
|
const argv0 = getCommandName(argv);
|
|
1300
1304
|
if (!argv0) {
|
|
1301
1305
|
return false;
|
|
@@ -1336,11 +1340,15 @@ function getRepositoryInventorySafety(command) {
|
|
|
1336
1340
|
}
|
|
1337
1341
|
function isRepositoryInspectionCommand2(input) {
|
|
1338
1342
|
const argv = input.argv?.length ? getEffectiveCommandArgv(input) : getRepositoryInventorySourceArgv(input.command ?? "");
|
|
1343
|
+
return isPreparedRepositoryInspection({ argv, fileContent: isFileContentInspectionCommand(input) });
|
|
1344
|
+
}
|
|
1345
|
+
function isPreparedRepositoryInspection(analysis) {
|
|
1346
|
+
const { argv, fileContent } = analysis;
|
|
1339
1347
|
const argv0 = getCommandName(argv);
|
|
1340
|
-
if (
|
|
1348
|
+
if (fileContent) {
|
|
1341
1349
|
return true;
|
|
1342
1350
|
}
|
|
1343
|
-
if (
|
|
1351
|
+
if (isRepositoryInventoryArgv(argv)) {
|
|
1344
1352
|
return true;
|
|
1345
1353
|
}
|
|
1346
1354
|
if (argv0 && REPO_INSPECTION_ONLY_COMMANDS.has(argv0)) {
|
|
@@ -1362,15 +1370,16 @@ function getInspectionCommandSkipReason(command, policy) {
|
|
|
1362
1370
|
if (policy === "skip-all") {
|
|
1363
1371
|
return isRepositoryInspectionCommand2({ command }) ? "inspection-command" : null;
|
|
1364
1372
|
}
|
|
1365
|
-
|
|
1373
|
+
const fileContent = isFileContentInspectionCommand({ command });
|
|
1374
|
+
if (fileContent && !hasCommandOnlyFileContentSummary(command)) {
|
|
1366
1375
|
return "file-content-inspection-command";
|
|
1367
1376
|
}
|
|
1368
1377
|
if (policy === "skip-file-content") {
|
|
1369
1378
|
return null;
|
|
1370
1379
|
}
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
const argv0 = getCommandName(
|
|
1380
|
+
const analysis = { argv: getRepositoryInventorySourceArgv(command), fileContent };
|
|
1381
|
+
if (isPreparedRepositoryInspection(analysis)) {
|
|
1382
|
+
const argv0 = getCommandName(analysis.argv);
|
|
1374
1383
|
if (argv0 && REPO_INSPECTION_ONLY_COMMANDS.has(argv0)) {
|
|
1375
1384
|
return "inspection-command";
|
|
1376
1385
|
}
|
|
@@ -1701,7 +1710,7 @@ var FLAG_EMOJI_PATTERN = new RegExp("^\\p{Regional_Indicator}{2}$", "u");
|
|
|
1701
1710
|
var KEYCAP_EMOJI_PATTERN = /^[#*0-9]\uFE0F?\u20E3$/u;
|
|
1702
1711
|
var REPEATED_EMOJI_BANNER_MIN_REPETITIONS = 24;
|
|
1703
1712
|
var graphemeSegmenter = typeof Intl !== "undefined" && "Segmenter" in Intl ? new Intl.Segmenter(void 0, { granularity: "grapheme" }) : null;
|
|
1704
|
-
function
|
|
1713
|
+
function segmentTextChars(text) {
|
|
1705
1714
|
if (!graphemeSegmenter) {
|
|
1706
1715
|
return Array.from(text);
|
|
1707
1716
|
}
|
|
@@ -1725,10 +1734,13 @@ function stripAnsi(text) {
|
|
|
1725
1734
|
return text.replaceAll(ANSI_OSC_PATTERN, "").replaceAll(ANSI_CSI_PATTERN, "").replaceAll(ANSI_OSC_INCOMPLETE_PATTERN, "").replaceAll(ANSI_CSI_INCOMPLETE_PATTERN, "").replaceAll(ANSI_SINGLE_PATTERN, "").replaceAll("\x1B", "");
|
|
1726
1735
|
}
|
|
1727
1736
|
function countTextChars(text) {
|
|
1728
|
-
|
|
1737
|
+
const iterator = graphemeSegmenter ? graphemeSegmenter.segment(text)[Symbol.iterator]() : text[Symbol.iterator]();
|
|
1738
|
+
let count = 0;
|
|
1739
|
+
while (!iterator.next().done) count += 1;
|
|
1740
|
+
return count;
|
|
1729
1741
|
}
|
|
1730
1742
|
function sliceTextChars(text, start, end) {
|
|
1731
|
-
return
|
|
1743
|
+
return segmentTextChars(text).slice(start, end).join("");
|
|
1732
1744
|
}
|
|
1733
1745
|
function normalizeLines(text) {
|
|
1734
1746
|
return text.replaceAll("\r\n", "\n").split("\n").map((line) => line.replace(/\s+$/u, ""));
|
|
@@ -1762,7 +1774,7 @@ function isEmojiGrapheme(text) {
|
|
|
1762
1774
|
function collapseRepeatedEmojiBanner(lines) {
|
|
1763
1775
|
let collapsed = false;
|
|
1764
1776
|
const nextLines = lines.map((line) => {
|
|
1765
|
-
const visibleSegments =
|
|
1777
|
+
const visibleSegments = segmentTextChars(line).filter((segment) => !/^\s+$/u.test(segment));
|
|
1766
1778
|
const repeatedEmoji = visibleSegments[0];
|
|
1767
1779
|
if (visibleSegments.length < REPEATED_EMOJI_BANNER_MIN_REPETITIONS || !repeatedEmoji || !isEmojiGrapheme(repeatedEmoji) || visibleSegments.some((segment) => segment !== repeatedEmoji)) {
|
|
1768
1780
|
return line;
|
|
@@ -1799,16 +1811,14 @@ function headTail(lines, head, tail, noOmit = false) {
|
|
|
1799
1811
|
compaction: createCompactionMetadata("head-tail-omission")
|
|
1800
1812
|
};
|
|
1801
1813
|
}
|
|
1802
|
-
function
|
|
1803
|
-
if (countTextChars(text) <= maxChars) {
|
|
1804
|
-
return text;
|
|
1805
|
-
}
|
|
1814
|
+
function clampSegments(segments, maxChars) {
|
|
1806
1815
|
const bodyChars = Math.max(0, maxChars - countTextChars(TRUNCATION_SUFFIX));
|
|
1807
|
-
const head = trimHeadToLineBoundary(
|
|
1816
|
+
const head = trimHeadToLineBoundary(segments.slice(0, bodyChars).join(""));
|
|
1808
1817
|
return `${head}${TRUNCATION_SUFFIX}`;
|
|
1809
1818
|
}
|
|
1810
1819
|
function clampTextWithMetadata(text, maxChars, noOmit = false) {
|
|
1811
|
-
|
|
1820
|
+
const segments = segmentTextChars(text);
|
|
1821
|
+
if (segments.length <= maxChars) {
|
|
1812
1822
|
return { text };
|
|
1813
1823
|
}
|
|
1814
1824
|
if (noOmit) {
|
|
@@ -1818,12 +1828,13 @@ function clampTextWithMetadata(text, maxChars, noOmit = false) {
|
|
|
1818
1828
|
};
|
|
1819
1829
|
}
|
|
1820
1830
|
return {
|
|
1821
|
-
text:
|
|
1831
|
+
text: clampSegments(segments, maxChars),
|
|
1822
1832
|
compaction: createCompactionMetadata("tail-truncation")
|
|
1823
1833
|
};
|
|
1824
1834
|
}
|
|
1825
1835
|
function clampTextMiddleWithMetadata(text, maxChars, noOmit = false) {
|
|
1826
|
-
|
|
1836
|
+
const segments = segmentTextChars(text);
|
|
1837
|
+
if (segments.length <= maxChars) {
|
|
1827
1838
|
return { text };
|
|
1828
1839
|
}
|
|
1829
1840
|
if (noOmit) {
|
|
@@ -1836,7 +1847,6 @@ function clampTextMiddleWithMetadata(text, maxChars, noOmit = false) {
|
|
|
1836
1847
|
const bodyChars = Math.max(0, maxChars - markerChars);
|
|
1837
1848
|
const headChars = Math.ceil(bodyChars * 0.7);
|
|
1838
1849
|
const tailChars = Math.max(0, bodyChars - headChars);
|
|
1839
|
-
const segments = graphemes(text);
|
|
1840
1850
|
const head = trimHeadToLineBoundary(segments.slice(0, headChars).join(""));
|
|
1841
1851
|
const tail = trimTailToLineBoundary(segments.slice(-tailChars).join(""));
|
|
1842
1852
|
return {
|
|
@@ -2068,9 +2078,10 @@ function shouldRecordStats(env = process.env) {
|
|
|
2068
2078
|
const value = env[STATS_ENABLED_ENV]?.trim().toLowerCase();
|
|
2069
2079
|
return value !== "0" && value !== "false" && value !== "no" && value !== "off";
|
|
2070
2080
|
}
|
|
2071
|
-
async function storeArtifact(input, storeDir) {
|
|
2081
|
+
async function storeArtifact(input, storeDir, statsForRef) {
|
|
2072
2082
|
const id = `tj_${randomUUID2().slice(0, 12)}`;
|
|
2073
2083
|
const ref = buildArtifactPaths(id, storeDir);
|
|
2084
|
+
const stats = statsForRef ? statsForRef(ref) : input.stats;
|
|
2074
2085
|
await mkdir2(resolveArtifactBaseDir(storeDir), { recursive: true, mode: 448 });
|
|
2075
2086
|
const captureTruncated = extractCaptureTruncatedFlag(input.input);
|
|
2076
2087
|
const artifact = {
|
|
@@ -2080,12 +2091,12 @@ async function storeArtifact(input, storeDir) {
|
|
|
2080
2091
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2081
2092
|
source: resolveArtifactSource(input.input),
|
|
2082
2093
|
classification: input.classification,
|
|
2083
|
-
rawChars:
|
|
2094
|
+
rawChars: stats?.rawChars ?? countTextChars(stripAnsi(input.rawText)),
|
|
2084
2095
|
...input.input.toolName ? { toolName: input.input.toolName } : {},
|
|
2085
2096
|
...input.input.command ? { command: input.input.command } : {},
|
|
2086
2097
|
...typeof input.input.exitCode === "number" ? { exitCode: input.input.exitCode } : {},
|
|
2087
2098
|
...captureTruncated !== void 0 ? { captureTruncated } : {},
|
|
2088
|
-
...
|
|
2099
|
+
...stats ? { reducedChars: stats.reducedChars, ratio: stats.ratio } : {}
|
|
2089
2100
|
}
|
|
2090
2101
|
};
|
|
2091
2102
|
await Promise.all([
|
|
@@ -2605,8 +2616,12 @@ var tsc_default = {
|
|
|
2605
2616
|
family: "build-typescript",
|
|
2606
2617
|
description: "Compact TypeScript compiler output while preserving real diagnostics.",
|
|
2607
2618
|
match: {
|
|
2608
|
-
toolNames: [
|
|
2609
|
-
|
|
2619
|
+
toolNames: [
|
|
2620
|
+
"exec"
|
|
2621
|
+
],
|
|
2622
|
+
commandIncludes: [
|
|
2623
|
+
"tsc"
|
|
2624
|
+
]
|
|
2610
2625
|
},
|
|
2611
2626
|
transforms: {
|
|
2612
2627
|
stripAnsi: true,
|
|
@@ -2650,7 +2665,8 @@ var tsc_default = {
|
|
|
2650
2665
|
"^.+\\(\\d+,\\d+\\):\\s+error TS\\d+: .+",
|
|
2651
2666
|
"^.+\\(\\d+,\\d+\\):\\s+warning TS\\d+: .+",
|
|
2652
2667
|
"^Found \\d+ errors?.+",
|
|
2653
|
-
"^error TS\\d+: .+"
|
|
2668
|
+
"^error TS\\d+: .+",
|
|
2669
|
+
"^\\s{2,}\\S"
|
|
2654
2670
|
]
|
|
2655
2671
|
},
|
|
2656
2672
|
summarize: {
|
|
@@ -4385,15 +4401,23 @@ var bun_install_default = {
|
|
|
4385
4401
|
description: "Compact bun install output while preserving warnings and package counts.",
|
|
4386
4402
|
matchOutput: [
|
|
4387
4403
|
{
|
|
4388
|
-
pattern: "Checked \\d+ installs? across \\d+ packages? \\(no changes\\)",
|
|
4404
|
+
pattern: "^(?:bun install v[^\\r\\n]+\\n)?Checked \\d+ installs? across \\d+ packages? \\(no changes\\)$",
|
|
4389
4405
|
message: "bun install: up to date",
|
|
4390
4406
|
flags: "i"
|
|
4391
4407
|
}
|
|
4392
4408
|
],
|
|
4393
4409
|
match: {
|
|
4394
|
-
toolNames: [
|
|
4395
|
-
|
|
4396
|
-
|
|
4410
|
+
toolNames: [
|
|
4411
|
+
"exec"
|
|
4412
|
+
],
|
|
4413
|
+
argv0: [
|
|
4414
|
+
"bun"
|
|
4415
|
+
],
|
|
4416
|
+
argvIncludes: [
|
|
4417
|
+
[
|
|
4418
|
+
"install"
|
|
4419
|
+
]
|
|
4420
|
+
]
|
|
4397
4421
|
},
|
|
4398
4422
|
transforms: {
|
|
4399
4423
|
stripAnsi: true,
|
|
@@ -4431,15 +4455,23 @@ var npm_ci_default = {
|
|
|
4431
4455
|
onEmpty: "npm ci: ok",
|
|
4432
4456
|
matchOutput: [
|
|
4433
4457
|
{
|
|
4434
|
-
pattern: "up to date, audited \\d+
|
|
4458
|
+
pattern: "^up to date, audited \\d+ packages? in [^\\r\\n]+(?:\\n+found 0 vulnerabilities)?$",
|
|
4435
4459
|
message: "npm ci: up to date",
|
|
4436
4460
|
flags: "i"
|
|
4437
4461
|
}
|
|
4438
4462
|
],
|
|
4439
4463
|
match: {
|
|
4440
|
-
toolNames: [
|
|
4441
|
-
|
|
4442
|
-
|
|
4464
|
+
toolNames: [
|
|
4465
|
+
"exec"
|
|
4466
|
+
],
|
|
4467
|
+
argv0: [
|
|
4468
|
+
"npm"
|
|
4469
|
+
],
|
|
4470
|
+
argvIncludes: [
|
|
4471
|
+
[
|
|
4472
|
+
"ci"
|
|
4473
|
+
]
|
|
4474
|
+
]
|
|
4443
4475
|
},
|
|
4444
4476
|
transforms: {
|
|
4445
4477
|
stripAnsi: true,
|
|
@@ -4482,15 +4514,23 @@ var npm_install_default = {
|
|
|
4482
4514
|
onEmpty: "npm install: ok",
|
|
4483
4515
|
matchOutput: [
|
|
4484
4516
|
{
|
|
4485
|
-
pattern: "up to date, audited \\d+
|
|
4517
|
+
pattern: "^up to date, audited \\d+ packages? in [^\\r\\n]+(?:\\n+found 0 vulnerabilities)?$",
|
|
4486
4518
|
message: "npm install: up to date",
|
|
4487
4519
|
flags: "i"
|
|
4488
4520
|
}
|
|
4489
4521
|
],
|
|
4490
4522
|
match: {
|
|
4491
|
-
toolNames: [
|
|
4492
|
-
|
|
4493
|
-
|
|
4523
|
+
toolNames: [
|
|
4524
|
+
"exec"
|
|
4525
|
+
],
|
|
4526
|
+
argv0: [
|
|
4527
|
+
"npm"
|
|
4528
|
+
],
|
|
4529
|
+
argvIncludes: [
|
|
4530
|
+
[
|
|
4531
|
+
"install"
|
|
4532
|
+
]
|
|
4533
|
+
]
|
|
4494
4534
|
},
|
|
4495
4535
|
transforms: {
|
|
4496
4536
|
stripAnsi: true,
|
|
@@ -4532,15 +4572,23 @@ var pnpm_install_default = {
|
|
|
4532
4572
|
description: "Compact pnpm install output while preserving warnings and summary lines.",
|
|
4533
4573
|
matchOutput: [
|
|
4534
4574
|
{
|
|
4535
|
-
pattern: "Already up to date",
|
|
4575
|
+
pattern: "^(?:Lockfile is up to date, resolution step is skipped\\n)?Already up to date(?:\\nDone in [^\\r\\n]+)?$",
|
|
4536
4576
|
message: "pnpm install: up to date",
|
|
4537
4577
|
flags: "i"
|
|
4538
4578
|
}
|
|
4539
4579
|
],
|
|
4540
4580
|
match: {
|
|
4541
|
-
toolNames: [
|
|
4542
|
-
|
|
4543
|
-
|
|
4581
|
+
toolNames: [
|
|
4582
|
+
"exec"
|
|
4583
|
+
],
|
|
4584
|
+
argv0: [
|
|
4585
|
+
"pnpm"
|
|
4586
|
+
],
|
|
4587
|
+
argvIncludes: [
|
|
4588
|
+
[
|
|
4589
|
+
"install"
|
|
4590
|
+
]
|
|
4591
|
+
]
|
|
4544
4592
|
},
|
|
4545
4593
|
transforms: {
|
|
4546
4594
|
stripAnsi: true,
|
|
@@ -4577,14 +4625,22 @@ var yarn_install_default = {
|
|
|
4577
4625
|
description: "Compact yarn install output while preserving warnings and summary lines.",
|
|
4578
4626
|
matchOutput: [
|
|
4579
4627
|
{
|
|
4580
|
-
pattern: "Already up-to-date\\.",
|
|
4628
|
+
pattern: "^(?:\\[\\d+/\\d+\\] Resolving packages\\.\\.\\.\\n)?(?:success )?Already up-to-date\\.(?:\\nDone in [^\\r\\n]+)?$",
|
|
4581
4629
|
message: "yarn install: up to date"
|
|
4582
4630
|
}
|
|
4583
4631
|
],
|
|
4584
4632
|
match: {
|
|
4585
|
-
toolNames: [
|
|
4586
|
-
|
|
4587
|
-
|
|
4633
|
+
toolNames: [
|
|
4634
|
+
"exec"
|
|
4635
|
+
],
|
|
4636
|
+
argv0: [
|
|
4637
|
+
"yarn"
|
|
4638
|
+
],
|
|
4639
|
+
argvIncludes: [
|
|
4640
|
+
[
|
|
4641
|
+
"install"
|
|
4642
|
+
]
|
|
4643
|
+
]
|
|
4588
4644
|
},
|
|
4589
4645
|
transforms: {
|
|
4590
4646
|
stripAnsi: true,
|
|
@@ -6842,8 +6898,12 @@ var pytest_default = {
|
|
|
6842
6898
|
description: "Compact pytest output while preserving failures and final summary.",
|
|
6843
6899
|
counterSource: "preKeep",
|
|
6844
6900
|
match: {
|
|
6845
|
-
toolNames: [
|
|
6846
|
-
|
|
6901
|
+
toolNames: [
|
|
6902
|
+
"exec"
|
|
6903
|
+
],
|
|
6904
|
+
commandIncludes: [
|
|
6905
|
+
"pytest"
|
|
6906
|
+
]
|
|
6847
6907
|
},
|
|
6848
6908
|
transforms: {
|
|
6849
6909
|
stripAnsi: true,
|
|
@@ -6865,7 +6925,8 @@ var pytest_default = {
|
|
|
6865
6925
|
"^E\\s+.+",
|
|
6866
6926
|
"AssertionError",
|
|
6867
6927
|
"^.+::.+ (FAILED|ERROR)$",
|
|
6868
|
-
"^>\\s+.+"
|
|
6928
|
+
"^>\\s+.+",
|
|
6929
|
+
"^\\S.*\\.py:\\d+:\\s+\\S"
|
|
6869
6930
|
]
|
|
6870
6931
|
},
|
|
6871
6932
|
summarize: {
|
|
@@ -7990,6 +8051,74 @@ function classifyExecution(input, rules, forcedRuleId) {
|
|
|
7990
8051
|
return resolved.classification;
|
|
7991
8052
|
}
|
|
7992
8053
|
|
|
8054
|
+
// src/core/failure-summary.ts
|
|
8055
|
+
var FAILURE_LINE = /(?:^|\s)(?:fatal(?:\s+error)?|error|panic|exception|caused by|traceback)(?:[:\s]|$)|\b[A-Z][A-Za-z]*(?:Error|Exception):/iu;
|
|
8056
|
+
function buildFailureSummary(input, rawText, maxChars, noOmit = false) {
|
|
8057
|
+
if (noOmit || typeof input.exitCode !== "number" || input.exitCode === 0) return null;
|
|
8058
|
+
const text = stripAnsi(rawText);
|
|
8059
|
+
const lines = normalizeLines(text);
|
|
8060
|
+
if (lines.length <= 32) return null;
|
|
8061
|
+
const signals = lines.flatMap((line, index) => FAILURE_LINE.test(line) ? [index] : []);
|
|
8062
|
+
if (signals.length === 0) return null;
|
|
8063
|
+
const fullText = `[exit ${input.exitCode}]
|
|
8064
|
+
${text}`;
|
|
8065
|
+
if (countTextChars(fullText) <= maxChars) return { text: fullText, compaction: NO_COMPACTION_METADATA };
|
|
8066
|
+
const header = `[exit ${input.exitCode}] selected failure details (original line numbers):
|
|
8067
|
+
`;
|
|
8068
|
+
const footer = "\n[other output omitted]";
|
|
8069
|
+
let remaining = maxChars - countTextChars(header + footer);
|
|
8070
|
+
if (remaining < 32) return null;
|
|
8071
|
+
const diagnosticRows = signals.map((index) => {
|
|
8072
|
+
const row = `${index + 1}: ${lines[index]}`;
|
|
8073
|
+
const cost = countTextChars(row) + 1;
|
|
8074
|
+
return { index, row, cost, minimum: Math.min(cost, 64) };
|
|
8075
|
+
});
|
|
8076
|
+
let candidates = diagnosticRows;
|
|
8077
|
+
if (diagnosticRows.reduce((sum, row) => sum + row.minimum, 0) > remaining) {
|
|
8078
|
+
candidates = [];
|
|
8079
|
+
let reserved2 = 0;
|
|
8080
|
+
for (let offset = 0; offset < diagnosticRows.length; offset++) {
|
|
8081
|
+
const index = offset % 2 === 0 ? offset / 2 : diagnosticRows.length - 1 - Math.floor(offset / 2);
|
|
8082
|
+
const row = diagnosticRows[index];
|
|
8083
|
+
if (reserved2 + row.minimum <= remaining) {
|
|
8084
|
+
candidates.push(row);
|
|
8085
|
+
reserved2 += row.minimum;
|
|
8086
|
+
}
|
|
8087
|
+
}
|
|
8088
|
+
candidates.sort((left, right) => left.index - right.index);
|
|
8089
|
+
}
|
|
8090
|
+
const selected = /* @__PURE__ */ new Map();
|
|
8091
|
+
let reserved = candidates.reduce((sum, row) => sum + row.minimum, 0);
|
|
8092
|
+
for (const { index, row, cost, minimum } of candidates) {
|
|
8093
|
+
reserved -= minimum;
|
|
8094
|
+
const allowance = remaining - reserved;
|
|
8095
|
+
if (cost <= allowance) {
|
|
8096
|
+
selected.set(index, row);
|
|
8097
|
+
remaining -= cost;
|
|
8098
|
+
} else {
|
|
8099
|
+
const clipped = clampTextWithMetadata(row, allowance - 1).text;
|
|
8100
|
+
selected.set(index, clipped);
|
|
8101
|
+
remaining -= countTextChars(clipped) + 1;
|
|
8102
|
+
}
|
|
8103
|
+
}
|
|
8104
|
+
for (const index of signals) {
|
|
8105
|
+
if (!selected.has(index)) continue;
|
|
8106
|
+
for (const neighbor of [index - 1, index + 1]) {
|
|
8107
|
+
if (neighbor < 0 || neighbor >= lines.length || selected.has(neighbor)) continue;
|
|
8108
|
+
const row = `${neighbor + 1}: ${lines[neighbor]}`;
|
|
8109
|
+
const cost = countTextChars(row) + 1;
|
|
8110
|
+
if (cost <= remaining) {
|
|
8111
|
+
selected.set(neighbor, row);
|
|
8112
|
+
remaining -= cost;
|
|
8113
|
+
}
|
|
8114
|
+
}
|
|
8115
|
+
}
|
|
8116
|
+
return {
|
|
8117
|
+
text: header + [...selected].sort(([left], [right]) => left - right).map(([, row]) => row).join("\n") + footer,
|
|
8118
|
+
compaction: createCompactionMetadata("failure-signal-filter")
|
|
8119
|
+
};
|
|
8120
|
+
}
|
|
8121
|
+
|
|
7993
8122
|
// src/core/github-actions-summary.ts
|
|
7994
8123
|
var GITHUB_ACTIONS_EXIT_PATTERN = /^Error: Process completed with exit code (\d+)\.?$/u;
|
|
7995
8124
|
var GITHUB_ACTIONS_RUN_PATTERN = /^(?:##\[group\]|::group::)?Run\s+(.+)$/u;
|
|
@@ -8094,7 +8223,8 @@ function shortHash(text) {
|
|
|
8094
8223
|
return createHash2("sha256").update(text).digest("hex").slice(0, 12);
|
|
8095
8224
|
}
|
|
8096
8225
|
function clipMiddleWithHashStrict(text, maxChars, noOmit = false) {
|
|
8097
|
-
|
|
8226
|
+
const segments = segmentTextChars(text);
|
|
8227
|
+
if (segments.length <= maxChars) {
|
|
8098
8228
|
return { text };
|
|
8099
8229
|
}
|
|
8100
8230
|
if (noOmit) {
|
|
@@ -8103,7 +8233,7 @@ function clipMiddleWithHashStrict(text, maxChars, noOmit = false) {
|
|
|
8103
8233
|
compaction: createPassthroughCompactionMetadata("no-omit-char-clip-passthrough")
|
|
8104
8234
|
};
|
|
8105
8235
|
}
|
|
8106
|
-
const omitted =
|
|
8236
|
+
const omitted = segments.length - maxChars;
|
|
8107
8237
|
const marker = `...[${omitted} chars omitted, sha256:${shortHash(text)}]...`;
|
|
8108
8238
|
const markerChars = countTextChars(marker);
|
|
8109
8239
|
if (maxChars <= markerChars) {
|
|
@@ -8116,7 +8246,7 @@ function clipMiddleWithHashStrict(text, maxChars, noOmit = false) {
|
|
|
8116
8246
|
const headChars = Math.ceil(bodyChars * 0.7);
|
|
8117
8247
|
const tailChars = Math.max(0, bodyChars - headChars);
|
|
8118
8248
|
return {
|
|
8119
|
-
text: `${
|
|
8249
|
+
text: `${segments.slice(0, headChars).join("")}${marker}${tailChars > 0 ? segments.slice(-tailChars).join("") : ""}`,
|
|
8120
8250
|
compaction: createCompactionMetadata("hashed-middle-clip")
|
|
8121
8251
|
};
|
|
8122
8252
|
}
|
|
@@ -8150,7 +8280,8 @@ function minifyJsonLexically(rawText) {
|
|
|
8150
8280
|
return output;
|
|
8151
8281
|
}
|
|
8152
8282
|
function clipMiddleWithHash(text, maxChars, noOmit = false) {
|
|
8153
|
-
|
|
8283
|
+
const segments = segmentTextChars(text);
|
|
8284
|
+
if (segments.length <= maxChars) {
|
|
8154
8285
|
return { text };
|
|
8155
8286
|
}
|
|
8156
8287
|
if (noOmit) {
|
|
@@ -8159,11 +8290,11 @@ function clipMiddleWithHash(text, maxChars, noOmit = false) {
|
|
|
8159
8290
|
compaction: createPassthroughCompactionMetadata("no-omit-char-clip-passthrough")
|
|
8160
8291
|
};
|
|
8161
8292
|
}
|
|
8162
|
-
const omitted =
|
|
8293
|
+
const omitted = segments.length - maxChars;
|
|
8163
8294
|
const headChars = Math.max(20, Math.floor(maxChars * 0.55));
|
|
8164
8295
|
const tailChars = Math.max(20, maxChars - headChars);
|
|
8165
8296
|
return {
|
|
8166
|
-
text: `${
|
|
8297
|
+
text: `${segments.slice(0, headChars).join("")} ...[${omitted} chars omitted, sha256:${shortHash(text)}]... ${segments.slice(-tailChars).join("")}`,
|
|
8167
8298
|
compaction: createCompactionMetadata("hashed-middle-clip")
|
|
8168
8299
|
};
|
|
8169
8300
|
}
|
|
@@ -8834,7 +8965,7 @@ function prettyPrintJsonIfPossible(text) {
|
|
|
8834
8965
|
}
|
|
8835
8966
|
return text;
|
|
8836
8967
|
}
|
|
8837
|
-
function applyRule(compiledRule, input, rawText, noOmit = false) {
|
|
8968
|
+
function applyRule(compiledRule, input, rawText, noOmit = false, maxInlineChars = 1200) {
|
|
8838
8969
|
const rule = compiledRule.rule;
|
|
8839
8970
|
if (rule.transforms?.prettyPrintJson) {
|
|
8840
8971
|
rawText = prettyPrintJsonIfPossible(rawText);
|
|
@@ -8852,13 +8983,14 @@ function applyRule(compiledRule, input, rawText, noOmit = false) {
|
|
|
8852
8983
|
}
|
|
8853
8984
|
const outputMatchText = trimEmptyEdges(lines).join("\n");
|
|
8854
8985
|
const matchedOutput = compiledRule.compiled.outputMatches.find((entry) => entry.pattern.test(outputMatchText));
|
|
8855
|
-
if (!noOmit && matchedOutput) {
|
|
8986
|
+
if (!noOmit && input.exitCode === 0 && matchedOutput) {
|
|
8856
8987
|
return {
|
|
8857
8988
|
summary: matchedOutput.message,
|
|
8858
8989
|
facts,
|
|
8859
|
-
compaction: NO_COMPACTION_METADATA
|
|
8990
|
+
compaction: matchedOutput.message === outputMatchText ? NO_COMPACTION_METADATA : createCompactionMetadata("rule-output-replacement")
|
|
8860
8991
|
};
|
|
8861
8992
|
}
|
|
8993
|
+
const unfilteredLineCount = lines.length;
|
|
8862
8994
|
if (!noOmit && rule.filters?.skipPatterns?.length) {
|
|
8863
8995
|
lines = lines.filter((line) => !compiledRule.compiled.skipPatterns.some((pattern) => pattern.test(line)));
|
|
8864
8996
|
}
|
|
@@ -8869,6 +9001,9 @@ function applyRule(compiledRule, input, rawText, noOmit = false) {
|
|
|
8869
9001
|
lines = kept;
|
|
8870
9002
|
}
|
|
8871
9003
|
}
|
|
9004
|
+
if (lines.length < unfilteredLineCount) {
|
|
9005
|
+
rewriteCompaction = mergeCompactionMetadata(rewriteCompaction, createCompactionMetadata("rule-line-filter"));
|
|
9006
|
+
}
|
|
8872
9007
|
if (rule.transforms?.trimEmptyEdges) {
|
|
8873
9008
|
counterLines = trimEmptyEdges(counterLines);
|
|
8874
9009
|
lines = trimEmptyEdges(lines);
|
|
@@ -8888,11 +9023,6 @@ function applyRule(compiledRule, input, rawText, noOmit = false) {
|
|
|
8888
9023
|
lines = rewritten.lines;
|
|
8889
9024
|
rewriteCompaction = mergeCompactionMetadata(rewriteCompaction, rewritten.compaction);
|
|
8890
9025
|
}
|
|
8891
|
-
if (rule.id === "search/rg") {
|
|
8892
|
-
const rewritten = rewriteSearchLines(lines, noOmit);
|
|
8893
|
-
lines = rewritten.lines;
|
|
8894
|
-
rewriteCompaction = mergeCompactionMetadata(rewriteCompaction, rewritten.compaction);
|
|
8895
|
-
}
|
|
8896
9026
|
if (rule.id === "git/diff") {
|
|
8897
9027
|
const rewritten = rewriteGitDiffLines(lines, noOmit);
|
|
8898
9028
|
lines = rewritten.lines;
|
|
@@ -8906,6 +9036,18 @@ function applyRule(compiledRule, input, rawText, noOmit = false) {
|
|
|
8906
9036
|
}
|
|
8907
9037
|
facts[counter.name] = factLines.filter((line) => pattern.test(line)).length;
|
|
8908
9038
|
}
|
|
9039
|
+
const searchFits = rule.family === "search" && countTextChars(formatInline(
|
|
9040
|
+
{ family: rule.family, matchedReducer: rule.id },
|
|
9041
|
+
input,
|
|
9042
|
+
lines.join("\n"),
|
|
9043
|
+
facts,
|
|
9044
|
+
noOmit
|
|
9045
|
+
)) <= maxInlineChars;
|
|
9046
|
+
if (rule.id === "search/rg" && !searchFits) {
|
|
9047
|
+
const rewritten = rewriteSearchLines(lines, noOmit);
|
|
9048
|
+
lines = rewritten.lines;
|
|
9049
|
+
rewriteCompaction = mergeCompactionMetadata(rewriteCompaction, rewritten.compaction);
|
|
9050
|
+
}
|
|
8909
9051
|
if (lines.length === 0 && rule.onEmpty) {
|
|
8910
9052
|
return {
|
|
8911
9053
|
summary: rule.onEmpty,
|
|
@@ -8920,7 +9062,7 @@ function applyRule(compiledRule, input, rawText, noOmit = false) {
|
|
|
8920
9062
|
head: rule.summarize?.head ?? 6,
|
|
8921
9063
|
tail: rule.summarize?.tail ?? 6
|
|
8922
9064
|
};
|
|
8923
|
-
const compacted = headTail(lines, summarize.head, summarize.tail, noOmit);
|
|
9065
|
+
const compacted = searchFits ? { lines, compaction: NO_COMPACTION_METADATA } : headTail(lines, summarize.head, summarize.tail, noOmit);
|
|
8924
9066
|
return {
|
|
8925
9067
|
summary: compacted.lines.join("\n").trim(),
|
|
8926
9068
|
facts,
|
|
@@ -8990,9 +9132,8 @@ function formatInline(classification, input, summary, facts, noOmit = false) {
|
|
|
8990
9132
|
lines.push(summary);
|
|
8991
9133
|
return lines.join("\n").trim();
|
|
8992
9134
|
}
|
|
8993
|
-
function selectInlineText(classification, input, rawText, compactText, maxInlineChars, compactCompaction, noOmit = false) {
|
|
9135
|
+
function selectInlineText(classification, input, rawText, rawChars, compactText, maxInlineChars, compactCompaction, noOmit = false) {
|
|
8994
9136
|
const passthroughText = buildPassthroughText(input, rawText);
|
|
8995
|
-
const rawChars = countTextChars(stripAnsi(rawText));
|
|
8996
9137
|
const compactChars = countTextChars(compactText);
|
|
8997
9138
|
if (noOmit) {
|
|
8998
9139
|
return {
|
|
@@ -9019,13 +9160,14 @@ function selectInlineText(classification, input, rawText, compactText, maxInline
|
|
|
9019
9160
|
};
|
|
9020
9161
|
}
|
|
9021
9162
|
const passthroughLimit = classification.family === "help" ? maxInlineChars : TINY_OUTPUT_MAX_CHARS;
|
|
9022
|
-
|
|
9163
|
+
const passthroughChars = countTextChars(passthroughText);
|
|
9164
|
+
if (passthroughChars > passthroughLimit) {
|
|
9023
9165
|
return {
|
|
9024
9166
|
text: compactText,
|
|
9025
9167
|
compaction: compactCompaction
|
|
9026
9168
|
};
|
|
9027
9169
|
}
|
|
9028
|
-
if (
|
|
9170
|
+
if (passthroughChars <= compactChars) {
|
|
9029
9171
|
return {
|
|
9030
9172
|
text: passthroughText,
|
|
9031
9173
|
compaction: NO_COMPACTION_METADATA
|
|
@@ -9188,9 +9330,9 @@ async function reduceExecutionWithRules(input, rules, opts = {}) {
|
|
|
9188
9330
|
if (!matchedRule) {
|
|
9189
9331
|
throw new Error("missing generic fallback rule");
|
|
9190
9332
|
}
|
|
9191
|
-
const
|
|
9192
|
-
if (
|
|
9193
|
-
const inlineText2 = clampTextMiddleWithMetadata(
|
|
9333
|
+
const failureSummary = classification.matchedReducer === "generic/fallback" ? buildGithubActionsFailureSummary(reducerInput, rawText, opts.noOmit) ?? buildFailureSummary(reducerInput, rawText, maxInlineChars, opts.noOmit) : null;
|
|
9334
|
+
if (failureSummary) {
|
|
9335
|
+
const inlineText2 = clampTextMiddleWithMetadata(failureSummary.text, maxInlineChars, opts.noOmit);
|
|
9194
9336
|
const reducedChars2 = countTextChars(inlineText2.text);
|
|
9195
9337
|
const stats2 = {
|
|
9196
9338
|
rawChars: measuredRawChars,
|
|
@@ -9220,8 +9362,8 @@ async function reduceExecutionWithRules(input, rules, opts = {}) {
|
|
|
9220
9362
|
}
|
|
9221
9363
|
return {
|
|
9222
9364
|
inlineText: inlineText2.text,
|
|
9223
|
-
previewText:
|
|
9224
|
-
compaction: mergeCompactionMetadata(
|
|
9365
|
+
previewText: failureSummary.text,
|
|
9366
|
+
compaction: mergeCompactionMetadata(failureSummary.compaction, inlineText2.compaction),
|
|
9225
9367
|
...trace ? { trace } : {},
|
|
9226
9368
|
...rawRef2 ? { rawRef: rawRef2 } : {},
|
|
9227
9369
|
stats: stats2,
|
|
@@ -9275,7 +9417,7 @@ async function reduceExecutionWithRules(input, rules, opts = {}) {
|
|
|
9275
9417
|
};
|
|
9276
9418
|
}
|
|
9277
9419
|
}
|
|
9278
|
-
const { summary, facts, compaction } = applyRule(matchedRule, reducerInput, rawText, opts.noOmit);
|
|
9420
|
+
const { summary, facts, compaction } = applyRule(matchedRule, reducerInput, rawText, opts.noOmit, maxInlineChars);
|
|
9279
9421
|
const compactText = formatInline(
|
|
9280
9422
|
classification,
|
|
9281
9423
|
reducerInput,
|
|
@@ -9283,7 +9425,7 @@ async function reduceExecutionWithRules(input, rules, opts = {}) {
|
|
|
9283
9425
|
facts,
|
|
9284
9426
|
opts.noOmit
|
|
9285
9427
|
);
|
|
9286
|
-
const selectedText = selectInlineText(classification, reducerInput, rawText, compactText, maxInlineChars, compaction, opts.noOmit);
|
|
9428
|
+
const selectedText = selectInlineText(classification, reducerInput, rawText, measuredRawChars, compactText, maxInlineChars, compaction, opts.noOmit);
|
|
9287
9429
|
const clamp = classification.family === "help" || selectedText.text.includes("\n") ? clampTextMiddleWithMetadata : clampTextWithMetadata;
|
|
9288
9430
|
const inlineText = clamp(selectedText.text, maxInlineChars, opts.noOmit);
|
|
9289
9431
|
const reducedChars = countTextChars(inlineText.text);
|
|
@@ -17,11 +17,13 @@ compact-shell-result` subprocess. It never executes the command supplied in the
|
|
|
17
17
|
hook payload. Only successful foreground output is eligible; failures, background
|
|
18
18
|
polls, exact file reads, and explicit raw requests retain their original output.
|
|
19
19
|
Missing executables, invalid responses, inputs over 2 MB, and five-second timeouts
|
|
20
|
-
also preserve the original output
|
|
20
|
+
also preserve the original output; launch failures, nonzero exits, timeouts and
|
|
21
|
+
invalid responses log one `tokenjuice` warning per process.
|
|
21
22
|
|
|
22
23
|
The CLI reads tokenjuice's local configuration and rules. Bridge calls disable
|
|
23
24
|
statistics and require no credentials or network service. Keep `tokenjuice` on
|
|
24
|
-
PATH, or set `TOKENJUICE_BIN` to its executable path.
|
|
25
|
+
PATH, or set `TOKENJUICE_BIN` to its executable path. On Windows, the bridge
|
|
26
|
+
resolves npm's `tokenjuice.cmd` shim from absolute PATH entries. No Hermes permissions are
|
|
25
27
|
changed. Disable with `hermes plugins disable tokenjuice`; remove with
|
|
26
28
|
`hermes plugins remove tokenjuice`.
|
|
27
29
|
|