@deepseek-harness-tui/dsh-tui 0.9.2 → 0.9.3

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.
Files changed (214) hide show
  1. package/README.md +4 -4
  2. package/bin/dsh-tui.js +26 -4
  3. package/dsh-ecosystem-spec/protocols/profile-definitions.d.ts +13 -13
  4. package/dsh-ecosystem-spec/protocols/profile-definitions.js +59 -59
  5. package/dsh-ecosystem-spec/protocols/tui-channel-http.d.ts +15 -15
  6. package/dsh-ecosystem-spec/protocols/tui-channel-http.js +32 -32
  7. package/dsh-ecosystem-spec/protocols/tui-channel.d.ts +59 -59
  8. package/dsh-ecosystem-spec/protocols/tui-channel.js +166 -166
  9. package/dsh-ecosystem-spec/protocols/tui-contributions.d.ts +42 -42
  10. package/dsh-ecosystem-spec/protocols/tui-contributions.js +143 -143
  11. package/dsh-ecosystem-spec/registry/README.md +14 -14
  12. package/dsh-ecosystem-spec/registry/host-descriptor.tui.example.json +56 -56
  13. package/dsh-ecosystem-spec/registry/permissions-0.1.json +13 -13
  14. package/dsh-ecosystem-spec/registry/registry-0.15.json +149 -149
  15. package/lib/types/commands.d.ts.map +1 -1
  16. package/lib/types/commands.js +7 -8
  17. package/lib/types/components/BalanceReportRow.d.ts +24 -0
  18. package/lib/types/components/BalanceReportRow.d.ts.map +1 -0
  19. package/lib/types/components/BalanceReportRow.js +87 -0
  20. package/lib/types/components/HistorySearchDialog.js +1 -1
  21. package/lib/types/components/MessageList.d.ts +3 -1
  22. package/lib/types/components/MessageList.d.ts.map +1 -1
  23. package/lib/types/components/MessageList.js +11 -7
  24. package/lib/types/components/PluginSceneBoundary.d.ts +1 -1
  25. package/lib/types/components/PluginSceneBoundary.js +1 -1
  26. package/lib/types/components/PromptInput.d.ts.map +1 -1
  27. package/lib/types/components/PromptInput.js +16 -0
  28. package/lib/types/components/Whale.d.ts +15 -4
  29. package/lib/types/components/Whale.d.ts.map +1 -1
  30. package/lib/types/components/Whale.js +9 -8
  31. package/lib/types/components/messages/AssistantToolUseMessage.d.ts +7 -1
  32. package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
  33. package/lib/types/components/messages/AssistantToolUseMessage.js +34 -4
  34. package/lib/types/deepseekBalance.d.ts +53 -0
  35. package/lib/types/deepseekBalance.d.ts.map +1 -0
  36. package/lib/types/deepseekBalance.js +86 -0
  37. package/lib/types/deepseekPricing.d.ts +82 -0
  38. package/lib/types/deepseekPricing.d.ts.map +1 -0
  39. package/lib/types/deepseekPricing.js +133 -0
  40. package/lib/types/dsh-adapter/channel.d.ts +46 -1
  41. package/lib/types/dsh-adapter/channel.d.ts.map +1 -1
  42. package/lib/types/dsh-adapter/channel.js +84 -10
  43. package/lib/types/dsh-adapter/index.d.ts +5 -0
  44. package/lib/types/dsh-adapter/index.d.ts.map +1 -1
  45. package/lib/types/dsh-adapter/index.js +1 -0
  46. package/lib/types/dsh-adapter/packaged-skills.d.ts +9 -0
  47. package/lib/types/dsh-adapter/packaged-skills.d.ts.map +1 -1
  48. package/lib/types/dsh-adapter/packaged-skills.js +19 -4
  49. package/lib/types/dsh-adapter/plugin.d.ts +6 -0
  50. package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
  51. package/lib/types/dsh-adapter/plugin.js +122 -18
  52. package/lib/types/dsh-adapter/settings-sections.d.ts +1 -0
  53. package/lib/types/dsh-adapter/settings-sections.d.ts.map +1 -1
  54. package/lib/types/dsh-adapter/settings-sections.js +35 -2
  55. package/lib/types/history.d.ts +4 -3
  56. package/lib/types/history.d.ts.map +1 -1
  57. package/lib/types/history.js +66 -18
  58. package/lib/types/i18n.d.ts +122 -55
  59. package/lib/types/i18n.d.ts.map +1 -1
  60. package/lib/types/i18n.js +39 -18
  61. package/lib/types/ink/ink.d.ts.map +1 -1
  62. package/lib/types/ink/ink.js +67 -17
  63. package/lib/types/ink/root.d.ts +16 -0
  64. package/lib/types/ink/root.d.ts.map +1 -1
  65. package/lib/types/ink/root.js +2 -0
  66. package/lib/types/ink/terminal-querier.d.ts +8 -0
  67. package/lib/types/ink/terminal-querier.d.ts.map +1 -1
  68. package/lib/types/ink/terminal-querier.js +13 -0
  69. package/lib/types/ink/terminal.d.ts +42 -0
  70. package/lib/types/ink/terminal.d.ts.map +1 -1
  71. package/lib/types/ink/terminal.js +52 -2
  72. package/lib/types/plugin-spec/registry.d.ts +1 -1
  73. package/lib/types/plugin-spec/registry.js +1 -1
  74. package/lib/types/screens/Chat.d.ts.map +1 -1
  75. package/lib/types/screens/Chat.js +72 -37
  76. package/lib/types/screens/SessionBrowser.d.ts.map +1 -1
  77. package/lib/types/screens/SessionBrowser.js +28 -13
  78. package/lib/types/screens/SessionTree.d.ts.map +1 -1
  79. package/lib/types/screens/SessionTree.js +33 -9
  80. package/lib/types/screens/Settings.d.ts +7 -5
  81. package/lib/types/screens/Settings.d.ts.map +1 -1
  82. package/lib/types/screens/Settings.js +206 -99
  83. package/lib/types/screens/StatusLine.d.ts.map +1 -1
  84. package/lib/types/screens/StatusLine.js +32 -1
  85. package/lib/types/sessionHistory.d.ts +11 -0
  86. package/lib/types/sessionHistory.d.ts.map +1 -1
  87. package/lib/types/sessionHistory.js +29 -0
  88. package/lib/types/sessions/format.d.ts.map +1 -1
  89. package/lib/types/sessions/format.js +14 -4
  90. package/lib/types/tips.js +2 -2
  91. package/lib/types/tuiDisplayPrefs.d.ts +3 -0
  92. package/lib/types/tuiDisplayPrefs.d.ts.map +1 -1
  93. package/lib/types/tuiDisplayPrefs.js +1 -0
  94. package/lib/types/update.d.ts +46 -0
  95. package/lib/types/update.d.ts.map +1 -1
  96. package/lib/types/update.js +232 -3
  97. package/node_modules/@deepseek-harness-tui/dsh-auth/LICENSE +21 -21
  98. package/node_modules/@deepseek-harness-tui/dsh-auth/dsh-plugin.json +44 -44
  99. package/node_modules/@dsh-std/command/CHANGELOG.md +8 -8
  100. package/node_modules/@dsh-std/command/LICENSE +21 -21
  101. package/node_modules/@dsh-std/command/README.md +26 -26
  102. package/node_modules/@dsh-std/command/README.zh.md +28 -28
  103. package/node_modules/@dsh-std/command/lib/index.js.map +1 -1
  104. package/node_modules/@dsh-std/command/package.json +22 -22
  105. package/node_modules/@dsh-std/connection/CHANGELOG.md +8 -8
  106. package/node_modules/@dsh-std/connection/LICENSE +21 -21
  107. package/node_modules/@dsh-std/connection/README.md +42 -42
  108. package/node_modules/@dsh-std/connection/README.zh.md +42 -42
  109. package/node_modules/@dsh-std/connection/lib/index.js.map +1 -1
  110. package/node_modules/@dsh-std/connection/lib/memory.js.map +1 -1
  111. package/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -1
  112. package/node_modules/@dsh-std/connection/package.json +20 -20
  113. package/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
  114. package/node_modules/@dsh-std/core/LICENSE +21 -21
  115. package/node_modules/@dsh-std/core/README.md +13 -13
  116. package/node_modules/@dsh-std/core/README.zh.md +13 -13
  117. package/node_modules/@dsh-std/core/lib/index.js.map +1 -1
  118. package/node_modules/@dsh-std/core/package.json +21 -21
  119. package/node_modules/@dsh-std/manifest/CHANGELOG.md +9 -9
  120. package/node_modules/@dsh-std/manifest/LICENSE +21 -21
  121. package/node_modules/@dsh-std/manifest/README.md +5 -5
  122. package/node_modules/@dsh-std/manifest/README.zh.md +5 -5
  123. package/node_modules/@dsh-std/manifest/lib/index.js.map +1 -1
  124. package/node_modules/@dsh-std/manifest/package.json +20 -20
  125. package/node_modules/@dsh-std/manifest/schema/dsh-plugin-0.15.schema.json +144 -144
  126. package/node_modules/@dsh-std/messages/CHANGELOG.md +8 -8
  127. package/node_modules/@dsh-std/messages/LICENSE +21 -21
  128. package/node_modules/@dsh-std/messages/README.md +5 -5
  129. package/node_modules/@dsh-std/messages/README.zh.md +7 -7
  130. package/node_modules/@dsh-std/messages/lib/index.js.map +1 -1
  131. package/node_modules/@dsh-std/messages/package.json +20 -20
  132. package/node_modules/@dsh-std/messages/schema/message-observer-envelope-0.15.schema.json +54 -54
  133. package/node_modules/@dsh-std/presentation/CHANGELOG.md +9 -9
  134. package/node_modules/@dsh-std/presentation/LICENSE +21 -21
  135. package/node_modules/@dsh-std/presentation/README.md +27 -27
  136. package/node_modules/@dsh-std/presentation/README.zh.md +29 -29
  137. package/node_modules/@dsh-std/presentation/lib/callback.js.map +1 -1
  138. package/node_modules/@dsh-std/presentation/lib/index.js.map +1 -1
  139. package/node_modules/@dsh-std/presentation/package.json +25 -25
  140. package/node_modules/@dsh-std/storage/CHANGELOG.md +8 -8
  141. package/node_modules/@dsh-std/storage/LICENSE +21 -21
  142. package/node_modules/@dsh-std/storage/README.md +5 -5
  143. package/node_modules/@dsh-std/storage/README.zh.md +7 -7
  144. package/node_modules/@dsh-std/storage/lib/index.js.map +1 -1
  145. package/node_modules/@dsh-std/storage/package.json +20 -20
  146. package/node_modules/@dsh-std/storage/schema/local-storage-0.15.schema.json +56 -56
  147. package/package.json +95 -5
  148. package/skills/pr-comments/SKILL.md +1 -1
  149. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/CHANGELOG.md +8 -8
  150. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/LICENSE +21 -21
  151. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/README.md +42 -42
  152. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/README.zh.md +42 -42
  153. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/index.js.map +1 -1
  154. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.js.map +1 -1
  155. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -1
  156. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/package.json +20 -20
  157. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
  158. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/LICENSE +21 -21
  159. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/README.md +13 -13
  160. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/README.zh.md +13 -13
  161. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/lib/index.js.map +1 -1
  162. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/package.json +21 -21
  163. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/CHANGELOG.md +9 -9
  164. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/LICENSE +21 -21
  165. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/README.md +5 -5
  166. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/README.zh.md +5 -5
  167. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/lib/index.js.map +1 -1
  168. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/package.json +20 -20
  169. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/schema/dsh-plugin-0.15.schema.json +144 -144
  170. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/CHANGELOG.md +9 -9
  171. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/LICENSE +21 -21
  172. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/README.md +27 -27
  173. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/README.zh.md +29 -29
  174. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/callback.js.map +1 -1
  175. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.js.map +1 -1
  176. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/package.json +25 -25
  177. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
  178. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/LICENSE +21 -21
  179. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/README.md +13 -13
  180. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/README.zh.md +13 -13
  181. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/lib/index.js.map +1 -1
  182. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/package.json +21 -21
  183. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
  184. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/LICENSE +21 -21
  185. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/README.md +13 -13
  186. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/README.zh.md +13 -13
  187. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/lib/index.js.map +1 -1
  188. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/package.json +21 -21
  189. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
  190. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/LICENSE +21 -21
  191. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/README.md +13 -13
  192. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/README.zh.md +13 -13
  193. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/lib/index.js.map +1 -1
  194. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/package.json +21 -21
  195. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/CHANGELOG.md +8 -8
  196. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/LICENSE +21 -21
  197. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/README.md +42 -42
  198. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/README.zh.md +42 -42
  199. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/index.js.map +1 -1
  200. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.js.map +1 -1
  201. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -1
  202. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/package.json +20 -20
  203. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
  204. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/LICENSE +21 -21
  205. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/README.md +13 -13
  206. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/README.zh.md +13 -13
  207. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/lib/index.js.map +1 -1
  208. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/package.json +21 -21
  209. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
  210. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/LICENSE +21 -21
  211. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/README.md +13 -13
  212. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/README.zh.md +13 -13
  213. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/lib/index.js.map +1 -1
  214. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/package.json +21 -21
@@ -4,11 +4,14 @@ import { Box, Text, useTerminalSize, useTheme } from '../ui.js';
4
4
  import { formatTokens } from '../cc/format.js';
5
5
  import { t } from '../i18n.js';
6
6
  import { formatContextUsage, DEFAULT_STATUS_BAR, normalizeStatusBar } from '../tuiDisplayPrefs.js';
7
+ import { estimateSessionCostCny, estimateSessionCostSplitCny, isDeepSeekOfficialProvider, isPeakHour } from '../deepseekPricing.js';
7
8
  import { ActivityLine, contextPressurePct } from '../components/ActivityLine.js';
8
9
  import { GoalStatusChip } from '../components/GoalTodoPanel.js';
9
10
  import { modeDisplayName } from '../sessionModes.js';
10
11
  import { MiniWake } from '../components/trajectory/MiniWake.js';
11
12
  import { ContextBarView } from '../components/ContextBarView.js';
13
+ import { formatProject } from '../sessions/format.js';
14
+ import { homeDir } from '../utils/paths.js';
12
15
  import { USED_SEGMENTS, renderMiniContextBar, renderTpsGauge, renderTpsSparkline, speedColor, tpsStats, } from './StatusMetrics.js';
13
16
  /**
14
17
  * Render field parts as sibling shrinkable Boxes joined by the Byline
@@ -36,6 +39,11 @@ export function StatusLine({ channel, selectionActive = false, helpOpen = false,
36
39
  // footer can never grow decorations regardless of saved preferences.
37
40
  ? { ...DEFAULT_STATUS_BAR, compact: true, model: true, cwd: true }
38
41
  : normalizeStatusBar(channel.statusBar);
42
+ // Provider workspaces expose a remote display path alongside a host alias;
43
+ // only the local target has identical cwd/displayCwd values to fold.
44
+ const displayCwd = channel.displayCwd === channel.cwd
45
+ ? formatProject(channel.displayCwd, homeDir())
46
+ : channel.displayCwd;
39
47
  const usage = channel.lastUsage;
40
48
  const contextUsed = usage === undefined
41
49
  ? undefined
@@ -140,6 +148,22 @@ export function StatusLine({ channel, selectionActive = false, helpOpen = false,
140
148
  node: (_jsxs(Text, { color: "inactiveShimmer", children: [formatTokens(channel.tokens.input), "\u2192", formatTokens(channel.tokens.output)] })),
141
149
  }]
142
150
  : []),
151
+ // Estimated session spend (≈¥): only for official DeepSeek providers
152
+ // whose model has a known price, and only once the estimate is non-zero
153
+ // (a fresh session showing ¥0.00 is noise). The trailing 峰/谷 marker
154
+ // shows the current billing window. Hover shows the breakdown.
155
+ ...(statusBar.cost && isDeepSeekOfficialProvider(channel.provider)
156
+ ? (() => {
157
+ const estimate = estimateSessionCostCny(channel.tokens, channel.model);
158
+ return estimate === undefined || estimate <= 0
159
+ ? []
160
+ : [{
161
+ key: 'cost',
162
+ id: 'cost',
163
+ node: (_jsxs(Text, { color: "inactiveShimmer", children: [t('status-cost-label'), "\u00A5", estimate.toFixed(2), " ", t(isPeakHour() ? 'cost-now-peak' : 'cost-now-idle')] })),
164
+ }];
165
+ })()
166
+ : []),
143
167
  ];
144
168
  const rightFields = [
145
169
  // Goal chip first: session-level state outranks repo/location details.
@@ -162,7 +186,7 @@ export function StatusLine({ channel, selectionActive = false, helpOpen = false,
162
186
  ? [{
163
187
  key: 'cwd',
164
188
  id: 'cwd',
165
- node: (_jsx(Text, { color: "inactiveShimmer", children: statusBar.compact ? basename(channel.displayCwd) : channel.displayCwd })),
189
+ node: (_jsx(Text, { color: "inactiveShimmer", children: statusBar.compact ? basename(displayCwd) : displayCwd })),
166
190
  }]
167
191
  : []),
168
192
  ...(statusBar.sessionTitle && channel.sessionTitle
@@ -288,6 +312,13 @@ function buildHoverDetail(hover, channel, usage, contextUsed) {
288
312
  const { input, output } = channel.tokens;
289
313
  return (_jsxs(Text, { wrap: "truncate", children: [dim('in '), input.toLocaleString(), " \u00B7 ", dim('out '), output.toLocaleString(), " \u00B7", ' ', dim('total '), (input + output).toLocaleString()] }));
290
314
  }
315
+ case 'cost': {
316
+ const split = estimateSessionCostSplitCny(channel.tokens, channel.model);
317
+ if (split === undefined)
318
+ return null;
319
+ const { input, output, cacheRead } = channel.tokens;
320
+ return (_jsxs(Text, { wrap: "truncate", children: [dim('≈¥'), split.total.toFixed(2), " \u00B7 ", dim('peak '), "\u00A5", split.peak.toFixed(2), ' · ', dim('idle '), "\u00A5", split.idle.toFixed(2), " \u00B7 ", dim('in '), formatTokens(input), ' · ', dim('out '), formatTokens(output), " \u00B7 ", dim('cache '), formatTokens(cacheRead), ' · ', t('status-cost-note')] }));
321
+ }
291
322
  case 'goal': {
292
323
  const goal = channel.goal;
293
324
  if (goal === undefined)
@@ -12,6 +12,17 @@ export declare function clearResumeTarget(): void;
12
12
  * @returns The stored session id, or undefined when none is set.
13
13
  */
14
14
  export declare function readResumeTarget(): string | undefined;
15
+ /**
16
+ * The session id requested through `--resume`/`-c`/`--continue` in app args,
17
+ * mirroring the standalone bin's interception (issue #120/#53). The
18
+ * `dsh --profile tui` boot path forwards these args to the booted app
19
+ * verbatim and never parses them into DSH_TUI_RESUME_SESSION, so the
20
+ * in-profile plugin reads them itself. A bare flag with no id defers to the
21
+ * exit-time marker, exactly like the bin.
22
+ * @param argv - the app arguments (typically `process.argv.slice(2)`).
23
+ * @returns The requested session id, or undefined when none was given.
24
+ */
25
+ export declare function resumeTargetFromArgv(argv: readonly string[]): string | undefined;
15
26
  /**
16
27
  * Session-id → last-used epoch ms map for MRU ordering.
17
28
  * @returns The parsed map; best effort, an unreadable file yields {}.
@@ -1 +1 @@
1
- {"version":3,"file":"sessionHistory.d.ts","sourceRoot":"","sources":["../../src/sessionHistory.ts"],"names":[],"mappings":"AA6BA;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CASzD;AAED,qEAAqE;AACrE,wBAAgB,iBAAiB,IAAI,IAAI,CAQxC;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAUrD;AAED;;;GAGG;AACH,wBAAgB,YAAY,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAiB/D;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAQpD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAUrD"}
1
+ {"version":3,"file":"sessionHistory.d.ts","sourceRoot":"","sources":["../../src/sessionHistory.ts"],"names":[],"mappings":"AA6BA;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CASzD;AAED,qEAAqE;AACrE,wBAAgB,iBAAiB,IAAI,IAAI,CAQxC;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAUrD;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAehF;AAED;;;GAGG;AACH,wBAAgB,YAAY,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAiB/D;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAQpD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAUrD"}
@@ -69,6 +69,35 @@ export function readResumeTarget() {
69
69
  }
70
70
  return undefined;
71
71
  }
72
+ /**
73
+ * The session id requested through `--resume`/`-c`/`--continue` in app args,
74
+ * mirroring the standalone bin's interception (issue #120/#53). The
75
+ * `dsh --profile tui` boot path forwards these args to the booted app
76
+ * verbatim and never parses them into DSH_TUI_RESUME_SESSION, so the
77
+ * in-profile plugin reads them itself. A bare flag with no id defers to the
78
+ * exit-time marker, exactly like the bin.
79
+ * @param argv - the app arguments (typically `process.argv.slice(2)`).
80
+ * @returns The requested session id, or undefined when none was given.
81
+ */
82
+ export function resumeTargetFromArgv(argv) {
83
+ for (let i = 0; i < argv.length; i++) {
84
+ const a = argv[i];
85
+ if (a === '--resume' || a === '-c' || a === '--continue' || a.startsWith('--resume=')) {
86
+ let sessionId = '';
87
+ if (a.startsWith('--resume=')) {
88
+ sessionId = a.slice('--resume='.length).trim();
89
+ }
90
+ else if (a === '--resume' && argv[i + 1] !== undefined && !argv[i + 1].startsWith('-')) {
91
+ sessionId = argv[++i].trim();
92
+ }
93
+ if (!sessionId)
94
+ sessionId = readResumeTarget() ?? '';
95
+ if (sessionId)
96
+ return sessionId;
97
+ }
98
+ }
99
+ return undefined;
100
+ }
72
101
  /**
73
102
  * Session-id → last-used epoch ms map for MRU ordering.
74
103
  * @returns The parsed map; best effort, an unreadable file yields {}.
@@ -1 +1 @@
1
- {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/sessions/format.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAChF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAExC;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,IA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;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CA4B/D;AAED,mEAAmE;AACnE,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAInD;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,KAAK,CAK7E;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAkB/D"}
@@ -235,10 +235,20 @@ export function titleColor(source, focused) {
235
235
  export function formatProject(cwd, home) {
236
236
  if (cwd.length === 0)
237
237
  return t('session-project-unknown');
238
- const normalized = cwd.replace(/\\/g, '/');
239
- const base = home.replace(/\\/g, '/').replace(/\/$/, '');
240
- if (base.length > 0 && (normalized === base || normalized.startsWith(`${base}/`))) {
241
- return `~${normalized.slice(base.length)}`;
238
+ const normalize = (value) => {
239
+ const normalized = value.replace(/\\/g, '/');
240
+ return normalized.length > 1 ? normalized.replace(/\/+$/, '') : normalized;
241
+ };
242
+ const normalized = normalize(cwd);
243
+ const base = normalize(home);
244
+ const comparableCwd = process.platform === 'win32' ? normalized.toLowerCase() : normalized;
245
+ const comparableBase = process.platform === 'win32' ? base.toLowerCase() : base;
246
+ const isBelowHome = comparableBase === '/'
247
+ ? comparableCwd.startsWith('/')
248
+ : comparableCwd.startsWith(`${comparableBase}/`);
249
+ if (base.length > 0 && (comparableCwd === comparableBase || isBelowHome)) {
250
+ const suffix = normalized.slice(base.length);
251
+ return suffix.length === 0 ? '~' : `~${suffix.startsWith('/') ? suffix : `/${suffix}`}`;
242
252
  }
243
253
  return normalized;
244
254
  }
package/lib/types/tips.js CHANGED
@@ -558,8 +558,8 @@ export const TIPS = [
558
558
  {
559
559
  id: 'pit-ctrl-c',
560
560
  group: 'pitfalls',
561
- zh: 'Ctrl+C 有输入时先清空,连按两次才退出',
562
- en: 'Ctrl+C clears input first; double-tap to exit',
561
+ zh: 'Ctrl+C 工作时先中断;中断卡住再按强制退出;空闲连按两次退出',
562
+ en: 'Ctrl+C interrupts while working; press again if the interrupt stalls to force-exit; double-tap when idle',
563
563
  },
564
564
  {
565
565
  id: 'pit-unknown-cmd',
@@ -25,6 +25,9 @@ export interface StatusBarConfig {
25
25
  cache: boolean;
26
26
  /** Running input/output token totals. */
27
27
  tokens: boolean;
28
+ /** Estimated session spend (≈¥, DeepSeek official pricing — only shown
29
+ * for official DeepSeek providers whose model has a known price). */
30
+ cost: boolean;
28
31
  /** Live and recent output speed. */
29
32
  tps: boolean;
30
33
  /** Current git branch. */
@@ -1 +1 @@
1
- {"version":3,"file":"tuiDisplayPrefs.d.ts","sourceRoot":"","sources":["../../src/tuiDisplayPrefs.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAEzD;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,WAAW,GAAG,QAAQ,CAAA;AAElE,2DAA2D;AAC3D,MAAM,WAAW,eAAe;IAC9B,uEAAuE;IACvE,OAAO,EAAE,OAAO,CAAA;IAChB,qBAAqB;IACrB,KAAK,EAAE,OAAO,CAAA;IACd,wCAAwC;IACxC,QAAQ,EAAE,OAAO,CAAA;IACjB,iCAAiC;IACjC,GAAG,EAAE,OAAO,CAAA;IACZ,0CAA0C;IAC1C,YAAY,EAAE,OAAO,CAAA;IACrB,6BAA6B;IAC7B,KAAK,EAAE,OAAO,CAAA;IACd,yCAAyC;IACzC,MAAM,EAAE,OAAO,CAAA;IACf,oCAAoC;IACpC,GAAG,EAAE,OAAO,CAAA;IACZ,0BAA0B;IAC1B,SAAS,EAAE,OAAO,CAAA;IAClB,6BAA6B;IAC7B,YAAY,EAAE,OAAO,CAAA;IACrB,+EAA+E;IAC/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+ cost: true,
10
11
  tps: false,
11
12
  gitBranch: false,
12
13
  sessionTitle: false,
@@ -17,6 +17,8 @@ export declare function writeHandoffNotice(text: string): void;
17
17
  export interface TuiUpdateInfo {
18
18
  current: string;
19
19
  latest: string;
20
+ isStandalone?: boolean;
21
+ downloadUrl?: string;
20
22
  }
21
23
  /** What a fresh registry lookup says about this install. */
22
24
  export type TuiUpdateTarget = {
@@ -24,11 +26,15 @@ export type TuiUpdateTarget = {
24
26
  current: string;
25
27
  latest: string;
26
28
  authoritative?: string;
29
+ isStandalone?: boolean;
30
+ downloadUrl?: string;
27
31
  } | {
28
32
  kind: 'latest';
29
33
  current: string;
34
+ isStandalone?: boolean;
30
35
  } | {
31
36
  kind: 'unknown';
37
+ isStandalone?: boolean;
32
38
  };
33
39
  export interface TuiUpdateResult {
34
40
  /** Exit code of the `dsh plugin update` run (0 = the package was updated). */
@@ -69,6 +75,46 @@ export declare function isVersionNewer(current: string, previous: string): boole
69
75
  * @returns true for the known boot-deadlock version range.
70
76
  */
71
77
  export declare function isBootDeadlockTarget(version: string): boolean;
78
+ /**
79
+ * Detect whether the current process is running in standalone / portable package mode.
80
+ *
81
+ * @returns `true` when running inside a standalone binary distribution, `false` otherwise.
82
+ */
83
+ export declare function isStandaloneRuntime(): boolean;
84
+ /**
85
+ * Get the path to the current standalone executable binary.
86
+ *
87
+ * @returns The resolved executable path from environment or `process.execPath`.
88
+ */
89
+ export declare function getStandaloneBinaryPath(): string;
90
+ /**
91
+ * Get the expected release asset file name for the current platform and architecture.
92
+ *
93
+ * @param platform - Node.js platform identifier (e.g. `'linux'`, `'win32'`, `'darwin'`).
94
+ * @param arch - Node.js architecture identifier (e.g. `'x64'`, `'arm64'`).
95
+ * @returns The archive file name matching the target platform.
96
+ */
97
+ export declare function getStandaloneAssetName(platform?: NodeJS.Platform, arch?: NodeJS.Architecture): string;
98
+ /**
99
+ * Fetch latest release info from GitHub Releases API for the standalone asset.
100
+ *
101
+ * @returns Release version tag and matching asset download URL, or `undefined` on any failure.
102
+ */
103
+ export declare function fetchGithubLatestRelease(): Promise<{
104
+ version: string;
105
+ downloadUrl?: string;
106
+ } | undefined>;
107
+ /**
108
+ * Download the new standalone release binary package and atomically replace the running binary.
109
+ *
110
+ * @param downloadUrl - Direct URL to download the release archive.
111
+ * @param onProgress - Optional callback invoked with progress status strings.
112
+ * @returns Object indicating success or an error message on failure.
113
+ */
114
+ export declare function downloadAndReplaceStandaloneBinary(downloadUrl: string, onProgress?: (text: string) => void): Promise<{
115
+ success: boolean;
116
+ error?: string;
117
+ }>;
72
118
  /**
73
119
  * Classify this install against a fresh registry lookup: an update is
74
120
  * available, the install is already latest, or the answer is unknown
@@ -1 +1 @@
1
- {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/update.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAKlD,OAAO,EAAE,UAAU,EAAE,CAAA;AAmCrB;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAEnF;AAED,0EAA0E;AAC1E,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAc3D;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAMrD;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;CACf;AAED,4DAA4D;AAC5D,MAAM,MAAM,eAAe,GACvB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3E;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC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AAW,gBAAgB;IAC/B,wEAAwE;IACxE,IAAI,EAAE,MAAM,CAAA;IACZ,gEAAgE;IAChE,WAAW,EAAE,MAAM,CAAA;IACnB,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,SAAS,CAC7B,OAAO,EAAE,MAAM,EACf,aAAa,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,gBAAgB,CAAC,CAyH3B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,aAAa,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,eAAe,CAAC,CAiB1B;AAED;;;;;;;;GAQG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA0DhE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,WAAW,iBAAiB;IAChC,uEAAuE;IACvE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC5B;;;;OAIG;IACH,IAAI,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;CAC5B;AAED,wBAAsB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC,CA8HpG"}
@@ -1,5 +1,5 @@
1
- import { spawn } from 'node:child_process';
2
- import { appendFileSync, lstatSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';
1
+ import { execFileSync, spawn } from 'node:child_process';
2
+ import { appendFileSync, chmodSync, copyFileSync, existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';
3
3
  import { homedir } from 'node:os';
4
4
  import { dirname, join, resolve } from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
@@ -11,7 +11,9 @@ import { DATA_DIR } from './utils/paths.js';
11
11
  export { shellQuote };
12
12
  const PACKAGE_NAME = '@deepseek-harness-tui/dsh-tui';
13
13
  const DEFAULT_REGISTRY = 'https://registry.npmjs.org';
14
+ const GITHUB_REPO = 'ccch1mneyyy/dsh-TUI';
14
15
  const UPDATE_CHECK_TIMEOUT_MS = 4000;
16
+ const STANDALONE_DOWNLOAD_TIMEOUT_MS = 300000;
15
17
  /** env marker set on the /update restart; the new process verifies it at boot. */
16
18
  const UPDATED_FROM_ENV = 'DSH_TUI_UPDATED_FROM';
17
19
  /**
@@ -189,6 +191,189 @@ async function fetchLatestVersion(registryBase) {
189
191
  clearTimeout(timeout);
190
192
  }
191
193
  }
194
+ /**
195
+ * Detect whether the current process is running in standalone / portable package mode.
196
+ *
197
+ * @returns `true` when running inside a standalone binary distribution, `false` otherwise.
198
+ */
199
+ export function isStandaloneRuntime() {
200
+ return (process.env.DSH_TUI_STANDALONE === '1' ||
201
+ process.env.DSH_TUI_STANDALONE_BINARY !== undefined ||
202
+ (typeof process.env.DSH_HOME === 'string' && process.env.DSH_HOME.includes('dsh-tui-standalone')));
203
+ }
204
+ /**
205
+ * Get the path to the current standalone executable binary.
206
+ *
207
+ * @returns The resolved executable path from environment or `process.execPath`.
208
+ */
209
+ export function getStandaloneBinaryPath() {
210
+ return process.env.DSH_TUI_STANDALONE_BINARY ?? process.execPath;
211
+ }
212
+ /**
213
+ * Get the expected release asset file name for the current platform and architecture.
214
+ *
215
+ * @param platform - Node.js platform identifier (e.g. `'linux'`, `'win32'`, `'darwin'`).
216
+ * @param arch - Node.js architecture identifier (e.g. `'x64'`, `'arm64'`).
217
+ * @returns The archive file name matching the target platform.
218
+ */
219
+ export function getStandaloneAssetName(platform = process.platform, arch = process.arch) {
220
+ if (platform === 'win32') {
221
+ return 'dsh-tui-standalone-win-x64.zip';
222
+ }
223
+ if (platform === 'darwin') {
224
+ return arch === 'arm64'
225
+ ? 'dsh-tui-standalone-darwin-arm64.tar.gz'
226
+ : 'dsh-tui-standalone-darwin-x64.tar.gz';
227
+ }
228
+ return arch === 'arm64'
229
+ ? 'dsh-tui-standalone-linux-arm64.tar.gz'
230
+ : 'dsh-tui-standalone-linux-x64.tar.gz';
231
+ }
232
+ /**
233
+ * Fetch latest release info from GitHub Releases API for the standalone asset.
234
+ *
235
+ * @returns Release version tag and matching asset download URL, or `undefined` on any failure.
236
+ */
237
+ export async function fetchGithubLatestRelease() {
238
+ const controller = new AbortController();
239
+ const timeout = setTimeout(() => controller.abort(), UPDATE_CHECK_TIMEOUT_MS);
240
+ try {
241
+ const response = await fetch(`https://api.github.com/repos/${GITHUB_REPO}/releases/latest`, {
242
+ headers: { accept: 'application/vnd.github.v3+json', 'user-agent': 'dsh-tui-updater' },
243
+ signal: controller.signal,
244
+ });
245
+ if (!response.ok)
246
+ return undefined;
247
+ const payload = await response.json();
248
+ if (!isRecord(payload) || typeof payload.tag_name !== 'string')
249
+ return undefined;
250
+ const rawTag = payload.tag_name.replace(/^v/, '');
251
+ const version = valid(rawTag);
252
+ if (version === null)
253
+ return undefined;
254
+ const assetName = getStandaloneAssetName();
255
+ let downloadUrl;
256
+ if (Array.isArray(payload.assets)) {
257
+ const asset = payload.assets.find((a) => isRecord(a) && a.name === assetName && typeof a.browser_download_url === 'string');
258
+ if (asset !== undefined && typeof asset.browser_download_url === 'string') {
259
+ downloadUrl = asset.browser_download_url;
260
+ }
261
+ }
262
+ if (downloadUrl === undefined) {
263
+ downloadUrl = `https://github.com/${GITHUB_REPO}/releases/download/v${version}/${assetName}`;
264
+ }
265
+ return { version, downloadUrl };
266
+ }
267
+ catch {
268
+ return undefined;
269
+ }
270
+ finally {
271
+ clearTimeout(timeout);
272
+ }
273
+ }
274
+ /**
275
+ * Download the new standalone release binary package and atomically replace the running binary.
276
+ *
277
+ * @param downloadUrl - Direct URL to download the release archive.
278
+ * @param onProgress - Optional callback invoked with progress status strings.
279
+ * @returns Object indicating success or an error message on failure.
280
+ */
281
+ export async function downloadAndReplaceStandaloneBinary(downloadUrl, onProgress) {
282
+ const tempDir = join(process.env.DSH_TUI_STANDALONE_CACHE ?? join(homedir(), '.cache', 'dsh-tui-standalone'), `.update-${Date.now()}-${process.pid}`);
283
+ try {
284
+ const currentBinary = getStandaloneBinaryPath();
285
+ const targetDir = dirname(currentBinary);
286
+ const assetName = getStandaloneAssetName();
287
+ const isZip = assetName.endsWith('.zip');
288
+ mkdirSync(tempDir, { recursive: true });
289
+ const downloadPath = join(tempDir, assetName);
290
+ onProgress?.(`downloading: ${downloadUrl}`);
291
+ const controller = new AbortController();
292
+ const timeout = setTimeout(() => controller.abort(), STANDALONE_DOWNLOAD_TIMEOUT_MS);
293
+ let response;
294
+ try {
295
+ response = await fetch(downloadUrl, {
296
+ headers: { 'user-agent': 'dsh-tui-updater' },
297
+ redirect: 'follow',
298
+ signal: controller.signal,
299
+ });
300
+ }
301
+ finally {
302
+ clearTimeout(timeout);
303
+ }
304
+ if (!response.ok) {
305
+ throw new Error(`HTTP ${response.status} ${response.statusText}`);
306
+ }
307
+ const buffer = Buffer.from(await response.arrayBuffer());
308
+ writeFileSync(downloadPath, buffer);
309
+ onProgress?.('extracting…');
310
+ const extractDir = join(tempDir, 'extracted');
311
+ mkdirSync(extractDir, { recursive: true });
312
+ if (isZip) {
313
+ if (process.platform === 'win32') {
314
+ execFileSync('powershell', [
315
+ '-NoProfile', '-Command',
316
+ `Expand-Archive -Path '${downloadPath}' -DestinationPath '${extractDir}' -Force`,
317
+ ]);
318
+ }
319
+ else {
320
+ execFileSync('unzip', ['-o', downloadPath, '-d', extractDir]);
321
+ }
322
+ }
323
+ else {
324
+ execFileSync('tar', ['-xzf', downloadPath, '-C', extractDir]);
325
+ }
326
+ const binaryName = process.platform === 'win32' ? 'dsh-tui.exe' : 'dsh-tui';
327
+ const newBinaryPath = join(extractDir, binaryName);
328
+ if (!existsSync(newBinaryPath)) {
329
+ throw new Error('No executable binary found in release archive');
330
+ }
331
+ onProgress?.('replacing binary…');
332
+ if (process.platform !== 'win32') {
333
+ try {
334
+ chmodSync(newBinaryPath, 0o755);
335
+ }
336
+ catch { }
337
+ }
338
+ if (process.platform === 'win32') {
339
+ const oldBinary = `${currentBinary}.old`;
340
+ try {
341
+ rmSync(oldBinary, { force: true });
342
+ }
343
+ catch { }
344
+ renameSync(currentBinary, oldBinary);
345
+ try {
346
+ copyFileSync(newBinaryPath, currentBinary);
347
+ }
348
+ catch (copyError) {
349
+ // Restore the original executable if copying the new binary failed.
350
+ try {
351
+ renameSync(oldBinary, currentBinary);
352
+ }
353
+ catch { }
354
+ throw copyError;
355
+ }
356
+ }
357
+ else {
358
+ const stagedTarget = join(targetDir, `.dsh-tui-new-${process.pid}`);
359
+ copyFileSync(newBinaryPath, stagedTarget);
360
+ chmodSync(stagedTarget, 0o755);
361
+ renameSync(stagedTarget, currentBinary);
362
+ }
363
+ try {
364
+ rmSync(tempDir, { recursive: true, force: true });
365
+ }
366
+ catch { }
367
+ return { success: true };
368
+ }
369
+ catch (error) {
370
+ try {
371
+ rmSync(tempDir, { recursive: true, force: true });
372
+ }
373
+ catch { }
374
+ return { success: false, error: error instanceof Error ? error.message : String(error) };
375
+ }
376
+ }
192
377
  /**
193
378
  * Classify this install against a fresh registry lookup: an update is
194
379
  * available, the install is already latest, or the answer is unknown
@@ -207,6 +392,16 @@ export async function resolveTuiUpdateTarget() {
207
392
  const currentVersion = current === undefined ? null : valid(current);
208
393
  if (currentVersion === null)
209
394
  return { kind: 'unknown' };
395
+ if (isStandaloneRuntime()) {
396
+ const ghRelease = await fetchGithubLatestRelease();
397
+ const latest = ghRelease?.version ?? (await fetchLatestVersion(resolveRegistryBase()));
398
+ if (latest === undefined)
399
+ return { kind: 'unknown' };
400
+ if (!gt(latest, currentVersion))
401
+ return { kind: 'latest', current: currentVersion, isStandalone: true };
402
+ const downloadUrl = ghRelease?.downloadUrl ?? `https://github.com/${GITHUB_REPO}/releases/download/v${latest}/${getStandaloneAssetName()}`;
403
+ return { kind: 'update', current: currentVersion, latest, isStandalone: true, downloadUrl };
404
+ }
210
405
  const registryBase = resolveRegistryBase();
211
406
  const [latest, official] = await Promise.all([
212
407
  fetchLatestVersion(registryBase),
@@ -226,7 +421,9 @@ export async function resolveTuiUpdateTarget() {
226
421
  */
227
422
  export async function checkForTuiUpdate() {
228
423
  const target = await resolveTuiUpdateTarget();
229
- return target.kind === 'update' ? { current: target.current, latest: target.latest } : undefined;
424
+ return target.kind === 'update'
425
+ ? { current: target.current, latest: target.latest, isStandalone: target.isStandalone, downloadUrl: target.downloadUrl }
426
+ : undefined;
230
427
  }
231
428
  /**
232
429
  * Run a child process with its output attached to the user's terminal. The
@@ -552,6 +749,26 @@ export async function updateTui(profile, targetVersion) {
552
749
  // process then compares new-vs-new and false-alarms "version did not
553
750
  // advance" on every successful update (issue #307's screenshots).
554
751
  const updatedFrom = installedTuiVersion() ?? '';
752
+ if (isStandaloneRuntime()) {
753
+ const target = await resolveTuiUpdateTarget();
754
+ const latestVersion = targetVersion ?? (target.kind === 'update' ? target.latest : undefined);
755
+ const downloadUrl = (target.kind === 'update' && target.downloadUrl)
756
+ ? target.downloadUrl
757
+ : (latestVersion ? `https://github.com/${GITHUB_REPO}/releases/download/v${latestVersion}/${getStandaloneAssetName()}` : undefined);
758
+ if (downloadUrl === undefined || latestVersion === undefined) {
759
+ process.stderr.write('dsh-tui: 无法解析便携包更新下载地址\n');
760
+ return { code: 1, updatedFrom };
761
+ }
762
+ process.stderr.write(`dsh-tui: 正在更新便携包 (${updatedFrom || 'current'} → ${latestVersion})…\n`);
763
+ const result = await downloadAndReplaceStandaloneBinary(downloadUrl, msg => {
764
+ process.stderr.write(`dsh-tui: ${msg}\n`);
765
+ });
766
+ if (!result.success) {
767
+ process.stderr.write(`dsh-tui: 便携包更新失败: ${result.error ?? '未知错误'}\n`);
768
+ return { code: 1, updatedFrom };
769
+ }
770
+ return { code: 0, updatedFrom, installed: latestVersion };
771
+ }
555
772
  const dsh = process.platform === 'win32' ? 'dsh.cmd' : 'dsh';
556
773
  const updateArgs = tuiUpdatePluginArgs(profile, targetVersion);
557
774
  // pnpm ≥11 hard-fails installs whose dependency tree carries un-allowlisted
@@ -683,6 +900,18 @@ export async function cliUpdate(profile) {
683
900
  process.stdout.write(`dsh-tui: already the latest version (${target.current}).\n`);
684
901
  return 0;
685
902
  }
903
+ if (isStandaloneRuntime()) {
904
+ if (target.kind === 'update') {
905
+ process.stdout.write(`dsh-tui: updating standalone binary ${target.current} → ${target.latest}…\n`);
906
+ const outcome = await updateTui(profile, target.latest);
907
+ if (outcome.code === 0) {
908
+ process.stdout.write(`dsh-tui: standalone binary updated successfully (${outcome.updatedFrom || target.current} → ${outcome.installed}).\n`);
909
+ }
910
+ return outcome.code;
911
+ }
912
+ process.stderr.write('dsh-tui: version check failed (offline or unreachable registry).\n');
913
+ return 1;
914
+ }
686
915
  let targetVersion;
687
916
  if (target.kind === 'update') {
688
917
  // Mirror the /update flow exactly: refuse the 0.7.0–0.7.1 hard-inject
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 ccch1mneyyy
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ccch1mneyyy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.