@lifenrir/dsh-external-task-context-patch 0.0.0-stage → 0.1.0

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-zh.md ADDED
@@ -0,0 +1,103 @@
1
+ # dsh-external-task-context-patch
2
+
3
+ DSH 官方发行版 `0.2.2-rc.1` 中的 `@deepseek-ai/dsh-subagent-claude-code` 不会写运行日志,而外部任务上下文插件依赖这些日志提供实时对话流与「统计」标签。本包在官方提供方源码上应用插件的运行日志补丁并重新构建,然后安装到现有的 DSH profile 中。
4
+
5
+ 未打补丁时,插件仍能展示委派提示词、运行上下文和返回结果,但 Claude Code 任务没有实时日志,也没有统计。
6
+
7
+ ## 支持的版本
8
+
9
+ | 提供方版本 | deepseek-harness tag |
10
+ | --- | --- |
11
+ | `0.2.2-rc.1` | `dsh-v0.2.2-rc.1`(默认) |
12
+
13
+ 安装器按 `dsh-v<version>` 建立版本与 tag 的映射;若 profile 中已安装的提供方版本与 `--tag` 不一致,除非传入 `--force`,否则拒绝安装。
14
+
15
+ ## 使用
16
+
17
+ ```sh
18
+ # 未发布到 npm 时,从插件根目录直接运行(推荐先 --dry-run)。
19
+ node patch/install.mjs --profile desktop --dry-run
20
+ node patch/install.mjs --profile desktop
21
+
22
+ # 已发布后可用 npx。
23
+ # Patch the only profile that has the provider installed.
24
+ npx @lifenrir/dsh-external-task-context-patch
25
+
26
+ # 指定 profile(可重复传入 --profile 处理多个)。
27
+ npx @lifenrir/dsh-external-task-context-patch --profile desktop
28
+
29
+ # 只下载和构建,不写入 profile;临时文件除外。
30
+ npx @lifenrir/dsh-external-task-context-patch --profile desktop --dry-run
31
+
32
+ # 恢复该 profile 最新的备份。
33
+ npx @lifenrir/dsh-external-task-context-patch --profile desktop --restore
34
+
35
+ # 使用本地 deepseek-harness 检出,不访问网络。
36
+ npx @lifenrir/dsh-external-task-context-patch --profile desktop \
37
+ --source /path/to/deepseek-harness/packages/subagent/subagent-claude-code/src
38
+ ```
39
+
40
+ 其他选项:
41
+
42
+ - `--dsh-home <path>`:DSH home。默认使用非空的 `$DSH_HOME`,否则 `~/.dsh`。
43
+ - `--tag <git-tag>`:要下载的发行 tag,默认 `dsh-v0.2.2-rc.1`。
44
+ - `--force`:在版本与 tag 不匹配,或同一 tag 已存在有效安装记录时仍继续安装,并打印醒目警告。
45
+ - `--yes`:非交互地处理所有发现的 profile。不传时,发现结果必须恰好只有一个 profile。
46
+ - `--source <dir>`:离线模式。目录中必须包含官方 `index.ts`、`run.ts`、`process.ts`。
47
+
48
+ 未指定 `--profile` 时,安装器查找
49
+ `<dsh-home>/profiles/*/node_modules/@deepseek-ai/dsh-subagent-claude-code`。
50
+ 必须恰好匹配一个 profile;传入 `--yes` 时处理全部匹配项。
51
+
52
+ 每次运行都会打印 profile、提供方版本、tag、备份路径、日志目录
53
+ (`<dsh-home>/logs/subagent-claude-code`)以及重启提醒。
54
+
55
+ ## 安装器改动的文件
56
+
57
+ 只替换提供方包中的一个文件:
58
+
59
+ ```
60
+ <profile>/node_modules/@deepseek-ai/dsh-subagent-claude-code/lib/index.js
61
+ ```
62
+
63
+ 下载的官方 `process.ts` 保持不变;补丁版 `index.ts`、`run.ts`、`log.ts` 由 esbuild 与其一起打包(单个 ESM bundle、`packages: 'external'`、`platform: 'node'`、`target: 'node20'`)。补丁版 `log.ts` 内联解析 DSH home(`$DSH_HOME` 非空时优先,否则 `~/.dsh`),因此 bundle 不再依赖 `@deepseek-ai/dsh-home-paths`。
64
+
65
+ 安装器不修改 profile 的 `package.json`,不运行 `pnpm`,也不改动其他已安装文件。
66
+
67
+ ## 备份与恢复
68
+
69
+ 替换 `lib/index.js` 之前,原文件会被复制到:
70
+
71
+ ```
72
+ <dsh-home>/backups/subagent-claude-code-patch/<UTC 时间戳>/<profile>/index.js
73
+ <dsh-home>/backups/subagent-claude-code-patch/<UTC 时间戳>/<profile>/install.json
74
+ ```
75
+
76
+ `install.json` 记录 `{ version, tag, installedAt, providerDir, backupFile }`。
77
+ `--restore` 会把最新记录的备份复制回 `lib/index.js`,并写入 `restoredAt`;再次恢复是无操作。
78
+
79
+ 替换文件后,安装器会从提供方真实目录导入已安装的 bundle,检查
80
+ `name === 'subagent-claude-code'` 且 `Config({}).persistNativeTranscript === true`。
81
+ 检查失败时会自动还原备份并以非零状态退出。
82
+
83
+ ## 重启
84
+
85
+ DSH 在启动时加载提供方。安装或恢复后需要重启 DSH;在此之前旧模块仍然驻留。
86
+
87
+ ## 升级
88
+
89
+ 升级 DSH 或提供方会替换包内容,从而覆盖 `lib/index.js` 并移除补丁。升级后请按新版本和 tag 重新运行安装器。建议先使用 `--dry-run`;版本与 tag 不一致时必须加 `--force`。
90
+
91
+ ## 网络与代理
92
+
93
+ 源码从
94
+ `https://raw.githubusercontent.com/deepseek-ai/deepseek-harness/<tag>/packages/subagent/subagent-claude-code/src/`
95
+ 下载,每个文件 30 秒超时。若 DSH 位于代理之后,请在运行安装器前设置
96
+ `NODE_USE_ENV_PROXY=1` 与 `HTTPS_PROXY`(或 `HTTP_PROXY`),或使用
97
+ `--source <dir>` 指向本地检出。
98
+
99
+ ## 测试
100
+
101
+ ```sh
102
+ node --test tests/lib.test.mjs
103
+ ```
package/README.md CHANGED
@@ -1,3 +1,125 @@
1
- # Temporary Holding Version
1
+ # dsh-external-task-context-patch
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The official DSH release `0.2.2-rc.1` ships `@deepseek-ai/dsh-subagent-claude-code`
4
+ as a package whose provider does not write run logs. The External Task Context
5
+ plugin needs those logs for its live conversation stream and its Statistics tab.
6
+ This package rebuilds the official provider with the plugin's run-log patch and
7
+ installs it into an existing DSH profile.
8
+
9
+ Without the patch the plugin still shows the delegation prompt, the runtime
10
+ context, and the returned outcome, but there is no live log and no statistics
11
+ for Claude Code tasks.
12
+
13
+ ## Supported release
14
+
15
+ | Provider version | deepseek-harness tag |
16
+ | --- | --- |
17
+ | `0.2.2-rc.1` | `dsh-v0.2.2-rc.1` (default) |
18
+
19
+ The installer maps `version` to `dsh-v<version>` and refuses a profile whose
20
+ installed provider version does not match `--tag` unless `--force` is passed.
21
+
22
+ ## Usage
23
+
24
+ ```sh
25
+ # Before publishing to npm, run it from the plugin root (prefer --dry-run first).
26
+ node patch/install.mjs --profile desktop --dry-run
27
+ node patch/install.mjs --profile desktop
28
+
29
+ # Once published, the npx shortcut works.
30
+ # Patch the only profile that has the provider installed.
31
+ npx @lifenrir/dsh-external-task-context-patch
32
+
33
+ # Patch a named profile (repeat --profile for several).
34
+ npx @lifenrir/dsh-external-task-context-patch --profile desktop
35
+
36
+ # Show what would happen; downloads and builds, but writes only temp files.
37
+ npx @lifenrir/dsh-external-task-context-patch --profile desktop --dry-run
38
+
39
+ # Restore the newest backup for the profile.
40
+ npx @lifenrir/dsh-external-task-context-patch --profile desktop --restore
41
+
42
+ # Build from a local deepseek-harness checkout instead of GitHub.
43
+ npx @lifenrir/dsh-external-task-context-patch --profile desktop \
44
+ --source /path/to/deepseek-harness/packages/subagent/subagent-claude-code/src
45
+ ```
46
+
47
+ Other options:
48
+
49
+ - `--dsh-home <path>`: DSH home. Defaults to a non-empty `$DSH_HOME`, then `~/.dsh`.
50
+ - `--tag <git-tag>`: release tag to download. Defaults to `dsh-v0.2.2-rc.1`.
51
+ - `--force`: install despite a provider-version/tag mismatch, or reinstall over an
52
+ existing active patch record for the same tag. A loud warning is printed.
53
+ - `--yes`: process every discovered profile non-interactively. Without it,
54
+ discovery must find exactly one profile.
55
+ - `--source <dir>`: offline mode. The directory must contain the official
56
+ `index.ts`, `run.ts`, and `process.ts`.
57
+
58
+ When no `--profile` is given the installer looks for
59
+ `<dsh-home>/profiles/*/node_modules/@deepseek-ai/dsh-subagent-claude-code`.
60
+ Exactly one match is required unless `--yes` is passed, in which case all
61
+ matches are patched.
62
+
63
+ Each run prints the profile, the provider version, the tag, the backup path, the
64
+ log directory (`<dsh-home>/logs/subagent-claude-code`), and a restart reminder.
65
+
66
+ ## What the installer changes
67
+
68
+ It replaces exactly one file in the provider package:
69
+
70
+ ```
71
+ <profile>/node_modules/@deepseek-ai/dsh-subagent-claude-code/lib/index.js
72
+ ```
73
+
74
+ The downloaded official `process.ts` is kept; the patched `index.ts`, `run.ts`,
75
+ and `log.ts` are bundled over it with esbuild (single ESM bundle,
76
+ `packages: 'external'`, `platform: 'node'`, `target: 'node20'`). The patched
77
+ `log.ts` resolves the DSH home inline (`$DSH_HOME` when non-empty, otherwise
78
+ `~/.dsh`), so the bundle has no `@deepseek-ai/dsh-home-paths` dependency.
79
+
80
+ The installer does not modify the profile's `package.json`, does not run `pnpm`,
81
+ and does not touch any other installed file.
82
+
83
+ ## Backups and restore
84
+
85
+ Before replacing `lib/index.js`, the original is copied to:
86
+
87
+ ```
88
+ <dsh-home>/backups/subagent-claude-code-patch/<UTC timestamp>/<profile>/index.js
89
+ <dsh-home>/backups/subagent-claude-code-patch/<UTC timestamp>/<profile>/install.json
90
+ ```
91
+
92
+ `install.json` records `{ version, tag, installedAt, providerDir, backupFile }`.
93
+ `--restore` copies the newest record's backup back over `lib/index.js` and marks
94
+ the record with `restoredAt`; restoring again is a no-op.
95
+
96
+ After replacing the file, the installer imports the installed bundle and checks
97
+ that `name === 'subagent-claude-code'` and that
98
+ `Config({}).persistNativeTranscript === true`. If that check fails, the backup is
99
+ restored automatically and the command exits non-zero.
100
+
101
+ ## Restart
102
+
103
+ DSH loads the provider at startup. Restart DSH after installing or restoring.
104
+ Until then the old module stays loaded.
105
+
106
+ ## Upgrades
107
+
108
+ A DSH or provider upgrade replaces the package contents, which overwrites
109
+ `lib/index.js` and removes the patch. After any upgrade, re-run the installer
110
+ for the new version and tag. Use `--dry-run` first; `--force` is required when
111
+ the version and tag do not match.
112
+
113
+ ## Network and proxies
114
+
115
+ Sources are downloaded from
116
+ `https://raw.githubusercontent.com/deepseek-ai/deepseek-harness/<tag>/packages/subagent/subagent-claude-code/src/`
117
+ with a 30-second timeout per file. If DSH runs behind a proxy, set
118
+ `NODE_USE_ENV_PROXY=1` and `HTTPS_PROXY` (or `HTTP_PROXY`) before running the
119
+ installer, or use `--source <dir>` with a local checkout.
120
+
121
+ ## Tests
122
+
123
+ ```sh
124
+ node --test tests/lib.test.mjs
125
+ ```