@getchomp/cli 0.2.42 → 0.2.43

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Chomp
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -164,11 +164,15 @@ export function detectAgentIntegrations(repoRoot, env = process.env) {
164
164
  const agentsMd = resolve(repoRoot, "AGENTS.md");
165
165
  const windsurfRules = resolve(repoRoot, ".windsurfrules");
166
166
  const kiroDir = resolve(repoRoot, ".kiro");
167
- const agyMcpConfig = resolve(homedir(), ".gemini", "antigravity", "mcp_config.json");
167
+ const agyWorkspaceDir = resolve(repoRoot, ".agents");
168
+ const agyWorkspaceMcp = resolve(agyWorkspaceDir, "mcp_config.json");
168
169
  const cursorDetected = existsSync(cursorDir) || existsSync(cursorRules);
169
170
  const claudeDetected = existsSync(claudeMd) || existsSync(claudeMcp);
170
171
  const agyDetected = existsSync(agentsMd) ||
171
- existsSync(resolve(homedir(), ".gemini", "antigravity"));
172
+ existsSync(agyWorkspaceDir) ||
173
+ existsSync(resolve(homedir(), ".gemini", "antigravity")) ||
174
+ existsSync(resolve(homedir(), ".gemini", "antigravity-cli")) ||
175
+ existsSync(resolve(homedir(), ".gemini", "config"));
172
176
  const windsurfDetected = existsSync(windsurfRules);
173
177
  const kiroDetected = existsSync(kiroDir) ||
174
178
  Boolean(env.KIRO_PID) ||
@@ -205,13 +209,11 @@ export function detectAgentIntegrations(repoRoot, env = process.env) {
205
209
  },
206
210
  {
207
211
  id: "antigravity",
208
- label: "Antigravity / AGENTS.md",
209
- hint: "AGENTS.md + mcp_config.json",
212
+ label: "Antigravity (`agy` CLI & IDE)",
213
+ hint: ".agents/mcp_config.json + AGENTS.md",
210
214
  detected: agyDetected || !anyDetected,
211
215
  ruleFile: "AGENTS.md",
212
- mcpConfigPath: existsSync(dirname(agyMcpConfig))
213
- ? agyMcpConfig
214
- : undefined,
216
+ mcpConfigPath: agyWorkspaceMcp,
215
217
  },
216
218
  {
217
219
  id: "windsurf",
@@ -586,6 +588,9 @@ export async function runInitWizard(inputPath, options = {}) {
586
588
  console.log(` ${ansi.green("✓")} Verified Chomp rules in ${ansi.cyan(agent.ruleFile)}`);
587
589
  }
588
590
  if (agent.mcpConfigPath && (!isStealth || agent.id === "antigravity")) {
591
+ if (isStealth && agent.id === "antigravity") {
592
+ ensureGitExcludeHasChomp(targetPath, [".agents/mcp_config.json"]);
593
+ }
589
594
  if (upsertMcpServerConfig(agent.mcpConfigPath, targetPath)) {
590
595
  console.log(` ${ansi.green("✓")} Connected ${ansi.bold("chomp-server")} MCP in ${ansi.cyan(agent.mcpConfigPath)}`);
591
596
  }
@@ -41,7 +41,8 @@ export async function startUiServer(targetPath, options = {}) {
41
41
  setActiveChompTarget(resolvedTarget);
42
42
  }
43
43
  const app = express();
44
- const host = options.host ?? process.env.CHOMP_UI_HOST ?? "127.0.0.1";
44
+ const defaultHost = existsSync("/.dockerenv") ? "0.0.0.0" : "127.0.0.1";
45
+ const host = options.host ?? process.env.CHOMP_UI_HOST ?? defaultHost;
45
46
  registerLoopbackSecurityMiddleware(app);
46
47
  // Serve the local Next.js static export when running inside the master monorepo
47
48
  const localWebDir = options.remote ? null : resolveLocalMasterWebDir();
@@ -235,6 +236,7 @@ export function registerUiCommand(program) {
235
236
  .command("ui [path]")
236
237
  .description("Start the local Chomp server and open Chomp Map (defaults to active connected repo or current directory)")
237
238
  .option("-p, --port <number>", "Port to run the local server on", "5555")
239
+ .option("--host <host>", "Host interface to bind to (defaults to 127.0.0.1, or 0.0.0.0 inside Docker)")
238
240
  .option("--db <path>", "Path to SQLite database file (default: <path>/.chomp/graph.db)")
239
241
  .option("-o, --open", "Automatically open Chomp Map in your browser", false)
240
242
  .option("-w, --watch", "Watch source files and automatically re-analyze on changes", false)
@@ -1,7 +1,7 @@
1
1
  import { existsSync, readdirSync, readFileSync, rmdirSync, rmSync, statSync, unlinkSync, writeFileSync, } from "node:fs";
2
2
  import { resolve } from "node:path";
3
3
  import { ansi } from "../utils/branding.js";
4
- import { getChompMasterRoot, readMasterContext, setActiveChompTarget, } from "../utils/masterContext.js";
4
+ import { clearRemovedChompTarget, } from "../utils/masterContext.js";
5
5
  const HOOK_FILES = [
6
6
  ".husky/post-commit",
7
7
  ".husky/post-merge",
@@ -22,6 +22,7 @@ const RULE_FILES = [
22
22
  const MCP_FILES = [
23
23
  ".cursor/mcp.json",
24
24
  ".mcp.json",
25
+ ".agents/mcp_config.json",
25
26
  ".kiro/settings/mcp.json",
26
27
  ];
27
28
  function isDefaultKiroSteeringRemainder(text) {
@@ -190,6 +191,7 @@ export function runUninstall(inputPath, options) {
190
191
  ".kiro/powers",
191
192
  ".kiro",
192
193
  ".cursor",
194
+ ".agents",
193
195
  ]) {
194
196
  pruneEmptyDir(resolve(cwd, relDir));
195
197
  }
@@ -200,9 +202,16 @@ export function runUninstall(inputPath, options) {
200
202
  const gitignoreContent = readFileSync(gitignorePath, "utf8");
201
203
  if (gitignoreContent.includes("# --- BEGIN CHOMP IGNORE ---")) {
202
204
  const cleaned = gitignoreContent.replace(ignoreRegex, "\n").trimEnd();
203
- writeFileSync(gitignorePath, cleaned ? cleaned + "\n" : "", "utf8");
204
- updated.push(".gitignore");
205
- log(` ${ansi.green("✓")} Cleaned up ${ansi.cyan(".gitignore")}`);
205
+ if (cleaned.trim().length === 0) {
206
+ unlinkSync(gitignorePath);
207
+ removed.push(".gitignore");
208
+ log(` ${ansi.green("✓")} Removed empty ${ansi.cyan(".gitignore")}`);
209
+ }
210
+ else {
211
+ writeFileSync(gitignorePath, cleaned + "\n", "utf8");
212
+ updated.push(".gitignore");
213
+ log(` ${ansi.green("✓")} Cleaned up ${ansi.cyan(".gitignore")}`);
214
+ }
206
215
  }
207
216
  }
208
217
  for (const gitExcludePath of resolveGitExcludePaths(cwd)) {
@@ -216,14 +225,13 @@ export function runUninstall(inputPath, options) {
216
225
  }
217
226
  }
218
227
  }
219
- // 6. If this repo was the active Master Tether, reset tether back to Chomp master
220
- const ctx = readMasterContext();
221
- if (ctx?.activeRepoPath && resolve(ctx.activeRepoPath) === resolve(cwd)) {
222
- const masterRoot = getChompMasterRoot();
223
- if (resolve(masterRoot) !== resolve(cwd)) {
224
- setActiveChompTarget(masterRoot);
225
- log(` ${ansi.green("✓")} Switched active repo back to ${ansi.cyan(masterRoot)}`);
226
- }
228
+ // 6. Update or clear active repo tether cleanly (never writing _npx/.../node_modules)
229
+ const tetherUpdate = clearRemovedChompTarget(cwd);
230
+ if (tetherUpdate.switchedTo) {
231
+ log(` ${ansi.green("✓")} Switched active repo back to ${ansi.cyan(tetherUpdate.switchedTo)}`);
232
+ }
233
+ else if (tetherUpdate.cleared) {
234
+ log(` ${ansi.green("✓")} Cleared active repo from global Chomp context`);
227
235
  }
228
236
  log(`\n ${ansi.yellowBold("◆")} ${ansi.bold("Chomp has been cleanly removed. We left no trace.")}\n`);
229
237
  return { removed, updated };
@@ -4,7 +4,7 @@ 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, 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)
@@ -91,7 +91,7 @@ function visualPadEnd(str, targetCols) {
91
91
  */
92
92
  export function renderChompBanner(subtitle, frame = "open") {
93
93
  const sideText = {
94
- 3: `${ansi.yellowBold("c h o m p")} ${ansi.dim("v0.1.0")}`,
94
+ 3: `${ansi.yellowBold("c h o m p")} ${ansi.dim(`v${CORE_EXTRACTOR_VERSION}`)}`,
95
95
  5: ansi.bold("The live map of your codebase."),
96
96
  6: ansi.dim(subtitle || "See how routes, components, and functions actually connect."),
97
97
  8: ansi.dim("Proven from code · Shared by you and your AI agent."),
@@ -951,24 +951,26 @@ export async function multiSelectPrompt(title, subtitle, options) {
951
951
  export function openBrowserUrl(url) {
952
952
  try {
953
953
  const platform = process.platform;
954
+ let child;
954
955
  if (platform === "darwin") {
955
- const child = spawn("open", [url], { stdio: "ignore", detached: true });
956
- child.unref();
956
+ child = spawn("open", [url], { stdio: "ignore", detached: true });
957
957
  }
958
958
  else if (platform === "win32") {
959
- const child = spawn("cmd", ["/c", "start", "", url], {
959
+ child = spawn("cmd", ["/c", "start", "", url], {
960
960
  stdio: "ignore",
961
961
  detached: true,
962
962
  });
963
- child.unref();
964
963
  }
965
964
  else {
966
- const child = spawn("xdg-open", [url], {
965
+ child = spawn("xdg-open", [url], {
967
966
  stdio: "ignore",
968
967
  detached: true,
969
968
  });
970
- child.unref();
971
969
  }
970
+ child.on("error", () => {
971
+ // Non-fatal in headless Linux / SSH / Docker / WSL environments without xdg-open
972
+ });
973
+ child.unref();
972
974
  }
973
975
  catch {
974
976
  // Non-fatal if browser opener is unavailable
@@ -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`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getchomp/cli",
3
- "version": "0.2.42",
3
+ "version": "0.2.43",
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.42",
39
- "@getchomp/db": "0.2.42",
40
- "@getchomp/mcp": "0.2.42"
39
+ "@getchomp/core": "0.2.43",
40
+ "@getchomp/db": "0.2.43",
41
+ "@getchomp/mcp": "0.2.43"
41
42
  },
42
43
  "devDependencies": {
43
44
  "@types/better-sqlite3": "^7.6.11",