@draht/coding-agent 2026.6.11 → 2026.7.7
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 +15 -0
- package/README.md +1 -4
- package/dist/bun/register-bedrock.d.ts.map +1 -1
- package/dist/bun/register-bedrock.js +1 -1
- package/dist/bun/register-bedrock.js.map +1 -1
- package/dist/bun/restore-sandbox-env.d.ts +4 -0
- package/dist/bun/restore-sandbox-env.d.ts.map +1 -1
- package/dist/bun/restore-sandbox-env.js +4 -0
- package/dist/bun/restore-sandbox-env.js.map +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +4 -4
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/config-selector.d.ts +4 -2
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js +1 -1
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js +13 -25
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/cli/session-picker.d.ts +2 -1
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js +5 -4
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli/startup-ui.d.ts +5 -1
- package/dist/cli/startup-ui.d.ts.map +1 -1
- package/dist/cli/startup-ui.js +94 -22
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/config.d.ts +6 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +35 -16
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +10 -4
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +124 -83
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +11 -12
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +25 -26
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +3 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +3 -3
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +5 -4
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +23 -20
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/export-html/vendor/marked.min.js +75 -3
- 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 +2 -3
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +77 -14
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +2 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +33 -1
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +29 -2
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts +1 -0
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +45 -2
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/keybindings.d.ts +1 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +3 -6
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-registry.d.ts +2 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +32 -67
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +11 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +37 -19
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/package-manager.d.ts +5 -2
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +99 -43
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/project-trust.d.ts.map +1 -1
- package/dist/core/project-trust.js +4 -3
- package/dist/core/project-trust.js.map +1 -1
- package/dist/core/provider-attribution.d.ts +2 -2
- package/dist/core/provider-attribution.d.ts.map +1 -1
- package/dist/core/provider-attribution.js.map +1 -1
- package/dist/core/provider-display-names.d.ts.map +1 -1
- package/dist/core/provider-display-names.js +1 -1
- package/dist/core/provider-display-names.js.map +1 -1
- package/dist/core/resolve-config-value.d.ts +7 -8
- package/dist/core/resolve-config-value.d.ts.map +1 -1
- package/dist/core/resolve-config-value.js +24 -26
- package/dist/core/resolve-config-value.js.map +1 -1
- package/dist/core/resource-loader.d.ts +3 -2
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +16 -6
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts +9 -9
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +3 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +21 -2
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +121 -77
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +10 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +29 -3
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +7 -7
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/timings.d.ts +4 -2
- package/dist/core/timings.d.ts.map +1 -1
- package/dist/core/timings.js +24 -14
- package/dist/core/timings.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +32 -8
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts +23 -4
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +99 -20
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +2 -2
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +19 -11
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +12 -25
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/trust-manager.d.ts +8 -3
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +26 -11
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +2 -2
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +47 -15
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +1 -123
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/assets/clankolas.png +0 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +3 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +23 -15
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts +34 -3
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +284 -29
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/custom-entry.d.ts +19 -0
- package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-entry.js +52 -0
- package/dist/modes/interactive/components/custom-entry.js.map +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +3 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +12 -3
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +2 -2
- 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/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +0 -1
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +2 -1
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +4 -1
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +0 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +14 -8
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +4 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +188 -16
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +28 -0
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -0
- package/dist/modes/interactive/components/status-indicator.js +60 -0
- package/dist/modes/interactive/components/status-indicator.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +130 -15
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/trust-selector.js +4 -4
- package/dist/modes/interactive/components/trust-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts +6 -2
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +19 -6
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +13 -11
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +252 -233
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/model-search.d.ts +12 -0
- package/dist/modes/interactive/model-search.d.ts.map +1 -0
- package/dist/modes/interactive/model-search.js +15 -0
- package/dist/modes/interactive/model-search.js.map +1 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts +29 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-controller.js +102 -0
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -0
- package/dist/modes/interactive/theme/theme-schema.json +2 -1
- package/dist/modes/interactive/theme/theme.d.ts +27 -8
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +64 -42
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +19 -4
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +14 -0
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +17 -1
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +26 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts +2 -2
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +152 -48
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/prompts/commands/brainstorm.md +148 -0
- package/dist/rpc-entry.d.ts +3 -0
- package/dist/rpc-entry.d.ts.map +1 -0
- package/dist/rpc-entry.js +10 -0
- package/dist/rpc-entry.js.map +1 -0
- package/dist/utils/child-process.d.ts +7 -4
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js +23 -5
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/image-convert.d.ts +1 -0
- package/dist/utils/image-convert.d.ts.map +1 -1
- package/dist/utils/image-convert.js +21 -15
- package/dist/utils/image-convert.js.map +1 -1
- package/dist/utils/image-process.d.ts +18 -0
- package/dist/utils/image-process.d.ts.map +1 -0
- package/dist/utils/image-process.js +83 -0
- package/dist/utils/image-process.js.map +1 -0
- package/dist/utils/mime.d.ts.map +1 -1
- package/dist/utils/mime.js +41 -0
- package/dist/utils/mime.js.map +1 -1
- package/dist/utils/shell.d.ts +1 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +12 -5
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +4 -27
- package/dist/utils/version-check.js.map +1 -1
- package/docs/extensions.md +55 -8
- package/docs/keybindings.md +1 -1
- package/docs/packages.md +2 -2
- package/docs/providers.md +2 -1
- package/docs/rpc.md +58 -0
- package/docs/sdk.md +50 -0
- package/docs/session-format.md +18 -8
- package/docs/settings.md +10 -0
- package/docs/usage.md +2 -2
- package/examples/extensions/README.md +1 -0
- package/examples/extensions/custom-compaction.ts +2 -1
- package/examples/extensions/custom-provider-anthropic/index.ts +1 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +9 -5
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +1 -1
- package/examples/extensions/entry-renderer.ts +41 -0
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/handoff.ts +2 -2
- package/examples/extensions/plan-mode/index.ts +87 -37
- package/examples/extensions/preset.ts +10 -4
- package/examples/extensions/provider-payload.ts +5 -5
- package/examples/extensions/qna.ts +2 -2
- package/examples/extensions/question.ts +32 -18
- package/examples/extensions/questionnaire.ts +41 -28
- package/examples/extensions/sandbox/index.ts +2 -2
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/subagent/agents.ts +2 -2
- package/examples/extensions/subagent/index.ts +9 -3
- package/examples/extensions/summarize.ts +2 -1
- 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 +1 -1
- package/examples/sdk/12-full-control.ts +2 -2
- package/package.json +14 -15
- package/prompts/commands/brainstorm.md +148 -0
package/docs/session-format.md
CHANGED
|
@@ -255,7 +255,7 @@ Extension state persistence. Does NOT participate in LLM context.
|
|
|
255
255
|
{"type":"custom","id":"h8i9j0k1","parentId":"g7h8i9j0","timestamp":"2024-12-03T14:20:00.000Z","customType":"my-extension","data":{"count":42}}
|
|
256
256
|
```
|
|
257
257
|
|
|
258
|
-
Use `customType` to identify your extension's entries on reload.
|
|
258
|
+
Use `customType` to identify your extension's entries on reload. Interactive mode can render custom entries via `pi.registerEntryRenderer(customType, renderer)`, but they still do not participate in LLM context.
|
|
259
259
|
|
|
260
260
|
### CustomMessageEntry
|
|
261
261
|
|
|
@@ -306,15 +306,24 @@ Entries form a tree:
|
|
|
306
306
|
|
|
307
307
|
## Context Building
|
|
308
308
|
|
|
309
|
-
`
|
|
309
|
+
`buildContextEntries()` walks from the current leaf to the root, producing the active entry list while honoring compaction:
|
|
310
310
|
|
|
311
311
|
1. Collects all entries on the path
|
|
312
|
-
2.
|
|
313
|
-
|
|
314
|
-
-
|
|
315
|
-
- Then
|
|
316
|
-
|
|
317
|
-
|
|
312
|
+
2. If a `CompactionEntry` is on the path:
|
|
313
|
+
- Includes the compaction entry first
|
|
314
|
+
- Then entries from `firstKeptEntryId` to compaction
|
|
315
|
+
- Then entries after compaction
|
|
316
|
+
3. Preserves non-message entries in the selected range so interactive mode can render them
|
|
317
|
+
|
|
318
|
+
`buildSessionContext()` builds on that entry list to produce the message list for the LLM:
|
|
319
|
+
|
|
320
|
+
1. Extracts current model and thinking level settings from the full path
|
|
321
|
+
2. Converts selected entries to messages:
|
|
322
|
+
- `message` -> stored `AgentMessage`
|
|
323
|
+
- `compaction` -> `compactionSummary`
|
|
324
|
+
- `branch_summary` -> `branchSummary`
|
|
325
|
+
- `custom_message` -> `CustomMessage`
|
|
326
|
+
- `custom` -> no context message
|
|
318
327
|
|
|
319
328
|
## Parsing Example
|
|
320
329
|
|
|
@@ -401,6 +410,7 @@ Key methods for working with sessions programmatically.
|
|
|
401
410
|
- `branchWithSummary(entryId, summary, details?, fromHook?)` - Branch with context summary
|
|
402
411
|
|
|
403
412
|
### Instance Methods - Context & Info
|
|
413
|
+
- `buildContextEntries()` - Get active branch entries with compaction applied
|
|
404
414
|
- `buildSessionContext()` - Get messages, thinkingLevel, and model for LLM
|
|
405
415
|
- `getEntries()` - All entries (excluding header)
|
|
406
416
|
- `getHeader()` - Session header metadata
|
package/docs/settings.md
CHANGED
|
@@ -51,6 +51,7 @@ Use `/trust` in interactive mode to save a project trust decision for future ses
|
|
|
51
51
|
| Setting | Type | Default | Description |
|
|
52
52
|
|---------|------|---------|-------------|
|
|
53
53
|
| `theme` | string | `"dark"` | Theme name (`"dark"`, `"light"`, or custom) |
|
|
54
|
+
| `externalEditor` | string | `$VISUAL`, then `$EDITOR`, then Notepad on Windows or `nano` elsewhere | Command for Ctrl+G external editor; takes precedence over environment variables |
|
|
54
55
|
| `quietStartup` | boolean | `false` | Hide startup header |
|
|
55
56
|
| `defaultProjectTrust` | string | `"ask"` | Fallback project trust behavior: `"ask"`, `"always"`, or `"never"`. Global setting only |
|
|
56
57
|
| `collapseChangelog` | boolean | `false` | Show condensed changelog after updates |
|
|
@@ -60,9 +61,18 @@ Use `/trust` in interactive mode to save a project trust decision for future ses
|
|
|
60
61
|
| `doubleEscapeAction` | string | `"tree"` | Action for double-escape: `"tree"`, `"fork"`, or `"none"` |
|
|
61
62
|
| `treeFilterMode` | string | `"default"` | Default filter for `/tree`: `"default"`, `"no-tools"`, `"user-only"`, `"labeled-only"`, `"all"` |
|
|
62
63
|
| `editorPaddingX` | number | `0` | Horizontal padding for input editor (0-3) |
|
|
64
|
+
| `outputPad` | number | `1` | Horizontal padding for user messages, assistant messages, and thinking (0 or 1) |
|
|
63
65
|
| `autocompleteMaxVisible` | number | `5` | Max visible items in autocomplete dropdown (3-20) |
|
|
64
66
|
| `showHardwareCursor` | boolean | `false` | Show the terminal cursor while TUI positions it for IME support |
|
|
65
67
|
|
|
68
|
+
For VS Code, include `--wait` so pi resumes after the editor exits:
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"externalEditor": "code --wait"
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
66
76
|
### Telemetry and update checks
|
|
67
77
|
|
|
68
78
|
`enableInstallTelemetry` only controls the anonymous install/update ping to `https://pi.dev/api/report-install`. Opting out of telemetry does not disable update checks; Pi can still fetch `https://pi.dev/api/latest-version` to look for the latest version.
|
package/docs/usage.md
CHANGED
|
@@ -25,7 +25,7 @@ The editor can be replaced temporarily by built-in UI such as `/settings` or by
|
|
|
25
25
|
| Images | Paste with Ctrl+V, Alt+V on Windows, or drag into the terminal |
|
|
26
26
|
| Shell command | `!command` runs and sends output to the model |
|
|
27
27
|
| Hidden shell command | `!!command` runs without sending output to the model |
|
|
28
|
-
| External editor | Ctrl+G opens `$VISUAL
|
|
28
|
+
| External editor | Ctrl+G opens `externalEditor`, `$VISUAL`, `$EDITOR`, Notepad on Windows, or `nano` elsewhere |
|
|
29
29
|
|
|
30
30
|
See [Keybindings](keybindings.md) for all shortcuts and customization.
|
|
31
31
|
|
|
@@ -294,7 +294,7 @@ pi --exclude-tools ask_question
|
|
|
294
294
|
| `PI_SKIP_VERSION_CHECK` | Skip the Pi version update check at startup. This prevents the `pi.dev` latest-version request |
|
|
295
295
|
| `PI_TELEMETRY` | Override install/update telemetry and provider attribution headers: `1`/`true`/`yes` or `0`/`false`/`no`. This does not disable update checks |
|
|
296
296
|
| `PI_CACHE_RETENTION` | Set to `long` for extended prompt cache where supported |
|
|
297
|
-
| `VISUAL`, `EDITOR` |
|
|
297
|
+
| `VISUAL`, `EDITOR` | Fallback external editor for Ctrl+G when `externalEditor` is unset; defaults to Notepad on Windows and `nano` elsewhere |
|
|
298
298
|
|
|
299
299
|
## Design Principles
|
|
300
300
|
|
|
@@ -106,6 +106,7 @@ cp permission-gate.ts ~/.draht/agent/extensions/
|
|
|
106
106
|
| Extension | Description |
|
|
107
107
|
|-----------|-------------|
|
|
108
108
|
| `message-renderer.ts` | Custom message rendering with colors and expandable details via `registerMessageRenderer` |
|
|
109
|
+
| `entry-renderer.ts` | TUI-only session entry rendering via `appendEntry` and `registerEntryRenderer` |
|
|
109
110
|
| `event-bus.ts` | Inter-extension communication via `pi.events` |
|
|
110
111
|
|
|
111
112
|
### Session Metadata
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* pi --extension examples/extensions/custom-compaction.ts
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import { complete } from "@draht/ai";
|
|
16
|
+
import { complete } from "@draht/ai/compat";
|
|
17
17
|
import type { ExtensionAPI } from "@draht/coding-agent";
|
|
18
18
|
import { convertToLlm, serializeConversation } from "@draht/coding-agent";
|
|
19
19
|
|
|
@@ -93,6 +93,7 @@ ${conversationText}
|
|
|
93
93
|
{
|
|
94
94
|
apiKey: auth.apiKey,
|
|
95
95
|
headers: auth.headers,
|
|
96
|
+
env: auth.env,
|
|
96
97
|
maxTokens: 8192,
|
|
97
98
|
signal,
|
|
98
99
|
},
|
|
@@ -153,7 +153,7 @@ async function refreshAnthropicToken(credentials: OAuthCredentials): Promise<OAu
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
// =============================================================================
|
|
156
|
-
// Streaming Implementation (simplified from packages/ai/src/
|
|
156
|
+
// Streaming Implementation (simplified from packages/ai/src/api/anthropic-messages.ts)
|
|
157
157
|
// =============================================================================
|
|
158
158
|
|
|
159
159
|
// Claude Code tool names for OAuth stealth mode
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-custom-provider",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.80.3",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-custom-provider",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.80.3",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sdk": "^0.52.0"
|
|
12
12
|
}
|
|
@@ -12,16 +12,16 @@
|
|
|
12
12
|
import {
|
|
13
13
|
type Api,
|
|
14
14
|
type AssistantMessageEventStream,
|
|
15
|
+
anthropicMessagesApi,
|
|
15
16
|
type Context,
|
|
16
17
|
createAssistantMessageEventStream,
|
|
17
18
|
type Model,
|
|
18
19
|
type OAuthCredentials,
|
|
19
20
|
type OAuthLoginCallbacks,
|
|
21
|
+
openAIResponsesApi,
|
|
20
22
|
type SimpleStreamOptions,
|
|
21
|
-
streamSimpleAnthropic,
|
|
22
|
-
streamSimpleOpenAIResponses,
|
|
23
23
|
type ThinkingLevelMap,
|
|
24
|
-
} from "@draht/ai";
|
|
24
|
+
} from "@draht/ai/compat";
|
|
25
25
|
import type { ExtensionAPI } from "@draht/coding-agent";
|
|
26
26
|
|
|
27
27
|
// =============================================================================
|
|
@@ -325,7 +325,7 @@ export function streamGitLabDuo(
|
|
|
325
325
|
|
|
326
326
|
const innerStream =
|
|
327
327
|
cfg.backend === "anthropic"
|
|
328
|
-
?
|
|
328
|
+
? anthropicMessagesApi().streamSimple(
|
|
329
329
|
{
|
|
330
330
|
...(modelWithBaseUrl as Model<"anthropic-messages">),
|
|
331
331
|
compat: {
|
|
@@ -336,7 +336,11 @@ export function streamGitLabDuo(
|
|
|
336
336
|
context,
|
|
337
337
|
streamOptions,
|
|
338
338
|
)
|
|
339
|
-
:
|
|
339
|
+
: openAIResponsesApi().streamSimple(
|
|
340
|
+
modelWithBaseUrl as Model<"openai-responses">,
|
|
341
|
+
context,
|
|
342
|
+
streamOptions,
|
|
343
|
+
);
|
|
340
344
|
|
|
341
345
|
for await (const event of innerStream) stream.push(event);
|
|
342
346
|
stream.end();
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* npx tsx test.ts claude-sonnet-4-5-20250929 --thinking
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { type Api, type Context, type Model, registerApiProvider, streamSimple } from "@draht/ai";
|
|
11
|
+
import { type Api, type Context, type Model, registerApiProvider, streamSimple } from "@draht/ai/compat";
|
|
12
12
|
import { readFileSync } from "fs";
|
|
13
13
|
import { getAgentDir } from "packages/coding-agent/src/config.js";
|
|
14
14
|
import { join } from "path";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom entry rendering example.
|
|
3
|
+
*
|
|
4
|
+
* Shows how to render durable extension data inside the chat without sending it
|
|
5
|
+
* to the LLM. Custom entries are stored in the session via pi.appendEntry() and
|
|
6
|
+
* rendered in interactive mode via pi.registerEntryRenderer().
|
|
7
|
+
*
|
|
8
|
+
* Usage: /status-card [message]
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { ExtensionAPI } from "@draht/coding-agent";
|
|
12
|
+
import { Box, Text } from "@draht/tui";
|
|
13
|
+
|
|
14
|
+
interface StatusCardData {
|
|
15
|
+
message: string;
|
|
16
|
+
timestamp: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default function (pi: ExtensionAPI) {
|
|
20
|
+
pi.registerEntryRenderer<StatusCardData>("status-card", (entry, { expanded }, theme) => {
|
|
21
|
+
const data = entry.data ?? { message: "No data", timestamp: Date.now() };
|
|
22
|
+
const box = new Box(1, 1, (text) => theme.bg("customMessageBg", text));
|
|
23
|
+
box.addChild(new Text(`${theme.fg("accent", "[status]")} ${data.message}`, 0, 0));
|
|
24
|
+
|
|
25
|
+
if (expanded) {
|
|
26
|
+
box.addChild(new Text(theme.fg("dim", new Date(data.timestamp).toLocaleString()), 0, 0));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return box;
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
pi.registerCommand("status-card", {
|
|
33
|
+
description: "Render a durable status card that is not sent to the LLM",
|
|
34
|
+
handler: async (args) => {
|
|
35
|
+
pi.appendEntry<StatusCardData>("status-card", {
|
|
36
|
+
message: args.trim() || "Status card",
|
|
37
|
+
timestamp: Date.now(),
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-gondolin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.80.3",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-gondolin",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.80.3",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@earendil-works/gondolin": "0.12.0"
|
|
12
12
|
}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import type { AgentMessage } from "@draht/agent-core";
|
|
16
|
-
import { complete, type Message } from "@draht/ai";
|
|
16
|
+
import { complete, type Message } from "@draht/ai/compat";
|
|
17
17
|
import type { ExtensionAPI, SessionEntry } from "@draht/coding-agent";
|
|
18
18
|
import { BorderedLoader, convertToLlm, serializeConversation } from "@draht/coding-agent";
|
|
19
19
|
|
|
@@ -136,7 +136,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
136
136
|
const response = await complete(
|
|
137
137
|
ctx.model!,
|
|
138
138
|
{ systemPrompt: SYSTEM_PROMPT, messages: [userMessage] },
|
|
139
|
-
{ apiKey: auth.apiKey, headers: auth.headers, signal: loader.signal },
|
|
139
|
+
{ apiKey: auth.apiKey, headers: auth.headers, env: auth.env, signal: loader.signal },
|
|
140
140
|
);
|
|
141
141
|
|
|
142
142
|
if (response.stopReason === "aborted") {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Plan Mode Extension
|
|
3
3
|
*
|
|
4
4
|
* Read-only exploration mode for safe code analysis.
|
|
5
|
-
* When enabled,
|
|
5
|
+
* When enabled, built-in write tools are disabled.
|
|
6
6
|
*
|
|
7
7
|
* Features:
|
|
8
8
|
* - /plan command or Ctrl+Alt+P to toggle
|
|
@@ -21,6 +21,15 @@ import { extractTodoItems, isSafeCommand, markCompletedSteps, type TodoItem } fr
|
|
|
21
21
|
// Tools
|
|
22
22
|
const PLAN_MODE_TOOLS = ["read", "bash", "grep", "find", "ls", "questionnaire"];
|
|
23
23
|
const NORMAL_MODE_TOOLS = ["read", "bash", "edit", "write"];
|
|
24
|
+
const PLAN_MODE_DISABLED_TOOLS = new Set<string>(["edit", "write"]);
|
|
25
|
+
const PLAN_MANAGED_TOOLS = new Set<string>([...PLAN_MODE_TOOLS, ...NORMAL_MODE_TOOLS]);
|
|
26
|
+
|
|
27
|
+
interface PlanModeState {
|
|
28
|
+
enabled: boolean;
|
|
29
|
+
todos?: TodoItem[];
|
|
30
|
+
executing?: boolean;
|
|
31
|
+
toolsBeforePlanMode?: string[];
|
|
32
|
+
}
|
|
24
33
|
|
|
25
34
|
// Type guard for assistant messages
|
|
26
35
|
function isAssistantMessage(m: AgentMessage): m is AssistantMessage {
|
|
@@ -39,6 +48,7 @@ export default function planModeExtension(pi: ExtensionAPI): void {
|
|
|
39
48
|
let planModeEnabled = false;
|
|
40
49
|
let executionMode = false;
|
|
41
50
|
let todoItems: TodoItem[] = [];
|
|
51
|
+
let toolsBeforePlanMode: string[] | undefined;
|
|
42
52
|
|
|
43
53
|
pi.registerFlag("plan", {
|
|
44
54
|
description: "Start in plan mode (read-only exploration)",
|
|
@@ -73,19 +83,34 @@ export default function planModeExtension(pi: ExtensionAPI): void {
|
|
|
73
83
|
}
|
|
74
84
|
}
|
|
75
85
|
|
|
76
|
-
function
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
todoItems = [];
|
|
86
|
+
function uniqueToolNames(toolNames: string[]): string[] {
|
|
87
|
+
return [...new Set(toolNames)];
|
|
88
|
+
}
|
|
80
89
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
90
|
+
function getPlanModeTools(activeToolNames: string[]): string[] {
|
|
91
|
+
return uniqueToolNames([
|
|
92
|
+
...activeToolNames.filter((name) => !PLAN_MODE_DISABLED_TOOLS.has(name)),
|
|
93
|
+
...PLAN_MODE_TOOLS,
|
|
94
|
+
]);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function getNormalModeTools(activeToolNames: string[]): string[] {
|
|
98
|
+
return uniqueToolNames([
|
|
99
|
+
...NORMAL_MODE_TOOLS,
|
|
100
|
+
...activeToolNames.filter((name) => !PLAN_MANAGED_TOOLS.has(name)),
|
|
101
|
+
]);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function enablePlanModeTools(): void {
|
|
105
|
+
if (toolsBeforePlanMode === undefined) {
|
|
106
|
+
toolsBeforePlanMode = pi.getActiveTools();
|
|
87
107
|
}
|
|
88
|
-
|
|
108
|
+
pi.setActiveTools(getPlanModeTools(toolsBeforePlanMode));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function restoreNormalModeTools(): void {
|
|
112
|
+
pi.setActiveTools(toolsBeforePlanMode ?? getNormalModeTools(pi.getActiveTools()));
|
|
113
|
+
toolsBeforePlanMode = undefined;
|
|
89
114
|
}
|
|
90
115
|
|
|
91
116
|
function persistState(): void {
|
|
@@ -93,9 +118,26 @@ export default function planModeExtension(pi: ExtensionAPI): void {
|
|
|
93
118
|
enabled: planModeEnabled,
|
|
94
119
|
todos: todoItems,
|
|
95
120
|
executing: executionMode,
|
|
121
|
+
toolsBeforePlanMode,
|
|
96
122
|
});
|
|
97
123
|
}
|
|
98
124
|
|
|
125
|
+
function togglePlanMode(ctx: ExtensionContext): void {
|
|
126
|
+
planModeEnabled = !planModeEnabled;
|
|
127
|
+
executionMode = false;
|
|
128
|
+
todoItems = [];
|
|
129
|
+
|
|
130
|
+
if (planModeEnabled) {
|
|
131
|
+
enablePlanModeTools();
|
|
132
|
+
ctx.ui.notify("Plan mode enabled. Built-in write tools disabled.");
|
|
133
|
+
} else {
|
|
134
|
+
restoreNormalModeTools();
|
|
135
|
+
ctx.ui.notify("Plan mode disabled. Full access restored.");
|
|
136
|
+
}
|
|
137
|
+
updateStatus(ctx);
|
|
138
|
+
persistState();
|
|
139
|
+
}
|
|
140
|
+
|
|
99
141
|
pi.registerCommand("plan", {
|
|
100
142
|
description: "Toggle plan mode (read-only exploration)",
|
|
101
143
|
handler: async (_args, ctx) => togglePlanMode(ctx),
|
|
@@ -165,8 +207,8 @@ export default function planModeExtension(pi: ExtensionAPI): void {
|
|
|
165
207
|
You are in plan mode - a read-only exploration mode for safe code analysis.
|
|
166
208
|
|
|
167
209
|
Restrictions:
|
|
168
|
-
-
|
|
169
|
-
-
|
|
210
|
+
- Built-in edit and write tools are disabled
|
|
211
|
+
- Other currently active tools remain available
|
|
170
212
|
- Bash is restricted to an allowlist of read-only commands
|
|
171
213
|
|
|
172
214
|
Ask clarifying questions using the questionnaire tool.
|
|
@@ -228,7 +270,6 @@ After completing a step, include a [DONE:n] tag in your response.`,
|
|
|
228
270
|
);
|
|
229
271
|
executionMode = false;
|
|
230
272
|
todoItems = [];
|
|
231
|
-
pi.setActiveTools(NORMAL_MODE_TOOLS);
|
|
232
273
|
updateStatus(ctx);
|
|
233
274
|
persistState(); // Save cleared state so resume doesn't restore old execution mode
|
|
234
275
|
}
|
|
@@ -246,43 +287,51 @@ After completing a step, include a [DONE:n] tag in your response.`,
|
|
|
246
287
|
}
|
|
247
288
|
}
|
|
248
289
|
|
|
290
|
+
if (todoItems.length === 0) return;
|
|
291
|
+
persistState();
|
|
292
|
+
|
|
249
293
|
// Show plan steps and prompt for next action
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
display: true,
|
|
257
|
-
},
|
|
258
|
-
{ triggerTurn: false },
|
|
259
|
-
);
|
|
260
|
-
}
|
|
294
|
+
const todoListText = todoItems.map((t, i) => `${i + 1}. ☐ ${t.text}`).join("\n");
|
|
295
|
+
const planTodoListMessage = {
|
|
296
|
+
customType: "plan-todo-list",
|
|
297
|
+
content: `**Plan Steps (${todoItems.length}):**\n\n${todoListText}`,
|
|
298
|
+
display: true,
|
|
299
|
+
};
|
|
261
300
|
|
|
262
301
|
const choice = await ctx.ui.select("Plan mode - what next?", [
|
|
263
|
-
|
|
302
|
+
"Execute the plan (track progress)",
|
|
264
303
|
"Stay in plan mode",
|
|
265
304
|
"Refine the plan",
|
|
266
305
|
]);
|
|
267
306
|
|
|
268
307
|
if (choice?.startsWith("Execute")) {
|
|
308
|
+
const firstTodoItem = todoItems[0];
|
|
309
|
+
if (!firstTodoItem) return;
|
|
310
|
+
|
|
269
311
|
planModeEnabled = false;
|
|
270
|
-
executionMode =
|
|
271
|
-
|
|
312
|
+
executionMode = true;
|
|
313
|
+
restoreNormalModeTools();
|
|
272
314
|
updateStatus(ctx);
|
|
315
|
+
persistState();
|
|
316
|
+
|
|
317
|
+
const remainingList = todoItems.map((t) => `${t.step}. ${t.text}`).join("\n");
|
|
318
|
+
const execMessage = `Execute the plan.
|
|
319
|
+
|
|
320
|
+
Remaining steps:
|
|
321
|
+
${remainingList}
|
|
273
322
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
: "Execute the plan you just created.";
|
|
323
|
+
Start with: ${firstTodoItem.text}
|
|
324
|
+
After completing a step, include a [DONE:n] tag in your response.`;
|
|
325
|
+
pi.sendMessage(planTodoListMessage, { deliverAs: "followUp" });
|
|
278
326
|
pi.sendMessage(
|
|
279
327
|
{ customType: "plan-mode-execute", content: execMessage, display: true },
|
|
280
|
-
{ triggerTurn: true },
|
|
328
|
+
{ triggerTurn: true, deliverAs: "followUp" },
|
|
281
329
|
);
|
|
282
330
|
} else if (choice === "Refine the plan") {
|
|
283
331
|
const refinement = await ctx.ui.editor("Refine the plan:", "");
|
|
284
332
|
if (refinement?.trim()) {
|
|
285
|
-
pi.
|
|
333
|
+
pi.sendMessage(planTodoListMessage, { deliverAs: "followUp" });
|
|
334
|
+
pi.sendUserMessage(refinement.trim(), { deliverAs: "followUp" });
|
|
286
335
|
}
|
|
287
336
|
}
|
|
288
337
|
});
|
|
@@ -298,12 +347,13 @@ After completing a step, include a [DONE:n] tag in your response.`,
|
|
|
298
347
|
// Restore persisted state
|
|
299
348
|
const planModeEntry = entries
|
|
300
349
|
.filter((e: { type: string; customType?: string }) => e.type === "custom" && e.customType === "plan-mode")
|
|
301
|
-
.pop() as { data?:
|
|
350
|
+
.pop() as { data?: PlanModeState } | undefined;
|
|
302
351
|
|
|
303
352
|
if (planModeEntry?.data) {
|
|
304
353
|
planModeEnabled = planModeEntry.data.enabled ?? planModeEnabled;
|
|
305
354
|
todoItems = planModeEntry.data.todos ?? todoItems;
|
|
306
355
|
executionMode = planModeEntry.data.executing ?? executionMode;
|
|
356
|
+
toolsBeforePlanMode = planModeEntry.data.toolsBeforePlanMode ?? toolsBeforePlanMode;
|
|
307
357
|
}
|
|
308
358
|
|
|
309
359
|
// On resume: re-scan messages to rebuild completion state
|
|
@@ -333,7 +383,7 @@ After completing a step, include a [DONE:n] tag in your response.`,
|
|
|
333
383
|
}
|
|
334
384
|
|
|
335
385
|
if (planModeEnabled) {
|
|
336
|
-
|
|
386
|
+
enablePlanModeTools();
|
|
337
387
|
}
|
|
338
388
|
updateStatus(ctx);
|
|
339
389
|
});
|
|
@@ -42,7 +42,7 @@ import { existsSync, readFileSync } from "node:fs";
|
|
|
42
42
|
import { join } from "node:path";
|
|
43
43
|
import type { Api, Model } from "@draht/ai";
|
|
44
44
|
import type { ExtensionAPI, ExtensionContext } from "@draht/coding-agent";
|
|
45
|
-
import { DynamicBorder, getAgentDir } from "@draht/coding-agent";
|
|
45
|
+
import { CONFIG_DIR_NAME, DynamicBorder, getAgentDir } from "@draht/coding-agent";
|
|
46
46
|
import { Container, Key, type SelectItem, SelectList, Text } from "@draht/tui";
|
|
47
47
|
|
|
48
48
|
// Preset configuration
|
|
@@ -69,7 +69,7 @@ interface PresetsConfig {
|
|
|
69
69
|
*/
|
|
70
70
|
function loadPresets(cwd: string): PresetsConfig {
|
|
71
71
|
const globalPath = join(getAgentDir(), "presets.json");
|
|
72
|
-
const projectPath = join(cwd,
|
|
72
|
+
const projectPath = join(cwd, CONFIG_DIR_NAME, "presets.json");
|
|
73
73
|
|
|
74
74
|
let globalPresets: PresetsConfig = {};
|
|
75
75
|
let projectPresets: PresetsConfig = {};
|
|
@@ -200,7 +200,10 @@ export default function presetExtension(pi: ExtensionAPI) {
|
|
|
200
200
|
const presetNames = Object.keys(presets);
|
|
201
201
|
|
|
202
202
|
if (presetNames.length === 0) {
|
|
203
|
-
ctx.ui.notify(
|
|
203
|
+
ctx.ui.notify(
|
|
204
|
+
`No presets defined. Add presets to ${join(getAgentDir(), "presets.json")} or ${join(ctx.cwd, CONFIG_DIR_NAME, "presets.json")}`,
|
|
205
|
+
"warning",
|
|
206
|
+
);
|
|
204
207
|
return;
|
|
205
208
|
}
|
|
206
209
|
|
|
@@ -308,7 +311,10 @@ export default function presetExtension(pi: ExtensionAPI) {
|
|
|
308
311
|
async function cyclePreset(ctx: ExtensionContext): Promise<void> {
|
|
309
312
|
const presetNames = getPresetOrder();
|
|
310
313
|
if (presetNames.length === 0) {
|
|
311
|
-
ctx.ui.notify(
|
|
314
|
+
ctx.ui.notify(
|
|
315
|
+
`No presets defined. Add presets to ${join(getAgentDir(), "presets.json")} or ${join(ctx.cwd, CONFIG_DIR_NAME, "presets.json")}`,
|
|
316
|
+
"warning",
|
|
317
|
+
);
|
|
312
318
|
return;
|
|
313
319
|
}
|
|
314
320
|
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { appendFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import type
|
|
3
|
+
import { CONFIG_DIR_NAME, type ExtensionAPI } from "@draht/coding-agent";
|
|
4
4
|
|
|
5
5
|
export default function (pi: ExtensionAPI) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
pi.on("before_provider_request", (event) => {
|
|
6
|
+
pi.on("before_provider_request", (event, ctx) => {
|
|
7
|
+
const logFile = join(ctx.cwd, CONFIG_DIR_NAME, "provider-payload.log");
|
|
9
8
|
appendFileSync(logFile, `${JSON.stringify(event.payload, null, 2)}\n\n`, "utf8");
|
|
10
9
|
|
|
11
10
|
// Optional: replace the payload instead of only logging it.
|
|
12
11
|
// return { ...event.payload, temperature: 0 };
|
|
13
12
|
});
|
|
14
13
|
|
|
15
|
-
pi.on("after_provider_response", (event) => {
|
|
14
|
+
pi.on("after_provider_response", (event, ctx) => {
|
|
15
|
+
const logFile = join(ctx.cwd, CONFIG_DIR_NAME, "provider-payload.log");
|
|
16
16
|
appendFileSync(logFile, `[${event.status}] ${JSON.stringify(event.headers)}\n\n`, "utf8");
|
|
17
17
|
});
|
|
18
18
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* 3. Loads the result into the editor for user to fill in answers
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { complete, type UserMessage } from "@draht/ai";
|
|
10
|
+
import { complete, type UserMessage } from "@draht/ai/compat";
|
|
11
11
|
import type { ExtensionAPI } from "@draht/coding-agent";
|
|
12
12
|
import { BorderedLoader } from "@draht/coding-agent";
|
|
13
13
|
|
|
@@ -90,7 +90,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
90
90
|
const response = await complete(
|
|
91
91
|
ctx.model!,
|
|
92
92
|
{ systemPrompt: SYSTEM_PROMPT, messages: [userMessage] },
|
|
93
|
-
{ apiKey: auth.apiKey, headers: auth.headers, signal: loader.signal },
|
|
93
|
+
{ apiKey: auth.apiKey, headers: auth.headers, env: auth.env, signal: loader.signal },
|
|
94
94
|
);
|
|
95
95
|
|
|
96
96
|
if (response.stopReason === "aborted") {
|