@suifei/dsh-ai-team 0.4.149 → 0.4.151
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 +11 -0
- package/README.md +6 -2
- package/client.js +235 -22
- package/index.js +152 -20
- package/lib/domain/catalog.js +14 -6
- package/lib/host/skill-import.js +204 -0
- package/lib/runtime/skill-catalog.js +56 -41
- package/lib/runtime/skill-provider.js +69 -44
- package/package.json +75 -74
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs';
|
|
15
|
-
import { join } from 'node:path';
|
|
15
|
+
import { dirname, join } from 'node:path';
|
|
16
|
+
import { isScalar, parseDocument } from 'yaml';
|
|
16
17
|
import { isSkillExcluded } from './skill-policy.js';
|
|
17
18
|
import { renderSkillVars } from './skill-loader.js';
|
|
18
19
|
import { reportFail } from '../diaglog.js';
|
|
@@ -50,7 +51,7 @@ export function pickProjectForCwd(projects, cwd) {
|
|
|
50
51
|
return list.length === 1 ? shape(list[0]) : undefined;
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
const
|
|
54
|
+
export const MAX_SKILL_BODY_BYTES = 512 * 1024;
|
|
54
55
|
|
|
55
56
|
/** Official per-source ranks; a lower rank beats a higher one on name clash. */
|
|
56
57
|
const SOURCE_RANK = Object.freeze({
|
|
@@ -61,13 +62,30 @@ const SOURCE_RANK = Object.freeze({
|
|
|
61
62
|
});
|
|
62
63
|
|
|
63
64
|
function parseFrontmatter(text) {
|
|
65
|
+
if (text.charCodeAt(0) === 0xfeff) text = text.slice(1);
|
|
64
66
|
if (!text.startsWith('---')) return {};
|
|
65
67
|
const end = text.indexOf('\n---', 3);
|
|
66
68
|
if (end < 0) return {};
|
|
69
|
+
const header = text.slice(3, end);
|
|
70
|
+
try {
|
|
71
|
+
const document = parseDocument(header);
|
|
72
|
+
if (document.errors.length > 0) throw document.errors[0];
|
|
73
|
+
const parsed = document.toJS();
|
|
74
|
+
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) return {};
|
|
75
|
+
for (const key of ['disable-model-invocation', 'user-invocable']) {
|
|
76
|
+
if (!Object.hasOwn(parsed, key)) continue;
|
|
77
|
+
const value = document.get(key, true);
|
|
78
|
+
// 旧本地 provider 只识别裸布尔写法;YAML 解码不能悄悄放宽已安装技能的策略。
|
|
79
|
+
if (!isScalar(value) || value.type !== 'PLAIN') parsed[key] = null;
|
|
80
|
+
}
|
|
81
|
+
return parsed;
|
|
82
|
+
} catch {
|
|
83
|
+
// 旧的本地技能可能带未引用的冒号。继续识别已能加载的文件。
|
|
84
|
+
}
|
|
67
85
|
// CRLF 必须在这里断干净:`\r` 在 JS 里是行终止符,`.$` 无法越过它,
|
|
68
86
|
// 带尾 `\r` 的最后一行(常见于 Windows 编辑器)会整行失配——
|
|
69
87
|
// description 恰好位于末尾时,整个技能被当成「缺少 description」丢弃。
|
|
70
|
-
const lines =
|
|
88
|
+
const lines = header.split(/\r\n|\r|\n/);
|
|
71
89
|
const fields = {};
|
|
72
90
|
let key = null;
|
|
73
91
|
for (const line of lines) {
|
|
@@ -114,43 +132,50 @@ function invocationFlag(fields, key, inverted) {
|
|
|
114
132
|
return inverted ? !parsed : parsed;
|
|
115
133
|
}
|
|
116
134
|
|
|
117
|
-
function
|
|
118
|
-
if (!existsSync(file)) return null;
|
|
119
|
-
let text;
|
|
120
|
-
try {
|
|
121
|
-
if (statSync(file).size > MAX_BODY_BYTES) return null;
|
|
122
|
-
text = readFileSync(file, 'utf8');
|
|
123
|
-
} catch {
|
|
124
|
-
return null;
|
|
125
|
-
}
|
|
135
|
+
export function inspectFileSkill(text, fallbackName = '') {
|
|
126
136
|
const fields = parseFrontmatter(text);
|
|
127
137
|
const name = unquote(fields.name) || fallbackName;
|
|
128
138
|
// Must match the host registry's SKILL_NAME exactly (`^[a-z0-9]+(?:-[a-z0-9]+)*$`):
|
|
129
139
|
// a name we accept but the registry rejects makes `skills.snapshot` throw
|
|
130
140
|
// "skill provider returned invalid skill name", which aborts every agent step.
|
|
131
|
-
if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(name)) return
|
|
132
|
-
if (isSkillExcluded(name)) return
|
|
141
|
+
if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(name)) return { name, problem: 'name-invalid' };
|
|
142
|
+
if (isSkillExcluded(name)) return { name, problem: 'name-excluded' };
|
|
133
143
|
const description = unquote(fields.description);
|
|
134
|
-
|
|
135
|
-
// dropped with a warning rather than synthesized into the catalog.
|
|
136
|
-
if (description === '') {
|
|
137
|
-
reportFail('skill.dropped.fail', { skill: name, file, reason: 'description-required' }, `[ai-team] skill "${name}" dropped: frontmatter description is required`);
|
|
138
|
-
return null;
|
|
139
|
-
}
|
|
144
|
+
if (description === '') return { name, problem: 'description-required' };
|
|
140
145
|
const modelInvocable = invocationFlag(fields, 'disable-model-invocation', true);
|
|
141
146
|
const userInvocable = invocationFlag(fields, 'user-invocable', false);
|
|
142
|
-
if (modelInvocable === null || userInvocable === null) {
|
|
143
|
-
reportFail('skill.dropped.fail', { skill: name, file, reason: 'invocation-not-boolean' }, `[ai-team] skill "${name}" dropped: invocation flag is not a boolean`);
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
147
|
+
if (modelInvocable === null || userInvocable === null) return { name, problem: 'invocation-not-boolean' };
|
|
146
148
|
return {
|
|
147
149
|
name,
|
|
148
150
|
description,
|
|
149
151
|
whenToUse: unquote(fields.whenToUse) || unquote(fields['when-to-use']) || undefined,
|
|
150
152
|
invocation: { modelInvocable, userInvocable },
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function scanCandidate(file, fallbackName, source) {
|
|
157
|
+
if (!existsSync(file)) return null;
|
|
158
|
+
let text;
|
|
159
|
+
try {
|
|
160
|
+
if (statSync(file).size > MAX_SKILL_BODY_BYTES) return null;
|
|
161
|
+
text = readFileSync(file, 'utf8');
|
|
162
|
+
} catch {
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
const metadata = inspectFileSkill(text, fallbackName);
|
|
166
|
+
if (metadata.problem) {
|
|
167
|
+
if (metadata.problem === 'description-required' || metadata.problem === 'invocation-not-boolean') {
|
|
168
|
+
const message = metadata.problem === 'description-required' ? 'frontmatter description is required' : 'invocation flag is not a boolean';
|
|
169
|
+
reportFail('skill.dropped.fail', { skill: metadata.name, file, reason: metadata.problem }, `[ai-team] skill "${metadata.name}" dropped: ${message}`);
|
|
170
|
+
}
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
...metadata,
|
|
151
175
|
source,
|
|
152
176
|
provider: 'ai-team-files',
|
|
153
177
|
path: file,
|
|
178
|
+
resourceBase: { kind: 'directory', path: dirname(file) },
|
|
154
179
|
locator: file,
|
|
155
180
|
rank: SOURCE_RANK[source] ?? 500,
|
|
156
181
|
};
|
|
@@ -183,25 +208,21 @@ function scanRoot(root, source) {
|
|
|
183
208
|
export function createFileSkillProvider({ dshHome, projectCwd, bundledDir, resolveVars } = {}) {
|
|
184
209
|
// Bundled last: the official rank order puts disk roots above the packaged
|
|
185
210
|
// copy, so a user's own edit of a same-named skill wins (README L48-56).
|
|
186
|
-
const
|
|
187
|
-
if (
|
|
188
|
-
|
|
189
|
-
roots.push([join(projectCwd, '.agents', 'skills'), 'project-agents']);
|
|
190
|
-
}
|
|
191
|
-
if (dshHome) roots.push([join(dshHome, 'skills'), 'user-dsh']);
|
|
192
|
-
if (bundledDir) roots.push([join(bundledDir, 'skills'), 'bundled']);
|
|
211
|
+
const globalRoots = [];
|
|
212
|
+
if (dshHome) globalRoots.push([join(dshHome, 'skills'), 'user-dsh']);
|
|
213
|
+
if (bundledDir) globalRoots.push([join(bundledDir, 'skills'), 'bundled']);
|
|
193
214
|
return {
|
|
194
215
|
name: 'ai-team-files',
|
|
195
216
|
async list(options = {}) {
|
|
196
|
-
const
|
|
217
|
+
const resolveCwd = typeof options.cwd === 'string' && options.cwd !== '' ? options.cwd : projectCwd;
|
|
218
|
+
const projectRoots = resolveCwd
|
|
197
219
|
? [
|
|
198
|
-
[join(
|
|
199
|
-
[join(
|
|
220
|
+
[join(resolveCwd, '.dsh', 'skills'), 'project-dsh'],
|
|
221
|
+
[join(resolveCwd, '.agents', 'skills'), 'project-agents'],
|
|
200
222
|
]
|
|
201
223
|
: [];
|
|
202
224
|
const all = [];
|
|
203
|
-
const
|
|
204
|
-
for (const [root, source] of [...roots, ...extra]) {
|
|
225
|
+
for (const [root, source] of [...projectRoots, ...globalRoots]) {
|
|
205
226
|
for (const candidate of scanRoot(root, source)) all.push({ ...candidate, resolveCwd });
|
|
206
227
|
}
|
|
207
228
|
// Same-name clash: the lowest rank wins, mirroring the registry's
|
|
@@ -218,7 +239,7 @@ export function createFileSkillProvider({ dshHome, projectCwd, bundledDir, resol
|
|
|
218
239
|
// 读取失败不能把 rejection 冒到 skill 工具:宿主在 agent/pre-step 里
|
|
219
240
|
// await skills.snapshot,一次 EACCES/EBUSY 会打断该 agent 的整个回合。
|
|
220
241
|
try {
|
|
221
|
-
if (statSync(file).size >
|
|
242
|
+
if (statSync(file).size > MAX_SKILL_BODY_BYTES) return undefined;
|
|
222
243
|
const raw = readFileSync(file, 'utf8');
|
|
223
244
|
// 技能按文件原样提供,但 `{{GOAL}}` 这类占位符必须在返回前渲染:成员主动
|
|
224
245
|
// 加载技能时不该看到字面量(与激活注入走同一套变量)。
|
|
@@ -237,12 +258,16 @@ export function createFileSkillProvider({ dshHome, projectCwd, bundledDir, resol
|
|
|
237
258
|
export function installFileSkillProvider(skills, options) {
|
|
238
259
|
if (!skills || typeof skills.registerProvider !== 'function') return () => {};
|
|
239
260
|
const provider = createFileSkillProvider(options);
|
|
240
|
-
// SDK
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
261
|
+
// 失效能力属于工厂收到的 SDK control。注册的返回值只负责注销。
|
|
262
|
+
let providerControl;
|
|
263
|
+
const registration = skills.registerProvider((control) => {
|
|
264
|
+
providerControl = control;
|
|
265
|
+
return provider;
|
|
266
|
+
});
|
|
267
|
+
const dispose = typeof registration === 'function' ? registration : () => registration?.dispose?.();
|
|
268
|
+
const release = () => {
|
|
269
|
+
try { dispose(); } catch { /* already disposed */ }
|
|
247
270
|
};
|
|
271
|
+
release.invalidate = () => providerControl?.invalidate?.();
|
|
272
|
+
return release;
|
|
248
273
|
}
|
package/package.json
CHANGED
|
@@ -1,74 +1,75 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@suifei/dsh-ai-team",
|
|
3
|
-
"version": "0.4.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"description": "文渊阁 (Wenyuan Pavilion) — AI Team mode for DeepSeek Harness: concurrent projects, owned tasks, threads, inbox and an append-only team ledger",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"author": "suifei",
|
|
8
|
-
"homepage": "https://github.com/suifei/dsh-ai-team#readme",
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "https://github.com/suifei/dsh-ai-team.git"
|
|
12
|
-
},
|
|
13
|
-
"bugs": {
|
|
14
|
-
"url": "https://github.com/suifei/dsh-ai-team/issues"
|
|
15
|
-
},
|
|
16
|
-
"keywords": [
|
|
17
|
-
"deepseek-harness",
|
|
18
|
-
"dsh",
|
|
19
|
-
"dsh-plugin",
|
|
20
|
-
"ai-team",
|
|
21
|
-
"multi-agent",
|
|
22
|
-
"agent-team",
|
|
23
|
-
"task-ledger",
|
|
24
|
-
"wenyuan"
|
|
25
|
-
],
|
|
26
|
-
"publishConfig": {
|
|
27
|
-
"access": "public"
|
|
28
|
-
},
|
|
29
|
-
"icon": "./icon.svg",
|
|
30
|
-
"exports": {
|
|
31
|
-
".": "./index.js",
|
|
32
|
-
"./client": "./client.js",
|
|
33
|
-
"./package.json": "./package.json",
|
|
34
|
-
"./lib/*": "./lib/*",
|
|
35
|
-
"./locale/*.json": "./locale/*.json",
|
|
36
|
-
"./icon": "./icon.svg"
|
|
37
|
-
},
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"@deepseek-ai/schemastery": "~3.19.0",
|
|
40
|
-
"yaml": "~2.9.1"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"lib
|
|
50
|
-
"lib/vendor/skillopt/
|
|
51
|
-
"lib/vendor/skillopt/skillopt_sleep/**/*.
|
|
52
|
-
"lib/vendor/skillopt/
|
|
53
|
-
"lib/vendor/skillopt/
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@suifei/dsh-ai-team",
|
|
3
|
+
"version": "0.4.151",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "文渊阁 (Wenyuan Pavilion) — AI Team mode for DeepSeek Harness: concurrent projects, owned tasks, threads, inbox and an append-only team ledger",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "suifei",
|
|
8
|
+
"homepage": "https://github.com/suifei/dsh-ai-team#readme",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/suifei/dsh-ai-team.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/suifei/dsh-ai-team/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"deepseek-harness",
|
|
18
|
+
"dsh",
|
|
19
|
+
"dsh-plugin",
|
|
20
|
+
"ai-team",
|
|
21
|
+
"multi-agent",
|
|
22
|
+
"agent-team",
|
|
23
|
+
"task-ledger",
|
|
24
|
+
"wenyuan"
|
|
25
|
+
],
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"icon": "./icon.svg",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": "./index.js",
|
|
32
|
+
"./client": "./client.js",
|
|
33
|
+
"./package.json": "./package.json",
|
|
34
|
+
"./lib/*": "./lib/*",
|
|
35
|
+
"./locale/*.json": "./locale/*.json",
|
|
36
|
+
"./icon": "./icon.svg"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@deepseek-ai/schemastery": "~3.19.0",
|
|
40
|
+
"yaml": "~2.9.1",
|
|
41
|
+
"yauzl": "3.4.0"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"index.js",
|
|
45
|
+
"client.js",
|
|
46
|
+
"cordis.patch.yml",
|
|
47
|
+
"icon.svg",
|
|
48
|
+
"locale/*.json",
|
|
49
|
+
"lib/**/*.js",
|
|
50
|
+
"lib/vendor/skillopt/scripts/*.py",
|
|
51
|
+
"lib/vendor/skillopt/skillopt_sleep/**/*.py",
|
|
52
|
+
"lib/vendor/skillopt/skillopt_sleep/**/*.mjs",
|
|
53
|
+
"lib/vendor/skillopt/requirements.txt",
|
|
54
|
+
"lib/vendor/skillopt/LICENSE",
|
|
55
|
+
"skills/**/*",
|
|
56
|
+
"talents/**/*",
|
|
57
|
+
"teams/**/*",
|
|
58
|
+
"README.md",
|
|
59
|
+
"CHANGELOG.md",
|
|
60
|
+
"LICENSE"
|
|
61
|
+
],
|
|
62
|
+
"scripts": {
|
|
63
|
+
"test": "node --test"
|
|
64
|
+
},
|
|
65
|
+
"dsh": {
|
|
66
|
+
"bundle": {
|
|
67
|
+
"patch": "./cordis.patch.yml"
|
|
68
|
+
},
|
|
69
|
+
"client": {
|
|
70
|
+
"platform": "web",
|
|
71
|
+
"immediately": true,
|
|
72
|
+
"inject": []
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|