dsh-opencode-palette 1.4.1 → 1.5.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.md CHANGED
@@ -24,15 +24,9 @@ Then install the plugin into your profile:
24
24
  dsh plugin --profile web add dsh-opencode-palette
25
25
  ```
26
26
 
27
- Register the entry (hot-reloaded, no restart): append to `~/.dsh/profiles/web/cordis.patch.yml`:
27
+ That's it — **zero configuration**: this plugin uses DSH's official bundle mechanism — it ships its own `cordis.patch.yml` (declared via `dsh.bundle.patch`), so `dsh plugin add` automatically joins the package into the profile's `dsh.profile.bundles` layer stack, where the DSH loader assembles it at startup; `dsh plugin remove` removes it automatically. No manual file editing, and no pnpm build scripts (no postinstall, so pnpm v10 never blocks it). Restart DSH (or refresh the browser page) and the plugin is on, using the official `opencode` theme (deep black with orange / blue / violet).
28
28
 
29
- ```yaml
30
- - insert:
31
- - id: opencode-palette
32
- name: 'dsh-opencode-palette'
33
- ```
34
-
35
- Refresh the browser page — the plugin is on, using the official `opencode` theme (deep black with orange / blue / violet).
29
+ > **Upgrading from 1.4.x or earlier**: old versions wrote a registration block into `~/.dsh/profiles/web/cordis.patch.yml` via postinstall. Before upgrading, delete the `opencode-palette` block from that file (a leftover would duplicate the bundle registration), then re-run `dsh plugin --profile web add dsh-opencode-palette`.
36
30
 
37
31
  ## What it does
38
32
 
@@ -0,0 +1,7 @@
1
+ # dsh-opencode-palette bundle 层:插入主题引擎插件条目。
2
+ # 由 dsh plugin --profile <name> add 自动装配(包声明 dsh.bundle.patch),
3
+ # 无需手动编辑任何文件;dsh plugin remove 时自动移除。
4
+ - insert:
5
+ - id: opencode-palette
6
+ name: 'dsh-opencode-palette'
7
+ config: {}
package/lib/client.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * dsh-opencode-palette v1.4.1 — 浏览器半(构建产物,勿手改)
2
+ * dsh-opencode-palette v1.5.0 — 浏览器半(构建产物,勿手改)
3
3
  * 数据驱动管线:opencode v1.18.12 官方主题 JSON → 颜色解析 → DSH 适配注入
4
4
  * 源:src/engine/* + runtime/client.mjs(npm run build 重新生成)
5
5
  */
package/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * dsh-opencode-palette v1.4.1 — 宿主半(no-op)
2
+ * dsh-opencode-palette v1.5.0 — 宿主半(no-op)
3
3
  *
4
4
  * 主题的全部工作在浏览器端(./client.js)完成:
5
5
  * - 34 个 opencode 主题(33 内置 JSON + system)经数据驱动管线解析
package/package.json CHANGED
@@ -1,22 +1,19 @@
1
1
  {
2
2
  "name": "dsh-opencode-palette",
3
- "version": "1.4.1",
3
+ "version": "1.5.0",
4
4
  "description": "DSH Web 多主题引擎:完整支持 opencode TUI 全部 34 个主题(33 内置 + system)。数据驱动管线:主题 JSON → 颜色解析 → DSH 适配注入;设置面板即时切换、持久化。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
8
8
  ".": "./lib/index.js",
9
9
  "./client": "./lib/client.js",
10
+ "./cordis.patch.yml": "./cordis.patch.yml",
10
11
  "./package.json": "./package.json"
11
12
  },
12
13
  "files": [
13
14
  "lib",
14
- "scripts"
15
+ "cordis.patch.yml"
15
16
  ],
16
- "scripts": {
17
- "postinstall": "node scripts/install-patch.cjs",
18
- "preuninstall": "node scripts/uninstall-patch.cjs"
19
- },
20
17
  "keywords": [
21
18
  "dsh",
22
19
  "deepseek-harness",
@@ -28,6 +25,9 @@
28
25
  "multi-theme"
29
26
  ],
30
27
  "dsh": {
28
+ "bundle": {
29
+ "patch": "./cordis.patch.yml"
30
+ },
31
31
  "client": {
32
32
  "platform": "web",
33
33
  "immediately": true,
@@ -1,58 +0,0 @@
1
- /**
2
- * dsh-opencode-palette postinstall — 自动注册到 DSH profile(npm 标准安装即完成,无需手动编辑 patch)
3
- *
4
- * 行为:
5
- * 1. 定位 $DSH_HOME/profiles/web/cordis.patch.yml(DSH_HOME 未设 → ~/.dsh/profiles/web/…)
6
- * 2. 文件不存在 → 跳过(非 DSH 环境不打扰)
7
- * 3. 已含注册行 → 跳过(幂等,重装/升级不叠加)
8
- * 4. 否则文件末尾追加注册块(- insert: id opencode-palette / name dsh-opencode-palette)
9
- * 容错:任何异常只警告,绝不令 npm install 失败(退出码恒 0)。
10
- */
11
- const fs = require('fs')
12
- const path = require('path')
13
-
14
- const PLUGIN_ID = 'opencode-palette'
15
- const PLUGIN_NAME = 'dsh-opencode-palette'
16
-
17
- function findPatchPath() {
18
- const home = process.env.DSH_HOME
19
- || (process.platform === 'win32' ? process.env.USERPROFILE : process.env.HOME)
20
- if (!home) return null
21
- return path.join(home, '.dsh', 'profiles', 'web', 'cordis.patch.yml')
22
- }
23
-
24
- const REGISTER_BLOCK =
25
- '\n# dsh-opencode-palette(npm 安装 · 自动注册)\n' +
26
- '- insert:\n' +
27
- ' - id: ' + PLUGIN_ID + '\n' +
28
- " name: '" + PLUGIN_NAME + "'\n"
29
-
30
- function main() {
31
- const patch = findPatchPath()
32
- if (!patch) {
33
- console.log('[dsh-opencode-palette] 未找到 DSH_HOME,跳过自动注册(非 DSH 环境)')
34
- return
35
- }
36
- let existed = true
37
- let text = ''
38
- try {
39
- text = fs.readFileSync(patch, 'utf8')
40
- } catch (e) {
41
- existed = false
42
- }
43
- if (existed && new RegExp("id\\s*:\\s*['\"]?" + PLUGIN_ID + "['\"]?").test(text)) {
44
- console.log('[dsh-opencode-palette] 已在 cordis.patch.yml 注册,跳过')
45
- return
46
- }
47
- try {
48
- fs.mkdirSync(path.dirname(patch), { recursive: true })
49
- fs.appendFileSync(patch, REGISTER_BLOCK, 'utf8')
50
- console.log('[dsh-opencode-palette] 已自动注册到 ' + patch + '(刷新浏览器页面即生效)')
51
- } catch (e) {
52
- console.warn('[dsh-opencode-palette] 自动注册失败(不影响本包安装):' + String((e && e.message) || e))
53
- }
54
- }
55
-
56
- try { main() } catch (e) {
57
- console.warn('[dsh-opencode-palette] postinstall 异常(已忽略):' + String((e && e.message) || e))
58
- }
@@ -1,50 +0,0 @@
1
- /**
2
- * dsh-opencode-palette preuninstall — 自动从 DSH profile 移除注册(npm remove 即完成,无需手动编辑 patch)
3
- * 幂等:不存在注册块 → 直接返回;任何异常只警告,退出码恒 0。
4
- */
5
- const fs = require('fs')
6
- const path = require('path')
7
-
8
- const PLUGIN_ID = 'opencode-palette'
9
-
10
- function findPatchPath() {
11
- const home = process.env.DSH_HOME
12
- || (process.platform === 'win32' ? process.env.USERPROFILE : process.env.HOME)
13
- if (!home) return null
14
- return path.join(home, '.dsh', 'profiles', 'web', 'cordis.patch.yml')
15
- }
16
-
17
- // 匹配注册块:可选注释行 + insert 块(容错 name 引号/缩进变化)
18
- const BLOCK_RE = new RegExp(
19
- '(?:^|\\n)\\s*# dsh-opencode-palette[^\\n]*\\n' +
20
- '\\s*- insert:\\n' +
21
- '\\s*\\s*- id:\\s*' + PLUGIN_ID + '\\s*\\n' +
22
- "\\s*\\s*name:\\s*['\"]?dsh-opencode-palette['\"]?\\s*\\n",
23
- 'g'
24
- )
25
-
26
- function main() {
27
- const patch = findPatchPath()
28
- if (!patch) return
29
- let text = ''
30
- try {
31
- text = fs.readFileSync(patch, 'utf8')
32
- } catch (e) {
33
- return // 文件不存在 → 无需清理
34
- }
35
- const next = text.replace(BLOCK_RE, '\n')
36
- if (next === text) {
37
- console.log('[dsh-opencode-palette] 未在 cordis.patch.yml 找到注册块,无需清理')
38
- return
39
- }
40
- try {
41
- fs.writeFileSync(patch, next, 'utf8')
42
- console.log('[dsh-opencode-palette] 已从 cordis.patch.yml 移除注册(卸载完成)')
43
- } catch (e) {
44
- console.warn('[dsh-opencode-palette] 移除注册失败:' + String((e && e.message) || e))
45
- }
46
- }
47
-
48
- try { main() } catch (e) {
49
- console.warn('[dsh-opencode-palette] preuninstall 异常(已忽略):' + String((e && e.message) || e))
50
- }