diff --git a/src/agents/dynamic-agent-prompt-builder.ts b/src/agents/dynamic-agent-prompt-builder.ts index 3221738f..f6bf6e47 100644 --- a/src/agents/dynamic-agent-prompt-builder.ts +++ b/src/agents/dynamic-agent-prompt-builder.ts @@ -421,7 +421,7 @@ export function buildUltraworkSection( lines.push("**Agents** (for specialized consultation/exploration):") for (const agent of sortedAgents) { - const shortDesc = agent.description.split(".")[0] || agent.description + const shortDesc = agent.description.length > 120 ? agent.description.slice(0, 120) + "..." : agent.description const suffix = agent.name === "explore" || agent.name === "librarian" ? " (multiple)" : "" lines.push(`- \`${agent.name}${suffix}\`: ${shortDesc}`) } diff --git a/src/tools/ast-grep/cli.ts b/src/tools/ast-grep/cli.ts index b93c317f..19d12443 100644 --- a/src/tools/ast-grep/cli.ts +++ b/src/tools/ast-grep/cli.ts @@ -86,10 +86,22 @@ export async function runSg(options: RunOptions): Promise { let cliPath = getSgCliPath() - if (!existsSync(cliPath) && cliPath !== "sg") { + if (!cliPath || !existsSync(cliPath)) { const downloadedPath = await getAstGrepPath() if (downloadedPath) { cliPath = downloadedPath + } else { + return { + matches: [], + totalMatches: 0, + truncated: false, + error: + `ast-grep (sg) binary not found.\n\n` + + `Install options:\n` + + ` bun add -D @ast-grep/cli\n` + + ` cargo install ast-grep --locked\n` + + ` brew install ast-grep`, + } } } diff --git a/src/tools/ast-grep/constants.ts b/src/tools/ast-grep/constants.ts index af9d15ec..d1d1609b 100644 --- a/src/tools/ast-grep/constants.ts +++ b/src/tools/ast-grep/constants.ts @@ -82,7 +82,7 @@ export function findSgCliPathSync(): string | null { let resolvedCliPath: string | null = null -export function getSgCliPath(): string { +export function getSgCliPath(): string | null { if (resolvedCliPath !== null) { return resolvedCliPath } @@ -93,7 +93,7 @@ export function getSgCliPath(): string { return syncPath } - return "sg" + return null } export function setSgCliPath(path: string): void { @@ -186,29 +186,17 @@ export function checkEnvironment(): EnvironmentCheckResult { const result: EnvironmentCheckResult = { cli: { available: false, - path: cliPath, + path: cliPath ?? "not found", }, napi: { available: false, }, } - if (existsSync(cliPath)) { + if (cliPath && existsSync(cliPath)) { result.cli.available = true - } else if (cliPath === "sg") { - try { - const { spawnSync } = require("child_process") - const whichResult = spawnSync(process.platform === "win32" ? "where" : "which", ["sg"], { - encoding: "utf-8", - timeout: 5000, - }) - result.cli.available = whichResult.status === 0 && !!whichResult.stdout?.trim() - if (!result.cli.available) { - result.cli.error = "sg binary not found in PATH" - } - } catch { - result.cli.error = "Failed to check sg availability" - } + } else if (!cliPath) { + result.cli.error = "ast-grep binary not found. Install with: bun add -D @ast-grep/cli" } else { result.cli.error = `Binary not found: ${cliPath}` }