@suifei/dsh-ai-team 0.4.85 → 0.4.86

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/index.js CHANGED
@@ -27,7 +27,7 @@ import { memberIdentity } from './lib/domain/member-profile.js';
27
27
  import { loadSkillContext } from './lib/runtime/skill-loader.js';
28
28
  import { formatSkillCatalog } from './lib/runtime/skill-catalog.js';
29
29
  import { isSkillExcluded } from './lib/runtime/skill-policy.js';
30
- import { installFileSkillProvider } from './lib/runtime/skill-provider.js';
30
+ import { installFileSkillProvider, pickProjectForCwd } from './lib/runtime/skill-provider.js';
31
31
  import { apply as applySkillOpt } from './lib/vendor/skillopt/src/index.js';
32
32
  import { createAdoptGate, wrapToolsWithAdoptGate } from './lib/skillopt/adopt-gate.js';
33
33
  import { wrapToolsWithSkilloptAccess } from './lib/skillopt/tool-access.js';
@@ -747,6 +747,16 @@ export function apply(ctx, config = {}) {
747
747
  // runtime.dir(账本目录)兜底,曾把成员会话 cwd 钉进插件数据目录。
748
748
  // 技能里的 {{GOAL}}:项目目标来自账本 projects[id].goal;没填就明说,不要让成员
749
749
  // 对着一行空白猜(这也是 {{GOAL}} 之前"原样出现"的替代品)。
750
+ // cwd → 项目:技能 provider 的 get() 只拿得到 cwd,用它反查所属项目,
751
+ // 才能把 `{{GOAL}}` 渲染成那个项目的目标。
752
+ const projectForCwd = (cwd) => {
753
+ const projects = [];
754
+ for (const runtime of booted?.runtimes?.values() ?? []) {
755
+ const project = runtime?.service?.state?.projects?.[runtime.id];
756
+ if (project !== undefined) projects.push(project);
757
+ }
758
+ return pickProjectForCwd(projects, cwd);
759
+ };
750
760
  const goalForProject = (projectRuntime) => {
751
761
  const goal = projectRuntime?.service?.state?.projects?.[projectRuntime?.id]?.goal;
752
762
  const text = typeof goal === 'string' ? goal.trim() : '';
@@ -1302,6 +1312,17 @@ export function apply(ctx, config = {}) {
1302
1312
  dshHome: dshHome(),
1303
1313
  projectCwd: process.cwd(),
1304
1314
  bundledDir: fileURLToPath(new URL('./', import.meta.url)),
1315
+ // 成员用 `skill` 工具主动加载技能时,内容按文件原样返回——`{{GOAL}}`
1316
+ // 若不在这里渲染,成员看到的就是字面量。cwd 由 list() 随候选带下来,
1317
+ // 这里反查它属于哪个项目,再取该项目账本里的目标。
1318
+ resolveVars: ({ cwd }) => {
1319
+ const project = projectForCwd(cwd);
1320
+ return {
1321
+ GOAL: project?.goal || '(本项目尚未填写目标:请先在项目简报里补充)',
1322
+ PROJECT: project?.name ?? '',
1323
+ WORKSPACE: typeof cwd === 'string' ? cwd : '',
1324
+ };
1325
+ },
1305
1326
  }) ?? (() => {});
1306
1327
  } catch (error) {
1307
1328
  diag.append({ ev: 'skill.provider.fail', message: error?.message ?? String(error) });
@@ -1,206 +1,248 @@
1
- /**
2
- * Filesystem skill provider for DSH profiles that do not mount the desktop
3
- * marketplace's user-skill scanner. It exposes `<dshHome>/skills` and project
4
- * `.dsh/skills` / `.agents/skills` to the normal `skills` service, so members can
5
- * load installed skills through their own `skill` tool.
6
- *
7
- * Discovery parity with @deepseek-ai/dsh-skill-filesystem (README L36-56):
8
- * directory bundles `<name>/SKILL.md` and flat `<name>.md` files, required
9
- * kebab-case `name` + `description`, loose-boolean `disable-model-invocation`
10
- * / `user-invocable` keys, and the official rank order (project-dsh 100,
11
- * project-agents 200, user-dsh 400, bundled 600; lower rank wins a name).
12
- */
13
-
14
- import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs';
15
- import { join } from 'node:path';
16
- import { isSkillExcluded } from './skill-policy.js';
17
- import { reportFail } from '../diaglog.js';
18
-
19
- const MAX_BODY_BYTES = 512 * 1024;
20
-
21
- /** Official per-source ranks; a lower rank beats a higher one on name clash. */
22
- const SOURCE_RANK = Object.freeze({
23
- 'project-dsh': 100,
24
- 'project-agents': 200,
25
- 'user-dsh': 400,
26
- bundled: 600,
27
- });
28
-
29
- function parseFrontmatter(text) {
30
- if (!text.startsWith('---')) return {};
31
- const end = text.indexOf('\n---', 3);
32
- if (end < 0) return {};
33
- // CRLF 必须在这里断干净:`\r` 在 JS 里是行终止符,`.$` 无法越过它,
34
- // 带尾 `\r` 的最后一行(常见于 Windows 编辑器)会整行失配——
35
- // description 恰好位于末尾时,整个技能被当成「缺少 description」丢弃。
36
- const lines = text.slice(3, end).split(/\r\n|\r|\n/);
37
- const fields = {};
38
- let key = null;
39
- for (const line of lines) {
40
- const match = /^([A-Za-z][\w-]*):\s*(.*)$/.exec(line);
41
- if (match) {
42
- key = match[1];
43
- fields[key] = match[2].trim();
44
- continue;
45
- }
46
- if (key !== null && /^\s+/.test(line)) {
47
- fields[key] = `${fields[key] ? fields[key] + ' ' : ''}${line.trim()}`;
48
- }
49
- }
50
- return fields;
51
- }
52
-
53
- function unquote(value) {
54
- const text = String(value ?? '').trim();
55
- return text.length >= 2 && ((text.startsWith('"') && text.endsWith('"')) || (text.startsWith("'") && text.endsWith("'")))
56
- ? text.slice(1, -1)
57
- : text;
58
- }
59
-
60
- /**
61
- * Official loose boolean syntax (skill-filesystem README L38): YAML booleans
62
- * plus case-insensitive true/false, yes/no, on/off, 1/0. `null` marks a
63
- * rejected spelling, which drops the whole skill instead of silently allowing
64
- * an interface.
65
- */
66
- function parseLooseBoolean(value) {
67
- if (typeof value === 'boolean') return value;
68
- const text = String(value ?? '').trim().toLowerCase();
69
- if (['true', 'yes', 'on', '1'].includes(text)) return true;
70
- if (['false', 'no', 'off', '0'].includes(text)) return false;
71
- return null;
72
- }
73
-
74
- /** Resolve one invocation flag; returns null when the skill must be dropped. */
75
- function invocationFlag(fields, key, inverted) {
76
- const raw = fields[key];
77
- if (raw === undefined) return true;
78
- const parsed = parseLooseBoolean(raw);
79
- if (parsed === null) return null;
80
- return inverted ? !parsed : parsed;
81
- }
82
-
83
- function scanCandidate(file, fallbackName, source) {
84
- if (!existsSync(file)) return null;
85
- let text;
86
- try {
87
- if (statSync(file).size > MAX_BODY_BYTES) return null;
88
- text = readFileSync(file, 'utf8');
89
- } catch {
90
- return null;
91
- }
92
- const fields = parseFrontmatter(text);
93
- const name = unquote(fields.name) || fallbackName;
94
- // Must match the host registry's SKILL_NAME exactly (`^[a-z0-9]+(?:-[a-z0-9]+)*$`):
95
- // a name we accept but the registry rejects makes `skills.snapshot` throw
96
- // "skill provider returned invalid skill name", which aborts every agent step.
97
- if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(name)) return null;
98
- if (isSkillExcluded(name)) return null;
99
- const description = unquote(fields.description);
100
- // Official semantics: `description` is required; a skill without one is
101
- // dropped with a warning rather than synthesized into the catalog.
102
- if (description === '') {
103
- reportFail('skill.dropped.fail', { skill: name, file, reason: 'description-required' }, `[ai-team] skill "${name}" dropped: frontmatter description is required`);
104
- return null;
105
- }
106
- const modelInvocable = invocationFlag(fields, 'disable-model-invocation', true);
107
- const userInvocable = invocationFlag(fields, 'user-invocable', false);
108
- if (modelInvocable === null || userInvocable === null) {
109
- reportFail('skill.dropped.fail', { skill: name, file, reason: 'invocation-not-boolean' }, `[ai-team] skill "${name}" dropped: invocation flag is not a boolean`);
110
- return null;
111
- }
112
- return {
113
- name,
114
- description,
115
- whenToUse: unquote(fields.whenToUse) || unquote(fields['when-to-use']) || undefined,
116
- invocation: { modelInvocable, userInvocable },
117
- source,
118
- provider: 'ai-team-files',
119
- path: file,
120
- locator: file,
121
- rank: SOURCE_RANK[source] ?? 500,
122
- };
123
- }
124
-
125
- function scanRoot(root, source) {
126
- const candidates = [];
127
- if (!existsSync(root)) return candidates;
128
- let entries;
129
- try {
130
- entries = readdirSync(root, { withFileTypes: true });
131
- } catch {
132
- return candidates;
133
- }
134
- for (const entry of entries) {
135
- if (entry.name.startsWith('.')) continue;
136
- if (entry.isDirectory()) {
137
- const found = scanCandidate(join(root, entry.name, 'SKILL.md'), entry.name, source);
138
- if (found !== null) candidates.push(found);
139
- continue;
140
- }
141
- if (entry.isFile() && entry.name.endsWith('.md')) {
142
- const found = scanCandidate(join(root, entry.name), entry.name.replace(/\.md$/, ''), source);
143
- if (found !== null) candidates.push(found);
144
- }
145
- }
146
- return candidates;
147
- }
148
-
149
- export function createFileSkillProvider({ dshHome, projectCwd, bundledDir } = {}) {
150
- // Bundled last: the official rank order puts disk roots above the packaged
151
- // copy, so a user's own edit of a same-named skill wins (README L48-56).
152
- const roots = [];
153
- if (projectCwd) {
154
- roots.push([join(projectCwd, '.dsh', 'skills'), 'project-dsh']);
155
- roots.push([join(projectCwd, '.agents', 'skills'), 'project-agents']);
156
- }
157
- if (dshHome) roots.push([join(dshHome, 'skills'), 'user-dsh']);
158
- if (bundledDir) roots.push([join(bundledDir, 'skills'), 'bundled']);
159
- return {
160
- name: 'ai-team-files',
161
- async list(options = {}) {
162
- const extra = options.cwd && options.cwd !== projectCwd
163
- ? [
164
- [join(options.cwd, '.dsh', 'skills'), 'project-dsh'],
165
- [join(options.cwd, '.agents', 'skills'), 'project-agents'],
166
- ]
167
- : [];
168
- const all = [];
169
- for (const [root, source] of [...roots, ...extra]) {
170
- all.push(...scanRoot(root, source));
171
- }
172
- // Same-name clash: the lowest rank wins, mirroring the registry's
173
- // rank → provider-order → local-order adjudication.
174
- const byName = new Map();
175
- for (const candidate of all.sort((left, right) => left.rank - right.rank)) {
176
- if (!byName.has(candidate.name)) byName.set(candidate.name, candidate);
177
- }
178
- return [...byName.values()].sort((left, right) => left.name.localeCompare(right.name));
179
- },
180
- async get(candidate) {
181
- const file = candidate?.locator;
182
- if (typeof file !== 'string' || !existsSync(file)) return undefined;
183
- // 读取失败不能把 rejection 冒到 skill 工具:宿主在 agent/pre-step 里
184
- // await skills.snapshot,一次 EACCES/EBUSY 会打断该 agent 的整个回合。
185
- try {
186
- if (statSync(file).size > MAX_BODY_BYTES) return undefined;
187
- return { ...candidate, content: readFileSync(file, 'utf8') };
188
- } catch {
189
- return undefined;
190
- }
191
- },
192
- };
193
- }
194
-
195
- export function installFileSkillProvider(skills, options) {
196
- if (!skills || typeof skills.registerProvider !== 'function') return () => {};
197
- const provider = createFileSkillProvider(options);
198
- // SDK 契约(dsh-skill.md):`registerProvider` 同步注册、**返回 disposer**,
199
- // 没有 invalidate 这一档。旧实现按「可能返回 { dispose, invalidate }」处理,
200
- // invalidate 分支永远不可达,属于死代码——这里只保留真实的两种返回形态。
201
- const control = skills.registerProvider(() => provider);
202
- const dispose = typeof control === 'function' ? control : control?.dispose;
203
- return () => {
204
- try { dispose?.(); } catch { /* already disposed */ }
205
- };
206
- }
1
+ /**
2
+ * Filesystem skill provider for DSH profiles that do not mount the desktop
3
+ * marketplace's user-skill scanner. It exposes `<dshHome>/skills` and project
4
+ * `.dsh/skills` / `.agents/skills` to the normal `skills` service, so members can
5
+ * load installed skills through their own `skill` tool.
6
+ *
7
+ * Discovery parity with @deepseek-ai/dsh-skill-filesystem (README L36-56):
8
+ * directory bundles `<name>/SKILL.md` and flat `<name>.md` files, required
9
+ * kebab-case `name` + `description`, loose-boolean `disable-model-invocation`
10
+ * / `user-invocable` keys, and the official rank order (project-dsh 100,
11
+ * project-agents 200, user-dsh 400, bundled 600; lower rank wins a name).
12
+ */
13
+
14
+ import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs';
15
+ import { join } from 'node:path';
16
+ import { isSkillExcluded } from './skill-policy.js';
17
+ import { renderSkillVars } from './skill-loader.js';
18
+ import { reportFail } from '../diaglog.js';
19
+
20
+ /**
21
+ * 从项目列表里挑出 cwd 所属的那个项目(用于把 `{{GOAL}}` 等变量渲染成真实值)。
22
+ *
23
+ * 技能加载器按文件原样返回内容,`get()` 不知道自己属于哪个项目;`list()` 知道 cwd,
24
+ * 于是把它随候选一起带下去。这里只做「cwd → 项目」的匹配:先精确(忽略大小写与
25
+ * 分隔符差异),再按前缀(成员在项目子目录里工作时也要命中),最后当只有一个项目时
26
+ * 直接用它。
27
+ *
28
+ * @param {Array<{id?: string, name?: string, goal?: string, workspacePath?: string}>} projects
29
+ * @param {string} cwd
30
+ * @returns {{id: string, name: string, goal: string}|undefined}
31
+ */
32
+ export function pickProjectForCwd(projects, cwd) {
33
+ const list = (Array.isArray(projects) ? projects : []).filter((project) => project !== null && typeof project === 'object');
34
+ if (list.length === 0) return undefined;
35
+ const normalize = (value) => String(value ?? '').trim().replace(/\\/g, '/').replace(/\/+$/, '').toLowerCase();
36
+ const target = normalize(cwd);
37
+ const shape = (project) => ({
38
+ id: typeof project.id === 'string' ? project.id : '',
39
+ name: typeof project.name === 'string' ? project.name : '',
40
+ goal: typeof project.goal === 'string' ? project.goal.trim() : '',
41
+ });
42
+ if (target === '') return list.length === 1 ? shape(list[0]) : undefined;
43
+ const withWorkspace = list.filter((project) => normalize(project.workspacePath) !== '');
44
+ const exact = withWorkspace.find((project) => normalize(project.workspacePath) === target);
45
+ if (exact !== undefined) return shape(exact);
46
+ const prefix = withWorkspace
47
+ .filter((project) => target.startsWith(normalize(project.workspacePath) + '/'))
48
+ .sort((left, right) => normalize(right.workspacePath).length - normalize(left.workspacePath).length);
49
+ if (prefix.length > 0) return shape(prefix[0]);
50
+ return list.length === 1 ? shape(list[0]) : undefined;
51
+ }
52
+
53
+ const MAX_BODY_BYTES = 512 * 1024;
54
+
55
+ /** Official per-source ranks; a lower rank beats a higher one on name clash. */
56
+ const SOURCE_RANK = Object.freeze({
57
+ 'project-dsh': 100,
58
+ 'project-agents': 200,
59
+ 'user-dsh': 400,
60
+ bundled: 600,
61
+ });
62
+
63
+ function parseFrontmatter(text) {
64
+ if (!text.startsWith('---')) return {};
65
+ const end = text.indexOf('\n---', 3);
66
+ if (end < 0) return {};
67
+ // CRLF 必须在这里断干净:`\r` 在 JS 里是行终止符,`.$` 无法越过它,
68
+ // 带尾 `\r` 的最后一行(常见于 Windows 编辑器)会整行失配——
69
+ // description 恰好位于末尾时,整个技能被当成「缺少 description」丢弃。
70
+ const lines = text.slice(3, end).split(/\r\n|\r|\n/);
71
+ const fields = {};
72
+ let key = null;
73
+ for (const line of lines) {
74
+ const match = /^([A-Za-z][\w-]*):\s*(.*)$/.exec(line);
75
+ if (match) {
76
+ key = match[1];
77
+ fields[key] = match[2].trim();
78
+ continue;
79
+ }
80
+ if (key !== null && /^\s+/.test(line)) {
81
+ fields[key] = `${fields[key] ? fields[key] + ' ' : ''}${line.trim()}`;
82
+ }
83
+ }
84
+ return fields;
85
+ }
86
+
87
+ function unquote(value) {
88
+ const text = String(value ?? '').trim();
89
+ return text.length >= 2 && ((text.startsWith('"') && text.endsWith('"')) || (text.startsWith("'") && text.endsWith("'")))
90
+ ? text.slice(1, -1)
91
+ : text;
92
+ }
93
+
94
+ /**
95
+ * Official loose boolean syntax (skill-filesystem README L38): YAML booleans
96
+ * plus case-insensitive true/false, yes/no, on/off, 1/0. `null` marks a
97
+ * rejected spelling, which drops the whole skill instead of silently allowing
98
+ * an interface.
99
+ */
100
+ function parseLooseBoolean(value) {
101
+ if (typeof value === 'boolean') return value;
102
+ const text = String(value ?? '').trim().toLowerCase();
103
+ if (['true', 'yes', 'on', '1'].includes(text)) return true;
104
+ if (['false', 'no', 'off', '0'].includes(text)) return false;
105
+ return null;
106
+ }
107
+
108
+ /** Resolve one invocation flag; returns null when the skill must be dropped. */
109
+ function invocationFlag(fields, key, inverted) {
110
+ const raw = fields[key];
111
+ if (raw === undefined) return true;
112
+ const parsed = parseLooseBoolean(raw);
113
+ if (parsed === null) return null;
114
+ return inverted ? !parsed : parsed;
115
+ }
116
+
117
+ function scanCandidate(file, fallbackName, source) {
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
+ }
126
+ const fields = parseFrontmatter(text);
127
+ const name = unquote(fields.name) || fallbackName;
128
+ // Must match the host registry's SKILL_NAME exactly (`^[a-z0-9]+(?:-[a-z0-9]+)*$`):
129
+ // a name we accept but the registry rejects makes `skills.snapshot` throw
130
+ // "skill provider returned invalid skill name", which aborts every agent step.
131
+ if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(name)) return null;
132
+ if (isSkillExcluded(name)) return null;
133
+ const description = unquote(fields.description);
134
+ // Official semantics: `description` is required; a skill without one is
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
+ }
140
+ const modelInvocable = invocationFlag(fields, 'disable-model-invocation', true);
141
+ 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
+ }
146
+ return {
147
+ name,
148
+ description,
149
+ whenToUse: unquote(fields.whenToUse) || unquote(fields['when-to-use']) || undefined,
150
+ invocation: { modelInvocable, userInvocable },
151
+ source,
152
+ provider: 'ai-team-files',
153
+ path: file,
154
+ locator: file,
155
+ rank: SOURCE_RANK[source] ?? 500,
156
+ };
157
+ }
158
+
159
+ function scanRoot(root, source) {
160
+ const candidates = [];
161
+ if (!existsSync(root)) return candidates;
162
+ let entries;
163
+ try {
164
+ entries = readdirSync(root, { withFileTypes: true });
165
+ } catch {
166
+ return candidates;
167
+ }
168
+ for (const entry of entries) {
169
+ if (entry.name.startsWith('.')) continue;
170
+ if (entry.isDirectory()) {
171
+ const found = scanCandidate(join(root, entry.name, 'SKILL.md'), entry.name, source);
172
+ if (found !== null) candidates.push(found);
173
+ continue;
174
+ }
175
+ if (entry.isFile() && entry.name.endsWith('.md')) {
176
+ const found = scanCandidate(join(root, entry.name), entry.name.replace(/\.md$/, ''), source);
177
+ if (found !== null) candidates.push(found);
178
+ }
179
+ }
180
+ return candidates;
181
+ }
182
+
183
+ export function createFileSkillProvider({ dshHome, projectCwd, bundledDir, resolveVars } = {}) {
184
+ // Bundled last: the official rank order puts disk roots above the packaged
185
+ // copy, so a user's own edit of a same-named skill wins (README L48-56).
186
+ const roots = [];
187
+ if (projectCwd) {
188
+ roots.push([join(projectCwd, '.dsh', 'skills'), 'project-dsh']);
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']);
193
+ return {
194
+ name: 'ai-team-files',
195
+ async list(options = {}) {
196
+ const extra = options.cwd && options.cwd !== projectCwd
197
+ ? [
198
+ [join(options.cwd, '.dsh', 'skills'), 'project-dsh'],
199
+ [join(options.cwd, '.agents', 'skills'), 'project-agents'],
200
+ ]
201
+ : [];
202
+ const all = [];
203
+ const resolveCwd = typeof options.cwd === 'string' && options.cwd !== '' ? options.cwd : projectCwd;
204
+ for (const [root, source] of [...roots, ...extra]) {
205
+ for (const candidate of scanRoot(root, source)) all.push({ ...candidate, resolveCwd });
206
+ }
207
+ // Same-name clash: the lowest rank wins, mirroring the registry's
208
+ // rank → provider-order → local-order adjudication.
209
+ const byName = new Map();
210
+ for (const candidate of all.sort((left, right) => left.rank - right.rank)) {
211
+ if (!byName.has(candidate.name)) byName.set(candidate.name, candidate);
212
+ }
213
+ return [...byName.values()].sort((left, right) => left.name.localeCompare(right.name));
214
+ },
215
+ async get(candidate) {
216
+ const file = candidate?.locator;
217
+ if (typeof file !== 'string' || !existsSync(file)) return undefined;
218
+ // 读取失败不能把 rejection 冒到 skill 工具:宿主在 agent/pre-step 里
219
+ // await skills.snapshot,一次 EACCES/EBUSY 会打断该 agent 的整个回合。
220
+ try {
221
+ if (statSync(file).size > MAX_BODY_BYTES) return undefined;
222
+ const raw = readFileSync(file, 'utf8');
223
+ // 技能按文件原样提供,但 `{{GOAL}}` 这类占位符必须在返回前渲染:成员主动
224
+ // 加载技能时不该看到字面量(与激活注入走同一套变量)。
225
+ const vars = typeof resolveVars === 'function'
226
+ ? resolveVars({ cwd: candidate?.resolveCwd ?? projectCwd, candidate }) ?? {}
227
+ : {};
228
+ const content = renderSkillVars(raw, vars);
229
+ return { ...candidate, content };
230
+ } catch {
231
+ return undefined;
232
+ }
233
+ },
234
+ };
235
+ }
236
+
237
+ export function installFileSkillProvider(skills, options) {
238
+ if (!skills || typeof skills.registerProvider !== 'function') return () => {};
239
+ const provider = createFileSkillProvider(options);
240
+ // SDK 契约(dsh-skill.md):`registerProvider` 同步注册、**返回 disposer**,
241
+ // 没有 invalidate 这一档。旧实现按「可能返回 { dispose, invalidate }」处理,
242
+ // invalidate 分支永远不可达,属于死代码——这里只保留真实的两种返回形态。
243
+ const control = skills.registerProvider(() => provider);
244
+ const dispose = typeof control === 'function' ? control : control?.dispose;
245
+ return () => {
246
+ try { dispose?.(); } catch { /* already disposed */ }
247
+ };
248
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suifei/dsh-ai-team",
3
- "version": "0.4.85",
3
+ "version": "0.4.86",
4
4
  "type": "module",
5
5
  "description": "文渊阁 (Wenyuan Pavilion) — AI Team mode for DeepSeek Harness: concurrent projects, owned tasks, threads, inbox and an append-only team ledger",
6
6
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: ai-team-core
3
- description: 文渊阁 AI Team 核心工程纪律:单一实现、网页取证与代理、懒惰的高级程序员、最小依赖、日志埋点。
4
- whenToUse: 所有 Agent(PMO/主理人/执行/验收)在规划、实现、验收、排查和汇报前都应加载并遵守。
3
+ description: 只读「审查与导航」PMO 作业规程:核实子代理是否真的做到、对照目标锚点找偏离与漏项、只给下一步,输出 STATUS: CONTINUE | DONE | NEED_HUMAN。
4
+ whenToUse: 每一轮子代理输出之后做核实与导航时加载;需要确认交付是否达标、是否越界加功能、该不该转交 Human 决策时使用。
5
5
  ---
6
6
 
7
7
  # AI Team 核心工程纪律