cowork-flow 2.4.2 → 2.5.0

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 (41) hide show
  1. package/CHANGELOG.md +19 -1
  2. package/README.en.md +2 -1
  3. package/README.md +2 -1
  4. package/docs/architecture.en.md +2 -0
  5. package/docs/architecture.md +2 -0
  6. package/docs/hosts.en.md +15 -0
  7. package/docs/hosts.md +15 -0
  8. package/package.json +2 -2
  9. package/presets/claude-code/.claude-plugin/plugin.json +1 -1
  10. package/presets/codex/.codex-plugin/plugin.json +1 -1
  11. package/presets/kimi-code/.kimi-plugin/plugin.json +1 -1
  12. package/presets/qoder/.qoder-plugin/plugin.json +1 -1
  13. package/presets/zcode/.zcode-plugin/plugin.json +1 -1
  14. package/src/commands/host-inspect.js +86 -0
  15. package/src/commands/host.js +42 -18
  16. package/src/commands/init.js +100 -3
  17. package/src/commands/install-claude-code-plugin.js +53 -2
  18. package/src/commands/install-codex-plugin.js +114 -4
  19. package/src/commands/install-dsh-hook.js +51 -0
  20. package/src/commands/install-dsh-preset.js +46 -4
  21. package/src/commands/install-kimi-code-plugin.js +61 -2
  22. package/src/commands/install-kimi-hook.js +84 -2
  23. package/src/commands/install-opencode-plugin.js +58 -2
  24. package/src/commands/install-qoder-plugin.js +67 -3
  25. package/src/commands/install-zcode-plugin.js +77 -2
  26. package/src/commands/registry.js +20 -5
  27. package/src/lib/dsh-home.js +2 -2
  28. package/template/.cowork-flow/.version +1 -1
  29. package/template/.cowork-flow/scripts/adapters/host/host_manifest.py +4 -0
  30. package/template/.cowork-flow/scripts/adapters/host/workflow_state_hook.py +1 -3
  31. package/template/.cowork-flow/scripts/infra/files.py +0 -13
  32. package/template/.cowork-flow/scripts/services/ac_evidence.py +1 -1
  33. package/template/.cowork-flow/scripts/services/decision_anchor_schema.py +65 -0
  34. package/template/.cowork-flow/scripts/services/fact_view.py +2 -75
  35. package/template/.cowork-flow/scripts/services/lifecycle_checks.py +1 -1
  36. package/template/.cowork-flow/scripts/services/plan_readiness.py +139 -67
  37. package/template/.cowork-flow/spec/contracts/host-install-inspection.md +174 -0
  38. package/template/.cowork-flow/spec/contracts/index.md +1 -0
  39. package/template/.cowork-flow/spec/runtime/contract-registry.json +15 -0
  40. package/template/skills/runtime-health/scripts/doctor.py +538 -489
  41. package/template/skills/task-review/scripts/review_check.py +33 -6
@@ -1,6 +1,6 @@
1
1
  import { UsageError } from '../lib/cli-flags.js';
2
2
  import { hostRegistry } from '../lib/host-assets.js';
3
- import { HOST_COMPONENTS, HOST_FLAGS, runHostAdd, runHostList, runHostRemove } from './host.js';
3
+ import { HOST_COMPONENTS, HOST_FLAGS, runHostAdd, runHostInspect, runHostList, runHostRemove } from './host.js';
4
4
  import { runInit } from './init.js';
5
5
  import { runMcpState } from './mcp-state.js';
6
6
  import { runSourceRefresh } from './source-refresh.js';
@@ -107,13 +107,26 @@ export const COMMANDS = [
107
107
  examples: ['cwf host remove codex', 'cwf host remove dsh --component hook'],
108
108
  run: (args) => runHostRemove(args)
109
109
  },
110
+ {
111
+ path: ['host', 'inspect'],
112
+ summary: 'Report machine-level host installation state without changing it',
113
+ usage: 'host inspect [host] [--json]',
114
+ flags: [flag('--json')],
115
+ positional: { min: 0, max: 1, name: '[host]' },
116
+ notes: [
117
+ 'Read-only: it reports installed, missing, stale, broken or unsupported and never repairs, installs or removes.',
118
+ 'Without a host, every declared host is inspected; an unknown host is a usage error.'
119
+ ],
120
+ examples: ['cwf host inspect', 'cwf host inspect qoder --json'],
121
+ run: (args, context) => runHostInspect(args, context)
122
+ },
110
123
  {
111
124
  path: ['host', 'list'],
112
125
  summary: 'List declared hosts and whether this project selected them',
113
126
  usage: 'host list [target] [--json]',
114
127
  flags: [flag('--json')],
115
128
  positional: { min: 0, max: 1, name: '[target]' },
116
- notes: ['Reports declarations and project selection only; installed-state health is what `./.cowork-flow/run doctor` checks.'],
129
+ notes: ['Reports declarations and project selection only; `cwf host inspect` reads each host\'s installed state, and doctor consumes that read model.'],
117
130
  examples: ['cwf host list', 'cwf host list --json'],
118
131
  run: (args, context) => runHostList(args, context)
119
132
  },
@@ -149,7 +162,9 @@ export const COMMANDS = [
149
162
  // Old names. `permanent` aliases are spellings already
150
163
  // written outside this repository (MCP client configs);
151
164
  // the rest print a migration note on stderr and go away
152
- // after two minor releases.
165
+ // after the shared retirement policy.
166
+ const ALIAS_RETIREMENT_POLICY = 'two more minor releases';
167
+
153
168
  export const ALIASES = [
154
169
  { name: 'init', command: ['project', 'init'], args: [], permanent: true },
155
170
  { name: 'sync', command: ['project', 'sync'], args: [], permanent: true },
@@ -211,7 +226,7 @@ export function aliasReplacement(alias) {
211
226
 
212
227
  export function aliasNotice(alias) {
213
228
  return `note: "${PROGRAM} ${alias.name}" is now "${aliasReplacement(alias)}"; `
214
- + 'the old name keeps working for two more minor releases.\n';
229
+ + `the old name keeps working for ${ALIAS_RETIREMENT_POLICY}.\n`;
215
230
  }
216
231
 
217
232
 
@@ -282,7 +297,7 @@ function renderRootHelp() {
282
297
  );
283
298
  const aliasWidth = Math.max(...ALIASES.map((alias) => alias.name.length));
284
299
  for (const alias of ALIASES) {
285
- const suffix = alias.permanent ? '(permanent)' : '(removed after two minor releases)';
300
+ const suffix = alias.permanent ? '(permanent)' : `(removed after ${ALIAS_RETIREMENT_POLICY})`;
286
301
  lines.push(` ${alias.name.padEnd(aliasWidth)} -> ${aliasReplacement(alias)} ${suffix}`);
287
302
  }
288
303
  return `${lines.join('\n')}\n`;
@@ -1,6 +1,6 @@
1
1
  import { homedir } from 'node:os';
2
2
  import { join } from 'node:path';
3
3
 
4
- export function getDshHome() {
5
- return process.env.DSH_HOME || join(homedir(), '.dsh');
4
+ export function getDshHome(env = process.env) {
5
+ return env.DSH_HOME || join(homedir(), '.dsh');
6
6
  }
@@ -1 +1 @@
1
- 2.4.2
1
+ 2.5.0
@@ -283,6 +283,10 @@ def _validate_platform(
283
283
  errors.append(
284
284
  f"illegal capability {platform.id}:{name}={value}"
285
285
  )
286
+ # The manifest carries the platform facts that ship into projects; the
287
+ # adapter is the copy the project runtime reads. The duplication is
288
+ # deliberate, so this equality check is what keeps both sides in step:
289
+ # editing either one alone is a validation error.
286
290
  if capabilities != platform.capabilities:
287
291
  errors.append(
288
292
  f"capability mismatch between manifest and adapter: {platform.id}"
@@ -20,6 +20,7 @@ from pathlib import Path
20
20
  from typing import Any, NamedTuple
21
21
 
22
22
  from adapters.host.policy_base import DEFAULT_DIGEST_POLICY, HostPolicy, default_policy
23
+ from services.decision_anchor_schema import parse_decision_anchor
23
24
 
24
25
 
25
26
  TAG_RE = re.compile(
@@ -358,8 +359,6 @@ def _decision_anchor_block(
358
359
  if effective_status not in DECISION_ANCHOR_STATES:
359
360
  return None
360
361
  try:
361
- from services.fact_view import parse_decision_anchor
362
-
363
362
  text = (root / task_path / "decision-anchor.md").read_text(
364
363
  encoding="utf-8"
365
364
  )
@@ -428,7 +427,6 @@ def _stage_contract_block(
428
427
  from services.fact_view import (
429
428
  build_stage_contract,
430
429
  file_scope_whitelist,
431
- parse_decision_anchor,
432
430
  spec_digest_items,
433
431
  spec_pointer_files,
434
432
  )
@@ -4,7 +4,6 @@
4
4
  from __future__ import annotations
5
5
 
6
6
  import json
7
- import os
8
7
  from pathlib import Path
9
8
 
10
9
 
@@ -27,15 +26,3 @@ def read_text_utf8(path: Path) -> str:
27
26
  return path.read_text(encoding="utf-8")
28
27
  except (OSError, UnicodeDecodeError):
29
28
  return ""
30
-
31
-
32
- def write_json_file(path: Path, data: dict) -> bool:
33
- """Write dict to JSON file atomically (temp + os.replace)."""
34
- try:
35
- json_text = json.dumps(data, indent=2, ensure_ascii=False)
36
- tmp_path = path.with_name(f"{path.name}.{os.getpid()}.tmp")
37
- tmp_path.write_text(json_text, encoding="utf-8")
38
- os.replace(tmp_path, path)
39
- return True
40
- except OSError:
41
- return False
@@ -15,7 +15,7 @@ import json
15
15
  from pathlib import Path
16
16
  from typing import Any
17
17
 
18
- from services.fact_view import parse_decision_anchor
18
+ from services.decision_anchor_schema import parse_decision_anchor
19
19
 
20
20
  EVIDENCE_FILE = "evidence.jsonl"
21
21
  EVIDENCE_KINDS = ("test", "command", "manual")
@@ -11,6 +11,7 @@ which set a newly generated anchor uses.
11
11
  from __future__ import annotations
12
12
 
13
13
  import re
14
+ from typing import Any
14
15
 
15
16
  GOAL = "goal"
16
17
  ACCEPTANCE = "acceptance"
@@ -57,6 +58,13 @@ HEADING_RE = re.compile(r"^##\s*(.+?)\s*$")
57
58
  ACCEPTANCE_RE = re.compile(
58
59
  r"^\s*-\s*(?:\[([ xX])\]?\s*)?(AC-[A-Za-z0-9-]+)\s*[::]\s*(.+?)\s*$"
59
60
  )
61
+ REJECTED_RE = re.compile(r"^\s*-\s*\*\*(.+?)\*\*")
62
+
63
+ GOAL_TRUNCATE = 300
64
+ VERIFY_COMMAND_TRUNCATE = 120
65
+ VERIFY_COMMAND_MAX = 10
66
+ SCOPE_BOUNDARY_TRUNCATE = 160
67
+
60
68
  LIST_ITEM_RE = re.compile(r"^\s*[-*]\s")
61
69
  LIST_PREFIX_RE = re.compile(r"^\s*[-*+]\s*")
62
70
  FENCE_MARKER_RE = re.compile(r"^(```|~~~)")
@@ -226,3 +234,60 @@ def present_sections(text: str) -> set[str]:
226
234
  def acceptance_section_lines(text: str) -> list[str]:
227
235
  """Raw lines under the acceptance heading, up to the next heading."""
228
236
  return section_lines(text, ACCEPTANCE)
237
+
238
+
239
+ def parse_decision_anchor(text: str) -> dict[str, Any]:
240
+ """Extract goal / acceptance criteria / rejected option names / declared
241
+ verification commands / scope boundary from a decision-anchor.md body.
242
+ Section headings may be the Chinese set or the English aliases (see
243
+ spec/contracts/decision-anchor.md); parsing is line-level and degrades to
244
+ empty values when sections are missing."""
245
+ goal_lines: list[str] = []
246
+ acceptance: list[dict[str, str]] = []
247
+ rejected: list[str] = []
248
+ verify_commands: list[str] = []
249
+ scope_boundary = ""
250
+ section: str | None = None
251
+ for raw in text.splitlines():
252
+ heading = HEADING_RE.match(raw.strip())
253
+ if heading:
254
+ section = canonical_section(heading.group(1))
255
+ continue
256
+ if section == GOAL:
257
+ if raw.strip():
258
+ goal_lines.append(raw.strip())
259
+ elif section == ACCEPTANCE:
260
+ match = ACCEPTANCE_RE.match(raw)
261
+ if match:
262
+ acceptance.append(
263
+ {
264
+ "id": match.group(2),
265
+ "text": match.group(3),
266
+ "checked": match.group(1) in ("x", "X"),
267
+ }
268
+ )
269
+ elif section == REJECTED:
270
+ match = REJECTED_RE.match(raw)
271
+ if match:
272
+ rejected.append(match.group(1).strip())
273
+ elif section == VERIFICATION:
274
+ command = raw.strip()
275
+ if command.startswith("- "):
276
+ command = command[2:].strip()
277
+ if command.startswith("<!--"):
278
+ # Scaffold instructions and author notes are not commands.
279
+ continue
280
+ if is_spec_check_line(command):
281
+ continue
282
+ if command and len(verify_commands) < VERIFY_COMMAND_MAX:
283
+ verify_commands.append(command[:VERIFY_COMMAND_TRUNCATE])
284
+ elif section == SCOPE:
285
+ if raw.strip() and not scope_boundary:
286
+ scope_boundary = raw.strip()[:SCOPE_BOUNDARY_TRUNCATE]
287
+ return {
288
+ "goal": "\n".join(goal_lines)[:GOAL_TRUNCATE],
289
+ "acceptanceCriteria": acceptance,
290
+ "rejectedOptions": rejected,
291
+ "validationCommands": verify_commands,
292
+ "scopeBoundary": scope_boundary,
293
+ }
@@ -12,85 +12,12 @@ them from file conventions.
12
12
  from __future__ import annotations
13
13
 
14
14
  import json
15
- import re
16
15
  from datetime import datetime, timezone
17
16
  from pathlib import Path
18
17
  from typing import Any
19
18
 
20
- from services.decision_anchor_schema import (
21
- ACCEPTANCE,
22
- ACCEPTANCE_RE,
23
- GOAL,
24
- HEADING_RE,
25
- REJECTED,
26
- SCOPE,
27
- VERIFICATION,
28
- canonical_section,
29
- is_spec_check_line,
30
- )
31
-
32
- GOAL_TRUNCATE = 300
33
- VERIFY_COMMAND_TRUNCATE = 120
34
- VERIFY_COMMAND_MAX = 10
35
- SCOPE_BOUNDARY_TRUNCATE = 160
36
- REJECTED_RE = re.compile(r"^\s*-\s*\*\*(.+?)\*\*")
37
-
38
-
39
- def parse_decision_anchor(text: str) -> dict[str, Any]:
40
- """Extract goal / acceptance criteria / rejected option names / declared
41
- verification commands / scope boundary from a decision-anchor.md body.
42
- Section headings may be the Chinese set or the English aliases (see
43
- spec/contracts/decision-anchor.md); parsing is line-level and degrades to
44
- empty values when sections are missing."""
45
- goal_lines: list[str] = []
46
- acceptance: list[dict[str, str]] = []
47
- rejected: list[str] = []
48
- verify_commands: list[str] = []
49
- scope_boundary = ""
50
- section: str | None = None
51
- for raw in text.splitlines():
52
- heading = HEADING_RE.match(raw.strip())
53
- if heading:
54
- section = canonical_section(heading.group(1))
55
- continue
56
- if section == GOAL:
57
- if raw.strip():
58
- goal_lines.append(raw.strip())
59
- elif section == ACCEPTANCE:
60
- match = ACCEPTANCE_RE.match(raw)
61
- if match:
62
- acceptance.append(
63
- {
64
- "id": match.group(2),
65
- "text": match.group(3),
66
- "checked": match.group(1) in ("x", "X"),
67
- }
68
- )
69
- elif section == REJECTED:
70
- match = REJECTED_RE.match(raw)
71
- if match:
72
- rejected.append(match.group(1).strip())
73
- elif section == VERIFICATION:
74
- command = raw.strip()
75
- if command.startswith("- "):
76
- command = command[2:].strip()
77
- if command.startswith("<!--"):
78
- # Scaffold instructions and author notes are not commands.
79
- continue
80
- if is_spec_check_line(command):
81
- continue
82
- if command and len(verify_commands) < VERIFY_COMMAND_MAX:
83
- verify_commands.append(command[:VERIFY_COMMAND_TRUNCATE])
84
- elif section == SCOPE:
85
- if raw.strip() and not scope_boundary:
86
- scope_boundary = raw.strip()[:SCOPE_BOUNDARY_TRUNCATE]
87
- return {
88
- "goal": "\n".join(goal_lines)[:GOAL_TRUNCATE],
89
- "acceptanceCriteria": acceptance,
90
- "rejectedOptions": rejected,
91
- "validationCommands": verify_commands,
92
- "scopeBoundary": scope_boundary,
93
- }
19
+ # Re-exported for existing callers; the parser has one definition.
20
+ from services.decision_anchor_schema import parse_decision_anchor
94
21
 
95
22
 
96
23
  def _now_iso() -> str:
@@ -15,8 +15,8 @@ from dataclasses import dataclass
15
15
  from pathlib import Path
16
16
 
17
17
  from infra.git_snapshot import collect_changed_paths_since
18
+ from services.decision_anchor_schema import parse_decision_anchor
18
19
  from services.fact_view import (
19
- parse_decision_anchor,
20
20
  spec_pointer_files,
21
21
  task_baseline,
22
22
  task_data,
@@ -18,6 +18,7 @@ from services.decision_anchor_schema import (
18
18
  heading_for,
19
19
  headings,
20
20
  is_spec_check_result_line,
21
+ parse_decision_anchor,
21
22
  present_sections,
22
23
  section_headings,
23
24
  spec_check_example,
@@ -143,13 +144,7 @@ def plan_readiness_blockers(
143
144
  repo_root = Path(repo_root)
144
145
  task_dir = Path(task_dir)
145
146
  resolved_language = language or get_language(repo_root)
146
- status = task_data.get("status")
147
- blockers: list[str] = []
148
- if status != "planning":
149
- blockers.append(
150
- "plan finalize only runs on a planning task; "
151
- f"current status is {status or 'missing'}"
152
- )
147
+ blockers = _planning_status_blockers(task_data)
153
148
 
154
149
  blocking_plan_facts = plan_file_blockers(repo_root, task_data)
155
150
  blockers.extend(blocking_plan_facts)
@@ -165,6 +160,56 @@ def plan_readiness_blockers(
165
160
  blockers.append(f"plan is empty: {_display(repo_root, plan_path)}")
166
161
  return blockers
167
162
 
163
+ goal, acceptance, content_blockers = _plan_content_blockers(
164
+ plan_text, resolved_language
165
+ )
166
+ blockers.extend(content_blockers)
167
+
168
+ template_path = repo_root / PLAN_TEMPLATE_PATH
169
+ template_text = (
170
+ read_text_utf8(template_path) if template_path.is_file() else ""
171
+ )
172
+ if not template_text.strip():
173
+ blockers.append(
174
+ "installed plan template is missing or empty; run "
175
+ "`cwf project sync .` before finalizing"
176
+ )
177
+ return blockers
178
+ blockers.extend(
179
+ _plan_structure_blockers(
180
+ plan_text,
181
+ template_text,
182
+ task_data,
183
+ resolved_language,
184
+ )
185
+ )
186
+ blockers.extend(
187
+ _anchor_artifact_blockers(
188
+ task_dir,
189
+ task_data,
190
+ goal,
191
+ acceptance,
192
+ resolved_language,
193
+ )
194
+ )
195
+ return blockers
196
+
197
+
198
+ def _planning_status_blockers(task_data: dict) -> list[str]:
199
+ status = task_data.get("status")
200
+ if status == "planning":
201
+ return []
202
+ return [
203
+ "plan finalize only runs on a planning task; "
204
+ f"current status is {status or 'missing'}"
205
+ ]
206
+
207
+
208
+ def _plan_content_blockers(
209
+ plan_text: str,
210
+ language: str,
211
+ ) -> tuple[str | None, list[dict[str, str]], list[str]]:
212
+ blockers: list[str] = []
168
213
  goal = plan_goal(plan_text)
169
214
  if not goal:
170
215
  blockers.append(
@@ -177,7 +222,7 @@ def plan_readiness_blockers(
177
222
  "replace it with the observable behavior"
178
223
  )
179
224
 
180
- acceptance = plan_acceptance_criteria(plan_text, resolved_language)
225
+ acceptance = plan_acceptance_criteria(plan_text, language)
181
226
  if not acceptance:
182
227
  blockers.append(
183
228
  "plan `## 验收标准` / `## Acceptance Criteria` has no AC-NNN rows"
@@ -193,24 +238,26 @@ def plan_readiness_blockers(
193
238
  "plan acceptance criterion(s) still use template placeholders: "
194
239
  + ", ".join(placeholder_rows)
195
240
  )
241
+ return goal, acceptance, blockers
242
+
196
243
 
197
- expected_sections = {
244
+ def _expected_sections(language: str) -> tuple[str, ...]:
245
+ return {
198
246
  "zh-CN": ("目标", "全局约束", "文件边界", "任务"),
199
247
  "en-US": ("Goal", "Global Constraints", "File Boundaries", "Tasks"),
200
248
  }.get(
201
- resolved_language,
249
+ language,
202
250
  ("目标", "全局约束", "文件边界", "任务"),
203
251
  )
204
- template_path = repo_root / PLAN_TEMPLATE_PATH
205
- template_text = (
206
- read_text_utf8(template_path) if template_path.is_file() else ""
207
- )
208
- if not template_text.strip():
209
- blockers.append(
210
- "installed plan template is missing or empty; run "
211
- "`cwf project sync .` before finalizing"
212
- )
213
- return blockers
252
+
253
+
254
+ def _plan_structure_blockers(
255
+ plan_text: str,
256
+ template_text: str,
257
+ task_data: dict,
258
+ language: str,
259
+ ) -> list[str]:
260
+ expected_sections = _expected_sections(language)
214
261
  template_sections = {
215
262
  heading: _raw_section_lines(template_text, heading)
216
263
  for heading in expected_sections
@@ -218,6 +265,7 @@ def plan_readiness_blockers(
218
265
  template_fields = _task_fields(
219
266
  template_sections.get(expected_sections[-1], [])
220
267
  )
268
+ blockers: list[str] = []
221
269
 
222
270
  for heading in expected_sections[:-1]:
223
271
  if not _has_meaningful_lines(
@@ -235,64 +283,92 @@ def plan_readiness_blockers(
235
283
  "plan `## 任务` / `## Tasks` has no `### 任务 N` / `### Task N` block"
236
284
  )
237
285
  else:
238
- tiny = declares_light_profile(task_data)
239
- required_fields = TINY_TASK_FIELDS.get(
240
- resolved_language, TINY_TASK_FIELDS["zh-CN"]
241
- ) if tiny else TASK_FIELDS.get(
242
- resolved_language, TASK_FIELDS["zh-CN"]
286
+ blockers.extend(
287
+ _task_block_blockers(
288
+ task_blocks,
289
+ task_data,
290
+ language,
291
+ template_fields,
292
+ )
293
+ )
294
+ return blockers
295
+
296
+
297
+ def _task_block_blockers(
298
+ task_blocks: list[dict],
299
+ task_data: dict,
300
+ language: str,
301
+ template_fields: dict[str, list[str]],
302
+ ) -> list[str]:
303
+ blockers: list[str] = []
304
+ tiny = declares_light_profile(task_data)
305
+ required_fields = TINY_TASK_FIELDS.get(
306
+ language, TINY_TASK_FIELDS["zh-CN"]
307
+ ) if tiny else TASK_FIELDS.get(
308
+ language, TASK_FIELDS["zh-CN"]
309
+ )
310
+ missing_template_fields = [
311
+ field for field in required_fields if field not in template_fields
312
+ ]
313
+ if missing_template_fields:
314
+ blockers.append(
315
+ "installed plan template is missing task brief field(s): "
316
+ + ", ".join(missing_template_fields)
243
317
  )
244
- missing_template_fields = [
245
- field for field in required_fields if field not in template_fields
318
+ verification_field = (
319
+ "Verification Command"
320
+ if language == "en-US"
321
+ else "验证命令"
322
+ )
323
+ for block in task_blocks:
324
+ fields = _task_fields(block["lines"])
325
+ missing = [
326
+ field for field in required_fields if field not in fields
246
327
  ]
247
- if missing_template_fields:
328
+ if missing:
248
329
  blockers.append(
249
- "installed plan template is missing task brief field(s): "
250
- + ", ".join(missing_template_fields)
330
+ f"plan task `### {block['heading']}` is missing brief "
331
+ f"field(s): {', '.join(missing)}"
251
332
  )
252
- verification_field = (
253
- "Verification Command"
254
- if resolved_language == "en-US"
255
- else "验证命令"
256
- )
257
- for block in task_blocks:
258
- fields = _task_fields(block["lines"])
259
- missing = [
260
- field for field in required_fields if field not in fields
261
- ]
262
- if missing:
263
- blockers.append(
264
- f"plan task `### {block['heading']}` is missing brief "
265
- f"field(s): {', '.join(missing)}"
266
- )
267
- continue
268
- empty = [
269
- field
270
- for field in required_fields
271
- if (
272
- not _has_verification_command(fields[field])
273
- if field == verification_field
274
- else not _has_meaningful_lines(
275
- fields[field], template_fields.get(field, [])
276
- )
277
- )
278
- ]
279
- if empty:
280
- blockers.append(
281
- f"plan task `### {block['heading']}` has empty brief "
282
- f"field(s): {', '.join(empty)}"
333
+ continue
334
+ empty = [
335
+ field
336
+ for field in required_fields
337
+ if (
338
+ not _has_verification_command(fields[field])
339
+ if field == verification_field
340
+ else not _has_meaningful_lines(
341
+ fields[field], template_fields.get(field, [])
283
342
  )
343
+ )
344
+ ]
345
+ if empty:
346
+ blockers.append(
347
+ f"plan task `### {block['heading']}` has empty brief "
348
+ f"field(s): {', '.join(empty)}"
349
+ )
350
+ return blockers
351
+
284
352
 
353
+ def _anchor_artifact_blockers(
354
+ task_dir: Path,
355
+ task_data: dict,
356
+ goal: str | None,
357
+ acceptance: list[dict[str, str]],
358
+ language: str,
359
+ ) -> list[str]:
360
+ blockers: list[str] = []
285
361
  anchor_path = task_dir / "decision-anchor.md"
286
362
  anchor_text = read_text_utf8(anchor_path)
287
363
  if not anchor_text.strip():
288
364
  blockers.append("decision-anchor.md is missing or empty")
289
365
  else:
290
- blockers.extend(_anchor_blockers(anchor_text, resolved_language))
366
+ blockers.extend(_anchor_blockers(anchor_text, language))
291
367
  blockers.extend(acceptance_row_blockers(anchor_text))
292
368
  blockers.extend(
293
369
  _anchor_spec_check_blockers(
294
370
  anchor_text,
295
- resolved_language,
371
+ language,
296
372
  _dev_type(task_data),
297
373
  )
298
374
  )
@@ -544,8 +620,6 @@ def _anchor_spec_check_blockers(
544
620
 
545
621
 
546
622
  def _acceptance_sync_blockers(plan_rows: list[dict[str, str]], anchor_text: str) -> list[str]:
547
- from services.fact_view import parse_decision_anchor
548
-
549
623
  anchor_rows = parse_decision_anchor(anchor_text).get("acceptanceCriteria") or []
550
624
  plan_ids = [row["id"] for row in plan_rows]
551
625
  anchor_ids = [row.get("id") for row in anchor_rows]
@@ -566,8 +640,6 @@ def _acceptance_sync_blockers(plan_rows: list[dict[str, str]], anchor_text: str)
566
640
  def _goal_sync_blockers(plan_goal_text: str | None, anchor_text: str) -> list[str]:
567
641
  if not plan_goal_text:
568
642
  return []
569
- from services.fact_view import parse_decision_anchor
570
-
571
643
  anchor_goal = str(parse_decision_anchor(anchor_text).get("goal") or "").strip()
572
644
  if not anchor_goal:
573
645
  return ["decision-anchor.md has no goal text"]