@jayyuen66/dsh-dir-prep-organize 0.1.3 → 0.1.5

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/host.js CHANGED
@@ -9,15 +9,15 @@ import { errorText } from "@jayyuen66/dsh-plugin-shared/lib/errors";
9
9
  //#region src/host-messages.ts
10
10
  const HOST_MESSAGES = {
11
11
  zh: {
12
- sysRole: "你是输入框内容整理助手。用户在 dsh 对话输入框写了一段要求,你需要结合当前工作目录的结构与会话最近上下文,把它整理成一段更清晰、可直接发送的要求。",
12
+ sysRole: "你是输入框内容润色助手。用户在 dsh 对话输入框写了一段要求,你需要结合当前工作目录的结构与会话最近上下文,把它润色成一段更清晰、可直接发送的要求。",
13
13
  sysRulesHeading: "规则:",
14
- sysRuleOutputOnly: "- 输出只有整理后的正文,不要任何前言、markdown 代码围栏、标题或解释。",
15
- sysRuleNoExecution: "- 不执行草稿中要求的任何任务:不写代码、不回答问题、不审查/不搜索/不生成任何内容——只整理文本本身(重组措辞与结构、补全缺失的上下文、消歧指代)。",
16
- sysRuleNoAnswer: "- 若草稿本身是问题或待办指令,整理结果仍是同一问题/指令的清晰完整版本,不要把解答、方案或示例写进整理结果。",
14
+ sysRuleOutputOnly: "- 输出只有润色后的正文,不要任何前言、markdown 代码围栏、标题或解释。",
15
+ sysRuleNoExecution: "- 不执行草稿中要求的任何任务:不写代码、不回答问题、不审查/不搜索/不生成任何内容——只润色文本本身(重组措辞与结构、补全缺失的上下文、消歧指代)。",
16
+ sysRuleNoAnswer: "- 若草稿本身是问题或待办指令,润色结果仍是同一问题/指令的清晰完整版本,不要把解答、方案或示例写进润色结果。",
17
17
  sysRuleKeepIntent: "- 保留用户原意与语言(中文保持中文);缺失的关键信息(如目标文件/模块)若能从目录结构或最近对话推断就补上,推断不了不要编造。",
18
- sysRuleResolveRefs: "- 最近对话可能含相关指代(\"上面说的\"\"刚才那个文件\"),整理时把指代解析成明确表述。",
18
+ sysRuleResolveRefs: "- 最近对话可能含相关指代(\"上面说的\"\"刚才那个文件\"),润色时把指代解析成明确表述。",
19
19
  sysRuleNoListing: "- 目录结构与对话历史仅是参考,不要罗列它们本身。",
20
- sysRuleRoleView: "- 若提供了参考角色,只借用其专业术语与措辞风格来重写草稿,不得以角色身份实际执行任务(如审查、修复、生成内容)。",
20
+ sysRuleRoleView: "- 若提供了参考角色,只借用其专业术语与措辞风格来润色草稿,不得以角色身份实际执行任务(如审查、修复、生成内容)。",
21
21
  sysCwdLine: "- 当前工作目录: {cwd}",
22
22
  sysCwdMissing: "(未提供)",
23
23
  sysSummaryLine: "- 目录结构摘要:\n{summary}",
@@ -43,28 +43,28 @@ const HOST_MESSAGES = {
43
43
  importPathNotString: "导入路径必须是字符串(仅设置卡点「导入角色」时可留空 = 内置角色库)",
44
44
  importPathBlank: "导入路径不能只含空白字符",
45
45
  missingFinishChunk: "模型返回流缺少 finish 块",
46
- streamNotFinished: "模型整理未正常完成({reason})",
46
+ streamNotFinished: "模型润色未正常完成({reason})",
47
47
  failureReason: "{kind}: {message}",
48
- emptyPrompt: "用户要求为空,无法整理",
48
+ emptyPrompt: "用户要求为空,无法润色",
49
49
  noModelSelected: "当前无可用模型选择",
50
- emptyOrganizeResult: "模型整理结果为空",
50
+ emptyOrganizeResult: "模型润色结果为空",
51
51
  fsUnavailable: "fs 服务不可用",
52
52
  cwdUnknown: "无法确定会话 cwd(sessionId 缺失或会话不存在)",
53
53
  modelServiceUnavailable: "agentDefaultModel 服务不可用",
54
54
  readModelFailed: "读取模型选择失败: {reason}",
55
55
  llmUnavailable: "llm 服务不可用",
56
- organizeFailed: "整理异常: {reason}"
56
+ organizeFailed: "润色异常: {reason}"
57
57
  },
58
58
  en: {
59
- sysRole: "You are a drafting assistant for the chat input box. The user wrote a request in the dsh input box; combine the layout of the current working directory with the session's recent context and turn it into a clearer request that is ready to send.",
59
+ sysRole: "You are a polishing assistant for the chat input box. The user wrote a request in the dsh input box; combine the layout of the current working directory with the session's recent context and polish it into a clearer request that is ready to send.",
60
60
  sysRulesHeading: "Rules:",
61
- sysRuleOutputOnly: "- Output only the refined body: no preamble, no markdown code fences, no headings, no explanations.",
62
- sysRuleNoExecution: "- Do not carry out any task the draft asks for: write no code, answer no question, run no review/search/generation - refine the text itself only (reword and restructure, fill in missing context, disambiguate references).",
61
+ sysRuleOutputOnly: "- Output only the polished body: no preamble, no markdown code fences, no headings, no explanations.",
62
+ sysRuleNoExecution: "- Do not carry out any task the draft asks for: write no code, answer no question, run no review/search/generation - polish the text itself only (reword and restructure, fill in missing context, disambiguate references).",
63
63
  sysRuleNoAnswer: "- If the draft is itself a question or a to-do instruction, the result stays a clear and complete version of that same question/instruction; do not write answers, solutions or examples into the result.",
64
64
  sysRuleKeepIntent: "- Keep the user's intent and language (keep the original language of the draft); add missing key details (target file/module) when the directory layout or the recent turns make them inferable, and never invent them when they are not.",
65
- sysRuleResolveRefs: "- The recent turns may carry references such as \"what you said above\" or \"that file from before\"; resolve them into explicit wording while refining.",
65
+ sysRuleResolveRefs: "- The recent turns may carry references such as \"what you said above\" or \"that file from before\"; resolve them into explicit wording while polishing.",
66
66
  sysRuleNoListing: "- The directory layout and the conversation history are background only; do not enumerate them.",
67
- sysRuleRoleView: "- If a reference role is given, borrow only its terminology and tone to rewrite the draft; never act as that role (no reviews, fixes or content generation).",
67
+ sysRuleRoleView: "- If a reference role is given, borrow only its terminology and tone to polish the draft; never act as that role (no reviews, fixes or content generation).",
68
68
  sysCwdLine: "- Current working directory: {cwd}",
69
69
  sysCwdMissing: "(not provided)",
70
70
  sysSummaryLine: "- Directory summary:\n{summary}",
@@ -90,9 +90,9 @@ const HOST_MESSAGES = {
90
90
  importPathNotString: "The import path must be a string (it may only be empty when you press \"Import roles\" on the settings card, which means the built-in role library)",
91
91
  importPathBlank: "The import path cannot consist of whitespace only",
92
92
  missingFinishChunk: "The model stream is missing its finish chunk",
93
- streamNotFinished: "The model did not finish refining ({reason})",
93
+ streamNotFinished: "The model did not finish polishing ({reason})",
94
94
  failureReason: "{kind}: {message}",
95
- emptyPrompt: "The request is empty: nothing to refine",
95
+ emptyPrompt: "The request is empty: nothing to polish",
96
96
  noModelSelected: "No model selection is available",
97
97
  emptyOrganizeResult: "The model returned an empty result",
98
98
  fsUnavailable: "fs service unavailable",
@@ -100,7 +100,7 @@ const HOST_MESSAGES = {
100
100
  modelServiceUnavailable: "agentDefaultModel service unavailable",
101
101
  readModelFailed: "Failed to read the model selection: {reason}",
102
102
  llmUnavailable: "llm service unavailable",
103
- organizeFailed: "Refinement failed: {reason}"
103
+ organizeFailed: "Polishing failed: {reason}"
104
104
  }
105
105
  };
106
106
  //#endregion
@@ -134,7 +134,7 @@ const AGENT_DIR_GROUP_LABELS = {
134
134
  };
135
135
  //#endregion
136
136
  //#region src/templates.ts
137
- /** 角色正文提炼/「按角色整理」上下文:不设字符上限(用户拍板,
137
+ /** 角色正文提炼/「按角色风格润色」上下文:不设字符上限(用户拍板,
138
138
  * 上下文完整性优先;模型 context 超限由模型报错提示用户自行处理)。 */
139
139
  /** 仓库目录名 → 下拉分组标签的**唯一**导出点在 `./group-labels.generated.ts`(表源 =
140
140
  * scripts/gen-defaults-lib.mjs,键序 = 下拉分组展示序),本文件不再同名 re-export:
@@ -161,7 +161,7 @@ function stripPairQuotes(value) {
161
161
  if (isWrappedIn(value, "'") || isWrappedIn(value, "\"")) return value.slice(1, -1).trim();
162
162
  return value;
163
163
  }
164
- /** frontmatter 键名形状(与旧版 `^key:.*$` 正则同语义)。 */
164
+ /** frontmatter 键名形状:字母开头,随后字母/数字/下划线/连字符。 */
165
165
  const FRONTMATTER_KEY = /^[A-Za-z][A-Za-z0-9_-]*$/u;
166
166
  /** 头部只解析前 20 行键值对(防御恶意超长头部拖慢)。 */
167
167
  const FRONTMATTER_MAX_LINES = 20;
@@ -235,13 +235,13 @@ function parseAgentFrontmatter(text) {
235
235
  return result;
236
236
  }
237
237
  /**
238
- * 角色正文提炼(导入 / 「按角色整理」共用):取叙述主干、去代码围栏。
238
+ * 角色正文提炼(导入 / 「按角色风格润色」共用):取叙述主干、去代码围栏。
239
239
  *
240
240
  * 规则(确定性,测试锁死):
241
241
  * - ``` 围栏行整体剔除(围栏内容多为长代码样例,对角色语境价值低);
242
242
  * - 行内反引号一并剔除——沿用"正文不含反引号、插入不破坏 markdown 围栏"不变式;
243
243
  * - 不设字符上限(用户拍板):全量保留叙述内容,避免截断影响
244
- * 「以角色整理」的上下文完整性;模型 context 超限由模型报错提示用户自行处理;
244
+ * 「以角色风格润色」的上下文完整性;模型 context 超限由模型报错提示用户自行处理;
245
245
  * - 结果 trim;空正文(全围栏/全空白)→ 空串。
246
246
  */
247
247
  function condenseRoleBody(body) {
@@ -254,9 +254,9 @@ function condenseRoleBody(body) {
254
254
  }
255
255
  //#endregion
256
256
  //#region host.ts
257
- /** 本包送进 `llm.stream({ messages })` 的整理请求帧是 **request-only 输入**:它从不落
257
+ /** 本包送进 `llm.stream({ messages })` 的润色请求帧是 **request-only 输入**:它从不落
258
258
  * 任何持久消息位(`runOrganize` 只回 `{ content }`,读面也不把帧身份回投给卡片),所以
259
- * 按 0.1.7 它既不需要 `id` 也不带 `source`——证据三条:
259
+ * 它既不需要 `id` 也不带 `source`——证据三条:
260
260
  * 1. installed `@deepseek-ai/dsh-llm/lib/types/types.d.ts` 的 `RequestUserInput`
261
261
  * 把两面都标成 `?: never`(`readonly id?: never` / `readonly source?: never`),
262
262
  * `GenerateOptions.messages` 收的是 `RequestMessage[] = Message | RequestUserInput`
@@ -368,19 +368,19 @@ const KEY_EXT = /* @__PURE__ */ new Set([
368
368
  * `db-password.json` 命中,而 `monkey.js`(key 前是 n)、`AUTHORS.md`(auth 后是 o)不命中。
369
369
  * 复数形式一并收进来:`tokens.json`、`accounts.json` 是真实存在的凭据文件名。 */
370
370
  const SECRET_PATTERN = /(?:^|[^a-z0-9])(?:credentials?|secrets?|id_rsa|pem|p12|pfx|keystore|env|keys?|tokens?|auth|passwd|password|accounts?)(?:[^a-z0-9]|$)/u;
371
- /** LLM 整理超时。 */
371
+ /** LLM 润色超时。 */
372
372
  /** schema .default() 的单源(host 消费走 config 字段,不再直读常量)。 */
373
373
  const ORGANIZE_TIMEOUT_MS = 12e4;
374
374
  /** 单个关键文件的摘要字节上限。harness 的 readWholeText 无上限,超限文件整份
375
375
  * 跳过(不截半份——半份摘要会以"全量"的名义喂给模型,比没有更误导),
376
376
  * 并计入 skipped.tooLarge 回报。 */
377
377
  const MAX_SNIPPET_BYTES = 262144;
378
- /** 单次整理带进模型的全部摘要的**总量**上限。
378
+ /** 单次润色带进模型的全部摘要的**总量**上限。
379
379
  *
380
380
  * 为什么需要总量而单文件上限不够:`maxSnippetBytes` 只管每个文件,而条目数不设上界
381
381
  * (用户拍板)。于是 client 把所有摘要拼成 `entriesSummary` 原样回投 organize,请求
382
382
  * 仍要过宿主 /api 网关的请求体上限,摘要一多就顶得过它,结果是 context 读面成功、
383
- * UI 正常列出文件树,用户点「整理」才在网关处失败。这里给总量封顶,让「context 成功」
383
+ * UI 正常列出文件树,用户点「润色」才在网关处失败。这里给总量封顶,让「context 成功」
384
384
  * 不再意味着「organize 必然失败」。留足余量:JSON 转义与 client 侧的拼接还会再放大一截。 */
385
385
  const MAX_CONTEXT_TOTAL_BYTES = 2097152;
386
386
  /** 文件读取并发上限:Promise.all 一次铺开会在导入内置角色库(整棵 agents/)时打满
@@ -657,7 +657,7 @@ async function collectDirContext(fs, cwd, messages, limits) {
657
657
  * 不得被 `/home/dev/project` 的字符串前缀放行),越界即拒并回显解析后的绝对路径;
658
658
  * - 命中根后,「根以内的剩余部分」仍逐段校验:`.` / `..` / 以 `.` 开头的隐藏段一律
659
659
  * 拒绝(cwd 里的 `.ssh/` 不因"在 cwd 之内"就可读)。根前缀本身不参与该判断,
660
- * 因此装在 ~/.dsh 下的项目也能导入自己 cwd 内的角色(旧版把这类 cwd 整体拦死)。
660
+ * 因此装在 ~/.dsh 下的项目也能导入自己 cwd 内的角色。
661
661
  * - 请求路径以 `.md` 结尾 → 单文件导入;否则按目录导入(顶层 *.md + 一层子目录
662
662
  * *.md,跳过隐藏项),目录扫描不递归更深层,但漏掉的必须计数回报。
663
663
  *
@@ -982,7 +982,7 @@ async function collectAgentTemplates(fs, requested, cwd, messages, opts) {
982
982
  }
983
983
  }
984
984
  /** 构造 system 提示(导出供测试)。规则正文与各段标题全部取自注入的字典——
985
- * 面向模型的 prompt 也随官方 locale 偏好切语言,zh 输出与迁移前逐字一致。 */
985
+ * 面向模型的 prompt 也随官方 locale 偏好切语言;zh 输出的正文逐字取自该字典。 */
986
986
  function buildOrganizeSystem(input, messages) {
987
987
  return [
988
988
  messages.sysRole,
@@ -1002,9 +1002,12 @@ function buildOrganizeSystem(input, messages) {
1002
1002
  * user 消息 = 草稿 + 围栏起来的不可信数据块。
1003
1003
  *
1004
1004
  * 围栏用**成对的定界标记**而不是缩进或横线:模型侧最容易被无视的是「看起来像普通内容」
1005
- * 的标记,而 `</data>` 这种成对标签既显眼、又难以由数据自身伪造(数据里出现的
1006
- * `</data>` 会被当作提前闭合,后续内容重新落回指令位——所以围栏内容仍按纯文本处理,
1007
- * 不做任何解析或转义)。
1005
+ * 的标记,而成对标签既显眼、又便于判断边界。
1006
+ *
1007
+ * ⚠ 标签本身拦不住数据:围栏内容来自用户仓库(目录摘要里的文件名、会话历史、角色 .md
1008
+ * 正文),里面完全可能含 `</data>`。原样拼进去会被读成提前闭合,其后的字符就重新落回
1009
+ * 指令位——围栏反而把不可信内容送到了它本该隔离的信任层。所以落进围栏的每一段文本都先
1010
+ * 把自己的定界标记替换成中性写法,标记只能由本函数产生。
1008
1011
  *
1009
1012
  * @param prompt - 真正的用户草稿
1010
1013
  * @param input - 其余上下文(摘要/历史/角色)
@@ -1012,9 +1015,10 @@ function buildOrganizeSystem(input, messages) {
1012
1015
  * @returns 交给模型的那条 user 文本
1013
1016
  */
1014
1017
  function buildOrganizeUser(prompt, input, messages) {
1018
+ const defused = (line) => line.split(messages.sysDataFenceStart).join("[fence-open]").split(messages.sysDataFenceEnd).join("[fence-close]");
1015
1019
  const fenced = (line) => [
1016
1020
  messages.sysDataFenceStart,
1017
- line,
1021
+ defused(line),
1018
1022
  messages.sysDataFenceEnd
1019
1023
  ].join("\n");
1020
1024
  const blocks = [
@@ -1088,7 +1092,7 @@ async function drainStreamToText(stream, messages) {
1088
1092
  }
1089
1093
  return text.trim();
1090
1094
  }
1091
- /** 整理入口(读面调用;导出供测试注入假 stream)。失败文案与 system 提示都来自
1095
+ /** 润色入口(读面调用;导出供测试注入假 stream)。失败文案与 system 提示都来自
1092
1096
  * 注入的字典,本函数不读设置。 */
1093
1097
  async function runOrganize(llm, input, messages, timeoutMs = ORGANIZE_TIMEOUT_MS, callerSignal) {
1094
1098
  const { prompt } = input;
@@ -1119,12 +1123,7 @@ async function runOrganize(llm, input, messages, timeoutMs = ORGANIZE_TIMEOUT_MS
1119
1123
  model: model.model,
1120
1124
  ...model.reasoningEffort === void 0 ? {} : { reasoningEffort: model.reasoningEffort },
1121
1125
  messages: llmMessages,
1122
- system: buildOrganizeSystem({
1123
- cwd: input.cwd,
1124
- ...input.entriesSummary === void 0 ? {} : { entriesSummary: input.entriesSummary },
1125
- ...input.recentTurns === void 0 ? {} : { recentTurns: input.recentTurns },
1126
- ...input.roleText === void 0 ? {} : { roleText: input.roleText }
1127
- }, messages),
1126
+ system: buildOrganizeSystem({ cwd: input.cwd }, messages),
1128
1127
  signal: controller.signal
1129
1128
  }), messages);
1130
1129
  if (content.length === 0) throw new Error(messages.emptyOrganizeResult);
@@ -1187,9 +1186,9 @@ function importAllowRootsOf(raw) {
1187
1186
  return roots;
1188
1187
  }
1189
1188
  /** 注入的服务面:settings 为硬依赖(cordis 等它就绪才 apply)。
1190
- * 0.1.7 起命名空间是隐式的(= 本条目在 cordis.patch.yml 里的裸 id,可编辑字段取自
1191
- * 导出的 Config),所以 settings 不再是「注册的前提」而是「页面策略(configure)与
1192
- * 跨命名空间读(describe)」的载体;设置页只派发「host 已 serve 的命名空间 ∩
1189
+ * 命名空间是隐式的(= 本条目在 cordis.patch.yml 里的裸 id,可编辑字段取自
1190
+ * 导出的 Config),所以 settings 在这里的职责是「页面策略(configure)与跨命名空间读
1191
+ * (describe)」,而非「注册的前提」;设置页只派发「host 已 serve 的命名空间 ∩
1193
1192
  * settings.plugin.item 卡」(dsh-client-ui-settings-plugins 源码语义),configure 必须
1194
1193
  * 发生在 apply 期,故仍硬注入。sessions/fs/llm/agentDefaultModel 仍可选读。 */
1195
1194
  const inject = ["settings"];
@@ -1218,8 +1217,8 @@ function resolveRecentTurns(sessions, sessionId) {
1218
1217
  }
1219
1218
  }
1220
1219
  /** 已解析的请求体 → 导入目标(拒绝时带回执的状态码与文案,由调用方原样发出)。
1221
- * path 缺失/非字符串 → 直接拒(旧版把它悄悄当成"留空",于是一个写坏字段的请求会
1222
- * 静默导入整个内置库——越界与坏输入都不许降级成"更多权限");只含空白字符的串同样
1220
+ * path 缺失/非字符串 → 直接拒(把它当成"留空"就是一个写坏字段的请求静默导入
1221
+ * 整个内置库——越界与坏输入都不许降级成"更多权限");只含空白字符的串同样
1223
1222
  * 是坏输入,不给降级空间(**精确空串**才是内置全量那个哨兵)。 */
1224
1223
  function importRequestOf(parsed, messages) {
1225
1224
  const { path: importPathRaw, sessionId } = isRecord(parsed) ? parsed : {};
@@ -1318,7 +1317,7 @@ function modelPayload(scope) {
1318
1317
  };
1319
1318
  }
1320
1319
  }
1321
- /** organize 请求体的输入面:JSON 已解析的 unknown → 整理入参(非字符串一律按空值处理)。 */
1320
+ /** organize 请求体的输入面:JSON 已解析的 unknown → 润色入参(非字符串一律按空值处理)。 */
1322
1321
  function organizeRequestOf(body) {
1323
1322
  const { prompt, sessionId, entriesSummary, roleText } = body;
1324
1323
  return {
@@ -1328,7 +1327,7 @@ function organizeRequestOf(body) {
1328
1327
  sessionId: typeof sessionId === "string" ? sessionId : null
1329
1328
  };
1330
1329
  }
1331
- /** 整理:LLM 调用与两层错误回执。内层 catch 是「整理过程本身失败」(回裸 errorText),
1330
+ /** 润色:LLM 调用与两层错误回执。内层 catch 是「润色过程本身失败」(回裸 errorText),
1332
1331
  * 外层是「装配入参时炸」。`messages` 每次调用现读一次,不在此处二次现读。 */
1333
1332
  async function organizePayload(scope, parsed) {
1334
1333
  const messages = scope.messagesOf();
@@ -1455,8 +1454,8 @@ function createRemotePayloads(deps, messagesOf) {
1455
1454
  /** 官方 Typert Remote 的服务键(= 线上命名空间)。 */
1456
1455
  const DIR_PREP_REMOTE_NAMESPACE = "dirPrepOrganize";
1457
1456
  /**
1458
- * 设置卡的宿主读面(官方 Typert Remote):目录上下文、当前模型、整理、导入与内置模板。
1459
- * 取代原先的五条 HTTP 端点(旧数据面已删除)。
1457
+ * 设置卡的宿主读面(官方 Typert Remote):目录上下文、当前模型、润色、导入与内置模板。
1458
+ * 本包不自建 HTTP 端点,认证与分派由宿主 /api 网关负责。
1460
1459
  */
1461
1460
  var DirPrepRemoteService = class extends TypertRemoteService {
1462
1461
  scope;
@@ -1513,7 +1512,7 @@ function installDirPrepRemote(ctx, scope) {
1513
1512
  /** settings 注册的占位清理(无额外拆卸动作,注册随插件生命周期存续)。 */
1514
1513
  function noopDisposer() {}
1515
1514
  /** host apply:登记设置页策略 + 注册官方 Remote 读面(注入子上下文,卸载即撤)。
1516
- * 0.1.7 起模板设置是**隐式注册**的(导出的 Config + 字段上的 .volatile()),本函数
1515
+ * 模板设置是**隐式注册**的(导出的 Config + 字段上的 .volatile()),本函数
1517
1516
  * 不再向 settings 注册任何东西;配置值由 cordis 校验并填过默认后按 volatile 引用交进来
1518
1517
  * (第二参数 config),读当前值一律 `.get()`。 */
1519
1518
  function apply(ctx, config) {
package/package.json CHANGED
@@ -1,7 +1,15 @@
1
1
  {
2
2
  "name": "@jayyuen66/dsh-dir-prep-organize",
3
- "version": "0.1.3",
4
- "description": "dsh 插件:对话输入框「整理」按钮(主键直接整理/▾ 以角色视角整理,结合当前目录 + session 模型整理优化草稿)+「模板」下拉(内置精选角色集生成自插件 agents/ 角色库,可按部门分组;设置卡可增删改/一键导入内置全部/导入本地角色 .md)",
3
+ "version": "0.1.5",
4
+ "description": "dsh 插件:对话输入框「润色」按钮(主键直接润色/▾ 以角色风格润色,结合当前目录 + session 模型润色草稿)+「模板」下拉(内置精选角色集生成自插件 agents/ 角色库,可按部门分组;设置卡可增删改/一键导入内置全部/导入本地角色 .md)",
5
+ "keywords": [
6
+ "cordis",
7
+ "dsh",
8
+ "dsh-plugin",
9
+ "prompt-engineering",
10
+ "role-template",
11
+ "ui"
12
+ ],
5
13
  "homepage": "https://github.com/JayYuen666/dsh-dir-prep-organize#readme",
6
14
  "bugs": {
7
15
  "url": "https://github.com/JayYuen666/dsh-dir-prep-organize/issues"
package/types/host.d.ts CHANGED
@@ -114,7 +114,7 @@ export interface SessionsService {
114
114
  get: (id: SessionId) => SessionLike | undefined;
115
115
  }
116
116
  /** `ReasoningEffortId` 取官方真品牌(`Branded<'ReasoningEffortId'>`,以 dsh-brand 的
117
- * `unique symbol` 为键)。原先本地重述成 `string & { effortBrand: ... }` 是**假品牌**:
117
+ * `unique symbol` 为键)。本地重述成 `string & { effortBrand: ... }` 是**假品牌**:
118
118
  * 键不同名即不同型,宿主真值塞不进来、任何带该属性的字符串反倒能通过,注释里那句
119
119
  * 「转换点为 0」并不成立。取官方类型后模型选择与 stream 入参两侧共用同一真值。 */
120
120
  export type { ReasoningEffortId } from "@deepseek-ai/dsh-llm";
@@ -157,8 +157,8 @@ export interface DirEntry {
157
157
  /** 关键文本文件首段摘要;非关键文件/目录为 undefined。 */
158
158
  snippet: string | undefined;
159
159
  }
160
- /** 静默丢数据的记账(审计修复:原先"读失败即 undefined、超限即忽略"完全没有
161
- * 回执,界面与 host 都显示成功)。dir context 与 import 两个读面共用此形状。 */
160
+ /** 静默丢数据的记账("读失败即 undefined、超限即忽略"的话没有任何回执,
161
+ * 界面与 host 都显示成功)。dir context 与 import 两个读面共用此形状。 */
162
162
  export interface SkipCounts {
163
163
  /** 字节超限、整份跳过的文件数。 */
164
164
  tooLarge: number;
@@ -245,20 +245,23 @@ export interface OrganizeInput {
245
245
  entriesSummary?: string;
246
246
  /** 会话最近对话文本(user/assistant 交替,host 侧从 deriveMessages 提取)。 */
247
247
  recentTurns?: string;
248
- /** 参考角色上下文(提炼自模板正文;可选)。提供时整理以其角色视角重写需求。 */
248
+ /** 参考角色上下文(提炼自模板正文;可选)。提供时借用该角色的术语与风格润色草稿。 */
249
249
  roleText?: string;
250
250
  model?: ModelSelection;
251
251
  }
252
252
  /** 构造 system 提示(导出供测试)。规则正文与各段标题全部取自注入的字典——
253
- * 面向模型的 prompt 也随官方 locale 偏好切语言,zh 输出与迁移前逐字一致。 */
253
+ * 面向模型的 prompt 也随官方 locale 偏好切语言;zh 输出的正文逐字取自该字典。 */
254
254
  export declare function buildOrganizeSystem(input: Omit<OrganizeInput, "prompt">, messages: HostMessages): string;
255
255
  /**
256
256
  * user 消息 = 草稿 + 围栏起来的不可信数据块。
257
257
  *
258
258
  * 围栏用**成对的定界标记**而不是缩进或横线:模型侧最容易被无视的是「看起来像普通内容」
259
- * 的标记,而 `</data>` 这种成对标签既显眼、又难以由数据自身伪造(数据里出现的
260
- * `</data>` 会被当作提前闭合,后续内容重新落回指令位——所以围栏内容仍按纯文本处理,
261
- * 不做任何解析或转义)。
259
+ * 的标记,而成对标签既显眼、又便于判断边界。
260
+ *
261
+ * ⚠ 标签本身拦不住数据:围栏内容来自用户仓库(目录摘要里的文件名、会话历史、角色 .md
262
+ * 正文),里面完全可能含 `</data>`。原样拼进去会被读成提前闭合,其后的字符就重新落回
263
+ * 指令位——围栏反而把不可信内容送到了它本该隔离的信任层。所以落进围栏的每一段文本都先
264
+ * 把自己的定界标记替换成中性写法,标记只能由本函数产生。
262
265
  *
263
266
  * @param prompt - 真正的用户草稿
264
267
  * @param input - 其余上下文(摘要/历史/角色)
@@ -283,7 +286,7 @@ export declare function buildOrganizeUser(prompt: string, input: Omit<OrganizeIn
283
286
  export declare function extractRecentTurns(messages: readonly DerivedMessageView[]): string;
284
287
  /** 流式聚合 text-delta 为完整文本;终态非 stop 视为失败(失败文本取自注入字典)。 */
285
288
  export declare function drainStreamToText(stream: AsyncIterable<StreamChunk>, messages: HostMessages): Promise<string>;
286
- /** 整理入口(读面调用;导出供测试注入假 stream)。失败文案与 system 提示都来自
289
+ /** 润色入口(读面调用;导出供测试注入假 stream)。失败文案与 system 提示都来自
287
290
  * 注入的字典,本函数不读设置。 */
288
291
  export declare function runOrganize(llm: LlmService, input: OrganizeInput, messages: HostMessages, timeoutMs?: number, callerSignal?: AbortSignal): Promise<{
289
292
  content: string;
@@ -342,7 +345,7 @@ declare const configSchema: ReturnType<typeof Schema.object<typeof configShape>>
342
345
  export interface Config {
343
346
  templates: Volatile<TemplateEntry[] | undefined>;
344
347
  importAllowRoots: Volatile<string[]>;
345
- /** LLM 整理中止时限(volatile:客户端经 configForms 快照同源读取)。 */
348
+ /** LLM 润色中止时限(volatile:客户端经 configForms 快照同源读取)。 */
346
349
  organizeTimeoutMs: Volatile<number>;
347
350
  /** 关键文件摘要的单文件字节上限(超出整份跳过)。 */
348
351
  maxSnippetBytes: number;
@@ -355,9 +358,9 @@ export { configSchema as Config };
355
358
  * 丢弃——绝不能把非字符串塞进路径校验,也不能让空串变成"允许 process.cwd()"。 */
356
359
  export declare function importAllowRootsOf(raw: unknown): string[];
357
360
  /** 注入的服务面:settings 为硬依赖(cordis 等它就绪才 apply)。
358
- * 0.1.7 起命名空间是隐式的(= 本条目在 cordis.patch.yml 里的裸 id,可编辑字段取自
359
- * 导出的 Config),所以 settings 不再是「注册的前提」而是「页面策略(configure)与
360
- * 跨命名空间读(describe)」的载体;设置页只派发「host 已 serve 的命名空间 ∩
361
+ * 命名空间是隐式的(= 本条目在 cordis.patch.yml 里的裸 id,可编辑字段取自
362
+ * 导出的 Config),所以 settings 在这里的职责是「页面策略(configure)与跨命名空间读
363
+ * (describe)」,而非「注册的前提」;设置页只派发「host 已 serve 的命名空间 ∩
361
364
  * settings.plugin.item 卡」(dsh-client-ui-settings-plugins 源码语义),configure 必须
362
365
  * 发生在 apply 期,故仍硬注入。sessions/fs/llm/agentDefaultModel 仍可选读。 */
363
366
  export declare const inject: string[];
@@ -370,7 +373,7 @@ export interface RouteDeps {
370
373
  agentDefaultModel?: () => AgentDefaultModel | undefined;
371
374
  /** 设置里登记的额外导入允许根(每次请求现读,改设置无需重启)。 */
372
375
  importAllowRoots?: () => readonly string[];
373
- /** 部署值(Config 化):整理超时 / 摘要字节上限 / 读取并发。
376
+ /** 部署值(Config 化):润色超时 / 摘要字节上限 / 读取并发。
374
377
  * 缺省回落原模块常量(与 schema .default 同值)——测试与旧调用方不必逐一改。 */
375
378
  limits?: () => RouteLimits;
376
379
  /** 内置精选模板表的取数口。缺省走按需 import 产物;测试替掉它即可覆盖载入失败那条回执,
@@ -412,8 +415,8 @@ interface ImportTemplatesRequest {
412
415
  sessionId: string;
413
416
  }
414
417
  /**
415
- * 设置卡的宿主读面(官方 Typert Remote):目录上下文、当前模型、整理、导入与内置模板。
416
- * 取代原先的五条 HTTP 端点(旧数据面已删除)。
418
+ * 设置卡的宿主读面(官方 Typert Remote):目录上下文、当前模型、润色、导入与内置模板。
419
+ * 本包不自建 HTTP 端点,认证与分派由宿主 /api 网关负责。
417
420
  */
418
421
  export declare class DirPrepRemoteService extends TypertRemoteService {
419
422
  private readonly scope;
@@ -427,7 +430,7 @@ export declare class DirPrepRemoteService extends TypertRemoteService {
427
430
  /** 注册读面(构造即注册);替身上下文没有注册口时只少掉这一栏。 */
428
431
  export declare function installDirPrepRemote(ctx: Context, scope: RemoteScope): boolean;
429
432
  /** host apply:登记设置页策略 + 注册官方 Remote 读面(注入子上下文,卸载即撤)。
430
- * 0.1.7 起模板设置是**隐式注册**的(导出的 Config + 字段上的 .volatile()),本函数
433
+ * 模板设置是**隐式注册**的(导出的 Config + 字段上的 .volatile()),本函数
431
434
  * 不再向 settings 注册任何东西;配置值由 cordis 校验并填过默认后按 volatile 引用交进来
432
435
  * (第二参数 config),读当前值一律 `.get()`。 */
433
436
  export declare function apply(ctx: Context, config: Config): void;
@@ -12,19 +12,19 @@ export declare const ORGANIZE_TIMEOUT_SLACK_MS = 5000;
12
12
  * `organizeTimeoutMs` 的前端取表。
13
13
  *
14
14
  * 上界与 host 同为 `[1, MAX_TIMER_MS]`:host 自己夹了上界正是为了躲开上面那个静默夹断,
15
- * 而这一侧是**唯一**发起整理读面调用的地方,它要是没夹,host 夹得再对也没用。
15
+ * 而这一侧是**唯一**发起润色读面调用的地方,它要是没夹,host 夹得再对也没用。
16
16
  *
17
17
  * @param value - 配置表单投影值
18
18
  * @returns `[1, MAX_TIMER_MS]` 区间内的整数;不合法时 undefined(回落默认)
19
19
  */
20
20
  export declare function rawOrganizeTimeoutMsOf(value: Record<string, unknown>): number | undefined;
21
21
  /**
22
- * 整理请求的客户端超时:host 的整理时限 + 余量,整条结果同样夹进 `[1, MAX_TIMER_MS]`。
22
+ * 润色请求的客户端超时:host 的润色时限 + 余量,整条结果同样夹进 `[1, MAX_TIMER_MS]`。
23
23
  *
24
24
  * **加法之后还要再夹一次**,因为 `MAX_TIMER_MS + ORGANIZE_TIMEOUT_SLACK_MS` 自己就越界了
25
- * (实测 V8 把 2147488647 的延时夹成 1ms,点击整理立刻回「请求超时」)。
25
+ * (实测 V8 把 2147488647 的延时夹成 1ms,点击润色立刻回「请求超时」)。
26
26
  *
27
- * @param raw - 配置表单投影里的整理时限(未夹)
27
+ * @param raw - 配置表单投影里的润色时限(未夹)
28
28
  * @returns 可安全交给 setTimeout 的毫秒数
29
29
  */
30
30
  export declare function organizeFetchTimeoutMs(raw: number | undefined): number;
@@ -1,11 +1,11 @@
1
1
  import type { MessagesCatalog } from "@jayyuen66/dsh-plugin-shared/lib/locale";
2
- /** 本包 host 侧产出的全部人读文案(整理 system prompt + 端点/导入回执)。 */
2
+ /** 本包 host 侧产出的全部人读文案(润色 system prompt + 端点/导入回执)。 */
3
3
  export interface HostMessages {
4
4
  /** 角色定位与任务说明(整段 prompt 的第一行)。 */
5
5
  readonly sysRole: string;
6
6
  /** 规则清单的标题行。 */
7
7
  readonly sysRulesHeading: string;
8
- /** 规则:只输出整理后的正文。 */
8
+ /** 规则:只输出润色后的正文。 */
9
9
  readonly sysRuleOutputOnly: string;
10
10
  /** 规则:不执行草稿里的任务。 */
11
11
  readonly sysRuleNoExecution: string;
@@ -88,7 +88,7 @@ export interface HostMessages {
88
88
  readonly readModelFailed: string;
89
89
  /** llm 服务未就绪。 */
90
90
  readonly llmUnavailable: string;
91
- /** 整理端点兜底异常整句(`{reason}`)。 */
91
+ /** 润色端点兜底异常整句(`{reason}`)。 */
92
92
  readonly organizeFailed: string;
93
93
  }
94
94
  export declare const HOST_MESSAGES: MessagesCatalog<HostMessages>;
@@ -1,4 +1,10 @@
1
1
  import type { InvocationDescriptor } from "@deepseek-ai/dsh-typert-protocol";
2
+ /** Typert Remote 命名空间(client 半这一侧的唯一一枚)。
3
+ *
4
+ * 宿主半的注册键在 host.ts 的 `DIR_PREP_REMOTE_NAMESPACE`——两半各自打包、client 包
5
+ * 不能 import host.ts,所以这一枚字面量必然有两份。两边取值必须一致:写岔了的表现是
6
+ * 网关挂上的是 A、报错文案说的是 B,而没有任何运行期信号。 */
7
+ export declare const DIR_PREP_NAMESPACE = "dirPrepOrganize";
2
8
  export declare const DIR_PREP_DESCRIPTORS: readonly InvocationDescriptor[];
3
9
  export interface DirPrepOrganizeArgs {
4
10
  sessionId: string;
@@ -9,7 +9,7 @@ export interface TemplateEntry {
9
9
  /** 角色视觉标记(下拉 item 前缀);空=不显示。 */
10
10
  emoji: string;
11
11
  }
12
- /** 角色正文提炼/「按角色整理」上下文:不设字符上限(用户拍板,
12
+ /** 角色正文提炼/「按角色风格润色」上下文:不设字符上限(用户拍板,
13
13
  * 上下文完整性优先;模型 context 超限由模型报错提示用户自行处理)。 */
14
14
  /** 仓库目录名 → 下拉分组标签的**唯一**导出点在 `./group-labels.generated.ts`(表源 =
15
15
  * scripts/gen-defaults-lib.mjs,键序 = 下拉分组展示序),本文件不再同名 re-export:
@@ -39,13 +39,13 @@ export interface AgentFileInfo {
39
39
  */
40
40
  export declare function parseAgentFrontmatter(text: string): AgentFileInfo | undefined;
41
41
  /**
42
- * 角色正文提炼(导入 / 「按角色整理」共用):取叙述主干、去代码围栏。
42
+ * 角色正文提炼(导入 / 「按角色风格润色」共用):取叙述主干、去代码围栏。
43
43
  *
44
44
  * 规则(确定性,测试锁死):
45
45
  * - ``` 围栏行整体剔除(围栏内容多为长代码样例,对角色语境价值低);
46
46
  * - 行内反引号一并剔除——沿用"正文不含反引号、插入不破坏 markdown 围栏"不变式;
47
47
  * - 不设字符上限(用户拍板):全量保留叙述内容,避免截断影响
48
- * 「以角色整理」的上下文完整性;模型 context 超限由模型报错提示用户自行处理;
48
+ * 「以角色风格润色」的上下文完整性;模型 context 超限由模型报错提示用户自行处理;
49
49
  * - 结果 trim;空正文(全围栏/全空白)→ 空串。
50
50
  */
51
51
  export declare function condenseRoleBody(body: string): string;
@@ -2,9 +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
- /** 卡片标题(设置页插件列表里的那一行)。 */
5
+ /** 卡片标题(设置页插件列表里的那一行):这份列表同时喂「模板」下拉与「润色」▾。 */
6
6
  readonly cardTitle: string;
7
- /** 卡片副标题:一句话说明这张卡管什么。 */
7
+ /** 卡片副标题:一句话说明这张卡管什么(数据源、空表回落、导入放行面)。 */
8
8
  readonly cardDescription: string;
9
9
  /** 设置源可写位为 false 时的状态条。 */
10
10
  readonly statusReadOnly: string;
@@ -122,33 +122,33 @@ export interface UiMessages {
122
122
  readonly rootsAdd: string;
123
123
  /** 允许目录面板的规则说明(绝对路径默认拒绝)。 */
124
124
  readonly rootsHint: string;
125
- /** dock 注册项 label:「整理」按钮。 */
125
+ /** dock 注册项 label:「润色」按钮。 */
126
126
  readonly dockOrganizeEntry: string;
127
127
  /** dock 注册项 label:「模板」按钮。 */
128
128
  readonly dockTemplatesEntry: string;
129
- /** 「整理」主键(空闲态)。 */
129
+ /** 「润色」主键(空闲态)。 */
130
130
  readonly organizeIdle: string;
131
- /** 「整理」主键(请求中)。 */
131
+ /** 「润色」主键(请求中)。 */
132
132
  readonly organizeLoading: string;
133
- /** 「整理」主键(失败闪烁)。 */
133
+ /** 「润色」主键(失败闪烁)。 */
134
134
  readonly organizeFailedShort: string;
135
- /** 「整理」按钮 title(空闲态)。 */
135
+ /** 「润色」按钮 title(空闲态)。 */
136
136
  readonly organizeIdleTitle: string;
137
- /** 「整理」失败时 title 前缀(后接错误摘要)。 */
137
+ /** 「润色」失败时 title 前缀(后接错误摘要)。 */
138
138
  readonly organizeFailedTitle: string;
139
139
  /** ▾ 角色菜单按钮的 aria-label。 */
140
140
  readonly organizeCaretAria: string;
141
141
  /** ▾ 角色菜单按钮的 title。 */
142
142
  readonly organizeCaretTitle: string;
143
- /** 「整理」主键的 aria-label。 */
143
+ /** 「润色」主键的 aria-label。 */
144
144
  readonly organizeMainAria: string;
145
- /** 角色菜单首项:直接整理。 */
145
+ /** 角色菜单首项:直接润色。 */
146
146
  readonly organizeDirectItem: string;
147
147
  /** 角色菜单空态(没有任何模板)。 */
148
148
  readonly organizeNoTemplates: string;
149
149
  /** 角色菜单条目({name} = 模板名)。 */
150
150
  readonly organizeRoleItem: string;
151
- /** 整理成功但输入框动作缺失时抛出的错误(会闪烁在按钮上)。 */
151
+ /** 润色成功但输入框动作缺失时抛出的错误(会闪烁在按钮上)。 */
152
152
  readonly organizeWriteBackUnavailable: string;
153
153
  /** 「模板」按钮 title(可写时)。 */
154
154
  readonly templatesIdleTitle: string;
@@ -172,7 +172,7 @@ export interface UiMessages {
172
172
  * `dsh-client-ui-slots/lib/types/index.d.ts`「Dictionary owners extend via declaration
173
173
  * merging (exactly like SlotMap)」)。这不是美化:不 merge 时 `ctx.locale.bind(NS)` 只能
174
174
  * 落到官方那条**未类型化**重载(返回 `Translate<string>`),卡片要的窄键集 `t` 就无官方
175
- * 来源,本地只好手写一份同构签名(就是被这一段替换掉的旧版本)。
175
+ * 来源,本地只好手写一份同构签名。
176
176
  * ⚠ interface 键位必须是字面量,故用下面的等式常量把它与 client-entry.ts 的 `NS` 钉住。
177
177
  */
178
178
  declare module "@deepseek-ai/dsh-client-ui-slots" {