@getchomp/cli 0.2.44 → 0.2.46

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.
@@ -11,10 +11,10 @@ import { startUiServer } from "./ui.js";
11
11
  export const HARNESS_TEXT = `
12
12
  # --- BEGIN CHOMP HARNESS ---
13
13
  You are working in a Chomp-enabled workspace. Use the live codebase map first instead of guessing structure with grep or blind file scans:
14
- 1. Resolve target node IDs with chomp_get_nodes (using search_term / packageName) BEFORE reading source files. When the user asks an architectural question, queries how a flow works, or requests a visual walkthrough, IMMEDIATELY call chomp_create_view (passing viewLevel: "system" | "package") to spotlight the flow on Chomp Map and share the returned viewUrl link. Do NOT call chomp_create_view on routine coding or implementation prompts.
15
- 2. Call chomp_get_blast_radius (with create_view: false during coding tasks, or create_view: true when answering impact questions) BEFORE modifying a function, class, or route to check upstream callers, downstream dependencies, and input/output types, and use chomp_get_edges to trace call paths.
16
- 3. Call chomp_audit_health, chomp_find_redundancies, and chomp_check_boundaries to find unresolved calls, pass-through wrappers, duplicate flows, and boundary issues. Use chomp_get_conventions to match standard project patterns, and chomp_local_shims to add Bridges for dynamic or dependency-injected calls. For frontend CSS, Tailwind, or React UI edits, call chomp_audit_design_system before writing and chomp_diff_design_system after editing.
17
- 4. Call chomp_get_diff BEFORE finishing code changes to verify the exact structural impact against the saved map. Read the map first.
14
+ 1. Resolve target node IDs BEFORE reading source files by batching terms into a single chomp_get_nodes call using search_terms: [...] (or file_paths: [...] / packageName) instead of firing many single-term lookups. For frontend CSS, Tailwind, or React UI edits, call chomp_audit_design_system in parallel during initial discovery. Only call chomp_create_view (viewLevel: "system" | "package") when the user asks an architectural question, queries how a flow works, or requests a visual walkthrough—do NOT call chomp_create_view on coding prompts.
15
+ 2. Call chomp_get_blast_radius (create_view: false) BEFORE modifying a function, class, or route to check upstream callers, downstream dependencies, and input/output types, and use chomp_get_edges to trace call paths.
16
+ 3. Align new code with canonical workspace boundaries and shared packages (use chomp_get_conventions when unsure, and chomp_local_shims to add Bridges for dynamic or dependency-injected calls).
17
+ 4. After finishing edits, call chomp_get_diff ONCE as your unified post-edit gate (it evaluates both architecturalGate—new pass-through middlemen, duplicate flows/symbols, upward boundary violations, and cycles—and designSystemGate when a design-system baseline exists). If gateStatus is "PASS", STOP IMMEDIATELY—do NOT call chomp_check_boundaries, chomp_find_redundancies, or chomp_diff_design_system separately. Only call those drill-down tools (with only_new: true) when chomp_get_diff reports "WARN" and you need details to fix a newly introduced regression; never chase pre-existing advisories.
18
18
  # --- END CHOMP HARNESS ---
19
19
  `.trim() + "\n";
20
20
  export const CHOMP_HOOK_BLOCK = `
@@ -360,11 +360,11 @@ export function installKiroIntegration(repoRoot, options) {
360
360
  "",
361
361
  "## Core Workflow",
362
362
  "",
363
- "1. **Map-First Navigation:** Call `chomp_get_nodes` (`search_term` / `packageName`) and `chomp_get_edges` before reading files.",
363
+ "1. **Map-First Navigation:** Batch lookups into a single `chomp_get_nodes` call (`search_terms: [...]` / `file_paths: [...]` / `packageName`) and trace flows with `chomp_get_edges` before reading files.",
364
364
  "2. **Pre-Edit Impact:** Call `chomp_get_blast_radius` (`create_view: false` during coding tasks) before modifying functions, classes, or routes.",
365
365
  "3. **Spotlight Views (Questions Only):** Call `chomp_create_view` only when answering architectural questions or walkthrough requests.",
366
- "4. **Health, Boundaries & Design System:** Call `chomp_audit_health`, `chomp_find_redundancies`, `chomp_check_boundaries`, `chomp_get_conventions`, `chomp_local_shims`, and `chomp_audit_design_system` (for frontend work).",
367
- "5. **Post-Edit Verification:** Call `chomp_get_diff` (and `chomp_diff_design_system` for frontend changes) before completing code changes.",
366
+ "4. **Health, Boundaries & Design System:** Call `chomp_audit_design_system` upfront for frontend work, and `chomp_get_conventions` / `chomp_local_shims` when aligning dynamic patterns.",
367
+ "5. **Unified Post-Edit Gate:** Call `chomp_get_diff` ONCE after edits. If `gateStatus` is `'PASS'`, stop immediately—only call `chomp_check_boundaries`, `chomp_find_redundancies`, or `chomp_diff_design_system` (`only_new: true`) when `chomp_get_diff` reports `'WARN'`.",
368
368
  ].join("\n") + "\n";
369
369
  writeFileSync(powerMdPath, powerMd, "utf8");
370
370
  writeFileSync(powerMcpPath, JSON.stringify({
@@ -217,7 +217,10 @@ export function registerLayoutRoutes(app, state) {
217
217
  if (effectiveTargetRef !== "WORKING_TREE") {
218
218
  const targetRefInfo = await resolveGitRefInfo(repoPath, effectiveTargetRef, gitTargets);
219
219
  if (!targetRefInfo) {
220
- throw new Error(`Unable to resolve git ref '${effectiveTargetRef}' in ${repoPath}`);
220
+ return res.status(404).json({
221
+ error: `Unable to resolve git ref '${effectiveTargetRef}' in ${repoPath}`,
222
+ code: "UNKNOWN_GIT_REF",
223
+ });
221
224
  }
222
225
  const baseShaFull = baseRefInfo?.fullCommitSha ?? activeCommitSha ?? "base";
223
226
  const targetShaFull = targetRefInfo.fullCommitSha;
@@ -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;
@@ -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
- ...n,
673
+ ...nodeRest,
672
674
  name: pseudoName,
673
- ...(anonEvidence ? { evidence: anonEvidence } : {}),
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.name;
682
- if (!e.targetId && e.name) {
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
- ...rawGraph,
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 = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getchomp/cli",
3
- "version": "0.2.44",
3
+ "version": "0.2.46",
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.44",
40
- "@getchomp/mcp": "0.2.44",
41
- "@getchomp/db": "0.2.44"
39
+ "@getchomp/core": "0.2.46",
40
+ "@getchomp/mcp": "0.2.46",
41
+ "@getchomp/db": "0.2.46"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/better-sqlite3": "^7.6.11",