§ 02 Docs commands · flags · workspaces

Reads package.json. Writes node_modules.

phi follows the contracts every Node project already obeys. Drop it in alongside npm/yarn/pnpm — separate phi.lock, no conflict.

Quick start

In a project with a package.json:

phi install

phi resolves the full transitive tree, scans every package, and either installs everything (if all safe), prompts on review-flagged ones, or aborts on a blocked one. Outputs phi.lock and phi-report.json.

To add a new dep:

phi install chalk@^5.0.0

Updates the dependencies field, scans, installs.

To audit without installing:

phi audit

Commands

CommandAliasesBehavior
phi initCreate package.json + .gitignore + README.md. --yes for non-interactive; --force to overwrite.
phi install [pkg…]i, aScan and install. Args added to package.json (or to devDependencies with --save-dev).
phi update [pkg…]uRe-resolve and install fresh, ignoring phi.lock.
phi remove <pkg…>rmDrop from package.json, prune from lockfile + node_modules.
phi auditResolve + scan, no extraction. Writes phi-report.json.
phi do <script> [args…]dRun a script from package.json with node_modules/.bin on PATH. Pre/post hooks honored.
phi exec <bin> [args…]xRun a binary from node_modules/.bin. Like npx, but no auto-install.
phi dev | build | start | …Direct shortcuts to phi do <name>. Available: dev, build, start, test, lint, preview, prod.
phi outdatedShow direct deps with newer versions available, color-coded by major bump.
phi why <pkg>Print every dep chain from a root that reaches <pkg>.
phi cache statTarball cache size.
phi cache cleanPrune cache. --older-than 30d default; --all wipes everything.
phi versionPrint version, commit, build date.
phi helpPrint available commands and flags.

Flags

FlagEffect
--allow-scripts a,bRun lifecycle scripts only for the named packages. Default: never run.
--frozen-lockfileRequire phi.lock to exactly cover package.json. CI mode.
--no-lockfileIgnore phi.lock and resolve fresh.
--no-advisoriesSkip OSV vulnerability database query (offline mode).
--jsonEmit phi-report.json to stdout, suppress UI. Review-flagged packages cause exit 1.
--save-dev / -DWrite to devDependencies, moving from dependencies if needed.
--save-peerWrite to peerDependencies.
--save-exact / -EPin without caret prefix.

Lockfile & cache

phi.lock is generated on every install. Format mirrors npm's package-lock.json shape with extra score and verdict fields per entry. When present and it covers package.json, phi reuses it without re-resolving.

Cache: Tarballs cache at $XDG_CACHE_HOME/phi/tarballs/ (Linux/macOS) or %LOCALAPPDATA%\phi\tarballs\ (Windows), keyed by sha512 integrity. Repeat installs are near-instant.

Workspaces

If your root package.json declares a workspaces field, phi aggregates dependencies from every workspace package, installs the union into the root node_modules/, and links each workspace into node_modules/<workspace-name> as a junction (Windows) or symlink (Unix).

{
  "workspaces": ["packages/*"]
}

Both array form and {packages: [...]} object form are supported. Sibling references ("@org/utils": "*" from inside @org/app) bypass the registry — they resolve through the link.

Private registries (.npmrc)

phi reads .npmrc from $HOME and the project root (project wins on conflict). Supported settings:

//npm.pkg.github.com/:_authToken=${GITHUB_PAT}
@my-org:registry=https://npm.pkg.github.com/

CI integration

# GitHub Actions
- run: phi install --frozen-lockfile
- run: phi audit --json > phi-report.json
- run: jq '.summary.blocked == 0 and .summary.review == 0' phi-report.json

--frozen-lockfile requires phi.lock to exactly cover package.json; non-zero exit on drift. --json emits the full scan report to stdout and exits non-zero on any blocked or review-flagged package.