@di-code/coding-agent 0.1.6 → 0.1.8
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/README.md +112 -68
- package/compositions/base.yml +54 -0
- package/compositions/interactive.yml +14 -0
- package/compositions/json.yml +6 -0
- package/compositions/print.yml +5 -0
- package/compositions/rpc.yml +12 -0
- package/compositions/webui.yml +9 -0
- package/dist/cli.d.ts +22 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +97 -3
- package/dist/cli.js.map +1 -1
- package/dist/composition-loader-entry.d.ts +11 -0
- package/dist/composition-loader-entry.d.ts.map +1 -0
- package/dist/composition-loader-entry.js +12 -0
- package/dist/composition-loader-entry.js.map +1 -0
- package/dist/compositions.d.ts +32 -0
- package/dist/compositions.d.ts.map +1 -0
- package/dist/compositions.js +173 -0
- package/dist/compositions.js.map +1 -0
- package/dist/core/session/session-manager.d.ts +9 -2
- package/dist/core/session/session-manager.d.ts.map +1 -1
- package/dist/core/session/session-manager.js +28 -0
- package/dist/core/session/session-manager.js.map +1 -1
- package/dist/core/session/session-storage.d.ts.map +1 -1
- package/dist/core/session/session-storage.js +20 -3
- package/dist/core/session/session-storage.js.map +1 -1
- package/dist/core/session/types.d.ts +11 -2
- package/dist/core/session/types.d.ts.map +1 -1
- package/dist/core/session/types.js.map +1 -1
- package/dist/core/session-tools.d.ts +5 -0
- package/dist/core/session-tools.d.ts.map +1 -0
- package/dist/core/session-tools.js +17 -0
- package/dist/core/session-tools.js.map +1 -0
- package/dist/core/session.d.ts +21 -7
- package/dist/core/session.d.ts.map +1 -1
- package/dist/core/session.js +77 -41
- package/dist/core/session.js.map +1 -1
- package/dist/core/tools/bash.d.ts +1 -38
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +1 -207
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts +1 -24
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +1 -135
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts +1 -26
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +1 -140
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/file-mutation-queue.d.ts +1 -1
- package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
- package/dist/core/tools/file-mutation-queue.js +1 -23
- package/dist/core/tools/file-mutation-queue.js.map +1 -1
- package/dist/core/tools/file-search.d.ts +1 -13
- package/dist/core/tools/file-search.d.ts.map +1 -1
- package/dist/core/tools/file-search.js +1 -98
- package/dist/core/tools/file-search.js.map +1 -1
- package/dist/core/tools/glob.d.ts +1 -10
- package/dist/core/tools/glob.d.ts.map +1 -1
- package/dist/core/tools/glob.js +1 -43
- package/dist/core/tools/glob.js.map +1 -1
- package/dist/core/tools/grep.d.ts +1 -12
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +1 -66
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/load-skill.d.ts +1 -9
- package/dist/core/tools/load-skill.d.ts.map +1 -1
- package/dist/core/tools/load-skill.js +1 -21
- package/dist/core/tools/load-skill.js.map +1 -1
- package/dist/core/tools/path-boundary.d.ts +1 -4
- package/dist/core/tools/path-boundary.d.ts.map +1 -1
- package/dist/core/tools/path-boundary.js +1 -65
- package/dist/core/tools/path-boundary.js.map +1 -1
- package/dist/core/tools/read.d.ts +1 -16
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +1 -131
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/write.d.ts +1 -16
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +1 -44
- package/dist/core/tools/write.js.map +1 -1
- package/dist/entry.js +30 -28
- package/dist/entry.js.map +1 -1
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +2 -0
- package/dist/i18n.js.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/interactive/builtin.d.ts +17 -0
- package/dist/interactive/builtin.d.ts.map +1 -0
- package/dist/interactive/builtin.js +47 -0
- package/dist/interactive/builtin.js.map +1 -0
- package/dist/interactive/controller.d.ts +85 -0
- package/dist/interactive/controller.d.ts.map +1 -0
- package/dist/interactive/controller.js +211 -0
- package/dist/interactive/controller.js.map +1 -0
- package/dist/interactive/index.d.ts +3 -0
- package/dist/interactive/index.d.ts.map +1 -0
- package/dist/interactive/index.js +3 -0
- package/dist/interactive/index.js.map +1 -0
- package/dist/interactive-host-entry.d.ts +7 -0
- package/dist/interactive-host-entry.d.ts.map +1 -0
- package/dist/interactive-host-entry.js +123 -0
- package/dist/interactive-host-entry.js.map +1 -0
- package/dist/interactive-profile.d.ts +18 -0
- package/dist/interactive-profile.d.ts.map +1 -0
- package/dist/interactive-profile.js +290 -0
- package/dist/interactive-profile.js.map +1 -0
- package/dist/interactive-resources-entry.d.ts +7 -0
- package/dist/interactive-resources-entry.d.ts.map +1 -0
- package/dist/interactive-resources-entry.js +42 -0
- package/dist/interactive-resources-entry.js.map +1 -0
- package/dist/legacy-main.d.ts +39 -0
- package/dist/legacy-main.d.ts.map +1 -0
- package/dist/legacy-main.js +611 -0
- package/dist/legacy-main.js.map +1 -0
- package/dist/main.d.ts +15 -34
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +130 -513
- package/dist/main.js.map +1 -1
- package/dist/mcp/entries.d.ts +42 -0
- package/dist/mcp/entries.d.ts.map +1 -0
- package/dist/mcp/entries.js +98 -0
- package/dist/mcp/entries.js.map +1 -0
- package/dist/mcp-client-entry.d.ts +5 -0
- package/dist/mcp-client-entry.d.ts.map +1 -0
- package/dist/mcp-client-entry.js +6 -0
- package/dist/mcp-client-entry.js.map +1 -0
- package/dist/mcp-config-entry.d.ts +5 -0
- package/dist/mcp-config-entry.d.ts.map +1 -0
- package/dist/mcp-config-entry.js +6 -0
- package/dist/mcp-config-entry.js.map +1 -0
- package/dist/mcp-tools-entry.d.ts +5 -0
- package/dist/mcp-tools-entry.d.ts.map +1 -0
- package/dist/mcp-tools-entry.js +6 -0
- package/dist/mcp-tools-entry.js.map +1 -0
- package/dist/mcp-transport-entry.d.ts +5 -0
- package/dist/mcp-transport-entry.d.ts.map +1 -0
- package/dist/mcp-transport-entry.js +6 -0
- package/dist/mcp-transport-entry.js.map +1 -0
- package/dist/modes/interactive-entry.d.ts +18 -0
- package/dist/modes/interactive-entry.d.ts.map +1 -0
- package/dist/modes/interactive-entry.js +21 -0
- package/dist/modes/interactive-entry.js.map +1 -0
- package/dist/modes/interactive-state.js +1 -1
- package/dist/modes/interactive-state.js.map +1 -1
- package/dist/modes/interactive.d.ts +16 -6
- package/dist/modes/interactive.d.ts.map +1 -1
- package/dist/modes/interactive.js +99 -33
- package/dist/modes/interactive.js.map +1 -1
- package/dist/modes/json-entry.d.ts +13 -0
- package/dist/modes/json-entry.d.ts.map +1 -0
- package/dist/modes/json-entry.js +14 -0
- package/dist/modes/json-entry.js.map +1 -0
- package/dist/modes/json.d.ts +4 -1
- package/dist/modes/json.d.ts.map +1 -1
- package/dist/modes/json.js +3 -3
- package/dist/modes/json.js.map +1 -1
- package/dist/modes/print-entry.d.ts +10 -0
- package/dist/modes/print-entry.d.ts.map +1 -0
- package/dist/modes/print-entry.js +11 -0
- package/dist/modes/print-entry.js.map +1 -0
- package/dist/modes/tree-selector.d.ts.map +1 -1
- package/dist/modes/tree-selector.js +4 -0
- package/dist/modes/tree-selector.js.map +1 -1
- package/dist/plugin-dump-composition.d.ts +6 -0
- package/dist/plugin-dump-composition.d.ts.map +1 -0
- package/dist/plugin-dump-composition.js +7 -0
- package/dist/plugin-dump-composition.js.map +1 -0
- package/dist/plugin-inventory.d.ts +7 -0
- package/dist/plugin-inventory.d.ts.map +1 -0
- package/dist/plugin-inventory.js +8 -0
- package/dist/plugin-inventory.js.map +1 -0
- package/dist/plugin-manager.d.ts +6 -0
- package/dist/plugin-manager.d.ts.map +1 -0
- package/dist/plugin-manager.js +7 -0
- package/dist/plugin-manager.js.map +1 -0
- package/dist/plugin-trace.d.ts +6 -0
- package/dist/plugin-trace.d.ts.map +1 -0
- package/dist/plugin-trace.js +7 -0
- package/dist/plugin-trace.js.map +1 -0
- package/dist/plugins/dynamic-broker.d.ts +76 -0
- package/dist/plugins/dynamic-broker.d.ts.map +1 -0
- package/dist/plugins/dynamic-broker.js +852 -0
- package/dist/plugins/dynamic-broker.js.map +1 -0
- package/dist/plugins/profile.d.ts +15 -0
- package/dist/plugins/profile.d.ts.map +1 -0
- package/dist/plugins/profile.js +34 -0
- package/dist/plugins/profile.js.map +1 -0
- package/dist/plugins/runtime-host.d.ts +37 -0
- package/dist/plugins/runtime-host.d.ts.map +1 -0
- package/dist/plugins/runtime-host.js +95 -0
- package/dist/plugins/runtime-host.js.map +1 -0
- package/dist/plugins/trust.d.ts +8 -0
- package/dist/plugins/trust.d.ts.map +1 -0
- package/dist/plugins/trust.js +59 -0
- package/dist/plugins/trust.js.map +1 -0
- package/dist/project-trust-entry.d.ts +15 -0
- package/dist/project-trust-entry.d.ts.map +1 -0
- package/dist/project-trust-entry.js +15 -0
- package/dist/project-trust-entry.js.map +1 -0
- package/dist/rpc/client.d.ts +78 -6
- package/dist/rpc/client.d.ts.map +1 -1
- package/dist/rpc/client.js +172 -4
- package/dist/rpc/client.js.map +1 -1
- package/dist/rpc/dispatcher.d.ts +121 -0
- package/dist/rpc/dispatcher.d.ts.map +1 -0
- package/dist/rpc/dispatcher.js +994 -0
- package/dist/rpc/dispatcher.js.map +1 -0
- package/dist/rpc/index.d.ts +2 -0
- package/dist/rpc/index.d.ts.map +1 -1
- package/dist/rpc/index.js +2 -0
- package/dist/rpc/index.js.map +1 -1
- package/dist/rpc/lifecycle.d.ts +6 -0
- package/dist/rpc/lifecycle.d.ts.map +1 -0
- package/dist/rpc/lifecycle.js +24 -0
- package/dist/rpc/lifecycle.js.map +1 -0
- package/dist/rpc/protocol.d.ts +112 -31
- package/dist/rpc/protocol.d.ts.map +1 -1
- package/dist/rpc/protocol.js +569 -117
- package/dist/rpc/protocol.js.map +1 -1
- package/dist/rpc/server-service.d.ts +7 -0
- package/dist/rpc/server-service.d.ts.map +1 -0
- package/dist/rpc/server-service.js +3 -0
- package/dist/rpc/server-service.js.map +1 -0
- package/dist/rpc/server.d.ts +16 -19
- package/dist/rpc/server.d.ts.map +1 -1
- package/dist/rpc/server.js +59 -115
- package/dist/rpc/server.js.map +1 -1
- package/dist/rpc-client-sdk-entry.d.ts +12 -0
- package/dist/rpc-client-sdk-entry.d.ts.map +1 -0
- package/dist/rpc-client-sdk-entry.js +11 -0
- package/dist/rpc-client-sdk-entry.js.map +1 -0
- package/dist/rpc-entry.js +50 -18
- package/dist/rpc-entry.js.map +1 -1
- package/dist/rpc-server-entry.d.ts +8 -0
- package/dist/rpc-server-entry.d.ts.map +1 -0
- package/dist/rpc-server-entry.js +67 -0
- package/dist/rpc-server-entry.js.map +1 -0
- package/dist/runtime/attachment-store.d.ts +13 -0
- package/dist/runtime/attachment-store.d.ts.map +1 -0
- package/dist/runtime/attachment-store.js +93 -0
- package/dist/runtime/attachment-store.js.map +1 -0
- package/dist/runtime/bootstrap.d.ts +14 -0
- package/dist/runtime/bootstrap.d.ts.map +1 -0
- package/dist/runtime/bootstrap.js +29 -0
- package/dist/runtime/bootstrap.js.map +1 -0
- package/dist/runtime/interactive-host-service.d.ts +22 -0
- package/dist/runtime/interactive-host-service.d.ts.map +1 -0
- package/dist/runtime/interactive-host-service.js +2 -0
- package/dist/runtime/interactive-host-service.js.map +1 -0
- package/dist/runtime/interactive-resource-service.d.ts +11 -0
- package/dist/runtime/interactive-resource-service.d.ts.map +1 -0
- package/dist/runtime/interactive-resource-service.js +3 -0
- package/dist/runtime/interactive-resource-service.js.map +1 -0
- package/dist/runtime/plugin-inventory-entry.d.ts +5 -0
- package/dist/runtime/plugin-inventory-entry.d.ts.map +1 -0
- package/dist/runtime/plugin-inventory-entry.js +18 -0
- package/dist/runtime/plugin-inventory-entry.js.map +1 -0
- package/dist/runtime/plugin-inventory-service.d.ts +8 -0
- package/dist/runtime/plugin-inventory-service.d.ts.map +1 -0
- package/dist/runtime/plugin-inventory-service.js +3 -0
- package/dist/runtime/plugin-inventory-service.js.map +1 -0
- package/dist/runtime/plugin-manager-entry.d.ts +20 -0
- package/dist/runtime/plugin-manager-entry.d.ts.map +1 -0
- package/dist/runtime/plugin-manager-entry.js +96 -0
- package/dist/runtime/plugin-manager-entry.js.map +1 -0
- package/dist/runtime/plugin-observability-entry.d.ts +12 -0
- package/dist/runtime/plugin-observability-entry.d.ts.map +1 -0
- package/dist/runtime/plugin-observability-entry.js +73 -0
- package/dist/runtime/plugin-observability-entry.js.map +1 -0
- package/dist/runtime/product-host.d.ts +91 -0
- package/dist/runtime/product-host.d.ts.map +1 -0
- package/dist/runtime/product-host.js +529 -0
- package/dist/runtime/product-host.js.map +1 -0
- package/dist/runtime/session-factory.d.ts +17 -0
- package/dist/runtime/session-factory.d.ts.map +1 -0
- package/dist/runtime/session-factory.js +75 -0
- package/dist/runtime/session-factory.js.map +1 -0
- package/dist/runtime/session-host.d.ts +152 -0
- package/dist/runtime/session-host.d.ts.map +1 -0
- package/dist/runtime/session-host.js +895 -0
- package/dist/runtime/session-host.js.map +1 -0
- package/dist/runtime-core-entry.d.ts +11 -0
- package/dist/runtime-core-entry.d.ts.map +1 -0
- package/dist/runtime-core-entry.js +9 -0
- package/dist/runtime-core-entry.js.map +1 -0
- package/dist/session-factory-entry.d.ts +7 -0
- package/dist/session-factory-entry.d.ts.map +1 -0
- package/dist/session-factory-entry.js +9 -0
- package/dist/session-factory-entry.js.map +1 -0
- package/dist/session-store-jsonl-entry.d.ts +7 -0
- package/dist/session-store-jsonl-entry.d.ts.map +1 -0
- package/dist/session-store-jsonl-entry.js +33 -0
- package/dist/session-store-jsonl-entry.js.map +1 -0
- package/dist/startup.d.ts +21 -1
- package/dist/startup.d.ts.map +1 -1
- package/dist/startup.js +179 -10
- package/dist/startup.js.map +1 -1
- package/dist/subagents/index.d.ts +2 -0
- package/dist/subagents/index.d.ts.map +1 -0
- package/dist/subagents/index.js +2 -0
- package/dist/subagents/index.js.map +1 -0
- package/dist/subagents/service.d.ts +50 -0
- package/dist/subagents/service.d.ts.map +1 -0
- package/dist/subagents/service.js +521 -0
- package/dist/subagents/service.js.map +1 -0
- package/dist/ui-host.d.ts +125 -0
- package/dist/ui-host.d.ts.map +1 -0
- package/dist/ui-host.js +275 -0
- package/dist/ui-host.js.map +1 -0
- package/dist/web/assets/index-BwfuGMvv.css +1 -0
- package/dist/web/assets/index-DPUaJqFJ.js +41 -0
- package/dist/web/assets/index-DPUaJqFJ.js.map +1 -0
- package/dist/web/index.html +14 -0
- package/dist/web-command.d.ts +11 -0
- package/dist/web-command.d.ts.map +1 -0
- package/dist/web-command.js +114 -0
- package/dist/web-command.js.map +1 -0
- package/dist/web-frontend.d.ts +73 -0
- package/dist/web-frontend.d.ts.map +1 -0
- package/dist/web-frontend.js +249 -0
- package/dist/web-frontend.js.map +1 -0
- package/dist/web.d.ts +254 -0
- package/dist/web.d.ts.map +1 -0
- package/dist/web.js +740 -0
- package/dist/web.js.map +1 -0
- package/dist/webui-entry.d.ts +3 -0
- package/dist/webui-entry.d.ts.map +1 -0
- package/dist/webui-entry.js +73 -0
- package/dist/webui-entry.js.map +1 -0
- package/dist/webui.d.ts +91 -0
- package/dist/webui.d.ts.map +1 -0
- package/dist/webui.js +882 -0
- package/dist/webui.js.map +1 -0
- package/package.json +89 -8
package/dist/core/tools/read.js
CHANGED
|
@@ -1,132 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { Type } from "@di-code/ai";
|
|
3
|
-
import { resolveAllowedFilePath } from "./path-boundary.js";
|
|
4
|
-
export const DEFAULT_READ_MAX_LINES = 2_000;
|
|
5
|
-
export const DEFAULT_READ_MAX_BYTES = 50 * 1024;
|
|
6
|
-
export const readParameters = Type.Object({
|
|
7
|
-
path: Type.String({ minLength: 1 }),
|
|
8
|
-
offset: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
9
|
-
limit: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
10
|
-
});
|
|
11
|
-
function assertPositiveInteger(name, value) {
|
|
12
|
-
if (value !== undefined && (!Number.isInteger(value) || value < 1)) {
|
|
13
|
-
throw new Error(`${name} must be a positive integer`);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function splitLines(text) {
|
|
17
|
-
if (text.length === 0)
|
|
18
|
-
return [];
|
|
19
|
-
const lines = text.split("\n");
|
|
20
|
-
if (text.endsWith("\n"))
|
|
21
|
-
lines.pop();
|
|
22
|
-
return lines;
|
|
23
|
-
}
|
|
24
|
-
function selectUserWindow(lines, offset, limit) {
|
|
25
|
-
if (lines.length === 0) {
|
|
26
|
-
if (offset > 1)
|
|
27
|
-
throw new Error(`Offset ${offset} is beyond end of file (0 lines total)`);
|
|
28
|
-
return { content: "", startLine: 1, endLine: 0, totalLines: 0, truncatedBy: null };
|
|
29
|
-
}
|
|
30
|
-
const startIndex = offset - 1;
|
|
31
|
-
if (startIndex >= lines.length) {
|
|
32
|
-
throw new Error(`Offset ${offset} is beyond end of file (${lines.length} lines total)`);
|
|
33
|
-
}
|
|
34
|
-
const available = lines.slice(startIndex);
|
|
35
|
-
const selected = limit === undefined ? available : available.slice(0, limit);
|
|
36
|
-
const endLine = offset + selected.length - 1;
|
|
37
|
-
return {
|
|
38
|
-
content: selected.join("\n"),
|
|
39
|
-
startLine: offset,
|
|
40
|
-
endLine,
|
|
41
|
-
totalLines: lines.length,
|
|
42
|
-
truncatedBy: limit !== undefined && selected.length < available.length ? "limit" : null,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
function applyOutputLimits(window, maxLines, maxBytes) {
|
|
46
|
-
if (window.content === "")
|
|
47
|
-
return window;
|
|
48
|
-
const lines = window.content.split("\n");
|
|
49
|
-
const selected = [];
|
|
50
|
-
let bytes = 0;
|
|
51
|
-
let truncatedBy = null;
|
|
52
|
-
for (const line of lines) {
|
|
53
|
-
if (selected.length >= maxLines) {
|
|
54
|
-
truncatedBy = "lines";
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
const separatorBytes = selected.length === 0 ? 0 : 1;
|
|
58
|
-
const nextBytes = bytes + separatorBytes + Buffer.byteLength(line, "utf8");
|
|
59
|
-
if (nextBytes > maxBytes) {
|
|
60
|
-
if (selected.length === 0)
|
|
61
|
-
throw new Error("A single line exceeds the read byte limit");
|
|
62
|
-
truncatedBy = "bytes";
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
selected.push(line);
|
|
66
|
-
bytes = nextBytes;
|
|
67
|
-
}
|
|
68
|
-
if (truncatedBy === null && selected.length < lines.length)
|
|
69
|
-
truncatedBy = "lines";
|
|
70
|
-
if (truncatedBy === null)
|
|
71
|
-
return window;
|
|
72
|
-
return {
|
|
73
|
-
...window,
|
|
74
|
-
content: selected.join("\n"),
|
|
75
|
-
endLine: window.startLine + selected.length - 1,
|
|
76
|
-
truncatedBy,
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
function formatByteLimit(maxBytes) {
|
|
80
|
-
if (maxBytes % 1024 === 0)
|
|
81
|
-
return `${maxBytes / 1024} KiB`;
|
|
82
|
-
return `${maxBytes} bytes`;
|
|
83
|
-
}
|
|
84
|
-
function appendContinuation(window, maxBytes) {
|
|
85
|
-
if (window.truncatedBy === null)
|
|
86
|
-
return window.content;
|
|
87
|
-
const nextOffset = window.endLine + 1;
|
|
88
|
-
if (window.truncatedBy === "limit") {
|
|
89
|
-
const remaining = window.totalLines - window.endLine;
|
|
90
|
-
return `${window.content}\n\n[${remaining} more lines in file. Use offset=${nextOffset} to continue.]`;
|
|
91
|
-
}
|
|
92
|
-
const reason = window.truncatedBy === "bytes" ? ` (${formatByteLimit(maxBytes)} limit)` : "";
|
|
93
|
-
return `${window.content}\n\n[Showing lines ${window.startLine}-${window.endLine} of ${window.totalLines}${reason}. Use offset=${nextOffset} to continue.]`;
|
|
94
|
-
}
|
|
95
|
-
function containsNulByte(buffer) {
|
|
96
|
-
const sampleLength = Math.min(buffer.length, 8 * 1024);
|
|
97
|
-
for (let index = 0; index < sampleLength; index++) {
|
|
98
|
-
if (buffer[index] === 0)
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
export function createReadTool(allowedRoot, options = {}) {
|
|
104
|
-
const maxLines = options.maxLines ?? DEFAULT_READ_MAX_LINES;
|
|
105
|
-
const maxBytes = options.maxBytes ?? DEFAULT_READ_MAX_BYTES;
|
|
106
|
-
assertPositiveInteger("maxLines", maxLines);
|
|
107
|
-
assertPositiveInteger("maxBytes", maxBytes);
|
|
108
|
-
return {
|
|
109
|
-
name: "read",
|
|
110
|
-
description: "Read a UTF-8 text file inside the allowed root. Use offset and limit for large files.",
|
|
111
|
-
parameters: readParameters,
|
|
112
|
-
async execute(_toolCallId, parameters, signal) {
|
|
113
|
-
if (signal?.aborted)
|
|
114
|
-
throw new Error("Operation aborted");
|
|
115
|
-
if (parameters.path.length === 0)
|
|
116
|
-
throw new Error("path must not be empty");
|
|
117
|
-
assertPositiveInteger("offset", parameters.offset);
|
|
118
|
-
assertPositiveInteger("limit", parameters.limit);
|
|
119
|
-
const absolutePath = await resolveAllowedFilePath(parameters.path, allowedRoot);
|
|
120
|
-
if (signal?.aborted)
|
|
121
|
-
throw new Error("Operation aborted");
|
|
122
|
-
const buffer = await readFile(absolutePath);
|
|
123
|
-
if (containsNulByte(buffer)) {
|
|
124
|
-
throw new Error("Binary files are not supported by read");
|
|
125
|
-
}
|
|
126
|
-
const userWindow = selectUserWindow(splitLines(buffer.toString("utf8")), parameters.offset ?? 1, parameters.limit);
|
|
127
|
-
const boundedWindow = applyOutputLimits(userWindow, maxLines, maxBytes);
|
|
128
|
-
return [{ type: "text", text: appendContinuation(boundedWindow, maxBytes) }];
|
|
129
|
-
},
|
|
130
|
-
};
|
|
131
|
-
}
|
|
1
|
+
export * from "@di-code/builtins";
|
|
132
2
|
//# sourceMappingURL=read.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read.js","sourceRoot":"","sources":["../../../src/core/tools/read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAuC,IAAI,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAC5C,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,GAAG,IAAI,CAAC;AAEhD,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC;IACzC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IACnC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;IACnD,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;CAClD,CAAC,CAAC;AAmBH,SAAS,qBAAqB,CAAC,IAAY,EAAE,KAAyB;IACrE,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC;QACpE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,6BAA6B,CAAC,CAAC;IACvD,CAAC;AACF,CAAC;AAED,SAAS,UAAU,CAAC,IAAY;IAC/B,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACjC,MAAM,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AC,wCAAwC,CAAC,CAAC;YAC3D,CAAC;YACD,MAAM,UAAU,GAAG,gBAAgB,CAClC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EACnC,UAAU,CAAC,MAAM,IAAI,CAAC,EACtB,UAAU,CAAC,KAAK,CAChB,CAAC;YACF,MAAM,aAAa,GAAG,iBAAiB,CAAC,UAAU,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;YACxE,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,CAAC,aAAa,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;QAC9E,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport type { AgentTool } from \"@di-code/agent\";\nimport { type Static, type ToolResultContent, Type } from \"@di-code/ai\";\nimport { resolveAllowedFilePath } from \"./path-boundary.ts\";\n\nexport const DEFAULT_READ_MAX_LINES = 2_000;\nexport const DEFAULT_READ_MAX_BYTES = 50 * 1024;\n\nexport const readParameters = Type.Object({\n\tpath: Type.String({ minLength: 1 }),\n\toffset: Type.Optional(Type.Integer({ minimum: 1 })),\n\tlimit: Type.Optional(Type.Integer({ minimum: 1 })),\n});\n\nexport type ReadParameters = Static<typeof readParameters>;\n\nexport interface ReadToolOptions {\n\treadonly maxLines?: number;\n\treadonly maxBytes?: number;\n}\n\nexport type ReadTool = AgentTool<typeof readParameters, ToolResultContent[]>;\n\ninterface TextWindow {\n\treadonly content: string;\n\treadonly startLine: number;\n\treadonly endLine: number;\n\treadonly totalLines: number;\n\treadonly truncatedBy: \"limit\" | \"lines\" | \"bytes\" | null;\n}\n\nfunction assertPositiveInteger(name: string, value: number | undefined): void {\n\tif (value !== undefined && (!Number.isInteger(value) || value < 1)) {\n\t\tthrow new Error(`${name} must be a positive integer`);\n\t}\n}\n\nfunction splitLines(text: string): string[] {\n\tif (text.length === 0) return [];\n\tconst lines = text.split(\"\\n\");\n\tif (text.endsWith(\"\\n\")) lines.pop();\n\treturn lines;\n}\n\nfunction selectUserWindow(lines: readonly string[], offset: number, limit: number | undefined): TextWindow {\n\tif (lines.length === 0) {\n\t\tif (offset > 1) throw new Error(`Offset ${offset} is beyond end of file (0 lines total)`);\n\t\treturn { content: \"\", startLine: 1, endLine: 0, totalLines: 0, truncatedBy: null };\n\t}\n\n\tconst startIndex = offset - 1;\n\tif (startIndex >= lines.length) {\n\t\tthrow new Error(`Offset ${offset} is beyond end of file (${lines.length} lines total)`);\n\t}\n\n\tconst available = lines.slice(startIndex);\n\tconst selected = limit === undefined ? available : available.slice(0, limit);\n\tconst endLine = offset + selected.length - 1;\n\treturn {\n\t\tcontent: selected.join(\"\\n\"),\n\t\tstartLine: offset,\n\t\tendLine,\n\t\ttotalLines: lines.length,\n\t\ttruncatedBy: limit !== undefined && selected.length < available.length ? \"limit\" : null,\n\t};\n}\n\nfunction applyOutputLimits(window: TextWindow, maxLines: number, maxBytes: number): TextWindow {\n\tif (window.content === \"\") return window;\n\tconst lines = window.content.split(\"\\n\");\n\tconst selected: string[] = [];\n\tlet bytes = 0;\n\tlet truncatedBy: \"lines\" | \"bytes\" | null = null;\n\n\tfor (const line of lines) {\n\t\tif (selected.length >= maxLines) {\n\t\t\ttruncatedBy = \"lines\";\n\t\t\tbreak;\n\t\t}\n\t\tconst separatorBytes = selected.length === 0 ? 0 : 1;\n\t\tconst nextBytes = bytes + separatorBytes + Buffer.byteLength(line, \"utf8\");\n\t\tif (nextBytes > maxBytes) {\n\t\t\tif (selected.length === 0) throw new Error(\"A single line exceeds the read byte limit\");\n\t\t\ttruncatedBy = \"bytes\";\n\t\t\tbreak;\n\t\t}\n\t\tselected.push(line);\n\t\tbytes = nextBytes;\n\t}\n\n\tif (truncatedBy === null && selected.length < lines.length) truncatedBy = \"lines\";\n\tif (truncatedBy === null) return window;\n\treturn {\n\t\t...window,\n\t\tcontent: selected.join(\"\\n\"),\n\t\tendLine: window.startLine + selected.length - 1,\n\t\ttruncatedBy,\n\t};\n}\n\nfunction formatByteLimit(maxBytes: number): string {\n\tif (maxBytes % 1024 === 0) return `${maxBytes / 1024} KiB`;\n\treturn `${maxBytes} bytes`;\n}\n\nfunction appendContinuation(window: TextWindow, maxBytes: number): string {\n\tif (window.truncatedBy === null) return window.content;\n\tconst nextOffset = window.endLine + 1;\n\tif (window.truncatedBy === \"limit\") {\n\t\tconst remaining = window.totalLines - window.endLine;\n\t\treturn `${window.content}\\n\\n[${remaining} more lines in file. Use offset=${nextOffset} to continue.]`;\n\t}\n\tconst reason = window.truncatedBy === \"bytes\" ? ` (${formatByteLimit(maxBytes)} limit)` : \"\";\n\treturn `${window.content}\\n\\n[Showing lines ${window.startLine}-${window.endLine} of ${window.totalLines}${reason}. Use offset=${nextOffset} to continue.]`;\n}\n\nfunction containsNulByte(buffer: Buffer): boolean {\n\tconst sampleLength = Math.min(buffer.length, 8 * 1024);\n\tfor (let index = 0; index < sampleLength; index++) {\n\t\tif (buffer[index] === 0) return true;\n\t}\n\treturn false;\n}\n\nexport function createReadTool(allowedRoot: string, options: ReadToolOptions = {}): ReadTool {\n\tconst maxLines = options.maxLines ?? DEFAULT_READ_MAX_LINES;\n\tconst maxBytes = options.maxBytes ?? DEFAULT_READ_MAX_BYTES;\n\tassertPositiveInteger(\"maxLines\", maxLines);\n\tassertPositiveInteger(\"maxBytes\", maxBytes);\n\n\treturn {\n\t\tname: \"read\",\n\t\tdescription: \"Read a UTF-8 text file inside the allowed root. Use offset and limit for large files.\",\n\t\tparameters: readParameters,\n\t\tasync execute(_toolCallId, parameters, signal): Promise<ToolResultContent[]> {\n\t\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\tif (parameters.path.length === 0) throw new Error(\"path must not be empty\");\n\t\t\tassertPositiveInteger(\"offset\", parameters.offset);\n\t\t\tassertPositiveInteger(\"limit\", parameters.limit);\n\t\t\tconst absolutePath = await resolveAllowedFilePath(parameters.path, allowedRoot);\n\t\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\tconst buffer = await readFile(absolutePath);\n\t\t\tif (containsNulByte(buffer)) {\n\t\t\t\tthrow new Error(\"Binary files are not supported by read\");\n\t\t\t}\n\t\t\tconst userWindow = selectUserWindow(\n\t\t\t\tsplitLines(buffer.toString(\"utf8\")),\n\t\t\t\tparameters.offset ?? 1,\n\t\t\t\tparameters.limit,\n\t\t\t);\n\t\t\tconst boundedWindow = applyOutputLimits(userWindow, maxLines, maxBytes);\n\t\t\treturn [{ type: \"text\", text: appendContinuation(boundedWindow, maxBytes) }];\n\t\t},\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"read.js","sourceRoot":"","sources":["../../../src/core/tools/read.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC","sourcesContent":["export * from \"@di-code/builtins\";\n"]}
|
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { type Static, type ToolResultContent, Type } from "@di-code/ai";
|
|
3
|
-
export declare const writeParameters: Type.TObject<{
|
|
4
|
-
path: Type.TString;
|
|
5
|
-
content: Type.TString;
|
|
6
|
-
}>;
|
|
7
|
-
export type WriteParameters = Static<typeof writeParameters>;
|
|
8
|
-
export interface WriteOperations {
|
|
9
|
-
mkdir(directory: string): Promise<void>;
|
|
10
|
-
writeFile(filePath: string, content: string): Promise<void>;
|
|
11
|
-
}
|
|
12
|
-
export interface WriteToolOptions {
|
|
13
|
-
readonly operations?: WriteOperations;
|
|
14
|
-
}
|
|
15
|
-
export type WriteTool = AgentTool<typeof writeParameters, ToolResultContent[]>;
|
|
16
|
-
export declare function createWriteTool(allowedRoot: string, options?: WriteToolOptions): WriteTool;
|
|
1
|
+
export * from "@di-code/builtins";
|
|
17
2
|
//# sourceMappingURL=write.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../../src/core/tools/write.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../../src/core/tools/write.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
|
package/dist/core/tools/write.js
CHANGED
|
@@ -1,45 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { dirname } from "node:path";
|
|
3
|
-
import { Type } from "@di-code/ai";
|
|
4
|
-
import { withFileMutationQueue } from "./file-mutation-queue.js";
|
|
5
|
-
import { resolveAllowedMutationPath } from "./path-boundary.js";
|
|
6
|
-
export const writeParameters = Type.Object({
|
|
7
|
-
path: Type.String({ minLength: 1 }),
|
|
8
|
-
content: Type.String(),
|
|
9
|
-
});
|
|
10
|
-
const defaultWriteOperations = {
|
|
11
|
-
async mkdir(directory) {
|
|
12
|
-
await fsMkdir(directory, { recursive: true });
|
|
13
|
-
},
|
|
14
|
-
async writeFile(filePath, content) {
|
|
15
|
-
await fsWriteFile(filePath, content, "utf8");
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
function throwIfAborted(signal) {
|
|
19
|
-
if (signal?.aborted)
|
|
20
|
-
throw new Error("Operation aborted");
|
|
21
|
-
}
|
|
22
|
-
export function createWriteTool(allowedRoot, options = {}) {
|
|
23
|
-
const operations = options.operations ?? defaultWriteOperations;
|
|
24
|
-
return {
|
|
25
|
-
name: "write",
|
|
26
|
-
description: "Create or completely overwrite a UTF-8 text file inside the allowed root.",
|
|
27
|
-
parameters: writeParameters,
|
|
28
|
-
async execute(_toolCallId, parameters, signal) {
|
|
29
|
-
throwIfAborted(signal);
|
|
30
|
-
if (parameters.path.length === 0)
|
|
31
|
-
throw new Error("path must not be empty");
|
|
32
|
-
const absolutePath = await resolveAllowedMutationPath(parameters.path, allowedRoot);
|
|
33
|
-
return withFileMutationQueue(absolutePath, async () => {
|
|
34
|
-
throwIfAborted(signal);
|
|
35
|
-
await operations.mkdir(dirname(absolutePath));
|
|
36
|
-
throwIfAborted(signal);
|
|
37
|
-
await operations.writeFile(absolutePath, parameters.content);
|
|
38
|
-
throwIfAborted(signal);
|
|
39
|
-
const bytes = Buffer.byteLength(parameters.content, "utf8");
|
|
40
|
-
return [{ type: "text", text: `Successfully wrote ${bytes} bytes to ${parameters.path}` }];
|
|
41
|
-
});
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
}
|
|
1
|
+
export * from "@di-code/builtins";
|
|
45
2
|
//# sourceMappingURL=write.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write.js","sourceRoot":"","sources":["../../../src/core/tools/write.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"write.js","sourceRoot":"","sources":["../../../src/core/tools/write.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC","sourcesContent":["export * from \"@di-code/builtins\";\n"]}
|
package/dist/entry.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { homedir } from "node:os";
|
|
3
|
-
import { join } from "node:path";
|
|
4
2
|
import { createInterface } from "node:readline/promises";
|
|
5
|
-
import {
|
|
3
|
+
import { redactSensitiveText } from "@di-code/plugin-runtime";
|
|
6
4
|
import packageMetadata from "../package.json" with { type: "json" };
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
5
|
+
import { parseCliArgs } from "./cli.js";
|
|
6
|
+
import { runMinimalProfile } from "./main.js";
|
|
7
|
+
import { resolveStartupArgs } from "./startup.js";
|
|
8
|
+
import { runWebCommand } from "./web-command.js";
|
|
10
9
|
async function promptProjectTrust(cwd) {
|
|
11
10
|
const readline = createInterface({ input: process.stdin, output: process.stdout });
|
|
12
11
|
try {
|
|
13
|
-
const answer = await readline.question(`Trust project-local Skills
|
|
12
|
+
const answer = await readline.question(`Trust project-local Skills and MCP configuration in ${cwd}? [y/N] `);
|
|
14
13
|
return /^(?:y|yes)$/i.test(answer.trim());
|
|
15
14
|
}
|
|
16
15
|
finally {
|
|
@@ -18,29 +17,32 @@ async function promptProjectTrust(cwd) {
|
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
19
|
try {
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
20
|
+
const rawArgs = process.argv.slice(2);
|
|
21
|
+
const args = resolveStartupArgs(rawArgs);
|
|
22
|
+
const command = parseCliArgs(args);
|
|
23
|
+
if (command.kind === "web") {
|
|
24
|
+
process.exitCode = await runWebCommand(command);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
const isInteractiveTerminal = Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
28
|
+
process.exitCode = await runMinimalProfile(args, {
|
|
29
|
+
version: packageMetadata.version,
|
|
30
|
+
stdout: (text) => process.stdout.write(text),
|
|
31
|
+
stderr: (text) => process.stderr.write(text),
|
|
32
|
+
interactive: { isInteractiveTerminal, promptProjectTrust },
|
|
33
|
+
onRuntimeEvent: (event) => {
|
|
34
|
+
if (process.env.DI_CODE_TRACE_PLUGINS === "1")
|
|
35
|
+
process.stderr.write(`${JSON.stringify(event)}\n`);
|
|
36
|
+
},
|
|
37
|
+
onSessionDisposed: () => {
|
|
38
|
+
if (process.env.DI_CODE_TRACE_PLUGINS === "1")
|
|
39
|
+
process.stderr.write('{"type":"session_dispose"}\n');
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
41
43
|
}
|
|
42
44
|
catch (cause) {
|
|
43
|
-
const message = cause instanceof Error ? cause.message : "Unknown startup error";
|
|
45
|
+
const message = redactSensitiveText(cause instanceof Error ? cause.message : "Unknown startup error");
|
|
44
46
|
process.stderr.write(`${message}\n`);
|
|
45
47
|
process.exitCode = 1;
|
|
46
48
|
}
|
package/dist/entry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.js","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"entry.js","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,eAAe,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,KAAK,UAAU,kBAAkB,CAAC,GAAW;IAC5C,MAAM,QAAQ,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACnF,IAAI,CAAC;QACJ,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,uDAAuD,GAAG,UAAU,CAAC,CAAC;QAC7G,OAAO,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3C,CAAC;YAAS,CAAC;QACV,QAAQ,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;AACF,CAAC;AAED,IAAI,CAAC;IACJ,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACtC,MAAM,IAAI,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACzC,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,O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,IAAI,CAAC,CAAC;IACrC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACtB,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport { createInterface } from \"node:readline/promises\";\nimport { redactSensitiveText } from \"@di-code/plugin-runtime\";\nimport packageMetadata from \"../package.json\" with { type: \"json\" };\nimport { parseCliArgs } from \"./cli.ts\";\nimport { runMinimalProfile } from \"./main.ts\";\nimport { resolveStartupArgs } from \"./startup.ts\";\nimport { runWebCommand } from \"./web-command.ts\";\n\nasync function promptProjectTrust(cwd: string): Promise<boolean> {\n\tconst readline = createInterface({ input: process.stdin, output: process.stdout });\n\ttry {\n\t\tconst answer = await readline.question(`Trust project-local Skills and MCP configuration in ${cwd}? [y/N] `);\n\t\treturn /^(?:y|yes)$/i.test(answer.trim());\n\t} finally {\n\t\treadline.close();\n\t}\n}\n\ntry {\n\tconst rawArgs = process.argv.slice(2);\n\tconst args = resolveStartupArgs(rawArgs);\n\tconst command = parseCliArgs(args);\n\tif (command.kind === \"web\") {\n\t\tprocess.exitCode = await runWebCommand(command);\n\t} else {\n\t\tconst isInteractiveTerminal = Boolean(process.stdin.isTTY && process.stdout.isTTY);\n\t\tprocess.exitCode = await runMinimalProfile(args, {\n\t\t\tversion: packageMetadata.version,\n\t\t\tstdout: (text) => process.stdout.write(text),\n\t\t\tstderr: (text) => process.stderr.write(text),\n\t\t\tinteractive: { isInteractiveTerminal, promptProjectTrust },\n\t\t\tonRuntimeEvent: (event) => {\n\t\t\t\tif (process.env.DI_CODE_TRACE_PLUGINS === \"1\") process.stderr.write(`${JSON.stringify(event)}\\n`);\n\t\t\t},\n\t\t\tonSessionDisposed: () => {\n\t\t\t\tif (process.env.DI_CODE_TRACE_PLUGINS === \"1\") process.stderr.write('{\"type\":\"session_dispose\"}\\n');\n\t\t\t},\n\t\t});\n\t}\n} catch (cause) {\n\tconst message = redactSensitiveText(cause instanceof Error ? cause.message : \"Unknown startup error\");\n\tprocess.stderr.write(`${message}\\n`);\n\tprocess.exitCode = 1;\n}\n"]}
|
package/dist/i18n.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../src/i18n.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC;AAEpC,eAAO,MAAM,cAAc,EAAE,MAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../src/i18n.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC;AAEpC,eAAO,MAAM,cAAc,EAAE,MAAa,CAAC;AA6N3C,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAGlF"}
|
package/dist/i18n.js
CHANGED
|
@@ -40,6 +40,7 @@ const MESSAGES = {
|
|
|
40
40
|
pasteImage: "paste image",
|
|
41
41
|
thinkingShortcut: "thinking",
|
|
42
42
|
cancel: "cancel",
|
|
43
|
+
cancelled: "Cancelled",
|
|
43
44
|
model: "model",
|
|
44
45
|
imageShortcut: "image",
|
|
45
46
|
language: "Language",
|
|
@@ -146,6 +147,7 @@ const MESSAGES = {
|
|
|
146
147
|
pasteImage: "粘贴图片",
|
|
147
148
|
thinkingShortcut: "思考",
|
|
148
149
|
cancel: "取消",
|
|
150
|
+
cancelled: "已取消",
|
|
149
151
|
model: "模型",
|
|
150
152
|
imageShortcut: "图片",
|
|
151
153
|
language: "语言",
|
package/dist/i18n.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../src/i18n.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAW,IAAI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,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC;IAC9E,OAAO,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AACrE,CAAC","sourcesContent":["export type Locale = \"en\" | \"zh-CN\";\n\nexport const DEFAULT_LOCALE: Locale = \"en\";\n\ntype Message = string | ((...values: string[]) => string);\n\nconst MESSAGES: Record<Locale, Record<string, Message>> = {\n\ten: {\n\t\tusage: \"Usage: di-code [options] <prompt>\",\n\t\toptions: \"Options:\",\n\t\tprint: \"Print only the final assistant text (default)\",\n\t\tmode: \"Output mode: print, json, or interactive\",\n\t\tinteractive: \"Start interactive terminal mode\",\n\t\tcontinueSession: \"Continue the most recently modified session\",\n\t\tsession: \"Create or resume a JSONL session (relative to the work root)\",\n\t\timage: \"Attach a local PNG, JPEG, WebP, or GIF image (repeatable)\",\n\t\tskill: \"Add a SKILL.md file or skill directory (repeatable)\",\n\t\tnoSkills: \"Disable all Skill loading\",\n\t\tnoContextFiles: \"Disable AGENTS.md discovery and loading\",\n\t\ttrustProject: \"Persist trust for project-local Skill discovery\",\n\t\tuntrustProject: \"Persist denial for project-local Skill discovery\",\n\t\tplugin: \"Install, list, enable, disable, update, or remove a plugin\",\n\t\tmcp: \"Manage MCP configuration (add <id> -- <command> defaults to local stdio)\",\n\t\thelp: \"Show help\",\n\t\tversion: \"Show version\",\n\t\tcommands: \"commands\",\n\t\tcomplete: \"complete\",\n\t\tworking: \"WORKING\",\n\t\tready: \"READY\",\n\t\terror: \"ERROR\",\n\t\tcompacting: \"COMPACTING\",\n\t\tretrying: \"RETRYING\",\n\t\tthinking: \"Thinking\",\n\t\tactivity: \"Activity\",\n\t\tqueue: (count) => `Queue (${count})`,\n\t\terrorPrefix: \"Error\",\n\t\tedited: \"Edited\",\n\t\twrote: \"Wrote\",\n\t\tearlierToolUpdates: (count) => `${count} earlier tool updates`,\n\t\tmessages: (count) => `${count} messages`,\n\t\tcontext: \"ctx\",\n\t\ttotal: \"total\",\n\t\ttokens: \"tok\",\n\t\tsend: \"send\",\n\t\tpasteImage: \"paste image\",\n\t\tthinkingShortcut: \"thinking\",\n\t\tcancel: \"cancel\",\n\t\tmodel: \"model\",\n\t\timageShortcut: \"image\",\n\t\tlanguage: \"Language\",\n\t\tsettings: \"Settings\",\n\t\tenglish: \"English\",\n\t\tchinese: \"中文\",\n\t\tcontextCompaction: \"Context compaction\",\n\t\ton: \"on\",\n\t\toff: \"off\",\n\t\tcompactionUnavailable: \"compaction unavailable without a persisted session\",\n\t\tvisibleMessagesCleared: \"visible messages cleared\",\n\t\tnothingToRetry: \"nothing to retry\",\n\t\tmanualCompactionStarting: \"starting manual compaction\",\n\t\tmanualCompactionComplete: \"manual compaction complete\",\n\t\tcurrentSession: \"Current session\",\n\t\tinMemorySession: \"In-memory session\",\n\t\tnewSession: \"New session\",\n\t\tnewSessionDescription: \"Start a new persistent conversation.\",\n\t\tdark: \"Dark\",\n\t\tlight: \"Light\",\n\t\tdarkTheme: \"Dark terminal theme\",\n\t\tlightTheme: \"Light terminal theme\",\n\t\topenModelSelector: \"Open the model selector\",\n\t\topenSessionSelector: \"Open the session selector\",\n\t\topenTreeSelector: \"Browse the current session tree\",\n\t\ttreeTitle: \"Branch tree\",\n\t\ttreeNodes: \"Branches\",\n\t\ttreePreview: \"Preview\",\n\t\ttreeEmpty: \"The current session has no history nodes.\",\n\t\ttreeActiveLeaf: \"active leaf\",\n\t\ttreeBranchNode: \"branch node\",\n\t\ttreeImagesOmitted: \"Images are not restored when editing this prompt.\",\n\t\ttreeContinue: \"Continue\",\n\t\ttreeEdit: \"Edit prompt\",\n\t\ttreeSummarize: \"Summarize + branch\",\n\t\ttreeCancel: \"Cancel\",\n\t\topenThemeSelector: \"Open the theme selector\",\n\t\topenSettingsSelector: \"Open the settings selector\",\n\t\tshowInteractiveCommands: \"Show interactive commands\",\n\t\tclearVisibleMessages: \"Clear visible messages\",\n\t\tchooseProvider: \"Choose a Provider and save its global API key\",\n\t\tremoveProviderKey: \"Remove the current Provider global API key\",\n\t\tcompactContext: \"Compact the persisted context now\",\n\t\tshowUsage: \"Show token and cost usage\",\n\t\tretryPrompt: \"Retry the last failed prompt\",\n\t\tsteerAgent: \"Steer the running agent\",\n\t\tproviderSetup: \"di-code provider setup\",\n\t\tlogin: \"di-code login\",\n\t\tselectProvider: \"Select a provider:\",\n\t\tselectProviderModel: (provider) => `Select a ${provider} model:`,\n\t\tenterApiKey: (name) => `Enter ${name} (input is hidden):`,\n\t\tapiKeyRequired: \"API key cannot be empty. Press Escape to cancel.\",\n\t\tproviderSetupCancelled: \"Provider setup cancelled.\",\n\t\tproviderConfigured: \"Provider configured for this run.\",\n\t\tproviderSetupFailed: \"Provider setup failed.\",\n\t\treasoning: \"reasoning\",\n\t\tfauxProvider: \"Deterministic local provider\",\n\t\tcustomProvider: \"Custom\",\n\t\tcustomProviderDescription: \"Configure a compatible gateway or private endpoint\",\n\t\tselectCustomApi: \"Select an API protocol:\",\n\t\tenterCustomBaseUrl: \"Enter the API base URL (for example, https://gateway.example.com/v1):\",\n\t\tenterCustomApiKey: \"Enter API key (input is hidden):\",\n\t\tenterCustomModelId: \"Enter model ID:\",\n\t\tmodelIdRequired: \"Model ID cannot be empty. Press Escape to cancel.\",\n\t\tcustomBaseUrlInvalid: \"Base URL is invalid.\",\n\t},\n\t\"zh-CN\": {\n\t\tusage: \"用法:di-code [选项] <提示词>\",\n\t\toptions: \"选项:\",\n\t\tprint: \"只输出最终 assistant 文本(默认)\",\n\t\tmode: \"输出模式:print、json 或 interactive\",\n\t\tinteractive: \"启动交互式终端模式\",\n\t\tcontinueSession: \"继续最近修改的会话\",\n\t\tsession: \"创建或恢复 JSONL 会话(相对工作根目录)\",\n\t\timage: \"附加本地 PNG、JPEG、WebP 或 GIF 图片(可重复)\",\n\t\tskill: \"加载一个 SKILL.md 文件或技能目录(可重复)\",\n\t\tnoSkills: \"禁用所有 Skill 加载\",\n\t\tnoContextFiles: \"禁用 AGENTS.md 发现和加载\",\n\t\ttrustProject: \"保存对项目本地 Skill 的信任\",\n\t\tuntrustProject: \"保存对项目本地 Skill 的拒绝\",\n\t\tplugin: \"安装、列出、启用、禁用、更新或移除插件\",\n\t\tmcp: \"管理 MCP 配置(add <id> -- <command> 默认为本地 stdio)\",\n\t\thelp: \"显示帮助\",\n\t\tversion: \"显示版本\",\n\t\tcommands: \"命令\",\n\t\tcomplete: \"补全\",\n\t\tworking: \"工作中\",\n\t\tready: \"就绪\",\n\t\terror: \"错误\",\n\t\tcompacting: \"压缩中\",\n\t\tretrying: \"重试中\",\n\t\tthinking: \"思考中\",\n\t\tactivity: \"活动\",\n\t\tqueue: (count) => `队列(${count})`,\n\t\terrorPrefix: \"错误\",\n\t\tedited: \"已编辑\",\n\t\twrote: \"已写入\",\n\t\tearlierToolUpdates: (count) => `之前还有 ${count} 条工具更新`,\n\t\tmessages: (count) => `${count} 条消息`,\n\t\tcontext: \"上下文\",\n\t\ttotal: \"总计\",\n\t\ttokens: \"token\",\n\t\tsend: \"发送\",\n\t\tpasteImage: \"粘贴图片\",\n\t\tthinkingShortcut: \"思考\",\n\t\tcancel: \"取消\",\n\t\tmodel: \"模型\",\n\t\timageShortcut: \"图片\",\n\t\tlanguage: \"语言\",\n\t\tsettings: \"设置\",\n\t\tenglish: \"English\",\n\t\tchinese: \"中文\",\n\t\tcontextCompaction: \"上下文压缩\",\n\t\ton: \"开\",\n\t\toff: \"关\",\n\t\tcompactionUnavailable: \"没有持久化会话,无法进行上下文压缩\",\n\t\tvisibleMessagesCleared: \"已清除可见消息\",\n\t\tnothingToRetry: \"没有可重试的内容\",\n\t\tmanualCompactionStarting: \"开始手动压缩\",\n\t\tmanualCompactionComplete: \"手动压缩完成\",\n\t\tcurrentSession: \"当前会话\",\n\t\tinMemorySession: \"内存会话\",\n\t\tnewSession: \"新建会话\",\n\t\tnewSessionDescription: \"开始新的持久化对话。\",\n\t\tdark: \"深色\",\n\t\tlight: \"浅色\",\n\t\tdarkTheme: \"深色终端主题\",\n\t\tlightTheme: \"浅色终端主题\",\n\t\topenModelSelector: \"打开模型选择器\",\n\t\topenSessionSelector: \"打开会话选择器\",\n\t\topenTreeSelector: \"浏览当前会话树\",\n\t\ttreeTitle: \"分支树\",\n\t\ttreeNodes: \"分支\",\n\t\ttreePreview: \"预览\",\n\t\ttreeEmpty: \"当前会话还没有历史节点。\",\n\t\ttreeActiveLeaf: \"当前叶节点\",\n\t\ttreeBranchNode: \"分支节点\",\n\t\ttreeImagesOmitted: \"编辑此提示词时不会恢复图片。\",\n\t\ttreeContinue: \"从此处继续\",\n\t\ttreeEdit: \"编辑提示词\",\n\t\ttreeSummarize: \"摘要后分支\",\n\t\ttreeCancel: \"取消\",\n\t\topenThemeSelector: \"打开主题选择器\",\n\t\topenSettingsSelector: \"打开设置选择器\",\n\t\tshowInteractiveCommands: \"显示交互命令\",\n\t\tclearVisibleMessages: \"清除可见消息\",\n\t\tchooseProvider: \"选择 Provider 并保存全局 API key\",\n\t\tremoveProviderKey: \"移除当前 Provider 的全局 API key\",\n\t\tcompactContext: \"立即压缩持久化上下文\",\n\t\tshowUsage: \"显示 token 和费用用量\",\n\t\tretryPrompt: \"重试上次失败的提示词\",\n\t\tsteerAgent: \"调整运行中的 Agent\",\n\t\tproviderSetup: \"di-code Provider 设置\",\n\t\tlogin: \"di-code 登录\",\n\t\tselectProvider: \"选择 Provider:\",\n\t\tselectProviderModel: (provider) => `选择 ${provider} 模型:`,\n\t\tenterApiKey: (name) => `输入 ${name}(输入内容会隐藏):`,\n\t\tapiKeyRequired: \"API key 不能为空。按 Escape 取消。\",\n\t\tproviderSetupCancelled: \"已取消 Provider 设置。\",\n\t\tproviderConfigured: \"已为本次运行配置 Provider。\",\n\t\tproviderSetupFailed: \"Provider 设置失败。\",\n\t\treasoning: \"推理\",\n\t\tfauxProvider: \"确定性的本地 Provider\",\n\t\tcustomProvider: \"Custom\",\n\t\tcustomProviderDescription: \"配置兼容网关或私有 endpoint\",\n\t\tselectCustomApi: \"选择 API 协议:\",\n\t\tenterCustomBaseUrl: \"输入 API 根地址(例如 https://gateway.example.com/v1):\",\n\t\tenterCustomApiKey: \"输入 API key(输入内容会隐藏):\",\n\t\tenterCustomModelId: \"输入模型 ID:\",\n\t\tmodelIdRequired: \"模型 ID 不能为空。按 Escape 取消。\",\n\t\tcustomBaseUrlInvalid: \"Base URL 无效。\",\n\t},\n};\n\nexport function isLocale(value: unknown): value is Locale {\n\treturn value === \"en\" || value === \"zh-CN\";\n}\n\nexport function translate(locale: Locale, key: string, ...values: string[]): string {\n\tconst message = MESSAGES[locale][key] ?? MESSAGES[DEFAULT_LOCALE][key] ?? key;\n\treturn typeof message === \"function\" ? message(...values) : message;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../src/i18n.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAW,IAAI,CAAC;AAI3C,MAAM,QAAQ,GAA4C;IACzD,EAAE,EAAE;QACH,KAAK,EAAE,mCAAmC;QAC1C,OAAO,EAAE,UAAU;QACnB,KAAK,EAAE,+CAA+C;QACtD,IAAI,EAAE,0CAA0C;QAChD,WAAW,EAAE,iCAAiC;QAC9C,eAAe,EAAE,6CAA6C;QAC9D,OAAO,EAAE,8DAA8D;QACvE,KAAK,EAAE,2DAA2D;QAClE,KAAK,EAAE,qDAAqD;QAC5D,QAAQ,EAAE,2BAA2B;QACrC,cAAc,EAAE,yCAAyC;QACzD,YAAY,EAAE,iDAAiD;QAC/D,cAAc,EAAE,kDAAkD;QAClE,MAAM,EAAE,4DAA4D;QACpE,GAAG,EAAE,0EAA0E;QAC/E,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,cAAc;QACvB,QAAQ,EAAE,UAAU;QACpB,QAAQ,EAAE,UAAU;QACpB,OAAO,EAAE,SAAS;QAClB,KAAK,EAAE,OAAO;QACd,KAAK,EAAE,OA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AC7C,cAAc,EAAE,2BAA2B;QAC3C,sBAAsB,EAAE,kBAAkB;QAC1C,kBAAkB,EAAE,oBAAoB;QACxC,mBAAmB,EAAE,gBAAgB;QACrC,SAAS,EAAE,IAAI;QACf,YAAY,EAAE,iBAAiB;QAC/B,cAAc,EAAE,QAAQ;QACxB,yBAAyB,EAAE,oBAAoB;QAC/C,eAAe,EAAE,YAAY;QAC7B,kBAAkB,EAAE,gDAAgD;QACpE,iBAAiB,EAAE,sBAAsB;QACzC,kBAAkB,EAAE,UAAU;QAC9B,eAAe,EAAE,yBAAyB;QAC1C,oBAAoB,EAAE,cAAc;KACpC;CACD,CAAC;AAEF,MAAM,UAAU,QAAQ,CAAC,KAAc;IACtC,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,OAAO,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,MAAc,EAAE,GAAW,EAAE,GAAG,MAAgB;IACzE,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC;IAC9E,OAAO,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AACrE,CAAC","sourcesContent":["export type Locale = \"en\" | \"zh-CN\";\n\nexport const DEFAULT_LOCALE: Locale = \"en\";\n\ntype Message = string | ((...values: string[]) => string);\n\nconst MESSAGES: Record<Locale, Record<string, Message>> = {\n\ten: {\n\t\tusage: \"Usage: di-code [options] <prompt>\",\n\t\toptions: \"Options:\",\n\t\tprint: \"Print only the final assistant text (default)\",\n\t\tmode: \"Output mode: print, json, or interactive\",\n\t\tinteractive: \"Start interactive terminal mode\",\n\t\tcontinueSession: \"Continue the most recently modified session\",\n\t\tsession: \"Create or resume a JSONL session (relative to the work root)\",\n\t\timage: \"Attach a local PNG, JPEG, WebP, or GIF image (repeatable)\",\n\t\tskill: \"Add a SKILL.md file or skill directory (repeatable)\",\n\t\tnoSkills: \"Disable all Skill loading\",\n\t\tnoContextFiles: \"Disable AGENTS.md discovery and loading\",\n\t\ttrustProject: \"Persist trust for project-local Skill discovery\",\n\t\tuntrustProject: \"Persist denial for project-local Skill discovery\",\n\t\tplugin: \"Install, list, enable, disable, update, or remove a plugin\",\n\t\tmcp: \"Manage MCP configuration (add <id> -- <command> defaults to local stdio)\",\n\t\thelp: \"Show help\",\n\t\tversion: \"Show version\",\n\t\tcommands: \"commands\",\n\t\tcomplete: \"complete\",\n\t\tworking: \"WORKING\",\n\t\tready: \"READY\",\n\t\terror: \"ERROR\",\n\t\tcompacting: \"COMPACTING\",\n\t\tretrying: \"RETRYING\",\n\t\tthinking: \"Thinking\",\n\t\tactivity: \"Activity\",\n\t\tqueue: (count) => `Queue (${count})`,\n\t\terrorPrefix: \"Error\",\n\t\tedited: \"Edited\",\n\t\twrote: \"Wrote\",\n\t\tearlierToolUpdates: (count) => `${count} earlier tool updates`,\n\t\tmessages: (count) => `${count} messages`,\n\t\tcontext: \"ctx\",\n\t\ttotal: \"total\",\n\t\ttokens: \"tok\",\n\t\tsend: \"send\",\n\t\tpasteImage: \"paste image\",\n\t\tthinkingShortcut: \"thinking\",\n\t\tcancel: \"cancel\",\n\t\tcancelled: \"Cancelled\",\n\t\tmodel: \"model\",\n\t\timageShortcut: \"image\",\n\t\tlanguage: \"Language\",\n\t\tsettings: \"Settings\",\n\t\tenglish: \"English\",\n\t\tchinese: \"中文\",\n\t\tcontextCompaction: \"Context compaction\",\n\t\ton: \"on\",\n\t\toff: \"off\",\n\t\tcompactionUnavailable: \"compaction unavailable without a persisted session\",\n\t\tvisibleMessagesCleared: \"visible messages cleared\",\n\t\tnothingToRetry: \"nothing to retry\",\n\t\tmanualCompactionStarting: \"starting manual compaction\",\n\t\tmanualCompactionComplete: \"manual compaction complete\",\n\t\tcurrentSession: \"Current session\",\n\t\tinMemorySession: \"In-memory session\",\n\t\tnewSession: \"New session\",\n\t\tnewSessionDescription: \"Start a new persistent conversation.\",\n\t\tdark: \"Dark\",\n\t\tlight: \"Light\",\n\t\tdarkTheme: \"Dark terminal theme\",\n\t\tlightTheme: \"Light terminal theme\",\n\t\topenModelSelector: \"Open the model selector\",\n\t\topenSessionSelector: \"Open the session selector\",\n\t\topenTreeSelector: \"Browse the current session tree\",\n\t\ttreeTitle: \"Branch tree\",\n\t\ttreeNodes: \"Branches\",\n\t\ttreePreview: \"Preview\",\n\t\ttreeEmpty: \"The current session has no history nodes.\",\n\t\ttreeActiveLeaf: \"active leaf\",\n\t\ttreeBranchNode: \"branch node\",\n\t\ttreeImagesOmitted: \"Images are not restored when editing this prompt.\",\n\t\ttreeContinue: \"Continue\",\n\t\ttreeEdit: \"Edit prompt\",\n\t\ttreeSummarize: \"Summarize + branch\",\n\t\ttreeCancel: \"Cancel\",\n\t\topenThemeSelector: \"Open the theme selector\",\n\t\topenSettingsSelector: \"Open the settings selector\",\n\t\tshowInteractiveCommands: \"Show interactive commands\",\n\t\tclearVisibleMessages: \"Clear visible messages\",\n\t\tchooseProvider: \"Choose a Provider and save its global API key\",\n\t\tremoveProviderKey: \"Remove the current Provider global API key\",\n\t\tcompactContext: \"Compact the persisted context now\",\n\t\tshowUsage: \"Show token and cost usage\",\n\t\tretryPrompt: \"Retry the last failed prompt\",\n\t\tsteerAgent: \"Steer the running agent\",\n\t\tproviderSetup: \"di-code provider setup\",\n\t\tlogin: \"di-code login\",\n\t\tselectProvider: \"Select a provider:\",\n\t\tselectProviderModel: (provider) => `Select a ${provider} model:`,\n\t\tenterApiKey: (name) => `Enter ${name} (input is hidden):`,\n\t\tapiKeyRequired: \"API key cannot be empty. Press Escape to cancel.\",\n\t\tproviderSetupCancelled: \"Provider setup cancelled.\",\n\t\tproviderConfigured: \"Provider configured for this run.\",\n\t\tproviderSetupFailed: \"Provider setup failed.\",\n\t\treasoning: \"reasoning\",\n\t\tfauxProvider: \"Deterministic local provider\",\n\t\tcustomProvider: \"Custom\",\n\t\tcustomProviderDescription: \"Configure a compatible gateway or private endpoint\",\n\t\tselectCustomApi: \"Select an API protocol:\",\n\t\tenterCustomBaseUrl: \"Enter the API base URL (for example, https://gateway.example.com/v1):\",\n\t\tenterCustomApiKey: \"Enter API key (input is hidden):\",\n\t\tenterCustomModelId: \"Enter model ID:\",\n\t\tmodelIdRequired: \"Model ID cannot be empty. Press Escape to cancel.\",\n\t\tcustomBaseUrlInvalid: \"Base URL is invalid.\",\n\t},\n\t\"zh-CN\": {\n\t\tusage: \"用法:di-code [选项] <提示词>\",\n\t\toptions: \"选项:\",\n\t\tprint: \"只输出最终 assistant 文本(默认)\",\n\t\tmode: \"输出模式:print、json 或 interactive\",\n\t\tinteractive: \"启动交互式终端模式\",\n\t\tcontinueSession: \"继续最近修改的会话\",\n\t\tsession: \"创建或恢复 JSONL 会话(相对工作根目录)\",\n\t\timage: \"附加本地 PNG、JPEG、WebP 或 GIF 图片(可重复)\",\n\t\tskill: \"加载一个 SKILL.md 文件或技能目录(可重复)\",\n\t\tnoSkills: \"禁用所有 Skill 加载\",\n\t\tnoContextFiles: \"禁用 AGENTS.md 发现和加载\",\n\t\ttrustProject: \"保存对项目本地 Skill 的信任\",\n\t\tuntrustProject: \"保存对项目本地 Skill 的拒绝\",\n\t\tplugin: \"安装、列出、启用、禁用、更新或移除插件\",\n\t\tmcp: \"管理 MCP 配置(add <id> -- <command> 默认为本地 stdio)\",\n\t\thelp: \"显示帮助\",\n\t\tversion: \"显示版本\",\n\t\tcommands: \"命令\",\n\t\tcomplete: \"补全\",\n\t\tworking: \"工作中\",\n\t\tready: \"就绪\",\n\t\terror: \"错误\",\n\t\tcompacting: \"压缩中\",\n\t\tretrying: \"重试中\",\n\t\tthinking: \"思考中\",\n\t\tactivity: \"活动\",\n\t\tqueue: (count) => `队列(${count})`,\n\t\terrorPrefix: \"错误\",\n\t\tedited: \"已编辑\",\n\t\twrote: \"已写入\",\n\t\tearlierToolUpdates: (count) => `之前还有 ${count} 条工具更新`,\n\t\tmessages: (count) => `${count} 条消息`,\n\t\tcontext: \"上下文\",\n\t\ttotal: \"总计\",\n\t\ttokens: \"token\",\n\t\tsend: \"发送\",\n\t\tpasteImage: \"粘贴图片\",\n\t\tthinkingShortcut: \"思考\",\n\t\tcancel: \"取消\",\n\t\tcancelled: \"已取消\",\n\t\tmodel: \"模型\",\n\t\timageShortcut: \"图片\",\n\t\tlanguage: \"语言\",\n\t\tsettings: \"设置\",\n\t\tenglish: \"English\",\n\t\tchinese: \"中文\",\n\t\tcontextCompaction: \"上下文压缩\",\n\t\ton: \"开\",\n\t\toff: \"关\",\n\t\tcompactionUnavailable: \"没有持久化会话,无法进行上下文压缩\",\n\t\tvisibleMessagesCleared: \"已清除可见消息\",\n\t\tnothingToRetry: \"没有可重试的内容\",\n\t\tmanualCompactionStarting: \"开始手动压缩\",\n\t\tmanualCompactionComplete: \"手动压缩完成\",\n\t\tcurrentSession: \"当前会话\",\n\t\tinMemorySession: \"内存会话\",\n\t\tnewSession: \"新建会话\",\n\t\tnewSessionDescription: \"开始新的持久化对话。\",\n\t\tdark: \"深色\",\n\t\tlight: \"浅色\",\n\t\tdarkTheme: \"深色终端主题\",\n\t\tlightTheme: \"浅色终端主题\",\n\t\topenModelSelector: \"打开模型选择器\",\n\t\topenSessionSelector: \"打开会话选择器\",\n\t\topenTreeSelector: \"浏览当前会话树\",\n\t\ttreeTitle: \"分支树\",\n\t\ttreeNodes: \"分支\",\n\t\ttreePreview: \"预览\",\n\t\ttreeEmpty: \"当前会话还没有历史节点。\",\n\t\ttreeActiveLeaf: \"当前叶节点\",\n\t\ttreeBranchNode: \"分支节点\",\n\t\ttreeImagesOmitted: \"编辑此提示词时不会恢复图片。\",\n\t\ttreeContinue: \"从此处继续\",\n\t\ttreeEdit: \"编辑提示词\",\n\t\ttreeSummarize: \"摘要后分支\",\n\t\ttreeCancel: \"取消\",\n\t\topenThemeSelector: \"打开主题选择器\",\n\t\topenSettingsSelector: \"打开设置选择器\",\n\t\tshowInteractiveCommands: \"显示交互命令\",\n\t\tclearVisibleMessages: \"清除可见消息\",\n\t\tchooseProvider: \"选择 Provider 并保存全局 API key\",\n\t\tremoveProviderKey: \"移除当前 Provider 的全局 API key\",\n\t\tcompactContext: \"立即压缩持久化上下文\",\n\t\tshowUsage: \"显示 token 和费用用量\",\n\t\tretryPrompt: \"重试上次失败的提示词\",\n\t\tsteerAgent: \"调整运行中的 Agent\",\n\t\tproviderSetup: \"di-code Provider 设置\",\n\t\tlogin: \"di-code 登录\",\n\t\tselectProvider: \"选择 Provider:\",\n\t\tselectProviderModel: (provider) => `选择 ${provider} 模型:`,\n\t\tenterApiKey: (name) => `输入 ${name}(输入内容会隐藏):`,\n\t\tapiKeyRequired: \"API key 不能为空。按 Escape 取消。\",\n\t\tproviderSetupCancelled: \"已取消 Provider 设置。\",\n\t\tproviderConfigured: \"已为本次运行配置 Provider。\",\n\t\tproviderSetupFailed: \"Provider 设置失败。\",\n\t\treasoning: \"推理\",\n\t\tfauxProvider: \"确定性的本地 Provider\",\n\t\tcustomProvider: \"Custom\",\n\t\tcustomProviderDescription: \"配置兼容网关或私有 endpoint\",\n\t\tselectCustomApi: \"选择 API 协议:\",\n\t\tenterCustomBaseUrl: \"输入 API 根地址(例如 https://gateway.example.com/v1):\",\n\t\tenterCustomApiKey: \"输入 API key(输入内容会隐藏):\",\n\t\tenterCustomModelId: \"输入模型 ID:\",\n\t\tmodelIdRequired: \"模型 ID 不能为空。按 Escape 取消。\",\n\t\tcustomBaseUrlInvalid: \"Base URL 无效。\",\n\t},\n};\n\nexport function isLocale(value: unknown): value is Locale {\n\treturn value === \"en\" || value === \"zh-CN\";\n}\n\nexport function translate(locale: Locale, key: string, ...values: string[]): string {\n\tconst message = MESSAGES[locale][key] ?? MESSAGES[DEFAULT_LOCALE][key] ?? key;\n\treturn typeof message === \"function\" ? message(...values) : message;\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,9 +6,12 @@ export * from "./core/session/session-storage.ts";
|
|
|
6
6
|
export * from "./core/session/types.ts";
|
|
7
7
|
export * from "./core/session.ts";
|
|
8
8
|
export * from "./core/system-prompt.ts";
|
|
9
|
-
export * from "./extensions/index.ts";
|
|
10
9
|
export * from "./mcp/config.ts";
|
|
11
|
-
export * from "./mcp/
|
|
10
|
+
export * from "./mcp/entries.ts";
|
|
12
11
|
export * from "./mcp/tool-adapter.ts";
|
|
13
|
-
export
|
|
12
|
+
export { apiVersion as rpcClientSdkApiVersion, apply as rpcClientSdkApply, name as rpcClientSdkName, type RpcClientSdk, rpcClientSdkKey, version as rpcClientSdkVersion, } from "./rpc-client-sdk-entry.ts";
|
|
13
|
+
export { pluginInventory } from "./runtime/plugin-inventory-entry.ts";
|
|
14
|
+
export { type PluginInventoryService, pluginInventoryKey } from "./runtime/plugin-inventory-service.ts";
|
|
15
|
+
export { type PluginManagementAction, type PluginManagementCommand, type PluginManagerEntryConfig, type PluginManagerService, pluginManager, pluginManagerKey, } from "./runtime/plugin-manager-entry.ts";
|
|
16
|
+
export { type PluginObservationService, pluginDumpComposition, pluginDumpCompositionKey, pluginTrace, pluginTraceKey, } from "./runtime/plugin-observability-entry.ts";
|
|
14
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EACN,UAAU,IAAI,sBAAsB,EACpC,KAAK,IAAI,iBAAiB,EAC1B,IAAI,IAAI,gBAAgB,EACxB,KAAK,YAAY,EACjB,eAAe,EACf,OAAO,IAAI,mBAAmB,GAC9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,KAAK,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AACxG,OAAO,EACN,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,aAAa,EACb,gBAAgB,GAChB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACN,KAAK,wBAAwB,EAC7B,qBAAqB,EACrB,wBAAwB,EACxB,WAAW,EACX,cAAc,GACd,MAAM,yCAAyC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -6,9 +6,12 @@ export * from "./core/session/session-storage.js";
|
|
|
6
6
|
export * from "./core/session/types.js";
|
|
7
7
|
export * from "./core/session.js";
|
|
8
8
|
export * from "./core/system-prompt.js";
|
|
9
|
-
export * from "./extensions/index.js";
|
|
10
9
|
export * from "./mcp/config.js";
|
|
11
|
-
export * from "./mcp/
|
|
10
|
+
export * from "./mcp/entries.js";
|
|
12
11
|
export * from "./mcp/tool-adapter.js";
|
|
13
|
-
export
|
|
12
|
+
export { apiVersion as rpcClientSdkApiVersion, apply as rpcClientSdkApply, name as rpcClientSdkName, rpcClientSdkKey, version as rpcClientSdkVersion, } from "./rpc-client-sdk-entry.js";
|
|
13
|
+
export { pluginInventory } from "./runtime/plugin-inventory-entry.js";
|
|
14
|
+
export { pluginInventoryKey } from "./runtime/plugin-inventory-service.js";
|
|
15
|
+
export { pluginManager, pluginManagerKey, } from "./runtime/plugin-manager-entry.js";
|
|
16
|
+
export { pluginDumpComposition, pluginDumpCompositionKey, pluginTrace, pluginTraceKey, } from "./runtime/plugin-observability-entry.js";
|
|
14
17
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EACN,UAAU,IAAI,sBAAsB,EACpC,KAAK,IAAI,iBAAiB,EAC1B,IAAI,IAAI,gBAAgB,EAExB,eAAe,EACf,OAAO,IAAI,mBAAmB,GAC9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAA+B,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AACxG,OAAO,EAKN,aAAa,EACb,gBAAgB,GAChB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAEN,qBAAqB,EACrB,wBAAwB,EACxB,WAAW,EACX,cAAc,GACd,MAAM,yCAAyC,CAAC","sourcesContent":["export * from \"./cli.ts\";\nexport * from \"./core/context-builder.ts\";\nexport * from \"./core/resources/index.ts\";\nexport * from \"./core/session/session-manager.ts\";\nexport * from \"./core/session/session-storage.ts\";\nexport * from \"./core/session/types.ts\";\nexport * from \"./core/session.ts\";\nexport * from \"./core/system-prompt.ts\";\nexport * from \"./mcp/config.ts\";\nexport * from \"./mcp/entries.ts\";\nexport * from \"./mcp/tool-adapter.ts\";\nexport {\n\tapiVersion as rpcClientSdkApiVersion,\n\tapply as rpcClientSdkApply,\n\tname as rpcClientSdkName,\n\ttype RpcClientSdk,\n\trpcClientSdkKey,\n\tversion as rpcClientSdkVersion,\n} from \"./rpc-client-sdk-entry.ts\";\nexport { pluginInventory } from \"./runtime/plugin-inventory-entry.ts\";\nexport { type PluginInventoryService, pluginInventoryKey } from \"./runtime/plugin-inventory-service.ts\";\nexport {\n\ttype PluginManagementAction,\n\ttype PluginManagementCommand,\n\ttype PluginManagerEntryConfig,\n\ttype PluginManagerService,\n\tpluginManager,\n\tpluginManagerKey,\n} from \"./runtime/plugin-manager-entry.ts\";\nexport {\n\ttype PluginObservationService,\n\tpluginDumpComposition,\n\tpluginDumpCompositionKey,\n\tpluginTrace,\n\tpluginTraceKey,\n} from \"./runtime/plugin-observability-entry.ts\";\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PluginFrontendController, PluginTerminalFrontendHost } from "@di-code/plugin-runtime";
|
|
2
|
+
import { type InteractiveModeOptions } from "../modes/interactive.ts";
|
|
3
|
+
export interface BuiltinInteractiveFrontendOptions extends Omit<InteractiveModeOptions, "tui"> {
|
|
4
|
+
readonly initialPrompt?: string;
|
|
5
|
+
}
|
|
6
|
+
/** The default ANSI frontend. It owns only the terminal facade supplied by the host. */
|
|
7
|
+
export declare class BuiltinInteractiveFrontend {
|
|
8
|
+
readonly id: "builtin";
|
|
9
|
+
private readonly options;
|
|
10
|
+
private mode?;
|
|
11
|
+
private resolveStart?;
|
|
12
|
+
constructor(options: BuiltinInteractiveFrontendOptions);
|
|
13
|
+
start(_controller: PluginFrontendController, terminal: PluginTerminalFrontendHost): Promise<void>;
|
|
14
|
+
dispose(): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export declare function createBuiltinInteractiveFrontend(options: BuiltinInteractiveFrontendOptions): BuiltinInteractiveFrontend;
|
|
17
|
+
//# sourceMappingURL=builtin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtin.d.ts","sourceRoot":"","sources":["../../src/interactive/builtin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAEpG,OAAO,EAAmB,KAAK,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEvF,MAAM,WAAW,iCAAkC,SAAQ,IAAI,CAAC,sBAAsB,EAAE,KAAK,CAAC;IAC7F,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,wFAAwF;AACxF,qBAAa,0BAA0B;IACtC,QAAQ,CAAC,EAAE,EAAG,SAAS,CAAU;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoC;IAC5D,OAAO,CAAC,IAAI,CAAC,CAAkB;IAC/B,OAAO,CAAC,YAAY,CAAC,CAAa;gBAEtB,OAAO,EAAE,iCAAiC;IAIhD,KAAK,CAAC,WAAW,EAAE,wBAAwB,EAAE,QAAQ,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBjG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAM9B;AAED,wBAAgB,gCAAgC,CAC/C,OAAO,EAAE,iCAAiC,GACxC,0BAA0B,CAE5B"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { TUI } from "@di-code/tui";
|
|
2
|
+
import { InteractiveMode } from "../modes/interactive.js";
|
|
3
|
+
/** The default ANSI frontend. It owns only the terminal facade supplied by the host. */
|
|
4
|
+
export class BuiltinInteractiveFrontend {
|
|
5
|
+
id = "builtin";
|
|
6
|
+
options;
|
|
7
|
+
mode;
|
|
8
|
+
resolveStart;
|
|
9
|
+
constructor(options) {
|
|
10
|
+
this.options = options;
|
|
11
|
+
}
|
|
12
|
+
async start(_controller, terminal) {
|
|
13
|
+
if (this.mode)
|
|
14
|
+
throw new Error("Builtin interactive frontend is already started.");
|
|
15
|
+
await new Promise((resolve, reject) => {
|
|
16
|
+
this.resolveStart = resolve;
|
|
17
|
+
const onExit = this.options.onExit;
|
|
18
|
+
this.mode = new InteractiveMode({
|
|
19
|
+
...this.options,
|
|
20
|
+
tui: new TUI(terminal),
|
|
21
|
+
onExit: () => {
|
|
22
|
+
onExit?.();
|
|
23
|
+
this.resolveStart = undefined;
|
|
24
|
+
resolve();
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
try {
|
|
28
|
+
this.mode.start(this.options.initialPrompt);
|
|
29
|
+
}
|
|
30
|
+
catch (cause) {
|
|
31
|
+
this.mode = undefined;
|
|
32
|
+
this.resolveStart = undefined;
|
|
33
|
+
reject(cause);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
async dispose() {
|
|
38
|
+
this.mode?.stop();
|
|
39
|
+
this.mode = undefined;
|
|
40
|
+
this.resolveStart?.();
|
|
41
|
+
this.resolveStart = undefined;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export function createBuiltinInteractiveFrontend(options) {
|
|
45
|
+
return new BuiltinInteractiveFrontend(options);
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=builtin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtin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CAAC,CAAC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,OAAO;QACZ,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;QAClB,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;QACtB,IAAI,CAAC,YAAY,EAAE,EAAE,CAAC;QACtB,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;IAC/B,CAAC;CACD;AAED,MAAM,UAAU,gCAAgC,CAC/C,OAA0C;IAE1C,OAAO,IAAI,0BAA0B,CAAC,OAAO,CAAC,CAAC;AAChD,CAAC","sourcesContent":["import type { PluginFrontendController, PluginTerminalFrontendHost } from \"@di-code/plugin-runtime\";\nimport { TUI } from \"@di-code/tui\";\nimport { InteractiveMode, type InteractiveModeOptions } from \"../modes/interactive.ts\";\n\nexport interface BuiltinInteractiveFrontendOptions extends Omit<InteractiveModeOptions, \"tui\"> {\n\treadonly initialPrompt?: string;\n}\n\n/** The default ANSI frontend. It owns only the terminal facade supplied by the host. */\nexport class BuiltinInteractiveFrontend {\n\treadonly id = \"builtin\" as const;\n\tprivate readonly options: BuiltinInteractiveFrontendOptions;\n\tprivate mode?: InteractiveMode;\n\tprivate resolveStart?: () => void;\n\n\tconstructor(options: BuiltinInteractiveFrontendOptions) {\n\t\tthis.options = options;\n\t}\n\n\tasync start(_controller: PluginFrontendController, terminal: PluginTerminalFrontendHost): Promise<void> {\n\t\tif (this.mode) throw new Error(\"Builtin interactive frontend is already started.\");\n\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\tthis.resolveStart = resolve;\n\t\t\tconst onExit = this.options.onExit;\n\t\t\tthis.mode = new InteractiveMode({\n\t\t\t\t...this.options,\n\t\t\t\ttui: new TUI(terminal),\n\t\t\t\tonExit: () => {\n\t\t\t\t\tonExit?.();\n\t\t\t\t\tthis.resolveStart = undefined;\n\t\t\t\t\tresolve();\n\t\t\t\t},\n\t\t\t});\n\t\t\ttry {\n\t\t\t\tthis.mode.start(this.options.initialPrompt);\n\t\t\t} catch (cause) {\n\t\t\t\tthis.mode = undefined;\n\t\t\t\tthis.resolveStart = undefined;\n\t\t\t\treject(cause);\n\t\t\t}\n\t\t});\n\t}\n\n\tasync dispose(): Promise<void> {\n\t\tthis.mode?.stop();\n\t\tthis.mode = undefined;\n\t\tthis.resolveStart?.();\n\t\tthis.resolveStart = undefined;\n\t}\n}\n\nexport function createBuiltinInteractiveFrontend(\n\toptions: BuiltinInteractiveFrontendOptions,\n): BuiltinInteractiveFrontend {\n\treturn new BuiltinInteractiveFrontend(options);\n}\n"]}
|