@suifei/dsh-ai-team 0.4.57 → 0.4.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.59 - 2026-11-12
4
+
5
+ **默认工作目录改成 `~/works` 子目录(不再用主目录根)**
6
+
7
+ 0.4.57 把建议值修成主目录 `C:\Users\SuiFei`——用户裁定这也不行:**不能把主目录根当工作目录,必须是它下面的子目录**(`~/works`)。跨平台由调用方的 `homedir()` 决定(Windows 是 `USERPROFILE`,Linux/macOS 是 `~`),本模块只做 `join`,不自己判断平台。
8
+
9
+ - 候选顺序:配置项 → 显式 cwd(须存在且不在 `~/.dsh`、非系统目录)→ **`join(homedir(), 'works')`**。
10
+ - `~/works` 可能尚不存在,而 `project.workspace.update` 只接受已存在的目录:boot 解析出建议值后**创建它**(失败则不给建议,不阻断启动)。
11
+ - 真机实测:`cwd=…\.dsh\profiles\desktop` → 建议 `C:\Users\SuiFei\works`,不等于主目录;创建成功。
12
+ - 测试:`node --test` **258 通过 / 1 跳过**(`default-workspace` 6 例,新增「永远是 home 的子目录、绝非 home 根」与「home 落在 ~/.dsh 内时不给建议」)。
13
+
14
+ ## 0.4.58 - 2026-11-12
15
+
16
+ **让「归档修复跑没跑」可判定:`host.repair.ok` 进 errors 白名单**
17
+
18
+ 真机 0.4.57 启动后,诊断日志(发布默认 `errors` 级)里**只有**一行 `host.repair.deferred.fail`(boot 瞬间 `workspaceRegistry` 未就绪)。修复后来到底成功没有,`errors` 级看不到——成功行被级别过滤掉了,等于这个关键修复永远处于「不知是否生效」的状态。
19
+
20
+ - 新增成功行 `host.repair.ok`(带 `archived` 数量与前 5 个 sessionId),并在 `isErrorEvent` 白名单里登记,**发布默认级别即落盘**。
21
+ - 端到端验证(`.ptc/rounds/dryrun-real-ledger.mjs`,仓库源码 + 模拟 registry 就绪 + `diagLevel: errors`):日志里只有 `host.repair.ok` 与 `skillopt.skip.fail` 两行,`deferred.fail` 消失。
22
+ - 测试:`node --test` **257 通过 / 1 跳过**(新增 1 例:`isErrorEvent('host.repair.ok')` 为真)。
23
+
3
24
  ## 0.4.57 - 2026-11-12
4
25
 
5
26
  **修 0.4.56 真机暴露的默认目录建议错误:整个 `~/.dsh` 都排除**
package/index.js CHANGED
@@ -11,7 +11,7 @@
11
11
  import { homedir } from 'node:os';
12
12
  import { join, sep } from 'node:path';
13
13
  import { fileURLToPath } from 'node:url';
14
- import { existsSync, readFileSync, renameSync, statSync, writeFileSync } from 'node:fs';
14
+ import { existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from 'node:fs';
15
15
  import z from '@deepseek-ai/schemastery';
16
16
  import { ProjectRuntime } from './lib/host/project-runtime.js';
17
17
  import { ProjectRegistry } from './lib/host/project-registry.js';
@@ -185,7 +185,7 @@ async function boot(diag, config = {}) {
185
185
  migrateLegacyNamespace({ fromDir: legacyDir, toDir: dataDir, diag });
186
186
  }
187
187
  // 默认工作目录:规则与优先级见 lib/host/default-workspace.js(有独立测试)。
188
- const defaultWorkspace = resolveDefaultWorkspace({
188
+ let defaultWorkspace = resolveDefaultWorkspace({
189
189
  configured: typeof config?.defaultWorkspace === 'string' ? config.defaultWorkspace : '',
190
190
  cwd: process.cwd(),
191
191
  home: homedir(),
@@ -193,6 +193,11 @@ async function boot(diag, config = {}) {
193
193
  // 整个 ~/.dsh 都不能当工作目录(桌面启动器的 cwd 就是 profile 目录)。
194
194
  excludeRoots: [dshHome()],
195
195
  });
196
+ // 兜底建议是 `~/works`:它可能还不存在,而 `project.workspace.update` 只接受
197
+ // 已存在的目录。用户确认的就是这个子目录,所以在这里建出来(失败则不提供建议)。
198
+ if (defaultWorkspace !== '' && !existsSync(defaultWorkspace)) {
199
+ try { mkdirSync(defaultWorkspace, { recursive: true }); } catch { defaultWorkspace = ''; }
200
+ }
196
201
  const registry = ProjectRegistry.load(dataDir, { defaultWorkspacePath: defaultWorkspace });
197
202
  const runtimes = new Map();
198
203
  for (const project of registry.list()) {
@@ -1488,6 +1493,13 @@ export function apply(ctx, config = {}) {
1488
1493
  return;
1489
1494
  }
1490
1495
  hostRepaired = true;
1496
+ // 成功行必须留在 errors 级别:否则「归档修复有没有跑过」永远无法判定
1497
+ // (只有 boot 瞬间那一行 deferred.fail 可见,见 lib/diaglog.js 白名单)。
1498
+ diag.append({
1499
+ ev: 'host.repair.ok',
1500
+ archived: Array.isArray(repaired) ? repaired.length : 0,
1501
+ sessionIds: Array.isArray(repaired) ? repaired.slice(0, 5) : [],
1502
+ });
1491
1503
  } catch (error) {
1492
1504
  hostRepaired = true;
1493
1505
  diag.append({ ev: 'host.unarchive.sweep.fail', error: error?.message ?? String(error) });
package/lib/diaglog.js CHANGED
@@ -1,4 +1,4 @@
1
- /**
1
+ /**
2
2
  * Plugin-owned diagnostic log: one JSONL file per day, appended serially,
3
3
  * rotated at a byte cap, and readable back through tail(). Both the Host
4
4
  * (boot, dispatch, wake, PMO, member failure/recovery) and the Client half
@@ -22,7 +22,10 @@ export function defaultDiagDir() {
22
22
  /** Rows worth keeping when the logger runs in `errors` mode. */
23
23
  export function isErrorEvent(ev) {
24
24
  return typeof ev === 'string'
25
- && (ev.endsWith('.fail') || ev === 'boot.refused' || ev === 'route.reject' || ev === 'ledger.repair');
25
+ && (ev.endsWith('.fail') || ev === 'boot.refused' || ev === 'route.reject' || ev === 'ledger.repair'
26
+ // 归档修复的**成功**行必须留在 `errors` 级别:否则「修没修」永远无法
27
+ // 判定(只有 boot 瞬间那一行 deferred.fail 可见)。
28
+ || ev === 'host.repair.ok');
26
29
  }
27
30
 
28
31
  /**
@@ -5,22 +5,30 @@
5
5
  * 1. 只有**没有指定**项目工作目录时才用默认目录;
6
6
  * 2. 项目一旦切换过工作目录,就按项目自己的目录执行(本模块只负责默认值);
7
7
  * 3. 默认值不能是插件自己的数据目录,否则成员会退化成「在账本目录里干活」;
8
- * 4. 系统目录(Windows / Program Files)不当作团队工作目录——桌面启动器的
8
+ * 4. 不能把用户主目录**根**当工作目录——必须是它下面的子目录(`~/works`);
9
+ * 5. 系统目录(Windows / Program Files)不当作团队工作目录——桌面启动器的
9
10
  * cwd 可能就是程序目录。
11
+ *
12
+ * 跨平台:主目录一律来自调用方的 `homedir()`(Windows 是 `USERPROFILE`,
13
+ * Linux/macOS 是 `~`),本模块不自己判断平台,只用 `join` 拼路径。
10
14
  */
11
15
 
12
16
  import { statSync } from 'node:fs';
13
- import { sep } from 'node:path';
17
+ import { join, sep } from 'node:path';
14
18
 
15
19
  const SYSTEM_DIR = /^[a-z]:[\\/](windows|program files|program files \(x86\))([\\/]|$)/i;
16
20
 
21
+ /** 用户主目录下的工作区子目录名(不给主目录根本身)。 */
22
+ export const WORKSPACE_SUBDIR = 'works';
23
+
17
24
  const isDirectory = (value) => {
18
25
  try { return statSync(value).isDirectory() === true; } catch { return false; }
19
26
  };
20
27
 
21
28
  /**
22
- * @param {{ configured?: string, cwd?: string, home?: string, dataDir?: string }} input
23
- * @returns {string} 绝对目录,找不到任何可用目录时返回空串
29
+ * @param {{ configured?: string, cwd?: string, home?: string, dataDir?: string, excludeRoots?: string[] }} input
30
+ * @returns {string} 绝对目录;找不到任何可用目录时返回空串。
31
+ * 注意:返回的路径**可能尚不存在**——那是 `~/works` 建议值,调用方负责创建。
24
32
  */
25
33
  export function resolveDefaultWorkspace({ configured = '', cwd = '', home = '', dataDir = '', excludeRoots = [] } = {}) {
26
34
  const explicit = typeof configured === 'string' ? configured.trim() : '';
@@ -37,7 +45,7 @@ export function resolveDefaultWorkspace({ configured = '', cwd = '', home = '',
37
45
  for (const root of excludeRoots) if (under(value, root)) return true;
38
46
  return false;
39
47
  };
40
- for (const raw of [explicit, cwd, home]) {
48
+ for (const raw of [explicit, cwd]) {
41
49
  if (typeof raw !== 'string' || raw === '') continue;
42
50
  if (!isDirectory(raw)) continue;
43
51
  if (excluded(raw)) continue;
@@ -45,5 +53,11 @@ export function resolveDefaultWorkspace({ configured = '', cwd = '', home = '',
45
53
  if (raw !== explicit && SYSTEM_DIR.test(raw)) continue;
46
54
  return raw;
47
55
  }
56
+ // 兜底:用户主目录下的 `works` 子目录(跨平台由调用方传入 homedir)。
57
+ if (typeof home === 'string' && home !== '') {
58
+ const suggested = join(home, WORKSPACE_SUBDIR);
59
+ // 主目录本身被排除(例如 home 就落在 ~/.dsh 下)时不再兜底。
60
+ if (!excluded(suggested)) return suggested;
61
+ }
48
62
  return '';
49
63
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suifei/dsh-ai-team",
3
- "version": "0.4.57",
3
+ "version": "0.4.59",
4
4
  "type": "module",
5
5
  "description": "文渊阁 (Wenyuan Pavilion) — AI Team mode for DeepSeek Harness: concurrent projects, owned tasks, threads, inbox and an append-only team ledger",
6
6
  "license": "MIT",