@openclaw/tokenjuice 2026.9.4 → 2026.9.5
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/assets/activity.svg +3 -0
- package/assets/icon.png +0 -0
- package/node_modules/tokenjuice/README.md +6 -1
- package/node_modules/tokenjuice/dist/cli/install-output.d.ts +7 -0
- package/node_modules/tokenjuice/dist/cli/install-output.js +19 -0
- package/node_modules/tokenjuice/dist/cli/main.d.ts +4 -0
- package/node_modules/tokenjuice/dist/cli/main.js +143 -26
- package/node_modules/tokenjuice/dist/core/artifacts.d.ts +1 -0
- package/node_modules/tokenjuice/dist/core/artifacts.js +29 -0
- package/node_modules/tokenjuice/dist/core/compaction-metadata.d.ts +1 -1
- package/node_modules/tokenjuice/dist/core/integrations/compact-bash-result.d.ts +1 -0
- package/node_modules/tokenjuice/dist/core/integrations/compact-bash-result.js +1 -1
- package/node_modules/tokenjuice/dist/core/reduce.js +18 -10
- package/node_modules/tokenjuice/dist/core/text.d.ts +4 -0
- package/node_modules/tokenjuice/dist/core/text.js +32 -0
- package/node_modules/tokenjuice/dist/hosts/codex/index.d.ts +25 -1
- package/node_modules/tokenjuice/dist/hosts/codex/index.js +211 -163
- package/node_modules/tokenjuice/dist/hosts/grok-bot/index.d.ts +25 -0
- package/node_modules/tokenjuice/dist/hosts/grok-bot/index.js +644 -0
- package/node_modules/tokenjuice/dist/hosts/opencode/extension/runtime.js +79 -10
- package/node_modules/tokenjuice/dist/hosts/pi/extension/runtime.js +79 -10
- package/node_modules/tokenjuice/dist/hosts/shared/hook-command-doctor.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/shared/hook-command-doctor.js +80 -1
- package/node_modules/tokenjuice/dist/hosts/shared/hook-command.d.ts +19 -0
- package/node_modules/tokenjuice/dist/hosts/shared/hook-command.js +61 -6
- package/node_modules/tokenjuice/dist/hosts/shared/hook-doctor.d.ts +3 -1
- package/node_modules/tokenjuice/dist/hosts/shared/hook-doctor.js +2 -0
- package/node_modules/tokenjuice/dist/hosts/shared/host-command.d.ts +10 -1
- package/node_modules/tokenjuice/dist/hosts/shared/host-command.js +43 -4
- package/node_modules/tokenjuice/dist/hosts/shared/pre-tool-wrap.js +9 -7
- package/node_modules/tokenjuice/dist/index.d.ts +2 -0
- package/node_modules/tokenjuice/dist/index.js +1 -0
- package/node_modules/tokenjuice/package.json +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +8 -6
package/assets/icon.png
ADDED
|
Binary file
|
|
@@ -80,6 +80,7 @@ beta integrations:
|
|
|
80
80
|
| <img width="48px" src="docs/client-goose.svg" alt="Goose" /> | [Goose](https://goose-docs.ai/) | `tokenjuice install goose` | `.goosehints` |
|
|
81
81
|
| <img width="48px" src="docs/client-greptile.svg" alt="Greptile" /> | [Greptile](https://www.greptile.com/docs/code-review/greptile-config) | `tokenjuice install greptile` | `.greptile/rules.md` |
|
|
82
82
|
| <img width="48px" src="docs/client-grok-build.svg" alt="Grok Build" /> | [Grok Build](https://docs.x.ai/build/overview) | `tokenjuice install grok-build` | `AGENTS.md` |
|
|
83
|
+
| <img width="48px" src="docs/client-grok-bot.svg" alt="Grok Bot" /> | Grok Bot | `tokenjuice install grok-bot` | `.cursor/rules/tokenjuice.mdc` |
|
|
83
84
|
| <img width="48px" src="docs/client-grok-cli.svg" alt="Grok CLI" /> | [Grok CLI](https://github.com/superagent-ai/grok-cli) | `tokenjuice install grok-cli` | `~/.grok/user-settings.json` |
|
|
84
85
|
| <img width="48px" src="docs/client-gptme.svg" alt="gptme" /> | [gptme](https://gptme.org/docs/prompts.html) | `tokenjuice install gptme` | `AGENTS.md` |
|
|
85
86
|
| <img width="48px" src="docs/client-copilot.png" alt="GitHub Copilot coding agent" /> | [GitHub Copilot coding agent](https://docs.github.com/en/copilot/using-github-copilot/coding-agent) | `tokenjuice install copilot-agent` | `.github/hooks/tokenjuice-agent.json` |
|
|
@@ -130,11 +131,15 @@ npm install -g tokenjuice
|
|
|
130
131
|
pnpm add -g tokenjuice
|
|
131
132
|
# or
|
|
132
133
|
yarn global add tokenjuice
|
|
133
|
-
# or
|
|
134
|
+
# or (the vincentkoc/tap alias maps to github.com/vincentkoc/homebrew-tap)
|
|
134
135
|
brew tap vincentkoc/tap
|
|
135
136
|
brew install tokenjuice
|
|
136
137
|
```
|
|
137
138
|
|
|
139
|
+
Homebrew publication is owned by the Tokenjuice workflow in the canonical
|
|
140
|
+
`vincentkoc/homebrew-tap` repository. Release maintainers dispatch it manually
|
|
141
|
+
with the published tag until GitHub App automation lands.
|
|
142
|
+
|
|
138
143
|
then:
|
|
139
144
|
|
|
140
145
|
```bash
|
|
@@ -2,4 +2,11 @@ export type InstallOutputDetail = {
|
|
|
2
2
|
label: string;
|
|
3
3
|
value: string;
|
|
4
4
|
};
|
|
5
|
+
export type CodeBuddyInstallOutput = {
|
|
6
|
+
settingsPath: string;
|
|
7
|
+
command: string;
|
|
8
|
+
backupPath?: string;
|
|
9
|
+
local: boolean;
|
|
10
|
+
};
|
|
5
11
|
export declare function formatInstallSuccess(target: string, noun: string, details: InstallOutputDetail[]): string;
|
|
12
|
+
export declare function formatCodeBuddyInstallSuccess(result: CodeBuddyInstallOutput): string;
|
|
@@ -9,3 +9,22 @@ export function formatInstallSuccess(target, noun, details) {
|
|
|
9
9
|
}
|
|
10
10
|
return `${lines.join("\n")}\n`;
|
|
11
11
|
}
|
|
12
|
+
export function formatCodeBuddyInstallSuccess(result) {
|
|
13
|
+
const doctorCommand = `tokenjuice doctor codebuddy${result.local ? " --local" : ""}`;
|
|
14
|
+
const details = [
|
|
15
|
+
{ label: "Settings", value: result.settingsPath },
|
|
16
|
+
{ label: "Command", value: result.command },
|
|
17
|
+
{
|
|
18
|
+
label: "Activate",
|
|
19
|
+
value: "open /hooks and review the external change for this session, or start a new CodeBuddy session",
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
label: "Verify",
|
|
23
|
+
value: `${doctorCommand} (persisted config only; not active-session activation)`,
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
if (result.backupPath) {
|
|
27
|
+
details.push({ label: "Backup", value: result.backupPath });
|
|
28
|
+
}
|
|
29
|
+
return formatInstallSuccess("codebuddy", "hook", details);
|
|
30
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import type { StatsSourceReport } from "../core/analysis.js";
|
|
2
3
|
import type { WrapResult } from "../types.js";
|
|
3
4
|
type Format = "text" | "json";
|
|
4
5
|
type ParsedArgs = {
|
|
@@ -14,6 +15,7 @@ type ParsedArgs = {
|
|
|
14
15
|
tee: boolean;
|
|
15
16
|
raw: boolean;
|
|
16
17
|
noOmit: boolean;
|
|
18
|
+
allowOmit: boolean;
|
|
17
19
|
storeDir: string | undefined;
|
|
18
20
|
maxInlineChars: number | undefined;
|
|
19
21
|
maxCaptureBytes: number | undefined;
|
|
@@ -30,5 +32,7 @@ type ParsedArgs = {
|
|
|
30
32
|
export declare function parseArgs(argv: string[]): ParsedArgs;
|
|
31
33
|
export declare function resolveNoOmit(noOmitFlag: boolean, env?: NodeJS.ProcessEnv): boolean;
|
|
32
34
|
export declare function decorateWrapInlineText(result: WrapResult["result"], raw: boolean): string;
|
|
35
|
+
export declare function formatStatsSources(sources: StatsSourceReport[]): string;
|
|
36
|
+
export declare function main(argv?: string[]): Promise<number>;
|
|
33
37
|
export declare function isDirectModuleEntrypoint(moduleUrl: string | URL, argv?: string[]): Promise<boolean>;
|
|
34
38
|
export {};
|
|
@@ -12,6 +12,7 @@ import { parseReduceJsonRequest } from "../core/json-protocol.js";
|
|
|
12
12
|
import { WRAP_AUTHORITATIVE_FOOTER } from "../core/compaction-metadata.js";
|
|
13
13
|
import { reduceExecution } from "../core/reduce.js";
|
|
14
14
|
import { verifyRules } from "../core/rules.js";
|
|
15
|
+
import { UNKNOWN_ARTIFACT_SOURCE } from "../core/source.js";
|
|
15
16
|
import { runWrappedCommand } from "../core/wrap.js";
|
|
16
17
|
import { doctorAdalInstructions, installAdalInstructions, uninstallAdalInstructions } from "../hosts/adal/index.js";
|
|
17
18
|
import { doctorAetherPrompt, installAetherPrompt, uninstallAetherPrompt } from "../hosts/aether/index.js";
|
|
@@ -50,7 +51,7 @@ import { doctorCodeRabbitConfig, installCodeRabbitConfig, uninstallCodeRabbitCon
|
|
|
50
51
|
import { doctorCodeBuddyHook, installCodeBuddyHook, runCodeBuddyPreToolUseHook, uninstallCodeBuddyHook } from "../hosts/codebuddy/index.js";
|
|
51
52
|
import { doctorCommandCodeHook, installCommandCodeHook, runCommandCodePostToolUseHook, uninstallCommandCodeHook } from "../hosts/command-code/index.js";
|
|
52
53
|
import { doctorContinueRule, installContinueRule, uninstallContinueRule } from "../hosts/continue/index.js";
|
|
53
|
-
import { doctorCodexHook, installCodexHook, runCodexPostToolUseHook, uninstallCodexHook } from "../hosts/codex/index.js";
|
|
54
|
+
import { doctorCodexHook, installCodexHook, runCodexPostToolUseHook, uninstallCodexHook, } from "../hosts/codex/index.js";
|
|
54
55
|
import { doctorCopilotAgentHook, installCopilotAgentHook, runCopilotAgentPostToolUseHook, uninstallCopilotAgentHook } from "../hosts/copilot-agent/index.js";
|
|
55
56
|
import { doctorCopilotCliHook, getCopilotCliInstructionsSnippet, installCopilotCliHook, runCopilotCliPostToolUseHook, uninstallCopilotCliHook, } from "../hosts/copilot-cli/index.js";
|
|
56
57
|
import { doctorCrushSkill, installCrushSkill, uninstallCrushSkill } from "../hosts/crush/index.js";
|
|
@@ -69,6 +70,7 @@ import { doctorGitLabDuoRule, installGitLabDuoRule, uninstallGitLabDuoRule } fro
|
|
|
69
70
|
import { doctorGooseHints, installGooseHints, uninstallGooseHints } from "../hosts/goose/index.js";
|
|
70
71
|
import { doctorGreptileRule, installGreptileRule, uninstallGreptileRule } from "../hosts/greptile/index.js";
|
|
71
72
|
import { doctorGrokBuildInstructions, installGrokBuildInstructions, uninstallGrokBuildInstructions } from "../hosts/grok-build/index.js";
|
|
73
|
+
import { doctorGrokBotRule, installGrokBotRule, uninstallGrokBotRule } from "../hosts/grok-bot/index.js";
|
|
72
74
|
import { doctorGrokCliHook, installGrokCliHook, runGrokCliPostToolUseHook, uninstallGrokCliHook } from "../hosts/grok-cli/index.js";
|
|
73
75
|
import { doctorGptmeInstructions, installGptmeInstructions, uninstallGptmeInstructions } from "../hosts/gptme/index.js";
|
|
74
76
|
import { doctorJean2Instructions, installJean2Instructions, uninstallJean2Instructions } from "../hosts/jean2/index.js";
|
|
@@ -115,7 +117,7 @@ import { doctorZencoderRule, installZencoderRule, uninstallZencoderRule } from "
|
|
|
115
117
|
import { doctorInstalledHooks } from "../hosts/shared/hook-doctor.js";
|
|
116
118
|
import { shellQuote } from "../hosts/shared/hook-command.js";
|
|
117
119
|
import { formatHookDoctorReport } from "./doctor-output.js";
|
|
118
|
-
import { formatInstallSuccess } from "./install-output.js";
|
|
120
|
+
import { formatCodeBuddyInstallSuccess, formatInstallSuccess } from "./install-output.js";
|
|
119
121
|
function formatPlandexLoadCommand(conventionPath) {
|
|
120
122
|
const loadPath = relative(process.cwd(), conventionPath) || "PLANDEX.tokenjuice.md";
|
|
121
123
|
return `plandex load ${shellQuote(loadPath)}`;
|
|
@@ -162,7 +164,7 @@ function printUsage() {
|
|
|
162
164
|
" tokenjuice install bob",
|
|
163
165
|
" tokenjuice install builder",
|
|
164
166
|
" tokenjuice install charlie",
|
|
165
|
-
" tokenjuice install codex [--local]",
|
|
167
|
+
" tokenjuice install codex [--local] [--no-omit]",
|
|
166
168
|
" tokenjuice install claude-code [--local]",
|
|
167
169
|
" tokenjuice install cline [--local]",
|
|
168
170
|
" tokenjuice install codeant",
|
|
@@ -190,6 +192,7 @@ function printUsage() {
|
|
|
190
192
|
" tokenjuice install goose",
|
|
191
193
|
" tokenjuice install greptile",
|
|
192
194
|
" tokenjuice install grok-build",
|
|
195
|
+
" tokenjuice install grok-bot",
|
|
193
196
|
" tokenjuice install grok-cli [--local]",
|
|
194
197
|
" tokenjuice install gptme",
|
|
195
198
|
" tokenjuice install jean2",
|
|
@@ -289,6 +292,7 @@ function printUsage() {
|
|
|
289
292
|
" tokenjuice uninstall goose",
|
|
290
293
|
" tokenjuice uninstall greptile",
|
|
291
294
|
" tokenjuice uninstall grok-build",
|
|
295
|
+
" tokenjuice uninstall grok-bot",
|
|
292
296
|
" tokenjuice uninstall grok-cli",
|
|
293
297
|
" tokenjuice uninstall gptme",
|
|
294
298
|
" tokenjuice uninstall jean2",
|
|
@@ -337,7 +341,8 @@ function printUsage() {
|
|
|
337
341
|
" tokenjuice cat <artifact-id>",
|
|
338
342
|
" tokenjuice verify [--fixtures]",
|
|
339
343
|
" tokenjuice discover [file] [--source-command <cmd>] [--tool-name <name>] [--exit-code <n>] [--source <name>] [--by-source]",
|
|
340
|
-
" tokenjuice doctor [file|hooks|adal|aether|aictl|ai-memory-protocol|aider|agent-layer|agentinit|agentlink|agentloom|agents-cli|agents-md|agentsge|agentsmesh|amazon-q|amp|antigravity|anywhere-agents|augment|avante|baz|bito|blackbox|blocks|clawdbot|bob|builder|charlie|codex|claude-code|cline|codeant|codebuff|codegen|coder-agents|coderabbit|codebuddy|command-code|continue|copilot-agent|crush|cursor|deepagents|devin|dot-agents|docker-agent|droid|eca|elyra|firebase-studio|forgecode|gemini-cli|gitlab-duo|goose|greptile|grok-build|grok-cli|gptme|jean2|jetbrains-ai|junie|jules|leanctl|kimi|kiro|kilo|localcode|mcp-agent|mini-swe-agent|swe-agent|stagewise|mistral-vibe|mux|novakit|knowns|ona|openhands|open-interpreter|openwebui|pi|pi-go|opencode|plandex|qodo|qoder|qwen-code|replit|roo|rovo|ruler|tabby|tabnine|trae|uipath|vscode-copilot|warp|windsurf|zed|zencoder|copilot-cli] [--local] [--print-instructions] [--source-command <cmd>] [--tool-name <name>] [--exit-code <n>]",
|
|
344
|
+
" tokenjuice doctor [file|hooks|adal|aether|aictl|ai-memory-protocol|aider|agent-layer|agentinit|agentlink|agentloom|agents-cli|agents-md|agentsge|agentsmesh|amazon-q|amp|antigravity|anywhere-agents|augment|avante|baz|bito|blackbox|blocks|clawdbot|bob|builder|charlie|codex|claude-code|cline|codeant|codebuff|codegen|coder-agents|coderabbit|codebuddy|command-code|continue|copilot-agent|crush|cursor|deepagents|devin|dot-agents|docker-agent|droid|eca|elyra|firebase-studio|forgecode|gemini-cli|gitlab-duo|goose|greptile|grok-build|grok-bot|grok-cli|gptme|jean2|jetbrains-ai|junie|jules|leanctl|kimi|kiro|kilo|localcode|mcp-agent|mini-swe-agent|swe-agent|stagewise|mistral-vibe|mux|novakit|knowns|ona|openhands|open-interpreter|openwebui|pi|pi-go|opencode|plandex|qodo|qoder|qwen-code|replit|roo|rovo|ruler|tabby|tabnine|trae|uipath|vscode-copilot|warp|windsurf|zed|zencoder|copilot-cli] [--local] [--print-instructions] [--source-command <cmd>] [--tool-name <name>] [--exit-code <n>]",
|
|
345
|
+
" tokenjuice doctor codex [--local] [--no-omit]",
|
|
341
346
|
" tokenjuice stats [--timezone local|utc|<iana-timezone>] [--source <name>] [--by-source]",
|
|
342
347
|
].join("\n"));
|
|
343
348
|
process.stderr.write("\n");
|
|
@@ -357,6 +362,7 @@ export function parseArgs(argv) {
|
|
|
357
362
|
let tee = false;
|
|
358
363
|
let raw = false;
|
|
359
364
|
let noOmit = false;
|
|
365
|
+
let allowOmit = false;
|
|
360
366
|
let storeDir;
|
|
361
367
|
let maxInlineChars;
|
|
362
368
|
let maxCaptureBytes;
|
|
@@ -437,6 +443,10 @@ export function parseArgs(argv) {
|
|
|
437
443
|
noOmit = true;
|
|
438
444
|
index += 1;
|
|
439
445
|
break;
|
|
446
|
+
case "--allow-omit":
|
|
447
|
+
allowOmit = true;
|
|
448
|
+
index += 1;
|
|
449
|
+
break;
|
|
440
450
|
case "--tee":
|
|
441
451
|
tee = true;
|
|
442
452
|
index += 1;
|
|
@@ -506,6 +516,12 @@ export function parseArgs(argv) {
|
|
|
506
516
|
throw new Error(`unknown flag: ${current}`);
|
|
507
517
|
}
|
|
508
518
|
}
|
|
519
|
+
if (noOmit && allowOmit) {
|
|
520
|
+
throw new Error("--no-omit and --allow-omit cannot be used together");
|
|
521
|
+
}
|
|
522
|
+
if (allowOmit && (command === "install" || command === "doctor")) {
|
|
523
|
+
throw new Error("--allow-omit is not supported for install or doctor; Codex hooks honor the configured omission policy");
|
|
524
|
+
}
|
|
509
525
|
return {
|
|
510
526
|
command,
|
|
511
527
|
format,
|
|
@@ -519,6 +535,7 @@ export function parseArgs(argv) {
|
|
|
519
535
|
tee,
|
|
520
536
|
raw,
|
|
521
537
|
noOmit,
|
|
538
|
+
allowOmit,
|
|
522
539
|
storeDir,
|
|
523
540
|
maxInlineChars,
|
|
524
541
|
maxCaptureBytes,
|
|
@@ -549,6 +566,25 @@ async function readStdin(maxBytes = DEFAULT_MAX_INPUT_BYTES) {
|
|
|
549
566
|
}
|
|
550
567
|
return Buffer.concat(chunks).toString("utf8");
|
|
551
568
|
}
|
|
569
|
+
async function readStdinForCodexHook(maxBytes = DEFAULT_MAX_INPUT_BYTES) {
|
|
570
|
+
if (inputStdin.isTTY) {
|
|
571
|
+
return "";
|
|
572
|
+
}
|
|
573
|
+
const chunks = [];
|
|
574
|
+
let totalBytes = 0;
|
|
575
|
+
let exceededLimit = false;
|
|
576
|
+
for await (const chunk of inputStdin) {
|
|
577
|
+
const buffer = Buffer.from(chunk);
|
|
578
|
+
totalBytes += buffer.length;
|
|
579
|
+
if (totalBytes > maxBytes) {
|
|
580
|
+
exceededLimit = true;
|
|
581
|
+
continue;
|
|
582
|
+
}
|
|
583
|
+
chunks.push(buffer);
|
|
584
|
+
}
|
|
585
|
+
// Drain stdin so Tokenjuice exits cleanly instead of failing on oversized hook input.
|
|
586
|
+
return exceededLimit ? undefined : Buffer.concat(chunks).toString("utf8");
|
|
587
|
+
}
|
|
552
588
|
async function readTextInput(file, maxBytes = DEFAULT_MAX_INPUT_BYTES) {
|
|
553
589
|
if (!file) {
|
|
554
590
|
return await readStdin(maxBytes);
|
|
@@ -1170,7 +1206,10 @@ async function runInstall(args) {
|
|
|
1170
1206
|
return 0;
|
|
1171
1207
|
}
|
|
1172
1208
|
if (target === "codex") {
|
|
1173
|
-
const result = await installCodexHook(undefined, {
|
|
1209
|
+
const result = await installCodexHook(undefined, {
|
|
1210
|
+
local: args.local,
|
|
1211
|
+
...(args.noOmit ? { noOmit: true } : {}),
|
|
1212
|
+
});
|
|
1174
1213
|
if (args.format === "json") {
|
|
1175
1214
|
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
1176
1215
|
return 0;
|
|
@@ -1309,12 +1348,7 @@ async function runInstall(args) {
|
|
|
1309
1348
|
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
1310
1349
|
return 0;
|
|
1311
1350
|
}
|
|
1312
|
-
process.stdout.write(
|
|
1313
|
-
process.stdout.write(`command: ${result.command}\n`);
|
|
1314
|
-
if (result.backupPath) {
|
|
1315
|
-
process.stdout.write(`backup: ${result.backupPath}\n`);
|
|
1316
|
-
}
|
|
1317
|
-
process.stdout.write(`doctor: tokenjuice doctor hooks${args.local ? " --local" : ""}\n`);
|
|
1351
|
+
process.stdout.write(formatCodeBuddyInstallSuccess({ ...result, local: args.local }));
|
|
1318
1352
|
return 0;
|
|
1319
1353
|
}
|
|
1320
1354
|
if (target === "command-code" || target === "commandcode") {
|
|
@@ -1667,6 +1701,24 @@ async function runInstall(args) {
|
|
|
1667
1701
|
process.stdout.write(formatInstallSuccess("grok-build", "instructions", details));
|
|
1668
1702
|
return 0;
|
|
1669
1703
|
}
|
|
1704
|
+
if (target === "grok-bot" || target === "grokbot") {
|
|
1705
|
+
const result = await installGrokBotRule();
|
|
1706
|
+
if (args.format === "json") {
|
|
1707
|
+
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
1708
|
+
return 0;
|
|
1709
|
+
}
|
|
1710
|
+
const details = [
|
|
1711
|
+
{ label: "Rule", value: result.rulePath },
|
|
1712
|
+
{ label: "Beta", value: ".cursor/rules guidance; Grok Bot still owns execution and output delivery" },
|
|
1713
|
+
{ label: "Verify", value: "tokenjuice doctor grok-bot" },
|
|
1714
|
+
{ label: "Escape hatch", value: "tokenjuice wrap --raw -- <command>" },
|
|
1715
|
+
];
|
|
1716
|
+
if (result.backupPath) {
|
|
1717
|
+
details.push({ label: "Backup", value: result.backupPath });
|
|
1718
|
+
}
|
|
1719
|
+
process.stdout.write(formatInstallSuccess("grok-bot", "rule", details));
|
|
1720
|
+
return 0;
|
|
1721
|
+
}
|
|
1670
1722
|
if (target === "goose") {
|
|
1671
1723
|
const result = await installGooseHints();
|
|
1672
1724
|
if (args.format === "json") {
|
|
@@ -2501,7 +2553,7 @@ async function runInstall(args) {
|
|
|
2501
2553
|
process.stdout.write(formatInstallSuccess("zencoder", "rule", details));
|
|
2502
2554
|
return 0;
|
|
2503
2555
|
}
|
|
2504
|
-
throw new Error("install currently supports: adal, aether, aictl, ai-memory-protocol, aider, agent-layer, agentinit, agentlink, agentloom, agents-cli, agents-md, agentsge, agentsmesh, amazon-q, amp, antigravity, anywhere-agents, augment, avante, baz, bito, blackbox, blocks, clawdbot, bob, builder, charlie, codex, claude-code, cline, codeant, codebuff, codegen, coder-agents, coderabbit, codebuddy, command-code, continue, copilot-agent, crush, cursor, deepagents, devin, dot-agents, docker-agent, droid, eca, elyra, firebase-studio, forgecode, gemini-cli, gitlab-duo, goose, greptile, grok-build, grok-cli, gptme, jean2, jetbrains-ai, junie, jules, leanctl, kimi, kiro, kilo, knowns, localcode, mcp-agent, mini-swe-agent, swe-agent, stagewise, mistral-vibe, mux, novakit, ona, openhands, open-interpreter, openwebui, pi, pi-go, opencode, plandex, qodo, qoder, replit, qwen-code, roo, rovo, ruler, tabby, tabnine, trae, uipath, vscode-copilot, warp, windsurf, copilot-cli, zed, zencoder");
|
|
2556
|
+
throw new Error("install currently supports: adal, aether, aictl, ai-memory-protocol, aider, agent-layer, agentinit, agentlink, agentloom, agents-cli, agents-md, agentsge, agentsmesh, amazon-q, amp, antigravity, anywhere-agents, augment, avante, baz, bito, blackbox, blocks, clawdbot, bob, builder, charlie, codex, claude-code, cline, codeant, codebuff, codegen, coder-agents, coderabbit, codebuddy, command-code, continue, copilot-agent, crush, cursor, deepagents, devin, dot-agents, docker-agent, droid, eca, elyra, firebase-studio, forgecode, gemini-cli, gitlab-duo, goose, greptile, grok-build, grok-bot, grok-cli, gptme, jean2, jetbrains-ai, junie, jules, leanctl, kimi, kiro, kilo, knowns, localcode, mcp-agent, mini-swe-agent, swe-agent, stagewise, mistral-vibe, mux, novakit, ona, openhands, open-interpreter, openwebui, pi, pi-go, opencode, plandex, qodo, qoder, replit, qwen-code, roo, rovo, ruler, tabby, tabnine, trae, uipath, vscode-copilot, warp, windsurf, copilot-cli, zed, zencoder");
|
|
2505
2557
|
}
|
|
2506
2558
|
async function runUninstall(args) {
|
|
2507
2559
|
const target = args.positionals[0];
|
|
@@ -3076,6 +3128,18 @@ async function runUninstall(args) {
|
|
|
3076
3128
|
process.stdout.write("enable: tokenjuice install grok-build\n");
|
|
3077
3129
|
return 0;
|
|
3078
3130
|
}
|
|
3131
|
+
if (target === "grok-bot" || target === "grokbot") {
|
|
3132
|
+
const result = await uninstallGrokBotRule();
|
|
3133
|
+
if (args.format === "json") {
|
|
3134
|
+
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
3135
|
+
return 0;
|
|
3136
|
+
}
|
|
3137
|
+
process.stdout.write(`removed grok-bot rule: ${result.removed ? "yes" : "no"}\n`);
|
|
3138
|
+
process.stdout.write(`rule path: ${result.rulePath}\n`);
|
|
3139
|
+
process.stdout.write(`restored backup: ${result.restoredBackup ? "yes" : "no"}\n`);
|
|
3140
|
+
process.stdout.write("enable: tokenjuice install grok-bot\n");
|
|
3141
|
+
return 0;
|
|
3142
|
+
}
|
|
3079
3143
|
if (target === "goose") {
|
|
3080
3144
|
const result = await uninstallGooseHints();
|
|
3081
3145
|
if (args.format === "json") {
|
|
@@ -3637,7 +3701,7 @@ async function runUninstall(args) {
|
|
|
3637
3701
|
process.stdout.write("enable: tokenjuice install zencoder\n");
|
|
3638
3702
|
return 0;
|
|
3639
3703
|
}
|
|
3640
|
-
throw new Error("uninstall currently supports: adal, aether, aictl, ai-memory-protocol, aider, agent-layer, agentinit, agentlink, agentloom, agents-cli, agents-md, agentsge, agentsmesh, amazon-q, amp, antigravity, anywhere-agents, augment, avante, baz, bito, blackbox, blocks, clawdbot, bob, builder, charlie, codex, claude-code, cline, codeant, codebuff, codegen, coder-agents, coderabbit, codebuddy, command-code, continue, copilot-agent, crush, cursor, deepagents, devin, dot-agents, docker-agent, droid, eca, elyra, firebase-studio, forgecode, gitlab-duo, gemini-cli, goose, greptile, grok-build, grok-cli, gptme, jean2, jetbrains-ai, junie, jules, leanctl, kimi, kiro, kilo, knowns, localcode, mcp-agent, mini-swe-agent, swe-agent, stagewise, mistral-vibe, mux, novakit, ona, openhands, open-interpreter, openwebui, pi, pi-go, opencode, plandex, qodo, qoder, replit, qwen-code, roo, rovo, ruler, tabby, tabnine, trae, uipath, vscode-copilot, warp, windsurf, copilot-cli, zed, zencoder");
|
|
3704
|
+
throw new Error("uninstall currently supports: adal, aether, aictl, ai-memory-protocol, aider, agent-layer, agentinit, agentlink, agentloom, agents-cli, agents-md, agentsge, agentsmesh, amazon-q, amp, antigravity, anywhere-agents, augment, avante, baz, bito, blackbox, blocks, clawdbot, bob, builder, charlie, codex, claude-code, cline, codeant, codebuff, codegen, coder-agents, coderabbit, codebuddy, command-code, continue, copilot-agent, crush, cursor, deepagents, devin, dot-agents, docker-agent, droid, eca, elyra, firebase-studio, forgecode, gitlab-duo, gemini-cli, goose, greptile, grok-build, grok-bot, grok-cli, gptme, jean2, jetbrains-ai, junie, jules, leanctl, kimi, kiro, kilo, knowns, localcode, mcp-agent, mini-swe-agent, swe-agent, stagewise, mistral-vibe, mux, novakit, ona, openhands, open-interpreter, openwebui, pi, pi-go, opencode, plandex, qodo, qoder, replit, qwen-code, roo, rovo, ruler, tabby, tabnine, trae, uipath, vscode-copilot, warp, windsurf, copilot-cli, zed, zencoder");
|
|
3641
3705
|
}
|
|
3642
3706
|
async function runList(args) {
|
|
3643
3707
|
const refs = await listArtifacts(args.storeDir);
|
|
@@ -3744,6 +3808,30 @@ function formatMetric(value) {
|
|
|
3744
3808
|
.format(value)
|
|
3745
3809
|
.replace(/([KMBT])$/u, (suffix) => suffix.toLowerCase());
|
|
3746
3810
|
}
|
|
3811
|
+
export function formatStatsSources(sources) {
|
|
3812
|
+
if (sources.length === 0) {
|
|
3813
|
+
return "";
|
|
3814
|
+
}
|
|
3815
|
+
const orderedSources = [...sources].sort((left, right) => right.totals.observedRawChars - left.totals.observedRawChars
|
|
3816
|
+
|| left.source.localeCompare(right.source));
|
|
3817
|
+
const lines = ["sources:"];
|
|
3818
|
+
for (const source of orderedSources) {
|
|
3819
|
+
const observedRaw = source.totals.captureTruncatedEntries > 0
|
|
3820
|
+
? ` observedRaw=${formatMetric(source.totals.observedRawChars)}`
|
|
3821
|
+
: "";
|
|
3822
|
+
lines.push(`source ${source.source}: entries=${formatMetric(source.totals.entries)} raw=${formatMetric(source.totals.rawChars)}${observedRaw} reduced=${formatMetric(source.totals.reducedChars)} saved=${formatMetric(source.totals.savedChars)} avgRatio=${formatRatio(source.totals.avgRatio)}`);
|
|
3823
|
+
if (source.reducers.length > 0) {
|
|
3824
|
+
lines.push(` reducers: ${source.reducers.slice(0, 3).map((reducer) => `${reducer.reducer}(${formatMetric(reducer.count)})`).join(", ")}`);
|
|
3825
|
+
}
|
|
3826
|
+
if (source.commands.length > 0) {
|
|
3827
|
+
lines.push(` commands: ${source.commands.slice(0, 3).map((command) => `${command.signature}(${formatMetric(command.count)})`).join(", ")}`);
|
|
3828
|
+
}
|
|
3829
|
+
}
|
|
3830
|
+
if (orderedSources.some((source) => source.source === UNKNOWN_ARTIFACT_SOURCE)) {
|
|
3831
|
+
lines.push("note: source unknown means stored artifacts have missing or invalid source metadata.");
|
|
3832
|
+
}
|
|
3833
|
+
return `${lines.join("\n")}\n`;
|
|
3834
|
+
}
|
|
3747
3835
|
async function runDiscover(args) {
|
|
3748
3836
|
const direct = await loadDirectAnalysisEntry(args);
|
|
3749
3837
|
const entries = direct ? [direct.entry] : await listArtifactMetadata(args.storeDir);
|
|
@@ -4476,7 +4564,10 @@ async function runDoctor(args) {
|
|
|
4476
4564
|
return report.status === "broken" ? 1 : 0;
|
|
4477
4565
|
}
|
|
4478
4566
|
if (args.positionals[0] === "codex") {
|
|
4479
|
-
const report = await doctorCodexHook(undefined, {
|
|
4567
|
+
const report = await doctorCodexHook(undefined, {
|
|
4568
|
+
local: args.local,
|
|
4569
|
+
...(args.noOmit ? { noOmit: true } : {}),
|
|
4570
|
+
});
|
|
4480
4571
|
if (args.format === "json") {
|
|
4481
4572
|
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
4482
4573
|
return report.status === "broken" ? 1 : 0;
|
|
@@ -5210,6 +5301,35 @@ async function runDoctor(args) {
|
|
|
5210
5301
|
process.stdout.write(`repair: ${report.fixCommand}\n`);
|
|
5211
5302
|
return report.status === "broken" ? 1 : 0;
|
|
5212
5303
|
}
|
|
5304
|
+
if (args.positionals[0] === "grok-bot" || args.positionals[0] === "grokbot") {
|
|
5305
|
+
const report = await doctorGrokBotRule();
|
|
5306
|
+
if (args.format === "json") {
|
|
5307
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
5308
|
+
return report.status === "broken" ? 1 : 0;
|
|
5309
|
+
}
|
|
5310
|
+
process.stdout.write(`rule path: ${report.rulePath}\n`);
|
|
5311
|
+
process.stdout.write(`health: ${report.status}\n`);
|
|
5312
|
+
if (report.issues.length > 0) {
|
|
5313
|
+
process.stdout.write("issues:\n");
|
|
5314
|
+
for (const issue of report.issues) {
|
|
5315
|
+
process.stdout.write(`- ${issue}\n`);
|
|
5316
|
+
}
|
|
5317
|
+
}
|
|
5318
|
+
if (report.missingPaths.length > 0) {
|
|
5319
|
+
process.stdout.write("missing paths:\n");
|
|
5320
|
+
for (const path of report.missingPaths) {
|
|
5321
|
+
process.stdout.write(`- ${path}\n`);
|
|
5322
|
+
}
|
|
5323
|
+
}
|
|
5324
|
+
if (report.advisories.length > 0) {
|
|
5325
|
+
process.stdout.write("advisories:\n");
|
|
5326
|
+
for (const advisory of report.advisories) {
|
|
5327
|
+
process.stdout.write(`- ${advisory}\n`);
|
|
5328
|
+
}
|
|
5329
|
+
}
|
|
5330
|
+
process.stdout.write(`repair: ${report.fixCommand}\n`);
|
|
5331
|
+
return report.status === "broken" ? 1 : 0;
|
|
5332
|
+
}
|
|
5213
5333
|
if (args.positionals[0] === "goose") {
|
|
5214
5334
|
const report = await doctorGooseHints();
|
|
5215
5335
|
if (args.format === "json") {
|
|
@@ -6496,20 +6616,11 @@ async function runStats(args) {
|
|
|
6496
6616
|
}
|
|
6497
6617
|
}
|
|
6498
6618
|
if (report.sources && report.sources.length > 0) {
|
|
6499
|
-
process.stdout.write(
|
|
6500
|
-
for (const source of report.sources) {
|
|
6501
|
-
process.stdout.write(`source ${source.source}: entries=${formatMetric(source.totals.entries)} saved=${formatMetric(source.totals.savedChars)} avgRatio=${formatRatio(source.totals.avgRatio)}\n`);
|
|
6502
|
-
if (source.reducers.length > 0) {
|
|
6503
|
-
process.stdout.write(` reducers: ${source.reducers.slice(0, 3).map((reducer) => `${reducer.reducer}(${formatMetric(reducer.count)})`).join(", ")}\n`);
|
|
6504
|
-
}
|
|
6505
|
-
if (source.commands.length > 0) {
|
|
6506
|
-
process.stdout.write(` commands: ${source.commands.slice(0, 3).map((command) => `${command.signature}(${formatMetric(command.count)})`).join(", ")}\n`);
|
|
6507
|
-
}
|
|
6508
|
-
}
|
|
6619
|
+
process.stdout.write(formatStatsSources(report.sources));
|
|
6509
6620
|
}
|
|
6510
6621
|
return 0;
|
|
6511
6622
|
}
|
|
6512
|
-
async function main(argv = process.argv.slice(2)) {
|
|
6623
|
+
export async function main(argv = process.argv.slice(2)) {
|
|
6513
6624
|
const args = parseArgs(argv);
|
|
6514
6625
|
switch (args.command) {
|
|
6515
6626
|
case undefined:
|
|
@@ -6546,7 +6657,13 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
6546
6657
|
case "stats":
|
|
6547
6658
|
return await runStats(args);
|
|
6548
6659
|
case "codex-post-tool-use":
|
|
6549
|
-
|
|
6660
|
+
{
|
|
6661
|
+
const hookInput = await readStdinForCodexHook(args.maxInputBytes);
|
|
6662
|
+
if (hookInput === undefined) {
|
|
6663
|
+
return 0;
|
|
6664
|
+
}
|
|
6665
|
+
return await runCodexPostToolUseHook(hookInput, { noOmit: args.noOmit, allowOmit: args.allowOmit });
|
|
6666
|
+
}
|
|
6550
6667
|
case "claude-code-pre-tool-use":
|
|
6551
6668
|
return await runClaudeCodePreToolUseHook(await readStdin(args.maxInputBytes), args.wrapLauncher);
|
|
6552
6669
|
case "claude-code-post-tool-use":
|
|
@@ -4,6 +4,7 @@ export declare function resolveArtifactBaseDir(storeDir?: string): string;
|
|
|
4
4
|
export declare function isValidArtifactId(id: string): boolean;
|
|
5
5
|
export declare function storeArtifact(input: StoredArtifactInput, storeDir?: string): Promise<StoredArtifactRef>;
|
|
6
6
|
export declare function storeArtifactMetadata(input: StoredArtifactInput, storeDir?: string): Promise<ArtifactMetadataRef>;
|
|
7
|
+
export declare function tryStoreArtifactMetadata(input: StoredArtifactInput, storeDir?: string): Promise<ArtifactMetadataRef | undefined>;
|
|
7
8
|
export declare function getArtifact(id: string, storeDir?: string): Promise<StoredArtifact | null>;
|
|
8
9
|
export declare function listArtifacts(storeDir?: string): Promise<StoredArtifactRef[]>;
|
|
9
10
|
export declare function listArtifactMetadata(storeDir?: string): Promise<ArtifactMetadataRef[]>;
|
|
@@ -6,6 +6,23 @@ import { countTextChars, stripAnsi } from "./text.js";
|
|
|
6
6
|
import { resolveArtifactSource } from "./source.js";
|
|
7
7
|
const ARTIFACT_ID_PATTERN = /^tj_[0-9a-f-]{12}$/iu;
|
|
8
8
|
export const ARTIFACT_DIR_ENV = "TOKENJUICE_ARTIFACT_DIR";
|
|
9
|
+
const OPTIONAL_METADATA_STORAGE_ERROR_CODES = new Set([
|
|
10
|
+
"EACCES",
|
|
11
|
+
"EDQUOT",
|
|
12
|
+
"EEXIST",
|
|
13
|
+
"EFBIG",
|
|
14
|
+
"EIO",
|
|
15
|
+
"EISDIR",
|
|
16
|
+
"ELOOP",
|
|
17
|
+
"EMFILE",
|
|
18
|
+
"ENAMETOOLONG",
|
|
19
|
+
"ENFILE",
|
|
20
|
+
"ENOENT",
|
|
21
|
+
"ENOSPC",
|
|
22
|
+
"ENOTDIR",
|
|
23
|
+
"EPERM",
|
|
24
|
+
"EROFS",
|
|
25
|
+
]);
|
|
9
26
|
function isRecord(value) {
|
|
10
27
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11
28
|
}
|
|
@@ -127,6 +144,18 @@ export async function storeArtifactMetadata(input, storeDir) {
|
|
|
127
144
|
metadata,
|
|
128
145
|
};
|
|
129
146
|
}
|
|
147
|
+
export async function tryStoreArtifactMetadata(input, storeDir) {
|
|
148
|
+
try {
|
|
149
|
+
return await storeArtifactMetadata(input, storeDir);
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
const code = error.code;
|
|
153
|
+
if (typeof code !== "string" || !OPTIONAL_METADATA_STORAGE_ERROR_CODES.has(code)) {
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
return undefined;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
130
159
|
export async function getArtifact(id, storeDir) {
|
|
131
160
|
if (!isValidArtifactId(id)) {
|
|
132
161
|
return null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type CompactionKind = "head-tail-omission" | "middle-truncation" | "tail-truncation" | "hashed-middle-clip" | "git-diff-hunk-clip" | "inspection-package-lock-summary" | "inspection-large-document-summary" | "github-actions-command-list-omission" | "github-actions-log-signal-filter" | "github-status-check-rollup-omission" | "no-omit-head-tail-passthrough" | "no-omit-char-clip-passthrough" | "no-omit-domain-passthrough";
|
|
1
|
+
export type CompactionKind = "head-tail-omission" | "middle-truncation" | "tail-truncation" | "hashed-middle-clip" | "git-diff-hunk-clip" | "inspection-package-lock-summary" | "inspection-large-document-summary" | "repeated-emoji-banner-omission" | "github-actions-command-list-omission" | "github-actions-log-signal-filter" | "github-status-check-rollup-omission" | "no-omit-head-tail-passthrough" | "no-omit-char-clip-passthrough" | "no-omit-domain-passthrough";
|
|
2
2
|
export type CompactionMetadata = {
|
|
3
3
|
authoritative: boolean;
|
|
4
4
|
kinds: CompactionKind[];
|
|
@@ -61,7 +61,7 @@ export async function compactBashResult(input) {
|
|
|
61
61
|
const options = {
|
|
62
62
|
...(typeof input.cwd === "string" && input.cwd.trim() ? { cwd: input.cwd } : {}),
|
|
63
63
|
...(typeof input.maxInlineChars === "number" ? { maxInlineChars: input.maxInlineChars } : {}),
|
|
64
|
-
...(
|
|
64
|
+
...(input.noOmit || (!input.allowOmit && readNoOmissionFromEnv()) ? { noOmit: true } : {}),
|
|
65
65
|
recordStats: true,
|
|
66
66
|
...(input.storeRaw ? { store: true } : {}),
|
|
67
67
|
};
|
|
@@ -3,8 +3,8 @@ import { hasMultipleSubstantiveShellCommands } from "./command-match.js";
|
|
|
3
3
|
import { classifyExecution, resolveRuleMatch } from "./classify.js";
|
|
4
4
|
import { isFileContentInspectionCommand, isVerbatimConfigInspectionCommand } from "./command-identity.js";
|
|
5
5
|
import { normalizeExecutionInput } from "./execution-input.js";
|
|
6
|
-
import { clampTextMiddleWithMetadata, clampTextWithMetadata, countTextChars, dedupeAdjacent, headTail, normalizeLines, pluralize, stripAnsi, trimEmptyEdges } from "./text.js";
|
|
7
|
-
import { storeArtifact,
|
|
6
|
+
import { clampTextMiddleWithMetadata, clampTextWithMetadata, collapseRepeatedEmojiBanner, countTextChars, dedupeAdjacent, headTail, normalizeLines, pluralize, stripAnsi, trimEmptyEdges } from "./text.js";
|
|
7
|
+
import { storeArtifact, tryStoreArtifactMetadata } from "./artifacts.js";
|
|
8
8
|
import { NO_COMPACTION_METADATA, mergeCompactionMetadata } from "./compaction-metadata.js";
|
|
9
9
|
import { buildGithubActionsFailureSummary } from "./github-actions-summary.js";
|
|
10
10
|
import { rewriteGhLines, rewriteGitDiffLines, rewriteGitStatusLines, rewriteSearchLines } from "./reduce-formatters.js";
|
|
@@ -13,6 +13,7 @@ import { compactWholeJsonText } from "./reduce-utils.js";
|
|
|
13
13
|
const TINY_OUTPUT_MAX_CHARS = 240;
|
|
14
14
|
const SMALL_OUTPUT_PASSTHROUGH_MIN_SAVED_CHARS = 120;
|
|
15
15
|
const SMALL_OUTPUT_PASSTHROUGH_MAX_RATIO = 0.75;
|
|
16
|
+
const FAILURE_SEVERITY_FACTS = new Set(["error", "warning"]);
|
|
16
17
|
function buildRawText(input) {
|
|
17
18
|
if (input.combinedText) {
|
|
18
19
|
return input.combinedText;
|
|
@@ -53,6 +54,12 @@ function applyRule(compiledRule, input, rawText, noOmit = false) {
|
|
|
53
54
|
if (rule.transforms?.stripAnsi) {
|
|
54
55
|
lines = normalizeLines(stripAnsi(lines.join("\n")));
|
|
55
56
|
}
|
|
57
|
+
let rewriteCompaction;
|
|
58
|
+
if (!noOmit && rule.id === "generic/fallback") {
|
|
59
|
+
const collapsed = collapseRepeatedEmojiBanner(lines);
|
|
60
|
+
lines = collapsed.lines;
|
|
61
|
+
rewriteCompaction = mergeCompactionMetadata(rewriteCompaction, collapsed.compaction);
|
|
62
|
+
}
|
|
56
63
|
const outputMatchText = trimEmptyEdges(lines).join("\n");
|
|
57
64
|
const matchedOutput = compiledRule.compiled.outputMatches.find((entry) => entry.pattern.test(outputMatchText));
|
|
58
65
|
if (!noOmit && matchedOutput) {
|
|
@@ -85,7 +92,6 @@ function applyRule(compiledRule, input, rawText, noOmit = false) {
|
|
|
85
92
|
lines = rewriteGitStatusLines(lines);
|
|
86
93
|
}
|
|
87
94
|
const preRewriteLines = [...lines];
|
|
88
|
-
let rewriteCompaction;
|
|
89
95
|
if (rule.id === "cloud/gh") {
|
|
90
96
|
counterLines = rewriteGhLines(counterLines, input, noOmit).lines;
|
|
91
97
|
const rewritten = rewriteGhLines(lines, input, noOmit);
|
|
@@ -179,9 +185,11 @@ function isTerseDiscoveryCommand(classification, input) {
|
|
|
179
185
|
return false;
|
|
180
186
|
}
|
|
181
187
|
function formatInline(classification, input, summary, facts, noOmit = false) {
|
|
188
|
+
const neutralizeSeverityFacts = classification.matchedReducer === "generic/fallback"
|
|
189
|
+
&& input.exitCode === 0;
|
|
182
190
|
const factParts = Object.entries(facts)
|
|
183
191
|
.filter(([, count]) => count > 0)
|
|
184
|
-
.map(([name, count]) => pluralize(count, name));
|
|
192
|
+
.map(([name, count]) => pluralize(count, neutralizeSeverityFacts && FAILURE_SEVERITY_FACTS.has(name) ? `${name} mention` : name));
|
|
185
193
|
const lines = [];
|
|
186
194
|
if (input.exitCode && input.exitCode !== 0) {
|
|
187
195
|
lines.push(`exit ${input.exitCode}`);
|
|
@@ -302,7 +310,7 @@ export async function reduceExecutionWithRules(input, rules, opts = {}) {
|
|
|
302
310
|
}, opts.storeDir)
|
|
303
311
|
: undefined;
|
|
304
312
|
if (!opts.store && opts.recordStats) {
|
|
305
|
-
await
|
|
313
|
+
await tryStoreArtifactMetadata({
|
|
306
314
|
input: normalizedInput,
|
|
307
315
|
rawText,
|
|
308
316
|
classification,
|
|
@@ -352,7 +360,7 @@ export async function reduceExecutionWithRules(input, rules, opts = {}) {
|
|
|
352
360
|
}, opts.storeDir)
|
|
353
361
|
: undefined;
|
|
354
362
|
if (!opts.store && opts.recordStats) {
|
|
355
|
-
await
|
|
363
|
+
await tryStoreArtifactMetadata({
|
|
356
364
|
input: normalizedInput,
|
|
357
365
|
rawText,
|
|
358
366
|
classification: summaryClassification,
|
|
@@ -371,7 +379,7 @@ export async function reduceExecutionWithRules(input, rules, opts = {}) {
|
|
|
371
379
|
}
|
|
372
380
|
if (classification.matchedReducer === "generic/fallback" && isFileContentInspectionCommand(normalizedInput)) {
|
|
373
381
|
if (!opts.store && opts.recordStats) {
|
|
374
|
-
await
|
|
382
|
+
await tryStoreArtifactMetadata({
|
|
375
383
|
input: normalizedInput,
|
|
376
384
|
rawText,
|
|
377
385
|
classification,
|
|
@@ -419,7 +427,7 @@ export async function reduceExecutionWithRules(input, rules, opts = {}) {
|
|
|
419
427
|
}, opts.storeDir)
|
|
420
428
|
: undefined;
|
|
421
429
|
if (!opts.store && opts.recordStats) {
|
|
422
|
-
await
|
|
430
|
+
await tryStoreArtifactMetadata({
|
|
423
431
|
input: normalizedInput,
|
|
424
432
|
rawText,
|
|
425
433
|
classification,
|
|
@@ -460,7 +468,7 @@ export async function reduceExecutionWithRules(input, rules, opts = {}) {
|
|
|
460
468
|
}, opts.storeDir)
|
|
461
469
|
: undefined;
|
|
462
470
|
if (!opts.store && opts.recordStats) {
|
|
463
|
-
await
|
|
471
|
+
await tryStoreArtifactMetadata({
|
|
464
472
|
input: normalizedInput,
|
|
465
473
|
rawText,
|
|
466
474
|
classification: jsonClassification,
|
|
@@ -497,7 +505,7 @@ export async function reduceExecutionWithRules(input, rules, opts = {}) {
|
|
|
497
505
|
}, opts.storeDir)
|
|
498
506
|
: undefined;
|
|
499
507
|
if (!opts.store && opts.recordStats) {
|
|
500
|
-
await
|
|
508
|
+
await tryStoreArtifactMetadata({
|
|
501
509
|
input: normalizedInput,
|
|
502
510
|
rawText,
|
|
503
511
|
classification,
|
|
@@ -6,6 +6,10 @@ export declare function countTerminalCells(text: string): number;
|
|
|
6
6
|
export declare function normalizeLines(text: string): string[];
|
|
7
7
|
export declare function trimEmptyEdges(lines: string[]): string[];
|
|
8
8
|
export declare function dedupeAdjacent(lines: string[]): string[];
|
|
9
|
+
export declare function collapseRepeatedEmojiBanner(lines: string[]): {
|
|
10
|
+
lines: string[];
|
|
11
|
+
compaction?: CompactionMetadata;
|
|
12
|
+
};
|
|
9
13
|
export declare function headTail(lines: string[], head: number, tail: number, noOmit?: boolean): {
|
|
10
14
|
lines: string[];
|
|
11
15
|
compaction?: CompactionMetadata;
|