@jayyuen66/dsh-dir-prep-organize 0.1.6 → 0.1.7

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/docs/DETAIL.md ADDED
@@ -0,0 +1,26 @@
1
+ # Draft polish and templates
2
+
3
+ Polishes the draft sitting in the input box before you send it, and inserts curated templates at the cursor.
4
+
5
+ ## What the card changes
6
+
7
+ This card has two list editors rather than a grid of knobs.
8
+
9
+ - **Role library** — rows of name, emoji, group, description and body, which the input-box Template picker reads. Leaving the table empty is not a disabled state: the plugin then serves its built-in curated set, fetched on demand rather than shipped inside the form description.
10
+ - **Import-allowed roots** — additional absolute directories whose role files may be imported. An empty list adds nothing: this card has no session context, so only the bundled `agents/` role library stays importable; the endpoint called with a session also accepts paths inside that session's cwd. Absolute paths outside those zones stay refused. It is not a placeholder waiting to be filled.
11
+
12
+ Both are read per request, so a change applies on the next action without restarting the host.
13
+
14
+ ## Values that are not on the card
15
+
16
+ `organizeTimeoutMs` is marked as a live value but has no knob here: the client reads it only to size its own fetch timeout, and the host times out first.
17
+
18
+ `maxSnippetBytes` and `readConcurrency` are deployment assumptions kept off the card deliberately. Set them in the `config:` block of this plugin's row in `cordis.patch.yml`; they take effect on restart.
19
+
20
+ ## What it needs from outside
21
+
22
+ No external CLI, interpreter or credential of its own. It uses the host's model runtime and model selection (the live agent's current choice, falling back to the default selection), the session store and the filesystem service; polish follows the model selected for that conversation, so switching the model in the input area changes what the next polish call uses.
23
+
24
+ ## Further detail
25
+
26
+ The vendored role library, the generated default-template table and the import-scan depth rules are developer-facing and live in the package README (`README.md` / `README.zh-CN.md`).
@@ -0,0 +1,26 @@
1
+ # 输入框润色与模板
2
+
3
+ 在发送之前把输入框里的草稿润色一遍,并把精选模板插到光标处。
4
+
5
+ ## 设置卡上改的是什么
6
+
7
+ 这张卡是两个列表编辑器,不是一堆开关。
8
+
9
+ - **角色库** — 每行是名称、表情、分组、说明与正文,输入框的「模板」选择器读的就是这张表。把表清空不是关掉功能:插件会改用随包内置的精选集合,需要时由宿主现取,而不是把整份塞进表单描述里。
10
+ - **允许导入的目录** — 额外允许导入角色文件的绝对目录。留空不额外放行:这张卡没有会话上下文,因此只剩随包内置的 `agents/` 角色库可导入;带会话调用的端点还接受该会话 cwd 之内的路径。这些区域之外的绝对路径仍被拒绝,而不是等着填的占位。
11
+
12
+ 两者都是每次请求现读,改完下一次动作就生效,不需要重启宿主。
13
+
14
+ ## 卡上没有的值
15
+
16
+ `organizeTimeoutMs` 虽标为即时生效,但卡上没有它的旋钮:客户端只读它来对齐自己的 fetch 超时,真正先超时的是宿主那侧。
17
+
18
+ `maxSnippetBytes` 与 `readConcurrency` 是刻意留在卡外的部署假定值。写在本插件注册行的 `config:` 块,改值随重启生效。
19
+
20
+ ## 需要外部提供什么
21
+
22
+ 不需要外部 CLI、解释器或自有凭据。它用宿主的模型运行时与模型选择(会话活 Agent 的当前选择,取不到时回落默认选择)、会话存储与文件系统服务;润色跟随当前会话选定的模型,所以在输入区换模型会改变下一次润色用的是哪个。
23
+
24
+ ## 更完整的说明
25
+
26
+ vendored 角色库、生成的默认模板表、导入扫描的层数规则都属于开发面,写在随包 README(`README.md` / `README.zh-CN.md`)。
package/host.js CHANGED
@@ -134,6 +134,9 @@ const AGENT_DIR_GROUP_LABELS = {
134
134
  testing: "测试"
135
135
  };
136
136
  // src/templates.ts
137
+ /** frontmatter 的闭合围栏与正文行分隔。 */
138
+ const FRONTMATTER_CLOSE = /^---[ \t]*$/mu;
139
+ const LINE_BREAK = /\r?\n/u;
137
140
  /** 角色正文提炼/「按角色风格润色」上下文:不设字符上限(用户拍板,
138
141
  * 上下文完整性优先;模型 context 超限由模型报错提示用户自行处理)。 */
139
142
  /** 仓库目录名 → 下拉分组标签的**唯一**导出点在 `./group-labels.generated.ts`(表源 =
@@ -162,7 +165,7 @@ function stripPairQuotes(value) {
162
165
  return value;
163
166
  }
164
167
  /** frontmatter 键名形状:字母开头,随后字母/数字/下划线/连字符。 */
165
- const FRONTMATTER_KEY = /^[A-Za-z][A-Za-z0-9_-]*$/u;
168
+ const FRONTMATTER_KEY = /^[A-Za-z][\w-]*$/u;
166
169
  /** 头部只解析前 20 行键值对(防御恶意超长头部拖慢)。 */
167
170
  const FRONTMATTER_MAX_LINES = 20;
168
171
  /** 视觉标记进入下拉前缀的最大字符数。 */
@@ -218,7 +221,7 @@ function parseAgentFrontmatter(text) {
218
221
  let result;
219
222
  if (firstNl !== -1 && norm.slice(0, firstNl).trim() === "---") {
220
223
  const rest = norm.slice(firstNl + 1);
221
- const closeIdx = rest.search(/^---[ \t]*$/mu);
224
+ const closeIdx = rest.search(FRONTMATTER_CLOSE);
222
225
  if (closeIdx !== -1) {
223
226
  const head = rest.slice(0, closeIdx);
224
227
  const bodyStart = rest.indexOf("\n", closeIdx) + 1;
@@ -245,7 +248,7 @@ function parseAgentFrontmatter(text) {
245
248
  * - 结果 trim;空正文(全围栏/全空白)→ 空串。
246
249
  */
247
250
  function condenseRoleBody(body) {
248
- const lines = body.split(/\r?\n/u);
251
+ const lines = body.split(LINE_BREAK);
249
252
  const out = [];
250
253
  let inFence = false;
251
254
  let fenceStart = 0;
@@ -425,6 +428,9 @@ function isSettingsService(value) {
425
428
  function isSessionsService(value) {
426
429
  return hasFnMember(value, "get");
427
430
  }
431
+ function isAgentsService(value) {
432
+ return hasFnMember(value, "get");
433
+ }
428
434
  function isFsService(value) {
429
435
  return hasFnMember(value, "resolve") && hasFnMember(value, "stat");
430
436
  }
@@ -677,12 +683,14 @@ async function collectDirContext(fs, cwd, messages, limits) {
677
683
  * 门禁后仍要求每个文件能解析出非空 frontmatter name(parseAgentFrontmatter),
678
684
  * 否则跳过并计数——绝不返回任意文件原文,只产出模板条目形状。
679
685
  */
686
+ /** 两种路径分隔符(win32 与 POSIX)。 */
687
+ const PATH_SEPARATOR = /[\\/]/u;
680
688
  /** 路径拆段(**逐段**比较而非字符串前缀:`/home/dev/project-two/x.md` 会骗过
681
689
  * `startsWith("/home/dev/project")`,前缀式包含判断等于放行兄弟目录)。
682
690
  * 两种分隔符都拆:win32 的 `path.resolve`/`path.relative` 产出 `\`,只按 `/` 拆会
683
691
  * 把整条路径当成一段,于是合法子路径被判成越界、`..\` 也漏过逐段校验。 */
684
692
  function pathSegments(absolute) {
685
- return absolute.split(/[\\/]/u).filter((token) => token.length > 0);
693
+ return absolute.split(PATH_SEPARATOR).filter((token) => token.length > 0);
686
694
  }
687
695
  /** 逐段校验:段为 "." / ".." 一律拒(归一前必须先拦,否则 path.resolve 吃掉 `..`);
688
696
  * checkHidden=true 时额外拒隐藏段(凭据/敏感目录,如 `.ssh`)。 */
@@ -1224,8 +1232,20 @@ function importAllowRootsOf(raw) {
1224
1232
  * settings.plugin.item 卡」(dsh-client-ui-settings-plugins 源码语义),configure 必须
1225
1233
  * 发生在 apply 期,故仍硬注入。sessions/fs/llm/agentDefaultModel 仍可选读。 */
1226
1234
  const inject = ["settings"];
1235
+ /** 会话活线模型:新版读 `agent.model.current()`(含待切换选择),旧版回落
1236
+ * `agent.options`。没有活 Agent、或两处都答不全时 undefined(调用方回落默认模型)。
1237
+ * 与 rescue 同一条规则:`current()` 交回 undefined 是「还没记录过选择」,不是读失败。 */
1238
+ function liveModelOf(deps, sessionId) {
1239
+ const agent = sessionId === null ? void 0 : deps.agents?.()?.get(sessionIdOf(sessionId));
1240
+ const raw = agent?.model?.current() ?? agent?.options;
1241
+ return raw !== void 0 && typeof raw.provider === "string" && raw.provider.length > 0 && typeof raw.model === "string" && raw.model.length > 0 ? {
1242
+ provider: raw.provider,
1243
+ model: raw.model,
1244
+ ...raw.reasoningEffort === void 0 ? {} : { reasoningEffort: raw.reasoningEffort }
1245
+ } : void 0;
1246
+ }
1227
1247
  /** 当前默认模型解析(缺服务/抛错 → undefined)。 */
1228
- function resolveModel(deps) {
1248
+ function defaultModelOf(deps) {
1229
1249
  const current = deps.agentDefaultModel?.();
1230
1250
  let result;
1231
1251
  if (current !== void 0) try {
@@ -1238,6 +1258,10 @@ function resolveModel(deps) {
1238
1258
  } catch {}
1239
1259
  return result;
1240
1260
  }
1261
+ /** 润色的模型来源:会话活线优先,没有才用默认模型。 */
1262
+ function resolveModel(deps, sessionId) {
1263
+ return liveModelOf(deps, sessionId) ?? defaultModelOf(deps);
1264
+ }
1241
1265
  /** 会话最近对话文本提取(deriveMessages 尾部;缺会话/无方法/抛错 → 空串)。 */
1242
1266
  function resolveRecentTurns(sessions, sessionId) {
1243
1267
  const session = sessionId === null ? void 0 : sessions?.get(sessionIdOf(sessionId));
@@ -1377,7 +1401,7 @@ async function organizePayload(scope, parsed) {
1377
1401
  ok: false,
1378
1402
  error: messages.cwdUnknown
1379
1403
  };
1380
- const model = resolveModel(scope.deps);
1404
+ const model = resolveModel(scope.deps, sessionIdText);
1381
1405
  try {
1382
1406
  return {
1383
1407
  ok: true,
@@ -1597,6 +1621,10 @@ function apply(ctx, config) {
1597
1621
  const service = getService("agentDefaultModel");
1598
1622
  return isAgentDefaultModel(service) ? service : void 0;
1599
1623
  },
1624
+ agents: () => {
1625
+ const service = getService("agents");
1626
+ return isAgentsService(service) ? service : void 0;
1627
+ },
1600
1628
  importAllowRoots: () => importAllowRootsOf(config.importAllowRoots.get()),
1601
1629
  limits: limitsOfConfig
1602
1630
  },
@@ -1607,4 +1635,4 @@ function apply(ctx, config) {
1607
1635
  installDirPrepRemote(child, scope);
1608
1636
  });
1609
1637
  }
1610
- export { configSchema as Config, DIR_PREP_REMOTE_NAMESPACE, DirPrepRemoteService, apply, buildOrganizeSystem, buildOrganizeUser, clampInt, collectAgentTemplates, collectDirContext, createRemotePayloads, defaultTemplatesFrom, drainStreamToText, extractRecentTurns, importAllowRootsOf, importPathError, inject, installDirPrepRemote, loadDefaultTemplates, runOrganize, sanitizeLimits };
1638
+ export { configSchema as Config, DIR_PREP_REMOTE_NAMESPACE, DirPrepRemoteService, apply, buildOrganizeSystem, buildOrganizeUser, clampInt, collectAgentTemplates, collectDirContext, createRemotePayloads, defaultTemplatesFrom, drainStreamToText, extractRecentTurns, importAllowRootsOf, importPathError, inject, installDirPrepRemote, liveModelOf, loadDefaultTemplates, runOrganize, sanitizeLimits };
package/locale/en.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "meta": {
3
+ "title": "Draft polish and templates",
4
+ "description": "Polishes the draft in the input box before you send it and inserts curated templates at the cursor.",
5
+ "detail": "docs/DETAIL.md"
6
+ }
7
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "meta": {
3
+ "title": "输入框润色与模板",
4
+ "description": "发送前把输入框里的草稿润色一遍,并把精选模板插到光标处。",
5
+ "detail": "docs/DETAIL.zh.md"
6
+ }
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jayyuen66/dsh-dir-prep-organize",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "dsh 插件:对话输入框「润色」按钮(主键直接润色/▾ 以角色风格润色,结合当前目录 + session 模型润色草稿)+「模板」下拉(内置精选角色集生成自插件 agents/ 角色库,可按部门分组;设置卡可增删改/一键导入内置全部/导入本地角色 .md)",
5
5
  "keywords": [
6
6
  "cordis",
@@ -28,6 +28,9 @@
28
28
  "types",
29
29
  "cordis.patch.yml",
30
30
  "agents",
31
+ "locale/zh.json",
32
+ "locale/en.json",
33
+ "docs",
31
34
  "README.zh-CN.md",
32
35
  "CHANGELOG.md",
33
36
  "THIRD_PARTY_NOTICES.md"
@@ -47,6 +50,7 @@
47
50
  },
48
51
  "./client": "./client.js",
49
52
  "./cordis.patch.yml": "./cordis.patch.yml",
53
+ "./locale/*.json": "./locale/*.json",
50
54
  "./package.json": "./package.json"
51
55
  },
52
56
  "publishConfig": {
@@ -54,42 +58,46 @@
54
58
  "registry": "https://registry.npmjs.org"
55
59
  },
56
60
  "dependencies": {
57
- "@jayyuen66/dsh-plugin-shared": "0.1.9"
61
+ "@jayyuen66/dsh-plugin-shared": "0.2.1",
62
+ "zod": "4.6.7"
58
63
  },
59
64
  "devDependencies": {
60
- "@deepseek-ai/cordis": "4.0.5",
61
- "@deepseek-ai/cordis-plugin-group": "1.0.5",
62
- "@deepseek-ai/cordis-plugin-include": "1.0.10",
63
- "@deepseek-ai/cosmokit": "1.8.6",
64
- "@deepseek-ai/dsh-agent-default-model": "0.2.1-rc.3",
65
- "@deepseek-ai/dsh-app-boot": "0.2.1-rc.3",
66
- "@deepseek-ai/dsh-brand": "0.2.1-rc.3",
67
- "@deepseek-ai/dsh-client-locale": "0.2.1-rc.3",
68
- "@deepseek-ai/dsh-client-ui-conversation": "0.2.1-rc.3",
69
- "@deepseek-ai/dsh-client-ui-plugin-manager": "0.2.1-rc.3",
70
- "@deepseek-ai/dsh-client-ui-renderer": "0.2.1-rc.3",
71
- "@deepseek-ai/dsh-client-ui-settings": "0.2.1-rc.3",
72
- "@deepseek-ai/dsh-client-ui-slots": "0.2.1-rc.3",
73
- "@deepseek-ai/dsh-config-editor": "0.2.1-rc.3",
74
- "@deepseek-ai/dsh-fs": "0.2.1-rc.3",
75
- "@deepseek-ai/dsh-home-paths": "0.2.1-rc.3",
76
- "@deepseek-ai/dsh-host-webserver": "0.2.1-rc.3",
77
- "@deepseek-ai/dsh-launch-environment": "0.2.1-rc.3",
78
- "@deepseek-ai/dsh-llm": "0.2.1-rc.3",
79
- "@deepseek-ai/dsh-sandbox": "0.2.1-rc.3",
80
- "@deepseek-ai/dsh-scope": "0.2.1-rc.3",
81
- "@deepseek-ai/dsh-session": "0.2.1-rc.3",
82
- "@deepseek-ai/dsh-settings": "0.2.1-rc.3",
83
- "@deepseek-ai/dsh-typert-protocol": "0.2.1-rc.3",
84
- "@deepseek-ai/schemastery": "3.18.5",
85
- "@types/node": "26.6.5",
65
+ "@deepseek-ai/cordis": "4.0.6-alpha.1",
66
+ "@deepseek-ai/cordis-plugin-group": "1.0.6-alpha.1",
67
+ "@deepseek-ai/cordis-plugin-include": "1.0.11-alpha.1",
68
+ "@deepseek-ai/cosmokit": "1.8.7-alpha.1",
69
+ "@deepseek-ai/dsh-agent-default-model": "0.2.2-alpha.2",
70
+ "@deepseek-ai/dsh-app-boot": "0.2.2-alpha.2",
71
+ "@deepseek-ai/dsh-brand": "0.2.2-alpha.2",
72
+ "@deepseek-ai/dsh-client-locale": "0.2.2-alpha.2",
73
+ "@deepseek-ai/dsh-client-ui-conversation": "0.2.2-alpha.2",
74
+ "@deepseek-ai/dsh-client-ui-plugin-manager": "0.2.2-alpha.2",
75
+ "@deepseek-ai/dsh-client-ui-renderer": "0.2.2-alpha.2",
76
+ "@deepseek-ai/dsh-client-ui-settings": "0.2.2-alpha.2",
77
+ "@deepseek-ai/dsh-client-ui-slots": "0.2.2-alpha.2",
78
+ "@deepseek-ai/dsh-config-editor": "0.2.2-alpha.2",
79
+ "@deepseek-ai/dsh-fs": "0.2.2-alpha.2",
80
+ "@deepseek-ai/dsh-home-paths": "0.2.2-alpha.2",
81
+ "@deepseek-ai/dsh-host-webserver": "0.2.2-alpha.2",
82
+ "@deepseek-ai/dsh-launch-environment": "0.2.2-alpha.2",
83
+ "@deepseek-ai/dsh-llm": "0.2.2-alpha.2",
84
+ "@deepseek-ai/dsh-sandbox": "0.2.2-alpha.2",
85
+ "@deepseek-ai/dsh-scope": "0.2.2-alpha.2",
86
+ "@deepseek-ai/dsh-session": "0.2.2-alpha.2",
87
+ "@deepseek-ai/dsh-settings": "0.2.2-alpha.2",
88
+ "@deepseek-ai/dsh-typert-protocol": "0.2.2-alpha.2",
89
+ "@deepseek-ai/schemastery": "3.18.6-alpha.1",
90
+ "@e18e/eslint-plugin": "0.8.1",
91
+ "@types/node": "26.6.6",
86
92
  "@types/react": "19.3.0",
87
93
  "@types/react-dom": "19.3.0",
88
94
  "@vitest/coverage-v8": "5.0.5",
95
+ "eslint-plugin-regexp": "3.3.2",
89
96
  "eslint-plugin-sonarjs": "4.2.2",
97
+ "eslint-plugin-zod": "5.2.2",
90
98
  "happy-dom": "21.0.4",
91
- "oxfmt": "0.74.0",
92
- "oxlint": "1.89.0",
99
+ "oxfmt": "0.75.0",
100
+ "oxlint": "1.90.0",
93
101
  "oxlint-tsgolint": "7.0.2005",
94
102
  "react": "^19.3.0",
95
103
  "react-dom": "^19.3.0",
@@ -99,21 +107,21 @@
99
107
  "vitest": "5.0.5"
100
108
  },
101
109
  "peerDependencies": {
102
- "@deepseek-ai/cordis": "4.0.5",
103
- "@deepseek-ai/cosmokit": "1.8.6",
110
+ "@deepseek-ai/cordis": "~4.0.5 || 4.0.6-alpha.1",
111
+ "@deepseek-ai/cosmokit": "1.8.7-alpha.1",
104
112
  "@deepseek-ai/dsh": "^0.2.1-rc.3",
105
- "@deepseek-ai/dsh-agent-default-model": "0.2.1-rc.3",
106
- "@deepseek-ai/dsh-brand": "0.2.1-rc.3",
107
- "@deepseek-ai/dsh-client-locale": "0.2.1-rc.3",
108
- "@deepseek-ai/dsh-client-ui-conversation": "0.2.1-rc.3",
109
- "@deepseek-ai/dsh-client-ui-renderer": "0.2.1-rc.3",
110
- "@deepseek-ai/dsh-client-ui-settings": "0.2.1-rc.3",
111
- "@deepseek-ai/dsh-client-ui-slots": "0.2.1-rc.3",
112
- "@deepseek-ai/dsh-fs": "0.2.1-rc.3",
113
- "@deepseek-ai/dsh-llm": "0.2.1-rc.3",
114
- "@deepseek-ai/dsh-session": "0.2.1-rc.3",
115
- "@deepseek-ai/dsh-typert-protocol": "0.2.1-rc.3",
116
- "@deepseek-ai/schemastery": "3.18.5"
113
+ "@deepseek-ai/dsh-agent-default-model": "^0.2.1-rc.3",
114
+ "@deepseek-ai/dsh-brand": "^0.2.1-rc.3",
115
+ "@deepseek-ai/dsh-client-locale": "^0.2.1-rc.3",
116
+ "@deepseek-ai/dsh-client-ui-conversation": "^0.2.1-rc.3",
117
+ "@deepseek-ai/dsh-client-ui-renderer": "^0.2.1-rc.3",
118
+ "@deepseek-ai/dsh-client-ui-settings": "^0.2.1-rc.3",
119
+ "@deepseek-ai/dsh-client-ui-slots": "^0.2.1-rc.3",
120
+ "@deepseek-ai/dsh-fs": "^0.2.1-rc.3",
121
+ "@deepseek-ai/dsh-llm": "^0.2.1-rc.3",
122
+ "@deepseek-ai/dsh-session": "^0.2.1-rc.3",
123
+ "@deepseek-ai/dsh-typert-protocol": "^0.2.1-rc.3",
124
+ "@deepseek-ai/schemastery": "3.18.6-alpha.1"
117
125
  },
118
126
  "peerDependenciesMeta": {
119
127
  "@deepseek-ai/cordis": {
package/types/host.d.ts CHANGED
@@ -112,6 +112,27 @@ export interface SessionLike {
112
112
  export interface SessionsService {
113
113
  get: (id: SessionId) => SessionLike | undefined;
114
114
  }
115
+ /** 活 Agent 的模型选择面(新版 `model.current()`;旧版只有 `options`)。 */
116
+ export interface LiveModelSelection {
117
+ readonly provider: string;
118
+ readonly model: string;
119
+ readonly reasoningEffort?: ModelSelection["reasoningEffort"];
120
+ }
121
+ /** 活 Agent 的只读投影:本包只碰模型这两位。 */
122
+ export interface LiveAgent {
123
+ readonly model?: {
124
+ readonly current: () => LiveModelSelection | undefined;
125
+ } | null;
126
+ readonly options?: {
127
+ readonly provider?: string;
128
+ readonly model?: string;
129
+ readonly reasoningEffort?: ModelSelection["reasoningEffort"];
130
+ };
131
+ }
132
+ /** 宿主 agent 注册表读面:按会话 id 取活 Agent。 */
133
+ export interface AgentsService {
134
+ get: (id: SessionId) => LiveAgent | undefined;
135
+ }
115
136
  /** `ReasoningEffortId` 取官方真品牌(`Branded<'ReasoningEffortId'>`,以 dsh-brand 的
116
137
  * `unique symbol` 为键)。本地重述成 `string & { effortBrand: ... }` 是**假品牌**:
117
138
  * 键不同名即不同型,宿主真值塞不进来、任何带该属性的字符串反倒能通过,注释里那句
@@ -376,6 +397,8 @@ export interface RouteDeps {
376
397
  fs?: () => FsService | undefined;
377
398
  llm?: () => LlmService | undefined;
378
399
  agentDefaultModel?: () => AgentDefaultModel | undefined;
400
+ /** 会话活线:有活 Agent 时润色跟随它的模型,没有才回落默认模型。 */
401
+ agents?: () => AgentsService | undefined;
379
402
  /** 设置里登记的额外导入允许根(每次请求现读,改设置无需重启)。 */
380
403
  importAllowRoots?: () => readonly string[];
381
404
  /** 部署值(Config 化):润色超时 / 摘要字节上限 / 读取并发。
@@ -388,6 +411,10 @@ export interface RouteDeps {
388
411
  /** 回执字典的现读 getter:每个请求取一次,用户在「设置 → 常规」改语言后下一个请求即
389
412
  * 切文案(不重启、不加插件自己的 locale 设置项;与 importAllowRoots 的现读同构)。 */
390
413
  export type MessagesOf = () => HostMessages;
414
+ /** 会话活线模型:新版读 `agent.model.current()`(含待切换选择),旧版回落
415
+ * `agent.options`。没有活 Agent、或两处都答不全时 undefined(调用方回落默认模型)。
416
+ * 与 rescue 同一条规则:`current()` 交回 undefined 是「还没记录过选择」,不是读失败。 */
417
+ export declare function liveModelOf(deps: RouteDeps, sessionId: string | null): ModelSelection | undefined;
391
418
  /** 读面每次调用的共享面:服务 getter 与现读文案/限额。 */
392
419
  interface RemoteScope {
393
420
  readonly deps: RouteDeps;
@@ -72,12 +72,11 @@ export declare function persistError(t: Translate, persisted: Pick<PersistedView
72
72
  treatEmptyAsReverted?: boolean;
73
73
  }): string | undefined;
74
74
  export declare function rootsPersistError(t: Translate, persisted: Pick<PersistedView, "ready" | "revision" | "allowRoots">, expected: readonly string[], action: string): string | undefined;
75
- export declare function applyTemplateToDraft(current: string, template: string): string;
76
75
  export interface KitProps {
77
76
  t: Translate;
78
77
  useCard: <TResult>(selector: (snap: TemplatesSnapshot) => TResult) => TResult;
79
- useInput?: <TResult>(selector: (state: Pick<InputState, "draft">) => TResult) => TResult;
80
- inputActions?: Pick<InputActions, "setDraft">;
78
+ useInput?: <TResult>(selector: (state: Pick<InputState, "draft" | "draftRev" | "phase">) => TResult) => TResult;
79
+ inputActions?: Pick<InputActions, "setDraft" | "captureInsertion" | "insertText">;
81
80
  sessionId?: string;
82
81
  }
83
82
  export interface ClientCtx {
@@ -0,0 +1,32 @@
1
+ import type { InputActions, InputState } from "@deepseek-ai/dsh-client-ui-conversation/client";
2
+ export type InputActionsFace = Pick<InputActions, "setDraft" | "captureInsertion" | "insertText">;
3
+ /** 输入面的最新一帧(异步返回时读它,不读发起那次 render 的闭包)。 */
4
+ export interface InputSnapshot {
5
+ readonly sessionId: string;
6
+ readonly actions: InputActionsFace | undefined;
7
+ readonly draftRev: number;
8
+ readonly phase: InputState["phase"];
9
+ }
10
+ /** 一次整稿写回的凭据。 */
11
+ export interface WriteBackTicket {
12
+ readonly sessionId: string;
13
+ readonly draftRev: number;
14
+ readonly actions: InputActionsFace | undefined;
15
+ invalidated: boolean;
16
+ }
17
+ /** 宿主是否给了整稿替换面(润色结果最后落到 setDraft)。 */
18
+ export declare function hasDraftFace(actions: InputActionsFace | undefined): actions is InputActionsFace;
19
+ /** 宿主是否给了版本校验插入面(模板走这一对,不整稿覆盖)。 */
20
+ export declare function hasInsertFace(actions: InputActionsFace | undefined): actions is InputActionsFace;
21
+ export interface WriteBackMessages {
22
+ readonly unavailable: string;
23
+ readonly stale: string;
24
+ }
25
+ export interface WriteBackBinding {
26
+ readonly begin: () => WriteBackTicket;
27
+ readonly finish: (ticket: WriteBackTicket) => void;
28
+ readonly commit: (content: string, ticket: WriteBackTicket) => void;
29
+ }
30
+ /** 提交期(`phase !== "plain"`)也算失效:发送成功后编辑器会被清空,失败时原稿要留着,
31
+ * 两种情况下在途的润色结果都不该再写进草稿。 */
32
+ export declare function useWriteBack(input: InputSnapshot, messages: WriteBackMessages): WriteBackBinding;
@@ -2,10 +2,9 @@ import type { TranslateNS as OfficialTranslateNS } from "@deepseek-ai/dsh-client
2
2
  import type { MessagesCatalog } from "@jayyuen66/dsh-plugin-shared/lib/locale";
3
3
  /** 本包设置卡产出的全部界面文案。 */
4
4
  export interface UiMessages {
5
- /** 卡片标题(设置页插件列表里的那一行):这份列表同时喂「模板」下拉与「润色」▾。 */
6
- readonly cardTitle: string;
7
- /** 卡片副标题:一句话说明这张卡管什么(数据源、空表回落、导入放行面)。 */
8
- readonly cardDescription: string;
5
+ /** 角色库小节标题与说明(这份列表同时喂「模板」下拉与「润色」▾)。 */
6
+ readonly rolesSection: string;
7
+ readonly rolesHint: string;
9
8
  /** 设置源可写位为 false 时的状态条。 */
10
9
  readonly statusReadOnly: string;
11
10
  /** 设置源尚未就绪时的状态条。 */
@@ -158,10 +157,16 @@ export interface UiMessages {
158
157
  readonly organizeRoleItem: string;
159
158
  /** 润色成功但输入框动作缺失时抛出的错误(会闪烁在按钮上)。 */
160
159
  readonly organizeWriteBackUnavailable: string;
160
+ /** 润色结果因草稿版本变化或会话切换而没有写回时的错误。 */
161
+ readonly organizeWriteBackStale: string;
162
+ /** 「润色」按钮 title(输入框处于提交期,编辑面只读)。 */
163
+ readonly organizeBusyTitle: string;
161
164
  /** 「模板」按钮 title(可写时)。 */
162
165
  readonly templatesIdleTitle: string;
163
166
  /** 「模板」按钮 title(输入框动作缺失)。 */
164
167
  readonly templatesBrokenTitle: string;
168
+ /** 「模板」按钮 title(输入框处于提交期,编辑面只读)。 */
169
+ readonly templatesBusyTitle: string;
165
170
  /** 空分组名的归组名。 */
166
171
  readonly templatesGroupCommon: string;
167
172
  /** 「模板」按钮的 aria-label。 */