Skip to content

armgit / Ix

Public Imported from GitHub
0

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

feat: gate ix query behind --unsafe flag to prevent token explosions

riley0227307f30a6bda7
diff --git a/ix-cli/src/cli/commands/query.ts b/ix-cli/src/cli/commands/query.ts
index bbc74e00..77c96f28 100644
--- a/ix-cli/src/cli/commands/query.ts
+++ b/ix-cli/src/cli/commands/query.ts
@@ -6,11 +6,23 @@ import { formatContext } from "../format.js";
export function registerQueryCommand(program: Command): void {
program
.command("query <question>")
- .description("Query the knowledge graph for structured context")
+ .description("Query the knowledge graph for structured context (use --unsafe to enable)")
.option("--as-of <rev>", "Time-travel to a specific revision")
.option("--depth <depth>", "Query depth (shallow|standard|deep)", "standard")
.option("--format <fmt>", "Output format (text|json)", "text")
- .action(async (question: string, opts: { asOf?: string; depth?: string; format: string }) => {
+ .option("--unsafe", "Enable query (can produce large outputs)")
+ .action(async (question: string, opts: { asOf?: string; depth?: string; format: string; unsafe?: boolean }) => {
+ if (!opts.unsafe) {
+ console.log("ix query is disabled by default to prevent large token outputs.");
+ console.log("Use --unsafe to enable, or try these targeted alternatives:\n");
+ console.log(" ix search <term> Find entities by name");
+ console.log(" ix explain <symbol> Understand an entity");
+ console.log(" ix callers <symbol> Find what calls a function");
+ console.log(" ix contains <symbol> See members of a class/module");
+ console.log(" ix text <term> Lexical search across code");
+ console.log(" ix read <target> Read source code directly");
+ return;
+ }
const client = new IxClient(getEndpoint());
const result = await client.query(question, {
asOfRev: opts.asOf ? parseInt(opts.asOf, 10) : undefined,