trimprompt 1.0.30 → 1.0.31
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 +13 -0
- package/api-proxy.js +1 -1
- package/cache-manager.js +1 -1
- package/cache.js +1 -1
- package/ccr.js +1 -1
- package/cli.js +1 -1
- package/dashboard.js +1 -1
- package/executor.js +1 -1
- package/file-watcher.js +1 -1
- package/filters/devops.js +1 -1
- package/filters/generic.js +1 -1
- package/filters/git.js +1 -1
- package/filters/go.js +99 -1
- package/filters/index.js +185 -1
- package/filters/js.js +78 -1
- package/filters/python.js +130 -1
- package/filters/rust.js +115 -1
- package/filters/shell.js +395 -1
- package/hooks/claude-hook.js +79 -1
- package/mcp.js +132 -1
- package/package.json +1 -4
- package/proxy-conv.js +181 -1
- package/proxy-daemon.js +382 -1
- package/proxy-resp.js +1 -1
- package/redactor.js +1 -1
- package/seed.js +1 -1
- package/shims.js +1 -1
- package/simulate.js +1 -1
- package/sync.js +1 -1
- package/tracker.js +1 -1
- package/traffic-interceptor.js +1 -1
package/filters/index.js
CHANGED
|
@@ -1 +1,185 @@
|
|
|
1
|
-
'use strict';const a0_0x1a8d2d=a0_0x552f;(function(_0x5e0343,_0x4d325c){const _0x175db1=a0_0x552f,_0x1708ac=_0x5e0343();while(!![]){try{const _0x2dbc9f=-parseInt(_0x175db1(0xe5))/0x1*(-parseInt(_0x175db1(0xfd))/0x2)+parseInt(_0x175db1(0xd4))/0x3*(-parseInt(_0x175db1(0xfc))/0x4)+parseInt(_0x175db1(0x102))/0x5+parseInt(_0x175db1(0xf9))/0x6+parseInt(_0x175db1(0xe7))/0x7*(-parseInt(_0x175db1(0x109))/0x8)+-parseInt(_0x175db1(0x104))/0x9*(-parseInt(_0x175db1(0xf7))/0xa)+-parseInt(_0x175db1(0xb0))/0xb;if(_0x2dbc9f===_0x4d325c)break;else _0x1708ac['push'](_0x1708ac['shift']());}catch(_0x3c7c25){_0x1708ac['push'](_0x1708ac['shift']());}}}(a0_0x4cec,0xa19da));Object[a0_0x1a8d2d(0xd6)](exports,a0_0x1a8d2d(0x11a),{'value':!![]}),exports[a0_0x1a8d2d(0xf8)]=exports[a0_0x1a8d2d(0xe8)]=void 0x0,exports['compressOutput']=compressOutput,exports[a0_0x1a8d2d(0xdd)]=rewriteCommand;const generic_1=require('./generic'),git_1=require('./git'),python_1=require(a0_0x1a8d2d(0xd7)),js_1=require(a0_0x1a8d2d(0xe9)),shell_1=require('./shell'),rust_1=require(a0_0x1a8d2d(0xd3)),go_1=require(a0_0x1a8d2d(0xbc)),devops_1=require(a0_0x1a8d2d(0xeb)),redactor_1=require('../redactor'),tracker_1=require('../tracker');exports[a0_0x1a8d2d(0xe8)]={'secretsFound':0x0,'secretTypes':[]},exports[a0_0x1a8d2d(0xf8)]=[];function a0_0x4cec(){const _0x466b16=['trim\x20cargo','23476794CKauoZ','\x20tree\x20','filterTree','\x20tree','trim\x20kubectl','filterNpmInstall','cargo\x20build','match','yadm\x20log','trim\x20grep','secretsFound','tracker','./go','[minified\x20file]','filterJestVitest','filterDockerPs','jest','push','text','filterPipInstall','git\x20show','trim\x20glab','secretTypes','filterDockerLogs','trim','npm\x20run\x20test','trim\x20ls','some','trim\x20git','startsWith','go\x20vet','---','trim\x20gh','pattern','toLowerCase','./rust','222bIDshD','cargo\x20clippy','defineProperty','./python','filterGoVet','ansi_strip','npm\x20i\x20','trim\x20docker','pnpm\x20install','rewriteCommand','endsWith','trim\x20npx','ruff\x20check','filterRuff','filterGitDiff','filterKubectl','getConfig','12114WuBctG','\x20ls','539LaTHfW','lastRedactAudit','./js','filter','./devops','yarn\x20test','collapseWhitespace','filterDockerImages','pip3\x20install','yadm\x20diff','softTruncate','includes','[code\x20skeleton]','ruff\x20','npm\x20i','npm\x20test','1746790cVNLNP','lastFeatures','7472892JhmAiy','trim\x20pytest','trim\x20pip','38860LjDxbZ','158ixMFKU','filterGitStatus','[lock\x20file]','filterPytest','get','5106510ACxMhN','whitespace','45wNfGfm','binary','filterFind','\x20ls\x20','redactWithAudit','60472CPQfUd','collapseDuplicates','test','trim\x20go','kubectl','filterGrep','git\x20log','redact','filterCat','skeleton','features_enabled','json_crusher','trim\x20','yadm\x20status','length','lines\x20truncated','cargo\x20test','__esModule'];a0_0x4cec=function(){return _0x466b16;};return a0_0x4cec();}function isFeatureEnabled(_0x93c8bd){const _0x15e11a=a0_0x1a8d2d;try{const _0x5050e0=tracker_1[_0x15e11a(0xbb)][_0x15e11a(0xe4)](),_0x5e6dfe=_0x5050e0[_0x15e11a(0x113)];if(!_0x5e6dfe||_0x5e6dfe[_0x93c8bd]===undefined)return!![];return _0x5e6dfe[_0x93c8bd]!==![];}catch{return!![];}}function a0_0x552f(_0x2036f8,_0x2f3cbc){_0x2036f8=_0x2036f8-0xaf;const _0x4cecc4=a0_0x4cec();let _0x552f4b=_0x4cecc4[_0x2036f8];return _0x552f4b;}function compressOutput(_0x437124,_0x1e3714,_0x49e54d,_0x1aa897=!![]){const _0xe8a016=a0_0x1a8d2d,_0x3c67f1=_0x437124['trim']();let _0x1fafc3=_0x1e3714;_0x49e54d[_0xe8a016(0xc8)]()[_0xe8a016(0x117)]>0x0&&(_0x1fafc3=_0x1e3714+'\x0a'+_0x49e54d);let _0xce41cd=isFeatureEnabled(_0xe8a016(0xd9))?(0x0,generic_1['stripAnsi'])(_0x1fafc3):_0x1fafc3;const _0x21a06c=[];if(_0xce41cd['length']<_0x1fafc3['length'])_0x21a06c[_0xe8a016(0xc1)](_0xe8a016(0xd9));const _0x16b3d6=(_0x181282,_0x5dade6)=>{const _0x4d45ab=_0xe8a016;return _0x21a06c[_0x4d45ab(0xc1)](_0x181282),exports[_0x4d45ab(0xf8)]=_0x21a06c,_0x5dade6;};if(_0x1aa897&&isFeatureEnabled(_0xe8a016(0x110))){const _0x300300=redactor_1['redactor'][_0xe8a016(0x108)](_0xce41cd);_0xce41cd=_0x300300[_0xe8a016(0xc2)],exports['lastRedactAudit']={'secretsFound':_0x300300[_0xe8a016(0xba)],'secretTypes':_0x300300[_0xe8a016(0xc6)]};if(_0x300300[_0xe8a016(0xba)]>0x0)_0x21a06c[_0xe8a016(0xc1)](_0xe8a016(0x110));}else exports[_0xe8a016(0xe8)]={'secretsFound':0x0,'secretTypes':[]};const _0x53caef=_0x3c67f1[_0xe8a016(0xd2)](),_0x4fc495=isFeatureEnabled('filter');try{if(_0x4fc495){if(_0x53caef['includes']('git\x20status')||_0x53caef[_0xe8a016(0xf2)](_0xe8a016(0x116)))return _0x16b3d6(_0xe8a016(0xea),(0x0,git_1[_0xe8a016(0xfe)])(_0xce41cd));if(_0x53caef[_0xe8a016(0xf2)](_0xe8a016(0x10f))||_0x53caef[_0xe8a016(0xf2)](_0xe8a016(0xb8)))return _0x16b3d6(_0xe8a016(0xea),(0x0,git_1['filterGitLog'])(_0xce41cd));if(_0x53caef[_0xe8a016(0xf2)]('git\x20diff')||_0x53caef[_0xe8a016(0xf2)](_0xe8a016(0xc4))||_0x53caef[_0xe8a016(0xf2)](_0xe8a016(0xf0)))return _0x16b3d6('filter',(0x0,git_1[_0xe8a016(0xe2)])(_0xce41cd));if(_0x53caef['includes']('pytest')||_0x53caef[_0xe8a016(0xb7)](/python3?\s+-m\s+pytest/))return _0x16b3d6(_0xe8a016(0xea),(0x0,python_1[_0xe8a016(0x100)])(_0xce41cd));if(_0x53caef[_0xe8a016(0xf2)]('pip\x20install')||_0x53caef[_0xe8a016(0xf2)](_0xe8a016(0xef)))return _0x16b3d6('filter',(0x0,python_1[_0xe8a016(0xc3)])(_0xce41cd));if(_0x53caef[_0xe8a016(0xf2)](_0xe8a016(0xe0))||_0x53caef[_0xe8a016(0xf2)](_0xe8a016(0xf4)))return _0x16b3d6('filter',(0x0,devops_1[_0xe8a016(0xe1)])(_0xce41cd));if(_0x53caef[_0xe8a016(0xf2)]('npm\x20install')||_0x53caef[_0xe8a016(0xf2)](_0xe8a016(0xda))||_0x53caef[_0xe8a016(0xde)](_0xe8a016(0xf5))||_0x53caef['includes'](_0xe8a016(0xdc))||_0x53caef['includes']('yarn\x20install'))return _0x16b3d6(_0xe8a016(0xea),(0x0,js_1[_0xe8a016(0xb5)])(_0xce41cd));if(_0x53caef['includes'](_0xe8a016(0xc0))||_0x53caef[_0xe8a016(0xf2)]('vitest'))return _0x16b3d6(_0xe8a016(0xea),(0x0,js_1[_0xe8a016(0xbe)])(_0xce41cd));if(_0x53caef[_0xe8a016(0xf2)](_0xe8a016(0xf6))||_0x53caef[_0xe8a016(0xf2)]('pnpm\x20test')||_0x53caef[_0xe8a016(0xf2)](_0xe8a016(0xec))||_0x53caef[_0xe8a016(0xf2)](_0xe8a016(0xc9)))return _0x16b3d6('filter',(0x0,js_1[_0xe8a016(0xbe)])(_0xce41cd));if(_0x53caef[_0xe8a016(0xf2)](_0xe8a016(0x119)))return _0x16b3d6('filter',(0x0,rust_1['filterCargoTest'])(_0xce41cd));if(_0x53caef['includes'](_0xe8a016(0xb6))||_0x53caef[_0xe8a016(0xf2)]('cargo\x20check')||_0x53caef[_0xe8a016(0xf2)](_0xe8a016(0xd5)))return _0x16b3d6(_0xe8a016(0xea),(0x0,rust_1['filterCargoBuild'])(_0xce41cd));if(_0x53caef['includes']('go\x20test'))return _0x16b3d6(_0xe8a016(0xea),(0x0,go_1['filterGoTest'])(_0xce41cd));if(_0x53caef[_0xe8a016(0xf2)](_0xe8a016(0xce)))return _0x16b3d6(_0xe8a016(0xea),(0x0,go_1[_0xe8a016(0xd8)])(_0xce41cd));if(_0x53caef[_0xe8a016(0xb7)](/docker\s+ps/))return _0x16b3d6('filter',(0x0,devops_1[_0xe8a016(0xbf)])(_0xce41cd));if(_0x53caef[_0xe8a016(0xb7)](/docker\s+images/))return _0x16b3d6(_0xe8a016(0xea),(0x0,devops_1[_0xe8a016(0xee)])(_0xce41cd));if(_0x53caef[_0xe8a016(0xb7)](/docker\s+logs/))return _0x16b3d6(_0xe8a016(0xea),(0x0,devops_1[_0xe8a016(0xc7)])(_0xce41cd));if(_0x53caef[_0xe8a016(0xf2)](_0xe8a016(0x10d))){const _0x3c103=_0x53caef[_0xe8a016(0xb7)](/kubectl\s+(get|logs|describe|apply)/),_0x484187=_0x3c103?_0x3c103[0x1]:_0xe8a016(0x101);return _0x16b3d6('filter',(0x0,devops_1[_0xe8a016(0xe3)])(_0xce41cd,_0x484187));}if(_0x53caef[_0xe8a016(0xb7)](/^(ls|dir)(\s|$)/)||_0x53caef[_0xe8a016(0xf2)](_0xe8a016(0x107))||_0x53caef[_0xe8a016(0xde)](_0xe8a016(0xe6)))return _0x16b3d6(_0xe8a016(0xea),(0x0,shell_1['filterLs'])(_0xce41cd));if(_0x53caef['match'](/^tree(\s|$)/)||_0x53caef[_0xe8a016(0xf2)](_0xe8a016(0xb1))||_0x53caef[_0xe8a016(0xde)](_0xe8a016(0xb3)))return _0x16b3d6(_0xe8a016(0xea),(0x0,shell_1[_0xe8a016(0xb2)])(_0xce41cd));if(_0x53caef['match'](/^(cat|head|tail|read|bat)(\s|$)/)){const _0x2da928=(0x0,shell_1[_0xe8a016(0x111)])(_0xce41cd,_0x3c67f1);if(_0x2da928['includes'](_0xe8a016(0xff)))_0x21a06c['push']('lock');else{if(_0x2da928['includes']('[binary')||_0x2da928[_0xe8a016(0xf2)](_0xe8a016(0xbd)))_0x21a06c['push'](_0xe8a016(0x105));else{if(_0x2da928['includes'](_0xe8a016(0xf3)))_0x21a06c[_0xe8a016(0xc1)](_0xe8a016(0x112));else{if(_0x2da928['includes']('|\x20')&&_0x2da928[_0xe8a016(0xf2)](_0xe8a016(0xcf))&&_0x2da928[_0xe8a016(0x117)]<_0xce41cd[_0xe8a016(0x117)]*0.5)_0x21a06c[_0xe8a016(0xc1)](_0xe8a016(0x114));else{if(_0x2da928[_0xe8a016(0xf2)](_0xe8a016(0x118)))_0x21a06c['push'](_0xe8a016(0xea));}}}}if(_0x2da928[_0xe8a016(0x117)]<_0xce41cd[_0xe8a016(0x117)]&&!_0x21a06c[_0xe8a016(0xcb)](_0xfa0fe4=>_0xfa0fe4!==_0xe8a016(0xd9)&&_0xfa0fe4!=='redact'))_0x21a06c[_0xe8a016(0xc1)](_0xe8a016(0xea));return exports[_0xe8a016(0xf8)]=_0x21a06c,_0x2da928;}if(_0x53caef[_0xe8a016(0xb7)](/^find(\s|$)/))return _0x16b3d6(_0xe8a016(0xea),(0x0,shell_1[_0xe8a016(0x106)])(_0xce41cd));if(_0x53caef['match'](/^(grep|rg|ripgrep)(\s|$)/))return _0x16b3d6(_0xe8a016(0xea),(0x0,shell_1[_0xe8a016(0x10e)])(_0xce41cd));}}catch(_0x4eb51b){}return isFeatureEnabled('whitespace')&&(_0xce41cd=(0x0,generic_1[_0xe8a016(0xed)])(_0xce41cd),_0x21a06c[_0xe8a016(0xc1)](_0xe8a016(0x103))),_0xce41cd=(0x0,generic_1[_0xe8a016(0x10a)])(_0xce41cd),_0xce41cd=(0x0,generic_1[_0xe8a016(0xf1)])(_0xce41cd,0x4e20),exports['lastFeatures']=_0x21a06c,_0xce41cd;}const REWRITE_RULES=[{'pattern':/^(?:git|yadm)\s+(?:-[Cc]\s+\S+\s+)*(status|log|diff|show|add|commit|push|pull|branch|fetch|stash|worktree)/,'prefix':a0_0x1a8d2d(0xcc)},{'pattern':/^gh\s+(pr|issue|run|repo|api|release)/,'prefix':a0_0x1a8d2d(0xd0)},{'pattern':/^glab\s+(mr|issue|ci|pipeline|api|release)/,'prefix':a0_0x1a8d2d(0xc5)},{'pattern':/^cargo\s+(build|test|clippy|check|fmt|install)/,'prefix':a0_0x1a8d2d(0xaf)},{'pattern':/^pnpm\s+(exec|i|install|list|ls|outdated|run|run-script)/,'prefix':'trim\x20pnpm'},{'pattern':/^npm\s+(exec|run|run-script|rum|urn|x|test)(\s|$)/,'prefix':'trim\x20npm'},{'pattern':/^npx\s+/,'prefix':a0_0x1a8d2d(0xdf)},{'pattern':/^(cat|head|tail)\s+/,'prefix':'trim\x20read'},{'pattern':/^(rg|grep)\s+/,'prefix':a0_0x1a8d2d(0xb9)},{'pattern':/^ls(\s|$)/,'prefix':a0_0x1a8d2d(0xca)},{'pattern':/^tree(\s|$)/,'prefix':'trim\x20tree'},{'pattern':/^find\s+/,'prefix':'trim\x20find'},{'pattern':/^docker\s+(ps|images|logs|run|exec|build|compose)/,'prefix':a0_0x1a8d2d(0xdb)},{'pattern':/^kubectl\s+(get|logs|describe|apply)/,'prefix':a0_0x1a8d2d(0xb4)},{'pattern':/^(python3?\s+-m\s+)?pytest(\s|$)/,'prefix':a0_0x1a8d2d(0xfa)},{'pattern':/^ruff\s+(check|format)/,'prefix':'trim\x20ruff'},{'pattern':/^(pip3?|uv\s+pip)\s+(list|outdated|install|show)/,'prefix':a0_0x1a8d2d(0xfb)},{'pattern':/^go\s+(test|build|vet)/,'prefix':a0_0x1a8d2d(0x10c)}];function rewriteCommand(_0x3fd896){const _0x3f1dc6=a0_0x1a8d2d,_0x3e327b=_0x3fd896[_0x3f1dc6(0xc8)]();if(_0x3e327b[_0x3f1dc6(0xcd)](_0x3f1dc6(0x115)))return _0x3e327b;for(const _0x445cac of REWRITE_RULES){if(_0x445cac[_0x3f1dc6(0xd1)][_0x3f1dc6(0x10b)](_0x3e327b))return _0x3f1dc6(0x115)+_0x3e327b;}return _0x3e327b;}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.lastFeatures = exports.lastRedactAudit = void 0;
|
|
4
|
+
exports.compressOutput = compressOutput;
|
|
5
|
+
exports.rewriteCommand = rewriteCommand;
|
|
6
|
+
const generic_1 = require("./generic");
|
|
7
|
+
const git_1 = require("./git");
|
|
8
|
+
const python_1 = require("./python");
|
|
9
|
+
const js_1 = require("./js");
|
|
10
|
+
const shell_1 = require("./shell");
|
|
11
|
+
const rust_1 = require("./rust");
|
|
12
|
+
const go_1 = require("./go");
|
|
13
|
+
const devops_1 = require("./devops");
|
|
14
|
+
const redactor_1 = require("../redactor");
|
|
15
|
+
const tracker_1 = require("../tracker");
|
|
16
|
+
exports.lastRedactAudit = { secretsFound: 0, secretTypes: [] };
|
|
17
|
+
exports.lastFeatures = [];
|
|
18
|
+
function isFeatureEnabled(key) {
|
|
19
|
+
try {
|
|
20
|
+
const config = tracker_1.tracker.getConfig();
|
|
21
|
+
const fe = config.features_enabled;
|
|
22
|
+
if (!fe || fe[key] === undefined)
|
|
23
|
+
return true;
|
|
24
|
+
return fe[key] !== false;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function compressOutput(commandLine, stdout, stderr, redactionEnabled = true) {
|
|
31
|
+
const cmd = commandLine.trim();
|
|
32
|
+
let combinedOutput = stdout;
|
|
33
|
+
if (stderr.trim().length > 0) {
|
|
34
|
+
combinedOutput = `${stdout}\n${stderr}`;
|
|
35
|
+
}
|
|
36
|
+
let processed = isFeatureEnabled('ansi_strip') ? (0, generic_1.stripAnsi)(combinedOutput) : combinedOutput;
|
|
37
|
+
const features = [];
|
|
38
|
+
if (processed.length < combinedOutput.length)
|
|
39
|
+
features.push('ansi_strip');
|
|
40
|
+
const tagged = (tag, result) => { features.push(tag); exports.lastFeatures = features; return result; };
|
|
41
|
+
if (redactionEnabled && isFeatureEnabled('redact')) {
|
|
42
|
+
const result = redactor_1.redactor.redactWithAudit(processed);
|
|
43
|
+
processed = result.text;
|
|
44
|
+
exports.lastRedactAudit = { secretsFound: result.secretsFound, secretTypes: result.secretTypes };
|
|
45
|
+
if (result.secretsFound > 0)
|
|
46
|
+
features.push('redact');
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
exports.lastRedactAudit = { secretsFound: 0, secretTypes: [] };
|
|
50
|
+
}
|
|
51
|
+
const cmdLower = cmd.toLowerCase();
|
|
52
|
+
const filtersOn = isFeatureEnabled('filter');
|
|
53
|
+
try {
|
|
54
|
+
if (filtersOn) {
|
|
55
|
+
if (cmdLower.includes('git status') || cmdLower.includes('yadm status')) {
|
|
56
|
+
return tagged('filter', (0, git_1.filterGitStatus)(processed));
|
|
57
|
+
}
|
|
58
|
+
if (cmdLower.includes('git log') || cmdLower.includes('yadm log')) {
|
|
59
|
+
return tagged('filter', (0, git_1.filterGitLog)(processed));
|
|
60
|
+
}
|
|
61
|
+
if (cmdLower.includes('git diff') || cmdLower.includes('git show') || cmdLower.includes('yadm diff')) {
|
|
62
|
+
return tagged('filter', (0, git_1.filterGitDiff)(processed));
|
|
63
|
+
}
|
|
64
|
+
if (cmdLower.includes('pytest') || cmdLower.match(/python3?\s+-m\s+pytest/)) {
|
|
65
|
+
return tagged('filter', (0, python_1.filterPytest)(processed));
|
|
66
|
+
}
|
|
67
|
+
if (cmdLower.includes('pip install') || cmdLower.includes('pip3 install')) {
|
|
68
|
+
return tagged('filter', (0, python_1.filterPipInstall)(processed));
|
|
69
|
+
}
|
|
70
|
+
if (cmdLower.includes('ruff check') || cmdLower.includes('ruff ')) {
|
|
71
|
+
return tagged('filter', (0, devops_1.filterRuff)(processed));
|
|
72
|
+
}
|
|
73
|
+
if (cmdLower.includes('npm install') ||
|
|
74
|
+
cmdLower.includes('npm i ') ||
|
|
75
|
+
cmdLower.endsWith('npm i') ||
|
|
76
|
+
cmdLower.includes('pnpm install') ||
|
|
77
|
+
cmdLower.includes('yarn install')) {
|
|
78
|
+
return tagged('filter', (0, js_1.filterNpmInstall)(processed));
|
|
79
|
+
}
|
|
80
|
+
if (cmdLower.includes('jest') || cmdLower.includes('vitest')) {
|
|
81
|
+
return tagged('filter', (0, js_1.filterJestVitest)(processed));
|
|
82
|
+
}
|
|
83
|
+
if (cmdLower.includes('npm test') || cmdLower.includes('pnpm test') || cmdLower.includes('yarn test') || cmdLower.includes('npm run test')) {
|
|
84
|
+
return tagged('filter', (0, js_1.filterJestVitest)(processed));
|
|
85
|
+
}
|
|
86
|
+
if (cmdLower.includes('cargo test')) {
|
|
87
|
+
return tagged('filter', (0, rust_1.filterCargoTest)(processed));
|
|
88
|
+
}
|
|
89
|
+
if (cmdLower.includes('cargo build') || cmdLower.includes('cargo check') || cmdLower.includes('cargo clippy')) {
|
|
90
|
+
return tagged('filter', (0, rust_1.filterCargoBuild)(processed));
|
|
91
|
+
}
|
|
92
|
+
if (cmdLower.includes('go test')) {
|
|
93
|
+
return tagged('filter', (0, go_1.filterGoTest)(processed));
|
|
94
|
+
}
|
|
95
|
+
if (cmdLower.includes('go vet')) {
|
|
96
|
+
return tagged('filter', (0, go_1.filterGoVet)(processed));
|
|
97
|
+
}
|
|
98
|
+
if (cmdLower.match(/docker\s+ps/)) {
|
|
99
|
+
return tagged('filter', (0, devops_1.filterDockerPs)(processed));
|
|
100
|
+
}
|
|
101
|
+
if (cmdLower.match(/docker\s+images/)) {
|
|
102
|
+
return tagged('filter', (0, devops_1.filterDockerImages)(processed));
|
|
103
|
+
}
|
|
104
|
+
if (cmdLower.match(/docker\s+logs/)) {
|
|
105
|
+
return tagged('filter', (0, devops_1.filterDockerLogs)(processed));
|
|
106
|
+
}
|
|
107
|
+
if (cmdLower.includes('kubectl')) {
|
|
108
|
+
const subMatch = cmdLower.match(/kubectl\s+(get|logs|describe|apply)/);
|
|
109
|
+
const sub = subMatch ? subMatch[1] : 'get';
|
|
110
|
+
return tagged('filter', (0, devops_1.filterKubectl)(processed, sub));
|
|
111
|
+
}
|
|
112
|
+
if (cmdLower.match(/^(ls|dir)(\s|$)/) || cmdLower.includes(' ls ') || cmdLower.endsWith(' ls')) {
|
|
113
|
+
return tagged('filter', (0, shell_1.filterLs)(processed));
|
|
114
|
+
}
|
|
115
|
+
if (cmdLower.match(/^tree(\s|$)/) || cmdLower.includes(' tree ') || cmdLower.endsWith(' tree')) {
|
|
116
|
+
return tagged('filter', (0, shell_1.filterTree)(processed));
|
|
117
|
+
}
|
|
118
|
+
if (cmdLower.match(/^(cat|head|tail|read|bat)(\s|$)/)) {
|
|
119
|
+
const catResult = (0, shell_1.filterCat)(processed, cmd);
|
|
120
|
+
if (catResult.includes('[lock file]'))
|
|
121
|
+
features.push('lock');
|
|
122
|
+
else if (catResult.includes('[binary') || catResult.includes('[minified file]'))
|
|
123
|
+
features.push('binary');
|
|
124
|
+
else if (catResult.includes('[code skeleton]'))
|
|
125
|
+
features.push('skeleton');
|
|
126
|
+
else if (catResult.includes('| ') && catResult.includes('---') && catResult.length < processed.length * 0.5)
|
|
127
|
+
features.push('json_crusher');
|
|
128
|
+
else if (catResult.includes('lines truncated'))
|
|
129
|
+
features.push('filter');
|
|
130
|
+
if (catResult.length < processed.length && !features.some(f => f !== 'ansi_strip' && f !== 'redact'))
|
|
131
|
+
features.push('filter');
|
|
132
|
+
exports.lastFeatures = features;
|
|
133
|
+
return catResult;
|
|
134
|
+
}
|
|
135
|
+
if (cmdLower.match(/^find(\s|$)/)) {
|
|
136
|
+
return tagged('filter', (0, shell_1.filterFind)(processed));
|
|
137
|
+
}
|
|
138
|
+
if (cmdLower.match(/^(grep|rg|ripgrep)(\s|$)/)) {
|
|
139
|
+
return tagged('filter', (0, shell_1.filterGrep)(processed));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
catch (err) {
|
|
144
|
+
}
|
|
145
|
+
if (isFeatureEnabled('whitespace')) {
|
|
146
|
+
processed = (0, generic_1.collapseWhitespace)(processed);
|
|
147
|
+
features.push('whitespace');
|
|
148
|
+
}
|
|
149
|
+
processed = (0, generic_1.collapseDuplicates)(processed);
|
|
150
|
+
processed = (0, generic_1.softTruncate)(processed, 20000);
|
|
151
|
+
exports.lastFeatures = features;
|
|
152
|
+
return processed;
|
|
153
|
+
}
|
|
154
|
+
const REWRITE_RULES = [
|
|
155
|
+
{ pattern: /^(?:git|yadm)\s+(?:-[Cc]\s+\S+\s+)*(status|log|diff|show|add|commit|push|pull|branch|fetch|stash|worktree)/, prefix: 'trim git' },
|
|
156
|
+
{ pattern: /^gh\s+(pr|issue|run|repo|api|release)/, prefix: 'trim gh' },
|
|
157
|
+
{ pattern: /^glab\s+(mr|issue|ci|pipeline|api|release)/, prefix: 'trim glab' },
|
|
158
|
+
{ pattern: /^cargo\s+(build|test|clippy|check|fmt|install)/, prefix: 'trim cargo' },
|
|
159
|
+
{ pattern: /^pnpm\s+(exec|i|install|list|ls|outdated|run|run-script)/, prefix: 'trim pnpm' },
|
|
160
|
+
{ pattern: /^npm\s+(exec|run|run-script|rum|urn|x|test)(\s|$)/, prefix: 'trim npm' },
|
|
161
|
+
{ pattern: /^npx\s+/, prefix: 'trim npx' },
|
|
162
|
+
{ pattern: /^(cat|head|tail)\s+/, prefix: 'trim read' },
|
|
163
|
+
{ pattern: /^(rg|grep)\s+/, prefix: 'trim grep' },
|
|
164
|
+
{ pattern: /^ls(\s|$)/, prefix: 'trim ls' },
|
|
165
|
+
{ pattern: /^tree(\s|$)/, prefix: 'trim tree' },
|
|
166
|
+
{ pattern: /^find\s+/, prefix: 'trim find' },
|
|
167
|
+
{ pattern: /^docker\s+(ps|images|logs|run|exec|build|compose)/, prefix: 'trim docker' },
|
|
168
|
+
{ pattern: /^kubectl\s+(get|logs|describe|apply)/, prefix: 'trim kubectl' },
|
|
169
|
+
{ pattern: /^(python3?\s+-m\s+)?pytest(\s|$)/, prefix: 'trim pytest' },
|
|
170
|
+
{ pattern: /^ruff\s+(check|format)/, prefix: 'trim ruff' },
|
|
171
|
+
{ pattern: /^(pip3?|uv\s+pip)\s+(list|outdated|install|show)/, prefix: 'trim pip' },
|
|
172
|
+
{ pattern: /^go\s+(test|build|vet)/, prefix: 'trim go' }
|
|
173
|
+
];
|
|
174
|
+
function rewriteCommand(commandLine) {
|
|
175
|
+
const trimmed = commandLine.trim();
|
|
176
|
+
if (trimmed.startsWith('trim ')) {
|
|
177
|
+
return trimmed;
|
|
178
|
+
}
|
|
179
|
+
for (const rule of REWRITE_RULES) {
|
|
180
|
+
if (rule.pattern.test(trimmed)) {
|
|
181
|
+
return `trim ${trimmed}`;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return trimmed;
|
|
185
|
+
}
|
package/filters/js.js
CHANGED
|
@@ -1 +1,78 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.filterNpmInstall = filterNpmInstall;
|
|
4
|
+
exports.filterJestVitest = filterJestVitest;
|
|
5
|
+
function filterNpmInstall(stdout) {
|
|
6
|
+
const cleanText = stdout.replace(/\r/g, '\n');
|
|
7
|
+
const lines = cleanText.split('\n');
|
|
8
|
+
const result = [];
|
|
9
|
+
for (const line of lines) {
|
|
10
|
+
const trimmed = line.trim();
|
|
11
|
+
if (trimmed.includes('added ') ||
|
|
12
|
+
trimmed.includes('removed ') ||
|
|
13
|
+
trimmed.includes('audited ') ||
|
|
14
|
+
trimmed.includes('up to date') ||
|
|
15
|
+
trimmed.includes('found ')) {
|
|
16
|
+
if (!trimmed.includes('%') && !trimmed.startsWith('⠋') && !trimmed.startsWith('⠙')) {
|
|
17
|
+
result.push(trimmed);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const output = result.join('\n').trim();
|
|
22
|
+
return output.length > 0 ? output : "NPM: Packages verified/installed successfully";
|
|
23
|
+
}
|
|
24
|
+
function filterJestVitest(stdout) {
|
|
25
|
+
const lines = stdout.split('\n');
|
|
26
|
+
let passed = 0;
|
|
27
|
+
let failed = 0;
|
|
28
|
+
let total = 0;
|
|
29
|
+
const failureLines = [];
|
|
30
|
+
let inFailureSection = false;
|
|
31
|
+
for (const line of lines) {
|
|
32
|
+
const trimmed = line.trim();
|
|
33
|
+
if (trimmed.startsWith('Tests:') || trimmed.includes('Test Files:')) {
|
|
34
|
+
const matchPassed = trimmed.match(/(\d+)\s+passed/);
|
|
35
|
+
const matchFailed = trimmed.match(/(\d+)\s+failed/);
|
|
36
|
+
const matchTotal = trimmed.match(/(\d+)\s+total/);
|
|
37
|
+
if (matchPassed)
|
|
38
|
+
passed = parseInt(matchPassed[1]);
|
|
39
|
+
if (matchFailed)
|
|
40
|
+
failed = parseInt(matchFailed[1]);
|
|
41
|
+
if (matchTotal)
|
|
42
|
+
total = parseInt(matchTotal[1]);
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (trimmed.startsWith('❯') || trimmed.startsWith('●') || trimmed.startsWith('FAIL ')) {
|
|
46
|
+
inFailureSection = true;
|
|
47
|
+
}
|
|
48
|
+
if (inFailureSection) {
|
|
49
|
+
if (trimmed.length > 0 && !trimmed.startsWith('Test Suites:') && !trimmed.startsWith('Tests:')) {
|
|
50
|
+
failureLines.push(line);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (total === 0 && passed === 0 && failed === 0) {
|
|
55
|
+
if (stdout.includes('PASS') && !stdout.includes('FAIL')) {
|
|
56
|
+
const match = stdout.match(/(\d+)\s+passed/);
|
|
57
|
+
const count = match ? match[1] : "all";
|
|
58
|
+
return `Test Runner: ${count} passed`;
|
|
59
|
+
}
|
|
60
|
+
return stdout;
|
|
61
|
+
}
|
|
62
|
+
if (failed === 0 && passed > 0) {
|
|
63
|
+
return `Test Runner: ${passed} passed`;
|
|
64
|
+
}
|
|
65
|
+
const result = [`Test Runner: ${passed} passed, ${failed} failed (${total} total)`];
|
|
66
|
+
if (failureLines.length > 0) {
|
|
67
|
+
result.push("\nFailures:");
|
|
68
|
+
const limit = 25;
|
|
69
|
+
const printedLines = failureLines.slice(0, limit);
|
|
70
|
+
for (const line of printedLines) {
|
|
71
|
+
result.push(` ${line}`);
|
|
72
|
+
}
|
|
73
|
+
if (failureLines.length > limit) {
|
|
74
|
+
result.push(` ... (${failureLines.length - limit} lines of trace details truncated)`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return result.join('\n');
|
|
78
|
+
}
|
package/filters/python.js
CHANGED
|
@@ -1 +1,130 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.filterPytest = filterPytest;
|
|
4
|
+
exports.filterPipInstall = filterPipInstall;
|
|
5
|
+
function filterPytest(stdout) {
|
|
6
|
+
const lines = stdout.split('\n');
|
|
7
|
+
let passed = 0;
|
|
8
|
+
let failed = 0;
|
|
9
|
+
let skipped = 0;
|
|
10
|
+
let xfailed = 0;
|
|
11
|
+
let xpassed = 0;
|
|
12
|
+
const failureBlocks = [];
|
|
13
|
+
let currentFailure = [];
|
|
14
|
+
let inFailureSection = false;
|
|
15
|
+
for (const line of lines) {
|
|
16
|
+
const trimmed = line.trim();
|
|
17
|
+
if (trimmed.startsWith('=== FAILURES ===') || trimmed.startsWith('=== ERRORS ===')) {
|
|
18
|
+
inFailureSection = true;
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
else if (trimmed.startsWith('=== short test summary info ===') || (trimmed.startsWith('===') && trimmed.includes('passed'))) {
|
|
22
|
+
inFailureSection = false;
|
|
23
|
+
if (currentFailure.length > 0) {
|
|
24
|
+
failureBlocks.push(currentFailure);
|
|
25
|
+
currentFailure = [];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (inFailureSection) {
|
|
29
|
+
if (trimmed.startsWith('___')) {
|
|
30
|
+
if (currentFailure.length > 0) {
|
|
31
|
+
failureBlocks.push(currentFailure);
|
|
32
|
+
currentFailure = [];
|
|
33
|
+
}
|
|
34
|
+
currentFailure.push(trimmed);
|
|
35
|
+
}
|
|
36
|
+
else if (trimmed.length > 0) {
|
|
37
|
+
currentFailure.push(line);
|
|
38
|
+
}
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (trimmed.startsWith('===') && trimmed.includes(' in ')) {
|
|
42
|
+
const matchPassed = trimmed.match(/(\d+)\s+passed/);
|
|
43
|
+
const matchFailed = trimmed.match(/(\d+)\s+failed/);
|
|
44
|
+
const matchSkipped = trimmed.match(/(\d+)\s+skipped/);
|
|
45
|
+
const matchXfailed = trimmed.match(/(\d+)\s+xfailed/);
|
|
46
|
+
const matchXpassed = trimmed.match(/(\d+)\s+xpassed/);
|
|
47
|
+
if (matchPassed)
|
|
48
|
+
passed = parseInt(matchPassed[1]);
|
|
49
|
+
if (matchFailed)
|
|
50
|
+
failed = parseInt(matchFailed[1]);
|
|
51
|
+
if (matchSkipped)
|
|
52
|
+
skipped = parseInt(matchSkipped[1]);
|
|
53
|
+
if (matchXfailed)
|
|
54
|
+
xfailed = parseInt(matchXfailed[1]);
|
|
55
|
+
if (matchXpassed)
|
|
56
|
+
xpassed = parseInt(matchXpassed[1]);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (currentFailure.length > 0) {
|
|
60
|
+
failureBlocks.push(currentFailure);
|
|
61
|
+
}
|
|
62
|
+
if (passed === 0 && failed === 0 && skipped === 0 && xfailed === 0 && xpassed === 0) {
|
|
63
|
+
if (stdout.includes('passed') && !stdout.includes('failed')) {
|
|
64
|
+
return "Pytest: All tests passed";
|
|
65
|
+
}
|
|
66
|
+
return stdout;
|
|
67
|
+
}
|
|
68
|
+
if (failed === 0 && passed > 0 && skipped === 0 && xfailed === 0 && xpassed === 0) {
|
|
69
|
+
return `Pytest: ${passed} passed`;
|
|
70
|
+
}
|
|
71
|
+
const summaryParts = [];
|
|
72
|
+
summaryParts.push(`Pytest: ${passed} passed`);
|
|
73
|
+
if (failed > 0)
|
|
74
|
+
summaryParts.push(`${failed} failed`);
|
|
75
|
+
if (skipped > 0)
|
|
76
|
+
summaryParts.push(`${skipped} skipped`);
|
|
77
|
+
if (xfailed > 0)
|
|
78
|
+
summaryParts.push(`${xfailed} xfailed`);
|
|
79
|
+
if (xpassed > 0)
|
|
80
|
+
summaryParts.push(`${xpassed} xpassed (warning!)`);
|
|
81
|
+
const result = [summaryParts.join(', ')];
|
|
82
|
+
if (failureBlocks.length > 0) {
|
|
83
|
+
result.push("\nFailures:");
|
|
84
|
+
const limit = 3;
|
|
85
|
+
const printedFailures = failureBlocks.slice(0, limit);
|
|
86
|
+
for (let i = 0; i < printedFailures.length; i++) {
|
|
87
|
+
const block = printedFailures[i];
|
|
88
|
+
const header = block[0].replace(/_/g, '').trim();
|
|
89
|
+
result.push(` ${i + 1}. [FAIL] ${header}`);
|
|
90
|
+
const body = block.slice(1);
|
|
91
|
+
const essentialLines = body.filter(line => {
|
|
92
|
+
const t = line.trim();
|
|
93
|
+
return t.startsWith('>') || t.startsWith('E ') || t.includes('.py:') || t.includes('AssertionError:');
|
|
94
|
+
});
|
|
95
|
+
for (const line of essentialLines.slice(0, 8)) {
|
|
96
|
+
result.push(` ${line}`);
|
|
97
|
+
}
|
|
98
|
+
if (essentialLines.length > 8) {
|
|
99
|
+
result.push(` ... (${essentialLines.length - 8} lines of stacktrace truncated)`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (failureBlocks.length > limit) {
|
|
103
|
+
result.push(` ... +${failureBlocks.length - limit} more failures truncated`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return result.join('\n');
|
|
107
|
+
}
|
|
108
|
+
function filterPipInstall(stdout) {
|
|
109
|
+
const lines = stdout.split('\n');
|
|
110
|
+
const installed = [];
|
|
111
|
+
for (const line of lines) {
|
|
112
|
+
const trimmed = line.trim();
|
|
113
|
+
if (trimmed.startsWith('Successfully installed')) {
|
|
114
|
+
installed.push(trimmed);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (installed.length > 0) {
|
|
118
|
+
return installed.join('\n');
|
|
119
|
+
}
|
|
120
|
+
return lines
|
|
121
|
+
.filter(line => {
|
|
122
|
+
const t = line.trim();
|
|
123
|
+
return !t.startsWith('Collecting') &&
|
|
124
|
+
!t.startsWith('Downloading') &&
|
|
125
|
+
!t.includes('Using cached') &&
|
|
126
|
+
!t.startsWith('Requirement already satisfied');
|
|
127
|
+
})
|
|
128
|
+
.join('\n')
|
|
129
|
+
.trim();
|
|
130
|
+
}
|
package/filters/rust.js
CHANGED
|
@@ -1 +1,115 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.filterCargoTest = filterCargoTest;
|
|
4
|
+
exports.filterCargoBuild = filterCargoBuild;
|
|
5
|
+
function filterCargoTest(stdout) {
|
|
6
|
+
const lines = stdout.split('\n');
|
|
7
|
+
let passed = 0;
|
|
8
|
+
let failed = 0;
|
|
9
|
+
let ignored = 0;
|
|
10
|
+
let measured = 0;
|
|
11
|
+
const failedTests = [];
|
|
12
|
+
let inFailures = false;
|
|
13
|
+
let currentFailure = [];
|
|
14
|
+
for (const line of lines) {
|
|
15
|
+
const trimmed = line.trim();
|
|
16
|
+
const resultMatch = trimmed.match(/test result:\s*(\w+)\.\s*(\d+)\s+passed;\s*(\d+)\s+failed;\s*(\d+)\s+ignored;\s*(\d+)\s+measured/);
|
|
17
|
+
if (resultMatch) {
|
|
18
|
+
passed += parseInt(resultMatch[2]);
|
|
19
|
+
failed += parseInt(resultMatch[3]);
|
|
20
|
+
ignored += parseInt(resultMatch[4]);
|
|
21
|
+
measured += parseInt(resultMatch[5]);
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
if (trimmed === 'failures:' || trimmed === '---- failures ----') {
|
|
25
|
+
inFailures = true;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (inFailures) {
|
|
29
|
+
if (trimmed.startsWith('---- ') && trimmed.endsWith(' ----')) {
|
|
30
|
+
if (currentFailure.length > 0)
|
|
31
|
+
failedTests.push(currentFailure.join('\n'));
|
|
32
|
+
currentFailure = [trimmed.replace(/^-+\s*/, '').replace(/\s*-+$/, '')];
|
|
33
|
+
}
|
|
34
|
+
else if (trimmed === 'failures:' || trimmed.startsWith('test result:')) {
|
|
35
|
+
if (currentFailure.length > 0)
|
|
36
|
+
failedTests.push(currentFailure.join('\n'));
|
|
37
|
+
currentFailure = [];
|
|
38
|
+
inFailures = false;
|
|
39
|
+
}
|
|
40
|
+
else if (trimmed.length > 0) {
|
|
41
|
+
currentFailure.push(line);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (currentFailure.length > 0)
|
|
46
|
+
failedTests.push(currentFailure.join('\n'));
|
|
47
|
+
if (passed === 0 && failed === 0 && ignored === 0) {
|
|
48
|
+
if (stdout.includes('test result: ok'))
|
|
49
|
+
return "Cargo test: all tests passed";
|
|
50
|
+
return stdout;
|
|
51
|
+
}
|
|
52
|
+
if (failed === 0) {
|
|
53
|
+
const parts = [`Cargo test: ${passed} passed`];
|
|
54
|
+
if (ignored > 0)
|
|
55
|
+
parts.push(`${ignored} ignored`);
|
|
56
|
+
return parts.join(', ');
|
|
57
|
+
}
|
|
58
|
+
const result = [`Cargo test: ${passed} passed, ${failed} failed, ${ignored} ignored`];
|
|
59
|
+
if (failedTests.length > 0) {
|
|
60
|
+
result.push("\nFailures:");
|
|
61
|
+
const limit = 3;
|
|
62
|
+
for (let i = 0; i < Math.min(failedTests.length, limit); i++) {
|
|
63
|
+
const failLines = failedTests[i].split('\n');
|
|
64
|
+
result.push(` ${i + 1}. ${failLines[0]}`);
|
|
65
|
+
const body = failLines.slice(1);
|
|
66
|
+
const essential = body.filter(l => l.trim().startsWith('thread') || l.includes('panicked') || l.includes('assert') || l.includes('left:') || l.includes('right:'));
|
|
67
|
+
for (const l of essential.slice(0, 5)) {
|
|
68
|
+
result.push(` ${l.trim()}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (failedTests.length > limit) {
|
|
72
|
+
result.push(` ... +${failedTests.length - limit} more failures`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return result.join('\n');
|
|
76
|
+
}
|
|
77
|
+
function filterCargoBuild(stdout) {
|
|
78
|
+
const lines = stdout.split('\n');
|
|
79
|
+
const warnings = [];
|
|
80
|
+
const errors = [];
|
|
81
|
+
let compiled = 0;
|
|
82
|
+
for (const line of lines) {
|
|
83
|
+
const trimmed = line.trim();
|
|
84
|
+
if (trimmed.startsWith('Compiling '))
|
|
85
|
+
compiled++;
|
|
86
|
+
else if (trimmed.startsWith('warning[') || trimmed.startsWith('warning:'))
|
|
87
|
+
warnings.push(trimmed);
|
|
88
|
+
else if (trimmed.startsWith('error[') || trimmed.startsWith('error:'))
|
|
89
|
+
errors.push(trimmed);
|
|
90
|
+
}
|
|
91
|
+
if (errors.length === 0 && warnings.length === 0) {
|
|
92
|
+
return compiled > 0 ? `Cargo: compiled ${compiled} crates successfully` : stdout.trim();
|
|
93
|
+
}
|
|
94
|
+
const result = [];
|
|
95
|
+
if (errors.length > 0) {
|
|
96
|
+
result.push(`Cargo: ${errors.length} errors, ${warnings.length} warnings`);
|
|
97
|
+
result.push("\nErrors:");
|
|
98
|
+
for (const e of errors.slice(0, 5))
|
|
99
|
+
result.push(` ${e}`);
|
|
100
|
+
if (errors.length > 5)
|
|
101
|
+
result.push(` ... +${errors.length - 5} more errors`);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
result.push(`Cargo: compiled ${compiled} crates, ${warnings.length} warnings`);
|
|
105
|
+
}
|
|
106
|
+
if (warnings.length > 0 && warnings.length <= 5) {
|
|
107
|
+
result.push("\nWarnings:");
|
|
108
|
+
for (const w of warnings)
|
|
109
|
+
result.push(` ${w}`);
|
|
110
|
+
}
|
|
111
|
+
else if (warnings.length > 5) {
|
|
112
|
+
result.push(`\n(${warnings.length} warnings — run cargo clippy for details)`);
|
|
113
|
+
}
|
|
114
|
+
return result.join('\n');
|
|
115
|
+
}
|