@counterposition/skill-pi 0.78.1 → 0.80.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@counterposition/skill-pi",
3
- "version": "0.78.1",
3
+ "version": "0.80.3",
4
4
  "description": "Pi coding agent reference skill — extensions, settings, providers, SDK/RPC, packages, and .pi/ config",
5
5
  "keywords": [
6
6
  "ai-skill",
@@ -53,6 +53,7 @@ Core packages on npm (source: [github.com/earendil-works/pi](https://github.com/
53
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
54
  - **Settings** — Hierarchical JSON: project `.pi/settings.json` merges over global `~/.pi/agent/settings.json`. → `references/settings.md`
55
55
  - **Packages** — Bundles of extensions/skills/prompts/themes via npm, git, or local paths. Installed with `pi install`. → `references/packages.md`
56
+ - **Project trust** — Pi 0.79+ asks before loading project-local settings, resources, and packages; decisions persist in `~/.pi/agent/trust.json`. `--approve`/`--no-approve` override per run; `defaultProjectTrust` sets the non-interactive fallback. → `references/settings.md`
56
57
  - **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
58
  - **SDK** — Programmatic embedding via `createAgentSession()`; `createAgentSessionRuntime()` for session replacement. → `references/sdk.md`
58
59
  - **Custom providers & models** — `models.json` or extension `pi.registerProvider()` for any OpenAI-/Anthropic-/Google-compatible or custom LLM endpoint. → `references/providers.md`
@@ -25,6 +25,7 @@ import { Text } from "@earendil-works/pi-tui";
25
25
 
26
26
  - Use `typebox` (1.x) for schemas.
27
27
  - Use `StringEnum` from `@earendil-works/pi-ai` for Google-compatible string enums.
28
+ - Pi 0.80.0 moved pi-ai's old global API (`getModel`, `getModels`, `stream`, `complete`, `registerApiProvider`, ...) off the pi-ai root entrypoint to `@earendil-works/pi-ai/compat`. Extensions keep working unchanged at runtime (the extension loader aliases the root to the compat superset), but extension sources that typecheck against pi-ai's published types must import those APIs from `@earendil-works/pi-ai/compat`. `StringEnum` and the type surface remain on the root. The compat entrypoint and loader alias will be removed in a future release.
28
29
 
29
30
  ## Quick Start
30
31
 
@@ -75,8 +76,12 @@ Useful session events:
75
76
  - `session_compact`
76
77
  - `session_before_tree`
77
78
  - `session_tree`
79
+ - `session_info_changed` — observe session display-name changes
78
80
  - `session_shutdown`
79
81
  - `resources_discover`
82
+ - `project_trust` — user/global and CLI extensions only, fired before project resources load; return `{ trusted: "yes" | "no" | "undecided" }` (optionally `remember: true` to persist). The first yes/no decision wins and suppresses the built-in trust prompt.
83
+
84
+ `session_before_compact` and `session_compact` carry `reason` and `willRetry` (Pi 0.79.10) so handlers can distinguish manual `/compact`, threshold auto-compaction, and overflow-retry compaction.
80
85
 
81
86
  `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`.
82
87
 
@@ -125,6 +130,9 @@ Tool results may include `terminate: true` to end the current tool batch without
125
130
  - `ctx.getContextUsage()`
126
131
  - `ctx.compact(options?)` — trigger compaction without awaiting completion
127
132
  - `ctx.getSystemPrompt()`
133
+ - `ctx.isProjectTrusted()` — the effective project trust decision, including temporary `--approve`/`--no-approve` decisions
134
+
135
+ Use `CONFIG_DIR_NAME` (exported from `@earendil-works/pi-coding-agent`) instead of hardcoding `.pi` when building project config paths, e.g. `join(ctx.cwd, CONFIG_DIR_NAME, "my-extension.json")`.
128
136
 
129
137
  Command handlers receive `ExtensionCommandContext`, which extends the above with session-control methods that would deadlock from event handlers: `ctx.getSystemPromptOptions()` (inspect the base system-prompt inputs), `ctx.waitForIdle()`, `ctx.newSession()`, `ctx.fork()`, `ctx.switchSession()`, `ctx.navigateTree()`, and `ctx.reload()`.
130
138
 
@@ -191,7 +199,11 @@ const editorFactory = ctx.ui.getEditorComponent(); // wrap the a
191
199
 
192
200
  ctx.ui.setToolsExpanded(true);
193
201
 
194
- ctx.ui.addAutocompleteProvider((query, ctx) => /* completions */); // stack on top of slash/path provider
202
+ ctx.ui.addAutocompleteProvider((current) => ({ // stack on top of slash/path provider
203
+ triggerCharacters: ["#"], // optional natural triggers (Pi 0.79.1)
204
+ async getSuggestions(lines, cursorLine, cursorCol, options) { /* ... or delegate to current */ },
205
+ applyCompletion(...args) { return current.applyCompletion(...args); },
206
+ }));
195
207
 
196
208
  const result = await ctx.ui.custom((tui, theme, keybindings, done) => {
197
209
  return new Text("Press Enter", 0, 0);
@@ -16,16 +16,19 @@ 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 # update pi itself + all installed packages (skips pinned)
20
- pi update --self # update pi only
19
+ pi update # update pi only (changed in Pi 0.79.7)
20
+ pi update --all # update pi + packages, reconcile pinned git refs
21
21
  pi update --extensions # update packages only
22
+ pi update --self # update pi only
22
23
  pi update <source> # update one package
23
24
  pi config
24
25
  ```
25
26
 
26
- By default, `install` and `remove` write to user settings (`~/.pi/agent/settings.json`). Use `-l` to write to project settings (`.pi/settings.json`) instead.
27
+ By default, `install` and `remove` write to user settings (`~/.pi/agent/settings.json`). Use `-l` to write to project settings (`.pi/settings.json`) instead. `pi update` installs the exact version returned by the update check.
28
+
29
+ Package commands follow the project trust flow (`pi update` never prompts); pass `--approve`/`-a` or `--no-approve`/`-na` to trust or ignore project-local settings for one command.
27
30
 
28
- Project installs are shareable with a team. Pi will install missing project packages automatically on startup.
31
+ Project installs are shareable with a team. Pi will install missing project packages automatically on startup once the project is trusted.
29
32
 
30
33
  For temporary one-run testing, use `--extension` / `-e` with an npm or git source. Pi installs it into a temporary directory for that run only.
31
34
 
@@ -40,7 +43,7 @@ npm:pkg
40
43
 
41
44
  - User installs go under `~/.pi/agent/npm/`
42
45
  - Project installs go under `.pi/npm/`
43
- - Version-pinned installs are skipped by `pi update`
46
+ - Version-pinned installs are skipped by `pi update --extensions` / `--all`
44
47
  - Use `npmCommand` in settings if you need a wrapper such as `mise` or `asdf`
45
48
 
46
49
  ### git
@@ -54,7 +57,7 @@ ssh://git@github.com/user/repo@v1
54
57
 
55
58
  - Global clones live in `~/.pi/agent/git/`
56
59
  - Project clones live in `.pi/git/`
57
- - Refs pin the package and are skipped by `pi update`
60
+ - Refs pin the package; `pi update --extensions` / `--all` do not move them to newer refs but do reconcile the clone to the configured ref — use `pi install git:host/user/repo@new-ref` to move a pin
58
61
  - Pi runs `npm install` after clone/pull when `package.json` exists
59
62
 
60
63
  ### local paths
@@ -52,16 +52,25 @@ Use `/logout` to clear stored OAuth credentials. Pi 0.71.0 removed built-in Goog
52
52
  {
53
53
  "anthropic": { "type": "api_key", "key": "sk-ant-..." },
54
54
  "openai": { "type": "api_key", "key": "!op read 'OpenAI API Key'" },
55
- "google": { "type": "api_key", "key": "GEMINI_API_KEY" },
56
- "together": { "type": "api_key", "key": "TOGETHER_API_KEY" }
55
+ "google": { "type": "api_key", "key": "$GEMINI_API_KEY" },
56
+ "cloudflare-ai-gateway": {
57
+ "type": "api_key",
58
+ "key": "$CLOUDFLARE_API_KEY",
59
+ "env": {
60
+ "CLOUDFLARE_ACCOUNT_ID": "account-id",
61
+ "CLOUDFLARE_GATEWAY_ID": "gateway-id"
62
+ }
63
+ }
57
64
  }
58
65
  ```
59
66
 
60
67
  `key` values can be:
61
68
 
62
69
  - A literal secret
63
- - An environment variable name
64
- - A shell command prefixed with `!`
70
+ - `$ENV_VAR` / `${ENV_VAR}` environment interpolation (works inside larger literals). Plain uppercase names without `$` are treated as literals since Pi 0.79.4 — the old bare-env-var-name form no longer resolves.
71
+ - A shell command prefixed with `!` (stdout is used, cached for the process lifetime)
72
+
73
+ Entries may include an `env` object (Pi 0.79.5) for provider-scoped environment overrides — Cloudflare account/gateway IDs, Azure endpoints, Vertex project/location, Bedrock config, cache retention, proxies — applied without changing the project shell.
65
74
 
66
75
  ## Credential Resolution Order
67
76
 
@@ -77,8 +86,10 @@ Use `/logout` to clear stored OAuth credentials. Pi 0.71.0 removed built-in Goog
77
86
  ```bash
78
87
  export AZURE_OPENAI_API_KEY=...
79
88
  export AZURE_OPENAI_BASE_URL=https://your-resource.openai.azure.com
80
- # Cognitive Services endpoints are also supported and auto-normalized to /openai/v1:
89
+ # Cognitive Services and modern Microsoft Foundry endpoint URLs are also
90
+ # supported; root endpoints are auto-normalized to /openai/v1:
81
91
  # export AZURE_OPENAI_BASE_URL=https://your-resource.cognitiveservices.azure.com
92
+ # export AZURE_OPENAI_BASE_URL=https://your-resource.ai.azure.com
82
93
  # Or supply the resource name only:
83
94
  export AZURE_OPENAI_RESOURCE_NAME=your-resource
84
95
 
@@ -156,6 +167,8 @@ Use `models.json` for OpenAI-compatible, Anthropic-compatible, Google-compatible
156
167
  }
157
168
  ```
158
169
 
170
+ `apiKey` is optional (Pi 0.80.0): omit it when auth comes from `/login`, `auth.json`, or CLI `--api-key`. Like `auth.json` keys, `apiKey` and `headers` values support `!command` execution and `$ENV_VAR` interpolation; plain uppercase strings are literals. Keyless local servers (e.g. Ollama) should keep a dummy value so their models appear in `/model`.
171
+
159
172
  Common `api` values:
160
173
 
161
174
  - `"openai-completions"`
@@ -171,7 +184,7 @@ Common `api` values:
171
184
 
172
185
  - `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.
173
186
  - `openRouterRouting` is forwarded as-is in the OpenRouter `provider` field (fallbacks, ZDR, ignore lists, throughput/latency).
174
- - `compat.thinkingFormat` supports OpenAI-compatible reasoning variants: `openrouter` sends `reasoning: { effort }`, `together` sends `reasoning: { enabled }` plus `reasoning_effort` when supported, and `qwen-chat-template` targets local Qwen-compatible servers that read `chat_template_kwargs.enable_thinking`.
187
+ - `compat.thinkingFormat` supports OpenAI-compatible reasoning variants: `openrouter` sends `reasoning: { effort }`, `together` sends `reasoning: { enabled }` plus `reasoning_effort` when supported, `qwen-chat-template` targets local Qwen-compatible servers that read `chat_template_kwargs.enable_thinking`, and `chat-template` (Pi 0.79.9) sends configurable `chat_template_kwargs` via `compat.chatTemplateKwargs` — e.g. `{ "thinking": { "$var": "thinking.enabled" } }` for DeepSeek models behind vLLM/Hugging Face chat templates (`"$var"` accepts `"thinking.enabled"` or `"thinking.effort"`).
175
188
  - Advanced `compat` flags exist for proxy quirks (`cacheControlFormat`, `supportsReasoningEffort`, `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.
176
189
 
177
190
  ### Context Overflow Recovery
@@ -51,9 +51,11 @@ import {
51
51
  ModelRegistry,
52
52
  SessionManager,
53
53
  } from "@earendil-works/pi-coding-agent";
54
- import { getModel } from "@earendil-works/pi-ai";
54
+ import { getBuiltinModel } from "@earendil-works/pi-ai/providers/all";
55
55
  ```
56
56
 
57
+ **pi-ai 0.80.0 API move:** the old global API (`getModel`, `getModels`, `getProviders`, `stream`, `complete`, `completeSimple`, `registerApiProvider`, `getEnvApiKey`, ...) moved off the `@earendil-works/pi-ai` root entrypoint to `@earendil-works/pi-ai/compat` (a deprecated shim slated for removal). For built-in model lookup use `getBuiltinModel(provider, modelId)` from `@earendil-works/pi-ai/providers/all`, or the provider-factory API (`createModels()` / `Models.getModel()`). Extensions loaded by Pi are unaffected at runtime — the extension loader aliases the pi-ai root to the compat superset — but standalone SDK scripts and typechecked extension sources must use the new paths. The selective `@earendil-works/pi-ai/base` / `@earendil-works/pi-agent-core/base` entrypoints introduced in 0.79.8 were removed again in 0.80.0.
58
+
57
59
  ## Core Options
58
60
 
59
61
  ```typescript
@@ -66,10 +68,10 @@ const { session } = await createAgentSession({
66
68
  agentDir: "~/.pi/agent",
67
69
  authStorage,
68
70
  modelRegistry,
69
- model: getModel("anthropic", "claude-opus-4-8"),
71
+ model: getBuiltinModel("anthropic", "claude-opus-4-8"),
70
72
  thinkingLevel: "medium",
71
73
  scopedModels: [
72
- { model: getModel("anthropic", "claude-opus-4-8"), thinkingLevel: "high" },
74
+ { model: getBuiltinModel("anthropic", "claude-opus-4-8"), thinkingLevel: "high" },
73
75
  ],
74
76
  tools: ["read", "bash", "edit", "write"],
75
77
  customTools: [/* defineTool(...) entries */],
@@ -204,6 +206,18 @@ session.subscribe((event) => {
204
206
  });
205
207
  ```
206
208
 
209
+ `compaction_end` results and RPC `compact` responses include estimated post-compaction token counts (Pi 0.79.8) so clients can show the approximate context reduction.
210
+
211
+ ## RPC Mode
212
+
213
+ `pi --mode rpc` speaks newline-delimited JSON over stdio. Additions since Pi 0.79:
214
+
215
+ - `get_entries` / `get_tree` (Pi 0.80.3) read session entries and tree snapshots over RPC.
216
+ - `@earendil-works/pi-coding-agent/rpc-entry` (Pi 0.80.3) launches Pi directly in RPC mode from an importing process.
217
+ - RPC extension UI request/response types are exported from the public API (Pi 0.79.0).
218
+ - Package asset path helpers are exported from the public API (Pi 0.79.0).
219
+ - `CONFIG_DIR_NAME` and edit diff helpers (`generateDiffString`, `generateUnifiedPatch`, `EditDiffResult`) are exported for extensions and hosts (Pi 0.79.7).
220
+
207
221
  ## Resource Loader Hooks
208
222
 
209
223
  `DefaultResourceLoader` supports overrides for extensions, skills, prompts, themes, and context files. Common patterns:
@@ -39,14 +39,19 @@ Edit JSON directly or use `/settings` for common interactive options.
39
39
  "doubleEscapeAction": "tree",
40
40
  "treeFilterMode": "default",
41
41
  "editorPaddingX": 0,
42
+ "outputPad": 1,
42
43
  "autocompleteMaxVisible": 5,
43
- "showHardwareCursor": false
44
+ "showHardwareCursor": false,
45
+ "externalEditor": "code --wait"
44
46
  }
45
47
  ```
46
48
 
47
49
  - `doubleEscapeAction`: `"tree"`, `"fork"`, or `"none"`
48
50
  - `treeFilterMode`: `"default"`, `"no-tools"`, `"user-only"`, `"labeled-only"`, or `"all"`
49
51
  - In `/tree`, `Shift+T` toggles timestamps on entry labels
52
+ - `theme` also accepts `"light-name/dark-name"` (Pi 0.79.7) to switch themes automatically with the terminal color scheme; `/` is reserved in theme names for this. On first run Pi detects the terminal background and defaults to `dark` or `light`.
53
+ - `outputPad` (Pi 0.80.3, `0` or `1`) sets horizontal padding for user messages, assistant messages, and thinking blocks.
54
+ - `externalEditor` (Pi 0.80.3) sets the `Ctrl+G` external editor command and takes precedence over `$VISUAL`/`$EDITOR`.
50
55
 
51
56
  ## Compaction, Branch Summary, Retry
52
57
 
@@ -89,7 +94,8 @@ Notes:
89
94
  "followUpMode": "one-at-a-time",
90
95
  "transport": "auto",
91
96
  "httpIdleTimeoutMs": 300000,
92
- "websocketConnectTimeoutMs": 15000
97
+ "websocketConnectTimeoutMs": 15000,
98
+ "httpProxy": "http://127.0.0.1:7890"
93
99
  }
94
100
  ```
95
101
 
@@ -97,6 +103,7 @@ Notes:
97
103
  - `transport` (default `"auto"`): `"sse"`, `"websocket"`, `"websocket-cached"`, or `"auto"` — the preferred transport for providers that support several
98
104
  - `httpIdleTimeoutMs` (default `300000`) is the HTTP header/body idle timeout, also applied as the default SDK request timeout for providers that support it (e.g. OpenAI Codex WebSocket waits, llama.cpp). Set to `0` to disable.
99
105
  - `websocketConnectTimeoutMs` (default `15000`) bounds the WebSocket connect/open handshake. Set to `0` to disable.
106
+ - `httpProxy` (Pi 0.79.5, global settings only) is applied as `HTTP_PROXY` and `HTTPS_PROXY` for Pi-managed HTTP clients.
100
107
 
101
108
  ## Terminal, Images, and Shell
102
109
 
@@ -147,6 +154,21 @@ Notes:
147
154
 
148
155
  When multiple sources specify a session directory, `--session-dir` takes precedence over `sessionDir` in settings. Pi 0.65.0 removed the old `session_directory` extension/settings hook.
149
156
 
157
+ ## Project Trust
158
+
159
+ Since Pi 0.79.0, project-local settings, resources, and packages (`.pi/` settings/extensions/skills/prompts/themes, project packages) only load after the project is trusted. `AGENTS.md` / `CLAUDE.md` context files load regardless of trust. Trust is a loading gate, not a sandbox.
160
+
161
+ ```json
162
+ {
163
+ "defaultProjectTrust": "ask"
164
+ }
165
+ ```
166
+
167
+ - Interactive mode prompts on first use; `/trust` saves a decision (written to `~/.pi/agent/trust.json`; restart Pi to apply).
168
+ - `--approve`/`-a` and `--no-approve`/`-na` override trust for one run, including for `pi install` and other package commands. `pi update` never prompts.
169
+ - Non-interactive modes (`-p`, `--mode json`, `--mode rpc`) never prompt. Without a saved decision they follow `defaultProjectTrust` (global setting only): `"ask"` (default) and `"never"` skip project resources; `"always"` trusts them.
170
+ - Extensions can decide or defer trust via the `project_trust` event and inspect the outcome with `ctx.isProjectTrusted()` — see `references/extensions.md`.
171
+
150
172
  ## Resources
151
173
 
152
174
  These settings control what Pi loads from disk or packages:
@@ -240,6 +262,11 @@ pi [options] [@files...] [messages...]
240
262
  --no-extensions / --no-skills / --no-prompt-templates / --no-themes
241
263
  --no-context-files, -nc skip AGENTS.md / CLAUDE.md discovery
242
264
 
265
+ # trust and network
266
+ -a, --approve trust project-local files for this run
267
+ -na, --no-approve ignore project-local files for this run
268
+ --offline disable startup network operations (same as PI_OFFLINE=1)
269
+
243
270
  # prompts and misc
244
271
  --system-prompt <text> replace default
245
272
  --append-system-prompt <text> repeatable; appended with double newlines
@@ -259,7 +286,7 @@ pi [options] [@files...] [messages...]
259
286
  | `PI_CACHE_RETENTION` | Set to `long` for extended prompt-cache retention where supported |
260
287
  | `PI_OAUTH_CALLBACK_HOST` | Bind the OAuth callback server to a custom interface |
261
288
  | `PI_CODING_AGENT=true` | Set automatically at startup so subprocesses can detect Pi |
262
- | `VISUAL`, `EDITOR` | External editor for `Ctrl+G` |
289
+ | `VISUAL`, `EDITOR` | External editor for `Ctrl+G` (the `externalEditor` setting takes precedence) |
263
290
  | Provider API key env vars | See `references/providers.md` |
264
291
 
265
292
  ## Practical Notes
@@ -18,7 +18,7 @@ Pi discovers skills from:
18
18
  - Global:
19
19
  - `~/.pi/agent/skills/`
20
20
  - `~/.agents/skills/`
21
- - Project:
21
+ - Project (loaded only after the project is trusted; see project trust in `references/settings.md`):
22
22
  - `.pi/skills/`
23
23
  - `.agents/skills/` in `cwd` and ancestor directories
24
24
  - Packages: