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

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
@@ -166,8 +166,9 @@ function stripPairQuotes(value) {
166
166
  }
167
167
  /** frontmatter 键名形状:字母开头,随后字母/数字/下划线/连字符。 */
168
168
  const FRONTMATTER_KEY = /^[A-Za-z][\w-]*$/u;
169
- /** 头部只解析前 20 行键值对(防御恶意超长头部拖慢)。 */
170
- const FRONTMATTER_MAX_LINES = 20;
169
+ /** 头部只解析前 200 行键值对(防御恶意超长头部拖慢)。20 行会让带 tags/多行说明的
170
+ * 合法角色文件在后半段丢 name/description,整份被判成非角色文件。 */
171
+ const FRONTMATTER_MAX_LINES = 200;
171
172
  /** 视觉标记进入下拉前缀的最大字符数。 */
172
173
  const EMOJI_MAX_LENGTH = 12;
173
174
  /** 一行 frontmatter → `键 + 原样值`;无冒号 / 键名不合法 / 值为空 → 不算键值对。
@@ -186,13 +187,22 @@ function readFrontmatterPair(line) {
186
187
  }
187
188
  return result;
188
189
  }
189
- /** 键 → 目标位:防重复(已有值不覆盖,取首个同名键);emoji 截断至 EMOJI_MAX_LENGTH。 */
190
+ /** 按 Unicode 码点截断:`String#slice` 数的是 UTF-16 码元,会把一个 emoji(代理对)或
191
+ * 组合字符劈成半个,落进模板后显示成空白方块。两个截断点(frontmatter 与设置卡草稿)
192
+ * 共用这一份实现,scripts/gen-defaults-lib.mjs 有同源镜像。 */
193
+ function truncateCodePoints(value, max) {
194
+ const points = Array.from(value);
195
+ return points.length > max ? points.slice(0, max).join("") : value;
196
+ }
197
+ /** 键 → 目标位:防重复(已有值不覆盖,取首个同名键);emoji 截断至 EMOJI_MAX_LENGTH(按码点)。 */
190
198
  function takeFrontmatterField(fields, key, value) {
191
199
  if (key === "name" && fields.name === "" && value.length > 0) fields.name = value;
192
200
  else if (key === "description" && fields.description === "" && value.length > 0) fields.description = value;
193
- else if (key === "emoji" && fields.emoji === "") fields.emoji = value.slice(0, EMOJI_MAX_LENGTH);
201
+ else if (key === "emoji" && fields.emoji === "") fields.emoji = truncateCodePoints(value, EMOJI_MAX_LENGTH);
194
202
  }
195
- /** 从 frontmatter 头部解析 name/description/emoji(只解析前 20 行键值对,
203
+ /** 缩进行:属于嵌套映射(`metadata:` 下的 `name:` 之类),不是 frontmatter 顶层键。 */
204
+ const INDENTED_LINE = /^\s/u;
205
+ /** 从 frontmatter 头部解析 name/description/emoji(只解析前 FRONTMATTER_MAX_LINES 行键值对,
196
206
  * 防御恶意超长头部拖慢;防重复,取首个同名键)。 */
197
207
  function parseFrontmatterFields(head) {
198
208
  const fields = {
@@ -202,8 +212,10 @@ function parseFrontmatterFields(head) {
202
212
  };
203
213
  for (const [lineNum, rawLine] of head.split("\n").entries()) {
204
214
  if (lineNum >= FRONTMATTER_MAX_LINES) break;
205
- const pair = readFrontmatterPair(rawLine.trim());
206
- if (pair !== void 0) takeFrontmatterField(fields, pair.key, stripPairQuotes(pair.value));
215
+ if (!INDENTED_LINE.test(rawLine)) {
216
+ const pair = readFrontmatterPair(rawLine.trim());
217
+ if (pair !== void 0) takeFrontmatterField(fields, pair.key, stripPairQuotes(pair.value));
218
+ }
207
219
  }
208
220
  return fields;
209
221
  }
@@ -237,17 +249,7 @@ function parseAgentFrontmatter(text) {
237
249
  }
238
250
  return result;
239
251
  }
240
- /**
241
- * 角色正文提炼(导入 / 「按角色风格润色」共用):取叙述主干、去代码围栏。
242
- *
243
- * 规则(确定性,测试锁死):
244
- * - ``` 围栏行整体剔除(围栏内容多为长代码样例,对角色语境价值低);
245
- * - 行内反引号一并剔除——沿用"正文不含反引号、插入不破坏 markdown 围栏"不变式;
246
- * - 不设字符上限(用户拍板):全量保留叙述内容,避免截断影响
247
- * 「以角色风格润色」的上下文完整性;模型 context 超限由模型报错提示用户自行处理;
248
- * - 结果 trim;空正文(全围栏/全空白)→ 空串。
249
- */
250
- function condenseRoleBody(body) {
252
+ function tryCondenseRoleBody(body) {
251
253
  const lines = body.split(LINE_BREAK);
252
254
  const out = [];
253
255
  let inFence = false;
@@ -256,8 +258,10 @@ function condenseRoleBody(body) {
256
258
  fenceStart = inFence ? 0 : index + 1;
257
259
  inFence = !inFence;
258
260
  } else if (inFence) {} else out.push(raw.replaceAll("`", ""));
259
- if (inFence) throw new Error(`正文第 ${String(fenceStart)} 行的代码围栏没有结束标记(\`\`\`)`);
260
- return out.join("\n").trim();
261
+ return {
262
+ text: out.join("\n").trim(),
263
+ unclosedFenceLine: inFence ? fenceStart : void 0
264
+ };
261
265
  }
262
266
  // host.ts
263
267
  /** 本包送进 `llm.stream({ messages })` 的润色请求帧是 **request-only 输入**:它从不落
@@ -334,11 +338,19 @@ async function importDefaultTemplates() {
334
338
  * 静态导入会让整张精选表随宿主载入插件一起进内存,而它们只有一个消费者——default-templates
335
339
  * 读面,而客户端本来就是首次打开下拉时才拉这一发。两边都按需,才是同一件事的同一口径。
336
340
  *
341
+ * @param load - 载入器,缺省即真实 import 产物;单测靠它把「首读失败」那一档做成可复跑
342
+ * 的判据(产物 URL 一旦被成功加载就进 ESM 缓存,改磁盘内容对后续 import 无效,所以失败路径
343
+ * 只能从这一个缝注入)。
337
344
  * @returns 内置精选模板表
338
345
  */
339
- async function loadDefaultTemplates() {
340
- defaultTemplatesPromise ??= importDefaultTemplates();
341
- return defaultTemplatesPromise;
346
+ async function loadDefaultTemplates(load = importDefaultTemplates) {
347
+ defaultTemplatesPromise ??= load();
348
+ try {
349
+ return await defaultTemplatesPromise;
350
+ } catch (error) {
351
+ defaultTemplatesPromise = void 0;
352
+ throw error;
353
+ }
342
354
  }
343
355
  /** 关键文本扩展名(这些文件取首段摘要)。仅代码/文档/结构配置面;
344
356
  * yaml/env 等敏感配置不取摘要(凭据泄露风险,实测 .credentials.yaml 被带出)。 */
@@ -432,7 +444,7 @@ function isAgentsService(value) {
432
444
  return hasFnMember(value, "get");
433
445
  }
434
446
  function isFsService(value) {
435
- return hasFnMember(value, "resolve") && hasFnMember(value, "stat");
447
+ return hasFnMember(value, "resolve") && hasFnMember(value, "stat") && hasFnMember(value, "listDir") && hasFnMember(value, "readText") && hasFnMember(value, "contains");
436
448
  }
437
449
  function isLlmService(value) {
438
450
  return hasFnMember(value, "stream");
@@ -726,11 +738,17 @@ function importRootsOf(cwd, allowRoots, messages) {
726
738
  for (const root of allowRoots) roots.push(toImportRoot(root, messages.rootLabelAllowed));
727
739
  return roots;
728
740
  }
741
+ /** 越界回执里最多列出几个允许根。这条文本会进会话日志与模型上下文,而允许根的清单
742
+ * 来自设置存储——手改过的 settings 或脏数据能把几百项拼进一条 403,所以列举面要有界。
743
+ * 被省略的数量以 `…<条数>` 收尾:只用标点与数字,不引入未经 locale 的新词。 */
744
+ const OUTSIDE_ROOTS_LISTED = 5;
729
745
  /** 越界回执文本:点名每一类允许区并回显解析后的绝对路径——越界不做静默降级,
730
746
  * 必须让模型/人一眼看清"规则是什么、这次解析到了哪里"。 */
731
747
  function outsideRootsError(absolute, roots, messages) {
732
- const zones = roots.map((root) => `${root.label} ${root.absolute}`);
733
- return fillTemplate(messages.outsideRoots, [["{zones}", zones.join(messages.zoneSeparator)], ["{absolute}", absolute]]);
748
+ const listed = roots.slice(0, OUTSIDE_ROOTS_LISTED);
749
+ const omitted = roots.length - listed.length;
750
+ const zones = listed.map((root) => `${root.label} ${root.absolute}`).join(messages.zoneSeparator);
751
+ return fillTemplate(messages.outsideRoots, [["{zones}", omitted > 0 ? `${zones}${messages.zoneSeparator}…${String(omitted)}` : zones], ["{absolute}", absolute]]);
734
752
  }
735
753
  /** 真实目标是否落在**每一个**允许根之外。判据交给后端(`contains` 用它自己的世界判
736
754
  * 包含关系),而不是再写第二条字符串规则:符号链接让「路径长得合法」与「读的是哪个
@@ -755,14 +773,16 @@ function importPathError(requested, cwd, allowRoots, messages) {
755
773
  if (!path.isAbsolute(trimmed) && cwd === void 0) return messages.relativeNeedsCwd;
756
774
  const absolute = path.resolve(cwd ?? "", trimmed);
757
775
  const roots = importRootsOf(cwd, allowRoots, messages);
758
- const matched = roots.find((root) => isWithinRoot(root.absolute, absolute));
759
- if (matched === void 0) return outsideRootsError(absolute, roots, messages);
760
- return pathTokensError(path.relative(matched.absolute, absolute), true, messages);
776
+ const matched = roots.filter((root) => isWithinRoot(root.absolute, absolute));
777
+ if (matched.length === 0) return outsideRootsError(absolute, roots, messages);
778
+ const errors = matched.toSorted((left, right) => right.absolute.length - left.absolute.length).map((root) => pathTokensError(path.relative(root.absolute, absolute), true, messages));
779
+ return errors.some((error) => error === void 0) ? void 0 : errors[0];
761
780
  }
762
781
  /** 角色文件 → 模板条目(正文提炼 + 目录分组标签 + 确定性 id 去重)。
763
782
  * 正文提炼不设字符上限。 */
764
783
  function agentEntryFromFile(slug, dirName, info, collided) {
765
- const text = condenseRoleBody(info.body);
784
+ const { text: condensedText, unclosedFenceLine } = tryCondenseRoleBody(info.body);
785
+ const text = unclosedFenceLine === void 0 ? condensedText : "";
766
786
  let result;
767
787
  if (text.length > 0) {
768
788
  let suffix = collided.size;
@@ -787,9 +807,19 @@ function agentEntryFromFile(slug, dirName, info, collided) {
787
807
  function isVisibleDirectory(child) {
788
808
  return child.type === "directory" && !child.name.startsWith(".");
789
809
  }
810
+ /** 扩展名是否 .md:不区分大小写。macOS 默认文件系统不区分大小写,`Agent.MD` 在用户看来
811
+ * 就是一份角色文件;按字节判后缀会把它静默丢在扫描面之外(且不计任何 skipped)。 */
812
+ function isMdName(name) {
813
+ return name.toLowerCase().endsWith(".md");
814
+ }
815
+ const MD_SUFFIX = /\.md$/iu;
816
+ /** 去掉 .md 后缀(大小写不敏感);没有该后缀时原样返回(replace 不命中即原样,无需分支)。 */
817
+ function stripMdSuffix(name) {
818
+ return name.replace(MD_SUFFIX, "");
819
+ }
790
820
  /** 目录项是「可见 .md 文件」?(候选收集与第三层清点同一判据,两处必须数到同一批)。 */
791
821
  function isVisibleMdFile(child) {
792
- return child.type === "file" && child.name.endsWith(".md") && !child.name.startsWith(".");
822
+ return child.type === "file" && isMdName(child.name) && !child.name.startsWith(".");
793
823
  }
794
824
  /** 一层目录内容 → 顶层 .md 候选(跳过隐藏项,按名排序保确定性)。
795
825
  * `skipped` 就地累加 escaped 计数:被 contains 拦下的链接文件如果不数出来,
@@ -874,9 +904,17 @@ async function importFromFile(args, absolute) {
874
904
  error: messages.missingRoleName
875
905
  };
876
906
  }
877
- const entry = agentEntryFromFile(path.basename(absolute, ".md"), path.basename(path.dirname(absolute)), info, /* @__PURE__ */ new Set());
907
+ const entry = agentEntryFromFile(stripMdSuffix(path.basename(absolute)), path.basename(path.dirname(absolute)), info, /* @__PURE__ */ new Set());
908
+ if (entry === void 0) {
909
+ skipped.unnamed += 1;
910
+ return {
911
+ entries: [],
912
+ truncated: true,
913
+ skipped
914
+ };
915
+ }
878
916
  return {
879
- entries: entry === void 0 ? [] : [entry],
917
+ entries: [entry],
880
918
  truncated: false,
881
919
  skipped
882
920
  };
@@ -924,7 +962,7 @@ function pushReadResult(read, entries, collided, skipped) {
924
962
  skipped.unnamed += 1;
925
963
  return;
926
964
  }
927
- const entry = agentEntryFromFile(path.basename(read.file.name, ".md"), read.file.dirName, read.info, collided);
965
+ const entry = agentEntryFromFile(stripMdSuffix(read.file.name), read.file.dirName, read.info, collided);
928
966
  if (entry === void 0) {
929
967
  skipped.unnamed += 1;
930
968
  return;
@@ -938,11 +976,16 @@ function pushReadResult(read, entries, collided, skipped) {
938
976
  async function importFromDirectory(fs, absolute, target, limits, skipped) {
939
977
  const rootChildren = await fs.listDir(target);
940
978
  const rootFiles = mdCandidates(fs, target, rootChildren, path.basename(absolute), skipped);
941
- const subScans = await mapBounded(rootChildren.filter((child) => isVisibleDirectory(child)).map((child) => child.target).toSorted((left, right) => left.displayPath.localeCompare(right.displayPath)), limits.readConcurrency, async (sub) => {
979
+ const subScans = await mapBounded(rootChildren.filter((child) => {
980
+ if (!isVisibleDirectory(child)) return false;
981
+ const inside = fs.contains(target, child.target);
982
+ if (!inside) skipped.escaped += 1;
983
+ return inside;
984
+ }).map((child) => child.target).toSorted((left, right) => left.displayPath.localeCompare(right.displayPath)), limits.readConcurrency, async (sub) => {
942
985
  const children = await listDirOrUnreadable(fs, sub, skipped);
943
986
  return {
944
987
  files: mdCandidates(fs, target, children, path.basename(sub.displayPath), skipped),
945
- deeper: children.filter((child) => isVisibleDirectory(child)).map((child) => child.target)
988
+ deeper: children.filter((child) => isVisibleDirectory(child) && fs.contains(target, child.target)).map((child) => child.target)
946
989
  };
947
990
  });
948
991
  const subFiles = [];
@@ -990,7 +1033,7 @@ async function collectAgentTemplates(fs, requested, cwd, messages, opts) {
990
1033
  error: outsideRootsError(target.displayPath, roots, messages)
991
1034
  };
992
1035
  }
993
- if (absolute.endsWith(".md")) return await importFromFile({
1036
+ if (isMdName(absolute)) return await importFromFile({
994
1037
  fs,
995
1038
  target,
996
1039
  limits,
@@ -1217,11 +1260,21 @@ const configShape = {
1217
1260
  const configSchema = Schema.object(configShape);
1218
1261
  /** volatile 引用读出的值 → importAllowRoots 字符串列表(纯函数,测试锁死)。
1219
1262
  * 引用背后可能是存量脏配置:非数组一律空表(fail-closed),非字符串/纯空白项逐个
1220
- * 丢弃——绝不能把非字符串塞进路径校验,也不能让空串变成"允许 process.cwd()"。 */
1263
+ * 丢弃——绝不能把非字符串塞进路径校验,也不能让空串变成"允许 process.cwd()"。
1264
+ * 相对路径同样丢弃:契约写的是「额外允许的**绝对**目录」(见 schema describe 与 DETAIL
1265
+ * 文档),放进来会被 toImportRoot 的 path.resolve 按**宿主进程 cwd** 解析,变成一条用户
1266
+ * 没写过、也不知道存在着的允许根。 */
1221
1267
  function importAllowRootsOf(raw) {
1222
1268
  const roots = [];
1269
+ const seen = /* @__PURE__ */ new Set();
1223
1270
  if (Array.isArray(raw)) {
1224
- for (const item of raw) if (typeof item === "string" && item.trim().length > 0) roots.push(item.trim());
1271
+ for (const item of raw) if (typeof item === "string" && item.trim().length > 0 && path.isAbsolute(item.trim())) {
1272
+ const normalized = path.resolve(item.trim());
1273
+ if (!seen.has(normalized)) {
1274
+ seen.add(normalized);
1275
+ roots.push(normalized);
1276
+ }
1277
+ }
1225
1278
  }
1226
1279
  return roots;
1227
1280
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jayyuen66/dsh-dir-prep-organize",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "dsh 插件:对话输入框「润色」按钮(主键直接润色/▾ 以角色风格润色,结合当前目录 + session 模型润色草稿)+「模板」下拉(内置精选角色集生成自插件 agents/ 角色库,可按部门分组;设置卡可增删改/一键导入内置全部/导入本地角色 .md)",
5
5
  "keywords": [
6
6
  "cordis",
@@ -15,7 +15,10 @@
15
15
  "url": "https://github.com/JayYuen666/dsh-dir-prep-organize/issues"
16
16
  },
17
17
  "license": "MIT",
18
- "author": "JayYuen",
18
+ "author": {
19
+ "name": "JayYuen",
20
+ "url": "https://github.com/JayYuen666"
21
+ },
19
22
  "repository": {
20
23
  "type": "git",
21
24
  "url": "git+https://github.com/JayYuen666/dsh-dir-prep-organize.git"
@@ -58,70 +61,70 @@
58
61
  "registry": "https://registry.npmjs.org"
59
62
  },
60
63
  "dependencies": {
61
- "@jayyuen66/dsh-plugin-shared": "0.2.1",
64
+ "@jayyuen66/dsh-plugin-shared": "^0.2.4",
62
65
  "zod": "4.6.7"
63
66
  },
64
67
  "devDependencies": {
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",
68
+ "@deepseek-ai/cordis": "4.1.0",
69
+ "@deepseek-ai/cordis-plugin-group": "1.1.0",
70
+ "@deepseek-ai/cordis-plugin-include": "1.1.0",
71
+ "@deepseek-ai/cosmokit": "1.9.0",
72
+ "@deepseek-ai/dsh-agent-default-model": "0.2.2-rc.1",
73
+ "@deepseek-ai/dsh-app-boot": "0.2.2-rc.1",
74
+ "@deepseek-ai/dsh-brand": "0.2.2-rc.1",
75
+ "@deepseek-ai/dsh-client-locale": "0.2.2-rc.1",
76
+ "@deepseek-ai/dsh-client-ui-conversation": "0.2.2-rc.1",
77
+ "@deepseek-ai/dsh-client-ui-plugin-manager": "0.2.2-rc.1",
78
+ "@deepseek-ai/dsh-client-ui-renderer": "0.2.2-rc.1",
79
+ "@deepseek-ai/dsh-client-ui-settings": "0.2.2-rc.1",
80
+ "@deepseek-ai/dsh-client-ui-slots": "0.2.2-rc.1",
81
+ "@deepseek-ai/dsh-config-editor": "0.2.2-rc.1",
82
+ "@deepseek-ai/dsh-fs": "0.2.2-rc.1",
83
+ "@deepseek-ai/dsh-home-paths": "0.2.2-rc.1",
84
+ "@deepseek-ai/dsh-launch-environment": "0.2.2-rc.1",
85
+ "@deepseek-ai/dsh-llm": "0.2.2-rc.1",
86
+ "@deepseek-ai/dsh-sandbox": "0.2.2-rc.1",
87
+ "@deepseek-ai/dsh-scope": "0.2.2-rc.1",
88
+ "@deepseek-ai/dsh-session": "0.2.2-rc.1",
89
+ "@deepseek-ai/dsh-settings": "0.2.2-rc.1",
90
+ "@deepseek-ai/dsh-typert-protocol": "0.2.2-rc.1",
91
+ "@deepseek-ai/schemastery": "3.19.0",
90
92
  "@e18e/eslint-plugin": "0.8.1",
91
93
  "@types/node": "26.6.6",
92
94
  "@types/react": "19.3.0",
93
95
  "@types/react-dom": "19.3.0",
94
- "@vitest/coverage-v8": "5.0.5",
95
- "eslint-plugin-regexp": "3.3.2",
96
+ "@vitest/coverage-v8": "5.1.0",
97
+ "eslint-plugin-regexp": "3.3.3",
96
98
  "eslint-plugin-sonarjs": "4.2.2",
97
99
  "eslint-plugin-zod": "5.2.2",
100
+ "fast-check": "4.10.2",
98
101
  "happy-dom": "21.0.4",
99
- "oxfmt": "0.75.0",
100
- "oxlint": "1.90.0",
102
+ "oxfmt": "0.76.0",
103
+ "oxlint": "1.91.0",
101
104
  "oxlint-tsgolint": "7.0.2005",
102
105
  "react": "^19.3.0",
103
106
  "react-dom": "^19.3.0",
104
- "rolldown": "1.2.15",
107
+ "rolldown": "1.2.16",
105
108
  "typescript": "7.0.2",
106
- "vite": "8.3.5",
107
- "vitest": "5.0.5"
109
+ "vite": "8.3.6",
110
+ "vitest": "5.1.0"
108
111
  },
109
112
  "peerDependencies": {
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"
113
+ "@deepseek-ai/cordis": "^4.0.5 || ^4.0.6-alpha.2",
114
+ "@deepseek-ai/cosmokit": "^1.8.6 || ^1.8.7-alpha.2",
115
+ "@deepseek-ai/dsh": "^0.2.1-rc.5 || ^0.2.2-alpha.3",
116
+ "@deepseek-ai/dsh-agent-default-model": "^0.2.1-rc.5 || ^0.2.2-alpha.3",
117
+ "@deepseek-ai/dsh-brand": "^0.2.1-rc.5 || ^0.2.2-alpha.3",
118
+ "@deepseek-ai/dsh-client-locale": "^0.2.1-rc.5 || ^0.2.2-alpha.3",
119
+ "@deepseek-ai/dsh-client-ui-conversation": "^0.2.1-rc.5 || ^0.2.2-alpha.3",
120
+ "@deepseek-ai/dsh-client-ui-renderer": "^0.2.1-rc.5 || ^0.2.2-alpha.3",
121
+ "@deepseek-ai/dsh-client-ui-settings": "^0.2.1-rc.5 || ^0.2.2-alpha.3",
122
+ "@deepseek-ai/dsh-client-ui-slots": "^0.2.1-rc.5 || ^0.2.2-alpha.3",
123
+ "@deepseek-ai/dsh-fs": "^0.2.1-rc.5 || ^0.2.2-alpha.3",
124
+ "@deepseek-ai/dsh-llm": "^0.2.1-rc.5 || ^0.2.2-alpha.3",
125
+ "@deepseek-ai/dsh-session": "^0.2.1-rc.5 || ^0.2.2-alpha.3",
126
+ "@deepseek-ai/dsh-typert-protocol": "^0.2.1-rc.5 || ^0.2.2-alpha.3",
127
+ "@deepseek-ai/schemastery": "^3.18.5 || ^3.18.6-alpha.1"
125
128
  },
126
129
  "peerDependenciesMeta": {
127
130
  "@deepseek-ai/cordis": {
@@ -166,8 +169,8 @@
166
169
  },
167
170
  "icon": "icon.svg",
168
171
  "engines": {
169
- "dsh": "^0.2.1-rc.3",
170
- "node": ">=22.12.0"
172
+ "dsh": "^0.2.1-rc.5 || ^0.2.2-alpha.3",
173
+ "node": ">=24.9.0"
171
174
  },
172
175
  "dsh": {
173
176
  "manifestVersion": 1,
@@ -176,7 +179,10 @@
176
179
  },
177
180
  "client": {
178
181
  "platform": "web",
179
- "immediately": true
182
+ "immediately": true,
183
+ "external": [
184
+ "@jayyuen66/dsh-plugin-shared/client"
185
+ ]
180
186
  }
181
187
  },
182
188
  "scripts": {
package/types/host.d.ts CHANGED
@@ -24,9 +24,12 @@ export declare function defaultTemplatesFrom(raw: unknown): readonly TemplateEnt
24
24
  * 静态导入会让整张精选表随宿主载入插件一起进内存,而它们只有一个消费者——default-templates
25
25
  * 读面,而客户端本来就是首次打开下拉时才拉这一发。两边都按需,才是同一件事的同一口径。
26
26
  *
27
+ * @param load - 载入器,缺省即真实 import 产物;单测靠它把「首读失败」那一档做成可复跑
28
+ * 的判据(产物 URL 一旦被成功加载就进 ESM 缓存,改磁盘内容对后续 import 无效,所以失败路径
29
+ * 只能从这一个缝注入)。
27
30
  * @returns 内置精选模板表
28
31
  */
29
- export declare function loadDefaultTemplates(): Promise<readonly TemplateEntry[]>;
32
+ export declare function loadDefaultTemplates(load?: () => Promise<readonly TemplateEntry[]>): Promise<readonly TemplateEntry[]>;
30
33
  /**
31
34
  * 把一个部署来的数夹进 `[min, max]`,非有限值回落到 `fallback`。
32
35
  *
@@ -381,7 +384,10 @@ export interface Config {
381
384
  export { configSchema as Config };
382
385
  /** volatile 引用读出的值 → importAllowRoots 字符串列表(纯函数,测试锁死)。
383
386
  * 引用背后可能是存量脏配置:非数组一律空表(fail-closed),非字符串/纯空白项逐个
384
- * 丢弃——绝不能把非字符串塞进路径校验,也不能让空串变成"允许 process.cwd()"。 */
387
+ * 丢弃——绝不能把非字符串塞进路径校验,也不能让空串变成"允许 process.cwd()"。
388
+ * 相对路径同样丢弃:契约写的是「额外允许的**绝对**目录」(见 schema describe 与 DETAIL
389
+ * 文档),放进来会被 toImportRoot 的 path.resolve 按**宿主进程 cwd** 解析,变成一条用户
390
+ * 没写过、也不知道存在着的允许根。 */
385
391
  export declare function importAllowRootsOf(raw: unknown): string[];
386
392
  /** 注入的服务面:settings 为硬依赖(cordis 等它就绪才 apply)。
387
393
  * 命名空间是隐式的(= 本条目在 cordis.patch.yml 里的裸 id,可编辑字段取自
@@ -46,13 +46,25 @@ export declare function parseAgentFrontmatter(text: string): AgentFileInfo | und
46
46
  * - 行内反引号一并剔除——沿用"正文不含反引号、插入不破坏 markdown 围栏"不变式;
47
47
  * - 不设字符上限(用户拍板):全量保留叙述内容,避免截断影响
48
48
  * 「以角色风格润色」的上下文完整性;模型 context 超限由模型报错提示用户自行处理;
49
- * - 结果 trim;空正文(全围栏/全空白)→ 空串。
49
+ * - 结果 trim;空正文(全围栏/全空白)→ 空串;
50
+ * - 围栏未闭合时**不抛**:把行号作为结果交出,由调用方决定是拒绝整份文件还是跳过它。
51
+ * 异常只由 `condenseRoleBody` 这一层抛(生成器要据此拒绝产出),导入读面拿到的是结果。
50
52
  */
53
+ export interface CondenseResult {
54
+ /** 清洗后的正文(围栏未闭合时是围栏起始行之前的那些行)。 */
55
+ text: string;
56
+ /** 未闭合围栏在正文里的行号(1 起);闭合完整时为 undefined。 */
57
+ unclosedFenceLine: number | undefined;
58
+ }
59
+ export declare function tryCondenseRoleBody(body: string): CondenseResult;
60
+ /** `tryCondenseRoleBody` 的严格形态:围栏未闭合时抛错,供生成器拒收畸形角色文件。
61
+ * 导入读面不用这一支——一份漏写结束围栏的文件不该让同目录其余角色全部失败。 */
51
62
  export declare function condenseRoleBody(body: string): string;
52
63
  /**
53
64
  * 导入条目并入现有草稿:与既有 id 碰撞时确定性改写(追加 `-i` 直到唯一)。
54
- * 返回新数组(不改输入),保证 pre-save 阶段 React key 唯一(保存前的 id 去重,
55
- * sanitizeTemplateList 的确定性补 id 只兜底缺失/空,不负责碰撞改写)。
65
+ * 返回新数组(不改输入),保证 pre-save 阶段 React key 唯一。sanitizeTemplateList 对**存量
66
+ * 快照**同样按序号补 id(缺失/空/撞名三档都管),这边要额外做的是避开草稿里已有的 id
67
+ * ——两个入口各管一段,不靠对方兜底。
56
68
  */
57
69
  export declare function mergeImportedTemplates(existing: readonly TemplateEntry[], incoming: readonly TemplateEntry[]): TemplateEntry[];
58
70
  /** 内置默认模板(独立开发者精选角色集,生成自插件内置 agents/ 目录)。
@@ -61,6 +73,13 @@ export declare function mergeImportedTemplates(existing: readonly TemplateEntry[
61
73
  * 全量角色可经设置页「导入角色」导入(路径留空 = 导入内置 agents/ 全部;显式路径
62
74
  * 受 host 的「cwd 内 + 内置角色目录 allowlist」策略约束)。 */
63
75
  export { DEFAULT_TEMPLATES } from "./default-templates.generated.js";
76
+ /** 任意来源(settings 快照 / 设置卡草稿)→ 合法模板列表(纯函数,测试锁死)。
77
+ *
78
+ * - 非数组输入 → [](调用方自行决定是否回落 DEFAULT_TEMPLATES);
79
+ * - 剔除非对象条目与 name/text trim 后为空的条目;
80
+ * - name/text/description/group 一律 trim;emoji trim 后按码点截断至 12 个字符;
81
+ * - id 缺失与已收集 id 撞名都由 uniqueEntryId 按序号补成唯一(同输入同输出,可测试);
82
+ * - 绝不修改输入(深比较测试锁死)。 */
64
83
  export declare function sanitizeTemplateList(raw: unknown): TemplateEntry[];
65
84
  /** 任意来源(settings 快照 / 设置卡草稿)→ 合法的「导入允许目录」列表(纯函数)。
66
85
  * host 的导入策略是「会话 cwd + 内置角色库 + importAllowRoots」,绝对路径默认拒绝,
@@ -68,5 +87,10 @@ export declare function sanitizeTemplateList(raw: unknown): TemplateEntry[];
68
87
  * - 非数组 → [](未设置 = 一条都不登记,不是"全放行");
69
88
  * - 非字符串 / trim 后为空 → 丢弃(空串在 host 侧 path.resolve 会落到进程 cwd,
70
89
  * 绝不能让它变成一个隐式允许根);
71
- * - 去重(同一目录登记两次没有额外语义,界面上也不该出现两行)。 */
90
+ * - **非绝对路径 → 丢弃**:契约是「额外允许的绝对目录」,相对项会被 host 按它自己的
91
+ * 进程 cwd 解析,等于登记了一条用户没写过、界面上也看不出指向哪里的允许根;`~`
92
+ * 靠 shell 展开,host 的 path.resolve 不展开它,同归这一档;
93
+ * - 末尾分隔符归一后去重(`/a` 与 `/a/` 是同一棵树,不该在界面上摆两行);
94
+ * - 条数与单条长度都不设上限:静默丢一条就是「看着成功、内容没进去」;条目多撑长的
95
+ * 越界回执由 host 侧的列举上限收口。 */
72
96
  export declare function sanitizeAllowRoots(raw: unknown): string[];
@@ -71,6 +71,8 @@ export interface UiMessages {
71
71
  readonly importAllDone: string;
72
72
  /** 导入成功(显式路径)。 */
73
73
  readonly importFromDone: string;
74
+ /** 回执带 truncated 标记时的追加说明(有内容因上限被跳过的总括)。 */
75
+ readonly importTruncated: string;
74
76
  /** 导入路径输入框的 placeholder。 */
75
77
  readonly importPlaceholder: string;
76
78
  /** 导入路径输入框的 aria-label。 */
@@ -139,6 +141,9 @@ export interface UiMessages {
139
141
  readonly organizeErrModelFailed: string;
140
142
  /** 润色前置检查失败:输入框为空。 */
141
143
  readonly organizeErrEmpty: string;
144
+ /** 润色请求超时(宿主端未在时限内回报)。 */
145
+ readonly organizeErrTimeout: string;
146
+ /** 没有会话 id 时「润色」不可用的 title 说明。 */
142
147
  /** 润色链路兜底:宿主回执没带 error 字段时给 {message} 的占位原因。 */
143
148
  readonly organizeErrUnknownReason: string;
144
149
  /** 润色回执整体不是对象时的兜底错误。 */