@carljia/omd-dsh 0.1.5 → 0.1.8

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/README.md CHANGED
@@ -1,10 +1,16 @@
1
1
  # @carljia/omd-dsh
2
2
 
3
- OMD 理念的 DSH 插件:两个 cordis 行 + 7 个模式 preset + 同步 CLI。总览、模式矩阵与安装见仓库根 [README.md](../../README.md)。
3
+ OMD 理念的 DSH 插件:两个 cordis 行 + 7 个模式 preset + 同步 CLI。以 `dsh.bundle` 形式分发——`dsh plugin add @carljia/omd-dsh` 安装后重启即自动同步预设;也可全局安装后用 `omd-dsh sync`。总览、模式矩阵与安装见仓库根 [README.md](../../README.md)。
4
+
5
+ ## 分发:bundle + boot 行
6
+
7
+ 包声明 `dsh.bundle.patch` → `cordis.patch.yml`,后者注入宿主行 `@carljia/omd-dsh/boot`。该行在 profile 启动时执行与 `omd-dsh sync` 相同的内核(`lib/sync.js`):渲染并复制 7 个 preset 与 `.omd-vendor/` 行模块、首次生成 `omd-matrix.json`。全程幂等、hash 保护、不覆盖本地修改。
8
+
9
+ `.omd-vendor/` 里的行模块是**自包含 bundle**(`scripts/postbuild.mjs` 用 esbuild 把 schemastery / dsh-tools / dsh-llm / dsh-subagent 全部打进模块,唯一的例外是 `shared.js`——omd-mode 与 omd-task 共享的按 agent 键控状态,作为相对兄弟模块保持单一实例)。行模块不含任何 `@deepseek-ai/*` 导入,因此 sync **不需要知道 harness 装在哪里**,也不会出现"导入指向的树与运行进程不一致"导致的挂载失败——无论 DSH 从 npx 缓存、全局 npm 还是 profile bundles 加载 agent 机制都能工作。preset 组合里其余裸包名行(如 `@deepseek-ai/dsh-persona`)由 harness 的 loader 在运行时按宿主 base 解析。
4
10
 
5
11
  ## 行:omd-mode
6
12
 
7
- 按模式(agent preset)固定模型路由。仅限 preset 作用域内挂载(无作用域挂载直接报错)。
13
+ 按模式(agent preset)固定模型路由。行模块是自包含 bundle,不再做 scope 守卫(bundle 内自带的 dsh-scope 副本读不到 harness 实例写入的 kScope Symbol,守卫会误报——见 docs/ARCHITECTURE.md);请按 preset 组合挂载,误挂到全局组合会导致进程级钉模型。
8
14
 
9
15
  | 配置字段 | 含义 |
10
16
  |---|---|
@@ -20,7 +26,7 @@ OMD 理念的 DSH 插件:两个 cordis 行 + 7 个模式 preset + 同步 CLI
20
26
  1. 入口选择 == 矩阵模型 → 钉住矩阵模型(无操作);
21
27
  2. 会话尚无任何请求(blank)且入口选择 == 挂载时的部署默认模型 → 视为未选择,钉住矩阵模型;
22
28
  3. 会话已跑过请求且刚发生 preset 切换(/mode 或 UI 选择,日志中 agent-preset/selected 在最后一次 request/header 之后)且入口选择 == 切换前的路由 → 新模式认领矩阵模型;
23
- 4. 其余情况 → 入口选择与矩阵模型不同 = 用户显式切换:请求与 persona 变量均保持用户选择,本行在作用域 ctx 上记录 `omdModeOverride`(provider/model),omd-task 行据此把 deep tier 路由到用户选择的模型。
29
+ 4. 其余情况 → 入口选择与矩阵模型不同 = 用户显式切换:请求与 persona 变量均保持用户选择,本行在共享状态 `shared.js`(按顶层 agent 对象为键的 WeakMap)上记录用户选择,omd-task 行据此把 deep tier 路由到用户选择的模型。
24
30
 
25
31
  模型体验:persona 文本每次请求固定携带实际路由模型的声明;模式模型路由在 agent 生命周期内稳定(KV 前缀稳定)。
26
32
 
@@ -39,19 +45,19 @@ tier 差异化子代理委派(等价 OMD 的 task(category=…))。仅限 pr
39
45
 
40
46
  模型可见参数:description(展示名)、prompt、tier(枚举见工具描述)、run_in_background(仅 continuable 模式)。工具描述枚举各 tier 的 hint 与模型,模型据此选型。
41
47
 
42
- **deep tier 与用户模型覆盖**:用户在 UI 显式切换模型后(omd-mode 让路并记录 `ctx.omdModeOverride`),名为 `deep` 的 tier 改用用户选择的模型(provider/model 整体替换),其余 tier 保持矩阵配置。
48
+ **deep tier 与用户模型覆盖**:用户在 UI 显式切换模型后(omd-mode 让路并在 `shared.js` 里记录用户选择),名为 `deep` 的 tier 改用用户选择的模型(provider/model 整体替换),其余 tier 保持矩阵配置。
43
49
 
44
50
  ## CLI:omd-dsh
45
51
 
46
52
  ```
47
- omd-dsh <command> [--harness <路径>] [--dry-run]
53
+ omd-dsh <command> [--dry-run]
48
54
  ```
49
55
 
50
- - `omd-dsh sync` — 把 presets/ 与 vendored 行模块同步到 `<DSH_HOME>/.agent-presets/`(hash 保护、orphan 报告、非管理目录零操作)。每个 preset 的 omd-mode / omd-task 行由用户矩阵 `<DSH_HOME>/omd-matrix.json` 渲染。
56
+ - `omd-dsh sync` — 把 presets/ 与 vendored 行模块同步到 `<DSH_HOME>/.agent-presets/`(hash 保护、orphan 报告、非管理目录零操作)。每个 preset 的 omd-mode / omd-task 行由用户矩阵 `<DSH_HOME>/omd-matrix.json` 渲染。不需要任何 harness 路径配置。
51
57
  - `omd-dsh setup` — 交互式向导:先读取 DSH 已有模型,再引导逐模式/逐 tier 选择模型,写回 `<DSH_HOME>/omd-matrix.json` 并可选立即同步。
52
58
  - `omd-dsh models` — 打印发现的 DSH 模型目录(非交互)。
53
59
 
54
- 细节见 docs/ARCHITECTURE.md 的「vendored 分发与跨树符号风险」。
60
+ 细节见 docs/ARCHITECTURE.md 的「vendored 分发与自包含 bundle」。
55
61
 
56
62
  ## 集中配置:<DSH_HOME>/omd-matrix.json
57
63
 
@@ -60,19 +66,20 @@ omd-dsh <command> [--harness <路径>] [--dry-run]
60
66
  ## 开发
61
67
 
62
68
  ```bash
63
- npm install # 触发 build(tsc + postbuild)
64
- npm test # vitest,39 个测试
69
+ npm install # 触发 build(tsc + esbuild 打包自包含 bundle)
70
+ npm test # vitest 全量测试
65
71
  npm pack # prepack 自动重建,产出 tgz
66
72
  ```
67
73
 
68
- 测试桩在 test/stubs/(dsh-scope/dsh-tools/dsh-subagent 的轻量替身),不依赖真实 harness。
74
+ 测试桩在 test/stubs/(dsh-tools/dsh-subagent 的轻量替身),不依赖真实 harness。
69
75
 
70
76
 
71
77
  ### 子代理透传语义
72
78
 
73
79
  omd-mode 对 subagentDepth > 0 的子代理一律透传(不覆盖 provider/model/变量):
74
80
  omd-task 的 tier 模型通过显式 agentOptions 生效;顶层 agent 才被钉到模式模型
75
- (除非用户显式切换模型——此时顶层跟随用户选择,deep tier 通过 `ctx.omdModeOverride` 同步)。
81
+ (除非用户显式切换模型——此时顶层跟随用户选择,deep tier 通过 `shared.js` 里
82
+ 按 agent 记录的覆盖值同步)。
76
83
  这保证「强模型顶层 + tier 差异化子代理」的优先级正确。
77
84
 
78
85
  ### toolFilter 注意
@@ -0,0 +1,10 @@
1
+ # omd-dsh bundle patch: inject the boot row that, on startup, materializes
2
+ # the 7 OMD agent presets into the user preset root (<DSH_HOME>/.agent-presets).
3
+ #
4
+ # The boot row (lib/boot.js) resolves the harness tree, copies the presets and
5
+ # the vendored row modules, rewrites their @deepseek-ai/* imports to the harness,
6
+ # and generates the model matrix on first run — idempotently. Install with:
7
+ # dsh plugin --profile web add @carljia/omd-dsh # then restart dsh.
8
+ - insert:
9
+ - id: omd-dsh
10
+ name: '@carljia/omd-dsh/boot'
package/lib/boot.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @module @carljia/omd-dsh/boot
3
+ *
4
+ * omd-dsh bundle boot row: materialize the 7 OMD agent presets into the user
5
+ * preset root (<DSH_HOME>/.agent-presets) when the profile boots, so
6
+ * "dsh plugin add @carljia/omd-dsh" + a restart is the whole install — no
7
+ * manual "omd-dsh sync" and no harness configuration needed.
8
+ *
9
+ * The sync is idempotent (hash-aware, conflict-protected) and reuses the same
10
+ * core as the "omd-dsh sync" CLI. The vendored rows are self-contained
11
+ * bundles (see scripts/postbuild.mjs), so the sync needs no harness tree
12
+ * knowledge and cannot break on harness/profile layout differences.
13
+ *
14
+ * A sync failure is logged, not thrown: a broken omd-dsh should never brick
15
+ * the host's boot.
16
+ */
17
+ /** Cordis plugin name used by loader diagnostics. */
18
+ export declare const name = "omd-dsh";
19
+ /** No service injection: this row only runs its idempotent install at mount. */
20
+ export declare const inject: string[];
21
+ export declare function apply(ctx: any): Promise<void>;
package/lib/boot.js ADDED
@@ -0,0 +1,40 @@
1
+ import { runSync } from "./sync.js";
2
+ /**
3
+ * @module @carljia/omd-dsh/boot
4
+ *
5
+ * omd-dsh bundle boot row: materialize the 7 OMD agent presets into the user
6
+ * preset root (<DSH_HOME>/.agent-presets) when the profile boots, so
7
+ * "dsh plugin add @carljia/omd-dsh" + a restart is the whole install — no
8
+ * manual "omd-dsh sync" and no harness configuration needed.
9
+ *
10
+ * The sync is idempotent (hash-aware, conflict-protected) and reuses the same
11
+ * core as the "omd-dsh sync" CLI. The vendored rows are self-contained
12
+ * bundles (see scripts/postbuild.mjs), so the sync needs no harness tree
13
+ * knowledge and cannot break on harness/profile layout differences.
14
+ *
15
+ * A sync failure is logged, not thrown: a broken omd-dsh should never brick
16
+ * the host's boot.
17
+ */
18
+ /** Cordis plugin name used by loader diagnostics. */
19
+ export const name = "omd-dsh";
20
+ /** No service injection: this row only runs its idempotent install at mount. */
21
+ export const inject = [];
22
+ function log(ctx, level, message) {
23
+ try {
24
+ const logger = ctx?.logger;
25
+ if (logger !== undefined && logger !== null) {
26
+ logger[level](message);
27
+ return;
28
+ }
29
+ }
30
+ catch { /* fall through to console */ }
31
+ (level === "error" ? console.error : console.log)(message);
32
+ }
33
+ export async function apply(ctx) {
34
+ try {
35
+ await runSync({ dryRun: false, verbose: false }, (message) => log(ctx, "info", message));
36
+ }
37
+ catch (error) {
38
+ log(ctx, "error", "omd-dsh: preset sync failed: " + (error instanceof Error ? error.message : String(error)));
39
+ }
40
+ }