@counterposition/skill-pi 0.65.3 → 0.74.0
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/README.md +8 -14
- package/package.json +1 -1
- package/skills/pi/README.md +8 -14
- package/skills/pi/SKILL.md +35 -166
- package/skills/pi/evals/evals.json +1 -1
- package/skills/pi/references/extensions.md +45 -25
- package/skills/pi/references/packages.md +11 -7
- package/skills/pi/references/patterns.md +2 -2
- package/skills/pi/references/providers.md +57 -8
- package/skills/pi/references/sdk.md +22 -14
- package/skills/pi/references/settings.md +77 -4
package/README.md
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
# Pi Skill
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
>
|
|
5
|
-
> — Lao Tzu, *Tao Te Ching*
|
|
3
|
+
Pi's own system prompt already points it at its source documentation. But when you use a different coding agent — Claude Code, OpenCode, Codex CLI, or an IDE agent like Cursor or Windsurf — to work on Pi extensions, skills, packages, or configuration, that agent has no built-in knowledge of Pi's architecture. It will hallucinate APIs, invent settings, and confidently describe extension hooks that don't exist.
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
This skill gives Pi self-knowledge. It injects task-specific reference documentation into context so that Pi reasons from grounded facts — about its extensions, settings, providers, sessions, and SDK — rather than from plausible fictions.
|
|
10
|
-
|
|
11
|
-
Without this skill, Pi guesses about itself. With it, Pi *knows*.
|
|
5
|
+
This skill gives any coding agent grounded knowledge of Pi via the [Agent Skills](https://agentskills.io/home) standard. It injects task-specific reference documentation into context so the agent reasons from facts — about extensions, settings, providers, sessions, and the SDK — rather than from plausible fictions.
|
|
12
6
|
|
|
13
7
|
## Install
|
|
14
8
|
|
|
@@ -40,9 +34,9 @@ The reference material lives in `references/` as task-specific documents — not
|
|
|
40
34
|
|
|
41
35
|
## Files
|
|
42
36
|
|
|
43
|
-
| Path
|
|
44
|
-
|
|
45
|
-
| `SKILL.md`
|
|
46
|
-
| `references/`
|
|
47
|
-
| `evals/evals.json` | Example evaluation cases
|
|
48
|
-
| `LICENSE.md`
|
|
37
|
+
| Path | Purpose |
|
|
38
|
+
| ------------------ | ------------------------------------- |
|
|
39
|
+
| `SKILL.md` | Trigger rules and routing description |
|
|
40
|
+
| `references/` | Task-specific Pi reference documents |
|
|
41
|
+
| `evals/evals.json` | Example evaluation cases |
|
|
42
|
+
| `LICENSE.md` | GPLv3 license text |
|
package/package.json
CHANGED
package/skills/pi/README.md
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
# Pi Skill
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
>
|
|
5
|
-
> — Lao Tzu, *Tao Te Ching*
|
|
3
|
+
Pi's own system prompt already points it at its source documentation. But when you use a different coding agent — Claude Code, OpenCode, Codex CLI, or an IDE agent like Cursor or Windsurf — to work on Pi extensions, skills, packages, or configuration, that agent has no built-in knowledge of Pi's architecture. It will hallucinate APIs, invent settings, and confidently describe extension hooks that don't exist.
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
This skill gives Pi self-knowledge. It injects task-specific reference documentation into context so that Pi reasons from grounded facts — about its extensions, settings, providers, sessions, and SDK — rather than from plausible fictions.
|
|
10
|
-
|
|
11
|
-
Without this skill, Pi guesses about itself. With it, Pi *knows*.
|
|
5
|
+
This skill gives any coding agent grounded knowledge of Pi via the [Agent Skills](https://agentskills.io/home) standard. It injects task-specific reference documentation into context so the agent reasons from facts — about extensions, settings, providers, sessions, and the SDK — rather than from plausible fictions.
|
|
12
6
|
|
|
13
7
|
## Install
|
|
14
8
|
|
|
@@ -40,9 +34,9 @@ The reference material lives in `references/` as task-specific documents — not
|
|
|
40
34
|
|
|
41
35
|
## Files
|
|
42
36
|
|
|
43
|
-
| Path
|
|
44
|
-
|
|
45
|
-
| `SKILL.md`
|
|
46
|
-
| `references/`
|
|
47
|
-
| `evals/evals.json` | Example evaluation cases
|
|
48
|
-
| `LICENSE.md`
|
|
37
|
+
| Path | Purpose |
|
|
38
|
+
| ------------------ | ------------------------------------- |
|
|
39
|
+
| `SKILL.md` | Trigger rules and routing description |
|
|
40
|
+
| `references/` | Task-specific Pi reference documents |
|
|
41
|
+
| `evals/evals.json` | Example evaluation cases |
|
|
42
|
+
| `LICENSE.md` | GPLv3 license text |
|
package/skills/pi/SKILL.md
CHANGED
|
@@ -7,198 +7,67 @@ compatibility: "Pi-specific guidance for agents that support Agent Skills"
|
|
|
7
7
|
|
|
8
8
|
# Pi Coding Agent
|
|
9
9
|
|
|
10
|
-
Pi is a minimal terminal coding harness.
|
|
10
|
+
Pi is a minimal terminal coding harness. Default tools: `read`, `write`, `edit`, `bash`, `grep`, `find`, `ls`. Modes: interactive (`pi`), print (`pi -p`), JSON (`--mode json`), RPC (`--mode rpc`), or embedded (`createAgentSession()`). Sub-agents, plan mode, permission flows, and MCP are intentionally left to extensions and Pi packages.
|
|
11
11
|
|
|
12
|
-
Pi's philosophy: **adapt Pi to your workflows, not the other way around**.
|
|
12
|
+
Pi's philosophy: **adapt Pi to your workflows, not the other way around**.
|
|
13
13
|
|
|
14
|
-
## Architecture
|
|
14
|
+
## Architecture
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Core packages on npm (source: [github.com/earendil-works/pi](https://github.com/earendil-works/pi)):
|
|
17
17
|
|
|
18
|
-
| Package |
|
|
19
|
-
|
|
20
|
-
|
|
|
21
|
-
|
|
|
22
|
-
|
|
|
23
|
-
|
|
|
24
|
-
|
|
25
|
-
**Source:** [github.com/badlogic/pi-mono](https://github.com/badlogic/pi-mono)
|
|
18
|
+
| Package | Purpose |
|
|
19
|
+
|---------|---------|
|
|
20
|
+
| `@earendil-works/pi-ai` | Unified LLM API across 20+ providers |
|
|
21
|
+
| `@earendil-works/pi-agent-core` | Agent runtime with tool execution and state |
|
|
22
|
+
| `@earendil-works/pi-tui` | Terminal UI components |
|
|
23
|
+
| `@earendil-works/pi-coding-agent` | CLI, extensions, skills, sessions, settings |
|
|
24
|
+
| `@earendil-works/pi-web-ui` | Web components for chat interfaces |
|
|
26
25
|
|
|
27
26
|
## File System Layout
|
|
28
27
|
|
|
29
28
|
```text
|
|
30
|
-
~/.pi/agent/ # Global config
|
|
29
|
+
~/.pi/agent/ # Global config dir (PI_CODING_AGENT_DIR overrides)
|
|
31
30
|
├── settings.json # Global settings
|
|
32
31
|
├── auth.json # Credentials (0600 perms)
|
|
33
32
|
├── models.json # Custom provider/model definitions
|
|
34
33
|
├── keybindings.json # Keyboard shortcuts
|
|
35
|
-
├──
|
|
36
|
-
├──
|
|
37
|
-
├──
|
|
38
|
-
├── prompts/ # Global prompt templates (auto-discovered)
|
|
34
|
+
├── extensions/ # Auto-discovered
|
|
35
|
+
├── skills/ # Auto-discovered
|
|
36
|
+
├── prompts/ # Auto-discovered
|
|
39
37
|
├── themes/ # Custom themes
|
|
40
|
-
|
|
41
|
-
└── bin/ # Tool binaries (fd, ripgrep)
|
|
38
|
+
└── sessions/ # JSONL session files
|
|
42
39
|
|
|
43
40
|
<project>/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
41
|
+
└── .pi/ # Project-local config (overrides global)
|
|
42
|
+
├── settings.json
|
|
43
|
+
├── extensions/
|
|
44
|
+
├── skills/
|
|
45
|
+
├── prompts/
|
|
46
|
+
├── themes/
|
|
47
|
+
└── agents/ # Agent definitions (subagent extension)
|
|
51
48
|
```
|
|
52
49
|
|
|
53
50
|
## Key Concepts
|
|
54
51
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
Markdown-based capability packages (`SKILL.md` with frontmatter). Pi loads skill names and descriptions into the system prompt; the full skill body is read on demand. Skills follow the Agent Skills standard.
|
|
64
|
-
|
|
65
|
-
Read `references/skills.md` for the authoring guide, frontmatter schema, and directory conventions.
|
|
66
|
-
|
|
67
|
-
### Settings
|
|
68
|
-
|
|
69
|
-
Hierarchical JSON configuration: project `.pi/settings.json` merges over global `~/.pi/agent/settings.json`. Controls model, thinking level, compaction, retry, shell, transport, and resource loading.
|
|
70
|
-
|
|
71
|
-
Read `references/settings.md` for every setting with its type, default, and effect.
|
|
72
|
-
|
|
73
|
-
### Packages
|
|
74
|
-
|
|
75
|
-
Bundles of extensions, skills, prompts, and themes distributed via npm, git, or local paths. Installed with `pi install`.
|
|
76
|
-
|
|
77
|
-
Read `references/packages.md` for the package structure, `pi` manifest field, installation, and publishing.
|
|
78
|
-
|
|
79
|
-
### Context Files & Prompt Templates
|
|
80
|
-
|
|
81
|
-
Pi loads `AGENTS.md` or `CLAUDE.md` from the global agent dir and from `cwd` up through parent directories. `.pi/SYSTEM.md` replaces the default system prompt, and `APPEND_SYSTEM.md` appends to it. Prompt templates in `prompts/` directories become slash commands.
|
|
82
|
-
|
|
83
|
-
Read `references/settings.md` for discovery rules and config keys, and `references/packages.md` for how prompts/themes ship in packages.
|
|
84
|
-
|
|
85
|
-
### SDK
|
|
86
|
-
|
|
87
|
-
Programmatic embedding via `createAgentSession()`. Gives full control over models, tools, extensions, sessions, and event streaming.
|
|
88
|
-
|
|
89
|
-
Read `references/sdk.md` for factory options, event types, and usage patterns.
|
|
90
|
-
|
|
91
|
-
### Custom Providers & Models
|
|
92
|
-
|
|
93
|
-
Add any OpenAI-compatible, Anthropic, Google, or custom LLM endpoint via `models.json` or extension-based `registerProvider()`.
|
|
94
|
-
|
|
95
|
-
Read `references/providers.md` for provider configuration, auth methods, and the model schema.
|
|
96
|
-
|
|
97
|
-
### Common Patterns
|
|
98
|
-
|
|
99
|
-
Practical recipes for permission gates, presets, sub-agents, git checkpoints, custom compaction, TUI components, and more.
|
|
100
|
-
|
|
101
|
-
Read `references/patterns.md` for copy-paste-ready examples.
|
|
102
|
-
|
|
103
|
-
## Sessions & Compaction
|
|
104
|
-
|
|
105
|
-
Sessions are append-only JSONL files with a tree structure (entries linked by `id`/`parentId`). This allows branching without modifying history. Key operations:
|
|
106
|
-
|
|
107
|
-
- **`/tree`** — Navigate the session tree, jump to any point
|
|
108
|
-
- **`Shift+T` in `/tree`** — Toggle timestamps on tree entry labels
|
|
109
|
-
- **`/compact`** — Manually trigger context compaction
|
|
110
|
-
- **`/fork`** — Branch from a specific point
|
|
111
|
-
- **Auto-compaction** — Triggers when `contextTokens > contextWindow - reserveTokens`
|
|
112
|
-
|
|
113
|
-
Compaction walks backward from the newest message, keeping `keepRecentTokens` (default 20,000) of recent conversation, and summarizes everything older. Extensions can intercept compaction via `session_before_compact`.
|
|
114
|
-
|
|
115
|
-
## Built-in Tools
|
|
116
|
-
|
|
117
|
-
| Tool | Description |
|
|
118
|
-
|------|-------------|
|
|
119
|
-
| `read` | Read files (with offset/limit support, images, PDFs) |
|
|
120
|
-
| `write` | Create or overwrite files |
|
|
121
|
-
| `edit` | Line-based file editing with diffs |
|
|
122
|
-
| `bash` | Execute shell commands with streaming output |
|
|
123
|
-
| `grep` | Search file contents by pattern |
|
|
124
|
-
| `find` | Find files by glob pattern |
|
|
125
|
-
| `ls` | List directory contents |
|
|
126
|
-
|
|
127
|
-
**Common tool sets:** `codingTools()` = `[read, bash, edit, write]`, `readOnlyTools()` = `[read, grep, find, ls]`. When you provide a custom `cwd` and explicit tools in the SDK, use `createCodingTools(cwd)` / `createReadOnlyTools(cwd)` so path resolution stays correct.
|
|
128
|
-
|
|
129
|
-
## Execution Modes
|
|
130
|
-
|
|
131
|
-
| Mode | Start with | Use case |
|
|
132
|
-
|------|-----------|----------|
|
|
133
|
-
| Interactive | `pi` | Full TUI with editor, streaming, keybindings |
|
|
134
|
-
| Print | `pi -p "prompt"` | Single-shot text output |
|
|
135
|
-
| JSON | `pi --mode json "prompt"` | Newline-delimited event stream |
|
|
136
|
-
| RPC | `pi --mode rpc` | JSON-RPC over stdin/stdout for IDE integration |
|
|
137
|
-
| SDK | `createAgentSession()` | Embed in Node.js applications |
|
|
138
|
-
|
|
139
|
-
## Quick Reference: CLI Flags
|
|
140
|
-
|
|
141
|
-
```text
|
|
142
|
-
pi [options] [@files...] [messages...]
|
|
143
|
-
|
|
144
|
-
# package commands
|
|
145
|
-
install <source> [-l]
|
|
146
|
-
remove <source> [-l]
|
|
147
|
-
uninstall <source> [-l]
|
|
148
|
-
update [source]
|
|
149
|
-
list
|
|
150
|
-
config
|
|
151
|
-
|
|
152
|
-
# modes and output
|
|
153
|
-
-p, --print
|
|
154
|
-
--mode json|rpc
|
|
155
|
-
--export <in> [out]
|
|
156
|
-
|
|
157
|
-
# model selection
|
|
158
|
-
--provider <name>
|
|
159
|
-
--model <pattern>
|
|
160
|
-
--api-key <key>
|
|
161
|
-
--thinking <level>
|
|
162
|
-
--models <patterns>
|
|
163
|
-
--list-models [search]
|
|
164
|
-
|
|
165
|
-
# sessions
|
|
166
|
-
-c, --continue
|
|
167
|
-
-r, --resume
|
|
168
|
-
--session <path|id>
|
|
169
|
-
--fork <path|id>
|
|
170
|
-
--session-dir <dir>
|
|
171
|
-
--no-session
|
|
172
|
-
|
|
173
|
-
# tools and resources
|
|
174
|
-
--tools <list>
|
|
175
|
-
--no-tools
|
|
176
|
-
-e, --extension <source>
|
|
177
|
-
--skill <path>
|
|
178
|
-
--prompt-template <path>
|
|
179
|
-
--theme <path>
|
|
180
|
-
--no-extensions
|
|
181
|
-
--no-skills
|
|
182
|
-
--no-prompt-templates
|
|
183
|
-
--no-themes
|
|
184
|
-
|
|
185
|
-
# prompts and misc
|
|
186
|
-
--system-prompt <text>
|
|
187
|
-
--append-system-prompt <text>
|
|
188
|
-
--verbose
|
|
189
|
-
```
|
|
52
|
+
- **Extensions** — TypeScript modules with full system access. Hook into Pi's lifecycle to register tools, intercept calls, add commands, build UI. → `references/extensions.md`
|
|
53
|
+
- **Skills** — Markdown capability packages (`SKILL.md` + frontmatter) following the Agent Skills standard. Pi loads names + descriptions into the system prompt; bodies load on demand. → `references/skills.md`
|
|
54
|
+
- **Settings** — Hierarchical JSON: project `.pi/settings.json` merges over global `~/.pi/agent/settings.json`. → `references/settings.md`
|
|
55
|
+
- **Packages** — Bundles of extensions/skills/prompts/themes via npm, git, or local paths. Installed with `pi install`. → `references/packages.md`
|
|
56
|
+
- **Context files & prompt templates** — Pi loads `AGENTS.md` / `CLAUDE.md` from the agent dir and from `cwd` up through ancestors. `.pi/SYSTEM.md` replaces the system prompt; `APPEND_SYSTEM.md` appends. Prompt templates in `prompts/` become slash commands. → `references/settings.md`
|
|
57
|
+
- **SDK** — Programmatic embedding via `createAgentSession()`; `createAgentSessionRuntime()` for session replacement. → `references/sdk.md`
|
|
58
|
+
- **Custom providers & models** — `models.json` or extension `pi.registerProvider()` for any OpenAI-/Anthropic-/Google-compatible or custom LLM endpoint. → `references/providers.md`
|
|
59
|
+
- **Sessions & compaction** — Append-only JSONL with a tree structure; branch with `/tree`, `/fork`, `/clone`, compact with `/compact`. Auto-compaction triggers when `contextTokens > contextWindow - reserveTokens`. Extensions intercept via `session_before_compact`. → `references/extensions.md` and `references/sdk.md`
|
|
190
60
|
|
|
191
61
|
## How to Use This Skill
|
|
192
62
|
|
|
193
|
-
When working with Pi, read the appropriate reference file for the task at hand:
|
|
194
|
-
|
|
195
63
|
| Task | Reference |
|
|
196
64
|
|------|-----------|
|
|
197
65
|
| Writing an extension (tools, commands, events, UI) | `references/extensions.md` |
|
|
198
|
-
| Creating a skill
|
|
199
|
-
| Configuring Pi (settings
|
|
200
|
-
| Context files, prompt templates, themes, and resource discovery | `references/settings.md` and `references/packages.md` |
|
|
66
|
+
| Creating a skill | `references/skills.md` |
|
|
67
|
+
| Configuring Pi (settings, env vars, CLI flags) | `references/settings.md` |
|
|
201
68
|
| Building a shareable package | `references/packages.md` |
|
|
202
69
|
| Embedding Pi programmatically | `references/sdk.md` |
|
|
203
70
|
| Adding LLM providers or models | `references/providers.md` |
|
|
204
71
|
| Looking for a recipe or pattern | `references/patterns.md` |
|
|
72
|
+
|
|
73
|
+
For exact CLI flags run `pi --help` or read the relevant reference. Resource flags (`--no-extensions`, `--no-skills`, `--no-context-files`, `--no-builtin-tools`, etc.) are documented in `references/settings.md`.
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"expected_output": "A TypeScript extension file that hooks into tool_call events, checks for curl in bash commands, prompts via ctx.ui.select, and appends blocked commands to a log file. Should check ctx.hasUI and handle non-interactive mode.",
|
|
8
8
|
"files": [],
|
|
9
9
|
"assertions": [
|
|
10
|
-
"Uses correct ExtensionAPI import from @
|
|
10
|
+
"Uses correct ExtensionAPI import from @earendil-works/pi-coding-agent",
|
|
11
11
|
"Hooks into tool_call event (the correct event for intercepting tool calls)",
|
|
12
12
|
"Checks event.toolName === 'bash' before inspecting command",
|
|
13
13
|
"Tests for curl in the command string",
|
|
@@ -17,20 +17,20 @@ Use `pi -e ./my-extension.ts` or `pi --extension ...` for quick tests. Put stabl
|
|
|
17
17
|
## Common Imports
|
|
18
18
|
|
|
19
19
|
```typescript
|
|
20
|
-
import type { ExtensionAPI } from "@
|
|
21
|
-
import { Type } from "
|
|
22
|
-
import { StringEnum } from "@
|
|
23
|
-
import { Text } from "@
|
|
20
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
21
|
+
import { Type } from "typebox";
|
|
22
|
+
import { StringEnum } from "@earendil-works/pi-ai";
|
|
23
|
+
import { Text } from "@earendil-works/pi-tui";
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
- Use
|
|
27
|
-
- Use `StringEnum` from `@
|
|
26
|
+
- Use `typebox` (1.x) for schemas.
|
|
27
|
+
- Use `StringEnum` from `@earendil-works/pi-ai` for Google-compatible string enums.
|
|
28
28
|
|
|
29
29
|
## Quick Start
|
|
30
30
|
|
|
31
31
|
```typescript
|
|
32
|
-
import type { ExtensionAPI } from "@
|
|
33
|
-
import { Type } from "
|
|
32
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
33
|
+
import { Type } from "typebox";
|
|
34
34
|
|
|
35
35
|
export default function (pi: ExtensionAPI) {
|
|
36
36
|
pi.on("session_start", async (_event, ctx) => {
|
|
@@ -52,6 +52,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
52
52
|
},
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
+
// For reusable tool definitions outside `pi.registerTool(...)`, use `defineTool({...})`
|
|
56
|
+
// — it preserves parameter type inference and can be passed via `customTools` to the SDK.
|
|
57
|
+
|
|
55
58
|
pi.registerCommand("hello", {
|
|
56
59
|
description: "Say hello",
|
|
57
60
|
async handler(args, ctx) {
|
|
@@ -75,32 +78,24 @@ Useful session events:
|
|
|
75
78
|
- `session_shutdown`
|
|
76
79
|
- `resources_discover`
|
|
77
80
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
```typescript
|
|
81
|
-
pi.on("session_start", async (event, ctx) => {
|
|
82
|
-
if (event.reason === "fork" && event.previousSessionFile && ctx.hasUI) {
|
|
83
|
-
ctx.ui.notify(`Forked from ${event.previousSessionFile}`, "info");
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
Use `event.reason` to distinguish `"startup"`, `"reload"`, `"new"`, `"resume"`, and `"fork"`. For `"new"`, `"resume"`, and `"fork"`, `event.previousSessionFile` points at the session file being replaced.
|
|
81
|
+
`session_start` carries `event.reason` — `"startup" | "reload" | "new" | "resume" | "fork"` — and `event.previousSessionFile` for `"new"`/`"resume"`/`"fork"`. The old post-transition `session_switch` / `session_fork` events were removed; route all of those flows through `session_start`.
|
|
89
82
|
|
|
90
83
|
Useful agent events:
|
|
91
84
|
|
|
92
85
|
- `input`
|
|
93
|
-
- `before_agent_start`
|
|
86
|
+
- `before_agent_start` — receives `event.systemPromptOptions` (a `BuildSystemPromptOptions`) so handlers can inspect the structured inputs feeding the system prompt
|
|
94
87
|
- `agent_start`
|
|
95
88
|
- `agent_end`
|
|
96
89
|
- `turn_start`
|
|
97
90
|
- `turn_end`
|
|
98
91
|
- `message_start`
|
|
99
92
|
- `message_update`
|
|
100
|
-
- `message_end`
|
|
93
|
+
- `message_end` — return a replacement message to override usage/cost or rewrite the finalized assistant message
|
|
101
94
|
- `context`
|
|
102
95
|
- `before_provider_request`
|
|
96
|
+
- `after_provider_response` — inspect the provider HTTP status and headers before stream consumption
|
|
103
97
|
- `model_select`
|
|
98
|
+
- `thinking_level_select` — observe interactive thinking-level changes
|
|
104
99
|
|
|
105
100
|
Useful tool events:
|
|
106
101
|
|
|
@@ -110,6 +105,10 @@ Useful tool events:
|
|
|
110
105
|
- `tool_result`
|
|
111
106
|
- `tool_execution_end`
|
|
112
107
|
|
|
108
|
+
Tool results may include `terminate: true` to end the current tool batch without an automatic follow-up LLM turn — useful for tools that produce a structured final answer (see `examples/extensions/structured-output.ts` in the Pi repo).
|
|
109
|
+
|
|
110
|
+
`session_shutdown` events carry `event.reason` (`"quit" | "reload" | "new" | "resume" | "fork"`) and, where applicable, `event.targetSessionFile` so cleanup logic can distinguish teardown paths.
|
|
111
|
+
|
|
113
112
|
## Extension Context
|
|
114
113
|
|
|
115
114
|
`ctx` gives extensions access to:
|
|
@@ -172,6 +171,8 @@ ctx.ui.notify("Done", "info");
|
|
|
172
171
|
|
|
173
172
|
ctx.ui.setStatus("my-ext", "Processing...");
|
|
174
173
|
ctx.ui.setWorkingMessage("Thinking deeply...");
|
|
174
|
+
ctx.ui.setWorkingIndicator({ frames: ["⣷", "⣯", "⣟", "⡿"], intervalMs: 80 });
|
|
175
|
+
ctx.ui.setWorkingVisible(false); // hide the built-in loader row
|
|
175
176
|
ctx.ui.setWidget("my-widget", ["Line 1", "Line 2"]);
|
|
176
177
|
ctx.ui.setFooter((tui, theme) => new Text(theme.fg("dim", "Custom footer"), 0, 0));
|
|
177
178
|
ctx.ui.setTitle("pi - custom");
|
|
@@ -179,16 +180,18 @@ ctx.ui.setTitle("pi - custom");
|
|
|
179
180
|
ctx.ui.setEditorText("prefilled text");
|
|
180
181
|
const current = ctx.ui.getEditorText();
|
|
181
182
|
ctx.ui.pasteToEditor("extra text");
|
|
183
|
+
ctx.ui.setHiddenThinkingLabel("…");
|
|
184
|
+
const editorFactory = ctx.ui.getEditorComponent(); // wrap the active editor factory
|
|
182
185
|
|
|
183
186
|
ctx.ui.setToolsExpanded(true);
|
|
184
187
|
|
|
188
|
+
ctx.ui.addAutocompleteProvider((query, ctx) => /* completions */); // stack on top of slash/path provider
|
|
189
|
+
|
|
185
190
|
const result = await ctx.ui.custom((tui, theme, keybindings, done) => {
|
|
186
191
|
return new Text("Press Enter", 0, 0);
|
|
187
192
|
}, { overlay: true });
|
|
188
193
|
```
|
|
189
194
|
|
|
190
|
-
Pi 0.64.0 also added `ctx.ui.setHiddenThinkingLabel(...)` so interactive extensions can customize the collapsed thinking label.
|
|
191
|
-
|
|
192
195
|
## Commands, Shortcuts, Flags
|
|
193
196
|
|
|
194
197
|
```typescript
|
|
@@ -233,15 +236,30 @@ pi.on("session_start", async (_event, ctx) => {
|
|
|
233
236
|
|
|
234
237
|
## Provider Integration
|
|
235
238
|
|
|
236
|
-
Extensions can register providers:
|
|
239
|
+
Extensions can register or override providers:
|
|
237
240
|
|
|
238
241
|
```typescript
|
|
239
242
|
pi.registerProvider("my-provider", {
|
|
243
|
+
name: "My Provider", // optional friendly label for /login
|
|
240
244
|
baseUrl: "https://api.example.com",
|
|
241
245
|
api: "openai-completions",
|
|
242
246
|
apiKey: "MY_PROVIDER_KEY",
|
|
243
|
-
models: [
|
|
247
|
+
models: [
|
|
248
|
+
{
|
|
249
|
+
id: "my-model",
|
|
250
|
+
name: "My Model",
|
|
251
|
+
contextWindow: 128000,
|
|
252
|
+
maxTokens: 4096,
|
|
253
|
+
baseUrl: "https://us-east.api.example.com", // per-model override
|
|
254
|
+
thinkingLevelMap: { off: null, minimal: "low", medium: "medium", high: "high", xhigh: "high" },
|
|
255
|
+
},
|
|
256
|
+
],
|
|
244
257
|
});
|
|
258
|
+
|
|
259
|
+
// Override-only: re-route an existing built-in provider through a proxy
|
|
260
|
+
pi.registerProvider("anthropic", { baseUrl: "https://proxy.example.com" });
|
|
261
|
+
|
|
262
|
+
pi.unregisterProvider("my-provider");
|
|
245
263
|
```
|
|
246
264
|
|
|
247
265
|
If you need auth for a specific model request, use:
|
|
@@ -250,6 +268,8 @@ If you need auth for a specific model request, use:
|
|
|
250
268
|
const auth = await ctx.modelRegistry.getApiKeyAndHeaders(model);
|
|
251
269
|
```
|
|
252
270
|
|
|
271
|
+
Pass `shouldStopAfterTurn` via the SDK to exit the agent loop gracefully after a completed turn. See `references/sdk.md` and `references/providers.md` for the full provider/model schema.
|
|
272
|
+
|
|
253
273
|
## Handy Patterns
|
|
254
274
|
|
|
255
275
|
- Permission gates via `tool_call`
|
|
@@ -16,7 +16,10 @@ pi install ./relative/path/to/package
|
|
|
16
16
|
pi remove npm:@foo/bar
|
|
17
17
|
pi uninstall npm:@foo/bar
|
|
18
18
|
pi list
|
|
19
|
-
pi update
|
|
19
|
+
pi update # update pi itself + all installed packages (skips pinned)
|
|
20
|
+
pi update --self # update pi only
|
|
21
|
+
pi update --extensions # update packages only
|
|
22
|
+
pi update <source> # update one package
|
|
20
23
|
pi config
|
|
21
24
|
```
|
|
22
25
|
|
|
@@ -88,12 +91,13 @@ If there is no `pi` manifest, Pi auto-discovers:
|
|
|
88
91
|
|
|
89
92
|
- Normal runtime dependencies belong in `dependencies`
|
|
90
93
|
- Pi core libraries should be peer deps with `"*"` ranges:
|
|
91
|
-
- `@
|
|
92
|
-
- `@
|
|
93
|
-
- `@
|
|
94
|
-
- `@
|
|
95
|
-
-
|
|
96
|
-
- Other Pi packages must be bundled explicitly
|
|
94
|
+
- `@earendil-works/pi-ai`
|
|
95
|
+
- `@earendil-works/pi-agent-core`
|
|
96
|
+
- `@earendil-works/pi-coding-agent`
|
|
97
|
+
- `@earendil-works/pi-tui`
|
|
98
|
+
- `typebox`
|
|
99
|
+
- Other Pi packages must be bundled explicitly
|
|
100
|
+
- Git package installs run `npm install --omit=dev` — runtime needs go in `dependencies`, not `devDependencies`
|
|
97
101
|
|
|
98
102
|
## Package Filtering
|
|
99
103
|
|
|
@@ -27,7 +27,7 @@ Practical recipes for extending Pi. Each pattern is a self-contained example.
|
|
|
27
27
|
Block dangerous bash commands with user confirmation:
|
|
28
28
|
|
|
29
29
|
```typescript
|
|
30
|
-
import type { ExtensionAPI } from "@
|
|
30
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
31
31
|
|
|
32
32
|
export default function (pi: ExtensionAPI) {
|
|
33
33
|
const dangerous = [/\brm\s+(-rf?|--recursive)/i, /\bsudo\b/i, /\b(chmod|chown)\b.*777/i];
|
|
@@ -237,7 +237,7 @@ The Pi examples include an `interactive-shell.ts` extension that maintains a per
|
|
|
237
237
|
|
|
238
238
|
## TUI Components
|
|
239
239
|
|
|
240
|
-
Pi's TUI library (`@
|
|
240
|
+
Pi's TUI library (`@earendil-works/pi-tui`) provides:
|
|
241
241
|
|
|
242
242
|
- `Text` — Word-wrapped text
|
|
243
243
|
- `Box` — Padded container with border
|
|
@@ -4,15 +4,13 @@ Pi supports subscription-based providers via OAuth, API-key providers via env va
|
|
|
4
4
|
|
|
5
5
|
## Subscription Providers
|
|
6
6
|
|
|
7
|
-
Use `/login` in interactive mode, then select a provider
|
|
7
|
+
Use `/login` in interactive mode, then select a provider. The `/login` selector is fuzzy-searchable and shows where each entry's auth comes from (`--api-key`, env var, custom provider) without leaking the secret.
|
|
8
8
|
|
|
9
|
-
- Anthropic Claude Pro / Max
|
|
9
|
+
- Anthropic Claude Pro / Max — third-party usage draws from extra usage and is billed per token (suppress the warning via `warnings.anthropicExtraUsage`)
|
|
10
10
|
- OpenAI ChatGPT Plus / Pro (Codex)
|
|
11
11
|
- GitHub Copilot
|
|
12
|
-
- Google Gemini CLI
|
|
13
|
-
- Google Antigravity
|
|
14
12
|
|
|
15
|
-
Use `/logout` to clear stored OAuth credentials.
|
|
13
|
+
Use `/logout` to clear stored OAuth credentials. Pi 0.71.0 removed built-in Google Gemini CLI and Google Antigravity providers.
|
|
16
14
|
|
|
17
15
|
## API Key Providers
|
|
18
16
|
|
|
@@ -21,10 +19,13 @@ Use `/logout` to clear stored OAuth credentials.
|
|
|
21
19
|
| Anthropic | `ANTHROPIC_API_KEY` | `anthropic` |
|
|
22
20
|
| Azure OpenAI Responses | `AZURE_OPENAI_API_KEY` | `azure-openai-responses` |
|
|
23
21
|
| OpenAI | `OPENAI_API_KEY` | `openai` |
|
|
22
|
+
| DeepSeek | `DEEPSEEK_API_KEY` | `deepseek` |
|
|
24
23
|
| Google Gemini | `GEMINI_API_KEY` | `google` |
|
|
25
24
|
| Mistral | `MISTRAL_API_KEY` | `mistral` |
|
|
26
25
|
| Groq | `GROQ_API_KEY` | `groq` |
|
|
27
26
|
| Cerebras | `CEREBRAS_API_KEY` | `cerebras` |
|
|
27
|
+
| Cloudflare AI Gateway | `CLOUDFLARE_API_KEY` (+ `CLOUDFLARE_ACCOUNT_ID`, `CLOUDFLARE_GATEWAY_ID`) | `cloudflare-ai-gateway` |
|
|
28
|
+
| Cloudflare Workers AI | `CLOUDFLARE_API_KEY` (+ `CLOUDFLARE_ACCOUNT_ID`) | `cloudflare-workers-ai` |
|
|
28
29
|
| xAI | `XAI_API_KEY` | `xai` |
|
|
29
30
|
| OpenRouter | `OPENROUTER_API_KEY` | `openrouter` |
|
|
30
31
|
| Vercel AI Gateway | `AI_GATEWAY_API_KEY` | `vercel-ai-gateway` |
|
|
@@ -32,9 +33,13 @@ Use `/logout` to clear stored OAuth credentials.
|
|
|
32
33
|
| OpenCode Zen | `OPENCODE_API_KEY` | `opencode` |
|
|
33
34
|
| OpenCode Go | `OPENCODE_API_KEY` | `opencode-go` |
|
|
34
35
|
| Hugging Face | `HF_TOKEN` | `huggingface` |
|
|
36
|
+
| Fireworks | `FIREWORKS_API_KEY` | `fireworks` |
|
|
37
|
+
| Together AI | `TOGETHER_API_KEY` | `together` |
|
|
35
38
|
| Kimi For Coding | `KIMI_API_KEY` | `kimi-coding` |
|
|
36
39
|
| MiniMax | `MINIMAX_API_KEY` | `minimax` |
|
|
37
40
|
| MiniMax (China) | `MINIMAX_CN_API_KEY` | `minimax-cn` |
|
|
41
|
+
| Xiaomi MiMo | `XIAOMI_API_KEY` | `xiaomi` |
|
|
42
|
+
| Xiaomi MiMo Token Plan (CN/AMS/SGP) | `XIAOMI_TOKEN_PLAN_{CN,AMS,SGP}_API_KEY` | `xiaomi-token-plan-{cn,ams,sgp}` |
|
|
38
43
|
|
|
39
44
|
## Auth File
|
|
40
45
|
|
|
@@ -68,6 +73,11 @@ Use `/logout` to clear stored OAuth credentials.
|
|
|
68
73
|
```bash
|
|
69
74
|
export AZURE_OPENAI_API_KEY=...
|
|
70
75
|
export AZURE_OPENAI_BASE_URL=https://your-resource.openai.azure.com
|
|
76
|
+
# Cognitive Services endpoints are also supported and auto-normalized to /openai/v1:
|
|
77
|
+
# export AZURE_OPENAI_BASE_URL=https://your-resource.cognitiveservices.azure.com
|
|
78
|
+
# Or supply the resource name only:
|
|
79
|
+
export AZURE_OPENAI_RESOURCE_NAME=your-resource
|
|
80
|
+
|
|
71
81
|
export AZURE_OPENAI_API_VERSION=2024-02-01
|
|
72
82
|
export AZURE_OPENAI_DEPLOYMENT_NAME_MAP=gpt-4o=my-gpt4o
|
|
73
83
|
```
|
|
@@ -86,6 +96,18 @@ Useful extras:
|
|
|
86
96
|
- `AWS_BEDROCK_FORCE_CACHE=1` for application inference profiles
|
|
87
97
|
- `AWS_ENDPOINT_URL_BEDROCK_RUNTIME` / `AWS_BEDROCK_SKIP_AUTH` / `AWS_BEDROCK_FORCE_HTTP1` for proxies
|
|
88
98
|
|
|
99
|
+
### Cloudflare AI Gateway / Workers AI
|
|
100
|
+
|
|
101
|
+
`/login` stores `CLOUDFLARE_API_KEY`. Account ID (and gateway slug for AI Gateway) must be set as env vars:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
export CLOUDFLARE_ACCOUNT_ID=...
|
|
105
|
+
export CLOUDFLARE_GATEWAY_ID=... # AI Gateway only
|
|
106
|
+
|
|
107
|
+
pi --provider cloudflare-ai-gateway --model "claude-sonnet-4-5"
|
|
108
|
+
pi --provider cloudflare-workers-ai --model "@cf/moonshotai/kimi-k2.6"
|
|
109
|
+
```
|
|
110
|
+
|
|
89
111
|
### Google Vertex AI
|
|
90
112
|
|
|
91
113
|
Use ADC:
|
|
@@ -114,7 +136,15 @@ Use `models.json` for OpenAI-compatible, Anthropic-compatible, Google-compatible
|
|
|
114
136
|
"name": "Llama 3.2",
|
|
115
137
|
"contextWindow": 128000,
|
|
116
138
|
"maxTokens": 4096,
|
|
117
|
-
"input": ["text"]
|
|
139
|
+
"input": ["text"],
|
|
140
|
+
"thinkingLevelMap": {
|
|
141
|
+
"off": null,
|
|
142
|
+
"minimal": "low",
|
|
143
|
+
"low": "low",
|
|
144
|
+
"medium": "medium",
|
|
145
|
+
"high": "high",
|
|
146
|
+
"xhigh": "high"
|
|
147
|
+
}
|
|
118
148
|
}
|
|
119
149
|
]
|
|
120
150
|
}
|
|
@@ -133,17 +163,36 @@ Common `api` values:
|
|
|
133
163
|
- `"mistral-conversations"`
|
|
134
164
|
- `"bedrock-converse-stream"`
|
|
135
165
|
|
|
166
|
+
### Model & Compatibility Knobs
|
|
167
|
+
|
|
168
|
+
- `thinkingLevelMap` (Pi 0.72) replaces `compat.reasoningEffortMap`. Map pi levels (`off`/`minimal`/`low`/`medium`/`high`/`xhigh`) to provider values; use `null` to hide a level.
|
|
169
|
+
- `openRouterRouting` is forwarded as-is in the OpenRouter `provider` field (fallbacks, ZDR, ignore lists, throughput/latency).
|
|
170
|
+
- Advanced `compat` flags exist for proxy quirks (`cacheControlFormat`, `supportsLongCacheRetention`, `supportsEagerToolInputStreaming`, `sendSessionIdHeader`, `sendSessionAffinityHeaders`). See [Pi `docs/models.md`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/models.md) when a proxy rejects pi's defaults.
|
|
171
|
+
|
|
136
172
|
## Custom Providers via Extensions
|
|
137
173
|
|
|
138
|
-
Use extensions when you need custom streaming, custom headers,
|
|
174
|
+
Use extensions when you need custom streaming, custom headers, OAuth/device-flow logic, or want to override an existing provider's `baseUrl`/`headers`:
|
|
139
175
|
|
|
140
176
|
```typescript
|
|
177
|
+
// Full registration
|
|
141
178
|
pi.registerProvider("my-provider", {
|
|
179
|
+
name: "My Provider", // optional friendly /login label
|
|
142
180
|
baseUrl: "https://api.example.com",
|
|
143
181
|
api: "openai-completions",
|
|
144
182
|
apiKey: "MY_PROVIDER_KEY",
|
|
145
|
-
models: [
|
|
183
|
+
models: [
|
|
184
|
+
{
|
|
185
|
+
id: "my-model",
|
|
186
|
+
name: "My Model",
|
|
187
|
+
contextWindow: 128000,
|
|
188
|
+
maxTokens: 4096,
|
|
189
|
+
baseUrl: "https://us-east.api.example.com", // per-model override
|
|
190
|
+
},
|
|
191
|
+
],
|
|
146
192
|
});
|
|
193
|
+
|
|
194
|
+
// Override-only: re-route an existing built-in provider through a proxy
|
|
195
|
+
pi.registerProvider("anthropic", { baseUrl: "https://proxy.example.com" });
|
|
147
196
|
```
|
|
148
197
|
|
|
149
198
|
## SDK / Extension Auth Lookup
|
|
@@ -5,7 +5,7 @@ The SDK embeds Pi in Node.js applications via `createAgentSession()`. Use `creat
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @
|
|
8
|
+
npm install @earendil-works/pi-coding-agent
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Quick Start
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
createAgentSession,
|
|
17
17
|
ModelRegistry,
|
|
18
18
|
SessionManager,
|
|
19
|
-
} from "@
|
|
19
|
+
} from "@earendil-works/pi-coding-agent";
|
|
20
20
|
|
|
21
21
|
const authStorage = AuthStorage.create();
|
|
22
22
|
const modelRegistry = ModelRegistry.create(authStorage);
|
|
@@ -46,13 +46,12 @@ Run with `npx tsx my-script.ts`.
|
|
|
46
46
|
import {
|
|
47
47
|
AuthStorage,
|
|
48
48
|
createAgentSession,
|
|
49
|
-
createCodingTools,
|
|
50
|
-
createReadOnlyTools,
|
|
51
49
|
DefaultResourceLoader,
|
|
50
|
+
defineTool,
|
|
52
51
|
ModelRegistry,
|
|
53
52
|
SessionManager,
|
|
54
|
-
} from "@
|
|
55
|
-
import { getModel } from "@
|
|
53
|
+
} from "@earendil-works/pi-coding-agent";
|
|
54
|
+
import { getModel } from "@earendil-works/pi-ai";
|
|
56
55
|
```
|
|
57
56
|
|
|
58
57
|
## Core Options
|
|
@@ -67,22 +66,27 @@ const { session } = await createAgentSession({
|
|
|
67
66
|
agentDir: "~/.pi/agent",
|
|
68
67
|
authStorage,
|
|
69
68
|
modelRegistry,
|
|
70
|
-
model: getModel("anthropic", "claude-
|
|
69
|
+
model: getModel("anthropic", "claude-opus-4-7"),
|
|
71
70
|
thinkingLevel: "medium",
|
|
72
71
|
scopedModels: [
|
|
73
|
-
{ model: getModel("anthropic", "claude-
|
|
72
|
+
{ model: getModel("anthropic", "claude-opus-4-7"), thinkingLevel: "high" },
|
|
74
73
|
],
|
|
75
|
-
tools:
|
|
74
|
+
tools: ["read", "bash", "edit", "write"],
|
|
75
|
+
customTools: [/* defineTool(...) entries */],
|
|
76
76
|
resourceLoader: new DefaultResourceLoader(),
|
|
77
77
|
sessionManager: SessionManager.inMemory(),
|
|
78
|
+
shouldStopAfterTurn: (state) => state.turnCount >= 5,
|
|
78
79
|
});
|
|
79
80
|
```
|
|
80
81
|
|
|
81
82
|
Notes:
|
|
82
83
|
|
|
83
84
|
- `cwd` and `agentDir` control default resource discovery when using `DefaultResourceLoader`.
|
|
84
|
-
-
|
|
85
|
-
- `
|
|
85
|
+
- Pi 0.68.0 changed the SDK `tools` option from `Tool[]` to a `string[]` allowlist of built-in, extension, and custom tool names. Use `noTools: "builtin"` to disable built-ins while keeping extension/custom tools enabled, or `noTools: "all"` for none.
|
|
86
|
+
- `customTools` accepts `ToolDefinition[]`. Build them with `defineTool({...})` for full TypeScript inference.
|
|
87
|
+
- The `create*Tool(cwd)` factories still exist for code that needs explicit `AgentTool` instances (e.g. when wiring tools into pi-agent-core directly), but they are no longer the value passed to `createAgentSession({ tools })`.
|
|
88
|
+
- `DefaultResourceLoader` loads extensions, skills, prompt templates, themes, and context files. Replace it to drive resource discovery from custom sources (and it must implement `loadProjectContextFiles()` if you want `AGENTS.md`/`CLAUDE.md` discovery; that helper is also exported standalone).
|
|
89
|
+
- Pass `shouldStopAfterTurn(state) => boolean` (Pi 0.72.0) to exit the agent loop gracefully after a completed turn.
|
|
86
90
|
|
|
87
91
|
## Prompting & Queueing
|
|
88
92
|
|
|
@@ -111,7 +115,7 @@ import {
|
|
|
111
115
|
createAgentSessionServices,
|
|
112
116
|
getAgentDir,
|
|
113
117
|
SessionManager,
|
|
114
|
-
} from "@
|
|
118
|
+
} from "@earendil-works/pi-coding-agent";
|
|
115
119
|
|
|
116
120
|
const createRuntime: CreateAgentSessionRuntimeFactory = async ({
|
|
117
121
|
cwd,
|
|
@@ -140,6 +144,7 @@ let session = runtime.session;
|
|
|
140
144
|
let unsubscribe = session.subscribe(() => {});
|
|
141
145
|
|
|
142
146
|
await runtime.newSession();
|
|
147
|
+
await runtime.fork("entry-id", { position: "at" }); // "before" | "at" — `at` powers /clone
|
|
143
148
|
|
|
144
149
|
unsubscribe();
|
|
145
150
|
session = runtime.session;
|
|
@@ -213,8 +218,8 @@ session.subscribe((event) => {
|
|
|
213
218
|
Use `defineTool()` when you want a reusable custom tool definition outside `pi.registerTool(...)`:
|
|
214
219
|
|
|
215
220
|
```typescript
|
|
216
|
-
import { defineTool } from "@
|
|
217
|
-
import { Type } from "
|
|
221
|
+
import { defineTool } from "@earendil-works/pi-coding-agent";
|
|
222
|
+
import { Type } from "typebox";
|
|
218
223
|
|
|
219
224
|
const myTool = defineTool({
|
|
220
225
|
name: "my_tool",
|
|
@@ -227,7 +232,10 @@ const myTool = defineTool({
|
|
|
227
232
|
return {
|
|
228
233
|
content: [{ type: "text", text: `Result: ${params.input}` }],
|
|
229
234
|
details: {},
|
|
235
|
+
// terminate: true, // optional — end the tool batch without an automatic follow-up LLM turn
|
|
230
236
|
};
|
|
231
237
|
},
|
|
232
238
|
});
|
|
233
239
|
```
|
|
240
|
+
|
|
241
|
+
Pass these via `customTools: [myTool]` on `createAgentSession()` or via `pi.registerTool(myTool)` from inside an extension.
|
|
@@ -65,7 +65,12 @@ Edit JSON directly or use `/settings` for common interactive options.
|
|
|
65
65
|
"enabled": true,
|
|
66
66
|
"maxRetries": 3,
|
|
67
67
|
"baseDelayMs": 2000,
|
|
68
|
-
"maxDelayMs": 60000
|
|
68
|
+
"maxDelayMs": 60000,
|
|
69
|
+
"provider": {
|
|
70
|
+
"timeoutMs": 0,
|
|
71
|
+
"maxRetries": 0,
|
|
72
|
+
"maxRetryDelayMs": 0
|
|
73
|
+
}
|
|
69
74
|
}
|
|
70
75
|
}
|
|
71
76
|
```
|
|
@@ -73,6 +78,7 @@ Edit JSON directly or use `/settings` for common interactive options.
|
|
|
73
78
|
Notes:
|
|
74
79
|
|
|
75
80
|
- `retry.maxDelayMs = 0` disables the cap on server-requested retry delays.
|
|
81
|
+
- `retry.provider.*` (Pi 0.70.1) controls the underlying provider SDK's request timeout and retry/backoff — useful for slow local LLMs and flaky proxies. Pi forwards these into `streamSimple` request options when set.
|
|
76
82
|
- `branchSummary.skipPrompt` skips the confirmation step when navigating with `/tree`.
|
|
77
83
|
|
|
78
84
|
## Message Delivery
|
|
@@ -94,7 +100,9 @@ Notes:
|
|
|
94
100
|
{
|
|
95
101
|
"terminal": {
|
|
96
102
|
"showImages": true,
|
|
97
|
-
"clearOnShrink": false
|
|
103
|
+
"clearOnShrink": false,
|
|
104
|
+
"showTerminalProgress": false,
|
|
105
|
+
"imageWidthCells": 60
|
|
98
106
|
},
|
|
99
107
|
"images": {
|
|
100
108
|
"autoResize": true,
|
|
@@ -107,6 +115,19 @@ Notes:
|
|
|
107
115
|
```
|
|
108
116
|
|
|
109
117
|
- `npmCommand` is argv-style and is used for npm lookup/install operations, including git-package installs.
|
|
118
|
+
- `terminal.showTerminalProgress` (default `false` since Pi 0.70.0) toggles OSC 9;4 progress reporting in supporting terminals (iTerm2, WezTerm, Windows Terminal, Kitty).
|
|
119
|
+
- `terminal.imageWidthCells` (Pi 0.68.1) caps inline tool-output image width in terminal cells.
|
|
120
|
+
|
|
121
|
+
## Warnings & Telemetry
|
|
122
|
+
|
|
123
|
+
```json
|
|
124
|
+
{
|
|
125
|
+
"warnings": { "anthropicExtraUsage": true },
|
|
126
|
+
"enableInstallTelemetry": true
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
`enableInstallTelemetry` sends an anonymous version ping to `pi.dev` once per local changelog advance (interactive mode only). `PI_OFFLINE=1` or `PI_TELEMETRY=0` disable it.
|
|
110
131
|
|
|
111
132
|
## Sessions, Model Cycling, Markdown
|
|
112
133
|
|
|
@@ -171,14 +192,66 @@ Arrays support filtering:
|
|
|
171
192
|
- `+path` force-includes an exact path
|
|
172
193
|
- `-path` force-excludes an exact path
|
|
173
194
|
|
|
195
|
+
## CLI Flags
|
|
196
|
+
|
|
197
|
+
Run `pi --help` for the authoritative list. Most commonly:
|
|
198
|
+
|
|
199
|
+
```text
|
|
200
|
+
pi [options] [@files...] [messages...]
|
|
201
|
+
|
|
202
|
+
# package commands: install/remove/uninstall/update/list/config (all support -l for project scope)
|
|
203
|
+
|
|
204
|
+
# modes
|
|
205
|
+
-p, --print single-shot text output
|
|
206
|
+
--mode json|rpc newline-delimited events / JSON-RPC over stdio
|
|
207
|
+
--export <in> [out] export a session to HTML
|
|
208
|
+
|
|
209
|
+
# model
|
|
210
|
+
--provider <name> e.g. anthropic, openai, google
|
|
211
|
+
--model <pattern> supports provider/id and optional :<thinking>
|
|
212
|
+
--api-key <key>
|
|
213
|
+
--thinking off|minimal|low|medium|high|xhigh
|
|
214
|
+
--models <patterns> Ctrl+P cycling allowlist
|
|
215
|
+
--list-models [search]
|
|
216
|
+
|
|
217
|
+
# sessions
|
|
218
|
+
-c, --continue continue most recent session
|
|
219
|
+
-r, --resume browse and select
|
|
220
|
+
--session <path|id>
|
|
221
|
+
--fork <path|id>
|
|
222
|
+
--session-dir <dir>
|
|
223
|
+
--no-session ephemeral
|
|
224
|
+
|
|
225
|
+
# tools and resources
|
|
226
|
+
--tools <list>, -t name allowlist (read,bash,edit,write,grep,find,ls,...)
|
|
227
|
+
--no-tools, -nt disable everything
|
|
228
|
+
--no-builtin-tools, -nbt disable built-ins, keep extension/custom
|
|
229
|
+
-e, --extension <source> repeatable; npm/git/path
|
|
230
|
+
--skill <path> repeatable
|
|
231
|
+
--prompt-template <path> repeatable
|
|
232
|
+
--theme <path> repeatable
|
|
233
|
+
--no-extensions / --no-skills / --no-prompt-templates / --no-themes
|
|
234
|
+
--no-context-files, -nc skip AGENTS.md / CLAUDE.md discovery
|
|
235
|
+
|
|
236
|
+
# prompts and misc
|
|
237
|
+
--system-prompt <text> replace default
|
|
238
|
+
--append-system-prompt <text> repeatable; appended with double newlines
|
|
239
|
+
--verbose
|
|
240
|
+
```
|
|
241
|
+
|
|
174
242
|
## Environment Variables
|
|
175
243
|
|
|
176
244
|
| Variable | Effect |
|
|
177
245
|
|----------|--------|
|
|
178
246
|
| `PI_CODING_AGENT_DIR` | Override the global agent directory |
|
|
247
|
+
| `PI_CODING_AGENT_SESSION_DIR` | Override session storage; `--session-dir` still wins |
|
|
179
248
|
| `PI_PACKAGE_DIR` | Override package storage directory |
|
|
180
|
-
| `PI_SKIP_VERSION_CHECK` | Skip
|
|
181
|
-
| `
|
|
249
|
+
| `PI_SKIP_VERSION_CHECK` | Skip the `pi.dev` latest-version request at startup |
|
|
250
|
+
| `PI_OFFLINE` | Disable all startup network operations (update checks, telemetry) |
|
|
251
|
+
| `PI_TELEMETRY` | Force install telemetry on/off (`1`/`0`); does not gate update checks |
|
|
252
|
+
| `PI_CACHE_RETENTION` | Set to `long` for extended prompt-cache retention where supported |
|
|
253
|
+
| `PI_OAUTH_CALLBACK_HOST` | Bind the OAuth callback server to a custom interface |
|
|
254
|
+
| `PI_CODING_AGENT=true` | Set automatically at startup so subprocesses can detect Pi |
|
|
182
255
|
| `VISUAL`, `EDITOR` | External editor for `Ctrl+G` |
|
|
183
256
|
| Provider API key env vars | See `references/providers.md` |
|
|
184
257
|
|