Skip to content

armgit / Ix

Public Imported from GitHub
0

Understand any codebase instantly. System intelligence for codebases, built for humans and AI.

fix: route all remaining stdout leaks to stderr — query, read, text commands

riley02276bd791a20b1d
diff --git a/ix-cli/src/cli/commands/query.ts b/ix-cli/src/cli/commands/query.ts
index 9873c3ec..de76b84d 100644
--- a/ix-cli/src/cli/commands/query.ts
+++ b/ix-cli/src/cli/commands/query.ts
@@ -2,6 +2,7 @@ import type { Command } from "commander";
import { IxClient } from "../../client/api.js";
import { getEndpoint } from "../config.js";
import { formatContext } from "../format.js";
+import { stderr } from "../stderr.js";
export function registerQueryCommand(program: Command): void {
program
@@ -12,26 +13,26 @@ export function registerQueryCommand(program: Command): void {
.option("--format <fmt>", "Output format (text|json)", "text")
.option("--unsafe", "Enable query (can produce large outputs)")
.action(async (question: string, opts: { asOf?: string; depth?: string; format: string; unsafe?: boolean }) => {
- console.log("\n⚠ ix query is DEPRECATED — broad NLP-style graph queries produce oversized, low-signal responses.");
- console.log(" Decompose your question into targeted commands instead:\n");
- console.log(" ix search <term> Find entities by name/kind");
- console.log(" ix explain <symbol> Structure, container, history, calls");
- console.log(" ix callers <symbol> What calls a function (cross-file)");
- console.log(" ix callees <symbol> What a function calls");
- console.log(" ix contains <symbol> Members of a class/module");
- console.log(" ix imports <symbol> What an entity imports");
- console.log(" ix imported-by <symbol> What imports an entity");
- console.log(" ix depends <symbol> Dependency impact analysis");
- console.log(" ix text <term> Fast lexical search (ripgrep)");
- console.log(" ix read <target> Read source code directly");
- console.log(" ix decisions List design decisions");
- console.log(" ix history <entityId> Provenance chain");
- console.log(" ix diff <from> <to> Changes between revisions\n");
+ stderr("\n⚠ ix query is DEPRECATED — broad NLP-style graph queries produce oversized, low-signal responses.");
+ stderr(" Decompose your question into targeted commands instead:\n");
+ stderr(" ix search <term> Find entities by name/kind");
+ stderr(" ix explain <symbol> Structure, container, history, calls");
+ stderr(" ix callers <symbol> What calls a function (cross-file)");
+ stderr(" ix callees <symbol> What a function calls");
+ stderr(" ix contains <symbol> Members of a class/module");
+ stderr(" ix imports <symbol> What an entity imports");
+ stderr(" ix imported-by <symbol> What imports an entity");
+ stderr(" ix depends <symbol> Dependency impact analysis");
+ stderr(" ix text <term> Fast lexical search (ripgrep)");
+ stderr(" ix read <target> Read source code directly");
+ stderr(" ix decisions List design decisions");
+ stderr(" ix history <entityId> Provenance chain");
+ stderr(" ix diff <from> <to> Changes between revisions\n");
if (!opts.unsafe) {
- console.log("Pass --unsafe to run anyway (not recommended).\n");
+ stderr("Pass --unsafe to run anyway (not recommended).\n");
return;
}
- console.log("Running with --unsafe...\n");
+ stderr("Running with --unsafe...\n");
const client = new IxClient(getEndpoint());
const result = await client.query(question, {
asOfRev: opts.asOf ? parseInt(opts.asOf, 10) : undefined,
diff --git a/ix-cli/src/cli/commands/read.ts b/ix-cli/src/cli/commands/read.ts
index 7a566906..a4b1a0c0 100644
--- a/ix-cli/src/cli/commands/read.ts
+++ b/ix-cli/src/cli/commands/read.ts
@@ -5,6 +5,7 @@ import chalk from "chalk";
import { IxClient } from "../../client/api.js";
import { getEndpoint, resolveWorkspaceRoot } from "../config.js";
import { resolveEntity } from "../resolve.js";
+import { stderr } from "../stderr.js";
export function registerReadCommand(program: Command): void {
program
@@ -53,7 +54,7 @@ export function registerReadCommand(program: Command): void {
"function", "method", "class", "trait", "object", "interface", "module", "file"
], opts);
if (!resolved) {
- console.error(`Could not resolve symbol: ${target}`);
+ stderr(`Could not resolve symbol: ${target}`);
return;
}
@@ -70,7 +71,7 @@ export function registerReadCommand(program: Command): void {
}
return;
}
- console.error(`Source file not found: ${sourceUri ?? "(no provenance)"}`);
+ stderr(`Source file not found: ${sourceUri ?? "(no provenance)"}`);
return;
}
diff --git a/ix-cli/src/cli/commands/text.ts b/ix-cli/src/cli/commands/text.ts
index 5d4c4236..7704ce86 100644
--- a/ix-cli/src/cli/commands/text.ts
+++ b/ix-cli/src/cli/commands/text.ts
@@ -3,6 +3,7 @@ import { promisify } from "node:util";
import type { Command } from "commander";
import { formatTextResults, type TextResult } from "../format.js";
import { resolveWorkspaceRoot } from "../config.js";
+import { stderr } from "../stderr.js";
const execFileAsync = promisify(execFile);
@@ -62,7 +63,7 @@ export function registerTextCommand(program: Command): void {
formatTextResults(results.slice(0, limit), opts.format);
} catch (err: any) {
if (err.code === "ENOENT") {
- console.error("Error: ripgrep (rg) is not installed. Install it: https://github.com/BurntSushi/ripgrep#installation");
+ stderr("Error: ripgrep (rg) is not installed. Install it: https://github.com/BurntSushi/ripgrep#installation");
process.exit(1);
}
if (err.code === 1 || err.status === 1) {