mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
chore: add buildOutput RTK filter, drop legacy cloud sync, internal cleanup
- feat(rtk): buildOutput filter + autodetect for npm/yarn/cargo logs - chore: remove unused cloud sync module and related routes - ui: hide deprecated providers (qwen, iflow, antigravity) - chore: minor tray/cli/internal adjustments
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
// Port of auto_detect_filter (rtk/src/cmds/system/pipe_cmd.rs:132-188) + JS extras
|
||||
// Order: git-diff → git-status → grep → find → tree → ls → search-list
|
||||
// Order: git-diff → git-status → build-output → grep → find → tree → ls → search-list
|
||||
// → read-numbered → dedup-log → smart-truncate → null
|
||||
import { DETECT_WINDOW, READ_NUMBERED_MIN_HIT_RATIO, SMART_TRUNCATE_MIN_LINES } from "./constants.js";
|
||||
import { gitDiff } from "./filters/gitDiff.js";
|
||||
import { gitStatus } from "./filters/gitStatus.js";
|
||||
import { buildOutput } from "./filters/buildOutput.js";
|
||||
import { grep } from "./filters/grep.js";
|
||||
import { find } from "./filters/find.js";
|
||||
import { dedupLog } from "./filters/dedupLog.js";
|
||||
@@ -17,6 +18,7 @@ const RE_GIT_DIFF = /^diff --git /m;
|
||||
const RE_GIT_DIFF_HUNK = /^@@ /m;
|
||||
const RE_GIT_STATUS = /^On branch |^nothing to commit|^Changes (not |to be )|^Untracked files:/m;
|
||||
const RE_PORCELAIN = /^[ MADRCU?!][ MADRCU?!] \S/m;
|
||||
const RE_BUILD_OUTPUT = /^(npm (warn|error|ERR!)|yarn (warn|error)|\s*Compiling\s+\S+|\s*Downloading\s+\S+|added \d+ package|\[ERROR\]|BUILD (SUCCESS|FAILED)|\s*Finished\s+|Successfully (installed|built)|ERROR:)/im;
|
||||
const RE_TREE_GLYPH = /[├└]──|│ /;
|
||||
const RE_LS_ROW = /^[-dlbcps][rwx-]{9}/m;
|
||||
const RE_LS_TOTAL = /^total \d+$/m;
|
||||
@@ -26,7 +28,12 @@ export function autoDetectFilter(text) {
|
||||
const head = text.length > DETECT_WINDOW ? text.slice(0, DETECT_WINDOW) : text;
|
||||
|
||||
if (RE_GIT_DIFF.test(head) || RE_GIT_DIFF_HUNK.test(head)) return gitDiff;
|
||||
if (RE_GIT_STATUS.test(head) || isMostlyPorcelain(head)) return gitStatus;
|
||||
if (RE_GIT_STATUS.test(head)) return gitStatus;
|
||||
|
||||
// Build output BEFORE porcelain check: prevents cargo "Compiling" misdetection as git-status
|
||||
if (RE_BUILD_OUTPUT.test(head)) return buildOutput;
|
||||
|
||||
if (isMostlyPorcelain(head)) return gitStatus;
|
||||
|
||||
const lines = head.split("\n");
|
||||
const nonEmpty = lines.filter(l => l.trim().length > 0);
|
||||
|
||||
@@ -50,5 +50,6 @@ export const FILTERS = {
|
||||
DEDUP_LOG: "dedup-log",
|
||||
SMART_TRUNCATE: "smart-truncate",
|
||||
READ_NUMBERED: "read-numbered",
|
||||
SEARCH_LIST: "search-list"
|
||||
SEARCH_LIST: "search-list",
|
||||
BUILD_OUTPUT: "build-output"
|
||||
};
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
// Compress build tool output (npm, cargo, pip, maven, gradle, etc.)
|
||||
// Keeps: errors, warnings, final summary
|
||||
// Strips: progress logs, verbose "Compiling X" lists, download logs
|
||||
|
||||
// Cargo/rustc error continuation: " --> file:line", " |", "N | code", " = note: ..."
|
||||
const RE_CARGO_ERR_CONT = /^\s*(-->|\||\d+\s*\||=)/;
|
||||
const DEPRECATION_KEEP = 3;
|
||||
|
||||
export function buildOutput(input) {
|
||||
const lines = input.split("\n");
|
||||
if (lines.length === 0) return input;
|
||||
|
||||
const errors = [];
|
||||
const warnings = [];
|
||||
const deprecations = [];
|
||||
let summary = null;
|
||||
let compilingCount = 0;
|
||||
let downloadingCount = 0;
|
||||
let inCargoError = false;
|
||||
|
||||
for (const line of lines) {
|
||||
const trimmed = line.trim();
|
||||
|
||||
// Continuation of cargo error block: keep verbatim while in block
|
||||
if (inCargoError) {
|
||||
if (!trimmed) { inCargoError = false; continue; }
|
||||
if (RE_CARGO_ERR_CONT.test(line)) { errors.push(line); continue; }
|
||||
inCargoError = false;
|
||||
}
|
||||
|
||||
if (!trimmed) continue;
|
||||
|
||||
if (/^npm (ERR!|error)/i.test(trimmed) || /^yarn error/i.test(trimmed)) {
|
||||
errors.push(line);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (/^npm warn deprecated/i.test(trimmed)) {
|
||||
deprecations.push(line);
|
||||
continue;
|
||||
}
|
||||
if (/^npm warn/i.test(trimmed) || /^yarn warn/i.test(trimmed)) {
|
||||
warnings.push(line);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (/^error(\[|:)/i.test(trimmed) || trimmed.startsWith("error -->")) {
|
||||
errors.push(line);
|
||||
inCargoError = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (/^warning(\[|:)/i.test(trimmed) || trimmed.startsWith("warning -->")) {
|
||||
warnings.push(line);
|
||||
inCargoError = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (/^ERROR:/i.test(trimmed)) {
|
||||
errors.push(line);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (/^\[ERROR\]/i.test(trimmed) || /^BUILD FAILED/i.test(trimmed)) {
|
||||
errors.push(line);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (/^\[WARNING\]/i.test(trimmed)) {
|
||||
warnings.push(line);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (/^\s*Compiling\s+\S+/i.test(trimmed)) {
|
||||
compilingCount++;
|
||||
continue;
|
||||
}
|
||||
if (/^\s*Downloading\s+\S+/i.test(trimmed) || /^Fetching\s+/i.test(trimmed)) {
|
||||
downloadingCount++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (
|
||||
/^(added|removed|changed|audited|installed)\s+\d+\s+package/i.test(trimmed) ||
|
||||
/^\s*Finished\s+/i.test(trimmed) ||
|
||||
/^BUILD SUCCESS/i.test(trimmed) ||
|
||||
/^\d+\s+(vulnerabilities|packages?|warnings?|errors?)/i.test(trimmed) ||
|
||||
/^Successfully (installed|built)/i.test(trimmed) ||
|
||||
/^To address .* issues/i.test(trimmed) ||
|
||||
/^Run `npm (audit|fund)`/i.test(trimmed) ||
|
||||
/packages are looking for funding/i.test(trimmed)
|
||||
) {
|
||||
summary = summary ? `${summary}\n${line}` : line;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
let out = "";
|
||||
|
||||
// Keep first N deprecations verbatim (package name + reason), count the rest
|
||||
const keepDep = deprecations.slice(0, DEPRECATION_KEEP);
|
||||
for (const d of keepDep) out += `${d}\n`;
|
||||
if (deprecations.length > DEPRECATION_KEEP) {
|
||||
out += `... +${deprecations.length - DEPRECATION_KEEP} more deprecated packages\n`;
|
||||
}
|
||||
|
||||
if (compilingCount > 0) {
|
||||
out += `Compiled ${compilingCount} packages\n`;
|
||||
}
|
||||
if (downloadingCount > 0) {
|
||||
out += `Downloaded ${downloadingCount} packages\n`;
|
||||
}
|
||||
|
||||
for (const e of errors) out += `${e}\n`;
|
||||
|
||||
const keepWarnings = warnings.slice(0, 5);
|
||||
for (const w of keepWarnings) out += `${w}\n`;
|
||||
if (warnings.length > 5) {
|
||||
out += `... +${warnings.length - 5} more warnings\n`;
|
||||
}
|
||||
|
||||
if (summary) out += `${summary}\n`;
|
||||
|
||||
return out.replace(/\n+$/, "") || input;
|
||||
}
|
||||
|
||||
buildOutput.filterName = "build-output";
|
||||
Reference in New Issue
Block a user