dsh-plugin-tool-management 0.16.6 → 0.18.0

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 (96) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/README.md +20 -4
  3. package/README_EN.md +20 -4
  4. package/docs/images/1-EN.png +0 -0
  5. package/docs/images/1.png +0 -0
  6. package/docs/images/2-EN.png +0 -0
  7. package/docs/images/2.png +0 -0
  8. package/docs/images/3-EN.png +0 -0
  9. package/docs/images/3.png +0 -0
  10. package/docs/images/4-EN.png +0 -0
  11. package/docs/images/4.png +0 -0
  12. package/docs/images/5-EN.png +0 -0
  13. package/docs/images/5.png +0 -0
  14. package/docs/images/6-EN.png +0 -0
  15. package/docs/images/6.png +0 -0
  16. package/docs/images/7-EN.png +0 -0
  17. package/docs/images/7.png +0 -0
  18. package/docs/images/8-EN.png +0 -0
  19. package/docs/images/8.png +0 -0
  20. package/docs/update.md +59 -0
  21. package/lib/audit-log.js +6 -2
  22. package/lib/client.js +1615 -148
  23. package/lib/compat/capability-specs.js +321 -0
  24. package/lib/compat/host-probe.js +261 -0
  25. package/lib/compat/host-roots.js +168 -0
  26. package/lib/compat/probe-types.js +6 -0
  27. package/lib/compat/probe.js +54 -714
  28. package/lib/context-inject-contract.js +114 -0
  29. package/lib/context-inject-frame.js +147 -0
  30. package/lib/context-inject-select.js +127 -0
  31. package/lib/context-inject-surface.js +97 -0
  32. package/lib/context-inject.js +57 -459
  33. package/lib/host-names.js +150 -0
  34. package/lib/http-api.js +229 -0
  35. package/lib/hub.js +84 -11
  36. package/lib/imports/parsers.js +40 -15
  37. package/lib/index.js +235 -843
  38. package/lib/mcp/inspect-probe.js +199 -0
  39. package/lib/mcp/loader-token.js +26 -0
  40. package/lib/mcp/manager.js +267 -558
  41. package/lib/mcp/patch-yaml.js +207 -40
  42. package/lib/mcp/secret-guard.js +122 -16
  43. package/lib/mcp/tool-visibility.js +388 -0
  44. package/lib/memories/archive-engine.js +163 -16
  45. package/lib/memories/archive.js +10 -1
  46. package/lib/memories/discovery.js +261 -0
  47. package/lib/memories/export-plan.js +42 -0
  48. package/lib/memories/index-io.js +125 -12
  49. package/lib/memories/memories-types.js +1 -0
  50. package/lib/memories/service.js +167 -78
  51. package/lib/memories/snapshot.js +41 -260
  52. package/lib/op-registry.js +72 -8
  53. package/lib/ops/compat.js +17 -2
  54. package/lib/ops/prompts.js +18 -5
  55. package/lib/ops/quick-prompts.js +26 -0
  56. package/lib/ops/scene-records.js +157 -10
  57. package/lib/ops/scene-sync.js +71 -1
  58. package/lib/ops/sessions.js +63 -13
  59. package/lib/ops/snapshot.js +123 -24
  60. package/lib/ops/trash.js +45 -9
  61. package/lib/prompts/quick-service.js +211 -0
  62. package/lib/prompts/service.js +7 -2
  63. package/lib/request-gate.js +115 -56
  64. package/lib/scene-linkage.js +184 -0
  65. package/lib/scene-prompt-sync.js +46 -7
  66. package/lib/scenes/candidates.js +21 -3
  67. package/lib/sessions/archive-schemas.js +121 -0
  68. package/lib/sessions/path-key.js +46 -0
  69. package/lib/sessions/workspace.js +45 -168
  70. package/lib/settings-sidecars.js +143 -0
  71. package/lib/skills/core-types.js +8 -0
  72. package/lib/skills/core-util.js +81 -0
  73. package/lib/skills/core.js +97 -2297
  74. package/lib/skills/dir-watch.js +71 -0
  75. package/lib/skills/frontmatter.js +96 -0
  76. package/lib/skills/homes.js +14 -0
  77. package/lib/skills/import-pipeline.js +231 -0
  78. package/lib/skills/manager-state.js +800 -0
  79. package/lib/skills/official.js +269 -0
  80. package/lib/skills/provider-registration.js +89 -0
  81. package/lib/skills/service.js +4 -234
  82. package/lib/skills/skill-roots.js +287 -0
  83. package/lib/skills/skill-trash.js +265 -0
  84. package/lib/skills/system-trash.js +97 -0
  85. package/lib/skills/upload-pipeline.js +374 -0
  86. package/lib/slash-settings.js +25 -0
  87. package/lib/subagents/persona-parse.js +312 -0
  88. package/lib/subagents/persona-types.js +5 -0
  89. package/lib/subagents/persona-write.js +93 -0
  90. package/lib/subagents/run-provider.js +159 -0
  91. package/lib/subagents/service.js +20 -639
  92. package/lib/subagents/tool-filter.js +98 -0
  93. package/lib/token-config.js +240 -0
  94. package/lib/tool-table-switch.js +163 -0
  95. package/lib/tools/scene.js +40 -9
  96. package/package.json +3 -2
@@ -0,0 +1,81 @@
1
+ // 技能核心的公共底座:业务错误码的构造与透传、条目路径谓词、可恢复 rename 的重试、
2
+ // 同目录临时文件名。
3
+ //
4
+ // 声明从 core.ts 逐个搬来(`--export-top-level` 只多 `export ` 前缀,正文一字未改)。
5
+ // 为什么要先有这一层:codedError / attachCode / lstatOrNull / renameWithRetry 这四件被
6
+ // **导入链路与技能读写两侧同时用到**,留在 core.ts 里就意味着任何从 core 搬出去的下游段
7
+ // 都要反过来引 core —— 那是运行时环。搬到这里,core.ts 与导入链路两侧都只向下引这一层。
8
+ // 这一层自己不引同目录的任何兄弟模块(只引 ../paths.js 与 node:*)。
9
+ import { basename, dirname, join, resolve } from "node:path";
10
+ import { promises as fs } from "node:fs";
11
+ import { randomUUID } from "node:crypto";
12
+ import { isSameOrDescendant, isValidSegment } from "../paths.js";
13
+ export const MAX_ENTRY_NAME_LENGTH = 128;
14
+ export const TRANSIENT_RENAME_CODES = new Set(["EACCES", "EBUSY", "EPERM"]);
15
+ // ── 业务错误码 ────────────────────────────────────────────────────────────────
16
+ /** 构造带 code/params 的业务 Error,供导入链路 throw 后透传到失败明细。 */
17
+ export function codedError(message, code, params) {
18
+ const error = new Error(message);
19
+ error.code = code;
20
+ error.params = params;
21
+ return error;
22
+ }
23
+ /** 把业务 Error 的 code/params 附加到失败明细;系统异常(ENOENT 等,非 error.* 前缀)保持原文。 */
24
+ export function attachCode(item, error) {
25
+ // 透传并回写任意失败明细对象(形状由各调用点决定),故按 any 处理。
26
+ const coded = error;
27
+ if (coded && typeof coded.code === "string" && /^error\./.test(coded.code))
28
+ item.code = coded.code;
29
+ if (coded && coded.params)
30
+ item.params = coded.params;
31
+ return item;
32
+ }
33
+ export function pathIdentity(path) {
34
+ const canonical = resolve(path);
35
+ return process.platform === "win32" ? canonical.toLowerCase() : canonical;
36
+ }
37
+ export async function lstatOrNull(path) {
38
+ try {
39
+ return await fs.lstat(path);
40
+ }
41
+ catch {
42
+ return null;
43
+ }
44
+ }
45
+ /** 名称只允许一个普通路径段;不把既有技能名称限制为 kebab-case。 */
46
+ export function entryPath(root, name) {
47
+ // 段名谓词收敛到 paths.js(此前与 rules / subagents / imports 各写一套,口径不一)。
48
+ // 原实现里 `basename(name) !== name` 那条已被谓词的「不含路径分隔符」覆盖。
49
+ if (!isValidSegment(name, MAX_ENTRY_NAME_LENGTH))
50
+ return null;
51
+ const rootPath = resolve(root);
52
+ const path = resolve(rootPath, name);
53
+ return isSameOrDescendant(rootPath, path) && rootPath !== path ? path : null;
54
+ }
55
+ /** 同目录临时文件加 rename,避免写入中断时截断原 SKILL.md。 */
56
+ /** Windows 上杀毒软件或索引器可能短暂占用目录;只重试明确可恢复的 rename 错误。 */
57
+ export async function renameWithRetry(source, destination, options = {}) {
58
+ const rename = typeof options.rename === "function" ? options.rename : fs.rename;
59
+ // Number.isInteger/isFinite 不收窄类型,故断言成 number 以保持既有比较表达式。
60
+ const maxAttempts = Number.isInteger(options.maxAttempts) && options.maxAttempts > 0
61
+ ? options.maxAttempts
62
+ : 6;
63
+ const delayMs = Number.isFinite(options.delayMs) && options.delayMs >= 0
64
+ ? options.delayMs
65
+ : 40;
66
+ for (let attempt = 1;; attempt++) {
67
+ try {
68
+ return await rename(source, destination);
69
+ }
70
+ catch (error) {
71
+ // 系统 rename 异常按可选 code 读取,保持既有重试判定。
72
+ if (!TRANSIENT_RENAME_CODES.has(error && error.code) ||
73
+ attempt >= maxAttempts)
74
+ throw error;
75
+ await new Promise((resolvePromise) => setTimeout(resolvePromise, delayMs * attempt));
76
+ }
77
+ }
78
+ }
79
+ export function temporaryPath(target, kind) {
80
+ return join(dirname(target), `.${basename(target)}.dssm-${kind}-${randomUUID()}`);
81
+ }