@draht/coding-agent 2026.6.11 → 2026.7.7-1
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 +21 -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/agents/build.md +38 -0
- package/dist/prompts/agents/plan.md +36 -0
- package/dist/prompts/agents/verify.md +36 -4
- package/dist/prompts/commands/brainstorm.md +162 -0
- package/dist/prompts/commands/discuss-phase.md +1 -1
- package/dist/prompts/commands/execute-phase.md +4 -1
- package/dist/prompts/commands/fix.md +12 -0
- package/dist/prompts/commands/init-project.md +1 -0
- package/dist/prompts/commands/map-codebase.md +1 -1
- package/dist/prompts/commands/new-project.md +1 -0
- package/dist/prompts/commands/next-milestone.md +2 -0
- package/dist/prompts/commands/orchestrate.md +4 -4
- package/dist/prompts/commands/plan-phase.md +5 -0
- package/dist/prompts/commands/quick.md +4 -0
- package/dist/prompts/commands/review.md +4 -1
- package/dist/prompts/commands/verify-work.md +10 -8
- 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/agents/build.md +38 -0
- package/prompts/agents/plan.md +36 -0
- package/prompts/agents/verify.md +36 -4
- package/prompts/commands/brainstorm.md +162 -0
- package/prompts/commands/discuss-phase.md +1 -1
- package/prompts/commands/execute-phase.md +4 -1
- package/prompts/commands/fix.md +12 -0
- package/prompts/commands/init-project.md +1 -0
- package/prompts/commands/map-codebase.md +1 -1
- package/prompts/commands/new-project.md +1 -0
- package/prompts/commands/next-milestone.md +2 -0
- package/prompts/commands/orchestrate.md +4 -4
- package/prompts/commands/plan-phase.md +5 -0
- package/prompts/commands/quick.md +4 -0
- package/prompts/commands/review.md +4 -1
- package/prompts/commands/verify-work.md +10 -8
|
@@ -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") {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import type { ExtensionAPI } from "@draht/coding-agent";
|
|
8
|
-
import { Editor, type EditorTheme, Key, matchesKey, Text,
|
|
8
|
+
import { Editor, type EditorTheme, Key, matchesKey, Text, visibleWidth, wrapTextWithAnsi } from "@draht/tui";
|
|
9
9
|
import { Type } from "typebox";
|
|
10
10
|
|
|
11
11
|
interface OptionWithDesc {
|
|
@@ -39,6 +39,7 @@ export default function question(pi: ExtensionAPI) {
|
|
|
39
39
|
label: "Question",
|
|
40
40
|
description: "Ask the user a question and let them pick from options. Use when you need user input to proceed.",
|
|
41
41
|
parameters: QuestionParams,
|
|
42
|
+
executionMode: "sequential",
|
|
42
43
|
|
|
43
44
|
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
44
45
|
if (ctx.mode !== "tui") {
|
|
@@ -139,10 +140,27 @@ export default function question(pi: ExtensionAPI) {
|
|
|
139
140
|
if (cachedLines) return cachedLines;
|
|
140
141
|
|
|
141
142
|
const lines: string[] = [];
|
|
142
|
-
const
|
|
143
|
+
const renderWidth = Math.max(1, width);
|
|
143
144
|
|
|
144
|
-
|
|
145
|
-
|
|
145
|
+
function addWrapped(text: string) {
|
|
146
|
+
lines.push(...wrapTextWithAnsi(text, renderWidth));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function addWrappedWithPrefix(prefix: string, text: string) {
|
|
150
|
+
const prefixWidth = visibleWidth(prefix);
|
|
151
|
+
if (prefixWidth >= renderWidth) {
|
|
152
|
+
addWrapped(prefix + text);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const wrapped = wrapTextWithAnsi(text, renderWidth - prefixWidth);
|
|
156
|
+
const continuationPrefix = " ".repeat(prefixWidth);
|
|
157
|
+
for (let i = 0; i < wrapped.length; i++) {
|
|
158
|
+
lines.push(`${i === 0 ? prefix : continuationPrefix}${wrapped[i]}`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
lines.push(theme.fg("accent", "─".repeat(renderWidth)));
|
|
163
|
+
addWrappedWithPrefix(" ", theme.fg("text", params.question));
|
|
146
164
|
lines.push("");
|
|
147
165
|
|
|
148
166
|
for (let i = 0; i < allOptions.length; i++) {
|
|
@@ -150,36 +168,32 @@ export default function question(pi: ExtensionAPI) {
|
|
|
150
168
|
const selected = i === optionIndex;
|
|
151
169
|
const isOther = opt.isOther === true;
|
|
152
170
|
const prefix = selected ? theme.fg("accent", "> ") : " ";
|
|
171
|
+
const label = `${i + 1}. ${opt.label}${isOther && editMode ? " ✎" : ""}`;
|
|
172
|
+
const color = selected || (isOther && editMode) ? "accent" : "text";
|
|
153
173
|
|
|
154
|
-
|
|
155
|
-
add(prefix + theme.fg("accent", `${i + 1}. ${opt.label} ✎`));
|
|
156
|
-
} else if (selected) {
|
|
157
|
-
add(prefix + theme.fg("accent", `${i + 1}. ${opt.label}`));
|
|
158
|
-
} else {
|
|
159
|
-
add(` ${theme.fg("text", `${i + 1}. ${opt.label}`)}`);
|
|
160
|
-
}
|
|
174
|
+
addWrappedWithPrefix(prefix, theme.fg(color, label));
|
|
161
175
|
|
|
162
176
|
// Show description if present
|
|
163
177
|
if (opt.description) {
|
|
164
|
-
|
|
178
|
+
addWrappedWithPrefix(" ", theme.fg("muted", opt.description));
|
|
165
179
|
}
|
|
166
180
|
}
|
|
167
181
|
|
|
168
182
|
if (editMode) {
|
|
169
183
|
lines.push("");
|
|
170
|
-
|
|
171
|
-
for (const line of editor.render(
|
|
172
|
-
|
|
184
|
+
addWrappedWithPrefix(" ", theme.fg("muted", "Your answer:"));
|
|
185
|
+
for (const line of editor.render(Math.max(1, renderWidth - 2))) {
|
|
186
|
+
lines.push(` ${line}`);
|
|
173
187
|
}
|
|
174
188
|
}
|
|
175
189
|
|
|
176
190
|
lines.push("");
|
|
177
191
|
if (editMode) {
|
|
178
|
-
|
|
192
|
+
addWrappedWithPrefix(" ", theme.fg("dim", "Enter to submit • Esc to go back"));
|
|
179
193
|
} else {
|
|
180
|
-
|
|
194
|
+
addWrappedWithPrefix(" ", theme.fg("dim", "↑↓ navigate • Enter to select • Esc to cancel"));
|
|
181
195
|
}
|
|
182
|
-
|
|
196
|
+
lines.push(theme.fg("accent", "─".repeat(renderWidth)));
|
|
183
197
|
|
|
184
198
|
cachedLines = lines;
|
|
185
199
|
return lines;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import type { ExtensionAPI } from "@draht/coding-agent";
|
|
9
|
-
import { Editor, type EditorTheme, Key, matchesKey, Text,
|
|
9
|
+
import { Editor, type EditorTheme, Key, matchesKey, Text, visibleWidth, wrapTextWithAnsi } from "@draht/tui";
|
|
10
10
|
import { Type } from "typebox";
|
|
11
11
|
|
|
12
12
|
// Types
|
|
@@ -259,13 +259,28 @@ export default function questionnaire(pi: ExtensionAPI) {
|
|
|
259
259
|
if (cachedLines) return cachedLines;
|
|
260
260
|
|
|
261
261
|
const lines: string[] = [];
|
|
262
|
+
const renderWidth = Math.max(1, width);
|
|
262
263
|
const q = currentQuestion();
|
|
263
264
|
const opts = currentOptions();
|
|
264
265
|
|
|
265
|
-
|
|
266
|
-
|
|
266
|
+
function addWrapped(text: string) {
|
|
267
|
+
lines.push(...wrapTextWithAnsi(text, renderWidth));
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function addWrappedWithPrefix(prefix: string, text: string) {
|
|
271
|
+
const prefixWidth = visibleWidth(prefix);
|
|
272
|
+
if (prefixWidth >= renderWidth) {
|
|
273
|
+
addWrapped(prefix + text);
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
const wrapped = wrapTextWithAnsi(text, renderWidth - prefixWidth);
|
|
277
|
+
const continuationPrefix = " ".repeat(prefixWidth);
|
|
278
|
+
for (let i = 0; i < wrapped.length; i++) {
|
|
279
|
+
lines.push(`${i === 0 ? prefix : continuationPrefix}${wrapped[i]}`);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
267
282
|
|
|
268
|
-
|
|
283
|
+
lines.push(theme.fg("accent", "─".repeat(renderWidth)));
|
|
269
284
|
|
|
270
285
|
// Tab bar (multi-question only)
|
|
271
286
|
if (isMulti) {
|
|
@@ -287,7 +302,7 @@ export default function questionnaire(pi: ExtensionAPI) {
|
|
|
287
302
|
? theme.bg("selectedBg", theme.fg("text", submitText))
|
|
288
303
|
: theme.fg(canSubmit ? "success" : "dim", submitText);
|
|
289
304
|
tabs.push(`${submitStyled} →`);
|
|
290
|
-
|
|
305
|
+
addWrappedWithPrefix(" ", tabs.join(""));
|
|
291
306
|
lines.push("");
|
|
292
307
|
}
|
|
293
308
|
|
|
@@ -298,54 +313,52 @@ export default function questionnaire(pi: ExtensionAPI) {
|
|
|
298
313
|
const selected = i === optionIndex;
|
|
299
314
|
const isOther = opt.isOther === true;
|
|
300
315
|
const prefix = selected ? theme.fg("accent", "> ") : " ";
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
} else {
|
|
306
|
-
add(prefix + theme.fg(color, `${i + 1}. ${opt.label}`));
|
|
307
|
-
}
|
|
316
|
+
const label = `${i + 1}. ${opt.label}${isOther && inputMode ? " ✎" : ""}`;
|
|
317
|
+
const color = selected || (isOther && inputMode) ? "accent" : "text";
|
|
318
|
+
|
|
319
|
+
addWrappedWithPrefix(prefix, theme.fg(color, label));
|
|
308
320
|
if (opt.description) {
|
|
309
|
-
|
|
321
|
+
addWrappedWithPrefix(" ", theme.fg("muted", opt.description));
|
|
310
322
|
}
|
|
311
323
|
}
|
|
312
324
|
}
|
|
313
325
|
|
|
314
326
|
// Content
|
|
315
327
|
if (inputMode && q) {
|
|
316
|
-
|
|
328
|
+
addWrappedWithPrefix(" ", theme.fg("text", q.prompt));
|
|
317
329
|
lines.push("");
|
|
318
330
|
// Show options for reference
|
|
319
331
|
renderOptions();
|
|
320
332
|
lines.push("");
|
|
321
|
-
|
|
322
|
-
for (const line of editor.render(
|
|
323
|
-
|
|
333
|
+
addWrappedWithPrefix(" ", theme.fg("muted", "Your answer:"));
|
|
334
|
+
for (const line of editor.render(Math.max(1, renderWidth - 2))) {
|
|
335
|
+
lines.push(` ${line}`);
|
|
324
336
|
}
|
|
325
337
|
lines.push("");
|
|
326
|
-
|
|
338
|
+
addWrappedWithPrefix(" ", theme.fg("dim", "Enter to submit • Esc to cancel"));
|
|
327
339
|
} else if (currentTab === questions.length) {
|
|
328
|
-
|
|
340
|
+
addWrappedWithPrefix(" ", theme.fg("accent", theme.bold("Ready to submit")));
|
|
329
341
|
lines.push("");
|
|
330
342
|
for (const question of questions) {
|
|
331
343
|
const answer = answers.get(question.id);
|
|
332
344
|
if (answer) {
|
|
333
345
|
const prefix = answer.wasCustom ? "(wrote) " : "";
|
|
334
|
-
|
|
346
|
+
const summary = `${theme.fg("muted", `${question.label}: `)}${theme.fg("text", prefix + answer.label)}`;
|
|
347
|
+
addWrappedWithPrefix(" ", summary);
|
|
335
348
|
}
|
|
336
349
|
}
|
|
337
350
|
lines.push("");
|
|
338
351
|
if (allAnswered()) {
|
|
339
|
-
|
|
352
|
+
addWrappedWithPrefix(" ", theme.fg("success", "Press Enter to submit"));
|
|
340
353
|
} else {
|
|
341
354
|
const missing = questions
|
|
342
355
|
.filter((q) => !answers.has(q.id))
|
|
343
356
|
.map((q) => q.label)
|
|
344
357
|
.join(", ");
|
|
345
|
-
|
|
358
|
+
addWrappedWithPrefix(" ", theme.fg("warning", `Unanswered: ${missing}`));
|
|
346
359
|
}
|
|
347
360
|
} else if (q) {
|
|
348
|
-
|
|
361
|
+
addWrappedWithPrefix(" ", theme.fg("text", q.prompt));
|
|
349
362
|
lines.push("");
|
|
350
363
|
renderOptions();
|
|
351
364
|
}
|
|
@@ -353,11 +366,11 @@ export default function questionnaire(pi: ExtensionAPI) {
|
|
|
353
366
|
lines.push("");
|
|
354
367
|
if (!inputMode) {
|
|
355
368
|
const help = isMulti
|
|
356
|
-
? "
|
|
357
|
-
: "
|
|
358
|
-
|
|
369
|
+
? "Tab/←→ navigate • ↑↓ select • Enter confirm • Esc cancel"
|
|
370
|
+
: "↑↓ navigate • Enter select • Esc cancel";
|
|
371
|
+
addWrappedWithPrefix(" ", theme.fg("dim", help));
|
|
359
372
|
}
|
|
360
|
-
|
|
373
|
+
lines.push(theme.fg("accent", "─".repeat(renderWidth)));
|
|
361
374
|
|
|
362
375
|
cachedLines = lines;
|
|
363
376
|
return lines;
|
|
@@ -400,7 +413,7 @@ export default function questionnaire(pi: ExtensionAPI) {
|
|
|
400
413
|
let text = theme.fg("toolTitle", theme.bold("questionnaire "));
|
|
401
414
|
text += theme.fg("muted", `${count} question${count !== 1 ? "s" : ""}`);
|
|
402
415
|
if (labels) {
|
|
403
|
-
text += theme.fg("dim", ` (${
|
|
416
|
+
text += theme.fg("dim", ` (${labels})`);
|
|
404
417
|
}
|
|
405
418
|
return new Text(text, 0, 0);
|
|
406
419
|
},
|
|
@@ -46,7 +46,7 @@ import { existsSync, readFileSync } from "node:fs";
|
|
|
46
46
|
import { join } from "node:path";
|
|
47
47
|
import { SandboxManager, type SandboxRuntimeConfig } from "@anthropic-ai/sandbox-runtime";
|
|
48
48
|
import type { ExtensionAPI } from "@draht/coding-agent";
|
|
49
|
-
import { type BashOperations, createBashTool, getAgentDir } from "@draht/coding-agent";
|
|
49
|
+
import { type BashOperations, CONFIG_DIR_NAME, createBashTool, getAgentDir } from "@draht/coding-agent";
|
|
50
50
|
|
|
51
51
|
interface SandboxConfig extends SandboxRuntimeConfig {
|
|
52
52
|
enabled?: boolean;
|
|
@@ -77,7 +77,7 @@ const DEFAULT_CONFIG: SandboxConfig = {
|
|
|
77
77
|
};
|
|
78
78
|
|
|
79
79
|
function loadConfig(cwd: string): SandboxConfig {
|
|
80
|
-
const projectConfigPath = join(cwd,
|
|
80
|
+
const projectConfigPath = join(cwd, CONFIG_DIR_NAME, "sandbox.json");
|
|
81
81
|
const globalConfigPath = join(getAgentDir(), "extensions", "sandbox.json");
|
|
82
82
|
|
|
83
83
|
let globalConfig: Partial<SandboxConfig> = {};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-sandbox",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.3",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-sandbox",
|
|
9
|
-
"version": "1.
|
|
9
|
+
"version": "1.10.3",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sandbox-runtime": "^0.0.26"
|
|
12
12
|
}
|