prizmkit 1.1.183 → 1.1.184

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.
@@ -31,7 +31,7 @@ program
31
31
  program
32
32
  .command('install [directory]')
33
33
  .description('Install PrizmKit into a project directory')
34
- .option('--platform <platform>', 'Target platform: codebuddy, claude, codex, pi, cursor, or all')
34
+ .option('--platform <platform>', 'Target platform: codebuddy, claude, codex, pi, cursor, comma-separated list, or all')
35
35
  .option('--runtime <runtime>', 'Runtime assets: python or auto; unix/windows are accepted as legacy aliases for python')
36
36
  .option('--skills <suite>', 'Skill suite: core, minimal, or recommended:<type> (frontend/backend/fullstack/library)', 'core')
37
37
  .option('--pipeline', 'Install dev-pipeline (default: true)')
@@ -90,7 +90,7 @@ program
90
90
  program
91
91
  .command('config [directory]')
92
92
  .description('Reconfigure existing PrizmKit installation (change platform, skills, rules, options)')
93
- .option('--platform <platform>', 'Target platform: codebuddy, claude, codex, pi, cursor, or all')
93
+ .option('--platform <platform>', 'Target platform: codebuddy, claude, codex, pi, cursor, comma-separated list, or all')
94
94
  .option('--runtime <runtime>', 'Runtime assets: python or auto; unix/windows are accepted as legacy aliases for python')
95
95
  .option('--skills <suite>', 'Skill suite: core, minimal, or recommended:<type>')
96
96
  .option('--rules <preset>', 'Rules preset: recommended, minimal, or none')
@@ -1,5 +1,5 @@
1
1
  {
2
- "frameworkVersion": "1.1.183",
3
- "bundledAt": "2026-09-17T12:36:02.984Z",
4
- "bundledFrom": "9a9990c"
2
+ "frameworkVersion": "1.1.184",
3
+ "bundledAt": "2026-09-18T15:58:59.797Z",
4
+ "bundledFrom": "72909d7"
5
5
  }
@@ -13,6 +13,7 @@ from pathlib import Path
13
13
 
14
14
  from .launch_profiles import HeadlessLaunchProfile
15
15
  from .paths import RuntimePaths
16
+ from .platform_detection import PlatformSelectionError, parse_platform_selection
16
17
 
17
18
 
18
19
  @dataclass(frozen=True)
@@ -168,21 +169,23 @@ def _normalize_platform(platform: str | None) -> str:
168
169
 
169
170
  def _cli_names_for_platform(platform: str | None) -> tuple[str, ...]:
170
171
  normalized = _normalize_platform(platform)
171
- if normalized == "codex":
172
- return ("codex",)
173
- if normalized == "claude":
174
- return ("claude",)
175
- if normalized == "codebuddy":
176
- return ("cbc",)
177
- if normalized == "pi":
178
- return ("pi",)
179
- if normalized == "cursor":
180
- return ("agent",)
181
- if normalized == "both":
182
- return ("claude", "cbc")
183
- if normalized == "all":
184
- return ("codex", "claude", "cbc", "pi", "agent")
185
- return ()
172
+ if not normalized:
173
+ return ()
174
+ try:
175
+ hosts = parse_platform_selection(normalized)
176
+ except PlatformSelectionError:
177
+ return ()
178
+ cli_by_host = {
179
+ "codex": ("codex",),
180
+ "claude": ("claude",),
181
+ "codebuddy": ("cbc",),
182
+ "pi": ("pi",),
183
+ "cursor": ("agent",),
184
+ }
185
+ names: list[str] = []
186
+ for host in hosts:
187
+ names.extend(cli_by_host[host])
188
+ return tuple(names)
186
189
 
187
190
 
188
191
  def _known_platform_from_cli(cli_command: str | None) -> str | None:
@@ -400,6 +403,18 @@ def _resolve_ai_client(paths: RuntimePaths, env: Mapping[str, str]) -> AIClientR
400
403
  (manifest_platform, "prizmkit-manifest:platform", "Installed PrizmKit platform"),
401
404
  (config_platform, "prizmkit-config:platform", "Configured PrizmKit platform"),
402
405
  ):
406
+ if not platform:
407
+ continue
408
+ try:
409
+ parse_platform_selection(platform)
410
+ except PlatformSelectionError as exc:
411
+ return AIClientResolution(
412
+ command=None,
413
+ platform=None,
414
+ source=f"unresolved:{source}",
415
+ precedence=AI_CLIENT_PRECEDENCE,
416
+ notes=(str(exc),),
417
+ )
403
418
  resolved = _cli_for_platform(platform, env)
404
419
  if resolved:
405
420
  return AIClientResolution(
@@ -4,11 +4,23 @@ from __future__ import annotations
4
4
 
5
5
  import json
6
6
  import os
7
+ import shutil
7
8
  from collections.abc import Mapping
8
9
  from dataclasses import dataclass
9
10
  from pathlib import Path
10
11
 
11
12
  SUPPORTED_PLATFORMS = ("claude", "codex", "codebuddy", "pi", "cursor")
13
+ PLATFORM_IDS = ("codebuddy", "claude", "codex", "pi", "cursor")
14
+ PLATFORM_INPUT_HELP = (
15
+ "codebuddy, claude, codex, pi, cursor, a comma-separated list of those, or all"
16
+ )
17
+ _CLI_BY_PLATFORM = {
18
+ "codebuddy": "cbc",
19
+ "claude": "claude",
20
+ "codex": "codex",
21
+ "pi": "pi",
22
+ "cursor": "agent",
23
+ }
12
24
 
13
25
 
14
26
  @dataclass(frozen=True)
@@ -117,6 +129,48 @@ def platform_from_command(command: object) -> str:
117
129
  return ""
118
130
 
119
131
 
132
+ class PlatformSelectionError(ValueError):
133
+ """Raised when a stored or supplied platform field cannot be parsed."""
134
+
135
+
136
+ def unknown_platform_message(platform: object) -> str:
137
+ return f'Unknown platform "{platform}". Expected {PLATFORM_INPUT_HELP}.'
138
+
139
+
140
+ def parse_platform_selection(platform: object) -> tuple[str, ...]:
141
+ """Parse a single host, comma-separated subset, or standalone all."""
142
+ if not isinstance(platform, str):
143
+ raise PlatformSelectionError(unknown_platform_message(platform))
144
+ trimmed = platform.strip()
145
+ if not trimmed:
146
+ raise PlatformSelectionError(unknown_platform_message(platform))
147
+ tokens = [part.strip() for part in trimmed.split(",")]
148
+ if any(not token for token in tokens):
149
+ raise PlatformSelectionError(unknown_platform_message(platform))
150
+ if "all" in tokens:
151
+ if len(tokens) != 1:
152
+ raise PlatformSelectionError(unknown_platform_message(platform))
153
+ return PLATFORM_IDS
154
+ if "both" in tokens or any(token not in PLATFORM_IDS for token in tokens):
155
+ raise PlatformSelectionError(unknown_platform_message(platform))
156
+ present = set(tokens)
157
+ return tuple(pid for pid in PLATFORM_IDS if pid in present)
158
+
159
+
160
+ def prompt_host_from_platform_field(value: object, env: Mapping[str, str] | None = None) -> str:
161
+ """Return one concrete prompt host from a legal platform field, or "" if absent."""
162
+ if not isinstance(value, str) or not value.strip():
163
+ return ""
164
+ hosts = parse_platform_selection(value)
165
+ if len(hosts) == 1:
166
+ return hosts[0]
167
+ which_path = None if env is None else env.get("PATH")
168
+ for host in hosts:
169
+ if shutil.which(_CLI_BY_PLATFORM[host], path=which_path):
170
+ return host
171
+ return hosts[0]
172
+
173
+
120
174
  def valid_prompt_platform(value: object) -> str:
121
175
  """Normalize a platform value for prompt path rendering."""
122
176
  platform = str(value or "").strip().lower()
@@ -146,7 +200,10 @@ def resolve_platform(project_root: str | Path, env: Mapping[str, str] | None = N
146
200
  detected = platform_from_command(config.get(key, ""))
147
201
  if detected:
148
202
  return PlatformResolution(detected, f"config:{key}")
149
- detected = valid_prompt_platform(config.get("platform", ""))
203
+ try:
204
+ detected = prompt_host_from_platform_field(config.get("platform", ""), environment)
205
+ except PlatformSelectionError as exc:
206
+ return PlatformResolution("", "unresolved:config:platform", (str(exc),))
150
207
  if detected:
151
208
  return PlatformResolution(detected, "config:platform")
152
209
 
@@ -156,7 +213,10 @@ def resolve_platform(project_root: str | Path, env: Mapping[str, str] | None = N
156
213
  detected = platform_from_command(value)
157
214
  if detected:
158
215
  return PlatformResolution(detected, f"manifest:{key}")
159
- detected = valid_prompt_platform(manifest.get("platform", ""))
216
+ try:
217
+ detected = prompt_host_from_platform_field(manifest.get("platform", ""), environment)
218
+ except PlatformSelectionError as exc:
219
+ return PlatformResolution("", "unresolved:manifest:platform", (str(exc),))
160
220
  if detected:
161
221
  return PlatformResolution(detected, "manifest:platform")
162
222
 
@@ -175,6 +175,33 @@ class TestPlatformExecutableAndPortHelpers:
175
175
  assert resolution.platform == "codebuddy"
176
176
  assert resolution.source == "environment:CODEBUDDY_CLI"
177
177
 
178
+ def test_manifest_platform_list_selects_a_concrete_prompt_host(self, tmp_path, monkeypatch):
179
+ from prizmkit_runtime.platform_detection import resolve_platform
180
+
181
+ project = tmp_path / "project"
182
+ (project / ".prizmkit").mkdir(parents=True)
183
+ (project / ".prizmkit" / "manifest.json").write_text(
184
+ json.dumps({"platform": "claude,cursor"}), encoding="utf-8"
185
+ )
186
+ monkeypatch.delenv("PRIZMKIT_PLATFORM", raising=False)
187
+ resolution = resolve_platform(project, env={"PATH": ""})
188
+ assert resolution.platform == "claude"
189
+ assert resolution.source == "manifest:platform"
190
+
191
+ def test_manifest_both_platform_does_not_fall_through_to_filesystem(self, tmp_path, monkeypatch):
192
+ from prizmkit_runtime.platform_detection import resolve_platform
193
+
194
+ project = tmp_path / "project"
195
+ (project / ".prizmkit").mkdir(parents=True)
196
+ (project / ".prizmkit" / "manifest.json").write_text(
197
+ json.dumps({"platform": "both"}), encoding="utf-8"
198
+ )
199
+ (project / ".claude" / "commands").mkdir(parents=True)
200
+ monkeypatch.delenv("PRIZMKIT_PLATFORM", raising=False)
201
+ resolution = resolve_platform(project, env={"PATH": ""})
202
+ assert resolution.platform == ""
203
+ assert resolution.source == "unresolved:manifest:platform"
204
+
178
205
  def test_executable_check_and_version_use_shutil_and_direct_subprocess(self, tmp_path):
179
206
  executable = tmp_path / "tool.py"
180
207
  executable.write_text("#!/usr/bin/env python3\nprint('tool 1.2.3')\n", encoding="utf-8")
@@ -339,6 +339,54 @@ def test_runtime_config_matches_canonical_ai_cli_precedence(tmp_path):
339
339
  assert legacy_alias.source == "environment:CODEBUDDY_CLI"
340
340
 
341
341
 
342
+ def test_runtime_config_resolves_comma_separated_manifest_platform(tmp_path, monkeypatch):
343
+ import prizmkit_runtime.config as runtime_config
344
+ from prizmkit_runtime.config import resolve_ai_client
345
+ from prizmkit_runtime.paths import resolve_runtime_paths
346
+
347
+ project = tmp_path / "project"
348
+ pipeline = project / ".prizmkit" / "dev-pipeline"
349
+ pipeline.mkdir(parents=True)
350
+ (project / ".prizmkit" / "manifest.json").write_text(
351
+ json.dumps({"platform": "claude,cursor"}), encoding="utf-8"
352
+ )
353
+ paths = resolve_runtime_paths(pipeline_root=pipeline)
354
+ monkeypatch.setattr(
355
+ runtime_config.shutil,
356
+ "which",
357
+ lambda name, path=None: "/tools/claude" if name == "claude" else None,
358
+ )
359
+
360
+ resolved = resolve_ai_client(paths, env={"PATH": "/tools"})
361
+ assert resolved.command == "claude"
362
+ assert resolved.platform == "claude"
363
+ assert resolved.source == "prizmkit-manifest:platform"
364
+
365
+
366
+ def test_runtime_config_rejects_legacy_both_manifest_without_path_fallback(tmp_path, monkeypatch):
367
+ import prizmkit_runtime.config as runtime_config
368
+ from prizmkit_runtime.config import resolve_ai_client
369
+ from prizmkit_runtime.paths import resolve_runtime_paths
370
+
371
+ project = tmp_path / "project"
372
+ pipeline = project / ".prizmkit" / "dev-pipeline"
373
+ pipeline.mkdir(parents=True)
374
+ (project / ".prizmkit" / "manifest.json").write_text(
375
+ json.dumps({"platform": "both"}), encoding="utf-8"
376
+ )
377
+ paths = resolve_runtime_paths(pipeline_root=pipeline)
378
+ monkeypatch.setattr(
379
+ runtime_config.shutil,
380
+ "which",
381
+ lambda name, path=None: "/tools/claude" if name == "claude" else None,
382
+ )
383
+
384
+ rejected = resolve_ai_client(paths, env={"PATH": "/tools"})
385
+ assert rejected.command is None
386
+ assert rejected.source == "unresolved:prizmkit-manifest:platform"
387
+ assert "both" in rejected.notes[0]
388
+
389
+
342
390
  def test_runtime_config_resolves_custom_ai_cli_launch_profile(tmp_path):
343
391
  from prizmkit_runtime.config import RuntimeConfigError, load_runtime_config
344
392
  from prizmkit_runtime.paths import resolve_runtime_paths
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.1.183",
2
+ "version": "1.1.184",
3
3
  "skills": {
4
4
  "prizmkit": {
5
5
  "description": "Framework introduction and navigation for the formal single-requirement lifecycle, project initialization, Prizm docs, and independent deployment.",
@@ -154,7 +154,7 @@ Before questions, check optional context files (never block if absent):
154
154
  - `.prizmkit/config.json` (existing stack preferences and detected tech stack)
155
155
  - `.prizmkit/plans/project-brief.md` (project context from app-planner, if available)
156
156
  - existing `.prizmkit/plans/feature-list.json` (required for incremental mode; inspect it only through the bounded commands below)
157
- - Platform instruction file: use the `platform` field in `.prizmkit/manifest.json` as source of truth when present (`codex` → `AGENTS.md`, `cursor` → existing user-owned `AGENTS.md` when present, `claude` → `CLAUDE.md`, `codebuddy` → `CODEBUDDY.md`, `all` → read every matching file). Legacy manifests may contain `both`; treat it as read-only compatibility and read `CLAUDE.md` plus `CODEBUDDY.md` only when encountered.
157
+ - Platform instruction file: use the `platform` field in `.prizmkit/manifest.json` as source of truth when present (`codex` → `AGENTS.md`, `cursor` → existing user-owned `AGENTS.md` when present, `claude` → `CLAUDE.md`, `codebuddy` → `CODEBUDDY.md`). A comma-separated list selects those hosts; the five-name form or an older stored `all` means read every matching file. `both` is not a supported alias.
158
158
  - If `.prizmkit/prizm-docs/root.prizm` is absent and the project has existing source code, scan the directory structure to understand the codebase layout:
159
159
  ```bash
160
160
  find . -maxdepth 2 -type d \
@@ -20,13 +20,13 @@ Handles re-init without losing user edits:
20
20
  | Field | Type | Description |
21
21
  |-------|------|-------------|
22
22
  | `adoption_mode` | string | `"passive"` \| `"advisory"` \| `"active"` |
23
- | `platform` | string | Installed payload metadata: `"codebuddy"` \| `"claude"` \| `"codex"` \| `"pi"` \| `"cursor"` \| `"all"`. It records installation, not a canonical behavior allowlist. |
23
+ | `platform` | string | Installed host metadata: a single id (`codebuddy`, `claude`, `codex`, `pi`, `cursor`), a canonical comma-separated subset such as `claude,cursor`, or the five-name form `codebuddy,claude,codex,pi,cursor`. It records installation, not a canonical behavior allowlist. Input alias `all` expands to the five names on write. |
24
24
  | `tech_stack` | object | Detected or user-provided tech stack |
25
25
  | `tech_stack._auto_detected` | boolean | `true` if auto-detected, `false` if user-provided |
26
26
  | `detected_layers` | string[] | Development layers observed in the project. Written by prizmkit-init Phase 4.5. Values: `frontend` / `backend` / `database` / `mobile`. Empty only when no layers are observed. Always refreshed from code and never cleared by rule-adoption choices. |
27
27
  | `enabled_rule_profiles` | string[] | Rule profiles the user explicitly enabled. This is independent from `detected_layers`; an empty array means no custom profile is enabled, not that the project has no detected layers. |
28
28
 
29
- Legacy manifests may still contain `both` for read-only migration compatibility. New config writes must use `codebuddy`, `claude`, `codex`, `pi`, `cursor`, or `all`.
29
+ New writes must use a single host id, a canonical comma-separated subset, or the five concrete names. `all` is an installer input alias only. `both` is not a supported value.
30
30
 
31
31
  ## Examples
32
32
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prizmkit",
3
- "version": "1.1.183",
3
+ "version": "1.1.184",
4
4
  "description": "Create a new PrizmKit-powered project with clean initialization — no framework dev files, just what you need.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/config.js CHANGED
@@ -52,7 +52,7 @@ import {
52
52
  selectRulesPreset,
53
53
  confirmPipeline,
54
54
  } from './prompts.js';
55
- import { isKnownPlatform, platformLabel, privateProjectMemoryFile, projectMemoryFile, resolvePayloadPlatforms } from './platforms.js';
55
+ import { canonicalizePlatformSelection, isKnownPlatform, platformLabel, privateProjectMemoryFile, projectMemoryFile, resolvePayloadPlatforms, uniquePlatforms, unknownPlatformMessage } from './platforms.js';
56
56
  import { normalizeRuntime, runtimeLabel } from './runtimes.js';
57
57
  import { applyAiCliLaunchToConfig, resolveAiCliLaunchSelection, storedAiCliLaunch } from './ai-cli-launch.js';
58
58
 
@@ -130,15 +130,9 @@ async function detectInstalledPlatforms(projectRoot) {
130
130
  const hasCodex = await hasPlatformFiles(path.join(projectRoot, '.agents', 'skills'));
131
131
  const hasPi = await hasPlatformFiles(path.join(projectRoot, '.pi', 'skills'));
132
132
  const hasCursor = await hasPlatformFiles(path.join(projectRoot, '.cursor', 'skills'));
133
- const detected = [hasClaude && 'claude', hasCodeBuddy && 'codebuddy', hasCodex && 'codex', hasPi && 'pi', hasCursor && 'cursor'].filter(Boolean);
134
-
135
- if (detected.length > 1) return detected.length === 2 && hasClaude && hasCodeBuddy ? 'both' : 'all';
136
- if (hasCursor) return 'cursor';
137
- if (hasPi) return 'pi';
138
- if (hasCodex) return 'codex';
139
- if (hasCodeBuddy) return 'codebuddy';
140
- if (hasClaude) return 'claude';
141
- return null;
133
+ const detected = [hasCodeBuddy && 'codebuddy', hasClaude && 'claude', hasCodex && 'codex', hasPi && 'pi', hasCursor && 'cursor'].filter(Boolean);
134
+ if (detected.length === 0) return null;
135
+ return uniquePlatforms(detected).join(',');
142
136
  }
143
137
 
144
138
  function getProjectMemoryFile(platform) {
@@ -463,7 +457,10 @@ export async function runConfig(directory, options = {}) {
463
457
  // Existing manifests are the source of truth. Filesystem detection is only a
464
458
  // legacy fallback for manifests created before platform was recorded.
465
459
  const detectedPlatformRaw = oldManifest.platform || await detectInstalledPlatforms(projectRoot) || 'claude';
466
- const detectedPlatform = detectedPlatformRaw === 'both' ? 'all' : detectedPlatformRaw;
460
+ if (!isKnownPlatform(detectedPlatformRaw)) {
461
+ throw new Error(unknownPlatformMessage(detectedPlatformRaw));
462
+ }
463
+ const detectedPlatform = canonicalizePlatformSelection(detectedPlatformRaw);
467
464
 
468
465
  const rawManifestRuntime = oldManifest.runtime;
469
466
  const normalizedManifestRuntime = normalizeRuntime(rawManifestRuntime);
@@ -481,7 +478,7 @@ export async function runConfig(directory, options = {}) {
481
478
  };
482
479
 
483
480
  if (options.platform !== undefined && !isKnownPlatform(options.platform)) {
484
- throw new Error(`Unknown platform "${options.platform}". Expected codebuddy, claude, codex, pi, cursor, or all.`);
481
+ throw new Error(unknownPlatformMessage(options.platform));
485
482
  }
486
483
 
487
484
  // Display current config
@@ -559,8 +556,9 @@ export async function runConfig(directory, options = {}) {
559
556
  }
560
557
 
561
558
  if (!isKnownPlatform(newConfig.platform)) {
562
- throw new Error(`Unknown platform "${newConfig.platform}". Expected codebuddy, claude, codex, pi, cursor, or all.`);
559
+ throw new Error(unknownPlatformMessage(newConfig.platform));
563
560
  }
561
+ newConfig.platform = canonicalizePlatformSelection(newConfig.platform);
564
562
 
565
563
  // ── Phase 3: COMPUTE DIFF ────────────────────────────────────────────────
566
564
 
package/src/index.js CHANGED
@@ -17,7 +17,7 @@ import { loadMetadata } from './metadata.js';
17
17
  import { platformLabel } from './platforms.js';
18
18
  import { normalizeRuntime, runtimeLabel } from './runtimes.js';
19
19
  import { resolveAiCliLaunchSelection } from './ai-cli-launch.js';
20
- import { selectAiCliLaunch } from './prompts.js';
20
+ import { selectAiCliLaunch, selectPlatform } from './prompts.js';
21
21
 
22
22
  export { runUpgrade } from './upgrade.js';
23
23
 
@@ -94,37 +94,8 @@ export async function runScaffold(directory, options) {
94
94
  // 1. 统一 Python runtime(旧 runtime 参数仅作为兼容别名归一)
95
95
  const runtime = normalizeRuntime(options.runtime);
96
96
 
97
- // 2. 选择平台(控制安装的目录结构)
98
- const platform = await select({
99
- message: '选择目标平台 (决定安装的目录结构):',
100
- choices: [
101
- {
102
- name: `CodeBuddy (.codebuddy/)${detected.cbc ? chalk.green(' ← 已检测到 cbc') : ''}`,
103
- value: 'codebuddy',
104
- },
105
- {
106
- name: `Claude Code (.claude/)${(detected.claude || detected.claudeInternal) ? chalk.green(' ← 已检测到') : ''}`,
107
- value: 'claude',
108
- },
109
- {
110
- name: `Codex (AGENTS.md + .agents/skills + .codex/)${detected.codex ? chalk.green(' ← 已检测到 codex') : ''}`,
111
- value: 'codex',
112
- },
113
- {
114
- name: `Pi (.pi/skills + .pi/APPEND_SYSTEM.md)${detected.pi ? chalk.green(' ← 已检测到 pi') : ''}`,
115
- value: 'pi',
116
- },
117
- {
118
- name: `Cursor (.cursor/skills + .cursor/rules + .cursor/hooks.json)${detected.cursor ? chalk.green(' ← 已验证 agent') : ''}`,
119
- value: 'cursor',
120
- },
121
- {
122
- name: '同时安装全部平台',
123
- value: 'all',
124
- },
125
- ],
126
- default: detected.suggested,
127
- });
97
+ // 2. 选择平台(控制安装的目录结构,可多选)
98
+ const platform = await selectPlatform('', detected);
128
99
 
129
100
  // 2.5. AI CLI 命令配置(独立于平台,决定实际运行的可执行命令)
130
101
  const aiCliSelection = await selectAiCliLaunch('', detected);
package/src/platforms.js CHANGED
@@ -2,15 +2,55 @@ import path from 'path';
2
2
  import { isBuiltInAiCli } from './ai-cli-launch.js';
3
3
 
4
4
  export const PLATFORM_IDS = ['codebuddy', 'claude', 'codex', 'pi', 'cursor'];
5
- export const PLATFORM_GROUPS = {
6
- all: PLATFORM_IDS,
7
- };
8
- const LEGACY_PLATFORM_GROUPS = {
9
- both: ['codebuddy', 'claude'],
5
+ export const PLATFORM_INPUT_HELP = 'codebuddy, claude, codex, pi, cursor, a comma-separated list of those, or all';
6
+ export const CANONICAL_ALL_PLATFORMS = PLATFORM_IDS.join(',');
7
+
8
+ const HOST_LABELS = {
9
+ codebuddy: 'CodeBuddy',
10
+ claude: 'Claude Code',
11
+ codex: 'Codex',
12
+ pi: 'Pi',
13
+ cursor: 'Cursor',
10
14
  };
11
15
 
16
+ export function unknownPlatformMessage(platform) {
17
+ return `Unknown platform "${platform}". Expected ${PLATFORM_INPUT_HELP}.`;
18
+ }
19
+
20
+ export function parsePlatformSelection(platform) {
21
+ if (typeof platform !== 'string') {
22
+ throw new Error(unknownPlatformMessage(platform));
23
+ }
24
+ const trimmed = platform.trim();
25
+ if (!trimmed) {
26
+ throw new Error(unknownPlatformMessage(platform));
27
+ }
28
+
29
+ const tokens = trimmed.split(',').map(part => part.trim());
30
+ if (tokens.some(token => !token)) {
31
+ throw new Error(unknownPlatformMessage(platform));
32
+ }
33
+
34
+ if (tokens.includes('all')) {
35
+ if (tokens.length !== 1) {
36
+ throw new Error(unknownPlatformMessage(platform));
37
+ }
38
+ return [...PLATFORM_IDS];
39
+ }
40
+
41
+ if (tokens.includes('both') || tokens.some(token => !PLATFORM_IDS.includes(token))) {
42
+ throw new Error(unknownPlatformMessage(platform));
43
+ }
44
+
45
+ return PLATFORM_IDS.filter(id => tokens.includes(id));
46
+ }
47
+
48
+ export function canonicalizePlatformSelection(platform) {
49
+ return parsePlatformSelection(platform).join(',');
50
+ }
51
+
12
52
  export function expandPlatforms(platform) {
13
- return PLATFORM_GROUPS[platform] || LEGACY_PLATFORM_GROUPS[platform] || [platform];
53
+ return parsePlatformSelection(platform);
14
54
  }
15
55
 
16
56
  export function platformFromAiCli(aiCli) {
@@ -35,7 +75,8 @@ export function platformFromAiCli(aiCli) {
35
75
  }
36
76
 
37
77
  export function uniquePlatforms(platforms) {
38
- return [...new Set(platforms.filter(p => PLATFORM_IDS.includes(p)))];
78
+ const present = new Set((platforms || []).filter(p => PLATFORM_IDS.includes(p)));
79
+ return PLATFORM_IDS.filter(id => present.has(id));
39
80
  }
40
81
 
41
82
  export function resolvePayloadPlatforms(platform, aiCli = '') {
@@ -50,18 +91,23 @@ export function payloadPlatformLabel(platform, aiCli = '') {
50
91
  }
51
92
 
52
93
  export function isKnownPlatform(platform) {
53
- return PLATFORM_IDS.includes(platform) || Object.hasOwn(PLATFORM_GROUPS, platform);
94
+ try {
95
+ parsePlatformSelection(platform);
96
+ return true;
97
+ } catch {
98
+ return false;
99
+ }
54
100
  }
55
101
 
56
102
  export function platformLabel(platform) {
57
- if (platform === 'both') return 'legacy codebuddy/claude group';
58
- if (platform === 'all') return 'All platforms (CodeBuddy, Claude Code, Codex, Pi, Cursor)';
59
- if (platform === 'codebuddy') return 'CodeBuddy';
60
- if (platform === 'claude') return 'Claude Code';
61
- if (platform === 'codex') return 'Codex';
62
- if (platform === 'pi') return 'Pi';
63
- if (platform === 'cursor') return 'Cursor';
64
- return platform;
103
+ if (typeof platform === 'string' && HOST_LABELS[platform]) {
104
+ return HOST_LABELS[platform];
105
+ }
106
+ try {
107
+ return parsePlatformSelection(platform).map(id => HOST_LABELS[id]).join(' + ');
108
+ } catch {
109
+ return platform;
110
+ }
65
111
  }
66
112
 
67
113
  export function projectMemoryFile(platform) {
package/src/prompts.js CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  import { select, confirm, checkbox, input } from '@inquirer/prompts';
7
7
  import chalk from 'chalk';
8
- import { platformLabel } from './platforms.js';
8
+ import { canonicalizePlatformSelection, parsePlatformSelection, PLATFORM_IDS } from './platforms.js';
9
9
  import {
10
10
  formatCliArgsForPrompt,
11
11
  isCustomAiCli,
@@ -14,7 +14,7 @@ import {
14
14
  tokenizeCliArgs,
15
15
  } from './ai-cli-launch.js';
16
16
 
17
- let selectPlatformPrompt = select;
17
+ let selectPlatformPrompt = checkbox;
18
18
  let selectAiCliPrompt = select;
19
19
  let inputPrompt = input;
20
20
 
@@ -37,53 +37,55 @@ export function __resetAiCliPromptsForTests() {
37
37
  }
38
38
 
39
39
  /**
40
- * Select target platform (codebuddy, claude, codex, pi, cursor, or all).
40
+ * Select target platforms (codebuddy, claude, codex, pi, cursor).
41
41
  * @param {string} currentPlatform - current platform value
42
42
  * @param {Object} detected - detected environment info (e.g., { cbc: true, claude: false })
43
- * @returns {Promise<string>}
43
+ * @returns {Promise<string>} canonical comma-separated platform ids
44
44
  */
45
45
  export async function selectPlatform(currentPlatform, detected = {}) {
46
- const selectablePlatforms = ['codebuddy', 'claude', 'codex', 'pi', 'cursor', 'all'];
47
- const detectedDefault = selectablePlatforms.includes(detected.suggested)
48
- ? detected.suggested
49
- : 'claude';
50
- let defaultPlatform = detectedDefault;
51
- if (currentPlatform === 'both') {
52
- defaultPlatform = 'all';
53
- } else if (selectablePlatforms.includes(currentPlatform)) {
54
- defaultPlatform = currentPlatform;
55
- }
56
- const platform = await selectPlatformPrompt({
57
- message: '选择目标平台 (决定安装的目录结构):',
58
- choices: [
59
- {
60
- name: `CodeBuddy (.codebuddy/)${detected.cbc ? chalk.green(' ← 已检测到 cbc') : ''}`,
61
- value: 'codebuddy',
62
- },
63
- {
64
- name: `Claude Code (.claude/)${(detected.claude || detected.claudeInternal) ? chalk.green(' ← 已检测到') : ''}`,
65
- value: 'claude',
66
- },
67
- {
68
- name: `Codex (AGENTS.md + .agents/skills + .codex/)${detected.codex ? chalk.green(' ← 已检测到 codex') : ''}`,
69
- value: 'codex',
70
- },
71
- {
72
- name: `Pi (.pi/skills + .pi/APPEND_SYSTEM.md)${detected.pi ? chalk.green(' ← 已检测到 pi') : ''}`,
73
- value: 'pi',
74
- },
75
- {
76
- name: `Cursor (.cursor/skills + .cursor/rules + .cursor/hooks.json)${detected.cursor ? chalk.green(' ← 已检测到 agent') : ''}`,
77
- value: 'cursor',
78
- },
79
- {
80
- name: `同时安装全部平台 (${platformLabel('all')})`,
81
- value: 'all',
82
- },
83
- ],
84
- default: defaultPlatform,
46
+ const checked = currentPlatform
47
+ ? parsePlatformSelection(currentPlatform)
48
+ : [];
49
+ const platformChoices = [
50
+ {
51
+ id: 'codebuddy',
52
+ name: `CodeBuddy (.codebuddy/)${detected.cbc ? chalk.green(' ← 已检测到 cbc') : ''}`,
53
+ },
54
+ {
55
+ id: 'claude',
56
+ name: `Claude Code (.claude/)${(detected.claude || detected.claudeInternal) ? chalk.green(' ← 已检测到') : ''}`,
57
+ },
58
+ {
59
+ id: 'codex',
60
+ name: `Codex (AGENTS.md + .agents/skills + .codex/)${detected.codex ? chalk.green(' ← 已检测到 codex') : ''}`,
61
+ },
62
+ {
63
+ id: 'pi',
64
+ name: `Pi (.pi/skills + .pi/APPEND_SYSTEM.md)${detected.pi ? chalk.green(' ← 已检测到 pi') : ''}`,
65
+ },
66
+ {
67
+ id: 'cursor',
68
+ name: `Cursor (.cursor/skills + .cursor/rules + .cursor/hooks.json)${detected.cursor ? chalk.green(' ← 已检测到 agent') : ''}`,
69
+ },
70
+ ];
71
+ const selected = await selectPlatformPrompt({
72
+ message: '选择目标平台 (决定安装的目录结构,可多选):',
73
+ choices: platformChoices.map(choice => ({
74
+ name: choice.name,
75
+ value: choice.id,
76
+ checked: checked.includes(choice.id),
77
+ })),
78
+ required: true,
79
+ validate: value => (value?.length ? true : '请至少选择一个平台'),
85
80
  });
86
- return platform;
81
+ if (!Array.isArray(selected) || selected.length === 0) {
82
+ throw new Error('请至少选择一个平台');
83
+ }
84
+ const selectedIds = selected.filter(id => PLATFORM_IDS.includes(id));
85
+ if (selectedIds.length === 0) {
86
+ throw new Error('请至少选择一个平台');
87
+ }
88
+ return canonicalizePlatformSelection(selectedIds.join(','));
87
89
  }
88
90
 
89
91
  /**
package/src/scaffold.js CHANGED
@@ -26,7 +26,7 @@ import {
26
26
  } from './metadata.js';
27
27
  import { generateGitignore } from './gitignore-template.js';
28
28
  import { buildManifest, readManifestForLifecycle, writeManifest } from './manifest.js';
29
- import { defaultCliForPlatform, expandPlatforms, isKnownPlatform, nativeSkillRoot, payloadSkillRoots, platformLabel, privateProjectMemoryFile, privateProjectMemoryFiles, projectMemoryFile, resolvePayloadPlatforms } from './platforms.js';
29
+ import { canonicalizePlatformSelection, defaultCliForPlatform, expandPlatforms, isKnownPlatform, nativeSkillRoot, payloadSkillRoots, platformLabel, privateProjectMemoryFile, privateProjectMemoryFiles, projectMemoryFile, resolvePayloadPlatforms, unknownPlatformMessage } from './platforms.js';
30
30
  import { normalizeRuntime, runtimeLabel } from './runtimes.js';
31
31
  import { applyAiCliLaunchToConfig, resolveAiCliLaunchSelection } from './ai-cli-launch.js';
32
32
 
@@ -1725,7 +1725,7 @@ const SCAFFOLD_CONFIG_FIELDS = new Set([
1725
1725
  /**
1726
1726
  * 执行纯净安装
1727
1727
  * @param {Object} config
1728
- * @param {string} config.platform - 'codebuddy' | 'claude' | 'codex' | 'pi' | 'cursor' | 'all'
1728
+ * @param {string} config.platform - 'codebuddy' | 'claude' | 'codex' | 'pi' | 'cursor' | 'all' | comma-separated subset
1729
1729
  * @param {string} [config.runtime] - 'python' (legacy aliases accepted: 'unix' | 'windows')
1730
1730
  * @param {string} config.skills - 'core' | 'minimal' | 'recommended:<type>'
1731
1731
  * @param {boolean} config.pipeline - 是否安装 dev-pipeline
@@ -1756,10 +1756,11 @@ export async function scaffold(config) {
1756
1756
  });
1757
1757
  const resolvedAiCli = launchSelection.aiCli;
1758
1758
  if (!isKnownPlatform(platform)) {
1759
- throw new Error(`Unknown platform "${platform}". Expected codebuddy, claude, codex, pi, cursor, or all.`);
1759
+ throw new Error(unknownPlatformMessage(platform));
1760
1760
  }
1761
- const platforms = expandPlatforms(platform);
1762
- const payloadPlatforms = resolvePayloadPlatforms(platform, resolvedAiCli);
1761
+ const canonicalPlatform = canonicalizePlatformSelection(platform);
1762
+ const platforms = expandPlatforms(canonicalPlatform);
1763
+ const payloadPlatforms = resolvePayloadPlatforms(canonicalPlatform, resolvedAiCli);
1763
1764
 
1764
1765
  if (dryRun) {
1765
1766
  console.log(chalk.yellow('\n [DRY RUN] 预览将要安装的内容:\n'));
@@ -1854,7 +1855,7 @@ export async function scaffold(config) {
1854
1855
  const skillDef = knownSkills.find(s => s.name === name);
1855
1856
  if (skillDef) {
1856
1857
  try {
1857
- await installExternalSkill(skillDef, platform, projectRoot, dryRun, resolvedAiCli);
1858
+ await installExternalSkill(skillDef, canonicalPlatform, projectRoot, dryRun, resolvedAiCli);
1858
1859
  console.log(chalk.green(` ✓ ${name} (external)`));
1859
1860
  } catch (e) {
1860
1861
  console.log(chalk.yellow(` ⚠ ${name} 安装失败,跳过: ${e.message}`));
@@ -1862,7 +1863,7 @@ export async function scaffold(config) {
1862
1863
  }
1863
1864
  }
1864
1865
  if (!dryRun) {
1865
- await cleanExternalSkillArtifacts(projectRoot, platform, resolvedAiCli);
1866
+ await cleanExternalSkillArtifacts(projectRoot, canonicalPlatform, resolvedAiCli);
1866
1867
  }
1867
1868
  }
1868
1869
 
@@ -1871,7 +1872,7 @@ export async function scaffold(config) {
1871
1872
  if (playwrightCli) {
1872
1873
  activeExtras.push('playwright-cli');
1873
1874
  console.log(chalk.blue(` ${EXTRAS_REGISTRY['playwright-cli'].label}:`));
1874
- await installPlaywrightCli(projectRoot, dryRun, { platform, aiCli: resolvedAiCli });
1875
+ await installPlaywrightCli(projectRoot, dryRun, { platform: canonicalPlatform, aiCli: resolvedAiCli });
1875
1876
  console.log('');
1876
1877
  }
1877
1878
  if (openCli) {
@@ -1910,7 +1911,7 @@ export async function scaffold(config) {
1910
1911
 
1911
1912
  const manifest = buildManifest({
1912
1913
  version: scaffoldPkg.version,
1913
- platform,
1914
+ platform: canonicalPlatform,
1914
1915
  runtime,
1915
1916
  suite: skills,
1916
1917
  skills: skillList,
package/src/upgrade.js CHANGED
@@ -32,7 +32,7 @@ import {
32
32
  removeRetiredAgentTeamArtifacts,
33
33
  EXTRAS_REGISTRY,
34
34
  } from './scaffold.js';
35
- import { expandPlatforms, PLATFORM_IDS, platformLabel, resolvePayloadPlatforms, uniquePlatforms } from './platforms.js';
35
+ import { canonicalizePlatformSelection, expandPlatforms, isKnownPlatform, PLATFORM_IDS, platformLabel, resolvePayloadPlatforms, uniquePlatforms, unknownPlatformMessage } from './platforms.js';
36
36
  import { normalizeRuntime, runtimeLabel } from './runtimes.js';
37
37
 
38
38
  const __dirname = dirname(fileURLToPath(import.meta.url));
@@ -159,9 +159,8 @@ export function previousPayloadPlatformsFromManifest(manifest) {
159
159
  if (Array.isArray(manifest.files?.payloadPlatforms)) {
160
160
  listed.push(...manifest.files.payloadPlatforms);
161
161
  }
162
- if (manifest.platform) {
163
- const group = manifest.platform === 'both' ? 'all' : manifest.platform;
164
- listed.push(...expandPlatforms(group));
162
+ if (manifest.platform && isKnownPlatform(manifest.platform)) {
163
+ listed.push(...expandPlatforms(manifest.platform));
165
164
  }
166
165
  return uniquePlatforms(listed);
167
166
  }
@@ -329,7 +328,10 @@ export async function runUpgrade(directory, options = {}) {
329
328
  // (e.g. legacy installs before manifest tracked platform).
330
329
  let platform;
331
330
  if (oldManifest?.platform) {
332
- platform = oldManifest.platform === 'both' ? 'all' : oldManifest.platform;
331
+ if (!isKnownPlatform(oldManifest.platform)) {
332
+ throw new Error(unknownPlatformMessage(oldManifest.platform));
333
+ }
334
+ platform = canonicalizePlatformSelection(oldManifest.platform);
333
335
  } else {
334
336
  // Fallback: detect from filesystem for legacy manifests without platform field
335
337
  const hasPlatformFiles = async (dir) => {
@@ -354,9 +356,9 @@ export async function runUpgrade(directory, options = {}) {
354
356
  hasCursor && 'cursor',
355
357
  ].filter(Boolean);
356
358
 
357
- if (detectedPlatforms.length > 1) platform = 'all';
358
- else if (detectedPlatforms.length === 1) platform = detectedPlatforms[0];
359
- else platform = 'claude'; // ultimate fallback
359
+ platform = detectedPlatforms.length
360
+ ? uniquePlatforms(detectedPlatforms).join(',')
361
+ : 'claude';
360
362
  }
361
363
 
362
364
  const newSkillList = await resolveSkillList(suite);