@love-moon/conductor-cli 0.2.41 → 0.3.0

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.
@@ -3,19 +3,59 @@ import path from "node:path";
3
3
  import { pathToFileURL } from "node:url";
4
4
 
5
5
  import yaml from "js-yaml";
6
+ import { BUILT_IN_BACKENDS as AI_SDK_BUILT_IN_BACKENDS } from "@love-moon/ai-sdk";
6
7
 
8
+ // CLI display order for built-in backends. ai-sdk owns the canonical set of
9
+ // built-in backends; CLI just picks an ordering for "Supported Backends:" log
10
+ // output. The self-check below ensures this list always matches ai-sdk's set.
7
11
  const BUILT_IN_RUNTIME_BACKENDS = ["codex", "claude", "kimi", "opencode", "copilot"];
8
12
  const BUILT_IN_RUNTIME_BACKEND_SET = new Set(BUILT_IN_RUNTIME_BACKENDS);
9
13
  const COMMAND_OPTIONAL_BUILT_IN_RUNTIME_BACKENDS = ["copilot"];
10
14
  const COMMAND_OPTIONAL_BUILT_IN_RUNTIME_BACKEND_SET = new Set(COMMAND_OPTIONAL_BUILT_IN_RUNTIME_BACKENDS);
11
- const LEGACY_RUNTIME_BACKEND_ALIASES = new Set([
12
- "code",
13
- "claude-code",
14
- "open-code",
15
- "open_code",
16
- "kimi-cli",
17
- "kimi-code",
18
- ]);
15
+
16
+ // Legacy aliases (e.g. "code" → "codex", "kimi-cli" → "kimi") are derived
17
+ // from ai-sdk's BUILT_IN_BACKENDS to avoid drift. ai-sdk is the single source
18
+ // of truth for which alias maps to which built-in backend.
19
+ const LEGACY_RUNTIME_BACKEND_ALIASES = new Set(
20
+ AI_SDK_BUILT_IN_BACKENDS.flatMap((entry) =>
21
+ entry.aliases.filter((alias) => alias !== entry.backend),
22
+ ),
23
+ );
24
+
25
+ /**
26
+ * Asserts that CLI's ordered built-in display list and ai-sdk's built-in
27
+ * backend set are exactly equal. Throws on drift in either direction.
28
+ *
29
+ * Exported for test use; also invoked at module load below as a fail-fast
30
+ * invariant check.
31
+ *
32
+ * @param {string[]} cliBackends
33
+ * @param {ReadonlyArray<{ backend: string }>} aiSdkBackends
34
+ */
35
+ export function assertCliAndAiSdkBackendsAgree(cliBackends, aiSdkBackends) {
36
+ const aiSdkBackendSet = new Set(aiSdkBackends.map((entry) => entry.backend));
37
+ const cliBackendSet = new Set(cliBackends);
38
+ for (const backend of cliBackends) {
39
+ if (!aiSdkBackendSet.has(backend)) {
40
+ throw new Error(
41
+ `cli/runtime-backends: BUILT_IN_RUNTIME_BACKENDS lists "${backend}" `
42
+ + `but ai-sdk does not know about it. Did you remove it from ai-sdk's BUILT_IN_BACKENDS?`,
43
+ );
44
+ }
45
+ }
46
+ for (const backend of aiSdkBackendSet) {
47
+ if (!cliBackendSet.has(backend)) {
48
+ throw new Error(
49
+ `cli/runtime-backends: ai-sdk has built-in backend "${backend}" `
50
+ + `but BUILT_IN_RUNTIME_BACKENDS does not list it. Add it to BUILT_IN_RUNTIME_BACKENDS in cli/src/runtime-backends.js.`,
51
+ );
52
+ }
53
+ }
54
+ }
55
+
56
+ // Module-load self-check: fails fast if someone adds a new built-in to ai-sdk
57
+ // without updating CLI's ordering, or vice versa.
58
+ assertCliAndAiSdkBackendsAgree(BUILT_IN_RUNTIME_BACKENDS, AI_SDK_BUILT_IN_BACKENDS);
19
59
  const externalRuntimeCatalogPromises = new Map();
20
60
  let externalRuntimeImportNonce = 0;
21
61