@getforgeai/cli 0.1.0-beta.1 → 0.1.0-beta.2

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.
@@ -1,3 +1,23 @@
1
+ /**
2
+ * Resolve the ForgeAI CLI binary to spawn for the MCP probe.
3
+ *
4
+ * This must point at the CLI entry point (dist/bin/forgeai.js), which is the
5
+ * only script that parses an `mcp` subcommand. It used to use
6
+ * `process.argv[1]`, which is correct when the probe runs from the CLI itself
7
+ * but WRONG in the case that actually matters: the probe normally runs inside
8
+ * the daemon, where argv[1] is dist/lib/daemon-entry.js. That entry point
9
+ * parses no arguments, so `daemon-entry.js mcp ...` silently started another
10
+ * daemon instead of an MCP server — the probe then timed out every time,
11
+ * `mcpHealthy` stayed false, and the Cloud skipped this CLI for dispatch
12
+ * (task-dispatch-engine skips CLIs reporting mcpHealthy === false), while each
13
+ * re-probe leaked one more detached daemon process.
14
+ *
15
+ * Resolve it from this module's own location instead: dist/mcp/ -> dist/bin/.
16
+ */
17
+ export declare function resolveForgeBinary(): {
18
+ command: string;
19
+ prefixArgs: string[];
20
+ };
1
21
  /**
2
22
  * Probe the MCP server to verify it can start and respond to JSON-RPC initialize.
3
23
  *
@@ -1,13 +1,33 @@
1
1
  import { spawn } from "node:child_process";
2
+ import { existsSync } from "node:fs";
3
+ import { join } from "node:path";
2
4
  import chalk from "chalk";
3
5
  const PROBE_TIMEOUT_MS = 10_000;
4
6
  /**
5
- * Resolve the ForgeAI CLI binary for MCP probe.
6
- * Same logic as agent-spawner's resolveForgeBinary.
7
+ * Resolve the ForgeAI CLI binary to spawn for the MCP probe.
8
+ *
9
+ * This must point at the CLI entry point (dist/bin/forgeai.js), which is the
10
+ * only script that parses an `mcp` subcommand. It used to use
11
+ * `process.argv[1]`, which is correct when the probe runs from the CLI itself
12
+ * but WRONG in the case that actually matters: the probe normally runs inside
13
+ * the daemon, where argv[1] is dist/lib/daemon-entry.js. That entry point
14
+ * parses no arguments, so `daemon-entry.js mcp ...` silently started another
15
+ * daemon instead of an MCP server — the probe then timed out every time,
16
+ * `mcpHealthy` stayed false, and the Cloud skipped this CLI for dispatch
17
+ * (task-dispatch-engine skips CLIs reporting mcpHealthy === false), while each
18
+ * re-probe leaked one more detached daemon process.
19
+ *
20
+ * Resolve it from this module's own location instead: dist/mcp/ -> dist/bin/.
7
21
  */
8
- function resolveForgeBinary() {
22
+ export function resolveForgeBinary() {
23
+ const binPath = join(import.meta.dirname, "..", "bin", "forgeai.js");
24
+ if (existsSync(binPath)) {
25
+ return { command: process.execPath, prefixArgs: [binPath] };
26
+ }
27
+ // Fallback for unusual layouts: use argv[1] only when it really is the CLI
28
+ // entry point, never the daemon entry.
9
29
  const scriptPath = process.argv[1];
10
- if (scriptPath) {
30
+ if (scriptPath?.includes(join("bin", "forgeai"))) {
11
31
  return { command: process.execPath, prefixArgs: [scriptPath] };
12
32
  }
13
33
  return { command: "forgeai", prefixArgs: [] };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getforgeai/cli",
3
- "version": "0.1.0-beta.1",
3
+ "version": "0.1.0-beta.2",
4
4
  "description": "ForgeAI CLI — runs AI coding agents in local Docker containers with your own AI tokens, and connects them to the ForgeAI cockpit.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",