@astralyn/pi 0.81.1-1 → 0.82.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.
Files changed (185) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.md +690 -677
  3. package/dist/cli/args.d.ts.map +1 -1
  4. package/dist/cli/args.js +1 -0
  5. package/dist/cli/args.js.map +1 -1
  6. package/dist/cli/config-selector.d.ts.map +1 -1
  7. package/dist/cli/config-selector.js +1 -1
  8. package/dist/cli/config-selector.js.map +1 -1
  9. package/dist/cli/startup-ui.d.ts.map +1 -1
  10. package/dist/cli/startup-ui.js +1 -1
  11. package/dist/cli/startup-ui.js.map +1 -1
  12. package/dist/cli.js +0 -0
  13. package/dist/core/agent-session.d.ts +11 -0
  14. package/dist/core/agent-session.d.ts.map +1 -1
  15. package/dist/core/agent-session.js +7 -8
  16. package/dist/core/agent-session.js.map +1 -1
  17. package/dist/core/compaction/compaction.d.ts.map +1 -1
  18. package/dist/core/compaction/compaction.js +11 -3
  19. package/dist/core/compaction/compaction.js.map +1 -1
  20. package/dist/core/extensions/runner.d.ts.map +1 -1
  21. package/dist/core/extensions/runner.js +4 -0
  22. package/dist/core/extensions/runner.js.map +1 -1
  23. package/dist/core/extensions/types.d.ts +9 -1
  24. package/dist/core/extensions/types.d.ts.map +1 -1
  25. package/dist/core/extensions/types.js.map +1 -1
  26. package/dist/core/model-config.d.ts +30 -0
  27. package/dist/core/model-config.d.ts.map +1 -1
  28. package/dist/core/model-config.js +6 -0
  29. package/dist/core/model-config.js.map +1 -1
  30. package/dist/core/model-registry.d.ts.map +1 -1
  31. package/dist/core/model-registry.js +2 -2
  32. package/dist/core/model-registry.js.map +1 -1
  33. package/dist/core/model-resolver.d.ts.map +1 -1
  34. package/dist/core/model-resolver.js +7 -0
  35. package/dist/core/model-resolver.js.map +1 -1
  36. package/dist/core/model-runtime.d.ts +0 -1
  37. package/dist/core/model-runtime.d.ts.map +1 -1
  38. package/dist/core/model-runtime.js +3 -5
  39. package/dist/core/model-runtime.js.map +1 -1
  40. package/dist/core/remote-catalog-provider.d.ts +1 -1
  41. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  42. package/dist/core/remote-catalog-provider.js +5 -10
  43. package/dist/core/remote-catalog-provider.js.map +1 -1
  44. package/dist/core/settings-manager.d.ts +1 -1
  45. package/dist/core/settings-manager.d.ts.map +1 -1
  46. package/dist/core/settings-manager.js.map +1 -1
  47. package/dist/core/system-prompt.d.ts.map +1 -1
  48. package/dist/core/system-prompt.js +1 -1
  49. package/dist/core/system-prompt.js.map +1 -1
  50. package/dist/core/tools/bash.d.ts +2 -1
  51. package/dist/core/tools/bash.d.ts.map +1 -1
  52. package/dist/core/tools/bash.js +114 -24
  53. package/dist/core/tools/bash.js.map +1 -1
  54. package/dist/core/tools/find.d.ts.map +1 -1
  55. package/dist/core/tools/find.js +1 -0
  56. package/dist/core/tools/find.js.map +1 -1
  57. package/dist/core/tools/read.d.ts.map +1 -1
  58. package/dist/core/tools/read.js +4 -3
  59. package/dist/core/tools/read.js.map +1 -1
  60. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  61. package/dist/core/tools/tool-definition-wrapper.js +5 -1
  62. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  63. package/dist/extensions/index.d.ts.map +1 -1
  64. package/dist/extensions/index.js +2 -0
  65. package/dist/extensions/index.js.map +1 -1
  66. package/dist/extensions/llama/provider.d.ts.map +1 -1
  67. package/dist/extensions/llama/provider.js +1 -2
  68. package/dist/extensions/llama/provider.js.map +1 -1
  69. package/dist/extensions/subagent/activity.d.ts +16 -0
  70. package/dist/extensions/subagent/activity.d.ts.map +1 -0
  71. package/dist/extensions/subagent/activity.js +150 -0
  72. package/dist/extensions/subagent/activity.js.map +1 -0
  73. package/dist/extensions/subagent/agents.d.ts +7 -0
  74. package/dist/extensions/subagent/agents.d.ts.map +1 -0
  75. package/dist/extensions/subagent/agents.js +218 -0
  76. package/dist/extensions/subagent/agents.js.map +1 -0
  77. package/dist/extensions/subagent/constants.d.ts +22 -0
  78. package/dist/extensions/subagent/constants.d.ts.map +1 -0
  79. package/dist/extensions/subagent/constants.js +32 -0
  80. package/dist/extensions/subagent/constants.js.map +1 -0
  81. package/dist/extensions/subagent/index.d.ts +3 -0
  82. package/dist/extensions/subagent/index.d.ts.map +1 -0
  83. package/dist/extensions/subagent/index.js +249 -0
  84. package/dist/extensions/subagent/index.js.map +1 -0
  85. package/dist/extensions/subagent/picker.d.ts +31 -0
  86. package/dist/extensions/subagent/picker.d.ts.map +1 -0
  87. package/dist/extensions/subagent/picker.js +116 -0
  88. package/dist/extensions/subagent/picker.js.map +1 -0
  89. package/dist/extensions/subagent/render.d.ts +8 -0
  90. package/dist/extensions/subagent/render.d.ts.map +1 -0
  91. package/dist/extensions/subagent/render.js +322 -0
  92. package/dist/extensions/subagent/render.js.map +1 -0
  93. package/dist/extensions/subagent/resolve.d.ts +16 -0
  94. package/dist/extensions/subagent/resolve.d.ts.map +1 -0
  95. package/dist/extensions/subagent/resolve.js +103 -0
  96. package/dist/extensions/subagent/resolve.js.map +1 -0
  97. package/dist/extensions/subagent/runner.d.ts +30 -0
  98. package/dist/extensions/subagent/runner.d.ts.map +1 -0
  99. package/dist/extensions/subagent/runner.js +355 -0
  100. package/dist/extensions/subagent/runner.js.map +1 -0
  101. package/dist/extensions/subagent/schema.d.ts +28 -0
  102. package/dist/extensions/subagent/schema.d.ts.map +1 -0
  103. package/dist/extensions/subagent/schema.js +33 -0
  104. package/dist/extensions/subagent/schema.js.map +1 -0
  105. package/dist/extensions/subagent/sdk-runner.d.ts +14 -0
  106. package/dist/extensions/subagent/sdk-runner.d.ts.map +1 -0
  107. package/dist/extensions/subagent/sdk-runner.js +210 -0
  108. package/dist/extensions/subagent/sdk-runner.js.map +1 -0
  109. package/dist/extensions/subagent/settings.d.ts +9 -0
  110. package/dist/extensions/subagent/settings.d.ts.map +1 -0
  111. package/dist/extensions/subagent/settings.js +131 -0
  112. package/dist/extensions/subagent/settings.js.map +1 -0
  113. package/dist/extensions/subagent/types.d.ts +99 -0
  114. package/dist/extensions/subagent/types.d.ts.map +1 -0
  115. package/dist/extensions/subagent/types.js +2 -0
  116. package/dist/extensions/subagent/types.js.map +1 -0
  117. package/dist/modes/interactive/components/extension-editor.d.ts +1 -2
  118. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  119. package/dist/modes/interactive/components/extension-editor.js +16 -46
  120. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  121. package/dist/modes/interactive/components/index.d.ts +1 -0
  122. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  123. package/dist/modes/interactive/components/index.js +1 -0
  124. package/dist/modes/interactive/components/index.js.map +1 -1
  125. package/dist/modes/interactive/components/tool-execution.d.ts +2 -0
  126. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  127. package/dist/modes/interactive/components/tool-execution.js +25 -4
  128. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  129. package/dist/modes/interactive/components/tool-group.d.ts +16 -0
  130. package/dist/modes/interactive/components/tool-group.d.ts.map +1 -0
  131. package/dist/modes/interactive/components/tool-group.js +64 -0
  132. package/dist/modes/interactive/components/tool-group.js.map +1 -0
  133. package/dist/modes/interactive/external-editor.d.ts +12 -0
  134. package/dist/modes/interactive/external-editor.d.ts.map +1 -0
  135. package/dist/modes/interactive/external-editor.js +37 -0
  136. package/dist/modes/interactive/external-editor.js.map +1 -0
  137. package/dist/modes/interactive/interactive-mode.d.ts +3 -1
  138. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  139. package/dist/modes/interactive/interactive-mode.js +61 -62
  140. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  141. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  142. package/dist/modes/rpc/rpc-mode.js +1 -0
  143. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  144. package/dist/rpc-entry.js +0 -0
  145. package/dist/utils/clipboard.d.ts.map +1 -1
  146. package/dist/utils/clipboard.js +19 -8
  147. package/dist/utils/clipboard.js.map +1 -1
  148. package/dist/utils/version-check.d.ts.map +1 -1
  149. package/dist/utils/version-check.js +3 -1
  150. package/dist/utils/version-check.js.map +1 -1
  151. package/docs/compaction.md +401 -401
  152. package/docs/containerization.md +111 -111
  153. package/docs/custom-provider.md +766 -763
  154. package/docs/environment-variables.md +88 -0
  155. package/docs/extensions.md +2961 -2953
  156. package/docs/index.md +80 -77
  157. package/docs/models.md +6 -2
  158. package/docs/packages.md +228 -228
  159. package/docs/providers.md +8 -1
  160. package/docs/quickstart.md +165 -165
  161. package/docs/rpc.md +1576 -1559
  162. package/docs/sdk.md +1186 -1186
  163. package/docs/session-format.md +436 -436
  164. package/docs/settings.md +1 -1
  165. package/docs/termux.md +127 -127
  166. package/docs/tui.md +942 -942
  167. package/docs/usage.md +0 -13
  168. package/examples/extensions/README.md +213 -213
  169. package/examples/extensions/custom-compaction.ts +3 -0
  170. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  171. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  172. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  173. package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
  174. package/examples/extensions/doom-overlay/doom/build.sh +0 -0
  175. package/examples/extensions/gondolin/package-lock.json +2 -2
  176. package/examples/extensions/gondolin/package.json +1 -1
  177. package/examples/extensions/handoff.ts +9 -1
  178. package/examples/extensions/sandbox/package-lock.json +2 -2
  179. package/examples/extensions/sandbox/package.json +1 -1
  180. package/examples/extensions/summarize.ts +3 -0
  181. package/examples/extensions/with-deps/package-lock.json +2 -2
  182. package/examples/extensions/with-deps/package.json +1 -1
  183. package/examples/sdk/README.md +140 -140
  184. package/npm-shrinkwrap.json +16 -15
  185. package/package.json +10 -4
package/docs/packages.md CHANGED
@@ -1,228 +1,228 @@
1
- > pi can help you create pi packages. Ask it to bundle your extensions, skills, prompt templates, or themes.
2
-
3
- # Pi Packages
4
-
5
- Pi packages bundle extensions, skills, prompt templates, and themes so you can share them through npm or git. A package can declare resources in `package.json` under the `pi` key, or use conventional directories.
6
-
7
- ## Table of Contents
8
-
9
- - [Install and Manage](#install-and-manage)
10
- - [Package Sources](#package-sources)
11
- - [Creating a Pi Package](#creating-a-pi-package)
12
- - [Package Structure](#package-structure)
13
- - [Dependencies](#dependencies)
14
- - [Package Filtering](#package-filtering)
15
- - [Enable and Disable Resources](#enable-and-disable-resources)
16
- - [Scope and Deduplication](#scope-and-deduplication)
17
-
18
- ## Install and Manage
19
-
20
- > **Security:** Pi packages run with full system access. Extensions execute arbitrary code, and skills can instruct the model to perform any action including running executables. Review source code before installing third-party packages.
21
-
22
- ```bash
23
- pi install npm:@foo/bar@1.0.0
24
- pi install git:github.com/user/repo@v1
25
- pi install https://github.com/user/repo # raw URLs work too
26
- pi install /absolute/path/to/package
27
- pi install ./relative/path/to/package
28
-
29
- pi remove npm:@foo/bar
30
- pi list # show installed packages from settings
31
- pi update # update pi only
32
- pi update --all # update pi, update packages, and reconcile pinned git refs
33
- pi update --extensions # update packages and reconcile pinned git refs only
34
- pi update --models # refresh model catalogs only
35
- pi update --self # update pi only
36
- pi update --self --force # reinstall pi even if current
37
- pi update npm:@foo/bar # update one package
38
- pi update --extension npm:@foo/bar
39
- ```
40
-
41
- These commands manage pi packages and `pi update` can update the pi CLI installation. To uninstall pi itself, see [Quickstart](quickstart.md#uninstall).
42
-
43
- By default, `install` and `remove` write to user settings (`~/.pi/agent/settings.json`). Use `-l` to write to project settings (`.pi/settings.json`) instead. Project settings can be shared with your team, and pi installs any missing packages automatically on startup after the project is trusted.
44
-
45
- To try a package without installing it, use `--extension` or `-e`. This installs to a temporary directory for the current run only:
46
-
47
- ```bash
48
- pi -e npm:@foo/bar
49
- pi -e git:github.com/user/repo
50
- ```
51
-
52
- ## Package Sources
53
-
54
- Pi accepts three source types in settings and `pi install`.
55
-
56
- ### npm
57
-
58
- ```
59
- npm:@scope/pkg@1.2.3
60
- npm:pkg
61
- ```
62
-
63
- - Versioned specs are pinned and skipped by package updates (`pi update --extensions`, `pi update --all`).
64
- - User installs go under `~/.pi/agent/npm/`.
65
- - Project installs go under `.pi/npm/`.
66
- - Set `npmCommand` in `settings.json` to pin npm package lookup and install operations to a specific wrapper command such as `mise` or `asdf`.
67
-
68
- Example:
69
-
70
- ```json
71
- {
72
- "npmCommand": ["mise", "exec", "node@20", "--", "npm"]
73
- }
74
- ```
75
-
76
- ### git
77
-
78
- ```
79
- git:github.com/user/repo@v1
80
- git:git@github.com:user/repo@v1
81
- https://github.com/user/repo@v1
82
- ssh://git@github.com/user/repo@v1
83
- ```
84
-
85
- - Without `git:` prefix, only protocol URLs are accepted (`https://`, `http://`, `ssh://`, `git://`).
86
- - With `git:` prefix, shorthand formats are accepted, including `github.com/user/repo` and `git@github.com:user/repo`.
87
- - HTTPS and SSH URLs are both supported.
88
- - SSH URLs use your configured SSH keys automatically (respects `~/.ssh/config`).
89
- - For non-interactive runs (for example CI), you can set `GIT_TERMINAL_PROMPT=0` to disable credential prompts and set `GIT_SSH_COMMAND` (for example `ssh -o BatchMode=yes -o ConnectTimeout=5`) to fail fast.
90
- - Refs are pinned tags or commits. `pi update --extensions` and `pi update --all` do not move them to newer refs, but they do reconcile an existing clone to the configured ref.
91
- - Use `pi install git:host/user/repo@new-ref` to update settings and move an existing package to a new pinned ref.
92
- - Cloned to `~/.pi/agent/git/<host>/<path>` (global) or `.pi/git/<host>/<path>` (project).
93
- - When reconciliation changes the checkout, pi resets and cleans the clone, then runs `npm install` if `package.json` exists.
94
-
95
- **SSH examples:**
96
- ```bash
97
- # git@host:path shorthand (requires git: prefix)
98
- pi install git:git@github.com:user/repo
99
-
100
- # ssh:// protocol format
101
- pi install ssh://git@github.com/user/repo
102
-
103
- # With version ref
104
- pi install git:git@github.com:user/repo@v1.0.0
105
- ```
106
-
107
- ### Local Paths
108
-
109
- ```
110
- /absolute/path/to/package
111
- ./relative/path/to/package
112
- ```
113
-
114
- Local paths point to files or directories on disk and are added to settings without copying. Relative paths are resolved against the settings file they appear in. If the path is a file, it loads as a single extension. If it is a directory, pi loads resources using package rules.
115
-
116
- ## Creating a Pi Package
117
-
118
- Add a `pi` manifest to `package.json` or use conventional directories. Include the `pi-package` keyword for discoverability.
119
-
120
- ```json
121
- {
122
- "name": "my-package",
123
- "keywords": ["pi-package"],
124
- "pi": {
125
- "extensions": ["./extensions"],
126
- "skills": ["./skills"],
127
- "prompts": ["./prompts"],
128
- "themes": ["./themes"]
129
- }
130
- }
131
- ```
132
-
133
- Paths are relative to the package root. Arrays support glob patterns and `!exclusions`.
134
-
135
- ### Gallery Metadata
136
-
137
- The [package gallery](https://pi.dev/packages) displays packages tagged with `pi-package`. Add `video` or `image` fields to show a preview:
138
-
139
- ```json
140
- {
141
- "name": "my-package",
142
- "keywords": ["pi-package"],
143
- "pi": {
144
- "extensions": ["./extensions"],
145
- "video": "https://example.com/demo.mp4",
146
- "image": "https://example.com/screenshot.png"
147
- }
148
- }
149
- ```
150
-
151
- - **video**: MP4 only. On desktop, autoplays on hover. Clicking opens a fullscreen player.
152
- - **image**: PNG, JPEG, GIF, or WebP. Displayed as a static preview.
153
-
154
- If both are set, video takes precedence.
155
-
156
- ## Package Structure
157
-
158
- ### Convention Directories
159
-
160
- If no `pi` manifest is present, pi auto-discovers resources from these directories:
161
-
162
- - `extensions/` loads `.ts` and `.js` files
163
- - `skills/` recursively finds `SKILL.md` folders and loads top-level `.md` files as skills
164
- - `prompts/` loads `.md` files
165
- - `themes/` loads `.json` files
166
-
167
- ## Dependencies
168
-
169
- Third party runtime dependencies belong in `dependencies` in `package.json`. Dependencies that do not register extensions, skills, prompt templates, or themes also belong in `dependencies`. When pi installs a package from npm or git, it runs `npm install`, so those dependencies are installed automatically.
170
-
171
- Pi bundles core packages for extensions and skills. If you import any of these, list them in `peerDependencies` with a `"*"` range and do not bundle them: `@earendil-works/pi-ai`, `@earendil-works/pi-agent-core`, `@astralyn/pi`, `@earendil-works/pi-tui`, `typebox`.
172
-
173
- Other pi packages must be bundled in your tarball. Add them to `dependencies` and `bundledDependencies`, then reference their resources through `node_modules/` paths. Pi loads packages with separate module roots, so separate installs do not collide or share modules.
174
-
175
- Example:
176
-
177
- ```json
178
- {
179
- "dependencies": {
180
- "shitty-extensions": "^1.0.1"
181
- },
182
- "bundledDependencies": ["shitty-extensions"],
183
- "pi": {
184
- "extensions": ["extensions", "node_modules/shitty-extensions/extensions"],
185
- "skills": ["skills", "node_modules/shitty-extensions/skills"]
186
- }
187
- }
188
- ```
189
-
190
- ## Package Filtering
191
-
192
- Filter what a package loads using the object form in settings:
193
-
194
- ```json
195
- {
196
- "packages": [
197
- "npm:simple-pkg",
198
- {
199
- "source": "npm:my-package",
200
- "extensions": ["extensions/*.ts", "!extensions/legacy.ts"],
201
- "skills": [],
202
- "prompts": ["prompts/review.md"],
203
- "themes": ["+themes/legacy.json"]
204
- }
205
- ]
206
- }
207
- ```
208
-
209
- `+path` and `-path` are exact paths relative to the package root.
210
-
211
- - Omit a key to load all of that type.
212
- - Use `[]` to load none of that type.
213
- - `!pattern` excludes matches.
214
- - `+path` force-includes an exact path.
215
- - `-path` force-excludes an exact path.
216
- - Filters layer on top of the manifest. They narrow down what is already allowed.
217
-
218
- ## Enable and Disable Resources
219
-
220
- Use `pi config` to enable or disable extensions, skills, prompt templates, and themes from installed packages and local directories. `pi config` starts in global settings (`~/.pi/agent/settings.json`); press Tab to switch between global and project-local modes. Use `pi config -l` to start in project overrides (`.pi/settings.json`) with inherited global resources dimmed.
221
-
222
- ## Scope and Deduplication
223
-
224
- Packages can appear in both global and project settings. If the same package appears in both, the project entry wins unless the project entry has `autoload: false`, in which case it is applied as a delta over the global entry. Identity is determined by:
225
-
226
- - npm: package name
227
- - git: repository URL without ref
228
- - local: resolved absolute path
1
+ > pi can help you create pi packages. Ask it to bundle your extensions, skills, prompt templates, or themes.
2
+
3
+ # Pi Packages
4
+
5
+ Pi packages bundle extensions, skills, prompt templates, and themes so you can share them through npm or git. A package can declare resources in `package.json` under the `pi` key, or use conventional directories.
6
+
7
+ ## Table of Contents
8
+
9
+ - [Install and Manage](#install-and-manage)
10
+ - [Package Sources](#package-sources)
11
+ - [Creating a Pi Package](#creating-a-pi-package)
12
+ - [Package Structure](#package-structure)
13
+ - [Dependencies](#dependencies)
14
+ - [Package Filtering](#package-filtering)
15
+ - [Enable and Disable Resources](#enable-and-disable-resources)
16
+ - [Scope and Deduplication](#scope-and-deduplication)
17
+
18
+ ## Install and Manage
19
+
20
+ > **Security:** Pi packages run with full system access. Extensions execute arbitrary code, and skills can instruct the model to perform any action including running executables. Review source code before installing third-party packages.
21
+
22
+ ```bash
23
+ pi install npm:@foo/bar@1.0.0
24
+ pi install git:github.com/user/repo@v1
25
+ pi install https://github.com/user/repo # raw URLs work too
26
+ pi install /absolute/path/to/package
27
+ pi install ./relative/path/to/package
28
+
29
+ pi remove npm:@foo/bar
30
+ pi list # show installed packages from settings
31
+ pi update # update pi only
32
+ pi update --all # update pi, update packages, and reconcile pinned git refs
33
+ pi update --extensions # update packages and reconcile pinned git refs only
34
+ pi update --models # refresh model catalogs only
35
+ pi update --self # update pi only
36
+ pi update --self --force # reinstall pi even if current
37
+ pi update npm:@foo/bar # update one package
38
+ pi update --extension npm:@foo/bar
39
+ ```
40
+
41
+ These commands manage pi packages and `pi update` can update the pi CLI installation. To uninstall pi itself, see [Quickstart](quickstart.md#uninstall).
42
+
43
+ By default, `install` and `remove` write to user settings (`~/.pi/agent/settings.json`). Use `-l` to write to project settings (`.pi/settings.json`) instead. Project settings can be shared with your team, and pi installs any missing packages automatically on startup after the project is trusted.
44
+
45
+ To try a package without installing it, use `--extension` or `-e`. This installs to a temporary directory for the current run only:
46
+
47
+ ```bash
48
+ pi -e npm:@foo/bar
49
+ pi -e git:github.com/user/repo
50
+ ```
51
+
52
+ ## Package Sources
53
+
54
+ Pi accepts three source types in settings and `pi install`.
55
+
56
+ ### npm
57
+
58
+ ```
59
+ npm:@scope/pkg@1.2.3
60
+ npm:pkg
61
+ ```
62
+
63
+ - Versioned specs are pinned and skipped by package updates (`pi update --extensions`, `pi update --all`).
64
+ - User installs go under `~/.pi/agent/npm/`.
65
+ - Project installs go under `.pi/npm/`.
66
+ - Set `npmCommand` in `settings.json` to pin npm package lookup and install operations to a specific wrapper command such as `mise` or `asdf`.
67
+
68
+ Example:
69
+
70
+ ```json
71
+ {
72
+ "npmCommand": ["mise", "exec", "node@20", "--", "npm"]
73
+ }
74
+ ```
75
+
76
+ ### git
77
+
78
+ ```
79
+ git:github.com/user/repo@v1
80
+ git:git@github.com:user/repo@v1
81
+ https://github.com/user/repo@v1
82
+ ssh://git@github.com/user/repo@v1
83
+ ```
84
+
85
+ - Without `git:` prefix, only protocol URLs are accepted (`https://`, `http://`, `ssh://`, `git://`).
86
+ - With `git:` prefix, shorthand formats are accepted, including `github.com/user/repo` and `git@github.com:user/repo`.
87
+ - HTTPS and SSH URLs are both supported.
88
+ - SSH URLs use your configured SSH keys automatically (respects `~/.ssh/config`).
89
+ - For non-interactive runs (for example CI), you can set `GIT_TERMINAL_PROMPT=0` to disable credential prompts and set `GIT_SSH_COMMAND` (for example `ssh -o BatchMode=yes -o ConnectTimeout=5`) to fail fast.
90
+ - Refs are pinned tags or commits. `pi update --extensions` and `pi update --all` do not move them to newer refs, but they do reconcile an existing clone to the configured ref.
91
+ - Use `pi install git:host/user/repo@new-ref` to update settings and move an existing package to a new pinned ref.
92
+ - Cloned to `~/.pi/agent/git/<host>/<path>` (global) or `.pi/git/<host>/<path>` (project).
93
+ - When reconciliation changes the checkout, pi resets and cleans the clone, then runs `npm install` if `package.json` exists.
94
+
95
+ **SSH examples:**
96
+ ```bash
97
+ # git@host:path shorthand (requires git: prefix)
98
+ pi install git:git@github.com:user/repo
99
+
100
+ # ssh:// protocol format
101
+ pi install ssh://git@github.com/user/repo
102
+
103
+ # With version ref
104
+ pi install git:git@github.com:user/repo@v1.0.0
105
+ ```
106
+
107
+ ### Local Paths
108
+
109
+ ```
110
+ /absolute/path/to/package
111
+ ./relative/path/to/package
112
+ ```
113
+
114
+ Local paths point to files or directories on disk and are added to settings without copying. Relative paths are resolved against the settings file they appear in. If the path is a file, it loads as a single extension. If it is a directory, pi loads resources using package rules.
115
+
116
+ ## Creating a Pi Package
117
+
118
+ Add a `pi` manifest to `package.json` or use conventional directories. Include the `pi-package` keyword for discoverability.
119
+
120
+ ```json
121
+ {
122
+ "name": "my-package",
123
+ "keywords": ["pi-package"],
124
+ "pi": {
125
+ "extensions": ["./extensions"],
126
+ "skills": ["./skills"],
127
+ "prompts": ["./prompts"],
128
+ "themes": ["./themes"]
129
+ }
130
+ }
131
+ ```
132
+
133
+ Paths are relative to the package root. Arrays support glob patterns and `!exclusions`.
134
+
135
+ ### Gallery Metadata
136
+
137
+ The [package gallery](https://pi.dev/packages) displays packages tagged with `pi-package`. Add `video` or `image` fields to show a preview:
138
+
139
+ ```json
140
+ {
141
+ "name": "my-package",
142
+ "keywords": ["pi-package"],
143
+ "pi": {
144
+ "extensions": ["./extensions"],
145
+ "video": "https://example.com/demo.mp4",
146
+ "image": "https://example.com/screenshot.png"
147
+ }
148
+ }
149
+ ```
150
+
151
+ - **video**: MP4 only. On desktop, autoplays on hover. Clicking opens a fullscreen player.
152
+ - **image**: PNG, JPEG, GIF, or WebP. Displayed as a static preview.
153
+
154
+ If both are set, video takes precedence.
155
+
156
+ ## Package Structure
157
+
158
+ ### Convention Directories
159
+
160
+ If no `pi` manifest is present, pi auto-discovers resources from these directories:
161
+
162
+ - `extensions/` loads `.ts` and `.js` files
163
+ - `skills/` recursively finds `SKILL.md` folders and loads top-level `.md` files as skills
164
+ - `prompts/` loads `.md` files
165
+ - `themes/` loads `.json` files
166
+
167
+ ## Dependencies
168
+
169
+ Third party runtime dependencies belong in `dependencies` in `package.json`. Dependencies that do not register extensions, skills, prompt templates, or themes also belong in `dependencies`. When pi installs a package from npm or git, it runs `npm install`, so those dependencies are installed automatically.
170
+
171
+ Pi bundles core packages for extensions and skills. If you import any of these, list them in `peerDependencies` with a `"*"` range and do not bundle them: `@earendil-works/pi-ai`, `@earendil-works/pi-agent-core`, `@astralyn/pi`, `@earendil-works/pi-tui`, `typebox`.
172
+
173
+ Other pi packages must be bundled in your tarball. Add them to `dependencies` and `bundledDependencies`, then reference their resources through `node_modules/` paths. Pi loads packages with separate module roots, so separate installs do not collide or share modules.
174
+
175
+ Example:
176
+
177
+ ```json
178
+ {
179
+ "dependencies": {
180
+ "shitty-extensions": "^1.0.1"
181
+ },
182
+ "bundledDependencies": ["shitty-extensions"],
183
+ "pi": {
184
+ "extensions": ["extensions", "node_modules/shitty-extensions/extensions"],
185
+ "skills": ["skills", "node_modules/shitty-extensions/skills"]
186
+ }
187
+ }
188
+ ```
189
+
190
+ ## Package Filtering
191
+
192
+ Filter what a package loads using the object form in settings:
193
+
194
+ ```json
195
+ {
196
+ "packages": [
197
+ "npm:simple-pkg",
198
+ {
199
+ "source": "npm:my-package",
200
+ "extensions": ["extensions/*.ts", "!extensions/legacy.ts"],
201
+ "skills": [],
202
+ "prompts": ["prompts/review.md"],
203
+ "themes": ["+themes/legacy.json"]
204
+ }
205
+ ]
206
+ }
207
+ ```
208
+
209
+ `+path` and `-path` are exact paths relative to the package root.
210
+
211
+ - Omit a key to load all of that type.
212
+ - Use `[]` to load none of that type.
213
+ - `!pattern` excludes matches.
214
+ - `+path` force-includes an exact path.
215
+ - `-path` force-excludes an exact path.
216
+ - Filters layer on top of the manifest. They narrow down what is already allowed.
217
+
218
+ ## Enable and Disable Resources
219
+
220
+ Use `pi config` to enable or disable extensions, skills, prompt templates, and themes from installed packages and local directories. `pi config` starts in global settings (`~/.pi/agent/settings.json`); press Tab to switch between global and project-local modes. Use `pi config -l` to start in project overrides (`.pi/settings.json`) with inherited global resources dimmed.
221
+
222
+ ## Scope and Deduplication
223
+
224
+ Packages can appear in both global and project settings. If the same package appears in both, the project entry wins unless the project entry has `autoload: false`, in which case it is applied as a delta over the global entry. Identity is determined by:
225
+
226
+ - npm: package name
227
+ - git: repository URL without ref
228
+ - local: resolved absolute path
package/docs/providers.md CHANGED
@@ -20,9 +20,10 @@ Use `/login` in interactive mode, then select a provider:
20
20
  - Claude Pro/Max
21
21
  - GitHub Copilot
22
22
  - xAI (Grok/X subscription)
23
+ - OpenRouter (OAuth-minted API key billed from OpenRouter credits)
23
24
  - Radius
24
25
 
25
- Use `/logout` to clear credentials. Tokens are stored in `~/.pi/agent/auth.json` and auto-refresh when expired.
26
+ Use `/logout` to clear credentials. Tokens are stored in `~/.pi/agent/auth.json` and auto-refresh when expired. OpenRouter instead mints a user-controlled API key that does not expire automatically.
26
27
 
27
28
  ### OpenAI Codex
28
29
 
@@ -43,6 +44,12 @@ Anthropic subscription auth is active for Claude Pro/Max accounts. Third-party h
43
44
  - Run `/login xai`, then select **Use a subscription**
44
45
  - `XAI_API_KEY` remains available through **Use an API key**
45
46
 
47
+ ### OpenRouter
48
+
49
+ - Run `/login openrouter`, then select **Sign in with OpenRouter** to open the OpenRouter PKCE authorization flow
50
+ - The authorization creates a user-controlled OpenRouter API key billed from your OpenRouter credits
51
+ - `OPENROUTER_API_KEY` remains available through **Use an API key**
52
+
46
53
  ### Radius
47
54
 
48
55
  Radius is a dynamic `pi-messages` gateway. `/login radius` stores OAuth tokens in `auth.json`; the gateway catalog is refreshed independently and cached in `models-store.json`. Custom Radius gateways can be declared in `models.json` with `"oauth": "radius"` and a gateway `baseUrl`.