@getchomp/cli 0.0.0-stage → 0.2.42
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 +39 -2
- package/dist/commands/analyze.d.ts +49 -0
- package/dist/commands/analyze.js +280 -0
- package/dist/commands/connect.d.ts +12 -0
- package/dist/commands/connect.js +255 -0
- package/dist/commands/export.d.ts +29 -0
- package/dist/commands/export.js +356 -0
- package/dist/commands/health.d.ts +19 -0
- package/dist/commands/health.js +259 -0
- package/dist/commands/init.d.ts +40 -0
- package/dist/commands/init.js +654 -0
- package/dist/commands/mcp.d.ts +2 -0
- package/dist/commands/mcp.js +12 -0
- package/dist/commands/plugin.d.ts +8 -0
- package/dist/commands/plugin.js +198 -0
- package/dist/commands/ui.d.ts +20 -0
- package/dist/commands/ui.js +250 -0
- package/dist/commands/uninstall.d.ts +8 -0
- package/dist/commands/uninstall.js +238 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +37 -0
- package/dist/ports/portHydrator.d.ts +63 -0
- package/dist/ports/portHydrator.js +954 -0
- package/dist/ports/portHydratorWorker.d.ts +22 -0
- package/dist/ports/portHydratorWorker.js +75 -0
- package/dist/server/buildStatusTracker.d.ts +45 -0
- package/dist/server/buildStatusTracker.js +122 -0
- package/dist/server/graphLayoutState.d.ts +205 -0
- package/dist/server/graphLayoutState.js +930 -0
- package/dist/server/loopbackSecurity.d.ts +18 -0
- package/dist/server/loopbackSecurity.js +57 -0
- package/dist/server/routes/authSourceRoutes.d.ts +18 -0
- package/dist/server/routes/authSourceRoutes.js +231 -0
- package/dist/server/routes/layoutRoutes.d.ts +3 -0
- package/dist/server/routes/layoutRoutes.js +857 -0
- package/dist/server/routes/pluginRoutes.d.ts +3 -0
- package/dist/server/routes/pluginRoutes.js +368 -0
- package/dist/server/routes/viewRulesRoutes.d.ts +3 -0
- package/dist/server/routes/viewRulesRoutes.js +173 -0
- package/dist/server/uiHotkeys.d.ts +26 -0
- package/dist/server/uiHotkeys.js +160 -0
- package/dist/utils/branding.d.ts +126 -0
- package/dist/utils/branding.js +976 -0
- package/dist/utils/credentials.d.ts +22 -0
- package/dist/utils/credentials.js +126 -0
- package/dist/utils/git.d.ts +95 -0
- package/dist/utils/git.js +780 -0
- package/dist/utils/masterContext.d.ts +102 -0
- package/dist/utils/masterContext.js +559 -0
- package/dist/visualizer/cloudLayoutClient.d.ts +84 -0
- package/dist/visualizer/cloudLayoutClient.js +1200 -0
- package/dist/visualizer/layoutCache.d.ts +25 -0
- package/dist/visualizer/layoutCache.js +406 -0
- package/dist/visualizer/localEngineBridge.d.ts +50 -0
- package/dist/visualizer/localEngineBridge.js +80 -0
- package/dist/visualizer/pluginPresentationApi.d.ts +111 -0
- package/dist/visualizer/pluginPresentationApi.js +432 -0
- package/dist/visualizer/rulesConfig.d.ts +11 -0
- package/dist/visualizer/rulesConfig.js +266 -0
- package/dist/visualizer/sourceAccess.d.ts +45 -0
- package/dist/visualizer/sourceAccess.js +204 -0
- package/package.json +51 -3
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Non-blocking interactive hotkey & signal controller for `chomp ui`.
|
|
3
|
+
*
|
|
4
|
+
* Spawns heavy CLI hotkey operations (`[a]` analyze, `[h]` health) in
|
|
5
|
+
* isolated child processes (`stdio: ["ignore", "inherit", "inherit"]`) so the UI
|
|
6
|
+
* Express server, SSE `/api/status`, and raw-mode keyboard handling (`[q]` / `Ctrl+C`)
|
|
7
|
+
* remain immediately responsive at all times.
|
|
8
|
+
*/
|
|
9
|
+
import { spawn } from "node:child_process";
|
|
10
|
+
import { existsSync } from "node:fs";
|
|
11
|
+
import { dirname, resolve } from "node:path";
|
|
12
|
+
import { fileURLToPath } from "node:url";
|
|
13
|
+
import { filterExecArgvForChild } from "../ports/portHydrator.js";
|
|
14
|
+
import { ansi } from "../utils/branding.js";
|
|
15
|
+
function resolveCliEntryPath() {
|
|
16
|
+
const currentFile = fileURLToPath(import.meta.url);
|
|
17
|
+
const srcRoot = resolve(dirname(currentFile), "..");
|
|
18
|
+
const ext = currentFile.endsWith(".ts") ? ".ts" : ".js";
|
|
19
|
+
const primary = resolve(srcRoot, `index${ext}`);
|
|
20
|
+
if (existsSync(primary))
|
|
21
|
+
return primary;
|
|
22
|
+
const fallback = resolve(srcRoot, `index${ext === ".ts" ? ".js" : ".ts"}`);
|
|
23
|
+
return existsSync(fallback) ? fallback : null;
|
|
24
|
+
}
|
|
25
|
+
export function attachUiInteractiveHotkeys(options) {
|
|
26
|
+
let activeChild = null;
|
|
27
|
+
let activeTaskLabel = null;
|
|
28
|
+
let shuttingDown = false;
|
|
29
|
+
let rawModeActive = false;
|
|
30
|
+
const killActiveTask = () => {
|
|
31
|
+
if (!activeChild)
|
|
32
|
+
return;
|
|
33
|
+
const child = activeChild;
|
|
34
|
+
activeChild = null;
|
|
35
|
+
activeTaskLabel = null;
|
|
36
|
+
if (!child.killed && child.exitCode === null && child.signalCode === null) {
|
|
37
|
+
try {
|
|
38
|
+
child.kill("SIGTERM");
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
// Ignore already-exited child
|
|
42
|
+
}
|
|
43
|
+
setTimeout(() => {
|
|
44
|
+
if (child.exitCode === null && child.signalCode === null) {
|
|
45
|
+
try {
|
|
46
|
+
child.kill("SIGKILL");
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// Ignore
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}, 1500).unref();
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const restoreTerminal = () => {
|
|
56
|
+
if (!rawModeActive)
|
|
57
|
+
return;
|
|
58
|
+
rawModeActive = false;
|
|
59
|
+
try {
|
|
60
|
+
if (process.stdin.isTTY && typeof process.stdin.setRawMode === "function") {
|
|
61
|
+
process.stdin.setRawMode(false);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
// ignore
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
process.stdin.pause();
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
// ignore
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const shutdown = () => {
|
|
75
|
+
if (shuttingDown)
|
|
76
|
+
return;
|
|
77
|
+
shuttingDown = true;
|
|
78
|
+
killActiveTask();
|
|
79
|
+
restoreTerminal();
|
|
80
|
+
options.onShutdown();
|
|
81
|
+
};
|
|
82
|
+
const runCliSubcommand = (label, args, onSuccess) => {
|
|
83
|
+
if (activeChild) {
|
|
84
|
+
console.log(` ${ansi.yellow("⏳")} Still running ${activeTaskLabel ?? "task"} — press ${ansi.bold("[q]")} or ${ansi.bold("Ctrl+C")} to cancel.`);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const cliEntry = resolveCliEntryPath();
|
|
88
|
+
if (!cliEntry) {
|
|
89
|
+
console.error(` ${ansi.red("✖")} Unable to locate Chomp CLI entry point.`);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const child = spawn(process.execPath, [...filterExecArgvForChild(), cliEntry, ...args], {
|
|
93
|
+
stdio: ["ignore", "inherit", "inherit"],
|
|
94
|
+
env: process.env,
|
|
95
|
+
});
|
|
96
|
+
activeChild = child;
|
|
97
|
+
activeTaskLabel = label;
|
|
98
|
+
child.on("error", (err) => {
|
|
99
|
+
if (activeChild === child) {
|
|
100
|
+
activeChild = null;
|
|
101
|
+
activeTaskLabel = null;
|
|
102
|
+
}
|
|
103
|
+
if (!shuttingDown) {
|
|
104
|
+
console.error(` ${ansi.red("✖")} Failed to run ${label}: ${err?.message ?? String(err)}`);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
child.on("exit", (code) => {
|
|
108
|
+
if (activeChild === child) {
|
|
109
|
+
activeChild = null;
|
|
110
|
+
activeTaskLabel = null;
|
|
111
|
+
}
|
|
112
|
+
if (!shuttingDown && code === 0 && onSuccess) {
|
|
113
|
+
onSuccess();
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
const onSignal = () => shutdown();
|
|
118
|
+
process.once("SIGINT", onSignal);
|
|
119
|
+
process.once("SIGTERM", onSignal);
|
|
120
|
+
if (process.stdin.isTTY &&
|
|
121
|
+
typeof process.stdin.setRawMode === "function") {
|
|
122
|
+
process.stdin.setRawMode(true);
|
|
123
|
+
rawModeActive = true;
|
|
124
|
+
process.stdin.resume();
|
|
125
|
+
process.stdin.setEncoding("utf8");
|
|
126
|
+
process.stdin.on("data", (key) => {
|
|
127
|
+
if (key === "\u0003" || key === "q" || key === "Q") {
|
|
128
|
+
shutdown();
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const lower = key.toLowerCase();
|
|
132
|
+
const { target: activeTarget } = options.getActiveTarget();
|
|
133
|
+
if (lower === "o") {
|
|
134
|
+
console.log(` ${ansi.yellowBold("↗")} Opening ${options.url} in browser...`);
|
|
135
|
+
options.onOpenBrowser(options.url);
|
|
136
|
+
}
|
|
137
|
+
else if (lower === "a") {
|
|
138
|
+
const args = [
|
|
139
|
+
"analyze",
|
|
140
|
+
activeTarget,
|
|
141
|
+
...(options.dbOption ? ["--db", options.dbOption] : []),
|
|
142
|
+
];
|
|
143
|
+
runCliSubcommand("re-analyze", args, () => {
|
|
144
|
+
options.onAfterAnalyze();
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
else if (lower === "h") {
|
|
148
|
+
runCliSubcommand("health check", ["health", activeTarget]);
|
|
149
|
+
}
|
|
150
|
+
else if (lower === "c") {
|
|
151
|
+
console.clear();
|
|
152
|
+
options.onPrintBanner();
|
|
153
|
+
}
|
|
154
|
+
else if (lower === "?") {
|
|
155
|
+
options.onPrintBanner();
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
return { shutdown, killActiveTask };
|
|
160
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { type FrameworkCoverageWarning, type RepresentationGraph } from "@getchomp/core";
|
|
2
|
+
export declare const ansi: {
|
|
3
|
+
yellow: (s: string) => string;
|
|
4
|
+
yellowBold: (s: string) => string;
|
|
5
|
+
bold: (s: string) => string;
|
|
6
|
+
dim: (s: string) => string;
|
|
7
|
+
green: (s: string) => string;
|
|
8
|
+
cyan: (s: string) => string;
|
|
9
|
+
amber: (s: string) => string;
|
|
10
|
+
red: (s: string) => string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Primary Chomp logo mark (Open Mouth — 13 lines).
|
|
14
|
+
* Normalized to a 2-space left margin while preserving exact relative geometry.
|
|
15
|
+
*/
|
|
16
|
+
export declare const CHOMP_UNICODE_LOGO_LINES: readonly string[];
|
|
17
|
+
/**
|
|
18
|
+
* Chomping animation frame (Closed Mouth — 13 lines, padded 3 top / 3 bottom
|
|
19
|
+
* so the eye `●` stays anchored on row index 6).
|
|
20
|
+
*/
|
|
21
|
+
export declare const CHOMP_CHOMPING_FRAME_LINES: readonly string[];
|
|
22
|
+
export type ChompLogoFrame = "open" | "chomp";
|
|
23
|
+
/**
|
|
24
|
+
* Renders the Chomp Unicode logo mark (or chomping frame) in brand yellow
|
|
25
|
+
* alongside the wordmark and tagline.
|
|
26
|
+
*/
|
|
27
|
+
export declare function renderChompBanner(subtitle?: string, frame?: ChompLogoFrame): string;
|
|
28
|
+
export declare function printChompBanner(subtitle?: string, frame?: ChompLogoFrame): void;
|
|
29
|
+
/**
|
|
30
|
+
* Plays a live terminal chomping animation that alternates between the open-mouth
|
|
31
|
+
* Chomp logo and the closed-mouth chomping frame in-place, settling on the open-mouth logo.
|
|
32
|
+
* Falls back to printing the static banner once when stdout is not an interactive TTY.
|
|
33
|
+
*/
|
|
34
|
+
export declare function playChompBannerAnimation(subtitle?: string, options?: {
|
|
35
|
+
cycles?: number;
|
|
36
|
+
frameMs?: number;
|
|
37
|
+
}): Promise<void>;
|
|
38
|
+
export interface DetectedWorkspacePackage {
|
|
39
|
+
name: string;
|
|
40
|
+
relPath: string;
|
|
41
|
+
absPath: string;
|
|
42
|
+
frameworks: string[];
|
|
43
|
+
currentlyExcluded: boolean;
|
|
44
|
+
}
|
|
45
|
+
export declare function detectFrameworksFromPackageJson(pkgJsonPath: string): string[];
|
|
46
|
+
export declare function loadExcludeWorkspaces(repoRoot: string): string[];
|
|
47
|
+
export declare function saveExcludeWorkspaces(repoRoot: string, excludeWorkspaces: string[]): void;
|
|
48
|
+
export interface ScaffoldDesignSystemResult {
|
|
49
|
+
written: boolean;
|
|
50
|
+
wouldWrite: boolean;
|
|
51
|
+
alreadyConfigured: boolean;
|
|
52
|
+
frontendPackages: string[];
|
|
53
|
+
configRelPath: string | null;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Scaffolds a starter `designSystem` configuration block when frontend packages are detected.
|
|
57
|
+
* - Normal mode (`stealth: false`): merges `designSystem` into root `chomp.config.json`.
|
|
58
|
+
* - Stealth mode (`stealth: true`): writes `.chomp/plugins/design-system/config.json` so tracked files remain 100% git-clean.
|
|
59
|
+
* Never overwrites an existing `designSystem` configuration in either location.
|
|
60
|
+
*/
|
|
61
|
+
export declare function scaffoldDesignSystemConfig(repoRoot: string, options?: {
|
|
62
|
+
stealth?: boolean;
|
|
63
|
+
dryRun?: boolean;
|
|
64
|
+
excludeWorkspaces?: string[];
|
|
65
|
+
}): ScaffoldDesignSystemResult;
|
|
66
|
+
export declare function detectWorkspacePackages(repoRoot: string): DetectedWorkspacePackage[];
|
|
67
|
+
export declare function printFrameworkWarnings(warnings: readonly FrameworkCoverageWarning[]): void;
|
|
68
|
+
/**
|
|
69
|
+
* Surfaces a concise CLI hint when extraction detects unregistered knowable shape clusters
|
|
70
|
+
* that are not yet tracked in `fixtures/research/pattern_ledger.db`.
|
|
71
|
+
*/
|
|
72
|
+
export declare function printUnregisteredShapeHint(graph: RepresentationGraph, repoName: string, darkFiles?: readonly string[]): void;
|
|
73
|
+
export declare function computeQuickConnectivity(graph: RepresentationGraph): {
|
|
74
|
+
connectivityRate: number;
|
|
75
|
+
unresolvedCount: number;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Prints a clear, concise Polaris-style welcome message before workspace detection begins.
|
|
79
|
+
*/
|
|
80
|
+
export declare function printWelcomeMessage(repoName: string, isDryRun?: boolean): void;
|
|
81
|
+
/**
|
|
82
|
+
* Runs a paced, single-line thinking ticker directly underneath the opening Chomp logo
|
|
83
|
+
* so the user has time to take in the brand mark while system discovery runs.
|
|
84
|
+
*/
|
|
85
|
+
export declare function runDiscoveryTicker(repoName: string, customMessages?: string[]): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Renders the detected repository & package configuration inside a structured
|
|
88
|
+
* read-only box table so it is visually distinct from interactive wizard prompts.
|
|
89
|
+
*/
|
|
90
|
+
export declare function printDetectedWorkspaceTable(repoName: string, packages: DetectedWorkspacePackage[], vaultNotes?: string[]): void;
|
|
91
|
+
export interface ChompExtractionAnimationOptions {
|
|
92
|
+
repoName: string;
|
|
93
|
+
repoPath: string;
|
|
94
|
+
dbPath: string;
|
|
95
|
+
commitSha?: string;
|
|
96
|
+
branchName?: string;
|
|
97
|
+
excludeWorkspaces?: string[];
|
|
98
|
+
isSandbox?: boolean;
|
|
99
|
+
executeExtraction: () => Promise<{
|
|
100
|
+
graph: RepresentationGraph;
|
|
101
|
+
durationMs: number;
|
|
102
|
+
}>;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Runs the 2-frame Chomp mouth animation continuously during code analysis
|
|
106
|
+
* (guaranteed minimum of 2 full chomp cycles, and more if extraction takes longer)
|
|
107
|
+
* while streaming a live sequence of package & contract discovery events to the right.
|
|
108
|
+
*/
|
|
109
|
+
export declare function runChompExtractionWithAnimation(opts: ChompExtractionAnimationOptions): Promise<{
|
|
110
|
+
graph: RepresentationGraph;
|
|
111
|
+
durationMs: number;
|
|
112
|
+
}>;
|
|
113
|
+
export declare function confirmPrompt(question: string, defaultYes?: boolean, description?: string): Promise<boolean>;
|
|
114
|
+
export interface MultiSelectOption<T = string> {
|
|
115
|
+
value: T;
|
|
116
|
+
label: string;
|
|
117
|
+
hint?: string;
|
|
118
|
+
selected: boolean;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Interactive multi-select checklist in the terminal.
|
|
122
|
+
* Supports Up/Down arrows (or j/k), Space to toggle, 'a' to toggle all, and Enter to confirm.
|
|
123
|
+
* Gracefully falls back to comma-separated numbers if raw mode is unavailable.
|
|
124
|
+
*/
|
|
125
|
+
export declare function multiSelectPrompt<T = string>(title: string, subtitle: string, options: MultiSelectOption<T>[]): Promise<T[]>;
|
|
126
|
+
export declare function openBrowserUrl(url: string): void;
|