@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
|
@@ -65,6 +65,16 @@ export interface SetActiveChompTargetOptions {
|
|
|
65
65
|
allowWorktree?: boolean;
|
|
66
66
|
}
|
|
67
67
|
export declare function setActiveChompTarget(targetPath: string, options?: SetActiveChompTargetOptions): ChompMasterContext;
|
|
68
|
+
/**
|
|
69
|
+
* Removes an uninstalled repository from `~/.chomp/context.json` (`recentRepos`),
|
|
70
|
+
* switching `activeRepoPath` to the next valid recent repo (or canonical master monorepo)
|
|
71
|
+
* when available, or clearing `~/.chomp/context.json` cleanly in standalone NPM installs
|
|
72
|
+
* so ephemeral `_npx/.../node_modules` paths are never persisted as active targets.
|
|
73
|
+
*/
|
|
74
|
+
export declare function clearRemovedChompTarget(removedPath: string): {
|
|
75
|
+
switchedTo: string | null;
|
|
76
|
+
cleared: boolean;
|
|
77
|
+
};
|
|
68
78
|
/**
|
|
69
79
|
* Resolves the `.git` directory for a repository or git worktree and adds `.chomp/`
|
|
70
80
|
* (and optional extra patterns) to `.git/info/exclude` so Chomp never dirties `.gitignore`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { chmodSync, existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
1
|
+
import { chmodSync, existsSync, mkdirSync, readFileSync, readdirSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
3
|
import { basename, delimiter, dirname, resolve } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
@@ -351,6 +351,89 @@ export function setActiveChompTarget(targetPath, options = {}) {
|
|
|
351
351
|
}
|
|
352
352
|
return nextCtx;
|
|
353
353
|
}
|
|
354
|
+
/**
|
|
355
|
+
* Removes an uninstalled repository from `~/.chomp/context.json` (`recentRepos`),
|
|
356
|
+
* switching `activeRepoPath` to the next valid recent repo (or canonical master monorepo)
|
|
357
|
+
* when available, or clearing `~/.chomp/context.json` cleanly in standalone NPM installs
|
|
358
|
+
* so ephemeral `_npx/.../node_modules` paths are never persisted as active targets.
|
|
359
|
+
*/
|
|
360
|
+
export function clearRemovedChompTarget(removedPath) {
|
|
361
|
+
const repoRoot = resolve(removedPath);
|
|
362
|
+
const prev = readMasterContext();
|
|
363
|
+
if (!prev) {
|
|
364
|
+
return { switchedTo: null, cleared: false };
|
|
365
|
+
}
|
|
366
|
+
const remainingRecents = (prev.recentRepos ?? []).filter((r) => r && r.path && resolve(r.path) !== repoRoot && existsSync(r.path));
|
|
367
|
+
const wasActive = Boolean(prev.activeRepoPath) && resolve(prev.activeRepoPath) === repoRoot;
|
|
368
|
+
if (!wasActive) {
|
|
369
|
+
if (remainingRecents.length !== (prev.recentRepos ?? []).length) {
|
|
370
|
+
const updated = {
|
|
371
|
+
...prev,
|
|
372
|
+
updatedAt: new Date().toISOString(),
|
|
373
|
+
recentRepos: remainingRecents,
|
|
374
|
+
};
|
|
375
|
+
const payload = JSON.stringify(updated, null, 2) + "\n";
|
|
376
|
+
try {
|
|
377
|
+
const ctxPath = getGlobalContextPath();
|
|
378
|
+
mkdirSync(dirname(ctxPath), { recursive: true });
|
|
379
|
+
writeFileSync(ctxPath, payload, "utf8");
|
|
380
|
+
}
|
|
381
|
+
catch {
|
|
382
|
+
// Ignore sandbox write errors
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return { switchedTo: null, cleared: false };
|
|
386
|
+
}
|
|
387
|
+
if (remainingRecents.length > 0) {
|
|
388
|
+
const nextRepo = remainingRecents[0];
|
|
389
|
+
const nextTarget = resolve(nextRepo.path);
|
|
390
|
+
const canonicalMaster = getCanonicalChompMasterRoot();
|
|
391
|
+
const updated = {
|
|
392
|
+
activeRepoId: nextRepo.id,
|
|
393
|
+
activeRepoPath: nextTarget,
|
|
394
|
+
activeRepoName: nextRepo.name,
|
|
395
|
+
masterRoot: canonicalMaster,
|
|
396
|
+
updatedAt: new Date().toISOString(),
|
|
397
|
+
recentRepos: remainingRecents,
|
|
398
|
+
};
|
|
399
|
+
const payload = JSON.stringify(updated, null, 2) + "\n";
|
|
400
|
+
if (isChompMasterMonorepo(canonicalMaster)) {
|
|
401
|
+
try {
|
|
402
|
+
const fallbackPath = getWorkspaceFallbackContextPath();
|
|
403
|
+
mkdirSync(dirname(fallbackPath), { recursive: true });
|
|
404
|
+
writeFileSync(fallbackPath, payload, "utf8");
|
|
405
|
+
}
|
|
406
|
+
catch {
|
|
407
|
+
// Ignore read-only workspace
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
try {
|
|
411
|
+
const ctxPath = getGlobalContextPath();
|
|
412
|
+
mkdirSync(dirname(ctxPath), { recursive: true });
|
|
413
|
+
writeFileSync(ctxPath, payload, "utf8");
|
|
414
|
+
}
|
|
415
|
+
catch {
|
|
416
|
+
// Ignore sandbox errors
|
|
417
|
+
}
|
|
418
|
+
return { switchedTo: nextTarget, cleared: false };
|
|
419
|
+
}
|
|
420
|
+
const canonicalMaster = getCanonicalChompMasterRoot();
|
|
421
|
+
if (isChompMasterMonorepo(canonicalMaster) &&
|
|
422
|
+
resolve(canonicalMaster) !== repoRoot) {
|
|
423
|
+
setActiveChompTarget(canonicalMaster);
|
|
424
|
+
return { switchedTo: resolve(canonicalMaster), cleared: false };
|
|
425
|
+
}
|
|
426
|
+
try {
|
|
427
|
+
const ctxPath = getGlobalContextPath();
|
|
428
|
+
if (existsSync(ctxPath)) {
|
|
429
|
+
unlinkSync(ctxPath);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
catch {
|
|
433
|
+
// Ignore sandbox errors
|
|
434
|
+
}
|
|
435
|
+
return { switchedTo: null, cleared: true };
|
|
436
|
+
}
|
|
354
437
|
/**
|
|
355
438
|
* Resolves the `.git` directory for a repository or git worktree and adds `.chomp/`
|
|
356
439
|
* (and optional extra patterns) to `.git/info/exclude` so Chomp never dirties `.gitignore`
|
|
@@ -78,7 +78,12 @@ export interface RequestCloudLayoutOptions {
|
|
|
78
78
|
apiKey?: string;
|
|
79
79
|
/** Force calling the remote Cloud Layout Worker even inside the master monorepo (`--remote`). */
|
|
80
80
|
remote?: boolean;
|
|
81
|
-
/** Request timeout in milliseconds (
|
|
81
|
+
/** Request timeout in milliseconds (defaults to dynamic 30s–90s scaling by graph size). */
|
|
82
82
|
timeoutMs?: number;
|
|
83
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Computes the dynamic Cloud Layout Worker timeout (`30s`–`90s`) when an explicit
|
|
86
|
+
* `timeoutMs` is not supplied, preventing premature `15s` aborts on 2,000–3,000+ node monorepos.
|
|
87
|
+
*/
|
|
88
|
+
export declare function computeCloudLayoutTimeoutMs(nodeCount: number, explicitTimeoutMs?: number): number;
|
|
84
89
|
export declare function requestStatelessCloudLayout(rawGraph: RepresentationGraph, repoName: string, diffDelta?: GraphDelta, rulesConfig?: ChompRulesConfig, overlays?: EntityOverlayItem[], options?: RequestCloudLayoutOptions): Promise<LayoutData>;
|
|
@@ -1114,6 +1114,19 @@ export function rehydrateCloudLayout(response, hydrationMap, rawGraph, repoName,
|
|
|
1114
1114
|
...(overlays ? { overlays } : {}),
|
|
1115
1115
|
};
|
|
1116
1116
|
}
|
|
1117
|
+
/**
|
|
1118
|
+
* Computes the dynamic Cloud Layout Worker timeout (`30s`–`90s`) when an explicit
|
|
1119
|
+
* `timeoutMs` is not supplied, preventing premature `15s` aborts on 2,000–3,000+ node monorepos.
|
|
1120
|
+
*/
|
|
1121
|
+
export function computeCloudLayoutTimeoutMs(nodeCount, explicitTimeoutMs) {
|
|
1122
|
+
if (typeof explicitTimeoutMs === "number" &&
|
|
1123
|
+
Number.isFinite(explicitTimeoutMs) &&
|
|
1124
|
+
explicitTimeoutMs > 0) {
|
|
1125
|
+
return explicitTimeoutMs;
|
|
1126
|
+
}
|
|
1127
|
+
const safeNodeCount = Math.max(0, nodeCount);
|
|
1128
|
+
return Math.max(30_000, Math.min(90_000, 20_000 + safeNodeCount * 15));
|
|
1129
|
+
}
|
|
1117
1130
|
export async function requestStatelessCloudLayout(rawGraph, repoName, diffDelta, rulesConfig, overlays, options = {}) {
|
|
1118
1131
|
const { request, hydrationMap } = anonymizeGraphForCloudLayout(rawGraph, diffDelta, rulesConfig, overlays);
|
|
1119
1132
|
const explicitUrl = (options.cloudApiUrl ??
|
|
@@ -1134,8 +1147,9 @@ export async function requestStatelessCloudLayout(rawGraph, repoName, diffDelta,
|
|
|
1134
1147
|
return rehydrateCloudLayout(response, hydrationMap, rawGraph, repoName, overlays);
|
|
1135
1148
|
}
|
|
1136
1149
|
const baseUrl = explicitUrl || DEFAULT_CLOUD_API_URL;
|
|
1150
|
+
const effectiveTimeoutMs = computeCloudLayoutTimeoutMs(rawGraph.nodes.length, options.timeoutMs);
|
|
1137
1151
|
const controller = new AbortController();
|
|
1138
|
-
const timeout = setTimeout(() => controller.abort(),
|
|
1152
|
+
const timeout = setTimeout(() => controller.abort(), effectiveTimeoutMs);
|
|
1139
1153
|
try {
|
|
1140
1154
|
const headers = {
|
|
1141
1155
|
"Content-Type": "application/json",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getchomp/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.44",
|
|
4
4
|
"description": "Chomp CLI and local server — map your codebase, check architecture health, and launch Chomp Map.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://getchomp.dev",
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
26
|
"dist",
|
|
27
|
-
"README.md"
|
|
27
|
+
"README.md",
|
|
28
|
+
"LICENSE"
|
|
28
29
|
],
|
|
29
30
|
"dependencies": {
|
|
30
31
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
@@ -35,9 +36,9 @@
|
|
|
35
36
|
"express": "^5.2.1",
|
|
36
37
|
"typescript": "^5.3.0",
|
|
37
38
|
"zod": "^3.23.8",
|
|
38
|
-
"@getchomp/core": "0.2.
|
|
39
|
-
"@getchomp/
|
|
40
|
-
"@getchomp/
|
|
39
|
+
"@getchomp/core": "0.2.44",
|
|
40
|
+
"@getchomp/mcp": "0.2.44",
|
|
41
|
+
"@getchomp/db": "0.2.44"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
44
|
"@types/better-sqlite3": "^7.6.11",
|
|
@@ -49,6 +50,6 @@
|
|
|
49
50
|
"build": "tsc -p tsconfig.build.json",
|
|
50
51
|
"dev": "tsx src/index.ts",
|
|
51
52
|
"typecheck": "tsc --noEmit",
|
|
52
|
-
"test": "tsx --test src/utils/masterContext.test.ts src/visualizer/layoutCache.test.ts src/visualizer/rulesConfig.test.ts src/visualizer/pluginPresentationApi.test.ts src/visualizer/cloudLayoutClient.test.ts src/visualizer/sourceAccess.test.ts src/ports/portHydrator.test.ts src/ports/portHydratorWorker.test.ts src/visualizer/visualLinter.test.ts"
|
|
53
|
+
"test": "tsx --test src/server/hostedUiProxy.test.ts src/utils/branding.test.ts src/utils/masterContext.test.ts src/visualizer/layoutCache.test.ts src/visualizer/rulesConfig.test.ts src/visualizer/pluginPresentationApi.test.ts src/visualizer/cloudLayoutClient.test.ts src/visualizer/sourceAccess.test.ts src/ports/portHydrator.test.ts src/ports/portHydratorWorker.test.ts src/visualizer/visualLinter.test.ts"
|
|
53
54
|
}
|
|
54
55
|
}
|