Skip to content

fix(desktop): arch-scope managed node-tools and self-repair adapters - #5

Merged
oscarlehuu merged 5 commits into
mainfrom
fix/managed-node-tools-arch-scoping
Jul 30, 2026
Merged

fix(desktop): arch-scope managed node-tools and self-repair adapters#5
oscarlehuu merged 5 commits into
mainfrom
fix/managed-node-tools-arch-scoping

Conversation

@oscarlehuu

@oscarlehuu oscarlehuu commented Jul 30, 2026

Copy link
Copy Markdown

Summary

  • Arch-scope managed npm prefix to node-tools/<platform>/, share one (os,arch)→platform helper with the Node runtime, and seed product dir from Tauri productName (fallback "Buzz") so forks no longer share one poisoned tree.
  • On adapter arch mismatch, guarded purge + reinstall; reclaim legacy unscoped node-tools/ contents after success; pass npm --cpu/--os (aarch64→arm64, macos→darwin, windows→win32).
  • Phase 03: only put managed Node/npm dirs on PATH when the binary exists; managed adapters fail loudly if managed Node is missing (no spawn-time download). Unmanaged CLIs unchanged.
  • Phase 04: replace upstream npm install -g optional-dep advice with Settings → Agent runtimes Install guidance (install stderr, agent log parse, buzz-acp init errors).

Closes #4.

Plan: plans/20260731-0009-managed-node-tools-arch-scoping/

Buzz channel: 9fcd2dc3-5f3e-4f7e-9cb3-3409f33ba7fa

NuncioCrew / fork note (disk reclaim)

Legacy unscoped reclaim targets data_dir()/<productName>/node-tools (e.g. NuncioCrew/node-tools). Older NuncioCrew builds stored managed Node/npm under the literal Buzz/ product dir, so those trees are not auto-reclaimed after this change — by design: deleting Buzz/node-tools or Buzz/runtimes/node/… could remove a live stock Buzz install sharing the same machine.

If you use NuncioCrew only (no stock Buzz), you may manually remove leftover disk under:

  • ~/Library/Application Support/Buzz/node-tools/
  • ~/Library/Application Support/Buzz/runtimes/node/ (e.g. v24.18.0/darwin-x64/)

Test plan

  • cargo clippy --workspace --all-targets -- -D warnings
  • ./scripts/run-tests.sh unit
  • just desktop-tauri-check
  • just desktop-tauri-test (1905 passed) including arch/purge/hint/probe fixtures
  • Manual smoke on macOS arm64 per plan Verification section (legacy x64 tree as miss → reinstall)

Reviewer notes

  1. Purge guard: is_safe_to_purge_node_tools_path + tests refusing outside node-tools.
  2. Phase 03: verified-PATH only; require_managed_node_for_adapter clears positive probe memo then fresh-probes; no download on spawn.
  3. npm spelling: --cpu=arm64|x64, --os=darwin|linux|win32 (windows→win32, not pass-through).
  4. Partial-success UI: failed sibling adapter-repair surfaces as warning while primary success:true.
  5. Orphan optional-only prefix → NoAdaptersInstalled (no phantom reinstall).

Made with Cursor

oscarlehuu and others added 5 commits July 31, 2026 00:25
Close #4: scope the npm prefix by platform, isolate product
dirs, purge+reinstall on arch mismatch with a guarded delete, pin managed
adapter PATH to an existing Node binary, and replace upstream npm -g advice
with an in-app repair hint.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: oscarlehuu <oscar.lehuu@gmail.com>
Signed-off-by: oscarlehuu <oscar.lehuu@gmail.com>
Reject `..` components and the node-tools root itself before purge, make the
guard injectable for hermetic fixtures, and run arch self-repair even when
plan_adapter_install skips because an adapter already looks current.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: oscarlehuu <oscar.lehuu@gmail.com>
Signed-off-by: oscarlehuu <oscar.lehuu@gmail.com>
Split managed adapter install into modules for the file-size ratchet, match
arch per adapter family, reinstall purged siblings as visible non-fatal steps,
and gate PATH/spawn on the managed Node version probe.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: oscarlehuu <oscar.lehuu@gmail.com>
Signed-off-by: oscarlehuu <oscar.lehuu@gmail.com>
Keep sibling repair accounting after primary failure, ignore orphan
optionals, serialize the shared npm prefix, and memoize Node readiness
as true-only so install can observe missing→ready.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: oscarlehuu <oscar.lehuu@gmail.com>
Signed-off-by: oscarlehuu <oscar.lehuu@gmail.com>
Keep primary install success:true while UI shows failed sibling
adapter-repair steps, and clear the positive Node probe memo at
managed-adapter spawn so a stale true cache cannot pass a missing
binary. Hermetic tempfile seam replaces app data_dir rename tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: oscarlehuu <oscar.lehuu@gmail.com>
Signed-off-by: oscarlehuu <oscar.lehuu@gmail.com>
@oscarlehuu
oscarlehuu merged commit 3d0a807 into main Jul 30, 2026
5 checks passed
@oscarlehuu
oscarlehuu deleted the fix/managed-node-tools-arch-scoping branch July 30, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Managed node-tools npm prefix is not arch-scoped — one x64 run permanently breaks all ACP adapters on arm64

1 participant