@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/cli.js
CHANGED
|
@@ -6,15 +6,22 @@ export class CliUsageError extends Error {
|
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
export function parseCliArgs(args) {
|
|
9
|
+
if (args[0] === "web")
|
|
10
|
+
return parseWebArgs(args.slice(1));
|
|
11
|
+
if (args.length === 1 && args[0] === "--trace-plugins")
|
|
12
|
+
return { kind: "observe", action: "trace" };
|
|
13
|
+
if (args.length === 1 && args[0] === "--dump-composition")
|
|
14
|
+
return { kind: "observe", action: "dump-composition" };
|
|
9
15
|
if (args[0] === "plugin") {
|
|
10
16
|
const action = args[1];
|
|
11
17
|
if (action !== "install" &&
|
|
12
18
|
action !== "list" &&
|
|
19
|
+
action !== "get" &&
|
|
13
20
|
action !== "enable" &&
|
|
14
21
|
action !== "disable" &&
|
|
15
22
|
action !== "update" &&
|
|
16
23
|
action !== "remove")
|
|
17
|
-
throw new CliUsageError("Plugin command must be install, list, enable, disable, update, or remove.");
|
|
24
|
+
throw new CliUsageError("Plugin command must be install, list, get, enable, disable, update, or remove.");
|
|
18
25
|
const argument = args[2];
|
|
19
26
|
if (args.length > 3 ||
|
|
20
27
|
(action !== "list" && (argument === undefined || argument.trim() === "")) ||
|
|
@@ -38,6 +45,10 @@ export function parseCliArgs(args) {
|
|
|
38
45
|
let continueSession = false;
|
|
39
46
|
let noSkills = false;
|
|
40
47
|
let noContextFiles = false;
|
|
48
|
+
let profile;
|
|
49
|
+
let compositionPath;
|
|
50
|
+
let noProjectPlugins = false;
|
|
51
|
+
let modeWasSelected = false;
|
|
41
52
|
let projectTrust;
|
|
42
53
|
const skillPaths = [];
|
|
43
54
|
const imagePaths = [];
|
|
@@ -49,7 +60,11 @@ export function parseCliArgs(args) {
|
|
|
49
60
|
continue;
|
|
50
61
|
}
|
|
51
62
|
if (argument === "--interactive") {
|
|
63
|
+
if (profile !== undefined && profile !== "interactive") {
|
|
64
|
+
throw new CliUsageError(`Cannot combine --profile ${profile} with --mode interactive.`);
|
|
65
|
+
}
|
|
52
66
|
mode = "interactive";
|
|
67
|
+
modeWasSelected = true;
|
|
53
68
|
continue;
|
|
54
69
|
}
|
|
55
70
|
if (argument === "-c" || argument === "--continue") {
|
|
@@ -64,6 +79,34 @@ export function parseCliArgs(args) {
|
|
|
64
79
|
noContextFiles = true;
|
|
65
80
|
continue;
|
|
66
81
|
}
|
|
82
|
+
if (argument === "--no-project-plugins") {
|
|
83
|
+
noProjectPlugins = true;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (argument === "--profile") {
|
|
87
|
+
const value = args[index + 1];
|
|
88
|
+
if (value !== "print" && value !== "json" && value !== "interactive") {
|
|
89
|
+
throw new CliUsageError("Option --profile expects print, json, or interactive.");
|
|
90
|
+
}
|
|
91
|
+
if (modeWasSelected && mode !== value) {
|
|
92
|
+
throw new CliUsageError(`Cannot combine --profile ${value} with --mode ${mode}.`);
|
|
93
|
+
}
|
|
94
|
+
profile = value;
|
|
95
|
+
mode = value;
|
|
96
|
+
index++;
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (argument === "--composition") {
|
|
100
|
+
const value = args[index + 1];
|
|
101
|
+
if (value === undefined || value.trim().length === 0) {
|
|
102
|
+
throw new CliUsageError("Option --composition requires a non-empty path.");
|
|
103
|
+
}
|
|
104
|
+
if (compositionPath !== undefined)
|
|
105
|
+
throw new CliUsageError("Option --composition may only be used once.");
|
|
106
|
+
compositionPath = value;
|
|
107
|
+
index++;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
67
110
|
if (argument === "--trust-project" || argument === "--untrust-project") {
|
|
68
111
|
const nextTrust = argument === "--trust-project";
|
|
69
112
|
if (projectTrust !== undefined && projectTrust !== nextTrust) {
|
|
@@ -98,7 +141,11 @@ export function parseCliArgs(args) {
|
|
|
98
141
|
if (value !== "print" && value !== "json" && value !== "interactive") {
|
|
99
142
|
throw new CliUsageError(`Unsupported mode "${value}". Expected print, json, or interactive.`);
|
|
100
143
|
}
|
|
144
|
+
if (profile !== undefined && profile !== value) {
|
|
145
|
+
throw new CliUsageError(`Cannot combine --profile ${profile} with --mode ${value}.`);
|
|
146
|
+
}
|
|
101
147
|
mode = value;
|
|
148
|
+
modeWasSelected = true;
|
|
102
149
|
index++;
|
|
103
150
|
continue;
|
|
104
151
|
}
|
|
@@ -141,6 +188,9 @@ export function parseCliArgs(args) {
|
|
|
141
188
|
...(continueSession ? { continueSession: true } : {}),
|
|
142
189
|
...(noSkills ? { noSkills: true } : {}),
|
|
143
190
|
...(noContextFiles ? { noContextFiles: true } : {}),
|
|
191
|
+
...(profile ? { profile } : {}),
|
|
192
|
+
...(compositionPath ? { compositionPath } : {}),
|
|
193
|
+
...(noProjectPlugins ? { noProjectPlugins: true } : {}),
|
|
144
194
|
...(skillPaths.length > 0 ? { skillPaths } : {}),
|
|
145
195
|
...(imagePaths.length > 0 ? { imagePaths } : {}),
|
|
146
196
|
...(projectTrust === undefined ? {} : { projectTrust }),
|
|
@@ -214,6 +264,30 @@ function parseMcpArgs(args) {
|
|
|
214
264
|
throw new CliUsageError("MCP HTTP add requires <server-id> <url>.");
|
|
215
265
|
return { kind: "mcp", action, transport, serverId: positional[0], url: positional[1], ...(scope ? { scope } : {}) };
|
|
216
266
|
}
|
|
267
|
+
function parseWebArgs(args) {
|
|
268
|
+
let port = 0;
|
|
269
|
+
const workspaces = [];
|
|
270
|
+
for (let index = 0; index < args.length; index++) {
|
|
271
|
+
const arg = args[index];
|
|
272
|
+
if (arg === "--port") {
|
|
273
|
+
const value = args[++index];
|
|
274
|
+
if (value === undefined)
|
|
275
|
+
throw new CliUsageError("Option --port requires a value.");
|
|
276
|
+
port = Number(value);
|
|
277
|
+
}
|
|
278
|
+
else if (arg === "--workspace") {
|
|
279
|
+
const value = args[++index];
|
|
280
|
+
if (!value?.trim())
|
|
281
|
+
throw new CliUsageError("Option --workspace requires a path.");
|
|
282
|
+
workspaces.push(value);
|
|
283
|
+
}
|
|
284
|
+
else
|
|
285
|
+
throw new CliUsageError("Web command accepts --port <0-65535> and --workspace <path>.");
|
|
286
|
+
}
|
|
287
|
+
if (!Number.isSafeInteger(port) || port < 0 || port > 65_535)
|
|
288
|
+
throw new CliUsageError("Option --port expects a TCP port from 0 to 65535.");
|
|
289
|
+
return { kind: "web", port, ...(workspaces.length ? { workspaces } : {}) };
|
|
290
|
+
}
|
|
217
291
|
export function helpText(locale) {
|
|
218
292
|
const t = (key) => translate(locale, key);
|
|
219
293
|
return `${t("usage")}
|
|
@@ -228,18 +302,31 @@ ${t("options")}
|
|
|
228
302
|
--skill <path> ${t("skill")}
|
|
229
303
|
--no-skills ${t("noSkills")}
|
|
230
304
|
--no-context-files ${t("noContextFiles")}
|
|
305
|
+
--profile <profile> Select print, json, or interactive composition
|
|
306
|
+
--composition <path> Apply a JSON or YAML composition after project configuration
|
|
307
|
+
--no-project-plugins Skip .di-code/composition.yml for this run
|
|
231
308
|
--trust-project ${t("trustProject")}
|
|
232
309
|
--untrust-project ${t("untrustProject")}
|
|
233
310
|
plugin <action> ${t("plugin")}
|
|
311
|
+
--trace-plugins Emit Loader phase, owner Fiber, capability, and failure diagnostics
|
|
312
|
+
--dump-composition Emit the resolved composition without configuration values
|
|
234
313
|
mcp add|list|get|remove ${t("mcp")}
|
|
314
|
+
web [--port <port>] Start the local web application (default: an available port)
|
|
235
315
|
-h, --help ${t("help")}
|
|
236
316
|
-v, --version ${t("version")}
|
|
237
317
|
`;
|
|
238
318
|
}
|
|
319
|
+
/** Product-owned parser service consumed by the CLI composition entry. */
|
|
320
|
+
export function createCliParser() {
|
|
321
|
+
return {
|
|
322
|
+
parse: (args) => parseCliArgs(args),
|
|
323
|
+
help: (locale) => helpText(locale === "zh-CN" ? "zh-CN" : "en"),
|
|
324
|
+
};
|
|
325
|
+
}
|
|
239
326
|
export async function runCli(args, dependencies) {
|
|
240
327
|
let command;
|
|
241
328
|
try {
|
|
242
|
-
command = parseCliArgs(args);
|
|
329
|
+
command = dependencies.parser?.parse(args) ?? parseCliArgs(args);
|
|
243
330
|
}
|
|
244
331
|
catch (cause) {
|
|
245
332
|
if (cause instanceof CliUsageError) {
|
|
@@ -250,12 +337,17 @@ export async function runCli(args, dependencies) {
|
|
|
250
337
|
}
|
|
251
338
|
switch (command.kind) {
|
|
252
339
|
case "help":
|
|
253
|
-
dependencies.stdout(
|
|
340
|
+
dependencies.stdout(dependencies.parser?.help(dependencies.locale ?? DEFAULT_LOCALE) ??
|
|
341
|
+
helpText(dependencies.locale ?? DEFAULT_LOCALE));
|
|
254
342
|
return 0;
|
|
255
343
|
case "plugin":
|
|
256
344
|
if (!dependencies.plugin)
|
|
257
345
|
throw new Error("Plugin command handler is unavailable.");
|
|
258
346
|
return dependencies.plugin(command);
|
|
347
|
+
case "observe":
|
|
348
|
+
if (!dependencies.observe)
|
|
349
|
+
throw new Error("Plugin observability command handler is unavailable.");
|
|
350
|
+
return dependencies.observe(command);
|
|
259
351
|
case "mcp":
|
|
260
352
|
if (!dependencies.mcp)
|
|
261
353
|
throw new Error("MCP command handler is unavailable.");
|
|
@@ -265,6 +357,8 @@ export async function runCli(args, dependencies) {
|
|
|
265
357
|
return 0;
|
|
266
358
|
case "run":
|
|
267
359
|
return dependencies.run(command);
|
|
360
|
+
case "web":
|
|
361
|
+
throw new Error("Web command must be handled by the executable entry point.");
|
|
268
362
|
}
|
|
269
363
|
}
|
|
270
364
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAe,SAAS,EAAE,MAAM,WAAW,CAAC;AA+BnE,MAAM,OAAO,aAAc,SAAQ,KAAK;IACvC,YAAY,OAAe;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC7B,CAAC;CACD;AAED,MAAM,UAAU,YAAY,CAAC,IAAuB;IACnD,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACvB,IACC,MAAM,KAAK,SAAS;YACpB,MAAM,KAAK,MAAM;YACjB,MAAM,KAAK,QAAQ;YACnB,MAAM,KAAK,SAAS;YACpB,MAA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,CAAC;QACV,KAAK,KAAK;YACT,OAAO,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;AACF,CAAC","sourcesContent":["import { DEFAULT_LOCALE, type Locale, translate } from \"./i18n.ts\";\n\nexport type OutputMode = \"print\" | \"json\" | \"interactive\";\n\nexport type CliCommand =\n\t| { kind: \"help\" }\n\t| { kind: \"version\" }\n\t| { kind: \"plugin\"; action: \"install\" | \"list\" | \"enable\" | \"disable\" | \"update\" | \"remove\"; argument?: string }\n\t| {\n\t\t\tkind: \"mcp\";\n\t\t\taction: \"add\" | \"list\" | \"get\" | \"remove\";\n\t\t\tscope?: \"local\" | \"project\" | \"user\";\n\t\t\tserverId?: string;\n\t\t\ttransport?: \"stdio\" | \"http\";\n\t\t\tcommand?: string;\n\t\t\targs?: readonly string[];\n\t\t\turl?: string;\n\t }\n\t| {\n\t\t\tkind: \"run\";\n\t\t\tmode: OutputMode;\n\t\t\tprompt: string;\n\t\t\tsessionPath?: string;\n\t\t\tcontinueSession?: true;\n\t\t\timagePaths?: readonly string[];\n\t\t\tnoSkills?: true;\n\t\t\tnoContextFiles?: true;\n\t\t\tskillPaths?: readonly string[];\n\t\t\tprojectTrust?: boolean;\n\t };\n\nexport class CliUsageError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"CliUsageError\";\n\t}\n}\n\nexport function parseCliArgs(args: readonly string[]): CliCommand {\n\tif (args[0] === \"plugin\") {\n\t\tconst action = args[1];\n\t\tif (\n\t\t\taction !== \"install\" &&\n\t\t\taction !== \"list\" &&\n\t\t\taction !== \"enable\" &&\n\t\t\taction !== \"disable\" &&\n\t\t\taction !== \"update\" &&\n\t\t\taction !== \"remove\"\n\t\t)\n\t\t\tthrow new CliUsageError(\"Plugin command must be install, list, enable, disable, update, or remove.\");\n\t\tconst argument = args[2];\n\t\tif (\n\t\t\targs.length > 3 ||\n\t\t\t(action !== \"list\" && (argument === undefined || argument.trim() === \"\")) ||\n\t\t\t(action === \"list\" && argument !== undefined)\n\t\t)\n\t\t\tthrow new CliUsageError(\"Plugin command has invalid arguments.\");\n\t\treturn { kind: \"plugin\", action, ...(argument ? { argument } : {}) };\n\t}\n\tif (args[0] === \"mcp\") return parseMcpArgs(args.slice(1));\n\tconst staticOption = args.find((argument) => [\"-h\", \"--help\", \"-v\", \"--version\"].includes(argument));\n\tif (staticOption !== undefined) {\n\t\tconst kind = staticOption === \"-h\" || staticOption === \"--help\" ? \"help\" : \"version\";\n\t\tif (args.length !== 1) {\n\t\t\tthrow new CliUsageError(`--${kind} must be used on its own.`);\n\t\t}\n\t\treturn { kind };\n\t}\n\n\tlet mode: OutputMode = \"print\";\n\tlet printAlias = false;\n\tlet sessionPath: string | undefined;\n\tlet continueSession = false;\n\tlet noSkills = false;\n\tlet noContextFiles = false;\n\tlet projectTrust: boolean | undefined;\n\tconst skillPaths: string[] = [];\n\tconst imagePaths: string[] = [];\n\tconst promptParts: string[] = [];\n\n\tfor (let index = 0; index < args.length; index++) {\n\t\tconst argument = args[index];\n\t\tif (argument === \"-p\" || argument === \"--print\") {\n\t\t\tprintAlias = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (argument === \"--interactive\") {\n\t\t\tmode = \"interactive\";\n\t\t\tcontinue;\n\t\t}\n\t\tif (argument === \"-c\" || argument === \"--continue\") {\n\t\t\tcontinueSession = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (argument === \"--no-skills\") {\n\t\t\tnoSkills = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (argument === \"--no-context-files\") {\n\t\t\tnoContextFiles = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (argument === \"--trust-project\" || argument === \"--untrust-project\") {\n\t\t\tconst nextTrust = argument === \"--trust-project\";\n\t\t\tif (projectTrust !== undefined && projectTrust !== nextTrust) {\n\t\t\t\tthrow new CliUsageError(\"Cannot combine --trust-project with --untrust-project.\");\n\t\t\t}\n\t\t\tprojectTrust = nextTrust;\n\t\t\tcontinue;\n\t\t}\n\t\tif (argument === \"--skill\") {\n\t\t\tconst value = args[index + 1];\n\t\t\tif (value === undefined || value.trim().length === 0) {\n\t\t\t\tthrow new CliUsageError(\"Option --skill requires a non-empty value.\");\n\t\t\t}\n\t\t\tskillPaths.push(value);\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (argument === \"--image\") {\n\t\t\tconst value = args[index + 1];\n\t\t\tif (value === undefined || value.trim().length === 0) {\n\t\t\t\tthrow new CliUsageError(\"Option --image requires a non-empty value.\");\n\t\t\t}\n\t\t\timagePaths.push(value);\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (argument === \"--mode\") {\n\t\t\tconst value = args[index + 1];\n\t\t\tif (value === undefined) {\n\t\t\t\tthrow new CliUsageError(\"Option --mode requires a value.\");\n\t\t\t}\n\t\t\tif (value !== \"print\" && value !== \"json\" && value !== \"interactive\") {\n\t\t\t\tthrow new CliUsageError(`Unsupported mode \"${value}\". Expected print, json, or interactive.`);\n\t\t\t}\n\t\t\tmode = value;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (argument === \"--session\") {\n\t\t\tconst value = args[index + 1];\n\t\t\tif (value === undefined) {\n\t\t\t\tthrow new CliUsageError(\"Option --session requires a value.\");\n\t\t\t}\n\t\t\tif (value.trim().length === 0) {\n\t\t\t\tthrow new CliUsageError(\"Option --session requires a non-empty value.\");\n\t\t\t}\n\t\t\tsessionPath = value;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (argument?.startsWith(\"-\")) {\n\t\t\tthrow new CliUsageError(`Unknown option \"${argument}\".`);\n\t\t}\n\t\tif (argument !== undefined) {\n\t\t\tpromptParts.push(argument);\n\t\t}\n\t}\n\n\tif (printAlias && mode !== \"print\") {\n\t\tthrow new CliUsageError(`Cannot combine --print with --mode ${mode}.`);\n\t}\n\tif (continueSession && sessionPath !== undefined) {\n\t\tthrow new CliUsageError(\"Cannot combine --continue with --session.\");\n\t}\n\tif (mode === \"interactive\" && imagePaths.length > 0) {\n\t\tthrow new CliUsageError(\"--image is not available in interactive mode.\");\n\t}\n\tif (promptParts.length === 0 && mode !== \"interactive\") {\n\t\tthrow new CliUsageError(\"A prompt is required.\");\n\t}\n\n\treturn {\n\t\tkind: \"run\",\n\t\tmode,\n\t\tprompt: promptParts.join(\" \"),\n\t\t...(sessionPath ? { sessionPath } : {}),\n\t\t...(continueSession ? { continueSession: true as const } : {}),\n\t\t...(noSkills ? { noSkills: true as const } : {}),\n\t\t...(noContextFiles ? { noContextFiles: true as const } : {}),\n\t\t...(skillPaths.length > 0 ? { skillPaths } : {}),\n\t\t...(imagePaths.length > 0 ? { imagePaths } : {}),\n\t\t...(projectTrust === undefined ? {} : { projectTrust }),\n\t};\n}\n\nfunction parseMcpArgs(args: readonly string[]): Extract<CliCommand, { kind: \"mcp\" }> {\n\tconst action = args[0];\n\tif (action !== \"add\" && action !== \"list\" && action !== \"get\" && action !== \"remove\")\n\t\tthrow new CliUsageError(\"MCP command must be add, list, get, or remove.\");\n\tlet scope: \"local\" | \"project\" | \"user\" | undefined;\n\tlet transport: \"stdio\" | \"http\" | undefined;\n\tconst positional: string[] = [];\n\tlet separator = -1;\n\tfor (let index = 1; index < args.length; index++) {\n\t\tconst argument = args[index];\n\t\tif (argument === \"--\") {\n\t\t\tseparator = index;\n\t\t\tbreak;\n\t\t}\n\t\tif (argument === \"--scope\") {\n\t\t\tconst value = args[++index];\n\t\t\tif (value !== \"local\" && value !== \"project\" && value !== \"user\")\n\t\t\t\tthrow new CliUsageError(\"Option --scope expects local, project, or user.\");\n\t\t\tif (scope !== undefined) throw new CliUsageError(\"Option --scope may only be used once.\");\n\t\t\tscope = value;\n\t\t\tcontinue;\n\t\t}\n\t\tif (argument === \"--transport\") {\n\t\t\tconst value = args[++index];\n\t\t\tif (value !== \"stdio\" && value !== \"http\") throw new CliUsageError(\"Option --transport expects stdio or http.\");\n\t\t\tif (transport !== undefined) throw new CliUsageError(\"Option --transport may only be used once.\");\n\t\t\ttransport = value;\n\t\t\tcontinue;\n\t\t}\n\t\tif (argument.startsWith(\"-\")) throw new CliUsageError(`Unknown MCP option \"${argument}\".`);\n\t\tpositional.push(argument);\n\t}\n\tif (separator >= 0) positional.push(...args.slice(separator + 1));\n\tif (action === \"list\") {\n\t\tif (transport !== undefined || positional.length > 0)\n\t\t\tthrow new CliUsageError(\"MCP list accepts only an optional --scope.\");\n\t\treturn { kind: \"mcp\", action, ...(scope ? { scope } : {}) };\n\t}\n\tif (action === \"get\" || action === \"remove\") {\n\t\tif (transport !== undefined || positional.length !== 1 || positional[0].trim() === \"\")\n\t\t\tthrow new CliUsageError(`MCP ${action} requires exactly one server id.`);\n\t\treturn { kind: \"mcp\", action, serverId: positional[0], ...(scope ? { scope } : {}) };\n\t}\n\tconst selectedTransport = transport ?? (separator >= 0 ? \"stdio\" : undefined);\n\tif (selectedTransport === undefined)\n\t\tthrow new CliUsageError(\n\t\t\t\"MCP add requires <server-id> -- <command> [args...] or --transport http <server-id> <url>.\",\n\t\t);\n\tif (selectedTransport === \"stdio\") {\n\t\tif (positional.length < 2 || separator < 0)\n\t\t\tthrow new CliUsageError(\"MCP stdio add requires <server-id> -- <command> [args...].\");\n\t\treturn {\n\t\t\tkind: \"mcp\",\n\t\t\taction,\n\t\t\ttransport: \"stdio\",\n\t\t\tserverId: positional[0],\n\t\t\tcommand: positional[1],\n\t\t\t...(positional.length > 2 ? { args: positional.slice(2) } : {}),\n\t\t\t...(scope ? { scope } : {}),\n\t\t};\n\t}\n\tif (separator >= 0 || positional.length !== 2) throw new CliUsageError(\"MCP HTTP add requires <server-id> <url>.\");\n\treturn { kind: \"mcp\", action, transport, serverId: positional[0], url: positional[1], ...(scope ? { scope } : {}) };\n}\n\nexport function helpText(locale: Locale): string {\n\tconst t = (key: string) => translate(locale, key);\n\treturn `${t(\"usage\")}\n\n${t(\"options\")}\n -p, --print ${t(\"print\")}\n --mode <mode> ${t(\"mode\")}\n --interactive ${t(\"interactive\")}\n --continue, -c ${t(\"continueSession\")}\n --session <path> ${t(\"session\")}\n --image <path> ${t(\"image\")}\n --skill <path> ${t(\"skill\")}\n --no-skills ${t(\"noSkills\")}\n --no-context-files ${t(\"noContextFiles\")}\n --trust-project ${t(\"trustProject\")}\n --untrust-project ${t(\"untrustProject\")}\n plugin <action> ${t(\"plugin\")}\n mcp add|list|get|remove ${t(\"mcp\")}\n -h, --help ${t(\"help\")}\n -v, --version ${t(\"version\")}\n`;\n}\n\nexport interface CliDependencies {\n\tstdout(text: string): void;\n\tstderr(text: string): void;\n\trun(command: Extract<CliCommand, { kind: \"run\" }>): Promise<number>;\n\tplugin?(command: Extract<CliCommand, { kind: \"plugin\" }>): Promise<number>;\n\tmcp?(command: Extract<CliCommand, { kind: \"mcp\" }>): Promise<number>;\n\treadonly version: string;\n\treadonly locale?: Locale;\n}\n\nexport async function runCli(args: readonly string[], dependencies: CliDependencies): Promise<number> {\n\tlet command: CliCommand;\n\ttry {\n\t\tcommand = parseCliArgs(args);\n\t} catch (cause) {\n\t\tif (cause instanceof CliUsageError) {\n\t\t\tdependencies.stderr(`${cause.message}\\n`);\n\t\t\treturn 1;\n\t\t}\n\t\tthrow cause;\n\t}\n\n\tswitch (command.kind) {\n\t\tcase \"help\":\n\t\t\tdependencies.stdout(helpText(dependencies.locale ?? DEFAULT_LOCALE));\n\t\t\treturn 0;\n\t\tcase \"plugin\":\n\t\t\tif (!dependencies.plugin) throw new Error(\"Plugin command handler is unavailable.\");\n\t\t\treturn dependencies.plugin(command);\n\t\tcase \"mcp\":\n\t\t\tif (!dependencies.mcp) throw new Error(\"MCP command handler is unavailable.\");\n\t\t\treturn dependencies.mcp(command);\n\t\tcase \"version\":\n\t\t\tdependencies.stdout(`${dependencies.version}\\n`);\n\t\t\treturn 0;\n\t\tcase \"run\":\n\t\t\treturn dependencies.run(command);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"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C,IAAI,EAAE,CAAC;QACtB,KAAK,MAAM;YACV,YAAY,CAAC,MAAM,CAClB,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM,IAAI,cAAc,CAAC;gBAC/D,QAAQ,CAAC,YAAY,CAAC,MAAM,IAAI,cAAc,CAAC,CAChD,CAAC;YACF,OAAO,CAAC,CAAC;QACV,KAAK,QAAQ;YACZ,IAAI,CAAC,YAAY,CAAC,MAAM;gBAAE,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;YACpF,OAAO,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACrC,KAAK,SAAS;YACb,IAAI,CAAC,YAAY,CAAC,OAAO;gBAAE,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;YACnG,OAAO,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACtC,KAAK,KAAK;YACT,IAAI,CAAC,YAAY,CAAC,GAAG;gBAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;YAC9E,OAAO,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAClC,KAAK,SAAS;YACb,YAAY,CAAC,MAAM,CAAC,GAAG,YAAY,CAAC,OAAO,IAAI,CAAC,CAAC;YACjD,OAAO,CAAC,CAAC;QACV,KAAK,KAAK;YACT,OAAO,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAClC,KAAK,KAAK;YACT,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAChF,CAAC;AACF,CAAC","sourcesContent":["import type { CliParser } from \"@di-code/builtins\";\nimport { DEFAULT_LOCALE, type Locale, translate } from \"./i18n.ts\";\n\nexport type OutputMode = \"print\" | \"json\" | \"interactive\";\nexport type CompositionProfile = OutputMode;\n\nexport type CliCommand =\n\t| { kind: \"help\" }\n\t| { kind: \"version\" }\n\t| { kind: \"web\"; port: number; workspaces?: readonly string[] }\n\t| { kind: \"observe\"; action: \"trace\" | \"dump-composition\" }\n\t| {\n\t\t\tkind: \"plugin\";\n\t\t\taction: \"install\" | \"list\" | \"get\" | \"enable\" | \"disable\" | \"update\" | \"remove\";\n\t\t\targument?: string;\n\t }\n\t| {\n\t\t\tkind: \"mcp\";\n\t\t\taction: \"add\" | \"list\" | \"get\" | \"remove\";\n\t\t\tscope?: \"local\" | \"project\" | \"user\";\n\t\t\tserverId?: string;\n\t\t\ttransport?: \"stdio\" | \"http\";\n\t\t\tcommand?: string;\n\t\t\targs?: readonly string[];\n\t\t\turl?: string;\n\t }\n\t| {\n\t\t\tkind: \"run\";\n\t\t\tmode: OutputMode;\n\t\t\tprompt: string;\n\t\t\tsessionPath?: string;\n\t\t\tcontinueSession?: true;\n\t\t\timagePaths?: readonly string[];\n\t\t\tnoSkills?: true;\n\t\t\tnoContextFiles?: true;\n\t\t\t/** Selects the composition matching the output mode. */\n\t\t\tprofile?: CompositionProfile;\n\t\t\t/** An explicit composition document applied after user and project layers. */\n\t\t\tcompositionPath?: string;\n\t\t\t/** Excludes the project composition layer without affecting user-managed plugins. */\n\t\t\tnoProjectPlugins?: true;\n\t\t\tskillPaths?: readonly string[];\n\t\t\tprojectTrust?: boolean;\n\t };\n\nexport class CliUsageError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"CliUsageError\";\n\t}\n}\n\nexport function parseCliArgs(args: readonly string[]): CliCommand {\n\tif (args[0] === \"web\") return parseWebArgs(args.slice(1));\n\tif (args.length === 1 && args[0] === \"--trace-plugins\") return { kind: \"observe\", action: \"trace\" };\n\tif (args.length === 1 && args[0] === \"--dump-composition\") return { kind: \"observe\", action: \"dump-composition\" };\n\tif (args[0] === \"plugin\") {\n\t\tconst action = args[1];\n\t\tif (\n\t\t\taction !== \"install\" &&\n\t\t\taction !== \"list\" &&\n\t\t\taction !== \"get\" &&\n\t\t\taction !== \"enable\" &&\n\t\t\taction !== \"disable\" &&\n\t\t\taction !== \"update\" &&\n\t\t\taction !== \"remove\"\n\t\t)\n\t\t\tthrow new CliUsageError(\"Plugin command must be install, list, get, enable, disable, update, or remove.\");\n\t\tconst argument = args[2];\n\t\tif (\n\t\t\targs.length > 3 ||\n\t\t\t(action !== \"list\" && (argument === undefined || argument.trim() === \"\")) ||\n\t\t\t(action === \"list\" && argument !== undefined)\n\t\t)\n\t\t\tthrow new CliUsageError(\"Plugin command has invalid arguments.\");\n\t\treturn { kind: \"plugin\", action, ...(argument ? { argument } : {}) };\n\t}\n\tif (args[0] === \"mcp\") return parseMcpArgs(args.slice(1));\n\tconst staticOption = args.find((argument) => [\"-h\", \"--help\", \"-v\", \"--version\"].includes(argument));\n\tif (staticOption !== undefined) {\n\t\tconst kind = staticOption === \"-h\" || staticOption === \"--help\" ? \"help\" : \"version\";\n\t\tif (args.length !== 1) {\n\t\t\tthrow new CliUsageError(`--${kind} must be used on its own.`);\n\t\t}\n\t\treturn { kind };\n\t}\n\n\tlet mode: OutputMode = \"print\";\n\tlet printAlias = false;\n\tlet sessionPath: string | undefined;\n\tlet continueSession = false;\n\tlet noSkills = false;\n\tlet noContextFiles = false;\n\tlet profile: CompositionProfile | undefined;\n\tlet compositionPath: string | undefined;\n\tlet noProjectPlugins = false;\n\tlet modeWasSelected = false;\n\tlet projectTrust: boolean | undefined;\n\tconst skillPaths: string[] = [];\n\tconst imagePaths: string[] = [];\n\tconst promptParts: string[] = [];\n\n\tfor (let index = 0; index < args.length; index++) {\n\t\tconst argument = args[index];\n\t\tif (argument === \"-p\" || argument === \"--print\") {\n\t\t\tprintAlias = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (argument === \"--interactive\") {\n\t\t\tif (profile !== undefined && profile !== \"interactive\") {\n\t\t\t\tthrow new CliUsageError(`Cannot combine --profile ${profile} with --mode interactive.`);\n\t\t\t}\n\t\t\tmode = \"interactive\";\n\t\t\tmodeWasSelected = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (argument === \"-c\" || argument === \"--continue\") {\n\t\t\tcontinueSession = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (argument === \"--no-skills\") {\n\t\t\tnoSkills = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (argument === \"--no-context-files\") {\n\t\t\tnoContextFiles = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (argument === \"--no-project-plugins\") {\n\t\t\tnoProjectPlugins = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (argument === \"--profile\") {\n\t\t\tconst value = args[index + 1];\n\t\t\tif (value !== \"print\" && value !== \"json\" && value !== \"interactive\") {\n\t\t\t\tthrow new CliUsageError(\"Option --profile expects print, json, or interactive.\");\n\t\t\t}\n\t\t\tif (modeWasSelected && mode !== value) {\n\t\t\t\tthrow new CliUsageError(`Cannot combine --profile ${value} with --mode ${mode}.`);\n\t\t\t}\n\t\t\tprofile = value;\n\t\t\tmode = value;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (argument === \"--composition\") {\n\t\t\tconst value = args[index + 1];\n\t\t\tif (value === undefined || value.trim().length === 0) {\n\t\t\t\tthrow new CliUsageError(\"Option --composition requires a non-empty path.\");\n\t\t\t}\n\t\t\tif (compositionPath !== undefined) throw new CliUsageError(\"Option --composition may only be used once.\");\n\t\t\tcompositionPath = value;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (argument === \"--trust-project\" || argument === \"--untrust-project\") {\n\t\t\tconst nextTrust = argument === \"--trust-project\";\n\t\t\tif (projectTrust !== undefined && projectTrust !== nextTrust) {\n\t\t\t\tthrow new CliUsageError(\"Cannot combine --trust-project with --untrust-project.\");\n\t\t\t}\n\t\t\tprojectTrust = nextTrust;\n\t\t\tcontinue;\n\t\t}\n\t\tif (argument === \"--skill\") {\n\t\t\tconst value = args[index + 1];\n\t\t\tif (value === undefined || value.trim().length === 0) {\n\t\t\t\tthrow new CliUsageError(\"Option --skill requires a non-empty value.\");\n\t\t\t}\n\t\t\tskillPaths.push(value);\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (argument === \"--image\") {\n\t\t\tconst value = args[index + 1];\n\t\t\tif (value === undefined || value.trim().length === 0) {\n\t\t\t\tthrow new CliUsageError(\"Option --image requires a non-empty value.\");\n\t\t\t}\n\t\t\timagePaths.push(value);\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (argument === \"--mode\") {\n\t\t\tconst value = args[index + 1];\n\t\t\tif (value === undefined) {\n\t\t\t\tthrow new CliUsageError(\"Option --mode requires a value.\");\n\t\t\t}\n\t\t\tif (value !== \"print\" && value !== \"json\" && value !== \"interactive\") {\n\t\t\t\tthrow new CliUsageError(`Unsupported mode \"${value}\". Expected print, json, or interactive.`);\n\t\t\t}\n\t\t\tif (profile !== undefined && profile !== value) {\n\t\t\t\tthrow new CliUsageError(`Cannot combine --profile ${profile} with --mode ${value}.`);\n\t\t\t}\n\t\t\tmode = value;\n\t\t\tmodeWasSelected = true;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (argument === \"--session\") {\n\t\t\tconst value = args[index + 1];\n\t\t\tif (value === undefined) {\n\t\t\t\tthrow new CliUsageError(\"Option --session requires a value.\");\n\t\t\t}\n\t\t\tif (value.trim().length === 0) {\n\t\t\t\tthrow new CliUsageError(\"Option --session requires a non-empty value.\");\n\t\t\t}\n\t\t\tsessionPath = value;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (argument?.startsWith(\"-\")) {\n\t\t\tthrow new CliUsageError(`Unknown option \"${argument}\".`);\n\t\t}\n\t\tif (argument !== undefined) {\n\t\t\tpromptParts.push(argument);\n\t\t}\n\t}\n\n\tif (printAlias && mode !== \"print\") {\n\t\tthrow new CliUsageError(`Cannot combine --print with --mode ${mode}.`);\n\t}\n\tif (continueSession && sessionPath !== undefined) {\n\t\tthrow new CliUsageError(\"Cannot combine --continue with --session.\");\n\t}\n\tif (mode === \"interactive\" && imagePaths.length > 0) {\n\t\tthrow new CliUsageError(\"--image is not available in interactive mode.\");\n\t}\n\tif (promptParts.length === 0 && mode !== \"interactive\") {\n\t\tthrow new CliUsageError(\"A prompt is required.\");\n\t}\n\n\treturn {\n\t\tkind: \"run\",\n\t\tmode,\n\t\tprompt: promptParts.join(\" \"),\n\t\t...(sessionPath ? { sessionPath } : {}),\n\t\t...(continueSession ? { continueSession: true as const } : {}),\n\t\t...(noSkills ? { noSkills: true as const } : {}),\n\t\t...(noContextFiles ? { noContextFiles: true as const } : {}),\n\t\t...(profile ? { profile } : {}),\n\t\t...(compositionPath ? { compositionPath } : {}),\n\t\t...(noProjectPlugins ? { noProjectPlugins: true as const } : {}),\n\t\t...(skillPaths.length > 0 ? { skillPaths } : {}),\n\t\t...(imagePaths.length > 0 ? { imagePaths } : {}),\n\t\t...(projectTrust === undefined ? {} : { projectTrust }),\n\t};\n}\n\nfunction parseMcpArgs(args: readonly string[]): Extract<CliCommand, { kind: \"mcp\" }> {\n\tconst action = args[0];\n\tif (action !== \"add\" && action !== \"list\" && action !== \"get\" && action !== \"remove\")\n\t\tthrow new CliUsageError(\"MCP command must be add, list, get, or remove.\");\n\tlet scope: \"local\" | \"project\" | \"user\" | undefined;\n\tlet transport: \"stdio\" | \"http\" | undefined;\n\tconst positional: string[] = [];\n\tlet separator = -1;\n\tfor (let index = 1; index < args.length; index++) {\n\t\tconst argument = args[index];\n\t\tif (argument === \"--\") {\n\t\t\tseparator = index;\n\t\t\tbreak;\n\t\t}\n\t\tif (argument === \"--scope\") {\n\t\t\tconst value = args[++index];\n\t\t\tif (value !== \"local\" && value !== \"project\" && value !== \"user\")\n\t\t\t\tthrow new CliUsageError(\"Option --scope expects local, project, or user.\");\n\t\t\tif (scope !== undefined) throw new CliUsageError(\"Option --scope may only be used once.\");\n\t\t\tscope = value;\n\t\t\tcontinue;\n\t\t}\n\t\tif (argument === \"--transport\") {\n\t\t\tconst value = args[++index];\n\t\t\tif (value !== \"stdio\" && value !== \"http\") throw new CliUsageError(\"Option --transport expects stdio or http.\");\n\t\t\tif (transport !== undefined) throw new CliUsageError(\"Option --transport may only be used once.\");\n\t\t\ttransport = value;\n\t\t\tcontinue;\n\t\t}\n\t\tif (argument.startsWith(\"-\")) throw new CliUsageError(`Unknown MCP option \"${argument}\".`);\n\t\tpositional.push(argument);\n\t}\n\tif (separator >= 0) positional.push(...args.slice(separator + 1));\n\tif (action === \"list\") {\n\t\tif (transport !== undefined || positional.length > 0)\n\t\t\tthrow new CliUsageError(\"MCP list accepts only an optional --scope.\");\n\t\treturn { kind: \"mcp\", action, ...(scope ? { scope } : {}) };\n\t}\n\tif (action === \"get\" || action === \"remove\") {\n\t\tif (transport !== undefined || positional.length !== 1 || positional[0].trim() === \"\")\n\t\t\tthrow new CliUsageError(`MCP ${action} requires exactly one server id.`);\n\t\treturn { kind: \"mcp\", action, serverId: positional[0], ...(scope ? { scope } : {}) };\n\t}\n\tconst selectedTransport = transport ?? (separator >= 0 ? \"stdio\" : undefined);\n\tif (selectedTransport === undefined)\n\t\tthrow new CliUsageError(\n\t\t\t\"MCP add requires <server-id> -- <command> [args...] or --transport http <server-id> <url>.\",\n\t\t);\n\tif (selectedTransport === \"stdio\") {\n\t\tif (positional.length < 2 || separator < 0)\n\t\t\tthrow new CliUsageError(\"MCP stdio add requires <server-id> -- <command> [args...].\");\n\t\treturn {\n\t\t\tkind: \"mcp\",\n\t\t\taction,\n\t\t\ttransport: \"stdio\",\n\t\t\tserverId: positional[0],\n\t\t\tcommand: positional[1],\n\t\t\t...(positional.length > 2 ? { args: positional.slice(2) } : {}),\n\t\t\t...(scope ? { scope } : {}),\n\t\t};\n\t}\n\tif (separator >= 0 || positional.length !== 2) throw new CliUsageError(\"MCP HTTP add requires <server-id> <url>.\");\n\treturn { kind: \"mcp\", action, transport, serverId: positional[0], url: positional[1], ...(scope ? { scope } : {}) };\n}\n\nfunction parseWebArgs(args: readonly string[]): Extract<CliCommand, { kind: \"web\" }> {\n\tlet port = 0;\n\tconst workspaces: string[] = [];\n\tfor (let index = 0; index < args.length; index++) {\n\t\tconst arg = args[index];\n\t\tif (arg === \"--port\") {\n\t\t\tconst value = args[++index];\n\t\t\tif (value === undefined) throw new CliUsageError(\"Option --port requires a value.\");\n\t\t\tport = Number(value);\n\t\t} else if (arg === \"--workspace\") {\n\t\t\tconst value = args[++index];\n\t\t\tif (!value?.trim()) throw new CliUsageError(\"Option --workspace requires a path.\");\n\t\t\tworkspaces.push(value);\n\t\t} else throw new CliUsageError(\"Web command accepts --port <0-65535> and --workspace <path>.\");\n\t}\n\tif (!Number.isSafeInteger(port) || port < 0 || port > 65_535)\n\t\tthrow new CliUsageError(\"Option --port expects a TCP port from 0 to 65535.\");\n\treturn { kind: \"web\", port, ...(workspaces.length ? { workspaces } : {}) };\n}\n\nexport function helpText(locale: Locale): string {\n\tconst t = (key: string) => translate(locale, key);\n\treturn `${t(\"usage\")}\n\n${t(\"options\")}\n -p, --print ${t(\"print\")}\n --mode <mode> ${t(\"mode\")}\n --interactive ${t(\"interactive\")}\n --continue, -c ${t(\"continueSession\")}\n --session <path> ${t(\"session\")}\n --image <path> ${t(\"image\")}\n --skill <path> ${t(\"skill\")}\n --no-skills ${t(\"noSkills\")}\n --no-context-files ${t(\"noContextFiles\")}\n --profile <profile> Select print, json, or interactive composition\n --composition <path> Apply a JSON or YAML composition after project configuration\n --no-project-plugins Skip .di-code/composition.yml for this run\n --trust-project ${t(\"trustProject\")}\n --untrust-project ${t(\"untrustProject\")}\n plugin <action> ${t(\"plugin\")}\n --trace-plugins Emit Loader phase, owner Fiber, capability, and failure diagnostics\n --dump-composition Emit the resolved composition without configuration values\n mcp add|list|get|remove ${t(\"mcp\")}\n web [--port <port>] Start the local web application (default: an available port)\n -h, --help ${t(\"help\")}\n -v, --version ${t(\"version\")}\n`;\n}\n\n/** Product-owned parser service consumed by the CLI composition entry. */\nexport function createCliParser(): CliParser<CliCommand> {\n\treturn {\n\t\tparse: (args) => parseCliArgs(args),\n\t\thelp: (locale) => helpText(locale === \"zh-CN\" ? \"zh-CN\" : \"en\"),\n\t};\n}\n\nexport interface CliDependencies {\n\tstdout(text: string): void;\n\tstderr(text: string): void;\n\trun(command: Extract<CliCommand, { kind: \"run\" }>): Promise<number>;\n\tplugin?(command: Extract<CliCommand, { kind: \"plugin\" }>): Promise<number>;\n\tobserve?(command: Extract<CliCommand, { kind: \"observe\" }>): Promise<number>;\n\tmcp?(command: Extract<CliCommand, { kind: \"mcp\" }>): Promise<number>;\n\treadonly version: string;\n\treadonly locale?: Locale;\n\treadonly parser?: CliParser<CliCommand>;\n}\n\nexport async function runCli(args: readonly string[], dependencies: CliDependencies): Promise<number> {\n\tlet command: CliCommand;\n\ttry {\n\t\tcommand = dependencies.parser?.parse(args) ?? parseCliArgs(args);\n\t} catch (cause) {\n\t\tif (cause instanceof CliUsageError) {\n\t\t\tdependencies.stderr(`${cause.message}\\n`);\n\t\t\treturn 1;\n\t\t}\n\t\tthrow cause;\n\t}\n\n\tswitch (command.kind) {\n\t\tcase \"help\":\n\t\t\tdependencies.stdout(\n\t\t\t\tdependencies.parser?.help(dependencies.locale ?? DEFAULT_LOCALE) ??\n\t\t\t\t\thelpText(dependencies.locale ?? DEFAULT_LOCALE),\n\t\t\t);\n\t\t\treturn 0;\n\t\tcase \"plugin\":\n\t\t\tif (!dependencies.plugin) throw new Error(\"Plugin command handler is unavailable.\");\n\t\t\treturn dependencies.plugin(command);\n\t\tcase \"observe\":\n\t\t\tif (!dependencies.observe) throw new Error(\"Plugin observability command handler is unavailable.\");\n\t\t\treturn dependencies.observe(command);\n\t\tcase \"mcp\":\n\t\t\tif (!dependencies.mcp) throw new Error(\"MCP command handler is unavailable.\");\n\t\t\treturn dependencies.mcp(command);\n\t\tcase \"version\":\n\t\t\tdependencies.stdout(`${dependencies.version}\\n`);\n\t\t\treturn 0;\n\t\tcase \"run\":\n\t\t\treturn dependencies.run(command);\n\t\tcase \"web\":\n\t\t\tthrow new Error(\"Web command must be handled by the executable entry point.\");\n\t}\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type CompositionEntry, createCompositionLoader, type PluginModule } from "@di-code/plugin-loader";
|
|
2
|
+
import { type PluginDefinition } from "@di-code/plugin-runtime";
|
|
3
|
+
export interface CompositionLoaderService {
|
|
4
|
+
readonly create: (entries: readonly CompositionEntry[], importModule: (name: string) => Promise<PluginModule>) => ReturnType<typeof createCompositionLoader>;
|
|
5
|
+
}
|
|
6
|
+
export declare const apiVersion: 1;
|
|
7
|
+
export declare const name = "composition-loader";
|
|
8
|
+
export declare const version = "0.1.7";
|
|
9
|
+
export declare const compositionLoaderKey: import("@di-code/plugin-runtime").ServiceKey<CompositionLoaderService>;
|
|
10
|
+
export declare const apply: PluginDefinition["apply"];
|
|
11
|
+
//# sourceMappingURL=composition-loader-entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composition-loader-entry.d.ts","sourceRoot":"","sources":["../src/composition-loader-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,uBAAuB,EAAE,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3G,OAAO,EAAkC,KAAK,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhG,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,MAAM,EAAE,CAChB,OAAO,EAAE,SAAS,gBAAgB,EAAE,EACpC,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,YAAY,CAAC,KACjD,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;CAChD;AAED,eAAO,MAAM,UAAU,EAAG,CAAU,CAAC;AACrC,eAAO,MAAM,IAAI,uBAAuB,CAAC;AACzC,eAAO,MAAM,OAAO,UAAU,CAAC;AAC/B,eAAO,MAAM,oBAAoB,wEAAmE,CAAC;AACrG,eAAO,MAAM,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAI3C,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createCompositionLoader } from "@di-code/plugin-loader";
|
|
2
|
+
import { createServiceKey } from "@di-code/plugin-runtime";
|
|
3
|
+
export const apiVersion = 1;
|
|
4
|
+
export const name = "composition-loader";
|
|
5
|
+
export const version = "0.1.7";
|
|
6
|
+
export const compositionLoaderKey = createServiceKey("composition-loader");
|
|
7
|
+
export const apply = (context) => {
|
|
8
|
+
context.set(compositionLoaderKey, {
|
|
9
|
+
create: (entries, importModule) => createCompositionLoader({ context, entries, importModule }),
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=composition-loader-entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composition-loader-entry.js","sourceRoot":"","sources":["../src/composition-loader-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,uBAAuB,EAAqB,MAAM,wBAAwB,CAAC;AAC3G,OAAO,EAAgB,gBAAgB,EAAyB,MAAM,yBAAyB,CAAC;AAShG,MAAM,CAAC,MAAM,UAAU,GAAG,CAAU,CAAC;AACrC,MAAM,CAAC,MAAM,IAAI,GAAG,oBAAoB,CAAC;AACzC,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAC/B,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAgB,CAA2B,oBAAoB,CAAC,CAAC;AACrG,MAAM,CAAC,MAAM,KAAK,GAA8B,CAAC,OAAgB,EAAE,EAAE;IACpE,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE;QACjC,MAAM,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,CAAC,uBAAuB,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;KAC9F,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { type CompositionEntry, createCompositionLoader, type PluginModule } from \"@di-code/plugin-loader\";\nimport { type Context, createServiceKey, type PluginDefinition } from \"@di-code/plugin-runtime\";\n\nexport interface CompositionLoaderService {\n\treadonly create: (\n\t\tentries: readonly CompositionEntry[],\n\t\timportModule: (name: string) => Promise<PluginModule>,\n\t) => ReturnType<typeof createCompositionLoader>;\n}\n\nexport const apiVersion = 1 as const;\nexport const name = \"composition-loader\";\nexport const version = \"0.1.7\";\nexport const compositionLoaderKey = createServiceKey<CompositionLoaderService>(\"composition-loader\");\nexport const apply: PluginDefinition[\"apply\"] = (context: Context) => {\n\tcontext.set(compositionLoaderKey, {\n\t\tcreate: (entries, importModule) => createCompositionLoader({ context, entries, importModule }),\n\t});\n};\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type CompositionEntry, type PluginModule } from "@di-code/plugin-loader";
|
|
2
|
+
export type DefaultCompositionName = "base" | "interactive" | "print" | "json" | "rpc" | "webui";
|
|
3
|
+
export interface CompositionResolutionOptions {
|
|
4
|
+
/** Work root used for project composition discovery and the workspace capability. */
|
|
5
|
+
readonly cwd?: string;
|
|
6
|
+
/** User data root containing the optional user composition document. */
|
|
7
|
+
readonly agentDir?: string;
|
|
8
|
+
/** Explicit JSON or YAML composition document applied last. */
|
|
9
|
+
readonly compositionPath?: string;
|
|
10
|
+
/** Excludes the project composition document for this invocation. */
|
|
11
|
+
readonly includeProjectComposition?: boolean;
|
|
12
|
+
readonly observability?: boolean;
|
|
13
|
+
readonly allowedRoot?: string;
|
|
14
|
+
}
|
|
15
|
+
/** Resolves the package-owned base plus exactly one mode document. */
|
|
16
|
+
export declare function resolveDefaultComposition(name: DefaultCompositionName, options?: {
|
|
17
|
+
readonly observability?: boolean;
|
|
18
|
+
readonly allowedRoot?: string;
|
|
19
|
+
}): Promise<readonly CompositionEntry[]>;
|
|
20
|
+
/**
|
|
21
|
+
* Resolves built-in, user, project, and explicit composition layers in their fixed precedence order.
|
|
22
|
+
* Project entries are marked local so the Loader retains trust checks for entries added through project configuration.
|
|
23
|
+
*/
|
|
24
|
+
export declare function resolveCompositionEntries(name: DefaultCompositionName, options?: CompositionResolutionOptions): Promise<readonly CompositionEntry[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Resolves only enabled managed plugins before the Loader receives its entry list.
|
|
27
|
+
* Disabled manifests are not resolved or dynamically imported.
|
|
28
|
+
*/
|
|
29
|
+
export declare function resolveManagedCompositionEntries(agentDir?: string): Promise<readonly CompositionEntry[]>;
|
|
30
|
+
/** Imports own composition entries from source in development; package exports handle published use. */
|
|
31
|
+
export declare function importCompositionModule(name: string): Promise<PluginModule>;
|
|
32
|
+
//# sourceMappingURL=compositions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compositions.d.ts","sourceRoot":"","sources":["../src/compositions.ts"],"names":[],"mappings":"AAGA,OAAO,EAEN,KAAK,gBAAgB,EAIrB,KAAK,YAAY,EAGjB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,aAAa,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,CAAC;AAEjG,MAAM,WAAW,4BAA4B;IAC5C,qFAAqF;IACrF,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,+DAA+D;IAC/D,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,qEAAqE;IACrE,QAAQ,CAAC,yBAAyB,CAAC,EAAE,OAAO,CAAC;IAC7C,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC9B;AAkBD,sEAAsE;AACtE,wBAAsB,yBAAyB,CAC9C,IAAI,EAAE,sBAAsB,EAC5B,OAAO,GAAE;IAAE,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAO,GAC/E,OAAO,CAAC,SAAS,gBAAgB,EAAE,CAAC,CAetC;AAyDD;;;GAGG;AACH,wBAAsB,yBAAyB,CAC9C,IAAI,EAAE,sBAAsB,EAC5B,OAAO,GAAE,4BAAiC,GACxC,OAAO,CAAC,SAAS,gBAAgB,EAAE,CAAC,CA2BtC;AAED;;;GAGG;AACH,wBAAsB,gCAAgC,CACrD,QAAQ,SAA8B,GACpC,OAAO,CAAC,SAAS,gBAAgB,EAAE,CAAC,CAatC;AAED,wGAAwG;AACxG,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAuC3E"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
import { homedir } from "node:os";
|
|
10
|
+
import { join, resolve } from "node:path";
|
|
11
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
12
|
+
import { mergeCompositionLayers, PluginInstallManager, readCompositionFile, resolvePackagePluginExport, } from "@di-code/plugin-loader";
|
|
13
|
+
const observabilityEntries = [
|
|
14
|
+
{ id: "plugin-profiler", name: "@di-code/builtins/plugin-profiler", dependsOn: ["runtime"] },
|
|
15
|
+
{ id: "plugin-invariants", name: "@di-code/builtins/plugin-invariants", dependsOn: ["runtime"] },
|
|
16
|
+
{ id: "plugin-test-runtime", name: "@di-code/builtins/plugin-test-runtime", dependsOn: ["runtime"] },
|
|
17
|
+
{ id: "plugin-trace", name: "@di-code/coding-agent/plugin-trace", dependsOn: ["plugin-inventory"] },
|
|
18
|
+
{
|
|
19
|
+
id: "plugin-dump-composition",
|
|
20
|
+
name: "@di-code/coding-agent/plugin-dump-composition",
|
|
21
|
+
dependsOn: ["plugin-inventory"],
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
function builtinCompositionPath(name) {
|
|
25
|
+
return fileURLToPath(new URL(`../compositions/${name}.yml`, import.meta.url));
|
|
26
|
+
}
|
|
27
|
+
/** Resolves the package-owned base plus exactly one mode document. */
|
|
28
|
+
export async function resolveDefaultComposition(name, options = {}) {
|
|
29
|
+
const base = await readRequiredComposition(builtinCompositionPath("base"));
|
|
30
|
+
const mode = name === "base" ? { entries: [] } : await readRequiredComposition(builtinCompositionPath(name));
|
|
31
|
+
return Object.freeze(withWorkspaceRoot(mergeCompositionLayers([
|
|
32
|
+
{ name: "base", document: base },
|
|
33
|
+
{
|
|
34
|
+
name: "mode",
|
|
35
|
+
document: { entries: [...(mode.entries ?? []), ...(options.observability ? observabilityEntries : [])] },
|
|
36
|
+
},
|
|
37
|
+
]), options.allowedRoot));
|
|
38
|
+
}
|
|
39
|
+
function isJsonObject(value) {
|
|
40
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
41
|
+
}
|
|
42
|
+
function withWorkspaceRoot(entries, allowedRoot) {
|
|
43
|
+
if (allowedRoot === undefined)
|
|
44
|
+
return entries;
|
|
45
|
+
return entries.map((entry) => entry.id === "workspace"
|
|
46
|
+
? { ...entry, config: { ...(isJsonObject(entry.config) ? entry.config : {}), allowedRoot } }
|
|
47
|
+
: entry);
|
|
48
|
+
}
|
|
49
|
+
function markProjectEntries(document) {
|
|
50
|
+
const mark = (entry) => ({ ...entry, projectLocal: true });
|
|
51
|
+
return {
|
|
52
|
+
...(document.entries ? { entries: document.entries.map(mark) } : {}),
|
|
53
|
+
...(document.patches
|
|
54
|
+
? {
|
|
55
|
+
patches: document.patches.map((patch) => "entry" in patch && patch.entry !== undefined ? { ...patch, entry: mark(patch.entry) } : patch),
|
|
56
|
+
}
|
|
57
|
+
: {}),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function isMissingFile(cause) {
|
|
61
|
+
return typeof cause === "object" && cause !== null && "code" in cause && cause.code === "ENOENT";
|
|
62
|
+
}
|
|
63
|
+
async function readOptionalComposition(filePath) {
|
|
64
|
+
try {
|
|
65
|
+
return await readCompositionFile(filePath);
|
|
66
|
+
}
|
|
67
|
+
catch (cause) {
|
|
68
|
+
if (isMissingFile(cause))
|
|
69
|
+
return undefined;
|
|
70
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
71
|
+
throw new Error(`Failed to read composition ${filePath}: ${message}`, { cause });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async function readRequiredComposition(filePath) {
|
|
75
|
+
try {
|
|
76
|
+
return await readCompositionFile(filePath);
|
|
77
|
+
}
|
|
78
|
+
catch (cause) {
|
|
79
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
80
|
+
throw new Error(`Failed to read composition ${filePath}: ${message}`, { cause });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Resolves built-in, user, project, and explicit composition layers in their fixed precedence order.
|
|
85
|
+
* Project entries are marked local so the Loader retains trust checks for entries added through project configuration.
|
|
86
|
+
*/
|
|
87
|
+
export async function resolveCompositionEntries(name, options = {}) {
|
|
88
|
+
const cwd = resolve(options.cwd ?? process.cwd());
|
|
89
|
+
const agentDir = resolve(options.agentDir ?? join(homedir(), ".di-code"));
|
|
90
|
+
const [base, mode] = await Promise.all([
|
|
91
|
+
readRequiredComposition(builtinCompositionPath("base")),
|
|
92
|
+
readRequiredComposition(builtinCompositionPath(name)),
|
|
93
|
+
]);
|
|
94
|
+
const layers = [
|
|
95
|
+
{ name: "base", document: base },
|
|
96
|
+
{
|
|
97
|
+
name: "mode",
|
|
98
|
+
document: {
|
|
99
|
+
entries: [...(mode.entries ?? []), ...(options.observability ? observabilityEntries : [])],
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
];
|
|
103
|
+
const userComposition = await readOptionalComposition(join(agentDir, "composition.yml"));
|
|
104
|
+
if (userComposition !== undefined)
|
|
105
|
+
layers.push({ name: "user", document: userComposition });
|
|
106
|
+
if (options.includeProjectComposition !== false) {
|
|
107
|
+
const projectComposition = await readOptionalComposition(join(cwd, ".di-code", "composition.yml"));
|
|
108
|
+
if (projectComposition !== undefined)
|
|
109
|
+
layers.push({ name: "project", document: markProjectEntries(projectComposition) });
|
|
110
|
+
}
|
|
111
|
+
if (options.compositionPath !== undefined) {
|
|
112
|
+
layers.push({ name: "explicit", document: await readRequiredComposition(resolve(cwd, options.compositionPath)) });
|
|
113
|
+
}
|
|
114
|
+
return Object.freeze(withWorkspaceRoot(mergeCompositionLayers(layers), options.allowedRoot));
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Resolves only enabled managed plugins before the Loader receives its entry list.
|
|
118
|
+
* Disabled manifests are not resolved or dynamically imported.
|
|
119
|
+
*/
|
|
120
|
+
export async function resolveManagedCompositionEntries(agentDir = join(homedir(), ".di-code")) {
|
|
121
|
+
const manager = new PluginInstallManager({ managedRoot: join(resolve(agentDir), "plugins", "installed") });
|
|
122
|
+
const plugins = await manager.list();
|
|
123
|
+
return await Promise.all(plugins
|
|
124
|
+
.filter((plugin) => plugin.enabled)
|
|
125
|
+
.map(async (plugin) => ({
|
|
126
|
+
id: `managed.${plugin.id}`,
|
|
127
|
+
name: pathToFileURL(await resolvePackagePluginExport(plugin.installedPath, plugin.manifest.entry)).href,
|
|
128
|
+
dependsOn: ["Bootstrap"],
|
|
129
|
+
required: false,
|
|
130
|
+
})));
|
|
131
|
+
}
|
|
132
|
+
/** Imports own composition entries from source in development; package exports handle published use. */
|
|
133
|
+
export function importCompositionModule(name) {
|
|
134
|
+
switch (name) {
|
|
135
|
+
case "@di-code/coding-agent/plugin-manager":
|
|
136
|
+
return import("./plugin-manager.js");
|
|
137
|
+
case "@di-code/coding-agent/plugin-inventory":
|
|
138
|
+
return import("./plugin-inventory.js");
|
|
139
|
+
case "@di-code/coding-agent/plugin-trace":
|
|
140
|
+
return import("./plugin-trace.js");
|
|
141
|
+
case "@di-code/coding-agent/plugin-dump-composition":
|
|
142
|
+
return import("./plugin-dump-composition.js");
|
|
143
|
+
case "@di-code/coding-agent/mcp-config-entry":
|
|
144
|
+
return import("./mcp-config-entry.js");
|
|
145
|
+
case "@di-code/coding-agent/mcp-client-entry":
|
|
146
|
+
return import("./mcp-client-entry.js");
|
|
147
|
+
case "@di-code/coding-agent/mcp-transport-entry":
|
|
148
|
+
return import("./mcp-transport-entry.js");
|
|
149
|
+
case "@di-code/coding-agent/mcp-tools-entry":
|
|
150
|
+
return import("./mcp-tools-entry.js");
|
|
151
|
+
case "@di-code/coding-agent/session-factory-entry":
|
|
152
|
+
return import("./session-factory-entry.js");
|
|
153
|
+
case "@di-code/coding-agent/session-store-jsonl-entry":
|
|
154
|
+
return import("./session-store-jsonl-entry.js");
|
|
155
|
+
case "@di-code/coding-agent/rpc-server-entry":
|
|
156
|
+
return import("./rpc-server-entry.js");
|
|
157
|
+
case "@di-code/coding-agent/interactive-resources-entry":
|
|
158
|
+
return import("./interactive-resources-entry.js");
|
|
159
|
+
case "@di-code/coding-agent/interactive-host-entry":
|
|
160
|
+
return import("./interactive-host-entry.js");
|
|
161
|
+
case "@di-code/coding-agent/runtime-core-entry":
|
|
162
|
+
return import("./runtime-core-entry.js");
|
|
163
|
+
case "@di-code/coding-agent/composition-loader-entry":
|
|
164
|
+
return import("./composition-loader-entry.js");
|
|
165
|
+
case "@di-code/coding-agent/project-trust-entry":
|
|
166
|
+
return import("./project-trust-entry.js");
|
|
167
|
+
case "@di-code/coding-agent/rpc-client-sdk-entry":
|
|
168
|
+
return import("./rpc-client-sdk-entry.js");
|
|
169
|
+
default:
|
|
170
|
+
return import(__rewriteRelativeImportExtension(name));
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=compositions.js.map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BAA4B,CAA0B,CAAC;QACtE,KAAK,iDAAiD;YACrD,OAAO,MAAM,CAAC,gCAAgC,CAA0B,CAAC;QAC1E,KAAK,wCAAwC;YAC5C,OAAO,MAAM,CAAC,uBAAuB,CAA0B,CAAC;QACjE,KAAK,mDAAmD;YACvD,OAAO,MAAM,CAAC,kCAAkC,CAA0B,CAAC;QAC5E,KAAK,8CAA8C;YAClD,OAAO,MAAM,CAAC,6BAA6B,CAA0B,CAAC;QACvE,KAAK,0CAA0C;YAC9C,OAAO,MAAM,CAAC,yBAAyB,CAA0B,CAAC;QACnE,KAAK,gDAAgD;YACpD,OAAO,MAAM,CAAC,+BAA+B,CAA0B,CAAC;QACzE,KAAK,2CAA2C;YAC/C,OAAO,MAAM,CAAC,0BAA0B,CAA0B,CAAC;QACpE,KAAK,4CAA4C;YAChD,OAAO,MAAM,CAAC,2BAA2B,CAA0B,CAAC;QACrE;YACC,OAAO,MAAM,kCAAC,IAAI,EAA0B,CAAC;IAC/C,CAAC;AACF,CAAC","sourcesContent":["import { homedir } from \"node:os\";\nimport { join, resolve } from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport {\n\ttype CompositionDocument,\n\ttype CompositionEntry,\n\ttype CompositionLayer,\n\tmergeCompositionLayers,\n\tPluginInstallManager,\n\ttype PluginModule,\n\treadCompositionFile,\n\tresolvePackagePluginExport,\n} from \"@di-code/plugin-loader\";\n\nexport type DefaultCompositionName = \"base\" | \"interactive\" | \"print\" | \"json\" | \"rpc\" | \"webui\";\n\nexport interface CompositionResolutionOptions {\n\t/** Work root used for project composition discovery and the workspace capability. */\n\treadonly cwd?: string;\n\t/** User data root containing the optional user composition document. */\n\treadonly agentDir?: string;\n\t/** Explicit JSON or YAML composition document applied last. */\n\treadonly compositionPath?: string;\n\t/** Excludes the project composition document for this invocation. */\n\treadonly includeProjectComposition?: boolean;\n\treadonly observability?: boolean;\n\treadonly allowedRoot?: string;\n}\n\nconst observabilityEntries = [\n\t{ id: \"plugin-profiler\", name: \"@di-code/builtins/plugin-profiler\", dependsOn: [\"runtime\"] },\n\t{ id: \"plugin-invariants\", name: \"@di-code/builtins/plugin-invariants\", dependsOn: [\"runtime\"] },\n\t{ id: \"plugin-test-runtime\", name: \"@di-code/builtins/plugin-test-runtime\", dependsOn: [\"runtime\"] },\n\t{ id: \"plugin-trace\", name: \"@di-code/coding-agent/plugin-trace\", dependsOn: [\"plugin-inventory\"] },\n\t{\n\t\tid: \"plugin-dump-composition\",\n\t\tname: \"@di-code/coding-agent/plugin-dump-composition\",\n\t\tdependsOn: [\"plugin-inventory\"],\n\t},\n] as const satisfies readonly CompositionEntry[];\n\nfunction builtinCompositionPath(name: DefaultCompositionName): string {\n\treturn fileURLToPath(new URL(`../compositions/${name}.yml`, import.meta.url));\n}\n\n/** Resolves the package-owned base plus exactly one mode document. */\nexport async function resolveDefaultComposition(\n\tname: DefaultCompositionName,\n\toptions: { readonly observability?: boolean; readonly allowedRoot?: string } = {},\n): Promise<readonly CompositionEntry[]> {\n\tconst base = await readRequiredComposition(builtinCompositionPath(\"base\"));\n\tconst mode = name === \"base\" ? { entries: [] } : await readRequiredComposition(builtinCompositionPath(name));\n\treturn Object.freeze(\n\t\twithWorkspaceRoot(\n\t\t\tmergeCompositionLayers([\n\t\t\t\t{ name: \"base\", document: base },\n\t\t\t\t{\n\t\t\t\t\tname: \"mode\",\n\t\t\t\t\tdocument: { entries: [...(mode.entries ?? []), ...(options.observability ? observabilityEntries : [])] },\n\t\t\t\t},\n\t\t\t]),\n\t\t\toptions.allowedRoot,\n\t\t),\n\t);\n}\n\nfunction isJsonObject(\n\tvalue: CompositionEntry[\"config\"],\n): value is Readonly<Record<string, import(\"@di-code/plugin-loader\").JsonValue>> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction withWorkspaceRoot(\n\tentries: readonly CompositionEntry[],\n\tallowedRoot: string | undefined,\n): readonly CompositionEntry[] {\n\tif (allowedRoot === undefined) return entries;\n\treturn entries.map((entry) =>\n\t\tentry.id === \"workspace\"\n\t\t\t? { ...entry, config: { ...(isJsonObject(entry.config) ? entry.config : {}), allowedRoot } }\n\t\t\t: entry,\n\t);\n}\n\nfunction markProjectEntries(document: CompositionDocument): CompositionDocument {\n\tconst mark = (entry: CompositionEntry): CompositionEntry => ({ ...entry, projectLocal: true });\n\treturn {\n\t\t...(document.entries ? { entries: document.entries.map(mark) } : {}),\n\t\t...(document.patches\n\t\t\t? {\n\t\t\t\t\tpatches: document.patches.map((patch) =>\n\t\t\t\t\t\t\"entry\" in patch && patch.entry !== undefined ? { ...patch, entry: mark(patch.entry) } : patch,\n\t\t\t\t\t),\n\t\t\t\t}\n\t\t\t: {}),\n\t};\n}\n\nfunction isMissingFile(cause: unknown): boolean {\n\treturn typeof cause === \"object\" && cause !== null && \"code\" in cause && cause.code === \"ENOENT\";\n}\n\nasync function readOptionalComposition(filePath: string): Promise<CompositionDocument | undefined> {\n\ttry {\n\t\treturn await readCompositionFile(filePath);\n\t} catch (cause) {\n\t\tif (isMissingFile(cause)) return undefined;\n\t\tconst message = cause instanceof Error ? cause.message : String(cause);\n\t\tthrow new Error(`Failed to read composition ${filePath}: ${message}`, { cause });\n\t}\n}\n\nasync function readRequiredComposition(filePath: string): Promise<CompositionDocument> {\n\ttry {\n\t\treturn await readCompositionFile(filePath);\n\t} catch (cause) {\n\t\tconst message = cause instanceof Error ? cause.message : String(cause);\n\t\tthrow new Error(`Failed to read composition ${filePath}: ${message}`, { cause });\n\t}\n}\n\n/**\n * Resolves built-in, user, project, and explicit composition layers in their fixed precedence order.\n * Project entries are marked local so the Loader retains trust checks for entries added through project configuration.\n */\nexport async function resolveCompositionEntries(\n\tname: DefaultCompositionName,\n\toptions: CompositionResolutionOptions = {},\n): Promise<readonly CompositionEntry[]> {\n\tconst cwd = resolve(options.cwd ?? process.cwd());\n\tconst agentDir = resolve(options.agentDir ?? join(homedir(), \".di-code\"));\n\tconst [base, mode] = await Promise.all([\n\t\treadRequiredComposition(builtinCompositionPath(\"base\")),\n\t\treadRequiredComposition(builtinCompositionPath(name)),\n\t]);\n\tconst layers: CompositionLayer[] = [\n\t\t{ name: \"base\", document: base },\n\t\t{\n\t\t\tname: \"mode\",\n\t\t\tdocument: {\n\t\t\t\tentries: [...(mode.entries ?? []), ...(options.observability ? observabilityEntries : [])],\n\t\t\t},\n\t\t},\n\t];\n\tconst userComposition = await readOptionalComposition(join(agentDir, \"composition.yml\"));\n\tif (userComposition !== undefined) layers.push({ name: \"user\", document: userComposition });\n\tif (options.includeProjectComposition !== false) {\n\t\tconst projectComposition = await readOptionalComposition(join(cwd, \".di-code\", \"composition.yml\"));\n\t\tif (projectComposition !== undefined)\n\t\t\tlayers.push({ name: \"project\", document: markProjectEntries(projectComposition) });\n\t}\n\tif (options.compositionPath !== undefined) {\n\t\tlayers.push({ name: \"explicit\", document: await readRequiredComposition(resolve(cwd, options.compositionPath)) });\n\t}\n\treturn Object.freeze(withWorkspaceRoot(mergeCompositionLayers(layers), options.allowedRoot));\n}\n\n/**\n * Resolves only enabled managed plugins before the Loader receives its entry list.\n * Disabled manifests are not resolved or dynamically imported.\n */\nexport async function resolveManagedCompositionEntries(\n\tagentDir = join(homedir(), \".di-code\"),\n): Promise<readonly CompositionEntry[]> {\n\tconst manager = new PluginInstallManager({ managedRoot: join(resolve(agentDir), \"plugins\", \"installed\") });\n\tconst plugins = await manager.list();\n\treturn await Promise.all(\n\t\tplugins\n\t\t\t.filter((plugin) => plugin.enabled)\n\t\t\t.map(async (plugin) => ({\n\t\t\t\tid: `managed.${plugin.id}`,\n\t\t\t\tname: pathToFileURL(await resolvePackagePluginExport(plugin.installedPath, plugin.manifest.entry)).href,\n\t\t\t\tdependsOn: [\"Bootstrap\"],\n\t\t\t\trequired: false,\n\t\t\t})),\n\t);\n}\n\n/** Imports own composition entries from source in development; package exports handle published use. */\nexport function importCompositionModule(name: string): Promise<PluginModule> {\n\tswitch (name) {\n\t\tcase \"@di-code/coding-agent/plugin-manager\":\n\t\t\treturn import(\"./plugin-manager.ts\") as Promise<PluginModule>;\n\t\tcase \"@di-code/coding-agent/plugin-inventory\":\n\t\t\treturn import(\"./plugin-inventory.ts\") as Promise<PluginModule>;\n\t\tcase \"@di-code/coding-agent/plugin-trace\":\n\t\t\treturn import(\"./plugin-trace.ts\") as Promise<PluginModule>;\n\t\tcase \"@di-code/coding-agent/plugin-dump-composition\":\n\t\t\treturn import(\"./plugin-dump-composition.ts\") as Promise<PluginModule>;\n\t\tcase \"@di-code/coding-agent/mcp-config-entry\":\n\t\t\treturn import(\"./mcp-config-entry.ts\") as Promise<PluginModule>;\n\t\tcase \"@di-code/coding-agent/mcp-client-entry\":\n\t\t\treturn import(\"./mcp-client-entry.ts\") as Promise<PluginModule>;\n\t\tcase \"@di-code/coding-agent/mcp-transport-entry\":\n\t\t\treturn import(\"./mcp-transport-entry.ts\") as Promise<PluginModule>;\n\t\tcase \"@di-code/coding-agent/mcp-tools-entry\":\n\t\t\treturn import(\"./mcp-tools-entry.ts\") as Promise<PluginModule>;\n\t\tcase \"@di-code/coding-agent/session-factory-entry\":\n\t\t\treturn import(\"./session-factory-entry.ts\") as Promise<PluginModule>;\n\t\tcase \"@di-code/coding-agent/session-store-jsonl-entry\":\n\t\t\treturn import(\"./session-store-jsonl-entry.ts\") as Promise<PluginModule>;\n\t\tcase \"@di-code/coding-agent/rpc-server-entry\":\n\t\t\treturn import(\"./rpc-server-entry.ts\") as Promise<PluginModule>;\n\t\tcase \"@di-code/coding-agent/interactive-resources-entry\":\n\t\t\treturn import(\"./interactive-resources-entry.ts\") as Promise<PluginModule>;\n\t\tcase \"@di-code/coding-agent/interactive-host-entry\":\n\t\t\treturn import(\"./interactive-host-entry.ts\") as Promise<PluginModule>;\n\t\tcase \"@di-code/coding-agent/runtime-core-entry\":\n\t\t\treturn import(\"./runtime-core-entry.ts\") as Promise<PluginModule>;\n\t\tcase \"@di-code/coding-agent/composition-loader-entry\":\n\t\t\treturn import(\"./composition-loader-entry.ts\") as Promise<PluginModule>;\n\t\tcase \"@di-code/coding-agent/project-trust-entry\":\n\t\t\treturn import(\"./project-trust-entry.ts\") as Promise<PluginModule>;\n\t\tcase \"@di-code/coding-agent/rpc-client-sdk-entry\":\n\t\t\treturn import(\"./rpc-client-sdk-entry.ts\") as Promise<PluginModule>;\n\t\tdefault:\n\t\t\treturn import(name) as Promise<PluginModule>;\n\t}\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Message } from "@di-code/ai";
|
|
1
|
+
import type { JsonValue, Message } from "@di-code/ai";
|
|
2
2
|
import { type BuiltSessionContext } from "../context-builder.ts";
|
|
3
3
|
import { type SessionAppendOptions } from "./session-storage.ts";
|
|
4
|
-
import { type SessionDiagnostic, type SessionEntry, type SessionHeader, type SessionMessageEntry, type SessionSummaryEntry, type SessionTreeNode } from "./types.ts";
|
|
4
|
+
import { type SessionDiagnostic, type SessionEntry, type SessionHeader, type SessionMessageEntry, type SessionPluginEntry, type SessionSummaryEntry, type SessionTreeNode } from "./types.ts";
|
|
5
5
|
export interface SessionManagerCreateOptions {
|
|
6
6
|
readonly filePath: string;
|
|
7
7
|
readonly cwd: string;
|
|
@@ -50,6 +50,13 @@ export declare class SessionManager {
|
|
|
50
50
|
readonly firstKeptEntryId: string;
|
|
51
51
|
readonly tokensBefore: number;
|
|
52
52
|
}): Promise<SessionSummaryEntry>;
|
|
53
|
+
/** Appends host-owned metadata without exposing it as a transcript message. */
|
|
54
|
+
appendPlugin(input: {
|
|
55
|
+
readonly pluginId: string;
|
|
56
|
+
readonly pluginVersion: string;
|
|
57
|
+
readonly schemaVersion: number;
|
|
58
|
+
readonly data: JsonValue;
|
|
59
|
+
}): Promise<SessionPluginEntry>;
|
|
53
60
|
private addToIndexes;
|
|
54
61
|
}
|
|
55
62
|
//# sourceMappingURL=session-manager.d.ts.map
|