@hyperspaceng/neural-coding-agent 0.60.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 +3188 -0
- package/README.md +586 -0
- package/docs/compaction.md +392 -0
- package/docs/custom-provider.md +596 -0
- package/docs/development.md +69 -0
- package/docs/extensions.md +2048 -0
- package/docs/images/doom-extension.png +0 -0
- package/docs/images/exy.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 +184 -0
- package/docs/models.md +335 -0
- package/docs/packages.md +218 -0
- package/docs/prompt-templates.md +67 -0
- package/docs/providers.md +195 -0
- package/docs/rpc.md +1354 -0
- package/docs/sdk.md +968 -0
- package/docs/session.md +412 -0
- package/docs/settings.md +234 -0
- package/docs/shell-aliases.md +13 -0
- package/docs/skills.md +231 -0
- package/docs/terminal-setup.md +106 -0
- package/docs/termux.md +127 -0
- package/docs/themes.md +295 -0
- package/docs/tmux.md +61 -0
- package/docs/tree.md +228 -0
- package/docs/tui.md +887 -0
- package/docs/windows.md +17 -0
- package/examples/README.md +25 -0
- package/examples/extensions/README.md +205 -0
- package/examples/extensions/antigravity-image-gen.ts +416 -0
- package/examples/extensions/auto-commit-on-exit.ts +49 -0
- package/examples/extensions/bash-spawn-hook.ts +30 -0
- package/examples/extensions/bookmark.ts +50 -0
- package/examples/extensions/built-in-tool-renderer.ts +246 -0
- package/examples/extensions/claude-rules.ts +86 -0
- package/examples/extensions/commands.ts +72 -0
- package/examples/extensions/confirm-destructive.ts +59 -0
- package/examples/extensions/custom-compaction.ts +114 -0
- package/examples/extensions/custom-footer.ts +64 -0
- package/examples/extensions/custom-header.ts +73 -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/custom-provider-qwen-cli/index.ts +345 -0
- package/examples/extensions/custom-provider-qwen-cli/package.json +16 -0
- package/examples/extensions/dirty-repo-guard.ts +56 -0
- package/examples/extensions/doom-overlay/README.md +46 -0
- package/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
- package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/examples/extensions/doom-overlay/doom/build.sh +152 -0
- package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
- package/examples/extensions/doom-overlay/doom-component.ts +132 -0
- package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
- package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
- package/examples/extensions/doom-overlay/index.ts +74 -0
- package/examples/extensions/doom-overlay/wad-finder.ts +51 -0
- package/examples/extensions/dynamic-resources/SKILL.md +8 -0
- package/examples/extensions/dynamic-resources/dynamic.json +79 -0
- package/examples/extensions/dynamic-resources/dynamic.md +5 -0
- package/examples/extensions/dynamic-resources/index.ts +15 -0
- package/examples/extensions/dynamic-tools.ts +74 -0
- package/examples/extensions/event-bus.ts +43 -0
- package/examples/extensions/file-trigger.ts +41 -0
- package/examples/extensions/git-checkpoint.ts +53 -0
- package/examples/extensions/handoff.ts +150 -0
- package/examples/extensions/hello.ts +25 -0
- package/examples/extensions/inline-bash.ts +94 -0
- package/examples/extensions/input-transform.ts +43 -0
- package/examples/extensions/interactive-shell.ts +196 -0
- package/examples/extensions/mac-system-theme.ts +47 -0
- package/examples/extensions/message-renderer.ts +59 -0
- package/examples/extensions/minimal-mode.ts +426 -0
- package/examples/extensions/modal-editor.ts +85 -0
- package/examples/extensions/model-status.ts +31 -0
- package/examples/extensions/notify.ts +55 -0
- package/examples/extensions/overlay-qa-tests.ts +1348 -0
- package/examples/extensions/overlay-test.ts +150 -0
- package/examples/extensions/permission-gate.ts +34 -0
- package/examples/extensions/pirate.ts +47 -0
- package/examples/extensions/plan-mode/README.md +65 -0
- package/examples/extensions/plan-mode/index.ts +340 -0
- package/examples/extensions/plan-mode/utils.ts +168 -0
- package/examples/extensions/preset.ts +397 -0
- package/examples/extensions/protected-paths.ts +30 -0
- package/examples/extensions/provider-payload.ts +14 -0
- package/examples/extensions/qna.ts +119 -0
- package/examples/extensions/question.ts +264 -0
- package/examples/extensions/questionnaire.ts +427 -0
- package/examples/extensions/rainbow-editor.ts +88 -0
- package/examples/extensions/reload-runtime.ts +37 -0
- package/examples/extensions/rpc-demo.ts +124 -0
- package/examples/extensions/sandbox/index.ts +317 -0
- package/examples/extensions/sandbox/package-lock.json +92 -0
- package/examples/extensions/sandbox/package.json +19 -0
- package/examples/extensions/send-user-message.ts +97 -0
- package/examples/extensions/session-name.ts +27 -0
- package/examples/extensions/shutdown-command.ts +63 -0
- package/examples/extensions/snake.ts +343 -0
- package/examples/extensions/space-invaders.ts +560 -0
- package/examples/extensions/ssh.ts +220 -0
- package/examples/extensions/status-line.ts +40 -0
- package/examples/extensions/subagent/README.md +172 -0
- package/examples/extensions/subagent/agents/planner.md +37 -0
- package/examples/extensions/subagent/agents/reviewer.md +35 -0
- package/examples/extensions/subagent/agents/scout.md +50 -0
- package/examples/extensions/subagent/agents/worker.md +24 -0
- package/examples/extensions/subagent/agents.ts +126 -0
- package/examples/extensions/subagent/index.ts +964 -0
- package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
- package/examples/extensions/subagent/prompts/implement.md +10 -0
- package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
- package/examples/extensions/summarize.ts +195 -0
- package/examples/extensions/system-prompt-header.ts +17 -0
- package/examples/extensions/timed-confirm.ts +70 -0
- package/examples/extensions/titlebar-spinner.ts +58 -0
- package/examples/extensions/todo.ts +299 -0
- package/examples/extensions/tool-override.ts +142 -0
- package/examples/extensions/tools.ts +146 -0
- package/examples/extensions/trigger-compact.ts +40 -0
- package/examples/extensions/truncated-tool.ts +192 -0
- package/examples/extensions/widget-placement.ts +17 -0
- package/examples/extensions/with-deps/index.ts +32 -0
- package/examples/extensions/with-deps/package-lock.json +31 -0
- package/examples/extensions/with-deps/package.json +22 -0
- package/examples/rpc-extension-ui.ts +632 -0
- package/examples/sdk/01-minimal.ts +22 -0
- package/examples/sdk/02-custom-model.ts +49 -0
- package/examples/sdk/03-custom-prompt.ts +55 -0
- package/examples/sdk/04-skills.ts +46 -0
- package/examples/sdk/05-tools.ts +56 -0
- package/examples/sdk/06-extensions.ts +88 -0
- package/examples/sdk/07-context-files.ts +40 -0
- package/examples/sdk/08-prompt-templates.ts +47 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +48 -0
- package/examples/sdk/10-settings.ts +51 -0
- package/examples/sdk/11-sessions.ts +48 -0
- package/examples/sdk/12-full-control.ts +82 -0
- package/examples/sdk/README.md +144 -0
- package/package.json +99 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
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,184 @@
|
|
|
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
|
+
After editing `keybindings.json`, run `/reload` in pi to apply the changes without restarting the session.
|
|
6
|
+
|
|
7
|
+
## Key Format
|
|
8
|
+
|
|
9
|
+
`modifier+key` where modifiers are `ctrl`, `shift`, `alt` (combinable) and keys are:
|
|
10
|
+
|
|
11
|
+
- **Letters:** `a-z`
|
|
12
|
+
- **Digits:** `0-9`
|
|
13
|
+
- **Special:** `escape`, `esc`, `enter`, `return`, `tab`, `space`, `backspace`, `delete`, `insert`, `clear`, `home`, `end`, `pageUp`, `pageDown`, `up`, `down`, `left`, `right`
|
|
14
|
+
- **Function:** `f1`-`f12`
|
|
15
|
+
- **Symbols:** `` ` ``, `-`, `=`, `[`, `]`, `\`, `;`, `'`, `,`, `.`, `/`, `!`, `@`, `#`, `$`, `%`, `^`, `&`, `*`, `(`, `)`, `_`, `+`, `|`, `~`, `{`, `}`, `:`, `<`, `>`, `?`
|
|
16
|
+
|
|
17
|
+
Modifier combinations: `ctrl+shift+x`, `alt+ctrl+x`, `ctrl+shift+alt+x`, `ctrl+1`, etc.
|
|
18
|
+
|
|
19
|
+
## All Actions
|
|
20
|
+
|
|
21
|
+
### Cursor Movement
|
|
22
|
+
|
|
23
|
+
| Action | Default | Description |
|
|
24
|
+
|--------|---------|-------------|
|
|
25
|
+
| `cursorUp` | `up` | Move cursor up |
|
|
26
|
+
| `cursorDown` | `down` | Move cursor down |
|
|
27
|
+
| `cursorLeft` | `left`, `ctrl+b` | Move cursor left |
|
|
28
|
+
| `cursorRight` | `right`, `ctrl+f` | Move cursor right |
|
|
29
|
+
| `cursorWordLeft` | `alt+left`, `ctrl+left`, `alt+b` | Move cursor word left |
|
|
30
|
+
| `cursorWordRight` | `alt+right`, `ctrl+right`, `alt+f` | Move cursor word right |
|
|
31
|
+
| `cursorLineStart` | `home`, `ctrl+a` | Move to line start |
|
|
32
|
+
| `cursorLineEnd` | `end`, `ctrl+e` | Move to line end |
|
|
33
|
+
| `jumpForward` | `ctrl+]` | Jump forward to character |
|
|
34
|
+
| `jumpBackward` | `ctrl+alt+]` | Jump backward to character |
|
|
35
|
+
| `pageUp` | `pageUp` | Scroll up by page |
|
|
36
|
+
| `pageDown` | `pageDown` | Scroll down by page |
|
|
37
|
+
|
|
38
|
+
### Deletion
|
|
39
|
+
|
|
40
|
+
| Action | Default | Description |
|
|
41
|
+
|--------|---------|-------------|
|
|
42
|
+
| `deleteCharBackward` | `backspace` | Delete character backward |
|
|
43
|
+
| `deleteCharForward` | `delete`, `ctrl+d` | Delete character forward |
|
|
44
|
+
| `deleteWordBackward` | `ctrl+w`, `alt+backspace` | Delete word backward |
|
|
45
|
+
| `deleteWordForward` | `alt+d`, `alt+delete` | Delete word forward |
|
|
46
|
+
| `deleteToLineStart` | `ctrl+u` | Delete to line start |
|
|
47
|
+
| `deleteToLineEnd` | `ctrl+k` | Delete to line end |
|
|
48
|
+
|
|
49
|
+
### Text Input
|
|
50
|
+
|
|
51
|
+
| Action | Default | Description |
|
|
52
|
+
|--------|---------|-------------|
|
|
53
|
+
| `newLine` | `shift+enter` | Insert new line |
|
|
54
|
+
| `submit` | `enter` | Submit input |
|
|
55
|
+
| `tab` | `tab` | Tab / autocomplete |
|
|
56
|
+
|
|
57
|
+
### Kill Ring
|
|
58
|
+
|
|
59
|
+
| Action | Default | Description |
|
|
60
|
+
|--------|---------|-------------|
|
|
61
|
+
| `yank` | `ctrl+y` | Paste most recently deleted text |
|
|
62
|
+
| `yankPop` | `alt+y` | Cycle through deleted text after yank |
|
|
63
|
+
| `undo` | `ctrl+-` | Undo last edit |
|
|
64
|
+
|
|
65
|
+
### Clipboard
|
|
66
|
+
|
|
67
|
+
| Action | Default | Description |
|
|
68
|
+
|--------|---------|-------------|
|
|
69
|
+
| `copy` | `ctrl+c` | Copy selection |
|
|
70
|
+
| `pasteImage` | `ctrl+v` | Paste image from clipboard |
|
|
71
|
+
|
|
72
|
+
### Application
|
|
73
|
+
|
|
74
|
+
| Action | Default | Description |
|
|
75
|
+
|--------|---------|-------------|
|
|
76
|
+
| `interrupt` | `escape` | Cancel / abort |
|
|
77
|
+
| `clear` | `ctrl+c` | Clear editor |
|
|
78
|
+
| `exit` | `ctrl+d` | Exit (when editor empty) |
|
|
79
|
+
| `suspend` | `ctrl+z` | Suspend to background |
|
|
80
|
+
| `externalEditor` | `ctrl+g` | Open in external editor (`$VISUAL` or `$EDITOR`) |
|
|
81
|
+
|
|
82
|
+
### Session
|
|
83
|
+
|
|
84
|
+
| Action | Default | Description |
|
|
85
|
+
|--------|---------|-------------|
|
|
86
|
+
| `newSession` | *(none)* | Start a new session (`/new`) |
|
|
87
|
+
| `tree` | *(none)* | Open session tree navigator (`/tree`) |
|
|
88
|
+
| `fork` | *(none)* | Fork current session (`/fork`) |
|
|
89
|
+
| `resume` | *(none)* | Open session resume picker (`/resume`) |
|
|
90
|
+
|
|
91
|
+
### Models & Thinking
|
|
92
|
+
|
|
93
|
+
| Action | Default | Description |
|
|
94
|
+
|--------|---------|-------------|
|
|
95
|
+
| `selectModel` | `ctrl+l` | Open model selector |
|
|
96
|
+
| `cycleModelForward` | `ctrl+p` | Cycle to next model |
|
|
97
|
+
| `cycleModelBackward` | `shift+ctrl+p` | Cycle to previous model |
|
|
98
|
+
| `cycleThinkingLevel` | `shift+tab` | Cycle thinking level |
|
|
99
|
+
|
|
100
|
+
### Display
|
|
101
|
+
|
|
102
|
+
| Action | Default | Description |
|
|
103
|
+
|--------|---------|-------------|
|
|
104
|
+
| `expandTools` | `ctrl+o` | Collapse/expand tool output |
|
|
105
|
+
| `toggleThinking` | `ctrl+t` | Collapse/expand thinking blocks |
|
|
106
|
+
|
|
107
|
+
### Message Queue
|
|
108
|
+
|
|
109
|
+
| Action | Default | Description |
|
|
110
|
+
|--------|---------|-------------|
|
|
111
|
+
| `followUp` | `alt+enter` | Queue follow-up message |
|
|
112
|
+
| `dequeue` | `alt+up` | Restore queued messages to editor |
|
|
113
|
+
|
|
114
|
+
### Selection (Lists, Pickers)
|
|
115
|
+
|
|
116
|
+
| Action | Default | Description |
|
|
117
|
+
|--------|---------|-------------|
|
|
118
|
+
| `selectUp` | `up` | Move selection up |
|
|
119
|
+
| `selectDown` | `down` | Move selection down |
|
|
120
|
+
| `selectPageUp` | `pageUp` | Page up in list |
|
|
121
|
+
| `selectPageDown` | `pageDown` | Page down in list |
|
|
122
|
+
| `selectConfirm` | `enter` | Confirm selection |
|
|
123
|
+
| `selectCancel` | `escape`, `ctrl+c` | Cancel selection |
|
|
124
|
+
|
|
125
|
+
### Tree Navigation
|
|
126
|
+
|
|
127
|
+
| Action | Default | Description |
|
|
128
|
+
|--------|---------|-------------|
|
|
129
|
+
| `treeFoldOrUp` | `ctrl+left`, `alt+left` | Fold current branch segment, or jump to the previous segment start |
|
|
130
|
+
| `treeUnfoldOrDown` | `ctrl+right`, `alt+right` | Unfold current branch segment, or jump to the next segment start or branch end |
|
|
131
|
+
|
|
132
|
+
### Session Picker
|
|
133
|
+
|
|
134
|
+
| Action | Default | Description |
|
|
135
|
+
|--------|---------|-------------|
|
|
136
|
+
| `toggleSessionPath` | `ctrl+p` | Toggle path display |
|
|
137
|
+
| `toggleSessionSort` | `ctrl+s` | Toggle sort mode |
|
|
138
|
+
| `toggleSessionNamedFilter` | `ctrl+n` | Toggle named-only filter |
|
|
139
|
+
| `renameSession` | `ctrl+r` | Rename session |
|
|
140
|
+
| `deleteSession` | `ctrl+d` | Delete session |
|
|
141
|
+
| `deleteSessionNoninvasive` | `ctrl+backspace` | Delete session (when query empty) |
|
|
142
|
+
|
|
143
|
+
## Custom Configuration
|
|
144
|
+
|
|
145
|
+
Create `~/.pi/agent/keybindings.json`:
|
|
146
|
+
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"cursorUp": ["up", "ctrl+p"],
|
|
150
|
+
"cursorDown": ["down", "ctrl+n"],
|
|
151
|
+
"deleteWordBackward": ["ctrl+w", "alt+backspace"]
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Each action can have a single key or an array of keys. User config overrides defaults.
|
|
156
|
+
|
|
157
|
+
### Emacs Example
|
|
158
|
+
|
|
159
|
+
```json
|
|
160
|
+
{
|
|
161
|
+
"cursorUp": ["up", "ctrl+p"],
|
|
162
|
+
"cursorDown": ["down", "ctrl+n"],
|
|
163
|
+
"cursorLeft": ["left", "ctrl+b"],
|
|
164
|
+
"cursorRight": ["right", "ctrl+f"],
|
|
165
|
+
"cursorWordLeft": ["alt+left", "alt+b"],
|
|
166
|
+
"cursorWordRight": ["alt+right", "alt+f"],
|
|
167
|
+
"deleteCharForward": ["delete", "ctrl+d"],
|
|
168
|
+
"deleteCharBackward": ["backspace", "ctrl+h"],
|
|
169
|
+
"newLine": ["shift+enter", "ctrl+j"]
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Vim Example
|
|
174
|
+
|
|
175
|
+
```json
|
|
176
|
+
{
|
|
177
|
+
"cursorUp": ["up", "alt+k"],
|
|
178
|
+
"cursorDown": ["down", "alt+j"],
|
|
179
|
+
"cursorLeft": ["left", "alt+h"],
|
|
180
|
+
"cursorRight": ["right", "alt+l"],
|
|
181
|
+
"cursorWordLeft": ["alt+left", "alt+b"],
|
|
182
|
+
"cursorWordRight": ["alt+right", "alt+w"]
|
|
183
|
+
}
|
|
184
|
+
```
|
package/docs/models.md
ADDED
|
@@ -0,0 +1,335 @@
|
|
|
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
|
+
- [Minimal Example](#minimal-example)
|
|
8
|
+
- [Full Example](#full-example)
|
|
9
|
+
- [Supported APIs](#supported-apis)
|
|
10
|
+
- [Provider Configuration](#provider-configuration)
|
|
11
|
+
- [Model Configuration](#model-configuration)
|
|
12
|
+
- [Overriding Built-in Providers](#overriding-built-in-providers)
|
|
13
|
+
- [Per-model Overrides](#per-model-overrides)
|
|
14
|
+
- [OpenAI Compatibility](#openai-compatibility)
|
|
15
|
+
|
|
16
|
+
## Minimal Example
|
|
17
|
+
|
|
18
|
+
For local models (Ollama, LM Studio, vLLM), only `id` is required per model:
|
|
19
|
+
|
|
20
|
+
```json
|
|
21
|
+
{
|
|
22
|
+
"providers": {
|
|
23
|
+
"ollama": {
|
|
24
|
+
"baseUrl": "http://localhost:11434/v1",
|
|
25
|
+
"api": "openai-completions",
|
|
26
|
+
"apiKey": "ollama",
|
|
27
|
+
"models": [
|
|
28
|
+
{ "id": "llama3.1:8b" },
|
|
29
|
+
{ "id": "qwen2.5-coder:7b" }
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
The `apiKey` is required but Ollama ignores it, so any value works.
|
|
37
|
+
|
|
38
|
+
Some OpenAI-compatible servers do not understand the `developer` role used for reasoning-capable models. For those providers, set `compat.supportsDeveloperRole` to `false` so pi sends the system prompt as a `system` message instead. If the server also does not support `reasoning_effort`, set `compat.supportsReasoningEffort` to `false` too.
|
|
39
|
+
|
|
40
|
+
You can set `compat` at the provider level to apply to all models, or at the model level to override a specific model. This commonly applies to Ollama, vLLM, SGLang, and similar OpenAI-compatible servers.
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"providers": {
|
|
45
|
+
"ollama": {
|
|
46
|
+
"baseUrl": "http://localhost:11434/v1",
|
|
47
|
+
"api": "openai-completions",
|
|
48
|
+
"apiKey": "ollama",
|
|
49
|
+
"compat": {
|
|
50
|
+
"supportsDeveloperRole": false,
|
|
51
|
+
"supportsReasoningEffort": false
|
|
52
|
+
},
|
|
53
|
+
"models": [
|
|
54
|
+
{
|
|
55
|
+
"id": "gpt-oss:20b",
|
|
56
|
+
"reasoning": true
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Full Example
|
|
65
|
+
|
|
66
|
+
Override defaults when you need specific values:
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"providers": {
|
|
71
|
+
"ollama": {
|
|
72
|
+
"baseUrl": "http://localhost:11434/v1",
|
|
73
|
+
"api": "openai-completions",
|
|
74
|
+
"apiKey": "ollama",
|
|
75
|
+
"models": [
|
|
76
|
+
{
|
|
77
|
+
"id": "llama3.1:8b",
|
|
78
|
+
"name": "Llama 3.1 8B (Local)",
|
|
79
|
+
"reasoning": false,
|
|
80
|
+
"input": ["text"],
|
|
81
|
+
"contextWindow": 128000,
|
|
82
|
+
"maxTokens": 32000,
|
|
83
|
+
"cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 }
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The file reloads each time you open `/model`. Edit during session; no restart needed.
|
|
92
|
+
|
|
93
|
+
## Supported APIs
|
|
94
|
+
|
|
95
|
+
| API | Description |
|
|
96
|
+
|-----|-------------|
|
|
97
|
+
| `openai-completions` | OpenAI Chat Completions (most compatible) |
|
|
98
|
+
| `openai-responses` | OpenAI Responses API |
|
|
99
|
+
| `anthropic-messages` | Anthropic Messages API |
|
|
100
|
+
| `google-generative-ai` | Google Generative AI |
|
|
101
|
+
|
|
102
|
+
Set `api` at provider level (default for all models) or model level (override per model).
|
|
103
|
+
|
|
104
|
+
## Provider Configuration
|
|
105
|
+
|
|
106
|
+
| Field | Description |
|
|
107
|
+
|-------|-------------|
|
|
108
|
+
| `baseUrl` | API endpoint URL |
|
|
109
|
+
| `api` | API type (see above) |
|
|
110
|
+
| `apiKey` | API key (see value resolution below) |
|
|
111
|
+
| `headers` | Custom headers (see value resolution below) |
|
|
112
|
+
| `authHeader` | Set `true` to add `Authorization: Bearer <apiKey>` automatically |
|
|
113
|
+
| `models` | Array of model configurations |
|
|
114
|
+
| `modelOverrides` | Per-model overrides for built-in models on this provider |
|
|
115
|
+
|
|
116
|
+
### Value Resolution
|
|
117
|
+
|
|
118
|
+
The `apiKey` and `headers` fields support three formats:
|
|
119
|
+
|
|
120
|
+
- **Shell command:** `"!command"` executes and uses stdout
|
|
121
|
+
```json
|
|
122
|
+
"apiKey": "!security find-generic-password -ws 'anthropic'"
|
|
123
|
+
"apiKey": "!op read 'op://vault/item/credential'"
|
|
124
|
+
```
|
|
125
|
+
- **Environment variable:** Uses the value of the named variable
|
|
126
|
+
```json
|
|
127
|
+
"apiKey": "MY_API_KEY"
|
|
128
|
+
```
|
|
129
|
+
- **Literal value:** Used directly
|
|
130
|
+
```json
|
|
131
|
+
"apiKey": "sk-..."
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Custom Headers
|
|
135
|
+
|
|
136
|
+
```json
|
|
137
|
+
{
|
|
138
|
+
"providers": {
|
|
139
|
+
"custom-proxy": {
|
|
140
|
+
"baseUrl": "https://proxy.example.com/v1",
|
|
141
|
+
"apiKey": "MY_API_KEY",
|
|
142
|
+
"api": "anthropic-messages",
|
|
143
|
+
"headers": {
|
|
144
|
+
"x-portkey-api-key": "PORTKEY_API_KEY",
|
|
145
|
+
"x-secret": "!op read 'op://vault/item/secret'"
|
|
146
|
+
},
|
|
147
|
+
"models": [...]
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Model Configuration
|
|
154
|
+
|
|
155
|
+
| Field | Required | Default | Description |
|
|
156
|
+
|-------|----------|---------|-------------|
|
|
157
|
+
| `id` | Yes | — | Model identifier (passed to the API) |
|
|
158
|
+
| `name` | No | `id` | Human-readable model label. Used for matching (`--model` patterns) and shown in model details/status text. |
|
|
159
|
+
| `api` | No | provider's `api` | Override provider's API for this model |
|
|
160
|
+
| `reasoning` | No | `false` | Supports extended thinking |
|
|
161
|
+
| `input` | No | `["text"]` | Input types: `["text"]` or `["text", "image"]` |
|
|
162
|
+
| `contextWindow` | No | `128000` | Context window size in tokens |
|
|
163
|
+
| `maxTokens` | No | `16384` | Maximum output tokens |
|
|
164
|
+
| `cost` | No | all zeros | `{"input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0}` (per million tokens) |
|
|
165
|
+
| `compat` | No | provider `compat` | OpenAI compatibility overrides. Merged with provider-level `compat` when both are set. |
|
|
166
|
+
|
|
167
|
+
Current behavior:
|
|
168
|
+
- `/model` and `--list-models` list entries by model `id`.
|
|
169
|
+
- The configured `name` is used for model matching and detail/status text.
|
|
170
|
+
|
|
171
|
+
## Overriding Built-in Providers
|
|
172
|
+
|
|
173
|
+
Route a built-in provider through a proxy without redefining models:
|
|
174
|
+
|
|
175
|
+
```json
|
|
176
|
+
{
|
|
177
|
+
"providers": {
|
|
178
|
+
"anthropic": {
|
|
179
|
+
"baseUrl": "https://my-proxy.example.com/v1"
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
All built-in Anthropic models remain available. Existing OAuth or API key auth continues to work.
|
|
186
|
+
|
|
187
|
+
To merge custom models into a built-in provider, include the `models` array:
|
|
188
|
+
|
|
189
|
+
```json
|
|
190
|
+
{
|
|
191
|
+
"providers": {
|
|
192
|
+
"anthropic": {
|
|
193
|
+
"baseUrl": "https://my-proxy.example.com/v1",
|
|
194
|
+
"apiKey": "ANTHROPIC_API_KEY",
|
|
195
|
+
"api": "anthropic-messages",
|
|
196
|
+
"models": [...]
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Merge semantics:
|
|
203
|
+
- Built-in models are kept.
|
|
204
|
+
- Custom models are upserted by `id` within the provider.
|
|
205
|
+
- If a custom model `id` matches a built-in model `id`, the custom model replaces that built-in model.
|
|
206
|
+
- If a custom model `id` is new, it is added alongside built-in models.
|
|
207
|
+
|
|
208
|
+
## Per-model Overrides
|
|
209
|
+
|
|
210
|
+
Use `modelOverrides` to customize specific built-in models without replacing the provider's full model list.
|
|
211
|
+
|
|
212
|
+
```json
|
|
213
|
+
{
|
|
214
|
+
"providers": {
|
|
215
|
+
"openrouter": {
|
|
216
|
+
"modelOverrides": {
|
|
217
|
+
"anthropic/claude-sonnet-4": {
|
|
218
|
+
"name": "Claude Sonnet 4 (Bedrock Route)",
|
|
219
|
+
"compat": {
|
|
220
|
+
"openRouterRouting": {
|
|
221
|
+
"only": ["amazon-bedrock"]
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
`modelOverrides` supports these fields per model: `name`, `reasoning`, `input`, `cost` (partial), `contextWindow`, `maxTokens`, `headers`, `compat`.
|
|
232
|
+
|
|
233
|
+
Behavior notes:
|
|
234
|
+
- `modelOverrides` are applied to built-in provider models.
|
|
235
|
+
- Unknown model IDs are ignored.
|
|
236
|
+
- You can combine provider-level `baseUrl`/`headers` with `modelOverrides`.
|
|
237
|
+
- If `models` is also defined for a provider, custom models are merged after built-in overrides. A custom model with the same `id` replaces the overridden built-in model entry.
|
|
238
|
+
|
|
239
|
+
## OpenAI Compatibility
|
|
240
|
+
|
|
241
|
+
For providers with partial OpenAI compatibility, use the `compat` field.
|
|
242
|
+
|
|
243
|
+
- Provider-level `compat` applies defaults to all models under that provider.
|
|
244
|
+
- Model-level `compat` overrides provider-level values for that model.
|
|
245
|
+
|
|
246
|
+
```json
|
|
247
|
+
{
|
|
248
|
+
"providers": {
|
|
249
|
+
"local-llm": {
|
|
250
|
+
"baseUrl": "http://localhost:8080/v1",
|
|
251
|
+
"api": "openai-completions",
|
|
252
|
+
"compat": {
|
|
253
|
+
"supportsUsageInStreaming": false,
|
|
254
|
+
"maxTokensField": "max_tokens"
|
|
255
|
+
},
|
|
256
|
+
"models": [...]
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
| Field | Description |
|
|
263
|
+
|-------|-------------|
|
|
264
|
+
| `supportsStore` | Provider supports `store` field |
|
|
265
|
+
| `supportsDeveloperRole` | Use `developer` vs `system` role |
|
|
266
|
+
| `supportsReasoningEffort` | Support for `reasoning_effort` parameter |
|
|
267
|
+
| `reasoningEffortMap` | Map pi thinking levels to provider-specific `reasoning_effort` values |
|
|
268
|
+
| `supportsUsageInStreaming` | Supports `stream_options: { include_usage: true }` (default: `true`) |
|
|
269
|
+
| `maxTokensField` | Use `max_completion_tokens` or `max_tokens` |
|
|
270
|
+
| `requiresToolResultName` | Include `name` on tool result messages |
|
|
271
|
+
| `requiresAssistantAfterToolResult` | Insert an assistant message before a user message after tool results |
|
|
272
|
+
| `requiresThinkingAsText` | Convert thinking blocks to plain text |
|
|
273
|
+
| `thinkingFormat` | Use `reasoning_effort`, `zai`, `qwen`, or `qwen-chat-template` thinking parameters |
|
|
274
|
+
| `supportsStrictMode` | Include the `strict` field in tool definitions |
|
|
275
|
+
| `openRouterRouting` | OpenRouter routing config passed to OpenRouter for model/provider selection |
|
|
276
|
+
| `vercelGatewayRouting` | Vercel AI Gateway routing config for provider selection (`only`, `order`) |
|
|
277
|
+
|
|
278
|
+
`qwen` uses top-level `enable_thinking`. Use `qwen-chat-template` for local Qwen-compatible servers that require `chat_template_kwargs.enable_thinking`.
|
|
279
|
+
|
|
280
|
+
Example:
|
|
281
|
+
|
|
282
|
+
```json
|
|
283
|
+
{
|
|
284
|
+
"providers": {
|
|
285
|
+
"openrouter": {
|
|
286
|
+
"baseUrl": "https://openrouter.ai/api/v1",
|
|
287
|
+
"apiKey": "OPENROUTER_API_KEY",
|
|
288
|
+
"api": "openai-completions",
|
|
289
|
+
"models": [
|
|
290
|
+
{
|
|
291
|
+
"id": "openrouter/anthropic/claude-3.5-sonnet",
|
|
292
|
+
"name": "OpenRouter Claude 3.5 Sonnet",
|
|
293
|
+
"compat": {
|
|
294
|
+
"openRouterRouting": {
|
|
295
|
+
"order": ["anthropic"],
|
|
296
|
+
"fallbacks": ["openai"]
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
]
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
Vercel AI Gateway example:
|
|
307
|
+
|
|
308
|
+
```json
|
|
309
|
+
{
|
|
310
|
+
"providers": {
|
|
311
|
+
"vercel-ai-gateway": {
|
|
312
|
+
"baseUrl": "https://ai-gateway.vercel.sh/v1",
|
|
313
|
+
"apiKey": "AI_GATEWAY_API_KEY",
|
|
314
|
+
"api": "openai-completions",
|
|
315
|
+
"models": [
|
|
316
|
+
{
|
|
317
|
+
"id": "moonshotai/kimi-k2.5",
|
|
318
|
+
"name": "Kimi K2.5 (Fireworks via Vercel)",
|
|
319
|
+
"reasoning": true,
|
|
320
|
+
"input": ["text", "image"],
|
|
321
|
+
"cost": { "input": 0.6, "output": 3, "cacheRead": 0, "cacheWrite": 0 },
|
|
322
|
+
"contextWindow": 262144,
|
|
323
|
+
"maxTokens": 262144,
|
|
324
|
+
"compat": {
|
|
325
|
+
"vercelGatewayRouting": {
|
|
326
|
+
"only": ["fireworks", "novita"],
|
|
327
|
+
"order": ["fireworks", "novita"]
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
]
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
```
|