Skip to content

armgit / Ix

Public Imported from GitHub
0

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

feat: add ix decisions command with --topic and --limit filters

riley0227385884bbd48b
diff --git a/ix-cli/src/cli/commands/decisions.ts b/ix-cli/src/cli/commands/decisions.ts
new file mode 100644
index 00000000..7bed539e
--- /dev/null
+++ b/ix-cli/src/cli/commands/decisions.ts
@@ -0,0 +1,21 @@
+import type { Command } from "commander";
+import { IxClient } from "../../client/api.js";
+import { getEndpoint } from "../config.js";
+import { formatDecisions } from "../format.js";
+
+export function registerDecisionsCommand(program: Command): void {
+ program
+ .command("decisions")
+ .description("List recorded design decisions")
+ .option("--limit <n>", "Max results", "50")
+ .option("--topic <topic>", "Filter by topic keyword")
+ .option("--format <fmt>", "Output format (text|json)", "text")
+ .action(async (opts: { limit: string; topic?: string; format: string }) => {
+ const client = new IxClient(getEndpoint());
+ const nodes = await client.listDecisions({
+ limit: parseInt(opts.limit, 10),
+ topic: opts.topic,
+ });
+ formatDecisions(nodes, opts.format);
+ });
+}
diff --git a/ix-cli/src/cli/format.ts b/ix-cli/src/cli/format.ts
index b5a94db3..e80b73ae 100644
--- a/ix-cli/src/cli/format.ts
+++ b/ix-cli/src/cli/format.ts
@@ -86,9 +86,38 @@ export function formatNodes(nodes: any[], format: string): void {
}
for (const n of nodes) {
const shortId = n.id.length > 8 ? n.id.slice(0, 8) : n.id;
+ if (n.kind === "decision") {
+ const title = n.attrs?.title ?? n.name ?? "(untitled)";
+ console.log(
+ ` ${chalk.blue("decision")} ${chalk.dim(shortId)} ${title}`
+ );
+ } else {
+ console.log(
+ ` ${chalk.cyan(n.kind)} ${chalk.dim(shortId)} ${n.attrs?.name ?? n.name ?? JSON.stringify(n.attrs)}`
+ );
+ }
+ }
+}
+
+export function formatDecisions(nodes: any[], format: string): void {
+ if (format === "json") {
+ console.log(JSON.stringify(nodes, null, 2));
+ return;
+ }
+ if (nodes.length === 0) {
+ console.log("No decisions found.");
+ return;
+ }
+ for (const n of nodes) {
+ const shortId = n.id.length > 8 ? n.id.slice(0, 8) : n.id;
+ const title = n.attrs?.title ?? n.name ?? "(untitled)";
+ const rationale = n.attrs?.rationale ?? "";
console.log(
- ` ${chalk.cyan(n.kind)} ${chalk.dim(shortId)} attrs: ${chalk.gray(JSON.stringify(n.attrs))}`
+ ` ${chalk.blue("*")} ${chalk.dim(shortId)} ${chalk.bold(title)}`
);
+ if (rationale) {
+ console.log(` ${chalk.gray(rationale)}`);
+ }
}
}
diff --git a/ix-cli/src/cli/main.ts b/ix-cli/src/cli/main.ts
index a0d3d554..fc809646 100644
--- a/ix-cli/src/cli/main.ts
+++ b/ix-cli/src/cli/main.ts
@@ -3,6 +3,7 @@ import { Command } from "commander";
import { registerQueryCommand } from "./commands/query.js";
import { registerIngestCommand } from "./commands/ingest.js";
import { registerDecideCommand } from "./commands/decide.js";
+import { registerDecisionsCommand } from "./commands/decisions.js";
import { registerSearchCommand } from "./commands/search.js";
import { registerTruthCommand } from "./commands/truth.js";
import { registerPatchesCommand } from "./commands/patches.js";
@@ -23,6 +24,7 @@ program
registerQueryCommand(program);
registerIngestCommand(program);
registerDecideCommand(program);
+registerDecisionsCommand(program);
registerSearchCommand(program);
registerTruthCommand(program);
registerPatchesCommand(program);
diff --git a/ix-cli/src/client/api.ts b/ix-cli/src/client/api.ts
index 3b5bd386..c44b03be 100644
--- a/ix-cli/src/client/api.ts
+++ b/ix-cli/src/client/api.ts
@@ -29,8 +29,35 @@ export class IxClient {
return this.post("/v1/decide", { title, rationale, ...opts });
}
- async search(term: string, limit?: number): Promise<GraphNode[]> {
- return this.post("/v1/search", { term, limit });
+ async search(
+ term: string,
+ opts?: { limit?: number; kind?: string; language?: string; asOfRev?: number }
+ ): Promise<GraphNode[]> {
+ return this.post("/v1/search", {
+ term,
+ limit: opts?.limit,
+ kind: opts?.kind,
+ language: opts?.language,
+ asOfRev: opts?.asOfRev,
+ });
+ }
+
+ async listDecisions(opts?: { limit?: number; topic?: string }): Promise<GraphNode[]> {
+ return this.post("/v1/decisions", { limit: opts?.limit, topic: opts?.topic });
+ }
+
+ async resolvePrefix(prefix: string): Promise<string> {
+ const uuidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
+ if (uuidPattern.test(prefix)) return prefix;
+
+ const result = await this.get<{ id?: string; error?: string; matches?: string[] }>(
+ `/v1/resolve-prefix/${encodeURIComponent(prefix)}`
+ );
+ if (result.id) return result.id;
+ if (result.error === "ambiguous") {
+ throw new Error(`Ambiguous prefix "${prefix}" — matches: ${result.matches?.join(", ")}`);
+ }
+ throw new Error(`No entity found for prefix: ${prefix}`);
}
async entity(id: string): Promise<{