@xenonbyte/da-vinci-workflow 0.1.23 → 0.1.25

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/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.1.25 - 2026-03-29
4
+
5
+ ### Added
6
+ - `scripts/test-audit-design-supervisor.js` now covers Chinese legacy review headings (for example `## Design-Supervisor Review(第2轮尝试)`) and ensures structured fallback parsing remains deterministic
7
+ - `scripts/test-pen-persistence.js` now verifies metadata-payload error paths prefer concise relative paths when `--nodes-file` is under current working directory
8
+
9
+ ### Changed
10
+ - `pen-persistence` now formats `--nodes-file` metadata-payload error locations using relative paths when possible (absolute path fallback when outside cwd)
11
+ - design-supervisor heading parsing now accepts both ASCII and full-width parentheses in heading suffixes
12
+ - legacy round-attempt heading detection now supports both English `Round ... Attempt` and Chinese `第N轮尝试` variants
13
+
14
+ ## v0.1.24 - 2026-03-29
15
+
16
+ ### Added
17
+ - `da-vinci supervisor-review` now supports structured reviewer provenance fields: `Configured reviewers`, `Executed reviewers`, and `Review source`
18
+ - `design-supervisor` compatibility binary (`design-supervisor review`) that forwards to `da-vinci supervisor-review`
19
+ - `scripts/test-supervisor-review-cli.js` coverage for alias behavior, inferred mode, and skill-source reviewer execution metadata
20
+ - `scripts/test-supervisor-review-integration.js` optional real `codex exec` smoke test (`DA_VINCI_RUN_SUPERVISOR_INTEGRATION=1`)
21
+
22
+ ### Changed
23
+ - supervisor-review audit parsing now prefers the latest structured `## Design-Supervisor Review` block, warns when the newest entry is a legacy/non-structured round attempt, and still supports multiline issue/outcome fields plus `Result` as a status alias
24
+ - completion audit now enforces skill-backed supervisor evidence (`Review source: skill` + executed configured reviewers) when `Require Supervisor Review: true`
25
+ - design prompts/skill docs now require configured reviewer skills to actually execute review before writing supervisor results
26
+ - command references and constraint docs (EN/ZH) now document structured reviewer fields and required skill-backed behavior for hard-gate projects
27
+ - `da-vinci supervisor-review --run-reviewers` now supports parallel execution (`--review-concurrency`) and resilient retries (`--review-retries`, `--review-retry-delay-ms`)
28
+
3
29
  ## v0.1.23 - 2026-03-29
4
30
 
5
31
  ### Added
package/README.md CHANGED
@@ -28,10 +28,14 @@ This workflow is intended for:
28
28
 
29
29
  Latest published npm package:
30
30
 
31
- - `@xenonbyte/da-vinci-workflow@0.1.23`
31
+ - `@xenonbyte/da-vinci-workflow@0.1.25`
32
32
 
33
33
  Release highlights:
34
34
 
35
+ - `da-vinci supervisor-review --run-reviewers` now supports configurable parallel reviewer execution and resilient retry backoff (`--review-concurrency`, `--review-retries`, `--review-retry-delay-ms`)
36
+ - added optional `test:supervisor-review-integration` smoke coverage for real `codex exec` review runner flows (enabled via `DA_VINCI_RUN_SUPERVISOR_INTEGRATION=1`)
37
+ - supervisor-review parsing now explicitly handles legacy Chinese round-attempt headings (for example `## Design-Supervisor Review(第2轮尝试)`) and keeps canonical structured review fallback deterministic
38
+ - `--nodes-file` metadata-payload guard now reports shorter relative file paths when possible, while preserving absolute-path fallback outside current working directory
35
39
  - audit parser logic is now split into `lib/audit-parsers.js`, reducing `lib/audit.js` size and making maintenance safer
36
40
  - recursive file traversal now uses bounded safe scans with depth/count limits and symlink skipping
37
41
  - completion/integrity audit now rejects out-of-root `.pen` references from `design-registry.md`
@@ -454,6 +458,7 @@ da-vinci audit --mode completion --change <change-id> /abs/path/to/project
454
458
  da-vinci icon-sync # tolerant by default; add --strict for hard gating
455
459
  cp references/icon-aliases.example.json ~/.da-vinci/icon-aliases.json
456
460
  da-vinci icon-search --query "settings lock" --family material --top 8
461
+ da-vinci supervisor-review --project /abs/path/to/project --change <change-id> --run-reviewers --write
457
462
  da-vinci preflight-pencil --ops-file /abs/path/to/ops.txt
458
463
  da-vinci uninstall --platform codex,claude,gemini
459
464
  ```
@@ -498,6 +503,14 @@ Both modes check the most common workflow-integrity failures in a project:
498
503
  - returns ranked candidates with ready-to-use `icon_font` node payload hints
499
504
  - for a copy-ready `Icon System Guidance (Advisory)` template, see `docs/constraint-files.md` and `references/artifact-templates.md`
500
505
 
506
+ `da-vinci supervisor-review` provides a local structured reviewer record:
507
+
508
+ - writes `Configured reviewers`, `Executed reviewers`, `Review source`, `Status`, `Issue list`, and `Revision outcome` into `pencil-design.md` when `--write` is provided
509
+ - accepts explicit status input (`--status PASS|WARN|BLOCK`) or can infer a conservative status from current design artifacts
510
+ - for required supervisor gates, prefer `--run-reviewers --write` so configured reviewer skills execute and the record is persisted in one step
511
+ - reviewer execution tuning is available via `--review-concurrency`, `--review-retries`, and `--review-retry-delay-ms` (exponential backoff)
512
+ - keeps `design-supervisor review` available as a compatibility alias
513
+
501
514
  When Pencil MCP is active, Da Vinci now also expects an MCP runtime gate record in `pencil-design.md` before terminal completion claims. That runtime gate checks live editor/source convergence separately from filesystem audit.
502
515
  During active redesign work, run `da-vinci audit --mode integrity <project-path>` immediately after the first successful Pencil write, then use `da-vinci preflight-pencil` plus smaller follow-up batches if the same anchor surface rolls back twice.
503
516
 
package/README.zh-CN.md CHANGED
@@ -30,10 +30,14 @@ Da Vinci 是一个把产品需求一路推进到结构化规格、Pencil 设计
30
30
 
31
31
  最新已发布 npm 包:
32
32
 
33
- - `@xenonbyte/da-vinci-workflow@0.1.23`
33
+ - `@xenonbyte/da-vinci-workflow@0.1.25`
34
34
 
35
35
  已发布版本重点:
36
36
 
37
+ - `da-vinci supervisor-review --run-reviewers` 现已支持 reviewer 并发执行与失败重试退避(`--review-concurrency`、`--review-retries`、`--review-retry-delay-ms`)
38
+ - 新增可选 `test:supervisor-review-integration` 烟测,用于覆盖真实 `codex exec` 评审执行链路(通过 `DA_VINCI_RUN_SUPERVISOR_INTEGRATION=1` 启用)
39
+ - supervisor-review 解析现已显式覆盖中文 legacy 轮次标题(例如 `## Design-Supervisor Review(第2轮尝试)`),并保持“优先结构化评审块”的回退策略可预测
40
+ - `--nodes-file` 元数据误传保护现在优先输出更短的相对路径(在 cwd 外仍回退绝对路径),便于日志阅读
37
41
  - audit 解析职责已拆分到 `lib/audit-parsers.js`,`lib/audit.js` 体量下降,可维护性更好
38
42
  - 递归文件扫描改为安全有界遍历:增加深度/数量上限,并跳过符号链接
39
43
  - completion/integrity audit 现在会拦截并忽略 `design-registry.md` 中越出项目根目录的 `.pen` 引用
@@ -375,6 +379,7 @@ da-vinci audit --mode completion --change <change-id> /abs/path/to/project
375
379
  da-vinci icon-sync # 默认容错;需要强门禁时加 --strict
376
380
  cp references/icon-aliases.example.json ~/.da-vinci/icon-aliases.json
377
381
  da-vinci icon-search --query "settings lock" --family material --top 8
382
+ da-vinci supervisor-review --project /abs/path/to/project --change <change-id> --run-reviewers --write
378
383
  da-vinci preflight-pencil --ops-file /abs/path/to/ops.txt
379
384
  da-vinci uninstall --platform codex,claude,gemini
380
385
  ```
@@ -419,6 +424,14 @@ Context Delta 与 audit 的关系:
419
424
  - 返回排序候选,并附带可直接复用的 `icon_font` 节点 payload 提示
420
425
  - `Icon System Guidance (Advisory)` 可复制模板见 `docs/constraint-files.md` 与 `references/artifact-templates.md`
421
426
 
427
+ `da-vinci supervisor-review` 提供本地结构化评审记录能力:
428
+
429
+ - 加上 `--write` 时,会把 `Configured reviewers`、`Executed reviewers`、`Review source`、`Status`、`Issue list`、`Revision outcome` 写入 `pencil-design.md`
430
+ - 可通过 `--status PASS|WARN|BLOCK` 显式指定,也可基于当前设计工件做保守推断
431
+ - 对 required supervisor gate,优先使用 `--run-reviewers --write`,让 reviewer skills 执行与结果持久化一体完成
432
+ - reviewer 执行参数可通过 `--review-concurrency`、`--review-retries`、`--review-retry-delay-ms` 调优(指数退避)
433
+ - `design-supervisor review` 作为兼容别名仍可使用
434
+
422
435
  当 Pencil MCP 可用时,Da Vinci 现在还要求在终态完成声明前,把 MCP runtime gate 结果记录到 `pencil-design.md`。这层 gate 负责检查 live editor/source convergence,与 filesystem audit 分工不同。
423
436
  在重设计进行中,如果有 shell 能力,应在第一次成功写入 Pencil 后立即运行 `da-vinci audit --mode integrity <project-path>`;如果同一个 anchor surface 连续回滚,则继续配合 `da-vinci preflight-pencil` 和更小的 follow-up batch。
424
437
 
package/SKILL.md CHANGED
@@ -280,9 +280,10 @@ During active Pencil work:
280
280
  - exported screenshots are review artifacts only; place them under `.da-vinci/changes/<change-id>/exports/` and never treat them as a substitute for the project-local `.pen` source
281
281
  - screenshot review is binding: if the review calls out hierarchy, spacing, clarity, inconsistency, or unresolved-placeholder issues, revise the screen before treating the checkpoint as `PASS`
282
282
  - screenshot review must record an explicit `PASS`, `WARN`, or `BLOCK` plus the concrete issue list and revision outcome; phrases such as "looks good" do not count as review evidence
283
- - if `DA-VINCI.md` declares `Design-supervisor reviewers`, run `design-supervisor review` after screenshot review, layout hygiene, and design checkpoint for the approved anchor set
283
+ - if `DA-VINCI.md` declares `Design-supervisor reviewers`, run an explicit review pass with those reviewer skills on the approved anchor set, then persist the structured result with `da-vinci supervisor-review --project <project-path> --change <change-id> --run-reviewers --write` (or the compatibility alias `design-supervisor review --run-reviewers --write`)
284
284
  - keep `Design-supervisor reviewers` separate from `Preferred adapters`; adapters lead the design pass, reviewers judge whether the final style quality is strong enough to expand or implement
285
- - when `design-supervisor review` is active, review screenshots together with Pencil theme variables, `visual-thesis.md`, `content-plan.md`, and `interaction-thesis.md`, then record an explicit `PASS`, `WARN`, or `BLOCK` plus issue list and revision outcome in `pencil-design.md`
285
+ - when `design-supervisor review` is active, review screenshots together with Pencil theme variables, `visual-thesis.md`, `content-plan.md`, and `interaction-thesis.md`; record `Configured reviewers`, `Executed reviewers`, `Review source`, explicit `PASS`/`WARN`/`BLOCK`, issue list, and revision outcome in `pencil-design.md`
286
+ - do not hand-write ad-hoc headings such as `## Design-Supervisor Review (Round X Attempt)`; use `da-vinci supervisor-review --write` (or overwrite the canonical `## Design-Supervisor Review` block) so audit can consume structured evidence deterministically
286
287
  - if `DA-VINCI.md` sets `Require Supervisor Review: true`, treat missing, blocked, or unaccepted `design-supervisor review` as a blocker before broad expansion, implementation-task handoff, or terminal completion
287
288
 
288
289
  ## Load References On Demand
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { runCli } = require("../lib/cli");
4
+
5
+ function printHelp() {
6
+ console.log(
7
+ [
8
+ "Design Supervisor CLI (Da Vinci bridge)",
9
+ "",
10
+ "Usage:",
11
+ " design-supervisor review --project <path> --change <id> [--run-reviewers] [--review-concurrency <value>] [--review-retries <value>] [--review-retry-delay-ms <value>] [--source <skill|manual|inferred>] [--executed-reviewers <csv>] [--status <PASS|WARN|BLOCK>] [--issue-list <text>] [--revision-outcome <text>] [--write] [--json]",
12
+ "",
13
+ "Notes:",
14
+ " - This command is a compatibility alias for `da-vinci supervisor-review`.",
15
+ " - It does not replace completion gating; use `da-vinci audit --mode completion` for final gate checks."
16
+ ].join("\n")
17
+ );
18
+ }
19
+
20
+ async function main() {
21
+ const args = process.argv.slice(2);
22
+ const [subcommand] = args;
23
+
24
+ if (!subcommand || subcommand === "--help" || subcommand === "-h" || subcommand === "help") {
25
+ printHelp();
26
+ return;
27
+ }
28
+
29
+ if (subcommand !== "review") {
30
+ throw new Error(`Unknown subcommand: ${subcommand}`);
31
+ }
32
+
33
+ await runCli(["supervisor-review", ...args.slice(1)]);
34
+ }
35
+
36
+ main().catch((error) => {
37
+ console.error(error.message || String(error));
38
+ process.exit(1);
39
+ });
@@ -26,5 +26,5 @@ If a registered project-local `.pen` already exists, reopen it for continuity bu
26
26
  After the first successful Pencil write, run `da-vinci audit --mode integrity <project-path>` before broad expansion continues.
27
27
  If Pencil MCP is active, run the MCP runtime gate after the first successful Pencil write and record it in `pencil-design.md`.
28
28
  Screenshot review must record an explicit `PASS`, `WARN`, or `BLOCK` plus the issue list and revision outcome; "looks good" is not a valid review record.
29
- If `DA-VINCI.md` declares `Design-supervisor reviewers`, run `design-supervisor review` after screenshot review, layout hygiene, and design checkpoint, then record the reviewers, inputs, status, issue list, and revision outcome in `pencil-design.md`. If `Require Supervisor Review: true`, treat missing, blocked, or unaccepted review results as blocking before broad expansion or terminal completion.
29
+ If `DA-VINCI.md` declares `Design-supervisor reviewers`, execute those reviewer skills on the approved anchor screenshots (do not skip to inferred review), then persist the structured result via `da-vinci supervisor-review --project <project-path> --change <change-id> --run-reviewers --write` (or the compatibility alias `design-supervisor review --run-reviewers --write`). Record configured/ executed reviewers, review source, status, issue list, and revision outcome in `pencil-design.md`. Do not add ad-hoc headings like `## Design-Supervisor Review (Round X Attempt)`; keep a canonical structured section so audit can parse it deterministically. If `Require Supervisor Review: true`, treat missing, blocked, unaccepted, or non-skill-backed review results as blocking before broad expansion or terminal completion.
30
30
  Before reporting `design complete` or `workflow complete`, run `da-vinci audit --mode completion --change <change-id> <project-path>` and treat any failure as blocking.
@@ -20,5 +20,5 @@ If a registered project-local `.pen` already exists, reopen it for continuity bu
20
20
  After the first successful Pencil write, run `da-vinci audit --mode integrity <project-path>` before broad expansion continues.
21
21
  If Pencil MCP is active, run the MCP runtime gate after the first successful Pencil write and record it in `pencil-design.md`.
22
22
  Screenshot review must record an explicit `PASS`, `WARN`, or `BLOCK` plus the issue list and revision outcome; "looks good" is not a valid review record.
23
- If `DA-VINCI.md` declares `Design-supervisor reviewers`, run `design-supervisor review` after screenshot review, layout hygiene, and design checkpoint, then record the reviewers, inputs, status, issue list, and revision outcome in `pencil-design.md`. If `Require Supervisor Review: true`, treat missing, blocked, or unaccepted review results as blocking before broad expansion or terminal completion.
23
+ If `DA-VINCI.md` declares `Design-supervisor reviewers`, execute those reviewer skills on the approved anchor screenshots (do not skip to inferred review), then persist the structured result via `da-vinci supervisor-review --project <project-path> --change <change-id> --run-reviewers --write` (or the compatibility alias `design-supervisor review --run-reviewers --write`). Record configured/ executed reviewers, review source, status, issue list, and revision outcome in `pencil-design.md`. Do not add ad-hoc headings like `## Design-Supervisor Review (Round X Attempt)`; keep a canonical structured section so audit can parse it deterministically. If `Require Supervisor Review: true`, treat missing, blocked, unaccepted, or non-skill-backed review results as blocking before broad expansion or terminal completion.
24
24
  Before claiming `design complete` or `workflow complete`, run `da-vinci audit --mode completion --change <change-id> <project-path>` and treat any failure as blocking.
@@ -19,6 +19,6 @@ If a registered project-local `.pen` already exists, reopen it for continuity bu
19
19
  After the first successful Pencil write, run `da-vinci audit --mode integrity <project-path>` before broad expansion continues.
20
20
  If Pencil MCP is active, run the MCP runtime gate after the first successful Pencil write and record it in `pencil-design.md`.
21
21
  Screenshot review must record an explicit `PASS`, `WARN`, or `BLOCK` plus the issue list and revision outcome; "looks good" is not a valid review record.
22
- If `DA-VINCI.md` declares `Design-supervisor reviewers`, run `design-supervisor review` after screenshot review, layout hygiene, and design checkpoint, then record the reviewers, inputs, status, issue list, and revision outcome in `pencil-design.md`. If `Require Supervisor Review: true`, treat missing, blocked, or unaccepted review results as blocking before broad expansion or terminal completion.
22
+ If `DA-VINCI.md` declares `Design-supervisor reviewers`, execute those reviewer skills on the approved anchor screenshots (do not skip to inferred review), then persist the structured result via `da-vinci supervisor-review --project <project-path> --change <change-id> --run-reviewers --write` (or the compatibility alias `design-supervisor review --run-reviewers --write`). Record configured/ executed reviewers, review source, status, issue list, and revision outcome in `pencil-design.md`. Do not add ad-hoc headings like `## Design-Supervisor Review (Round X Attempt)`; keep a canonical structured section so audit can parse it deterministically. If `Require Supervisor Review: true`, treat missing, blocked, unaccepted, or non-skill-backed review results as blocking before broad expansion or terminal completion.
23
23
  Before reporting `design complete` or `workflow complete`, run `da-vinci audit --mode completion --change <change-id> <project-path>` and treat any failure as blocking.
24
24
  """
@@ -38,11 +38,15 @@ The workflow audit currently parses specific fields. Keep these names stable.
38
38
 
39
39
  ### `pencil-design.md` -> `## Design-Supervisor Review`
40
40
 
41
+ - `Configured reviewers`
42
+ - `Executed reviewers`
43
+ - `Review source`
41
44
  - `Status`
42
45
  - `Issue list`
43
46
  - `Revision outcome`
44
47
 
45
- When supervisor review is required, missing or blocked review evidence blocks completion.
48
+ When supervisor review is required, missing, blocked, unaccepted, or non-skill-backed review evidence blocks completion.
49
+ Avoid ad-hoc headings such as `## Design-Supervisor Review (Round X Attempt)`; keep a canonical structured supervisor-review section (prefer `da-vinci supervisor-review --write`) so audit can parse the latest review deterministically.
46
50
 
47
51
  ## Advisory Constraint Sections (Customizable)
48
52
 
@@ -47,6 +47,12 @@ These commands do not replace route selection, but they support design execution
47
47
  - `da-vinci icon-search --query "<text>" [--family ...] [--top ...] [--aliases ...]`
48
48
  - resolve likely `icon_font` names before writing Pencil `batch_design` operations
49
49
  - supports mixed EN/ZH terms and optional alias expansion via `~/.da-vinci/icon-aliases.json`
50
+ - `da-vinci supervisor-review --project <path> --change <id> [--run-reviewers] [--review-concurrency <value>] [--review-retries <value>] [--review-retry-delay-ms <value>] [--source <skill|manual|inferred>] [--executed-reviewers <csv>] [--status ...] [--issue-list ...] [--revision-outcome ...] [--write]`
51
+ - persists a structured supervisor-review record (`Configured reviewers`, `Executed reviewers`, `Review source`, `Status`, `Issue list`, `Revision outcome`) in `pencil-design.md`
52
+ - use `--run-reviewers --write` for one-step execution + record persistence through configured reviewer skills
53
+ - `--review-concurrency`, `--review-retries`, and `--review-retry-delay-ms` control parallelism and retry backoff for reviewer execution
54
+ - when `Require Supervisor Review: true`, inferred/manual records are completion-blocking
55
+ - `design-supervisor review` is kept as a compatibility alias that forwards to this command
50
56
 
51
57
  Use these utilities during `/dv:design`, especially before anchor-surface icon finalization.
52
58
 
@@ -40,11 +40,15 @@
40
40
 
41
41
  ### `pencil-design.md` -> `## Design-Supervisor Review`
42
42
 
43
+ - `Configured reviewers`
44
+ - `Executed reviewers`
45
+ - `Review source`
43
46
  - `Status`
44
47
  - `Issue list`
45
48
  - `Revision outcome`
46
49
 
47
- 当 supervisor review 是必需时,缺失或 `BLOCK` 的评审证据会阻断 completion。
50
+ 当 supervisor review 是必需时,缺失、`BLOCK`、未接受、或非 skill-backed 的评审证据都会阻断 completion。
51
+ 避免写临时标题(例如 `## Design-Supervisor Review (Round X Attempt)`);应保持规范化、结构化的 supervisor-review 段(优先使用 `da-vinci supervisor-review --write`),这样 audit 才能稳定解析最新评审证据。
48
52
 
49
53
  ## 指导型约束段(可定制)
50
54
 
@@ -49,6 +49,12 @@ Da Vinci 期望它们遵循工作流状态。
49
49
  - `da-vinci icon-search --query "<关键词>" [--family ...] [--top ...] [--aliases ...]`
50
50
  - 在写 Pencil `batch_design` 前先收敛可用的 `icon_font` 名称
51
51
  - 支持中英文混合词,并可通过 `~/.da-vinci/icon-aliases.json` 做语义扩展
52
+ - `da-vinci supervisor-review --project <path> --change <id> [--run-reviewers] [--review-concurrency <value>] [--review-retries <value>] [--review-retry-delay-ms <value>] [--source <skill|manual|inferred>] [--executed-reviewers <csv>] [--status ...] [--issue-list ...] [--revision-outcome ...] [--write]`
53
+ - 持久化结构化 supervisor review 记录(`Configured reviewers`、`Executed reviewers`、`Review source`、`Status`、`Issue list`、`Revision outcome`)到 `pencil-design.md`
54
+ - 推荐直接用 `--run-reviewers --write` 一步完成 reviewer skills 执行与记录落盘
55
+ - 通过 `--review-concurrency`、`--review-retries`、`--review-retry-delay-ms` 可调 reviewer 并发与重试退避
56
+ - 当 `Require Supervisor Review: true` 时,`manual/inferred` 记录会被 completion 阻断
57
+ - `design-supervisor review` 作为兼容别名保留,并会转发到该命令
52
58
 
53
59
  建议在 `/dv:design` 阶段使用,尤其是在 anchor surface 的图标定稿前。
54
60
 
@@ -32,6 +32,135 @@ function getMarkdownSection(text, heading) {
32
32
  return sectionLines.join("\n").trim();
33
33
  }
34
34
 
35
+ function getMarkdownSectionsByHeading(text, heading, options = {}) {
36
+ if (!text) {
37
+ return [];
38
+ }
39
+
40
+ const escapedHeading = escapeRegExp(heading);
41
+ const allowParentheticalSuffix = options.allowParentheticalSuffix === true;
42
+ const suffixPattern = allowParentheticalSuffix
43
+ ? String.raw`(?:\s*[((][^))\n]*[))])?`
44
+ : "";
45
+ const headingPattern = new RegExp(`^##\\s+${escapedHeading}${suffixPattern}\\s*$`, "i");
46
+ const anyHeadingPattern = /^##\s+/;
47
+ const lines = String(text).replace(/\r\n?/g, "\n").split("\n");
48
+ const sections = [];
49
+ let capturing = false;
50
+ let currentHeading = "";
51
+ let sectionLines = [];
52
+
53
+ function flushSection() {
54
+ if (!capturing) {
55
+ return;
56
+ }
57
+
58
+ sections.push({
59
+ heading: currentHeading,
60
+ content: sectionLines.join("\n").trim()
61
+ });
62
+ capturing = false;
63
+ currentHeading = "";
64
+ sectionLines = [];
65
+ }
66
+
67
+ for (const line of lines) {
68
+ if (capturing && anyHeadingPattern.test(line)) {
69
+ flushSection();
70
+ }
71
+
72
+ if (!capturing && headingPattern.test(line)) {
73
+ capturing = true;
74
+ currentHeading = line.trim();
75
+ sectionLines = [];
76
+ continue;
77
+ }
78
+
79
+ if (capturing) {
80
+ sectionLines.push(line);
81
+ }
82
+ }
83
+
84
+ flushSection();
85
+ return sections;
86
+ }
87
+
88
+ function extractReviewFieldValue(section, fieldNames) {
89
+ const lines = String(section || "").replace(/\r\n?/g, "\n").split("\n");
90
+ const escapedFieldNames = fieldNames.map((fieldName) => escapeRegExp(fieldName)).join("|");
91
+ const fieldPattern = new RegExp(`^\\s*-\\s*(?:${escapedFieldNames})\\s*:\\s*(.*)$`, "i");
92
+ const topLevelFieldPattern = /^\s*-\s+[^:\n]+:\s*.*$/;
93
+ const bulletPattern = /^\s*-\s+(.+)$/;
94
+ const nestedTextPattern = /^\s{2,}(.+)$/;
95
+ const values = [];
96
+ let capturing = false;
97
+
98
+ for (const rawLine of lines) {
99
+ if (/^##\s+/.test(rawLine)) {
100
+ if (capturing) {
101
+ break;
102
+ }
103
+ continue;
104
+ }
105
+
106
+ const fieldMatch = rawLine.match(fieldPattern);
107
+ if (!capturing && fieldMatch) {
108
+ capturing = true;
109
+ const inlineValue = String(fieldMatch[1] || "").trim();
110
+ if (inlineValue) {
111
+ values.push(inlineValue);
112
+ }
113
+ continue;
114
+ }
115
+
116
+ if (!capturing) {
117
+ continue;
118
+ }
119
+
120
+ if (topLevelFieldPattern.test(rawLine)) {
121
+ break;
122
+ }
123
+
124
+ const bulletMatch = rawLine.match(bulletPattern);
125
+ if (bulletMatch) {
126
+ const value = String(bulletMatch[1] || "").trim();
127
+ if (value) {
128
+ values.push(value);
129
+ }
130
+ continue;
131
+ }
132
+
133
+ const nestedTextMatch = rawLine.match(nestedTextPattern);
134
+ if (nestedTextMatch) {
135
+ const value = String(nestedTextMatch[1] || "").trim();
136
+ if (value) {
137
+ values.push(value);
138
+ }
139
+ continue;
140
+ }
141
+
142
+ if (rawLine.trim() === "") {
143
+ continue;
144
+ }
145
+
146
+ break;
147
+ }
148
+
149
+ return values.join("\n").trim();
150
+ }
151
+
152
+ function parseListTokens(value) {
153
+ return String(value || "")
154
+ .split(/[,\n;]/)
155
+ .map((token) =>
156
+ token
157
+ .replace(/^[\-\*\u2022]\s*/, "")
158
+ .replace(/`/g, "")
159
+ .trim()
160
+ )
161
+ .filter(Boolean);
162
+ }
163
+
35
164
  function normalizeCheckpointLabel(value) {
36
165
  return String(value || "")
37
166
  .toLowerCase()
@@ -398,6 +527,12 @@ function hasConfiguredDesignSupervisorReview(daVinciText) {
398
527
  return getVisualAssistFieldValues(daVinciText, "Design-supervisor reviewers").length > 0;
399
528
  }
400
529
 
530
+ function getConfiguredDesignSupervisorReviewers(daVinciText) {
531
+ return getVisualAssistFieldValues(daVinciText, "Design-supervisor reviewers")
532
+ .flatMap((value) => parseListTokens(value))
533
+ .filter(Boolean);
534
+ }
535
+
401
536
  function isDesignSupervisorReviewRequired(daVinciText) {
402
537
  return getVisualAssistFieldValues(daVinciText, "Require Supervisor Review").some((value) =>
403
538
  /^true$/i.test(String(value).trim())
@@ -405,36 +540,98 @@ function isDesignSupervisorReviewRequired(daVinciText) {
405
540
  }
406
541
 
407
542
  function inspectDesignSupervisorReview(pencilDesignText) {
408
- const section = getMarkdownSection(pencilDesignText, "Design-Supervisor Review");
409
- if (!section) {
543
+ const sections = getMarkdownSectionsByHeading(pencilDesignText, "Design-Supervisor Review", {
544
+ allowParentheticalSuffix: true
545
+ });
546
+ if (sections.length === 0) {
410
547
  return {
411
548
  found: false,
412
549
  status: null,
413
550
  acceptedWarn: false,
414
551
  hasIssueList: false,
415
- hasRevisionOutcome: false
552
+ hasRevisionOutcome: false,
553
+ selectedFromLatest: true,
554
+ usedStructuredSectionFallback: false,
555
+ latestSectionLooksLegacyAttempt: false,
556
+ latestSectionStructuredFieldPresent: false,
557
+ selectedSectionHeading: "",
558
+ selectedSectionLooksLegacyAttempt: false
416
559
  };
417
560
  }
418
561
 
419
- const statusMatch = section.match(/(?:^|\n)\s*-\s*(?:Status|状态)\s*:\s*(PASS|WARN|BLOCK)\b/i);
420
- const status = statusMatch ? statusMatch[1].toUpperCase() : null;
421
- const issueListMatch = section.match(/(?:^|\n)\s*-\s*(?:Issue list|问题列表)\s*:\s*(.+)$/im);
422
- const revisionOutcomeMatch = section.match(
423
- /(?:^|\n)\s*-\s*(?:Revision outcome|修订结果)\s*:\s*(.+)$/im
424
- );
425
- const revisionOutcome = revisionOutcomeMatch ? revisionOutcomeMatch[1].trim() : "";
426
- const acceptedWarn =
427
- status === "WARN" &&
428
- /(accepted|accepted with follow-up|accepted warning|warn accepted|接受|已接受|接受警告)/i.test(
429
- revisionOutcome
562
+ const legacyRoundAttemptPattern =
563
+ /[((]\s*(?:round[^)\n)]*attempt|第?\s*[0-9一二三四五六七八九十百零两]+\s*轮\s*尝试)\s*[))]/i;
564
+ const parsedSections = sections.map((sectionRecord, index) => {
565
+ const section = sectionRecord.content;
566
+ const statusMatch = section.match(
567
+ /(?:^|\n)\s*-\s*(?:Status|状态|Result|结果)\s*:\s*`?(PASS|WARN|BLOCK)`?\b/i
430
568
  );
569
+ const status = statusMatch ? statusMatch[1].toUpperCase() : null;
570
+ const issueList = extractReviewFieldValue(section, ["Issue list", "问题列表"]);
571
+ const revisionOutcome = extractReviewFieldValue(section, ["Revision outcome", "修订结果"]);
572
+ const configuredReviewersRaw = extractReviewFieldValue(section, ["Configured reviewers", "配置评审"]);
573
+ const executedReviewersRaw = extractReviewFieldValue(section, [
574
+ "Executed reviewers",
575
+ "Executed reviewer skills",
576
+ "执行评审"
577
+ ]);
578
+ const reviewSource = extractReviewFieldValue(section, ["Review source", "评审来源"]).toLowerCase();
579
+ const configuredReviewers = parseListTokens(configuredReviewersRaw);
580
+ const executedReviewers = parseListTokens(executedReviewersRaw);
581
+ const hasConfiguredField = /(?:^|\n)\s*-\s*(?:Configured reviewers|配置评审)\s*:/i.test(section);
582
+ const hasExecutedField = /(?:^|\n)\s*-\s*(?:Executed reviewers|Executed reviewer skills|执行评审)\s*:/i.test(section);
583
+ const hasReviewSourceField = /(?:^|\n)\s*-\s*(?:Review source|评审来源)\s*:/i.test(section);
584
+ const structuredFieldPresent = hasConfiguredField || hasExecutedField || hasReviewSourceField;
585
+ const acceptedWarn =
586
+ status === "WARN" &&
587
+ /(accepted|accepted with follow-up|accepted warning|warn accepted|接受|已接受|接受警告)/i.test(
588
+ revisionOutcome
589
+ );
590
+ return {
591
+ index,
592
+ heading: sectionRecord.heading,
593
+ status,
594
+ issueList,
595
+ revisionOutcome,
596
+ configuredReviewers,
597
+ executedReviewers,
598
+ reviewSource,
599
+ acceptedWarn,
600
+ hasIssueList: Boolean(issueList),
601
+ hasRevisionOutcome: Boolean(revisionOutcome),
602
+ hasConfiguredReviewers: configuredReviewers.length > 0,
603
+ hasExecutedReviewers: executedReviewers.length > 0,
604
+ structuredFieldPresent,
605
+ looksLegacyRoundAttempt: legacyRoundAttemptPattern.test(sectionRecord.heading)
606
+ };
607
+ });
608
+
609
+ const latestSection = parsedSections[parsedSections.length - 1];
610
+ const selectedSection =
611
+ [...parsedSections].reverse().find((section) => section.structuredFieldPresent) || latestSection;
612
+ const selectedFromLatest = selectedSection.index === latestSection.index;
613
+ const usedStructuredSectionFallback =
614
+ !selectedFromLatest &&
615
+ latestSection.structuredFieldPresent === false &&
616
+ selectedSection.structuredFieldPresent === true;
431
617
 
432
618
  return {
433
619
  found: true,
434
- status,
435
- acceptedWarn,
436
- hasIssueList: Boolean(issueListMatch && issueListMatch[1].trim()),
437
- hasRevisionOutcome: Boolean(revisionOutcome)
620
+ status: selectedSection.status,
621
+ acceptedWarn: selectedSection.acceptedWarn,
622
+ hasIssueList: selectedSection.hasIssueList,
623
+ hasRevisionOutcome: selectedSection.hasRevisionOutcome,
624
+ configuredReviewers: selectedSection.configuredReviewers,
625
+ executedReviewers: selectedSection.executedReviewers,
626
+ reviewSource: selectedSection.reviewSource,
627
+ hasConfiguredReviewers: selectedSection.hasConfiguredReviewers,
628
+ hasExecutedReviewers: selectedSection.hasExecutedReviewers,
629
+ selectedFromLatest,
630
+ usedStructuredSectionFallback,
631
+ latestSectionLooksLegacyAttempt: latestSection.looksLegacyRoundAttempt,
632
+ latestSectionStructuredFieldPresent: latestSection.structuredFieldPresent,
633
+ selectedSectionHeading: selectedSection.heading,
634
+ selectedSectionLooksLegacyAttempt: selectedSection.looksLegacyRoundAttempt
438
635
  };
439
636
  }
440
637
 
@@ -446,6 +643,7 @@ module.exports = {
446
643
  buildContextDeltaReferenceIndex,
447
644
  resolveSupersedesReferenceIndices,
448
645
  inspectContextDelta,
646
+ getConfiguredDesignSupervisorReviewers,
449
647
  hasConfiguredDesignSupervisorReview,
450
648
  isDesignSupervisorReviewRequired,
451
649
  inspectDesignSupervisorReview