Skip to content

fix: resolve Pi CLI via process.argv[1] for Nix and non-standard installs#520

Open
chenxin-yan wants to merge 1 commit into
HenryLach:mainfrom
chenxin-yan:fix/nix-pi-cli-resolution
Open

fix: resolve Pi CLI via process.argv[1] for Nix and non-standard installs#520
chenxin-yan wants to merge 1 commit into
HenryLach:mainfrom
chenxin-yan:fix/nix-pi-cli-resolution

Conversation

@chenxin-yan
Copy link
Copy Markdown

@chenxin-yan chenxin-yan commented Apr 27, 2026

Fixes #519

Problem

resolvePiCliPath() fails to find the Pi CLI when pi is installed via Nix. Nix places packages in the Nix store (/nix/store/<hash>-pi-coding-agent-<ver>/), not in any npm global prefix, so none of the existing resolution candidates match. Worker agents never spawn and tasks fail immediately.

Fix

When taskplane runs as a Pi extension, the current process is already node dist/cli.js — so process.argv[1] is the exact entrypoint we need. Adding it as the first candidate in resolvePiCliPath() solves the problem with zero subprocess overhead and covers any non-standard install (Nix, custom node wrappers, symlinked binaries, etc.).

This technique is already used in resolveTaskplanePackageFile() (candidate 8) to locate taskplane's own package files — this PR applies it consistently to resolvePiCliPath() as well.

Also adds ~/.nix-profile and /run/current-system/sw as static fallbacks for the edge case where process.argv[1] is a shell wrapper rather than cli.js directly.

Changes

  • extensions/taskplane/path-resolver.ts: add process.argv[1] as candidate 1 in resolvePiCliPath(); add Nix static paths; update doc comment with new resolution order

Testing

Verified the reproduction case: Pi installed via pkgs.pi-coding-agent (nixpkgs, nix-darwin), taskplane loaded via pi -e npm:taskplane. Before this fix: worker spawn fails immediately. After: process.argv[1] resolves to the Nix store cli.js path and workers launch correctly.


Note: this PR was generated with AI assistance. The bug was identified through code analysis and the fix was written by an AI agent. Please review carefully — in particular, verify that process.argv[1] is always dist/cli.js (not a shell wrapper) in the Pi execution contexts you care about. The static Nix fallbacks are a safety net for any cases where it isn't.

…alls

When taskplane runs as a Pi extension, the current process is already
'node dist/cli.js' — so process.argv[1] is exactly the CLI entrypoint
we need to spawn worker agents. The previous implementation only checked
npm global roots and static paths, none of which cover Nix (where pi lives
in the Nix store, not in any npm prefix).

The process.argv[1] candidate:
- Is always correct when running inside Pi (it IS the file we're looking for)
- Requires no subprocess overhead unlike npm root -g
- Covers any non-standard install: Nix, custom node wrappers, symlinked bins
- Is consistent with how resolveTaskplanePackageFile() already uses
  process.argv[1] to locate taskplane's own package files

Also adds ~/.nix-profile and /run/current-system/sw as static Nix fallbacks
for cases where process.argv[1] is a shell wrapper rather than cli.js directly.
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.

Worker agent spawn fails when Pi is installed via Nix

1 participant