prizmkit 1.0.13 → 1.0.14

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.
Files changed (77) hide show
  1. package/bin/create-prizmkit.js +4 -1
  2. package/bundled/VERSION.json +3 -3
  3. package/bundled/adapters/claude/command-adapter.js +35 -4
  4. package/bundled/adapters/claude/rules-adapter.js +6 -58
  5. package/bundled/adapters/claude/team-adapter.js +2 -2
  6. package/bundled/adapters/codebuddy/agent-adapter.js +0 -1
  7. package/bundled/adapters/codebuddy/rules-adapter.js +30 -0
  8. package/bundled/adapters/shared/frontmatter.js +3 -1
  9. package/bundled/dev-pipeline/README.md +13 -3
  10. package/bundled/dev-pipeline/launch-bugfix-daemon.sh +10 -0
  11. package/bundled/dev-pipeline/launch-daemon.sh +18 -4
  12. package/bundled/dev-pipeline/lib/common.sh +105 -0
  13. package/bundled/dev-pipeline/run-bugfix.sh +57 -57
  14. package/bundled/dev-pipeline/run.sh +75 -59
  15. package/bundled/dev-pipeline/scripts/check-session-status.py +47 -2
  16. package/bundled/dev-pipeline/scripts/cleanup-logs.py +192 -0
  17. package/bundled/dev-pipeline/scripts/detect-stuck.py +15 -3
  18. package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +32 -27
  19. package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +23 -23
  20. package/bundled/dev-pipeline/scripts/update-feature-status.py +50 -2
  21. package/bundled/dev-pipeline/scripts/utils.py +22 -0
  22. package/bundled/dev-pipeline/templates/bootstrap-tier1.md +18 -1
  23. package/bundled/dev-pipeline/templates/bootstrap-tier2.md +19 -1
  24. package/bundled/dev-pipeline/templates/bootstrap-tier3.md +18 -2
  25. package/bundled/dev-pipeline/templates/session-status-schema.json +7 -1
  26. package/bundled/dev-pipeline/tests/__init__.py +0 -0
  27. package/bundled/dev-pipeline/tests/conftest.py +133 -0
  28. package/bundled/dev-pipeline/tests/test_check_session.py +127 -0
  29. package/bundled/dev-pipeline/tests/test_cleanup_logs.py +119 -0
  30. package/bundled/dev-pipeline/tests/test_detect_stuck.py +207 -0
  31. package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +181 -0
  32. package/bundled/dev-pipeline/tests/test_generate_prompt.py +190 -0
  33. package/bundled/dev-pipeline/tests/test_init_bugfix_pipeline.py +153 -0
  34. package/bundled/dev-pipeline/tests/test_init_pipeline.py +241 -0
  35. package/bundled/dev-pipeline/tests/test_update_bug_status.py +142 -0
  36. package/bundled/dev-pipeline/tests/test_update_feature_status.py +277 -0
  37. package/bundled/dev-pipeline/tests/test_utils.py +141 -0
  38. package/bundled/rules/USAGE.md +153 -0
  39. package/bundled/rules/_rules-metadata.json +43 -0
  40. package/bundled/rules/general/prefer-linux-commands.md +9 -0
  41. package/bundled/rules/prizm/prizm-commit-workflow.md +10 -0
  42. package/bundled/rules/prizm/prizm-documentation.md +19 -0
  43. package/bundled/rules/prizm/prizm-progressive-loading.md +11 -0
  44. package/bundled/skills/_metadata.json +130 -67
  45. package/bundled/skills/app-planner/SKILL.md +252 -499
  46. package/bundled/skills/app-planner/assets/evaluation-guide.md +44 -0
  47. package/bundled/skills/app-planner/scripts/validate-and-generate.py +143 -4
  48. package/bundled/skills/bug-planner/SKILL.md +58 -13
  49. package/bundled/skills/bugfix-pipeline-launcher/SKILL.md +5 -7
  50. package/bundled/skills/dev-pipeline-launcher/SKILL.md +16 -7
  51. package/bundled/skills/feature-workflow/SKILL.md +175 -234
  52. package/bundled/skills/prizm-kit/SKILL.md +17 -31
  53. package/bundled/skills/{prizmkit-adr-manager → prizmkit-tool-adr-manager}/SKILL.md +6 -7
  54. package/bundled/skills/{prizmkit-api-doc-generator → prizmkit-tool-api-doc-generator}/SKILL.md +4 -5
  55. package/bundled/skills/{prizmkit-bug-reproducer → prizmkit-tool-bug-reproducer}/SKILL.md +4 -5
  56. package/bundled/skills/{prizmkit-ci-cd-generator → prizmkit-tool-ci-cd-generator}/SKILL.md +4 -5
  57. package/bundled/skills/{prizmkit-db-migration → prizmkit-tool-db-migration}/SKILL.md +4 -5
  58. package/bundled/skills/{prizmkit-dependency-health → prizmkit-tool-dependency-health}/SKILL.md +3 -4
  59. package/bundled/skills/{prizmkit-deployment-strategy → prizmkit-tool-deployment-strategy}/SKILL.md +4 -5
  60. package/bundled/skills/{prizmkit-error-triage → prizmkit-tool-error-triage}/SKILL.md +4 -5
  61. package/bundled/skills/{prizmkit-log-analyzer → prizmkit-tool-log-analyzer}/SKILL.md +4 -5
  62. package/bundled/skills/{prizmkit-monitoring-setup → prizmkit-tool-monitoring-setup}/SKILL.md +4 -5
  63. package/bundled/skills/{prizmkit-onboarding-generator → prizmkit-tool-onboarding-generator}/SKILL.md +4 -5
  64. package/bundled/skills/{prizmkit-perf-profiler → prizmkit-tool-perf-profiler}/SKILL.md +4 -5
  65. package/bundled/skills/{prizmkit-security-audit → prizmkit-tool-security-audit}/SKILL.md +3 -4
  66. package/bundled/skills/{prizmkit-tech-debt-tracker → prizmkit-tool-tech-debt-tracker}/SKILL.md +3 -4
  67. package/bundled/skills/refactor-skill/SKILL.md +371 -0
  68. package/bundled/skills/refactor-workflow/SKILL.md +17 -119
  69. package/package.json +1 -1
  70. package/src/external-skills.js +71 -0
  71. package/src/index.js +62 -4
  72. package/src/metadata.js +36 -0
  73. package/src/scaffold.js +136 -32
  74. package/bundled/skills/prizmkit-bug-fix-workflow/SKILL.md +0 -356
  75. package/bundled/templates/claude-md-template.md +0 -38
  76. package/bundled/templates/codebuddy-md-template.md +0 -35
  77. /package/bundled/skills/{prizmkit-adr-manager → prizmkit-tool-adr-manager}/assets/adr-template.md +0 -0
package/src/scaffold.js CHANGED
@@ -18,7 +18,8 @@ import {
18
18
  getTemplatesDir,
19
19
  getPipelineDir,
20
20
  getAdaptersDir,
21
- getFrameworkRoot,
21
+ getRulesDir,
22
+ loadRulesMetadata,
22
23
  } from './metadata.js';
23
24
  import { generateGitignore } from './gitignore-template.js';
24
25
 
@@ -51,6 +52,20 @@ async function loadSharedFrontmatter() {
51
52
  async function resolveSkillList(suite) {
52
53
  const metadata = await loadMetadata();
53
54
 
55
+ // 处理 recommended:<type> 格式
56
+ if (suite && suite.startsWith('recommended:')) {
57
+ const projectType = suite.split(':')[1];
58
+ const rec = metadata.recommendations?.[projectType];
59
+ if (rec) {
60
+ const baseSkills = rec.base === '*'
61
+ ? Object.keys(metadata.skills)
62
+ : [...(metadata.suites[rec.base]?.skills || [])];
63
+ const includeSkills = rec.include || [];
64
+ const excludeSkills = new Set(rec.exclude || []);
65
+ return [...new Set([...baseSkills, ...includeSkills])].filter(s => !excludeSkills.has(s));
66
+ }
67
+ }
68
+
54
69
  const suiteDef = metadata.suites[suite] || metadata.suites.full;
55
70
  if (suiteDef.skills === '*') {
56
71
  return Object.keys(metadata.skills);
@@ -68,6 +83,13 @@ async function resolveSkillList(suite) {
68
83
  async function installSkills(platform, skills, projectRoot, dryRun) {
69
84
  const skillsDir = getSkillsDir();
70
85
  const { parseFrontmatter, buildMarkdown } = await loadSharedFrontmatter();
86
+
87
+ // Load metadata to get skill -> category mapping
88
+ const metadata = await loadMetadata();
89
+ const skillCategories = {};
90
+ for (const [skillName, skillDef] of Object.entries(metadata.skills)) {
91
+ skillCategories[skillName] = skillDef.category;
92
+ }
71
93
 
72
94
  // Load Claude command adapter for skill conversion
73
95
  let convertSkillToCommand;
@@ -77,7 +99,31 @@ async function installSkills(platform, skills, projectRoot, dryRun) {
77
99
  }
78
100
 
79
101
  for (const skillName of skills) {
80
- const corePath = path.join(skillsDir, skillName);
102
+ // Determine the category subdirectory (prizmkit-skill, prizmkit-tool-skill, Custom-skill)
103
+ const category = skillCategories[skillName];
104
+ if (!category) {
105
+ console.warn(` ⚠ Skill ${skillName} has no category mapping in metadata, skipping`);
106
+ continue;
107
+ }
108
+
109
+ // Security: validate category and skillName contain no path traversal sequences.
110
+ if (category.includes('..') || category.includes('/') || skillName.includes('..') || skillName.includes('/')) {
111
+ console.warn(` ⚠ Skill ${skillName} has invalid category or name, skipping`);
112
+ continue;
113
+ }
114
+
115
+ // Build path: prefer hierarchical layout (<skillsDir>/<category>/<skillName>),
116
+ // fallback to flat bundled layout (<skillsDir>/<skillName>) for npm package compatibility.
117
+ let corePath = path.resolve(skillsDir, category, skillName);
118
+ // Ensure resolved path stays within skillsDir
119
+ if (!corePath.startsWith(path.resolve(skillsDir))) {
120
+ console.warn(` ⚠ Skill ${skillName} path escapes skills directory, skipping`);
121
+ continue;
122
+ }
123
+ if (!await fs.pathExists(corePath)) {
124
+ corePath = path.resolve(skillsDir, skillName);
125
+ if (!corePath.startsWith(path.resolve(skillsDir))) continue;
126
+ }
81
127
  if (!await fs.pathExists(corePath)) continue;
82
128
 
83
129
  const stat = await fs.stat(corePath);
@@ -292,11 +338,28 @@ async function installTeamConfig(platform, projectRoot, dryRun) {
292
338
  * 安装平台配置文件(settings/hooks/rules)
293
339
  */
294
340
  async function installSettings(platform, projectRoot, options, dryRun) {
341
+ // 从文件加载 rules
342
+ const rulesMeta = await loadRulesMetadata();
343
+ const rulesPreset = options.rules || 'recommended';
344
+ const preset = rulesMeta.presets[rulesPreset] || rulesMeta.presets.recommended;
345
+ const ruleNames = preset?.rules || [];
346
+ const rulesDir = getRulesDir();
347
+ const ruleFiles = [];
348
+ for (const name of ruleNames) {
349
+ const filePath = path.join(rulesDir, `${name}.md`);
350
+ if (await fs.pathExists(filePath)) {
351
+ ruleFiles.push({ name, content: await fs.readFile(filePath, 'utf8') });
352
+ }
353
+ }
354
+
295
355
  if (platform === 'codebuddy') {
296
356
  const settingsPath = path.join(projectRoot, '.codebuddy', 'settings.json');
297
357
 
298
358
  if (dryRun) {
299
359
  console.log(chalk.gray(` [dry-run] .codebuddy/settings.json`));
360
+ if (ruleFiles.length > 0) {
361
+ console.log(chalk.gray(` [dry-run] .codebuddy/rules/ (${ruleFiles.length} 条规则)`));
362
+ }
300
363
  return;
301
364
  }
302
365
 
@@ -309,12 +372,19 @@ async function installSettings(platform, projectRoot, options, dryRun) {
309
372
  await fs.writeFile(settingsPath, JSON.stringify(hookTemplate, null, 2));
310
373
  console.log(chalk.green(` ✓ .codebuddy/settings.json`));
311
374
 
375
+ // Install rules for CodeBuddy
376
+ if (ruleFiles.length > 0) {
377
+ const { installRules: installCbRules } = await loadAdapter('codebuddy', 'rules-adapter.js');
378
+ await installCbRules(projectRoot, ruleFiles);
379
+ console.log(chalk.green(` ✓ .codebuddy/rules/ (${ruleFiles.length} 条规则)`));
380
+ }
381
+
312
382
  } else if (platform === 'claude') {
313
383
  const claudeDir = path.join(projectRoot, '.claude');
314
384
 
315
385
  if (dryRun) {
316
386
  console.log(chalk.gray(` [dry-run] .claude/settings.json`));
317
- console.log(chalk.gray(` [dry-run] .claude/rules/`));
387
+ console.log(chalk.gray(` [dry-run] .claude/rules/ (${ruleFiles.length} 条规则)`));
318
388
  return;
319
389
  }
320
390
 
@@ -363,28 +433,9 @@ async function installSettings(platform, projectRoot, options, dryRun) {
363
433
  console.log(chalk.green(` ✓ .claude/settings.json`));
364
434
 
365
435
  // Rules
366
- const rulesDir = path.join(claudeDir, 'rules');
367
- await fs.ensureDir(rulesDir);
368
-
369
- const rules = [
370
- {
371
- filename: 'prizm-documentation.md',
372
- content: `---\ndescription: "PrizmKit documentation rules"\nglobs:\n - "**/*.ts"\n - "**/*.tsx"\n - "**/*.js"\n - "**/*.jsx"\n - "**/*.py"\n - "**/*.go"\n - "**/*.rs"\n - "**/*.java"\n---\n\nWhen modifying source files in this project:\n1. Check if \`.prizm-docs/root.prizm\` exists\n2. If it does, read it before making changes to understand project structure\n3. After making changes, update affected \`.prizm-docs/\` files\n4. Follow the Prizm doc format (KEY: value, not prose)\n5. Size limits: L0 = 4KB, L1 = 3KB, L2 = 5KB\n`,
373
- },
374
- {
375
- filename: 'prizm-commit-workflow.md',
376
- content: `---\ndescription: "PrizmKit commit workflow rules"\n---\n\nBefore any git commit in this project:\n1. Update \`.prizm-docs/\` for affected modules\n2. Use Conventional Commits format: type(scope): description\n3. Bug fixes use \`fix()\` prefix, not \`feat()\`\n4. Do NOT create REGISTRY.md entries for bug fixes\n5. Use \`/prizmkit-committer\` command for the complete commit workflow\n`,
377
- },
378
- {
379
- filename: 'prizm-progressive-loading.md',
380
- content: `---\ndescription: "PrizmKit progressive context loading protocol"\n---\n\nThis project uses PrizmKit's progressive loading protocol:\n- ON SESSION START: Read \`.prizm-docs/root.prizm\` (L0 — project map)\n- ON TASK: Read L1 (\`.prizm-docs/<module>.prizm\`) for relevant modules\n- ON FILE EDIT: Read L2 (\`.prizm-docs/<module>/<submodule>.prizm\`) before modifying\n- NEVER load all .prizm docs at once\n- Arrow notation (->) in .prizm files indicates load pointers\n- DECISIONS and CHANGELOG in .prizm files are append-only\n`,
381
- },
382
- ];
383
-
384
- for (const rule of rules) {
385
- await fs.writeFile(path.join(rulesDir, rule.filename), rule.content);
386
- }
387
- console.log(chalk.green(` ✓ .claude/rules/ (${rules.length} 条规则)`));
436
+ const { installRules: installClaudeRules } = await loadAdapter('claude', 'rules-adapter.js');
437
+ await installClaudeRules(projectRoot, ruleFiles);
438
+ console.log(chalk.green(` ✓ .claude/rules/ (${ruleFiles.length} 条规则)`));
388
439
  }
389
440
  }
390
441
 
@@ -393,11 +444,19 @@ async function installSettings(platform, projectRoot, options, dryRun) {
393
444
  */
394
445
  async function installProjectMemory(platform, projectRoot, dryRun) {
395
446
  const templatesDir = getTemplatesDir();
447
+ const skillsDir = getSkillsDir();
396
448
  const templateName = platform === 'claude' ? 'claude-md-template.md' : 'codebuddy-md-template.md';
397
449
  const targetName = platform === 'claude' ? 'CLAUDE.md' : 'CODEBUDDY.md';
398
- const templatePath = path.join(templatesDir, templateName);
399
450
  const targetPath = path.join(projectRoot, targetName);
400
451
 
452
+ // Prefer core/templates, fallback to prizm-kit/assets in hierarchical or flat skills layouts.
453
+ const templateCandidates = [
454
+ path.join(templatesDir, templateName),
455
+ path.join(skillsDir, 'prizmkit-skill', 'prizm-kit', 'assets', templateName),
456
+ path.join(skillsDir, 'prizm-kit', 'assets', templateName),
457
+ ];
458
+ const templatePath = templateCandidates.find(candidate => fs.pathExistsSync(candidate));
459
+
401
460
  if (await fs.pathExists(targetPath)) {
402
461
  console.log(chalk.yellow(` ⚠ ${targetName} 已存在,跳过`));
403
462
  return;
@@ -408,7 +467,7 @@ async function installProjectMemory(platform, projectRoot, dryRun) {
408
467
  return;
409
468
  }
410
469
 
411
- if (await fs.pathExists(templatePath)) {
470
+ if (templatePath && await fs.pathExists(templatePath)) {
412
471
  await fs.copy(templatePath, targetPath);
413
472
  console.log(chalk.green(` ✓ ${targetName}`));
414
473
  } else {
@@ -492,14 +551,17 @@ async function installGitignore(projectRoot, options, dryRun) {
492
551
  * 执行纯净安装
493
552
  * @param {Object} config
494
553
  * @param {string} config.platform - 'codebuddy' | 'claude' | 'both'
495
- * @param {string} config.skills - 'full' | 'core' | 'minimal'
554
+ * @param {string} config.skills - 'full' | 'core' | 'minimal' | 'recommended:<type>'
496
555
  * @param {boolean} config.team - 是否启用团队模式
497
556
  * @param {boolean} config.pipeline - 是否安装 dev-pipeline
557
+ * @param {string} [config.rules] - Rules preset: 'recommended' | 'minimal' | 'none'
558
+ * @param {string} [config.aiCli] - AI CLI 可执行命令(写入 .prizmkit/config.json)
559
+ * @param {string[]} [config.externalSkills] - 要安装的外部 skill 名称列表
498
560
  * @param {string} config.projectRoot - 目标项目根目录
499
561
  * @param {boolean} config.dryRun - 是否为预览模式
500
562
  */
501
563
  export async function scaffold(config) {
502
- const { platform, skills, team, pipeline, projectRoot, dryRun } = config;
564
+ const { platform, skills, team, pipeline, rules, aiCli, externalSkills, projectRoot, dryRun } = config;
503
565
  const platforms = platform === 'both' ? ['codebuddy', 'claude'] : [platform];
504
566
 
505
567
  if (dryRun) {
@@ -531,7 +593,7 @@ export async function scaffold(config) {
531
593
 
532
594
  // 4. Settings/Hooks/Rules
533
595
  console.log(chalk.blue('\n 平台配置:'));
534
- await installSettings(p, projectRoot, { pipeline }, dryRun);
596
+ await installSettings(p, projectRoot, { pipeline, rules }, dryRun);
535
597
 
536
598
  // 5. Project Memory
537
599
  console.log(chalk.blue('\n 项目记忆文件:'));
@@ -551,6 +613,46 @@ export async function scaffold(config) {
551
613
  console.log(chalk.blue(' 项目配置:'));
552
614
  await installGitignore(projectRoot, { pipeline }, dryRun);
553
615
 
616
+ // 8. 写入 .prizmkit/config.json(如果指定了 aiCli)
617
+ if (aiCli) {
618
+ const prizmkitDir = path.join(projectRoot, '.prizmkit');
619
+ const configPath = path.join(prizmkitDir, 'config.json');
620
+
621
+ if (dryRun) {
622
+ console.log(chalk.gray(` [dry-run] .prizmkit/config.json (ai_cli: ${aiCli})`));
623
+ } else {
624
+ await fs.ensureDir(prizmkitDir);
625
+ let existingConfig = {};
626
+ if (await fs.pathExists(configPath)) {
627
+ existingConfig = await fs.readJSON(configPath);
628
+ }
629
+ existingConfig.ai_cli = aiCli;
630
+ await fs.writeJSON(configPath, existingConfig, { spaces: 2 });
631
+ console.log(chalk.green(` ✓ .prizmkit/config.json (ai_cli: ${aiCli})`));
632
+ }
633
+ }
634
+
635
+ // 9. 安装外部 Skills(如果选择了)
636
+ if (externalSkills?.length) {
637
+ const { installExternalSkill } = await import('./external-skills.js');
638
+ const metadata = await loadMetadata();
639
+ const knownSkills = metadata.external_skills?.known || [];
640
+ console.log(chalk.blue('\n 外部技能:'));
641
+ for (const name of externalSkills) {
642
+ const skillDef = knownSkills.find(s => s.name === name);
643
+ if (skillDef) {
644
+ for (const p of platforms) {
645
+ try {
646
+ await installExternalSkill(skillDef, p, projectRoot, dryRun);
647
+ console.log(chalk.green(` ✓ ${name} (external)`));
648
+ } catch (e) {
649
+ console.log(chalk.yellow(` ⚠ ${name} 拉取失败,跳过: ${e.message}`));
650
+ }
651
+ }
652
+ }
653
+ }
654
+ }
655
+
554
656
  // === 完成 ===
555
657
  console.log('');
556
658
  console.log(chalk.bold(' ════════════════════════════════════════════════'));
@@ -581,16 +683,18 @@ export async function scaffold(config) {
581
683
  console.log('');
582
684
 
583
685
  // 安装统计
584
- const metadata = await loadMetadata();
585
686
  const suiteLabel = skills === 'full' ? `全部 ${skillList.length} 个`
586
687
  : skills === 'core' ? `核心 ${skillList.length} 个`
587
- : `最小 ${skillList.length} 个`;
688
+ : skills === 'minimal' ? `最小 ${skillList.length} 个`
689
+ : `推荐 ${skillList.length} 个`;
588
690
 
589
691
  console.log(chalk.gray(` 安装统计:`));
590
692
  console.log(chalk.gray(` 技能: ${suiteLabel}`));
591
693
  console.log(chalk.gray(` 平台: ${platforms.map(p => p === 'codebuddy' ? 'CodeBuddy' : 'Claude Code').join(' + ')}`));
592
694
  console.log(chalk.gray(` 团队: ${team ? '已启用' : '未启用'}`));
593
695
  console.log(chalk.gray(` 流水线: ${pipeline ? '已安装' : '未安装'}`));
696
+ console.log(chalk.gray(` 规则: ${rules || 'recommended'}`));
697
+ if (aiCli) console.log(chalk.gray(` AI CLI: ${aiCli}`));
594
698
  console.log('');
595
699
  }
596
700
  }
@@ -1,356 +0,0 @@
1
- ---
2
- name: "prizmkit-bug-fix-workflow"
3
- tier: 1
4
- description: "[Tier 1] End-to-end bug fix workflow: triage → reproduce → fix → verify → commit. Orchestrates existing skills into a closed-loop 5-phase pipeline with standardized input/output artifacts. (project)"
5
- ---
6
-
7
- # PrizmKit Bug Fix Workflow
8
-
9
- End-to-end orchestration skill for bug fixes. Chains existing PrizmKit skills (error-triage, bug-reproducer, implement, code-review, committer) into a closed-loop 5-phase pipeline with standardized artifacts.
10
-
11
- ## Overview
12
-
13
- ```
14
- bug-planner → bug-fix-list.json → Bug Fix Pipeline → fix-plan.md + fix-report.md
15
- (plan) (input) (5 phases) (2 artifacts per bug)
16
- ```
17
-
18
- ### Pipeline Phases
19
-
20
- | Phase | Name | Skill Used | Artifact |
21
- |-------|------|-----------|----------|
22
- | 1 | Triage 分诊 | `prizmkit.error-triage` | → `fix-plan.md` |
23
- | 2 | Reproduce 复现 | `prizmkit.bug-reproduce` | (reproduction test) |
24
- | 3 | Fix 修复 | `prizmkit.implement` | (code changes) |
25
- | 4 | Verify 验证 | `prizmkit.code-review` | (review report) |
26
- | 5 | Commit & Learn | `prizmkit.committer` | → `fix-report.md` |
27
-
28
- ### Artifacts — Fixed at 2, NEVER more
29
-
30
- Each bug produces exactly **2 artifact documents**:
31
-
32
- 1. **`fix-plan.md`** — Generated after Phase 1 Triage. Contains root cause analysis, impact assessment, test strategy, and fix approach.
33
- 2. **`fix-report.md`** — Generated after Phase 5 Commit. Contains fix details, verification results, knowledge captured, and acceptance criteria verification.
34
-
35
- Artifacts are stored at: `.prizmkit/bugfix/<BUG_ID>/`
36
-
37
- ## Commands
38
-
39
- ### prizmkit.bug-fix \<bug-description-or-error\>
40
-
41
- Execute the full bug fix pipeline for a single bug.
42
-
43
- **INPUT FORMATS** (any of the following):
44
- - Natural language bug description
45
- - Stack trace / error log
46
- - Failed test case output
47
- - User reproduction steps
48
- - Reference to a `bug-fix-list.json` entry
49
-
50
- ### prizmkit.bug-fix-batch \<bug-fix-list.json\>
51
-
52
- Execute the bug fix pipeline for all pending bugs in a standardized `bug-fix-list.json` file.
53
-
54
- - Processes bugs in priority order (lower priority number = processed first)
55
- - Skips bugs with status ≠ `pending`
56
- - Updates status in `bug-fix-list.json` as each bug progresses through phases
57
-
58
- ---
59
-
60
- ## Phase 1: Triage — 分诊分类
61
-
62
- **Goal**: Classify the bug, identify scope and severity, check known issues, produce `fix-plan.md`.
63
-
64
- **STEPS:**
65
-
66
- 1. **Parse bug input**: Extract:
67
- - Error message / stack trace (if provided)
68
- - Expected vs actual behavior
69
- - Steps to reproduce (if provided)
70
- - Environment details (OS, runtime, browser)
71
- - Affected feature / module (if identifiable)
72
-
73
- 2. **Invoke `prizmkit.error-triage`**:
74
- - Receive: error category, subcategory, root cause analysis, affected files
75
- - Receive: severity rating (CRITICAL / HIGH / MEDIUM / LOW)
76
-
77
- 3. **Check TRAPS for known issues**:
78
- - Read `.prizm-docs/` TRAPS sections for identified modules
79
- - If matching trap found:
80
- - Set `KNOWN_ISSUE=true`, `SKIP_REPRODUCE=true`
81
- - Include documented solution in fix-plan.md
82
- - Jump to Phase 3
83
-
84
- 4. **Generate `fix-plan.md`** at `.prizmkit/bugfix/<BUG_ID>/fix-plan.md`:
85
-
86
- Required sections:
87
- - **Bug Summary**: ID, title, severity, source type, affected feature
88
- - **Root Cause Analysis**: error classification, root cause, call chain, TRAP match status
89
- - **Impact Assessment**: directly affected files (with impact level), potentially affected modules (with risk level), cross-module impact notes
90
- - **Test Strategy**: verification type, reproduction test design, regression test plan, manual verification steps (if verification_type=manual/hybrid)
91
- - **Fix Approach**: proposed fix, fix scope (estimated lines changed), constraints
92
-
93
- **CHECKPOINT CP-BF-1**: `fix-plan.md` exists.
94
-
95
- **DECISION GATE — Fast Path**:
96
- - If severity ∈ {low, medium} AND root cause confidence is HIGH AND estimated change < 10 lines:
97
- → Skip Phase 2, go directly to Phase 3
98
- - Otherwise → proceed to Phase 2
99
-
100
- ---
101
-
102
- ## Phase 2: Reproduce — 复现确认
103
-
104
- **Goal**: Create an automated reproduction that proves the bug exists.
105
-
106
- **STEPS:**
107
-
108
- 1. **Invoke `prizmkit.bug-reproduce`** with triage results and bug description
109
-
110
- 2. **Receive and execute reproduction**:
111
- - Run the generated reproduction test
112
- - Verify it FAILS (proving the bug exists)
113
-
114
- 3. **Handle reproduction result**:
115
- - **Success** (test fails as expected): record as regression baseline, proceed to Phase 3
116
- - **Failure** (cannot reproduce): refine and retry, **max 2 rounds**
117
- - **After 2 failed rounds**: set status to `needs_info`, output questions for reporter, STOP
118
-
119
- **CHECKPOINT CP-BF-2**: Reproduction test exists and FAILS.
120
-
121
- **KEY RULES:**
122
- - Reproduction test MUST be automated
123
- - MUST fail with current code and pass after fix
124
- - Use project's existing test framework and conventions
125
- - Naming convention: `test_bugfix_<short-description>.<ext>`
126
-
127
- ---
128
-
129
- ## Phase 3: Fix — 修复实现
130
-
131
- **Goal**: Implement the fix using TDD — reproduction test goes red → green.
132
-
133
- **STEPS:**
134
-
135
- 1. **Read context**: fix-plan.md, reproduction test, `.prizm-docs/` (TRAPS, RULES, PATTERNS)
136
-
137
- 2. **Plan fix** (lightweight, inline — NO spec/plan/tasks files):
138
- - Identify exact code location(s) to modify
139
- - Determine minimal fix approach
140
- - Assess regression risk
141
-
142
- 3. **Implement fix** via `prizmkit.implement` in TDD mode:
143
- - Reproduction test is the "red test"
144
- - Implement minimal code change to make it pass
145
- - Ensure all existing tests still pass
146
-
147
- 4. **Local verification**:
148
- - Reproduction test → MUST PASS (green)
149
- - Module test suite → MUST PASS (no regression)
150
-
151
- **CHECKPOINT CP-BF-3**: Reproduction test passes, module tests pass.
152
-
153
- **FIX LOOP**: Max 3 rounds. If still failing → escalate to user.
154
-
155
- **KEY RULES:**
156
- - Do NOT create `.prizmkit/specs/` directories
157
- - Do NOT create spec.md, plan.md, or tasks.md
158
- - Fix MUST be minimal and targeted — no scope creep
159
- - If fix requires architectural changes → STOP, recommend creating a Feature instead
160
-
161
- ---
162
-
163
- ## Phase 4: Verify — 代码审查与回归验证
164
-
165
- **Goal**: Ensure fix correctness and zero regressions.
166
-
167
- **STEPS:**
168
-
169
- 1. **Invoke `prizmkit.code-review`** (scoped to changed files only):
170
- - Review dimensions for bug fix:
171
- - **Fix correctness**: Does it address the root cause?
172
- - **Regression safety**: Does it break existing behavior?
173
- - **Code quality**: Is the fix clean and maintainable?
174
- - **Test coverage**: Is the reproduction test adequate?
175
- - Verdict: PASS / PASS_WITH_WARNINGS / NEEDS_FIXES
176
-
177
- 2. **Run full test suite**: All tests MUST pass
178
-
179
- 3. **Handle review results**:
180
- - PASS / PASS_WITH_WARNINGS → proceed to Phase 5
181
- - NEEDS_FIXES → return to Phase 3 (max 2 review rounds)
182
-
183
- **CHECKPOINT CP-BF-4**: Code review passes, all tests green.
184
-
185
- **MANUAL VERIFICATION GATE** (when verification_type=manual or hybrid):
186
- - Pipeline PAUSES after automated review passes
187
- - Output UAT checklist from fix-plan.md
188
- - Set status to `verifying`, wait for user confirmation
189
- - Resume to Phase 5 after user sign-off
190
-
191
- ---
192
-
193
- ## Phase 5: Commit & Learn — 提交与知识积累
194
-
195
- **Goal**: Commit with proper conventions, capture lessons, generate `fix-report.md`.
196
-
197
- **STEPS:**
198
-
199
- 1. **Invoke `prizmkit.committer`**:
200
- - Commit message: `fix(<scope>): <description>`
201
- - Include fix code + reproduction test
202
- - Do NOT run `prizmkit.summarize` (no REGISTRY.md entry)
203
- - Do NOT push
204
-
205
- 2. **Update TRAPS** (if new pitfall discovered):
206
- - Append to affected module's TRAPS section in `.prizm-docs/`
207
- - Format: `- TRAP: <description> | FIX: <solution> | DATE: YYYY-MM-DD`
208
- - If no new pitfall: skip
209
-
210
- 3. **Generate `fix-report.md`** at `.prizmkit/bugfix/<BUG_ID>/fix-report.md`:
211
-
212
- Required sections:
213
- - **Bug Resolution Summary**: ID, title, status (✅ FIXED), phases completed, duration
214
- - **What Was Fixed**: changes made (file, change type, description), diff summary, commit message
215
- - **Verification Results**: reproduction test before/after, regression test results, review verdict
216
- - **Knowledge Captured**: TRAPS updated (yes/no with details), prevention recommendation
217
- - **Acceptance Criteria Verification**: checklist with pass/fail for each criterion
218
-
219
- Additional sections (when verification_type=manual or hybrid):
220
- - **Manual Verification Results**: UAT checklist results, sign-off status, reviewer, date
221
-
222
- **CHECKPOINT CP-BF-5**: Commit recorded, fix-report.md written.
223
-
224
- ---
225
-
226
- ## Fast Path — 快速修复路径
227
-
228
- For LOW/MEDIUM severity bugs with obvious root cause and high confidence:
229
-
230
- ```
231
- Phase 1 (Triage) → Phase 3 (Fix) → Phase 5 (Commit)
232
- ```
233
-
234
- Skip Phase 2 (Reproduce) and Phase 4 (full Review).
235
- - Still write a basic test for the fix
236
- - Still use `fix(<scope>):` commit convention
237
- - Still update TRAPS if applicable
238
- - Still generate both fix-plan.md and fix-report.md
239
-
240
- **CRITERIA**:
241
- - Triage confidence is HIGH
242
- - Root cause is a single, obvious code error
243
- - Fix is less than 10 lines of code changes
244
- - No cross-module impact
245
-
246
- ---
247
-
248
- ## Status Mapping
249
-
250
- `bug-fix-list.json` status values map to pipeline phases:
251
-
252
- | Phase | Entry Status | In-Progress | Success Exit | Failure Exit |
253
- |-------|-------------|-------------|-------------|-------------|
254
- | Phase 1: Triage | `pending` | `triaging` | → `reproducing` | → `failed` |
255
- | Phase 2: Reproduce | `reproducing` | `reproducing` | → `fixing` | → `needs_info` |
256
- | Phase 3: Fix | `fixing` | `fixing` | → `verifying` | → `failed` (3 rounds) |
257
- | Phase 4: Verify | `verifying` | `verifying` | → Phase 5 | → `fixing` (return) |
258
- | Phase 5: Commit | — | — | → `completed` | → `failed` |
259
-
260
- ---
261
-
262
- ## Knowledge Accumulation Mechanism
263
-
264
- ### Automatic TRAPS Update
265
-
266
- After each successful bug fix (Phase 5):
267
- - If new pitfall discovered (not previously in TRAPS):
268
- → Append to `.prizm-docs/<affected-module>.prizm` TRAPS section
269
- - If `affected_feature` is set:
270
- → Cross-reference original Feature ID in TRAPS entry
271
-
272
- ### Bug Pattern Analysis (optional, manual trigger)
273
-
274
- When `.prizmkit/bugfix/` accumulates 5+ completed bugs:
275
- - Analyze `error_source.type` distribution
276
- - Analyze `severity` distribution trends
277
- - Analyze `affected_modules` frequency (identify fragile modules)
278
- - Output recommendations for preventive refactoring
279
-
280
- ### Feature Quality Tracking
281
-
282
- When `affected_feature` is non-empty:
283
- - If same Feature accumulates 3+ bugs → flag as "needs-revisit"
284
-
285
- ---
286
-
287
- ## Error Handling
288
-
289
- | Scenario | Action |
290
- |----------|--------|
291
- | Cannot parse bug description | Ask user for clarification |
292
- | Triage returns LOW confidence | Proceed with warning |
293
- | Cannot reproduce after 2 rounds | STOP, set `needs_info`, request more info |
294
- | Fix fails after 3 rounds | Escalate to user with analysis |
295
- | Review fails after 2 rounds | Escalate with review findings |
296
- | Full test suite has pre-existing failures | Warn user, isolate bug fix tests |
297
- | Fix requires architectural change | STOP, recommend Feature instead |
298
- | verification_type=manual and no user response | Keep status `verifying`, wait |
299
-
300
- ---
301
-
302
- ## Relationship to Other Skills
303
-
304
- | Skill | Role in Bug Fix Workflow |
305
- |-------|------------------------|
306
- | `prizmkit-error-triage` | Phase 1: error classification and root cause analysis |
307
- | `prizmkit-bug-reproducer` | Phase 2: generate minimal reproduction |
308
- | `prizmkit-implement` | Phase 3: TDD-style fix implementation |
309
- | `prizmkit-code-review` | Phase 4: review fix correctness |
310
- | `prizmkit-committer` | Phase 5: commit with `fix()` convention |
311
- | `prizmkit-log-analyzer` | Optional: analyze logs if bug includes log files |
312
- | `bug-planner` | Pre-pipeline: generate standardized `bug-fix-list.json` |
313
- | `prizmkit-retrospective` | NOT used (bug fixes don't get retrospectives) |
314
- | `prizmkit-summarize` | NOT used (no REGISTRY entries for bugs) |
315
- | `prizmkit-specify` | NOT used (no spec.md for bugs) |
316
- | `prizmkit-plan` | NOT used (no plan.md for bugs) |
317
- | `prizmkit-tasks` | NOT used (no tasks.md for bugs) |
318
- | `refactor-workflow` | NOT used (separate pipeline for refactoring) |
319
-
320
- ---
321
-
322
- ## Comparison with Feature and Refactor Pipelines
323
-
324
- | Dimension | Feature Pipeline | Refactor Workflow | Bug Fix Pipeline |
325
- |-----------|-----------------|-------------------|------------------|
326
- | Input Skill | `app-planner` (7-phase interactive) | Direct invocation (prizmkit.refactor) | `bug-planner` (multi-format parser) |
327
- | Input File | `feature-list.json` (F-NNN) | N/A (conversation trigger) | `bug-fix-list.json` (B-NNN) |
328
- | Schema Version | `dev-pipeline-feature-list-v1` | N/A | `dev-pipeline-bug-fix-list-v1` |
329
- | Pipeline Phases | 7 Phase (Fast Path: 5) | 6 Phase (Fast Path: 4) | 5 Phase (Fast Path: 3) |
330
- | Phase 1 | Specify (spec.md) | Analyze (refactor-analysis.md) | Triage (fix-plan.md) |
331
- | Artifact Docs | 3: spec.md + plan.md + tasks.md | 3: refactor-analysis.md + plan.md + tasks.md | 2: fix-plan.md + fix-report.md |
332
- | Artifact Path | `.prizmkit/specs/<feature-slug>/` | `.prizmkit/refactor/<slug>/` | `.prizmkit/bugfix/<bug-id>/` |
333
- | Prompt Template | `bootstrap-prompt.md` | N/A (in-session) | `bugfix-bootstrap-prompt.md` |
334
- | Skills Chain | specify → plan → tasks → implement → review → summarize → commit | tech-debt-tracker → plan → tasks → implement → review → commit | error-triage → bug-reproduce → implement → code-review → commit |
335
- | Commit Prefix | `feat(<scope>):` | `refactor(<scope>):` | `fix(<scope>):` |
336
- | REGISTRY Update | ✅ via summarize | ❌ not applicable | ❌ not applicable |
337
- | TRAPS Update | Only in retrospective | Resolved TRAPS removed | ✅ automatic after every fix |
338
- | Test Strategy | TDD per task | Full suite after EVERY task | Reproduction test |
339
- | Scope Guard | N/A | ✅ (enforced) | N/A |
340
- | Behavior Change | ✅ Expected | ❌ Forbidden | ✅ Fix behavior |
341
- | Manual Verification | None | None | Supported (verification_type=manual/hybrid) |
342
- | Agent Roles | PM → Dev → Reviewer → Doc | Dev → Reviewer (streamlined) | Dev → Reviewer (streamlined) |
343
-
344
- ## Path References
345
-
346
- All internal asset paths MUST use `${SKILL_DIR}` placeholder for cross-IDE compatibility.
347
-
348
- ## Output
349
-
350
- - `fix-plan.md` (Phase 1 artifact)
351
- - Reproduction test file (Phase 2)
352
- - Fix implementation (Phase 3)
353
- - Code review report (Phase 4, conversation only)
354
- - `fix-report.md` (Phase 5 artifact)
355
- - Git commit with `fix(<scope>):` prefix (Phase 5)
356
- - Updated `.prizm-docs/` TRAPS (if applicable)
@@ -1,38 +0,0 @@
1
- ## PrizmKit Documentation Framework
2
-
3
- This project uses PrizmKit with the Prizm documentation system for AI-optimized progressive context loading.
4
-
5
- ### Progressive Loading Protocol
6
- - ON SESSION START: Always read `.prizm-docs/root.prizm` first (L0 — project map)
7
- - ON TASK: Read L1 (`.prizm-docs/<module>.prizm`) for relevant modules referenced in MODULE_INDEX
8
- - ON FILE EDIT: Read L2 (`.prizm-docs/<module>/<submodule>.prizm`) before modifying files. Pay attention to TRAPS and DECISIONS.
9
- - NEVER load all .prizm docs at once. Load only what is needed for the current task.
10
-
11
- ### Auto-Update Protocol
12
- - BEFORE EVERY COMMIT: Update affected `.prizm-docs/` files
13
- - The `.claude/rules/` files will enforce this automatically
14
- - Use `/prizmkit-committer` command for the complete commit workflow
15
-
16
- ### Doc Format Rules
17
- - All `.prizm` files use KEY: value format, not prose
18
- - Size limits: L0 = 4KB, L1 = 3KB, L2 = 5KB
19
- - Arrow notation (->) indicates load pointers to other .prizm docs
20
- - DECISIONS and CHANGELOG are append-only (never delete entries)
21
-
22
- ### Creating New L2 Docs
23
- - When you first modify files in a sub-module that has no L2 doc:
24
- 1. Read the source files in that sub-module
25
- 2. Generate a new L2 `.prizm` file following Prizm specification
26
- 3. Add a pointer in the parent L1 doc's SUBDIRS section
27
-
28
- ### Available Commands
29
- Run `/prizm-kit` to see all available PrizmKit commands.
30
-
31
- ### Fast Path for Simple Changes
32
- Not every change needs the full spec -> plan -> tasks workflow. Use fast path for:
33
- - Bug fixes with clear root cause, config tweaks, typo fixes, simple refactors
34
- - Documentation-only changes, test additions for existing code
35
- - Directly use `/prizmkit-implement` with inline task description, then `/prizmkit-committer`
36
-
37
- Use the full workflow (/prizmkit-specify -> /prizmkit-plan -> /prizmkit-tasks -> /prizmkit-analyze -> /prizmkit-implement) for:
38
- - New features, multi-file coordinated changes, architectural decisions, data model or API changes