@mariozechner/pi-coding-agent 0.23.2 → 0.23.4

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/README.md +89 -148
  3. package/dist/core/agent-session.d.ts +3 -1
  4. package/dist/core/agent-session.d.ts.map +1 -1
  5. package/dist/core/agent-session.js +27 -6
  6. package/dist/core/agent-session.js.map +1 -1
  7. package/dist/core/custom-tools/loader.d.ts.map +1 -1
  8. package/dist/core/custom-tools/loader.js +4 -2
  9. package/dist/core/custom-tools/loader.js.map +1 -1
  10. package/dist/core/hooks/loader.d.ts.map +1 -1
  11. package/dist/core/hooks/loader.js +29 -3
  12. package/dist/core/hooks/loader.js.map +1 -1
  13. package/dist/core/hooks/types.d.ts +2 -1
  14. package/dist/core/hooks/types.d.ts.map +1 -1
  15. package/dist/core/hooks/types.js.map +1 -1
  16. package/dist/core/system-prompt.d.ts.map +1 -1
  17. package/dist/core/system-prompt.js +3 -3
  18. package/dist/core/system-prompt.js.map +1 -1
  19. package/dist/modes/interactive/components/diff.d.ts +12 -0
  20. package/dist/modes/interactive/components/diff.d.ts.map +1 -0
  21. package/dist/modes/interactive/components/diff.js +133 -0
  22. package/dist/modes/interactive/components/diff.js.map +1 -0
  23. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  24. package/dist/modes/interactive/components/tool-execution.js +26 -20
  25. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  26. package/dist/modes/interactive/theme/dark.json +9 -9
  27. package/dist/modes/interactive/theme/light.json +9 -9
  28. package/dist/modes/interactive/theme/theme.d.ts +10 -0
  29. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  30. package/dist/modes/interactive/theme/theme.js +131 -3
  31. package/dist/modes/interactive/theme/theme.js.map +1 -1
  32. package/docs/custom-tools.md +19 -1
  33. package/docs/hooks.md +39 -19
  34. package/docs/rpc.md +14 -0
  35. package/docs/skills.md +148 -52
  36. package/docs/theme.md +23 -21
  37. package/package.json +6 -6
  38. package/docs/compaction-new.md +0 -387
  39. package/docs/compaction-strategies.ts +0 -502
  40. package/docs/compaction.md +0 -519
  41. package/docs/gemini.md +0 -255
  42. package/docs/truncation.md +0 -235
  43. package/docs/undercompaction.md +0 -313
package/CHANGELOG.md CHANGED
@@ -2,6 +2,46 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.23.4] - 2025-12-18
6
+
7
+ ### Added
8
+
9
+ - **Syntax highlighting**: Added syntax highlighting for markdown code blocks, read tool output, and write tool content. Uses cli-highlight with theme-aware color mapping and VS Code-style syntax colors. ([#214](https://github.com/badlogic/pi-mono/pull/214) by [@svkozak](https://github.com/svkozak))
10
+
11
+ - **Intra-line diff highlighting**: Edit tool now shows word-level changes with inverse highlighting when a single line is modified. Multi-line changes show all removed lines first, then all added lines.
12
+
13
+ ### Fixed
14
+
15
+ - **Gemini tool result format**: Fixed tool result format for Gemini 3 Flash Preview which strictly requires `{ output: value }` for success and `{ error: value }` for errors. Previous format using `{ result, isError }` was rejected by newer Gemini models. ([#213](https://github.com/badlogic/pi-mono/issues/213), [#220](https://github.com/badlogic/pi-mono/pull/220))
16
+
17
+ - **Google baseUrl configuration**: Google provider now respects `baseUrl` configuration for custom endpoints or API proxies. ([#216](https://github.com/badlogic/pi-mono/issues/216), [#221](https://github.com/badlogic/pi-mono/pull/221) by [@theBucky](https://github.com/theBucky))
18
+
19
+ - **Google provider FinishReason**: Added handling for new `IMAGE_RECITATION` and `IMAGE_OTHER` finish reasons. Upgraded @google/genai to 1.34.0.
20
+
21
+ ## [0.23.3] - 2025-12-17
22
+
23
+ ### Fixed
24
+
25
+ - Check for compaction before submitting user prompt, not just after agent turn ends. This catches cases where user aborts mid-response and context is already near the limit.
26
+
27
+ ### Changed
28
+
29
+ - Improved system prompt documentation section with clearer pointers to specific doc files for custom models, themes, skills, hooks, custom tools, and RPC.
30
+
31
+ - Cleaned up documentation:
32
+ - `theme.md`: Added missing color tokens (`thinkingXhigh`, `bashMode`)
33
+ - `skills.md`: Rewrote with better framing and examples
34
+ - `hooks.md`: Fixed timeout/error handling docs, added import aliases section
35
+ - `custom-tools.md`: Added intro with use cases and comparison table
36
+ - `rpc.md`: Added missing `hook_error` event documentation
37
+ - `README.md`: Complete settings table, condensed philosophy section, standardized OAuth docs
38
+
39
+ - Hooks loader now supports same import aliases as custom tools (`@sinclair/typebox`, `@mariozechner/pi-ai`, `@mariozechner/pi-tui`, `@mariozechner/pi-coding-agent`).
40
+
41
+ ### Breaking Changes
42
+
43
+ - **Hooks**: `turn_end` event's `toolResults` type changed from `AppMessage[]` to `ToolResultMessage[]`. If you have hooks that handle `turn_end` events and explicitly type the results, update your type annotations.
44
+
5
45
  ## [0.23.2] - 2025-12-17
6
46
 
7
47
  ### Fixed
package/README.md CHANGED
@@ -9,7 +9,7 @@ Works on Linux, macOS, and Windows (requires bash; see [Windows Setup](#windows-
9
9
  - [Getting Started](#getting-started)
10
10
  - [Installation](#installation)
11
11
  - [Windows Setup](#windows-setup)
12
- - [API Keys](#api-keys)
12
+ - [API Keys & OAuth](#api-keys--oauth)
13
13
  - [Quick Start](#quick-start)
14
14
  - [Usage](#usage)
15
15
  - [Slash Commands](#slash-commands)
@@ -101,13 +101,13 @@ For most users, [Git for Windows](https://git-scm.com/download/win) is sufficien
101
101
  }
102
102
  ```
103
103
 
104
- ### API Keys
104
+ ### API Keys & OAuth
105
105
 
106
106
  Set the environment variable for your provider:
107
107
 
108
108
  | Provider | Environment Variable |
109
109
  |----------|---------------------|
110
- | Anthropic | `ANTHROPIC_API_KEY` or `ANTHROPIC_OAUTH_TOKEN` |
110
+ | Anthropic | `ANTHROPIC_API_KEY` |
111
111
  | OpenAI | `OPENAI_API_KEY` |
112
112
  | Google | `GEMINI_API_KEY` |
113
113
  | Mistral | `MISTRAL_API_KEY` |
@@ -117,31 +117,27 @@ Set the environment variable for your provider:
117
117
  | OpenRouter | `OPENROUTER_API_KEY` |
118
118
  | ZAI | `ZAI_API_KEY` |
119
119
 
120
- The `/model` command only shows models for providers with configured API keys.
121
-
122
- **OAuth (Claude Pro/Max subscribers):**
120
+ **Anthropic OAuth (Claude Pro/Max):**
123
121
 
124
122
  ```bash
125
123
  pi
126
124
  /login # Select "Anthropic (Claude Pro/Max)", authorize in browser
127
125
  ```
128
126
 
129
- Tokens stored in `~/.pi/agent/oauth.json` (mode 0600). Use `/logout` to clear.
127
+ Tokens stored in `~/.pi/agent/oauth.json`. Use `/logout` to clear.
130
128
 
131
- **GitHub Copilot:**
129
+ **GitHub Copilot OAuth:**
132
130
 
133
131
  ```bash
134
132
  pi
135
133
  /login # Select "GitHub Copilot", authorize in browser
136
134
  ```
137
135
 
138
- During login, you'll be prompted for an enterprise domain. Press Enter to use github.com, or enter your GitHub Enterprise Server domain (e.g., `github.mycompany.com`). All models are automatically enabled after login.
139
-
140
- If you get "The requested model is not supported" error, enable the model manually in VS Code: open Copilot Chat, click the model selector, select the model, and click "Enable".
136
+ Press Enter to use github.com, or enter your GitHub Enterprise Server domain (e.g., `github.mycompany.com`).
141
137
 
142
- For enterprise users, check with your organization's Copilot administrator for model availability.
138
+ If you get "The requested model is not supported" error, enable the model in VS Code: Copilot Chat model selector → select model → "Enable".
143
139
 
144
- Tokens stored in `~/.pi/agent/oauth.json` (mode 0600). Use `/logout` to clear.
140
+ Tokens stored in `~/.pi/agent/oauth.json`. Use `/logout` to clear.
145
141
 
146
142
  ### Quick Start
147
143
 
@@ -303,6 +299,8 @@ When disabled, neither case triggers automatic compaction (use `/compact` manual
303
299
  3. Summary replaces old messages as "context handoff"
304
300
  4. Previous compaction summaries chain into new ones
305
301
 
302
+ Compaction does not create a new session, but continues the existing one, with a marker in the `.jsonl` file that encodes the compaction point.
303
+
306
304
  **Configuration** (`~/.pi/agent/settings.json`):
307
305
 
308
306
  ```json
@@ -315,7 +313,7 @@ When disabled, neither case triggers automatic compaction (use `/compact` manual
315
313
  }
316
314
  ```
317
315
 
318
- > **Note:** Compaction is lossy. The agent loses full conversation access afterward. Size tasks to avoid context limits when possible. For critical context, ask the agent to write a summary to a file, then start a new session with that file. The full session history is preserved in the JSONL file; use `/branch` to revisit any previous point.
316
+ > **Note:** Compaction is lossy. The agent loses full conversation access afterward. Size tasks to avoid context limits when possible. For critical context, ask the agent to write a summary to a file, iterate on it until it covers everything, then start a new session with that file. The full session history is preserved in the JSONL file; use `/branch` to revisit any previous point.
319
317
 
320
318
  ### Branching
321
319
 
@@ -427,6 +425,8 @@ Add custom models (Ollama, vLLM, LM Studio, etc.) via `~/.pi/agent/models.json`:
427
425
  4. Saved default from settings
428
426
  5. First available model with valid API key
429
427
 
428
+ > pi can help you create custom provider and model configurations.
429
+
430
430
  ### Themes
431
431
 
432
432
  Built-in themes: `dark` (default), `light`. Auto-detected on first run.
@@ -444,7 +444,7 @@ cp $(npm root -g)/@mariozechner/pi-coding-agent/dist/theme/dark.json ~/.pi/agent
444
444
 
445
445
  Select with `/theme`, then edit the file. Changes apply on save.
446
446
 
447
- See [Theme Documentation](docs/theme.md) for all 44 color tokens.
447
+ > See [Theme Documentation](docs/theme.md) on how to create custom themes in detail. Pi can help you create a new one.
448
448
 
449
449
  **VS Code terminal fix:** Set `terminal.integrated.minimumContrastRatio` to `1` for accurate colors.
450
450
 
@@ -488,66 +488,49 @@ Usage: `/component Button "onClick handler" "disabled support"`
488
488
 
489
489
  ### Skills
490
490
 
491
- Skills are instruction files loaded on-demand when tasks match their descriptions. Compatible with Claude Code and Codex CLI skill formats.
491
+ Skills are self-contained capability packages that the agent loads on-demand. A skill provides specialized workflows, setup instructions, helper scripts, and reference documentation for specific tasks. Skills are loaded when the agent decides a task matches the description, or when you explicitly ask to use one.
492
+
493
+ **Example use cases:**
494
+ - Web search and content extraction (Brave Search API)
495
+ - Browser automation via Chrome DevTools Protocol
496
+ - Google Calendar, Gmail, Drive integration
497
+ - PDF/DOCX processing and creation
498
+ - Speech-to-text transcription
499
+ - YouTube transcript extraction
492
500
 
493
501
  **Skill locations:**
494
- - Pi user: `~/.pi/agent/skills/**/SKILL.md` (recursive, colon-separated names)
495
- - Pi project: `.pi/skills/**/SKILL.md` (recursive, colon-separated names)
496
- - Claude Code user: `~/.claude/skills/*/SKILL.md` (one level)
497
- - Claude Code project: `.claude/skills/*/SKILL.md` (one level)
502
+ - Pi user: `~/.pi/agent/skills/**/SKILL.md` (recursive)
503
+ - Pi project: `.pi/skills/**/SKILL.md` (recursive)
504
+ - Claude Code: `~/.claude/skills/*/SKILL.md` and `.claude/skills/*/SKILL.md`
498
505
  - Codex CLI: `~/.codex/skills/**/SKILL.md` (recursive)
499
506
 
500
- Later locations win on name collisions (Pi skills override Claude/Codex).
501
-
502
- Pi skills in subdirectories use colon-separated names: `~/.pi/agent/skills/db/migrate/SKILL.md` → `db:migrate`
503
-
504
507
  **Format:**
505
508
 
506
509
  ```markdown
507
510
  ---
508
- description: Extract text and tables from PDF files
511
+ description: Web search via Brave Search API. Use for documentation, facts, or web content.
509
512
  ---
510
513
 
511
- # PDF Processing
514
+ # Brave Search
512
515
 
513
- Use `pdftotext` for plain text extraction.
514
- For tables, use `tabula-py`.
516
+ ## Setup
517
+ \`\`\`bash
518
+ cd {baseDir} && npm install
519
+ \`\`\`
515
520
 
516
- Helper scripts: {baseDir}/scripts/
517
- ```
518
-
519
- - `description`: Required. Shown in system prompt for agent to decide when to load.
520
- - `name`: Optional. Overrides directory name.
521
- - `{baseDir}`: Placeholder for the skill's directory. Agent substitutes it when following instructions.
522
-
523
- **How it works:**
524
-
525
- Skills are listed in the system prompt with descriptions:
526
-
527
- ```
528
- <available_skills>
529
- - pdf-extract: Extract text and tables from PDF files
530
- File: ~/.pi/agent/skills/pdf-extract/SKILL.md
531
- Base directory: ~/.pi/agent/skills/pdf-extract
532
- </available_skills>
521
+ ## Usage
522
+ \`\`\`bash
523
+ {baseDir}/search.js "query" # Basic search
524
+ {baseDir}/search.js "query" --content # Include page content
525
+ \`\`\`
533
526
  ```
534
527
 
535
- Agent uses `read` tool to load full instructions when needed.
528
+ - `description`: Required. Determines when the skill is loaded.
529
+ - `{baseDir}`: Placeholder for the skill's directory.
536
530
 
537
- **Disable skills:**
531
+ **Disable skills:** `pi --no-skills` or set `skills.enabled: false` in settings.
538
532
 
539
- CLI: `pi --no-skills`
540
-
541
- Settings (`~/.pi/agent/settings.json`):
542
- ```json
543
- {
544
- "skills": {
545
- "enabled": false
546
- }
547
- }
548
- ```
549
-
550
- See [docs/skills.md](docs/skills.md) for details.
533
+ > See [docs/skills.md](docs/skills.md) for details, examples, and links to skill repositories. pi can help you create new skills.
551
534
 
552
535
  ### Hooks
553
536
 
@@ -557,7 +540,7 @@ Hooks are TypeScript modules that extend pi's behavior by subscribing to lifecyc
557
540
  - **Checkpoint code state** (git stash at each turn, restore on `/branch`)
558
541
  - **Protect paths** (block writes to `.env`, `node_modules/`, etc.)
559
542
  - **Modify tool output** (filter or transform results before the LLM sees them)
560
- - **Inject messages from external sources** (file watchers, webhooks, CI systems)
543
+ - **Inject messages from external sources to wake up the agent** (file watchers, webhooks, CI systems)
561
544
 
562
545
  **Hook locations:**
563
546
  - Global: `~/.pi/agent/hooks/*.ts`
@@ -599,13 +582,13 @@ export default function (pi: HookAPI) {
599
582
  }
600
583
  ```
601
584
 
602
- See [Hooks Documentation](docs/hooks.md) for full API reference.
585
+ > See [Hooks Documentation](docs/hooks.md) for full API reference. pi can help you create new hooks
603
586
 
604
- See [examples/hooks/](examples/hooks/) for working examples including permission gates, git checkpointing, and path protection.
587
+ > See [examples/hooks/](examples/hooks/) for working examples including permission gates, git checkpointing, and path protection.
605
588
 
606
589
  ### Custom Tools
607
590
 
608
- Custom tools extend pi with new capabilities beyond the built-in tools. They are TypeScript modules that define tools with optional custom TUI rendering.
591
+ Custom tools let you extend the built-in toolset (read, write, edit, bash, ...) and are called by the LLM directly. They are TypeScript modules that define tools with optional custom TUI integration for getting user input and custom tool call and result rendering.
609
592
 
610
593
  **Tool locations:**
611
594
  - Global: `~/.pi/agent/tools/*.ts`
@@ -644,12 +627,11 @@ export default factory;
644
627
  - Custom rendering via `renderCall()` and `renderResult()` methods
645
628
  - Streaming results via `onUpdate` callback
646
629
  - Abort handling via `signal` parameter
647
- - Cleanup via `dispose()` method
648
630
  - Multiple tools from one factory (return an array)
649
631
 
650
- See [Custom Tools Documentation](docs/custom-tools.md) for the full API reference, TUI component guide, and examples.
632
+ > See [Custom Tools Documentation](docs/custom-tools.md) for the full API reference, TUI component guide, and examples. pi can help you create custom tools.
651
633
 
652
- See [examples/custom-tools/](examples/custom-tools/) for working examples including a todo list with session state management and a question tool with UI interaction.
634
+ > See [examples/custom-tools/](examples/custom-tools/) for working examples including a todo list with session state management and a question tool with UI interaction.
653
635
 
654
636
  ### Settings File
655
637
 
@@ -658,8 +640,13 @@ See [examples/custom-tools/](examples/custom-tools/) for working examples includ
658
640
  ```json
659
641
  {
660
642
  "theme": "dark",
661
- "shellPath": "C:\\path\\to\\bash.exe",
643
+ "defaultProvider": "anthropic",
644
+ "defaultModel": "claude-sonnet-4-20250514",
645
+ "defaultThinkingLevel": "medium",
662
646
  "queueMode": "one-at-a-time",
647
+ "shellPath": "C:\\path\\to\\bash.exe",
648
+ "hideThinkingBlock": false,
649
+ "collapseChangelog": false,
663
650
  "compaction": {
664
651
  "enabled": true,
665
652
  "reserveTokens": 16384,
@@ -675,17 +662,34 @@ See [examples/custom-tools/](examples/custom-tools/) for working examples includ
675
662
  },
676
663
  "terminal": {
677
664
  "showImages": true
678
- }
665
+ },
666
+ "hooks": ["/path/to/hook.ts"],
667
+ "hookTimeout": 30000,
668
+ "customTools": ["/path/to/tool.ts"]
679
669
  }
680
670
  ```
681
671
 
682
- **Retry settings:**
683
- - `enabled`: Auto-retry on transient errors (overloaded, rate limit, 5xx). Default: `true`
684
- - `maxRetries`: Maximum retry attempts. Default: `3`
685
- - `baseDelayMs`: Base delay for exponential backoff (2s, 4s, 8s). Default: `2000`
686
-
687
- **Terminal settings:**
688
- - `showImages`: Render images inline in supported terminals. Default: `true`
672
+ | Setting | Description | Default |
673
+ |---------|-------------|---------|
674
+ | `theme` | Color theme name | auto-detected |
675
+ | `defaultProvider` | Default model provider | - |
676
+ | `defaultModel` | Default model ID | - |
677
+ | `defaultThinkingLevel` | Thinking level: `off`, `minimal`, `low`, `medium`, `high`, `xhigh` | - |
678
+ | `queueMode` | Message queue mode: `all` or `one-at-a-time` | `one-at-a-time` |
679
+ | `shellPath` | Custom bash path (Windows) | auto-detected |
680
+ | `hideThinkingBlock` | Hide thinking blocks in output (Ctrl+T to toggle) | `false` |
681
+ | `collapseChangelog` | Show condensed changelog after update | `false` |
682
+ | `compaction.enabled` | Enable auto-compaction | `true` |
683
+ | `compaction.reserveTokens` | Tokens to reserve before compaction triggers | `16384` |
684
+ | `compaction.keepRecentTokens` | Recent tokens to keep after compaction | `20000` |
685
+ | `skills.enabled` | Enable skills discovery | `true` |
686
+ | `retry.enabled` | Auto-retry on transient errors | `true` |
687
+ | `retry.maxRetries` | Maximum retry attempts | `3` |
688
+ | `retry.baseDelayMs` | Base delay for exponential backoff | `2000` |
689
+ | `terminal.showImages` | Render images inline (supported terminals) | `true` |
690
+ | `hooks` | Additional hook file paths | `[]` |
691
+ | `hookTimeout` | Timeout for hook operations (ms) | `30000` |
692
+ | `customTools` | Additional custom tool file paths | `[]` |
689
693
 
690
694
  ---
691
695
 
@@ -793,32 +797,7 @@ Available via `--tools` flag:
793
797
 
794
798
  Example: `--tools read,grep,find,ls` for code review without modification.
795
799
 
796
- ### Custom Tools
797
-
798
- Pi relies on CLI tools invoked via bash rather than MCP. Create a tool with a README:
799
-
800
- `~/agent-tools/screenshot/README.md`:
801
- ```markdown
802
- # Screenshot Tool
803
- Takes a screenshot of your main display.
804
-
805
- ## Usage
806
- ```bash
807
- screenshot.sh
808
- ```
809
- Returns the path to the saved PNG.
810
- ```
811
-
812
- `~/agent-tools/screenshot/screenshot.sh`:
813
- ```bash
814
- #!/bin/bash
815
- screencapture -x /tmp/screenshot-$(date +%s).png
816
- ls -t /tmp/screenshot-*.png | head -1
817
- ```
818
-
819
- Usage: "Read ~/agent-tools/screenshot/README.md and take a screenshot"
820
-
821
- Reference tool READMEs in `AGENTS.md` to make them automatically available.
800
+ For adding new tools, see [Custom Tools](#custom-tools) in the Configuration section.
822
801
 
823
802
  ---
824
803
 
@@ -855,59 +834,21 @@ Works with both session files and streaming event logs from `--mode json`.
855
834
 
856
835
  ## Philosophy
857
836
 
858
- Pi is opinionated about what it won't do. These are intentional design decisions.
859
-
860
- ### No MCP
837
+ Pi is opinionated about what it won't do. These are intentional design decisions to minimize context bloat and avoid anti-patterns.
861
838
 
862
- Pi does not support MCP (Model Context Protocol). Instead, it relies on four core tools (read, write, edit, bash) and assumes the agent can invoke CLI tools or write them as needed.
863
-
864
- CLI tools are simpler: any executable with a README works. No protocol overhead, no server management. The agent reads the README and uses bash.
865
-
866
- See: [What if you don't need MCP?](https://mariozechner.at/posts/2025-11-02-what-if-you-dont-need-mcp/)
867
-
868
- ### No Sub-Agents
869
-
870
- If the agent needs to delegate, it can spawn `pi` via bash or write a custom tool. Built-in sub-agents transfer context poorly; information gets lost or misrepresented. For parallel work, run multiple `pi` sessions in different terminals.
871
-
872
- ### No Built-in To-Dos
873
-
874
- To-do lists confuse models more than they help. For task tracking, use a file:
875
-
876
- ```markdown
877
- # TODO.md
878
- - [x] Implement authentication
879
- - [ ] Write API docs
880
- ```
881
-
882
- ### No Planning Mode
883
-
884
- Tell the agent to think through problems without modifying files. For persistent plans, write to a file:
885
-
886
- ```markdown
887
- # PLAN.md
888
- ## Goal
889
- Refactor auth to support OAuth
890
- ## Current Step
891
- Working on authorization endpoints
892
- ```
839
+ **No MCP.** Build CLI tools with READMEs (see [Skills](#skills)). The agent reads them on demand. [Would you like to know more?](https://mariozechner.at/posts/2025-11-02-what-if-you-dont-need-mcp/)
893
840
 
894
- ### No Permission System (YOLO Mode)
841
+ **No sub-agents.** Spawn pi instances via tmux, or build a task tool with [custom tools](#custom-tools). Full observability and steerability.
895
842
 
896
- Pi runs with full filesystem access and no permission prompts. Why:
897
- - Permission systems add friction while being easily circumvented
898
- - Pre-checking for "dangerous" patterns causes latency and false positives
843
+ **No permission popups.** Security theater. Run in a container or build your own with [Hooks](#hooks).
899
844
 
900
- **Risks:**
901
- - Can read, write, delete anything with your user privileges
902
- - Prompt injection via files or command output can influence behavior
845
+ **No plan mode.** Gather context in one session, write plans to file, start fresh for implementation.
903
846
 
904
- **Mitigations:**
905
- - Run in a container if uncomfortable
906
- - Don't use on systems with sensitive data you can't afford to lose
847
+ **No built-in to-dos.** They confuse models. Use a TODO.md file, or [build your own](examples/custom-tools/todo.ts) with [custom tools](#custom-tools).
907
848
 
908
- ### No Background Bash
849
+ **No background bash.** Use tmux. Full observability, direct interaction.
909
850
 
910
- Use `tmux` or similar. Bonus: you can watch the agent interact with CLIs and intervene if needed.
851
+ Read the [blog post](https://mariozechner.at/posts/2025-11-30-pi-coding-agent/) for the full rationale.
911
852
 
912
853
  ---
913
854
 
@@ -942,7 +883,7 @@ Never use `__dirname` directly for package assets.
942
883
 
943
884
  ### Debug Command
944
885
 
945
- `/debug` (hidden) writes rendered lines with ANSI codes to `~/.pi/agent/pi-debug.log` for TUI debugging.
886
+ `/debug` (hidden) writes rendered lines with ANSI codes to `~/.pi/agent/pi-debug.log` for TUI debugging, as well as the last set of messages that were sent to the LLM.
946
887
 
947
888
  For architecture and contribution guidelines, see [DEVELOPMENT.md](./DEVELOPMENT.md).
948
889
 
@@ -126,6 +126,8 @@ export declare class AgentSession {
126
126
  private _resolveRetry;
127
127
  /** Extract text content from a message */
128
128
  private _getUserMessageText;
129
+ /** Find the last assistant message in agent state (including aborted ones) */
130
+ private _findLastAssistantMessage;
129
131
  private _emitHookEvent;
130
132
  /**
131
133
  * Subscribe to agent events.
@@ -253,7 +255,7 @@ export declare class AgentSession {
253
255
  * Cancel in-progress compaction (manual or auto).
254
256
  */
255
257
  abortCompaction(): void;
256
- private _handleAgentEndCompaction;
258
+ private _checkCompaction;
257
259
  private _runAutoCompaction;
258
260
  /**
259
261
  * Toggle auto-compaction setting.