@averyyy/pi-coding-agent 0.87.0-piclient.2 → 0.87.1-piclient.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.
Files changed (87) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +25 -711
  3. package/dist/bundle/chunks/{anthropic-messages-MYU5ZMRF.js → anthropic-messages-J5WXPPPC.js} +1 -1
  4. package/dist/bundle/chunks/{chunk-6OYWS3W7.js → chunk-BZKWNWMI.js} +1 -1
  5. package/dist/bundle/chunks/{chunk-KEXYQWZW.js → chunk-X2F52Z34.js} +45 -29
  6. package/dist/bundle/chunks/github-copilot.js +1 -1
  7. package/dist/bundle/chunks/{openai-completions-XHML6MTL.js → openai-completions-OBX42CLD.js} +1 -1
  8. package/dist/bundle/chunks/{virtual-modules-5W7KEXM3.js → virtual-modules-WWGGM27U.js} +1 -1
  9. package/dist/bundle/cli-runtime.js +1 -1
  10. package/dist/bundle/index.js +1 -1
  11. package/dist/bundle/rpc-entry.js +1 -1
  12. package/dist/cli/args.d.ts.map +1 -1
  13. package/dist/cli/args.js +14 -4
  14. package/dist/cli/args.js.map +1 -1
  15. package/dist/core/agent-session.d.ts +2 -0
  16. package/dist/core/agent-session.d.ts.map +1 -1
  17. package/dist/core/agent-session.js +73 -3
  18. package/dist/core/agent-session.js.map +1 -1
  19. package/dist/core/compaction/compaction.d.ts +10 -3
  20. package/dist/core/compaction/compaction.d.ts.map +1 -1
  21. package/dist/core/compaction/compaction.js +82 -23
  22. package/dist/core/compaction/compaction.js.map +1 -1
  23. package/dist/core/model-resolver.d.ts.map +1 -1
  24. package/dist/core/model-resolver.js +1 -1
  25. package/dist/core/model-resolver.js.map +1 -1
  26. package/dist/core/pi-server-client.d.ts +5 -0
  27. package/dist/core/pi-server-client.d.ts.map +1 -1
  28. package/dist/core/pi-server-client.js +3 -0
  29. package/dist/core/pi-server-client.js.map +1 -1
  30. package/dist/core/pi-server-protocol.d.ts +2 -1
  31. package/dist/core/pi-server-protocol.d.ts.map +1 -1
  32. package/dist/core/pi-server-protocol.js +16 -0
  33. package/dist/core/pi-server-protocol.js.map +1 -1
  34. package/docs/cli-integration.md +106 -0
  35. package/docs/cli.md +268 -0
  36. package/docs/compaction.md +22 -22
  37. package/docs/configuration.md +45 -0
  38. package/docs/containerization.md +109 -82
  39. package/docs/custom-provider.md +132 -784
  40. package/docs/docs.json +139 -99
  41. package/docs/environment-variables.md +3 -5
  42. package/docs/extensions.md +134 -3020
  43. package/docs/how-pi-works.md +49 -0
  44. package/docs/images/interactive-mode.png +0 -0
  45. package/docs/index.md +24 -69
  46. package/docs/json.md +193 -65
  47. package/docs/keybindings.md +57 -102
  48. package/docs/llama-cpp.md +3 -3
  49. package/docs/message-types.md +261 -0
  50. package/docs/models.md +55 -565
  51. package/docs/packages.md +66 -167
  52. package/docs/prompt-templates.md +31 -68
  53. package/docs/providers.md +102 -240
  54. package/docs/quickstart.md +61 -106
  55. package/docs/rpc-commands.md +854 -0
  56. package/docs/rpc-extension-ui.md +200 -0
  57. package/docs/rpc.md +129 -1556
  58. package/docs/sdk.md +76 -1171
  59. package/docs/security.md +70 -32
  60. package/docs/session-format.md +10 -214
  61. package/docs/sessions.md +35 -141
  62. package/docs/settings.md +109 -387
  63. package/docs/shell-aliases.md +85 -5
  64. package/docs/skills.md +51 -190
  65. package/docs/slash-commands.md +60 -0
  66. package/docs/terminal-setup.md +105 -78
  67. package/docs/termux.md +74 -83
  68. package/docs/themes.md +68 -280
  69. package/docs/tmux.md +31 -39
  70. package/docs/tui.md +69 -923
  71. package/docs/usage.md +54 -272
  72. package/docs/windows.md +43 -17
  73. package/examples/README.md +13 -2
  74. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  75. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  76. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  77. package/examples/extensions/gondolin/package-lock.json +2 -2
  78. package/examples/extensions/gondolin/package.json +1 -1
  79. package/examples/extensions/sandbox/package-lock.json +2 -2
  80. package/examples/extensions/sandbox/package.json +1 -1
  81. package/examples/extensions/with-deps/package-lock.json +2 -2
  82. package/examples/extensions/with-deps/package.json +1 -1
  83. package/examples/rpc-client.ts +35 -0
  84. package/examples/rpc-extension-ui.ts +25 -5
  85. package/examples/sdk/README.md +1 -1
  86. package/package.json +8 -8
  87. package/docs/development.md +0 -90
package/docs/cli.md ADDED
@@ -0,0 +1,268 @@
1
+ <a id="cli-and-modes-reference"></a>
2
+
3
+ # Command Line
4
+
5
+ This page documents Pi's built-in command-line commands and options. Run `pi --help` or append `--help` to a command for the exact interface in your installed version. The top-level help also includes options registered by loaded extensions.
6
+
7
+ ```sh
8
+ pi [options] [--] [@files...] [messages...]
9
+ pi install <source> [options]
10
+ pi remove <source> [options]
11
+ pi uninstall <source> [options]
12
+ pi update [target] [options]
13
+ pi list
14
+ pi config [options]
15
+ pi auth <check|print-api-key|print-bearer-token> [options]
16
+ ```
17
+
18
+ <a id="modes"></a>
19
+
20
+ ## Invocation and output
21
+
22
+ ```sh
23
+ pi
24
+ pi --print "Summarize this repository"
25
+ git diff | pi --print "Review this change"
26
+ pi --mode json "Inspect this repository" > events.jsonl
27
+ ```
28
+
29
+ With terminal stdin and stdout, Pi opens the terminal UI unless `--print`, `--mode json`, or `--mode rpc` selects another interface. When either stream is redirected and neither JSON nor RPC mode is selected, Pi uses print mode. See [CLI Integration](cli-integration.md) for choosing between interactive, print, JSON, RPC, and SDK integration.
30
+
31
+ | Input | Behavior |
32
+ |---|---|
33
+ | `message` | Provide an initial prompt |
34
+ | `@path` | Include a text file or image in the first prompt |
35
+ | Piped stdin | Prepend its contents to the first prompt |
36
+ | `--` | Stop option parsing so a prompt can begin with `-` |
37
+
38
+ Pi resolves `@path` from the current working directory. The working directory also controls project configuration, resource discovery, and session grouping.
39
+
40
+ `--print` controls whether Pi runs once and exits. `--mode` selects the output interface. `--mode text` does not force one-shot execution when stdin and stdout are terminals; use `--print` for that behavior.
41
+
42
+ | Option | Behavior |
43
+ |---|---|
44
+ | `-p`, `--print` | Run the supplied prompts, write the final assistant text to stdout, then exit |
45
+ | `--mode text` | Select text output; still open the terminal UI when stdin and stdout are terminals |
46
+ | `--mode json` | Run the supplied prompts, write JSONL events to stdout, then exit |
47
+ | `--mode rpc` | Read JSONL commands from stdin and write responses and events to stdout until shutdown |
48
+ | `--export <input> [output]` | Export a session file to HTML and exit; derive the destination when `output` is omitted |
49
+
50
+ RPC mode rejects `@file` arguments. JSON and RPC modes reserve stdout for protocol records. See [JSON Event Stream](json.md) and [RPC Protocol](rpc.md).
51
+
52
+ <a id="model-options"></a>
53
+
54
+ ## Models
55
+
56
+ ```sh
57
+ pi --model sonnet:high
58
+ ```
59
+
60
+ See [Choose a Model](models.md) for model selection and [Provider Authentication](providers.md) for credentials.
61
+
62
+ - `--provider <name>`<br>
63
+ Restricts `--model` lookup to one provider.
64
+ - `--model <pattern>`<br>
65
+ Selects by exact ID or fuzzy ID/name match. It accepts `provider/id` and an optional `:<thinking>` suffix.
66
+ - `--api-key <key>`<br>
67
+ Uses a non-persistent API-key override. It requires a model selected through `--model` or `--models`.
68
+ - `--thinking <level>`<br>
69
+ Sets `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, or `max`. It overrides a `--model` suffix and is clamped to the model's capabilities.
70
+ - `--models <patterns>`<br>
71
+ Sets a comma-separated scope for startup and cycling. It accepts exact IDs, fuzzy matches, case-insensitive globs, and optional `:<thinking>` suffixes.
72
+ - `--list-models [search]`<br>
73
+ Lists available models, optionally filtered by a fuzzy search, then exits.
74
+
75
+ <a id="session-options"></a>
76
+
77
+ ## Sessions
78
+
79
+ ```sh
80
+ pi --continue
81
+ ```
82
+
83
+ See [Sessions and Context](sessions.md) for resuming, forking, naming, and storing sessions.
84
+
85
+ - `-c`, `--continue`<br>
86
+ Continues the most recent session for the current project.
87
+ - `-r`, `--resume`<br>
88
+ Opens the session selector.
89
+ - `--session <path|id>`<br>
90
+ Opens by file path, exact ID, or partial ID. Pi searches the current project first and offers to fork a cross-project match.
91
+ - `--session-id <id>`<br>
92
+ Opens the exact project session ID or creates it if absent. IDs accept letters, numbers, `.`, `_`, and `-`.
93
+ - `--fork <path|id>`<br>
94
+ Forks an existing session into a new session for the current project.
95
+ - `--session-dir <dir>`<br>
96
+ Overrides storage and lookup. It takes precedence over `PI_CODING_AGENT_SESSION_DIR` and the `sessionDir` setting.
97
+ - `--no-session`<br>
98
+ Uses an in-memory session that is not persisted.
99
+ - `-n`, `--name <name>`<br>
100
+ Sets the session display name.
101
+
102
+ Constraints:
103
+
104
+ - Session IDs must start and end with a letter or number.
105
+ - `--fork` cannot be combined with `--session`, `--continue`, `--resume`, or `--no-session`.
106
+ - `--session-id` cannot be combined with `--session`, `--continue`, or `--resume`. Combine it with `--fork` to choose the new ID.
107
+
108
+ <a id="tool-options"></a>
109
+
110
+ ## Tools
111
+
112
+ ```sh
113
+ pi --tools read,grep,find,ls --print "Review this project"
114
+ ```
115
+
116
+ See [Settings](settings.md#tools) for configuring the default tool selection.
117
+
118
+ - `-t`, `--tools <list>`<br>
119
+ Replaces the default selection with a comma-separated allowlist of built-in, extension, or custom tools.
120
+ - `-xt`, `--exclude-tools <list>`<br>
121
+ Disables comma-separated tool names after all other selection options.
122
+ - `-nbt`, `--no-builtin-tools`<br>
123
+ Disables default built-in tools while retaining extension and custom tools.
124
+ - `-nt`, `--no-tools`<br>
125
+ Starts with all built-in, extension, and custom tools disabled.
126
+
127
+ Default enabled tools are `read`, `bash`, `edit`, and `write`, unless `defaultTools` changes them.
128
+
129
+ | Built-in | Purpose |
130
+ |---|---|
131
+ | `read` | Read text files and supported images |
132
+ | `bash` | Run shell commands |
133
+ | `powershell` | Run PowerShell commands on Windows |
134
+ | `edit` | Apply exact text replacements to an existing file |
135
+ | `write` | Create or overwrite a file |
136
+ | `grep` | Search file contents |
137
+ | `find` | Find paths using glob patterns |
138
+ | `ls` | List directory contents |
139
+
140
+ <a id="resource-options"></a>
141
+
142
+ ## Resources
143
+
144
+ ```sh
145
+ pi --extension ./review.ts
146
+ ```
147
+
148
+ See [Configuration](configuration.md) for conventional directories and project trust, [Settings](settings.md#resources) for configured paths, and [Pi Packages](packages.md) for package sources.
149
+
150
+ - `-e`, `--extension <path>`<br>
151
+ Loads an extension file or directory and is repeatable.
152
+ - `-ne`, `--no-extensions`<br>
153
+ Disables discovered and configured extensions. Explicit `-e` paths still load.
154
+ - `--skill <path>`<br>
155
+ Loads a skill file or directory and is repeatable.
156
+ - `-ns`, `--no-skills`<br>
157
+ Disables discovered and configured skills. Explicit `--skill` paths still load.
158
+ - `--prompt-template <path>`<br>
159
+ Loads a prompt-template file or directory and is repeatable.
160
+ - `-np`, `--no-prompt-templates`<br>
161
+ Disables discovered and configured templates. Explicit `--prompt-template` paths still load.
162
+ - `--theme <path>`<br>
163
+ Loads a theme file or directory and is repeatable.
164
+ - `--use-theme <name[/name]>`<br>
165
+ Selects the initial interactive theme for this run.
166
+ - `--no-themes`<br>
167
+ Disables discovered and configured themes. Explicit `--theme` paths still load.
168
+ - `-nc`, `--no-context-files`<br>
169
+ Disables `AGENTS.md` and `CLAUDE.md` discovery.
170
+
171
+ Resource paths apply only to the current process. Relative paths resolve from the current working directory.
172
+
173
+ <a id="prompt-and-display-options"></a>
174
+
175
+ ## Prompts and process
176
+
177
+ ```sh
178
+ pi --append-system-prompt ./instructions.md
179
+ ```
180
+
181
+ See [Configuration](configuration.md) for saved configuration, [Security](security.md#understand-project-trust) for project trust, and [Environment Variables](environment-variables.md) for process controls.
182
+
183
+ - `--system-prompt <text|path>`<br>
184
+ Replaces the default system prompt with text or the contents of an existing file.
185
+ - `--append-system-prompt <text|path>`<br>
186
+ Appends text or an existing file to the system prompt and is repeatable.
187
+ - `--tui-mode <mode>`<br>
188
+ Uses `regular` or `fullscreen` terminal mode.
189
+ - `--verbose`<br>
190
+ Shows verbose interactive startup information, overriding `quietStartup`.
191
+ - `-a`, `--approve`<br>
192
+ Trusts project-local configuration and resources for this process.
193
+ - `-na`, `--no-approve`<br>
194
+ Ignores trust-gated project-local configuration and resources for this process.
195
+ - `--offline`<br>
196
+ Disables automatic network activity, including model catalog refreshes. Equivalent to `PI_OFFLINE=1`.
197
+ - `-h`, `--help`<br>
198
+ Shows help, including flags registered by loaded extensions, then exits.
199
+ - `-v`, `--version`<br>
200
+ Shows the Pi version, then exits.
201
+
202
+ Extensions may register additional long-form options. Unknown short options are rejected.
203
+
204
+ ## Package commands
205
+
206
+ ```sh
207
+ pi install npm:@scope/package
208
+ ```
209
+
210
+ See [Pi Packages](packages.md) for source formats, filtering, installation, and project scope.
211
+
212
+ ### Common tasks
213
+
214
+ | Task | Command |
215
+ |---|---|
216
+ | Install a package | `pi install <source>` |
217
+ | List configured packages | `pi list` |
218
+ | Remove a package and its settings entry | `pi remove <source>` |
219
+ | Configure which package resources load | `pi config` |
220
+
221
+ Add `--local` or `-l` to `install`, `remove`, `uninstall`, or `config` to use project settings instead of global settings.
222
+
223
+ ### Update Pi or packages
224
+
225
+ Running `pi update` without a target updates Pi itself.
226
+
227
+ | Task | Command |
228
+ |---|---|
229
+ | Update Pi | `pi update` |
230
+ | Update all installed packages | `pi update --extensions` |
231
+ | Update one installed package | `pi update <source>` |
232
+ | Refresh model catalogs | `pi update --models` |
233
+ | Update Pi and all installed packages | `pi update --all` |
234
+
235
+ Add `--force` to reinstall Pi when the selected update includes Pi.
236
+
237
+ ### Aliases and command options
238
+
239
+ - `pi uninstall <source>` is an alias for `pi remove <source>`.
240
+ - `pi update --self`, `pi update self`, and `pi update pi` are aliases for `pi update`.
241
+ - `pi update --extension <source>` is an alias for `pi update <source>`.
242
+ - `-a`, `--approve` trusts project-local files for one command. `-na`, `--no-approve` ignores trust-gated project-local files.
243
+ - Append `-h` or `--help` to a command for its exact usage and option constraints.
244
+
245
+ ## Credential commands
246
+
247
+ ```sh
248
+ pi auth check --provider openai --json
249
+ ```
250
+
251
+ Authentication commands require `--provider <provider>` or `--model <model>`. See [Provider Authentication](providers.md) for supported methods.
252
+
253
+ | Command | Description |
254
+ |---|---|
255
+ | `pi auth check` | Print `ready`, `not_ready`, or `invalid`; exit with status `0`, `1`, or `2`, respectively |
256
+ | `pi auth print-api-key` | Print the resolved API key |
257
+ | `pi auth print-bearer-token` | Print a resolved OAuth bearer token |
258
+
259
+ | Option | Applies to | Description |
260
+ |---|---|---|
261
+ | `--provider <provider>` | All | Resolve credentials for a provider |
262
+ | `--model <model>` | All | Resolve credentials from a model; may be combined with `--provider` |
263
+ | `--json` | `auth check` | Write the structured result as JSON |
264
+ | `--credentials` | `auth check` | Emit the resolved credential when ready |
265
+ | `--no-refresh` | `auth check` | Do not refresh expired OAuth credentials; refresh is the default |
266
+ | `--min-expiry <duration>` | `print-bearer-token` | Require remaining token lifetime using `ms`, `s`, `m`, or `h`, such as `30m` |
267
+
268
+ Credential-printing commands write secrets to stdout.
@@ -1,6 +1,6 @@
1
- # Compaction & Branch Summarization
1
+ # Compaction Reference
2
2
 
3
- LLMs have limited context windows. When conversations grow too long, Pi uses compaction to summarize older content while preserving recent work. This page covers both auto-compaction and branch summarization.
3
+ This reference describes automatic compaction, branch summarization, persisted entries, and extension hooks. For the user workflow, see [Sessions and Context](sessions.md#manage-conversation-context).
4
4
 
5
5
  **Source files** ([pi](https://github.com/earendil-works/pi)):
6
6
  - [`packages/coding-agent/src/core/compaction/compaction.ts`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/compaction/compaction.ts) - Auto-compaction logic
@@ -20,7 +20,7 @@ Pi has two summarization mechanisms:
20
20
  | Compaction | Context exceeds threshold, or `/compact` | Summarize old messages to free up context |
21
21
  | Branch summarization | `/tree` navigation | Preserve context when switching branches |
22
22
 
23
- Both use the same structured summary format and track file operations cumulatively. Compaction and branch-summary requests use fresh routing session IDs and, where supported by the provider, disable prompt-cache writes because these one-off prompts are unlikely to be reused.
23
+ Both use closely related structured formats and track file operations cumulatively. Summarization requests disable prompt-cache writes because these one-off prompts are unlikely to be reused.
24
24
 
25
25
  ## Compaction
26
26
 
@@ -97,14 +97,14 @@ persist final assistant response
97
97
 
98
98
  If recovery compaction fails or is cancelled, Pi keeps the omission edits, appends no compaction, and schedules no internal retry. Existing queued work remains governed by ordinary steering and follow-up rules. `agent_before_settle` sees the repaired projection after recovery processing. Raw transcript history, exports, billing totals, and history-search extensions can still inspect the omitted attempt.
99
99
 
100
- ### Split Turns
100
+ ### Split user-message spans
101
101
 
102
- A "turn" starts with a user message and includes all assistant responses and tool calls until the next user message. Normally, compaction cuts at turn boundaries.
102
+ A user-message span starts with a user message and includes all turns until the next user message. Normally, compaction cuts at user-message boundaries.
103
103
 
104
- When a single turn exceeds `keepRecentTokens`, the cut point lands mid-turn at an assistant message. This is a "split turn":
104
+ When one user-message span exceeds `keepRecentTokens`, the cut point lands within that span at an assistant message. This is a split user-message span:
105
105
 
106
106
  ```
107
- Split turn (one huge turn exceeds budget):
107
+ Split user-message span (one span exceeds budget):
108
108
 
109
109
  entry: 0 1 2 3 4 5 6 7 8
110
110
  ┌─────┬─────┬─────┬──────┬─────┬──────┬──────┬─────┬──────┐
@@ -117,13 +117,13 @@ Split turn (one huge turn exceeds budget):
117
117
  └── kept (7-8)
118
118
 
119
119
  isSplitTurn = true
120
- messagesToSummarize = [] (no complete turns before)
120
+ messagesToSummarize = [] (no earlier user-message spans)
121
121
  turnPrefixMessages = [usr, ass, tool, ass, tool, tool]
122
122
  ```
123
123
 
124
- For split turns, Pi generates two summaries and merges them:
124
+ For split user-message spans, Pi generates two summaries and merges them:
125
125
  1. **History summary**: Previous context (if any)
126
- 2. **Turn prefix summary**: The early part of the split turn
126
+ 2. **User-message-span prefix summary**: The early part of the split user-message span
127
127
 
128
128
  ### Cut Point Rules
129
129
 
@@ -145,8 +145,8 @@ Defined in [`session-manager.ts`](https://github.com/earendil-works/pi/blob/main
145
145
  interface CompactionEntry<T = unknown> {
146
146
  type: "compaction";
147
147
  id: string;
148
- parentId: string;
149
- timestamp: number;
148
+ parentId: string | null;
149
+ timestamp: string;
150
150
  summary: string;
151
151
  firstKeptEntryId: string;
152
152
  tokensBefore: number;
@@ -199,11 +199,9 @@ After navigation with summary:
199
199
 
200
200
  ### Cumulative File Tracking
201
201
 
202
- Both compaction and branch summarization track files cumulatively. When generating a summary, pi extracts file operations from:
203
- - Tool calls in the messages being summarized
204
- - Previous compaction or branch summary `details` (if any)
202
+ Default compaction and branch summarization track files cumulatively. Both extract file operations from tool calls in the messages being summarized. Compaction also carries file lists from the previous Pi-generated compaction. Branch summarization carries file lists from Pi-generated branch summaries in the entries it summarizes.
205
203
 
206
- This means file tracking accumulates across multiple compactions or nested branch summaries, preserving the full history of read and modified files.
204
+ File tracking therefore accumulates across default compactions and nested default branch summaries. Pi does not automatically carry file lists from extension-generated summaries whose `fromHook` field is `true`; extensions manage their own `details` format.
207
205
 
208
206
  ### BranchSummaryEntry Structure
209
207
 
@@ -213,8 +211,8 @@ Defined in [`session-manager.ts`](https://github.com/earendil-works/pi/blob/main
213
211
  interface BranchSummaryEntry<T = unknown> {
214
212
  type: "branch_summary";
215
213
  id: string;
216
- parentId: string;
217
- timestamp: number;
214
+ parentId: string | null;
215
+ timestamp: string;
218
216
  summary: string;
219
217
  fromId: string; // Entry we navigated from
220
218
  usage?: Usage; // LLM usage that generated the summary
@@ -235,7 +233,9 @@ See [`collectEntriesForBranchSummary()`](https://github.com/earendil-works/pi/bl
235
233
 
236
234
  ## Summary Format
237
235
 
238
- Both compaction and branch summarization use the same structured format:
236
+ Both formats include Goal, Constraints & Preferences, Progress, Key Decisions, and Next Steps. Compaction summaries also include Critical Context. Branch summaries stop after Next Steps. Pi appends file lists to either format when relevant.
237
+
238
+ Compaction summaries use this format:
239
239
 
240
240
  ```markdown
241
241
  ## Goal
@@ -302,7 +302,7 @@ pi.on("session_before_compact", async (event, ctx) => {
302
302
  const { preparation, branchEntries, customInstructions, reason, willRetry, signal } = event;
303
303
 
304
304
  // preparation.messagesToSummarize - messages to summarize
305
- // preparation.turnPrefixMessages - split turn prefix (if isSplitTurn)
305
+ // preparation.turnPrefixMessages - user-message-span prefix (if isSplitTurn)
306
306
  // preparation.previousSummary - previous compaction summary
307
307
  // preparation.fileOps - extracted file operations
308
308
  // preparation.tokensBefore - context tokens before compaction
@@ -376,7 +376,7 @@ pi.on("session_compact_failed", async (event, ctx) => {
376
376
  const { reason, errorMessage, aborted, willRetry, fromExtension } = event;
377
377
  // reason - "manual" (/compact), "threshold", or "overflow"
378
378
  // errorMessage - present for non-abort failures
379
- // aborted - true for cancelled/aborted compactions
379
+ // aborted - true for canceled/aborted compactions
380
380
  // willRetry - whether the aborted turn would have retried after compaction
381
381
  // fromExtension - whether extension-provided compaction content was being used
382
382
  });
@@ -460,4 +460,4 @@ Keys are exact, case-sensitive `provider/modelId` values, including any slashes
460
460
 
461
461
  These resolved values are used for manual compaction, all automatic threshold checks, overflow recovery, and extension-visible `preparation.settings`. Model switches affect subsequent checks and compactions without changing ordinary settings. Compaction already in progress uses the model and settings captured for that operation. Branch summarization settings are unaffected.
462
462
 
463
- Overrides work in both global and project settings. The files merge recursively before lookup, so a global model-specific value beats a project-wide fallback; a project must override that model entry to change it. See [settings.md](settings.md#per-model-compaction-overrides) for details.
463
+ Overrides work in both global and project settings. The files merge recursively before lookup, so a global model-specific value beats a project-wide fallback; a project must override that model entry to change it. See [Settings](settings.md#per-model-compaction-overrides) for details.
@@ -0,0 +1,45 @@
1
+ # Configuration
2
+
3
+ Pi supports user-level and project configuration. User-level configuration lives in the agent directory, which defaults to `~/.pi/agent`. Project configuration lives in `.pi` under the working directory and loads after [project trust](security.md#understand-project-trust) is granted. The only exception is `sessionDir`, which Pi reads before resolving trust so it can locate sessions.
4
+
5
+ In interactive mode, use `/settings` to change common preferences. For other options, ask Pi to update the configuration or edit the relevant files directly. Run `/reload` after manually changing settings, keybindings, instructions, or resources.
6
+
7
+ ## Agent directory
8
+
9
+ The agent directory is shown as `<agent-dir>` below. Set its location with the `PI_CODING_AGENT_DIR` environment variable or the SDK's [`agentDir`](sdk.md) option.
10
+
11
+ | Path | Responsibility |
12
+ |---|---|
13
+ | `<agent-dir>/settings.json` | User-level [settings](settings.md), including preferences, defaults, resource paths, and Pi package declarations. |
14
+ | `<agent-dir>/keybindings.json` | Custom terminal UI and application [keybindings](keybindings.md). |
15
+ | `<agent-dir>/models.json` | [Compatible endpoints, models, and model overrides](models.md#configure-a-compatible-endpoint). |
16
+ | `<agent-dir>/auth.json` | Saved API keys and OAuth credentials. |
17
+ | `<agent-dir>/AGENTS.override.md`, `AGENTS.md`, `AGENTS.MD`, `CLAUDE.md`, or `CLAUDE.MD` | User instructions applied across working directories. |
18
+ | `<agent-dir>/SYSTEM.md` | Replaces Pi’s default system prompt. |
19
+ | `<agent-dir>/APPEND_SYSTEM.md` | Adds instructions to Pi’s system prompt. |
20
+ | `<agent-dir>/extensions/` | User [extensions](extensions.md). |
21
+ | `<agent-dir>/skills/` | User [skills](skills.md) and supporting files. |
22
+ | `<agent-dir>/prompts/` | User [prompt templates](prompt-templates.md) exposed as slash commands. |
23
+ | `<agent-dir>/themes/` | User [theme](themes.md) files. |
24
+
25
+ ## Project `.pi` directory
26
+
27
+ | Path | Responsibility |
28
+ |---|---|
29
+ | `.pi/settings.json` | Project-level [settings](settings.md), resource paths, and Pi package declarations. |
30
+ | `.pi/SYSTEM.md` | Replaces the system prompt for the project. |
31
+ | `.pi/APPEND_SYSTEM.md` | Adds project-specific instructions to the system prompt. |
32
+ | `.pi/extensions/` | Project extensions. |
33
+ | `.pi/skills/` | Project skills and supporting files. |
34
+ | `.pi/prompts/` | Project prompt templates exposed as slash commands. |
35
+ | `.pi/themes/` | Project theme files. |
36
+
37
+ For `SYSTEM.md` and `APPEND_SYSTEM.md`, the trusted project file takes precedence over the corresponding agent-directory file. Files with the same name are not combined.
38
+
39
+ ## Context files
40
+
41
+ Context files are separate from project `.pi` configuration. Pi loads them from the agent directory, the working directory, and its parent directories. A context file applies whenever Pi runs in its directory or anywhere below it.
42
+
43
+ An `AGENTS.override.md` replaces `AGENTS.md` or `CLAUDE.md` only in the same directory. It does not suppress context files from the agent directory or other directories.
44
+
45
+ Context-file discovery does not require project trust.