@getchomp/cli 0.2.42 → 0.2.44
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/LICENSE +21 -0
- package/dist/commands/analyze.js +19 -2
- package/dist/commands/init.js +12 -7
- package/dist/commands/ui.d.ts +1 -0
- package/dist/commands/ui.js +47 -4
- package/dist/commands/uninstall.js +27 -13
- package/dist/ports/portHydrator.d.ts +5 -0
- package/dist/ports/portHydrator.js +175 -9
- package/dist/server/graphLayoutState.js +0 -2
- package/dist/server/hostedUiProxy.d.ts +13 -0
- package/dist/server/hostedUiProxy.js +137 -0
- package/dist/server/routes/authSourceRoutes.js +11 -0
- package/dist/server/routes/layoutRoutes.d.ts +5 -0
- package/dist/server/routes/layoutRoutes.js +32 -14
- package/dist/utils/branding.d.ts +56 -13
- package/dist/utils/branding.js +413 -222
- package/dist/utils/masterContext.d.ts +10 -0
- package/dist/utils/masterContext.js +84 -1
- package/dist/visualizer/cloudLayoutClient.d.ts +6 -1
- package/dist/visualizer/cloudLayoutClient.js +15 -1
- package/package.json +7 -6
package/dist/utils/branding.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { dirname, relative, resolve } from "node:path";
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync, writeSync } from "node:fs";
|
|
2
|
+
import { dirname, relative, resolve, sep } from "node:path";
|
|
3
3
|
import { spawn } from "node:child_process";
|
|
4
4
|
import { Worker } from "node:worker_threads";
|
|
5
5
|
import * as readline from "node:readline";
|
|
6
6
|
import Database from "better-sqlite3";
|
|
7
|
-
import { auditFrameworkCoverage, buildWorkspaceRegistry, collectLedgerSignalCandidates, computeStructuralHealthMetrics, detectFrameworksFromPackageJson as coreDetectFrameworksFromPackageJson, } from "@getchomp/core";
|
|
7
|
+
import { CORE_EXTRACTOR_VERSION, auditFrameworkCoverage, buildWorkspaceRegistry, collectFiles, collectLedgerSignalCandidates, computeStructuralHealthMetrics, detectFrameworksFromPackageJson as coreDetectFrameworksFromPackageJson, } from "@getchomp/core";
|
|
8
8
|
import { getChompMasterRoot, hasPrivateResearchLedger, resolveRepoName, } from "./masterContext.js";
|
|
9
9
|
// ---------------------------------------------------------------------------
|
|
10
10
|
// Zero-Dependency ANSI Terminal Styling (Chomp Brand Yellow: #face1d)
|
|
@@ -80,30 +80,76 @@ function visualWidth(str) {
|
|
|
80
80
|
}
|
|
81
81
|
return width;
|
|
82
82
|
}
|
|
83
|
-
function
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
function stripAnsi(str) {
|
|
84
|
+
return str.replace(/\x1b\[[0-9;]*m/g, "");
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Resolves the safe horizontal column budget for stacked CLI sections so output
|
|
88
|
+
* never wraps on default 80-column terminals (while adapting down to narrower panes).
|
|
89
|
+
*/
|
|
90
|
+
export function resolveMaxTerminalCols(overrideCols) {
|
|
91
|
+
const rawCols = typeof overrideCols === "number" && overrideCols > 0
|
|
92
|
+
? overrideCols
|
|
93
|
+
: typeof process.stdout.columns === "number" && process.stdout.columns > 0
|
|
94
|
+
? process.stdout.columns
|
|
95
|
+
: 80;
|
|
96
|
+
return Math.max(40, Math.min(78, rawCols - 2));
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Truncates an ANSI-colored string so its visible terminal column width never exceeds `maxCols`.
|
|
100
|
+
*/
|
|
101
|
+
export function truncateAnsiToCols(str, maxCols) {
|
|
102
|
+
if (maxCols <= 1)
|
|
103
|
+
return "";
|
|
104
|
+
const plainWidth = visualWidth(stripAnsi(str));
|
|
105
|
+
if (plainWidth <= maxCols)
|
|
106
|
+
return str;
|
|
107
|
+
const limit = maxCols - 1;
|
|
108
|
+
let visible = 0;
|
|
109
|
+
let out = "";
|
|
110
|
+
let i = 0;
|
|
111
|
+
let sawAnsi = false;
|
|
112
|
+
while (i < str.length) {
|
|
113
|
+
if (str.charCodeAt(i) === 0x1b && str[i + 1] === "[") {
|
|
114
|
+
const mIdx = str.indexOf("m", i + 2);
|
|
115
|
+
if (mIdx !== -1) {
|
|
116
|
+
out += str.slice(i, mIdx + 1);
|
|
117
|
+
sawAnsi = true;
|
|
118
|
+
i = mIdx + 1;
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const code = str.codePointAt(i) ?? 0;
|
|
123
|
+
const ch = String.fromCodePoint(code);
|
|
124
|
+
const chWidth = (code >= 0xff01 && code <= 0xff60) || (code >= 0xffe0 && code <= 0xffe6)
|
|
125
|
+
? 2
|
|
126
|
+
: 1;
|
|
127
|
+
if (visible + chWidth > limit) {
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
out += ch;
|
|
131
|
+
visible += chWidth;
|
|
132
|
+
i += ch.length;
|
|
133
|
+
}
|
|
134
|
+
return `${out}…${sawAnsi ? "\x1b[0m" : ""}`;
|
|
87
135
|
}
|
|
88
136
|
/**
|
|
89
137
|
* Renders the Chomp Unicode logo mark (or chomping frame) in brand yellow
|
|
90
|
-
*
|
|
138
|
+
* stacked cleanly above the wordmark and tagline so output stays <80 columns.
|
|
91
139
|
*/
|
|
92
|
-
export function renderChompBanner(subtitle, frame = "open") {
|
|
93
|
-
const
|
|
94
|
-
3: `${ansi.yellowBold("c h o m p")} ${ansi.dim("v0.1.0")}`,
|
|
95
|
-
5: ansi.bold("The live map of your codebase."),
|
|
96
|
-
6: ansi.dim(subtitle || "See how routes, components, and functions actually connect."),
|
|
97
|
-
8: ansi.dim("Proven from code · Shared by you and your AI agent."),
|
|
98
|
-
};
|
|
140
|
+
export function renderChompBanner(subtitle, frame = "open", maxColsOverride) {
|
|
141
|
+
const maxCols = resolveMaxTerminalCols(maxColsOverride);
|
|
99
142
|
const sourceLines = frame === "chomp" ? CHOMP_CHOMPING_FRAME_LINES : CHOMP_UNICODE_LOGO_LINES;
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
const right = sideText[idx] ? ` ${sideText[idx]}` : "";
|
|
104
|
-
return `${coloredLogo}${right}`;
|
|
143
|
+
const logoLines = sourceLines.map((rawLine) => {
|
|
144
|
+
const trimmed = rawLine.trimEnd();
|
|
145
|
+
return trimmed.length > 0 ? ansi.yellow(trimmed) : "";
|
|
105
146
|
});
|
|
106
|
-
|
|
147
|
+
const stackedInfoLines = [
|
|
148
|
+
truncateAnsiToCols(` ${ansi.yellowBold("c h o m p")} ${ansi.dim(`v${CORE_EXTRACTOR_VERSION}`)} ${ansi.dim("·")} ${ansi.bold("The live map of your codebase.")}`, maxCols),
|
|
149
|
+
truncateAnsiToCols(` ${ansi.dim(subtitle || "See how routes, components, and functions actually connect.")}`, maxCols),
|
|
150
|
+
truncateAnsiToCols(` ${ansi.dim("Proven from code · Shared by you and your AI agent.")}`, maxCols),
|
|
151
|
+
];
|
|
152
|
+
return ["", ...logoLines, "", ...stackedInfoLines, ""].join("\n");
|
|
107
153
|
}
|
|
108
154
|
export function printChompBanner(subtitle, frame = "open") {
|
|
109
155
|
console.log(renderChompBanner(subtitle, frame));
|
|
@@ -114,7 +160,7 @@ export function printChompBanner(subtitle, frame = "open") {
|
|
|
114
160
|
* Falls back to printing the static banner once when stdout is not an interactive TTY.
|
|
115
161
|
*/
|
|
116
162
|
export async function playChompBannerAnimation(subtitle, options = {}) {
|
|
117
|
-
if (!process.stdout.isTTY ||
|
|
163
|
+
if (!process.stdout.isTTY || Boolean(process.env.NO_COLOR)) {
|
|
118
164
|
printChompBanner(subtitle, "open");
|
|
119
165
|
return;
|
|
120
166
|
}
|
|
@@ -124,7 +170,7 @@ export async function playChompBannerAnimation(subtitle, options = {}) {
|
|
|
124
170
|
for (let i = 0; i < cycles; i++) {
|
|
125
171
|
sequence.push("chomp", "open");
|
|
126
172
|
}
|
|
127
|
-
const totalLines =
|
|
173
|
+
const totalLines = renderChompBanner(subtitle, "open").split("\n").length;
|
|
128
174
|
const sleep = (ms) => new Promise((res) => setTimeout(res, ms));
|
|
129
175
|
// Hide cursor during animation
|
|
130
176
|
process.stdout.write("\x1b[?25l");
|
|
@@ -486,27 +532,31 @@ function truncateCell(text, maxLen) {
|
|
|
486
532
|
return text.padEnd(maxLen);
|
|
487
533
|
return text.slice(0, Math.max(1, maxLen - 1)) + "…";
|
|
488
534
|
}
|
|
489
|
-
function stripAnsi(str) {
|
|
490
|
-
return str.replace(/\x1b\[[0-9;]*m/g, "");
|
|
491
|
-
}
|
|
492
535
|
function padAnsiCell(str, targetCols) {
|
|
493
|
-
const
|
|
536
|
+
const clamped = truncateAnsiToCols(str, targetCols);
|
|
537
|
+
const plainWidth = visualWidth(stripAnsi(clamped));
|
|
494
538
|
return plainWidth >= targetCols
|
|
495
|
-
?
|
|
496
|
-
:
|
|
539
|
+
? clamped
|
|
540
|
+
: clamped + " ".repeat(targetCols - plainWidth);
|
|
497
541
|
}
|
|
498
542
|
/**
|
|
499
543
|
* Renders the detected repository & package configuration inside a structured
|
|
500
|
-
* read-only box table
|
|
544
|
+
* read-only box table constrained to <80 terminal columns.
|
|
501
545
|
*/
|
|
502
|
-
export function printDetectedWorkspaceTable(repoName, packages, vaultNotes = []) {
|
|
503
|
-
const
|
|
504
|
-
|
|
505
|
-
const
|
|
506
|
-
const
|
|
546
|
+
export function printDetectedWorkspaceTable(repoName, packages, vaultNotes = [], maxColsOverride) {
|
|
547
|
+
const maxCols = resolveMaxTerminalCols(maxColsOverride);
|
|
548
|
+
// Total line width = 2 (indent) + 1 (left border) + innerWidth + 1 (right border) = innerWidth + 4
|
|
549
|
+
const innerWidth = Math.max(44, Math.min(74, maxCols - 4));
|
|
550
|
+
const usableCols = innerWidth - 8; // 2 leading + 2 gap + 2 gap + 2 trailing
|
|
551
|
+
const colPkg = Math.max(12, Math.min(20, Math.floor(usableCols * 0.31)));
|
|
552
|
+
const colPath = Math.max(8, Math.min(14, Math.floor(usableCols * 0.22)));
|
|
553
|
+
const colStack = Math.max(12, usableCols - colPkg - colPath);
|
|
507
554
|
const footerContentWidth = innerWidth - 4;
|
|
508
|
-
const
|
|
509
|
-
const
|
|
555
|
+
const rawTitle = ` Workspace Configuration · ${repoName} (${packages.length} package${packages.length === 1 ? "" : "s"}) `;
|
|
556
|
+
const titlePlain = rawTitle.length > innerWidth - 3
|
|
557
|
+
? `${rawTitle.slice(0, Math.max(8, innerWidth - 5))}… `
|
|
558
|
+
: rawTitle;
|
|
559
|
+
const topDashCount = Math.max(1, innerWidth - titlePlain.length - 1);
|
|
510
560
|
console.log(` ${ansi.dim("┌─")}${ansi.bold(titlePlain)}${ansi.dim("─".repeat(topDashCount) + "┐")}`);
|
|
511
561
|
console.log(` ${ansi.dim("│")} ${ansi.dim("PACKAGE".padEnd(colPkg))} ${ansi.dim("PATH".padEnd(colPath))} ${ansi.dim("DETECTED STACK".padEnd(colStack))} ${ansi.dim("│")}`);
|
|
512
562
|
console.log(` ${ansi.dim("├" + "─".repeat(innerWidth) + "┤")}`);
|
|
@@ -534,6 +584,69 @@ export function printDetectedWorkspaceTable(repoName, packages, vaultNotes = [])
|
|
|
534
584
|
console.log(` ${ansi.dim("│")} ${padAnsiCell(tipText, footerContentWidth)} ${ansi.dim("│")}`);
|
|
535
585
|
console.log(` ${ansi.dim("└" + "─".repeat(innerWidth) + "┘")}`);
|
|
536
586
|
}
|
|
587
|
+
export const LARGE_REPO_FILE_THRESHOLD = 150;
|
|
588
|
+
export const LARGE_REPO_PACKAGE_THRESHOLD = 6;
|
|
589
|
+
/**
|
|
590
|
+
* Fast pre-flight file discovery (~5–15ms) matching `analyzeTarget`'s workspace exclusion rules.
|
|
591
|
+
*/
|
|
592
|
+
export function countAnalyzableFiles(targetPath, excludeWorkspaces = []) {
|
|
593
|
+
try {
|
|
594
|
+
const resolvedTarget = resolve(targetPath);
|
|
595
|
+
if (!existsSync(resolvedTarget))
|
|
596
|
+
return 0;
|
|
597
|
+
const isFile = statSync(resolvedTarget).isFile();
|
|
598
|
+
const actualRepoRoot = isFile ? dirname(resolvedTarget) : resolvedTarget;
|
|
599
|
+
const rawRegistry = buildWorkspaceRegistry(actualRepoRoot);
|
|
600
|
+
const excludedDirs = [];
|
|
601
|
+
const excludedSet = new Set(excludeWorkspaces.map((w) => w.trim()).filter(Boolean));
|
|
602
|
+
for (const [pkgName, pkgPath] of Object.entries(rawRegistry)) {
|
|
603
|
+
const relPkgPath = relative(actualRepoRoot, pkgPath).replace(/\\/g, "/");
|
|
604
|
+
const shortName = pkgName.replace(/^@[^/]+\//, "");
|
|
605
|
+
if (excludedSet.has(pkgName) ||
|
|
606
|
+
excludedSet.has(relPkgPath) ||
|
|
607
|
+
excludedSet.has(shortName)) {
|
|
608
|
+
excludedDirs.push(pkgPath);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
for (const rawExcl of excludedSet) {
|
|
612
|
+
const candidate = resolve(actualRepoRoot, rawExcl);
|
|
613
|
+
if (candidate !== actualRepoRoot &&
|
|
614
|
+
existsSync(candidate) &&
|
|
615
|
+
!excludedDirs.includes(candidate)) {
|
|
616
|
+
excludedDirs.push(candidate);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
const allFiles = collectFiles(resolvedTarget);
|
|
620
|
+
if (excludedDirs.length === 0)
|
|
621
|
+
return allFiles.length;
|
|
622
|
+
return allFiles.filter((filePath) => !excludedDirs.some((dir) => filePath === dir || filePath.startsWith(dir + sep))).length;
|
|
623
|
+
}
|
|
624
|
+
catch {
|
|
625
|
+
return 0;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
export function shouldShowLargeRepoScaleNotice(fileCount, packageCount) {
|
|
629
|
+
return (fileCount >= LARGE_REPO_FILE_THRESHOLD ||
|
|
630
|
+
packageCount >= LARGE_REPO_PACKAGE_THRESHOLD);
|
|
631
|
+
}
|
|
632
|
+
export function formatLargeRepoScaleNotice(fileCount, packageCount, maxColsOverride) {
|
|
633
|
+
const maxCols = resolveMaxTerminalCols(maxColsOverride);
|
|
634
|
+
const pkgNoun = packageCount === 1 ? "package" : "packages";
|
|
635
|
+
const fileNoun = fileCount === 1 ? "source file" : "source files";
|
|
636
|
+
return truncateAnsiToCols(` ${ansi.cyan("ℹ")} Scanning ${ansi.bold(fileCount.toLocaleString())} ${fileNoun} across ${ansi.bold(String(packageCount))} ${pkgNoun} ${ansi.dim("— large monorepos may take 30–60s...")}`, maxCols);
|
|
637
|
+
}
|
|
638
|
+
function writeStdoutImmediate(payload) {
|
|
639
|
+
if (process.stdout.isTTY) {
|
|
640
|
+
try {
|
|
641
|
+
writeSync(1, payload);
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
644
|
+
catch {
|
|
645
|
+
// Fall through to stream write when fd 1 is unavailable
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
process.stdout.write(payload);
|
|
649
|
+
}
|
|
537
650
|
function resolvePackageNameForNode(nodeId, nodeById) {
|
|
538
651
|
let cursor = nodeById.get(nodeId);
|
|
539
652
|
const visited = new Set();
|
|
@@ -548,15 +661,21 @@ function resolvePackageNameForNode(nodeId, nodeById) {
|
|
|
548
661
|
}
|
|
549
662
|
return undefined;
|
|
550
663
|
}
|
|
551
|
-
|
|
664
|
+
const LIVE_EXTRACTION_FRAME_HEIGHT = CHOMP_UNICODE_LOGO_LINES.length + 5;
|
|
665
|
+
function renderLiveExtractionFrameLines(frame, headerLine, metaLine, statusLine, maxCols) {
|
|
552
666
|
const sourceLines = frame === "chomp" ? CHOMP_CHOMPING_FRAME_LINES : CHOMP_UNICODE_LOGO_LINES;
|
|
553
|
-
const
|
|
554
|
-
const
|
|
555
|
-
|
|
556
|
-
const right = sideLines[idx] ? ` ${sideLines[idx]}` : "";
|
|
557
|
-
return `${coloredLogo}${right}`;
|
|
667
|
+
const logoLines = sourceLines.map((rawLine) => {
|
|
668
|
+
const trimmed = rawLine.trimEnd();
|
|
669
|
+
return trimmed.length > 0 ? ansi.yellow(trimmed) : "";
|
|
558
670
|
});
|
|
559
|
-
return [
|
|
671
|
+
return [
|
|
672
|
+
"",
|
|
673
|
+
...logoLines,
|
|
674
|
+
"",
|
|
675
|
+
truncateAnsiToCols(headerLine, maxCols),
|
|
676
|
+
truncateAnsiToCols(metaLine, maxCols),
|
|
677
|
+
truncateAnsiToCols(statusLine, maxCols),
|
|
678
|
+
];
|
|
560
679
|
}
|
|
561
680
|
function formatAnalysisTimestamp(date = new Date()) {
|
|
562
681
|
const yyyy = date.getFullYear();
|
|
@@ -567,245 +686,315 @@ function formatAnalysisTimestamp(date = new Date()) {
|
|
|
567
686
|
const ss = String(date.getSeconds()).padStart(2, "0");
|
|
568
687
|
return `${yyyy}-${mm}-${dd} ${hh}:${min}:${ss}`;
|
|
569
688
|
}
|
|
689
|
+
/**
|
|
690
|
+
* Renders the settled open-mouth Chomp logo mark stacked vertically above the
|
|
691
|
+
* package progress breakdown and Bite Report summary (<80 columns per line).
|
|
692
|
+
*/
|
|
693
|
+
export function renderCompletedBiteSummary(input) {
|
|
694
|
+
const { repoName, repoPath, dbPath, gitTag, fileCount, packagesToDisplay, graph, durationMs, maxColsOverride, timestamp = formatAnalysisTimestamp(), } = input;
|
|
695
|
+
const maxCols = resolveMaxTerminalCols(maxColsOverride);
|
|
696
|
+
const dividerWidth = Math.max(24, Math.min(72, maxCols - 4));
|
|
697
|
+
const dividerLine = ` ${ansi.dim("─".repeat(dividerWidth))}`;
|
|
698
|
+
const userNodes = graph.nodes.filter((n) => (n.scope ?? "USER") === "USER");
|
|
699
|
+
const nodeById = new Map(graph.nodes.map((n) => [n.id, n]));
|
|
700
|
+
const contracts = userNodes.filter((n) => n.type === "CONTRACT");
|
|
701
|
+
const routesAndTools = contracts.filter((c) => [
|
|
702
|
+
"HTTP_ENDPOINT",
|
|
703
|
+
"NEXTJS_PAGE",
|
|
704
|
+
"NEXTJS_LAYOUT",
|
|
705
|
+
"MCP_TOOL",
|
|
706
|
+
"CLI_COMMAND",
|
|
707
|
+
"GRAPHQL_RESOLVER",
|
|
708
|
+
"EVENT_LISTENER",
|
|
709
|
+
].includes(c.entityType ?? ""));
|
|
710
|
+
const classes = userNodes.filter((n) => n.entityType === "CLASS");
|
|
711
|
+
const openConnectors = userNodes.filter((n) => n.type === "OPEN_CONNECTOR");
|
|
712
|
+
const { connectivityRate, unresolvedCount } = computeQuickConnectivity(graph);
|
|
713
|
+
const contractsByPkgKey = new Map();
|
|
714
|
+
for (const c of contracts) {
|
|
715
|
+
const unitName = resolvePackageNameForNode(c.id, nodeById);
|
|
716
|
+
if (unitName) {
|
|
717
|
+
contractsByPkgKey.set(unitName, (contractsByPkgKey.get(unitName) ?? 0) + 1);
|
|
718
|
+
const shortUnit = unitName.replace(/^@[^/]+\//, "");
|
|
719
|
+
if (shortUnit !== unitName) {
|
|
720
|
+
contractsByPkgKey.set(shortUnit, (contractsByPkgKey.get(shortUnit) ?? 0) + 1);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
const getPkgContractCount = (pkg) => {
|
|
725
|
+
const shortName = pkg.name.replace(/^@[^/]+\//, "");
|
|
726
|
+
const direct = contractsByPkgKey.get(pkg.name) ?? contractsByPkgKey.get(shortName);
|
|
727
|
+
if (typeof direct === "number")
|
|
728
|
+
return direct;
|
|
729
|
+
if (packagesToDisplay.length === 1)
|
|
730
|
+
return contracts.length;
|
|
731
|
+
return 0;
|
|
732
|
+
};
|
|
733
|
+
const maxVisiblePackages = packagesToDisplay.length <= 5 ? packagesToDisplay.length : 4;
|
|
734
|
+
const visiblePackages = packagesToDisplay.slice(0, maxVisiblePackages);
|
|
735
|
+
const hiddenPackages = packagesToDisplay.slice(maxVisiblePackages);
|
|
736
|
+
const completedPkgLines = visiblePackages.map((pkg) => {
|
|
737
|
+
const count = getPkgContractCount(pkg);
|
|
738
|
+
const fwHint = pkg.frameworks.length > 0
|
|
739
|
+
? ansi.dim(` [${pkg.frameworks.slice(0, 2).join(", ")}]`)
|
|
740
|
+
: "";
|
|
741
|
+
return truncateAnsiToCols(` ${ansi.green("✓")} ${ansi.bold(pkg.name)}${fwHint} ${ansi.dim("—")} ${ansi.yellowBold(count.toLocaleString())} nodes`, maxCols);
|
|
742
|
+
});
|
|
743
|
+
if (hiddenPackages.length > 0) {
|
|
744
|
+
const extraContracts = hiddenPackages.reduce((sum, p) => sum + getPkgContractCount(p), 0);
|
|
745
|
+
completedPkgLines.push(truncateAnsiToCols(` ${ansi.green("✓")} +${hiddenPackages.length} more package${hiddenPackages.length === 1 ? "" : "s"} ${ansi.dim("—")} ${ansi.yellowBold(extraContracts.toLocaleString())} nodes`, maxCols));
|
|
746
|
+
}
|
|
747
|
+
const timeTag = ansi.dim(` in ${(durationMs / 1000).toFixed(2)}s`);
|
|
748
|
+
const healthBadge = connectivityRate >= 80
|
|
749
|
+
? ansi.green(`● ${connectivityRate.toFixed(1)}% PASS`)
|
|
750
|
+
: ansi.amber(`? ${connectivityRate.toFixed(1)}% WARN`);
|
|
751
|
+
const shortDb = relative(repoPath, dbPath) || dbPath;
|
|
752
|
+
const logoLines = CHOMP_UNICODE_LOGO_LINES.map((rawLine) => {
|
|
753
|
+
const trimmed = rawLine.trimEnd();
|
|
754
|
+
return trimmed.length > 0 ? ansi.yellow(trimmed) : "";
|
|
755
|
+
});
|
|
756
|
+
const metaParts = [`${ansi.dim("Branch:")} ${gitTag}`];
|
|
757
|
+
if (fileCount > 0) {
|
|
758
|
+
metaParts.push(ansi.dim(`${fileCount.toLocaleString()} files`));
|
|
759
|
+
}
|
|
760
|
+
metaParts.push(ansi.dim(`${packagesToDisplay.length} package${packagesToDisplay.length === 1 ? "" : "s"}`));
|
|
761
|
+
const summaryLines = [
|
|
762
|
+
"",
|
|
763
|
+
...logoLines,
|
|
764
|
+
"",
|
|
765
|
+
truncateAnsiToCols(` ${ansi.green("✓")} ${ansi.bold(`Chomped ${repoName}`)}${timeTag}`, maxCols),
|
|
766
|
+
truncateAnsiToCols(` ${metaParts.join(ansi.dim(" · "))}`, maxCols),
|
|
767
|
+
dividerLine,
|
|
768
|
+
...completedPkgLines,
|
|
769
|
+
dividerLine,
|
|
770
|
+
truncateAnsiToCols(` ${ansi.yellowBold("◆")} ${ansi.bold(contracts.length.toLocaleString())} nodes mapped ${ansi.dim(`(${routesAndTools.length} entry points · ${classes.length} classes · ${openConnectors.length} external calls)`)}`, maxCols),
|
|
771
|
+
truncateAnsiToCols(` ${ansi.yellowBold("◆")} ${ansi.bold(graph.edges.length.toLocaleString())} connections wired ${ansi.dim("·")} Coverage: ${healthBadge}${unresolvedCount > 0 ? ansi.dim(` (? ${unresolvedCount} unresolved)`) : ""}`, maxCols),
|
|
772
|
+
truncateAnsiToCols(` ${ansi.dim("Storage:")} ${ansi.cyan(shortDb)} ${ansi.dim(`(${timestamp})`)}`, maxCols),
|
|
773
|
+
"",
|
|
774
|
+
];
|
|
775
|
+
return summaryLines.join("\n");
|
|
776
|
+
}
|
|
570
777
|
/**
|
|
571
778
|
* Runs the 2-frame Chomp mouth animation continuously during code analysis
|
|
572
|
-
*
|
|
573
|
-
*
|
|
779
|
+
* using a fixed-height <80-column animated block (preventing terminal line-wrap cursor drift)
|
|
780
|
+
* and settles onto a clean vertically stacked Bite Report summary.
|
|
574
781
|
*/
|
|
575
782
|
export async function runChompExtractionWithAnimation(opts) {
|
|
576
|
-
const { repoName, repoPath, dbPath, commitSha, branchName, excludeWorkspaces = [], isSandbox = false, executeExtraction, } = opts;
|
|
783
|
+
const { repoName, repoPath, targetPath, preFlightFileCount, dbPath, commitSha, branchName, excludeWorkspaces = [], isSandbox = false, writeOutput, executeExtraction, } = opts;
|
|
784
|
+
const emitOutput = writeOutput ?? writeStdoutImmediate;
|
|
577
785
|
const excludedSet = new Set(excludeWorkspaces);
|
|
578
786
|
const allPackages = detectWorkspacePackages(repoPath);
|
|
579
787
|
const activePackages = allPackages.filter((p) => !excludedSet.has(p.name) &&
|
|
580
788
|
!excludedSet.has(p.relPath) &&
|
|
581
789
|
!excludedSet.has(p.name.replace(/^@[^/]+\//, "")));
|
|
582
790
|
const packagesToDisplay = activePackages.length > 0 ? activePackages : allPackages;
|
|
791
|
+
const fileCount = typeof preFlightFileCount === "number"
|
|
792
|
+
? preFlightFileCount
|
|
793
|
+
: countAnalyzableFiles(targetPath ?? repoPath, excludeWorkspaces);
|
|
583
794
|
const gitTag = commitSha
|
|
584
795
|
? `${ansi.cyan(branchName ?? "detached")} ${ansi.dim(`(${commitSha.slice(0, 7)})`)}`
|
|
585
796
|
: ansi.dim("untracked");
|
|
586
|
-
const
|
|
587
|
-
const
|
|
797
|
+
const maxCols = resolveMaxTerminalCols();
|
|
798
|
+
const isTTY = Boolean(!writeOutput && process.stdout.isTTY && !process.env.NO_COLOR);
|
|
588
799
|
const frameMs = 200;
|
|
589
800
|
const sleep = (ms) => new Promise((res) => setTimeout(res, ms));
|
|
590
|
-
let
|
|
591
|
-
|
|
801
|
+
let hasRenderedLiveFrame = false;
|
|
802
|
+
// Immediately print & flush expectations banner on large repositories before AST parsing starts
|
|
803
|
+
if (shouldShowLargeRepoScaleNotice(fileCount, packagesToDisplay.length)) {
|
|
804
|
+
emitOutput(`\n${formatLargeRepoScaleNotice(fileCount, packagesToDisplay.length, maxCols)}\n`);
|
|
805
|
+
}
|
|
806
|
+
const headerLine = ` ${ansi.yellowBold("◆")} ${ansi.bold(`Chomping ${repoName}...`)}${isSandbox ? ansi.dim(" [sandbox in-memory]") : ""}`;
|
|
807
|
+
const metaParts = [`${ansi.dim("Branch:")} ${gitTag}`];
|
|
808
|
+
if (fileCount > 0) {
|
|
809
|
+
metaParts.push(ansi.dim(`${fileCount.toLocaleString()} files`));
|
|
810
|
+
}
|
|
811
|
+
metaParts.push(ansi.dim(`${packagesToDisplay.length} package${packagesToDisplay.length === 1 ? "" : "s"}`));
|
|
812
|
+
const metaLine = ` ${metaParts.join(ansi.dim(" · "))}`;
|
|
813
|
+
const formatStatusRow = (plainStatus) => ` ${ansi.yellowBold("▸")} ${plainStatus}`;
|
|
814
|
+
const drawLiveFrame = (frame, statusText) => {
|
|
592
815
|
if (!isTTY)
|
|
593
816
|
return;
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
hasRendered = true;
|
|
817
|
+
const lines = renderLiveExtractionFrameLines(frame, headerLine, metaLine, formatStatusRow(statusText), maxCols);
|
|
818
|
+
const prefix = hasRenderedLiveFrame
|
|
819
|
+
? `\x1b[${LIVE_EXTRACTION_FRAME_HEIGHT}A\r`
|
|
820
|
+
: "";
|
|
821
|
+
const payload = prefix + lines.map((l) => `\x1b[2K${l}\n`).join("");
|
|
822
|
+
writeStdoutImmediate(payload);
|
|
823
|
+
hasRenderedLiveFrame = true;
|
|
602
824
|
};
|
|
603
825
|
if (isTTY) {
|
|
604
|
-
|
|
826
|
+
writeStdoutImmediate("\x1b[?25l");
|
|
605
827
|
}
|
|
606
828
|
try {
|
|
607
829
|
let worker = null;
|
|
608
830
|
const animStartMs = Date.now();
|
|
831
|
+
const initialStatusPlain = fileCount > 0
|
|
832
|
+
? `Scanning ${fileCount.toLocaleString()} source files across ${packagesToDisplay.length} package${packagesToDisplay.length === 1 ? "" : "s"}...`
|
|
833
|
+
: `Analyzing ${packagesToDisplay[0]?.name ?? repoName}...`;
|
|
609
834
|
if (isTTY) {
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
// OS file descriptor 1 writes (`fs.writeSync(1, ...)`) so the mouth chomps
|
|
619
|
-
// continuously at 5fps even while the main thread is busy parsing ASTs.
|
|
620
|
-
const maxVisible = packagesToDisplay.length <= 5 ? packagesToDisplay.length : 4;
|
|
621
|
-
const visiblePkgs = packagesToDisplay.slice(0, maxVisible);
|
|
622
|
-
const workerFrames = [];
|
|
623
|
-
let nextLogoFrame = "chomp";
|
|
624
|
-
const totalSteps = Math.max(4, visiblePkgs.length * 2);
|
|
625
|
-
for (let step = 0; step < totalSteps; step++) {
|
|
626
|
-
const pkgIdx = Math.min(visiblePkgs.length - 1, Math.floor(step / 2));
|
|
627
|
-
const side = {
|
|
628
|
-
0: `${ansi.yellowBold("◆")} ${ansi.bold(`Chomping ${repoName}...`)}${isSandbox ? ansi.dim(" [sandbox in-memory]") : ""}`,
|
|
629
|
-
1: `${ansi.dim("Branch chomped:")} ${gitTag}`,
|
|
630
|
-
2: ansi.dim("──────────────────────────────────────────────────────────────"),
|
|
631
|
-
};
|
|
632
|
-
for (let j = 0; j < pkgIdx; j++) {
|
|
633
|
-
const p = visiblePkgs[j];
|
|
634
|
-
const fw = p.frameworks.length > 0
|
|
635
|
-
? ansi.dim(` [${p.frameworks.slice(0, 2).join(", ")}]`)
|
|
636
|
-
: "";
|
|
637
|
-
side[3 + j] = `${ansi.green("✓")} Scanned ${ansi.bold(p.name)}${fw}`;
|
|
638
|
-
}
|
|
639
|
-
const activePkg = visiblePkgs[pkgIdx];
|
|
640
|
-
if (activePkg) {
|
|
641
|
-
const fw = activePkg.frameworks.length > 0
|
|
642
|
-
? ansi.dim(` [${activePkg.frameworks.slice(0, 2).join(", ")}]`)
|
|
643
|
-
: "";
|
|
644
|
-
side[3 + pkgIdx] =
|
|
645
|
-
`${ansi.yellowBold("▸")} Analyzing ${ansi.bold(activePkg.name)}${fw} — extracting AST contracts...`;
|
|
646
|
-
}
|
|
647
|
-
const renderedLines = renderChompFrameWithSideLines(nextLogoFrame, side).split("\n");
|
|
648
|
-
const payload = `\x1b[${totalLines}A\r` +
|
|
649
|
-
renderedLines.map((l) => `\x1b[2K${l}\n`).join("");
|
|
650
|
-
workerFrames.push(payload);
|
|
651
|
-
nextLogoFrame = nextLogoFrame === "open" ? "chomp" : "open";
|
|
652
|
-
}
|
|
835
|
+
drawLiveFrame("open", initialStatusPlain);
|
|
836
|
+
const openLogoColored = renderLiveExtractionFrameLines("open", headerLine, metaLine, "", maxCols).slice(0, CHOMP_UNICODE_LOGO_LINES.length + 2);
|
|
837
|
+
const chompLogoColored = renderLiveExtractionFrameLines("chomp", headerLine, metaLine, "", maxCols).slice(0, CHOMP_UNICODE_LOGO_LINES.length + 2);
|
|
838
|
+
const clampedHeader = truncateAnsiToCols(headerLine, maxCols);
|
|
839
|
+
const clampedMeta = truncateAnsiToCols(metaLine, maxCols);
|
|
840
|
+
const bulletPrefix = isColorEnabled
|
|
841
|
+
? " \x1b[1m\x1b[38;2;250;206;29m▸\x1b[0m "
|
|
842
|
+
: " ▸ ";
|
|
653
843
|
try {
|
|
654
844
|
worker = new Worker(`
|
|
655
845
|
const fs = require("node:fs");
|
|
656
|
-
const { workerData } = require("node:worker_threads");
|
|
657
|
-
const {
|
|
658
|
-
|
|
846
|
+
const { parentPort, workerData } = require("node:worker_threads");
|
|
847
|
+
const {
|
|
848
|
+
openTopLines,
|
|
849
|
+
chompTopLines,
|
|
850
|
+
clampedHeader,
|
|
851
|
+
clampedMeta,
|
|
852
|
+
bulletPrefix,
|
|
853
|
+
initialStatus,
|
|
854
|
+
lineCount,
|
|
855
|
+
maxCols,
|
|
856
|
+
intervalMs,
|
|
857
|
+
dimStart,
|
|
858
|
+
dimEnd,
|
|
859
|
+
} = workerData;
|
|
860
|
+
|
|
861
|
+
let statusText = initialStatus;
|
|
862
|
+
let step = 0;
|
|
863
|
+
const startedAt = Date.now();
|
|
864
|
+
|
|
865
|
+
if (parentPort) {
|
|
866
|
+
parentPort.on("message", (msg) => {
|
|
867
|
+
if (msg && typeof msg.status === "string" && msg.status.length > 0) {
|
|
868
|
+
statusText = msg.status;
|
|
869
|
+
}
|
|
870
|
+
});
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
function clampPlain(s, limit) {
|
|
874
|
+
if (s.length <= limit) return s;
|
|
875
|
+
return s.slice(0, Math.max(1, limit - 1)) + "…";
|
|
876
|
+
}
|
|
877
|
+
|
|
659
878
|
setInterval(() => {
|
|
660
879
|
try {
|
|
661
|
-
|
|
662
|
-
|
|
880
|
+
const topLines = step % 2 === 0 ? chompTopLines : openTopLines;
|
|
881
|
+
step++;
|
|
882
|
+
const elapsedSec = Math.floor((Date.now() - startedAt) / 1000);
|
|
883
|
+
const timerSuffix = elapsedSec >= 1 ? " (" + elapsedSec + "s)" : "";
|
|
884
|
+
const availCols = Math.max(12, maxCols - 4 - timerSuffix.length);
|
|
885
|
+
const body = clampPlain(statusText, availCols);
|
|
886
|
+
const statusRow =
|
|
887
|
+
bulletPrefix +
|
|
888
|
+
body +
|
|
889
|
+
(timerSuffix ? dimStart + timerSuffix + dimEnd : "");
|
|
890
|
+
const allLines = [
|
|
891
|
+
...topLines,
|
|
892
|
+
clampedHeader,
|
|
893
|
+
clampedMeta,
|
|
894
|
+
statusRow,
|
|
895
|
+
];
|
|
896
|
+
const payload =
|
|
897
|
+
"\\x1b[" +
|
|
898
|
+
lineCount +
|
|
899
|
+
"A\\r" +
|
|
900
|
+
allLines.map((l) => "\\x1b[2K" + l + "\\n").join("");
|
|
901
|
+
fs.writeSync(1, payload);
|
|
663
902
|
} catch {}
|
|
664
903
|
}, intervalMs);
|
|
665
904
|
`, {
|
|
666
905
|
eval: true,
|
|
667
|
-
workerData: {
|
|
906
|
+
workerData: {
|
|
907
|
+
openTopLines: openLogoColored,
|
|
908
|
+
chompTopLines: chompLogoColored,
|
|
909
|
+
clampedHeader,
|
|
910
|
+
clampedMeta,
|
|
911
|
+
bulletPrefix,
|
|
912
|
+
initialStatus: initialStatusPlain,
|
|
913
|
+
lineCount: LIVE_EXTRACTION_FRAME_HEIGHT,
|
|
914
|
+
maxCols,
|
|
915
|
+
intervalMs: frameMs,
|
|
916
|
+
dimStart: isColorEnabled ? "\x1b[2m" : "",
|
|
917
|
+
dimEnd: isColorEnabled ? "\x1b[0m" : "",
|
|
918
|
+
},
|
|
668
919
|
});
|
|
669
920
|
}
|
|
670
921
|
catch {
|
|
671
922
|
worker = null;
|
|
672
923
|
}
|
|
924
|
+
// Yield briefly so terminal stdout and worker thread initialize before synchronous AST parsing starts
|
|
925
|
+
await sleep(15);
|
|
673
926
|
}
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
const res = await executeExtraction();
|
|
678
|
-
graph = res.graph;
|
|
679
|
-
durationMs = res.durationMs;
|
|
927
|
+
else if (shouldShowLargeRepoScaleNotice(fileCount, packagesToDisplay.length)) {
|
|
928
|
+
// Allow piped/non-TTY stdout buffer to flush before synchronous AST work begins
|
|
929
|
+
await sleep(5);
|
|
680
930
|
}
|
|
681
|
-
|
|
931
|
+
const onProgress = (nextStatus) => {
|
|
682
932
|
if (worker) {
|
|
683
933
|
try {
|
|
684
|
-
|
|
934
|
+
worker.postMessage({ status: nextStatus });
|
|
685
935
|
}
|
|
686
936
|
catch {
|
|
687
937
|
// ignore
|
|
688
938
|
}
|
|
689
939
|
}
|
|
940
|
+
};
|
|
941
|
+
let extractRes;
|
|
942
|
+
try {
|
|
943
|
+
extractRes = await executeExtraction(onProgress);
|
|
690
944
|
}
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
"NEXTJS_LAYOUT",
|
|
699
|
-
"MCP_TOOL",
|
|
700
|
-
"CLI_COMMAND",
|
|
701
|
-
"GRAPHQL_RESOLVER",
|
|
702
|
-
"EVENT_LISTENER",
|
|
703
|
-
].includes(c.entityType ?? ""));
|
|
704
|
-
const classes = userNodes.filter((n) => n.entityType === "CLASS");
|
|
705
|
-
const openConnectors = userNodes.filter((n) => n.type === "OPEN_CONNECTOR");
|
|
706
|
-
const { connectivityRate, unresolvedCount } = computeQuickConnectivity(graph);
|
|
707
|
-
const contractsByPkgKey = new Map();
|
|
708
|
-
for (const c of contracts) {
|
|
709
|
-
const unitName = resolvePackageNameForNode(c.id, nodeById);
|
|
710
|
-
if (unitName) {
|
|
711
|
-
contractsByPkgKey.set(unitName, (contractsByPkgKey.get(unitName) ?? 0) + 1);
|
|
712
|
-
const shortUnit = unitName.replace(/^@[^/]+\//, "");
|
|
713
|
-
if (shortUnit !== unitName) {
|
|
714
|
-
contractsByPkgKey.set(shortUnit, (contractsByPkgKey.get(shortUnit) ?? 0) + 1);
|
|
945
|
+
finally {
|
|
946
|
+
if (worker) {
|
|
947
|
+
try {
|
|
948
|
+
await worker.terminate();
|
|
949
|
+
}
|
|
950
|
+
catch {
|
|
951
|
+
// ignore
|
|
715
952
|
}
|
|
716
953
|
}
|
|
717
954
|
}
|
|
718
|
-
const
|
|
719
|
-
const shortName = pkg.name.replace(/^@[^/]+\//, "");
|
|
720
|
-
const direct = contractsByPkgKey.get(pkg.name) ?? contractsByPkgKey.get(shortName);
|
|
721
|
-
if (typeof direct === "number")
|
|
722
|
-
return direct;
|
|
723
|
-
if (packagesToDisplay.length === 1)
|
|
724
|
-
return contracts.length;
|
|
725
|
-
return 0;
|
|
726
|
-
};
|
|
727
|
-
const maxVisiblePackages = packagesToDisplay.length <= 5 ? packagesToDisplay.length : 4;
|
|
728
|
-
const visiblePackages = packagesToDisplay.slice(0, maxVisiblePackages);
|
|
729
|
-
const hiddenPackages = packagesToDisplay.slice(maxVisiblePackages);
|
|
730
|
-
const completedPkgLines = visiblePackages.map((pkg) => {
|
|
731
|
-
const count = getPkgContractCount(pkg);
|
|
732
|
-
const fwHint = pkg.frameworks.length > 0
|
|
733
|
-
? ansi.dim(` [${pkg.frameworks.slice(0, 2).join(", ")}]`)
|
|
734
|
-
: "";
|
|
735
|
-
return `${ansi.green("✓")} Analyzed ${ansi.bold(pkg.name)}${fwHint} ${ansi.dim("—")} ${ansi.yellowBold(String(count))} nodes mapped`;
|
|
736
|
-
});
|
|
737
|
-
if (hiddenPackages.length > 0) {
|
|
738
|
-
const extraContracts = hiddenPackages.reduce((sum, p) => sum + getPkgContractCount(p), 0);
|
|
739
|
-
completedPkgLines.push(`${ansi.green("✓")} Analyzed +${hiddenPackages.length} more package${hiddenPackages.length === 1 ? "" : "s"} ${ansi.dim("—")} ${ansi.yellowBold(String(extraContracts))} nodes mapped`);
|
|
740
|
-
}
|
|
741
|
-
const timeTag = ansi.dim(` in ${(durationMs / 1000).toFixed(2)}s`);
|
|
742
|
-
const healthBadge = connectivityRate >= 80
|
|
743
|
-
? ansi.green(`● ${connectivityRate.toFixed(1)}% PASS`)
|
|
744
|
-
: ansi.amber(`? ${connectivityRate.toFixed(1)}% WARN`);
|
|
745
|
-
const shortDb = relative(repoPath, dbPath) || dbPath;
|
|
746
|
-
const analysisTimestamp = formatAnalysisTimestamp();
|
|
955
|
+
const { graph, durationMs } = extractRes;
|
|
747
956
|
if (isTTY) {
|
|
748
|
-
// Ensure
|
|
749
|
-
// plus progressive package-by-package completion reveal
|
|
957
|
+
// Ensure quick extractions still play a crisp 2-chomp animation on the fixed-height block
|
|
750
958
|
const elapsedDuringExtract = Date.now() - animStartMs;
|
|
751
|
-
const minTotalAnimMs = frameMs *
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
0: `${ansi.yellowBold("◆")} ${ansi.bold(`Chomping ${repoName}...`)}${isSandbox ? ansi.dim(" [sandbox in-memory]") : ""}`,
|
|
758
|
-
1: `${ansi.dim("Branch chomped:")} ${gitTag}`,
|
|
759
|
-
2: ansi.dim("──────────────────────────────────────────────────────────────"),
|
|
760
|
-
};
|
|
761
|
-
for (let j = 0; j < revealedCount; j++) {
|
|
762
|
-
frameSide[3 + j] = completedPkgLines[j];
|
|
763
|
-
}
|
|
764
|
-
if (revealedCount < completedPkgLines.length) {
|
|
765
|
-
const nextPkg = visiblePackages[revealedCount]?.name ?? "remaining packages";
|
|
766
|
-
frameSide[3 + revealedCount] = `${ansi.yellowBold("▸")} Analyzing ${ansi.bold(nextPkg)}...`;
|
|
767
|
-
}
|
|
768
|
-
else {
|
|
769
|
-
frameSide[3 + revealedCount] = `${ansi.yellowBold("▸")} Wiring ${graph.edges.length.toLocaleString()} structural relationships...`;
|
|
959
|
+
const minTotalAnimMs = frameMs * 3;
|
|
960
|
+
if (elapsedDuringExtract < minTotalAnimMs) {
|
|
961
|
+
const quickSteps = ["chomp", "open", "chomp"];
|
|
962
|
+
for (const frame of quickSteps) {
|
|
963
|
+
drawLiveFrame(frame, `Wiring ${graph.edges.length.toLocaleString()} structural relationships...`);
|
|
964
|
+
await sleep(140);
|
|
770
965
|
}
|
|
771
|
-
drawFrame(currentFrame, frameSide);
|
|
772
|
-
currentFrame = currentFrame === "open" ? "chomp" : "open";
|
|
773
|
-
await sleep(frameMs);
|
|
774
966
|
}
|
|
775
967
|
}
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
`${ansi.dim("Local chomp storage:")} ${ansi.cyan(shortDb)} ${ansi.dim(`(${analysisTimestamp})`)}`;
|
|
793
|
-
if (isTTY) {
|
|
794
|
-
drawFrame("open", finalSide);
|
|
968
|
+
const summaryOutput = renderCompletedBiteSummary({
|
|
969
|
+
repoName,
|
|
970
|
+
repoPath,
|
|
971
|
+
dbPath,
|
|
972
|
+
gitTag,
|
|
973
|
+
fileCount,
|
|
974
|
+
packagesToDisplay,
|
|
975
|
+
graph,
|
|
976
|
+
durationMs,
|
|
977
|
+
maxColsOverride: maxCols,
|
|
978
|
+
});
|
|
979
|
+
if (isTTY && hasRenderedLiveFrame) {
|
|
980
|
+
emitOutput(`\x1b[${LIVE_EXTRACTION_FRAME_HEIGHT}A\r\x1b[J${summaryOutput}\n`);
|
|
981
|
+
}
|
|
982
|
+
else if (writeOutput) {
|
|
983
|
+
writeOutput(`${summaryOutput}\n`);
|
|
795
984
|
}
|
|
796
985
|
else {
|
|
797
|
-
console.log(
|
|
986
|
+
console.log(summaryOutput);
|
|
798
987
|
}
|
|
799
988
|
const coverage = auditFrameworkCoverage(repoPath, graph, excludeWorkspaces);
|
|
800
989
|
if (coverage.warnings.length > 0) {
|
|
801
990
|
printFrameworkWarnings(coverage.warnings);
|
|
802
991
|
}
|
|
803
992
|
printUnregisteredShapeHint(graph, repoName, coverage.darkFiles);
|
|
804
|
-
return
|
|
993
|
+
return extractRes;
|
|
805
994
|
}
|
|
806
995
|
finally {
|
|
807
996
|
if (isTTY) {
|
|
808
|
-
|
|
997
|
+
writeStdoutImmediate("\x1b[?25h");
|
|
809
998
|
}
|
|
810
999
|
}
|
|
811
1000
|
}
|
|
@@ -951,24 +1140,26 @@ export async function multiSelectPrompt(title, subtitle, options) {
|
|
|
951
1140
|
export function openBrowserUrl(url) {
|
|
952
1141
|
try {
|
|
953
1142
|
const platform = process.platform;
|
|
1143
|
+
let child;
|
|
954
1144
|
if (platform === "darwin") {
|
|
955
|
-
|
|
956
|
-
child.unref();
|
|
1145
|
+
child = spawn("open", [url], { stdio: "ignore", detached: true });
|
|
957
1146
|
}
|
|
958
1147
|
else if (platform === "win32") {
|
|
959
|
-
|
|
1148
|
+
child = spawn("cmd", ["/c", "start", "", url], {
|
|
960
1149
|
stdio: "ignore",
|
|
961
1150
|
detached: true,
|
|
962
1151
|
});
|
|
963
|
-
child.unref();
|
|
964
1152
|
}
|
|
965
1153
|
else {
|
|
966
|
-
|
|
1154
|
+
child = spawn("xdg-open", [url], {
|
|
967
1155
|
stdio: "ignore",
|
|
968
1156
|
detached: true,
|
|
969
1157
|
});
|
|
970
|
-
child.unref();
|
|
971
1158
|
}
|
|
1159
|
+
child.on("error", () => {
|
|
1160
|
+
// Non-fatal in headless Linux / SSH / Docker / WSL environments without xdg-open
|
|
1161
|
+
});
|
|
1162
|
+
child.unref();
|
|
972
1163
|
}
|
|
973
1164
|
catch {
|
|
974
1165
|
// Non-fatal if browser opener is unavailable
|