Expand description
pi install/remove/update/list/config subcommand router.
Ports .references/pi/packages/coding-agent/src/package-manager-cli.ts into
a thin parser + dispatcher. The parser is pure and infallible; the
dispatcher maps parsed options onto exit codes and verbatim status/error
strings, driving all side effects through an injected PackageHandler
trait so tests never spawn real subprocesses or touch the network.
§Exit code map (matches the TypeScript reference)
| path | exit | notes |
|---|---|---|
--help | 0 | prints usage |
| unknown option / missing val | 1 | verbatim error + usage hint |
| install/remove without source | 1 | Missing {cmd} source. + usage |
| untrusted local install/remove | 1 | Project is not trusted. … |
| install success | 0 | Installed {source} |
| remove no-match | 1 | No matching package found for {src} |
| remove success | 0 | Removed {source} |
| list (any) | 0 | formatted list |
| update models error | 1 | |
| update extensions error | 1 | |
| update self error | 1 | |
| update self success | 0 | win32: drain_quirk flag set |
| update self already-latest | 0 | no-op |
Structs§
- Listed
Package - One configured package row reported by
PackageHandler::list. - Package
Command Options - Parsed
pi <subcommand> …options. - Package
Outcome - Outcome of dispatching one subcommand.
Enums§
- Dispatch
Platform - Platform-specific dispatch behavior.
- Extensions
Skipped Notice - Whether the default self-update should explain that extensions were skipped.
- Listed
Scope - Scope of a configured package.
- Package
Command - Known subcommand discriminant.
- Update
Target - Update target resolution (the TS
UpdateTargetunion).
Traits§
- Package
Handler - Side-effect surface injected by the caller.
- Package
Output - Output sink for status/error lines. Implementations capture into a buffer
(tests) or write to stdout/stderr (production, via
ProductOutput).
Functions§
- config_
command_ usage - Usage string for the
configcommand. - format_
config_ command_ help - Render the
confighelp block (printConfigCommandHelp). - format_
package_ command_ help - Render the per-subcommand help block (
printPackageCommandHelp). - handle_
config_ command - Route
pi config …if recognized. ReturnsNonewhenargv[0]is notconfig. - handle_
package_ command - Mirrors the verbatim status/error strings and exit-code mapping of
handlePackageCommand(package-manager-cli.ts:676-887). - is_
config_ command - Whether
argv[0]is theconfigcommand. - package_
command_ kind - Whether
argv[0]is a recognized package subcommand. - package_
command_ usage - Usage string for one subcommand.
- parse_
package_ command - Parse
pi <subcommand> [rest…].