@zhuan-ai/zhuanspec 2.15.7 → 2.16.2

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 (43) hide show
  1. package/dist/cli/hooks.d.ts +13 -1
  2. package/dist/cli/hooks.js +75 -2
  3. package/dist/cli/index.js +111 -4
  4. package/dist/commands/accuracy.js +5 -1
  5. package/dist/commands/knowledge.d.ts +21 -0
  6. package/dist/commands/knowledge.js +80 -0
  7. package/dist/commands/progress.d.ts +78 -0
  8. package/dist/commands/progress.js +349 -3
  9. package/dist/core/archive.js +28 -0
  10. package/dist/core/configurators/codex.d.ts +55 -1
  11. package/dist/core/configurators/codex.js +234 -2
  12. package/dist/core/corrections/select-candidates.d.ts +58 -0
  13. package/dist/core/corrections/select-candidates.js +357 -0
  14. package/dist/core/hooks/collect-knowledge.js +80 -5
  15. package/dist/core/hooks/deviation-check.d.ts +26 -1
  16. package/dist/core/hooks/deviation-check.js +32 -184
  17. package/dist/core/hooks/knowledge-index.d.ts +84 -0
  18. package/dist/core/hooks/knowledge-index.js +270 -0
  19. package/dist/core/hooks/post-archive.js +25 -13
  20. package/dist/core/hooks/record-progress.d.ts +64 -1
  21. package/dist/core/hooks/record-progress.js +224 -54
  22. package/dist/core/hooks/summarize.js +107 -20
  23. package/dist/core/hooks/user-input-hook.d.ts +38 -2
  24. package/dist/core/hooks/user-input-hook.js +346 -21
  25. package/dist/core/init.d.ts +16 -0
  26. package/dist/core/init.js +208 -11
  27. package/dist/core/metrics/code-accuracy.d.ts +152 -3
  28. package/dist/core/metrics/code-accuracy.js +323 -19
  29. package/dist/core/templates/agents-root-stub.d.ts +1 -1
  30. package/dist/core/templates/agents-root-stub.js +1 -0
  31. package/dist/core/templates/agents-template.d.ts +1 -1
  32. package/dist/core/templates/agents-template.js +27 -25
  33. package/dist/core/templates/codex-hooks-template.d.ts +37 -0
  34. package/dist/core/templates/codex-hooks-template.js +33 -2
  35. package/dist/core/templates/slash-command-templates.js +208 -66
  36. package/dist/core/templates/tasks-template.js +66 -14
  37. package/dist/core/update.js +17 -0
  38. package/dist/core/validation/strict-rules.d.ts +28 -0
  39. package/dist/core/validation/strict-rules.js +284 -0
  40. package/dist/utils/hook-merge.d.ts +6 -0
  41. package/dist/utils/hook-merge.js +33 -2
  42. package/dist/utils/phase-utils.js +5 -0
  43. package/package.json +22 -20
@@ -10,5 +10,17 @@
10
10
  * - summarize: Stop hook - Summarize session progress
11
11
  * - review-*: Review phase hooks - Check skill outputs and control fix loops
12
12
  */
13
- export {};
13
+ /**
14
+ * Phase Transition Check - Unified function for phase transition validation
15
+ */
16
+ export declare function runPhaseTransitionCheck(options: {
17
+ from?: string;
18
+ to?: string;
19
+ change?: string;
20
+ }): Promise<{
21
+ continue: boolean;
22
+ systemMessage?: string;
23
+ checks?: Record<string, boolean>;
24
+ requiresUserConfirmation?: boolean;
25
+ }>;
14
26
  //# sourceMappingURL=hooks.d.ts.map
package/dist/cli/hooks.js CHANGED
@@ -16,6 +16,7 @@ import { deviationCheckHook } from '../core/hooks/deviation-check.js';
16
16
  import { recordProgressHook, initializeProgress } from '../core/hooks/record-progress.js';
17
17
  import { collectKnowledgeHook } from '../core/hooks/collect-knowledge.js';
18
18
  import { summarizeHook } from '../core/hooks/summarize.js';
19
+ import { runUserInputHook } from '../core/hooks/user-input-hook.js';
19
20
  import { preArchiveHook } from '../core/hooks/pre-archive.js';
20
21
  import { postArchiveHook } from '../core/hooks/post-archive.js';
21
22
  import { preApplyHook, checkPreApplyConditions } from '../core/hooks/pre-apply.js';
@@ -47,7 +48,17 @@ program
47
48
  .option('--trigger <type>', 'Trigger type: pre-tool|post-prompt|resume')
48
49
  .option('--prompt <text>', 'Prompt content for post-prompt checks')
49
50
  .action(async (options) => {
50
- await deviationCheckHook(options);
51
+ // v2.15.16 Sprint 3:'post-prompt' 分支已由 user-input-hook 接管,此处保留参数仅为
52
+ // 兼容 v2.15.14 及更早版本的 .claude/settings.json(未执行过 zhuanspec update)。
53
+ // 收到 post-prompt 时直接 no-op 返回,避免破坏 UserPromptSubmit 事件链。
54
+ if (options.trigger === 'post-prompt') {
55
+ if (options.json) {
56
+ console.log(JSON.stringify({ continue: true, hookSpecificOutput: { hookEventName: 'UserPromptSubmit' } }));
57
+ }
58
+ return;
59
+ }
60
+ const { trigger, ...rest } = options;
61
+ await deviationCheckHook({ ...rest, trigger: trigger });
51
62
  });
52
63
  // PostToolUse hook - record progress
53
64
  program
@@ -91,6 +102,14 @@ program
91
102
  .action(async (options) => {
92
103
  await summarizeHook(options);
93
104
  });
105
+ // UserPromptSubmit hook - record user input & activate correctionContext from phaseBaselines
106
+ program
107
+ .command('user-input')
108
+ .description('UserPromptSubmit hook - Record user input and activate correction context post-baseline')
109
+ .option('--json', 'Output as JSON for Claude Code consumption (envelope printed regardless)')
110
+ .action(async () => {
111
+ await runUserInputHook();
112
+ });
94
113
  program
95
114
  .command('pre-archive')
96
115
  .description('Pre-archive quality gate')
@@ -295,7 +314,7 @@ program
295
314
  /**
296
315
  * Phase Transition Check - Unified function for phase transition validation
297
316
  */
298
- async function runPhaseTransitionCheck(options) {
317
+ export async function runPhaseTransitionCheck(options) {
299
318
  const cwd = resolveZhuanSpecRoot();
300
319
  const changeId = options.change || process.env.ZHUANSPEC_CHANGE_ID || '';
301
320
  const fromPhase = options.from || process.env.ZHUANSPEC_PHASE || 'idle';
@@ -324,6 +343,60 @@ async function runPhaseTransitionCheck(options) {
324
343
  targetPhase = 'apply';
325
344
  }
326
345
  }
346
+ // === Phase 准确率确认门禅(Task 4)===
347
+ // 规则:上一 phase 存在 phaseAccuracy 桶但未 confirmed 时阻断,
348
+ // systemMessage 指引 AI 调 AskUserQuestion 与 show-phase-accuracy / override-phase / confirm-phase 纠正。
349
+ // 绕过方式:环境变量 ZHUANSPEC_SKIP_ACCURACY_CONFIRM=1(CI/自动化用)。
350
+ const SKIP_CONFIRM = process.env.ZHUANSPEC_SKIP_ACCURACY_CONFIRM === '1';
351
+ const CONFIRMABLE_PHASES = new Set(['techDesign', 'propose', 'apply', 'review']);
352
+ if (!SKIP_CONFIRM && CONFIRMABLE_PHASES.has(fromPhase)) {
353
+ try {
354
+ const progressPath = path.join(changeDir, 'metrics', 'progress.json');
355
+ if (await FileSystemUtils.fileExists(progressPath)) {
356
+ const progressRaw = await FileSystemUtils.readFile(progressPath);
357
+ const progress = JSON.parse(progressRaw);
358
+ const buckets = progress.accuracy?.phaseAccuracy?.filter(b => b.phase === fromPhase) ?? [];
359
+ if (buckets.length > 0) {
360
+ const unconfirmed = buckets.filter(b => !b.confirmed);
361
+ if (unconfirmed.length > 0) {
362
+ // 聚合展示
363
+ const aiTotal = buckets.reduce((s, b) => s + (b.aiTotalLines || 0), 0);
364
+ const correction = buckets.reduce((s, b) => s + (b.userCorrectionLines || 0), 0);
365
+ const avgRate = buckets.length > 0
366
+ ? buckets.reduce((s, b) => s + (b.accuracyRate || 0), 0) / buckets.length
367
+ : 1;
368
+ const rateStr = (avgRate * 100).toFixed(2);
369
+ return {
370
+ continue: false,
371
+ requiresUserConfirmation: true,
372
+ systemMessage: [
373
+ `✗ Phase transition blocked: ${fromPhase} → ${targetPhase}`,
374
+ '',
375
+ `阶段 ${fromPhase} 的准确率尚未被用户确认(桶数=${buckets.length},未确认=${unconfirmed.length})。`,
376
+ `当前数据:rate=${rateStr}%, AI产出=${aiTotal} 行, 用户纠偏=${correction} 行`,
377
+ '',
378
+ '请按以下步骤完成确认:',
379
+ `1. 查看详细数据:zhuanspec progress show-phase-accuracy ${changeId} ${fromPhase}`,
380
+ `2. 向用户提问(AskUserQuestion 或宿主等效工具):`,
381
+ ` 问题:“${fromPhase} 阶段准确率为 ${rateStr}%(AI 产出 ${aiTotal} 行,纠偏 ${correction} 行),是否正确?”`,
382
+ ` 选项A 准确或已内消 → zhuanspec progress confirm-phase ${changeId} ${fromPhase}`,
383
+ ` 选项B 需纠正 → 询问正确率 rate 与原因 reason`,
384
+ ` → zhuanspec progress override-phase ${changeId} ${fromPhase} --rate <0..1> --reason <text>`,
385
+ ` → zhuanspec progress confirm-phase ${changeId} ${fromPhase}`,
386
+ '3. 确认完成后重新运行 phase-transition-check。',
387
+ '',
388
+ '绕过本门禅(CI/自动化):设置 ZHUANSPEC_SKIP_ACCURACY_CONFIRM=1。',
389
+ ].join('\n'),
390
+ };
391
+ }
392
+ }
393
+ // 历史数据 / 无桶:跳过此门禅(fall-through 继续其他检查)
394
+ }
395
+ }
396
+ catch {
397
+ // 读取 progress.json 失败不阻断原有检查链路
398
+ }
399
+ }
327
400
  // Execute appropriate pre-check based on target phase
328
401
  switch (targetPhase) {
329
402
  case 'apply':
package/dist/cli/index.js CHANGED
@@ -286,15 +286,26 @@ progressCmd
286
286
  });
287
287
  // Progress resolve-correction subcommand
288
288
  progressCmd
289
- .command('resolve-correction <change-id>')
290
- .description('Clear pending user-correction marker (Apply phase)')
289
+ .command('resolve-correction <change-id> [path]')
290
+ .description('Clear pending user-correction marker (Apply phase). `path` can be given positionally (A|B|C|D) or via --path.')
291
291
  .option('--path <path>', 'Chosen resolution path: A|B|C|D')
292
292
  .option('--note <text>', 'Optional note to attach to the correction-log entry')
293
293
  .option('--mark-pitfall-saved', 'Also set askedPitfallSaved=true in progress.json to suppress Stop-hook ask')
294
- .action(async (changeId, options) => {
294
+ .action(async (changeId, positionalPath, options) => {
295
295
  try {
296
+ // v2.15.16:兼容位置参数形式 `resolve-correction <change-id> A`。
297
+ // deviation-check 注入到纠偏上下文里的提示里一直用的是位置参数形式,
298
+ // LLM 跳过 --path 直接跳 `A` 是常见误用。
299
+ // 策略:只要有一个来源就画;两个都有且不一致时报错。
300
+ const merged = { ...(options || {}) };
301
+ if (positionalPath) {
302
+ if (merged.path && merged.path !== positionalPath) {
303
+ throw new Error(`Conflicting path: positional '${positionalPath}' vs --path '${merged.path}'. Please specify only one.`);
304
+ }
305
+ merged.path = positionalPath;
306
+ }
296
307
  const progressCommand = new ProgressCommand();
297
- await progressCommand.resolveCorrection(changeId, options);
308
+ await progressCommand.resolveCorrection(changeId, merged);
298
309
  }
299
310
  catch (error) {
300
311
  console.log();
@@ -318,6 +329,102 @@ progressCmd
318
329
  process.exit(1);
319
330
  }
320
331
  });
332
+ // Progress list-corrections subcommand (review-step0 踩坑沉淀决策清单)
333
+ progressCmd
334
+ .command('list-corrections <change-id>')
335
+ .description('Render pending correction candidates (filter trivial acks + dedup) for review-step0 decision making')
336
+ .option('--out <path>', 'Output file path (default: zhuanspec/changes/<id>/review/pending-corrections.md)')
337
+ .option('--json', 'Print result as JSON to stdout instead of writing markdown file')
338
+ .action(async (changeId, options) => {
339
+ try {
340
+ const progressCommand = new ProgressCommand();
341
+ await progressCommand.listCorrections(changeId, options);
342
+ }
343
+ catch (error) {
344
+ console.log();
345
+ ora().fail(`Error: ${error.message}`);
346
+ process.exit(1);
347
+ }
348
+ });
349
+ // Progress mark-baseline subcommand (Task 0 手动路径)
350
+ progressCmd
351
+ .command('mark-baseline <change-id> <phase>')
352
+ .description('Manually mark phase baseline (techDesign|propose|apply|review). After marking, subsequent user prompts that touch whitelist files are counted as corrections.')
353
+ .option('--force', 'Overwrite existing baseline mark')
354
+ .action(async (changeId, phase, options) => {
355
+ try {
356
+ const progressCommand = new ProgressCommand();
357
+ await progressCommand.markBaseline(changeId, phase, options);
358
+ }
359
+ catch (error) {
360
+ console.log();
361
+ ora().fail(`Error: ${error.message}`);
362
+ process.exit(1);
363
+ }
364
+ });
365
+ // Progress recompute subcommand (Task 5 统一重算分阶段准确率)
366
+ progressCmd
367
+ .command('recompute <change-id>')
368
+ .description('Recompute phaseAccuracy buckets and top-level accuracyRate from accuracy.correctionEdits[]')
369
+ .action(async (changeId) => {
370
+ try {
371
+ const progressCommand = new ProgressCommand();
372
+ await progressCommand.recompute(changeId);
373
+ }
374
+ catch (error) {
375
+ console.log();
376
+ ora().fail(`Error: ${error.message}`);
377
+ process.exit(1);
378
+ }
379
+ });
380
+ // Progress override-phase subcommand (分阶段准确率手动修正)
381
+ progressCmd
382
+ .command('override-phase <change-id> <phase>')
383
+ .description('Override accuracy rate for a specific phase (techDesign|propose|apply|review). Raw snapshot is preserved in overrideHistory for differential analysis.')
384
+ .requiredOption('--rate <n>', 'Overridden rate (0.0~1.0)')
385
+ .requiredOption('--reason <text>', 'Reason for override (required for audit trail)')
386
+ .action(async (changeId, phase, options) => {
387
+ try {
388
+ const progressCommand = new ProgressCommand();
389
+ await progressCommand.overridePhase(changeId, phase, options);
390
+ }
391
+ catch (error) {
392
+ console.log();
393
+ ora().fail(`Error: ${error.message}`);
394
+ process.exit(1);
395
+ }
396
+ });
397
+ // Progress confirm-phase subcommand (标记某阶段准确率已被用户确认)
398
+ progressCmd
399
+ .command('confirm-phase <change-id> <phase>')
400
+ .description('Mark a phase accuracy as confirmed by user (required for phase-transition-check to pass)')
401
+ .action(async (changeId, phase) => {
402
+ try {
403
+ const progressCommand = new ProgressCommand();
404
+ await progressCommand.confirmPhase(changeId, phase);
405
+ }
406
+ catch (error) {
407
+ console.log();
408
+ ora().fail(`Error: ${error.message}`);
409
+ process.exit(1);
410
+ }
411
+ });
412
+ // Progress show-phase-accuracy subcommand (只读展示分阶段数据)
413
+ progressCmd
414
+ .command('show-phase-accuracy <change-id> <phase>')
415
+ .description('Show per-bucket accuracy snapshot for a phase (read-only)')
416
+ .option('--json', 'Output as JSON')
417
+ .action(async (changeId, phase, options) => {
418
+ try {
419
+ const progressCommand = new ProgressCommand();
420
+ await progressCommand.showPhaseAccuracy(changeId, phase, options);
421
+ }
422
+ catch (error) {
423
+ console.log();
424
+ ora().fail(`Error: ${error.message}`);
425
+ process.exit(1);
426
+ }
427
+ });
321
428
  // Accuracy command
322
429
  program
323
430
  .command('accuracy [change-name]')
@@ -44,7 +44,11 @@ export class AccuracyCommand {
44
44
  if (isNaN(overrideRate) || overrideRate < 0 || overrideRate > 1) {
45
45
  throw new Error('Override rate must be a number between 0.0 and 1.0');
46
46
  }
47
- const result = applyOverride(progress, overrideRate);
47
+ const result = applyOverride(progress, overrideRate, {
48
+ reason: 'CLI --override',
49
+ changeDir,
50
+ trigger: 'manual-cli',
51
+ });
48
52
  // Persist to progress.json
49
53
  await atomicWriteJson(progressPath, progress);
50
54
  // Also update accuracy.json
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Knowledge Command
3
+ *
4
+ * 管理项目级知识库 zhuanspec/knowledge/。当前仅提供 reindex 子命令:
5
+ * - reindex:扫描三类目录下的 *.md,解析 Front Matter,重建 index.md 三分区
6
+ * (保留 `## Archive Log` 既有内容)。用于回补历史漂移。
7
+ */
8
+ import { Command } from 'commander';
9
+ interface ReindexOptions {
10
+ dryRun?: boolean;
11
+ }
12
+ export declare class KnowledgeCommand {
13
+ reindex(options?: ReindexOptions): Promise<void>;
14
+ }
15
+ /**
16
+ * 在给定的 parent commander Command 上挂载 `reindex` 子命令。
17
+ * 父命令由 cli/index.ts 创建,形如 `zhuanspec knowledge`。
18
+ */
19
+ export declare function registerKnowledgeCommands(parent: Command): void;
20
+ export {};
21
+ //# sourceMappingURL=knowledge.d.ts.map
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Knowledge Command
3
+ *
4
+ * 管理项目级知识库 zhuanspec/knowledge/。当前仅提供 reindex 子命令:
5
+ * - reindex:扫描三类目录下的 *.md,解析 Front Matter,重建 index.md 三分区
6
+ * (保留 `## Archive Log` 既有内容)。用于回补历史漂移。
7
+ */
8
+ import path from 'path';
9
+ import chalk from 'chalk';
10
+ import { FileSystemUtils } from '../utils/file-system.js';
11
+ import { resolveZhuanSpecRoot } from '../utils/resolve-root.js';
12
+ import { rebuildIndexContent, scanKnowledgeEntries, } from '../core/hooks/knowledge-index.js';
13
+ export class KnowledgeCommand {
14
+ async reindex(options = {}) {
15
+ const repoRoot = resolveZhuanSpecRoot(process.cwd());
16
+ const knowledgeDir = path.join(repoRoot, 'zhuanspec', 'knowledge');
17
+ const indexPath = path.join(knowledgeDir, 'index.md');
18
+ if (!(await FileSystemUtils.directoryExists(knowledgeDir))) {
19
+ console.log(chalk.yellow(`⚠ 知识目录不存在:${knowledgeDir}`));
20
+ console.log(chalk.gray(' 未沉淀任何项目知识,无需 reindex。'));
21
+ return;
22
+ }
23
+ const scan = await scanKnowledgeEntries(knowledgeDir);
24
+ const existing = (await FileSystemUtils.fileExists(indexPath))
25
+ ? await FileSystemUtils.readFile(indexPath)
26
+ : null;
27
+ const rebuilt = rebuildIndexContent(scan, existing);
28
+ // 输出扫描摘要
29
+ const counts = {
30
+ troubleshooting: scan.entries.filter((e) => e.category === 'troubleshooting').length,
31
+ bestPractices: scan.entries.filter((e) => e.category === 'best-practices').length,
32
+ implicitConventions: scan.entries.filter((e) => e.category === 'implicit-conventions').length,
33
+ };
34
+ console.log(chalk.cyan('📚 扫描结果:'));
35
+ console.log(chalk.gray(` - troubleshooting : ${counts.troubleshooting} 条`));
36
+ console.log(chalk.gray(` - best-practices : ${counts.bestPractices} 条`));
37
+ console.log(chalk.gray(` - implicit-conventions : ${counts.implicitConventions} 条`));
38
+ if (scan.warnings.length > 0) {
39
+ console.log(chalk.yellow(`\n⚠ 发现 ${scan.warnings.length} 条 Front Matter 不完整,建议尽快补齐:`));
40
+ for (const w of scan.warnings) {
41
+ console.log(chalk.yellow(` ${w}`));
42
+ }
43
+ }
44
+ if (options.dryRun) {
45
+ console.log(chalk.cyan('\n🔎 dry-run:以下为将写入 index.md 的内容\n'));
46
+ console.log(rebuilt);
47
+ console.log(chalk.gray('\n(dry-run 模式未落盘,去掉 --dry-run 即可执行实际重建)'));
48
+ return;
49
+ }
50
+ if (existing !== null && existing === rebuilt) {
51
+ console.log(chalk.green('\n✓ index.md 与扫描结果一致,无需更新。'));
52
+ return;
53
+ }
54
+ await FileSystemUtils.writeFile(indexPath, rebuilt);
55
+ console.log(chalk.green(`\n✓ 已重建 ${path.relative(process.cwd(), indexPath)}`));
56
+ console.log(chalk.gray(' (## Archive Log 既有内容已保留)'));
57
+ }
58
+ }
59
+ /**
60
+ * 在给定的 parent commander Command 上挂载 `reindex` 子命令。
61
+ * 父命令由 cli/index.ts 创建,形如 `zhuanspec knowledge`。
62
+ */
63
+ export function registerKnowledgeCommands(parent) {
64
+ parent
65
+ .command('reindex')
66
+ .description('扫描 zhuanspec/knowledge/ 三类目录并重建 index.md 三分区(保留 Archive Log)')
67
+ .option('--dry-run', '只预览差异,不写文件')
68
+ .action(async (options) => {
69
+ try {
70
+ const cmd = new KnowledgeCommand();
71
+ await cmd.reindex(options ?? {});
72
+ }
73
+ catch (error) {
74
+ console.log();
75
+ console.log(chalk.red(`✗ reindex 失败: ${error.message}`));
76
+ process.exit(1);
77
+ }
78
+ });
79
+ }
80
+ //# sourceMappingURL=knowledge.js.map
@@ -42,6 +42,19 @@ export declare class ProgressCommand {
42
42
  * Resolve pending user-correction: remove `.pending-correction`, append
43
43
  * resolved entry to `.correction-log`, and optionally mark pitfall saved.
44
44
  * Usage: zhuanspec progress resolve-correction <change-id> [--path A|B|C|D] [--note <text>] [--mark-pitfall-saved]
45
+ *
46
+ * @deprecated v2.15.16 Sprint 3 起,`.correction-log` 已从事实源中下线,新 change
47
+ * 的纠偏信号由 user-input-hook 直接写入 `user_inputs.json` 的 correctionSignal /
48
+ * postBaseline / resolution 字段并由 review/knowledge 链路消费。
49
+ *
50
+ * 本命令仅保留给 v2.15.14 及更早版本创建的老 change 做手动兼容:
51
+ * - 仍会删除 `.pending-correction` marker(新旧 change 都需要)
52
+ * - 仍会 append 一条 resolved 记录到 `.correction-log`(仅老 change 会读)
53
+ * - 仍会写 `progress.correctionContext` 用于后续 resolveCorrection 窗口(30 min)
54
+ *
55
+ * 下一个 minor 版本计划迁移:writer 切换到 user_inputs.json.resolution,
56
+ * 届时本命令将退化为一次性提示 + marker 清理。
57
+ * TODO(Sprint 3.2):迁移到 user_inputs.json.resolution 字段
45
58
  */
46
59
  resolveCorrection(changeId: string, options?: {
47
60
  path?: string;
@@ -55,5 +68,70 @@ export declare class ProgressCommand {
55
68
  showCorrection(changeId: string, options?: {
56
69
  tail?: number;
57
70
  }): Promise<void>;
71
+ /**
72
+ * List pending correction candidates with trivial-ack filtering and dedup.
73
+ * Usage: zhuanspec progress list-corrections <change-id> [--out <path>] [--json]
74
+ *
75
+ * 默认会把 markdown 清单写到 `zhuanspec/changes/<id>/review/pending-corrections.md`,
76
+ * 供 review 阶段「踩坑沉淀」步骤的 askUserQuestion 三选项决策使用。
77
+ * `--json` 模式只走 stdout JSON,不写文件,便于 skill / 测试程序消费。
78
+ */
79
+ listCorrections(changeId: string, options?: {
80
+ out?: string;
81
+ json?: boolean;
82
+ }): Promise<void>;
83
+ /**
84
+ * Mark phase baseline manually.
85
+ * Usage: zhuanspec progress mark-baseline <change-id> <phase> [--force]
86
+ *
87
+ * 仅允许 techDesign / propose / apply / review 四个 phase;
88
+ * 若已有 markedAt 且未指定 --force,则报告不改;
89
+ * 否则写入 markedBy='manual-cli' 并 atomicWriteJson 保存。
90
+ */
91
+ markBaseline(changeId: string, phase: string, options?: {
92
+ force?: boolean;
93
+ }): Promise<void>;
94
+ /**
95
+ * Recompute phaseAccuracy buckets and accuracyRate from scratch.
96
+ * Usage: zhuanspec progress recompute <change-id>
97
+ *
98
+ * 流程:
99
+ * 1. 清空 accuracy.phaseAccuracy
100
+ * 2. 遍历 accuracy.correctionEdits,按 (phase, trackedKind) 累加到桶 userCorrectionLines
101
+ * 3. 将非纠偏的 AI 记录按 edit.phase + edit.trackedKind 累加到桶 aiLinesAdded / aiTotalLines
102
+ * 4. recomputeAccuracyRate + persistAccuracyJson
103
+ *
104
+ * 设计说明:历史 correctionEdits 中 source==='user' 的 edit 即为纠偏,
105
+ * source==='ai' 的 edit 则视为 AI 新增行数;顶层聚合字段保持不变。
106
+ */
107
+ recompute(changeId: string): Promise<void>;
108
+ /**
109
+ * Override accuracy rate for a specific phase.
110
+ * Usage: zhuanspec progress override-phase <change-id> <phase> --rate <0..1> --reason <text>
111
+ *
112
+ * 完整保留纠正前的桶级快照(rate/raw/aiTotal/correction)到 overrideHistory,
113
+ * 供事后差异分析 "raw vs overridden delta" 反向驱动改进。
114
+ */
115
+ overridePhase(changeId: string, phase: string, options: {
116
+ rate: string;
117
+ reason?: string;
118
+ }): Promise<void>;
119
+ /**
120
+ * Mark a phase's accuracy as confirmed by user.
121
+ * Usage: zhuanspec progress confirm-phase <change-id> <phase>
122
+ *
123
+ * 对该 phase 的所有桶写入 confirmed: { at, by: 'manual-cli' },
124
+ * 后续 phase-transition-check 判定时会读此标记放行。
125
+ */
126
+ confirmPhase(changeId: string, phase: string): Promise<void>;
127
+ /**
128
+ * Show per-bucket snapshot for a specific phase (read-only).
129
+ * Usage: zhuanspec progress show-phase-accuracy <change-id> <phase>
130
+ *
131
+ * 用于 phase-transition-check 阻断后 AI 先查看数据,再调 AskUserQuestion 纠正。
132
+ */
133
+ showPhaseAccuracy(changeId: string, phase: string, options?: {
134
+ json?: boolean;
135
+ }): Promise<void>;
58
136
  }
59
137
  //# sourceMappingURL=progress.d.ts.map