prizmkit 1.1.183 → 1.1.185
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/bin/create-prizmkit.js +2 -2
- package/bundled/VERSION.json +3 -3
- package/bundled/dev-pipeline/prizmkit_runtime/config.py +30 -15
- package/bundled/dev-pipeline/prizmkit_runtime/platform_detection.py +62 -2
- package/bundled/dev-pipeline/tests/test_runtime_helper.py +27 -0
- package/bundled/dev-pipeline/tests/test_unified_cli.py +48 -0
- package/bundled/skills/_metadata.json +1 -1
- package/bundled/skills/feature-planner/SKILL.md +1 -1
- package/bundled/skills/prizmkit-init/references/config-schema.md +2 -2
- package/package.json +1 -1
- package/src/config.js +11 -13
- package/src/gitignore-template.js +40 -9
- package/src/index.js +3 -32
- package/src/platforms.js +62 -16
- package/src/prompts.js +46 -44
- package/src/scaffold.js +36 -38
- package/src/upgrade.js +10 -8
package/bin/create-prizmkit.js
CHANGED
|
@@ -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')
|
package/bundled/VERSION.json
CHANGED
|
@@ -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
|
|
172
|
-
return (
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
return (
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
@@ -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
|
|
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
|
|
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
|
-
|
|
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
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 = [
|
|
134
|
-
|
|
135
|
-
|
|
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
|
-
|
|
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(
|
|
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(
|
|
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
|
|
|
@@ -1,19 +1,50 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Generate
|
|
2
|
+
* Generate install-time gitignore text.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Install appends the exact `.prizmkit/*` line and any explicit private
|
|
5
|
+
* host-memory filenames. Upgrade and config must not write `.gitignore`.
|
|
6
|
+
* Cleanup removes only private host-memory entries.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
const FRAMEWORK_HEADER = '# PrizmKit';
|
|
10
|
+
const FRAMEWORK_ENTRY = '.prizmkit/*';
|
|
11
|
+
const PRIVATE_MEMORY_HEADER = '# PrizmKit private host memory';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {string[] | undefined} values
|
|
15
|
+
* @returns {string[]}
|
|
16
|
+
*/
|
|
17
|
+
function uniqueGitignoreEntries(values) {
|
|
18
|
+
return Array.isArray(values) ? [...new Set(values.filter(Boolean))] : [];
|
|
19
|
+
}
|
|
20
|
+
|
|
9
21
|
/**
|
|
10
22
|
* @param {Object} options - { privateMemoryFiles?: string[] }
|
|
11
23
|
* @returns {string}
|
|
12
24
|
*/
|
|
13
25
|
export function generateGitignore(options = {}) {
|
|
14
|
-
const privateMemoryFiles =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
26
|
+
const privateMemoryFiles = uniqueGitignoreEntries(options.privateMemoryFiles);
|
|
27
|
+
const lines = [FRAMEWORK_HEADER, FRAMEWORK_ENTRY];
|
|
28
|
+
if (privateMemoryFiles.length > 0) {
|
|
29
|
+
lines.push(PRIVATE_MEMORY_HEADER, ...privateMemoryFiles);
|
|
30
|
+
}
|
|
31
|
+
return lines.join('\n');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Sections appended independently so an existing private-memory header
|
|
36
|
+
* is not treated as the framework header.
|
|
37
|
+
*
|
|
38
|
+
* @param {Object} options - { privateMemoryFiles?: string[] }
|
|
39
|
+
* @returns {{ header: string, entries: string[] }[]}
|
|
40
|
+
*/
|
|
41
|
+
export function gitignoreSections(options = {}) {
|
|
42
|
+
const privateMemoryFiles = uniqueGitignoreEntries(options.privateMemoryFiles);
|
|
43
|
+
const sections = [
|
|
44
|
+
{ header: FRAMEWORK_HEADER, entries: [FRAMEWORK_ENTRY] },
|
|
45
|
+
];
|
|
46
|
+
if (privateMemoryFiles.length > 0) {
|
|
47
|
+
sections.push({ header: PRIVATE_MEMORY_HEADER, entries: privateMemoryFiles });
|
|
48
|
+
}
|
|
49
|
+
return sections;
|
|
19
50
|
}
|
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
|
|
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
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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 === '
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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 {
|
|
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 =
|
|
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
|
|
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
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
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
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* 全部使用 Copy 模式(不使用 symlink),项目完全独立于框架仓库。
|
|
5
5
|
* 通过 adapters 转换 core/ 资源为平台特定格式。
|
|
6
6
|
* 不安装框架开发文件(docs、tests、scripts 等)。
|
|
7
|
-
*
|
|
7
|
+
* 安装时追加精确的 `.prizmkit/*` 行和所选平台的私有记忆文件 ignore。
|
|
8
|
+
* upgrade 与 config 不写 `.gitignore`。
|
|
8
9
|
*/
|
|
9
10
|
|
|
10
11
|
import chalk from 'chalk';
|
|
@@ -24,9 +25,9 @@ import {
|
|
|
24
25
|
loadRulesMetadata,
|
|
25
26
|
getSkillCandidatePaths,
|
|
26
27
|
} from './metadata.js';
|
|
27
|
-
import { generateGitignore } from './gitignore-template.js';
|
|
28
|
+
import { generateGitignore, gitignoreSections } from './gitignore-template.js';
|
|
28
29
|
import { buildManifest, readManifestForLifecycle, writeManifest } from './manifest.js';
|
|
29
|
-
import { defaultCliForPlatform, expandPlatforms, isKnownPlatform, nativeSkillRoot, payloadSkillRoots, platformLabel, privateProjectMemoryFile, privateProjectMemoryFiles, projectMemoryFile, resolvePayloadPlatforms } from './platforms.js';
|
|
30
|
+
import { canonicalizePlatformSelection, defaultCliForPlatform, expandPlatforms, isKnownPlatform, nativeSkillRoot, payloadSkillRoots, platformLabel, privateProjectMemoryFile, privateProjectMemoryFiles, projectMemoryFile, resolvePayloadPlatforms, unknownPlatformMessage } from './platforms.js';
|
|
30
31
|
import { normalizeRuntime, runtimeLabel } from './runtimes.js';
|
|
31
32
|
import { applyAiCliLaunchToConfig, resolveAiCliLaunchSelection } from './ai-cli-launch.js';
|
|
32
33
|
|
|
@@ -1374,46 +1375,42 @@ export async function installPipeline(projectRoot, dryRun, options = {}) {
|
|
|
1374
1375
|
*/
|
|
1375
1376
|
export async function installGitignore(projectRoot, options = {}, dryRun) {
|
|
1376
1377
|
const targetPath = path.join(projectRoot, '.gitignore');
|
|
1377
|
-
const
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
});
|
|
1378
|
+
const sectionOptions = { privateMemoryFiles: options.privateMemoryFiles || [] };
|
|
1379
|
+
const templateContent = generateGitignore(sectionOptions);
|
|
1380
|
+
const sections = gitignoreSections(sectionOptions);
|
|
1381
1381
|
const existed = await fs.pathExists(targetPath);
|
|
1382
1382
|
|
|
1383
1383
|
if (dryRun) {
|
|
1384
|
-
|
|
1385
|
-
if (!existed) console.log(chalk.gray(' [dry-run] .gitignore (no managed private-memory entries)'));
|
|
1386
|
-
return;
|
|
1387
|
-
}
|
|
1388
|
-
console.log(chalk.gray(' [dry-run] .gitignore (private host memory only)'));
|
|
1384
|
+
console.log(chalk.gray(' [dry-run] .gitignore (.prizmkit/* and private host memory)'));
|
|
1389
1385
|
return;
|
|
1390
1386
|
}
|
|
1391
1387
|
|
|
1392
|
-
if (!
|
|
1393
|
-
|
|
1388
|
+
if (!existed) {
|
|
1389
|
+
await fs.writeFile(targetPath, `${templateContent}\n`);
|
|
1390
|
+
console.log(chalk.green(' ✓ .gitignore'));
|
|
1394
1391
|
return;
|
|
1395
1392
|
}
|
|
1396
1393
|
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1394
|
+
const current = await fs.readFile(targetPath, 'utf-8');
|
|
1395
|
+
const existingLines = new Set(current.split('\n').map(line => line.trim()));
|
|
1396
|
+
const chunks = [];
|
|
1397
|
+
let missingCount = 0;
|
|
1398
|
+
for (const section of sections) {
|
|
1399
|
+
const missing = section.entries.filter(line => !existingLines.has(line));
|
|
1400
|
+
if (missing.length === 0) continue;
|
|
1401
|
+
missingCount += missing.length;
|
|
1402
|
+
const header = existingLines.has(section.header) ? '' : `${section.header}\n`;
|
|
1403
|
+
chunks.push(header + missing.join('\n'));
|
|
1404
|
+
}
|
|
1402
1405
|
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
const managedHeader = '# PrizmKit private host memory';
|
|
1406
|
-
const header = existingLines.has(managedHeader) ? '' : `${managedHeader}\n`;
|
|
1407
|
-
await fs.appendFile(targetPath, separator + '\n' + header + missing.join('\n') + '\n');
|
|
1408
|
-
console.log(chalk.green(` ✓ .gitignore (added ${missing.length} entries)`));
|
|
1409
|
-
} else {
|
|
1410
|
-
console.log(chalk.green(' ✓ .gitignore (up-to-date)'));
|
|
1411
|
-
}
|
|
1406
|
+
if (missingCount === 0) {
|
|
1407
|
+
console.log(chalk.green(' ✓ .gitignore (up-to-date)'));
|
|
1412
1408
|
return;
|
|
1413
1409
|
}
|
|
1414
1410
|
|
|
1415
|
-
|
|
1416
|
-
|
|
1411
|
+
const separator = current.endsWith('\n') ? '' : '\n';
|
|
1412
|
+
await fs.appendFile(targetPath, `${separator}\n${chunks.join('\n')}\n`);
|
|
1413
|
+
console.log(chalk.green(` ✓ .gitignore (added ${missingCount} entries)`));
|
|
1417
1414
|
}
|
|
1418
1415
|
|
|
1419
1416
|
// ============================================================
|
|
@@ -1725,7 +1722,7 @@ const SCAFFOLD_CONFIG_FIELDS = new Set([
|
|
|
1725
1722
|
/**
|
|
1726
1723
|
* 执行纯净安装
|
|
1727
1724
|
* @param {Object} config
|
|
1728
|
-
* @param {string} config.platform - 'codebuddy' | 'claude' | 'codex' | 'pi' | 'cursor' | 'all'
|
|
1725
|
+
* @param {string} config.platform - 'codebuddy' | 'claude' | 'codex' | 'pi' | 'cursor' | 'all' | comma-separated subset
|
|
1729
1726
|
* @param {string} [config.runtime] - 'python' (legacy aliases accepted: 'unix' | 'windows')
|
|
1730
1727
|
* @param {string} config.skills - 'core' | 'minimal' | 'recommended:<type>'
|
|
1731
1728
|
* @param {boolean} config.pipeline - 是否安装 dev-pipeline
|
|
@@ -1756,10 +1753,11 @@ export async function scaffold(config) {
|
|
|
1756
1753
|
});
|
|
1757
1754
|
const resolvedAiCli = launchSelection.aiCli;
|
|
1758
1755
|
if (!isKnownPlatform(platform)) {
|
|
1759
|
-
throw new Error(
|
|
1756
|
+
throw new Error(unknownPlatformMessage(platform));
|
|
1760
1757
|
}
|
|
1761
|
-
const
|
|
1762
|
-
const
|
|
1758
|
+
const canonicalPlatform = canonicalizePlatformSelection(platform);
|
|
1759
|
+
const platforms = expandPlatforms(canonicalPlatform);
|
|
1760
|
+
const payloadPlatforms = resolvePayloadPlatforms(canonicalPlatform, resolvedAiCli);
|
|
1763
1761
|
|
|
1764
1762
|
if (dryRun) {
|
|
1765
1763
|
console.log(chalk.yellow('\n [DRY RUN] 预览将要安装的内容:\n'));
|
|
@@ -1854,7 +1852,7 @@ export async function scaffold(config) {
|
|
|
1854
1852
|
const skillDef = knownSkills.find(s => s.name === name);
|
|
1855
1853
|
if (skillDef) {
|
|
1856
1854
|
try {
|
|
1857
|
-
await installExternalSkill(skillDef,
|
|
1855
|
+
await installExternalSkill(skillDef, canonicalPlatform, projectRoot, dryRun, resolvedAiCli);
|
|
1858
1856
|
console.log(chalk.green(` ✓ ${name} (external)`));
|
|
1859
1857
|
} catch (e) {
|
|
1860
1858
|
console.log(chalk.yellow(` ⚠ ${name} 安装失败,跳过: ${e.message}`));
|
|
@@ -1862,7 +1860,7 @@ export async function scaffold(config) {
|
|
|
1862
1860
|
}
|
|
1863
1861
|
}
|
|
1864
1862
|
if (!dryRun) {
|
|
1865
|
-
await cleanExternalSkillArtifacts(projectRoot,
|
|
1863
|
+
await cleanExternalSkillArtifacts(projectRoot, canonicalPlatform, resolvedAiCli);
|
|
1866
1864
|
}
|
|
1867
1865
|
}
|
|
1868
1866
|
|
|
@@ -1871,7 +1869,7 @@ export async function scaffold(config) {
|
|
|
1871
1869
|
if (playwrightCli) {
|
|
1872
1870
|
activeExtras.push('playwright-cli');
|
|
1873
1871
|
console.log(chalk.blue(` ${EXTRAS_REGISTRY['playwright-cli'].label}:`));
|
|
1874
|
-
await installPlaywrightCli(projectRoot, dryRun, { platform, aiCli: resolvedAiCli });
|
|
1872
|
+
await installPlaywrightCli(projectRoot, dryRun, { platform: canonicalPlatform, aiCli: resolvedAiCli });
|
|
1875
1873
|
console.log('');
|
|
1876
1874
|
}
|
|
1877
1875
|
if (openCli) {
|
|
@@ -1910,7 +1908,7 @@ export async function scaffold(config) {
|
|
|
1910
1908
|
|
|
1911
1909
|
const manifest = buildManifest({
|
|
1912
1910
|
version: scaffoldPkg.version,
|
|
1913
|
-
platform,
|
|
1911
|
+
platform: canonicalPlatform,
|
|
1914
1912
|
runtime,
|
|
1915
1913
|
suite: skills,
|
|
1916
1914
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
358
|
-
|
|
359
|
-
|
|
359
|
+
platform = detectedPlatforms.length
|
|
360
|
+
? uniquePlatforms(detectedPlatforms).join(',')
|
|
361
|
+
: 'claude';
|
|
360
362
|
}
|
|
361
363
|
|
|
362
364
|
const newSkillList = await resolveSkillList(suite);
|