Understand any codebase instantly. System intelligence for codebases, built for humans and AI.
TypeScript aiai-memoryclaude-codeclicode-analysiscode-mappingcode-memorycodebase-understandingcodexdeveloper-toolsllmopenclawpersistent-memoryprogram-analysissoftware-architecturesystem-intelligencesystem-mapping
feat(cli): auto-route ingest to cloud when configured, drop --remote flag
Joseph Mikhail4e9f52c1d16e
diff --git a/ix-cli/src/cli/commands/map.ts b/ix-cli/src/cli/commands/map.tsindex 1f5fd057..df153b3b 100644--- a/ix-cli/src/cli/commands/map.ts+++ b/ix-cli/src/cli/commands/map.ts@@ -7,7 +7,7 @@ import { roundFloat } from "../format.js";import { bootstrap } from "../bootstrap.js";import { formatFetchError } from "../errors.js";import { ingestFiles } from "./ingest.js";-import { getRemoteRunner } from "../remote.js";+import { getRemoteRunner, isCloudReady } from "../remote.js";export interface MapRegion {id: string;@@ -93,7 +93,7 @@ export function registerMapCommand(program: Command): void {.option("--graph", "Render the hierarchy as a graph/tree view (default)").option("--list", "Render the ranked list view instead of the default graph/tree view").option("--full", "Force full local map, bypassing automatic safety limits (advanced/testing)")- .option("--remote", "Route ingestion through the cloud pipeline instead of parsing locally (requires Ix Pro)")+ .option("--local", "Force local ingestion even when an active cloud instance is configured (Pro only)").option("--verbose", "Show raw confidence scores, crosscut scores, boundary ratios, and signals").option("--silent", "Suppress all output except a one-line summary (useful for LLM hooks)").addHelpText(@@ -112,6 +112,9 @@ Advanced:--full Override automatic local safety limits and force the full local mappath. Bypasses automatic downgrade to fast mode and the persistencesafety guardrail. Intended for testing and performance diagnosis.+ --local Force local ingestion even when an active cloud instance is+ configured. Useful for CI tests, network outages, or local-only+ development. (Pro only — OSS users are always local.)--silent Skip the full map rendering. Prints one summary line to stderr andexits. Ideal for LLM hooks and automated workflows where the fulloutput would waste context tokens.@@ -130,7 +133,7 @@ Examples:ix map . --fullix --debug map . --full`)- .action(async (pathArg: string | undefined, opts: { format: string; level?: string; minConfidence: string; maxItems: string; allItems?: boolean; sort: string; graph?: boolean; list?: boolean; full?: boolean; remote?: boolean; verbose?: boolean; silent?: boolean }) => {+ .action(async (pathArg: string | undefined, opts: { format: string; level?: string; minConfidence: string; maxItems: string; allItems?: boolean; sort: string; graph?: boolean; list?: boolean; full?: boolean; local?: boolean; verbose?: boolean; silent?: boolean }) => {const cwd = pathArg ? resolve(pathArg) : process.cwd();const silent = opts.silent === true || opts.format === "silent";@@ -144,21 +147,19 @@ Examples:}// Ingest the path before mapping so the graph is up to date.- // --remote routes through the cloud pipeline via a Pro-supplied- // RemoteRunner; absence means Pro isn't installed. The local- // backend bootstrap only runs on the non-remote path — cloud- // ingestion doesn't require a local Ix backend.+ //+ // Routing: if Pro is loaded AND the user has an active cloud+ // instance configured (isCloudReady === true), route ingestion+ // through the cloud pipeline. The --local opt-out forces local+ // even when cloud is configured (useful for CI tests, network+ // outages, or local-only development).+ //+ // The local backend bootstrap below only runs on the local path —+ // cloud ingestion doesn't require a local Ix backend.const ingestStart = performance.now();- if (opts.remote) {- const runner = getRemoteRunner();- if (!runner) {- console.error(- chalk.red("Error:"),- "--remote requires Ix Pro. Install @ix/pro to enable remote ingestion."- );- process.exitCode = 1;- return;- }+ const cloudReady = !opts.local && (await isCloudReady());+ if (cloudReady) {+ const runner = getRemoteRunner()!; // isCloudReady guarantees non-nulltry {await runner.runIngestion({cwd,diff --git a/ix-cli/src/cli/remote.ts b/ix-cli/src/cli/remote.tsindex d9b1cdc2..6f9dc312 100644--- a/ix-cli/src/cli/remote.ts+++ b/ix-cli/src/cli/remote.ts@@ -1,11 +1,11 @@// Optional extension point for a remote-ingestion backend.//-// OSS declares the --remote flag on commands that support remote-// ingestion (e.g. `ix map`) but ships no implementation. A Pro-// module (or other extension) registers a RemoteRunner at load-// time via registerRemoteRunner(); OSS command handlers look it up-// via getRemoteRunner() and fail with an actionable error when-// absent.+// OSS ships no remote implementation. A Pro module (or other extension)+// registers a RemoteRunner at load time via registerRemoteRunner(). OSS+// command handlers look it up via getRemoteRunner() and route through+// it automatically when isCloudReady() returns true — no per-command+// --remote flag required. A --local opt-out is still available for+// users who want to force local execution.export interface RemoteIngestOptions {cwd: string;@@ -15,6 +15,16 @@ export interface RemoteIngestOptions {export interface RemoteRunner {runIngestion(opts: RemoteIngestOptions): Promise<void>;+ /**+ * Optional readiness probe. Returns true when the runner is fully+ * configured (Pro loaded AND the user has set an active cloud+ * instance with an orgId). Pure local check — must NOT hit the+ * network; reachability is verified lazily inside runIngestion.+ *+ * Absent on legacy runners; in that case isCloudReady() treats the+ * runner as ready whenever it's registered.+ */+ isReady?(): Promise<boolean>;}let registered: RemoteRunner | null = null;@@ -26,3 +36,19 @@ export function registerRemoteRunner(runner: RemoteRunner): void {export function getRemoteRunner(): RemoteRunner | null {return registered;}++/**+ * True if a remote runner is registered AND it reports itself as ready.+ * Commands that auto-route between local and cloud (e.g. `ix map`) call+ * this once to decide which path to take. Pure local check — no network+ * I/O. Failure of the runner's isReady() falls back to "not ready".+ */+export async function isCloudReady(): Promise<boolean> {+ if (!registered) return false;+ if (!registered.isReady) return true; // legacy runner: registered => ready+ try {+ return await registered.isReady();+ } catch {+ return false;+ }+}