dsh-plugin-tool-management 0.21.5 → 0.21.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.
- package/CHANGELOG.md +27 -0
- package/README.md +125 -227
- package/README_EN.md +131 -230
- package/docs/UPDATE.md +42 -40
- 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/docs/images/banner-en.png +0 -0
- package/docs/images/banner-zh.png +0 -0
- package/lib/client.js +57 -9
- package/lib/compat/host-roots.js +1 -1
- package/lib/compat/probe.js +7 -6
- package/lib/index.js +14 -0
- package/lib/mcp/state-section.js +4 -1
- package/lib/op-registry.js +7 -5
- package/lib/ops/candidates.js +5 -4
- package/lib/ops/memory.js +10 -2
- package/lib/ops/prompts.js +2 -1
- package/lib/prompts/quick-service.js +3 -2
- package/lib/prompts/service.js +3 -2
- package/lib/scenes/candidates.js +4 -2
- package/lib/subagents/persona-parse.js +44 -2
- package/lib/subagents/persona-write.js +11 -3
- package/lib/subagents/service.js +2 -2
- package/lib/trash-retention.js +6 -2
- package/package.json +13 -13
|
@@ -4,12 +4,48 @@
|
|
|
4
4
|
// 从 subagents/service.ts 整段搬来,一行未改。这一层不认识宿主也不写文件:进来一段文本,
|
|
5
5
|
// 出去一个 PersonaDoc;创建与更新走的解析口径与扫描时同一份,两处不能各写一套。
|
|
6
6
|
import { decodeYamlScalar } from '../skills/frontmatter.js';
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* 按逗号/顿号切名单,引号内的逗号不切 —— 与写侧 `listEntry`(persona-write.ts)配对:
|
|
9
|
+
* 名字本身含逗号时整体加引落盘,这里必须原样取回,不能把一条名字裂成两条。
|
|
10
|
+
* 双引号内按 JSON 转义对(`\"`)原样透传给解码器。
|
|
11
|
+
*/
|
|
12
|
+
function splitNameList(text) {
|
|
13
|
+
const out = [];
|
|
14
|
+
let cur = '';
|
|
15
|
+
let quote = '';
|
|
16
|
+
for (let i = 0; i < text.length; i++) {
|
|
17
|
+
const ch = text[i];
|
|
18
|
+
if (quote !== '') {
|
|
19
|
+
cur += ch;
|
|
20
|
+
if (ch === '\\' && i + 1 < text.length) {
|
|
21
|
+
cur += text[++i];
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
if (ch === quote)
|
|
25
|
+
quote = '';
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (ch === '"' || ch === "'") {
|
|
29
|
+
quote = ch;
|
|
30
|
+
cur += ch;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (ch === ',' || ch === ',') {
|
|
34
|
+
out.push(cur);
|
|
35
|
+
cur = '';
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
cur += ch;
|
|
39
|
+
}
|
|
40
|
+
out.push(cur);
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
/** 逗号/顿号分隔的名字清单(空串 → undefined);单条按 YAML 标量解码,配对写侧的引号。 */
|
|
8
44
|
export function listOf(value) {
|
|
9
45
|
const text = String(value ?? '').trim();
|
|
10
46
|
if (!text)
|
|
11
47
|
return undefined;
|
|
12
|
-
const list = text
|
|
48
|
+
const list = splitNameList(text).map((s) => decodeYamlScalar(s).trim()).filter(Boolean);
|
|
13
49
|
return list.length ? list : undefined;
|
|
14
50
|
}
|
|
15
51
|
/**
|
|
@@ -107,6 +143,12 @@ export function parsePersona(raw, fallbackName) {
|
|
|
107
143
|
outputLines.push(value);
|
|
108
144
|
continue;
|
|
109
145
|
}
|
|
146
|
+
// 名单字段的引号是**逐条**的(含逗号的名字整体加引):整值解码会把唯一加引的
|
|
147
|
+
// 条目提前解开、再被 listOf 按逗号切坏 —— 这两个键存原值,解码交给 listOf。
|
|
148
|
+
if (key === 'tools' || key === 'toolsdeny') {
|
|
149
|
+
data[key] = kv[2].trim();
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
110
152
|
data[key] = decodeYamlScalar(kv[2]).trim();
|
|
111
153
|
}
|
|
112
154
|
toolsByPreset = parsePresetToolRules(m[1]);
|
|
@@ -20,6 +20,14 @@ export function validPersonaName(name) {
|
|
|
20
20
|
export function toStringList(value) {
|
|
21
21
|
return Array.isArray(value) ? value.map((x) => String(x).trim()).filter(Boolean) : [];
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* 名单里单条名字的转义。名字按逗号分隔落盘,含逗号(半角 / 全角)的名字不引起来
|
|
25
|
+
* 会在回读时裂成两条 —— `yamlScalar` 不引逗号(单值场景无此问题),这里补上。
|
|
26
|
+
* 读侧(persona-parse 的 `listOf`)按引号感知的切分配对解码。
|
|
27
|
+
*/
|
|
28
|
+
function listEntry(name) {
|
|
29
|
+
return /[,,]/.test(name) ? JSON.stringify(name) : yamlScalar(name);
|
|
30
|
+
}
|
|
23
31
|
/** 人设文件序列化:frontmatter 只写用户填过的键;正文 = 人设提示词。 */
|
|
24
32
|
export function serializePersona(args) {
|
|
25
33
|
const description = String((args && args.description) || '').replace(/\r?\n/g, ' ').trim();
|
|
@@ -68,13 +76,13 @@ export function serializePersona(args) {
|
|
|
68
76
|
lines.push(' - ' + yamlScalar(line));
|
|
69
77
|
}
|
|
70
78
|
if (tools.length)
|
|
71
|
-
lines.push('tools: ' + tools.join(', '));
|
|
79
|
+
lines.push('tools: ' + tools.map(listEntry).join(', '));
|
|
72
80
|
if (toolsDeny.length)
|
|
73
|
-
lines.push('toolsDeny: ' + toolsDeny.join(', '));
|
|
81
|
+
lines.push('toolsDeny: ' + toolsDeny.map(listEntry).join(', '));
|
|
74
82
|
if (byPreset.length) {
|
|
75
83
|
lines.push('toolsByPreset:');
|
|
76
84
|
for (const [id, rule] of byPreset)
|
|
77
|
-
lines.push(' ' + id + ': ' + rule.mode + ': ' + rule.names.join(', '));
|
|
85
|
+
lines.push(' ' + id + ': ' + rule.mode + ': ' + rule.names.map(listEntry).join(', '));
|
|
78
86
|
}
|
|
79
87
|
lines.push('---', '', body, '');
|
|
80
88
|
return lines.join('\n');
|
package/lib/subagents/service.js
CHANGED
|
@@ -10,7 +10,7 @@ import { createRequire } from 'node:module';
|
|
|
10
10
|
import { mkdir, readdir, readFile, rename, rm, stat, writeFile } from 'node:fs/promises';
|
|
11
11
|
import { join } from 'node:path';
|
|
12
12
|
import { writeFileAtomically } from '../memories/index-io.js';
|
|
13
|
-
import { resolveDshHome } from '../skills/core.js';
|
|
13
|
+
import { renameWithRetry, resolveDshHome } from '../skills/core.js';
|
|
14
14
|
import { listTrashEntries, moveOutOfTrash, moveToTrash, purgeTrashEntry, readTrashEntry } from '../hub.js';
|
|
15
15
|
import { expandUploads, planPersonaImport } from '../imports/upload.js';
|
|
16
16
|
import { catalogDepthOf, parsePersona, } from './persona-parse.js';
|
|
@@ -341,7 +341,7 @@ export function createSubagentService(ctx, opts) {
|
|
|
341
341
|
const tmp = join(dir, `.${finalName}.tmp-${process.pid}-${Date.now()}`);
|
|
342
342
|
try {
|
|
343
343
|
await writeFile(tmp, serializePersona({ ...args, name: finalName }), 'utf8');
|
|
344
|
-
await
|
|
344
|
+
await renameWithRetry(tmp, finalTarget);
|
|
345
345
|
}
|
|
346
346
|
catch (e) {
|
|
347
347
|
await rm(tmp, { force: true }).catch(() => undefined);
|
package/lib/trash-retention.js
CHANGED
|
@@ -25,7 +25,9 @@ import { dirname } from 'node:path';
|
|
|
25
25
|
import { writeFileAtomically } from './memories/index-io.js';
|
|
26
26
|
import { recordAudit } from './audit-log.js';
|
|
27
27
|
import { hubPath, listTrashEntries, purgeTrashEntry, } from './hub.js';
|
|
28
|
-
import { listTrash as listSkillTrash
|
|
28
|
+
import { listTrash as listSkillTrash } from './skills/skill-trash.js';
|
|
29
|
+
import { permanentlyDeleteTrashSafely } from './skills/system-trash.js';
|
|
30
|
+
import { pluginLog } from './skills/service.js';
|
|
29
31
|
/** 一天的毫秒数(保留期按「天」配置,比较按毫秒)。与 sessions/history.ts 同一个常量。 */
|
|
30
32
|
export const MS_PER_DAY = 24 * 60 * 60 * 1000;
|
|
31
33
|
/** 保留期侧车文件名(放 hub 根,与 `history-retention.json` 并排)。 */
|
|
@@ -139,7 +141,9 @@ export async function collectTrashCandidates(memories) {
|
|
|
139
141
|
name: item.name,
|
|
140
142
|
// `deletedAt` 在技能元数据里是可选的:更早的版本可能没写 → 空串 → 不清扫(第 ③ 条)。
|
|
141
143
|
deletedAt: String(item.deletedAt ?? ''),
|
|
142
|
-
|
|
144
|
+
// 与手工 skill-trash-delete 同一道保险:先送系统回收站、失败才硬删。自动清扫
|
|
145
|
+
// 无人值守、破坏力更大,不能反而比手工路径少一层。
|
|
146
|
+
purge: () => permanentlyDeleteTrashSafely(item.id, pluginLog()),
|
|
143
147
|
});
|
|
144
148
|
}
|
|
145
149
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-tool-management",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.7",
|
|
4
4
|
"description": "一个设置面板,统一管理 MCP、技能、记忆、子智能体、提示词和归档会话;可自定义搭配场景,一个场景即可切换整个环境;Agent也能帮你操作这个插件。",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"docs/UPDATE.md"
|
|
29
29
|
],
|
|
30
30
|
"engines": {
|
|
31
|
-
"dsh": ">=0.2.1-rc.
|
|
31
|
+
"dsh": ">=0.2.1-rc.3 <0.2.2",
|
|
32
32
|
"node": ">=18"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
@@ -73,17 +73,17 @@
|
|
|
73
73
|
"icon": "./docs/images/logo.png",
|
|
74
74
|
"peerDependencies": {
|
|
75
75
|
"@deepseek-ai/cordis": "^4.0.2",
|
|
76
|
-
"@deepseek-ai/dsh-agent-preset-registry": ">=0.2.1-rc.
|
|
77
|
-
"@deepseek-ai/dsh-llm": ">=0.2.1-rc.
|
|
78
|
-
"@deepseek-ai/dsh-session": ">=0.2.1-rc.
|
|
79
|
-
"@deepseek-ai/dsh-session-projection-cache": ">=0.2.1-rc.
|
|
80
|
-
"@deepseek-ai/dsh-settings": ">=0.2.1-rc.
|
|
81
|
-
"@deepseek-ai/dsh-spill-local": ">=0.2.1-rc.
|
|
82
|
-
"@deepseek-ai/dsh-storage-domain": ">=0.2.1-rc.
|
|
83
|
-
"@deepseek-ai/dsh-subagent-fork-in-process": ">=0.2.1-rc.
|
|
84
|
-
"@deepseek-ai/dsh-subagent-spawn-in-process": ">=0.2.1-rc.
|
|
85
|
-
"@deepseek-ai/dsh-tools": ">=0.2.1-rc.
|
|
86
|
-
"@deepseek-ai/dsh-workspace": ">=0.2.1-rc.
|
|
76
|
+
"@deepseek-ai/dsh-agent-preset-registry": ">=0.2.1-rc.3 <0.2.2",
|
|
77
|
+
"@deepseek-ai/dsh-llm": ">=0.2.1-rc.3 <0.2.2",
|
|
78
|
+
"@deepseek-ai/dsh-session": ">=0.2.1-rc.3 <0.2.2",
|
|
79
|
+
"@deepseek-ai/dsh-session-projection-cache": ">=0.2.1-rc.3 <0.2.2",
|
|
80
|
+
"@deepseek-ai/dsh-settings": ">=0.2.1-rc.3 <0.2.2",
|
|
81
|
+
"@deepseek-ai/dsh-spill-local": ">=0.2.1-rc.3 <0.2.2",
|
|
82
|
+
"@deepseek-ai/dsh-storage-domain": ">=0.2.1-rc.3 <0.2.2",
|
|
83
|
+
"@deepseek-ai/dsh-subagent-fork-in-process": ">=0.2.1-rc.3 <0.2.2",
|
|
84
|
+
"@deepseek-ai/dsh-subagent-spawn-in-process": ">=0.2.1-rc.3 <0.2.2",
|
|
85
|
+
"@deepseek-ai/dsh-tools": ">=0.2.1-rc.3 <0.2.2",
|
|
86
|
+
"@deepseek-ai/dsh-workspace": ">=0.2.1-rc.3 <0.2.2",
|
|
87
87
|
"react": "^18.2.0"
|
|
88
88
|
},
|
|
89
89
|
"peerDependenciesMeta": {
|