dsh-tui-theme 0.2.0 → 0.2.2

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
@@ -23,6 +23,20 @@
23
23
 
24
24
  > 小知识:`pink-day` 的 `text` 写成 `rgb(61,43,51)` 而非 hex——宿主按 `text` 墨色亮度自动判定主题深浅,且只认 `rgb()` 格式。
25
25
 
26
+ ## 截图
27
+
28
+ 实测于 dsh-tui 0.9.0:
29
+
30
+ | 昼樱 `pink-day` | 夜樱 `pink-night` |
31
+ | :---: | :---: |
32
+ | ![pink-day 主题界面](docs/screenshots/pink-day.png) | ![pink-night 主题界面](docs/screenshots/pink-night.png) |
33
+
34
+ `/settings` 里的 pink-theme 区块(跟随终端背景 / 花符 / 时钟 / 轮数,保存即时生效):
35
+
36
+ ![pink-theme 设置区块](docs/screenshots/settings.png)
37
+
38
+ > 图中底栏上下文进度条的蓝色分段与 ❯ 提示符是宿主硬编码的,见下文[宿主限制](#受宿主限制目前无法定制的部分)。
39
+
26
40
  ## 自动跟随终端背景
27
41
 
28
42
  设置里的“跟随终端背景”开启后(本部署默认开启):
@@ -35,11 +49,14 @@
35
49
  ## 安装
36
50
 
37
51
  ```sh
38
- # 方式一:本地路径(开发/自用)
39
- dsh plugin --profile dsh-tui add -w /path/to/dsh-tui-theme
52
+ # 方式一:从 npm(已发布)
53
+ dsh plugin --profile dsh-tui add -w dsh-tui-theme
40
54
 
41
- # 方式二:从 GitHub(发布后)
42
- dsh plugin --profile dsh-tui add -w github:<你的用户名>/dsh-tui-theme
55
+ # 方式二:从 GitHub
56
+ dsh plugin --profile dsh-tui add -w github:xiaoxiaohaigui/dsh-tui-theme
57
+
58
+ # 方式三:本地路径(开发/自用)
59
+ dsh plugin --profile dsh-tui add -w /path/to/dsh-tui-theme
43
60
  ```
44
61
 
45
62
  重启 dsh-TUI 后插件自动把三套主题复制进 `~/.dsh-tui/themes/`(**仅缺失时复制,绝不覆盖你已有的同名文件**),然后:
@@ -65,7 +82,19 @@ dsh plugin --profile dsh-tui add -w github:<你的用户名>/dsh-tui-theme
65
82
 
66
83
  三项装饰全关时状态行整体消失。另有仅 profile 层的开关(`cordis.patch.yml`,不出现在 /settings):`autoInstallThemes`、`statusEnabled`。
67
84
 
68
- > 已知宿主限制:底栏的上下文进度条分段色(蓝色系)与空余段配色是宿主硬编码的,主题与插件均无法覆盖;自定义浅色主题(pink-day)会拿到深色空余段配色(宿主按 `themeName === 'light'` 判断,不识别自定义浅色主题)。这需要上游修复。
85
+ ## 受宿主限制、目前无法定制的部分
86
+
87
+ 以下元素的颜色/形态由 dsh-TUI 宿主**硬编码**,不读取任何主题键,主题 JSON 与插件接缝都覆盖不到(dsh-TUI 0.9.0 实测):
88
+
89
+ | 元素 | 现状 | 位置(宿主源码) |
90
+ | --- | --- | --- |
91
+ | 输入框 ❯ 提示符 | 默认态无颜色参数(终端默认前景色,模型工作时变暗);最高推理档充能动画用**写死的蓝色 ramp**(深色端 `#82B9FF` / 浅色端 `#1E5FEB`) | `EffortChargeGlyph.tsx`、`trajectory/effortIgnition.ts` |
92
+ | 底栏上下文进度条分段色 | system / prompt / assistant / thinking / tools 五段为**写死的藏青→品牌蓝系**(`#22305F`→`#5A7CFF`),永远不随主题变化 | `screens/StatusMetrics.ts` |
93
+ | 进度条空余段配色 | 宿主按 `themeName === 'light'` **字符串比较**取浅色配色——自定义浅色主题(如 pink-day)不等于 `'light'`,会拿到深色空余段,在浅色终端上偏深 | `screens/StatusLine.tsx` |
94
+ | 状态行文字颜色 | 插件状态行(tuiStatus)由宿主统一以**无色 + 终端 dim** 渲染,插件无法指定颜色(✿ 行因此继承终端默认前景色) | `screens/Chat.tsx` |
95
+ | 主界面组件与布局 | 顶栏像素鲸鱼、工具卡、输入框等宿主组件不可被插件替换或改布局——平台规则(内建优先,无组件替换接缝);主题能碰的只有颜色层 | 宿主架构约定 |
96
+
97
+ 这些都需要上游 dsh-TUI 修改(例如:把充能色/进度条分段色接入主题键、空余段判断改用 `isLightThemeActive()`)。上游修复前,任何社区主题包都受同样约束。
69
98
 
70
99
  ## 卸载
71
100
 
@@ -86,5 +115,5 @@ npm run verify # 沙盒测试(临时 HOME + 伪造 TTY,不碰
86
115
 
87
116
  ## 兼容性
88
117
 
89
- - dsh-TUI `dsh-tui-extensions` 扩展面(tuiStatus / tuiSettingsSections);旧版 profile 缺这些服务时插件自动退化为“仅安装主题”,不会报错。
118
+ - **dsh-TUI 版本下限:0.8.8**(全功能,含状态行与设置面板;0.9.0 实测)。更旧的宿主缺 `dsh-tui-extensions` 扩展面时,插件自动降级为“仅安装三套主题 + 背景跟随”,不报错。
90
119
  - Node `^22.19 || >=24`,纯 ESM,MIT。
Binary file
Binary file
Binary file
@@ -6,9 +6,9 @@
6
6
  * ride it. This module gives pink-day/pink-night the same behavior from the
7
7
  * plugin side:
8
8
  *
9
- * - at apply() (which runs before the React tree mounts and reads
10
- * ~/.dsh-tui/theme.json), the cached detection writes the resolved theme
11
- * name into the pref synchronously always in time for this boot;
9
+ * - the caller wires this from the settings inject callback (see index.ts):
10
+ * that fires before the React tree mounts and reads ~/.dsh-tui/theme.json,
11
+ * so the cached detection still decides this boot;
12
12
  * - a fresh OSC 11 query then refreshes the cache for the next boot. The
13
13
  * very first enabling (or a system flip between boots) lands one boot
14
14
  * late — the same cadence as the host's own "re-select auto or restart".
@@ -1 +1 @@
1
- {"version":3,"file":"autoTheme.d.ts","sourceRoot":"","sources":["../../src/autoTheme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAgBH,UAAU,WAAW;IACnB,KAAK,EAAE,OAAO,CAAA;IACd,EAAE,EAAE,MAAM,CAAA;CACX;AAgCD,+DAA+D;AAC/D,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGjE;AAED,yDAAyD;AACzD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,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,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQrE;AAcD;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,EACf,MAAM,GAAE,MAAM,CAAC,WAA4B,EAC3C,KAAK,GAAE,MAAM,CAAC,UAA0B,EACxC,YAAY,GAAE,OAAO,UAAuB,GAC3C,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAmD9B;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GAC7B,IAAI,CAYN"}
@@ -6,9 +6,9 @@
6
6
  * ride it. This module gives pink-day/pink-night the same behavior from the
7
7
  * plugin side:
8
8
  *
9
- * - at apply() (which runs before the React tree mounts and reads
10
- * ~/.dsh-tui/theme.json), the cached detection writes the resolved theme
11
- * name into the pref synchronously always in time for this boot;
9
+ * - the caller wires this from the settings inject callback (see index.ts):
10
+ * that fires before the React tree mounts and reads ~/.dsh-tui/theme.json,
11
+ * so the cached detection still decides this boot;
12
12
  * - a fresh OSC 11 query then refreshes the cache for the next boot. The
13
13
  * very first enabling (or a system flip between boots) lands one boot
14
14
  * late — the same cadence as the host's own "re-select auto or restart".
@@ -19,7 +19,6 @@
19
19
  * @module dsh-tui-theme/autoTheme
20
20
  */
21
21
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
22
- import { homedir } from 'node:os';
23
22
  import { join } from 'node:path';
24
23
  /** The pair this feature switches between (light terminal → day). */
25
24
  const LIGHT_THEME = 'pink-day';
@@ -29,9 +28,6 @@ const QUERY = '\x1b]11;?\x07';
29
28
  // ST terminated.
30
29
  const REPLY = /\x1b\]11;rgb:([0-9a-fA-F]{1,4})\/([0-9a-fA-F]{1,4})\/([0-9a-fA-F]{1,4})(?:\x07|\x1b\\)/;
31
30
  const DETECT_TIMEOUT_MS = 400;
32
- function homeDir() {
33
- return homedir() || process.env.USERPROFILE || process.env.HOME || '';
34
- }
35
31
  function prefPath(dir) {
36
32
  return join(dir, 'theme.json');
37
33
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAKlD,OAAO,EAAwB,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEjF,eAAO,MAAM,IAAI,kBAAkB,CAAA;AAEnC,wDAAwD;AACxD,MAAM,MAAM,MAAM,GAAG,eAAe,CAAA;AAUpC,eAAO,MAAM,MAAM,EAAE,WAAW,CAAC,MAAM,CAOrC,CAAA;AAiBF;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,GAAE,MAAW,GAAG,IAAI,CAsC7D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAKlD,OAAO,EAAwB,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEjF,eAAO,MAAM,IAAI,kBAAkB,CAAA;AAEnC,wDAAwD;AACxD,MAAM,MAAM,MAAM,GAAG,eAAe,CAAA;AAUpC,eAAO,MAAM,MAAM,EAAE,WAAW,CAAC,MAAM,CAOrC,CAAA;AAwBF;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,GAAE,MAAW,GAAG,IAAI,CAgE7D"}
@@ -44,6 +44,12 @@ const DEFAULTS = {
44
44
  showClock: true,
45
45
  showTurns: true,
46
46
  };
47
+ /**
48
+ * Backstop delay for the cordis-layer follow decision on hosts without a
49
+ * settings service (see apply). Stays under the host's own 300ms pre-mount
50
+ * settings gate so the pref write still lands before first paint.
51
+ */
52
+ const FOLLOW_FALLBACK_MS = 150;
47
53
  /**
48
54
  * Wire the pink theme plugin.
49
55
  * @param ctx - Cordis context (the plugin's own activation).
@@ -69,18 +75,45 @@ export function apply(ctx, config = {}) {
69
75
  ctx.logger.warn(`dsh-tui-theme: could not install bundled theme "${file}"`);
70
76
  }
71
77
  }
72
- // Background follow runs before the React tree mounts (which reads the
73
- // theme pref), so the cached detection decides this boot.
74
- if (cordis.followSystem) {
75
- runFollowSystem(join(homeDir(), '.dsh-tui'), message => {
76
- ctx.logger.info(`dsh-tui-theme: ${message}`);
77
- });
78
- }
79
78
  // The /settings user layer (settings.yaml) overrides the cordis layer and
80
79
  // lands live through scope.watch; both override the hardcoded defaults.
81
80
  let effective = cordis;
81
+ // Background follow honors the MERGED knob (cordis layer overlaid by the
82
+ // /settings user layer), so the decision cannot be taken synchronously at
83
+ // apply(): the user layer is only readable once the settings service
84
+ // answers. The settings callback still fires before the host's React tree
85
+ // mounts (the host gates its own mount on the same service, probed
86
+ // against 0.9.0), so the pref write decides this boot exactly like a sync
87
+ // write would, and toggling followSystem in /settings re-decides live.
88
+ let followActive;
89
+ const dataDir = join(homeDir(), '.dsh-tui');
90
+ const startFollow = () => {
91
+ runFollowSystem(dataDir, message => {
92
+ ctx.logger.info(`dsh-tui-theme: ${message}`);
93
+ });
94
+ };
82
95
  registerPinkSettings(ctx, cordis, doc => {
83
96
  effective = { ...cordis, ...doc };
97
+ if (effective.followSystem !== followActive) {
98
+ followActive = effective.followSystem;
99
+ if (followActive) {
100
+ startFollow();
101
+ }
102
+ else {
103
+ ctx.logger.info('dsh-tui-theme: follow: disabled, manual /theme choice preserved');
104
+ }
105
+ }
84
106
  });
107
+ // Degradation backstop for hosts that never provide a settings service:
108
+ // the inject callback never fires there, so the cordis-layer decision
109
+ // applies instead. The delay lets any pending service registration (and
110
+ // its callback) land first — it no-ops once followActive is settled, and
111
+ // stays inside the host's own 300ms pre-mount settings gate either way.
112
+ setTimeout(() => {
113
+ if (followActive === undefined && cordis.followSystem) {
114
+ followActive = true;
115
+ startFollow();
116
+ }
117
+ }, FOLLOW_FALLBACK_MS);
85
118
  startStatusLine(ctx, () => effective);
86
119
  }
@@ -1 +1 @@
1
- {"version":3,"file":"settingsSection.d.ts","sourceRoot":"","sources":["../../src/settingsSection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAGlD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAEpD,+EAA+E;AAC/E,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG;IAC5C,sEAAsE;IACtE,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,oEAAoE;IACpE,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAcD;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,GACpC,IAAI,CAuCN"}
1
+ {"version":3,"file":"settingsSection.d.ts","sourceRoot":"","sources":["../../src/settingsSection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAGlD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAEpD,+EAA+E;AAC/E,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG;IAC5C,sEAAsE;IACtE,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,oEAAoE;IACpE,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAcD;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,GACpC,IAAI,CA2CN"}
@@ -46,8 +46,12 @@ export function registerPinkSettings(ctx, cordis, onDoc) {
46
46
  }
47
47
  onDoc(clean);
48
48
  };
49
- emit(scope.get());
50
- scope.watch(emit);
49
+ // Own the watcher on the inject-scoped ledger so it survives exactly as
50
+ // long as this activation (scope.watch's disposer is otherwise leaked).
51
+ settingsCtx.effect(() => {
52
+ emit(scope.get());
53
+ return scope.watch(emit);
54
+ });
51
55
  });
52
56
  ctx.inject(['tuiSettingsSections'], sectionsCtx => {
53
57
  const sections = sectionsCtx
@@ -1 +1 @@
1
- {"version":3,"file":"statusLine.d.ts","sourceRoot":"","sources":["../../src/statusLine.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAKlD,MAAM,WAAW,aAAa;IAC5B,2EAA2E;IAC3E,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,sCAAsC;IACtC,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,+BAA+B;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,0DAA0D;IAC1D,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,mCAAmC;AACnC,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAA;AAoBrD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,GAAG,IAAI,CAoDvF"}
1
+ {"version":3,"file":"statusLine.d.ts","sourceRoot":"","sources":["../../src/statusLine.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAKlD,MAAM,WAAW,aAAa;IAC5B,2EAA2E;IAC3E,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,sCAAsC;IACtC,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,+BAA+B;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,0DAA0D;IAC1D,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,mCAAmC;AACnC,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAA;AAoBrD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,GAAG,IAAI,CAsDvF"}
@@ -38,12 +38,14 @@ export function startStatusLine(ctx, getEffective) {
38
38
  try {
39
39
  const eff = getEffective();
40
40
  const parts = [];
41
- if (eff.showGlyph)
42
- parts.push(GLYPH);
43
- if (eff.showClock)
44
- parts.push(clockText());
45
- if (eff.showTurns && current !== undefined) {
46
- parts.push(`${turns.get(current) ?? 0}✦`);
41
+ if (eff.statusEnabled) {
42
+ if (eff.showGlyph)
43
+ parts.push(GLYPH);
44
+ if (eff.showClock)
45
+ parts.push(clockText());
46
+ if (eff.showTurns && current !== undefined) {
47
+ parts.push(`${turns.get(current) ?? 0}✦`);
48
+ }
47
49
  }
48
50
  const text = parts.join(' · ');
49
51
  // The trailing identity must be the inject-scoped context (the same
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-tui-theme",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Sakura-pink themes for dsh-TUI with terminal-background auto-follow (pink-day/pink-night), a blossom status line, and a /settings section. No shortcuts, no commands.",
5
5
  "type": "module",
6
6
  "main": "lib/types/index.js",
@@ -16,6 +16,7 @@
16
16
  "files": [
17
17
  "lib",
18
18
  "themes",
19
+ "docs",
19
20
  "cordis.patch.yml"
20
21
  ],
21
22
  "engines": {