kirograph 0.13.1 → 0.14.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/README.md +191 -8
- package/dist/bin/commands/caveman.js +7 -2
- package/dist/bin/commands/caveman.js.map +2 -2
- package/dist/bin/commands/compression.js +109 -0
- package/dist/bin/commands/compression.js.map +7 -0
- package/dist/bin/commands/context.js +31 -24
- package/dist/bin/commands/context.js.map +2 -2
- package/dist/bin/commands/exec.js +107 -0
- package/dist/bin/commands/exec.js.map +7 -0
- package/dist/bin/commands/gain.js +119 -0
- package/dist/bin/commands/gain.js.map +7 -0
- package/dist/bin/commands/help.js +10 -1
- package/dist/bin/commands/help.js.map +2 -2
- package/dist/bin/commands/query.js +5 -1
- package/dist/bin/commands/query.js.map +2 -2
- package/dist/bin/commands/uninit.js +1 -1
- package/dist/bin/commands/uninit.js.map +2 -2
- package/dist/bin/commands/utils.js +16 -0
- package/dist/bin/commands/utils.js.map +2 -2
- package/dist/bin/installer/config-prompt.js +9 -2
- package/dist/bin/installer/config-prompt.js.map +2 -2
- package/dist/bin/installer/hooks.js +19 -1
- package/dist/bin/installer/hooks.js.map +2 -2
- package/dist/bin/installer/index.js +6 -1
- package/dist/bin/installer/index.js.map +2 -2
- package/dist/bin/installer/steering.js +116 -40
- package/dist/bin/installer/steering.js.map +2 -2
- package/dist/bin/installer/targets/index.js.map +1 -1
- package/dist/bin/installer/targets/kiro.js +4 -2
- package/dist/bin/installer/targets/kiro.js.map +2 -2
- package/dist/bin/kirograph.js +7 -1
- package/dist/bin/kirograph.js.map +3 -3
- package/dist/compression/filters/aws.js +418 -0
- package/dist/compression/filters/aws.js.map +7 -0
- package/dist/compression/filters/docker.js +153 -0
- package/dist/compression/filters/docker.js.map +7 -0
- package/dist/compression/filters/files.js +150 -0
- package/dist/compression/filters/files.js.map +7 -0
- package/dist/compression/filters/generic.js +86 -0
- package/dist/compression/filters/generic.js.map +7 -0
- package/dist/compression/filters/git.js +272 -0
- package/dist/compression/filters/git.js.map +7 -0
- package/dist/compression/filters/github.js +137 -0
- package/dist/compression/filters/github.js.map +7 -0
- package/dist/compression/filters/lint.js +280 -0
- package/dist/compression/filters/lint.js.map +7 -0
- package/dist/compression/filters/misc.js +212 -0
- package/dist/compression/filters/misc.js.map +7 -0
- package/dist/compression/filters/package.js +151 -0
- package/dist/compression/filters/package.js.map +7 -0
- package/dist/compression/filters/test.js +266 -0
- package/dist/compression/filters/test.js.map +7 -0
- package/dist/compression/index.js +144 -0
- package/dist/compression/index.js.map +7 -0
- package/dist/compression/naive-cost.js +94 -0
- package/dist/compression/naive-cost.js.map +7 -0
- package/dist/compression/tracker.js +228 -0
- package/dist/compression/tracker.js.map +7 -0
- package/dist/compression/types.js +17 -0
- package/dist/compression/types.js.map +7 -0
- package/dist/config.js +18 -1
- package/dist/config.js.map +2 -2
- package/dist/mcp/tool-names.js +3 -1
- package/dist/mcp/tool-names.js.map +2 -2
- package/dist/mcp/tools.js +170 -4
- package/dist/mcp/tools.js.map +3 -3
- package/package.json +1 -1
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var package_exports = {};
|
|
20
|
+
__export(package_exports, {
|
|
21
|
+
packageFilter: () => packageFilter
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(package_exports);
|
|
24
|
+
const packageFilter = {
|
|
25
|
+
name: "package",
|
|
26
|
+
matches(command) {
|
|
27
|
+
return /\b(npm\s+(list|ls|outdated|install|i\b)|pnpm\s+(list|ls|outdated|install)|yarn\s+(list|outdated|add|install)|pip\s+(list|freeze|outdated|install)|bundle\s+(install|list|outdated)|cargo\s+(update|add)|go\s+(mod|get))\b/.test(command);
|
|
28
|
+
},
|
|
29
|
+
filter(command, rawOutput, level) {
|
|
30
|
+
if (/npm\s+(install|i)\b|pnpm\s+install|yarn\s+(install|add)/.test(command)) return filterNpmInstall(rawOutput, level);
|
|
31
|
+
if (/npm\s+(list|ls)|pnpm\s+(list|ls)/.test(command)) return filterNpmList(rawOutput, level);
|
|
32
|
+
if (/npm\s+outdated|pnpm\s+outdated|yarn\s+outdated/.test(command)) return filterOutdated(rawOutput, level);
|
|
33
|
+
if (/pip\s+(list|freeze)/.test(command)) return filterPipList(rawOutput, level);
|
|
34
|
+
if (/pip\s+outdated/.test(command)) return filterOutdated(rawOutput, level);
|
|
35
|
+
if (/pip\s+install/.test(command)) return filterPipInstall(rawOutput, level);
|
|
36
|
+
if (/bundle\s+install/.test(command)) return filterBundleInstall(rawOutput, level);
|
|
37
|
+
if (/bundle\s+list/.test(command)) return filterBundleList(rawOutput, level);
|
|
38
|
+
return { output: rawOutput, strategy: "package:passthrough" };
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
function filterNpmInstall(raw, level) {
|
|
42
|
+
const lines = raw.split("\n").filter((l) => l.trim());
|
|
43
|
+
const addedMatch = raw.match(/added\s+(\d+)\s+packages?/);
|
|
44
|
+
const removedMatch = raw.match(/removed\s+(\d+)\s+packages?/);
|
|
45
|
+
const changedMatch = raw.match(/changed\s+(\d+)\s+packages?/);
|
|
46
|
+
const auditMatch = raw.match(/(\d+)\s+vulnerabilit/);
|
|
47
|
+
const parts = [];
|
|
48
|
+
if (addedMatch) parts.push(`+${addedMatch[1]}`);
|
|
49
|
+
if (removedMatch) parts.push(`-${removedMatch[1]}`);
|
|
50
|
+
if (changedMatch) parts.push(`~${changedMatch[1]}`);
|
|
51
|
+
if (parts.length > 0) {
|
|
52
|
+
const audit = auditMatch ? ` (${auditMatch[1]} vulnerabilities)` : "";
|
|
53
|
+
return { output: `ok ${parts.join(" ")} packages${audit}`, strategy: "npm-install:summary" };
|
|
54
|
+
}
|
|
55
|
+
if (raw.includes("up to date")) {
|
|
56
|
+
return { output: "ok (up to date)", strategy: "npm-install:uptodate" };
|
|
57
|
+
}
|
|
58
|
+
const meaningful = lines.filter((l) => !l.startsWith("npm") || l.includes("added") || l.includes("removed"));
|
|
59
|
+
return { output: meaningful.pop() || "ok", strategy: "npm-install:fallback" };
|
|
60
|
+
}
|
|
61
|
+
function filterNpmList(raw, level) {
|
|
62
|
+
const lines = raw.split("\n").filter((l) => l.trim());
|
|
63
|
+
if (lines.length <= 10) return { output: raw, strategy: "npm-list:short" };
|
|
64
|
+
const topLevel = lines.filter((l) => l.startsWith("\u251C") || l.startsWith("\u2514"));
|
|
65
|
+
if (level === "ultra") {
|
|
66
|
+
return { output: `${topLevel.length} top-level packages`, strategy: "npm-list:ultra" };
|
|
67
|
+
}
|
|
68
|
+
if (level === "aggressive") {
|
|
69
|
+
const shown2 = topLevel.slice(0, 20).join("\n");
|
|
70
|
+
const extra = topLevel.length > 20 ? `
|
|
71
|
+
\u2026+${topLevel.length - 20} more` : "";
|
|
72
|
+
return { output: `${topLevel.length} packages:
|
|
73
|
+
${shown2}${extra}`, strategy: "npm-list:toplevel" };
|
|
74
|
+
}
|
|
75
|
+
const maxLines = 40;
|
|
76
|
+
if (lines.length <= maxLines) return { output: raw, strategy: "npm-list:full" };
|
|
77
|
+
const shown = lines.slice(0, maxLines).join("\n");
|
|
78
|
+
return { output: `${shown}
|
|
79
|
+
\u2026+${lines.length - maxLines} more lines`, strategy: "npm-list:truncated" };
|
|
80
|
+
}
|
|
81
|
+
function filterOutdated(raw, level) {
|
|
82
|
+
const lines = raw.split("\n").filter((l) => l.trim());
|
|
83
|
+
if (lines.length <= 1) return { output: "all up to date", strategy: "outdated:clean" };
|
|
84
|
+
const rows = lines.slice(1);
|
|
85
|
+
if (level === "ultra") {
|
|
86
|
+
return { output: `${rows.length} outdated packages`, strategy: "outdated:ultra" };
|
|
87
|
+
}
|
|
88
|
+
const maxRows = level === "aggressive" ? 10 : 20;
|
|
89
|
+
if (rows.length <= maxRows) return { output: raw, strategy: "outdated:short" };
|
|
90
|
+
const shown = [lines[0], ...rows.slice(0, maxRows)].join("\n");
|
|
91
|
+
return { output: `${shown}
|
|
92
|
+
\u2026+${rows.length - maxRows} more`, strategy: "outdated:truncated" };
|
|
93
|
+
}
|
|
94
|
+
function filterPipList(raw, level) {
|
|
95
|
+
const lines = raw.split("\n").filter((l) => l.trim());
|
|
96
|
+
if (lines.length <= 5) return { output: raw, strategy: "pip-list:short" };
|
|
97
|
+
const packages = lines.filter((l) => !l.startsWith("Package") && !l.startsWith("---") && !l.startsWith("WARNING"));
|
|
98
|
+
if (level === "ultra") {
|
|
99
|
+
return { output: `${packages.length} packages installed`, strategy: "pip-list:ultra" };
|
|
100
|
+
}
|
|
101
|
+
const maxPkgs = level === "aggressive" ? 20 : 40;
|
|
102
|
+
if (packages.length <= maxPkgs) return { output: packages.join("\n"), strategy: "pip-list:full" };
|
|
103
|
+
const shown = packages.slice(0, maxPkgs).join("\n");
|
|
104
|
+
return { output: `${shown}
|
|
105
|
+
\u2026+${packages.length - maxPkgs} more packages`, strategy: "pip-list:truncated" };
|
|
106
|
+
}
|
|
107
|
+
function filterPipInstall(raw, level) {
|
|
108
|
+
const lines = raw.split("\n").filter((l) => l.trim());
|
|
109
|
+
if (raw.includes("Successfully installed")) {
|
|
110
|
+
const installed = raw.match(/Successfully installed (.+)/);
|
|
111
|
+
if (installed) {
|
|
112
|
+
const pkgs = installed[1].split(/\s+/);
|
|
113
|
+
if (level === "ultra") return { output: `ok +${pkgs.length} packages`, strategy: "pip-install:ultra" };
|
|
114
|
+
return { output: `ok installed ${pkgs.length} packages: ${pkgs.slice(0, 5).join(", ")}${pkgs.length > 5 ? "\u2026" : ""}`, strategy: "pip-install:summary" };
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (raw.includes("already satisfied")) {
|
|
118
|
+
return { output: "ok (already satisfied)", strategy: "pip-install:satisfied" };
|
|
119
|
+
}
|
|
120
|
+
const meaningful = lines.filter((l) => !l.includes("Downloading") && !l.includes("\u2501") && !l.includes("Using cached"));
|
|
121
|
+
return { output: meaningful.join("\n") || "ok", strategy: "pip-install:filtered" };
|
|
122
|
+
}
|
|
123
|
+
function filterBundleInstall(raw, level) {
|
|
124
|
+
const lines = raw.split("\n").filter((l) => l.trim());
|
|
125
|
+
const meaningful = lines.filter((l) => !l.startsWith("Using ") && !l.startsWith("Fetching"));
|
|
126
|
+
const installed = lines.filter((l) => l.startsWith("Installing"));
|
|
127
|
+
if (level === "ultra") {
|
|
128
|
+
return { output: `ok ${installed.length} installed`, strategy: "bundle-install:ultra" };
|
|
129
|
+
}
|
|
130
|
+
if (meaningful.length <= 10) return { output: meaningful.join("\n"), strategy: "bundle-install:short" };
|
|
131
|
+
const summary = meaningful.filter((l) => l.startsWith("Bundle") || l.startsWith("Installing"));
|
|
132
|
+
return { output: summary.join("\n") || meaningful.slice(-5).join("\n"), strategy: "bundle-install:summary" };
|
|
133
|
+
}
|
|
134
|
+
function filterBundleList(raw, level) {
|
|
135
|
+
const lines = raw.split("\n").filter((l) => l.trim());
|
|
136
|
+
const gems = lines.filter((l) => l.startsWith(" *"));
|
|
137
|
+
if (level === "ultra") {
|
|
138
|
+
return { output: `${gems.length} gems`, strategy: "bundle-list:ultra" };
|
|
139
|
+
}
|
|
140
|
+
const maxGems = level === "aggressive" ? 20 : 40;
|
|
141
|
+
if (gems.length <= maxGems) return { output: raw, strategy: "bundle-list:full" };
|
|
142
|
+
const shown = gems.slice(0, maxGems).join("\n");
|
|
143
|
+
return { output: `${gems.length} gems:
|
|
144
|
+
${shown}
|
|
145
|
+
\u2026+${gems.length - maxGems} more`, strategy: "bundle-list:truncated" };
|
|
146
|
+
}
|
|
147
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
148
|
+
0 && (module.exports = {
|
|
149
|
+
packageFilter
|
|
150
|
+
});
|
|
151
|
+
//# sourceMappingURL=package.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/compression/filters/package.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Package manager output filters (npm, pip, bundle, pnpm, yarn)\n */\n\nimport type { CommandFilter, FilterResult, CompressorOptions } from '../types';\n\nexport const packageFilter: CommandFilter = {\n name: 'package',\n\n matches(command: string): boolean {\n return /\\b(npm\\s+(list|ls|outdated|install|i\\b)|pnpm\\s+(list|ls|outdated|install)|yarn\\s+(list|outdated|add|install)|pip\\s+(list|freeze|outdated|install)|bundle\\s+(install|list|outdated)|cargo\\s+(update|add)|go\\s+(mod|get))\\b/.test(command);\n },\n\n filter(command: string, rawOutput: string, level: CompressorOptions['level']): FilterResult {\n if (/npm\\s+(install|i)\\b|pnpm\\s+install|yarn\\s+(install|add)/.test(command)) return filterNpmInstall(rawOutput, level);\n if (/npm\\s+(list|ls)|pnpm\\s+(list|ls)/.test(command)) return filterNpmList(rawOutput, level);\n if (/npm\\s+outdated|pnpm\\s+outdated|yarn\\s+outdated/.test(command)) return filterOutdated(rawOutput, level);\n if (/pip\\s+(list|freeze)/.test(command)) return filterPipList(rawOutput, level);\n if (/pip\\s+outdated/.test(command)) return filterOutdated(rawOutput, level);\n if (/pip\\s+install/.test(command)) return filterPipInstall(rawOutput, level);\n if (/bundle\\s+install/.test(command)) return filterBundleInstall(rawOutput, level);\n if (/bundle\\s+list/.test(command)) return filterBundleList(rawOutput, level);\n\n return { output: rawOutput, strategy: 'package:passthrough' };\n },\n};\n\nfunction filterNpmInstall(raw: string, level: CompressorOptions['level']): FilterResult {\n const lines = raw.split('\\n').filter(l => l.trim());\n\n // Extract summary\n const addedMatch = raw.match(/added\\s+(\\d+)\\s+packages?/);\n const removedMatch = raw.match(/removed\\s+(\\d+)\\s+packages?/);\n const changedMatch = raw.match(/changed\\s+(\\d+)\\s+packages?/);\n const auditMatch = raw.match(/(\\d+)\\s+vulnerabilit/);\n\n const parts: string[] = [];\n if (addedMatch) parts.push(`+${addedMatch[1]}`);\n if (removedMatch) parts.push(`-${removedMatch[1]}`);\n if (changedMatch) parts.push(`~${changedMatch[1]}`);\n\n if (parts.length > 0) {\n const audit = auditMatch ? ` (${auditMatch[1]} vulnerabilities)` : '';\n return { output: `ok ${parts.join(' ')} packages${audit}`, strategy: 'npm-install:summary' };\n }\n\n // Already up to date\n if (raw.includes('up to date')) {\n return { output: 'ok (up to date)', strategy: 'npm-install:uptodate' };\n }\n\n // Fallback: last meaningful line\n const meaningful = lines.filter(l => !l.startsWith('npm') || l.includes('added') || l.includes('removed'));\n return { output: meaningful.pop() || 'ok', strategy: 'npm-install:fallback' };\n}\n\nfunction filterNpmList(raw: string, level: CompressorOptions['level']): FilterResult {\n const lines = raw.split('\\n').filter(l => l.trim());\n\n if (lines.length <= 10) return { output: raw, strategy: 'npm-list:short' };\n\n // Count top-level deps\n const topLevel = lines.filter(l => l.startsWith('\u251C') || l.startsWith('\u2514'));\n\n if (level === 'ultra') {\n return { output: `${topLevel.length} top-level packages`, strategy: 'npm-list:ultra' };\n }\n\n if (level === 'aggressive') {\n const shown = topLevel.slice(0, 20).join('\\n');\n const extra = topLevel.length > 20 ? `\\n\u2026+${topLevel.length - 20} more` : '';\n return { output: `${topLevel.length} packages:\\n${shown}${extra}`, strategy: 'npm-list:toplevel' };\n }\n\n // Normal: truncate tree\n const maxLines = 40;\n if (lines.length <= maxLines) return { output: raw, strategy: 'npm-list:full' };\n\n const shown = lines.slice(0, maxLines).join('\\n');\n return { output: `${shown}\\n\u2026+${lines.length - maxLines} more lines`, strategy: 'npm-list:truncated' };\n}\n\nfunction filterOutdated(raw: string, level: CompressorOptions['level']): FilterResult {\n const lines = raw.split('\\n').filter(l => l.trim());\n\n if (lines.length <= 1) return { output: 'all up to date', strategy: 'outdated:clean' };\n\n const rows = lines.slice(1); // Skip header\n\n if (level === 'ultra') {\n return { output: `${rows.length} outdated packages`, strategy: 'outdated:ultra' };\n }\n\n const maxRows = level === 'aggressive' ? 10 : 20;\n if (rows.length <= maxRows) return { output: raw, strategy: 'outdated:short' };\n\n const shown = [lines[0], ...rows.slice(0, maxRows)].join('\\n');\n return { output: `${shown}\\n\u2026+${rows.length - maxRows} more`, strategy: 'outdated:truncated' };\n}\n\nfunction filterPipList(raw: string, level: CompressorOptions['level']): FilterResult {\n const lines = raw.split('\\n').filter(l => l.trim());\n\n if (lines.length <= 5) return { output: raw, strategy: 'pip-list:short' };\n\n // Skip header lines (Package, Version, ---)\n const packages = lines.filter(l => !l.startsWith('Package') && !l.startsWith('---') && !l.startsWith('WARNING'));\n\n if (level === 'ultra') {\n return { output: `${packages.length} packages installed`, strategy: 'pip-list:ultra' };\n }\n\n const maxPkgs = level === 'aggressive' ? 20 : 40;\n if (packages.length <= maxPkgs) return { output: packages.join('\\n'), strategy: 'pip-list:full' };\n\n const shown = packages.slice(0, maxPkgs).join('\\n');\n return { output: `${shown}\\n\u2026+${packages.length - maxPkgs} more packages`, strategy: 'pip-list:truncated' };\n}\n\nfunction filterPipInstall(raw: string, level: CompressorOptions['level']): FilterResult {\n const lines = raw.split('\\n').filter(l => l.trim());\n\n // Success\n if (raw.includes('Successfully installed')) {\n const installed = raw.match(/Successfully installed (.+)/);\n if (installed) {\n const pkgs = installed[1].split(/\\s+/);\n if (level === 'ultra') return { output: `ok +${pkgs.length} packages`, strategy: 'pip-install:ultra' };\n return { output: `ok installed ${pkgs.length} packages: ${pkgs.slice(0, 5).join(', ')}${pkgs.length > 5 ? '\u2026' : ''}`, strategy: 'pip-install:summary' };\n }\n }\n\n if (raw.includes('already satisfied')) {\n return { output: 'ok (already satisfied)', strategy: 'pip-install:satisfied' };\n }\n\n // Strip download progress lines\n const meaningful = lines.filter(l => !l.includes('Downloading') && !l.includes('\u2501') && !l.includes('Using cached'));\n return { output: meaningful.join('\\n') || 'ok', strategy: 'pip-install:filtered' };\n}\n\nfunction filterBundleInstall(raw: string, level: CompressorOptions['level']): FilterResult {\n const lines = raw.split('\\n').filter(l => l.trim());\n\n // Strip \"Using ...\" lines\n const meaningful = lines.filter(l => !l.startsWith('Using ') && !l.startsWith('Fetching'));\n const installed = lines.filter(l => l.startsWith('Installing'));\n\n if (level === 'ultra') {\n return { output: `ok ${installed.length} installed`, strategy: 'bundle-install:ultra' };\n }\n\n if (meaningful.length <= 10) return { output: meaningful.join('\\n'), strategy: 'bundle-install:short' };\n\n // Show summary\n const summary = meaningful.filter(l => l.startsWith('Bundle') || l.startsWith('Installing'));\n return { output: summary.join('\\n') || meaningful.slice(-5).join('\\n'), strategy: 'bundle-install:summary' };\n}\n\nfunction filterBundleList(raw: string, level: CompressorOptions['level']): FilterResult {\n const lines = raw.split('\\n').filter(l => l.trim());\n const gems = lines.filter(l => l.startsWith(' *'));\n\n if (level === 'ultra') {\n return { output: `${gems.length} gems`, strategy: 'bundle-list:ultra' };\n }\n\n const maxGems = level === 'aggressive' ? 20 : 40;\n if (gems.length <= maxGems) return { output: raw, strategy: 'bundle-list:full' };\n\n const shown = gems.slice(0, maxGems).join('\\n');\n return { output: `${gems.length} gems:\\n${shown}\\n\u2026+${gems.length - maxGems} more`, strategy: 'bundle-list:truncated' };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,MAAM,gBAA+B;AA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E9D,MAAI,UAAU,SAAS;AACrB,WAAO,EAAE,QAAQ,MAAM,UAAU,MAAM,cAAc,UAAU,uBAAuB;AAAA,EACxF;AAEA,MAAI,WAAW,UAAU,GAAI,QAAO,EAAE,QAAQ,WAAW,KAAK,IAAI,GAAG,UAAU,uBAAuB;AAGtG,QAAM,UAAU,WAAW,OAAO,OAAK,EAAE,WAAW,QAAQ,KAAK,EAAE,WAAW,YAAY,CAAC;AAC3F,SAAO,EAAE,QAAQ,QAAQ,KAAK,IAAI,KAAK,WAAW,MAAM,EAAE,EAAE,KAAK,IAAI,GAAG,UAAU,yBAAyB;AAC7G;AAEA,SAAS,iBAAiB,KAAa,OAAiD;AACtF,QAAM,QAAQ,IAAI,MAAM,IAAI,EAAE,OAAO,OAAK,EAAE,KAAK,CAAC;AAClD,QAAM,OAAO,MAAM,OAAO,OAAK,EAAE,WAAW,KAAK,CAAC;AAElD,MAAI,UAAU,SAAS;AACrB,WAAO,EAAE,QAAQ,GAAG,KAAK,MAAM,SAAS,UAAU,oBAAoB;AAAA,EACxE;AAEA,QAAM,UAAU,UAAU,eAAe,KAAK;AAC9C,MAAI,KAAK,UAAU,QAAS,QAAO,EAAE,QAAQ,KAAK,UAAU,mBAAmB;AAE/E,QAAM,QAAQ,KAAK,MAAM,GAAG,OAAO,EAAE,KAAK,IAAI;AAC9C,SAAO,EAAE,QAAQ,GAAG,KAAK,MAAM;AAAA,EAAW,KAAK;AAAA,SAAO,KAAK,SAAS,OAAO,SAAS,UAAU,wBAAwB;AACxH;",
|
|
6
|
+
"names": ["shown"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var test_exports = {};
|
|
20
|
+
__export(test_exports, {
|
|
21
|
+
testFilter: () => testFilter
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(test_exports);
|
|
24
|
+
const testFilter = {
|
|
25
|
+
name: "test",
|
|
26
|
+
matches(command) {
|
|
27
|
+
return /\b(jest|vitest|pytest|cargo\s+test|go\s+test|rspec|rake\s+test|mocha|ava|tap|npm\s+test|yarn\s+test|pnpm\s+test|npx\s+vitest|npx\s+jest)\b/.test(command);
|
|
28
|
+
},
|
|
29
|
+
filter(command, rawOutput, level) {
|
|
30
|
+
if (/vitest/i.test(command)) return filterVitest(rawOutput, level);
|
|
31
|
+
if (/jest/i.test(command)) return filterJest(rawOutput, level);
|
|
32
|
+
if (/pytest/i.test(command)) return filterPytest(rawOutput, level);
|
|
33
|
+
if (/cargo\s+test/i.test(command)) return filterCargoTest(rawOutput, level);
|
|
34
|
+
if (/go\s+test/i.test(command)) return filterGoTest(rawOutput, level);
|
|
35
|
+
if (/rspec/i.test(command)) return filterRspec(rawOutput, level);
|
|
36
|
+
if (/rake\s+test/i.test(command)) return filterMinitest(rawOutput, level);
|
|
37
|
+
return filterGenericTest(rawOutput, level);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
function filterVitest(raw, level) {
|
|
41
|
+
return filterJsTestRunner(raw, level, "vitest");
|
|
42
|
+
}
|
|
43
|
+
function filterJest(raw, level) {
|
|
44
|
+
return filterJsTestRunner(raw, level, "jest");
|
|
45
|
+
}
|
|
46
|
+
function filterJsTestRunner(raw, level, runner) {
|
|
47
|
+
const lines = raw.split("\n");
|
|
48
|
+
const summaryLine = lines.find((l) => /Tests:\s+\d+/.test(l) || /\d+\s+passed/.test(l));
|
|
49
|
+
const failedMatch = raw.match(/(\d+)\s+failed/);
|
|
50
|
+
const passedMatch = raw.match(/(\d+)\s+passed/);
|
|
51
|
+
const totalMatch = raw.match(/Tests:\s+(\d+)/);
|
|
52
|
+
const failed = failedMatch ? parseInt(failedMatch[1]) : 0;
|
|
53
|
+
const passed = passedMatch ? parseInt(passedMatch[1]) : 0;
|
|
54
|
+
const total = totalMatch ? parseInt(totalMatch[1]) : failed + passed;
|
|
55
|
+
if (failed === 0) {
|
|
56
|
+
if (level === "ultra") {
|
|
57
|
+
return { output: `\u2713 ${passed}/${total}`, strategy: `${runner}:allpass:ultra` };
|
|
58
|
+
}
|
|
59
|
+
return { output: `PASSED: ${passed}/${total} tests`, strategy: `${runner}:allpass` };
|
|
60
|
+
}
|
|
61
|
+
const failures = [];
|
|
62
|
+
let inFailure = false;
|
|
63
|
+
let failureBlock = [];
|
|
64
|
+
for (const line of lines) {
|
|
65
|
+
if (line.includes("FAIL") && line.includes("\u25CF") || line.includes("\u2715") || line.includes("\u2717") || line.match(/FAIL\s+/)) {
|
|
66
|
+
if (failureBlock.length > 0) failures.push(failureBlock.join("\n"));
|
|
67
|
+
failureBlock = [line];
|
|
68
|
+
inFailure = true;
|
|
69
|
+
} else if (inFailure) {
|
|
70
|
+
if (line.trim() === "" && failureBlock.length > 3) {
|
|
71
|
+
failures.push(failureBlock.join("\n"));
|
|
72
|
+
failureBlock = [];
|
|
73
|
+
inFailure = false;
|
|
74
|
+
} else {
|
|
75
|
+
failureBlock.push(line);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (failureBlock.length > 0) failures.push(failureBlock.join("\n"));
|
|
80
|
+
const header = `FAILED: ${failed}/${total} tests`;
|
|
81
|
+
if (level === "ultra") {
|
|
82
|
+
const shortFailures = failures.map((f) => f.split("\n")[0]).slice(0, 5);
|
|
83
|
+
return { output: `${header}
|
|
84
|
+
${shortFailures.join("\n")}`, strategy: `${runner}:failures:ultra` };
|
|
85
|
+
}
|
|
86
|
+
const maxFailures = level === "aggressive" ? 3 : 5;
|
|
87
|
+
const shown = failures.slice(0, maxFailures).join("\n\n");
|
|
88
|
+
const extra = failures.length > maxFailures ? `
|
|
89
|
+
\u2026+${failures.length - maxFailures} more failures` : "";
|
|
90
|
+
return { output: `${header}
|
|
91
|
+
|
|
92
|
+
${shown}${extra}`, strategy: `${runner}:failures` };
|
|
93
|
+
}
|
|
94
|
+
function filterPytest(raw, level) {
|
|
95
|
+
const lines = raw.split("\n");
|
|
96
|
+
const summaryLine = lines.find((l) => /\d+\s+passed/.test(l) || /\d+\s+failed/.test(l));
|
|
97
|
+
const failedMatch = raw.match(/(\d+)\s+failed/);
|
|
98
|
+
const passedMatch = raw.match(/(\d+)\s+passed/);
|
|
99
|
+
const failed = failedMatch ? parseInt(failedMatch[1]) : 0;
|
|
100
|
+
const passed = passedMatch ? parseInt(passedMatch[1]) : 0;
|
|
101
|
+
const total = failed + passed;
|
|
102
|
+
if (failed === 0) {
|
|
103
|
+
if (level === "ultra") return { output: `\u2713 ${passed}/${total}`, strategy: "pytest:allpass:ultra" };
|
|
104
|
+
return { output: `PASSED: ${passed}/${total} tests`, strategy: "pytest:allpass" };
|
|
105
|
+
}
|
|
106
|
+
const failures = [];
|
|
107
|
+
let inFailure = false;
|
|
108
|
+
let block = [];
|
|
109
|
+
for (const line of lines) {
|
|
110
|
+
if (line.startsWith("FAILED") || line.startsWith("___ ") || line.includes("FAILURES ___")) {
|
|
111
|
+
if (block.length > 0) failures.push(block.join("\n"));
|
|
112
|
+
block = [line];
|
|
113
|
+
inFailure = true;
|
|
114
|
+
} else if (inFailure) {
|
|
115
|
+
block.push(line);
|
|
116
|
+
if (block.length > 20) {
|
|
117
|
+
failures.push(block.join("\n"));
|
|
118
|
+
block = [];
|
|
119
|
+
inFailure = false;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (block.length > 0) failures.push(block.join("\n"));
|
|
124
|
+
const header = `FAILED: ${failed}/${total} tests`;
|
|
125
|
+
const maxFailures = level === "ultra" ? 2 : level === "aggressive" ? 3 : 5;
|
|
126
|
+
const shown = failures.slice(0, maxFailures).join("\n\n");
|
|
127
|
+
const extra = failures.length > maxFailures ? `
|
|
128
|
+
\u2026+${failures.length - maxFailures} more` : "";
|
|
129
|
+
return { output: `${header}
|
|
130
|
+
|
|
131
|
+
${shown}${extra}`, strategy: "pytest:failures" };
|
|
132
|
+
}
|
|
133
|
+
function filterCargoTest(raw, level) {
|
|
134
|
+
const lines = raw.split("\n");
|
|
135
|
+
const resultLine = lines.find((l) => l.startsWith("test result:"));
|
|
136
|
+
const failedMatch = raw.match(/(\d+)\s+failed/);
|
|
137
|
+
const passedMatch = raw.match(/(\d+)\s+passed/);
|
|
138
|
+
const failed = failedMatch ? parseInt(failedMatch[1]) : 0;
|
|
139
|
+
const passed = passedMatch ? parseInt(passedMatch[1]) : 0;
|
|
140
|
+
const total = failed + passed;
|
|
141
|
+
if (failed === 0) {
|
|
142
|
+
if (level === "ultra") return { output: `\u2713 ${passed}/${total}`, strategy: "cargo-test:allpass:ultra" };
|
|
143
|
+
return { output: `PASSED: ${passed}/${total} tests`, strategy: "cargo-test:allpass" };
|
|
144
|
+
}
|
|
145
|
+
const failures = [];
|
|
146
|
+
let inFailure = false;
|
|
147
|
+
let block = [];
|
|
148
|
+
for (const line of lines) {
|
|
149
|
+
if (line.includes("FAILED") || line.includes("panicked at") || line.includes("---- ") && line.includes(" ----")) {
|
|
150
|
+
if (block.length > 0) failures.push(block.join("\n"));
|
|
151
|
+
block = [line];
|
|
152
|
+
inFailure = true;
|
|
153
|
+
} else if (inFailure) {
|
|
154
|
+
if (line.startsWith("test ") && line.includes("...")) {
|
|
155
|
+
failures.push(block.join("\n"));
|
|
156
|
+
block = [];
|
|
157
|
+
inFailure = false;
|
|
158
|
+
} else {
|
|
159
|
+
block.push(line);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (block.length > 0) failures.push(block.join("\n"));
|
|
164
|
+
const header = `FAILED: ${failed}/${total} tests`;
|
|
165
|
+
const maxFailures = level === "ultra" ? 2 : level === "aggressive" ? 3 : 5;
|
|
166
|
+
const shown = failures.slice(0, maxFailures).join("\n\n");
|
|
167
|
+
const extra = failures.length > maxFailures ? `
|
|
168
|
+
\u2026+${failures.length - maxFailures} more` : "";
|
|
169
|
+
return { output: `${header}
|
|
170
|
+
|
|
171
|
+
${shown}${extra}`, strategy: "cargo-test:failures" };
|
|
172
|
+
}
|
|
173
|
+
function filterGoTest(raw, level) {
|
|
174
|
+
const lines = raw.split("\n");
|
|
175
|
+
const failLines = lines.filter((l) => l.startsWith("--- FAIL"));
|
|
176
|
+
const passLines = lines.filter((l) => l.startsWith("--- PASS") || l.startsWith("ok"));
|
|
177
|
+
if (failLines.length === 0) {
|
|
178
|
+
const passed = passLines.length || lines.filter((l) => l.startsWith("ok")).length;
|
|
179
|
+
if (level === "ultra") return { output: `\u2713 ${passed} passed`, strategy: "go-test:allpass:ultra" };
|
|
180
|
+
return { output: `PASSED: ${passed} test(s)`, strategy: "go-test:allpass" };
|
|
181
|
+
}
|
|
182
|
+
const failures = [];
|
|
183
|
+
let inFailure = false;
|
|
184
|
+
let block = [];
|
|
185
|
+
for (const line of lines) {
|
|
186
|
+
if (line.startsWith("--- FAIL")) {
|
|
187
|
+
if (block.length > 0) failures.push(block.join("\n"));
|
|
188
|
+
block = [line];
|
|
189
|
+
inFailure = true;
|
|
190
|
+
} else if (inFailure) {
|
|
191
|
+
if (line.startsWith("--- ") || line.startsWith("FAIL") || line.startsWith("ok")) {
|
|
192
|
+
failures.push(block.join("\n"));
|
|
193
|
+
block = [];
|
|
194
|
+
inFailure = false;
|
|
195
|
+
} else {
|
|
196
|
+
block.push(line);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (block.length > 0) failures.push(block.join("\n"));
|
|
201
|
+
const header = `FAILED: ${failLines.length} test(s)`;
|
|
202
|
+
const maxFailures = level === "ultra" ? 2 : level === "aggressive" ? 3 : 5;
|
|
203
|
+
const shown = failures.slice(0, maxFailures).join("\n\n");
|
|
204
|
+
const extra = failures.length > maxFailures ? `
|
|
205
|
+
\u2026+${failures.length - maxFailures} more` : "";
|
|
206
|
+
return { output: `${header}
|
|
207
|
+
|
|
208
|
+
${shown}${extra}`, strategy: "go-test:failures" };
|
|
209
|
+
}
|
|
210
|
+
function filterRspec(raw, level) {
|
|
211
|
+
const lines = raw.split("\n");
|
|
212
|
+
const summaryMatch = raw.match(/(\d+)\s+examples?,\s+(\d+)\s+failures?/);
|
|
213
|
+
if (!summaryMatch) return { output: raw, strategy: "rspec:passthrough" };
|
|
214
|
+
const total = parseInt(summaryMatch[1]);
|
|
215
|
+
const failed = parseInt(summaryMatch[2]);
|
|
216
|
+
if (failed === 0) {
|
|
217
|
+
if (level === "ultra") return { output: `\u2713 ${total}/${total}`, strategy: "rspec:allpass:ultra" };
|
|
218
|
+
return { output: `PASSED: ${total}/${total} examples`, strategy: "rspec:allpass" };
|
|
219
|
+
}
|
|
220
|
+
const failures = lines.filter((l) => l.includes("Failure/Error") || l.includes("expected") || l.includes("got:"));
|
|
221
|
+
const header = `FAILED: ${failed}/${total} examples`;
|
|
222
|
+
const maxLines = level === "ultra" ? 5 : level === "aggressive" ? 10 : 20;
|
|
223
|
+
const shown = failures.slice(0, maxLines).join("\n");
|
|
224
|
+
return { output: `${header}
|
|
225
|
+
|
|
226
|
+
${shown}`, strategy: "rspec:failures" };
|
|
227
|
+
}
|
|
228
|
+
function filterMinitest(raw, level) {
|
|
229
|
+
const lines = raw.split("\n");
|
|
230
|
+
const summaryMatch = raw.match(/(\d+)\s+runs?,\s+\d+\s+assertions?,\s+(\d+)\s+failures?/);
|
|
231
|
+
if (!summaryMatch) return { output: raw, strategy: "minitest:passthrough" };
|
|
232
|
+
const total = parseInt(summaryMatch[1]);
|
|
233
|
+
const failed = parseInt(summaryMatch[2]);
|
|
234
|
+
if (failed === 0) {
|
|
235
|
+
if (level === "ultra") return { output: `\u2713 ${total}/${total}`, strategy: "minitest:allpass:ultra" };
|
|
236
|
+
return { output: `PASSED: ${total}/${total} tests`, strategy: "minitest:allpass" };
|
|
237
|
+
}
|
|
238
|
+
const failures = lines.filter((l) => l.includes("Failure:") || l.includes("Error:") || l.includes("Expected"));
|
|
239
|
+
const header = `FAILED: ${failed}/${total} tests`;
|
|
240
|
+
const maxLines = level === "ultra" ? 5 : level === "aggressive" ? 10 : 20;
|
|
241
|
+
const shown = failures.slice(0, maxLines).join("\n");
|
|
242
|
+
return { output: `${header}
|
|
243
|
+
|
|
244
|
+
${shown}`, strategy: "minitest:failures" };
|
|
245
|
+
}
|
|
246
|
+
function filterGenericTest(raw, level) {
|
|
247
|
+
const lines = raw.split("\n");
|
|
248
|
+
const failedMatch = raw.match(/(\d+)\s+(?:failed|failing|failure)/i);
|
|
249
|
+
const passedMatch = raw.match(/(\d+)\s+(?:passed|passing|success)/i);
|
|
250
|
+
if (failedMatch && parseInt(failedMatch[1]) === 0 && passedMatch) {
|
|
251
|
+
return { output: `PASSED: ${passedMatch[1]} tests`, strategy: "test:generic:allpass" };
|
|
252
|
+
}
|
|
253
|
+
const important = lines.filter(
|
|
254
|
+
(l) => /fail|error|assert|expect|panic/i.test(l) || /\d+\s+(passed|failed|tests)/i.test(l) || l.startsWith("FAIL") || l.startsWith("ERROR")
|
|
255
|
+
);
|
|
256
|
+
if (important.length > 0 && important.length < lines.length * 0.5) {
|
|
257
|
+
const maxLines = level === "ultra" ? 10 : level === "aggressive" ? 20 : 30;
|
|
258
|
+
return { output: important.slice(0, maxLines).join("\n"), strategy: "test:generic:filtered" };
|
|
259
|
+
}
|
|
260
|
+
return { output: raw, strategy: "test:generic:passthrough" };
|
|
261
|
+
}
|
|
262
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
263
|
+
0 && (module.exports = {
|
|
264
|
+
testFilter
|
|
265
|
+
});
|
|
266
|
+
//# sourceMappingURL=test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/compression/filters/test.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Test runner output filters (jest, vitest, pytest, cargo test, go test, rspec, minitest)\n */\n\nimport type { CommandFilter, FilterResult, CompressorOptions } from '../types';\n\nexport const testFilter: CommandFilter = {\n name: 'test',\n\n matches(command: string): boolean {\n return /\\b(jest|vitest|pytest|cargo\\s+test|go\\s+test|rspec|rake\\s+test|mocha|ava|tap|npm\\s+test|yarn\\s+test|pnpm\\s+test|npx\\s+vitest|npx\\s+jest)\\b/.test(command);\n },\n\n filter(command: string, rawOutput: string, level: CompressorOptions['level']): FilterResult {\n // Detect which runner\n if (/vitest/i.test(command)) return filterVitest(rawOutput, level);\n if (/jest/i.test(command)) return filterJest(rawOutput, level);\n if (/pytest/i.test(command)) return filterPytest(rawOutput, level);\n if (/cargo\\s+test/i.test(command)) return filterCargoTest(rawOutput, level);\n if (/go\\s+test/i.test(command)) return filterGoTest(rawOutput, level);\n if (/rspec/i.test(command)) return filterRspec(rawOutput, level);\n if (/rake\\s+test/i.test(command)) return filterMinitest(rawOutput, level);\n\n // Generic test output\n return filterGenericTest(rawOutput, level);\n },\n};\n\nfunction filterVitest(raw: string, level: CompressorOptions['level']): FilterResult {\n return filterJsTestRunner(raw, level, 'vitest');\n}\n\nfunction filterJest(raw: string, level: CompressorOptions['level']): FilterResult {\n return filterJsTestRunner(raw, level, 'jest');\n}\n\nfunction filterJsTestRunner(raw: string, level: CompressorOptions['level'], runner: string): FilterResult {\n const lines = raw.split('\\n');\n\n // Check if all passed\n const summaryLine = lines.find(l => /Tests:\\s+\\d+/.test(l) || /\\d+\\s+passed/.test(l));\n const failedMatch = raw.match(/(\\d+)\\s+failed/);\n const passedMatch = raw.match(/(\\d+)\\s+passed/);\n const totalMatch = raw.match(/Tests:\\s+(\\d+)/);\n\n const failed = failedMatch ? parseInt(failedMatch[1]) : 0;\n const passed = passedMatch ? parseInt(passedMatch[1]) : 0;\n const total = totalMatch ? parseInt(totalMatch[1]) : (failed + passed);\n\n if (failed === 0) {\n if (level === 'ultra') {\n return { output: `\u2713 ${passed}/${total}`, strategy: `${runner}:allpass:ultra` };\n }\n return { output: `PASSED: ${passed}/${total} tests`, strategy: `${runner}:allpass` };\n }\n\n // Extract failure details\n const failures: string[] = [];\n let inFailure = false;\n let failureBlock: string[] = [];\n\n for (const line of lines) {\n if (line.includes('FAIL') && line.includes('\u25CF') || line.includes('\u2715') || line.includes('\u2717') || line.match(/FAIL\\s+/)) {\n if (failureBlock.length > 0) failures.push(failureBlock.join('\\n'));\n failureBlock = [line];\n inFailure = true;\n } else if (inFailure) {\n if (line.trim() === '' && failureBlock.length > 3) {\n failures.push(failureBlock.join('\\n'));\n failureBlock = [];\n inFailure = false;\n } else {\n failureBlock.push(line);\n }\n }\n }\n if (failureBlock.length > 0) failures.push(failureBlock.join('\\n'));\n\n const header = `FAILED: ${failed}/${total} tests`;\n if (level === 'ultra') {\n const shortFailures = failures.map(f => f.split('\\n')[0]).slice(0, 5);\n return { output: `${header}\\n${shortFailures.join('\\n')}`, strategy: `${runner}:failures:ultra` };\n }\n\n const maxFailures = level === 'aggressive' ? 3 : 5;\n const shown = failures.slice(0, maxFailures).join('\\n\\n');\n const extra = failures.length > maxFailures ? `\\n\u2026+${failures.length - maxFailures} more failures` : '';\n\n return { output: `${header}\\n\\n${shown}${extra}`, strategy: `${runner}:failures` };\n}\n\nfunction filterPytest(raw: string, level: CompressorOptions['level']): FilterResult {\n const lines = raw.split('\\n');\n\n // Summary line: \"X passed, Y failed\"\n const summaryLine = lines.find(l => /\\d+\\s+passed/.test(l) || /\\d+\\s+failed/.test(l));\n const failedMatch = raw.match(/(\\d+)\\s+failed/);\n const passedMatch = raw.match(/(\\d+)\\s+passed/);\n\n const failed = failedMatch ? parseInt(failedMatch[1]) : 0;\n const passed = passedMatch ? parseInt(passedMatch[1]) : 0;\n const total = failed + passed;\n\n if (failed === 0) {\n if (level === 'ultra') return { output: `\u2713 ${passed}/${total}`, strategy: 'pytest:allpass:ultra' };\n return { output: `PASSED: ${passed}/${total} tests`, strategy: 'pytest:allpass' };\n }\n\n // Extract FAILED sections\n const failures: string[] = [];\n let inFailure = false;\n let block: string[] = [];\n\n for (const line of lines) {\n if (line.startsWith('FAILED') || line.startsWith('___ ') || line.includes('FAILURES ___')) {\n if (block.length > 0) failures.push(block.join('\\n'));\n block = [line];\n inFailure = true;\n } else if (inFailure) {\n block.push(line);\n if (block.length > 20) {\n failures.push(block.join('\\n'));\n block = [];\n inFailure = false;\n }\n }\n }\n if (block.length > 0) failures.push(block.join('\\n'));\n\n const header = `FAILED: ${failed}/${total} tests`;\n const maxFailures = level === 'ultra' ? 2 : level === 'aggressive' ? 3 : 5;\n const shown = failures.slice(0, maxFailures).join('\\n\\n');\n const extra = failures.length > maxFailures ? `\\n\u2026+${failures.length - maxFailures} more` : '';\n\n return { output: `${header}\\n\\n${shown}${extra}`, strategy: 'pytest:failures' };\n}\n\nfunction filterCargoTest(raw: string, level: CompressorOptions['level']): FilterResult {\n const lines = raw.split('\\n');\n\n const resultLine = lines.find(l => l.startsWith('test result:'));\n const failedMatch = raw.match(/(\\d+)\\s+failed/);\n const passedMatch = raw.match(/(\\d+)\\s+passed/);\n\n const failed = failedMatch ? parseInt(failedMatch[1]) : 0;\n const passed = passedMatch ? parseInt(passedMatch[1]) : 0;\n const total = failed + passed;\n\n if (failed === 0) {\n if (level === 'ultra') return { output: `\u2713 ${passed}/${total}`, strategy: 'cargo-test:allpass:ultra' };\n return { output: `PASSED: ${passed}/${total} tests`, strategy: 'cargo-test:allpass' };\n }\n\n // Extract failures\n const failures: string[] = [];\n let inFailure = false;\n let block: string[] = [];\n\n for (const line of lines) {\n if (line.includes('FAILED') || line.includes(\"panicked at\") || line.includes('---- ') && line.includes(' ----')) {\n if (block.length > 0) failures.push(block.join('\\n'));\n block = [line];\n inFailure = true;\n } else if (inFailure) {\n if (line.startsWith('test ') && line.includes('...')) {\n failures.push(block.join('\\n'));\n block = [];\n inFailure = false;\n } else {\n block.push(line);\n }\n }\n }\n if (block.length > 0) failures.push(block.join('\\n'));\n\n const header = `FAILED: ${failed}/${total} tests`;\n const maxFailures = level === 'ultra' ? 2 : level === 'aggressive' ? 3 : 5;\n const shown = failures.slice(0, maxFailures).join('\\n\\n');\n const extra = failures.length > maxFailures ? `\\n\u2026+${failures.length - maxFailures} more` : '';\n\n return { output: `${header}\\n\\n${shown}${extra}`, strategy: 'cargo-test:failures' };\n}\n\nfunction filterGoTest(raw: string, level: CompressorOptions['level']): FilterResult {\n const lines = raw.split('\\n');\n\n const failLines = lines.filter(l => l.startsWith('--- FAIL'));\n const passLines = lines.filter(l => l.startsWith('--- PASS') || l.startsWith('ok'));\n\n if (failLines.length === 0) {\n const passed = passLines.length || lines.filter(l => l.startsWith('ok')).length;\n if (level === 'ultra') return { output: `\u2713 ${passed} passed`, strategy: 'go-test:allpass:ultra' };\n return { output: `PASSED: ${passed} test(s)`, strategy: 'go-test:allpass' };\n }\n\n // Extract failure blocks\n const failures: string[] = [];\n let inFailure = false;\n let block: string[] = [];\n\n for (const line of lines) {\n if (line.startsWith('--- FAIL')) {\n if (block.length > 0) failures.push(block.join('\\n'));\n block = [line];\n inFailure = true;\n } else if (inFailure) {\n if (line.startsWith('--- ') || line.startsWith('FAIL') || line.startsWith('ok')) {\n failures.push(block.join('\\n'));\n block = [];\n inFailure = false;\n } else {\n block.push(line);\n }\n }\n }\n if (block.length > 0) failures.push(block.join('\\n'));\n\n const header = `FAILED: ${failLines.length} test(s)`;\n const maxFailures = level === 'ultra' ? 2 : level === 'aggressive' ? 3 : 5;\n const shown = failures.slice(0, maxFailures).join('\\n\\n');\n const extra = failures.length > maxFailures ? `\\n\u2026+${failures.length - maxFailures} more` : '';\n\n return { output: `${header}\\n\\n${shown}${extra}`, strategy: 'go-test:failures' };\n}\n\nfunction filterRspec(raw: string, level: CompressorOptions['level']): FilterResult {\n const lines = raw.split('\\n');\n const summaryMatch = raw.match(/(\\d+)\\s+examples?,\\s+(\\d+)\\s+failures?/);\n\n if (!summaryMatch) return { output: raw, strategy: 'rspec:passthrough' };\n\n const total = parseInt(summaryMatch[1]);\n const failed = parseInt(summaryMatch[2]);\n\n if (failed === 0) {\n if (level === 'ultra') return { output: `\u2713 ${total}/${total}`, strategy: 'rspec:allpass:ultra' };\n return { output: `PASSED: ${total}/${total} examples`, strategy: 'rspec:allpass' };\n }\n\n // Extract failure messages\n const failures = lines.filter(l => l.includes('Failure/Error') || l.includes('expected') || l.includes('got:'));\n const header = `FAILED: ${failed}/${total} examples`;\n const maxLines = level === 'ultra' ? 5 : level === 'aggressive' ? 10 : 20;\n const shown = failures.slice(0, maxLines).join('\\n');\n\n return { output: `${header}\\n\\n${shown}`, strategy: 'rspec:failures' };\n}\n\nfunction filterMinitest(raw: string, level: CompressorOptions['level']): FilterResult {\n const lines = raw.split('\\n');\n const summaryMatch = raw.match(/(\\d+)\\s+runs?,\\s+\\d+\\s+assertions?,\\s+(\\d+)\\s+failures?/);\n\n if (!summaryMatch) return { output: raw, strategy: 'minitest:passthrough' };\n\n const total = parseInt(summaryMatch[1]);\n const failed = parseInt(summaryMatch[2]);\n\n if (failed === 0) {\n if (level === 'ultra') return { output: `\u2713 ${total}/${total}`, strategy: 'minitest:allpass:ultra' };\n return { output: `PASSED: ${total}/${total} tests`, strategy: 'minitest:allpass' };\n }\n\n const failures = lines.filter(l => l.includes('Failure:') || l.includes('Error:') || l.includes('Expected'));\n const header = `FAILED: ${failed}/${total} tests`;\n const maxLines = level === 'ultra' ? 5 : level === 'aggressive' ? 10 : 20;\n const shown = failures.slice(0, maxLines).join('\\n');\n\n return { output: `${header}\\n\\n${shown}`, strategy: 'minitest:failures' };\n}\n\nfunction filterGenericTest(raw: string, level: CompressorOptions['level']): FilterResult {\n const lines = raw.split('\\n');\n\n // Try to detect pass/fail from common patterns\n const failedMatch = raw.match(/(\\d+)\\s+(?:failed|failing|failure)/i);\n const passedMatch = raw.match(/(\\d+)\\s+(?:passed|passing|success)/i);\n\n if (failedMatch && parseInt(failedMatch[1]) === 0 && passedMatch) {\n return { output: `PASSED: ${passedMatch[1]} tests`, strategy: 'test:generic:allpass' };\n }\n\n // Keep only lines that look like failures or summaries\n const important = lines.filter(l =>\n /fail|error|assert|expect|panic/i.test(l) ||\n /\\d+\\s+(passed|failed|tests)/i.test(l) ||\n l.startsWith('FAIL') || l.startsWith('ERROR')\n );\n\n if (important.length > 0 && important.length < lines.length * 0.5) {\n const maxLines = level === 'ultra' ? 10 : level === 'aggressive' ? 20 : 30;\n return { output: important.slice(0, maxLines).join('\\n'), strategy: 'test:generic:filtered' };\n }\n\n return { output: raw, strategy: 'test:generic:passthrough' };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,MAAM,aAA4B;AAAA,EACvC,MAAM;AAAA,EAEN,QAAQ,SAA0B;AAChC,WAAO,6IAA6I,KAAK,OAAO;AAAA,EAClK;AAAA,EAEA,OAAO,SAAiB,WAAmB,OAAiD;AAE1F,QAAI,UAAU,KAAK,OAAO,EAAG,QAAO,aAAa,WAAW,KAAK;AACjE,QAAI,QAAQ,KAAK,OAAO,EAAG,QAAO,WAAW,WAAW,KAAK;AAC7D,QAAI,UAAU,KAAK,OAAO,EAAG,QAAO,aAAa,WAAW,KAAK;AACjE,QAAI,gBAAgB,KAAK,OAAO,EAAG,QAAO,gBAAgB,WAAW,KAAK;AAC1E,QAAI,aA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K,UAAU,SAAS,MAAM,SAAS,KAAK;AACjE,UAAM,WAAW,UAAU,UAAU,KAAK,UAAU,eAAe,KAAK;AACxE,WAAO,EAAE,QAAQ,UAAU,MAAM,GAAG,QAAQ,EAAE,KAAK,IAAI,GAAG,UAAU,wBAAwB;AAAA,EAC9F;AAEA,SAAO,EAAE,QAAQ,KAAK,UAAU,2BAA2B;AAC7D;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var compression_exports = {};
|
|
20
|
+
__export(compression_exports, {
|
|
21
|
+
compress: () => compress,
|
|
22
|
+
detectCommandFamily: () => detectCommandFamily,
|
|
23
|
+
estimateTokens: () => estimateTokens
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(compression_exports);
|
|
26
|
+
var import_git = require("./filters/git");
|
|
27
|
+
var import_test = require("./filters/test");
|
|
28
|
+
var import_lint = require("./filters/lint");
|
|
29
|
+
var import_files = require("./filters/files");
|
|
30
|
+
var import_docker = require("./filters/docker");
|
|
31
|
+
var import_package = require("./filters/package");
|
|
32
|
+
var import_aws = require("./filters/aws");
|
|
33
|
+
var import_github = require("./filters/github");
|
|
34
|
+
var import_misc = require("./filters/misc");
|
|
35
|
+
var import_generic = require("./filters/generic");
|
|
36
|
+
const FILTERS = [
|
|
37
|
+
import_git.gitFilter,
|
|
38
|
+
import_test.testFilter,
|
|
39
|
+
import_lint.lintFilter,
|
|
40
|
+
import_misc.miscFilter,
|
|
41
|
+
// grep, diff, curl, wget, playwright, prisma
|
|
42
|
+
import_files.filesFilter,
|
|
43
|
+
import_docker.dockerFilter,
|
|
44
|
+
import_package.packageFilter,
|
|
45
|
+
import_aws.awsFilter,
|
|
46
|
+
import_github.githubFilter,
|
|
47
|
+
import_generic.genericFilter
|
|
48
|
+
// Always last — catches everything
|
|
49
|
+
];
|
|
50
|
+
function estimateTokens(text) {
|
|
51
|
+
if (!text) return 0;
|
|
52
|
+
return Math.ceil(text.length / 4);
|
|
53
|
+
}
|
|
54
|
+
const DEFAULT_OPTIONS = {
|
|
55
|
+
level: "normal",
|
|
56
|
+
preserveErrors: true
|
|
57
|
+
};
|
|
58
|
+
function compress(command, rawOutput, opts) {
|
|
59
|
+
const options = { ...DEFAULT_OPTIONS, ...opts };
|
|
60
|
+
if (!rawOutput || !rawOutput.trim()) {
|
|
61
|
+
return {
|
|
62
|
+
output: rawOutput || "",
|
|
63
|
+
originalTokens: 0,
|
|
64
|
+
compressedTokens: 0,
|
|
65
|
+
savings: 0,
|
|
66
|
+
strategy: "empty",
|
|
67
|
+
commandFamily: "none"
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const originalTokens = estimateTokens(rawOutput);
|
|
71
|
+
const filter = FILTERS.find((f) => f.matches(command));
|
|
72
|
+
if (!filter) {
|
|
73
|
+
return {
|
|
74
|
+
output: rawOutput,
|
|
75
|
+
originalTokens,
|
|
76
|
+
compressedTokens: originalTokens,
|
|
77
|
+
savings: 0,
|
|
78
|
+
strategy: "none",
|
|
79
|
+
commandFamily: "unknown"
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
if (options.preserveErrors && isErrorOutput(rawOutput, command)) {
|
|
83
|
+
const result2 = filter.filter(command, rawOutput, "normal");
|
|
84
|
+
const compressedTokens2 = estimateTokens(result2.output);
|
|
85
|
+
return {
|
|
86
|
+
output: result2.output,
|
|
87
|
+
originalTokens,
|
|
88
|
+
compressedTokens: compressedTokens2,
|
|
89
|
+
savings: Math.round((originalTokens - compressedTokens2) / originalTokens * 100),
|
|
90
|
+
strategy: result2.strategy + ":error-preserved",
|
|
91
|
+
commandFamily: filter.name
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
const result = filter.filter(command, rawOutput, options.level);
|
|
95
|
+
let output = result.output;
|
|
96
|
+
if (options.maxOutputTokens && estimateTokens(output) > options.maxOutputTokens) {
|
|
97
|
+
const maxChars = options.maxOutputTokens * 4;
|
|
98
|
+
output = output.slice(0, maxChars) + "\n\u2026(truncated to token limit)";
|
|
99
|
+
}
|
|
100
|
+
const compressedTokens = estimateTokens(output);
|
|
101
|
+
const savings = originalTokens > 0 ? Math.round((originalTokens - compressedTokens) / originalTokens * 100) : 0;
|
|
102
|
+
return {
|
|
103
|
+
output,
|
|
104
|
+
originalTokens,
|
|
105
|
+
compressedTokens,
|
|
106
|
+
savings: Math.max(0, savings),
|
|
107
|
+
// Never negative
|
|
108
|
+
strategy: result.strategy,
|
|
109
|
+
commandFamily: filter.name
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function detectCommandFamily(command) {
|
|
113
|
+
for (const filter of FILTERS) {
|
|
114
|
+
if (filter !== import_generic.genericFilter && filter.matches(command)) {
|
|
115
|
+
return filter.name;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return "other";
|
|
119
|
+
}
|
|
120
|
+
function isErrorOutput(output, _command) {
|
|
121
|
+
const errorIndicators = [
|
|
122
|
+
/^error/im,
|
|
123
|
+
/\bfailed\b/i,
|
|
124
|
+
/\bpanic\b/i,
|
|
125
|
+
/\bfatal\b/i,
|
|
126
|
+
/exit\s+code\s+[1-9]/i,
|
|
127
|
+
/\bException\b/,
|
|
128
|
+
/\bTraceback\b/,
|
|
129
|
+
/\bsegfault\b/i,
|
|
130
|
+
/\bSIGSEGV\b/,
|
|
131
|
+
/\bSIGABRT\b/
|
|
132
|
+
];
|
|
133
|
+
const head = output.slice(0, 500);
|
|
134
|
+
const tail = output.slice(-500);
|
|
135
|
+
const sample = head + tail;
|
|
136
|
+
return errorIndicators.some((re) => re.test(sample));
|
|
137
|
+
}
|
|
138
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
139
|
+
0 && (module.exports = {
|
|
140
|
+
compress,
|
|
141
|
+
detectCommandFamily,
|
|
142
|
+
estimateTokens
|
|
143
|
+
});
|
|
144
|
+
//# sourceMappingURL=index.js.map
|