pi-interactive-shell 0.8.0 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,19 @@ All notable changes to the `pi-interactive-shell` extension will be documented i
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.8.2] - 2026-02-10
8
+
9
+ ### Added
10
+ - `examples/prompts/` with three Codex CLI prompt templates: `codex-review-plan`, `codex-implement-plan`, `codex-review-impl`. Demonstrates a plan → implement → review workflow using meta-prompt generation and interactive shell overlays.
11
+ - `examples/skills/codex-cli/` skill that teaches pi Codex CLI flags, config, sandbox caveats, and interactive_shell usage patterns.
12
+ - README section documenting the workflow pipeline, installation, usage examples, and customization.
13
+
14
+ ## [0.8.1] - 2026-02-08
15
+
16
+ ### Fixed
17
+ - README: documented `handsFree.gracePeriod` tool parameter and startup grace period behavior in Auto-Exit on Quiet and Dispatch sections.
18
+ - README: added missing `handoffPreviewLines` and `handoffPreviewMaxChars` to config settings table.
19
+
7
20
  ## [0.8.0] - 2026-02-08
8
21
 
9
22
  ### Added
@@ -15,6 +28,7 @@ All notable changes to the `pi-interactive-shell` extension will be documented i
15
28
 
16
29
  ### Fixed
17
30
  - Dispatch/hands-free `autoExitOnQuiet` no longer kills sessions during startup silence; quiet timer now re-arms during grace period and applies auto-kill only after grace expires.
31
+ - README config table missing `handoffPreviewLines` and `handoffPreviewMaxChars` entries despite appearing in the JSON example.
18
32
 
19
33
  ## [0.7.1] - 2026-02-03
20
34
 
package/README.md CHANGED
@@ -115,7 +115,7 @@ Attach to review full output: interactive_shell({ attach: "calm-reef" })
115
115
 
116
116
  The notification includes a brief tail (last 5 lines) and a reattach instruction. The PTY is preserved for 5 minutes so the agent can attach to review full scrollback.
117
117
 
118
- Dispatch defaults `autoExitOnQuiet: true` — the session gets a 30s startup grace period, then is killed after output goes silent (5s by default), which signals completion for task-oriented subagents. Opt out with `handsFree: { autoExitOnQuiet: false }` for long-running processes.
118
+ Dispatch defaults `autoExitOnQuiet: true` — the session gets a 30s startup grace period, then is killed after output goes silent (5s by default), which signals completion for task-oriented subagents. Tune the grace period with `handsFree: { gracePeriod: 60000 }` or opt out entirely with `handsFree: { autoExitOnQuiet: false }`.
119
119
 
120
120
  The overlay still shows for the user, who can Ctrl+T to transfer output, Ctrl+B to background, take over by typing, or Ctrl+Q for more options.
121
121
 
@@ -161,6 +161,18 @@ interactive_shell({
161
161
  })
162
162
  ```
163
163
 
164
+ A 30s startup grace period prevents the session from being killed before the subprocess has time to produce output. Customize it per-call with `gracePeriod`:
165
+
166
+ ```typescript
167
+ interactive_shell({
168
+ command: 'pi "Run the full test suite"',
169
+ mode: "hands-free",
170
+ handsFree: { autoExitOnQuiet: true, gracePeriod: 60000 }
171
+ })
172
+ ```
173
+
174
+ The default grace period is also configurable globally via `autoExitGracePeriod` in the config file.
175
+
164
176
  For multi-turn sessions where you need back-and-forth interaction, leave it disabled (default) and use `kill: true` when done.
165
177
 
166
178
  ### Send Input
@@ -300,6 +312,8 @@ Configuration files (project overrides global):
300
312
  | `handsFreeUpdateMaxChars` | 1500 | Max chars per update |
301
313
  | `handsFreeMaxTotalChars` | 100000 | Total char budget for updates |
302
314
  | `handoffPreviewEnabled` | true | Include tail in tool result |
315
+ | `handoffPreviewLines` | 30 | Lines in tail preview (0-500) |
316
+ | `handoffPreviewMaxChars` | 2000 | Max chars in tail preview (0-50KB) |
303
317
  | `handoffSnapshotEnabled` | false | Write transcript on detach/exit |
304
318
  | `ansiReemit` | true | Preserve ANSI colors in output |
305
319
 
@@ -315,6 +329,82 @@ interactive_shell → node-pty → subprocess
315
329
 
316
330
  Full PTY. The subprocess thinks it's in a real terminal.
317
331
 
332
+ ## Example Workflow: Plan, Implement, Review
333
+
334
+ The `examples/prompts/` directory includes three prompt templates that chain together into a complete development workflow using Codex CLI. Each template instructs pi to gather context, generate a tailored meta prompt based on the [Codex prompting guide](https://developers.openai.com/cookbook/examples/gpt-5/gpt-5-2_prompting_guide.md), and launch Codex in an interactive overlay.
335
+
336
+ ### The Pipeline
337
+
338
+ ```
339
+ Write a plan
340
+
341
+ /codex-review-plan path/to/plan.md ← Codex verifies every assumption against the codebase
342
+
343
+ /codex-implement-plan path/to/plan.md ← Codex implements the reviewed plan faithfully
344
+
345
+ /codex-review-impl path/to/plan.md ← Codex reviews the diff against the plan, fixes issues
346
+ ```
347
+
348
+ ### Installing the Templates
349
+
350
+ Copy the prompt templates and Codex CLI skill to your pi config:
351
+
352
+ ```bash
353
+ # Prompt templates (slash commands)
354
+ cp ~/.pi/agent/extensions/interactive-shell/examples/prompts/*.md ~/.pi/agent/prompts/
355
+
356
+ # Codex CLI skill (teaches pi how to use codex flags, sandbox caveats, etc.)
357
+ cp -r ~/.pi/agent/extensions/interactive-shell/examples/skills/codex-cli ~/.pi/agent/skills/
358
+ ```
359
+
360
+ ### Usage
361
+
362
+ Say you have a plan at `docs/auth-redesign-plan.md`:
363
+
364
+ **Step 1: Review the plan** — Codex reads your plan, then verifies every file path, API shape, data flow, and integration point against the actual codebase. Fixes issues directly in the plan file.
365
+
366
+ ```
367
+ /codex-review-plan docs/auth-redesign-plan.md
368
+ /codex-review-plan docs/auth-redesign-plan.md pay attention to the migration steps
369
+ ```
370
+
371
+ **Step 2: Implement the plan** — Codex reads all relevant code first, then implements bottom-up: shared utilities first, then dependent modules, then integration code. No stubs, no TODOs.
372
+
373
+ ```
374
+ /codex-implement-plan docs/auth-redesign-plan.md
375
+ /codex-implement-plan docs/auth-redesign-plan.md skip test files for now
376
+ ```
377
+
378
+ **Step 3: Review the implementation** — Codex diffs the changes, reads every changed file in full (plus imports and dependents), traces code paths across file boundaries, and fixes every issue it finds. Pass the plan to verify completeness, or omit it to just review the diff.
379
+
380
+ ```
381
+ /codex-review-impl docs/auth-redesign-plan.md # review diff against plan
382
+ /codex-review-impl docs/auth-redesign-plan.md check cleanup ordering
383
+ /codex-review-impl # just review the diff, no plan
384
+ /codex-review-impl focus on error handling and race conditions
385
+ ```
386
+
387
+ ### How They Work
388
+
389
+ These templates demonstrate a "meta-prompt generation" pattern:
390
+
391
+ 1. **Pi gathers context** — reads the plan, runs git diff, fetches the Codex prompting guide
392
+ 2. **Pi generates a calibrated prompt** — tailored to the specific plan/diff, following the guide's best practices
393
+ 3. **Pi launches Codex in the overlay** — with explicit flags (`-m gpt-5.3-codex -c model_reasoning_effort="high" -a never`) and hands off control
394
+
395
+ The user watches Codex work in the overlay and can take over anytime (type to intervene, Ctrl+T to transfer output back to pi, Ctrl+Q for options).
396
+
397
+ ### Customizing
398
+
399
+ These are starting points. Fork them and adjust:
400
+
401
+ - **Model/flags** — swap `gpt-5.3-codex` for another model, change reasoning effort
402
+ - **Review criteria** — add project-specific checks (security policies, style rules)
403
+ - **Implementation rules** — change the 500-line file limit, add framework-specific patterns
404
+ - **Other agents** — adapt the pattern for Claude (`claude "prompt"`), Gemini (`gemini -i "prompt"`), or any CLI
405
+
406
+ See the [pi prompt templates docs](https://github.com/badlogic/pi-mono/) for the full `$1`, `$@` placeholder syntax.
407
+
318
408
  ## Advanced: Multi-Agent Workflows
319
409
 
320
410
  For orchestrating multi-agent chains (scout → planner → worker → reviewer) with file-based handoff and auto-continue support, see:
@@ -0,0 +1,23 @@
1
+ ---
2
+ description: Launch Codex CLI in overlay to fully implement an existing plan/spec document
3
+ ---
4
+ Read the Codex prompting guide at https://developers.openai.com/cookbook/examples/gpt-5/gpt-5-2_prompting_guide.md using fetch_content or web_search. Then read the plan at `$1`.
5
+
6
+ Analyze the plan to understand: how many files are created vs modified, whether there's a prescribed implementation order or prerequisites, what existing code is referenced, and roughly how large the implementation is.
7
+
8
+ Based on the prompting guide's best practices and the plan's content, generate a comprehensive meta prompt tailored for Codex CLI. The meta prompt should instruct Codex to:
9
+
10
+ 1. Read and internalize the full plan document. Identify every file to be created, every file to be modified, and any prerequisites or ordering constraints.
11
+ 2. Before writing any code, read all existing files that will be modified — in full, not just the sections mentioned in the plan. Also read key files they import from or that import them, to absorb the surrounding patterns, naming conventions, and architecture.
12
+ 3. If the plan specifies an implementation order or prerequisites (e.g., "extract module X before building Y"), follow that order exactly. Otherwise, implement bottom-up: shared utilities and types first, then the modules that depend on them, then integration/registration code last.
13
+ 4. Implement each piece completely. No stubs, no TODOs, no placeholder comments, no "implement this later" shortcuts. Every function body, every edge case handler, every error path described in the plan must be real code.
14
+ 5. Match existing code patterns exactly — same formatting, same import style, same error handling conventions, same naming. Read the surrounding codebase to absorb these patterns before writing. If the plan references patterns from specific files (e.g., "same pattern as X"), read those files and replicate the pattern faithfully.
15
+ 6. Keep files reasonably sized. If a file grows beyond ~500 lines, split it as the plan describes or refactor into logical sub-modules.
16
+ 7. After implementing all files, do a self-review pass: re-read the plan from top to bottom and verify every requirement, every edge case, every design decision is addressed in the code. Check for: missing imports, type mismatches, unreachable code paths, inconsistent field names between modules, and any plan requirement that was overlooked.
17
+ 8. Do NOT commit or push. Write a summary listing every file created or modified, what was implemented in each, and any plan ambiguities that required judgment calls.
18
+
19
+ The meta prompt should follow the Codex guide's structure: clear system context, explicit scope and verbosity constraints, step-by-step instructions, and expected output format. Emphasize that the plan has already been thoroughly reviewed — the job is faithful execution, not second-guessing the design.
20
+
21
+ Then launch Codex CLI in the interactive shell overlay with that meta prompt using these flags: `-m gpt-5.3-codex -c model_reasoning_effort="high" -a never`. Do NOT pass sandbox flags in interactive_shell. End your turn immediately after launching -- do not poll the session. The user will manage the overlay directly.
22
+
23
+ $@
@@ -0,0 +1,24 @@
1
+ ---
2
+ description: Launch Codex CLI in overlay to review implemented code changes (optionally against a plan)
3
+ ---
4
+ Read the Codex prompting guide at https://developers.openai.com/cookbook/examples/gpt-5/gpt-5-2_prompting_guide.md using fetch_content or web_search. Then determine the review scope:
5
+
6
+ - If `$1` looks like a file path (contains `/` or ends in `.md`): read it as the plan/spec these changes were based on. The diff scope is uncommitted changes vs HEAD, or if clean, the current branch vs main.
7
+ - Otherwise: no plan file. Diff scope is the same. Treat all of `$@` as additional review context or focus areas.
8
+
9
+ Run the appropriate git diff to identify which files changed and how many lines are involved. This context helps you generate a better-calibrated meta prompt.
10
+
11
+ Based on the prompting guide's best practices, the diff scope, and the optional plan, generate a comprehensive meta prompt tailored for Codex CLI. The meta prompt should instruct Codex to:
12
+
13
+ 1. Identify all changed files via git diff, then read every changed file in full — not just the diff hunks. For each changed file, also read the files it imports from and key files that depend on it, to understand integration points and downstream effects.
14
+ 2. If a plan/spec was provided, read it and verify the implementation is complete — every requirement addressed, no steps skipped, nothing invented beyond scope, no partial stubs left behind.
15
+ 3. Review each changed file for: bugs, logic errors, race conditions, resource leaks (timers, event listeners, file handles, unclosed connections), null/undefined hazards, off-by-one errors, error handling gaps, type mismatches, dead code, unused imports/variables/parameters, unnecessary complexity, and inconsistency with surrounding code patterns and naming conventions.
16
+ 4. Trace key code paths end-to-end across function and file boundaries — verify data flows, state transitions, error propagation, and cleanup ordering. Don't evaluate functions in isolation.
17
+ 5. Check for missing or inadequate tests, stale documentation, and missing changelog entries.
18
+ 6. Fix every issue found with direct code edits. After all fixes, write a clear summary listing what was found, what was fixed, and any remaining concerns that require human judgment.
19
+
20
+ The meta prompt should follow the Codex guide's structure: clear system context, explicit scope and verbosity constraints, step-by-step instructions, and expected output format. Emphasize thoroughness — read the actual code deeply before making judgments, question every assumption, and never rubber-stamp.
21
+
22
+ Then launch Codex CLI in the interactive shell overlay with that meta prompt using these flags: `-m gpt-5.3-codex -c model_reasoning_effort="high" -a never`. Do NOT pass sandbox flags in interactive_shell. End your turn immediately after launching -- do not poll the session. The user will manage the overlay directly.
23
+
24
+ $@
@@ -0,0 +1,19 @@
1
+ ---
2
+ description: Launch Codex CLI in overlay to review an implementation plan against the codebase
3
+ ---
4
+ Read the Codex prompting guide at https://developers.openai.com/cookbook/examples/gpt-5/gpt-5-2_prompting_guide.md using fetch_content or web_search. Then read the plan at `$1`.
5
+
6
+ Based on the prompting guide's best practices and the plan's content, generate a comprehensive meta prompt tailored for Codex CLI. The meta prompt should instruct Codex to:
7
+
8
+ 1. Read and internalize the full plan
9
+ 2. Systematically review the plan against the reference docs/links/code
10
+ 3. Verify every assumption, file path, API shape, data flow, and integration point mentioned in the plan
11
+ 4. Check that the plan's approach is logically sound, complete, and accounts for edge cases
12
+ 5. Identify any gaps, contradictions, incorrect assumptions, or missing steps
13
+ 6. Make direct edits to the plan file to fix any issues found, adding inline notes where changes were made
14
+
15
+ The meta prompt should be structured according to the Codex guide's recommendations (clear system context, explicit constraints, step-by-step instructions, expected output format).
16
+
17
+ Then launch Codex CLI in the interactive shell overlay with that meta prompt using these flags: `-m gpt-5.3-codex -c model_reasoning_effort="xhigh" -a never`. Do NOT pass sandbox flags in interactive_shell. End your turn immediately after launching -- do not poll the session. The user will manage the overlay directly.
18
+
19
+ $@
@@ -0,0 +1,86 @@
1
+ ---
2
+ name: codex-cli
3
+ description: OpenAI Codex CLI reference. Use when running codex in interactive_shell overlay or when user asks about codex CLI options.
4
+ ---
5
+
6
+ # Codex CLI (OpenAI)
7
+
8
+ ## Commands
9
+
10
+ | Command | Description |
11
+ |---------|-------------|
12
+ | `codex` | Start interactive TUI |
13
+ | `codex "prompt"` | TUI with initial prompt |
14
+ | `codex exec "prompt"` | Non-interactive (headless), streams to stdout. Supports `--output-schema <file>` for structured JSON output |
15
+ | `codex e "prompt"` | Shorthand for exec |
16
+ | `codex login` | Authenticate (OAuth, device auth, or API key) |
17
+ | `codex login status` | Show auth mode |
18
+ | `codex logout` | Remove credentials |
19
+ | `codex mcp` | Manage MCP servers |
20
+ | `codex completion` | Generate shell completions |
21
+
22
+ ## Key Flags
23
+
24
+ | Flag | Description |
25
+ |------|-------------|
26
+ | `-m, --model <model>` | Switch model (default: `gpt-5.3-codex`) |
27
+ | `-c <key=value>` | Override config.toml values (dotted paths, parsed as TOML) |
28
+ | `-p, --profile <name>` | Use config profile from config.toml |
29
+ | `-s, --sandbox <mode>` | Sandbox policy: `read-only`, `workspace-write`, `danger-full-access` |
30
+ | `-a, --ask-for-approval <policy>` | `untrusted`, `on-failure`, `on-request`, `never` |
31
+ | `--full-auto` | Alias for `-a on-request --sandbox workspace-write` |
32
+ | `--search` | Enable live web search tool |
33
+ | `-i, --image <file>` | Attach image(s) to initial prompt |
34
+ | `--add-dir <dir>` | Additional writable directories |
35
+ | `-C, --cd <dir>` | Set working root directory |
36
+ | `--no-alt-screen` | Inline mode (preserve terminal scrollback) |
37
+
38
+ ## Sandbox Modes
39
+
40
+ - `read-only` - Can only read files
41
+ - `workspace-write` - Can write to workspace
42
+ - `danger-full-access` - Full system access (use with caution)
43
+
44
+ ## Features
45
+
46
+ - **Image inputs** - Accepts screenshots and design specs
47
+ - **Code review** - Reviews changes before commit
48
+ - **Web search** - Can search for information
49
+ - **MCP integration** - Third-party tool support
50
+
51
+ ## Config
52
+
53
+ Config file: `~/.codex/config.toml`
54
+
55
+ Key config values (set in file or override with `-c`):
56
+ - `model` -- model name (e.g., `gpt-5.3-codex`)
57
+ - `model_reasoning_effort` -- `low`, `medium`, `high`, `xhigh`
58
+ - `model_reasoning_summary` -- `detailed`, `concise`, `none`
59
+ - `model_verbosity` -- `low`, `medium`, `high`
60
+ - `profile` -- default profile name
61
+ - `tool_output_token_limit` -- max tokens per tool output
62
+
63
+ Define profiles for different projects/modes with `[profiles.<name>]` sections. Override at runtime with `-p <name>` or `-c model_reasoning_effort="high"`.
64
+
65
+ ## In interactive_shell
66
+
67
+ Do NOT pass `-s` / `--sandbox` flags. Codex's `read-only` and `workspace-write` sandbox modes apply OS-level filesystem restrictions that break basic shell operations inside the PTY -- zsh can't even create temp files for here-documents, so every write attempt fails with "operation not permitted." The interactive shell overlay already provides supervision (user watches in real-time, Ctrl+Q to kill, Ctrl+T to transfer output), making Codex's sandbox redundant.
68
+
69
+ Use explicit flags to control model and behavior per-run:
70
+
71
+ ```typescript
72
+ // Interactive with prompt
73
+ interactive_shell({
74
+ command: 'codex -m gpt-5.3-codex -a never "Review this codebase for security issues"',
75
+ mode: "hands-free"
76
+ })
77
+
78
+ // Override reasoning effort for a single run
79
+ interactive_shell({
80
+ command: 'codex -m gpt-5.3-codex -c model_reasoning_effort="xhigh" -a never "Complex refactor task"',
81
+ mode: "hands-free"
82
+ })
83
+
84
+ // Headless - use bash instead
85
+ bash({ command: 'codex exec "summarize the repo"' })
86
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-interactive-shell",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
4
4
  "description": "Run AI coding agents as foreground subagents in pi TUI overlays with hands-free monitoring",
5
5
  "type": "module",
6
6
  "bin": {
@@ -18,6 +18,7 @@
18
18
  "headless-monitor.ts",
19
19
  "types.ts",
20
20
  "scripts/",
21
+ "examples/",
21
22
  "banner.png",
22
23
  "README.md",
23
24
  "SKILL.md",