cowork-flow 2.6.0 → 2.7.1

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
@@ -6,6 +6,18 @@
6
6
 
7
7
  ### Changed
8
8
 
9
+ ## [2.7.1] - 2026-11-05
10
+
11
+ ### Fixed
12
+
13
+ - **Qoder fixed agents 改为用户级安装**:三个 fixed agent 从插件 `agents/`(Qoder 会拼成 `cowork-flow:cowork-check`)迁到每个 edition 的用户级 `<home>/agents/`,文件名保持 `cowork-check.md` 等 plain name,避免 Windows 把插件命名空间里的 `:` 拼进子代理文件路径导致 `EINVAL`。`host add qoder` 会同步用户级 agent 并从插件缓存移除 `agents/`;已健康安装(无 `--force`)也会自动迁移。`host remove qoder` 只删除带 cowork-flow 管理标记的文件,不覆盖或删除用户自建 agent。
14
+
15
+ ## [2.7.0] - 2026-11-05
16
+
17
+ ### Added
18
+
19
+ - **Qoder CN 支持**:`cwf host add qoder` / `host remove qoder` 覆盖 `~/.qoder`(intl)与 `~/.qoder-cn`(CN)两个用户级 edition;安装/卸载时 `QODER_CONFIG_DIR` / `QODERCN_CONFIG_DIR` 显式设置只处理对应目标,目录名支持 `*_CONFIG_DIR_NAME`。`cwf host inspect qoder` 每个存在的 edition 输出一行并带 `variant`,报告 `schemaVersion` 升到 2(doctor 同时接受 1 与 2);doctor 的 Qoder 检查逐 edition 告警。运行时身份补 `QODERCN_SESSION_ID`,CN 会话的 Bash 侧任务能绑定到 `qoder` 宿主。项目级仍是单一 `qoder` 适配(CN 的项目配置目录同样叫 `.qoder`)。升级动作:`cwf host add qoder --force`。
20
+
9
21
  ## [2.6.0] - 2026-11-04
10
22
 
11
23
  ### Added
@@ -496,7 +508,9 @@
496
508
 
497
509
  此版本未保留本地条目正文,详情见 [GitHub Release](https://github.com/fishlikewater/cowork-flow/releases/tag/v0.0.47)。
498
510
 
499
- [Unreleased]: https://github.com/fishlikewater/cowork-flow/compare/v2.6.0...HEAD
511
+ [Unreleased]: https://github.com/fishlikewater/cowork-flow/compare/v2.7.1...HEAD
512
+ [2.7.1]: https://github.com/fishlikewater/cowork-flow/compare/v2.7.0...v2.7.1
513
+ [2.7.0]: https://github.com/fishlikewater/cowork-flow/compare/v2.6.0...v2.7.0
500
514
  [2.6.0]: https://github.com/fishlikewater/cowork-flow/compare/v2.5.2...v2.6.0
501
515
  [2.5.2]: https://github.com/fishlikewater/cowork-flow/compare/v2.5.1...v2.5.2
502
516
  [2.5.1]: https://github.com/fishlikewater/cowork-flow/compare/v2.5.0...v2.5.1
package/docs/hosts.en.md CHANGED
@@ -67,7 +67,7 @@ cwf host inspect qoder
67
67
  cwf host inspect --json
68
68
  ```
69
69
 
70
- One row per installable component, with status `installed`, `missing`, `stale`, `broken`, or `unsupported`. `stale` means the installed payload version differs from the running CLI version; `broken` means the host knows about cowork-flow but a required payload artifact is absent. The doctor then compares that same version with the project's `.cowork-flow/.version`: a CLI newer than the project with a payload that still matches the project's runtime stays silent, while a payload that lags a synced project is still `PLUGIN-STALE`. `kimi-code`'s `all` is only a command composition and never appears as a row. The command is read-only and never repairs, installs, or uninstalls; an unhealthy install is data, not a command failure, and only usage errors such as an unknown host exit with 2.
70
+ One row per installable component instance, with status `installed`, `missing`, `stale`, `broken`, or `unsupported`. Qoder's intl and CN editions each get a row (`variant` distinguishes them); an absent edition is omitted. `stale` means the installed payload version differs from the running CLI version; `broken` means the host knows about cowork-flow but a required payload artifact is absent. The doctor then compares that same version with the project's `.cowork-flow/.version`: a CLI newer than the project with a payload that still matches the project's runtime stays silent, while a payload that lags a synced project is still `PLUGIN-STALE`. `kimi-code`'s `all` is only a command composition and never appears as a row. The command is read-only and never repairs, installs, or uninstalls; an unhealthy install is data, not a command failure, and only usage errors such as an unknown host exit with 2.
71
71
 
72
72
  The doctor's host checks consume the same read model (`cwf host inspect --json`) and no longer parse host directories, registries, settings, or TOML themselves. When the CLI is not on `PATH`, exits non-zero, times out, or reports an unexpected `schemaVersion`, the doctor emits `HOST-INSPECT-UNAVAILABLE` with an upgrade hint instead of falsely reporting `PLUGIN-NOT-INSTALLED` — "could not read" and "read as not installed" are different facts. See `spec/contracts/host-install-inspection.md` for the full contract.
73
73
 
@@ -145,7 +145,9 @@ cwf host add qoder --force
145
145
  cwf host remove qoder
146
146
  ```
147
147
 
148
- The install location is determined by `QODER_CONFIG_DIR`, or `~/.qoder` when that variable is unset. The plugin provides hooks, the three fixed subagents, and the bootstrap Skill; the project-level `init` / `sync` commands only write the adaptation declarations and shared Skills.
148
+ Qoder has two user-level install directories: `~/.qoder` (international) and `~/.qoder-cn` (Qoder CN). The bare command covers every edition present on the machine; for install and removal, `QODER_CONFIG_DIR` / `QODERCN_CONFIG_DIR` are full-path overrides, and setting either restricts the command to that target (setting both covers both). The directory names can be overridden with `QODER_CONFIG_DIR_NAME` / `QODERCN_CONFIG_DIR_NAME`.
149
+
150
+ `cwf host inspect qoder` prints one row per present edition, labelled `Qoder` or `Qoder CN`; an explicitly configured home is reported as `missing` even when it does not exist, and never hides another present edition. The plugin provides hooks and the bootstrap Skill; the three fixed agents are installed as user-level `<home>/agents/` files (plain names, outside the plugin namespace), so Windows never puts the plugin's `:` into a subagent file name. The project-level `init` / `sync` commands only write the single `qoder` adaptation declaration and shared Skills (Qoder CN also uses `.qoder` as its project config directory).
149
151
 
150
152
  ## DeepSeek Harness
151
153
 
package/docs/hosts.md CHANGED
@@ -67,7 +67,7 @@ cwf host inspect qoder
67
67
  cwf host inspect --json
68
68
  ```
69
69
 
70
- 每个可安装组件一行,状态为 `installed`、`missing`、`stale`、`broken` 或 `unsupported`。`stale` 表示已装载荷版本与当前 CLI 版本不同;`broken` 表示宿主有注册但载荷缺件。doctor 会再拿同一版本与本项目 `.cowork-flow/.version` 比较:CLI 比项目新、但插件仍匹配项目运行时不报;项目已 sync 到新版本、插件落后时仍报 `PLUGIN-STALE`。`kimi-code` 的 `all` 只是命令组合,不会单独出现。命令只读,不修复、不安装、不卸载;安装态异常是数据,不是命令失败,只有未知宿主等用法错误才返回 2。
70
+ 每个可安装组件实例一行,状态为 `installed`、`missing`、`stale`、`broken` 或 `unsupported`。Qoder 的 intl 与 CN edition 各占一行(`variant` 区分),不存在的 edition 不出现。`stale` 表示已装载荷版本与当前 CLI 版本不同;`broken` 表示宿主有注册但载荷缺件。doctor 会再拿同一版本与本项目 `.cowork-flow/.version` 比较:CLI 比项目新、但插件仍匹配项目运行时不报;项目已 sync 到新版本、插件落后时仍报 `PLUGIN-STALE`。`kimi-code` 的 `all` 只是命令组合,不会单独出现。命令只读,不修复、不安装、不卸载;安装态异常是数据,不是命令失败,只有未知宿主等用法错误才返回 2。
71
71
 
72
72
  `run doctor` 的宿主检查消费同一份读模型(`cwf host inspect --json`),不再自己解析宿主目录、注册表、设置文件或 TOML。CLI 不在 PATH、退出码非 0、超时或 `schemaVersion` 不匹配时,doctor 报 `HOST-INSPECT-UNAVAILABLE` 并给出升级提示,而不是误报 `PLUGIN-NOT-INSTALLED`——“读不到”和“读到没装”是两件事。完整契约见 `spec/contracts/host-install-inspection.md`。
73
73
 
@@ -145,7 +145,9 @@ cwf host add qoder --force
145
145
  cwf host remove qoder
146
146
  ```
147
147
 
148
- 安装位置由 `QODER_CONFIG_DIR` 决定,未设置时为 `~/.qoder`。插件提供 hook、三个 fixed subagent 和引导技能;项目级 `init` / `sync` 只写适配声明和共享技能。
148
+ Qoder 有两个用户级安装目录:`~/.qoder`(国际版)和 `~/.qoder-cn`(Qoder CN)。裸命令覆盖机器上所有已存在的 edition;安装/卸载时 `QODER_CONFIG_DIR` / `QODERCN_CONFIG_DIR` 是完整路径覆盖,显式设置时只处理对应目标(两个都设置则两者都处理),目录名可用 `QODER_CONFIG_DIR_NAME` / `QODERCN_CONFIG_DIR_NAME` 覆盖。
149
+
150
+ `cwf host inspect qoder` 每个存在的 edition 一行,文本输出用 `Qoder` / `Qoder CN` 区分;显式配置的目录即使不存在也按 `missing` 报告,且不会掩盖另一个已存在的 edition。插件提供 hook 和引导技能;三个 fixed agent 安装为每个 edition 的用户级 `<home>/agents/`(plain name,不经插件命名空间),避免 Windows 上插件 agent 名里的 `:` 被拼进子代理文件名导致派发失败。项目级 `init` / `sync` 只写单一 `qoder` 适配声明和共享技能(Qoder CN 的项目配置目录同样叫 `.qoder`)。
149
151
 
150
152
  ## DeepSeek Harness
151
153
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cowork-flow",
3
- "version": "2.6.0",
3
+ "version": "2.7.1",
4
4
  "description": "CLI for installing and maintaining cowork-flow collaboration templates.",
5
5
  "keywords": [
6
6
  "ai-agent",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cowork-flow",
3
- "version": "2.6.0",
3
+ "version": "2.7.1",
4
4
  "description": "AI 协作工作流引擎:任务生命周期、子代理调度、门禁与状态注入。将 cowork-flow 的完整工作流带入 Claude Code。",
5
5
  "displayName": "Cowork Flow",
6
6
  "author": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cowork-flow",
3
- "version": "2.6.0",
3
+ "version": "2.7.1",
4
4
  "description": "AI 协作工作流引擎:任务生命周期、子代理调度、门禁与状态注入。将 cowork-flow 的完整工作流带入 Codex。",
5
5
  "author": {
6
6
  "name": "fishlikewater",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cowork-flow",
3
- "version": "2.6.0",
3
+ "version": "2.7.1",
4
4
  "description": "AI 协作工作流引擎:任务生命周期、子代理调度、门禁与状态注入。将 cowork-flow 的完整工作流带入 Kimi Code。",
5
5
  "author": {
6
6
  "name": "fishlikewater",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cowork-flow",
3
- "version": "2.6.0",
3
+ "version": "2.7.1",
4
4
  "description": "AI 协作工作流引擎:任务生命周期、子代理调度、门禁与状态注入。将 cowork-flow 的完整工作流带入 Qoder。",
5
5
  "displayName": "Cowork Flow",
6
6
  "author": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cowork-flow",
3
- "version": "2.6.0",
3
+ "version": "2.7.1",
4
4
  "description": "AI 协作工作流引擎:任务生命周期、子代理调度、门禁与状态注入。将 cowork-flow 的完整工作流带入 ZCode。",
5
5
  "author": {
6
6
  "name": "fishlikewater",
@@ -1,7 +1,7 @@
1
1
  import { hostRegistry } from '../lib/host-assets.js';
2
2
  import { readPackageInfo } from '../lib/package-info.js';
3
3
 
4
- export const INSPECT_SCHEMA_VERSION = 1;
4
+ export const INSPECT_SCHEMA_VERSION = 2;
5
5
 
6
6
  export const INSPECT_STATUSES = Object.freeze([
7
7
  'installed',
@@ -29,6 +29,14 @@ function normalizedRow(facts, cliVersion) {
29
29
  }
30
30
 
31
31
 
32
+ // A component may install more than one user-level edition (today only
33
+ // qoder); its reader returns one facts object per present edition. Single
34
+ // edition components keep returning one object.
35
+ function componentFacts(facts) {
36
+ return Array.isArray(facts) ? facts : [facts];
37
+ }
38
+
39
+
32
40
  function unsupportedRow(hostId, componentName) {
33
41
  return {
34
42
  status: 'unsupported',
@@ -59,12 +67,15 @@ export async function inspectHosts(components, hostIds, { env = process.env } =
59
67
  const facts = typeof component.inspect === 'function'
60
68
  ? await component.inspect({ env })
61
69
  : unsupportedRow(hostId, componentName);
62
- hosts.push({
63
- id: hostId,
64
- displayName: platform.displayName,
65
- component: componentName,
66
- ...normalizedRow(facts, cliVersion)
67
- });
70
+ for (const instance of componentFacts(facts)) {
71
+ hosts.push({
72
+ id: hostId,
73
+ displayName: platform.displayName,
74
+ component: componentName,
75
+ ...normalizedRow(instance, cliVersion),
76
+ ...(instance.variant ? { variant: instance.variant } : {})
77
+ });
78
+ }
68
79
  }
69
80
  }
70
81
  return {
@@ -82,5 +93,6 @@ export function renderInspectLine(row) {
82
93
  row.enabled === false ? 'not enabled' : null,
83
94
  row.reason
84
95
  ].filter(Boolean).join('; ');
85
- return `${row.id} (${row.displayName}, ${row.component}): ${row.status}${detail ? ` - ${detail}` : ''}\n`;
96
+ const name = row.variant === 'cn' ? `${row.displayName} CN` : row.displayName;
97
+ return `${row.id} (${name}, ${row.component}): ${row.status}${detail ? ` - ${detail}` : ''}\n`;
86
98
  }
@@ -1,6 +1,6 @@
1
- import { cp, mkdir, readFile, rm } from 'node:fs/promises';
1
+ import { cp, mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
2
2
  import { homedir } from 'node:os';
3
- import { join } from 'node:path';
3
+ import { dirname, join, resolve } from 'node:path';
4
4
 
5
5
  import { parseInstallArgs, pathExists, readJsonFile, writeJsonAtomic } from '../lib/install-support.js';
6
6
  import { readPackageInfo } from '../lib/package-info.js';
@@ -10,15 +10,104 @@ const QODER_MARKETPLACE = 'cowork-flow-local';
10
10
  const PLUGIN_NAME = 'cowork-flow';
11
11
  const PLUGIN_KEY = `${PLUGIN_NAME}@${QODER_MARKETPLACE}`;
12
12
  const REGISTRY_FILE = 'installed_plugins_v2.json';
13
+ const QODER_USER_AGENT_NAMES = ['cowork-check', 'cowork-implement', 'cowork-research'];
14
+ const QODER_USER_AGENT_MARKER = '<!-- cowork-flow-managed: qoder user agent -->';
13
15
 
14
16
  // Rendered by `host add`/`host remove`; the installer's
15
17
  // own vocabulary.
16
18
  export const FLAGS = ['--dry-run', '--force', '--uninstall'];
17
19
 
18
20
 
19
- function qoderHome(env = process.env) {
20
- const configured = (env.QODER_CONFIG_DIR || '').trim();
21
- return configured || join(homedir(), '.qoder');
21
+ // Qoder and Qoder CN share one plugin model and differ only in
22
+ // their user-level config home. The CN build keeps the project
23
+ // config directory at `.qoder`, so the project-level adapter stays
24
+ // single; only machine-level installs fan out.
25
+ const QODER_EDITIONS = [
26
+ {
27
+ variant: 'intl',
28
+ configEnv: 'QODER_CONFIG_DIR',
29
+ nameEnv: 'QODER_CONFIG_DIR_NAME',
30
+ defaultName: '.qoder'
31
+ },
32
+ {
33
+ variant: 'cn',
34
+ configEnv: 'QODERCN_CONFIG_DIR',
35
+ nameEnv: 'QODERCN_CONFIG_DIR_NAME',
36
+ defaultName: '.qoder-cn'
37
+ }
38
+ ];
39
+
40
+
41
+ function editionLabel(variant) {
42
+ return variant === 'cn' ? 'Qoder CN' : 'Qoder';
43
+ }
44
+
45
+
46
+ function qoderHomeForEdition(edition, env) {
47
+ const configured = (env[edition.configEnv] || '').trim();
48
+ if (configured) return configured;
49
+ // The host lets the directory name be renamed; `*_CONFIG_DIR` is
50
+ // the full-path override, `*_CONFIG_DIR_NAME` only the basename.
51
+ const name = (env[edition.nameEnv] || '').trim() || edition.defaultName;
52
+ return join(homedir(), name);
53
+ }
54
+
55
+
56
+ async function editionIsPresent(home) {
57
+ return (
58
+ (await pathExists(join(home, 'settings.json')))
59
+ || (await pathExists(join(home, 'plugins')))
60
+ );
61
+ }
62
+
63
+
64
+ // Install targets: an explicit config env is a single-target
65
+ // instruction and suppresses discovery; otherwise every edition with
66
+ // product state on disk is covered; a machine with no Qoder state yet
67
+ // keeps the historical `.qoder` default.
68
+ async function qoderHomes(env = process.env) {
69
+ return await resolveQoderHomes(env, { includePresentWithExplicit: false });
70
+ }
71
+
72
+
73
+ // Inspect reports every edition that exists on the machine, plus an
74
+ // explicitly named home even when it does not exist yet. An install
75
+ // override must not hide another present edition from the doctor.
76
+ async function qoderInspectHomes(env = process.env) {
77
+ return await resolveQoderHomes(env, { includePresentWithExplicit: true });
78
+ }
79
+
80
+
81
+ async function resolveQoderHomes(env, { includePresentWithExplicit }) {
82
+ const editions = QODER_EDITIONS.map((edition) => ({
83
+ edition,
84
+ home: qoderHomeForEdition(edition, env),
85
+ explicit: Boolean((env[edition.configEnv] || '').trim())
86
+ }));
87
+ const discovered = await Promise.all(
88
+ editions.map(async (item) => ({
89
+ ...item,
90
+ present: await editionIsPresent(item.home)
91
+ }))
92
+ );
93
+ let selected;
94
+ if (includePresentWithExplicit) {
95
+ selected = discovered.filter((item) => item.explicit || item.present);
96
+ } else {
97
+ const explicit = discovered.filter((item) => item.explicit);
98
+ selected = explicit.length > 0
99
+ ? explicit
100
+ : discovered.filter((item) => item.present);
101
+ }
102
+ const seen = new Set();
103
+ const homes = [];
104
+ for (const item of selected.length > 0 ? selected : [discovered[0]]) {
105
+ const key = resolve(item.home);
106
+ if (seen.has(key)) continue;
107
+ seen.add(key);
108
+ homes.push({ variant: item.edition.variant, home: item.home });
109
+ }
110
+ return homes;
22
111
  }
23
112
 
24
113
  function pluginPaths(home, version) {
@@ -123,12 +212,123 @@ async function enablePlugin(settings, paths, dryRun) {
123
212
  await writeJsonAtomic(paths.settings, settings);
124
213
  }
125
214
 
126
- async function uninstall(paths, dryRun) {
215
+ function failureSummary(failures) {
216
+ return failures
217
+ .map(({ variant, home, error }) => `${editionLabel(variant)} (${home}): ${error.message}`)
218
+ .join('; ');
219
+ }
220
+
221
+
222
+ // Qoder namespaces plugin agents as `plugin:agent` and writes that name into
223
+ // subagent transcript paths; Windows rejects the colon with EINVAL. The fixed
224
+ // agents therefore live in the host's user-level `agents/` directory, whose
225
+ // loader keeps the plain file name. The marker lets uninstall distinguish our
226
+ // files from a user's own agent with the same name.
227
+ function qoderUserAgentTargets(home) {
228
+ return QODER_USER_AGENT_NAMES.map((name) => ({
229
+ name,
230
+ target: join(home, 'agents', `${name}.md`)
231
+ }));
232
+ }
233
+
234
+
235
+ function managedAgentContent(source) {
236
+ const body = source.endsWith('\n') ? source : `${source}\n`;
237
+ return `${body}\n${QODER_USER_AGENT_MARKER}\n`;
238
+ }
239
+
240
+
241
+ function agentIsManaged(content) {
242
+ return content.includes(QODER_USER_AGENT_MARKER);
243
+ }
244
+
245
+
246
+ async function readOptionalFile(path) {
247
+ try {
248
+ return await readFile(path, 'utf8');
249
+ } catch (error) {
250
+ if (error?.code === 'ENOENT') return null;
251
+ throw error;
252
+ }
253
+ }
254
+
255
+
256
+ async function syncQoderUserAgents(home, { sourceDir, dryRun }) {
257
+ // Validate every target before writing any of them: a user's unmanaged
258
+ // `cowork-check.md` must stop the whole home, not leave a partial set.
259
+ const pending = [];
260
+ for (const { name, target } of qoderUserAgentTargets(home)) {
261
+ const source = join(sourceDir, `${name}.md`);
262
+ let body;
263
+ try {
264
+ body = await readFile(source, 'utf8');
265
+ } catch (error) {
266
+ throw new Error(`Qoder user agent source missing or unreadable at ${source}: ${error.message}`);
267
+ }
268
+ const expected = managedAgentContent(body);
269
+ const existing = await readOptionalFile(target);
270
+ if (existing !== null && !agentIsManaged(existing)) {
271
+ throw new Error(
272
+ `Qoder user agent at ${target} is not managed by cowork-flow; file was left unchanged`
273
+ );
274
+ }
275
+ if (existing === expected) continue;
276
+ pending.push({ target, expected });
277
+ }
278
+
279
+ for (const { target, expected } of pending) {
280
+ if (dryRun) {
281
+ console.log(`[dry-run] Would install Qoder user agent: ${target}`);
282
+ continue;
283
+ }
284
+ await mkdir(dirname(target), { recursive: true });
285
+ const temporary = `${target}.tmp`;
286
+ await writeFile(temporary, expected, 'utf8');
287
+ try {
288
+ await rename(temporary, target);
289
+ } catch (error) {
290
+ await rm(temporary, { force: true });
291
+ throw error;
292
+ }
293
+ console.log(` User agent: ${target}`);
294
+ }
295
+ }
296
+
297
+
298
+ async function removeQoderUserAgents(home, { dryRun }) {
299
+ for (const { target } of qoderUserAgentTargets(home)) {
300
+ const current = await readOptionalFile(target);
301
+ if (current === null || !agentIsManaged(current)) continue;
302
+ if (dryRun) {
303
+ console.log(`[dry-run] Would remove Qoder user agent: ${target}`);
304
+ continue;
305
+ }
306
+ await rm(target, { force: true });
307
+ console.log(` Removed user agent: ${target}`);
308
+ }
309
+ }
310
+
311
+
312
+ async function stripBundledQoderAgents(installPath, { dryRun }) {
313
+ const bundled = join(installPath, 'agents');
314
+ if (!(await pathExists(bundled))) return;
315
+ if (dryRun) {
316
+ console.log(`[dry-run] Would remove bundled plugin agents: ${bundled}`);
317
+ return;
318
+ }
319
+ await rm(bundled, { recursive: true, force: true });
320
+ console.log(` Removed bundled plugin agents: ${bundled}`);
321
+ }
322
+
323
+
324
+ async function uninstallQoderHome(paths, { variant, home, dryRun }) {
325
+ const label = editionLabel(variant);
127
326
  const { registry, settings } = await loadConfigs(paths);
128
327
  const owned = registry.plugins[PLUGIN_KEY];
129
328
  if (dryRun) {
130
329
  console.log(`[dry-run] Would remove ${PLUGIN_KEY} from ${paths.registry}`);
131
330
  console.log(`[dry-run] Would remove ${paths.cacheRoot}`);
331
+ await removeQoderUserAgents(home, { dryRun: true });
132
332
  return 0;
133
333
  }
134
334
  if (owned) {
@@ -140,32 +340,37 @@ async function uninstall(paths, dryRun) {
140
340
  await writeJsonAtomic(paths.settings, settings);
141
341
  }
142
342
  await rm(paths.cacheRoot, { recursive: true, force: true });
343
+ await removeQoderUserAgents(home, { dryRun: false });
143
344
  console.log(
144
345
  owned
145
- ? `✓ cowork-flow Qoder plugin uninstalled (${PLUGIN_KEY})`
146
- : `cowork-flow Qoder plugin was not registered; removed any cached copy at ${paths.cacheRoot}`
346
+ ? `✓ cowork-flow ${label} plugin uninstalled (${PLUGIN_KEY})`
347
+ : `cowork-flow ${label} plugin was not registered; removed any cached copy at ${paths.cacheRoot}`
147
348
  );
148
349
  return 0;
149
350
  }
150
351
 
151
- export async function runInstallQoderPlugin(args = []) {
152
- const { dryRun, force, uninstall: remove } = parseInstallArgs(args);
153
- const home = qoderHome();
154
- const { version } = await readPackageInfo();
155
- const target = pluginPaths(home, version);
156
352
 
157
- if (remove) {
158
- return uninstall(target, dryRun);
353
+ async function uninstallQoderEditions(homes, dryRun) {
354
+ const failures = [];
355
+ for (const { variant, home } of homes) {
356
+ try {
357
+ await uninstallQoderHome(pluginPaths(home, null), { variant, home, dryRun });
358
+ } catch (error) {
359
+ failures.push({ variant, home, error });
360
+ }
159
361
  }
160
-
161
- const { sourceDir: pluginSrc, manifest } = pluginPayload('qoder');
162
- if (!(await pathExists(pluginSrc))) {
163
- throw new Error(`Qoder plugin source missing at ${pluginSrc}. Reinstall cowork-flow.`);
362
+ if (failures.length > 0) {
363
+ throw new Error(
364
+ `Qoder plugin uninstall failed for ${failures.length} edition(s): ${failureSummary(failures)}`
365
+ );
164
366
  }
367
+ return 0;
368
+ }
165
369
 
370
+ async function installQoderHome(target, { version, pluginSrc, manifest, force, variant, home, dryRun }) {
371
+ const label = editionLabel(variant);
166
372
  const configs = await loadConfigs(target);
167
- console.log(`${dryRun ? '[dry-run] Would install' : 'Installing'} cowork-flow Qoder plugin:`);
168
- console.log(` Plugin: ${pluginSrc} -> ${target.installPath}`);
373
+ console.log(` ${label}: ${pluginSrc} -> ${target.installPath}`);
169
374
 
170
375
  const registeredEntries = configs.registry.plugins[PLUGIN_KEY];
171
376
  const pluginRegistered = Array.isArray(registeredEntries) && registeredEntries.length > 0;
@@ -177,38 +382,102 @@ export async function runInstallQoderPlugin(args = []) {
177
382
  pluginRegistered &&
178
383
  pluginEnabled
179
384
  ) {
180
- console.log(`cowork-flow Qoder plugin already installed at ${target.installPath}`);
385
+ // Migration path for a payload installed before agents moved to the user
386
+ // level: repair the agent files without recopying the healthy plugin.
387
+ // Sync first: it validates every target before writing, so an unmanaged
388
+ // file leaves the existing plugin payload intact instead of a home whose
389
+ // bundled agents were already stripped.
390
+ await syncQoderUserAgents(home, { sourceDir: join(pluginSrc, 'agents'), dryRun: false });
391
+ await stripBundledQoderAgents(target.installPath, { dryRun: false });
392
+ console.log(`cowork-flow ${label} plugin already installed at ${target.installPath}`);
181
393
  console.log('Use --force to overwrite.');
182
- return 0;
394
+ return;
183
395
  }
184
396
 
185
397
  const now = new Date().toISOString();
186
398
  if (dryRun) {
399
+ await syncQoderUserAgents(home, { sourceDir: join(pluginSrc, 'agents'), dryRun: true });
400
+ await stripBundledQoderAgents(target.installPath, { dryRun: true });
187
401
  await updateRegistry(configs.registry, target, version, now, true);
188
402
  await enablePlugin(configs.settings, target, true);
189
- return 0;
403
+ return;
190
404
  }
191
405
 
192
406
  await mkdir(target.cacheRoot, { recursive: true });
193
407
  await rm(target.installPath, { recursive: true, force: true });
194
408
  await cp(pluginSrc, target.installPath, { recursive: true });
195
409
  await stampPayloadManifest(target.installPath, manifest, version);
410
+ // The payload source still owns the canonical agent Markdown, but Qoder
411
+ // must not discover it as a plugin agent on Windows. Sync first so a
412
+ // conflicting user file cannot leave the payload half-migrated.
413
+ await syncQoderUserAgents(home, { sourceDir: join(pluginSrc, 'agents'), dryRun: false });
414
+ await stripBundledQoderAgents(target.installPath, { dryRun: false });
196
415
  // Registry and enable flag come last: a half-copied
197
416
  // payload must never be advertised as installed.
198
417
  await updateRegistry(configs.registry, target, version, now, false);
199
418
  await enablePlugin(configs.settings, target, false);
200
419
 
201
- console.log(`✓ cowork-flow Qoder plugin installed to ${target.installPath}`);
202
- console.log(' Restart Qoder to load the plugin (the IDE has no hook hot reload).');
420
+ console.log(`✓ cowork-flow ${label} plugin installed to ${target.installPath}`);
421
+ }
422
+
423
+
424
+ export async function runInstallQoderPlugin(args = []) {
425
+ const { dryRun, force, uninstall: remove } = parseInstallArgs(args);
426
+ const homes = await qoderHomes();
427
+ if (remove) {
428
+ return await uninstallQoderEditions(homes, dryRun);
429
+ }
430
+
431
+ const { version } = await readPackageInfo();
432
+ const { sourceDir: pluginSrc, manifest } = pluginPayload('qoder');
433
+ if (!(await pathExists(pluginSrc))) {
434
+ throw new Error(`Qoder plugin source missing at ${pluginSrc}. Reinstall cowork-flow.`);
435
+ }
436
+
437
+ console.log(`${dryRun ? '[dry-run] Would install' : 'Installing'} cowork-flow Qoder plugin:`);
438
+ const failures = [];
439
+ for (const { variant, home } of homes) {
440
+ try {
441
+ await installQoderHome(pluginPaths(home, version), {
442
+ version,
443
+ pluginSrc,
444
+ manifest,
445
+ force,
446
+ variant,
447
+ home,
448
+ dryRun
449
+ });
450
+ } catch (error) {
451
+ failures.push({ variant, home, error });
452
+ }
453
+ }
454
+ if (failures.length > 0) {
455
+ throw new Error(
456
+ `Qoder plugin install failed for ${failures.length} edition(s): ${failureSummary(failures)}`
457
+ );
458
+ }
459
+ if (!dryRun) {
460
+ console.log(' Restart Qoder to load the plugin (the IDE has no hook hot reload).');
461
+ }
203
462
  return 0;
204
463
  }
205
464
 
206
465
 
207
466
  // Read-only installed-state facts for `host inspect`. The registry and the
208
467
  // settings flag are the host's records; the payload files are what a session
209
- // actually loads.
468
+ // actually loads. One facts object per present edition.
210
469
  export async function inspectInstalledState({ env = process.env } = {}) {
211
- const home = qoderHome(env);
470
+ const homes = await qoderInspectHomes(env);
471
+ return await Promise.all(
472
+ homes.map(async ({ variant, home }) => ({
473
+ ...(await inspectQoderHome(home)),
474
+ variant
475
+ }))
476
+ );
477
+ }
478
+
479
+
480
+ async function inspectQoderHome(home) {
212
481
  const paths = pluginPaths(home, null);
213
482
  const registry = await readJsonFile(paths.registry);
214
483
  const entries = registry?.plugins?.[PLUGIN_KEY];
@@ -1 +1 @@
1
- 2.6.0
1
+ 2.7.1
@@ -139,22 +139,24 @@ HOST_IDENTITIES: tuple[HostIdentity, ...] = (
139
139
  input_keys=(),
140
140
  process_label_env=None,
141
141
  ),
142
- # Qoder documents QODER_SESSION_ID as a session env var and
143
- # puts the generic `session_id` in every hook payload; that
144
- # key is shared with codex/claude-code/kimi-code, so only
145
- # the declared host may resolve it. Payload `cwd` is the
146
- # project-root evidence that matters here: Qoder host
147
- # assets live in a machine-level plugin, not the project.
142
+ # Qoder and Qoder CN are one host with two user-level editions:
143
+ # both export their session id, but the CN CLI prefixes the
144
+ # environment namespace (`QODERCN_SESSION_ID`) while the hook
145
+ # payload keys stay the same. Payload `cwd` is the project-root
146
+ # evidence that matters here: host assets live in a machine-level
147
+ # plugin, not the project.
148
148
  HostIdentity(
149
149
  id="qoder",
150
150
  prefix="qoder",
151
151
  adapter="qoder.hooks",
152
152
  policy_module="adapters.host.qoder_policy",
153
153
  injects_context=True,
154
- session_env=("QODER_SESSION_ID",),
154
+ session_env=("QODER_SESSION_ID", "QODERCN_SESSION_ID"),
155
155
  input_keys=(
156
156
  "QODER_SESSION_ID",
157
157
  "qoder_session_id",
158
+ "QODERCN_SESSION_ID",
159
+ "qodercn_session_id",
158
160
  "session_id",
159
161
  ),
160
162
  process_label_env=None,
@@ -27,27 +27,46 @@ cwf host inspect [host] [--json]
27
27
 
28
28
  ```json
29
29
  {
30
- "schemaVersion": 1,
31
- "cliVersion": "2.4.2",
30
+ "schemaVersion": 2,
31
+ "cliVersion": "2.7.0",
32
32
  "hosts": [
33
33
  {
34
34
  "id": "qoder",
35
35
  "displayName": "Qoder",
36
36
  "component": "plugin",
37
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",
38
+ "version": "2.7.0",
39
+ "payloadPath": "/home/user/.qoder/plugins/cache/cowork-flow-local/cowork-flow/2.7.0",
40
+ "detailPath": "/home/user/.qoder/plugins/cache/cowork-flow-local/cowork-flow/2.7.0/.qoder-plugin/plugin.json",
41
41
  "registeredSource": "/home/user/.qoder/plugins/installed_plugins_v2.json",
42
42
  "enabled": true,
43
- "reason": null
43
+ "reason": null,
44
+ "variant": "intl"
45
+ },
46
+ {
47
+ "id": "qoder",
48
+ "displayName": "Qoder",
49
+ "component": "plugin",
50
+ "status": "installed",
51
+ "version": "2.7.0",
52
+ "payloadPath": "/home/user/.qoder-cn/plugins/cache/cowork-flow-local/cowork-flow/2.7.0",
53
+ "detailPath": "/home/user/.qoder-cn/plugins/cache/cowork-flow-local/cowork-flow/2.7.0/.qoder-plugin/plugin.json",
54
+ "registeredSource": "/home/user/.qoder-cn/plugins/installed_plugins_v2.json",
55
+ "enabled": true,
56
+ "reason": null,
57
+ "variant": "cn"
44
58
  }
45
59
  ]
46
60
  }
47
61
  ```
48
62
 
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.
63
+ There is one row per installable component instance. A host with several
64
+ user-level editions reports one row per present edition: `qoder` has `intl`
65
+ (`~/.qoder`) and `cn` (`~/.qoder-cn`), distinguished by `variant`. Row identity
66
+ is `(id, component, variant)`; an edition that is absent on the machine is
67
+ omitted unless its config directory was explicitly named. `kimi-code`'s `all`
68
+ component is a command composition, not an installed artifact, so it has no
69
+ row.
51
70
 
52
71
  | Field | Meaning |
53
72
  |---|---|
@@ -61,10 +80,13 @@ command composition, not an installed artifact, so it has no row.
61
80
  | `registeredSource` | Registry, config file or marketplace path the host reads, or `null`. |
62
81
  | `enabled` | `true`/`false` when the host has an enable flag; `null` when it has none or the state is unknown. |
63
82
  | `reason` | Human-readable explanation, or `null` when there is nothing to explain. |
83
+ | `variant` | Optional edition discriminator for hosts with several user-level installs. Today only `qoder` sets it: `intl` or `cn`. Absent for single-edition hosts. |
64
84
 
65
85
  Unknown fields are ignored by consumers. A breaking change to the shape, the
66
86
  statuses or the meaning of a field bumps `schemaVersion`; the doctor then
67
- reports `HOST-INSPECT-UNAVAILABLE` instead of guessing.
87
+ reports `HOST-INSPECT-UNAVAILABLE` instead of guessing. `schemaVersion` 2 adds
88
+ the multi-instance row shape (`variant`); version 1 was one row per component.
89
+ The doctor understands both; any other version is unavailable.
68
90
 
69
91
  ## Statuses
70
92
 
@@ -122,7 +144,7 @@ cwf host inspect --json
122
144
  - The command runs with stdin closed and its output parsed as UTF-8.
123
145
 
124
146
  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
147
+ `schemaVersion` other than 1 or 2, omits the `hosts` list, or omits the row the
126
148
  caller needs, the doctor emits one `HOST-INSPECT-UNAVAILABLE` warning for that
127
149
  host check. It must not translate an unavailable inspection into
128
150
  `PLUGIN-NOT-INSTALLED`: "could not read" and "read as missing" are different
@@ -145,6 +167,10 @@ host layout. Content-drift warnings (OpenCode) name the file they compared, and
145
167
  the skill-delivery check names `payloadPath/skills`; both point at the artifact
146
168
  that actually differs rather than the install record.
147
169
 
170
+ When a component reports several edition rows, the doctor evaluates each row
171
+ independently and emits one issue per affected edition; a healthy edition never
172
+ masks a missing, broken, disabled or stale one.
173
+
148
174
  The `stale` row above is the inspect status. The doctor's code depends on the
149
175
  project-relative comparison described under statuses: an `installed` row whose
150
176
  payload version also differs from the project's `.version` produces
@@ -169,6 +195,8 @@ command yet.
169
195
  ## Compatibility
170
196
 
171
197
  - Adding a host platform or component is additive.
198
+ - Adding a row for another edition of an existing component is additive; row
199
+ identity is `(id, component, variant)`.
172
200
  - Renaming or removing a field or status is breaking (`schemaVersion` bump).
173
201
  - `unsupported` stays a valid status so a future component can be declared
174
202
  before its reader exists.
@@ -1110,21 +1110,21 @@ def _run_host_inspect() -> dict[str, object]:
1110
1110
  payload = json.loads(completed.stdout)
1111
1111
  except (json.JSONDecodeError, ValueError):
1112
1112
  return _host_inspect_unavailable("host inspect returned invalid JSON")
1113
- if not isinstance(payload, dict) or payload.get("schemaVersion") != 1:
1113
+ if not isinstance(payload, dict) or payload.get("schemaVersion") not in (1, 2):
1114
1114
  return _host_inspect_unavailable(
1115
- "host inspect does not support schemaVersion 1; upgrade cowork-flow"
1115
+ "host inspect does not support schemaVersion 1 or 2; upgrade cowork-flow"
1116
1116
  )
1117
1117
  rows = payload.get("hosts")
1118
1118
  if not isinstance(rows, list):
1119
1119
  return _host_inspect_unavailable("host inspect returned no hosts list")
1120
1120
  hosts: dict[str, dict[str, object]] = {}
1121
- components: dict[str, dict[str, object]] = {}
1121
+ components: dict[str, list[dict[str, object]]] = {}
1122
1122
  for row in rows:
1123
1123
  if not isinstance(row, dict) or not isinstance(row.get("id"), str):
1124
1124
  continue
1125
1125
  host_id = row["id"]
1126
1126
  component = str(row.get("component") or "")
1127
- components[f"{host_id}:{component}"] = row
1127
+ components.setdefault(f"{host_id}:{component}", []).append(row)
1128
1128
  hosts.setdefault(host_id, row)
1129
1129
  return {
1130
1130
  "available": True,
@@ -1134,11 +1134,19 @@ def _run_host_inspect() -> dict[str, object]:
1134
1134
  }
1135
1135
 
1136
1136
 
1137
+ def _inspect_rows(
1138
+ facts: dict[str, object], host_id: str, component: str
1139
+ ) -> list[dict[str, object]]:
1140
+ """Every row for one component; a multi-edition host reports several."""
1141
+ rows = facts.get("components", {}).get(f"{host_id}:{component}", [])
1142
+ return [row for row in rows if isinstance(row, dict)]
1143
+
1144
+
1137
1145
  def _inspect_row(
1138
1146
  facts: dict[str, object], host_id: str, component: str
1139
1147
  ) -> dict[str, object] | None:
1140
- row = facts.get("components", {}).get(f"{host_id}:{component}")
1141
- return row if isinstance(row, dict) else None
1148
+ rows = _inspect_rows(facts, host_id, component)
1149
+ return rows[0] if rows else None
1142
1150
 
1143
1151
 
1144
1152
  def _host_inspect_facts(repo_root: Path) -> dict[str, object]:
@@ -1151,19 +1159,29 @@ def _host_inspect_facts(repo_root: Path) -> dict[str, object]:
1151
1159
  return cached
1152
1160
 
1153
1161
 
1154
- def _inspect_component_row(
1162
+ def _inspect_component_rows(
1155
1163
  repo_root: Path, host_id: str, component: str, label: str
1156
- ) -> tuple[dict[str, object] | None, list[dict[str, str]] | None]:
1157
- """The inspect row for one component, or the shared unavailable warning."""
1164
+ ) -> tuple[list[dict[str, object]] | None, list[dict[str, str]] | None]:
1165
+ """The inspect rows for one component, or the shared unavailable warning."""
1158
1166
  facts = _host_inspect_facts(repo_root)
1159
1167
  if not facts["available"]:
1160
1168
  return None, _host_inspect_unavailable_issue(host_id, facts)
1161
- row = _inspect_row(facts, host_id, component)
1162
- if row is None:
1169
+ rows = _inspect_rows(facts, host_id, component)
1170
+ if not rows:
1163
1171
  return None, _host_inspect_unavailable_issue(
1164
1172
  host_id, {"reason": f"host inspect omitted {label}"}
1165
1173
  )
1166
- return row, None
1174
+ return rows, None
1175
+
1176
+
1177
+ def _inspect_component_row(
1178
+ repo_root: Path, host_id: str, component: str, label: str
1179
+ ) -> tuple[dict[str, object] | None, list[dict[str, str]] | None]:
1180
+ """The first inspect row for one component (single-edition callers)."""
1181
+ rows, unavailable = _inspect_component_rows(repo_root, host_id, component, label)
1182
+ if unavailable is not None:
1183
+ return None, unavailable
1184
+ return rows[0], None
1167
1185
 
1168
1186
 
1169
1187
  def _unexpected_inspect_status(
@@ -1223,17 +1241,28 @@ def check_qoder_plugin(repo_root: Path) -> list[dict[str, str]]:
1223
1241
  """Qoder plugin health from the CLI-owned install-state read model.
1224
1242
 
1225
1243
  Advisory, and silent while the project never selected the Qoder host: the
1226
- plugin is a machine-level asset installed once into `~/.qoder/plugins`, so
1227
- it never updates through sync or npm."""
1244
+ plugin is a machine-level asset installed once into the Qoder user config
1245
+ directory (`~/.qoder` or `~/.qoder-cn`), so it never updates through sync
1246
+ or npm. Each present edition is checked independently."""
1228
1247
  adapter = repo_root / DIR_WORKFLOW / "adapters" / "qoder" / "adapter.yaml"
1229
1248
  if not adapter.is_file():
1230
1249
  return []
1231
1250
 
1232
- row, unavailable = _inspect_component_row(
1251
+ rows, unavailable = _inspect_component_rows(
1233
1252
  repo_root, "qoder", "plugin", "qoder"
1234
1253
  )
1235
1254
  if unavailable is not None:
1236
1255
  return unavailable
1256
+ issues: list[dict[str, str]] = []
1257
+ for row in rows:
1258
+ issues.extend(_qoder_row_issues(row, repo_root))
1259
+ return issues
1260
+
1261
+
1262
+ def _qoder_row_issues(
1263
+ row: dict[str, object], repo_root: Path
1264
+ ) -> list[dict[str, str]]:
1265
+ label = "Qoder CN" if row.get("variant") == "cn" else "Qoder"
1237
1266
  status = row.get("status")
1238
1267
  payload = Path(str(row.get("payloadPath") or row.get("registeredSource") or "qoder"))
1239
1268
  path = _inspect_path(row, "qoder")
@@ -1243,9 +1272,9 @@ def check_qoder_plugin(repo_root: Path) -> list[dict[str, str]]:
1243
1272
  return _qoder_warning(
1244
1273
  "PLUGIN-NOT-INSTALLED",
1245
1274
  path,
1246
- "this project declares the Qoder host, but cowork-flow is not "
1247
- "registered in the Qoder plugin cache, so Qoder sessions inject no "
1248
- "workflow context; loading also needs a Qoder restart and a "
1275
+ f"this project declares the Qoder host, but cowork-flow is not "
1276
+ f"registered in the {label} plugin cache, so {label} sessions inject "
1277
+ "no workflow context; loading also needs a Qoder restart and a "
1249
1278
  "trusted workspace",
1250
1279
  "cwf host add qoder",
1251
1280
  )
@@ -1258,7 +1287,7 @@ def check_qoder_plugin(repo_root: Path) -> list[dict[str, str]]:
1258
1287
  return _qoder_warning(
1259
1288
  code,
1260
1289
  path,
1261
- f"the Qoder plugin at {payload} is incomplete ({reason}); the host "
1290
+ f"the {label} plugin at {payload} is incomplete ({reason}); the host "
1262
1291
  "cannot load it",
1263
1292
  "cwf host add qoder --force",
1264
1293
  )
@@ -1267,7 +1296,7 @@ def check_qoder_plugin(repo_root: Path) -> list[dict[str, str]]:
1267
1296
  return _qoder_warning(
1268
1297
  "PLUGIN-DISABLED",
1269
1298
  path,
1270
- 'the Qoder plugin is installed but not enabled '
1299
+ f'the {label} plugin is installed but not enabled '
1271
1300
  f'(`enabledPlugins["{QODER_PLUGIN_KEY}"]`); no hook fires',
1272
1301
  "cwf host add qoder --force",
1273
1302
  )
@@ -1278,7 +1307,7 @@ def check_qoder_plugin(repo_root: Path) -> list[dict[str, str]]:
1278
1307
  "PLUGIN-STALE",
1279
1308
  path,
1280
1309
  _project_stale_message(
1281
- "the Qoder plugin",
1310
+ f"the {label} plugin",
1282
1311
  recorded,
1283
1312
  project_version,
1284
1313
  "the plugin does not update with sync or npm, so injection "