@caupulican/pi-adaptative 0.81.5 → 0.81.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/dist/core/agent-session.d.ts +8 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +125 -66
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/background-lane-controller.d.ts +1 -0
- package/dist/core/background-lane-controller.d.ts.map +1 -1
- package/dist/core/background-lane-controller.js +10 -3
- package/dist/core/background-lane-controller.js.map +1 -1
- package/dist/core/bash-execution-controller.d.ts +1 -1
- package/dist/core/bash-execution-controller.d.ts.map +1 -1
- package/dist/core/bash-execution-controller.js +9 -6
- package/dist/core/bash-execution-controller.js.map +1 -1
- package/dist/core/billing-failover-controller.d.ts +2 -2
- package/dist/core/billing-failover-controller.d.ts.map +1 -1
- package/dist/core/billing-failover-controller.js +2 -8
- package/dist/core/billing-failover-controller.js.map +1 -1
- package/dist/core/compaction-support.d.ts +3 -0
- package/dist/core/compaction-support.d.ts.map +1 -1
- package/dist/core/compaction-support.js +18 -4
- package/dist/core/compaction-support.js.map +1 -1
- package/dist/core/context-pipeline.d.ts +1 -0
- package/dist/core/context-pipeline.d.ts.map +1 -1
- package/dist/core/context-pipeline.js +12 -0
- package/dist/core/context-pipeline.js.map +1 -1
- package/dist/core/exec.d.ts.map +1 -1
- package/dist/core/exec.js +7 -2
- package/dist/core/exec.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +33 -9
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +19 -5
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/failure-corpus.d.ts.map +1 -1
- package/dist/core/failure-corpus.js +1 -1
- package/dist/core/failure-corpus.js.map +1 -1
- package/dist/core/learning/reflection-engine.d.ts.map +1 -1
- package/dist/core/learning/reflection-engine.js +3 -1
- package/dist/core/learning/reflection-engine.js.map +1 -1
- package/dist/core/models/local-registration.d.ts +1 -0
- package/dist/core/models/local-registration.d.ts.map +1 -1
- package/dist/core/models/local-registration.js +3 -2
- package/dist/core/models/local-registration.js.map +1 -1
- package/dist/core/research/model-fitness.d.ts +16 -0
- package/dist/core/research/model-fitness.d.ts.map +1 -1
- package/dist/core/research/model-fitness.js +74 -1
- package/dist/core/research/model-fitness.js.map +1 -1
- package/dist/core/scout-controller.d.ts +5 -0
- package/dist/core/scout-controller.d.ts.map +1 -1
- package/dist/core/scout-controller.js +4 -1
- package/dist/core/scout-controller.js.map +1 -1
- package/dist/core/session-tree-navigator.d.ts.map +1 -1
- package/dist/core/session-tree-navigator.js +1 -0
- package/dist/core/session-tree-navigator.js.map +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +6 -3
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/migrations.d.ts +1 -0
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +14 -2
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/auto-learn-controller.d.ts.map +1 -1
- package/dist/modes/interactive/auto-learn-controller.js +14 -6
- package/dist/modes/interactive/auto-learn-controller.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +1 -0
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +11 -4
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +2 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +107 -91
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -1
- package/dist/modes/interactive/session-flow-commands.js +10 -7
- package/dist/modes/interactive/session-flow-commands.js.map +1 -1
- package/dist/utils/tools-manager.d.ts +1 -0
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +14 -1
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/bug-ledger.md +45 -44
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +4 -4
|
@@ -266,6 +266,19 @@ function extractZipArchive(archivePath, extractDir, assetName) {
|
|
|
266
266
|
throw new Error(`Failed to extract ${assetName}: ${failures.join("; ")}`);
|
|
267
267
|
}
|
|
268
268
|
// Download and install a tool
|
|
269
|
+
const toolDownloadPromises = new Map();
|
|
270
|
+
export function runExclusiveToolDownload(tool, installer) {
|
|
271
|
+
const existing = toolDownloadPromises.get(tool);
|
|
272
|
+
if (existing)
|
|
273
|
+
return existing;
|
|
274
|
+
const promise = installer().finally(() => {
|
|
275
|
+
if (toolDownloadPromises.get(tool) === promise) {
|
|
276
|
+
toolDownloadPromises.delete(tool);
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
toolDownloadPromises.set(tool, promise);
|
|
280
|
+
return promise;
|
|
281
|
+
}
|
|
269
282
|
async function downloadTool(tool) {
|
|
270
283
|
const config = TOOLS[tool];
|
|
271
284
|
if (!config)
|
|
@@ -604,7 +617,7 @@ export async function ensureTool(tool, silent = false) {
|
|
|
604
617
|
console.log(chalk.dim(`${config.name} not found. Downloading...`));
|
|
605
618
|
}
|
|
606
619
|
try {
|
|
607
|
-
const path = await downloadTool(tool);
|
|
620
|
+
const path = await runExclusiveToolDownload(tool, () => downloadTool(tool));
|
|
608
621
|
if (!silent) {
|
|
609
622
|
console.log(chalk.dim(`${config.name} installed to ${path}`));
|
|
610
623
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools-manager.js","sourceRoot":"","sources":["../../src/utils/tools-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAyB,SAAS,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EACN,SAAS,EACT,iBAAiB,EACjB,UAAU,EACV,SAAS,EACT,WAAW,EACX,UAAU,EACV,MAAM,EACN,aAAa,GACb,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEvE,MAAM,SAAS,GAAG,SAAS,EAAE,CAAC;AAC9B,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAClC,MAAM,mBAAmB,GAAG,OAAO,CAAC;AACpC,MAAM,gBAAgB,GAAG,OAAO,CAAC;AACjC,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AACpD,MAAM,wBAAwB,GAAG,IAAI,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;AAIvE,MAAM,aAAa,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AACrD,MAAM,oBAAoB,GA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CAAC;AAAA,CACD","sourcesContent":["import chalk from \"chalk\";\nimport { type SpawnSyncReturns, spawnSync } from \"child_process\";\nimport {\n\tchmodSync,\n\tcreateWriteStream,\n\texistsSync,\n\tmkdirSync,\n\treaddirSync,\n\trenameSync,\n\trmSync,\n\twriteFileSync,\n} from \"fs\";\nimport { createRequire } from \"module\";\nimport { arch, platform } from \"os\";\nimport { dirname, join } from \"path\";\nimport { Readable } from \"stream\";\nimport { pipeline } from \"stream/promises\";\nimport { pathToFileURL } from \"url\";\nimport { APP_NAME, getBinDir } from \"../config.ts\";\nimport { spawnProcess, waitForChildProcess } from \"./child-process.ts\";\n\nconst TOOLS_DIR = getBinDir();\nconst NETWORK_TIMEOUT_MS = 10_000;\nconst DOWNLOAD_TIMEOUT_MS = 120_000;\nconst FFF_NODE_VERSION = \"0.9.6\";\nconst FFF_MANAGED_DIR = join(TOOLS_DIR, \"fff-node\");\nconst FFF_MANAGED_PACKAGE_JSON = join(FFF_MANAGED_DIR, \"package.json\");\n\ntype ModuleRequire = ((id: string) => unknown) & { resolve?: (id: string) => string };\n\nconst moduleRequire = createRequire(import.meta.url);\nconst executableDirRequire = createRequire(pathToFileURL(join(dirname(process.execPath), \"package.json\")).href);\n\nfunction isOfflineModeEnabled(): boolean {\n\tconst value = process.env.PI_OFFLINE;\n\tif (!value) return false;\n\treturn value === \"1\" || value.toLowerCase() === \"true\" || value.toLowerCase() === \"yes\";\n}\n\ninterface ToolConfig {\n\tname: string;\n\trepo: string; // GitHub repo (e.g., \"sharkdp/fd\")\n\tbinaryName: string; // Name of the binary inside the archive\n\tsystemBinaryNames?: string[]; // Alternative system command names to try before downloading\n\ttagPrefix: string; // Prefix for tags (e.g., \"v\" for v1.0.0, \"\" for 1.0.0)\n\tgetAssetName: (version: string, plat: string, architecture: string) => string | null;\n}\n\nconst TOOLS: Record<string, ToolConfig> = {\n\tfd: {\n\t\tname: \"fd\",\n\t\trepo: \"sharkdp/fd\",\n\t\tbinaryName: \"fd\",\n\t\tsystemBinaryNames: [\"fd\", \"fdfind\"],\n\t\ttagPrefix: \"v\",\n\t\tgetAssetName: (version, plat, architecture) => {\n\t\t\tif (plat === \"darwin\") {\n\t\t\t\tconst archStr = architecture === \"arm64\" ? \"aarch64\" : \"x86_64\";\n\t\t\t\treturn `fd-v${version}-${archStr}-apple-darwin.tar.gz`;\n\t\t\t} else if (plat === \"linux\") {\n\t\t\t\tconst archStr = architecture === \"arm64\" ? \"aarch64\" : \"x86_64\";\n\t\t\t\treturn `fd-v${version}-${archStr}-unknown-linux-gnu.tar.gz`;\n\t\t\t} else if (plat === \"win32\") {\n\t\t\t\tconst archStr = architecture === \"arm64\" ? \"aarch64\" : \"x86_64\";\n\t\t\t\treturn `fd-v${version}-${archStr}-pc-windows-msvc.zip`;\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t},\n\trg: {\n\t\tname: \"ripgrep\",\n\t\trepo: \"BurntSushi/ripgrep\",\n\t\tbinaryName: \"rg\",\n\t\ttagPrefix: \"\",\n\t\tgetAssetName: (version, plat, architecture) => {\n\t\t\tif (plat === \"darwin\") {\n\t\t\t\tconst archStr = architecture === \"arm64\" ? \"aarch64\" : \"x86_64\";\n\t\t\t\treturn `ripgrep-${version}-${archStr}-apple-darwin.tar.gz`;\n\t\t\t} else if (plat === \"linux\") {\n\t\t\t\tif (architecture === \"arm64\") {\n\t\t\t\t\treturn `ripgrep-${version}-aarch64-unknown-linux-gnu.tar.gz`;\n\t\t\t\t}\n\t\t\t\treturn `ripgrep-${version}-x86_64-unknown-linux-musl.tar.gz`;\n\t\t\t} else if (plat === \"win32\") {\n\t\t\t\tconst archStr = architecture === \"arm64\" ? \"aarch64\" : \"x86_64\";\n\t\t\t\treturn `ripgrep-${version}-${archStr}-pc-windows-msvc.zip`;\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t},\n};\n\n// Check if a command exists in PATH by trying to run it\nfunction commandExists(cmd: string): boolean {\n\ttry {\n\t\tconst result = spawnSync(cmd, [\"--version\"], { stdio: \"pipe\" });\n\t\t// Check for ENOENT error (command not found)\n\t\treturn result.error === undefined || result.error === null;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n// Get the path to a tool (system-wide or in our tools dir)\nexport function getToolPath(tool: \"fd\" | \"rg\"): string | null {\n\tconst config = TOOLS[tool];\n\tif (!config) return null;\n\n\t// Check our tools directory first\n\tconst localPath = join(TOOLS_DIR, config.binaryName + (platform() === \"win32\" ? \".exe\" : \"\"));\n\tif (existsSync(localPath)) {\n\t\treturn localPath;\n\t}\n\n\t// Check system PATH - if found, just return the command name (it's in PATH)\n\tconst systemBinaryNames = config.systemBinaryNames ?? [config.binaryName];\n\tfor (const systemBinaryName of systemBinaryNames) {\n\t\tif (commandExists(systemBinaryName)) {\n\t\t\treturn systemBinaryName;\n\t\t}\n\t}\n\n\treturn null;\n}\n\n/** Presence check for a SYSTEM tool the doctor only ever reports on -- never installs. */\nexport interface SystemToolStatus {\n\tpresent: boolean;\n\tcommand?: string;\n\tversion?: string;\n}\n\nconst PYTHON_COMMANDS = [\"python3\", \"python\"];\n\n/**\n * Detect a usable Python interpreter. SYSTEM tool (see src/core/doctor.ts):\n * the doctor reports presence/version, it never installs this itself.\n *\n * @param commands Override the candidate command names, for tests.\n */\nexport function detectPython(commands: readonly string[] = PYTHON_COMMANDS): SystemToolStatus {\n\tfor (const command of commands) {\n\t\ttry {\n\t\t\tconst result = spawnSync(command, [\"--version\"], { encoding: \"utf-8\", stdio: \"pipe\", timeout: 5_000 });\n\t\t\tif (result.error) continue;\n\t\t\t// Python 2 prints its version to stderr; Python 3 prints to stdout. Some\n\t\t\t// platforms' `python` alias is one or the other, so check both.\n\t\t\tconst version = `${result.stdout ?? \"\"}${result.stderr ?? \"\"}`.trim() || undefined;\n\t\t\tif (result.status !== 0 && !version) continue;\n\t\t\treturn { present: true, command, version };\n\t\t} catch {\n\t\t\t// Try the next candidate.\n\t\t}\n\t}\n\treturn { present: false };\n}\n\n/**\n * Runs `<command> --version` (or `versionArgs`) and returns its trimmed\n * combined stdout+stderr, or undefined if the command can't be run. Used by\n * the doctor (src/core/doctor.ts) to show a version alongside a tool it has\n * already located by some other means (e.g. getToolPath(\"rg\"), or the binary\n * path OllamaRuntime.detect() reports) -- callers that only need a yes/no\n * presence check should use commandExists/getToolPath/detectPython instead.\n */\nexport function probeVersion(command: string, versionArgs: readonly string[] = [\"--version\"]): string | undefined {\n\ttry {\n\t\tconst result = spawnSync(command, versionArgs, { encoding: \"utf-8\", stdio: \"pipe\", timeout: 5_000 });\n\t\tif (result.error) return undefined;\n\t\tconst output = `${result.stdout ?? \"\"}${result.stderr ?? \"\"}`.trim();\n\t\treturn output || undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n// Fetch latest release version from GitHub\nasync function getLatestVersion(repo: string): Promise<string> {\n\tconst response = await fetch(`https://api.github.com/repos/${repo}/releases/latest`, {\n\t\theaders: { \"User-Agent\": `${APP_NAME}-coding-agent` },\n\t\tsignal: AbortSignal.timeout(NETWORK_TIMEOUT_MS),\n\t});\n\n\tif (!response.ok) {\n\t\tthrow new Error(`GitHub API error: ${response.status}`);\n\t}\n\n\tconst data = (await response.json()) as { tag_name: string };\n\treturn data.tag_name.replace(/^v/, \"\");\n}\n\n// Download a file from URL\nasync function downloadFile(url: string, dest: string): Promise<void> {\n\tconst response = await fetch(url, {\n\t\tsignal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS),\n\t});\n\n\tif (!response.ok) {\n\t\tthrow new Error(`Failed to download: ${response.status}`);\n\t}\n\n\tif (!response.body) {\n\t\tthrow new Error(\"No response body\");\n\t}\n\n\tconst fileStream = createWriteStream(dest);\n\tawait pipeline(Readable.fromWeb(response.body as any), fileStream);\n}\n\nfunction findBinaryRecursively(rootDir: string, binaryFileName: string): string | null {\n\tconst stack: string[] = [rootDir];\n\n\twhile (stack.length > 0) {\n\t\tconst currentDir = stack.pop();\n\t\tif (!currentDir) continue;\n\n\t\tconst entries = readdirSync(currentDir, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = join(currentDir, entry.name);\n\t\t\tif (entry.isFile() && entry.name === binaryFileName) {\n\t\t\t\treturn fullPath;\n\t\t\t}\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tstack.push(fullPath);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn null;\n}\n\nfunction formatSpawnFailure(result: SpawnSyncReturns<Buffer>): string {\n\tif (result.error?.message) {\n\t\treturn result.error.message;\n\t}\n\tconst stderr = result.stderr?.toString().trim();\n\tif (stderr) {\n\t\treturn stderr;\n\t}\n\tconst stdout = result.stdout?.toString().trim();\n\tif (stdout) {\n\t\treturn stdout;\n\t}\n\treturn `exit status ${result.status ?? \"unknown\"}`;\n}\n\nfunction runExtractionCommand(command: string, args: string[]): string | null {\n\tconst result = spawnSync(command, args, { stdio: \"pipe\" });\n\tif (!result.error && result.status === 0) {\n\t\treturn null;\n\t}\n\treturn `${command}: ${formatSpawnFailure(result)}`;\n}\n\nfunction extractTarGzArchive(archivePath: string, extractDir: string, assetName: string): void {\n\tconst failure = runExtractionCommand(\"tar\", [\"xzf\", archivePath, \"-C\", extractDir]);\n\tif (failure) {\n\t\tthrow new Error(`Failed to extract ${assetName}: ${failure}`);\n\t}\n}\n\nfunction getWindowsTarCommand(): string {\n\tconst systemRoot = process.env.SystemRoot ?? process.env.WINDIR;\n\tif (systemRoot) {\n\t\tconst systemTar = join(systemRoot, \"System32\", \"tar.exe\");\n\t\tif (existsSync(systemTar)) {\n\t\t\treturn systemTar;\n\t\t}\n\t}\n\treturn \"tar.exe\";\n}\n\nfunction extractZipArchive(archivePath: string, extractDir: string, assetName: string): void {\n\tconst failures: string[] = [];\n\n\tif (platform() === \"win32\") {\n\t\t// Windows ships bsdtar as tar.exe, which supports zip files. Prefer the\n\t\t// System32 binary over Git Bash's GNU tar, which does not handle zip archives.\n\t\tconst tarFailure = runExtractionCommand(getWindowsTarCommand(), [\"xf\", archivePath, \"-C\", extractDir]);\n\t\tif (!tarFailure) return;\n\t\tfailures.push(tarFailure);\n\n\t\tconst script =\n\t\t\t\"& { param($archive, $destination) $ErrorActionPreference = 'Stop'; Expand-Archive -LiteralPath $archive -DestinationPath $destination -Force }\";\n\t\tconst powershellFailure = runExtractionCommand(\"powershell.exe\", [\n\t\t\t\"-NoLogo\",\n\t\t\t\"-NoProfile\",\n\t\t\t\"-NonInteractive\",\n\t\t\t\"-ExecutionPolicy\",\n\t\t\t\"Bypass\",\n\t\t\t\"-Command\",\n\t\t\tscript,\n\t\t\tarchivePath,\n\t\t\textractDir,\n\t\t]);\n\t\tif (!powershellFailure) return;\n\t\tfailures.push(powershellFailure);\n\t} else {\n\t\tconst unzipFailure = runExtractionCommand(\"unzip\", [\"-q\", archivePath, \"-d\", extractDir]);\n\t\tif (!unzipFailure) return;\n\t\tfailures.push(unzipFailure);\n\n\t\tconst tarFailure = runExtractionCommand(\"tar\", [\"xf\", archivePath, \"-C\", extractDir]);\n\t\tif (!tarFailure) return;\n\t\tfailures.push(tarFailure);\n\t}\n\n\tthrow new Error(`Failed to extract ${assetName}: ${failures.join(\"; \")}`);\n}\n\n// Download and install a tool\nasync function downloadTool(tool: \"fd\" | \"rg\"): Promise<string> {\n\tconst config = TOOLS[tool];\n\tif (!config) throw new Error(`Unknown tool: ${tool}`);\n\n\tconst plat = platform();\n\tconst architecture = arch();\n\n\t// Get latest version\n\tlet version = await getLatestVersion(config.repo);\n\tif (tool === \"fd\" && plat === \"darwin\" && architecture === \"x64\") {\n\t\tversion = \"10.3.0\";\n\t}\n\n\t// Get asset name for this platform\n\tconst assetName = config.getAssetName(version, plat, architecture);\n\tif (!assetName) {\n\t\tthrow new Error(`Unsupported platform: ${plat}/${architecture}`);\n\t}\n\n\t// Create tools directory\n\tmkdirSync(TOOLS_DIR, { recursive: true });\n\n\tconst downloadUrl = `https://github.com/${config.repo}/releases/download/${config.tagPrefix}${version}/${assetName}`;\n\tconst archivePath = join(TOOLS_DIR, assetName);\n\tconst binaryExt = plat === \"win32\" ? \".exe\" : \"\";\n\tconst binaryPath = join(TOOLS_DIR, config.binaryName + binaryExt);\n\n\t// Download\n\tawait downloadFile(downloadUrl, archivePath);\n\n\t// Extract into a unique temp directory. fd and rg downloads can run concurrently\n\t// during startup, so sharing a fixed directory causes races.\n\tconst extractDir = join(\n\t\tTOOLS_DIR,\n\t\t`extract_tmp_${config.binaryName}_${process.pid}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`,\n\t);\n\tmkdirSync(extractDir, { recursive: true });\n\n\ttry {\n\t\tif (assetName.endsWith(\".tar.gz\")) {\n\t\t\textractTarGzArchive(archivePath, extractDir, assetName);\n\t\t} else if (assetName.endsWith(\".zip\")) {\n\t\t\textractZipArchive(archivePath, extractDir, assetName);\n\t\t} else {\n\t\t\tthrow new Error(`Unsupported archive format: ${assetName}`);\n\t\t}\n\n\t\t// Find the binary in extracted files. Some archives contain files directly\n\t\t// at root, others nest under a versioned subdirectory.\n\t\tconst binaryFileName = config.binaryName + binaryExt;\n\t\tconst extractedDir = join(extractDir, assetName.replace(/\\.(tar\\.gz|zip)$/, \"\"));\n\t\tconst extractedBinaryCandidates = [join(extractedDir, binaryFileName), join(extractDir, binaryFileName)];\n\t\tlet extractedBinary = extractedBinaryCandidates.find((candidate) => existsSync(candidate));\n\n\t\tif (!extractedBinary) {\n\t\t\textractedBinary = findBinaryRecursively(extractDir, binaryFileName) ?? undefined;\n\t\t}\n\n\t\tif (extractedBinary) {\n\t\t\trenameSync(extractedBinary, binaryPath);\n\t\t} else {\n\t\t\tthrow new Error(`Binary not found in archive: expected ${binaryFileName} under ${extractDir}`);\n\t\t}\n\n\t\t// Make executable (Unix only)\n\t\tif (plat !== \"win32\") {\n\t\t\tchmodSync(binaryPath, 0o755);\n\t\t}\n\t} finally {\n\t\t// Cleanup\n\t\trmSync(archivePath, { force: true });\n\t\trmSync(extractDir, { recursive: true, force: true });\n\t}\n\n\treturn binaryPath;\n}\n\n// Termux package names for tools\nconst TERMUX_PACKAGES: Record<string, string> = {\n\tfd: \"fd\",\n\trg: \"ripgrep\",\n};\n\nconst FFF_PLATFORM_PACKAGES: Record<string, string> = {\n\t\"darwin/arm64\": \"@ff-labs/fff-bin-darwin-arm64\",\n\t\"darwin/x64\": \"@ff-labs/fff-bin-darwin-x64\",\n\t\"linux/arm64/glibc\": \"@ff-labs/fff-bin-linux-arm64-gnu\",\n\t\"linux/arm64/musl\": \"@ff-labs/fff-bin-linux-arm64-musl\",\n\t\"linux/x64/glibc\": \"@ff-labs/fff-bin-linux-x64-gnu\",\n\t\"linux/x64/musl\": \"@ff-labs/fff-bin-linux-x64-musl\",\n\t\"win32/arm64\": \"@ff-labs/fff-bin-win32-arm64\",\n\t\"win32/x64\": \"@ff-labs/fff-bin-win32-x64\",\n};\n\nlet fffNodeInstallPromise: Promise<unknown | undefined> | undefined;\n\nfunction detectLinuxLibc(): \"glibc\" | \"musl\" {\n\tlet output = \"\";\n\ttry {\n\t\tconst result = spawnSync(\"ldd\", [\"--version\"], { encoding: \"utf-8\", stdio: \"pipe\", timeout: 5000 });\n\t\toutput = `${result.stdout ?? \"\"}${result.stderr ?? \"\"}`;\n\t} catch (e: unknown) {\n\t\tconst err = e as { stdout?: string | Buffer; stderr?: string | Buffer };\n\t\toutput = `${String(err.stdout ?? \"\")}${String(err.stderr ?? \"\")}`;\n\t}\n\treturn output.toLowerCase().includes(\"musl\") ? \"musl\" : \"glibc\";\n}\n\nfunction getFffPlatformPackageName(): string | undefined {\n\tconst plat = platform();\n\tconst architecture = arch();\n\tif (plat === \"linux\") {\n\t\treturn FFF_PLATFORM_PACKAGES[`${plat}/${architecture}/${detectLinuxLibc()}`];\n\t}\n\treturn FFF_PLATFORM_PACKAGES[`${plat}/${architecture}`];\n}\n\nfunction createManagedFffRequire(): ModuleRequire | undefined {\n\tif (!existsSync(FFF_MANAGED_PACKAGE_JSON)) return undefined;\n\treturn createRequire(pathToFileURL(FFF_MANAGED_PACKAGE_JSON).href);\n}\n\nfunction findFffNodeDistEntry(startPath: string): string | undefined {\n\tlet currentDir = dirname(startPath);\n\twhile (currentDir !== dirname(currentDir)) {\n\t\tconst candidate = join(currentDir, \"node_modules\", \"@ff-labs\", \"fff-node\", \"dist\", \"src\", \"index.js\");\n\t\tif (existsSync(candidate)) return candidate;\n\t\tcurrentDir = dirname(currentDir);\n\t}\n\treturn undefined;\n}\n\nfunction loadFffNodeDistEntry(requireFff: ModuleRequire): unknown | undefined {\n\tif (!requireFff.resolve) return undefined;\n\ttry {\n\t\tconst ffiPath = requireFff.resolve(\"ffi-rs\");\n\t\tconst fffEntry = findFffNodeDistEntry(ffiPath);\n\t\treturn fffEntry ? requireFff(fffEntry) : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction loadFffNodeWith(requireFff: ModuleRequire): unknown | undefined {\n\ttry {\n\t\treturn requireFff(\"@ff-labs/fff-node\");\n\t} catch {\n\t\treturn loadFffNodeDistEntry(requireFff);\n\t}\n}\n\n/**\n * @param requires Override the resolution candidates, for tests (mirrors\n * fff-search-backend.ts's loadFffModule(requires?)). Whether this resolves\n * depends on the ambient environment -- @ff-labs/fff-node is a real npm\n * dependency (package.json), so moduleRequire succeeds wherever a normal\n * `npm install`/`npm ci` provisioned it (e.g. CI) even though it fails on a\n * dev checkout that never ran that install here (this repo resolves fff-node\n * via the separate managed-dir path instead). A test asserting \"nothing is\n * available\" must pass `[]` here rather than relying on that being true.\n */\nexport function loadAvailableFffNodePackage(requires?: readonly ModuleRequire[]): unknown | undefined {\n\tconst candidates =\n\t\trequires ??\n\t\t[moduleRequire, executableDirRequire, createManagedFffRequire()].filter((candidate): candidate is ModuleRequire =>\n\t\t\tBoolean(candidate),\n\t\t);\n\tfor (const requireFff of candidates) {\n\t\tconst loaded = loadFffNodeWith(requireFff);\n\t\tif (loaded) return loaded;\n\t}\n\treturn undefined;\n}\n\nasync function runNpmInstall(args: string[]): Promise<{ code: number | null; stderr: string }> {\n\ttry {\n\t\tconst child = spawnProcess(\"npm\", args, { stdio: [\"ignore\", \"pipe\", \"pipe\"] });\n\t\tlet stderr = \"\";\n\t\tchild.stderr?.on(\"data\", (chunk) => {\n\t\t\tstderr += chunk.toString();\n\t\t});\n\t\tconst code = await waitForChildProcess(child);\n\t\treturn { code, stderr };\n\t} catch (error) {\n\t\treturn { code: 1, stderr: error instanceof Error ? error.message : String(error) };\n\t}\n}\n\n/**\n * Outcome of the most recent {@link ensureFffNodePackage} call, kept for\n * observability (e.g. a future `doctor` check) since the function itself\n * only ever returns the loaded module or `undefined` either way.\n *\n * `install-failed` is distinguished from `offline`/`unsupported-platform`\n * because it is the only one worth *retrying*: offline mode and an\n * unsupported platform are stable for the life of the process, but a real\n * install attempt can fail on a transient issue (registry hiccup, timeout)\n * that may no longer apply on the next search. See\n * DefaultFffSearchBackend.getFinder in fff-search-backend.ts, which uses\n * this distinction to decide whether a failed finder is retryable.\n */\nexport type FffInstallOutcome =\n\t| { status: \"already-available\" }\n\t| { status: \"offline\" }\n\t| { status: \"unsupported-platform\" }\n\t| { status: \"installed\" }\n\t| { status: \"install-failed\"; reason: string };\n\n/**\n * How long a genuine install failure gates out a NEW npm spawn. An agent turn\n * can fire several find/grep calls in quick succession, and each one now\n * primes the finder in the background (see tryFffFind/tryFffGrep) -- without\n * this, a persistently-failing install (registry down, disk full, ...) would\n * re-spawn npm on every single one of those calls instead of once.\n *\n * This gates the SPAWN inside ensureFffNodePackage, not whether a failed\n * finder is retryable (see isFffInstallRetryable): DefaultFffSearchBackend\n * always evicts a failed finder so the next search re-enters this function,\n * and it is THIS cooldown check -- evaluated fresh, at call time -- that\n * decides whether that re-entry is a real attempt or a fast, spawn-free bail.\n * (An earlier version conflated the two: it gated eviction itself on the\n * cooldown, which is checked once, immediately after the failure it's timing\n * -- i.e. always still within the window -- so the failed finder was never\n * evicted and the retry never got a chance to happen at all.)\n */\nexport const FFF_INSTALL_RETRY_COOLDOWN_MS = 30_000;\n\nlet lastFffInstallOutcome: FffInstallOutcome | undefined;\nlet lastFffInstallFailureAt: number | undefined;\n\n/** The outcome of the last {@link ensureFffNodePackage} call, if any. */\nexport function getLastFffInstallOutcome(): FffInstallOutcome | undefined {\n\treturn lastFffInstallOutcome;\n}\n\n/** Whether the last install outcome was a genuine failure worth retrying (as opposed to a stable \"not applicable\" result). Cooldown-independent by design -- see FFF_INSTALL_RETRY_COOLDOWN_MS. */\nexport function isFffInstallRetryable(): boolean {\n\treturn lastFffInstallOutcome?.status === \"install-failed\";\n}\n\n/**\n * Pure decision logic behind {@link isFffInstallCoolingDown}, exposed directly\n * so tests can assert the cooldown boundary without faking the system clock.\n */\nexport function computeIsFffInstallCoolingDown(\n\toutcome: FffInstallOutcome | undefined,\n\tfailedAt: number | undefined,\n\tnow: number,\n): boolean {\n\tif (outcome?.status !== \"install-failed\") return false;\n\tif (failedAt === undefined) return false;\n\treturn now - failedAt < FFF_INSTALL_RETRY_COOLDOWN_MS;\n}\n\n/** Whether a real install attempt happened too recently to try again right now. */\nfunction isFffInstallCoolingDown(): boolean {\n\treturn computeIsFffInstallCoolingDown(lastFffInstallOutcome, lastFffInstallFailureAt, Date.now());\n}\n\n/** Records a genuine install failure and stamps when it happened, so the cooldown above has a start time to measure from. */\nfunction recordFffInstallFailure(reason: string): void {\n\tlastFffInstallOutcome = { status: \"install-failed\", reason };\n\tlastFffInstallFailureAt = Date.now();\n}\n\nasync function installManagedFffNodePackage(platformPackage: string, silent: boolean): Promise<unknown | undefined> {\n\ttry {\n\t\tmkdirSync(FFF_MANAGED_DIR, { recursive: true });\n\t\tif (!existsSync(FFF_MANAGED_PACKAGE_JSON)) {\n\t\t\twriteFileSync(FFF_MANAGED_PACKAGE_JSON, '{\"name\":\"pi-managed-fff-node\",\"private\":true,\"version\":\"0.0.0\"}\\n');\n\t\t}\n\n\t\tif (!silent) {\n\t\t\tconsole.log(chalk.dim(\"FFF native search not found. Installing managed FFF package...\"));\n\t\t}\n\n\t\tconst args = [\n\t\t\t\"install\",\n\t\t\t\"--ignore-scripts\",\n\t\t\t\"--omit=dev\",\n\t\t\t\"--include=optional\",\n\t\t\t\"--no-audit\",\n\t\t\t\"--no-fund\",\n\t\t\t\"--package-lock=false\",\n\t\t\t\"--prefix\",\n\t\t\tFFF_MANAGED_DIR,\n\t\t\t`@ff-labs/fff-node@${FFF_NODE_VERSION}`,\n\t\t\t`${platformPackage}@${FFF_NODE_VERSION}`,\n\t\t];\n\t\tconst result = await runNpmInstall(args);\n\t\tif (result.code !== 0) {\n\t\t\tconst reason = result.stderr.trim() || `npm exited with code ${result.code}`;\n\t\t\tif (!silent) {\n\t\t\t\tconsole.log(chalk.yellow(`Failed to install FFF native search: ${reason}`));\n\t\t\t}\n\t\t\trecordFffInstallFailure(reason);\n\t\t\treturn undefined;\n\t\t}\n\t\tconst loaded = loadFffNodeWith(createRequire(pathToFileURL(FFF_MANAGED_PACKAGE_JSON).href));\n\t\tif (!loaded) {\n\t\t\tconst reason = \"Managed FFF install completed but @ff-labs/fff-node could not be loaded.\";\n\t\t\tif (!silent) {\n\t\t\t\tconsole.log(chalk.yellow(reason));\n\t\t\t}\n\t\t\trecordFffInstallFailure(reason);\n\t\t\treturn undefined;\n\t\t}\n\t\tlastFffInstallOutcome = { status: \"installed\" };\n\t\treturn loaded;\n\t} catch (error) {\n\t\t// Never let a filesystem/spawn surprise (e.g. a read-only home directory)\n\t\t// crash the caller: fall back like any other install failure, but keep\n\t\t// the reason observable.\n\t\tconst reason = error instanceof Error ? error.message : String(error);\n\t\tif (!silent) {\n\t\t\tconsole.log(chalk.yellow(`Failed to install FFF native search: ${reason}`));\n\t\t}\n\t\trecordFffInstallFailure(reason);\n\t\treturn undefined;\n\t}\n}\n\nexport async function ensureFffNodePackage(\n\tsilent: boolean = false,\n\tforceManagedInstall: boolean = false,\n\t/** Override the \"is it already available\" resolution candidates, for tests. See loadAvailableFffNodePackage's doc. */\n\trequires?: readonly ModuleRequire[],\n): Promise<unknown | undefined> {\n\tconst existing = forceManagedInstall ? undefined : loadAvailableFffNodePackage(requires);\n\tif (existing) {\n\t\tlastFffInstallOutcome = { status: \"already-available\" };\n\t\treturn existing;\n\t}\n\n\tif (isOfflineModeEnabled()) {\n\t\tif (!silent) {\n\t\t\tconsole.log(chalk.yellow(\"FFF native search not found. Offline mode enabled, skipping install.\"));\n\t\t}\n\t\tlastFffInstallOutcome = { status: \"offline\" };\n\t\treturn undefined;\n\t}\n\n\t// A prior attempt failed too recently to try again: bail out fast (no npm\n\t// spawn, no platform/libc probing) rather than repeating a doomed attempt.\n\t// Leaves lastFffInstallOutcome/lastFffInstallFailureAt untouched -- this\n\t// isn't a new attempt, so there's nothing new to record.\n\tif (isFffInstallCoolingDown()) {\n\t\treturn undefined;\n\t}\n\n\tconst platformPackage = getFffPlatformPackageName();\n\tif (!platformPackage) {\n\t\tif (!silent) {\n\t\t\tconsole.log(chalk.yellow(`FFF native search is not available for ${platform()}/${arch()}.`));\n\t\t}\n\t\tlastFffInstallOutcome = { status: \"unsupported-platform\" };\n\t\treturn undefined;\n\t}\n\n\tfffNodeInstallPromise ??= installManagedFffNodePackage(platformPackage, silent).finally(() => {\n\t\tfffNodeInstallPromise = undefined;\n\t});\n\treturn fffNodeInstallPromise;\n}\n\n// Ensure a tool is available, downloading if necessary\n// Returns the path to the tool, or null if unavailable\nexport async function ensureTool(tool: \"fd\" | \"rg\", silent: boolean = false): Promise<string | undefined> {\n\tconst existingPath = getToolPath(tool);\n\tif (existingPath) {\n\t\treturn existingPath;\n\t}\n\n\tconst config = TOOLS[tool];\n\tif (!config) return undefined;\n\n\tif (isOfflineModeEnabled()) {\n\t\tif (!silent) {\n\t\t\tconsole.log(chalk.yellow(`${config.name} not found. Offline mode enabled, skipping download.`));\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t// On Android/Termux, Linux binaries don't work due to Bionic libc incompatibility.\n\t// Users must install via pkg.\n\tif (platform() === \"android\") {\n\t\tconst pkgName = TERMUX_PACKAGES[tool] ?? tool;\n\t\tif (!silent) {\n\t\t\tconsole.log(chalk.yellow(`${config.name} not found. Install with: pkg install ${pkgName}`));\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t// Tool not found - download it\n\tif (!silent) {\n\t\tconsole.log(chalk.dim(`${config.name} not found. Downloading...`));\n\t}\n\n\ttry {\n\t\tconst path = await downloadTool(tool);\n\t\tif (!silent) {\n\t\t\tconsole.log(chalk.dim(`${config.name} installed to ${path}`));\n\t\t}\n\t\treturn path;\n\t} catch (e) {\n\t\tif (!silent) {\n\t\t\tconsole.log(chalk.yellow(`Failed to download ${config.name}: ${e instanceof Error ? e.message : e}`));\n\t\t}\n\t\treturn undefined;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tools-manager.js","sourceRoot":"","sources":["../../src/utils/tools-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAyB,SAAS,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EACN,SAAS,EACT,iBAAiB,EACjB,UAAU,EACV,SAAS,EACT,WAAW,EACX,UAAU,EACV,MAAM,EACN,aAAa,GACb,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEvE,MAAM,SAAS,GAAG,SAAS,EAAE,CAAC;AAC9B,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAClC,MAA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CAAC,GAAG,MAAM,CAAC,IAAI,yCAAyC,OAAO,EAAE,CAAC,CAAC,CAAC;QAC7F,CAAC;QACD,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,+BAA+B;IAC/B,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,4BAA4B,CAAC,CAAC,CAAC;IACpE,CAAC;IAED,IAAI,CAAC;QACJ,MAAM,IAAI,GAAG,MAAM,wBAAwB,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5E,IAAI,CAAC,MAAM,EAAE,CAAC;YACb,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,iBAAiB,IAAI,EAAE,CAAC,CAAC,CAAC;QAC/D,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACZ,IAAI,CAAC,MAAM,EAAE,CAAC;YACb,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,sBAAsB,MAAM,CAAC,IAAI,KAAK,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACvG,CAAC;QACD,OAAO,SAAS,CAAC;IAClB,CAAC;AAAA,CACD","sourcesContent":["import chalk from \"chalk\";\nimport { type SpawnSyncReturns, spawnSync } from \"child_process\";\nimport {\n\tchmodSync,\n\tcreateWriteStream,\n\texistsSync,\n\tmkdirSync,\n\treaddirSync,\n\trenameSync,\n\trmSync,\n\twriteFileSync,\n} from \"fs\";\nimport { createRequire } from \"module\";\nimport { arch, platform } from \"os\";\nimport { dirname, join } from \"path\";\nimport { Readable } from \"stream\";\nimport { pipeline } from \"stream/promises\";\nimport { pathToFileURL } from \"url\";\nimport { APP_NAME, getBinDir } from \"../config.ts\";\nimport { spawnProcess, waitForChildProcess } from \"./child-process.ts\";\n\nconst TOOLS_DIR = getBinDir();\nconst NETWORK_TIMEOUT_MS = 10_000;\nconst DOWNLOAD_TIMEOUT_MS = 120_000;\nconst FFF_NODE_VERSION = \"0.9.6\";\nconst FFF_MANAGED_DIR = join(TOOLS_DIR, \"fff-node\");\nconst FFF_MANAGED_PACKAGE_JSON = join(FFF_MANAGED_DIR, \"package.json\");\n\ntype ModuleRequire = ((id: string) => unknown) & { resolve?: (id: string) => string };\n\nconst moduleRequire = createRequire(import.meta.url);\nconst executableDirRequire = createRequire(pathToFileURL(join(dirname(process.execPath), \"package.json\")).href);\n\nfunction isOfflineModeEnabled(): boolean {\n\tconst value = process.env.PI_OFFLINE;\n\tif (!value) return false;\n\treturn value === \"1\" || value.toLowerCase() === \"true\" || value.toLowerCase() === \"yes\";\n}\n\ninterface ToolConfig {\n\tname: string;\n\trepo: string; // GitHub repo (e.g., \"sharkdp/fd\")\n\tbinaryName: string; // Name of the binary inside the archive\n\tsystemBinaryNames?: string[]; // Alternative system command names to try before downloading\n\ttagPrefix: string; // Prefix for tags (e.g., \"v\" for v1.0.0, \"\" for 1.0.0)\n\tgetAssetName: (version: string, plat: string, architecture: string) => string | null;\n}\n\nconst TOOLS: Record<string, ToolConfig> = {\n\tfd: {\n\t\tname: \"fd\",\n\t\trepo: \"sharkdp/fd\",\n\t\tbinaryName: \"fd\",\n\t\tsystemBinaryNames: [\"fd\", \"fdfind\"],\n\t\ttagPrefix: \"v\",\n\t\tgetAssetName: (version, plat, architecture) => {\n\t\t\tif (plat === \"darwin\") {\n\t\t\t\tconst archStr = architecture === \"arm64\" ? \"aarch64\" : \"x86_64\";\n\t\t\t\treturn `fd-v${version}-${archStr}-apple-darwin.tar.gz`;\n\t\t\t} else if (plat === \"linux\") {\n\t\t\t\tconst archStr = architecture === \"arm64\" ? \"aarch64\" : \"x86_64\";\n\t\t\t\treturn `fd-v${version}-${archStr}-unknown-linux-gnu.tar.gz`;\n\t\t\t} else if (plat === \"win32\") {\n\t\t\t\tconst archStr = architecture === \"arm64\" ? \"aarch64\" : \"x86_64\";\n\t\t\t\treturn `fd-v${version}-${archStr}-pc-windows-msvc.zip`;\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t},\n\trg: {\n\t\tname: \"ripgrep\",\n\t\trepo: \"BurntSushi/ripgrep\",\n\t\tbinaryName: \"rg\",\n\t\ttagPrefix: \"\",\n\t\tgetAssetName: (version, plat, architecture) => {\n\t\t\tif (plat === \"darwin\") {\n\t\t\t\tconst archStr = architecture === \"arm64\" ? \"aarch64\" : \"x86_64\";\n\t\t\t\treturn `ripgrep-${version}-${archStr}-apple-darwin.tar.gz`;\n\t\t\t} else if (plat === \"linux\") {\n\t\t\t\tif (architecture === \"arm64\") {\n\t\t\t\t\treturn `ripgrep-${version}-aarch64-unknown-linux-gnu.tar.gz`;\n\t\t\t\t}\n\t\t\t\treturn `ripgrep-${version}-x86_64-unknown-linux-musl.tar.gz`;\n\t\t\t} else if (plat === \"win32\") {\n\t\t\t\tconst archStr = architecture === \"arm64\" ? \"aarch64\" : \"x86_64\";\n\t\t\t\treturn `ripgrep-${version}-${archStr}-pc-windows-msvc.zip`;\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t},\n};\n\n// Check if a command exists in PATH by trying to run it\nfunction commandExists(cmd: string): boolean {\n\ttry {\n\t\tconst result = spawnSync(cmd, [\"--version\"], { stdio: \"pipe\" });\n\t\t// Check for ENOENT error (command not found)\n\t\treturn result.error === undefined || result.error === null;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n// Get the path to a tool (system-wide or in our tools dir)\nexport function getToolPath(tool: \"fd\" | \"rg\"): string | null {\n\tconst config = TOOLS[tool];\n\tif (!config) return null;\n\n\t// Check our tools directory first\n\tconst localPath = join(TOOLS_DIR, config.binaryName + (platform() === \"win32\" ? \".exe\" : \"\"));\n\tif (existsSync(localPath)) {\n\t\treturn localPath;\n\t}\n\n\t// Check system PATH - if found, just return the command name (it's in PATH)\n\tconst systemBinaryNames = config.systemBinaryNames ?? [config.binaryName];\n\tfor (const systemBinaryName of systemBinaryNames) {\n\t\tif (commandExists(systemBinaryName)) {\n\t\t\treturn systemBinaryName;\n\t\t}\n\t}\n\n\treturn null;\n}\n\n/** Presence check for a SYSTEM tool the doctor only ever reports on -- never installs. */\nexport interface SystemToolStatus {\n\tpresent: boolean;\n\tcommand?: string;\n\tversion?: string;\n}\n\nconst PYTHON_COMMANDS = [\"python3\", \"python\"];\n\n/**\n * Detect a usable Python interpreter. SYSTEM tool (see src/core/doctor.ts):\n * the doctor reports presence/version, it never installs this itself.\n *\n * @param commands Override the candidate command names, for tests.\n */\nexport function detectPython(commands: readonly string[] = PYTHON_COMMANDS): SystemToolStatus {\n\tfor (const command of commands) {\n\t\ttry {\n\t\t\tconst result = spawnSync(command, [\"--version\"], { encoding: \"utf-8\", stdio: \"pipe\", timeout: 5_000 });\n\t\t\tif (result.error) continue;\n\t\t\t// Python 2 prints its version to stderr; Python 3 prints to stdout. Some\n\t\t\t// platforms' `python` alias is one or the other, so check both.\n\t\t\tconst version = `${result.stdout ?? \"\"}${result.stderr ?? \"\"}`.trim() || undefined;\n\t\t\tif (result.status !== 0 && !version) continue;\n\t\t\treturn { present: true, command, version };\n\t\t} catch {\n\t\t\t// Try the next candidate.\n\t\t}\n\t}\n\treturn { present: false };\n}\n\n/**\n * Runs `<command> --version` (or `versionArgs`) and returns its trimmed\n * combined stdout+stderr, or undefined if the command can't be run. Used by\n * the doctor (src/core/doctor.ts) to show a version alongside a tool it has\n * already located by some other means (e.g. getToolPath(\"rg\"), or the binary\n * path OllamaRuntime.detect() reports) -- callers that only need a yes/no\n * presence check should use commandExists/getToolPath/detectPython instead.\n */\nexport function probeVersion(command: string, versionArgs: readonly string[] = [\"--version\"]): string | undefined {\n\ttry {\n\t\tconst result = spawnSync(command, versionArgs, { encoding: \"utf-8\", stdio: \"pipe\", timeout: 5_000 });\n\t\tif (result.error) return undefined;\n\t\tconst output = `${result.stdout ?? \"\"}${result.stderr ?? \"\"}`.trim();\n\t\treturn output || undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n// Fetch latest release version from GitHub\nasync function getLatestVersion(repo: string): Promise<string> {\n\tconst response = await fetch(`https://api.github.com/repos/${repo}/releases/latest`, {\n\t\theaders: { \"User-Agent\": `${APP_NAME}-coding-agent` },\n\t\tsignal: AbortSignal.timeout(NETWORK_TIMEOUT_MS),\n\t});\n\n\tif (!response.ok) {\n\t\tthrow new Error(`GitHub API error: ${response.status}`);\n\t}\n\n\tconst data = (await response.json()) as { tag_name: string };\n\treturn data.tag_name.replace(/^v/, \"\");\n}\n\n// Download a file from URL\nasync function downloadFile(url: string, dest: string): Promise<void> {\n\tconst response = await fetch(url, {\n\t\tsignal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS),\n\t});\n\n\tif (!response.ok) {\n\t\tthrow new Error(`Failed to download: ${response.status}`);\n\t}\n\n\tif (!response.body) {\n\t\tthrow new Error(\"No response body\");\n\t}\n\n\tconst fileStream = createWriteStream(dest);\n\tawait pipeline(Readable.fromWeb(response.body as any), fileStream);\n}\n\nfunction findBinaryRecursively(rootDir: string, binaryFileName: string): string | null {\n\tconst stack: string[] = [rootDir];\n\n\twhile (stack.length > 0) {\n\t\tconst currentDir = stack.pop();\n\t\tif (!currentDir) continue;\n\n\t\tconst entries = readdirSync(currentDir, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = join(currentDir, entry.name);\n\t\t\tif (entry.isFile() && entry.name === binaryFileName) {\n\t\t\t\treturn fullPath;\n\t\t\t}\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tstack.push(fullPath);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn null;\n}\n\nfunction formatSpawnFailure(result: SpawnSyncReturns<Buffer>): string {\n\tif (result.error?.message) {\n\t\treturn result.error.message;\n\t}\n\tconst stderr = result.stderr?.toString().trim();\n\tif (stderr) {\n\t\treturn stderr;\n\t}\n\tconst stdout = result.stdout?.toString().trim();\n\tif (stdout) {\n\t\treturn stdout;\n\t}\n\treturn `exit status ${result.status ?? \"unknown\"}`;\n}\n\nfunction runExtractionCommand(command: string, args: string[]): string | null {\n\tconst result = spawnSync(command, args, { stdio: \"pipe\" });\n\tif (!result.error && result.status === 0) {\n\t\treturn null;\n\t}\n\treturn `${command}: ${formatSpawnFailure(result)}`;\n}\n\nfunction extractTarGzArchive(archivePath: string, extractDir: string, assetName: string): void {\n\tconst failure = runExtractionCommand(\"tar\", [\"xzf\", archivePath, \"-C\", extractDir]);\n\tif (failure) {\n\t\tthrow new Error(`Failed to extract ${assetName}: ${failure}`);\n\t}\n}\n\nfunction getWindowsTarCommand(): string {\n\tconst systemRoot = process.env.SystemRoot ?? process.env.WINDIR;\n\tif (systemRoot) {\n\t\tconst systemTar = join(systemRoot, \"System32\", \"tar.exe\");\n\t\tif (existsSync(systemTar)) {\n\t\t\treturn systemTar;\n\t\t}\n\t}\n\treturn \"tar.exe\";\n}\n\nfunction extractZipArchive(archivePath: string, extractDir: string, assetName: string): void {\n\tconst failures: string[] = [];\n\n\tif (platform() === \"win32\") {\n\t\t// Windows ships bsdtar as tar.exe, which supports zip files. Prefer the\n\t\t// System32 binary over Git Bash's GNU tar, which does not handle zip archives.\n\t\tconst tarFailure = runExtractionCommand(getWindowsTarCommand(), [\"xf\", archivePath, \"-C\", extractDir]);\n\t\tif (!tarFailure) return;\n\t\tfailures.push(tarFailure);\n\n\t\tconst script =\n\t\t\t\"& { param($archive, $destination) $ErrorActionPreference = 'Stop'; Expand-Archive -LiteralPath $archive -DestinationPath $destination -Force }\";\n\t\tconst powershellFailure = runExtractionCommand(\"powershell.exe\", [\n\t\t\t\"-NoLogo\",\n\t\t\t\"-NoProfile\",\n\t\t\t\"-NonInteractive\",\n\t\t\t\"-ExecutionPolicy\",\n\t\t\t\"Bypass\",\n\t\t\t\"-Command\",\n\t\t\tscript,\n\t\t\tarchivePath,\n\t\t\textractDir,\n\t\t]);\n\t\tif (!powershellFailure) return;\n\t\tfailures.push(powershellFailure);\n\t} else {\n\t\tconst unzipFailure = runExtractionCommand(\"unzip\", [\"-q\", archivePath, \"-d\", extractDir]);\n\t\tif (!unzipFailure) return;\n\t\tfailures.push(unzipFailure);\n\n\t\tconst tarFailure = runExtractionCommand(\"tar\", [\"xf\", archivePath, \"-C\", extractDir]);\n\t\tif (!tarFailure) return;\n\t\tfailures.push(tarFailure);\n\t}\n\n\tthrow new Error(`Failed to extract ${assetName}: ${failures.join(\"; \")}`);\n}\n\n// Download and install a tool\nconst toolDownloadPromises = new Map<\"fd\" | \"rg\", Promise<string | undefined>>();\n\nexport function runExclusiveToolDownload(\n\ttool: \"fd\" | \"rg\",\n\tinstaller: () => Promise<string | undefined>,\n): Promise<string | undefined> {\n\tconst existing = toolDownloadPromises.get(tool);\n\tif (existing) return existing;\n\tconst promise = installer().finally(() => {\n\t\tif (toolDownloadPromises.get(tool) === promise) {\n\t\t\ttoolDownloadPromises.delete(tool);\n\t\t}\n\t});\n\ttoolDownloadPromises.set(tool, promise);\n\treturn promise;\n}\n\nasync function downloadTool(tool: \"fd\" | \"rg\"): Promise<string> {\n\tconst config = TOOLS[tool];\n\tif (!config) throw new Error(`Unknown tool: ${tool}`);\n\n\tconst plat = platform();\n\tconst architecture = arch();\n\n\t// Get latest version\n\tlet version = await getLatestVersion(config.repo);\n\tif (tool === \"fd\" && plat === \"darwin\" && architecture === \"x64\") {\n\t\tversion = \"10.3.0\";\n\t}\n\n\t// Get asset name for this platform\n\tconst assetName = config.getAssetName(version, plat, architecture);\n\tif (!assetName) {\n\t\tthrow new Error(`Unsupported platform: ${plat}/${architecture}`);\n\t}\n\n\t// Create tools directory\n\tmkdirSync(TOOLS_DIR, { recursive: true });\n\n\tconst downloadUrl = `https://github.com/${config.repo}/releases/download/${config.tagPrefix}${version}/${assetName}`;\n\tconst archivePath = join(TOOLS_DIR, assetName);\n\tconst binaryExt = plat === \"win32\" ? \".exe\" : \"\";\n\tconst binaryPath = join(TOOLS_DIR, config.binaryName + binaryExt);\n\n\t// Download\n\tawait downloadFile(downloadUrl, archivePath);\n\n\t// Extract into a unique temp directory. fd and rg downloads can run concurrently\n\t// during startup, so sharing a fixed directory causes races.\n\tconst extractDir = join(\n\t\tTOOLS_DIR,\n\t\t`extract_tmp_${config.binaryName}_${process.pid}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`,\n\t);\n\tmkdirSync(extractDir, { recursive: true });\n\n\ttry {\n\t\tif (assetName.endsWith(\".tar.gz\")) {\n\t\t\textractTarGzArchive(archivePath, extractDir, assetName);\n\t\t} else if (assetName.endsWith(\".zip\")) {\n\t\t\textractZipArchive(archivePath, extractDir, assetName);\n\t\t} else {\n\t\t\tthrow new Error(`Unsupported archive format: ${assetName}`);\n\t\t}\n\n\t\t// Find the binary in extracted files. Some archives contain files directly\n\t\t// at root, others nest under a versioned subdirectory.\n\t\tconst binaryFileName = config.binaryName + binaryExt;\n\t\tconst extractedDir = join(extractDir, assetName.replace(/\\.(tar\\.gz|zip)$/, \"\"));\n\t\tconst extractedBinaryCandidates = [join(extractedDir, binaryFileName), join(extractDir, binaryFileName)];\n\t\tlet extractedBinary = extractedBinaryCandidates.find((candidate) => existsSync(candidate));\n\n\t\tif (!extractedBinary) {\n\t\t\textractedBinary = findBinaryRecursively(extractDir, binaryFileName) ?? undefined;\n\t\t}\n\n\t\tif (extractedBinary) {\n\t\t\trenameSync(extractedBinary, binaryPath);\n\t\t} else {\n\t\t\tthrow new Error(`Binary not found in archive: expected ${binaryFileName} under ${extractDir}`);\n\t\t}\n\n\t\t// Make executable (Unix only)\n\t\tif (plat !== \"win32\") {\n\t\t\tchmodSync(binaryPath, 0o755);\n\t\t}\n\t} finally {\n\t\t// Cleanup\n\t\trmSync(archivePath, { force: true });\n\t\trmSync(extractDir, { recursive: true, force: true });\n\t}\n\n\treturn binaryPath;\n}\n\n// Termux package names for tools\nconst TERMUX_PACKAGES: Record<string, string> = {\n\tfd: \"fd\",\n\trg: \"ripgrep\",\n};\n\nconst FFF_PLATFORM_PACKAGES: Record<string, string> = {\n\t\"darwin/arm64\": \"@ff-labs/fff-bin-darwin-arm64\",\n\t\"darwin/x64\": \"@ff-labs/fff-bin-darwin-x64\",\n\t\"linux/arm64/glibc\": \"@ff-labs/fff-bin-linux-arm64-gnu\",\n\t\"linux/arm64/musl\": \"@ff-labs/fff-bin-linux-arm64-musl\",\n\t\"linux/x64/glibc\": \"@ff-labs/fff-bin-linux-x64-gnu\",\n\t\"linux/x64/musl\": \"@ff-labs/fff-bin-linux-x64-musl\",\n\t\"win32/arm64\": \"@ff-labs/fff-bin-win32-arm64\",\n\t\"win32/x64\": \"@ff-labs/fff-bin-win32-x64\",\n};\n\nlet fffNodeInstallPromise: Promise<unknown | undefined> | undefined;\n\nfunction detectLinuxLibc(): \"glibc\" | \"musl\" {\n\tlet output = \"\";\n\ttry {\n\t\tconst result = spawnSync(\"ldd\", [\"--version\"], { encoding: \"utf-8\", stdio: \"pipe\", timeout: 5000 });\n\t\toutput = `${result.stdout ?? \"\"}${result.stderr ?? \"\"}`;\n\t} catch (e: unknown) {\n\t\tconst err = e as { stdout?: string | Buffer; stderr?: string | Buffer };\n\t\toutput = `${String(err.stdout ?? \"\")}${String(err.stderr ?? \"\")}`;\n\t}\n\treturn output.toLowerCase().includes(\"musl\") ? \"musl\" : \"glibc\";\n}\n\nfunction getFffPlatformPackageName(): string | undefined {\n\tconst plat = platform();\n\tconst architecture = arch();\n\tif (plat === \"linux\") {\n\t\treturn FFF_PLATFORM_PACKAGES[`${plat}/${architecture}/${detectLinuxLibc()}`];\n\t}\n\treturn FFF_PLATFORM_PACKAGES[`${plat}/${architecture}`];\n}\n\nfunction createManagedFffRequire(): ModuleRequire | undefined {\n\tif (!existsSync(FFF_MANAGED_PACKAGE_JSON)) return undefined;\n\treturn createRequire(pathToFileURL(FFF_MANAGED_PACKAGE_JSON).href);\n}\n\nfunction findFffNodeDistEntry(startPath: string): string | undefined {\n\tlet currentDir = dirname(startPath);\n\twhile (currentDir !== dirname(currentDir)) {\n\t\tconst candidate = join(currentDir, \"node_modules\", \"@ff-labs\", \"fff-node\", \"dist\", \"src\", \"index.js\");\n\t\tif (existsSync(candidate)) return candidate;\n\t\tcurrentDir = dirname(currentDir);\n\t}\n\treturn undefined;\n}\n\nfunction loadFffNodeDistEntry(requireFff: ModuleRequire): unknown | undefined {\n\tif (!requireFff.resolve) return undefined;\n\ttry {\n\t\tconst ffiPath = requireFff.resolve(\"ffi-rs\");\n\t\tconst fffEntry = findFffNodeDistEntry(ffiPath);\n\t\treturn fffEntry ? requireFff(fffEntry) : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction loadFffNodeWith(requireFff: ModuleRequire): unknown | undefined {\n\ttry {\n\t\treturn requireFff(\"@ff-labs/fff-node\");\n\t} catch {\n\t\treturn loadFffNodeDistEntry(requireFff);\n\t}\n}\n\n/**\n * @param requires Override the resolution candidates, for tests (mirrors\n * fff-search-backend.ts's loadFffModule(requires?)). Whether this resolves\n * depends on the ambient environment -- @ff-labs/fff-node is a real npm\n * dependency (package.json), so moduleRequire succeeds wherever a normal\n * `npm install`/`npm ci` provisioned it (e.g. CI) even though it fails on a\n * dev checkout that never ran that install here (this repo resolves fff-node\n * via the separate managed-dir path instead). A test asserting \"nothing is\n * available\" must pass `[]` here rather than relying on that being true.\n */\nexport function loadAvailableFffNodePackage(requires?: readonly ModuleRequire[]): unknown | undefined {\n\tconst candidates =\n\t\trequires ??\n\t\t[moduleRequire, executableDirRequire, createManagedFffRequire()].filter((candidate): candidate is ModuleRequire =>\n\t\t\tBoolean(candidate),\n\t\t);\n\tfor (const requireFff of candidates) {\n\t\tconst loaded = loadFffNodeWith(requireFff);\n\t\tif (loaded) return loaded;\n\t}\n\treturn undefined;\n}\n\nasync function runNpmInstall(args: string[]): Promise<{ code: number | null; stderr: string }> {\n\ttry {\n\t\tconst child = spawnProcess(\"npm\", args, { stdio: [\"ignore\", \"pipe\", \"pipe\"] });\n\t\tlet stderr = \"\";\n\t\tchild.stderr?.on(\"data\", (chunk) => {\n\t\t\tstderr += chunk.toString();\n\t\t});\n\t\tconst code = await waitForChildProcess(child);\n\t\treturn { code, stderr };\n\t} catch (error) {\n\t\treturn { code: 1, stderr: error instanceof Error ? error.message : String(error) };\n\t}\n}\n\n/**\n * Outcome of the most recent {@link ensureFffNodePackage} call, kept for\n * observability (e.g. a future `doctor` check) since the function itself\n * only ever returns the loaded module or `undefined` either way.\n *\n * `install-failed` is distinguished from `offline`/`unsupported-platform`\n * because it is the only one worth *retrying*: offline mode and an\n * unsupported platform are stable for the life of the process, but a real\n * install attempt can fail on a transient issue (registry hiccup, timeout)\n * that may no longer apply on the next search. See\n * DefaultFffSearchBackend.getFinder in fff-search-backend.ts, which uses\n * this distinction to decide whether a failed finder is retryable.\n */\nexport type FffInstallOutcome =\n\t| { status: \"already-available\" }\n\t| { status: \"offline\" }\n\t| { status: \"unsupported-platform\" }\n\t| { status: \"installed\" }\n\t| { status: \"install-failed\"; reason: string };\n\n/**\n * How long a genuine install failure gates out a NEW npm spawn. An agent turn\n * can fire several find/grep calls in quick succession, and each one now\n * primes the finder in the background (see tryFffFind/tryFffGrep) -- without\n * this, a persistently-failing install (registry down, disk full, ...) would\n * re-spawn npm on every single one of those calls instead of once.\n *\n * This gates the SPAWN inside ensureFffNodePackage, not whether a failed\n * finder is retryable (see isFffInstallRetryable): DefaultFffSearchBackend\n * always evicts a failed finder so the next search re-enters this function,\n * and it is THIS cooldown check -- evaluated fresh, at call time -- that\n * decides whether that re-entry is a real attempt or a fast, spawn-free bail.\n * (An earlier version conflated the two: it gated eviction itself on the\n * cooldown, which is checked once, immediately after the failure it's timing\n * -- i.e. always still within the window -- so the failed finder was never\n * evicted and the retry never got a chance to happen at all.)\n */\nexport const FFF_INSTALL_RETRY_COOLDOWN_MS = 30_000;\n\nlet lastFffInstallOutcome: FffInstallOutcome | undefined;\nlet lastFffInstallFailureAt: number | undefined;\n\n/** The outcome of the last {@link ensureFffNodePackage} call, if any. */\nexport function getLastFffInstallOutcome(): FffInstallOutcome | undefined {\n\treturn lastFffInstallOutcome;\n}\n\n/** Whether the last install outcome was a genuine failure worth retrying (as opposed to a stable \"not applicable\" result). Cooldown-independent by design -- see FFF_INSTALL_RETRY_COOLDOWN_MS. */\nexport function isFffInstallRetryable(): boolean {\n\treturn lastFffInstallOutcome?.status === \"install-failed\";\n}\n\n/**\n * Pure decision logic behind {@link isFffInstallCoolingDown}, exposed directly\n * so tests can assert the cooldown boundary without faking the system clock.\n */\nexport function computeIsFffInstallCoolingDown(\n\toutcome: FffInstallOutcome | undefined,\n\tfailedAt: number | undefined,\n\tnow: number,\n): boolean {\n\tif (outcome?.status !== \"install-failed\") return false;\n\tif (failedAt === undefined) return false;\n\treturn now - failedAt < FFF_INSTALL_RETRY_COOLDOWN_MS;\n}\n\n/** Whether a real install attempt happened too recently to try again right now. */\nfunction isFffInstallCoolingDown(): boolean {\n\treturn computeIsFffInstallCoolingDown(lastFffInstallOutcome, lastFffInstallFailureAt, Date.now());\n}\n\n/** Records a genuine install failure and stamps when it happened, so the cooldown above has a start time to measure from. */\nfunction recordFffInstallFailure(reason: string): void {\n\tlastFffInstallOutcome = { status: \"install-failed\", reason };\n\tlastFffInstallFailureAt = Date.now();\n}\n\nasync function installManagedFffNodePackage(platformPackage: string, silent: boolean): Promise<unknown | undefined> {\n\ttry {\n\t\tmkdirSync(FFF_MANAGED_DIR, { recursive: true });\n\t\tif (!existsSync(FFF_MANAGED_PACKAGE_JSON)) {\n\t\t\twriteFileSync(FFF_MANAGED_PACKAGE_JSON, '{\"name\":\"pi-managed-fff-node\",\"private\":true,\"version\":\"0.0.0\"}\\n');\n\t\t}\n\n\t\tif (!silent) {\n\t\t\tconsole.log(chalk.dim(\"FFF native search not found. Installing managed FFF package...\"));\n\t\t}\n\n\t\tconst args = [\n\t\t\t\"install\",\n\t\t\t\"--ignore-scripts\",\n\t\t\t\"--omit=dev\",\n\t\t\t\"--include=optional\",\n\t\t\t\"--no-audit\",\n\t\t\t\"--no-fund\",\n\t\t\t\"--package-lock=false\",\n\t\t\t\"--prefix\",\n\t\t\tFFF_MANAGED_DIR,\n\t\t\t`@ff-labs/fff-node@${FFF_NODE_VERSION}`,\n\t\t\t`${platformPackage}@${FFF_NODE_VERSION}`,\n\t\t];\n\t\tconst result = await runNpmInstall(args);\n\t\tif (result.code !== 0) {\n\t\t\tconst reason = result.stderr.trim() || `npm exited with code ${result.code}`;\n\t\t\tif (!silent) {\n\t\t\t\tconsole.log(chalk.yellow(`Failed to install FFF native search: ${reason}`));\n\t\t\t}\n\t\t\trecordFffInstallFailure(reason);\n\t\t\treturn undefined;\n\t\t}\n\t\tconst loaded = loadFffNodeWith(createRequire(pathToFileURL(FFF_MANAGED_PACKAGE_JSON).href));\n\t\tif (!loaded) {\n\t\t\tconst reason = \"Managed FFF install completed but @ff-labs/fff-node could not be loaded.\";\n\t\t\tif (!silent) {\n\t\t\t\tconsole.log(chalk.yellow(reason));\n\t\t\t}\n\t\t\trecordFffInstallFailure(reason);\n\t\t\treturn undefined;\n\t\t}\n\t\tlastFffInstallOutcome = { status: \"installed\" };\n\t\treturn loaded;\n\t} catch (error) {\n\t\t// Never let a filesystem/spawn surprise (e.g. a read-only home directory)\n\t\t// crash the caller: fall back like any other install failure, but keep\n\t\t// the reason observable.\n\t\tconst reason = error instanceof Error ? error.message : String(error);\n\t\tif (!silent) {\n\t\t\tconsole.log(chalk.yellow(`Failed to install FFF native search: ${reason}`));\n\t\t}\n\t\trecordFffInstallFailure(reason);\n\t\treturn undefined;\n\t}\n}\n\nexport async function ensureFffNodePackage(\n\tsilent: boolean = false,\n\tforceManagedInstall: boolean = false,\n\t/** Override the \"is it already available\" resolution candidates, for tests. See loadAvailableFffNodePackage's doc. */\n\trequires?: readonly ModuleRequire[],\n): Promise<unknown | undefined> {\n\tconst existing = forceManagedInstall ? undefined : loadAvailableFffNodePackage(requires);\n\tif (existing) {\n\t\tlastFffInstallOutcome = { status: \"already-available\" };\n\t\treturn existing;\n\t}\n\n\tif (isOfflineModeEnabled()) {\n\t\tif (!silent) {\n\t\t\tconsole.log(chalk.yellow(\"FFF native search not found. Offline mode enabled, skipping install.\"));\n\t\t}\n\t\tlastFffInstallOutcome = { status: \"offline\" };\n\t\treturn undefined;\n\t}\n\n\t// A prior attempt failed too recently to try again: bail out fast (no npm\n\t// spawn, no platform/libc probing) rather than repeating a doomed attempt.\n\t// Leaves lastFffInstallOutcome/lastFffInstallFailureAt untouched -- this\n\t// isn't a new attempt, so there's nothing new to record.\n\tif (isFffInstallCoolingDown()) {\n\t\treturn undefined;\n\t}\n\n\tconst platformPackage = getFffPlatformPackageName();\n\tif (!platformPackage) {\n\t\tif (!silent) {\n\t\t\tconsole.log(chalk.yellow(`FFF native search is not available for ${platform()}/${arch()}.`));\n\t\t}\n\t\tlastFffInstallOutcome = { status: \"unsupported-platform\" };\n\t\treturn undefined;\n\t}\n\n\tfffNodeInstallPromise ??= installManagedFffNodePackage(platformPackage, silent).finally(() => {\n\t\tfffNodeInstallPromise = undefined;\n\t});\n\treturn fffNodeInstallPromise;\n}\n\n// Ensure a tool is available, downloading if necessary\n// Returns the path to the tool, or null if unavailable\nexport async function ensureTool(tool: \"fd\" | \"rg\", silent: boolean = false): Promise<string | undefined> {\n\tconst existingPath = getToolPath(tool);\n\tif (existingPath) {\n\t\treturn existingPath;\n\t}\n\n\tconst config = TOOLS[tool];\n\tif (!config) return undefined;\n\n\tif (isOfflineModeEnabled()) {\n\t\tif (!silent) {\n\t\t\tconsole.log(chalk.yellow(`${config.name} not found. Offline mode enabled, skipping download.`));\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t// On Android/Termux, Linux binaries don't work due to Bionic libc incompatibility.\n\t// Users must install via pkg.\n\tif (platform() === \"android\") {\n\t\tconst pkgName = TERMUX_PACKAGES[tool] ?? tool;\n\t\tif (!silent) {\n\t\t\tconsole.log(chalk.yellow(`${config.name} not found. Install with: pkg install ${pkgName}`));\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t// Tool not found - download it\n\tif (!silent) {\n\t\tconsole.log(chalk.dim(`${config.name} not found. Downloading...`));\n\t}\n\n\ttry {\n\t\tconst path = await runExclusiveToolDownload(tool, () => downloadTool(tool));\n\t\tif (!silent) {\n\t\t\tconsole.log(chalk.dim(`${config.name} installed to ${path}`));\n\t\t}\n\t\treturn path;\n\t} catch (e) {\n\t\tif (!silent) {\n\t\t\tconsole.log(chalk.yellow(`Failed to download ${config.name}: ${e instanceof Error ? e.message : e}`));\n\t\t}\n\t\treturn undefined;\n\t}\n}\n"]}
|
package/docs/bug-ledger.md
CHANGED
|
@@ -28,8 +28,8 @@ updates. Sign the "Found by" column.
|
|
|
28
28
|
| 3 | high | lifecycle / continuous-learning | `/home/caudev/GitHub/mine/CaupulicanDev/AIConfigs/pi/extensions/continuous-learning/index.ts:4091-4152`, `:4561-4568` | Suspected shutdown bug: `session_shutdown` clears timers/status but does not cancel or await an active `runRound`; `runRound` only checks `runtimeActive` before starting. A manual close during a learning round can let file/memory writes continue against a stale session context after shutdown. Minimal fix: use an `AbortController`/generation token for active rounds, abort it on `session_shutdown`, and check it before each phase/write. | codex / claude | **open — verification failed (codex)**: `roundGeneration` is bumped and checked before the learning executor and `persistLearningOutcome`, but not before every phase/write (`writeHermesComparison`, provider sweep/indexing, skill audit, and run-log writes happen before the first abort check). The round is mostly synchronous, so an in-flight round also cannot observe `session_shutdown` until it yields. Root fix still needs per-phase/write abort checks and/or cancellable async phases. |
|
|
29
29
|
| 4 | medium | lifecycle / idle-watcher | `/home/caudev/GitHub/mine/CaupulicanDev/AIConfigs/pi/extensions/idle-watcher/index.ts:755-759`, `:772-774`; `packages/coding-agent/src/core/agent-session.ts:1023-1025` | Suspected stale-context race: `session_start` launches `handleSessionStartHandoff()` fire-and-forget, while `session_shutdown` only stops status UI. If the session is manually closed while the async picker/injection path is pending, the task can continue using a stale extension context after `AgentSession.dispose()` invalidates it. Minimal fix: track a per-session generation/abort flag, cancel it on `session_shutdown`, and re-check before UI calls, `pi.sendMessage`, or `pi.appendEntry`. | codex / claude | **verified (agy, codex)** — `disposed` is reset on `session_start`, set on `session_shutdown`, and checked after the model-restore await and after the confirm/picker await before `injectHandoff`/`pi.appendEntry`. |
|
|
30
30
|
|
|
31
|
-
| 5 | high | native reflection / cost accounting | `packages/coding-agent/src/modes/interactive/interactive-mode.ts:5783-5791`; `packages/agent/src/types.ts:309`; `packages/ai/src/types.ts:281-299` | Native reflection duplicate-cost dedupe is still ineffective on the real host path. `maybeRunNativeReflection()` derives `reportId` from `(messages[messages.length - 1] as { id?: string })?.id`, but `AgentMessage` is `Message | CustomAgentMessages[...]` and user/assistant messages have timestamps but no top-level `id`. In normal turns `reportId` is therefore `undefined`, so duplicate scheduling/retry can double-count reflection cost despite `runReflectionPass` supporting idempotence. Minimal fix: derive the report id from a real session entry id after persistence (e.g. latest branch entry id) or a stable turn digest, and add an integration test that calls `maybeRunNativeReflection` twice for one turn and asserts one `spawned_usage` report. | codex |
|
|
32
|
-
| 6 | low | lifecycle / continuous-learning | `/home/caudev/GitHub/mine/CaupulicanDev/AIConfigs/pi/extensions/continuous-learning/index.ts:4550-4563` | Suspected residual native-mode side effect: even when `PI_NATIVE_REFLECTION !== "0"`, `session_start` still initializes continuous-learning state, writes the Hermes comparison artifact, registers the active session, and updates status before returning. This no longer starts the scheduler (#2 fixed), but it is not a true no-op/yield while native reflection owns learning. Minimal fix: move the native-reflection gate to the top of `session_start` before state/artifact writes unless those side effects are explicitly still desired. | codex |
|
|
31
|
+
| 5 | high | native reflection / cost accounting | `packages/coding-agent/src/modes/interactive/interactive-mode.ts:5783-5791`; `packages/agent/src/types.ts:309`; `packages/ai/src/types.ts:281-299` | Native reflection duplicate-cost dedupe is still ineffective on the real host path. `maybeRunNativeReflection()` derives `reportId` from `(messages[messages.length - 1] as { id?: string })?.id`, but `AgentMessage` is `Message | CustomAgentMessages[...]` and user/assistant messages have timestamps but no top-level `id`. In normal turns `reportId` is therefore `undefined`, so duplicate scheduling/retry can double-count reflection cost despite `runReflectionPass` supporting idempotence. Minimal fix: derive the report id from a real session entry id after persistence (e.g. latest branch entry id) or a stable turn digest, and add an integration test that calls `maybeRunNativeReflection` twice for one turn and asserts one `spawned_usage` report. | codex | **fixed (pending commit)** — derives `reportId` from a stable digest of role/timestamp/plain-text turn content; duplicate normal turns produce the same reflection report id without reading a non-guaranteed `AgentMessage.id`. |
|
|
32
|
+
| 6 | low | lifecycle / continuous-learning | `/home/caudev/GitHub/mine/CaupulicanDev/AIConfigs/pi/extensions/continuous-learning/index.ts:4550-4563` | Suspected residual native-mode side effect: even when `PI_NATIVE_REFLECTION !== "0"`, `session_start` still initializes continuous-learning state, writes the Hermes comparison artifact, registers the active session, and updates status before returning. This no longer starts the scheduler (#2 fixed), but it is not a true no-op/yield while native reflection owns learning. Minimal fix: move the native-reflection gate to the top of `session_start` before state/artifact writes unless those side effects are explicitly still desired. | codex | open — W11.2 is out-of-repo in AIConfigs; intentionally not fixed in pi-adaptative. |
|
|
33
33
|
| 7 | high | context-gc / memory subsystem | `packages/coding-agent/src/core/context-gc.ts:236-243`; `packages/coding-agent/src/core/agent-session.ts:1497-1502` | `<memory_context` recall pages are prepended to history as `"user"` messages. However, `ContextGc.ts` only applies semantic memory GC markers (like `<memory_context`) to `"custom"` or `"toolResult"` messages. It does NOT scan `"user"` or `"assistant"` messages. As a result, every cross-session recall page fetched during a session accumulates permanently in active memory and gets persisted in transcript files, completely bypassing Context GC and leading to context window bloat over long sessions. | agy | **fixed (claude)** — recall injected as a GC-managed `custom` message (role custom, customType memory_context) so semantic-memory context-GC packs stale recall pages instead of accumulating forever. |
|
|
34
34
|
| 8 | high | memory subsystem / prompt injection | `packages/coding-agent/src/core/memory/providers/transcript-recall.ts:74-75`, `:134-157`; `packages/coding-agent/src/core/agent-session.ts:1497-1502` | Transcript recall interpolates raw past user/assistant text inside an XML-ish `<memory_context>` block and then injects that block as a `user` message. A prior transcript can contain `</memory_context>` or direct instructions, break out of the wrapper, and be replayed as current-turn user content. Minimal fix: treat snippets as untrusted data (escape/fence delimiters or encode), strengthen the wrapper instruction, and add a regression with a closing-tag/instruction payload. | codex | **fixed (claude)** — recall snippets fenced via the untrusted-content boundary (Hermes-aligned: recall = data, not instructions). |
|
|
35
35
|
| 9 | high | memory subsystem / corpus bounds | `packages/coding-agent/src/core/memory/providers/transcript-recall.ts:94-128`; `packages/coding-agent/src/core/session-manager.ts:489-553` | R3 corpus caps are applied only after `loadEntriesFromFile()` has synchronously read and parsed an entire selected JSONL session into memory. A huge or long-lived transcript can block the first recalled turn and allocate far beyond `MAX_DOC_CHARS` / `MAX_TOTAL_CHARS`, violating the bounded-ms-local contract. Minimal fix: stream-extract only user/assistant text with byte/entry/session caps, skip overlarge files before parse, and test a large transcript path. | codex | **fixed (claude)** — skip transcript files > MAX_FILE_BYTES (8MB) before parse so a huge log can't block/bloat the first recalled turn. |
|
|
@@ -71,45 +71,46 @@ updates. Sign the "Found by" column.
|
|
|
71
71
|
| 42 | high | coding-agent / html export | `packages/coding-agent/src/core/export-html/index.ts:164` | W1.6 HTML export asset injection uses String.replace values directly, corrupting $ sequences in JS/vendor assets. | 2026-07-05 harness bug hunt | fixed |
|
|
72
72
|
| 43 | high | coding-agent / goals | `packages/coding-agent/src/core/slash-commands.ts` | W2.1 /goal has no user-facing producer; goal consumer stack remains unreachable unless model volunteers goal tool calls. | 2026-07-05 harness bug hunt | fixed |
|
|
73
73
|
| 44 | high | agent / retry kernel | `packages/agent/src/reliability/retry-controller.ts:116` | W3.1 Turn retry controller ignores parsed retryAfterMs when computing backoff. | 2026-07-05 harness bug hunt | fixed |
|
|
74
|
-
| 45 | high | coding-agent / failure corpus | `packages/coding-agent/src/core/agent-session.ts:3639; packages/coding-agent/src/core/billing-failover-controller.ts:73` | W3.2 Failure corpus recording is side-effectful in retry predicate and billing failover, duplicating one failure and possibly disagreeing on classification. | 2026-07-05 harness bug hunt |
|
|
75
|
-
| 46 | medium | agent / classifier | `packages/agent/src/reliability/classifier.ts:53` | W3.3 Numeric status regexes match inside longer numbers, misclassifying token counts and IDs as rate/server errors. | 2026-07-05 harness bug hunt |
|
|
76
|
-
| 47 | medium | agent / compaction loop | `packages/agent/src/compaction/loop.ts:227` | W3.4 Compaction-loop failure mapping treats any aborted substring as user abort, suppressing retries for ECONNABORTED-style provider errors. | 2026-07-05 harness bug hunt |
|
|
77
|
-
| 48 | medium | ai+agent / streams | `packages/ai/src/utils/event-stream.ts:38; packages/agent/src/proxy.ts:213` | W3.5 Streams ending without terminal event can leave result() unresolved after watchdog disarms. | 2026-07-05 harness bug hunt |
|
|
78
|
-
| 49 | low | ai / oauth | `packages/ai/src/utils/oauth/openai-codex.ts:150` | W3.6 Codex OAuth token expiry lacks the 5-minute early-refresh buffer used by sibling providers. | 2026-07-05 harness bug hunt |
|
|
79
|
-
| 50 | high | agent / compaction loop | `packages/agent/src/compaction/loop.ts:63` | W4.1 effect-not-restored retry path is unreachable after apply appends a compaction entry; tests mask real branch mutation. | 2026-07-05 harness bug hunt |
|
|
80
|
-
| 51 | medium | agent / compaction verification | `packages/agent/src/compaction/extraction.ts:24` | W4.2 Cancelled-work extraction over-matches everyday phrasing and creates unsatisfiable verification gates. | 2026-07-05 harness bug hunt |
|
|
81
|
-
| 52 | medium | agent / compaction verification | `packages/agent/src/compaction/verification.ts:87` | W4.3 actions-overlap Jaccard penalizes faithful Done carry-over on update compactions. | 2026-07-05 harness bug hunt |
|
|
82
|
-
| 53 | low | agent / compaction tokens | `packages/agent/src/compaction/compaction.ts:294` | W4.4 Token estimator comment is directionally wrong and chunk sizing uses 100% of input bound with no headroom. | 2026-07-05 harness bug hunt |
|
|
83
|
-
| 54 | low | agent / branch summarization | `packages/agent/src/compaction/branch-summarization.ts:324` | W4.5 Branch summarization bypasses wrapped stream/retry/watchdog path. | 2026-07-05 harness bug hunt |
|
|
84
|
-
| 55 | medium | coding-agent / interactive rendering | `packages/coding-agent/src/modes/interactive/interactive-mode.ts:2465` | W5.1 renderSessionContext is not reentrancy-safe; overlapping rebuilds can orphan chat containers. | 2026-07-05 harness bug hunt |
|
|
85
|
-
| 56 | medium | coding-agent / extensions UI | `packages/coding-agent/src/modes/interactive/interactive-mode.ts:656` | W5.2 extensions-changed UI subscription is not rebound after session switch. | 2026-07-05 harness bug hunt |
|
|
86
|
-
| 57 | medium | coding-agent / extensions loader | `packages/coding-agent/src/core/resource-loader.ts:912` | W5.3 Failed /reload can leak event-bus subscriptions from new and partial extension generations. | 2026-07-05 harness bug hunt |
|
|
87
|
-
| 58 | medium | coding-agent / extensions runner | `packages/coding-agent/src/core/extensions/runner.ts:878` | W5.4 emitToolCall
|
|
88
|
-
| 59 | medium | tui / input | `packages/tui/src/keys.ts:1375` | W6.1 Kitty PUA functional keys
|
|
89
|
-
| 60 | medium | tui / measurement | `packages/tui/src/utils.ts:295` | W6.2 extractAnsiCode CSI terminator set
|
|
90
|
-
| 61 | low | tui / stdin buffer | `packages/tui/src/stdin-buffer.ts:315` | W6.3 Bracketed paste without end marker
|
|
91
|
-
| 62 | high | coding-agent / startup migrations | `packages/coding-agent/src/migrations.ts:147` | W7.1 Malformed models.json hard-crashes startup migrations; trust-manager parse has similar unguarded path. | 2026-07-05 harness bug hunt |
|
|
92
|
-
| 63 | medium | coding-agent / settings | `packages/coding-agent/src/core/settings-manager.ts:427` | W7.2 deepMergeSettings
|
|
93
|
-
| 64 | low | coding-agent / migrations | `packages/coding-agent/src/migrations.ts:252` | W7.3 Windows session migration basename extraction silently no-
|
|
94
|
-
| 65 | medium | coding-agent / scout | `packages/coding-agent/src/core/scout-controller.ts:103` | W8.1 Scout budget
|
|
95
|
-
| 66 | low | coding-agent / reflection | `packages/coding-agent/src/core/learning/reflection-engine.ts:177` | W8.2 Reflection JSON parse failure
|
|
96
|
-
| 67 | low | coding-agent / research lane | `packages/coding-agent/src/core/background-lane-controller.ts:452` | W8.3 Research-lane budget gate
|
|
97
|
-
| 68 | low | agent / public loop API | `packages/agent/src/agent-loop.ts:41` | W9.1 agentLoop public API
|
|
98
|
-
| 69 | low | agent / shell output | `packages/agent/src/utils/shell-output.ts` | W9.2 sanitizeBinaryOutput
|
|
99
|
-
| 70 | low | ai / anthropic | `packages/ai/src/providers/anthropic.ts:1259` | W9.3 Anthropic
|
|
100
|
-
| 71 | low | coding-agent / failure corpus | `packages/coding-agent/src/core/failure-corpus.ts:83` | W9.4 redactSecrets
|
|
101
|
-
| 72 | low | coding-agent / exec | `packages/coding-agent/src/core/exec.ts:135` | W9.5 exec
|
|
102
|
-
| 73 | low | coding-agent / bash execution | `packages/coding-agent/src/core/bash-execution-controller.ts:39` | W9.6 Overlapping executeBash calls
|
|
103
|
-
| 74 | low | coding-agent / tools manager | `packages/coding-agent/src/utils/tools-manager.ts:312` | W9.7 Concurrent same-tool first-run downloads
|
|
104
|
-
| 75 | low | coding-agent / interactive mode | `packages/coding-agent/src/modes/interactive/interactive-mode.ts` | W9.8 Interactive-mode small leaks: current-scope session selector
|
|
105
|
-
| 76 | low | ai / mistral streaming | `packages/ai/src/providers/mistral.ts:397` | W9.9 Investigation: Mistral streaming tool-call assembly may fragment if ids are absent from later deltas. | 2026-07-05 harness bug hunt |
|
|
106
|
-
| 77 | high | coding-agent / local models | `packages/coding-agent/src/core/models/local-registration.ts:81` | W10.1 Local model context windows are registered as a guess (8192 default); no num_ctx/served-window awareness anywhere, so over-window prompts are silently truncated by the server. | 2026-07-06 compaction incident |
|
|
107
|
-
| 78 | high | coding-agent / compaction | `packages/coding-agent/src/core/compaction-support.ts:132` | W10.2 Summarizer selection was capacity-blind: router-cheap local model chosen for spans its window cannot hold, producing recall-empty checkpoints. | 2026-07-06 compaction incident |
|
|
108
|
-
| 79 | high | agent / compaction | `packages/agent/src/compaction/compaction.ts` | W10.3 Verification demands scale with span size while the summary budget was fixed at 1500 tokens; length-stopped summaries were gated as complete; truncation deleted the gate-checked Files/Done sections. | 2026-07-06 compaction incident |
|
|
109
|
-
| 80 | high | agent+coding-agent / compaction | `packages/coding-agent/src/core/context-pipeline.ts:388` | W10.4 Pre-digest feeds the summarizer a lossy digest while facts are extracted from the raw span; active-task text did not ride in the facts block, making the gate unsatisfiable. | 2026-07-06 compaction incident |
|
|
110
|
-
| 81 | medium | coding-agent / compaction | `packages/coding-agent/src/core/agent-session.ts:2784` | W10.5 Manual /compact is single-shot on the cheap summarizer with no escalation ladder or deterministic fallback; surfaces raw gate internals. | 2026-07-06 compaction incident |
|
|
111
|
-
| 82 | low | agent / compaction extraction | `packages/agent/src/compaction/extraction.ts:23` | W10.6 Prohibition extraction captured a mid-sentence fragment as a mandatory rule in the incident trace; needs fixture with W4.2. | 2026-07-06 compaction incident |
|
|
112
|
-
| 83 | low | coding-agent / red-team tests | `packages/coding-agent/test/red-team/provider-limits.test.ts:158` | Pre-existing failure on main: d444e991 added _failureCorpus.record inside _compactWithRetry but the red-team CompactWithRetryHarness was never updated, so the quota-mid-compaction row failed with a TypeError. | 2026-07-06 compaction incident (drive-by) |
|
|
113
|
-
| 84 | high | ai / openai responses | `packages/ai/src/providers/openai-responses-shared.ts:349` | Regression in c81848ec (W1.1): providerSuppliedTotal flag dereferences response.usage.cost outside the usage guard, crashing finalizeResponse on usage-less streams; caught by the full sweep. | 2026-07-06 compaction incident (drive-by) |
|
|
114
|
-
| 85 | high | agent / compaction verification | `packages/agent/src/compaction/verification.ts:92` | Resumed-session incident 2026-07-06: actions gate used symmetric Jaccard against the whole ## Done section while the update prompt mandates carrying prior Done items, so every 2nd+ compaction (all resumed sessions that compact) trended to deterministic gate failure; capacity fix in 0.81.4 could not address this. Gate now measures recall of new-span actions; update prompt bounds Done carry-over; reversal trigger narrowed; fact paths excluded from cancelled-leakage. | 2026-07-06 compaction incident round 2 |
|
|
115
|
-
| 86 | low | coding-agent / tests | `packages/coding-agent/test/bash-edit-write-race.test.ts:28` | Flaky under full parallel sweep load: mutation-barrier ordering assertion observed [bash, file-start, file-end] once during ./test.sh while passing 5/5 in isolation; timing-sensitive microtask ordering. | 2026-07-06 compaction incident round 2 (drive-by) |
|
|
74
|
+
| 45 | high | coding-agent / failure corpus | `packages/coding-agent/src/core/agent-session.ts:3639; packages/coding-agent/src/core/billing-failover-controller.ts:73` | W3.2 Failure corpus recording is side-effectful in retry predicate and billing failover, duplicating one failure and possibly disagreeing on classification. | 2026-07-05 harness bug hunt | fixed: de7409ca |
|
|
75
|
+
| 46 | medium | agent / classifier | `packages/agent/src/reliability/classifier.ts:53` | W3.3 Numeric status regexes match inside longer numbers, misclassifying token counts and IDs as rate/server errors. | 2026-07-05 harness bug hunt | fixed: 553fa60f |
|
|
76
|
+
| 47 | medium | agent / compaction loop | `packages/agent/src/compaction/loop.ts:227` | W3.4 Compaction-loop failure mapping treats any aborted substring as user abort, suppressing retries for ECONNABORTED-style provider errors. | 2026-07-05 harness bug hunt | fixed: pending |
|
|
77
|
+
| 48 | medium | ai+agent / streams | `packages/ai/src/utils/event-stream.ts:38; packages/agent/src/proxy.ts:213` | W3.5 Streams ending without terminal event can leave result() unresolved after watchdog disarms. | 2026-07-05 harness bug hunt | fixed: pending |
|
|
78
|
+
| 49 | low | ai / oauth | `packages/ai/src/utils/oauth/openai-codex.ts:150` | W3.6 Codex OAuth token expiry lacks the 5-minute early-refresh buffer used by sibling providers. | 2026-07-05 harness bug hunt | fixed: pending |
|
|
79
|
+
| 50 | high | agent / compaction loop | `packages/agent/src/compaction/loop.ts:63` | W4.1 effect-not-restored retry path is unreachable after apply appends a compaction entry; tests mask real branch mutation. | 2026-07-05 harness bug hunt | fixed: ea6737fa |
|
|
80
|
+
| 51 | medium | agent / compaction verification | `packages/agent/src/compaction/extraction.ts:24` | W4.2 Cancelled-work extraction over-matches everyday phrasing and creates unsatisfiable verification gates. | 2026-07-05 harness bug hunt | fixed: e459899d |
|
|
81
|
+
| 52 | medium | agent / compaction verification | `packages/agent/src/compaction/verification.ts:87` | W4.3 actions-overlap Jaccard penalizes faithful Done carry-over on update compactions. | 2026-07-05 harness bug hunt | fixed: e459899d |
|
|
82
|
+
| 53 | low | agent / compaction tokens | `packages/agent/src/compaction/compaction.ts:294` | W4.4 Token estimator comment is directionally wrong and chunk sizing uses 100% of input bound with no headroom. | 2026-07-05 harness bug hunt | fixed: pending |
|
|
83
|
+
| 54 | low | agent / branch summarization | `packages/agent/src/compaction/branch-summarization.ts:324` | W4.5 Branch summarization bypasses wrapped stream/retry/watchdog path. | 2026-07-05 harness bug hunt | fixed: pending |
|
|
84
|
+
| 55 | medium | coding-agent / interactive rendering | `packages/coding-agent/src/modes/interactive/interactive-mode.ts:2465` | W5.1 renderSessionContext is not reentrancy-safe; overlapping rebuilds can orphan chat containers. | 2026-07-05 harness bug hunt | fixed (claude) |
|
|
85
|
+
| 56 | medium | coding-agent / extensions UI | `packages/coding-agent/src/modes/interactive/interactive-mode.ts:656` | W5.2 extensions-changed UI subscription is not rebound after session switch. | 2026-07-05 harness bug hunt | fixed: pending |
|
|
86
|
+
| 57 | medium | coding-agent / extensions loader | `packages/coding-agent/src/core/resource-loader.ts:912` | W5.3 Failed /reload can leak event-bus subscriptions from new and partial extension generations. | 2026-07-05 harness bug hunt | fixed: pending |
|
|
87
|
+
| 58 | medium | coding-agent / extensions runner | `packages/coding-agent/src/core/extensions/runner.ts:878` | W5.4 emitToolCall lacked per-handler error isolation, skipping later handlers and diagnostics on throw. | 2026-07-05 harness bug hunt | **fixed (pending commit)** — wraps each `tool_call` handler, emits `ExtensionError`, continues dispatch, then rethrows the first handler error to preserve fail-closed semantics. |
|
|
88
|
+
| 59 | medium | tui / input | `packages/tui/src/keys.ts:1375` | W6.1 Kitty PUA functional keys decoded as printable invisible text. | 2026-07-05 harness bug hunt | **fixed (pending commit)** — rejects unnormalized Kitty functional PUA codepoints while preserving keypad printable aliases. |
|
|
89
|
+
| 60 | medium | tui / measurement | `packages/tui/src/utils.ts:295` | W6.2 extractAnsiCode CSI terminator set was too narrow and could swallow visible text after non-SGR CSI. | 2026-07-05 harness bug hunt | **fixed (pending commit)** — CSI extraction now stops at any valid CSI final byte (`0x40`-`0x7e`), with regression coverage for `?25l`, cursor-forward, and clear-screen sequences. |
|
|
90
|
+
| 61 | low | tui / stdin buffer | `packages/tui/src/stdin-buffer.ts:315` | W6.3 Bracketed paste without end marker could leave pasteMode set forever. | 2026-07-05 harness bug hunt | **fixed (pending commit)** — arms a paste-mode timeout that emits unterminated paste content literally, exits paste mode, and lets subsequent keys process normally. |
|
|
91
|
+
| 62 | high | coding-agent / startup migrations | `packages/coding-agent/src/migrations.ts:147` | W7.1 Malformed models.json hard-crashes startup migrations; trust-manager parse has similar unguarded path. | 2026-07-05 harness bug hunt | fixed: pending |
|
|
92
|
+
| 63 | medium | coding-agent / settings | `packages/coding-agent/src/core/settings-manager.ts:427` | W7.2 deepMergeSettings documented recursive merge but only merged one level. | 2026-07-05 harness bug hunt | **fixed (pending commit)** — nested object overlays now recurse, preserving sibling leaves while arrays remain replacement values. |
|
|
93
|
+
| 64 | low | coding-agent / migrations | `packages/coding-agent/src/migrations.ts:252` | W7.3 Windows session migration basename extraction silently no-opped. | 2026-07-05 harness bug hunt | **fixed (pending commit)** — session migration now extracts file names with a separator regex that handles both POSIX and Windows-style paths. |
|
|
94
|
+
| 65 | medium | coding-agent / scout | `packages/coding-agent/src/core/scout-controller.ts:103` | W8.1 Scout budget counted total tokens against an output-token cap, causing premature truncation. | 2026-07-05 harness bug hunt | **fixed (pending commit)** — accumulates `usage.output` for the output-token cap and covers high-input/low-output scout turns. |
|
|
95
|
+
| 66 | low | coding-agent / reflection | `packages/coding-agent/src/core/learning/reflection-engine.ts:177` | W8.2 Reflection JSON parse failure returned empty usage, zeroing real spend. | 2026-07-05 harness bug hunt | **fixed (pending commit)** — completed reflection calls retain provider usage when JSON parsing or validation fails. |
|
|
96
|
+
| 67 | low | coding-agent / research lane | `packages/coding-agent/src/core/background-lane-controller.ts:452` | W8.3 Research-lane budget gate compared unclamped estimate against clamped envelope limit. | 2026-07-05 harness bug hunt | **fixed (pending commit)** — computes one clamped lane budget from settings and foreground envelope, then passes it to both the research envelope and runner limit. |
|
|
97
|
+
| 68 | low | agent / public loop API | `packages/agent/src/agent-loop.ts:41` | W9.1 agentLoop public API had a detached promise with no catch. Reproduction confirmed with a throwing `convertToLlm`: the stream never completed and Vitest reported an unhandled rejection. Continuation array mutation was not reproduced in this row's regression. | 2026-07-05 harness bug hunt | **fixed (pending commit)** — public `agentLoop`/`agentLoopContinue` wrappers catch detached loop failures, emit `agent_end`, and resolve the stream result with an error assistant message. |
|
|
98
|
+
| 69 | low | agent / shell output | `packages/agent/src/utils/shell-output.ts` | W9.2 sanitizeBinaryOutput preserved lone surrogates, DEL, and C1 controls despite comment. | 2026-07-05 harness bug hunt | **fixed (pending commit)** — filters lone surrogate code units plus DEL/C1 controls while preserving valid surrogate pairs. |
|
|
99
|
+
| 70 | low | ai / anthropic | `packages/ai/src/providers/anthropic.ts:1259` | W9.3 Anthropic stop-reason mapping default threw on future `stop_reason` values instead of graceful stop. | 2026-07-05 harness bug hunt | **fixed (pending commit)** — unknown Anthropic stop reasons now warn and map to `stop`; unit and SSE fixture coverage added. |
|
|
100
|
+
| 71 | low | coding-agent / failure corpus | `packages/coding-agent/src/core/failure-corpus.ts:83` | W9.4 redactSecrets missed separator-bearing sk-proj/sk-ant key formats. | 2026-07-05 harness bug hunt | **fixed (pending commit)** — redacts `sk-proj-` and `sk-ant-` keys containing separators. |
|
|
101
|
+
| 72 | low | coding-agent / exec | `packages/coding-agent/src/core/exec.ts:135` | W9.5 exec decoded per chunk with data.toString(), splitting multibyte characters. | 2026-07-05 harness bug hunt | **fixed (pending commit)** — uses UTF-8 `StringDecoder` per stream and flushes pending bytes at process settlement. |
|
|
102
|
+
| 73 | low | coding-agent / bash execution | `packages/coding-agent/src/core/bash-execution-controller.ts:39` | W9.6 Overlapping executeBash calls clobbered the shared abort controller. | 2026-07-05 harness bug hunt | **fixed (pending commit)** — tracks all active bash abort controllers and aborts/removes each independently. |
|
|
103
|
+
| 74 | low | coding-agent / tools manager | `packages/coding-agent/src/utils/tools-manager.ts:312` | W9.7 Concurrent same-tool first-run downloads raced on one archive path. | 2026-07-05 harness bug hunt | **fixed (pending commit)** — same-tool installs now share one in-flight download promise and clear it after settlement. |
|
|
104
|
+
| 75 | low | coding-agent / interactive mode | `packages/coding-agent/src/modes/interactive/interactive-mode.ts` | W9.8 Interactive-mode small leaks: current-scope session selector lacked seq guard; custom editor replacement did not dispose previous editor. | 2026-07-05 harness bug hunt | **fixed (pending commit)** — current/all session loads each have sequence guards and `setEditor` disposes replaced non-default editors. |
|
|
105
|
+
| 76 | low | ai / mistral streaming | `packages/ai/src/providers/mistral.ts:397` | W9.9 Investigation: Mistral streaming tool-call assembly may fragment if ids are absent from later deltas. | 2026-07-05 harness bug hunt | **not reproduced / no code change** — attempted fixture-gated investigation: repo has Mistral e2e tests gated on `MISTRAL_API_KEY`, but no key is available in this environment, so no SDK-executed streaming tool-call chunk fixture could be captured. Static search found no existing recorded Mistral streaming tool-call fixture to prove absent-id deltas. Per W9.9, left provider code unchanged because fragmentation was not demonstrated. |
|
|
106
|
+
| 77 | high | coding-agent / local models | `packages/coding-agent/src/core/models/local-registration.ts:81` | W10.1 Local model context windows are registered as a guess (8192 default); no num_ctx/served-window awareness anywhere, so over-window prompts are silently truncated by the server. | 2026-07-06 compaction incident | fixed: 15eb7c69 |
|
|
107
|
+
| 78 | high | coding-agent / compaction | `packages/coding-agent/src/core/compaction-support.ts:132` | W10.2 Summarizer selection was capacity-blind: router-cheap local model chosen for spans its window cannot hold, producing recall-empty checkpoints. | 2026-07-06 compaction incident | fixed: ebcc1137 |
|
|
108
|
+
| 79 | high | agent / compaction | `packages/agent/src/compaction/compaction.ts` | W10.3 Verification demands scale with span size while the summary budget was fixed at 1500 tokens; length-stopped summaries were gated as complete; truncation deleted the gate-checked Files/Done sections. | 2026-07-06 compaction incident | fixed: ebcc1137 |
|
|
109
|
+
| 80 | high | agent+coding-agent / compaction | `packages/coding-agent/src/core/context-pipeline.ts:388` | W10.4 Pre-digest feeds the summarizer a lossy digest while facts are extracted from the raw span; active-task text did not ride in the facts block, making the gate unsatisfiable. | 2026-07-06 compaction incident | fixed: ebcc1137 |
|
|
110
|
+
| 81 | medium | coding-agent / compaction | `packages/coding-agent/src/core/agent-session.ts:2784` | W10.5 Manual /compact is single-shot on the cheap summarizer with no escalation ladder or deterministic fallback; surfaces raw gate internals. | 2026-07-06 compaction incident | fixed: 77d22ee1 |
|
|
111
|
+
| 82 | low | agent / compaction extraction | `packages/agent/src/compaction/extraction.ts:23` | W10.6 Prohibition extraction captured a mid-sentence fragment as a mandatory rule in the incident trace; needs fixture with W4.2. | 2026-07-06 compaction incident | **fixed (pending commit)** — sentence splitting no longer breaks version-number sentences into mid-clause prohibition fragments; incident fixture added. |
|
|
112
|
+
| 83 | low | coding-agent / red-team tests | `packages/coding-agent/test/red-team/provider-limits.test.ts:158` | Pre-existing failure on main: d444e991 added _failureCorpus.record inside _compactWithRetry but the red-team CompactWithRetryHarness was never updated, so the quota-mid-compaction row failed with a TypeError. | 2026-07-06 compaction incident (drive-by) | fixed: ebcc1137 |
|
|
113
|
+
| 84 | high | ai / openai responses | `packages/ai/src/providers/openai-responses-shared.ts:349` | Regression in c81848ec (W1.1): providerSuppliedTotal flag dereferences response.usage.cost outside the usage guard, crashing finalizeResponse on usage-less streams; caught by the full sweep. | 2026-07-06 compaction incident (drive-by) | fixed: 4325cc7e |
|
|
114
|
+
| 85 | high | agent / compaction verification | `packages/agent/src/compaction/verification.ts:92` | Resumed-session incident 2026-07-06: actions gate used symmetric Jaccard against the whole ## Done section while the update prompt mandates carrying prior Done items, so every 2nd+ compaction (all resumed sessions that compact) trended to deterministic gate failure; capacity fix in 0.81.4 could not address this. Gate now measures recall of new-span actions; update prompt bounds Done carry-over; reversal trigger narrowed; fact paths excluded from cancelled-leakage. | 2026-07-06 compaction incident round 2 | fixed: e459899d |
|
|
115
|
+
| 86 | low | coding-agent / tests | `packages/coding-agent/test/bash-edit-write-race.test.ts:28` | Flaky under full parallel sweep load: mutation-barrier ordering assertion observed [bash, file-start, file-end] once during ./test.sh while passing 5/5 in isolation; timing-sensitive microtask ordering. | 2026-07-06 compaction incident round 2 (drive-by) | **fixed (pending commit)** — verdict: test setup race, not a barrier ordering bug; replaced fixed sleeps with explicit wait-until scheduling gates while preserving the exact ordering assertions. |
|
|
116
|
+
| 87 | high | agent / compaction extraction | `packages/agent/src/compaction/extraction.ts` | Field incident 2026-07-06 (round 3, on v0.81.5): prohibition extraction harvested 13 "never/do not" fragment rules from one pasted instruction document, making mandatory-rules-recall demand the checkpoint reproduce the document; harvest now skips user messages >1500 chars and caps rules at the 8 most recent. Same trace: /goal seeded no requirement when the model skipped decomposition (now seeded deterministically), and gate-failure warnings now name the summarizer selection + input estimate for the still-open estimator question (rows 77/85 lineage). | 2026-07-06 compaction incident round 3 | fix-proposed |
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-custom-provider",
|
|
3
|
-
"version": "0.81.
|
|
3
|
+
"version": "0.81.7",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-custom-provider",
|
|
9
|
-
"version": "0.81.
|
|
9
|
+
"version": "0.81.7",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sdk": "^0.52.0"
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-sandbox",
|
|
3
|
-
"version": "0.81.
|
|
3
|
+
"version": "0.81.7",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-sandbox",
|
|
9
|
-
"version": "0.81.
|
|
9
|
+
"version": "0.81.7",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sandbox-runtime": "^0.0.26"
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-with-deps",
|
|
3
|
-
"version": "0.81.
|
|
3
|
+
"version": "0.81.7",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-with-deps",
|
|
9
|
-
"version": "0.81.
|
|
9
|
+
"version": "0.81.7",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"ms": "^2.1.3"
|
|
12
12
|
},
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caupulican/pi-adaptative",
|
|
3
|
-
"version": "0.81.
|
|
3
|
+
"version": "0.81.7",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@caupulican/pi-adaptative",
|
|
9
|
-
"version": "0.81.
|
|
9
|
+
"version": "0.81.7",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@caupulican/pi-agent-core": "^0.81.
|
|
13
|
-
"@caupulican/pi-ai": "^0.81.
|
|
14
|
-
"@caupulican/pi-tui": "^0.81.
|
|
12
|
+
"@caupulican/pi-agent-core": "^0.81.7",
|
|
13
|
+
"@caupulican/pi-ai": "^0.81.7",
|
|
14
|
+
"@caupulican/pi-tui": "^0.81.7",
|
|
15
15
|
"@ff-labs/fff-node": "0.9.6",
|
|
16
16
|
"@silvia-odwyer/photon-node": "0.3.4",
|
|
17
17
|
"chalk": "5.6.2",
|
|
@@ -475,11 +475,11 @@
|
|
|
475
475
|
}
|
|
476
476
|
},
|
|
477
477
|
"node_modules/@caupulican/pi-agent-core": {
|
|
478
|
-
"version": "0.81.
|
|
479
|
-
"resolved": "https://registry.npmjs.org/@caupulican/pi-agent-core/-/pi-agent-core-0.81.
|
|
478
|
+
"version": "0.81.7",
|
|
479
|
+
"resolved": "https://registry.npmjs.org/@caupulican/pi-agent-core/-/pi-agent-core-0.81.7.tgz",
|
|
480
480
|
"license": "MIT",
|
|
481
481
|
"dependencies": {
|
|
482
|
-
"@caupulican/pi-ai": "^0.81.
|
|
482
|
+
"@caupulican/pi-ai": "^0.81.7",
|
|
483
483
|
"ignore": "7.0.5",
|
|
484
484
|
"typebox": "1.1.38",
|
|
485
485
|
"yaml": "2.9.0"
|
|
@@ -489,8 +489,8 @@
|
|
|
489
489
|
}
|
|
490
490
|
},
|
|
491
491
|
"node_modules/@caupulican/pi-ai": {
|
|
492
|
-
"version": "0.81.
|
|
493
|
-
"resolved": "https://registry.npmjs.org/@caupulican/pi-ai/-/pi-ai-0.81.
|
|
492
|
+
"version": "0.81.7",
|
|
493
|
+
"resolved": "https://registry.npmjs.org/@caupulican/pi-ai/-/pi-ai-0.81.7.tgz",
|
|
494
494
|
"license": "MIT",
|
|
495
495
|
"dependencies": {
|
|
496
496
|
"@anthropic-ai/sdk": "0.91.1",
|
|
@@ -512,8 +512,8 @@
|
|
|
512
512
|
}
|
|
513
513
|
},
|
|
514
514
|
"node_modules/@caupulican/pi-tui": {
|
|
515
|
-
"version": "0.81.
|
|
516
|
-
"resolved": "https://registry.npmjs.org/@caupulican/pi-tui/-/pi-tui-0.81.
|
|
515
|
+
"version": "0.81.7",
|
|
516
|
+
"resolved": "https://registry.npmjs.org/@caupulican/pi-tui/-/pi-tui-0.81.7.tgz",
|
|
517
517
|
"license": "MIT",
|
|
518
518
|
"dependencies": {
|
|
519
519
|
"get-east-asian-width": "1.6.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caupulican/pi-adaptative",
|
|
3
|
-
"version": "0.81.
|
|
3
|
+
"version": "0.81.7",
|
|
4
4
|
"description": "Adaptive fork of Pi coding agent for self-evolving agent harness experiments",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"piConfig": {
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"prepublishOnly": "npm run clean && npm run build && npm run shrinkwrap"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@caupulican/pi-agent-core": "^0.81.
|
|
45
|
-
"@caupulican/pi-ai": "^0.81.
|
|
46
|
-
"@caupulican/pi-tui": "^0.81.
|
|
44
|
+
"@caupulican/pi-agent-core": "^0.81.7",
|
|
45
|
+
"@caupulican/pi-ai": "^0.81.7",
|
|
46
|
+
"@caupulican/pi-tui": "^0.81.7",
|
|
47
47
|
"@ff-labs/fff-node": "0.9.6",
|
|
48
48
|
"@silvia-odwyer/photon-node": "0.3.4",
|
|
49
49
|
"chalk": "5.6.2",
|