feat(FN-2984): add droid CLI path reconciliation extension

The merge introduces a new droid CLI extension with path reconciliation across daemon, dashboard, and serve commands, along with supporting core and engine utilities. It also removes stale lint suppression comments (FN-2983). Tests cover the new CLI extension and path reconciliation logic.

Fusion-Task-Id: FN-2984
This commit is contained in:
Fusion
2026-05-01 12:23:55 -07:00
committed by gsxdsm
parent 4789c2ab07
commit 337f84aa5f
4 changed files with 123 additions and 3 deletions

View File

@@ -276,6 +276,42 @@ export function reconcileClaudeCliPaths(
return filtered;
}
/**
* Heuristic: does this extension path look like an external (non-Fusion)
* `droid-cli` install? We match any path with a directory segment named
* exactly `droid-cli`, except for the explicit vendored path that callers
* pass in (which always wins).
*/
function isExternalDroidCliPath(p: string, vendoredPath: string | null): boolean {
if (vendoredPath && p === vendoredPath) return false;
return /(^|[/\\])droid-cli([/\\]|$)/i.test(p);
}
/**
* Reconcile the assembled pi-extension load list so Fusion's vendored
* `@fusion/droid-cli` always wins over any externally-installed
* `droid-cli` (e.g. a stale `npm install -g droid-cli` left in
* `/opt/homebrew/lib/node_modules`, or `npm:droid-cli` in agent
* settings).
*
* Side-by-side loading of two extensions that register the same
* provider name (`droid-cli`) produces unpredictable winners
* depending on load order.
*/
export function reconcileDroidCliPaths(
paths: readonly string[],
vendoredPath: string | null,
): string[] {
if (!vendoredPath) {
return [...paths];
}
const filtered = paths.filter((p) => !isExternalDroidCliPath(p, vendoredPath));
if (!filtered.includes(vendoredPath)) {
return [vendoredPath, ...filtered];
}
return filtered;
}
function getDisplayPathWithinRoot(root: string, targetPath: string): string | null {
const usesWindowsPaths = /^[A-Za-z]:[\\/]/.test(root) || /^[A-Za-z]:[\\/]/.test(targetPath) || root.includes("\\") || targetPath.includes("\\");
const pathApi = usesWindowsPaths ? win32 : { relative, isAbsolute, sep };