@getchomp/cli 0.2.43 → 0.2.45
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/dist/commands/analyze.js +19 -2
- package/dist/commands/init.js +3 -3
- package/dist/commands/ui.d.ts +1 -0
- package/dist/commands/ui.js +44 -3
- package/dist/commands/uninstall.js +8 -2
- 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 +405 -216
- package/dist/visualizer/cloudLayoutClient.d.ts +8 -1
- package/dist/visualizer/cloudLayoutClient.js +39 -9
- package/package.json +5 -5
|
@@ -47,6 +47,8 @@ export interface SkeletonHydrationMap {
|
|
|
47
47
|
realBadgeByPseudoBadge: Map<string, string>;
|
|
48
48
|
/** Maps pseudonymized receptor ID -> real receptor ID. */
|
|
49
49
|
realReceptorIdByPseudoId: Map<string, string>;
|
|
50
|
+
/** Maps `${sourceId}::${targetId}` -> original resolved edge name. */
|
|
51
|
+
realEdgeNameByPair?: Map<string, string>;
|
|
50
52
|
/** Maps `${sourceId}::${lineNumber}::${pseudoCallName}` -> real unresolved call metadata. */
|
|
51
53
|
realUnresolvedByKey: Map<string, {
|
|
52
54
|
name: string;
|
|
@@ -78,7 +80,12 @@ export interface RequestCloudLayoutOptions {
|
|
|
78
80
|
apiKey?: string;
|
|
79
81
|
/** Force calling the remote Cloud Layout Worker even inside the master monorepo (`--remote`). */
|
|
80
82
|
remote?: boolean;
|
|
81
|
-
/** Request timeout in milliseconds (
|
|
83
|
+
/** Request timeout in milliseconds (defaults to dynamic 30s–90s scaling by graph size). */
|
|
82
84
|
timeoutMs?: number;
|
|
83
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Computes the dynamic Cloud Layout Worker timeout (`30s`–`90s`) when an explicit
|
|
88
|
+
* `timeoutMs` is not supplied, preventing premature `15s` aborts on 2,000–3,000+ node monorepos.
|
|
89
|
+
*/
|
|
90
|
+
export declare function computeCloudLayoutTimeoutMs(nodeCount: number, explicitTimeoutMs?: number): number;
|
|
84
91
|
export declare function requestStatelessCloudLayout(rawGraph: RepresentationGraph, repoName: string, diffDelta?: GraphDelta, rulesConfig?: ChompRulesConfig, overlays?: EntityOverlayItem[], options?: RequestCloudLayoutOptions): Promise<LayoutData>;
|
|
@@ -287,6 +287,7 @@ export function anonymizeGraphForCloudLayout(rawGraph, diffDelta, rulesConfig, o
|
|
|
287
287
|
const realDisplayNameByRealPkg = new Map();
|
|
288
288
|
const realBadgeByPseudoBadge = new Map();
|
|
289
289
|
const realReceptorIdByPseudoId = new Map();
|
|
290
|
+
const realEdgeNameByPair = new Map();
|
|
290
291
|
const realUnresolvedByKey = new Map();
|
|
291
292
|
const nodeById = new Map();
|
|
292
293
|
for (const n of rawGraph.nodes) {
|
|
@@ -667,19 +668,26 @@ export function anonymizeGraphForCloudLayout(rawGraph, diffDelta, rulesConfig, o
|
|
|
667
668
|
anonMetadata.dialect = inferred;
|
|
668
669
|
}
|
|
669
670
|
}
|
|
671
|
+
const { evidence: _rawNodeEv, metadata: _rawNodeMeta, ...nodeRest } = n;
|
|
670
672
|
return {
|
|
671
|
-
...
|
|
673
|
+
...nodeRest,
|
|
672
674
|
name: pseudoName,
|
|
673
|
-
|
|
675
|
+
evidence: anonEvidence ?? { filePath: "f_anon.ts" },
|
|
674
676
|
...(Object.keys(anonMetadata).length > 0 ? { metadata: anonMetadata } : {}),
|
|
675
677
|
};
|
|
676
678
|
});
|
|
677
|
-
// 5. Anonymize edges (including unresolved call edge names & evidence)
|
|
679
|
+
// 5. Anonymize edges (including resolved/unresolved call edge names, helper tags & evidence)
|
|
678
680
|
const anonymizedEdges = rawGraph.edges.map((e) => {
|
|
679
681
|
const ev = Array.isArray(e.evidence) ? e.evidence[0] : e.evidence;
|
|
680
682
|
const lineNumber = typeof ev?.lineNumber === "number" ? ev.lineNumber : undefined;
|
|
681
|
-
let anonEdgeName = e.
|
|
682
|
-
if (
|
|
683
|
+
let anonEdgeName = e.entityType ? `Edge: ${e.entityType}` : "call";
|
|
684
|
+
if (e.targetId && e.name) {
|
|
685
|
+
const pairKey = `${e.sourceId}::${e.targetId}`;
|
|
686
|
+
if (!realEdgeNameByPair.has(pairKey)) {
|
|
687
|
+
realEdgeNameByPair.set(pairKey, e.name);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
else if (!e.targetId && e.name) {
|
|
683
691
|
const rawCall = e.name.replace(/^Call:\s*/i, "").trim();
|
|
684
692
|
const pseudoCall = `call_${shortHash(`unres:${e.sourceId}:${rawCall}`).slice(0, 8)}`;
|
|
685
693
|
anonEdgeName = `Call: ${pseudoCall}`;
|
|
@@ -708,8 +716,9 @@ export function anonymizeGraphForCloudLayout(rawGraph, diffDelta, rulesConfig, o
|
|
|
708
716
|
anonEdgeMeta.source = "USER_SHIM";
|
|
709
717
|
if (e.metadata.shapeKey)
|
|
710
718
|
anonEdgeMeta.shapeKey = e.metadata.shapeKey;
|
|
711
|
-
if (e.metadata.viaHelper)
|
|
712
|
-
anonEdgeMeta.viaHelper = e.metadata.viaHelper
|
|
719
|
+
if (typeof e.metadata.viaHelper === "string" && e.metadata.viaHelper.trim()) {
|
|
720
|
+
anonEdgeMeta.viaHelper = `call_${shortHash(`unres:${e.sourceId}:${e.metadata.viaHelper.trim()}`).slice(0, 8)}`;
|
|
721
|
+
}
|
|
713
722
|
if (e.metadata.unresolvedReason) {
|
|
714
723
|
anonEdgeMeta.unresolvedReason = e.metadata.unresolvedReason;
|
|
715
724
|
}
|
|
@@ -823,7 +832,9 @@ export function anonymizeGraphForCloudLayout(rawGraph, diffDelta, rulesConfig, o
|
|
|
823
832
|
request: {
|
|
824
833
|
schemaVersion: "1.0",
|
|
825
834
|
graph: {
|
|
826
|
-
|
|
835
|
+
extractorVersion: rawGraph.extractorVersion ?? "1.0",
|
|
836
|
+
analyzedAt: rawGraph.analyzedAt ?? "1970-01-01T00:00:00.000Z",
|
|
837
|
+
...(rawGraph.version ? { version: rawGraph.version } : {}),
|
|
827
838
|
repoId: `repo_${shortHash(rawGraph.repoId || "local").slice(0, 8)}`,
|
|
828
839
|
nodes: anonymizedNodes,
|
|
829
840
|
edges: anonymizedEdges,
|
|
@@ -842,6 +853,7 @@ export function anonymizeGraphForCloudLayout(rawGraph, diffDelta, rulesConfig, o
|
|
|
842
853
|
realDisplayNameByRealPkg,
|
|
843
854
|
realBadgeByPseudoBadge,
|
|
844
855
|
realReceptorIdByPseudoId,
|
|
856
|
+
realEdgeNameByPair,
|
|
845
857
|
realUnresolvedByKey,
|
|
846
858
|
},
|
|
847
859
|
};
|
|
@@ -1023,11 +1035,15 @@ export function rehydrateCloudLayout(response, hydrationMap, rawGraph, repoName,
|
|
|
1023
1035
|
const rehydratedEdges = layout.edges.map((e) => {
|
|
1024
1036
|
const sourceId = mapLayoutNodeId(e.sourceId);
|
|
1025
1037
|
const targetId = mapLayoutNodeId(e.targetId);
|
|
1038
|
+
const srcOrig = extractBaseOriginalIdFromLayoutNodeId(e.sourceId).originalId.split("@")[0];
|
|
1039
|
+
const tgtOrig = extractBaseOriginalIdFromLayoutNodeId(e.targetId).originalId.split("@")[0];
|
|
1040
|
+
const realEdgeName = hydrationMap.realEdgeNameByPair?.get(`${srcOrig}::${tgtOrig}`) ?? e.name;
|
|
1026
1041
|
return {
|
|
1027
1042
|
...e,
|
|
1028
1043
|
id: `${sourceId}→${targetId}`,
|
|
1029
1044
|
sourceId,
|
|
1030
1045
|
targetId,
|
|
1046
|
+
...(realEdgeName ? { name: realEdgeName } : {}),
|
|
1031
1047
|
};
|
|
1032
1048
|
});
|
|
1033
1049
|
const rehydratedPackageBounds = {};
|
|
@@ -1114,6 +1130,19 @@ export function rehydrateCloudLayout(response, hydrationMap, rawGraph, repoName,
|
|
|
1114
1130
|
...(overlays ? { overlays } : {}),
|
|
1115
1131
|
};
|
|
1116
1132
|
}
|
|
1133
|
+
/**
|
|
1134
|
+
* Computes the dynamic Cloud Layout Worker timeout (`30s`–`90s`) when an explicit
|
|
1135
|
+
* `timeoutMs` is not supplied, preventing premature `15s` aborts on 2,000–3,000+ node monorepos.
|
|
1136
|
+
*/
|
|
1137
|
+
export function computeCloudLayoutTimeoutMs(nodeCount, explicitTimeoutMs) {
|
|
1138
|
+
if (typeof explicitTimeoutMs === "number" &&
|
|
1139
|
+
Number.isFinite(explicitTimeoutMs) &&
|
|
1140
|
+
explicitTimeoutMs > 0) {
|
|
1141
|
+
return explicitTimeoutMs;
|
|
1142
|
+
}
|
|
1143
|
+
const safeNodeCount = Math.max(0, nodeCount);
|
|
1144
|
+
return Math.max(30_000, Math.min(90_000, 20_000 + safeNodeCount * 15));
|
|
1145
|
+
}
|
|
1117
1146
|
export async function requestStatelessCloudLayout(rawGraph, repoName, diffDelta, rulesConfig, overlays, options = {}) {
|
|
1118
1147
|
const { request, hydrationMap } = anonymizeGraphForCloudLayout(rawGraph, diffDelta, rulesConfig, overlays);
|
|
1119
1148
|
const explicitUrl = (options.cloudApiUrl ??
|
|
@@ -1134,8 +1163,9 @@ export async function requestStatelessCloudLayout(rawGraph, repoName, diffDelta,
|
|
|
1134
1163
|
return rehydrateCloudLayout(response, hydrationMap, rawGraph, repoName, overlays);
|
|
1135
1164
|
}
|
|
1136
1165
|
const baseUrl = explicitUrl || DEFAULT_CLOUD_API_URL;
|
|
1166
|
+
const effectiveTimeoutMs = computeCloudLayoutTimeoutMs(rawGraph.nodes.length, options.timeoutMs);
|
|
1137
1167
|
const controller = new AbortController();
|
|
1138
|
-
const timeout = setTimeout(() => controller.abort(),
|
|
1168
|
+
const timeout = setTimeout(() => controller.abort(), effectiveTimeoutMs);
|
|
1139
1169
|
try {
|
|
1140
1170
|
const headers = {
|
|
1141
1171
|
"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.45",
|
|
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",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"express": "^5.2.1",
|
|
37
37
|
"typescript": "^5.3.0",
|
|
38
38
|
"zod": "^3.23.8",
|
|
39
|
-
"@getchomp/core": "0.2.
|
|
40
|
-
"@getchomp/db": "0.2.
|
|
41
|
-
"@getchomp/mcp": "0.2.
|
|
39
|
+
"@getchomp/core": "0.2.45",
|
|
40
|
+
"@getchomp/db": "0.2.45",
|
|
41
|
+
"@getchomp/mcp": "0.2.45"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/better-sqlite3": "^7.6.11",
|
|
@@ -50,6 +50,6 @@
|
|
|
50
50
|
"build": "tsc -p tsconfig.build.json",
|
|
51
51
|
"dev": "tsx src/index.ts",
|
|
52
52
|
"typecheck": "tsc --noEmit",
|
|
53
|
-
"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"
|
|
54
54
|
}
|
|
55
55
|
}
|