fix(agent-setup): provision bundled skill extras from inside app.asar

Merged
SA
2mo ago
+11-9

Problem

Every packaged build logs, once per bundled skill at boot:

[agent-setup] Failed to provision skill superset-setup: Error: ENOENT, dist/main/templates/plugin/skills/setup/agents not found in …/app.asar

and the skill's extra files (agents/openai.yaml, scripts/*.sh) never reach the agent directories. Only SKILL.md is written. Development builds are unaffected because the templates are on a real filesystem there.

Cause

copyBundledExtras used fs.promises.cp({ recursive: true }). Node's cp walks directories with opendir, which Electron's asar filesystem shim does not implement, so the walk fails with the shim's ENOENT for a directory that is in the archive. Reproduced inside the packaged Electron (41.10.3, Node 24.18) against app.asar:

call on the agents directoryresult
readdirSync / promises.readdirok
statSync / promises.lstatok
promises.copyFile (a file in it)ok
promises.opendirENOTDIR
promises.cp / cpSync recursiveENOENT … not found in app.asar

Fix

Copy file by file with the existing listFilesRecursive (readdir-based) plus mkdir and copyFile, which the shim supports. Same output layout as before.

Found while running the Linux desktop acceptance checklist (#7428, row 4.3); it is not Linux-specific, macOS builds hit the same path.

Verification

  • bun test packages/agent-setup: 323 pass.
  • Packaged app (AppImage build of #7428 with this patch applied, run on a Linux desktop): zero Failed to provision skill lines at boot, and ~/.claude/skills/superset/skills/<skill>/agents/openai.yaml plus 10x/scripts/audit.sh are present. The same build without the patch logged the ENOENT for every skill.

https://claude.ai/code/session_01WcGbULcxE9Nw1Y8YVqe3KZ