Skip to content

Find code by asking what it does. A CLI for coding agents that uses Jev to discover relevant files and source context.

feat(cli): add --no-locations flag to omit Declaration locations section

Liyua809db6a33a7
diff --git a/apps/cli/src/args.ts b/apps/cli/src/args.ts
index 8eb8902..446ecef 100644
--- a/apps/cli/src/args.ts
+++ b/apps/cli/src/args.ts
@@ -21,6 +21,7 @@ export type Command =
maxRequests: number;
maxSourceBytes: number;
maxOutputBytes: number;
+ noLocations: boolean;
policy: NonNullable<SearchInput["policy"]>;
};
@@ -46,6 +47,7 @@ export function parseCommand(args: string[]): Command {
"max-requests": { type: "string" },
"max-source-bytes": { type: "string" },
"max-output-bytes": { type: "string" },
+ "no-locations": { type: "boolean" },
hidden: { type: "boolean" },
"no-ignore": { type: "boolean" },
"include-dependencies": { type: "boolean" },
@@ -179,6 +181,7 @@ export function parseCommand(args: string[]): Command {
maxRequests,
maxSourceBytes,
maxOutputBytes,
+ noLocations: values["no-locations"] ?? false,
policy,
};
}
@@ -246,6 +249,7 @@ Search options:
--max-requests N Provider request ceiling (default: 1000)
--max-source-bytes N Source allocation; 0 means unlimited (default: ${DEFAULT_MAX_SOURCE_BYTES})
--max-output-bytes N Total stdout cap; 0 means unlimited (default: ${DEFAULT_MAX_OUTPUT_BYTES})
+ --no-locations Omit the trailing "Declaration locations:" section
--hidden Include hidden paths
--no-ignore Disable .gitignore/.ignore patterns
--include-dependencies Include dependency and build directories
diff --git a/apps/cli/src/index.ts b/apps/cli/src/index.ts
index a721807..e6cb438 100644
--- a/apps/cli/src/index.ts
+++ b/apps/cli/src/index.ts
@@ -133,7 +133,9 @@ async function main() {
evaluator,
);
if (pipeClosed) return;
- await write(renderResult(result, command.maxSourceBytes, command.maxOutputBytes));
+ await write(
+ renderResult(result, command.maxSourceBytes, command.maxOutputBytes, command.noLocations),
+ );
process.exitCode =
result.status === "interrupted" ? 130 : result.status === "incomplete" ? 2 : 0;
}
diff --git a/apps/cli/src/render.ts b/apps/cli/src/render.ts
index 7f76943..eaad1f4 100644
--- a/apps/cli/src/render.ts
+++ b/apps/cli/src/render.ts
@@ -21,6 +21,7 @@ export function renderResult(
result: RetrievalResult,
maxSourceBytes = DEFAULT_MAX_SOURCE_BYTES,
maxOutputBytes = DEFAULT_MAX_OUTPUT_BYTES,
+ noLocations = false,
): string {
let remaining = maxSourceBytes || Infinity;
const files = [...result.files]
@@ -65,7 +66,7 @@ export function renderResult(
...files.flatMap(({ file, excerpts, omitted }) => [
`- ${quote(file.path)} — ${file.roles.join(", ") || "relevant; role uncertain"}; ${excerpts.length ? "source below" : omitted ? "source omitted" : "locations only"}`,
]),
- "End file list. Declaration locations follow source.",
+ noLocations ? "End file list." : "End file list. Declaration locations follow source.",
];
for (const { file, excerpts } of files)
for (const { range, source, partial, sourceByteStart, sourceByteEnd } of excerpts) {
@@ -92,19 +93,23 @@ export function renderResult(
for (const line of sourceLines) lines.push(line);
lines.push(fence);
}
- lines.push("", "Declaration locations:");
- for (const { file, omitted } of files) {
- lines.push(
- `- ${quote(file.path)}`,
- ...[...file.leads]
- .sort((a, b) => a.range.startLine - b.range.startLine)
- .map((lead) => ` ${inlineLabel(lead.name)}@${lead.range.startLine}-${lead.range.endLine}`),
- ...(file.callLeads ?? []).map(
- (call) =>
- ` Possible local call ${inlineLabel(call.caller)} -> ${inlineLabel(call.name)}: lines ${call.range.startLine}-${call.range.endLine}${call.unknownEarlierBases.length ? `; earlier base(s) ${call.unknownEarlierBases.map(quote).join(", ")} not inspected` : ""}; runtime dispatch not verified.`,
- ),
- ...(omitted ? [" Some source omitted; locations remain available."] : []),
- );
+ if (!noLocations) {
+ lines.push("", "Declaration locations:");
+ for (const { file, omitted } of files) {
+ lines.push(
+ `- ${quote(file.path)}`,
+ ...[...file.leads]
+ .sort((a, b) => a.range.startLine - b.range.startLine)
+ .map(
+ (lead) => ` ${inlineLabel(lead.name)}@${lead.range.startLine}-${lead.range.endLine}`,
+ ),
+ ...(file.callLeads ?? []).map(
+ (call) =>
+ ` Possible local call ${inlineLabel(call.caller)} -> ${inlineLabel(call.name)}: lines ${call.range.startLine}-${call.range.endLine}${call.unknownEarlierBases.length ? `; earlier base(s) ${call.unknownEarlierBases.map(quote).join(", ")} not inspected` : ""}; runtime dispatch not verified.`,
+ ),
+ ...(omitted ? [" Some source omitted; locations remain available."] : []),
+ );
+ }
}
const output = lines.join("\n") + "\n\nEnd context.\n";
const outputBytes = Buffer.byteLength(output);
diff --git a/apps/cli/test/args.test.ts b/apps/cli/test/args.test.ts
index 0ce1e8e..d8fb218 100644
--- a/apps/cli/test/args.test.ts
+++ b/apps/cli/test/args.test.ts
@@ -1,5 +1,5 @@
import { expect, test } from "bun:test";
-import { parseCommand } from "../src/args";
+import { help, parseCommand } from "../src/args";
test("search accepts independent policy flags and a dash-prefixed root after --", () => {
expect(
@@ -20,6 +20,7 @@ test("search accepts independent policy flags and a dash-prefixed root after --"
maxRequests: 1000,
maxSourceBytes: 12,
maxOutputBytes: 256000,
+ noLocations: false,
policy: { hidden: true },
});
expect(() => parseCommand(["question", "a", "b"])).toThrow();
@@ -27,6 +28,20 @@ test("search accepts independent policy flags and a dash-prefixed root after --"
expect(() => parseCommand(["question", "--secret-mistake"])).toThrow("Unknown option");
});
+test("no-locations threads through to the search command", () => {
+ expect(parseCommand(["question", "--no-locations"])).toMatchObject({
+ kind: "search",
+ noLocations: true,
+ });
+ const def = parseCommand(["question"]);
+ if (def.kind !== "search") throw new Error("Expected search");
+ expect(def.noLocations).toBe(false);
+});
+
+test("help documents the no-locations flag", () => {
+ expect(help).toContain("--no-locations");
+});
+
test("request and output ceilings accept explicit bounds", () => {
expect(
parseCommand(["question", "--max-requests", "12", "--max-output-bytes", "512"]),
diff --git a/apps/cli/test/render.test.ts b/apps/cli/test/render.test.ts
index ac75b7b..a274444 100644
--- a/apps/cli/test/render.test.ts
+++ b/apps/cli/test/render.test.ts
@@ -45,6 +45,17 @@ test("source precedes detailed locations and remains verbatim", () => {
expect(output.endsWith("\nEnd context.\n")).toBe(true);
});
+test("no-locations omits the trailing declaration locations section", () => {
+ const output = renderResult(result(), 0, 0, true);
+ expect(output).not.toContain("Declaration locations");
+ expect(output).not.toContain("Declaration locations follow source");
+ expect(output).toContain("End file list.");
+ expect(output).toContain('- "one.py" — implementation; source below');
+ expect(output).toContain('Source block "one.py" lines 1-3:');
+ expect(output).not.toContain("behavior@2-3");
+ expect(output.endsWith("\nEnd context.\n")).toBe(true);
+});
+
test("explicit byte limits preserve all locations and mark omissions without clipping UTF-8", () => {
const value = result();
value.files.push({