dsh-plugin-tool-management 0.21.1 → 0.21.3
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/CHANGELOG.md +111 -1
- package/README.md +43 -7
- package/README_EN.md +41 -7
- package/docs/{update.md → UPDATE.md} +38 -36
- package/docs/images/1-EN.png +0 -0
- package/docs/images/1.png +0 -0
- package/docs/images/2-EN.png +0 -0
- package/docs/images/2.png +0 -0
- package/docs/images/3-EN.png +0 -0
- package/docs/images/3.png +0 -0
- package/docs/images/4-EN.png +0 -0
- package/docs/images/4.png +0 -0
- package/docs/images/5-EN.png +0 -0
- package/docs/images/5.png +0 -0
- package/docs/images/6-EN.png +0 -0
- package/docs/images/6.png +0 -0
- package/docs/images/7-EN.png +0 -0
- package/docs/images/7.png +0 -0
- package/docs/images/8-EN.png +0 -0
- package/docs/images/8.png +0 -0
- package/lib/approval-policy.js +2 -2
- package/lib/audit-log.js +1 -1
- package/lib/boot/reconcile.js +157 -0
- package/lib/client.js +6668 -3145
- package/lib/compat/capability-specs.js +13 -17
- package/lib/compat/host-contracts.js +2 -0
- package/lib/compat/host-probe.js +35 -38
- package/lib/compat/host-roots.js +86 -15
- package/lib/compat/patch-dialect.js +14 -1
- package/lib/compat/preset-reach.js +75 -102
- package/lib/compat/probe.js +86 -131
- package/lib/compat/runtime-notes.js +1 -1
- package/lib/context-inject-contract.js +6 -5
- package/lib/context-inject-frame.js +124 -73
- package/lib/context-inject-select.js +66 -12
- package/lib/context-inject-surface.js +52 -4
- package/lib/context-inject.js +176 -39
- package/lib/desktop-cookie-prune.js +95 -0
- package/lib/diagnostics.js +79 -0
- package/lib/exports/transcript.js +4 -4
- package/lib/host-names.js +6 -6
- package/lib/http-api.js +73 -48
- package/lib/http-fence.js +44 -9
- package/lib/hub.js +12 -13
- package/lib/imports/parsers.js +25 -21
- package/lib/imports/unzip.js +48 -0
- package/lib/imports/upload.js +13 -37
- package/lib/index.js +3026 -279
- package/lib/mcp/disabled-tools.js +97 -0
- package/lib/mcp/loader-token.js +4 -4
- package/lib/mcp/manager.js +636 -226
- package/lib/mcp/override-blocks.js +1 -1
- package/lib/mcp/patch-yaml.js +42 -31
- package/lib/mcp/restart-marker.js +110 -0
- package/lib/mcp/secret-guard.js +6 -6
- package/lib/mcp/state-section.js +190 -60
- package/lib/mcp/tool-visibility.js +364 -73
- package/lib/memories/archive-engine.js +67 -42
- package/lib/memories/archive.js +23 -3
- package/lib/memories/constants.js +40 -127
- package/lib/memories/discovery.js +41 -12
- package/lib/memories/index-io.js +238 -33
- package/lib/memories/projection.js +36 -20
- package/lib/memories/prompt-layer.js +38 -0
- package/lib/memories/search.js +86 -0
- package/lib/memories/service.js +350 -111
- package/lib/memories/snapshot.js +83 -36
- package/lib/op-registry.js +73 -15
- package/lib/ops/candidates.js +14 -5
- package/lib/ops/compat.js +56 -13
- package/lib/ops/ctx.js +1 -1
- package/lib/ops/memory.js +89 -20
- package/lib/ops/prompts.js +57 -13
- package/lib/ops/quick-prompts.js +25 -2
- package/lib/ops/scene-records.js +29 -23
- package/lib/ops/scene-sync.js +30 -10
- package/lib/ops/scope.js +1094 -0
- package/lib/ops/sessions.js +15 -11
- package/lib/ops/snapshot.js +65 -29
- package/lib/ops/state-doctor.js +40 -5
- package/lib/ops/trash-retention.js +2 -1
- package/lib/ops/trash.js +6 -6
- package/lib/paths.js +50 -3
- package/lib/prompts/preset-id.js +5 -1
- package/lib/prompts/project-instructions.js +162 -0
- package/lib/prompts/quick-service.js +6 -4
- package/lib/prompts/service.js +30 -18
- package/lib/request-gate.js +32 -29
- package/lib/scene-linkage.js +17 -4
- package/lib/scene-prompt-sync.js +11 -10
- package/lib/scene-settings.js +1 -0
- package/lib/scenes/candidates.js +17 -11
- package/lib/scope/intent-store.js +106 -0
- package/lib/scope/intent.js +376 -0
- package/lib/scope/resolve.js +190 -0
- package/lib/scope/scope-overrides.js +894 -0
- package/lib/scope/store.js +263 -0
- package/lib/scope/workspace-key.js +64 -0
- package/lib/sessions/archive-schemas.js +9 -0
- package/lib/sessions/bridge.js +42 -56
- package/lib/sessions/history.js +9 -9
- package/lib/sessions/workspace.js +21 -23
- package/lib/settings-sidecars.js +51 -24
- package/lib/sidebar-settings.js +1 -0
- package/lib/skills/catalog.js +207 -35
- package/lib/skills/core-util.js +5 -0
- package/lib/skills/core.js +36 -23
- package/lib/skills/frontmatter.js +144 -11
- package/lib/skills/homes.js +2 -0
- package/lib/skills/import-pipeline.js +8 -1
- package/lib/skills/manager-state.js +30 -6
- package/lib/skills/official.js +14 -11
- package/lib/skills/readonly-discovery.js +1 -0
- package/lib/skills/service.js +157 -31
- package/lib/skills/skill-roots.js +25 -7
- package/lib/skills/skill-trash.js +14 -3
- package/lib/skills/system-trash.js +3 -1
- package/lib/skills/upload-pipeline.js +19 -3
- package/lib/slash-settings.js +1 -0
- package/lib/stale-write.js +82 -0
- package/lib/subagents/catalog.js +52 -18
- package/lib/subagents/child-preset.js +7 -10
- package/lib/subagents/persona-parse.js +35 -13
- package/lib/subagents/persona-write.js +12 -8
- package/lib/subagents/run-provider.js +13 -15
- package/lib/subagents/service.js +16 -14
- package/lib/subagents/tool-filter.js +1 -1
- package/lib/subagents/tools.js +113 -41
- package/lib/token-config.js +34 -14
- package/lib/tool-table-switch.js +142 -49
- package/lib/tools/deps.js +172 -6
- package/lib/tools/mcp.js +231 -54
- package/lib/tools/memory.js +139 -39
- package/lib/tools/prompt.js +81 -17
- package/lib/tools/remove.js +52 -26
- package/lib/tools/scene.js +139 -42
- package/lib/tools/skills.js +211 -51
- package/lib/tools/subagent.js +63 -32
- package/lib/tools/table.js +63 -25
- package/lib/trash-id.js +3 -2
- package/lib/trash-retention.js +7 -7
- package/lib/update-check.js +222 -0
- package/package.json +18 -15
package/lib/imports/upload.js
CHANGED
|
@@ -4,17 +4,21 @@
|
|
|
4
4
|
// 约定:只认 .md;zip 内任意层级;隐藏项 / 绝对路径 / `..` 穿越 / 超限条目一律跳过并回报;
|
|
5
5
|
// 重名策略(跳过 or 覆盖)不在这里实现——由调用方按文件系统现状裁决(本项目取「跳过并报告」)。
|
|
6
6
|
//
|
|
7
|
-
//
|
|
7
|
+
// 两条限额的**口径**要分清(审计 T-09):`MAX_IMPORT_TOTAL_BYTES` 管的是
|
|
8
8
|
// **上传(编码后)**字节,管不住解压后的体积 —— 一个 8 MiB 条目 × 2000 条 ≈ 16 GiB 会在
|
|
9
9
|
// 单次 `unzipSync` 里被实体化。所以另有 `MAX_IMPORT_UNCOMPRESSED_BYTES` 管**解压后**的
|
|
10
10
|
// 累计量,在 filter 里按档案自报的 `info.originalSize` 累加。
|
|
11
|
-
import {
|
|
11
|
+
import { unzipLimited } from './unzip.js';
|
|
12
12
|
import { isValidSegment } from '../paths.js';
|
|
13
|
+
/** 单次导入的文件数上限:再多就不是「导一份技能」而是一次批量迁移了。 */
|
|
13
14
|
export const MAX_IMPORT_FILES = 200;
|
|
15
|
+
/** 单个条目(解码后)上限 8 MiB:技能正文与随包资源都远小于此,超了基本是误传。 */
|
|
14
16
|
export const MAX_IMPORT_ENTRY_BYTES = 8 * 1024 * 1024;
|
|
15
17
|
/** 上传(编码后)总量:与传输层的 88 MiB 体限是同一层口径,防止一次请求塞进几百 MiB。 */
|
|
16
18
|
export const MAX_IMPORT_TOTAL_BYTES = 32 * 1024 * 1024;
|
|
19
|
+
/** 一次导入的条目总数上限:与 `MAX_IMPORT_FILES` 分开算 —— 一个文件里可以有多个条目。 */
|
|
17
20
|
export const MAX_IMPORT_ENTRIES = 2000;
|
|
21
|
+
/** 条目名长度上限 64:与技能目录名、文件名的最长合法长度同档。 */
|
|
18
22
|
export const MAX_IMPORT_NAME_LENGTH = 64;
|
|
19
23
|
/**
|
|
20
24
|
* 解压后累计上限(与技能上传器 `MAX_UPLOAD_TOTAL_BYTES = 64 MiB` 同层口径)。
|
|
@@ -73,8 +77,6 @@ export function expandUploads(files) {
|
|
|
73
77
|
problems.push({ name: `(其余 ${all.length - MAX_IMPORT_FILES} 个文件)`, reason: `一次最多导入 ${MAX_IMPORT_FILES} 个文件` });
|
|
74
78
|
}
|
|
75
79
|
let total = 0;
|
|
76
|
-
/** 解压后超限只报一次(与"超条目数"同口径,避免几千条问题刷屏)。 */
|
|
77
|
-
let uncompressedReported = false;
|
|
78
80
|
for (const raw of list) {
|
|
79
81
|
const file = (raw || {});
|
|
80
82
|
const name = String(file.name || '').trim() || '(未命名)';
|
|
@@ -94,41 +96,15 @@ export function expandUploads(files) {
|
|
|
94
96
|
}
|
|
95
97
|
if (isZipBytes(bytes)) {
|
|
96
98
|
let unzipped;
|
|
97
|
-
let uncompressed = 0;
|
|
98
99
|
try {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
// 2026-09-13 实测(限额验证批):9 MiB 附件与第 2001 个条目都曾无声消失,
|
|
105
|
-
// 响应里 imported=1 / skipped=[] —— 用户完全看不出少了东西。
|
|
106
|
-
if (count > MAX_IMPORT_ENTRIES) {
|
|
107
|
-
// 超条目数时只报一次,避免 2000+ 条问题刷屏。
|
|
108
|
-
if (count === MAX_IMPORT_ENTRIES + 1) {
|
|
109
|
-
problems.push({ name, reason: `zip 内条目超过 ${MAX_IMPORT_ENTRIES} 个,其余条目已忽略` });
|
|
110
|
-
}
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
if (!info.name.endsWith('/') && info.originalSize > MAX_IMPORT_ENTRY_BYTES) {
|
|
114
|
-
problems.push({ name: info.name, reason: `zip 内单条目超过 ${MAX_IMPORT_ENTRY_BYTES >> 20} MiB,已跳过` });
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
// 解压后累计:单条目与条目数都挡不住「2000 × 8 MiB」这种组合,只有累计量挡得住。
|
|
118
|
-
// 目录条目不占解压预算(originalSize 为 0 且不产出内容)。
|
|
119
|
-
if (!info.name.endsWith('/')) {
|
|
120
|
-
uncompressed += info.originalSize;
|
|
121
|
-
if (uncompressed > MAX_IMPORT_UNCOMPRESSED_BYTES) {
|
|
122
|
-
if (!uncompressedReported) {
|
|
123
|
-
uncompressedReported = true;
|
|
124
|
-
problems.push({ name: info.name, reason: `zip 解压后合计超过 ${MAX_IMPORT_UNCOMPRESSED_BYTES >> 20} MiB,该条目及其后条目已忽略` });
|
|
125
|
-
}
|
|
126
|
-
return false;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return true;
|
|
130
|
-
},
|
|
100
|
+
const result = unzipLimited(bytes, {
|
|
101
|
+
maxEntries: MAX_IMPORT_ENTRIES,
|
|
102
|
+
maxEntryBytes: MAX_IMPORT_ENTRY_BYTES,
|
|
103
|
+
maxTotalUncompressedBytes: MAX_IMPORT_UNCOMPRESSED_BYTES,
|
|
104
|
+
sourceName: name,
|
|
131
105
|
});
|
|
106
|
+
unzipped = result.entries;
|
|
107
|
+
problems.push(...result.problems);
|
|
132
108
|
}
|
|
133
109
|
catch (e) {
|
|
134
110
|
problems.push({ name, reason: 'ZIP 解压失败:' + message(e) });
|