@mariozechner/pi-coding-agent 0.49.3 → 0.50.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/CHANGELOG.md +99 -1
- package/README.md +310 -1230
- package/dist/cli/args.d.ts +5 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +57 -23
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/config-selector.d.ts +14 -0
- package/dist/cli/config-selector.d.ts.map +1 -0
- package/dist/cli/config-selector.js +31 -0
- package/dist/cli/config-selector.js.map +1 -0
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js +1 -1
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/core/agent-session.d.ts +53 -34
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +262 -67
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +8 -18
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +39 -55
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +2 -1
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/diagnostics.d.ts +15 -0
- package/dist/core/diagnostics.d.ts.map +1 -0
- package/dist/core/diagnostics.js +2 -0
- package/dist/core/diagnostics.js.map +1 -0
- package/dist/core/export-html/template.css +9 -0
- package/dist/core/export-html/template.js +6 -4
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +10 -1
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +9 -3
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +39 -12
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +112 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +9 -2
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +13 -0
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/model-registry.d.ts +42 -2
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +154 -44
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +3 -2
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/package-manager.d.ts +129 -0
- package/dist/core/package-manager.d.ts.map +1 -0
- package/dist/core/package-manager.js +1148 -0
- package/dist/core/package-manager.js.map +1 -0
- package/dist/core/prompt-templates.d.ts +6 -0
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +114 -54
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/resource-loader.d.ts +160 -0
- package/dist/core/resource-loader.d.ts.map +1 -0
- package/dist/core/resource-loader.js +604 -0
- package/dist/core/resource-loader.js.map +1 -0
- package/dist/core/sdk.d.ts +14 -105
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +52 -304
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +45 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +34 -16
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +104 -25
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts +18 -10
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +126 -93
- package/dist/core/skills.js.map +1 -1
- package/dist/core/system-prompt.d.ts +3 -27
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +16 -103
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +2 -1
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +4 -4
- package/dist/core/tools/read.js.map +1 -1
- package/dist/index.d.ts +12 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -6
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +209 -97
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts +5 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.js +29 -9
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts +71 -0
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/config-selector.js +468 -0
- package/dist/modes/interactive/components/config-selector.js.map +1 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +4 -0
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +1 -0
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +3 -4
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +18 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +195 -87
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.js +47 -0
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +5 -5
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +42 -2
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +535 -200
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/dark.json +1 -1
- package/dist/modes/interactive/theme/light.json +1 -1
- package/dist/modes/interactive/theme/theme-schema.json +8 -1
- package/dist/modes/interactive/theme/theme.d.ts +8 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +72 -25
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +25 -89
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +32 -92
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/utils/git.d.ts +2 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +6 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/shell.d.ts +1 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +14 -1
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/sleep.d.ts +5 -0
- package/dist/utils/sleep.d.ts.map +1 -0
- package/dist/utils/sleep.js +17 -0
- package/dist/utils/sleep.js.map +1 -0
- package/docs/compaction.md +23 -21
- package/docs/custom-provider.md +538 -0
- package/docs/development.md +69 -0
- package/docs/extensions.md +180 -118
- package/docs/images/doom-extension.png +0 -0
- package/docs/images/interactive-mode.png +0 -0
- package/docs/images/tree-view.png +0 -0
- package/docs/json.md +79 -0
- package/docs/keybindings.md +162 -0
- package/docs/models.md +193 -0
- package/docs/packages.md +163 -0
- package/docs/prompt-templates.md +67 -0
- package/docs/providers.md +147 -0
- package/docs/sdk.md +111 -178
- package/docs/session.md +167 -16
- package/docs/settings.md +216 -0
- package/docs/shell-aliases.md +13 -0
- package/docs/skills.md +111 -202
- package/docs/terminal-setup.md +65 -0
- package/docs/themes.md +295 -0
- package/docs/tui.md +36 -5
- package/docs/windows.md +17 -0
- package/examples/README.md +1 -0
- package/examples/extensions/README.md +22 -2
- package/examples/extensions/bookmark.ts +50 -0
- package/examples/extensions/custom-provider-anthropic/index.ts +604 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
- package/examples/extensions/custom-provider-anthropic/package.json +19 -0
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +349 -0
- package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
- package/examples/extensions/doom-overlay/doom/build.sh +1 -1
- package/examples/extensions/event-bus.ts +43 -0
- package/examples/extensions/message-renderer.ts +59 -0
- package/examples/extensions/session-name.ts +27 -0
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/sdk/02-custom-model.ts +3 -3
- package/examples/sdk/03-custom-prompt.ts +20 -9
- package/examples/sdk/04-skills.ts +26 -27
- package/examples/sdk/06-extensions.ts +15 -6
- package/examples/sdk/07-context-files.ts +22 -18
- package/examples/sdk/08-prompt-templates.ts +19 -14
- package/examples/sdk/09-api-keys-and-oauth.ts +5 -12
- package/examples/sdk/10-settings.ts +3 -3
- package/examples/sdk/12-full-control.ts +16 -7
- package/examples/sdk/README.md +24 -30
- package/package.json +4 -4
- package/docs/theme.md +0 -617
- package/examples/extensions/chalk-logger.ts +0 -26
package/docs/json.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# JSON Event Stream Mode
|
|
2
|
+
|
|
3
|
+
```bash
|
|
4
|
+
pi --mode json "Your prompt"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Outputs all session events as JSON lines to stdout. Useful for integrating pi into other tools or custom UIs.
|
|
8
|
+
|
|
9
|
+
## Event Types
|
|
10
|
+
|
|
11
|
+
Events are defined in [`AgentSessionEvent`](https://github.com/badlogic/pi-mono/blob/main/packages/coding-agent/src/core/agent-session.ts#L102):
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
type AgentSessionEvent =
|
|
15
|
+
| AgentEvent
|
|
16
|
+
| { type: "auto_compaction_start"; reason: "threshold" | "overflow" }
|
|
17
|
+
| { type: "auto_compaction_end"; result: CompactionResult | undefined; aborted: boolean; willRetry: boolean; errorMessage?: string }
|
|
18
|
+
| { type: "auto_retry_start"; attempt: number; maxAttempts: number; delayMs: number; errorMessage: string }
|
|
19
|
+
| { type: "auto_retry_end"; success: boolean; attempt: number; finalError?: string };
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Base events from [`AgentEvent`](https://github.com/badlogic/pi-mono/blob/main/packages/agent/src/types.ts#L179):
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
type AgentEvent =
|
|
26
|
+
// Agent lifecycle
|
|
27
|
+
| { type: "agent_start" }
|
|
28
|
+
| { type: "agent_end"; messages: AgentMessage[] }
|
|
29
|
+
// Turn lifecycle
|
|
30
|
+
| { type: "turn_start" }
|
|
31
|
+
| { type: "turn_end"; message: AgentMessage; toolResults: ToolResultMessage[] }
|
|
32
|
+
// Message lifecycle
|
|
33
|
+
| { type: "message_start"; message: AgentMessage }
|
|
34
|
+
| { type: "message_update"; message: AgentMessage; assistantMessageEvent: AssistantMessageEvent }
|
|
35
|
+
| { type: "message_end"; message: AgentMessage }
|
|
36
|
+
// Tool execution
|
|
37
|
+
| { type: "tool_execution_start"; toolCallId: string; toolName: string; args: any }
|
|
38
|
+
| { type: "tool_execution_update"; toolCallId: string; toolName: string; args: any; partialResult: any }
|
|
39
|
+
| { type: "tool_execution_end"; toolCallId: string; toolName: string; result: any; isError: boolean };
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Message Types
|
|
43
|
+
|
|
44
|
+
Base messages from [`packages/ai/src/types.ts`](https://github.com/badlogic/pi-mono/blob/main/packages/ai/src/types.ts#L134):
|
|
45
|
+
- `UserMessage` (line 134)
|
|
46
|
+
- `AssistantMessage` (line 140)
|
|
47
|
+
- `ToolResultMessage` (line 152)
|
|
48
|
+
|
|
49
|
+
Extended messages from [`packages/coding-agent/src/core/messages.ts`](https://github.com/badlogic/pi-mono/blob/main/packages/coding-agent/src/core/messages.ts#L29):
|
|
50
|
+
- `BashExecutionMessage` (line 29)
|
|
51
|
+
- `CustomMessage` (line 46)
|
|
52
|
+
- `BranchSummaryMessage` (line 55)
|
|
53
|
+
- `CompactionSummaryMessage` (line 62)
|
|
54
|
+
|
|
55
|
+
## Output Format
|
|
56
|
+
|
|
57
|
+
Each line is a JSON object. The first line is the session header:
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{"type":"session","version":3,"id":"uuid","timestamp":"...","cwd":"/path"}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Followed by events as they occur:
|
|
64
|
+
|
|
65
|
+
```json
|
|
66
|
+
{"type":"agent_start"}
|
|
67
|
+
{"type":"turn_start"}
|
|
68
|
+
{"type":"message_start","message":{"role":"assistant","content":[],...}}
|
|
69
|
+
{"type":"message_update","message":{...},"assistantMessageEvent":{"type":"text_delta","delta":"Hello",...}}
|
|
70
|
+
{"type":"message_end","message":{...}}
|
|
71
|
+
{"type":"turn_end","message":{...},"toolResults":[]}
|
|
72
|
+
{"type":"agent_end","messages":[...]}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Example
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
pi --mode json "List files" 2>/dev/null | jq -c 'select(.type == "message_end")'
|
|
79
|
+
```
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# Keybindings
|
|
2
|
+
|
|
3
|
+
All keyboard shortcuts can be customized via `~/.pi/agent/keybindings.json`. Each action can be bound to one or more keys.
|
|
4
|
+
|
|
5
|
+
## Key Format
|
|
6
|
+
|
|
7
|
+
`modifier+key` where modifiers are `ctrl`, `shift`, `alt` (combinable) and keys are:
|
|
8
|
+
|
|
9
|
+
- **Letters:** `a-z`
|
|
10
|
+
- **Special:** `escape`, `esc`, `enter`, `return`, `tab`, `space`, `backspace`, `delete`, `insert`, `clear`, `home`, `end`, `pageUp`, `pageDown`, `up`, `down`, `left`, `right`
|
|
11
|
+
- **Function:** `f1`-`f12`
|
|
12
|
+
- **Symbols:** `` ` ``, `-`, `=`, `[`, `]`, `\`, `;`, `'`, `,`, `.`, `/`, `!`, `@`, `#`, `$`, `%`, `^`, `&`, `*`, `(`, `)`, `_`, `+`, `|`, `~`, `{`, `}`, `:`, `<`, `>`, `?`
|
|
13
|
+
|
|
14
|
+
Modifier combinations: `ctrl+shift+x`, `alt+ctrl+x`, `ctrl+shift+alt+x`, etc.
|
|
15
|
+
|
|
16
|
+
## All Actions
|
|
17
|
+
|
|
18
|
+
### Cursor Movement
|
|
19
|
+
|
|
20
|
+
| Action | Default | Description |
|
|
21
|
+
|--------|---------|-------------|
|
|
22
|
+
| `cursorUp` | `up` | Move cursor up |
|
|
23
|
+
| `cursorDown` | `down` | Move cursor down |
|
|
24
|
+
| `cursorLeft` | `left` | Move cursor left |
|
|
25
|
+
| `cursorRight` | `right` | Move cursor right |
|
|
26
|
+
| `cursorWordLeft` | `alt+left`, `ctrl+left` | Move cursor word left |
|
|
27
|
+
| `cursorWordRight` | `alt+right`, `ctrl+right` | Move cursor word right |
|
|
28
|
+
| `cursorLineStart` | `home`, `ctrl+a` | Move to line start |
|
|
29
|
+
| `cursorLineEnd` | `end`, `ctrl+e` | Move to line end |
|
|
30
|
+
| `pageUp` | `pageUp` | Scroll up by page |
|
|
31
|
+
| `pageDown` | `pageDown` | Scroll down by page |
|
|
32
|
+
|
|
33
|
+
### Deletion
|
|
34
|
+
|
|
35
|
+
| Action | Default | Description |
|
|
36
|
+
|--------|---------|-------------|
|
|
37
|
+
| `deleteCharBackward` | `backspace` | Delete character backward |
|
|
38
|
+
| `deleteCharForward` | `delete` | Delete character forward |
|
|
39
|
+
| `deleteWordBackward` | `ctrl+w`, `alt+backspace` | Delete word backward |
|
|
40
|
+
| `deleteWordForward` | `alt+d`, `alt+delete` | Delete word forward |
|
|
41
|
+
| `deleteToLineStart` | `ctrl+u` | Delete to line start |
|
|
42
|
+
| `deleteToLineEnd` | `ctrl+k` | Delete to line end |
|
|
43
|
+
|
|
44
|
+
### Text Input
|
|
45
|
+
|
|
46
|
+
| Action | Default | Description |
|
|
47
|
+
|--------|---------|-------------|
|
|
48
|
+
| `newLine` | `shift+enter` | Insert new line |
|
|
49
|
+
| `submit` | `enter` | Submit input |
|
|
50
|
+
| `tab` | `tab` | Tab / autocomplete |
|
|
51
|
+
|
|
52
|
+
### Kill Ring
|
|
53
|
+
|
|
54
|
+
| Action | Default | Description |
|
|
55
|
+
|--------|---------|-------------|
|
|
56
|
+
| `yank` | `ctrl+y` | Paste most recently deleted text |
|
|
57
|
+
| `yankPop` | `alt+y` | Cycle through deleted text after yank |
|
|
58
|
+
| `undo` | `ctrl+-` | Undo last edit |
|
|
59
|
+
|
|
60
|
+
### Clipboard
|
|
61
|
+
|
|
62
|
+
| Action | Default | Description |
|
|
63
|
+
|--------|---------|-------------|
|
|
64
|
+
| `copy` | `ctrl+c` | Copy selection |
|
|
65
|
+
| `pasteImage` | `ctrl+v` | Paste image from clipboard |
|
|
66
|
+
|
|
67
|
+
### Application
|
|
68
|
+
|
|
69
|
+
| Action | Default | Description |
|
|
70
|
+
|--------|---------|-------------|
|
|
71
|
+
| `interrupt` | `escape` | Cancel / abort |
|
|
72
|
+
| `clear` | `ctrl+c` | Clear editor |
|
|
73
|
+
| `exit` | `ctrl+d` | Exit (when editor empty) |
|
|
74
|
+
| `suspend` | `ctrl+z` | Suspend to background |
|
|
75
|
+
| `externalEditor` | `ctrl+g` | Open in external editor (`$VISUAL` or `$EDITOR`) |
|
|
76
|
+
|
|
77
|
+
### Models & Thinking
|
|
78
|
+
|
|
79
|
+
| Action | Default | Description |
|
|
80
|
+
|--------|---------|-------------|
|
|
81
|
+
| `selectModel` | `ctrl+l` | Open model selector |
|
|
82
|
+
| `cycleModelForward` | `ctrl+p` | Cycle to next model |
|
|
83
|
+
| `cycleModelBackward` | `shift+ctrl+p` | Cycle to previous model |
|
|
84
|
+
| `cycleThinkingLevel` | `shift+tab` | Cycle thinking level |
|
|
85
|
+
|
|
86
|
+
### Display
|
|
87
|
+
|
|
88
|
+
| Action | Default | Description |
|
|
89
|
+
|--------|---------|-------------|
|
|
90
|
+
| `expandTools` | `ctrl+o` | Collapse/expand tool output |
|
|
91
|
+
| `toggleThinking` | `ctrl+t` | Collapse/expand thinking blocks |
|
|
92
|
+
|
|
93
|
+
### Message Queue
|
|
94
|
+
|
|
95
|
+
| Action | Default | Description |
|
|
96
|
+
|--------|---------|-------------|
|
|
97
|
+
| `followUp` | `alt+enter` | Queue follow-up message |
|
|
98
|
+
| `dequeue` | `alt+up` | Restore queued messages to editor |
|
|
99
|
+
|
|
100
|
+
### Selection (Lists, Pickers)
|
|
101
|
+
|
|
102
|
+
| Action | Default | Description |
|
|
103
|
+
|--------|---------|-------------|
|
|
104
|
+
| `selectUp` | `up` | Move selection up |
|
|
105
|
+
| `selectDown` | `down` | Move selection down |
|
|
106
|
+
| `selectPageUp` | `pageUp` | Page up in list |
|
|
107
|
+
| `selectPageDown` | `pageDown` | Page down in list |
|
|
108
|
+
| `selectConfirm` | `enter` | Confirm selection |
|
|
109
|
+
| `selectCancel` | `escape`, `ctrl+c` | Cancel selection |
|
|
110
|
+
|
|
111
|
+
### Session Picker
|
|
112
|
+
|
|
113
|
+
| Action | Default | Description |
|
|
114
|
+
|--------|---------|-------------|
|
|
115
|
+
| `toggleSessionPath` | `ctrl+p` | Toggle path display |
|
|
116
|
+
| `toggleSessionSort` | `ctrl+s` | Toggle sort mode |
|
|
117
|
+
| `renameSession` | `ctrl+r` | Rename session |
|
|
118
|
+
| `deleteSession` | `ctrl+d` | Delete session |
|
|
119
|
+
| `deleteSessionNoninvasive` | `ctrl+backspace` | Delete session (when query empty) |
|
|
120
|
+
|
|
121
|
+
## Custom Configuration
|
|
122
|
+
|
|
123
|
+
Create `~/.pi/agent/keybindings.json`:
|
|
124
|
+
|
|
125
|
+
```json
|
|
126
|
+
{
|
|
127
|
+
"cursorUp": ["up", "ctrl+p"],
|
|
128
|
+
"cursorDown": ["down", "ctrl+n"],
|
|
129
|
+
"deleteWordBackward": ["ctrl+w", "alt+backspace"]
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Each action can have a single key or an array of keys. User config overrides defaults.
|
|
134
|
+
|
|
135
|
+
### Emacs Example
|
|
136
|
+
|
|
137
|
+
```json
|
|
138
|
+
{
|
|
139
|
+
"cursorUp": ["up", "ctrl+p"],
|
|
140
|
+
"cursorDown": ["down", "ctrl+n"],
|
|
141
|
+
"cursorLeft": ["left", "ctrl+b"],
|
|
142
|
+
"cursorRight": ["right", "ctrl+f"],
|
|
143
|
+
"cursorWordLeft": ["alt+left", "alt+b"],
|
|
144
|
+
"cursorWordRight": ["alt+right", "alt+f"],
|
|
145
|
+
"deleteCharForward": ["delete", "ctrl+d"],
|
|
146
|
+
"deleteCharBackward": ["backspace", "ctrl+h"],
|
|
147
|
+
"newLine": ["shift+enter", "ctrl+j"]
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Vim Example
|
|
152
|
+
|
|
153
|
+
```json
|
|
154
|
+
{
|
|
155
|
+
"cursorUp": ["up", "alt+k"],
|
|
156
|
+
"cursorDown": ["down", "alt+j"],
|
|
157
|
+
"cursorLeft": ["left", "alt+h"],
|
|
158
|
+
"cursorRight": ["right", "alt+l"],
|
|
159
|
+
"cursorWordLeft": ["alt+left", "alt+b"],
|
|
160
|
+
"cursorWordRight": ["alt+right", "alt+w"]
|
|
161
|
+
}
|
|
162
|
+
```
|
package/docs/models.md
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# Custom Models
|
|
2
|
+
|
|
3
|
+
Add custom providers and models (Ollama, vLLM, LM Studio, proxies) via `~/.pi/agent/models.json`.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Basic Example](#basic-example)
|
|
8
|
+
- [Supported APIs](#supported-apis)
|
|
9
|
+
- [Provider Configuration](#provider-configuration)
|
|
10
|
+
- [Model Configuration](#model-configuration)
|
|
11
|
+
- [Overriding Built-in Providers](#overriding-built-in-providers)
|
|
12
|
+
- [OpenAI Compatibility](#openai-compatibility)
|
|
13
|
+
|
|
14
|
+
## Basic Example
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
{
|
|
18
|
+
"providers": {
|
|
19
|
+
"ollama": {
|
|
20
|
+
"baseUrl": "http://localhost:11434/v1",
|
|
21
|
+
"api": "openai-completions",
|
|
22
|
+
"models": [
|
|
23
|
+
{
|
|
24
|
+
"id": "llama-3.1-8b",
|
|
25
|
+
"name": "Llama 3.1 8B (Local)",
|
|
26
|
+
"contextWindow": 128000,
|
|
27
|
+
"maxTokens": 32000
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The file reloads each time you open `/model`. Edit during session; no restart needed.
|
|
36
|
+
|
|
37
|
+
## Supported APIs
|
|
38
|
+
|
|
39
|
+
| API | Description |
|
|
40
|
+
|-----|-------------|
|
|
41
|
+
| `openai-completions` | OpenAI Chat Completions (most compatible) |
|
|
42
|
+
| `openai-responses` | OpenAI Responses API |
|
|
43
|
+
| `anthropic-messages` | Anthropic Messages API |
|
|
44
|
+
| `google-generative-ai` | Google Generative AI |
|
|
45
|
+
|
|
46
|
+
Set `api` at provider level (default for all models) or model level (override per model).
|
|
47
|
+
|
|
48
|
+
## Provider Configuration
|
|
49
|
+
|
|
50
|
+
| Field | Description |
|
|
51
|
+
|-------|-------------|
|
|
52
|
+
| `baseUrl` | API endpoint URL |
|
|
53
|
+
| `api` | API type (see above) |
|
|
54
|
+
| `apiKey` | API key (see value resolution below) |
|
|
55
|
+
| `headers` | Custom headers (see value resolution below) |
|
|
56
|
+
| `authHeader` | Set `true` to add `Authorization: Bearer <apiKey>` automatically |
|
|
57
|
+
| `models` | Array of model configurations |
|
|
58
|
+
|
|
59
|
+
### Value Resolution
|
|
60
|
+
|
|
61
|
+
The `apiKey` and `headers` fields support three formats:
|
|
62
|
+
|
|
63
|
+
- **Shell command:** `"!command"` executes and uses stdout
|
|
64
|
+
```json
|
|
65
|
+
"apiKey": "!security find-generic-password -ws 'anthropic'"
|
|
66
|
+
"apiKey": "!op read 'op://vault/item/credential'"
|
|
67
|
+
```
|
|
68
|
+
- **Environment variable:** Uses the value of the named variable
|
|
69
|
+
```json
|
|
70
|
+
"apiKey": "MY_API_KEY"
|
|
71
|
+
```
|
|
72
|
+
- **Literal value:** Used directly
|
|
73
|
+
```json
|
|
74
|
+
"apiKey": "sk-..."
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Custom Headers
|
|
78
|
+
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"providers": {
|
|
82
|
+
"custom-proxy": {
|
|
83
|
+
"baseUrl": "https://proxy.example.com/v1",
|
|
84
|
+
"apiKey": "MY_API_KEY",
|
|
85
|
+
"api": "anthropic-messages",
|
|
86
|
+
"headers": {
|
|
87
|
+
"x-portkey-api-key": "PORTKEY_API_KEY",
|
|
88
|
+
"x-secret": "!op read 'op://vault/item/secret'"
|
|
89
|
+
},
|
|
90
|
+
"models": [...]
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Model Configuration
|
|
97
|
+
|
|
98
|
+
| Field | Required | Description |
|
|
99
|
+
|-------|----------|-------------|
|
|
100
|
+
| `id` | Yes | Model identifier |
|
|
101
|
+
| `name` | No | Display name |
|
|
102
|
+
| `api` | No | Override provider's API for this model |
|
|
103
|
+
| `contextWindow` | No | Context window size in tokens |
|
|
104
|
+
| `maxTokens` | No | Maximum output tokens |
|
|
105
|
+
| `reasoning` | No | Supports extended thinking |
|
|
106
|
+
| `input` | No | Input types: `["text"]` or `["text", "image"]` |
|
|
107
|
+
| `cost` | No | `{"input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0}` |
|
|
108
|
+
|
|
109
|
+
## Overriding Built-in Providers
|
|
110
|
+
|
|
111
|
+
Route a built-in provider through a proxy without redefining models:
|
|
112
|
+
|
|
113
|
+
```json
|
|
114
|
+
{
|
|
115
|
+
"providers": {
|
|
116
|
+
"anthropic": {
|
|
117
|
+
"baseUrl": "https://my-proxy.example.com/v1"
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
All built-in Anthropic models remain available. Existing OAuth or API key auth continues to work.
|
|
124
|
+
|
|
125
|
+
To fully replace a built-in provider with custom models, include the `models` array:
|
|
126
|
+
|
|
127
|
+
```json
|
|
128
|
+
{
|
|
129
|
+
"providers": {
|
|
130
|
+
"anthropic": {
|
|
131
|
+
"baseUrl": "https://my-proxy.example.com/v1",
|
|
132
|
+
"apiKey": "ANTHROPIC_API_KEY",
|
|
133
|
+
"api": "anthropic-messages",
|
|
134
|
+
"models": [...]
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## OpenAI Compatibility
|
|
141
|
+
|
|
142
|
+
For providers with partial OpenAI compatibility, use the `compat` field:
|
|
143
|
+
|
|
144
|
+
```json
|
|
145
|
+
{
|
|
146
|
+
"providers": {
|
|
147
|
+
"local-llm": {
|
|
148
|
+
"baseUrl": "http://localhost:8080/v1",
|
|
149
|
+
"api": "openai-completions",
|
|
150
|
+
"compat": {
|
|
151
|
+
"supportsUsageInStreaming": false,
|
|
152
|
+
"maxTokensField": "max_tokens"
|
|
153
|
+
},
|
|
154
|
+
"models": [...]
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
| Field | Description |
|
|
161
|
+
|-------|-------------|
|
|
162
|
+
| `supportsStore` | Provider supports `store` field |
|
|
163
|
+
| `supportsDeveloperRole` | Use `developer` vs `system` role |
|
|
164
|
+
| `supportsReasoningEffort` | Support for `reasoning_effort` parameter |
|
|
165
|
+
| `supportsUsageInStreaming` | Supports `stream_options: { include_usage: true }` (default: `true`) |
|
|
166
|
+
| `maxTokensField` | Use `max_completion_tokens` or `max_tokens` |
|
|
167
|
+
| `openRouterRouting` | OpenRouter routing config passed to OpenRouter for model/provider selection |
|
|
168
|
+
|
|
169
|
+
Example:
|
|
170
|
+
|
|
171
|
+
```json
|
|
172
|
+
{
|
|
173
|
+
"providers": {
|
|
174
|
+
"openrouter": {
|
|
175
|
+
"baseUrl": "https://openrouter.ai/api/v1",
|
|
176
|
+
"apiKey": "OPENROUTER_API_KEY",
|
|
177
|
+
"api": "openai-completions",
|
|
178
|
+
"models": [
|
|
179
|
+
{
|
|
180
|
+
"id": "openrouter/anthropic/claude-3.5-sonnet",
|
|
181
|
+
"name": "OpenRouter Claude 3.5 Sonnet",
|
|
182
|
+
"compat": {
|
|
183
|
+
"openRouterRouting": {
|
|
184
|
+
"order": ["anthropic"],
|
|
185
|
+
"fallbacks": ["openai"]
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
```
|
package/docs/packages.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
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
|
+
- [Package Filtering](#package-filtering)
|
|
14
|
+
- [Enable and Disable Resources](#enable-and-disable-resources)
|
|
15
|
+
- [Scope and Deduplication](#scope-and-deduplication)
|
|
16
|
+
|
|
17
|
+
## Install and Manage
|
|
18
|
+
|
|
19
|
+
> **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.
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pi install npm:@foo/bar@1.0.0
|
|
23
|
+
pi install git:github.com/user/repo@v1
|
|
24
|
+
pi install https://github.com/user/repo # raw URLs work too
|
|
25
|
+
|
|
26
|
+
pi remove npm:@foo/bar
|
|
27
|
+
pi list # show installed packages from settings
|
|
28
|
+
pi update # update all non-pinned packages
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
By default, `install` and `remove` write to global 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.
|
|
32
|
+
|
|
33
|
+
To try a package without installing it, use `--extension` or `-e`. This installs to a temporary directory for the current run only:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pi -e npm:@foo/bar
|
|
37
|
+
pi -e git:github.com/user/repo
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Package Sources
|
|
41
|
+
|
|
42
|
+
Pi accepts three source types in settings and `pi install`.
|
|
43
|
+
|
|
44
|
+
### npm
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
npm:@scope/pkg@1.2.3
|
|
48
|
+
npm:pkg
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
- Versioned specs are pinned and skipped by `pi update`.
|
|
52
|
+
- Global installs use `npm install -g`.
|
|
53
|
+
- Project installs go under `.pi/npm/`.
|
|
54
|
+
|
|
55
|
+
### git
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
git:github.com/user/repo@v1
|
|
59
|
+
https://github.com/user/repo@v1
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
- Raw `https://` URLs work without the `git:` prefix.
|
|
63
|
+
- Refs pin the package and skip `pi update`.
|
|
64
|
+
- Cloned to `~/.pi/agent/git/<host>/<path>` (global) or `.pi/git/<host>/<path>` (project).
|
|
65
|
+
- Runs `npm install` after clone or pull if `package.json` exists.
|
|
66
|
+
|
|
67
|
+
### Local Paths
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
/absolute/path/to/package
|
|
71
|
+
./relative/path/to/package
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Local paths work in settings but not with `pi install`. If the path is a file, it loads as a single extension. If it is a directory, pi loads resources using package rules.
|
|
75
|
+
|
|
76
|
+
## Creating a Pi Package
|
|
77
|
+
|
|
78
|
+
Add a `pi` manifest to `package.json` or use conventional directories. Include the `pi-package` keyword for discoverability.
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"name": "my-package",
|
|
83
|
+
"keywords": ["pi-package"],
|
|
84
|
+
"pi": {
|
|
85
|
+
"extensions": ["./extensions"],
|
|
86
|
+
"skills": ["./skills"],
|
|
87
|
+
"prompts": ["./prompts"],
|
|
88
|
+
"themes": ["./themes"]
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Paths are relative to the package root. Arrays support glob patterns and `!exclusions`.
|
|
94
|
+
|
|
95
|
+
## Package Structure
|
|
96
|
+
|
|
97
|
+
### Convention Directories
|
|
98
|
+
|
|
99
|
+
If no `pi` manifest is present, pi auto-discovers resources from these directories:
|
|
100
|
+
|
|
101
|
+
- `extensions/` loads `.ts` and `.js` files
|
|
102
|
+
- `skills/` recursively finds `SKILL.md` folders and loads top-level `.md` files as skills
|
|
103
|
+
- `prompts/` loads `.md` files
|
|
104
|
+
- `themes/` loads `.json` files
|
|
105
|
+
|
|
106
|
+
### Bundling Other Pi Packages
|
|
107
|
+
|
|
108
|
+
Bundle other pi packages by adding them as dependencies and listing them in `bundledDependencies`. Reference their resources via `node_modules/` paths.
|
|
109
|
+
|
|
110
|
+
```json
|
|
111
|
+
{
|
|
112
|
+
"dependencies": {
|
|
113
|
+
"shitty-extensions": "^1.0.1"
|
|
114
|
+
},
|
|
115
|
+
"bundledDependencies": ["shitty-extensions"],
|
|
116
|
+
"pi": {
|
|
117
|
+
"extensions": ["extensions", "node_modules/shitty-extensions/extensions"],
|
|
118
|
+
"skills": ["skills", "node_modules/shitty-extensions/skills"]
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
`bundledDependencies` embeds the package in the published tarball, keeping paths stable. See `pi-package-test` for a working example.
|
|
124
|
+
|
|
125
|
+
## Package Filtering
|
|
126
|
+
|
|
127
|
+
Filter what a package loads using the object form in settings:
|
|
128
|
+
|
|
129
|
+
```json
|
|
130
|
+
{
|
|
131
|
+
"packages": [
|
|
132
|
+
"npm:simple-pkg",
|
|
133
|
+
{
|
|
134
|
+
"source": "npm:my-package",
|
|
135
|
+
"extensions": ["extensions/*.ts", "!extensions/legacy.ts"],
|
|
136
|
+
"skills": [],
|
|
137
|
+
"prompts": ["prompts/review.md"],
|
|
138
|
+
"themes": ["+themes/legacy.json"]
|
|
139
|
+
}
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
`+path` and `-path` are exact paths relative to the package root.
|
|
145
|
+
|
|
146
|
+
- Omit a key to load all of that type.
|
|
147
|
+
- Use `[]` to load none of that type.
|
|
148
|
+
- `!pattern` excludes matches.
|
|
149
|
+
- `+path` force-includes an exact path.
|
|
150
|
+
- `-path` force-excludes an exact path.
|
|
151
|
+
- Filters layer on top of the manifest. They narrow down what is already allowed.
|
|
152
|
+
|
|
153
|
+
## Enable and Disable Resources
|
|
154
|
+
|
|
155
|
+
Use `pi config` to enable or disable extensions, skills, prompt templates, and themes from installed packages and local directories. Works for both global (`~/.pi/agent`) and project (`.pi/`) scopes.
|
|
156
|
+
|
|
157
|
+
## Scope and Deduplication
|
|
158
|
+
|
|
159
|
+
Packages can appear in both global and project settings. If the same package appears in both, the project entry wins. Identity is determined by:
|
|
160
|
+
|
|
161
|
+
- npm: package name
|
|
162
|
+
- git: repository URL without ref
|
|
163
|
+
- local: resolved absolute path
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
> pi can create prompt templates. Ask it to build one for your workflow.
|
|
2
|
+
|
|
3
|
+
# Prompt Templates
|
|
4
|
+
|
|
5
|
+
Prompt templates are Markdown snippets that expand into full prompts. Type `/name` in the editor to invoke a template, where `name` is the filename without `.md`.
|
|
6
|
+
|
|
7
|
+
## Locations
|
|
8
|
+
|
|
9
|
+
Pi loads prompt templates from:
|
|
10
|
+
|
|
11
|
+
- Global: `~/.pi/agent/prompts/*.md`
|
|
12
|
+
- Project: `.pi/prompts/*.md`
|
|
13
|
+
- Packages: `prompts/` directories or `pi.prompts` entries in `package.json`
|
|
14
|
+
- Settings: `prompts` array with files or directories
|
|
15
|
+
- CLI: `--prompt-template <path>` (repeatable)
|
|
16
|
+
|
|
17
|
+
Disable discovery with `--no-prompt-templates`.
|
|
18
|
+
|
|
19
|
+
## Format
|
|
20
|
+
|
|
21
|
+
```markdown
|
|
22
|
+
---
|
|
23
|
+
description: Review staged git changes
|
|
24
|
+
---
|
|
25
|
+
Review the staged changes (`git diff --cached`). Focus on:
|
|
26
|
+
- Bugs and logic errors
|
|
27
|
+
- Security issues
|
|
28
|
+
- Error handling gaps
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
- The filename becomes the command name. `review.md` becomes `/review`.
|
|
32
|
+
- `description` is optional. If missing, the first non-empty line is used.
|
|
33
|
+
|
|
34
|
+
## Usage
|
|
35
|
+
|
|
36
|
+
Type `/` followed by the template name in the editor. Autocomplete shows available templates with descriptions.
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
/review # Expands review.md
|
|
40
|
+
/component Button # Expands with argument
|
|
41
|
+
/component Button "click handler" # Multiple arguments
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Arguments
|
|
45
|
+
|
|
46
|
+
Templates support positional arguments and simple slicing:
|
|
47
|
+
|
|
48
|
+
- `$1`, `$2`, ... positional args
|
|
49
|
+
- `$@` or `$ARGUMENTS` for all args joined
|
|
50
|
+
- `${@:N}` for args from the Nth position (1-indexed)
|
|
51
|
+
- `${@:N:L}` for `L` args starting at N
|
|
52
|
+
|
|
53
|
+
Example:
|
|
54
|
+
|
|
55
|
+
```markdown
|
|
56
|
+
---
|
|
57
|
+
description: Create a component
|
|
58
|
+
---
|
|
59
|
+
Create a React component named $1 with features: $@
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Usage: `/component Button "onClick handler" "disabled support"`
|
|
63
|
+
|
|
64
|
+
## Loading Rules
|
|
65
|
+
|
|
66
|
+
- Template discovery in `prompts/` is non-recursive.
|
|
67
|
+
- If you want templates in subdirectories, add them explicitly via `prompts` settings or a package manifest.
|