Summary
Simplify pi-codex by removing the external Codex CLI/app-server runtime solution and keeping only lightweight Pi-native skills/guidance that use the active Pi model. The package should no longer spawn codex, manage broker sockets, track background Codex jobs, or require separate Codex CLI authentication.
Context
The current package was built around an out-of-band Codex CLI companion runtime. That made sense as a porting strategy, but it now overlaps with running Codex directly inside the Pi harness with gpt-5.5.
Observed problems with the current architecture:
- It creates a second Codex stack inside Pi: Pi model/tooling plus a separate
codex CLI/app-server process.
- It requires separate Codex CLI auth even when the Pi harness itself is authenticated and working.
- A
/codex:review run failed with a Codex CLI 401 Unauthorized because the external runtime had no bearer/basic auth, despite Pi itself being active.
- It ships substantial runtime machinery for broker sockets, lifecycle hooks, state files, background jobs, job result rendering, cancellation, and stop-gate behavior.
- The user intent is now simpler: keep lightweight skills/guidance and rely on the active Pi model instead of delegating to an external CLI process.
Current runtime-heavy surfaces to remove or replace include:
extension/index.ts commands and codex_ask tool registration when they only support external CLI orchestration.
scripts/codex-companion.mjs.
scripts/app-server-broker.mjs.
scripts/session-lifecycle-hook.mjs.
scripts/stop-review-gate-hook.mjs.
scripts/lib/app-server*.mjs / .d.ts.
scripts/lib/broker-*.mjs.
scripts/lib/codex.mjs.
- Runtime state/job-control/rendering code that exists only for external Codex jobs.
- Prompt templates that shell out to
node "${PI_CODEX_ROOT}/scripts/codex-companion.mjs" ....
- Skills such as
codex-cli-runtime that instruct the model to invoke the external runtime.
Decisions
- Treat this as a product simplification/refactor, not a bug fix.
- The maintained package should become Pi-native and lightweight.
- Do not require a local
codex binary for normal package use.
- Do not require separate
codex login, device auth, API-key auth, app-server readiness, or broker state.
- Prefer skills/guidance that help the active Pi model do review, adversarial review, prompt shaping, and delegation planning directly.
- Remove background-job and stop-gate features unless they can be reimplemented without the external Codex CLI runtime.
- Preserve useful review/delegation instructions where possible, but remove code paths whose primary job is to shell out to the external Codex companion.
Implementation Plan
-
Define the new lightweight surface
- Decide which package assets remain after the simplification.
- Expected retained assets are lightweight skills/guidance only, for example:
- review guidance for the active Pi model,
- adversarial review guidance,
- rescue/delegation prompt-shaping guidance,
- GPT/Codex prompting references that do not invoke external commands.
- Remove or rewrite any skill that says to call
node "${PI_CODEX_ROOT}/scripts/codex-companion.mjs" or the codex CLI.
- Remove slash-command compatibility if it depends on the external runtime; document the replacement workflow clearly.
-
Remove the external runtime package surface
- Delete
scripts/codex-companion.mjs.
- Delete
scripts/app-server-broker.mjs.
- Delete
scripts/session-lifecycle-hook.mjs and scripts/stop-review-gate-hook.mjs if no extension runtime remains.
- Delete runtime-only libraries under
scripts/lib/ that exist for app-server/broker/job orchestration.
- Delete tests that only validate external runtime behavior, or replace them with tests for the new lightweight skill/prompt content.
-
Simplify or remove the extension
- If no runtime commands/tools remain, remove
extension/index.ts and the pi.extensions entry from package.json.
- Remove
codex_ask if wait-vs-background prompting is no longer needed.
- Remove
/codex:setup, /codex:status, /codex:result, /codex:cancel, and /codex:gate if their purpose was external runtime management.
- If any slash prompts remain, make them model-only instructions and ensure they do not shell out to Node scripts or Codex CLI.
-
Update package metadata and dependencies
- Remove
typebox if no extension tool schemas remain.
- Remove
@earendil-works/pi-coding-agent from devDependencies if no TypeScript extension remains.
- Remove TypeScript scripts/configuration if no TypeScript source remains.
- Update
package.json pi metadata so it exposes only the retained lightweight assets.
- Bump the version for the breaking simplification, e.g.
0.2.0-ys.
-
Update docs
- Rewrite
README.md around the new lightweight scope.
- Remove local
codex binary, codex login, app-server, broker, background job, and external runtime setup requirements.
- Add a migration note explaining that the old external-runtime slash commands were removed because Pi already runs the active model.
- Update
CHANGELOG.md with the simplification and breaking changes.
- Keep attribution in
NOTICE as required, but avoid implying the current package still ships an external Codex CLI runtime solution.
-
Validation
Run the remaining applicable checks after the simplification:
npm install
npm run typecheck # if still present
npm test # if still present
npm audit
pi install /path/to/pi-codex
pi list
Also verify that no retained runtime/source assets instruct users or models to invoke the removed external runtime:
rg -n 'codex-companion|app-server|app server|CODEX_COMPANION|BROKER|codex login|codex app-server|PI_CODEX_DATA|PI_CODEX_ROOT' \
README.md CHANGELOG.md NOTICE package.json prompts skills extension scripts tests || true
Files Summary
| File |
Action |
Purpose |
package.json |
Edit |
Remove extension/runtime/dependencies that supported the external CLI solution; expose only lightweight Pi assets. |
README.md |
Rewrite |
Document the current lightweight skills-only package behavior and remove external Codex CLI setup. |
CHANGELOG.md |
Update |
Record the breaking simplification and migration notes. |
NOTICE |
Review/edit |
Preserve required attribution without describing the current package as an external runtime wrapper. |
extension/index.ts |
Delete or rewrite |
Remove external runtime commands/tools unless a Pi-native extension remains necessary. |
prompts/** |
Delete or rewrite |
Remove shell-out prompt templates; keep only model-only prompts if still useful. |
skills/** |
Rewrite/prune |
Keep lightweight skills; remove codex-cli-runtime or any skill that invokes the companion runtime. |
scripts/** |
Delete/prune |
Remove Codex CLI/app-server/broker/job-state companion runtime code. |
tests/** |
Delete/rewrite |
Replace external runtime tests with lightweight asset/content validation if needed. |
tsconfig.json |
Delete or update |
Remove if TypeScript extension source is deleted. |
Commit Sequence
-
refactor: remove external codex runtime
- Remove companion runtime scripts, app-server/broker code, lifecycle hooks, job state, and runtime tests.
- Remove or simplify extension commands tied to the external runtime.
-
docs: document lightweight pi-codex scope
- Rewrite README and changelog for the new skills-only package.
- Document migration from old slash commands to Pi-native skills/guidance.
Acceptance Criteria
Out of Scope
- Building a new background job runner inside Pi.
- Reimplementing external Codex CLI auth or app-server orchestration.
- Preserving backward compatibility for every
/codex:* slash command if those commands only existed to manage the external runtime.
- Publishing the package to npm.
Risks & Mitigations
-
Risk: Removing slash commands may surprise users who installed the old runtime wrapper.
Mitigation: Document the breaking change, replacement skills/workflows, and rationale in README.md and CHANGELOG.md.
-
Risk: Removing scripts/tests too aggressively could delete useful review prompt logic.
Mitigation: Preserve reusable review/adversarial review/rescue guidance in lightweight skills before deleting runtime code.
-
Risk: Pi package discovery may expect certain prompt/extension metadata.
Mitigation: Validate with pi install /path/to/pi-codex and pi list after simplifying package.json.
-
Risk: Legal attribution could be accidentally removed while pruning upstream runtime references.
Mitigation: Keep required attribution in NOTICE and LICENSE while making current package behavior clear.
Related Issues
Summary
Simplify
pi-codexby removing the external Codex CLI/app-server runtime solution and keeping only lightweight Pi-native skills/guidance that use the active Pi model. The package should no longer spawncodex, manage broker sockets, track background Codex jobs, or require separate Codex CLI authentication.Context
The current package was built around an out-of-band Codex CLI companion runtime. That made sense as a porting strategy, but it now overlaps with running Codex directly inside the Pi harness with
gpt-5.5.Observed problems with the current architecture:
codexCLI/app-server process./codex:reviewrun failed with a Codex CLI401 Unauthorizedbecause the external runtime had no bearer/basic auth, despite Pi itself being active.Current runtime-heavy surfaces to remove or replace include:
extension/index.tscommands andcodex_asktool registration when they only support external CLI orchestration.scripts/codex-companion.mjs.scripts/app-server-broker.mjs.scripts/session-lifecycle-hook.mjs.scripts/stop-review-gate-hook.mjs.scripts/lib/app-server*.mjs/.d.ts.scripts/lib/broker-*.mjs.scripts/lib/codex.mjs.node "${PI_CODEX_ROOT}/scripts/codex-companion.mjs" ....codex-cli-runtimethat instruct the model to invoke the external runtime.Decisions
codexbinary for normal package use.codex login, device auth, API-key auth, app-server readiness, or broker state.Implementation Plan
Define the new lightweight surface
node "${PI_CODEX_ROOT}/scripts/codex-companion.mjs"or thecodexCLI.Remove the external runtime package surface
scripts/codex-companion.mjs.scripts/app-server-broker.mjs.scripts/session-lifecycle-hook.mjsandscripts/stop-review-gate-hook.mjsif no extension runtime remains.scripts/lib/that exist for app-server/broker/job orchestration.Simplify or remove the extension
extension/index.tsand thepi.extensionsentry frompackage.json.codex_askif wait-vs-background prompting is no longer needed./codex:setup,/codex:status,/codex:result,/codex:cancel, and/codex:gateif their purpose was external runtime management.Update package metadata and dependencies
typeboxif no extension tool schemas remain.@earendil-works/pi-coding-agentfromdevDependenciesif no TypeScript extension remains.package.jsonpimetadata so it exposes only the retained lightweight assets.0.2.0-ys.Update docs
README.mdaround the new lightweight scope.codexbinary,codex login, app-server, broker, background job, and external runtime setup requirements.CHANGELOG.mdwith the simplification and breaking changes.NOTICEas required, but avoid implying the current package still ships an external Codex CLI runtime solution.Validation
Run the remaining applicable checks after the simplification:
Also verify that no retained runtime/source assets instruct users or models to invoke the removed external runtime:
Files Summary
package.jsonREADME.mdCHANGELOG.mdNOTICEextension/index.tsprompts/**skills/**codex-cli-runtimeor any skill that invokes the companion runtime.scripts/**tests/**tsconfig.jsonCommit Sequence
refactor: remove external codex runtimedocs: document lightweight pi-codex scopeAcceptance Criteria
codexbinary for normal use.codex login,codex login --device-auth, orcodex login --with-api-key.node "${PI_CODEX_ROOT}/scripts/codex-companion.mjs"or invoke the external Codex CLI runtime.package.jsonno longer exposes extension commands whose purpose is external runtime setup/status/result/cancel/gate management.scripts/codex-companion.mjs,scripts/app-server-broker.mjs, app-server/broker libraries, lifecycle hooks, and runtime job-state management code.README.mdis rewritten to match the current lightweight package state and does not advertise the removed external runtime solution.package.json.npm auditreports zero vulnerabilities.pi install /path/to/pi-codexsucceeds andpi listshows the simplified package.Out of Scope
/codex:*slash command if those commands only existed to manage the external runtime.Risks & Mitigations
Risk: Removing slash commands may surprise users who installed the old runtime wrapper.
Mitigation: Document the breaking change, replacement skills/workflows, and rationale in
README.mdandCHANGELOG.md.Risk: Removing scripts/tests too aggressively could delete useful review prompt logic.
Mitigation: Preserve reusable review/adversarial review/rescue guidance in lightweight skills before deleting runtime code.
Risk: Pi package discovery may expect certain prompt/extension metadata.
Mitigation: Validate with
pi install /path/to/pi-codexandpi listafter simplifyingpackage.json.Risk: Legal attribution could be accidentally removed while pruning upstream runtime references.
Mitigation: Keep required attribution in
NOTICEandLICENSEwhile making current package behavior clear.Related Issues