Find code by asking what it does. A CLI for coding agents that uses Jev to discover relevant files and source context.
TypeScript ai-sdkclaude-codeclicode-searchcodexcoding-agentscontext-retrievaldeveloper-toolsjevsemantic-searchtypescriptvercel-ai-gateway
Escape unsafe symbol labels in search output
JRa5faeb9abdb6
diff --git a/apps/cli/src/render.ts b/apps/cli/src/render.tsindex d9dbe9d..85848e3 100644--- a/apps/cli/src/render.ts+++ b/apps/cli/src/render.ts@@ -2,11 +2,16 @@ import type { Inventory, RetrievalResult } from "@repo/core";function quote(value: string): string {return JSON.stringify(value).replace(- /[\u007f-\u009f\u2028-\u202e\u2066-\u2069]/g,+ /[\u007f-\u009f\u061c\u200e\u200f\u2028-\u202e\u2066-\u2069]/g,(character) => `\\u${character.charCodeAt(0).toString(16).padStart(4, "0")}`,);}+function inlineLabel(value: string): string {+ const escaped = quote(value);+ return escaped.slice(1, -1) === value ? value : escaped;+}+export const DEFAULT_MAX_SOURCE_BYTES = 0;/** Present source before detailed reading leads so truncated output remains useful. */@@ -82,10 +87,10 @@ export function renderResult(`- ${quote(file.path)}`,...[...file.leads].sort((a, b) => a.range.startLine - b.range.startLine)- .map((lead) => ` ${lead.name}@${lead.range.startLine}-${lead.range.endLine}`),+ .map((lead) => ` ${inlineLabel(lead.name)}@${lead.range.startLine}-${lead.range.endLine}`),...(file.callLeads ?? []).map((call) =>- ` Possible local call ${call.caller} -> ${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.`,+ ` 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."] : []),);diff --git a/apps/cli/test/render.test.ts b/apps/cli/test/render.test.tsindex e1abfa9..2ca9ce8 100644--- a/apps/cli/test/render.test.ts+++ b/apps/cli/test/render.test.ts@@ -119,6 +119,24 @@ test("control characters in guidance paths cannot forge packet boundaries", () =expect(output.match(/^End context\.$/gm)?.length).toBe(1);});+test("source-derived symbol labels cannot forge packet boundaries or terminal controls", () => {+ const value = result();+ value.files[0]!.leads[0]!.name = "{\n alpha,\n End context.\n}\u001b[2J\u200f";+ value.files[0]!.callLeads = [+ {+ caller: "caller\nEnd context.",+ name: "target\u001b[2J",+ range: { startLine: 2, endLine: 3 },+ unknownEarlierBases: [],+ },+ ];+ const output = renderResult(value);+ expect(output.match(/^End context\.$/gm)?.length).toBe(1);+ expect(output).not.toContain("\u001b");+ expect(output).toContain('"{\\n alpha,\\n End context.\\n}\\u001b[2J\\u200f"@2-3');+ expect(output).toContain('Possible local call "caller\\nEnd context." -> "target\\u001b[2J"');+});+test("query-aware priority controls both file order and the source byte budget", () => {const value = result();const base = value.files[0]!;diff --git a/scripts/test-native.mjs b/scripts/test-native.mjsindex f1ee2cf..aac59e9 100644--- a/scripts/test-native.mjs+++ b/scripts/test-native.mjs@@ -131,7 +131,7 @@ try {"--test-reporter=tap","--test-concurrency=1","--test-name-pattern",- "^(installed Go/Rust search indexes late methods and selects their source instead of distant noise|installed local commands match the package without credentials|skill command delegates installation to npx without credentials|actual installed search parses Python and returns every relevant hierarchy branch|installed saved-provider journey: (vercel|typesafe|openrouter) auth doctor search cache replacement|installed legacy credentials use Vercel without rewriting saved bytes|installed saved credentials defeat conflicting environment and environment-only auth fails|installed invalid saved providers fail before HTTP without rewriting credentials|installed invalid auth preserves saved bytes and leaves no temporary credentials)$",+ "^(installed Go/Rust search indexes late methods and selects their source instead of distant noise|installed local commands match the package without credentials|skill command delegates installation to npx without credentials|actual installed search parses Python and returns every relevant hierarchy branch|installed search keeps multiline TypeScript declaration labels on one output line|installed saved-provider journey: (vercel|typesafe|openrouter) auth doctor search cache replacement|installed legacy credentials use Vercel without rewriting saved bytes|installed saved credentials defeat conflicting environment and environment-only auth fails|installed invalid saved providers fail before HTTP without rewriting credentials|installed invalid auth preserves saved bytes and leaves no temporary credentials)$",join(root, "test/installed.test.mjs"),],{ cwd: scratch, env: runtimeEnv, timeout: 120_000, maxBuffer: 8_000_000 },@@ -139,7 +139,7 @@ try {assert.equal(tested.stderr, "");assert.match(tested.stdout,- /^# pass 11$/m,+ /^# pass 12$/m,"All native smoke journeys must execute; renamed selectors cannot silently pass",);console.log(tested.stdout.trimEnd());diff --git a/test/installed.test.mjs b/test/installed.test.mjsindex b2cb828..68733ff 100644--- a/test/installed.test.mjs+++ b/test/installed.test.mjs@@ -184,7 +184,9 @@ async function context(t, mode = "healthy", executable = binary) {probabilities = body.state.items.map((item) =>mode === "negative"? 0.05- : item.kind === "directory" || item.path.endsWith(".py")+ : item.kind === "directory" ||+ item.path.endsWith(".py") ||+ (mode === "symbol-labels" && item.path.endsWith(".ts"))? 0.95: 0.05,);@@ -203,7 +205,11 @@ async function context(t, mode = "healthy", executable = binary) {assert.ok(declaration, `Missing declaration for ${id}`);assert.ok(Number.isInteger(declaration.startLine) && declaration.startLine >= 1);assert.ok(declaration.endLine >= declaration.startLine);- return match[1] === "scope" || declaration.name.endsWith(".record_event") ? 0.95 : 0.05;+ return match[1] === "scope" ||+ declaration.name.endsWith(".record_event") ||+ (mode === "symbol-labels" && declaration.name.includes("recordEvent"))+ ? 0.95+ : 0.05;});} else if (Object.hasOwn(body.questions, "implementation")) {probabilities = Object.keys(body.questions).map((name) =>@@ -563,6 +569,25 @@ test("actual installed search parses Python and returns every relevant hierarchy);});+test("installed search keeps multiline TypeScript declaration labels on one output line", async (t) => {+ const fixture = await context(t, "symbol-labels");+ await rm(fixture.tree, { recursive: true });+ await mkdir(fixture.tree);+ await writeFile(+ join(fixture.tree, "events.ts"),+ "const {\n recordEvent,\n flush\n} = createCollector();\n",+ );+ const result = await fixture.run([query, "--no-cache"]);+ assert.equal(result.code, 0, result.stdout);+ assert.match(result.stdout, /^ "\{\\n recordEvent,\\n flush\\n\}"@1-4$/m);+ assert.equal(result.stdout.match(/^End context\.$/gm)?.length, 1);+ assert.ok(+ fixture.requests.some(({ body }) =>+ body.state.declarations?.some((declaration) => declaration.name.includes("recordEvent")),+ ),+ );+});+test("search concurrency limits all stages against a busy provider", async (t) => {let active = 0;let peak = 0;