prizmkit 1.1.196 → 1.1.197
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 +0 -2
- package/bundled/VERSION.json +3 -3
- package/bundled/adapters/antigravity/assets/prizmkit-hook.cjs +1 -1
- package/bundled/adapters/antigravity/rules-adapter.js +1 -13
- package/bundled/adapters/claude/paths.js +0 -1
- package/bundled/adapters/codex/paths.js +0 -1
- package/bundled/adapters/codex/settings-adapter.js +1 -1
- package/bundled/adapters/cursor/assets/prizmkit-hook.cjs +1 -1
- package/bundled/adapters/cursor/rules-adapter.js +1 -13
- package/bundled/adapters/pi/paths.js +0 -1
- package/bundled/dev-pipeline/.env.example +2 -2
- package/bundled/dev-pipeline/README.md +6 -5
- package/bundled/dev-pipeline/assets/skill-subagent-integration.md +2 -2
- package/bundled/dev-pipeline/prizmkit_runtime/checkpoint_state.py +15 -25
- package/bundled/dev-pipeline/prizmkit_runtime/iterate.py +1 -69
- package/bundled/dev-pipeline/prizmkit_runtime/platform_detection.py +1 -114
- package/bundled/dev-pipeline/prizmkit_runtime/runner_models.py +2 -2
- package/bundled/dev-pipeline/prizmkit_runtime/runners.py +78 -0
- package/bundled/dev-pipeline/prizmkit_runtime/runtime_helper.py +4 -234
- package/bundled/dev-pipeline/prizmkit_runtime/status.py +0 -5
- package/bundled/dev-pipeline/prizmkit_runtime/stream_progress.py +9 -1
- package/bundled/dev-pipeline/scripts/feature_list_contract.py +0 -43
- package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +15 -76
- package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +9 -112
- package/bundled/dev-pipeline/scripts/init-bugfix-pipeline.py +0 -13
- package/bundled/dev-pipeline/scripts/init-pipeline.py +0 -1
- package/bundled/dev-pipeline/scripts/prompt_framework.py +0 -79
- package/bundled/dev-pipeline/scripts/status_common.py +150 -4
- package/bundled/dev-pipeline/scripts/update-bug-status.py +20 -2
- package/bundled/dev-pipeline/scripts/update-feature-status.py +20 -2
- package/bundled/dev-pipeline/scripts/utils.py +6 -0
- package/bundled/dev-pipeline/templates/bootstrap-prompt.md +4 -5
- package/bundled/dev-pipeline/templates/bootstrap-tier3.md +5 -101
- package/bundled/dev-pipeline/templates/bug-fix-list-schema.json +0 -35
- package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +4 -52
- package/bundled/dev-pipeline/templates/feature-list-schema.json +0 -25
- package/bundled/dev-pipeline/templates/iterate/evaluate-prompt.md +5 -16
- package/bundled/dev-pipeline/templates/iterate/evaluation-schema.json +1 -58
- package/bundled/dev-pipeline/templates/iterate/headless-plan-prompt.md +1 -12
- package/bundled/dev-pipeline/templates/sections/artifact-manifest.md +0 -1
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-commit-report.md +0 -1
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-diagnose-plan.md +2 -2
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-review.md +1 -1
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-test.md +1 -1
- package/bundled/dev-pipeline/templates/sections/bugfix-reminders.md +0 -2
- package/bundled/dev-pipeline/templates/sections/bugfix-session-context.md +0 -1
- package/bundled/dev-pipeline/templates/sections/bugfix-task-contract.md +0 -5
- package/bundled/dev-pipeline/templates/sections/checkpoint-system.md +1 -2
- package/bundled/dev-pipeline/templates/sections/feature-completion-summary.md +1 -1
- package/bundled/dev-pipeline/templates/sections/phase-commit-full.md +3 -3
- package/bundled/dev-pipeline/templates/sections/phase-prizmkit-test.md +3 -3
- package/bundled/dev-pipeline/templates/sections/phase-review-full.md +3 -3
- package/bundled/dev-pipeline/templates/sections/phase-specify-plan-full.md +1 -1
- package/bundled/dev-pipeline/templates/sections/retrospective.md +3 -3
- package/bundled/dev-pipeline/templates/sections/runtime-commit-handoff.md +1 -1
- package/bundled/rules/USAGE.md +5 -19
- package/bundled/rules/general/coding-baseline.md +2 -2
- package/bundled/rules/prizm/prizm-progressive-loading.md +2 -1
- package/bundled/skills/_metadata.json +4 -4
- package/bundled/skills/app-planner/SKILL.md +1 -1
- package/bundled/skills/app-planner/references/generated-plan-review.md +1 -1
- package/bundled/skills/app-planner/references/rules-configuration.md +6 -7
- package/bundled/skills/app-planner/scripts/validate-rules-configuration.py +2 -20
- package/bundled/skills/bug-planner/SKILL.md +5 -6
- package/bundled/skills/bug-planner/assets/bug-confirmation-template.md +1 -1
- package/bundled/skills/bug-planner/references/input-formats.md +2 -2
- package/bundled/skills/bug-planner/references/schema-validation.md +0 -1
- package/bundled/skills/bug-planner/scripts/validate-bug-list.py +2 -9
- package/bundled/skills/bugfix-pipeline-launcher/SKILL.md +36 -25
- package/bundled/skills/bugfix-pipeline-launcher/references/configuration.md +32 -26
- package/bundled/skills/feature-pipeline-launcher/SKILL.md +33 -25
- package/bundled/skills/feature-pipeline-launcher/references/configuration.md +32 -26
- package/bundled/skills/feature-planner/SKILL.md +4 -10
- package/bundled/skills/feature-planner/references/completeness-review.md +2 -2
- package/bundled/skills/feature-planner/references/new-project-planning.md +0 -1
- package/bundled/skills/feature-planner/scripts/validate-and-generate.py +1 -25
- package/bundled/skills/iterate-pipeline-launcher/SKILL.md +53 -42
- package/bundled/skills/iterate-pipeline-launcher/references/configuration.md +47 -43
- package/bundled/skills/prizmkit-code-review/SKILL.md +1 -1
- package/bundled/skills/prizmkit-code-review/references/independent-code-review.md +2 -2
- package/bundled/skills/prizmkit-implement/SKILL.md +1 -1
- package/bundled/skills/prizmkit-init/SKILL.md +6 -7
- package/bundled/skills/prizmkit-init/references/config-schema.md +5 -9
- package/bundled/skills/prizmkit-init/references/rules/layer-detection.md +1 -1
- package/bundled/skills/prizmkit-plan/SKILL.md +1 -1
- package/bundled/skills/prizmkit-retrospective/SKILL.md +3 -3
- package/bundled/skills/prizmkit-retrospective/references/rule-evolution-steps.md +11 -17
- package/bundled/skills/prizmkit-workflow/SKILL.md +6 -3
- package/bundled/skills/prizmkit-workflow/references/cold-start-rules.md +8 -7
- package/bundled/templates/project-memory-template.md +2 -1
- package/package.json +1 -1
- package/src/clean.js +29 -7
- package/src/config.js +13 -15
- package/src/index.js +1 -5
- package/src/manifest.js +3 -6
- package/src/platforms.js +0 -14
- package/src/scaffold.js +93 -313
- package/src/upgrade.js +32 -31
- package/bundled/adapters/claude/rules-adapter.js +0 -25
- package/bundled/adapters/codebuddy/rules-adapter.js +0 -30
- package/bundled/adapters/codex/rules-adapter.js +0 -30
- package/bundled/adapters/pi/rules-adapter.js +0 -13
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-manual-verification.md +0 -10
- package/bundled/dev-pipeline/templates/sections/phase-browser-verification.md +0 -111
- package/bundled/skills/bug-planner/references/verification.md +0 -26
- package/bundled/skills/feature-planner/references/browser-interaction.md +0 -39
package/src/scaffold.js
CHANGED
|
@@ -14,7 +14,6 @@ import path from 'path';
|
|
|
14
14
|
import { readFileSync } from 'fs';
|
|
15
15
|
import { fileURLToPath, pathToFileURL } from 'url';
|
|
16
16
|
import { dirname, join } from 'path';
|
|
17
|
-
import { execSync } from 'child_process';
|
|
18
17
|
import {
|
|
19
18
|
loadMetadata,
|
|
20
19
|
getTemplatesDir,
|
|
@@ -26,7 +25,7 @@ import {
|
|
|
26
25
|
} from './metadata.js';
|
|
27
26
|
import { generateGitignore, gitignoreSections } from './gitignore-template.js';
|
|
28
27
|
import { buildManifest, readManifestForLifecycle, writeManifest } from './manifest.js';
|
|
29
|
-
import { canonicalizePlatformSelection, defaultCliForPlatform, expandPlatforms, isKnownPlatform,
|
|
28
|
+
import { canonicalizePlatformSelection, defaultCliForPlatform, expandPlatforms, isKnownPlatform, platformLabel, privateProjectMemoryFile, privateProjectMemoryFiles, projectMemoryFile, resolvePayloadPlatforms, unknownPlatformMessage } from './platforms.js';
|
|
30
29
|
import { normalizeRuntime, runtimeLabel } from './runtimes.js';
|
|
31
30
|
import { applyAiCliLaunchToConfig, resolveAiCliLaunchSelection } from './ai-cli-launch.js';
|
|
32
31
|
|
|
@@ -199,6 +198,85 @@ export async function resolveSkillList() {
|
|
|
199
198
|
return suiteDef.skills;
|
|
200
199
|
}
|
|
201
200
|
|
|
201
|
+
export const BUILTIN_RULES_DIR = path.join('.prizmkit', 'rules', 'builtin');
|
|
202
|
+
|
|
203
|
+
const LEGACY_PLATFORM_RULE_LOCATIONS = [
|
|
204
|
+
{ dir: path.join('.claude', 'rules'), ext: '.md' },
|
|
205
|
+
{ dir: path.join('.codebuddy', 'rules'), ext: '.mdc' },
|
|
206
|
+
{ dir: path.join('.agents', 'rules'), ext: '.md' },
|
|
207
|
+
{ dir: path.join('.codex', 'rules'), ext: '.md' },
|
|
208
|
+
{ dir: path.join('.pi', 'rules'), ext: '.md' },
|
|
209
|
+
{ dir: path.join('.cursor', 'rules'), ext: '.mdc' },
|
|
210
|
+
{ dir: path.join('.agents', 'plugins', 'prizmkit', 'rules'), ext: '.md' },
|
|
211
|
+
];
|
|
212
|
+
|
|
213
|
+
export function managedBuiltinRuleBasenames(rulesMeta, manifest = null) {
|
|
214
|
+
const names = new Set();
|
|
215
|
+
for (const key of Object.keys(rulesMeta?.rules || {})) {
|
|
216
|
+
names.add(`${path.basename(key)}.md`);
|
|
217
|
+
}
|
|
218
|
+
for (const recorded of manifest?.files?.rules || []) {
|
|
219
|
+
const baseName = path.basename(recorded);
|
|
220
|
+
const normalized = baseName.endsWith('.mdc') ? baseName.replace(/\.mdc$/, '.md') : baseName;
|
|
221
|
+
if (normalized !== 'prizmkit-framework.md') {
|
|
222
|
+
names.add(normalized);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
names.delete('prizmkit-framework.md');
|
|
226
|
+
return [...names];
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export async function removeLegacyPlatformBuiltinRules(projectRoot, rulesMeta, manifest = null, dryRun = false) {
|
|
230
|
+
const basenames = managedBuiltinRuleBasenames(rulesMeta, manifest);
|
|
231
|
+
if (!basenames.length) return;
|
|
232
|
+
for (const { dir, ext } of LEGACY_PLATFORM_RULE_LOCATIONS) {
|
|
233
|
+
const absDir = path.join(projectRoot, dir);
|
|
234
|
+
for (const fileName of basenames) {
|
|
235
|
+
const targetName = ext === '.mdc' ? fileName.replace(/\.md$/, '.mdc') : fileName;
|
|
236
|
+
const filePath = path.join(absDir, targetName);
|
|
237
|
+
if (await fs.pathExists(filePath)) {
|
|
238
|
+
if (dryRun) {
|
|
239
|
+
console.log(chalk.gray(` [dry-run] remove ${path.relative(projectRoot, filePath)}`));
|
|
240
|
+
} else {
|
|
241
|
+
await fs.remove(filePath);
|
|
242
|
+
console.log(chalk.red(` ✗ removed legacy ${path.relative(projectRoot, filePath)}`));
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
if (!dryRun) {
|
|
247
|
+
await removeEmptyDirectory(absDir);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export async function installBuiltinRules(projectRoot, dryRun = false, runtime = 'python') {
|
|
253
|
+
normalizeRuntime(runtime);
|
|
254
|
+
const rulesMeta = await loadRulesMetadata();
|
|
255
|
+
const ruleNames = resolveRuleNamesForRuntime(rulesMeta, runtime);
|
|
256
|
+
const rulesDir = getRulesDir();
|
|
257
|
+
const ruleFiles = [];
|
|
258
|
+
for (const name of ruleNames) {
|
|
259
|
+
const filePath = path.join(rulesDir, `${name}.md`);
|
|
260
|
+
if (await fs.pathExists(filePath)) {
|
|
261
|
+
ruleFiles.push({ name: path.basename(name), content: await fs.readFile(filePath, 'utf8') });
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
if (dryRun) {
|
|
266
|
+
console.log(chalk.gray(` [dry-run] .prizmkit/rules/builtin/ (${ruleFiles.length} 条规则)`));
|
|
267
|
+
} else {
|
|
268
|
+
const targetDir = path.join(projectRoot, BUILTIN_RULES_DIR);
|
|
269
|
+
await fs.ensureDir(targetDir);
|
|
270
|
+
for (const rule of ruleFiles) {
|
|
271
|
+
await fs.writeFile(path.join(targetDir, `${rule.name}.md`), rule.content, 'utf8');
|
|
272
|
+
}
|
|
273
|
+
console.log(chalk.green(` ✓ .prizmkit/rules/builtin/ (${ruleFiles.length} 条规则)`));
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
await removeLegacyPlatformBuiltinRules(projectRoot, rulesMeta, null, dryRun);
|
|
277
|
+
return ruleFiles.map(rule => `${rule.name}.md`);
|
|
278
|
+
}
|
|
279
|
+
|
|
202
280
|
export function resolveRuleNamesForRuntime(rulesMeta, runtime = 'python') {
|
|
203
281
|
normalizeRuntime(runtime);
|
|
204
282
|
return Object.keys(rulesMeta?.rules || {});
|
|
@@ -500,30 +578,16 @@ async function readUserSettings(settingsPath) {
|
|
|
500
578
|
}
|
|
501
579
|
|
|
502
580
|
/**
|
|
503
|
-
* 安装平台配置文件(settings/hooks
|
|
581
|
+
* 安装平台配置文件(settings/hooks)
|
|
504
582
|
*/
|
|
505
583
|
export async function installSettings(platform, projectRoot, _options = {}, dryRun = false, runtime = 'python') {
|
|
506
584
|
normalizeRuntime(runtime);
|
|
507
|
-
// 从文件加载全部内置 rules
|
|
508
|
-
const rulesMeta = await loadRulesMetadata();
|
|
509
|
-
const ruleNames = resolveRuleNamesForRuntime(rulesMeta, runtime);
|
|
510
|
-
const rulesDir = getRulesDir();
|
|
511
|
-
const ruleFiles = [];
|
|
512
|
-
for (const name of ruleNames) {
|
|
513
|
-
const filePath = path.join(rulesDir, `${name}.md`);
|
|
514
|
-
if (await fs.pathExists(filePath)) {
|
|
515
|
-
ruleFiles.push({ name, content: await fs.readFile(filePath, 'utf8') });
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
585
|
|
|
519
586
|
if (platform === 'codebuddy') {
|
|
520
587
|
const settingsPath = path.join(projectRoot, '.codebuddy', 'settings.json');
|
|
521
588
|
|
|
522
589
|
if (dryRun) {
|
|
523
590
|
console.log(chalk.gray(` [dry-run] .codebuddy/settings.json`));
|
|
524
|
-
if (ruleFiles.length > 0) {
|
|
525
|
-
console.log(chalk.gray(` [dry-run] .codebuddy/rules/ (${ruleFiles.length} 条规则)`));
|
|
526
|
-
}
|
|
527
591
|
return;
|
|
528
592
|
}
|
|
529
593
|
|
|
@@ -541,19 +605,11 @@ export async function installSettings(platform, projectRoot, _options = {}, dryR
|
|
|
541
605
|
await fs.writeFile(settingsPath, JSON.stringify(settings, null, 2));
|
|
542
606
|
console.log(chalk.green(` ✓ .codebuddy/settings.json`));
|
|
543
607
|
|
|
544
|
-
// Install rules for CodeBuddy
|
|
545
|
-
if (ruleFiles.length > 0) {
|
|
546
|
-
const { installRules: installCbRules } = await loadAdapter('codebuddy', 'rules-adapter.js');
|
|
547
|
-
await installCbRules(projectRoot, ruleFiles);
|
|
548
|
-
console.log(chalk.green(` ✓ .codebuddy/rules/ (${ruleFiles.length} 条规则)`));
|
|
549
|
-
}
|
|
550
|
-
|
|
551
608
|
} else if (platform === 'claude') {
|
|
552
609
|
const claudeDir = path.join(projectRoot, '.claude');
|
|
553
610
|
|
|
554
611
|
if (dryRun) {
|
|
555
612
|
console.log(chalk.gray(` [dry-run] .claude/settings.json`));
|
|
556
|
-
console.log(chalk.gray(` [dry-run] .claude/rules/ (${ruleFiles.length} 条规则)`));
|
|
557
613
|
return;
|
|
558
614
|
}
|
|
559
615
|
|
|
@@ -622,27 +678,19 @@ export async function installSettings(platform, projectRoot, _options = {}, dryR
|
|
|
622
678
|
JSON.stringify(settings, null, 2)
|
|
623
679
|
);
|
|
624
680
|
console.log(chalk.green(` ✓ .claude/settings.json`));
|
|
625
|
-
|
|
626
|
-
// Rules
|
|
627
|
-
const { installRules: installClaudeRules } = await loadAdapter('claude', 'rules-adapter.js');
|
|
628
|
-
await installClaudeRules(projectRoot, ruleFiles);
|
|
629
|
-
console.log(chalk.green(` ✓ .claude/rules/ (${ruleFiles.length} 条规则)`));
|
|
630
681
|
} else if (platform === 'codex') {
|
|
631
682
|
const configPath = path.join(projectRoot, '.codex', 'config.toml');
|
|
632
683
|
const legacySettingsPath = path.join(projectRoot, '.codex', 'prizmkit-settings.json');
|
|
633
|
-
const allRuleFileNames = Object.keys(rulesMeta.rules || {})
|
|
634
|
-
.map(name => `${name.includes('/') ? name.split('/').pop() : name}.md`);
|
|
635
684
|
|
|
636
685
|
if (dryRun) {
|
|
637
686
|
console.log(chalk.gray(` [dry-run] .codex/config.toml`));
|
|
638
|
-
console.log(chalk.gray(` [dry-run] .agents/rules/ (${ruleFiles.length} 条规则)`));
|
|
639
687
|
return;
|
|
640
688
|
}
|
|
641
689
|
|
|
642
690
|
await fs.ensureDir(path.dirname(configPath));
|
|
643
691
|
const configToml = `# Generated by PrizmKit for Codex CLI project configuration.
|
|
644
692
|
# Keep project guidance in AGENTS.md; repository skills in .agents/skills/;
|
|
645
|
-
# PrizmKit
|
|
693
|
+
# PrizmKit built-in rules live in .prizmkit/rules/builtin/.
|
|
646
694
|
|
|
647
695
|
project_doc_fallback_filenames = ["CLAUDE.md", "CODEBUDDY.md"]
|
|
648
696
|
|
|
@@ -653,56 +701,36 @@ job_max_runtime_seconds = 3300
|
|
|
653
701
|
await fs.writeFile(configPath, configToml);
|
|
654
702
|
await fs.remove(legacySettingsPath);
|
|
655
703
|
console.log(chalk.green(` ✓ .codex/config.toml`));
|
|
656
|
-
|
|
657
|
-
const {
|
|
658
|
-
installRules: installCodexRules,
|
|
659
|
-
removeLegacyCodexRules,
|
|
660
|
-
} = await loadAdapter('codex', 'rules-adapter.js');
|
|
661
|
-
await installCodexRules(projectRoot, ruleFiles);
|
|
662
|
-
removeLegacyCodexRules(projectRoot, allRuleFileNames);
|
|
663
|
-
console.log(chalk.green(` ✓ .agents/rules/ (${ruleFiles.length} 条规则)`));
|
|
664
704
|
} else if (platform === 'pi') {
|
|
665
705
|
if (dryRun) {
|
|
666
706
|
console.log(chalk.gray(' [dry-run] .pi/settings.json'));
|
|
667
|
-
console.log(chalk.gray(` [dry-run] .pi/rules/ (${ruleFiles.length} 条规则)`));
|
|
668
707
|
return;
|
|
669
708
|
}
|
|
670
709
|
const { generateSettings } = await loadAdapter('pi', 'settings-adapter.js');
|
|
671
|
-
const { installRules } = await loadAdapter('pi', 'rules-adapter.js');
|
|
672
710
|
await generateSettings(projectRoot);
|
|
673
|
-
await installRules(projectRoot, ruleFiles);
|
|
674
711
|
console.log(chalk.green(' ✓ .pi/settings.json'));
|
|
675
|
-
console.log(chalk.green(` ✓ .pi/rules/ (${ruleFiles.length} 条规则)`));
|
|
676
712
|
} else if (platform === 'cursor') {
|
|
677
713
|
if (dryRun) {
|
|
678
714
|
console.log(chalk.gray(' [dry-run] .cursor/hooks.json'));
|
|
679
715
|
console.log(chalk.gray(' [dry-run] .cursor/hooks/prizmkit-hook.cjs'));
|
|
680
|
-
console.log(chalk.gray(` [dry-run] .cursor/rules/ (${ruleFiles.length} 条规则)`));
|
|
681
716
|
return;
|
|
682
717
|
}
|
|
683
718
|
const { installHooks } = await loadAdapter('cursor', 'hooks-adapter.js');
|
|
684
|
-
const { installRules } = await loadAdapter('cursor', 'rules-adapter.js');
|
|
685
719
|
await installHooks(projectRoot);
|
|
686
|
-
await installRules(projectRoot, ruleFiles);
|
|
687
720
|
console.log(chalk.green(' ✓ .cursor/hooks.json'));
|
|
688
721
|
console.log(chalk.green(' ✓ .cursor/hooks/prizmkit-hook.cjs'));
|
|
689
|
-
console.log(chalk.green(` ✓ .cursor/rules/ (${ruleFiles.length} 条规则)`));
|
|
690
722
|
} else if (platform === 'antigravity') {
|
|
691
723
|
if (dryRun) {
|
|
692
724
|
console.log(chalk.gray(' [dry-run] .agents/plugins/prizmkit/plugin.json'));
|
|
693
725
|
console.log(chalk.gray(' [dry-run] .agents/plugins/prizmkit/hooks.json'));
|
|
694
726
|
console.log(chalk.gray(' [dry-run] .agents/plugins/prizmkit/hooks/prizmkit-hook.cjs'));
|
|
695
|
-
console.log(chalk.gray(` [dry-run] .agents/plugins/prizmkit/rules/ (${ruleFiles.length} 条规则)`));
|
|
696
727
|
return;
|
|
697
728
|
}
|
|
698
729
|
const { installHooks } = await loadAdapter('antigravity', 'hooks-adapter.js');
|
|
699
|
-
const { installRules } = await loadAdapter('antigravity', 'rules-adapter.js');
|
|
700
730
|
await installHooks(projectRoot, { version: scaffoldPkg.version });
|
|
701
|
-
await installRules(projectRoot, ruleFiles);
|
|
702
731
|
console.log(chalk.green(' ✓ .agents/plugins/prizmkit/plugin.json'));
|
|
703
732
|
console.log(chalk.green(' ✓ .agents/plugins/prizmkit/hooks.json'));
|
|
704
733
|
console.log(chalk.green(' ✓ .agents/plugins/prizmkit/hooks/prizmkit-hook.cjs'));
|
|
705
|
-
console.log(chalk.green(` ✓ .agents/plugins/prizmkit/rules/ (${ruleFiles.length} 条规则)`));
|
|
706
734
|
}
|
|
707
735
|
}
|
|
708
736
|
|
|
@@ -1166,7 +1194,7 @@ Pi discovers project skills from \`.pi/skills/\`. Invoke them with \`/skill:<nam
|
|
|
1166
1194
|
|
|
1167
1195
|
- Start with \`/skill:prizmkit\` to see all available PrizmKit skills.
|
|
1168
1196
|
- Skill assets and references live inside each \`.pi/skills/<skill>/\` directory.
|
|
1169
|
-
- PrizmKit
|
|
1197
|
+
- PrizmKit built-in rules live in \`.prizmkit/rules/builtin/\` (\`coding-baseline.md\`, \`cohesive-modeling.md\`, and \`prizm-*.md\`); read the relevant rules before planning, implementation, code review, commit, documentation, or context-loading work.
|
|
1170
1198
|
`
|
|
1171
1199
|
);
|
|
1172
1200
|
} else if (platform === 'codex') {
|
|
@@ -1177,7 +1205,7 @@ Codex discovers repository skills from \`.agents/skills/\`. When a user or promp
|
|
|
1177
1205
|
|
|
1178
1206
|
- Start with \`.agents/skills/prizmkit/SKILL.md\` to see all available PrizmKit skills.
|
|
1179
1207
|
- Skill assets and references live inside each \`.agents/skills/<skill>/\` directory.
|
|
1180
|
-
- PrizmKit
|
|
1208
|
+
- PrizmKit built-in rules live in \`.prizmkit/rules/builtin/\` (\`coding-baseline.md\`, \`cohesive-modeling.md\`, and \`prizm-*.md\`); read the relevant rules before planning, implementation, code review, commit, documentation, or context-loading work.
|
|
1181
1209
|
`
|
|
1182
1210
|
);
|
|
1183
1211
|
}
|
|
@@ -1486,254 +1514,13 @@ export async function installGitignore(projectRoot, options = {}, dryRun) {
|
|
|
1486
1514
|
console.log(chalk.green(` ✓ .gitignore (added ${missingCount} entries)`));
|
|
1487
1515
|
}
|
|
1488
1516
|
|
|
1489
|
-
// ============================================================
|
|
1490
|
-
// Playwright CLI 安装
|
|
1491
|
-
// ============================================================
|
|
1492
|
-
|
|
1493
|
-
const PLAYWRIGHT_SKILL_NAME = 'playwright-cli';
|
|
1494
|
-
const PLAYWRIGHT_CLI_PACKAGE = '@playwright/cli';
|
|
1495
|
-
|
|
1496
|
-
function parseVersion(value) {
|
|
1497
|
-
const match = String(value || '').match(/(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?/);
|
|
1498
|
-
if (!match) return null;
|
|
1499
|
-
return {
|
|
1500
|
-
core: [Number(match[1]), Number(match[2]), Number(match[3])],
|
|
1501
|
-
prerelease: match[4] || '',
|
|
1502
|
-
};
|
|
1503
|
-
}
|
|
1504
|
-
|
|
1505
|
-
/**
|
|
1506
|
-
* Compare two semantic versions. Returns -1, 0, or 1, or null when unparsable.
|
|
1507
|
-
*/
|
|
1508
|
-
function compareVersions(left, right) {
|
|
1509
|
-
const a = parseVersion(left);
|
|
1510
|
-
const b = parseVersion(right);
|
|
1511
|
-
if (!a || !b) return null;
|
|
1512
|
-
for (let i = 0; i < a.core.length; i += 1) {
|
|
1513
|
-
if (a.core[i] !== b.core[i]) return a.core[i] < b.core[i] ? -1 : 1;
|
|
1514
|
-
}
|
|
1515
|
-
if (a.prerelease === b.prerelease) return 0;
|
|
1516
|
-
if (!a.prerelease) return 1;
|
|
1517
|
-
if (!b.prerelease) return -1;
|
|
1518
|
-
return a.prerelease < b.prerelease ? -1 : 1;
|
|
1519
|
-
}
|
|
1520
|
-
|
|
1521
|
-
function readInstalledPlaywrightCliVersion() {
|
|
1522
|
-
try {
|
|
1523
|
-
return String(execSync('playwright-cli --version', { stdio: 'pipe', timeout: 20000 })).trim() || null;
|
|
1524
|
-
} catch {
|
|
1525
|
-
return null;
|
|
1526
|
-
}
|
|
1527
|
-
}
|
|
1528
|
-
|
|
1529
|
-
function readLatestNpmVersion(packageName) {
|
|
1530
|
-
try {
|
|
1531
|
-
const output = String(execSync(`npm view ${packageName} version`, { stdio: 'pipe', timeout: 30000 })).trim();
|
|
1532
|
-
return output.split('\n').pop().trim() || null;
|
|
1533
|
-
} catch {
|
|
1534
|
-
return null;
|
|
1535
|
-
}
|
|
1536
|
-
}
|
|
1537
|
-
|
|
1538
|
-
function installGlobalNpmPackage(packageName, version) {
|
|
1539
|
-
const target = version || 'latest';
|
|
1540
|
-
try {
|
|
1541
|
-
console.log(chalk.blue(` ⏳ Installing ${packageName}@${target} globally...`));
|
|
1542
|
-
execSync(`npm install -g ${packageName}@${target}`, { stdio: 'pipe', timeout: 120000 });
|
|
1543
|
-
console.log(chalk.green(` ✓ ${packageName}@${target} installed globally`));
|
|
1544
|
-
return true;
|
|
1545
|
-
} catch (e) {
|
|
1546
|
-
console.log(chalk.yellow(` ⚠ ${packageName} install failed: ${e.message}`));
|
|
1547
|
-
console.log(chalk.yellow(` ⚠ Run manually: npm install -g ${packageName}@${target}`));
|
|
1548
|
-
return false;
|
|
1549
|
-
}
|
|
1550
|
-
}
|
|
1551
|
-
|
|
1552
|
-
/**
|
|
1553
|
-
* Sync a globally installed npm CLI with the published latest version.
|
|
1554
|
-
* A registry failure never blocks installation: the existing global CLI keeps
|
|
1555
|
-
* working and the remaining external assets are still refreshed.
|
|
1556
|
-
*/
|
|
1557
|
-
function syncGlobalNpmPackage(packageName, label, installedVersion) {
|
|
1558
|
-
if (!installedVersion) return installGlobalNpmPackage(packageName);
|
|
1559
|
-
|
|
1560
|
-
const latest = readLatestNpmVersion(packageName);
|
|
1561
|
-
const comparison = latest ? compareVersions(installedVersion, latest) : null;
|
|
1562
|
-
if (comparison === null) {
|
|
1563
|
-
console.log(chalk.green(` ✓ ${label} ${installedVersion} (already installed)`));
|
|
1564
|
-
return true;
|
|
1565
|
-
}
|
|
1566
|
-
if (comparison === 0) {
|
|
1567
|
-
console.log(chalk.green(` ✓ ${label} ${installedVersion} (latest)`));
|
|
1568
|
-
return true;
|
|
1569
|
-
}
|
|
1570
|
-
if (comparison > 0) {
|
|
1571
|
-
console.log(chalk.green(` ✓ ${label} ${installedVersion} (newer than published ${latest})`));
|
|
1572
|
-
return true;
|
|
1573
|
-
}
|
|
1574
|
-
console.log(chalk.blue(` ⏳ Updating ${label} ${installedVersion} → ${latest}...`));
|
|
1575
|
-
if (installGlobalNpmPackage(packageName, latest)) return true;
|
|
1576
|
-
console.log(chalk.yellow(` ⚠ Continuing with ${label} ${installedVersion}`));
|
|
1577
|
-
return true;
|
|
1578
|
-
}
|
|
1579
|
-
|
|
1580
|
-
function ensurePlaywrightCli() {
|
|
1581
|
-
return syncGlobalNpmPackage(
|
|
1582
|
-
PLAYWRIGHT_CLI_PACKAGE,
|
|
1583
|
-
'playwright-cli',
|
|
1584
|
-
readInstalledPlaywrightCliVersion(),
|
|
1585
|
-
);
|
|
1586
|
-
}
|
|
1587
|
-
|
|
1588
|
-
function playwrightBrowserCacheDir() {
|
|
1589
|
-
return process.env.PLAYWRIGHT_BROWSERS_PATH
|
|
1590
|
-
|| path.join(process.env.HOME || process.env.USERPROFILE || '.',
|
|
1591
|
-
process.platform === 'darwin' ? 'Library/Caches/ms-playwright'
|
|
1592
|
-
: process.platform === 'win32' ? 'AppData/Local/ms-playwright'
|
|
1593
|
-
: '.cache/ms-playwright');
|
|
1594
|
-
}
|
|
1595
|
-
|
|
1596
|
-
/**
|
|
1597
|
-
* Detect installed Chromium builds. Recent Playwright releases install the
|
|
1598
|
-
* headless shell as a separate `chromium_headless_shell-<build>` directory.
|
|
1599
|
-
*/
|
|
1600
|
-
function playwrightChromiumState(cacheDir) {
|
|
1601
|
-
const state = { chromium: false, headlessShell: false };
|
|
1602
|
-
if (!fs.pathExistsSync(cacheDir)) return state;
|
|
1603
|
-
let entries = [];
|
|
1604
|
-
try {
|
|
1605
|
-
entries = fs.readdirSync(cacheDir);
|
|
1606
|
-
} catch {
|
|
1607
|
-
return state;
|
|
1608
|
-
}
|
|
1609
|
-
for (const entry of entries) {
|
|
1610
|
-
if (/^chromium-\d/.test(entry)) state.chromium = true;
|
|
1611
|
-
else if (/^chromium_headless_shell-\d/.test(entry)) state.headlessShell = true;
|
|
1612
|
-
}
|
|
1613
|
-
return state;
|
|
1614
|
-
}
|
|
1615
|
-
|
|
1616
|
-
function extrasContextObject(value) {
|
|
1617
|
-
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
1618
|
-
}
|
|
1619
|
-
|
|
1620
|
-
function completePlaywrightSkillDir(dir) {
|
|
1621
|
-
return dir && fs.pathExistsSync(path.join(dir, 'SKILL.md')) ? dir : null;
|
|
1622
|
-
}
|
|
1623
|
-
|
|
1624
|
-
function discoverPlaywrightSkillSource(projectRoot) {
|
|
1625
|
-
const home = process.env.HOME || process.env.USERPROFILE || '.';
|
|
1626
|
-
return completePlaywrightSkillDir(path.join(projectRoot, '.claude', 'skills', PLAYWRIGHT_SKILL_NAME))
|
|
1627
|
-
|| completePlaywrightSkillDir(path.join(home, '.claude', 'skills', PLAYWRIGHT_SKILL_NAME));
|
|
1628
|
-
}
|
|
1629
|
-
|
|
1630
|
-
async function distributePlaywrightSkill(projectRoot, extrasContext, dryRun) {
|
|
1631
|
-
const platform = extrasContext?.platform;
|
|
1632
|
-
if (!platform) {
|
|
1633
|
-
console.log(chalk.yellow(' ⚠ playwright-cli skills were not copied: install platform is missing'));
|
|
1634
|
-
return;
|
|
1635
|
-
}
|
|
1636
|
-
const aiCli = extrasContext?.aiCli || '';
|
|
1637
|
-
const payloadPlatforms = resolvePayloadPlatforms(platform, aiCli);
|
|
1638
|
-
const destinations = payloadSkillRoots(platform, projectRoot, aiCli).map(root => path.join(root, PLAYWRIGHT_SKILL_NAME));
|
|
1639
|
-
if (dryRun) {
|
|
1640
|
-
for (const dest of destinations) {
|
|
1641
|
-
console.log(chalk.gray(` [dry-run] ${path.relative(projectRoot, dest)}`));
|
|
1642
|
-
}
|
|
1643
|
-
return;
|
|
1644
|
-
}
|
|
1645
|
-
const source = discoverPlaywrightSkillSource(projectRoot);
|
|
1646
|
-
if (!source) {
|
|
1647
|
-
console.log(chalk.yellow(' ⚠ playwright-cli skill tree was not found after install --skills'));
|
|
1648
|
-
return;
|
|
1649
|
-
}
|
|
1650
|
-
const sourceReal = await fs.realpath(source).catch(() => path.resolve(source));
|
|
1651
|
-
for (const dest of destinations) {
|
|
1652
|
-
const destReal = await fs.realpath(dest).catch(() => path.resolve(dest));
|
|
1653
|
-
if (destReal === sourceReal) continue;
|
|
1654
|
-
await fs.remove(dest).catch(() => {});
|
|
1655
|
-
await fs.copy(source, dest);
|
|
1656
|
-
console.log(chalk.green(` ✓ ${path.relative(projectRoot, dest)}`));
|
|
1657
|
-
}
|
|
1658
|
-
if (!payloadPlatforms.includes('claude')) {
|
|
1659
|
-
const leftover = path.join(nativeSkillRoot('claude', projectRoot), PLAYWRIGHT_SKILL_NAME);
|
|
1660
|
-
if (await fs.pathExists(leftover)) {
|
|
1661
|
-
await fs.remove(leftover);
|
|
1662
|
-
console.log(chalk.gray(` • removed leftover ${path.relative(projectRoot, leftover)}`));
|
|
1663
|
-
}
|
|
1664
|
-
}
|
|
1665
|
-
}
|
|
1666
|
-
|
|
1667
|
-
/**
|
|
1668
|
-
* 安装 playwright-cli(全局 npm 包 + AI agent skills)
|
|
1669
|
-
* 用于浏览器交互验证(browser_interaction 功能)
|
|
1670
|
-
*/
|
|
1671
|
-
export async function installPlaywrightCli(projectRoot, dryRun, extrasContext = {}) {
|
|
1672
|
-
const context = extrasContextObject(extrasContext) ? extrasContext : {};
|
|
1673
|
-
if (dryRun) {
|
|
1674
|
-
console.log(chalk.gray(' [dry-run] @playwright/cli (global install/update + workspace skills)'));
|
|
1675
|
-
await distributePlaywrightSkill(projectRoot, context, true);
|
|
1676
|
-
return;
|
|
1677
|
-
}
|
|
1678
|
-
|
|
1679
|
-
if (!ensurePlaywrightCli()) return;
|
|
1680
|
-
|
|
1681
|
-
// Install AI agent skills (official SKILL.md + references, auto-detects system browser)
|
|
1682
|
-
try {
|
|
1683
|
-
execSync('playwright-cli install --skills', { cwd: projectRoot, stdio: 'pipe', timeout: 60000 });
|
|
1684
|
-
console.log(chalk.green(' ✓ playwright-cli skills installed'));
|
|
1685
|
-
// playwright-cli creates an empty .playwright directory — remove it
|
|
1686
|
-
const dotPlaywright = path.join(projectRoot, '.playwright');
|
|
1687
|
-
if (fs.pathExistsSync(dotPlaywright)) {
|
|
1688
|
-
fs.removeSync(dotPlaywright);
|
|
1689
|
-
}
|
|
1690
|
-
await distributePlaywrightSkill(projectRoot, context, false);
|
|
1691
|
-
} catch (e) {
|
|
1692
|
-
console.log(chalk.yellow(` ⚠ Skills install skipped: ${e.message}`));
|
|
1693
|
-
console.log(chalk.yellow(' ⚠ Run manually: playwright-cli install --skills'));
|
|
1694
|
-
}
|
|
1695
|
-
|
|
1696
|
-
// Install Playwright browser binary (needed for E2E testing via prizmkit-test)
|
|
1697
|
-
try {
|
|
1698
|
-
const browsers = playwrightChromiumState(playwrightBrowserCacheDir());
|
|
1699
|
-
if (browsers.chromium) {
|
|
1700
|
-
console.log(chalk.green(' ✓ Playwright Chromium (already installed)'));
|
|
1701
|
-
} else if (browsers.headlessShell) {
|
|
1702
|
-
console.log(chalk.green(' ✓ Playwright Chromium headless shell (already installed)'));
|
|
1703
|
-
console.log(chalk.gray(' • Headed runs still need a full build: npx playwright install chromium --no-shell'));
|
|
1704
|
-
} else {
|
|
1705
|
-
console.log(chalk.blue(' ⏳ Installing Playwright Chromium (needed for E2E testing)...'));
|
|
1706
|
-
execSync('npx --yes playwright install chromium', { stdio: 'pipe', timeout: 180000 });
|
|
1707
|
-
console.log(chalk.green(' ✓ Playwright Chromium installed'));
|
|
1708
|
-
}
|
|
1709
|
-
} catch (e) {
|
|
1710
|
-
console.log(chalk.yellow(` ⚠ Playwright browser install skipped: ${e.message}`));
|
|
1711
|
-
console.log(chalk.yellow(' ⚠ Run manually: npx playwright install chromium'));
|
|
1712
|
-
}
|
|
1713
|
-
}
|
|
1714
|
-
|
|
1715
|
-
// ============================================================
|
|
1716
|
-
// Extras 注册表
|
|
1717
|
-
// ============================================================
|
|
1718
|
-
|
|
1719
|
-
/**
|
|
1720
|
-
* 外部工具注册表。upgrade.js 遍历此表来安装/更新外部工具。
|
|
1721
|
-
* 新增工具只需:1) 写 installXxx 函数 2) 加一行到此表
|
|
1722
|
-
*/
|
|
1723
|
-
export const EXTRAS_REGISTRY = {
|
|
1724
|
-
'playwright-cli': {
|
|
1725
|
-
label: '浏览器交互工具 (playwright-cli)',
|
|
1726
|
-
install: installPlaywrightCli,
|
|
1727
|
-
},
|
|
1728
|
-
};
|
|
1729
|
-
|
|
1730
1517
|
// ============================================================
|
|
1731
1518
|
// 主安装函数
|
|
1732
1519
|
// ============================================================
|
|
1733
1520
|
|
|
1734
1521
|
const SCAFFOLD_CONFIG_FIELDS = new Set([
|
|
1735
1522
|
'platform', 'runtime', 'skills', 'pipeline', 'aiCli', 'aiCliLaunch',
|
|
1736
|
-
'
|
|
1523
|
+
'projectRoot', 'dryRun',
|
|
1737
1524
|
]);
|
|
1738
1525
|
|
|
1739
1526
|
/**
|
|
@@ -1744,7 +1531,6 @@ const SCAFFOLD_CONFIG_FIELDS = new Set([
|
|
|
1744
1531
|
* @param {string} [config.skills] - sole supported suite is 'core' (legacy values warn and normalize to 'core')
|
|
1745
1532
|
* @param {boolean} config.pipeline - 是否安装 dev-pipeline
|
|
1746
1533
|
* @param {string} [config.aiCli] - AI CLI 可执行命令(写入 .prizmkit/config.json)
|
|
1747
|
-
* @param {boolean} [config.playwrightCli] - 是否安装 playwright-cli
|
|
1748
1534
|
* @param {string} config.projectRoot - 目标项目根目录
|
|
1749
1535
|
* @param {boolean} config.dryRun - 是否为预览模式
|
|
1750
1536
|
*/
|
|
@@ -1758,7 +1544,7 @@ export async function scaffold(config) {
|
|
|
1758
1544
|
if (unknownFields.length) {
|
|
1759
1545
|
throw new TypeError(`scaffold config has unknown fields: ${unknownFields.join(', ')}`);
|
|
1760
1546
|
}
|
|
1761
|
-
const { platform, skills, pipeline, aiCli, aiCliLaunch,
|
|
1547
|
+
const { platform, skills, pipeline, aiCli, aiCliLaunch, projectRoot, dryRun } = config;
|
|
1762
1548
|
const normalizedSuite = normalizeSkillSuite(skills, { warn: true, warnOnCore: false });
|
|
1763
1549
|
const runtime = normalizeRuntime(config.runtime);
|
|
1764
1550
|
const launchSelection = resolveAiCliLaunchSelection(aiCli || '', {
|
|
@@ -1791,7 +1577,7 @@ export async function scaffold(config) {
|
|
|
1791
1577
|
console.log(chalk.blue(' 技能文件:'));
|
|
1792
1578
|
await installSkills(p, skillList, projectRoot, dryRun, runtime);
|
|
1793
1579
|
|
|
1794
|
-
// 2. Settings/Hooks
|
|
1580
|
+
// 2. Settings/Hooks
|
|
1795
1581
|
console.log(chalk.blue('\n 平台配置:'));
|
|
1796
1582
|
await installSettings(p, projectRoot, {}, dryRun, runtime);
|
|
1797
1583
|
|
|
@@ -1802,6 +1588,11 @@ export async function scaffold(config) {
|
|
|
1802
1588
|
console.log('');
|
|
1803
1589
|
}
|
|
1804
1590
|
|
|
1591
|
+
// Built-in rules (.prizmkit/rules/builtin/)
|
|
1592
|
+
console.log(chalk.blue(' 内置规则:'));
|
|
1593
|
+
await installBuiltinRules(projectRoot, dryRun, runtime);
|
|
1594
|
+
console.log('');
|
|
1595
|
+
|
|
1805
1596
|
let existingManifest = null;
|
|
1806
1597
|
try {
|
|
1807
1598
|
existingManifest = await readManifestForLifecycle(projectRoot);
|
|
@@ -1855,16 +1646,7 @@ export async function scaffold(config) {
|
|
|
1855
1646
|
}
|
|
1856
1647
|
}
|
|
1857
1648
|
|
|
1858
|
-
// 9.
|
|
1859
|
-
const activeExtras = [];
|
|
1860
|
-
if (playwrightCli) {
|
|
1861
|
-
activeExtras.push('playwright-cli');
|
|
1862
|
-
console.log(chalk.blue(` ${EXTRAS_REGISTRY['playwright-cli'].label}:`));
|
|
1863
|
-
await installPlaywrightCli(projectRoot, dryRun, { platform: canonicalPlatform, aiCli: resolvedAiCli });
|
|
1864
|
-
console.log('');
|
|
1865
|
-
}
|
|
1866
|
-
|
|
1867
|
-
// 10. Clean up empty stray .codebuddy/ directory when CodeBuddy is not a payload platform.
|
|
1649
|
+
// 9. Clean up empty stray .codebuddy/ directory when CodeBuddy is not a payload platform.
|
|
1868
1650
|
if (!dryRun && !payloadPlatforms.includes('codebuddy')) {
|
|
1869
1651
|
const strayCbDir = path.join(projectRoot, '.codebuddy');
|
|
1870
1652
|
if (await fs.pathExists(strayCbDir)) {
|
|
@@ -1898,7 +1680,6 @@ export async function scaffold(config) {
|
|
|
1898
1680
|
pipeline: installedPipelineFiles,
|
|
1899
1681
|
aiCli: resolvedAiCli,
|
|
1900
1682
|
rulesPreset: 'recommended',
|
|
1901
|
-
extras: activeExtras,
|
|
1902
1683
|
payloadPlatforms,
|
|
1903
1684
|
});
|
|
1904
1685
|
await writeManifest(projectRoot, manifest);
|
|
@@ -1953,7 +1734,6 @@ export async function scaffold(config) {
|
|
|
1953
1734
|
}
|
|
1954
1735
|
console.log(chalk.gray(` 运行时: ${runtimeLabel(runtime)}`));
|
|
1955
1736
|
console.log(chalk.gray(` 流水线: ${pipeline ? '已安装' : '未安装'}`));
|
|
1956
|
-
console.log(chalk.gray(` 浏览器工具: ${playwrightCli ? '已安装 (playwright-cli)' : '未安装'}`));
|
|
1957
1737
|
console.log(chalk.gray(` 规则: 全部内置规则`));
|
|
1958
1738
|
if (resolvedAiCli) console.log(chalk.gray(` AI CLI: ${resolvedAiCli}`));
|
|
1959
1739
|
console.log('');
|