@toddzheng024/dscode-bundle 0.7.12 → 0.7.14

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 (167) hide show
  1. package/THIRD_PARTY_NOTICES.md +3 -3
  2. package/cordis.patch.yml +6 -2
  3. package/package.json +7 -5
  4. package/plugins/code-review/index.mjs +5 -2
  5. package/plugins/compaction/threshold.mjs +12 -0
  6. package/plugins/credentials/index.mjs +13 -0
  7. package/plugins/grok/adapter.mjs +114 -0
  8. package/plugins/grok/auth.mjs +76 -0
  9. package/plugins/grok/billing.mjs +146 -0
  10. package/plugins/grok/index.mjs +118 -0
  11. package/plugins/grok/models.mjs +129 -0
  12. package/plugins/grok/status.mjs +28 -0
  13. package/plugins/grok/wire.mjs +268 -0
  14. package/plugins/i18n/messages.mjs +6 -6
  15. package/plugins/providers/catalog.mjs +2 -0
  16. package/plugins/session-metrics/view.mjs +34 -3
  17. package/vendor/compaction-basic/index.js +91 -1
  18. package/vendor/persistent/index.js +10 -9
  19. package/vendor/terminal/index.js +5 -0
  20. package/vendor/tui/lib/app.mjs +6711 -0
  21. package/vendor/tui/lib/approval.mjs +122 -0
  22. package/vendor/tui/lib/attachments.mjs +218 -0
  23. package/vendor/tui/lib/authorization-panel.mjs +242 -0
  24. package/vendor/tui/lib/authorization.mjs +111 -0
  25. package/vendor/tui/lib/commands.mjs +123 -0
  26. package/vendor/tui/lib/dscode/chat.mjs +84 -0
  27. package/vendor/tui/lib/dscode/flags.mjs +32 -0
  28. package/vendor/tui/lib/dscode/model-search.mjs +68 -0
  29. package/vendor/tui/lib/dscode/paste.mjs +87 -0
  30. package/vendor/tui/lib/dscode/telemetry.mjs +82 -0
  31. package/vendor/tui/lib/dscode/welcome.mjs +100 -0
  32. package/vendor/tui/lib/editor-keys.mjs +346 -0
  33. package/vendor/tui/lib/editor.mjs +50 -0
  34. package/vendor/tui/lib/fork.mjs +24 -0
  35. package/vendor/tui/lib/git-workflow.mjs +278 -0
  36. package/vendor/tui/{types/history.d.ts → lib/history.mjs} +69 -26
  37. package/vendor/tui/{types/i18n.d.ts → lib/i18n.mjs} +23 -15
  38. package/vendor/tui/lib/index.mjs +2200 -0
  39. package/vendor/tui/lib/input-split.mjs +170 -0
  40. package/vendor/tui/lib/internals.mjs +90 -0
  41. package/vendor/tui/lib/invariant.mjs +22 -0
  42. package/vendor/tui/lib/kernel-panels.mjs +1265 -0
  43. package/vendor/tui/lib/keyboard.mjs +283 -0
  44. package/vendor/tui/lib/language-panel.mjs +41 -0
  45. package/vendor/tui/lib/locales/en.mjs +495 -0
  46. package/vendor/tui/lib/locales/zh.mjs +495 -0
  47. package/vendor/tui/lib/mentions.mjs +150 -0
  48. package/vendor/tui/lib/model-capabilities.mjs +245 -0
  49. package/vendor/tui/lib/models.mjs +215 -0
  50. package/vendor/tui/{types/panel-accent.d.ts → lib/panel-accent.mjs} +11 -7
  51. package/vendor/tui/lib/permissions.mjs +45 -0
  52. package/vendor/tui/lib/plugin-inventory.mjs +27 -0
  53. package/vendor/tui/lib/presets.mjs +46 -0
  54. package/vendor/tui/lib/provider-settings.mjs +600 -0
  55. package/vendor/tui/lib/questions.mjs +116 -0
  56. package/vendor/tui/lib/rainbow.mjs +181 -0
  57. package/vendor/tui/lib/render/animations.mjs +665 -0
  58. package/vendor/tui/lib/render/editor.mjs +437 -0
  59. package/vendor/tui/lib/render/export.mjs +119 -0
  60. package/vendor/tui/lib/render/fuzzy.mjs +79 -0
  61. package/vendor/tui/lib/render/ime-cursor.mjs +135 -0
  62. package/vendor/tui/lib/render/inspector.mjs +93 -0
  63. package/vendor/tui/lib/render/lines.mjs +538 -0
  64. package/vendor/tui/lib/render/markdown.mjs +592 -0
  65. package/vendor/tui/lib/render/projection.mjs +1864 -0
  66. package/vendor/tui/lib/render/status.mjs +591 -0
  67. package/vendor/tui/lib/render/text.mjs +157 -0
  68. package/vendor/tui/lib/render/tool-detail.mjs +187 -0
  69. package/vendor/tui/lib/render/tool-preview.mjs +79 -0
  70. package/vendor/tui/lib/render/usage.mjs +336 -0
  71. package/vendor/tui/lib/render/width.mjs +191 -0
  72. package/vendor/tui/lib/session-directory.mjs +329 -0
  73. package/vendor/tui/lib/session-query.mjs +184 -0
  74. package/vendor/tui/lib/session-switch.mjs +51 -0
  75. package/vendor/tui/lib/settings-file.mjs +75 -0
  76. package/vendor/tui/lib/skills.mjs +119 -0
  77. package/vendor/tui/lib/startup.mjs +111 -0
  78. package/vendor/tui/lib/store.mjs +129 -0
  79. package/vendor/tui/lib/subagents.mjs +200 -0
  80. package/vendor/tui/lib/terminal-title.mjs +186 -0
  81. package/vendor/tui/lib/theme-panel.mjs +60 -0
  82. package/vendor/tui/lib/theme.mjs +379 -0
  83. package/vendor/tui/lib/update-panel.mjs +239 -0
  84. package/vendor/tui/lib/update.mjs +101 -0
  85. package/vendor/tui/lib/version.mjs +105 -0
  86. package/vendor/tui/lib/whale-glyph.mjs +20 -0
  87. package/vendor/tui/LICENSE +0 -21
  88. package/vendor/tui/devtools-CdTl3MNy.mjs +0 -3643
  89. package/vendor/tui/dscode-email/cli.mjs +0 -32
  90. package/vendor/tui/dscode-email/contacts.mjs +0 -36
  91. package/vendor/tui/dscode-email/gmail-oauth.mjs +0 -69
  92. package/vendor/tui/dscode-email/gmail-store.mjs +0 -2
  93. package/vendor/tui/dscode-email/gmail.mjs +0 -194
  94. package/vendor/tui/dscode-email/imap.mjs +0 -136
  95. package/vendor/tui/dscode-email/inbox.d.mts +0 -25
  96. package/vendor/tui/dscode-email/inbox.mjs +0 -76
  97. package/vendor/tui/dscode-email/smtp.mjs +0 -69
  98. package/vendor/tui/dscode-email/store.mjs +0 -32
  99. package/vendor/tui/dscode-providers/catalog.mjs +0 -136
  100. package/vendor/tui/dscode-providers/effort.mjs +0 -35
  101. package/vendor/tui/dscode-providers/openrouter-account.mjs +0 -171
  102. package/vendor/tui/index.mjs +0 -44441
  103. package/vendor/tui/invariant.mjs +0 -21
  104. package/vendor/tui/rolldown-runtime-CMFfr-1z.mjs +0 -26
  105. package/vendor/tui/session-query.mjs +0 -150
  106. package/vendor/tui/startup.mjs +0 -109
  107. package/vendor/tui/theme-7u5Qo3dF.mjs +0 -1265
  108. package/vendor/tui/types/app.d.ts +0 -348
  109. package/vendor/tui/types/approval.d.ts +0 -59
  110. package/vendor/tui/types/attachments.d.ts +0 -52
  111. package/vendor/tui/types/authorization-panel.d.ts +0 -22
  112. package/vendor/tui/types/authorization.d.ts +0 -36
  113. package/vendor/tui/types/commands.d.ts +0 -52
  114. package/vendor/tui/types/editor-keys.d.ts +0 -105
  115. package/vendor/tui/types/editor.d.ts +0 -6
  116. package/vendor/tui/types/fork.d.ts +0 -8
  117. package/vendor/tui/types/git-workflow.d.ts +0 -121
  118. package/vendor/tui/types/index.d.ts +0 -223
  119. package/vendor/tui/types/input-split.d.ts +0 -54
  120. package/vendor/tui/types/internals.d.ts +0 -26
  121. package/vendor/tui/types/invariant.d.ts +0 -15
  122. package/vendor/tui/types/kernel-panels.d.ts +0 -245
  123. package/vendor/tui/types/keyboard.d.ts +0 -80
  124. package/vendor/tui/types/language-panel.d.ts +0 -12
  125. package/vendor/tui/types/locales/en.d.ts +0 -450
  126. package/vendor/tui/types/locales/zh.d.ts +0 -9
  127. package/vendor/tui/types/mentions.d.ts +0 -85
  128. package/vendor/tui/types/model-capabilities.d.ts +0 -82
  129. package/vendor/tui/types/models.d.ts +0 -133
  130. package/vendor/tui/types/permissions.d.ts +0 -27
  131. package/vendor/tui/types/plugin-inventory.d.ts +0 -11
  132. package/vendor/tui/types/presets.d.ts +0 -22
  133. package/vendor/tui/types/provider-settings.d.ts +0 -239
  134. package/vendor/tui/types/questions.d.ts +0 -54
  135. package/vendor/tui/types/rainbow.d.ts +0 -69
  136. package/vendor/tui/types/render/animations.d.ts +0 -307
  137. package/vendor/tui/types/render/editor.d.ts +0 -163
  138. package/vendor/tui/types/render/export.d.ts +0 -9
  139. package/vendor/tui/types/render/fuzzy.d.ts +0 -21
  140. package/vendor/tui/types/render/ime-cursor.d.ts +0 -60
  141. package/vendor/tui/types/render/inspector.d.ts +0 -62
  142. package/vendor/tui/types/render/lines.d.ts +0 -86
  143. package/vendor/tui/types/render/markdown.d.ts +0 -29
  144. package/vendor/tui/types/render/projection.d.ts +0 -587
  145. package/vendor/tui/types/render/status.d.ts +0 -196
  146. package/vendor/tui/types/render/text.d.ts +0 -64
  147. package/vendor/tui/types/render/tool-detail.d.ts +0 -94
  148. package/vendor/tui/types/render/tool-preview.d.ts +0 -28
  149. package/vendor/tui/types/render/usage.d.ts +0 -113
  150. package/vendor/tui/types/render/width.d.ts +0 -29
  151. package/vendor/tui/types/session-directory.d.ts +0 -190
  152. package/vendor/tui/types/session-query.d.ts +0 -92
  153. package/vendor/tui/types/session-switch.d.ts +0 -17
  154. package/vendor/tui/types/settings-file.d.ts +0 -41
  155. package/vendor/tui/types/skills.d.ts +0 -47
  156. package/vendor/tui/types/startup.d.ts +0 -65
  157. package/vendor/tui/types/store.d.ts +0 -58
  158. package/vendor/tui/types/subagents.d.ts +0 -70
  159. package/vendor/tui/types/terminal-title.d.ts +0 -66
  160. package/vendor/tui/types/theme-panel.d.ts +0 -24
  161. package/vendor/tui/types/theme.d.ts +0 -434
  162. package/vendor/tui/types/update-panel.d.ts +0 -49
  163. package/vendor/tui/types/update.d.ts +0 -75
  164. package/vendor/tui/types/version.d.ts +0 -19
  165. package/vendor/tui/types/whale-glyph.d.ts +0 -6
  166. /package/vendor/tui/{dscode-clipboard-image → lib/dscode/clipboard-image}/clipboard-image.swift +0 -0
  167. /package/vendor/tui/{dscode-clipboard-image → lib/dscode/clipboard-image}/index.mjs +0 -0
@@ -1,21 +0,0 @@
1
- //#region src/invariant.ts
2
- const PACKAGE_NAME = "dsh-code";
3
- /** Cordis companion plugin name. */
4
- const name = "tui-invariant";
5
- /** Service required before the companion can register. */
6
- const inject = ["invariants"];
7
- /**
8
- * No runtime invariant beyond the projection's own contract: the TUI renders
9
- * only from `session/event` (model-visible means logged), so the display
10
- * relation the renderer could desync from is already asserted by the session
11
- * log's projection invariants; this companion registers nothing.
12
- */
13
- const install = () => {};
14
- /**
15
- * Register this package's invariant companion.
16
- * @param ctx - Cordis context carrying the invariant service.
17
- * @returns the installed registration's disposer after setup succeeds.
18
- */
19
- const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
20
- //#endregion
21
- export { apply, inject, name };
@@ -1,26 +0,0 @@
1
- import { createRequire } from "node:module";
2
- //#region \0rolldown/runtime.js
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
- key = keys[i];
13
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
- get: ((k) => from[k]).bind(null, key),
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
21
- value: mod,
22
- enumerable: true
23
- }) : target, mod));
24
- var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
25
- //#endregion
26
- export { __require as n, __toESM as r, __commonJSMin as t };
@@ -1,150 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- import SqliteSessionQueryEngine from "@deepseek-ai/dsh-session-query-sqlite";
3
- import { SessionQueryError, assertSessionHeadersCompatible, buildSessionEventSearchDocuments, readColdSessionLog } from "@deepseek-ai/dsh-session-query";
4
- //#region src/session-query.ts
5
- /**
6
- * Skip-tolerant session-query engine for this terminal.
7
- *
8
- * The upstream SqliteSessionQueryEngine reconciliation observes EVERY
9
- * persisted session before each search, and ONE unreadable source (for
10
- * example a pre-release session artifact the frozen format codecs reject)
11
- * fails the whole pass with SESSION_QUERY_PERSISTENCE_FAILED — every
12
- * cross-session search dies because of a single old file nobody opened
13
- * otherwise. This subclass overrides only the observation loop so an
14
- * unreadable source is skipped with a warning and the rest of the corpus
15
- * indexes normally; skipped sessions are retried on later reconciliations
16
- * and rejoin automatically once a host that can read them is installed.
17
- *
18
- * Vendored surface note: `_observeStable` and its module-local helpers are
19
- * private upstream; this file re-declares the observation loop against the
20
- * pinned @deepseek-ai line (see package.json peers) and must be re-checked
21
- * whenever that line moves. The engine class and the tool boundary also
22
- * share ONE physical parent-package instance through this bundle, which
23
- * restores instanceof-based typed error messages on the search path.
24
- */
25
- const STABLE_OBSERVATION_ATTEMPTS = 2;
26
- function assertNotAborted(signal) {
27
- if (signal?.aborted) throw new SessionQueryError("session-search aborted", "SESSION_QUERY_ABORTED");
28
- }
29
- function isAbort(error) {
30
- return error instanceof SessionQueryError && error.code === "SESSION_QUERY_ABORTED";
31
- }
32
- function errorMessage(error) {
33
- return error instanceof Error ? error.message : "unknown error";
34
- }
35
- function observeSession(header, inheritedEventCount, events) {
36
- const detachedHeader = structuredClone(header);
37
- const detachedEvents = events.map((event) => structuredClone(event));
38
- return {
39
- header: detachedHeader,
40
- inheritedEventCount,
41
- documents: buildSessionEventSearchDocuments(detachedHeader.id, detachedEvents),
42
- fingerprint: createHash("sha256").update(JSON.stringify({
43
- header: detachedHeader,
44
- inheritedEventCount,
45
- events: detachedEvents
46
- })).digest("base64url")
47
- };
48
- }
49
- function sameHeader(a, b) {
50
- return a.id === b.id && a.createdAt === b.createdAt && a.cwd === b.cwd && a.parentSession === b.parentSession && a.isSeeded === b.isSeeded && (a.delegationDepth ?? 0) === (b.delegationDepth ?? 0) && a.agentPreset === b.agentPreset;
51
- }
52
- function materializePersistenceSnapshots(snapshots) {
53
- const candidate = snapshots;
54
- if (!Array.isArray(candidate)) throw new Error("persistence snapshots must be an array");
55
- const result = /* @__PURE__ */ new Map();
56
- for (const snapshot of candidate) {
57
- if (typeof snapshot.revision !== "string") throw new Error("persistence snapshot revision must be a string");
58
- const header = structuredClone(snapshot.header);
59
- if (result.has(header.id)) throw new Error(`persistence listed duplicate session "${header.id}"`);
60
- result.set(header.id, {
61
- header,
62
- revision: snapshot.revision
63
- });
64
- }
65
- return result;
66
- }
67
- function samePersistenceSnapshots(before, after) {
68
- if (before.size !== after.size) return false;
69
- for (const [id, first] of before) {
70
- const second = after.get(id);
71
- if (second === void 0 || first.revision !== second.revision || !sameHeader(first.header, second.header)) return false;
72
- }
73
- return true;
74
- }
75
- /**
76
- * The skip-tolerant observation pass: structurally the upstream loop, with
77
- * the per-source cold read wrapped so one unreadable session degrades to a
78
- * warning instead of failing every search. Exported for unit tests with an
79
- * injectable cold reader.
80
- */
81
- async function observeStableWithSkip(engine, indexed, signal, readCold = readColdSessionLog) {
82
- for (let attempt = 0; attempt < STABLE_OBSERVATION_ATTEMPTS; attempt += 1) {
83
- assertNotAborted(signal);
84
- const persistenceBinding = engine._persistenceBinding;
85
- const persistence = persistenceBinding.service;
86
- const initiallyLive = new Set(engine.ctx.sessions.list().map((session) => session.id));
87
- let persisted = /* @__PURE__ */ new Map();
88
- if (persistence !== void 0) try {
89
- const canReuseIndexed = engine._lastPersistenceIdentity === void 0 || engine._lastPersistenceIdentity === persistenceBinding.identity;
90
- const listOptions = signal === void 0 ? void 0 : { signal };
91
- const before = await persistence.list(listOptions);
92
- assertNotAborted(signal);
93
- persisted = materializePersistenceSnapshots(before);
94
- for (const entry of persisted.values()) {
95
- if (canReuseIndexed && indexed.get(entry.header.id)?.revision === entry.revision) continue;
96
- if (initiallyLive.has(entry.header.id) || engine.ctx.sessions.get(entry.header.id) !== void 0) continue;
97
- assertNotAborted(signal);
98
- try {
99
- const loaded = await readCold(persistence, entry.header.id, signal);
100
- assertNotAborted(signal);
101
- assertSessionHeadersCompatible(entry.header, loaded.header);
102
- entry.loaded = observeSession(loaded.header, loaded.inheritedEventCount, loaded.events);
103
- } catch (error) {
104
- if (isAbort(error) || signal?.aborted) throw error;
105
- if (engine._persistenceBinding !== persistenceBinding) break;
106
- entry.unreadable = errorMessage(error);
107
- engine.ctx.logger?.warn("session-search skipped unreadable session %s: %s", entry.header.id, entry.unreadable);
108
- }
109
- }
110
- assertNotAborted(signal);
111
- const afterSnapshots = await persistence.list(listOptions);
112
- assertNotAborted(signal);
113
- const after = materializePersistenceSnapshots(afterSnapshots);
114
- if (!samePersistenceSnapshots(persisted, after)) continue;
115
- if (engine._persistenceBinding !== persistenceBinding) continue;
116
- } catch (error) {
117
- if (isAbort(error) || signal?.aborted) throw new SessionQueryError("session-search aborted", "SESSION_QUERY_ABORTED", { cause: error });
118
- if (engine._persistenceBinding !== persistenceBinding) continue;
119
- if (error instanceof SessionQueryError) throw error;
120
- throw new SessionQueryError(`session-search persistence observation failed: ${errorMessage(error)}`, "SESSION_QUERY_PERSISTENCE_FAILED", { cause: error });
121
- }
122
- const live = /* @__PURE__ */ new Map();
123
- for (const session of engine.ctx.sessions.list()) {
124
- const observed = observeSession(session.header, session.inheritedEventCount, session.snapshotEvents());
125
- const durable = persisted.get(session.id);
126
- if (durable !== void 0 && durable.loaded === void 0) {
127
- live.set(session.id, observed);
128
- continue;
129
- }
130
- if (durable !== void 0) assertSessionHeadersCompatible(observed.header, durable.header);
131
- live.set(session.id, observed);
132
- }
133
- if (!(initiallyLive.size === live.size && [...initiallyLive].every((id) => live.has(id)))) continue;
134
- return {
135
- persistenceBinding,
136
- persisted,
137
- live
138
- };
139
- }
140
- throw new SessionQueryError("session-search persistence observation did not stabilize after one retry", "SESSION_QUERY_PERSISTENCE_FAILED");
141
- }
142
- const EngineBase = SqliteSessionQueryEngine;
143
- /** The engine this bundle mounts in place of the base `session-query-sqlite` row. */
144
- var SkipTolerantSessionQueryEngine = class extends EngineBase {
145
- async _observeStable(indexed, signal) {
146
- return await observeStableWithSkip(this, indexed, signal);
147
- }
148
- };
149
- //#endregion
150
- export { SkipTolerantSessionQueryEngine, SkipTolerantSessionQueryEngine as default, observeStableWithSkip };
@@ -1,109 +0,0 @@
1
- import { r as THEME_NAMES } from "./theme-7u5Qo3dF.mjs";
2
- import { Command } from "commander";
3
- import { parseCmdline } from "@deepseek-ai/dsh-cmdline";
4
- //#region src/startup.ts
5
- /**
6
- * The interactive terminal app's command-line provider: parses `--resume`,
7
- * `--continue`, `--session`, `--mode`, `--theme`, `--image`, an optional
8
- * initial prompt, and `--help`, then
9
- * publishes {@link TUI_STARTUP_SERVICE} for the runner to consume lazily.
10
- * Follows the headless bundle's startup shape (a commander action publishing
11
- * a service through {@link parseCmdline}).
12
- *
13
- * Semantics:
14
- * - `--resume <id|prefix>` — continue the persisted session whose id or unique
15
- * id-prefix matches; the TUI replays its transcript and appends to the same
16
- * durable log.
17
- * - `--continue` / `-c` — resume the most recently modified persisted session
18
- * whose project directory matches the current working directory.
19
- * - `--session <id>` — create a new session under an explicit identity (the
20
- * id must not exist yet).
21
- * - `--theme <dark|light|prismatic|rainbow|auto>` — the color palette; auto follows the
22
- * terminal (dark fallback until OSC-11 detection lands).
23
- * - no flags — a fresh session with a minted id.
24
- *
25
- * @module @deepseek-ai/dsh-tui/startup
26
- */
27
- /** Stable Cordis plugin name. */
28
- const name = "tui-startup";
29
- /** Services required before the invocation can be resolved. */
30
- const inject = ["cmdlineArgs"];
31
- /** Service provided by this plugin and injected by the terminal runner. */
32
- const TUI_STARTUP_SERVICE = "tuiStartup";
33
- /** Pure option policy shared by Commander and tests. */
34
- function resolveTuiStartup(options) {
35
- if ([
36
- options.resume !== void 0,
37
- options.continue === true,
38
- options.session !== void 0
39
- ].filter(Boolean).length > 1) throw new Error("--resume, --continue, and --session are mutually exclusive");
40
- if (options.session === "") throw new Error("--session needs an id");
41
- if (options.resume === "") throw new Error("--resume needs a session id or id prefix");
42
- if (options.mode === "") throw new Error("--mode needs a preset id");
43
- if (options.mode !== void 0 && (options.resume !== void 0 || options.continue === true)) throw new Error("--mode applies only to a new session; it cannot be combined with --resume or --continue");
44
- if (options.theme !== void 0 && !THEME_NAMES.includes(options.theme)) throw new Error(`--theme must be one of: ${THEME_NAMES.join(", ")}`);
45
- const input = {
46
- ...options.theme === void 0 ? {} : { theme: options.theme },
47
- ...options.prompt === void 0 || options.prompt.trim() === "" ? {} : { prompt: options.prompt.trim() },
48
- ...options.images === void 0 || options.images.length === 0 ? {} : { images: [...options.images] }
49
- };
50
- return options.resume !== void 0 ? {
51
- kind: "resume",
52
- sessionId: options.resume,
53
- ...input
54
- } : options.continue === true ? {
55
- kind: "latest",
56
- ...input
57
- } : options.session !== void 0 ? {
58
- kind: "named",
59
- sessionId: options.session,
60
- ...options.mode === void 0 ? {} : { mode: options.mode },
61
- ...input
62
- } : {
63
- kind: "fresh",
64
- ...options.mode === void 0 ? {} : { mode: options.mode },
65
- ...input
66
- };
67
- }
68
- /**
69
- * This app's command: the launcher's flags this app owns, its description,
70
- * and its help text.
71
- * @returns a fresh program, so one process can parse more than once (tests).
72
- */
73
- function tuiCommand() {
74
- return new Command().name("dsh --profile cli").description("DeepSeek Harness CLI core: the interactive coding terminal.").helpOption("-h, --help", "show this help").option("-r, --resume <session>", "resume the persisted session with this id (or unique id prefix)").option("-c, --continue", "resume the most recent persisted session for this working directory").option("--session <id>", "create a new session under this explicit id").option("--mode <preset>", "agent preset for a newly created session").option("--theme <name>", "color theme: dark (default), light, prismatic, rainbow, or auto").option("-i, --image <path>", "attach an image to the initial prompt (repeatable)", (path, paths) => [...paths, path], []).argument("[prompt...]", "initial prompt; sends immediately after startup").addHelpText("after", `
75
- Examples:
76
- dsh --profile cli fresh session, minted id
77
- dsh --profile cli --resume abc123 resume session by id prefix
78
- dsh --profile cli --continue resume the latest local session
79
- dsh --profile cli --mode minimal fresh session using the minimal preset
80
- dsh --profile cli --theme light light palette for bright terminals
81
- dsh --profile cli "explain this repo" start and send an initial prompt
82
- dsh --profile cli -i diagram.png "review this diagram"
83
- `);
84
- }
85
- /**
86
- * Parse the invocation and publish the startup service. Mutual exclusions are
87
- * usage errors rejected from the action before anything is provided.
88
- * @param ctx - plugin context carrying the command line and exit request.
89
- */
90
- function apply(ctx) {
91
- const program = tuiCommand();
92
- program.action((prompt) => {
93
- const options = {
94
- ...program.opts(),
95
- prompt: prompt.join(" ")
96
- };
97
- let startup;
98
- try {
99
- startup = resolveTuiStartup(options);
100
- } catch (error) {
101
- program.error(`error: ${error instanceof Error ? error.message : String(error)}`);
102
- }
103
- if (startup === void 0) return;
104
- ctx.provide(TUI_STARTUP_SERVICE, { startup });
105
- });
106
- parseCmdline(ctx, program);
107
- }
108
- //#endregion
109
- export { apply, inject, name, resolveTuiStartup };