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.
Files changed (46) hide show
  1. package/CHANGELOG.md +44 -1
  2. package/CONTRIBUTING.en.md +115 -0
  3. package/CONTRIBUTING.md +14 -8
  4. package/README.en.md +14 -3
  5. package/README.md +10 -2
  6. package/docs/architecture.en.md +2 -0
  7. package/docs/architecture.md +2 -0
  8. package/docs/hosts.en.md +15 -0
  9. package/docs/hosts.md +15 -0
  10. package/docs/index.en.md +1 -1
  11. package/docs/release.en.md +1 -1
  12. package/package.json +4 -3
  13. package/presets/claude-code/.claude-plugin/plugin.json +1 -1
  14. package/presets/codex/.codex-plugin/plugin.json +1 -1
  15. package/presets/kimi-code/.kimi-plugin/plugin.json +1 -1
  16. package/presets/qoder/.qoder-plugin/plugin.json +1 -1
  17. package/presets/zcode/.zcode-plugin/plugin.json +1 -1
  18. package/src/commands/host-inspect.js +86 -0
  19. package/src/commands/host.js +42 -18
  20. package/src/commands/init.js +111 -5
  21. package/src/commands/install-claude-code-plugin.js +53 -2
  22. package/src/commands/install-codex-plugin.js +114 -4
  23. package/src/commands/install-dsh-hook.js +51 -0
  24. package/src/commands/install-dsh-preset.js +56 -9
  25. package/src/commands/install-kimi-code-plugin.js +61 -2
  26. package/src/commands/install-kimi-hook.js +84 -2
  27. package/src/commands/install-opencode-plugin.js +58 -2
  28. package/src/commands/install-qoder-plugin.js +67 -3
  29. package/src/commands/install-zcode-plugin.js +77 -2
  30. package/src/commands/registry.js +20 -5
  31. package/src/lib/dsh-home.js +2 -2
  32. package/template/.cowork-flow/.version +1 -1
  33. package/template/.cowork-flow/scripts/adapters/cli/task_navigation.py +8 -3
  34. package/template/.cowork-flow/scripts/adapters/host/host_manifest.py +4 -0
  35. package/template/.cowork-flow/scripts/adapters/host/workflow_state_hook.py +1 -3
  36. package/template/.cowork-flow/scripts/infra/files.py +0 -13
  37. package/template/.cowork-flow/scripts/services/ac_evidence.py +1 -1
  38. package/template/.cowork-flow/scripts/services/decision_anchor_schema.py +65 -0
  39. package/template/.cowork-flow/scripts/services/fact_view.py +2 -75
  40. package/template/.cowork-flow/scripts/services/lifecycle_checks.py +1 -1
  41. package/template/.cowork-flow/scripts/services/plan_readiness.py +139 -67
  42. package/template/.cowork-flow/spec/contracts/host-install-inspection.md +174 -0
  43. package/template/.cowork-flow/spec/contracts/index.md +1 -0
  44. package/template/.cowork-flow/spec/runtime/contract-registry.json +15 -0
  45. package/template/skills/runtime-health/scripts/doctor.py +538 -489
  46. package/template/skills/task-review/scripts/review_check.py +33 -6
@@ -23,8 +23,8 @@ const LABEL = 'Kimi Code plugin';
23
23
  export const FLAGS = ['--dry-run', '--force', '--uninstall'];
24
24
 
25
25
 
26
- function kimiHome() {
27
- const configured = (process.env.KIMI_CODE_HOME || '').trim();
26
+ function kimiHome(env = process.env) {
27
+ const configured = (env.KIMI_CODE_HOME || '').trim();
28
28
  // The host rejects a relative plugin root; the resolved path is printed to paste.
29
29
  return configured ? resolve(configured) : join(homedir(), '.kimi-code');
30
30
  }
@@ -150,3 +150,62 @@ export async function runInstallKimiPlugin(args = []) {
150
150
  console.log(' Restart Kimi Code to load the plugin.');
151
151
  return 0;
152
152
  }
153
+
154
+
155
+ // Read-only installed-state facts for `host inspect`.
156
+ export async function inspectInstalledState({ env = process.env } = {}) {
157
+ const home = kimiHome(env);
158
+ const registry = installedRegistryPath(home);
159
+ const data = await readJsonFile(registry);
160
+ const entries = Array.isArray(data?.plugins) ? data.plugins : [];
161
+ const record = entries.find(
162
+ (entry) => entry && typeof entry === 'object' && entry.id === KIMI_PLUGIN_ID
163
+ );
164
+ if (!record) {
165
+ return {
166
+ status: 'missing',
167
+ version: null,
168
+ payloadPath: null,
169
+ detailPath: registry,
170
+ registeredSource: registry,
171
+ enabled: null,
172
+ reason: 'no registry record'
173
+ };
174
+ }
175
+ const root = typeof record.root === 'string' && record.root
176
+ ? record.root
177
+ : managedDir(home);
178
+ const enabled = record.enabled !== false;
179
+ const { manifest } = pluginPayload('kimi-code');
180
+ for (const relative of [manifest, 'skills/cowork-flow-bootstrap/SKILL.md']) {
181
+ if (!(await pathExists(join(root, ...relative.split('/'))))) {
182
+ return {
183
+ status: 'broken',
184
+ version: null,
185
+ payloadPath: root,
186
+ detailPath: join(root, ...relative.split('/')),
187
+ registeredSource: registry,
188
+ enabled,
189
+ reason: `missing ${relative}`
190
+ };
191
+ }
192
+ }
193
+ const payloadManifest = await readJsonFile(join(root, ...manifest.split('/')));
194
+ const version = typeof payloadManifest?.version === 'string'
195
+ ? payloadManifest.version
196
+ : null;
197
+ const sourceMissing = !(await pathExists(sourceDir(home)));
198
+ return {
199
+ status: 'installed',
200
+ version,
201
+ payloadPath: root,
202
+ detailPath: !enabled
203
+ ? registry
204
+ : (sourceMissing
205
+ ? sourceDir(home)
206
+ : join(root, ...manifest.split('/'))),
207
+ registeredSource: registry,
208
+ enabled,
209
+ reason: sourceMissing ? 'stable reinstall source directory is missing' : null
210
+ };
211
+ }
@@ -20,6 +20,7 @@ const HOOK_TIMEOUT = 30;
20
20
  // would append a second block.
21
21
  const MANAGED_START = '# cowork-flow: kimi hook start. Managed by "cowork-flow install-kimi-hook"; edits inside this block are replaced.';
22
22
  const MANAGED_END = '# cowork-flow: kimi hook end.';
23
+ const HOOK_START_MARK = '# cowork-flow: kimi hook start.';
23
24
 
24
25
  // Rendered by `host add`/`host remove`. No --force:
25
26
  // installing always rewrites the shim and its managed
@@ -28,8 +29,8 @@ const MANAGED_END = '# cowork-flow: kimi hook end.';
28
29
  export const FLAGS = ['--dry-run', '--uninstall'];
29
30
 
30
31
 
31
- function getKimiHome() {
32
- return process.env.KIMI_CODE_HOME || join(homedir(), '.kimi-code');
32
+ function getKimiHome(env = process.env) {
33
+ return env.KIMI_CODE_HOME || join(homedir(), '.kimi-code');
33
34
  }
34
35
 
35
36
 
@@ -369,3 +370,84 @@ export async function runInstallKimiHook(args = []) {
369
370
 
370
371
  await installHook({ config, home, shim, marker });
371
372
  }
373
+
374
+
375
+ // Read-only installed-state facts for `host inspect`.
376
+ export async function inspectInstalledState({ env = process.env } = {}) {
377
+ const home = getKimiHome(env);
378
+ const config = configFile(home);
379
+ const shim = shimDest(home);
380
+ const marker = markerDest(home);
381
+ const configText = await readIfExists(config);
382
+ if (configText === null) {
383
+ return {
384
+ status: 'missing',
385
+ version: null,
386
+ payloadPath: shim,
387
+ detailPath: config,
388
+ registeredSource: config,
389
+ enabled: null,
390
+ reason: 'config file is absent'
391
+ };
392
+ }
393
+ if (!configText.includes(HOOK_START_MARK)) {
394
+ return {
395
+ status: 'missing',
396
+ version: null,
397
+ payloadPath: shim,
398
+ detailPath: config,
399
+ registeredSource: config,
400
+ enabled: null,
401
+ reason: 'hook block is absent'
402
+ };
403
+ }
404
+ if (!(await pathExists(shim))) {
405
+ return {
406
+ status: 'broken',
407
+ version: null,
408
+ payloadPath: shim,
409
+ detailPath: shim,
410
+ registeredSource: config,
411
+ enabled: true,
412
+ reason: 'shim is missing'
413
+ };
414
+ }
415
+ const markerDocument = await readIfExists(marker);
416
+ if (markerDocument === null) {
417
+ return {
418
+ status: 'broken',
419
+ version: null,
420
+ payloadPath: shim,
421
+ detailPath: marker,
422
+ registeredSource: config,
423
+ enabled: true,
424
+ reason: 'version marker is missing'
425
+ };
426
+ }
427
+ let version = null;
428
+ try {
429
+ version = JSON.parse(markerDocument).version ?? null;
430
+ } catch {
431
+ version = null;
432
+ }
433
+ if (typeof version !== 'string' || version === '') {
434
+ return {
435
+ status: 'broken',
436
+ version: null,
437
+ payloadPath: shim,
438
+ detailPath: marker,
439
+ registeredSource: config,
440
+ enabled: true,
441
+ reason: 'version marker is unreadable'
442
+ };
443
+ }
444
+ return {
445
+ status: 'installed',
446
+ version,
447
+ payloadPath: shim,
448
+ detailPath: marker,
449
+ registeredSource: config,
450
+ enabled: true,
451
+ reason: null
452
+ };
453
+ }
@@ -19,8 +19,8 @@ export const FLAGS = ['--dry-run', '--force', '--uninstall'];
19
19
 
20
20
 
21
21
  // $XDG_CONFIG_HOME/opencode, falling back to ~/.config/opencode — on every platform.
22
- function opencodeHome() {
23
- const configured = (process.env.XDG_CONFIG_HOME || '').trim();
22
+ function opencodeHome(env = process.env) {
23
+ const configured = (env.XDG_CONFIG_HOME || '').trim();
24
24
  return configured ? join(configured, 'opencode') : join(homedir(), '.config', 'opencode');
25
25
  }
26
26
 
@@ -88,3 +88,59 @@ export async function runInstallOpenCodePlugin(args = []) {
88
88
  onDone: () => console.log(' Loads in the next OpenCode session; no marketplace, registry or enable step.')
89
89
  });
90
90
  }
91
+
92
+
93
+ // Read-only installed-state facts for `host inspect`. OpenCode has no version
94
+ // manifest, so version stays null; the doctor compares file contents.
95
+ export async function inspectInstalledState({ env = process.env } = {}) {
96
+ const home = opencodeHome(env);
97
+ const plugin = pluginPath(home);
98
+ const payload = payloadPath(home);
99
+ let installed;
100
+ try {
101
+ installed = await readFile(plugin, 'utf8');
102
+ } catch {
103
+ return {
104
+ status: 'missing',
105
+ version: null,
106
+ payloadPath: payload,
107
+ detailPath: plugin,
108
+ registeredSource: plugin,
109
+ enabled: null,
110
+ reason: 'no plugin file'
111
+ };
112
+ }
113
+ if (!installed.includes(PLUGIN_MARKER)) {
114
+ return {
115
+ status: 'missing',
116
+ version: null,
117
+ payloadPath: payload,
118
+ detailPath: plugin,
119
+ registeredSource: plugin,
120
+ enabled: null,
121
+ reason: 'a different plugin owns this file'
122
+ };
123
+ }
124
+ for (const relative of ['plugin-core.js', 'skills/cowork-flow-bootstrap/SKILL.md']) {
125
+ if (!(await pathExists(join(payload, ...relative.split('/'))))) {
126
+ return {
127
+ status: 'broken',
128
+ version: null,
129
+ payloadPath: payload,
130
+ detailPath: join(payload, ...relative.split('/')),
131
+ registeredSource: plugin,
132
+ enabled: true,
133
+ reason: `missing cowork-flow/${relative}`
134
+ };
135
+ }
136
+ }
137
+ return {
138
+ status: 'installed',
139
+ version: null,
140
+ payloadPath: payload,
141
+ detailPath: plugin,
142
+ registeredSource: plugin,
143
+ enabled: true,
144
+ reason: null
145
+ };
146
+ }
@@ -2,7 +2,7 @@ import { cp, mkdir, readFile, rm } from 'node:fs/promises';
2
2
  import { homedir } from 'node:os';
3
3
  import { join } from 'node:path';
4
4
 
5
- import { parseInstallArgs, pathExists, writeJsonAtomic } from '../lib/install-support.js';
5
+ import { parseInstallArgs, pathExists, readJsonFile, writeJsonAtomic } from '../lib/install-support.js';
6
6
  import { readPackageInfo } from '../lib/package-info.js';
7
7
  import { pluginPayload, stampPayloadManifest } from '../lib/plugin-payload.js';
8
8
 
@@ -16,8 +16,8 @@ const REGISTRY_FILE = 'installed_plugins_v2.json';
16
16
  export const FLAGS = ['--dry-run', '--force', '--uninstall'];
17
17
 
18
18
 
19
- function qoderHome() {
20
- const configured = (process.env.QODER_CONFIG_DIR || '').trim();
19
+ function qoderHome(env = process.env) {
20
+ const configured = (env.QODER_CONFIG_DIR || '').trim();
21
21
  return configured || join(homedir(), '.qoder');
22
22
  }
23
23
 
@@ -202,3 +202,67 @@ export async function runInstallQoderPlugin(args = []) {
202
202
  console.log(' Restart Qoder to load the plugin (the IDE has no hook hot reload).');
203
203
  return 0;
204
204
  }
205
+
206
+
207
+ // Read-only installed-state facts for `host inspect`. The registry and the
208
+ // settings flag are the host's records; the payload files are what a session
209
+ // actually loads.
210
+ export async function inspectInstalledState({ env = process.env } = {}) {
211
+ const home = qoderHome(env);
212
+ const paths = pluginPaths(home, null);
213
+ const registry = await readJsonFile(paths.registry);
214
+ const entries = registry?.plugins?.[PLUGIN_KEY];
215
+ const entry = Array.isArray(entries) ? entries[0] : null;
216
+ if (!entry || typeof entry !== 'object') {
217
+ return {
218
+ status: 'missing',
219
+ version: null,
220
+ payloadPath: null,
221
+ detailPath: paths.registry,
222
+ registeredSource: paths.registry,
223
+ enabled: null,
224
+ reason: 'no registry entry'
225
+ };
226
+ }
227
+ const version = typeof entry.version === 'string' ? entry.version : null;
228
+ const installPath = typeof entry.installPath === 'string' ? entry.installPath : '';
229
+ if (!installPath) {
230
+ return {
231
+ status: 'broken',
232
+ version,
233
+ payloadPath: null,
234
+ detailPath: paths.registry,
235
+ registeredSource: paths.registry,
236
+ enabled: null,
237
+ reason: 'registry entry has no installPath'
238
+ };
239
+ }
240
+ const { manifest } = pluginPayload('qoder');
241
+ for (const relative of [manifest, 'hooks/hooks.json', 'hooks/inject-context.mjs']) {
242
+ if (!(await pathExists(join(installPath, ...relative.split('/'))))) {
243
+ const role = relative === manifest ? 'payload manifest' : 'required file';
244
+ return {
245
+ status: 'broken',
246
+ version,
247
+ payloadPath: installPath,
248
+ detailPath: join(installPath, ...relative.split('/')),
249
+ registeredSource: paths.registry,
250
+ enabled: null,
251
+ reason: `missing ${relative} (${role})`
252
+ };
253
+ }
254
+ }
255
+ const settings = await readJsonFile(paths.settings);
256
+ const enabled = settings?.enabledPlugins?.[PLUGIN_KEY] === true;
257
+ return {
258
+ status: 'installed',
259
+ version,
260
+ payloadPath: installPath,
261
+ detailPath: enabled
262
+ ? join(installPath, ...manifest.split('/'))
263
+ : paths.settings,
264
+ registeredSource: paths.registry,
265
+ enabled,
266
+ reason: enabled ? null : 'enable flag is not true'
267
+ };
268
+ }
@@ -18,8 +18,8 @@ const LOCAL_MARKETPLACE_DESCRIPTION = 'Local marketplace registration for cowork
18
18
  export const FLAGS = ['--dry-run', '--force', '--prune-old', '--uninstall'];
19
19
 
20
20
 
21
- function getZCodePluginsRoot() {
22
- const base = process.env.ZCODE_HOME || join(homedir(), '.zcode');
21
+ function getZCodePluginsRoot(env = process.env) {
22
+ const base = env.ZCODE_HOME || join(homedir(), '.zcode');
23
23
  return join(base, 'cli', 'plugins');
24
24
  }
25
25
 
@@ -324,3 +324,78 @@ export async function runInstallZCodePlugin(args = []) {
324
324
  console.log(`✓ cowork-flow ZCode plugin installed to ${destDir}`);
325
325
  console.log(' Restart ZCode to load the plugin.');
326
326
  }
327
+
328
+
329
+ // Read-only installed-state facts for `host inspect`. The active marketplace
330
+ // record is the registration; the payload manifest carries the installed
331
+ // version.
332
+ export async function inspectInstalledState({ env = process.env } = {}) {
333
+ const pluginsRoot = getZCodePluginsRoot(env);
334
+ const { activeMarketplacePath } = marketplacePaths(pluginsRoot);
335
+ const market = await readJsonFile(activeMarketplacePath);
336
+ const plugins = Array.isArray(market?.plugins) ? market.plugins : [];
337
+ const entry = plugins.find((plugin) => plugin?.name === PLUGIN_NAME) ?? null;
338
+ if (!entry) {
339
+ return {
340
+ status: 'missing',
341
+ version: null,
342
+ payloadPath: null,
343
+ detailPath: activeMarketplacePath,
344
+ registeredSource: activeMarketplacePath,
345
+ enabled: null,
346
+ reason: 'no marketplace entry'
347
+ };
348
+ }
349
+ const source = entry.source;
350
+ const payloadPath = source && typeof source === 'object'
351
+ && typeof source.path === 'string'
352
+ ? source.path
353
+ : null;
354
+ if (!payloadPath) {
355
+ return {
356
+ status: 'broken',
357
+ version: null,
358
+ payloadPath: null,
359
+ detailPath: activeMarketplacePath,
360
+ registeredSource: activeMarketplacePath,
361
+ enabled: null,
362
+ reason: 'marketplace entry has no payload path'
363
+ };
364
+ }
365
+ if (!(await pathExists(payloadPath))) {
366
+ return {
367
+ status: 'broken',
368
+ version: null,
369
+ payloadPath,
370
+ detailPath: payloadPath,
371
+ registeredSource: activeMarketplacePath,
372
+ enabled: null,
373
+ reason: 'payload directory is missing'
374
+ };
375
+ }
376
+ const { manifest } = pluginPayload('zcode');
377
+ const payloadManifest = await readJsonFile(join(payloadPath, ...manifest.split('/')));
378
+ const version = typeof payloadManifest?.version === 'string'
379
+ ? payloadManifest.version
380
+ : null;
381
+ if (version === null) {
382
+ return {
383
+ status: 'broken',
384
+ version: null,
385
+ payloadPath,
386
+ detailPath: join(payloadPath, ...manifest.split('/')),
387
+ registeredSource: activeMarketplacePath,
388
+ enabled: null,
389
+ reason: 'payload manifest has no version'
390
+ };
391
+ }
392
+ return {
393
+ status: 'installed',
394
+ version,
395
+ payloadPath,
396
+ detailPath: join(payloadPath, ...manifest.split('/')),
397
+ registeredSource: activeMarketplacePath,
398
+ enabled: null,
399
+ reason: null
400
+ };
401
+ }
@@ -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.2
@@ -342,6 +342,11 @@ def _print_json_route(
342
342
  print(json.dumps(payload, ensure_ascii=False, sort_keys=False))
343
343
 
344
344
 
345
+ def _text_source(source: str) -> str:
346
+ """Text output shows the source category, not the internal context key."""
347
+ return source.split(":", 1)[0]
348
+
349
+
345
350
  def _print_text_payload(payload: dict[str, object]) -> None:
346
351
  action = payload["action"]
347
352
  if not isinstance(action, dict):
@@ -390,7 +395,7 @@ def _navigation_target(args, repo_root: Path, structured: bool):
390
395
  print(json.dumps(payload, ensure_ascii=False, sort_keys=False))
391
396
  else:
392
397
  print("Status: no_task")
393
- print(f"Source: {source}")
398
+ print(f"Source: {_text_source(source)}")
394
399
  payload = build_navigation_payload(
395
400
  args=args,
396
401
  status="no_task",
@@ -418,7 +423,7 @@ def _print_stale_route(args, task_path: str, source: str, active_target: bool) -
418
423
  )
419
424
  return
420
425
  print("Status: stale")
421
- print(f"Source: {source}")
426
+ print(f"Source: {_text_source(source)}")
422
427
  payload = build_navigation_payload(
423
428
  args=args,
424
429
  status="stale",
@@ -438,7 +443,7 @@ def _print_text_route(
438
443
  active_target: bool,
439
444
  ) -> None:
440
445
  print(f"Status: {status}")
441
- print(f"Source: {source}")
446
+ print(f"Source: {_text_source(source)}")
442
447
  payload = build_navigation_payload(
443
448
  args=args,
444
449
  status=status,
@@ -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")