poe-code 0.1.26 → 1.0.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +110 -29
- package/dist/bin/poe-claude.js +16 -0
- package/dist/bin/poe-codex.js +16 -0
- package/dist/bin/poe-kimi-cli.js +16 -0
- package/dist/bin/poe-opencode.js +16 -0
- package/dist/cli/binary-aliases.d.ts +7 -0
- package/dist/cli/binary-aliases.js +26 -0
- package/dist/cli/binary-aliases.js.map +1 -0
- package/dist/cli/bootstrap.d.ts +4 -0
- package/dist/cli/bootstrap.js +78 -0
- package/dist/cli/bootstrap.js.map +1 -0
- package/dist/cli/command-runner.d.ts +1 -1
- package/dist/cli/command-runner.js +16 -2
- package/dist/cli/command-runner.js.map +1 -1
- package/dist/cli/commands/configure-payload.d.ts +15 -0
- package/dist/cli/commands/configure-payload.js +31 -0
- package/dist/cli/commands/configure-payload.js.map +1 -0
- package/dist/cli/commands/configure.d.ts +4 -3
- package/dist/cli/commands/configure.js +102 -101
- package/dist/cli/commands/configure.js.map +1 -1
- package/dist/cli/commands/ensure-isolated-config.d.ts +12 -0
- package/dist/cli/commands/ensure-isolated-config.js +53 -0
- package/dist/cli/commands/ensure-isolated-config.js.map +1 -0
- package/dist/cli/commands/generate.d.ts +9 -0
- package/dist/cli/commands/generate.js +323 -0
- package/dist/cli/commands/generate.js.map +1 -0
- package/dist/cli/commands/install.d.ts +4 -0
- package/dist/cli/commands/install.js +40 -0
- package/dist/cli/commands/install.js.map +1 -0
- package/dist/cli/commands/login.js +62 -8
- package/dist/cli/commands/login.js.map +1 -1
- package/dist/cli/commands/{root.d.ts → mcp.d.ts} +1 -1
- package/dist/cli/commands/mcp.js +168 -0
- package/dist/cli/commands/mcp.js.map +1 -0
- package/dist/cli/commands/shared.d.ts +16 -11
- package/dist/cli/commands/shared.js +45 -24
- package/dist/cli/commands/shared.js.map +1 -1
- package/dist/cli/commands/spawn.d.ts +14 -4
- package/dist/cli/commands/spawn.js +92 -77
- package/dist/cli/commands/spawn.js.map +1 -1
- package/dist/cli/commands/test.d.ts +6 -4
- package/dist/cli/commands/test.js +111 -16
- package/dist/cli/commands/test.js.map +1 -1
- package/dist/cli/commands/unconfigure.d.ts +7 -0
- package/dist/cli/commands/unconfigure.js +116 -0
- package/dist/cli/commands/unconfigure.js.map +1 -0
- package/dist/cli/commands/version.d.ts +3 -0
- package/dist/cli/commands/version.js +31 -0
- package/dist/cli/commands/version.js.map +1 -0
- package/dist/cli/commands/wrap.d.ts +3 -0
- package/dist/cli/commands/wrap.js +61 -0
- package/dist/cli/commands/wrap.js.map +1 -0
- package/dist/cli/constants.d.ts +23 -9
- package/dist/cli/constants.js +42 -9
- package/dist/cli/constants.js.map +1 -1
- package/dist/cli/container.d.ts +4 -10
- package/dist/cli/container.js +18 -22
- package/dist/cli/container.js.map +1 -1
- package/dist/cli/context.d.ts +9 -13
- package/dist/cli/context.js +45 -152
- package/dist/cli/context.js.map +1 -1
- package/dist/cli/environment.d.ts +2 -0
- package/dist/cli/environment.js +80 -0
- package/dist/cli/environment.js.map +1 -1
- package/dist/cli/error-logger.d.ts +18 -2
- package/dist/cli/error-logger.js +25 -7
- package/dist/cli/error-logger.js.map +1 -1
- package/dist/cli/errors.d.ts +14 -10
- package/dist/cli/errors.js +25 -12
- package/dist/cli/errors.js.map +1 -1
- package/dist/cli/exit-signals.d.ts +4 -0
- package/dist/cli/exit-signals.js +8 -0
- package/dist/cli/exit-signals.js.map +1 -0
- package/dist/cli/http.d.ts +1 -0
- package/dist/cli/isolated-env-runner.d.ts +10 -0
- package/dist/cli/isolated-env-runner.js +46 -0
- package/dist/cli/isolated-env-runner.js.map +1 -0
- package/dist/cli/isolated-env.d.ts +22 -0
- package/dist/cli/isolated-env.js +176 -0
- package/dist/cli/isolated-env.js.map +1 -0
- package/dist/cli/logger.d.ts +11 -1
- package/dist/cli/logger.js +101 -16
- package/dist/cli/logger.js.map +1 -1
- package/dist/cli/mcp-output-format.d.ts +2 -0
- package/dist/cli/mcp-output-format.js +22 -0
- package/dist/cli/mcp-output-format.js.map +1 -0
- package/dist/cli/mcp-server.d.ts +21 -0
- package/dist/cli/mcp-server.js +286 -0
- package/dist/cli/mcp-server.js.map +1 -0
- package/dist/cli/options.d.ts +18 -3
- package/dist/cli/options.js +39 -12
- package/dist/cli/options.js.map +1 -1
- package/dist/cli/poe-code-command-runner.d.ts +6 -0
- package/dist/cli/poe-code-command-runner.js +57 -0
- package/dist/cli/poe-code-command-runner.js.map +1 -0
- package/dist/cli/program.js +134 -23
- package/dist/cli/program.js.map +1 -1
- package/dist/cli/prompt-runner.d.ts +10 -0
- package/dist/cli/prompt-runner.js +79 -0
- package/dist/cli/prompt-runner.js.map +1 -0
- package/dist/cli/prompts.d.ts +23 -7
- package/dist/cli/prompts.js +17 -33
- package/dist/cli/prompts.js.map +1 -1
- package/dist/cli/service-registry.d.ts +86 -21
- package/dist/cli/service-registry.js +60 -12
- package/dist/cli/service-registry.js.map +1 -1
- package/dist/cli/ui/service-menu.d.ts +7 -0
- package/dist/cli/ui/service-menu.js +43 -0
- package/dist/cli/ui/service-menu.js.map +1 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +7 -74
- package/dist/index.js.map +1 -1
- package/dist/providers/claude-code.d.ts +13 -0
- package/dist/providers/claude-code.js +136 -0
- package/dist/providers/claude-code.js.map +1 -0
- package/dist/providers/codex.d.ts +17 -0
- package/dist/providers/codex.js +144 -0
- package/dist/providers/codex.js.map +1 -0
- package/dist/providers/create-provider.d.ts +29 -0
- package/dist/providers/create-provider.js +63 -0
- package/dist/providers/create-provider.js.map +1 -0
- package/dist/providers/index.d.ts +2 -2
- package/dist/providers/index.js +5 -10
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/kimi.d.ts +4 -0
- package/dist/providers/kimi.js +123 -0
- package/dist/providers/kimi.js.map +1 -0
- package/dist/providers/opencode.d.ts +3 -0
- package/dist/providers/opencode.js +119 -0
- package/dist/providers/opencode.js.map +1 -0
- package/dist/providers/spawn-options.d.ts +12 -0
- package/dist/providers/spawn-options.js +2 -0
- package/dist/providers/spawn-options.js.map +1 -0
- package/dist/sdk/container.d.ts +18 -0
- package/dist/sdk/container.js +127 -0
- package/dist/sdk/container.js.map +1 -0
- package/dist/sdk/credentials.d.ts +9 -0
- package/dist/sdk/credentials.js +35 -0
- package/dist/sdk/credentials.js.map +1 -0
- package/dist/sdk/generate.d.ts +5 -0
- package/dist/sdk/generate.js +97 -0
- package/dist/sdk/generate.js.map +1 -0
- package/dist/sdk/spawn-core.d.ts +23 -0
- package/dist/sdk/spawn-core.js +105 -0
- package/dist/sdk/spawn-core.js.map +1 -0
- package/dist/sdk/spawn.d.ts +23 -0
- package/dist/sdk/spawn.js +41 -0
- package/dist/sdk/spawn.js.map +1 -0
- package/dist/sdk/types.d.ts +38 -0
- package/dist/sdk/types.js +2 -0
- package/dist/sdk/types.js.map +1 -0
- package/dist/services/client-instance.d.ts +12 -0
- package/dist/services/client-instance.js +36 -0
- package/dist/services/client-instance.js.map +1 -0
- package/dist/services/credentials.d.ts +13 -0
- package/dist/services/credentials.js +132 -14
- package/dist/services/credentials.js.map +1 -1
- package/dist/services/llm-client.d.ts +22 -0
- package/dist/services/llm-client.js +138 -0
- package/dist/services/llm-client.js.map +1 -0
- package/dist/services/media-download.d.ts +17 -0
- package/dist/services/media-download.js +42 -0
- package/dist/services/media-download.js.map +1 -0
- package/dist/services/model-strategy.d.ts +2 -2
- package/dist/services/model-strategy.js +36 -31
- package/dist/services/model-strategy.js.map +1 -1
- package/dist/services/mutation-events.d.ts +4 -0
- package/dist/services/mutation-events.js +53 -0
- package/dist/services/mutation-events.js.map +1 -0
- package/dist/services/service-install.d.ts +5 -4
- package/dist/services/service-install.js +36 -13
- package/dist/services/service-install.js.map +1 -1
- package/dist/services/version.d.ts +11 -0
- package/dist/services/version.js +28 -0
- package/dist/services/version.js.map +1 -0
- package/dist/templates/codex/config.toml.hbs +3 -3
- package/dist/tools/label-generator.d.ts +11 -0
- package/dist/tools/label-generator.js +78 -0
- package/dist/tools/label-generator.js.map +1 -0
- package/dist/utils/command-checks.d.ts +45 -0
- package/dist/utils/command-checks.js +120 -0
- package/dist/utils/command-checks.js.map +1 -0
- package/dist/utils/dry-run.d.ts +1 -0
- package/dist/utils/dry-run.js +116 -7
- package/dist/utils/dry-run.js.map +1 -1
- package/dist/utils/execution-context.d.ts +40 -0
- package/dist/utils/execution-context.js +128 -0
- package/dist/utils/execution-context.js.map +1 -0
- package/dist/utils/json.js +3 -0
- package/dist/utils/json.js.map +1 -1
- package/dist/utils/templates.d.ts +1 -0
- package/dist/utils/templates.js +3 -4
- package/dist/utils/templates.js.map +1 -1
- package/package.json +54 -46
- package/dist/cli/api-client.d.ts +0 -14
- package/dist/cli/api-client.js +0 -140
- package/dist/cli/api-client.js.map +0 -1
- package/dist/cli/chat.d.ts +0 -32
- package/dist/cli/chat.js +0 -2
- package/dist/cli/chat.js.map +0 -1
- package/dist/cli/commands/agent.d.ts +0 -18
- package/dist/cli/commands/agent.js +0 -84
- package/dist/cli/commands/agent.js.map +0 -1
- package/dist/cli/commands/configure-agents.d.ts +0 -3
- package/dist/cli/commands/configure-agents.js +0 -72
- package/dist/cli/commands/configure-agents.js.map +0 -1
- package/dist/cli/commands/init.d.ts +0 -8
- package/dist/cli/commands/init.js +0 -45
- package/dist/cli/commands/init.js.map +0 -1
- package/dist/cli/commands/interactive.d.ts +0 -3
- package/dist/cli/commands/interactive.js +0 -17
- package/dist/cli/commands/interactive.js.map +0 -1
- package/dist/cli/commands/logout.d.ts +0 -3
- package/dist/cli/commands/logout.js +0 -31
- package/dist/cli/commands/logout.js.map +0 -1
- package/dist/cli/commands/prerequisites.d.ts +0 -3
- package/dist/cli/commands/prerequisites.js +0 -23
- package/dist/cli/commands/prerequisites.js.map +0 -1
- package/dist/cli/commands/query.d.ts +0 -7
- package/dist/cli/commands/query.js +0 -46
- package/dist/cli/commands/query.js.map +0 -1
- package/dist/cli/commands/remove.d.ts +0 -6
- package/dist/cli/commands/remove.js +0 -80
- package/dist/cli/commands/remove.js.map +0 -1
- package/dist/cli/commands/root.js +0 -7
- package/dist/cli/commands/root.js.map +0 -1
- package/dist/cli/commands/spawn-worktree.d.ts +0 -6
- package/dist/cli/commands/spawn-worktree.js +0 -91
- package/dist/cli/commands/spawn-worktree.js.map +0 -1
- package/dist/cli/file-mentions.d.ts +0 -13
- package/dist/cli/file-mentions.js +0 -87
- package/dist/cli/file-mentions.js.map +0 -1
- package/dist/cli/file-picker-state.d.ts +0 -14
- package/dist/cli/file-picker-state.js +0 -23
- package/dist/cli/file-picker-state.js.map +0 -1
- package/dist/cli/interactive-command-runner.d.ts +0 -11
- package/dist/cli/interactive-command-runner.js +0 -142
- package/dist/cli/interactive-command-runner.js.map +0 -1
- package/dist/cli/interactive-launcher.d.ts +0 -2
- package/dist/cli/interactive-launcher.js +0 -404
- package/dist/cli/interactive-launcher.js.map +0 -1
- package/dist/cli/interactive-tasks.d.ts +0 -7
- package/dist/cli/interactive-tasks.js +0 -199
- package/dist/cli/interactive-tasks.js.map +0 -1
- package/dist/cli/interactive.d.ts +0 -19
- package/dist/cli/interactive.js +0 -479
- package/dist/cli/interactive.js.map +0 -1
- package/dist/cli/markdown-renderer.d.ts +0 -27
- package/dist/cli/markdown-renderer.js +0 -178
- package/dist/cli/markdown-renderer.js.map +0 -1
- package/dist/cli/markdown-renderer.test.d.ts +0 -1
- package/dist/cli/markdown-renderer.test.js +0 -105
- package/dist/cli/markdown-renderer.test.js.map +0 -1
- package/dist/cli/telemetry.d.ts +0 -15
- package/dist/cli/telemetry.js +0 -45
- package/dist/cli/telemetry.js.map +0 -1
- package/dist/commands/init.d.ts +0 -9
- package/dist/commands/init.js +0 -43
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/publish-placeholder.d.ts +0 -8
- package/dist/commands/publish-placeholder.js +0 -50
- package/dist/commands/publish-placeholder.js.map +0 -1
- package/dist/commands/spawn-worktree.d.ts +0 -25
- package/dist/commands/spawn-worktree.js +0 -139
- package/dist/commands/spawn-worktree.js.map +0 -1
- package/dist/providers/claude-code-adapter.d.ts +0 -20
- package/dist/providers/claude-code-adapter.js +0 -48
- package/dist/providers/claude-code-adapter.js.map +0 -1
- package/dist/providers/codex-adapter.d.ts +0 -19
- package/dist/providers/codex-adapter.js +0 -49
- package/dist/providers/codex-adapter.js.map +0 -1
- package/dist/providers/opencode-adapter.d.ts +0 -18
- package/dist/providers/opencode-adapter.js +0 -45
- package/dist/providers/opencode-adapter.js.map +0 -1
- package/dist/providers/roo-code-adapter.d.ts +0 -19
- package/dist/providers/roo-code-adapter.js +0 -70
- package/dist/providers/roo-code-adapter.js.map +0 -1
- package/dist/services/agent-config-manager.d.ts +0 -32
- package/dist/services/agent-config-manager.js +0 -130
- package/dist/services/agent-config-manager.js.map +0 -1
- package/dist/services/agent-registry.d.ts +0 -27
- package/dist/services/agent-registry.js +0 -89
- package/dist/services/agent-registry.js.map +0 -1
- package/dist/services/agent-session.d.ts +0 -24
- package/dist/services/agent-session.js +0 -107
- package/dist/services/agent-session.js.map +0 -1
- package/dist/services/agent-task-registry.d.ts +0 -131
- package/dist/services/agent-task-registry.js +0 -491
- package/dist/services/agent-task-registry.js.map +0 -1
- package/dist/services/chat.d.ts +0 -94
- package/dist/services/chat.js +0 -241
- package/dist/services/chat.js.map +0 -1
- package/dist/services/claude-code.d.ts +0 -28
- package/dist/services/claude-code.js +0 -155
- package/dist/services/claude-code.js.map +0 -1
- package/dist/services/codex.d.ts +0 -27
- package/dist/services/codex.js +0 -231
- package/dist/services/codex.js.map +0 -1
- package/dist/services/mcp-client.d.ts +0 -38
- package/dist/services/mcp-client.js +0 -170
- package/dist/services/mcp-client.js.map +0 -1
- package/dist/services/mcp-manager.d.ts +0 -28
- package/dist/services/mcp-manager.js +0 -157
- package/dist/services/mcp-manager.js.map +0 -1
- package/dist/services/opencode.d.ts +0 -25
- package/dist/services/opencode.js +0 -161
- package/dist/services/opencode.js.map +0 -1
- package/dist/services/poe-code.d.ts +0 -7
- package/dist/services/poe-code.js +0 -5
- package/dist/services/poe-code.js.map +0 -1
- package/dist/services/roo-code.d.ts +0 -22
- package/dist/services/roo-code.js +0 -134
- package/dist/services/roo-code.js.map +0 -1
- package/dist/services/service-manifest.d.ts +0 -122
- package/dist/services/service-manifest.js +0 -368
- package/dist/services/service-manifest.js.map +0 -1
- package/dist/services/task-logger.d.ts +0 -24
- package/dist/services/task-logger.js +0 -73
- package/dist/services/task-logger.js.map +0 -1
- package/dist/services/task-runner.d.ts +0 -19
- package/dist/services/task-runner.js +0 -157
- package/dist/services/task-runner.js.map +0 -1
- package/dist/services/tools.d.ts +0 -76
- package/dist/services/tools.js +0 -870
- package/dist/services/tools.js.map +0 -1
- package/dist/templates/claude-code/anthropic_key.sh.hbs +0 -2
- package/dist/utils/e2e-flags.d.ts +0 -1
- package/dist/utils/e2e-flags.js +0 -9
- package/dist/utils/e2e-flags.js.map +0 -1
- package/dist/utils/prerequisites.d.ts +0 -41
- package/dist/utils/prerequisites.js +0 -92
- package/dist/utils/prerequisites.js.map +0 -1
- package/dist/utils/toml.d.ts +0 -8
- package/dist/utils/toml.js +0 -30
- package/dist/utils/toml.js.map +0 -1
- package/dist/utils/worktree.d.ts +0 -40
- package/dist/utils/worktree.js +0 -179
- package/dist/utils/worktree.js.map +0 -1
- package/shared/conversation-layout.cjs +0 -11
- package/shared/conversation-layout.d.ts +0 -7
- package/shared/conversation-layout.js +0 -11
- package/shared/package.json +0 -13
package/dist/cli/program.js
CHANGED
|
@@ -1,18 +1,119 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
2
3
|
import { createCliContainer } from "./container.js";
|
|
3
|
-
import {
|
|
4
|
-
import { registerInitCommand } from "./commands/init.js";
|
|
4
|
+
import { text } from "@poe-code/design-system";
|
|
5
5
|
import { registerConfigureCommand } from "./commands/configure.js";
|
|
6
|
+
import { registerSpawnCommand } from "./commands/spawn.js";
|
|
7
|
+
import { registerWrapCommand } from "./commands/wrap.js";
|
|
6
8
|
import { registerLoginCommand } from "./commands/login.js";
|
|
7
|
-
import {
|
|
9
|
+
import { registerInstallCommand } from "./commands/install.js";
|
|
10
|
+
import { registerUnconfigureCommand } from "./commands/unconfigure.js";
|
|
8
11
|
import { registerTestCommand } from "./commands/test.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
import { registerGenerateCommand } from "./commands/generate.js";
|
|
13
|
+
import { registerMcpCommand } from "./commands/mcp.js";
|
|
14
|
+
import { registerVersionOption } from "./commands/version.js";
|
|
15
|
+
const require = createRequire(import.meta.url);
|
|
16
|
+
const packageJson = require("../../package.json");
|
|
17
|
+
function formatHelpText() {
|
|
18
|
+
const commandWidth = 11;
|
|
19
|
+
const cmd = (name, args) => {
|
|
20
|
+
const padded = name.padEnd(commandWidth);
|
|
21
|
+
const argument = args ? ` ${text.argument(args)}` : "";
|
|
22
|
+
return ` ${text.command(padded)}${argument}`;
|
|
23
|
+
};
|
|
24
|
+
const example = (value) => ` ${text.example(value)}`;
|
|
25
|
+
const opt = (flag, desc) => ` ${text.option(flag.padEnd(27))}${desc}`;
|
|
26
|
+
return [
|
|
27
|
+
text.heading("Configure coding agents to use the Poe API."),
|
|
28
|
+
"",
|
|
29
|
+
`${text.section("Usage:")} ${text.usageCommand("poe-code")} ${text.argument("<command> [...options]")}`,
|
|
30
|
+
"",
|
|
31
|
+
text.section("Commands:"),
|
|
32
|
+
cmd("configure", "[agent]") + " Configure developer tooling for Poe API",
|
|
33
|
+
example("poe-code configure claude-code"),
|
|
34
|
+
"",
|
|
35
|
+
cmd("unconfigure", "<agent>") + " Remove existing Poe API tooling configuration",
|
|
36
|
+
example("poe-code unconfigure codex"),
|
|
37
|
+
"",
|
|
38
|
+
cmd("install", "[agent]") + " Install tooling for a configured agent",
|
|
39
|
+
example("poe-code install opencode"),
|
|
40
|
+
"",
|
|
41
|
+
cmd("spawn", "<agent> [prompt]") + " Run a single prompt through a configured agent CLI",
|
|
42
|
+
example("poe-code spawn codex \"Say hello\""),
|
|
43
|
+
"",
|
|
44
|
+
cmd("wrap", "<agent>") + " Run an agent CLI with Poe isolated configuration",
|
|
45
|
+
example("poe-code wrap claude-code --help"),
|
|
46
|
+
"",
|
|
47
|
+
cmd("test", "[agent]") + " Run agent health checks",
|
|
48
|
+
example("poe-code test codex"),
|
|
49
|
+
"",
|
|
50
|
+
cmd("generate", "[type]") + " Generate text or media via Poe API",
|
|
51
|
+
example("poe-code generate \"What is 2+2?\""),
|
|
52
|
+
"",
|
|
53
|
+
cmd("login", "") + " Store a Poe API key for reuse across commands",
|
|
54
|
+
"",
|
|
55
|
+
cmd("mcp", "[subcommand]") + " MCP server commands",
|
|
56
|
+
example("poe-code mcp configure claude-code"),
|
|
57
|
+
"",
|
|
58
|
+
text.section("Options:"),
|
|
59
|
+
opt("-y, --yes", "Accept defaults without prompting"),
|
|
60
|
+
opt("--dry-run", "Simulate commands without writing changes"),
|
|
61
|
+
opt("--verbose", "Show verbose logs"),
|
|
62
|
+
opt("-V, --version", "Output the version number"),
|
|
63
|
+
opt("-h, --help", "Display help for command"),
|
|
64
|
+
"",
|
|
65
|
+
opt("<command> --help", "Print help text for command"),
|
|
66
|
+
"",
|
|
67
|
+
`${text.muted("Learn more about Poe:")} ${text.link("https://poe.com")}`,
|
|
68
|
+
`${text.muted("GitHub:")} ${text.link("https://github.com/poe-platform/poe-code")}`
|
|
69
|
+
].join("\n");
|
|
70
|
+
}
|
|
71
|
+
function formatSubcommandHelp(cmd, helper) {
|
|
72
|
+
const termWidth = helper.padWidth(cmd, helper);
|
|
73
|
+
const itemIndentWidth = 2;
|
|
74
|
+
const itemSeparatorWidth = 2;
|
|
75
|
+
const padWidth = termWidth + itemSeparatorWidth;
|
|
76
|
+
const indent = " ".repeat(itemIndentWidth);
|
|
77
|
+
const formatItem = (term, description, style) => {
|
|
78
|
+
const padding = " ".repeat(Math.max(0, padWidth - term.length));
|
|
79
|
+
const styledTerm = `${style(term)}${padding}`;
|
|
80
|
+
if (!description) {
|
|
81
|
+
return style(term);
|
|
82
|
+
}
|
|
83
|
+
return `${styledTerm}${description}`;
|
|
84
|
+
};
|
|
85
|
+
const indentBlock = (value) => value
|
|
86
|
+
.split("\n")
|
|
87
|
+
.map((line) => `${indent}${line}`)
|
|
88
|
+
.join("\n");
|
|
89
|
+
const formatList = (items) => items.map(indentBlock).join("\n");
|
|
90
|
+
const output = [];
|
|
91
|
+
output.push(text.heading(`Poe - ${cmd.name()}`), "");
|
|
92
|
+
output.push(`${text.section("Usage:")} ${text.usageCommand(helper.commandUsage(cmd))}`, "");
|
|
93
|
+
const commandDescription = helper.commandDescription(cmd);
|
|
94
|
+
if (commandDescription.length > 0) {
|
|
95
|
+
output.push(commandDescription, "");
|
|
96
|
+
}
|
|
97
|
+
const argumentList = helper.visibleArguments(cmd).map((argument) => formatItem(helper.argumentTerm(argument), helper.argumentDescription(argument), text.argument));
|
|
98
|
+
if (argumentList.length > 0) {
|
|
99
|
+
output.push(text.section("Arguments:"), formatList(argumentList), "");
|
|
100
|
+
}
|
|
101
|
+
const optionList = helper.visibleOptions(cmd).map((option) => formatItem(helper.optionTerm(option), helper.optionDescription(option), text.option));
|
|
102
|
+
if (optionList.length > 0) {
|
|
103
|
+
output.push(text.section("Options:"), formatList(optionList), "");
|
|
104
|
+
}
|
|
105
|
+
if (helper.showGlobalOptions) {
|
|
106
|
+
const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => formatItem(helper.optionTerm(option), helper.optionDescription(option), text.option));
|
|
107
|
+
if (globalOptionList.length > 0) {
|
|
108
|
+
output.push(text.section("Global Options:"), formatList(globalOptionList), "");
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const commandList = helper.visibleCommands(cmd).map((subcommand) => formatItem(helper.subcommandTerm(subcommand), helper.subcommandDescription(subcommand), text.command));
|
|
112
|
+
if (commandList.length > 0) {
|
|
113
|
+
output.push(text.section("Commands:"), formatList(commandList), "");
|
|
114
|
+
}
|
|
115
|
+
return output.join("\n");
|
|
116
|
+
}
|
|
16
117
|
export function createProgram(dependencies) {
|
|
17
118
|
const container = createCliContainer(dependencies);
|
|
18
119
|
const program = bootstrapProgram(container);
|
|
@@ -28,22 +129,32 @@ function bootstrapProgram(container) {
|
|
|
28
129
|
const program = new Command();
|
|
29
130
|
program
|
|
30
131
|
.name("poe-code")
|
|
31
|
-
.description("
|
|
132
|
+
.description("Configure Poe API integrations for local developer tooling.")
|
|
133
|
+
.option("-y, --yes", "Accept defaults without prompting.")
|
|
32
134
|
.option("--dry-run", "Simulate commands without writing changes.")
|
|
33
|
-
.option("--verbose", "
|
|
34
|
-
|
|
35
|
-
|
|
135
|
+
.option("--verbose", "Show verbose logs.")
|
|
136
|
+
.helpOption("-h, --help", "Display help for command")
|
|
137
|
+
.configureHelp({
|
|
138
|
+
formatHelp: (cmd, helper) => {
|
|
139
|
+
if (cmd.name() === "poe-code") {
|
|
140
|
+
return formatHelpText();
|
|
141
|
+
}
|
|
142
|
+
return formatSubcommandHelp(cmd, helper);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
registerVersionOption(program, container, packageJson.version);
|
|
146
|
+
registerInstallCommand(program, container);
|
|
36
147
|
registerConfigureCommand(program, container);
|
|
37
|
-
registerLoginCommand(program, container);
|
|
38
|
-
registerLogoutCommand(program, container);
|
|
39
|
-
registerTestCommand(program, container);
|
|
40
|
-
registerQueryCommand(program, container);
|
|
41
|
-
registerAgentCommand(program, container);
|
|
42
|
-
registerPrerequisitesCommand(program, container);
|
|
43
|
-
registerRemoveCommand(program, container);
|
|
44
148
|
registerSpawnCommand(program, container);
|
|
45
|
-
|
|
46
|
-
|
|
149
|
+
registerWrapCommand(program, container);
|
|
150
|
+
registerGenerateCommand(program, container);
|
|
151
|
+
registerTestCommand(program, container);
|
|
152
|
+
registerUnconfigureCommand(program, container);
|
|
153
|
+
registerLoginCommand(program, container);
|
|
154
|
+
registerMcpCommand(program, container);
|
|
155
|
+
program.action(() => {
|
|
156
|
+
program.outputHelp();
|
|
157
|
+
});
|
|
47
158
|
return program;
|
|
48
159
|
}
|
|
49
160
|
function applyExitOverride(command) {
|
package/dist/cli/program.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"program.js","sourceRoot":"","sources":["../../src/cli/program.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"program.js","sourceRoot":"","sources":["../../src/cli/program.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAQ,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EACL,kBAAkB,EAGnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,WAAW,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,SAAS,CAAC,CAAC;IACzC,kBAAkB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAEvC,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE;QAClB,OAAO,CAAC,UAAU,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC;AAID,SAAS,iBAAiB,CAAC,OAAgB;IACzC,OAAO,CAAC,YAAY,EAAE,CAAC;IACvB,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC;AAED,SAAS,uBAAuB,CAAC,OAAgB;IAC/C,OAAO,CAAC,eAAe,CAAC;QACtB,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC;QAClB,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC;KACnB,CAAC,CAAC;IACH,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrC,uBAAuB,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { cancel, isCancel, password, select, promptText as text } from "@poe-code/design-system";
|
|
2
|
+
import type { PromptFn } from "./types.js";
|
|
3
|
+
export interface PromptAdapter {
|
|
4
|
+
text: typeof text;
|
|
5
|
+
password: typeof password;
|
|
6
|
+
select: typeof select;
|
|
7
|
+
isCancel: typeof isCancel;
|
|
8
|
+
cancel: typeof cancel;
|
|
9
|
+
}
|
|
10
|
+
export declare function createPromptRunner(adapter?: PromptAdapter): PromptFn;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { cancel, isCancel, password, select, promptText as text } from "@poe-code/design-system";
|
|
2
|
+
import { OperationCancelledError } from "./errors.js";
|
|
3
|
+
function toInitialValue(value) {
|
|
4
|
+
if (value == null) {
|
|
5
|
+
return undefined;
|
|
6
|
+
}
|
|
7
|
+
return String(value);
|
|
8
|
+
}
|
|
9
|
+
function resolveSelectInitial(descriptor) {
|
|
10
|
+
if (descriptor.initial == null) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
if (typeof descriptor.initial === "number") {
|
|
14
|
+
return descriptor.choices?.[descriptor.initial]?.value;
|
|
15
|
+
}
|
|
16
|
+
return descriptor.initial;
|
|
17
|
+
}
|
|
18
|
+
export function createPromptRunner(adapter = {
|
|
19
|
+
text,
|
|
20
|
+
password,
|
|
21
|
+
select,
|
|
22
|
+
isCancel,
|
|
23
|
+
cancel
|
|
24
|
+
}) {
|
|
25
|
+
const runPrompt = async (descriptor) => {
|
|
26
|
+
const type = descriptor.type ?? "text";
|
|
27
|
+
let result;
|
|
28
|
+
if (type === "password") {
|
|
29
|
+
result = await adapter.password({
|
|
30
|
+
message: descriptor.message
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
else if (type === "select") {
|
|
34
|
+
const choices = descriptor.choices ?? [];
|
|
35
|
+
if (choices.length === 0) {
|
|
36
|
+
throw new Error(`Missing choices for "${descriptor.name}".`);
|
|
37
|
+
}
|
|
38
|
+
result = await adapter.select({
|
|
39
|
+
message: descriptor.message,
|
|
40
|
+
options: choices.map((choice) => ({
|
|
41
|
+
label: choice.title,
|
|
42
|
+
value: choice.value
|
|
43
|
+
})),
|
|
44
|
+
initialValue: resolveSelectInitial(descriptor)
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
result = await adapter.text({
|
|
49
|
+
message: descriptor.message,
|
|
50
|
+
initialValue: toInitialValue(descriptor.initial)
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (adapter.isCancel(result)) {
|
|
54
|
+
adapter.cancel("Operation cancelled.");
|
|
55
|
+
throw new OperationCancelledError();
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
58
|
+
};
|
|
59
|
+
return async (questions) => {
|
|
60
|
+
const prompts = Array.isArray(questions)
|
|
61
|
+
? questions
|
|
62
|
+
: questions
|
|
63
|
+
? [questions]
|
|
64
|
+
: [];
|
|
65
|
+
if (prompts.length === 0) {
|
|
66
|
+
return {};
|
|
67
|
+
}
|
|
68
|
+
const responses = {};
|
|
69
|
+
for (const prompt of prompts) {
|
|
70
|
+
if (!prompt || typeof prompt !== "object") {
|
|
71
|
+
throw new Error("Invalid prompt descriptor.");
|
|
72
|
+
}
|
|
73
|
+
const descriptor = prompt;
|
|
74
|
+
responses[descriptor.name] = await runPrompt(descriptor);
|
|
75
|
+
}
|
|
76
|
+
return responses;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=prompt-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-runner.js","sourceRoot":"","sources":["../../src/cli/prompt-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,UAAU,IAAI,IAAI,EACnB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAYtD,SAAS,cAAc,CAAC,KAAkC;IACxD,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QAClB,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAED,SAAS,oBAAoB,CAC3B,UAA4B;IAE5B,IAAI,UAAU,CAAC,OAAO,IAAI,IAAI,EAAE,CAAC;QAC/B,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,OAAO,UAAU,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC3C,OAAO,UAAU,CAAC,OAAO,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC;IACzD,CAAC;IACD,OAAO,UAAU,CAAC,OAAO,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,UAAyB;IACvB,IAAI;IACJ,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AM,IAAI,uBAAuB,EAAE,CAAC;QACtC,CAAC;QAED,OAAO,MAAgB,CAAC;IAC1B,CAAC,CAAC;IAEF,OAAO,KAAK,EAAE,SAAS,EAAE,EAAE;QACzB,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;YACtC,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC,CAAC,SAAS,CAAC;gBACb,CAAC,CAAC,EAAE,CAAC;QACP,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,SAAS,GAA4B,EAAE,CAAC;QAC9C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;gBAC1C,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;YAChD,CAAC;YACD,MAAM,UAAU,GAAG,MAA0B,CAAC;YAC9C,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,MAAM,SAAS,CAAC,UAAU,CAAC,CAAC;QAC3D,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/cli/prompts.d.ts
CHANGED
|
@@ -8,16 +8,32 @@ export interface PromptDescriptor<TName extends string = string> {
|
|
|
8
8
|
value: string;
|
|
9
9
|
}>;
|
|
10
10
|
}
|
|
11
|
+
export interface ModelPromptInput {
|
|
12
|
+
label: string;
|
|
13
|
+
defaultValue: string;
|
|
14
|
+
choices: Array<{
|
|
15
|
+
title: string;
|
|
16
|
+
value: string;
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
export interface ReasoningPromptInput {
|
|
20
|
+
label: string;
|
|
21
|
+
defaultValue: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ServiceSelectionInput {
|
|
24
|
+
message: string;
|
|
25
|
+
choices: Array<{
|
|
26
|
+
title: string;
|
|
27
|
+
value: string;
|
|
28
|
+
}>;
|
|
29
|
+
}
|
|
11
30
|
export interface PromptLibrary {
|
|
12
|
-
apiKey(): PromptDescriptor<"apiKey">;
|
|
13
31
|
loginApiKey(): PromptDescriptor<"apiKey">;
|
|
14
|
-
model(
|
|
15
|
-
|
|
16
|
-
reasoningEffort(defaultValue: string): PromptDescriptor<"reasoningEffort">;
|
|
32
|
+
model(input: ModelPromptInput): PromptDescriptor<"model">;
|
|
33
|
+
reasoningEffort(input: ReasoningPromptInput): PromptDescriptor<"reasoningEffort">;
|
|
17
34
|
configName(defaultName: string): PromptDescriptor<"configName">;
|
|
18
|
-
serviceSelection(): PromptDescriptor<"serviceSelection"> & {
|
|
19
|
-
type: "
|
|
35
|
+
serviceSelection(input: ServiceSelectionInput): PromptDescriptor<"serviceSelection"> & {
|
|
36
|
+
type: "select";
|
|
20
37
|
};
|
|
21
|
-
queryPrompt(): PromptDescriptor<"prompt">;
|
|
22
38
|
}
|
|
23
39
|
export declare function createPromptLibrary(): PromptLibrary;
|
package/dist/cli/prompts.js
CHANGED
|
@@ -1,36 +1,24 @@
|
|
|
1
1
|
export function createPromptLibrary() {
|
|
2
2
|
const describe = (descriptor) => descriptor;
|
|
3
3
|
return {
|
|
4
|
-
apiKey: () => describe({
|
|
5
|
-
name: "apiKey",
|
|
6
|
-
message: "POE API key",
|
|
7
|
-
type: "text"
|
|
8
|
-
}),
|
|
9
4
|
loginApiKey: () => describe({
|
|
10
5
|
name: "apiKey",
|
|
11
6
|
message: "Enter your Poe API key (get one at https://poe.com/api_key)",
|
|
12
7
|
type: "password"
|
|
13
8
|
}),
|
|
14
|
-
model: (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
choices: [
|
|
26
|
-
{ title: "Claude-Haiku-4.5", value: "Claude-Haiku-4.5" },
|
|
27
|
-
{ title: "Claude-Sonnet-4.5", value: "Claude-Sonnet-4.5" },
|
|
28
|
-
{ title: "Claude-Opus-4.1", value: "Claude-Opus-4.1" }
|
|
29
|
-
]
|
|
30
|
-
}),
|
|
31
|
-
reasoningEffort: (defaultValue) => describe({
|
|
9
|
+
model: ({ label, defaultValue, choices }) => {
|
|
10
|
+
const initial = Math.max(choices.findIndex((choice) => choice.value === defaultValue), 0);
|
|
11
|
+
return describe({
|
|
12
|
+
name: "model",
|
|
13
|
+
message: label,
|
|
14
|
+
type: "select",
|
|
15
|
+
initial,
|
|
16
|
+
choices
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
reasoningEffort: ({ label, defaultValue }) => describe({
|
|
32
20
|
name: "reasoningEffort",
|
|
33
|
-
message:
|
|
21
|
+
message: label,
|
|
34
22
|
type: "text",
|
|
35
23
|
initial: defaultValue
|
|
36
24
|
}),
|
|
@@ -40,19 +28,15 @@ export function createPromptLibrary() {
|
|
|
40
28
|
type: "text",
|
|
41
29
|
initial: defaultName
|
|
42
30
|
}),
|
|
43
|
-
serviceSelection: () => {
|
|
31
|
+
serviceSelection: ({ message, choices }) => {
|
|
44
32
|
const descriptor = {
|
|
45
33
|
name: "serviceSelection",
|
|
46
|
-
message
|
|
47
|
-
type: "
|
|
34
|
+
message,
|
|
35
|
+
type: "select",
|
|
36
|
+
choices
|
|
48
37
|
};
|
|
49
38
|
return descriptor;
|
|
50
|
-
}
|
|
51
|
-
queryPrompt: () => describe({
|
|
52
|
-
name: "prompt",
|
|
53
|
-
message: "Prompt",
|
|
54
|
-
type: "text"
|
|
55
|
-
})
|
|
39
|
+
}
|
|
56
40
|
};
|
|
57
41
|
}
|
|
58
42
|
//# sourceMappingURL=prompts.js.map
|
package/dist/cli/prompts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/cli/prompts.ts"],"names":[],"mappings":"
|
|
1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ACd,OAAO;aACR,CAAC;YACF,OAAO,UAAU,CAAC;QACpB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,33 +1,98 @@
|
|
|
1
1
|
import type { CliEnvironment } from "./environment.js";
|
|
2
2
|
import type { CommandContext } from "./context.js";
|
|
3
3
|
import type { ScopedLogger } from "./logger.js";
|
|
4
|
-
import type {
|
|
5
|
-
|
|
4
|
+
import type { FileSystem } from "../utils/file-system.js";
|
|
5
|
+
import type { CommandCheck } from "../utils/command-checks.js";
|
|
6
|
+
import type { ModelPromptInput, ReasoningPromptInput } from "./prompts.js";
|
|
7
|
+
import type { MutationObservers } from "@poe-code/config-mutations";
|
|
8
|
+
export interface ServiceManifestPathMapper {
|
|
9
|
+
mapTargetDirectory: (input: {
|
|
10
|
+
targetDirectory: string;
|
|
11
|
+
env: CliEnvironment;
|
|
12
|
+
}) => string;
|
|
13
|
+
}
|
|
14
|
+
export interface ServiceRunOptions {
|
|
15
|
+
observers?: MutationObservers;
|
|
16
|
+
}
|
|
17
|
+
export interface ProviderColorSet {
|
|
18
|
+
light?: string;
|
|
19
|
+
dark?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface ProviderBranding {
|
|
22
|
+
colors?: ProviderColorSet;
|
|
23
|
+
}
|
|
24
|
+
export interface ProviderConfigurePrompts {
|
|
25
|
+
model?: ModelPromptInput;
|
|
26
|
+
reasoningEffort?: ReasoningPromptInput;
|
|
27
|
+
}
|
|
28
|
+
export interface ProviderContext {
|
|
6
29
|
env: CliEnvironment;
|
|
7
|
-
paths: TPaths;
|
|
8
30
|
command: CommandContext;
|
|
9
31
|
logger: ScopedLogger;
|
|
32
|
+
runCheck(check: CommandCheck): Promise<void>;
|
|
10
33
|
}
|
|
11
|
-
export interface
|
|
34
|
+
export interface ServiceExecutionContext<Options> {
|
|
35
|
+
fs: FileSystem;
|
|
36
|
+
env: CliEnvironment;
|
|
37
|
+
command: CommandContext;
|
|
38
|
+
options: Options;
|
|
39
|
+
pathMapper?: ServiceManifestPathMapper;
|
|
40
|
+
}
|
|
41
|
+
export interface ProviderService<TConfigure = any, TUnconfigure = TConfigure, TSpawn = any> {
|
|
42
|
+
id: string;
|
|
43
|
+
summary: string;
|
|
44
|
+
aliases?: string[];
|
|
45
|
+
configure(context: ServiceExecutionContext<TConfigure>, runOptions?: ServiceRunOptions): Promise<void>;
|
|
46
|
+
unconfigure(context: ServiceExecutionContext<TUnconfigure>, runOptions?: ServiceRunOptions): Promise<boolean>;
|
|
12
47
|
name: string;
|
|
13
48
|
label: string;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
49
|
+
branding?: ProviderBranding;
|
|
50
|
+
disabled?: boolean;
|
|
51
|
+
supportsStdinPrompt?: boolean;
|
|
52
|
+
configurePrompts?: ProviderConfigurePrompts;
|
|
53
|
+
postConfigureMessages?: string[];
|
|
54
|
+
isolatedEnv?: ProviderIsolatedEnv;
|
|
55
|
+
install?(context: ProviderContext): Promise<void> | void;
|
|
56
|
+
spawn?(context: ProviderContext, options: TSpawn): Promise<unknown>;
|
|
57
|
+
test?(context: ProviderContext): Promise<void>;
|
|
21
58
|
}
|
|
22
|
-
export interface
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
invoke<T>(serviceName: string, operation: ProviderOperation, runner: (adapter: ProviderAdapter) => Promise<T>): Promise<T>;
|
|
59
|
+
export interface ProviderIsolatedEnv {
|
|
60
|
+
agentBinary: string;
|
|
61
|
+
configProbe?: IsolatedEnvPath;
|
|
62
|
+
env: Record<string, IsolatedEnvValue>;
|
|
63
|
+
repairs?: IsolatedEnvRepair[];
|
|
64
|
+
requiresConfig?: boolean;
|
|
29
65
|
}
|
|
30
|
-
export
|
|
31
|
-
|
|
66
|
+
export type IsolatedEnvRepair = {
|
|
67
|
+
kind: "chmod";
|
|
68
|
+
relativePath: string;
|
|
69
|
+
mode: number;
|
|
70
|
+
};
|
|
71
|
+
export type IsolatedEnvPath = {
|
|
72
|
+
kind: "isolatedDir";
|
|
73
|
+
relativePath?: string;
|
|
74
|
+
} | {
|
|
75
|
+
kind: "isolatedFile";
|
|
76
|
+
relativePath: string;
|
|
77
|
+
};
|
|
78
|
+
export type IsolatedEnvValue = string | IsolatedEnvPath | IsolatedEnvVariable | IsolatedEnvPoeApiKey | IsolatedEnvPoeBaseUrl;
|
|
79
|
+
export type IsolatedEnvVariable = {
|
|
80
|
+
kind: "envVar";
|
|
81
|
+
name: string;
|
|
82
|
+
};
|
|
83
|
+
export type IsolatedEnvPoeApiKey = {
|
|
84
|
+
kind: "poeApiKey";
|
|
85
|
+
};
|
|
86
|
+
export type IsolatedEnvPoeBaseUrl = {
|
|
87
|
+
kind: "poeBaseUrl";
|
|
88
|
+
};
|
|
89
|
+
export type ProviderOperation = "install" | "configure" | "unconfigure" | "spawn" | "test";
|
|
90
|
+
export interface ServiceRegistry {
|
|
91
|
+
register(adapter: ProviderService): void;
|
|
92
|
+
discover(adapters: ProviderService[]): void;
|
|
93
|
+
get(name: string): ProviderService | undefined;
|
|
94
|
+
require(name: string): ProviderService;
|
|
95
|
+
list(): ProviderService[];
|
|
96
|
+
invoke<T>(serviceName: string, operation: ProviderOperation, runner: (adapter: ProviderService) => Promise<T>): Promise<T>;
|
|
32
97
|
}
|
|
33
|
-
export declare function createServiceRegistry(
|
|
98
|
+
export declare function createServiceRegistry(): ServiceRegistry;
|
|
@@ -1,33 +1,81 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { resolveAgentId } from "@poe-code/agent-defs";
|
|
2
|
+
export function createServiceRegistry() {
|
|
3
|
+
const canonicalAdapters = new Map();
|
|
4
|
+
const nameToCanonical = new Map();
|
|
5
|
+
const listProviderKeys = (adapter) => {
|
|
6
|
+
const keys = [adapter.name];
|
|
7
|
+
for (const alias of adapter.aliases ?? []) {
|
|
8
|
+
if (typeof alias !== "string") {
|
|
9
|
+
continue;
|
|
10
|
+
}
|
|
11
|
+
const normalized = alias.trim();
|
|
12
|
+
if (normalized.length === 0) {
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
if (!keys.includes(normalized)) {
|
|
16
|
+
keys.push(normalized);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return keys;
|
|
20
|
+
};
|
|
3
21
|
const register = (adapter) => {
|
|
4
|
-
if (
|
|
22
|
+
if (canonicalAdapters.has(adapter.name)) {
|
|
5
23
|
throw new Error(`Provider "${adapter.name}" is already registered.`);
|
|
6
24
|
}
|
|
7
|
-
|
|
25
|
+
const keys = listProviderKeys(adapter);
|
|
26
|
+
for (const key of keys) {
|
|
27
|
+
if (nameToCanonical.has(key)) {
|
|
28
|
+
throw new Error(`Provider "${key}" is already registered.`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
canonicalAdapters.set(adapter.name, adapter);
|
|
32
|
+
for (const key of keys) {
|
|
33
|
+
nameToCanonical.set(key, adapter.name);
|
|
34
|
+
}
|
|
8
35
|
};
|
|
9
36
|
const discover = (candidates) => {
|
|
10
37
|
for (const candidate of candidates) {
|
|
11
|
-
if (
|
|
38
|
+
if (canonicalAdapters.has(candidate.name)) {
|
|
12
39
|
continue;
|
|
13
40
|
}
|
|
14
|
-
|
|
41
|
+
const keys = listProviderKeys(candidate);
|
|
42
|
+
if (keys.some((key) => nameToCanonical.has(key))) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
canonicalAdapters.set(candidate.name, candidate);
|
|
46
|
+
for (const key of keys) {
|
|
47
|
+
nameToCanonical.set(key, candidate.name);
|
|
48
|
+
}
|
|
15
49
|
}
|
|
16
50
|
};
|
|
17
|
-
const
|
|
51
|
+
const resolveCanonicalName = (name) => {
|
|
52
|
+
const direct = nameToCanonical.get(name);
|
|
53
|
+
if (direct) {
|
|
54
|
+
return direct;
|
|
55
|
+
}
|
|
56
|
+
const resolvedAgent = resolveAgentId(name);
|
|
57
|
+
if (!resolvedAgent) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
return nameToCanonical.get(resolvedAgent);
|
|
61
|
+
};
|
|
62
|
+
const get = (name) => {
|
|
63
|
+
const canonicalName = resolveCanonicalName(name);
|
|
64
|
+
if (!canonicalName) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
return canonicalAdapters.get(canonicalName);
|
|
68
|
+
};
|
|
18
69
|
const require = (name) => {
|
|
19
|
-
const adapter =
|
|
70
|
+
const adapter = get(name);
|
|
20
71
|
if (!adapter) {
|
|
21
72
|
throw new Error(`Unknown provider "${name}".`);
|
|
22
73
|
}
|
|
23
74
|
return adapter;
|
|
24
75
|
};
|
|
25
|
-
const list = () => Array.from(
|
|
76
|
+
const list = () => Array.from(canonicalAdapters.values());
|
|
26
77
|
const invoke = async (serviceName, operation, runner) => {
|
|
27
78
|
const adapter = require(serviceName);
|
|
28
|
-
if (init.telemetry) {
|
|
29
|
-
return await init.telemetry.wrap(serviceName, operation, () => runner(adapter));
|
|
30
|
-
}
|
|
31
79
|
return await runner(adapter);
|
|
32
80
|
};
|
|
33
81
|
return { register, discover, get, require, list, invoke };
|