@jayyuen66/dsh-dir-prep-organize 0.1.5 → 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.
Files changed (86) hide show
  1. package/CHANGELOG.md +146 -0
  2. package/LICENSE +1 -1
  3. package/README.md +25 -21
  4. package/README.zh-CN.md +25 -21
  5. package/THIRD_PARTY_NOTICES.md +3 -1
  6. package/agents/academic/academic-statistician.md +143 -0
  7. package/agents/design/design-inclusive-visuals-specialist.md +4 -3
  8. package/agents/design/design-ui-designer.md +6 -3
  9. package/agents/design/design-ux-architect.md +20 -7
  10. package/agents/design/design-whimsy-injector.md +23 -1
  11. package/agents/engineering/engineering-autonomous-optimization-architect.md +31 -22
  12. package/agents/engineering/engineering-backend-architect.md +43 -54
  13. package/agents/engineering/engineering-data-engineer.md +21 -6
  14. package/agents/engineering/engineering-database-optimizer.md +22 -10
  15. package/agents/engineering/engineering-devops-automator.md +12 -3
  16. package/agents/engineering/engineering-email-intelligence-engineer.md +41 -4
  17. package/agents/engineering/engineering-embedded-firmware-engineer.md +27 -5
  18. package/agents/engineering/engineering-feishu-integration-developer.md +10 -2
  19. package/agents/engineering/engineering-frontend-developer.md +24 -18
  20. package/agents/engineering/engineering-git-workflow-master.md +16 -4
  21. package/agents/engineering/engineering-incident-response-commander.md +3 -3
  22. package/agents/engineering/engineering-prompt-engineer.md +7 -2
  23. package/agents/engineering/engineering-rapid-prototyper.md +7 -3
  24. package/agents/engineering/engineering-security-engineer.md +2 -0
  25. package/agents/engineering/engineering-solidity-smart-contract-engineer.md +1 -1
  26. package/agents/engineering/engineering-technical-writer.md +4 -4
  27. package/agents/engineering/engineering-threat-detection-engineer.md +2 -0
  28. package/agents/engineering/engineering-voice-ai-integration-engineer.md +39 -16
  29. package/agents/engineering/engineering-wechat-mini-program-developer.md +7 -2
  30. package/agents/game-development/blender/blender-addon-engineer.md +12 -3
  31. package/agents/game-development/economy-designer.md +155 -0
  32. package/agents/game-development/godot/godot-gameplay-scripter.md +4 -0
  33. package/agents/game-development/godot/godot-multiplayer-engineer.md +6 -2
  34. package/agents/game-development/godot/godot-shader-developer.md +4 -3
  35. package/agents/game-development/roblox-studio/roblox-experience-designer.md +7 -6
  36. package/agents/game-development/roblox-studio/roblox-systems-scripter.md +7 -0
  37. package/agents/game-development/technical-artist.md +4 -0
  38. package/agents/game-development/unity/unity-multiplayer-engineer.md +67 -0
  39. package/agents/game-development/unreal-engine/unreal-multiplayer-architect.md +82 -31
  40. package/agents/game-development/unreal-engine/unreal-systems-engineer.md +13 -1
  41. package/agents/marketing/marketing-agentic-search-optimizer.md +50 -87
  42. package/agents/marketing/marketing-carousel-growth-engine.md +49 -35
  43. package/agents/marketing/marketing-private-domain-operator.md +2 -2
  44. package/agents/marketing/marketing-seo-specialist.md +22 -0
  45. package/agents/product/product-behavioral-nudge-engine.md +3 -0
  46. package/agents/project-management/project-management-jira-workflow-steward.md +5 -2
  47. package/agents/security/security-appsec-engineer.md +75 -43
  48. package/agents/security/security-threat-detection-engineer.md +6 -0
  49. package/agents/security/security-threat-intelligence-analyst.md +32 -15
  50. package/agents/specialized/accounts-payable-agent.md +39 -45
  51. package/agents/specialized/grant-writer.md +2 -2
  52. package/agents/specialized/healthcare-aging-parent-care-companion.md +396 -0
  53. package/agents/specialized/identity-graph-operator.md +24 -3
  54. package/agents/specialized/lsp-index-engineer.md +17 -15
  55. package/agents/specialized/recruitment-specialist.md +17 -11
  56. package/agents/specialized/specialized-developer-advocate.md +4 -4
  57. package/agents/specialized/specialized-fedramp-rmf-compliance.md +379 -0
  58. package/agents/specialized/specialized-focus-music-architect.md +176 -0
  59. package/agents/specialized/specialized-french-consulting-market.md +17 -15
  60. package/agents/specialized/specialized-model-qa.md +78 -34
  61. package/agents/specialized/specialized-salesforce-architect.md +17 -15
  62. package/agents/specialized/specialized-workflow-architect.md +2 -2
  63. package/agents/supply-chain/supply-chain-strategist.md +12 -3
  64. package/agents/support/support-analytics-reporter.md +48 -30
  65. package/agents/support/support-finance-tracker.md +36 -18
  66. package/agents/support/support-infrastructure-maintainer.md +2 -2
  67. package/agents/support/support-support-responder.md +43 -26
  68. package/agents/testing/testing-api-tester.md +37 -27
  69. package/agents/testing/testing-performance-benchmarker.md +82 -47
  70. package/agents/testing/testing-test-results-analyzer.md +37 -18
  71. package/agents/testing/testing-tool-evaluator.md +30 -10
  72. package/client.js +470 -287
  73. package/cordis.patch.yml +4 -23
  74. package/docs/DETAIL.md +26 -0
  75. package/docs/DETAIL.zh.md +26 -0
  76. package/host.js +84 -25
  77. package/locale/en.json +7 -0
  78. package/locale/zh.json +7 -0
  79. package/package.json +61 -52
  80. package/templates.data.mjs +9 -10
  81. package/types/host.d.ts +36 -4
  82. package/types/src/client-entry.d.ts +2 -3
  83. package/types/src/host-messages.d.ts +2 -0
  84. package/types/src/input-writeback.d.ts +32 -0
  85. package/types/src/remote.d.ts +7 -1
  86. package/types/src/ui-messages.d.ts +19 -6
package/cordis.patch.yml CHANGED
@@ -1,26 +1,7 @@
1
- # dir-prep-organize(润色 + 模板;内容源为内置角色库)。
2
- # 功能一「润色」:输入框右上角分段按钮。主键点击 → 按当前目录结构 + 当前 session
3
- # 模型润色草稿(成功直接替换,失败保持原值);▾ → 「以 XX 的风格润色」(角色菜单,
4
- # 角色上下文 = 模板正文提炼,随 organize 调用注入 user 的 <data> 围栏,走同一 LLM 流)。
5
- # 功能二「模板」:输入框旁「模板」下拉,默认展示精选角色集(由 scripts/gen-defaults.mjs
6
- # 从插件 agents/ 目录生成,src/default-templates.generated.ts 单源),按 group 分组
7
- # 渲染(emoji + 名称 + description 悬停);点选插入草稿(空整段填入 / 非空末尾追加)。
8
- # 列表存 settings(隐式注册:命名空间 = 本条目 id,可编辑字段 = host.ts 导出的
9
- # Config 上标了 .volatile() 的那几项;内置精选集是 client 半在配置缺席时的回落),
10
- # 设置页卡逐条增删改(name/emoji/
11
- # group/description/text)+ 两步确认恢复默认 + 角色导入(importTemplates:留空 = 一键
12
- # 导入内置 agents/ 全部;填路径 = 导入本地 .md 或目录)。client 直读本条目的配置表单
13
- # (ctx.configForms.get(条目 id),没有 settingsScope 这一层)。
14
- #
15
- # 架构:Host 半(host.ts)注册官方 Typert Remote 的服务键 `dirPrepOrganize`,
16
- # 它导出的方法表就是全部读面;
17
- # 认证、Host/DNS 重绑定/Origin 判据与请求体上限由宿主 /api 网关承担,本包不注册
18
- # HTTP 路由、也没有自建 CSRF 令牌。Client 半(src/client-entry.ts → client.js)注册
19
- # conversation.input.right list 槽(润色 id=dir-prep-organize order 99 / 模板
20
- # id=dir-prep-organize-templates order 100)与 plugins.bundle.config 设置卡(keyed,
21
- # 旧设置页的 settings.plugin.item 面已不存在);润色经 Remote 读取器调用上述方法,写回走
22
- # inputActions.setDraft;模板读写配置表单 ctx.configForms.get(条目 id)(数组 set=字段级整体替换,
23
- # 已按 dsh-settings applyPathOp/cloneJsonShaped 源码取证)。
1
+ # 本包提供的输入框「润色」与「模板」能力由 client 半注册成 dock 条目;这份 patch 只负责
2
+ # 把 bundle 插进插件层栈。设置卡数据面走官方 Typert Remote 的 dirPrepOrganize 命名空间,
3
+ # 内置精选集由 host 半从 templates.data.mjs 经 defaults 方法按需下发。
4
+ # 架构与数据流见 README 与 host.ts / src/client-entry.ts。
24
5
  - insert:
25
6
  - id: dir-prep-organize
26
7
  name: "@jayyuen66/dsh-dir-prep-organize"
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
@@ -6,7 +6,7 @@ import { Remote, TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
6
6
  import { LOCALE_SETTINGS_NAMESPACE, messagesFor, resolveLocalePreference } from "@jayyuen66/dsh-plugin-shared/lib/locale";
7
7
  import { isRecord } from "@jayyuen66/dsh-plugin-shared/lib/record";
8
8
  import { errorText } from "@jayyuen66/dsh-plugin-shared/lib/errors";
9
- //#region src/host-messages.ts
9
+ // src/host-messages.ts
10
10
  const HOST_MESSAGES = {
11
11
  zh: {
12
12
  sysRole: "你是输入框内容润色助手。用户在 dsh 对话输入框写了一段要求,你需要结合当前工作目录的结构与会话最近上下文,把它润色成一段更清晰、可直接发送的要求。",
@@ -14,7 +14,7 @@ const HOST_MESSAGES = {
14
14
  sysRuleOutputOnly: "- 输出只有润色后的正文,不要任何前言、markdown 代码围栏、标题或解释。",
15
15
  sysRuleNoExecution: "- 不执行草稿中要求的任何任务:不写代码、不回答问题、不审查/不搜索/不生成任何内容——只润色文本本身(重组措辞与结构、补全缺失的上下文、消歧指代)。",
16
16
  sysRuleNoAnswer: "- 若草稿本身是问题或待办指令,润色结果仍是同一问题/指令的清晰完整版本,不要把解答、方案或示例写进润色结果。",
17
- sysRuleKeepIntent: "- 保留用户原意与语言(中文保持中文);缺失的关键信息(如目标文件/模块)若能从目录结构或最近对话推断就补上,推断不了不要编造。",
17
+ sysRuleKeepIntent: "- 保留用户原意与语言(用草稿本身的文字写,不换语言);缺失的关键信息(如目标文件/模块)若能从目录结构或最近对话推断就补上,推断不了不要编造。",
18
18
  sysRuleResolveRefs: "- 最近对话可能含相关指代(\"上面说的\"\"刚才那个文件\"),润色时把指代解析成明确表述。",
19
19
  sysRuleNoListing: "- 目录结构与对话历史仅是参考,不要罗列它们本身。",
20
20
  sysRuleRoleView: "- 若提供了参考角色,只借用其专业术语与措辞风格来润色草稿,不得以角色身份实际执行任务(如审查、修复、生成内容)。",
@@ -48,6 +48,7 @@ const HOST_MESSAGES = {
48
48
  emptyPrompt: "用户要求为空,无法润色",
49
49
  noModelSelected: "当前无可用模型选择",
50
50
  emptyOrganizeResult: "模型润色结果为空",
51
+ organizeTimeout: "润色超时:{seconds} 秒内模型未返回完整结果(可在设置里调大超时)",
51
52
  fsUnavailable: "fs 服务不可用",
52
53
  cwdUnknown: "无法确定会话 cwd(sessionId 缺失或会话不存在)",
53
54
  modelServiceUnavailable: "agentDefaultModel 服务不可用",
@@ -80,7 +81,7 @@ const HOST_MESSAGES = {
80
81
  rootLabelCwd: "session cwd",
81
82
  rootLabelBuiltin: "built-in role library",
82
83
  rootLabelAllowed: "importAllowRoots allowed directory",
83
- outsideRoots: "Import path out of bounds: absolute paths are refused by default, only inside {zones} are allowed; received: {absolute}",
84
+ outsideRoots: "Import path out of bounds: absolute paths are refused by default; allowed only inside \"{zones}\"; received: {absolute}",
84
85
  zoneSeparator: ", ",
85
86
  emptyImportPath: "The import path cannot be empty (give a role .md or a directory path; an empty path only means the built-in role library when you press \"Import roles\" on the settings card)",
86
87
  relativeNeedsCwd: "A relative path needs the session cwd (use an absolute path instead)",
@@ -95,6 +96,7 @@ const HOST_MESSAGES = {
95
96
  emptyPrompt: "The request is empty: nothing to polish",
96
97
  noModelSelected: "No model selection is available",
97
98
  emptyOrganizeResult: "The model returned an empty result",
99
+ organizeTimeout: "Polishing timed out: the model did not finish within {seconds} seconds (the timeout is configurable in settings)",
98
100
  fsUnavailable: "fs service unavailable",
99
101
  cwdUnknown: "Cannot determine the session cwd (sessionId missing or session unknown)",
100
102
  modelServiceUnavailable: "agentDefaultModel service unavailable",
@@ -103,8 +105,7 @@ const HOST_MESSAGES = {
103
105
  organizeFailed: "Polishing failed: {reason}"
104
106
  }
105
107
  };
106
- //#endregion
107
- //#region src/group-labels.generated.ts
108
+ // src/group-labels.generated.ts
108
109
  /** 仓库目录名 → 下拉分组标签;未收录的目录回落目录名本身(见 templates.ts groupLabelOf)。 */
109
110
  const AGENT_DIR_GROUP_LABELS = {
110
111
  academic: "学术",
@@ -132,8 +133,10 @@ const AGENT_DIR_GROUP_LABELS = {
132
133
  support: "客户支持",
133
134
  testing: "测试"
134
135
  };
135
- //#endregion
136
- //#region src/templates.ts
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,15 +248,18 @@ 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
- for (const raw of lines) if (raw.trim().startsWith("```")) inFence = !inFence;
252
- else if (inFence) {} else out.push(raw.replaceAll("`", ""));
254
+ let fenceStart = 0;
255
+ for (const [index, raw] of lines.entries()) if (raw.trim().startsWith("```")) {
256
+ fenceStart = inFence ? 0 : index + 1;
257
+ inFence = !inFence;
258
+ } else if (inFence) {} else out.push(raw.replaceAll("`", ""));
259
+ if (inFence) throw new Error(`正文第 ${String(fenceStart)} 行的代码围栏没有结束标记(\`\`\`)`);
253
260
  return out.join("\n").trim();
254
261
  }
255
- //#endregion
256
- //#region host.ts
262
+ // host.ts
257
263
  /** 本包送进 `llm.stream({ messages })` 的润色请求帧是 **request-only 输入**:它从不落
258
264
  * 任何持久消息位(`runOrganize` 只回 `{ content }`,读面也不把帧身份回投给卡片),所以
259
265
  * 它既不需要 `id` 也不带 `source`——证据三条:
@@ -417,11 +423,14 @@ function hasFnMember(value, member) {
417
423
  return typeof value[member] === "function";
418
424
  }
419
425
  function isSettingsService(value) {
420
- return hasFnMember(value, "describe");
426
+ return hasFnMember(value, "describe") && hasFnMember(value, "configure");
421
427
  }
422
428
  function isSessionsService(value) {
423
429
  return hasFnMember(value, "get");
424
430
  }
431
+ function isAgentsService(value) {
432
+ return hasFnMember(value, "get");
433
+ }
425
434
  function isFsService(value) {
426
435
  return hasFnMember(value, "resolve") && hasFnMember(value, "stat");
427
436
  }
@@ -437,6 +446,16 @@ function isServiceGetter(value) {
437
446
  /** 字典里的 `{name}` 占位填充(与卡片侧官方 Translate 同语义,host 侧没有官方 translator
438
447
  * 故自带)。用 split/join 而不是 replace:路径与模型回文里可能带 `$`,而字符串版
439
448
  * replace 会把 `$&` / `$1` 当替换模式解释。 */
449
+ /** 换行与控制字符(`Cc` 含 \r\n\t,`Zl`/`Zp` 是 Unicode 行分隔与段分隔)。 */
450
+ const LINE_BREAKERS = /[\p{Cc}\p{Zl}\p{Zp}]+/gu;
451
+ /** 把一段宿主文本压成单行。
452
+ *
453
+ * system 槽里每条内容独占一行,模型按行读它——任何能从外部带的换行都能在 system 里凭空
454
+ * 造出下一行,而那正是最高信任位。cwd 取自会话工作目录,是文件名,POSIX 允许目录名带换行。
455
+ * 这里不改成转义序列:读的人只需要知道「这一行就是那个路径」,多出来的字节不必还原。 */
456
+ function singleLine(text) {
457
+ return text.replaceAll(LINE_BREAKERS, " ");
458
+ }
440
459
  function fillTemplate(template, tokens) {
441
460
  let text = template;
442
461
  for (const [token, value] of tokens) text = text.split(token).join(value);
@@ -664,12 +683,14 @@ async function collectDirContext(fs, cwd, messages, limits) {
664
683
  * 门禁后仍要求每个文件能解析出非空 frontmatter name(parseAgentFrontmatter),
665
684
  * 否则跳过并计数——绝不返回任意文件原文,只产出模板条目形状。
666
685
  */
686
+ /** 两种路径分隔符(win32 与 POSIX)。 */
687
+ const PATH_SEPARATOR = /[\\/]/u;
667
688
  /** 路径拆段(**逐段**比较而非字符串前缀:`/home/dev/project-two/x.md` 会骗过
668
689
  * `startsWith("/home/dev/project")`,前缀式包含判断等于放行兄弟目录)。
669
690
  * 两种分隔符都拆:win32 的 `path.resolve`/`path.relative` 产出 `\`,只按 `/` 拆会
670
691
  * 把整条路径当成一段,于是合法子路径被判成越界、`..\` 也漏过逐段校验。 */
671
692
  function pathSegments(absolute) {
672
- return absolute.split(/[\\/]/u).filter((token) => token.length > 0);
693
+ return absolute.split(PATH_SEPARATOR).filter((token) => token.length > 0);
673
694
  }
674
695
  /** 逐段校验:段为 "." / ".." 一律拒(归一前必须先拦,否则 path.resolve 吃掉 `..`);
675
696
  * checkHidden=true 时额外拒隐藏段(凭据/敏感目录,如 `.ssh`)。 */
@@ -715,7 +736,16 @@ function outsideRootsError(absolute, roots, messages) {
715
736
  * 包含关系),而不是再写第二条字符串规则:符号链接让「路径长得合法」与「读的是哪个
716
737
  * 对象」分叉,只有后端能收这个叉。一个根命中即放行;全落空即为逃逸。 */
717
738
  async function escapesAllRoots(fs, target, roots) {
718
- return !(await Promise.all(roots.map((root) => fs.resolve(root.absolute)))).some((root) => fs.contains(root, target));
739
+ const resolved = await Promise.all(roots.map(async (root) => {
740
+ try {
741
+ return await fs.resolve(root.absolute);
742
+ } catch {
743
+ return null;
744
+ }
745
+ }));
746
+ let anyHit = false;
747
+ for (const root of resolved) if (root !== null && fs.contains(root, target)) anyHit = true;
748
+ return !anyHit;
719
749
  }
720
750
  function importPathError(requested, cwd, allowRoots, messages) {
721
751
  const trimmed = requested.trim();
@@ -836,7 +866,7 @@ async function importFromFile(args, absolute) {
836
866
  };
837
867
  }
838
868
  if (info === void 0) {
839
- skipped.unnamed = 1;
869
+ skipped.unnamed += 1;
840
870
  return {
841
871
  entries: [],
842
872
  truncated: false,
@@ -903,7 +933,8 @@ function pushReadResult(read, entries, collided, skipped) {
903
933
  }
904
934
  /** 目录路径扫描(顶层 + 一层子目录的 .md,第三层只清点)→ 条目列表。
905
935
  * 跳过计数**就地累加进调用方持有的 `skipped`**(而不是返回一份新表):中途抛错时
906
- * 上层 catch 仍要报出已经数到的那部分。 */
936
+ * 上层 catch 仍要报出已经数到的那部分。这里的两层形状被 src/ui-messages.ts 的
937
+ * skipDeeper / importHint(中英四键)写给用户,改扫描深度要同步那四处文案。 */
907
938
  async function importFromDirectory(fs, absolute, target, limits, skipped) {
908
939
  const rootChildren = await fs.listDir(target);
909
940
  const rootFiles = mdCandidates(fs, target, rootChildren, path.basename(absolute), skipped);
@@ -968,7 +999,7 @@ async function collectAgentTemplates(fs, requested, cwd, messages, opts) {
968
999
  }, absolute);
969
1000
  return {
970
1001
  entries: await importFromDirectory(fs, absolute, target, limits, skipped),
971
- truncated: skipped.tooLarge + skipped.unreadable + skipped.deeper + skipped.escaped > 0,
1002
+ truncated: skipped.tooLarge + skipped.unreadable + skipped.deeper + skipped.escaped + skipped.unnamed > 0,
972
1003
  skipped
973
1004
  };
974
1005
  } catch (error) {
@@ -995,7 +1026,7 @@ function buildOrganizeSystem(input, messages) {
995
1026
  messages.sysRuleNoListing,
996
1027
  messages.sysRuleRoleView,
997
1028
  messages.sysRuleDataNotInstruction,
998
- fillTemplate(messages.sysCwdLine, [["{cwd}", input.cwd || messages.sysCwdMissing]])
1029
+ fillTemplate(messages.sysCwdLine, [["{cwd}", singleLine(input.cwd) || messages.sysCwdMissing]])
999
1030
  ].filter((part) => part.length > 0).join("\n");
1000
1031
  }
1001
1032
  /**
@@ -1107,7 +1138,10 @@ async function runOrganize(llm, input, messages, timeoutMs = ORGANIZE_TIMEOUT_MS
1107
1138
  }]
1108
1139
  }];
1109
1140
  const controller = new AbortController();
1141
+ let timedOut = false;
1142
+ const hasTimedOut = () => timedOut;
1110
1143
  const timer = setTimeout(() => {
1144
+ timedOut = true;
1111
1145
  controller.abort();
1112
1146
  }, timeoutMs);
1113
1147
  const onCallerAbort = () => {
@@ -1128,6 +1162,12 @@ async function runOrganize(llm, input, messages, timeoutMs = ORGANIZE_TIMEOUT_MS
1128
1162
  }), messages);
1129
1163
  if (content.length === 0) throw new Error(messages.emptyOrganizeResult);
1130
1164
  return { content };
1165
+ } catch (error) {
1166
+ if (hasTimedOut()) {
1167
+ const seconds = String(Math.round(timeoutMs / 1e3));
1168
+ throw new Error(fillTemplate(messages.organizeTimeout, [["{seconds}", seconds]]), { cause: error });
1169
+ }
1170
+ throw error;
1131
1171
  } finally {
1132
1172
  clearTimeout(timer);
1133
1173
  callerSignal?.removeEventListener("abort", onCallerAbort);
@@ -1192,8 +1232,20 @@ function importAllowRootsOf(raw) {
1192
1232
  * settings.plugin.item 卡」(dsh-client-ui-settings-plugins 源码语义),configure 必须
1193
1233
  * 发生在 apply 期,故仍硬注入。sessions/fs/llm/agentDefaultModel 仍可选读。 */
1194
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
+ }
1195
1247
  /** 当前默认模型解析(缺服务/抛错 → undefined)。 */
1196
- function resolveModel(deps) {
1248
+ function defaultModelOf(deps) {
1197
1249
  const current = deps.agentDefaultModel?.();
1198
1250
  let result;
1199
1251
  if (current !== void 0) try {
@@ -1206,6 +1258,10 @@ function resolveModel(deps) {
1206
1258
  } catch {}
1207
1259
  return result;
1208
1260
  }
1261
+ /** 润色的模型来源:会话活线优先,没有才用默认模型。 */
1262
+ function resolveModel(deps, sessionId) {
1263
+ return liveModelOf(deps, sessionId) ?? defaultModelOf(deps);
1264
+ }
1209
1265
  /** 会话最近对话文本提取(deriveMessages 尾部;缺会话/无方法/抛错 → 空串)。 */
1210
1266
  function resolveRecentTurns(sessions, sessionId) {
1211
1267
  const session = sessionId === null ? void 0 : sessions?.get(sessionIdOf(sessionId));
@@ -1345,7 +1401,7 @@ async function organizePayload(scope, parsed) {
1345
1401
  ok: false,
1346
1402
  error: messages.cwdUnknown
1347
1403
  };
1348
- const model = resolveModel(scope.deps);
1404
+ const model = resolveModel(scope.deps, sessionIdText);
1349
1405
  try {
1350
1406
  return {
1351
1407
  ok: true,
@@ -1565,6 +1621,10 @@ function apply(ctx, config) {
1565
1621
  const service = getService("agentDefaultModel");
1566
1622
  return isAgentDefaultModel(service) ? service : void 0;
1567
1623
  },
1624
+ agents: () => {
1625
+ const service = getService("agents");
1626
+ return isAgentsService(service) ? service : void 0;
1627
+ },
1568
1628
  importAllowRoots: () => importAllowRootsOf(config.importAllowRoots.get()),
1569
1629
  limits: limitsOfConfig
1570
1630
  },
@@ -1575,5 +1635,4 @@ function apply(ctx, config) {
1575
1635
  installDirPrepRemote(child, scope);
1576
1636
  });
1577
1637
  }
1578
- //#endregion
1579
- 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.5",
3
+ "version": "0.1.7",
4
4
  "description": "dsh 插件:对话输入框「润色」按钮(主键直接润色/▾ 以角色风格润色,结合当前目录 + session 模型润色草稿)+「模板」下拉(内置精选角色集生成自插件 agents/ 角色库,可按部门分组;设置卡可增删改/一键导入内置全部/导入本地角色 .md)",
5
5
  "keywords": [
6
6
  "cordis",
@@ -28,7 +28,11 @@
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",
35
+ "CHANGELOG.md",
32
36
  "THIRD_PARTY_NOTICES.md"
33
37
  ],
34
38
  "type": "module",
@@ -46,6 +50,7 @@
46
50
  },
47
51
  "./client": "./client.js",
48
52
  "./cordis.patch.yml": "./cordis.patch.yml",
53
+ "./locale/*.json": "./locale/*.json",
49
54
  "./package.json": "./package.json"
50
55
  },
51
56
  "publishConfig": {
@@ -53,66 +58,70 @@
53
58
  "registry": "https://registry.npmjs.org"
54
59
  },
55
60
  "dependencies": {
56
- "@jayyuen66/dsh-plugin-shared": "^0.1.6"
61
+ "@jayyuen66/dsh-plugin-shared": "0.2.1",
62
+ "zod": "4.6.7"
57
63
  },
58
64
  "devDependencies": {
59
- "@deepseek-ai/cordis": "4.0.5",
60
- "@deepseek-ai/cordis-plugin-group": "1.0.5",
61
- "@deepseek-ai/cordis-plugin-include": "1.0.10",
62
- "@deepseek-ai/cosmokit": "1.8.6",
63
- "@deepseek-ai/dsh-agent-default-model": "0.2.1-rc.2",
64
- "@deepseek-ai/dsh-app-boot": "0.2.1-rc.2",
65
- "@deepseek-ai/dsh-brand": "0.2.1-rc.2",
66
- "@deepseek-ai/dsh-client-locale": "0.2.1-rc.2",
67
- "@deepseek-ai/dsh-client-ui-conversation": "0.2.1-rc.2",
68
- "@deepseek-ai/dsh-client-ui-plugin-manager": "0.2.1-rc.2",
69
- "@deepseek-ai/dsh-client-ui-renderer": "0.2.1-rc.2",
70
- "@deepseek-ai/dsh-client-ui-settings": "0.2.1-rc.2",
71
- "@deepseek-ai/dsh-client-ui-slots": "0.2.1-rc.2",
72
- "@deepseek-ai/dsh-config-editor": "0.2.1-rc.2",
73
- "@deepseek-ai/dsh-fs": "0.2.1-rc.2",
74
- "@deepseek-ai/dsh-home-paths": "0.2.1-rc.2",
75
- "@deepseek-ai/dsh-host-webserver": "0.2.1-rc.2",
76
- "@deepseek-ai/dsh-launch-environment": "0.2.1-rc.2",
77
- "@deepseek-ai/dsh-llm": "0.2.1-rc.2",
78
- "@deepseek-ai/dsh-sandbox": "0.2.1-rc.2",
79
- "@deepseek-ai/dsh-scope": "0.2.1-rc.2",
80
- "@deepseek-ai/dsh-session": "0.2.1-rc.2",
81
- "@deepseek-ai/dsh-settings": "0.2.1-rc.2",
82
- "@deepseek-ai/dsh-typert-protocol": "0.2.1-rc.2",
83
- "@deepseek-ai/schemastery": "3.18.5",
84
- "@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",
85
92
  "@types/react": "19.3.0",
86
93
  "@types/react-dom": "19.3.0",
87
94
  "@vitest/coverage-v8": "5.0.5",
95
+ "eslint-plugin-regexp": "3.3.2",
88
96
  "eslint-plugin-sonarjs": "4.2.2",
89
- "happy-dom": "21.0.3",
90
- "oxfmt": "0.73.0",
91
- "oxlint": "1.88.0",
92
- "oxlint-tsgolint": "7.0.2004",
97
+ "eslint-plugin-zod": "5.2.2",
98
+ "happy-dom": "21.0.4",
99
+ "oxfmt": "0.75.0",
100
+ "oxlint": "1.90.0",
101
+ "oxlint-tsgolint": "7.0.2005",
93
102
  "react": "^19.3.0",
94
103
  "react-dom": "^19.3.0",
95
- "rolldown": "1.2.14",
104
+ "rolldown": "1.2.15",
96
105
  "typescript": "7.0.2",
97
- "vite": "8.3.4",
106
+ "vite": "8.3.5",
98
107
  "vitest": "5.0.5"
99
108
  },
100
109
  "peerDependencies": {
101
- "@deepseek-ai/cordis": "4.0.5",
102
- "@deepseek-ai/cosmokit": "1.8.6",
103
- "@deepseek-ai/dsh": "^0.2.1-rc.2",
104
- "@deepseek-ai/dsh-agent-default-model": "0.2.1-rc.2",
105
- "@deepseek-ai/dsh-brand": "0.2.1-rc.2",
106
- "@deepseek-ai/dsh-client-locale": "0.2.1-rc.2",
107
- "@deepseek-ai/dsh-client-ui-conversation": "0.2.1-rc.2",
108
- "@deepseek-ai/dsh-client-ui-renderer": "0.2.1-rc.2",
109
- "@deepseek-ai/dsh-client-ui-settings": "0.2.1-rc.2",
110
- "@deepseek-ai/dsh-client-ui-slots": "0.2.1-rc.2",
111
- "@deepseek-ai/dsh-fs": "0.2.1-rc.2",
112
- "@deepseek-ai/dsh-llm": "0.2.1-rc.2",
113
- "@deepseek-ai/dsh-session": "0.2.1-rc.2",
114
- "@deepseek-ai/dsh-typert-protocol": "0.2.1-rc.2",
115
- "@deepseek-ai/schemastery": "3.18.5"
110
+ "@deepseek-ai/cordis": "~4.0.5 || 4.0.6-alpha.1",
111
+ "@deepseek-ai/cosmokit": "1.8.7-alpha.1",
112
+ "@deepseek-ai/dsh": "^0.2.1-rc.3",
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"
116
125
  },
117
126
  "peerDependenciesMeta": {
118
127
  "@deepseek-ai/cordis": {
@@ -157,7 +166,7 @@
157
166
  },
158
167
  "icon": "icon.svg",
159
168
  "engines": {
160
- "dsh": "^0.2.1-rc.2",
169
+ "dsh": "^0.2.1-rc.3",
161
170
  "node": ">=22.12.0"
162
171
  },
163
172
  "dsh": {
@@ -171,7 +180,7 @@
171
180
  }
172
181
  },
173
182
  "scripts": {
174
- "typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.client.json",
183
+ "typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.client.json && tsc --noEmit -p src/tsconfig.json && tsc --noEmit -p tsconfig.build-scripts.json",
175
184
  "lint": "oxlint .",
176
185
  "test": "vitest run --coverage",
177
186
  "gen:defaults": "node scripts/gen-defaults.mjs",
@@ -179,6 +188,6 @@
179
188
  "build:client": "node build-client.mjs",
180
189
  "build": "node build-host.mjs",
181
190
  "build:types": "node build-types.mjs",
182
- "fmt:check": "oxfmt --check ."
191
+ "fmt:check": "oxfmt --check . --ignore-path .gitignore --ignore-path .prettierignore"
183
192
  }
184
193
  }