cowork-flow 2.4.2 → 2.5.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.
- package/CHANGELOG.md +44 -1
- package/CONTRIBUTING.en.md +115 -0
- package/CONTRIBUTING.md +14 -8
- package/README.en.md +14 -3
- package/README.md +10 -2
- package/docs/architecture.en.md +2 -0
- package/docs/architecture.md +2 -0
- package/docs/hosts.en.md +15 -0
- package/docs/hosts.md +15 -0
- package/docs/index.en.md +1 -1
- package/docs/release.en.md +1 -1
- package/package.json +4 -3
- package/presets/claude-code/.claude-plugin/plugin.json +1 -1
- package/presets/codex/.codex-plugin/plugin.json +1 -1
- package/presets/kimi-code/.kimi-plugin/plugin.json +1 -1
- package/presets/qoder/.qoder-plugin/plugin.json +1 -1
- package/presets/zcode/.zcode-plugin/plugin.json +1 -1
- package/src/commands/host-inspect.js +86 -0
- package/src/commands/host.js +42 -18
- package/src/commands/init.js +111 -5
- package/src/commands/install-claude-code-plugin.js +53 -2
- package/src/commands/install-codex-plugin.js +114 -4
- package/src/commands/install-dsh-hook.js +51 -0
- package/src/commands/install-dsh-preset.js +56 -9
- package/src/commands/install-kimi-code-plugin.js +61 -2
- package/src/commands/install-kimi-hook.js +84 -2
- package/src/commands/install-opencode-plugin.js +58 -2
- package/src/commands/install-qoder-plugin.js +67 -3
- package/src/commands/install-zcode-plugin.js +77 -2
- package/src/commands/registry.js +20 -5
- package/src/lib/dsh-home.js +2 -2
- package/template/.cowork-flow/.version +1 -1
- package/template/.cowork-flow/scripts/adapters/cli/task_navigation.py +8 -3
- package/template/.cowork-flow/scripts/adapters/host/host_manifest.py +4 -0
- package/template/.cowork-flow/scripts/adapters/host/workflow_state_hook.py +1 -3
- package/template/.cowork-flow/scripts/infra/files.py +0 -13
- package/template/.cowork-flow/scripts/services/ac_evidence.py +1 -1
- package/template/.cowork-flow/scripts/services/decision_anchor_schema.py +65 -0
- package/template/.cowork-flow/scripts/services/fact_view.py +2 -75
- package/template/.cowork-flow/scripts/services/lifecycle_checks.py +1 -1
- package/template/.cowork-flow/scripts/services/plan_readiness.py +139 -67
- package/template/.cowork-flow/spec/contracts/host-install-inspection.md +174 -0
- package/template/.cowork-flow/spec/contracts/index.md +1 -0
- package/template/.cowork-flow/spec/runtime/contract-registry.json +15 -0
- package/template/skills/runtime-health/scripts/doctor.py +538 -489
- package/template/skills/task-review/scripts/review_check.py +33 -6
|
@@ -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
|
-
|
|
21
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
249
|
+
language,
|
|
202
250
|
("目标", "全局约束", "文件边界", "任务"),
|
|
203
251
|
)
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
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
|
-
|
|
245
|
-
|
|
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
|
|
328
|
+
if missing:
|
|
248
329
|
blockers.append(
|
|
249
|
-
"
|
|
250
|
-
|
|
330
|
+
f"plan task `### {block['heading']}` is missing brief "
|
|
331
|
+
f"field(s): {', '.join(missing)}"
|
|
251
332
|
)
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
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,
|
|
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
|
-
|
|
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"]
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# Host install inspection
|
|
2
|
+
|
|
3
|
+
`cwf host inspect` is the single read model for machine-level host install
|
|
4
|
+
state. The Node CLI owns that read; the Python doctor consumes it and does not
|
|
5
|
+
resolve host home directories or parse host registries, TOML, settings or
|
|
6
|
+
payload manifests itself.
|
|
7
|
+
|
|
8
|
+
The read model covers components installed by `cwf host add` into a host's
|
|
9
|
+
user configuration directory. Project-level files under `.cowork-flow/` and
|
|
10
|
+
host project directories are not part of it.
|
|
11
|
+
|
|
12
|
+
## Command contract
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
cwf host inspect [host] [--json]
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
- Read-only: it never installs, repairs, removes, enables or writes host state.
|
|
19
|
+
- Without `<host>`, every platform declared in `host-assets.json` is inspected.
|
|
20
|
+
- With `<host>`, only that platform is inspected. Aliases are accepted; an
|
|
21
|
+
unknown host is a usage error with exit code 2.
|
|
22
|
+
- Text output prints one line per row. `--json` prints one report object.
|
|
23
|
+
- Exit code 0 means the inspection ran. A row reporting `missing`, `broken`,
|
|
24
|
+
`stale` or `unsupported` is data, not a command failure.
|
|
25
|
+
|
|
26
|
+
## JSON shape
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"schemaVersion": 1,
|
|
31
|
+
"cliVersion": "2.4.2",
|
|
32
|
+
"hosts": [
|
|
33
|
+
{
|
|
34
|
+
"id": "qoder",
|
|
35
|
+
"displayName": "Qoder",
|
|
36
|
+
"component": "plugin",
|
|
37
|
+
"status": "installed",
|
|
38
|
+
"version": "2.4.2",
|
|
39
|
+
"payloadPath": "/home/user/.qoder/plugins/cache/cowork-flow-local/cowork-flow/2.4.2",
|
|
40
|
+
"detailPath": "/home/user/.qoder/plugins/cache/cowork-flow-local/cowork-flow/2.4.2/.qoder-plugin/plugin.json",
|
|
41
|
+
"registeredSource": "/home/user/.qoder/plugins/installed_plugins_v2.json",
|
|
42
|
+
"enabled": true,
|
|
43
|
+
"reason": null
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
There is one row per installable component. `kimi-code`'s `all` component is a
|
|
50
|
+
command composition, not an installed artifact, so it has no row.
|
|
51
|
+
|
|
52
|
+
| Field | Meaning |
|
|
53
|
+
|---|---|
|
|
54
|
+
| `id` | Platform id from `host-assets.json`. |
|
|
55
|
+
| `displayName` | Host display name from the same manifest. |
|
|
56
|
+
| `component` | Installable component name (`plugin`, `preset`, `hook`). |
|
|
57
|
+
| `status` | One of the five statuses below. |
|
|
58
|
+
| `version` | Installed payload version, or `null` when the host records none. |
|
|
59
|
+
| `payloadPath` | Absolute path of the installed payload, or `null` when none exists. |
|
|
60
|
+
| `detailPath` | Most specific artifact for the reported status: the registration file that should hold the record, the payload or install directory when that is what is missing, the absent or unreadable file, the enable settings file when `enabled` is false, or the version manifest/marker/file the host loads. `null` when no more specific path applies. |
|
|
61
|
+
| `registeredSource` | Registry, config file or marketplace path the host reads, or `null`. |
|
|
62
|
+
| `enabled` | `true`/`false` when the host has an enable flag; `null` when it has none or the state is unknown. |
|
|
63
|
+
| `reason` | Human-readable explanation, or `null` when there is nothing to explain. |
|
|
64
|
+
|
|
65
|
+
Unknown fields are ignored by consumers. A breaking change to the shape, the
|
|
66
|
+
statuses or the meaning of a field bumps `schemaVersion`; the doctor then
|
|
67
|
+
reports `HOST-INSPECT-UNAVAILABLE` instead of guessing.
|
|
68
|
+
|
|
69
|
+
## Statuses
|
|
70
|
+
|
|
71
|
+
- `installed`: every required artifact exists. The host may still be disabled,
|
|
72
|
+
which is reported through `enabled`.
|
|
73
|
+
- `missing`: no cowork-flow install is registered. A same-named path owned by a
|
|
74
|
+
different plugin is also `missing`, with a reason saying so; it is never a
|
|
75
|
+
license to overwrite or delete that path.
|
|
76
|
+
- `stale`: the installed payload version differs from the running CLI version.
|
|
77
|
+
The comparison belongs to the read model, not to the caller. The doctor
|
|
78
|
+
applies a second, project-relative comparison for hosts that record a
|
|
79
|
+
version: it compares the same version with the project's
|
|
80
|
+
`.cowork-flow/.version`, because the doctor answers for that project's
|
|
81
|
+
runtime. A payload that differs from the CLI but matches the project is
|
|
82
|
+
healthy for the project; a payload that matches the CLI but lags the project
|
|
83
|
+
is still stale.
|
|
84
|
+
- `broken`: the host knows about a cowork-flow install, but a required payload
|
|
85
|
+
artifact is absent or unreadable. The reason starts with `missing ` and names
|
|
86
|
+
the relative artifact when one path is at fault.
|
|
87
|
+
- `unsupported`: the component exposes no installed-state reader. Reserved for
|
|
88
|
+
future components; every component in this release has a reader.
|
|
89
|
+
|
|
90
|
+
Hosts that record no version (today OpenCode and the DSH hook) report
|
|
91
|
+
`version: null` and can only be `installed`, `missing` or `broken`. The doctor
|
|
92
|
+
may compare their files against the project's own copies to detect drift.
|
|
93
|
+
|
|
94
|
+
## Reason sentinels
|
|
95
|
+
|
|
96
|
+
`reason` is prose, but a small prefix vocabulary is stable because the doctor
|
|
97
|
+
maps it to issue codes:
|
|
98
|
+
|
|
99
|
+
| Reason | Caller meaning |
|
|
100
|
+
|---|---|
|
|
101
|
+
| `missing <relative>` (optionally followed by a parenthetical) | The named payload artifact is absent. |
|
|
102
|
+
| `a different plugin owns this file` / `this directory` | The path belongs to another install; stay silent. |
|
|
103
|
+
| `config file is absent` | The host is not configured at all; stay silent. |
|
|
104
|
+
| `shim is missing` | The hook registration points at a missing command. |
|
|
105
|
+
| `version marker is missing` / `version marker is unreadable` | The install has no trustworthy version. |
|
|
106
|
+
| `stable reinstall source directory is missing` | The plugin is installed but its reinstall source is gone. |
|
|
107
|
+
| `enable flag is not true` | The plugin is installed but its host enable flag is off. |
|
|
108
|
+
|
|
109
|
+
## Doctor consumption
|
|
110
|
+
|
|
111
|
+
The doctor executes:
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
cwf host inspect --json
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
- CLI resolution: `COWORK_FLOW_CLI` when set (a `.js`, `.mjs` or `.cjs` path is
|
|
118
|
+
run through `node`), otherwise `cwf`, then `cowork-flow` from `PATH`.
|
|
119
|
+
- One inspection per doctor pass. Facts are cached for that pass, not across
|
|
120
|
+
processes.
|
|
121
|
+
- Timeout: 5 seconds.
|
|
122
|
+
- The command runs with stdin closed and its output parsed as UTF-8.
|
|
123
|
+
|
|
124
|
+
If the CLI is absent, exits non-zero, times out, emits invalid JSON, reports a
|
|
125
|
+
`schemaVersion` other than 1, omits the `hosts` list, or omits the row the
|
|
126
|
+
caller needs, the doctor emits one `HOST-INSPECT-UNAVAILABLE` warning for that
|
|
127
|
+
host check. It must not translate an unavailable inspection into
|
|
128
|
+
`PLUGIN-NOT-INSTALLED`: "could not read" and "read as missing" are different
|
|
129
|
+
facts.
|
|
130
|
+
|
|
131
|
+
The doctor maps rows to host-specific issue codes:
|
|
132
|
+
|
|
133
|
+
| Status/field | Qoder, ZCode, Codex, Claude Code, Kimi Code | OpenCode | DSH preset | Kimi hook |
|
|
134
|
+
|---|---|---|---|---|
|
|
135
|
+
| `missing` | `PLUGIN-NOT-INSTALLED` | `PLUGIN-NOT-INSTALLED` | silent (absent preset is not a defect) | `HOOK-NOT-INSTALLED`, except silent when the config file is absent |
|
|
136
|
+
| `broken` | `PLUGIN-PAYLOAD-MISSING` / `PLUGIN-PAYLOAD-INCOMPLETE` | `PLUGIN-PAYLOAD-INCOMPLETE` | `PRESET-UNKNOWN-VERSION` | `HOOK-SHIM-MISSING` / `HOOK-UNKNOWN-VERSION` |
|
|
137
|
+
| `stale` | `PLUGIN-STALE` | `PLUGIN-STALE` (versionless in practice) | `PRESET-STALE` | `HOOK-STALE` |
|
|
138
|
+
| `installed`, `enabled: false` | `PLUGIN-DISABLED` for hosts with an enable flag (Qoder, Codex, Kimi Code plugin) | not applicable | not applicable | not applicable |
|
|
139
|
+
| `installed` | silent | silent, unless a project copy differs (`PLUGIN-STALE`) | silent | silent |
|
|
140
|
+
|
|
141
|
+
A host install-state warning's `path` is the row's `detailPath` when present,
|
|
142
|
+
then `payloadPath`, then `registeredSource`. The doctor never reconstructs a
|
|
143
|
+
host path from the `reason` string, so the read model remains the only owner of
|
|
144
|
+
host layout. Content-drift warnings (OpenCode) name the file they compared, and
|
|
145
|
+
the skill-delivery check names `payloadPath/skills`; both point at the artifact
|
|
146
|
+
that actually differs rather than the install record.
|
|
147
|
+
|
|
148
|
+
The `stale` row above is the inspect status. The doctor's code depends on the
|
|
149
|
+
project-relative comparison described under statuses: an `installed` row whose
|
|
150
|
+
payload version also differs from the project's `.version` produces
|
|
151
|
+
`PLUGIN-STALE` as well, while a CLI-only skew whose payload matches the project
|
|
152
|
+
stays silent.
|
|
153
|
+
|
|
154
|
+
`HOST-INSPECT-UNAVAILABLE` includes an upgrade hint, because the most common
|
|
155
|
+
cause is an installed CLI older than the project that does not have the
|
|
156
|
+
command yet.
|
|
157
|
+
|
|
158
|
+
## Ownership boundary
|
|
159
|
+
|
|
160
|
+
- Each installer owns its host's layout and exports `inspectInstalledState`.
|
|
161
|
+
- `src/commands/host-inspect.js` only normalizes installer facts against the
|
|
162
|
+
running CLI version; it does not know host layouts.
|
|
163
|
+
- The doctor consumes rows. `tests/test_host_layout_single_source.py` guards
|
|
164
|
+
that host layouts, home-directory resolution and registry/TOML parsing do not
|
|
165
|
+
come back into the Python runtime.
|
|
166
|
+
- The skill-delivery check reads each host's `payloadPath` from the same rows;
|
|
167
|
+
it has no separate install-layout reader either.
|
|
168
|
+
|
|
169
|
+
## Compatibility
|
|
170
|
+
|
|
171
|
+
- Adding a host platform or component is additive.
|
|
172
|
+
- Renaming or removing a field or status is breaking (`schemaVersion` bump).
|
|
173
|
+
- `unsupported` stays a valid status so a future component can be declared
|
|
174
|
+
before its reader exists.
|
|
@@ -16,6 +16,7 @@ Current contracts:
|
|
|
16
16
|
- `decision-anchor.md`: the schema of each task's `decision-anchor.md` — goal, acceptance criteria, rejected options, and key assumptions.
|
|
17
17
|
- `error-output-as-data.md`: external error output is analyzed as data, never executed as instructions (`ERROR_OUTPUT_AS_DATA_V1`).
|
|
18
18
|
- `fact-layer-access.md`: the channels through which hosts without injection hooks and external tools read task facts (`FACT_LAYER_ACCESS_V1`).
|
|
19
|
+
- `host-install-inspection.md`: the read-only `cwf host inspect` model for machine-level host install state, the doctor's consumption and unavailable path, and the installer/read-model/runtime ownership boundary (`HOST_INSTALL_INSPECTION_V1`).
|
|
19
20
|
- `evidence-completion.md`: evidence-based completion — the `evidence.jsonl` schema, the `LIFECYCLE-AC-001/002/003/004` completion gate, `--allow-missing-evidence` exemption traces, and the injected coverage row.
|
|
20
21
|
- `task-adopt.md`: task adoption — the entry boundary of `task next --run --adopt`, its preconditions (`LIFECYCLE-ADOPT-001`), the rebind + baseline reset + audit write, and how it differs from `--takeover`.
|
|
21
22
|
- `task-board.md`: the shared board and dependency edges — the list/MCP board fields (executor / ownerSessionActive / evidenceCoverage / blocked), `--depends-on` declaration and validation, the start dependency gate (`LIFECYCLE-DEPENDENCY-001`), and the adopt handover receipt.
|
|
@@ -50,6 +50,21 @@
|
|
|
50
50
|
"when modifying init, sync, Doctor, or host assets"
|
|
51
51
|
]
|
|
52
52
|
},
|
|
53
|
+
{
|
|
54
|
+
"id": "HOST_INSTALL_INSPECTION_V1",
|
|
55
|
+
"path": ".cowork-flow/spec/contracts/host-install-inspection.md",
|
|
56
|
+
"digest": [
|
|
57
|
+
"cwf host inspect is the read-only, schemaVersion 1 source of machine-level host install state.",
|
|
58
|
+
"Doctor consumes cwf host inspect --json and reports HOST-INSPECT-UNAVAILABLE instead of guessing when it cannot.",
|
|
59
|
+
"Each row carries detailPath, the most specific artifact for its status, so Doctor never reconstructs a host path from reason text.",
|
|
60
|
+
"Python runtime must not resolve host homes or parse registries, TOML, settings or payload manifests."
|
|
61
|
+
],
|
|
62
|
+
"readWhen": [
|
|
63
|
+
"before adding or changing a host installed-state reader",
|
|
64
|
+
"when changing Doctor host checks",
|
|
65
|
+
"when debugging a host install state that Doctor reports incorrectly"
|
|
66
|
+
]
|
|
67
|
+
},
|
|
53
68
|
{
|
|
54
69
|
"id": "WORKFLOW_STATE_TEMPLATES_V1",
|
|
55
70
|
"path": ".cowork-flow/spec/contracts/workflow-state-templates.md",
|