@suifei/dsh-ai-team 0.4.150 → 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 +6 -0
- package/README.md +5 -4
- package/client.js +78 -84
- package/index.js +57 -12
- package/lib/host/skill-import.js +204 -0
- package/lib/runtime/skill-catalog.js +56 -56
- package/lib/runtime/skill-provider.js +48 -24
- package/package.json +75 -74
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.151 - 2026-12-02
|
|
4
|
+
|
|
5
|
+
- 统一新建人才的技能导入入口。单个 Markdown、完整技能文件夹、ZIP 与 `.skill` 都从「导入技能」进入。
|
|
6
|
+
- 文渊阁直接校验、安装并回读完整技能包,可安装到个人目录或成员实际工作区。项目导入以文渊阁工作目录为准。感谢 @godfay-g 提出技能包导入建议(#109)。
|
|
7
|
+
- 完整包在 DSH 扫描范围外暂存,准备就绪后一次发布。Windows 临时占用导致重命名失败时自动重试。
|
|
8
|
+
|
|
3
9
|
## 0.4.150 - 2026-12-02
|
|
4
10
|
|
|
5
11
|
- 成员资料和新建人才可选择 DSH 已安装的技能。在同一 profile 启用 Skill Station 后,桌面端和本机 Web 可导入技能目录、ZIP 或 `.skill`,并把安装成功的技能加入当前表单。DSH 保留整包及相对资源。感谢 @godfay-g 的建议(#109)。
|
package/README.md
CHANGED
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
|
|
38
38
|
## 最近更新
|
|
39
39
|
|
|
40
|
-
-
|
|
40
|
+
- **文渊阁直接导入技能包**(0.4.151)。「导入技能」可选 Markdown、技能文件夹、ZIP 和 `.skill`。只需安装文渊阁,即可安装完整包并在 DSH 确认可加载后加入技能列表。感谢 [@godfay-g](https://github.com/godfay-g),[#109](https://github.com/suifei/dsh-ai-team/issues/109)。
|
|
41
|
+
- **给成员装技能包**(0.4.150)。成员资料和新建人才增加已安装技能选择和完整技能包导入。感谢 [@godfay-g](https://github.com/godfay-g),[#109](https://github.com/suifei/dsh-ai-team/issues/109)。
|
|
41
42
|
- **会话标题栏看板入口**(0.4.149)。文渊阁管理的 PMO 和成员会话会显示文渊阁图标,点击直达所属项目的看板。运行时的轻微脉冲遵循系统的减少动态效果设置。
|
|
42
43
|
- **安装指引与 503 提示**(0.4.148)。快速开始按入口使用内置 `desktop` 或 `web`。连接服务不可用时,工作台提示核对插件安装的 profile 和启动入口。感谢 [@Arnoldnuo](https://github.com/Arnoldnuo) 的反馈([#102](https://github.com/suifei/dsh-ai-team/issues/102))。
|
|
43
44
|
- **蓝图试跑与项目总览**(0.4.147)。新建项目可按星门项目的团队架构实践,先用两个岗位、一份真实样本跑通交付。开启 PMO 自动后,插件按实测证据派发、确认草稿和扩编复跑。工作台显示当前阶段和下一步,项目总览可查看验收、AI 协作与原始证据。
|
|
@@ -115,8 +116,8 @@ const svg = HashAvatar.svg('墨渊', { gender: 'male', age: 'middle', race: 'asi
|
|
|
115
116
|
- 团队 `teams/<团队>/team.yml`:只引用人才(可覆盖名字、岗位、性格,追加技能),`skills/` 放这个团队的三份岗位规程(`ai-team-core` / `ai-team-qa` / `ai-team-executor`),`procedures` 可换成自己的规程。内置默认团队见 [`teams/default/`](teams/default/)。还预置了**逆向工程队** [`teams/reverse/`](teams/reverse/):静态分析、动态调试、OLLVM 去混淆、移动端逆向、算法复刻与行为对账(`teamPreset: reverse` 启用)。此外预置了文档(`docs`)、视频(`video`)、游戏(`game`)、自媒体写作(`content`)、深度研究(`research`)、科学研究(`science`)、中小学教育软件(`education`)等团队,共 44 位人才可在人才市场挑选、组合或自建。
|
|
116
117
|
- 「人员 → 添加成员」先打开人才市场:按分类、关键词挑一位,点「招聘」预填表单,改名、换模型后创建;也可以切到「自定义」从零填写。
|
|
117
118
|
- 自建:人才放 `~/.dsh/ai-team/catalog/user/talents/<人才>/`,团队放 `~/.dsh/ai-team/catalog/user/teams/<团队>/`,同名覆盖内置;插件设置 `teamPreset` 选新项目用哪个团队。
|
|
118
|
-
- 在「添加成员 →
|
|
119
|
-
-
|
|
119
|
+
- 在「添加成员 → 新建人才」填写名号、岗位、职责、性格。点「导入技能」可选择 DSH 已安装的技能,或选择文件导入 `.md`、ZIP、`.skill`,也可以选择整个技能文件夹。人才还能从现有角色复制技能或自写一份。自带的 Markdown 保存在人才目录,DSH 技能以名称引用。
|
|
120
|
+
- 文渊阁直接安装并校验完整包。新建人才的完整包写入 DSH 个人技能目录。成员资料里的「添加 DSH 技能」写入成员实际工作区的 `.dsh/skills/`,由文渊阁自动分配。DSH 保留包内的 `references/` 等相对资源。同名技能可以直接从已安装列表选用。
|
|
120
121
|
- 成员资料的「存为人才」可保存成员当前的岗位、职责、性格、模型和技能。DSH 技能保留引用,使用时由目标工作区解析。自带的 Markdown 技能随人才保存。新建或存为人才时,重名自动加序号。
|
|
121
122
|
- **组队、建项目选团队**:「新建项目」里选团队(内置或自建),按它种成员、负责人当主理人;「组一个新团队」从人才里挑人(同一人才可招多位)、指定负责人即可保存。插件设置 `teamPreset` 只是不选时的默认值。
|
|
122
123
|
- **改内置人才、进化技能**:内置人才点「复制为可编辑」得到同 id 的副本(随时「恢复内置」);成员资料里技能旁的「进化」会让该成员用 SkillOpt 优化那份技能——内置的先自动复制,插件里的原文件不动。
|
|
@@ -360,7 +361,7 @@ round-19 DeepSeek + Zhipu 双 provider
|
|
|
360
361
|
|
|
361
362
|
| 贡献者 | 贡献 | 带来的进展 |
|
|
362
363
|
|---|---|---|
|
|
363
|
-
| [@godfay-g](https://github.com/godfay-g) | 技能目录和 ZIP 的导入建议 [#109](https://github.com/suifei/dsh-ai-team/issues/109) |
|
|
364
|
+
| [@godfay-g](https://github.com/godfay-g) | 技能目录和 ZIP 的导入建议 [#109](https://github.com/suifei/dsh-ai-team/issues/109) | 成员与自定义人才可在文渊阁选择已安装的技能或导入完整技能包。0.4.151 统一新建人才的导入入口,并由文渊阁直接安装整包 |
|
|
364
365
|
| [@qq958691165](https://github.com/qq958691165) | 归档项目的成员反馈、团队管理建议 [#103](https://github.com/suifei/dsh-ai-team/issues/103) | 人员池排除归档项目,侧栏集中管理项目成员与团队预设 |
|
|
365
366
|
| [@Arnoldnuo](https://github.com/Arnoldnuo) | 桌面端启动 503 反馈 [#102](https://github.com/suifei/dsh-ai-team/issues/102) | 工作台提供分情况的 503 提示,快速开始说明内置 `desktop` 与 `web` 的安装和启动方式,连接错误提示引导核对 profile |
|
|
366
367
|
| [@Lamooner](https://github.com/Lamooner) | PMO 决策反馈与建议 [#99](https://github.com/suifei/dsh-ai-team/issues/99) | 避免选中「不推荐」项,移除编号偏向并补充括注编号回归 |
|
package/client.js
CHANGED
|
@@ -339,14 +339,14 @@ window.__ModuleLoader__.load({
|
|
|
339
339
|
tcHint: '填好职责与性格,按需装几份技能,存成可复用的人才。',
|
|
340
340
|
tcName: '名号', tcRole: '岗位', tcDuty: '职责', tcCategory: '分类', tcTags: '标签', tcTagsHint: '逗号分隔', tcPersonality: '性格', tcPersonalityHint: '它怎么做事、什么风格',
|
|
341
341
|
tcSkills: '技能', tcEmpty: '还没装技能(可选)', tcAddExisting: '从已有装', tcWriteOwn: '自写一份', tcImport: '导入 .md', tcPick: '选一个已有技能…', tcAdd: '加入', tcRemove: '移除',
|
|
342
|
+
tcImportSkill: '导入技能', tcImportSkillFiles: '导入 .md / ZIP / .skill', tcImportSkillType: '请选择 .md、ZIP 或 .skill 文件。',
|
|
342
343
|
tcSkillName: '技能名(英文/数字/-)', tcSkillBody: '技能正文(SKILL.md)', tcSkillDup: '已经装了同名技能', tcSave: '存为我的人才', tcSaving: '保存中…',
|
|
343
344
|
tcHostAdd: '添加 DSH 技能', tcHostPick: '选择已安装的技能', tcHostEmpty: '没有可添加的已安装技能', tcHostUnavailable: 'DSH 技能目录暂不可用,请确认宿主已加载技能服务后重试。',
|
|
344
345
|
tcHostFolder: '导入文件夹', tcHostArchive: '导入 ZIP / .skill', tcHostUserRoot: '完整技能包将安装到 DSH 个人技能目录。', tcHostProjectRoot: '完整技能包将安装到成员工作区的 DSH 技能目录。',
|
|
345
|
-
|
|
346
|
-
tcHostLocalOnly: '请在 DSH 桌面版或本机 HTTP Web 页面打开文渊阁,即可导入完整技能包。', tcHostNoRoot: '请先在 DSH 打开成员的工作区,再导入工作区技能。',
|
|
346
|
+
tcHostNoRoot: '请先在文渊阁设置成员或项目的工作目录。',
|
|
347
347
|
tcHostFolderType: '请选择包含 SKILL.md 的技能文件夹。', tcHostArchiveType: '请选择 .zip 或 .skill 文件。', tcHostPackLarge: '技能包超过上传容量上限,请精简资源后重试。',
|
|
348
|
-
tcHostImporting: '正在安装技能包…',
|
|
349
|
-
tcHostConflict: '
|
|
348
|
+
tcHostImporting: '正在安装技能包…', tcHostImportFailed: '技能包导入失败({error})',
|
|
349
|
+
tcHostConflict: '技能 {name} 已存在或正在导入。可以从已安装技能中选择。', tcHostUnseen: 'DSH 未在目标目录识别到 {name},请检查同名技能后重试。',
|
|
350
350
|
memberSaveAsTalent: '存为人才', tcFromMember: '从成员「{name}」存出:沿用它此刻的岗位、职责、性格与技能,可先修改再保存。', tcModelKept: '沿用模型:{model}', tcMissing: '这些技能找不到正文,没有带上:{skills}', tcDraftFailed: '读取成员草稿失败:{error}',
|
|
351
351
|
teamManagement: '团队管理', teamManageGoal: '管理当前项目成员,或为新项目准备团队预设。', teamActiveProject: '当前项目成员', teamPickProject: '切换活动项目以管理成员', teamNoActiveProject: '请选择一个未归档的项目。', teamPresets: '团队预设', teamPresetHint: '预设用于新建项目,不会更改已创建的项目。', teamNoPresets: '没有可用的团队预设。',
|
|
352
352
|
projectTeam: '团队', teamCompose: '组一个新团队', teamComposeTitle: '组队', teamComposeHint: '从人才里挑人组队:同一人才可以招多位,给其中一位定为负责人(新项目的主理人)。', teamName: '团队名', teamDesc: '说明', teamMembers: '成员', teamPick: '从人才里挑人', teamAdd: '加入', teamLead: '负责人', teamEmptyPick: '还没挑人', teamSave: '保存团队', teamBack: '返回', teamDelete: '删除这个团队', teamDeleteConfirm: '删除自建团队「{name}」?团队文件会被删除,已用它建的项目和其中成员不受影响。', teamLoadFailed: '团队列表读取失败:{error}',
|
|
@@ -849,14 +849,14 @@ window.__ModuleLoader__.load({
|
|
|
849
849
|
tcHint: 'Set the duty and personality, install a few skills, save a reusable talent.',
|
|
850
850
|
tcName: 'Name', tcRole: 'Role', tcDuty: 'Duty', tcCategory: 'Category', tcTags: 'Tags', tcTagsHint: 'comma-separated', tcPersonality: 'Personality', tcPersonalityHint: 'how it works, its style',
|
|
851
851
|
tcSkills: 'Skills', tcEmpty: 'No skills yet (optional)', tcAddExisting: 'From existing', tcWriteOwn: 'Write one', tcImport: 'Import .md', tcPick: 'Pick an existing skill…', tcAdd: 'Add', tcRemove: 'Remove',
|
|
852
|
+
tcImportSkill: 'Import skill', tcImportSkillFiles: 'Import .md / ZIP / .skill', tcImportSkillType: 'Choose a .md, ZIP, or .skill file.',
|
|
852
853
|
tcSkillName: 'Skill name (a-z, 0-9, -)', tcSkillBody: 'Skill body (SKILL.md)', tcSkillDup: 'That skill name is already staged', tcSave: 'Save as my talent', tcSaving: 'Saving…',
|
|
853
854
|
tcHostAdd: 'Add DSH skill', tcHostPick: 'Choose an installed skill', tcHostEmpty: 'No installed skills to add', tcHostUnavailable: 'The DSH skill catalog is unavailable. Make sure the host skill service is running, then try again.',
|
|
854
855
|
tcHostFolder: 'Import folder', tcHostArchive: 'Import ZIP / .skill', tcHostUserRoot: 'Skill packages will be installed in your DSH user skill directory.', tcHostProjectRoot: 'Skill packages will be installed in the member workspace’s DSH skill directory.',
|
|
855
|
-
|
|
856
|
-
tcHostLocalOnly: 'Open Wenyuan in DSH Desktop or the local HTTP Web app to import a skill package.', tcHostNoRoot: 'Open the member’s workspace in DSH before importing a workspace skill.',
|
|
856
|
+
tcHostNoRoot: 'Set an existing workspace for the member or project in Wenyuan.',
|
|
857
857
|
tcHostFolderType: 'Choose a skill folder that contains SKILL.md.', tcHostArchiveType: 'Choose a .zip or .skill file.', tcHostPackLarge: 'This package exceeds the upload size limit. Reduce its size and try again.',
|
|
858
|
-
tcHostImporting: 'Installing skill package…',
|
|
859
|
-
tcHostConflict: '
|
|
858
|
+
tcHostImporting: 'Installing skill package…', tcHostImportFailed: 'Skill package import failed ({error})',
|
|
859
|
+
tcHostConflict: '{name} is already installed or being imported. Choose it from the installed skills.', tcHostUnseen: 'DSH could not resolve {name} in the selected directory. Check for a skill with the same name and try again.',
|
|
860
860
|
memberSaveAsTalent: 'Save as talent', tcFromMember: 'Saved from member “{name}”: its current role, duty, personality and skills are filled in; edit before saving.', tcModelKept: 'Keeps the model: {model}', tcMissing: 'These skills have no readable body and were left out: {skills}', tcDraftFailed: 'Could not read the member draft: {error}',
|
|
861
861
|
teamManagement: 'Team management', teamManageGoal: 'Manage the current project’s members or prepare team presets for new projects.', teamActiveProject: 'Current project members', teamPickProject: 'Switch active project to manage its members', teamNoActiveProject: 'Select a project that is not archived.', teamPresets: 'Team presets', teamPresetHint: 'Presets are used for new projects and do not change existing projects.', teamNoPresets: 'No available team presets.',
|
|
862
862
|
projectTeam: 'Team', teamCompose: 'Compose a new team', teamComposeTitle: 'Compose a team', teamComposeHint: 'Pick talents into a team: the same talent can be hired more than once; mark one as the lead (the new project owner).', teamName: 'Team name', teamDesc: 'Description', teamMembers: 'Members', teamPick: 'Pick from talents', teamAdd: 'Add', teamLead: 'Lead', teamEmptyPick: 'Nobody picked yet', teamSave: 'Save team', teamBack: 'Back', teamDelete: 'Delete this team', teamDeleteConfirm: 'Delete your team “{name}”? Its file is removed; projects already created from it and their members are unaffected.', teamLoadFailed: 'Could not load teams: {error}',
|
|
@@ -3402,18 +3402,18 @@ window.__ModuleLoader__.load({
|
|
|
3402
3402
|
h('button', { type: 'button', className: 'at-btn at-btn-small at-btn-primary', onClick: () => onHire(talent) }, withIco('userPlus', t('talentHire'), 12))))))));
|
|
3403
3403
|
}
|
|
3404
3404
|
// <host-skill-import>
|
|
3405
|
-
const SKILL_STATION_API = '/skill-station/api';
|
|
3406
3405
|
const SKILL_PACK_LIMIT = 64 * 1024 * 1024;
|
|
3407
|
-
function hostSkillCatalogPath(projectId, memberId
|
|
3406
|
+
function hostSkillCatalogPath(projectId, memberId) {
|
|
3408
3407
|
const params = new URLSearchParams();
|
|
3409
3408
|
if (projectId) params.set('project', projectId);
|
|
3410
3409
|
if (memberId) params.set('member', memberId);
|
|
3411
|
-
if (refresh) params.set('refresh', '1');
|
|
3412
3410
|
return '/ai-team/api/host-skills' + (params.size ? '?' + params : '');
|
|
3413
3411
|
}
|
|
3414
|
-
function
|
|
3415
|
-
|
|
3416
|
-
|
|
3412
|
+
function skillImportKind(file) {
|
|
3413
|
+
const name = file?.name ?? '';
|
|
3414
|
+
if (/\.(zip|skill)$/i.test(name)) return 'archive';
|
|
3415
|
+
if (/\.md$/i.test(name) || /^text\/(markdown|plain)$/.test(file?.type ?? '')) return 'markdown';
|
|
3416
|
+
return null;
|
|
3417
3417
|
}
|
|
3418
3418
|
function readSkillFileBase64(file) {
|
|
3419
3419
|
return new Promise((resolve, reject) => {
|
|
@@ -3423,13 +3423,13 @@ window.__ModuleLoader__.load({
|
|
|
3423
3423
|
reader.readAsDataURL(file);
|
|
3424
3424
|
});
|
|
3425
3425
|
}
|
|
3426
|
-
async function skillPackRequest(
|
|
3427
|
-
const payload = {
|
|
3426
|
+
async function skillPackRequest(mode, files) {
|
|
3427
|
+
const payload = {};
|
|
3428
3428
|
if (mode === 'folder') {
|
|
3429
3429
|
if (files.some((file) => !file.webkitRelativePath)) throw new Error('tcHostFolderType');
|
|
3430
3430
|
payload.files = files.map((file) => ({ path: file.webkitRelativePath, contentBase64: '' }));
|
|
3431
3431
|
} else {
|
|
3432
|
-
if (
|
|
3432
|
+
if (skillImportKind(files[0]) !== 'archive') throw new Error('tcHostArchiveType');
|
|
3433
3433
|
payload.zipBase64 = '';
|
|
3434
3434
|
}
|
|
3435
3435
|
const metadataBytes = new TextEncoder().encode(JSON.stringify(payload)).length;
|
|
@@ -3442,30 +3442,23 @@ window.__ModuleLoader__.load({
|
|
|
3442
3442
|
}
|
|
3443
3443
|
return JSON.stringify(payload);
|
|
3444
3444
|
}
|
|
3445
|
-
function hostSkillIsVisible(catalog, name, targetRoot) {
|
|
3446
|
-
const source = targetRoot.split(':', 1)[0];
|
|
3447
|
-
return catalog.skills.some((skill) => skill.name === name && skill.source === source);
|
|
3448
|
-
}
|
|
3449
3445
|
// </host-skill-import>
|
|
3450
3446
|
|
|
3451
|
-
/**
|
|
3452
|
-
function HostSkillPicker({ t, projectId, memberId, selectedNames = [], disabled, onChoose }) {
|
|
3447
|
+
/** 人才和成员共用的技能入口。宿主安装并确认 DSH 可调用后再分配。 */
|
|
3448
|
+
function HostSkillPicker({ t, projectId, memberId, selectedNames = [], disabled, onChoose, onImportMarkdown }) {
|
|
3453
3449
|
const [open, setOpen] = React.useState(false);
|
|
3454
3450
|
const [catalog, setCatalog] = React.useState(null);
|
|
3455
|
-
const [station, setStation] = React.useState(null);
|
|
3456
3451
|
const [selected, setSelected] = React.useState('');
|
|
3457
3452
|
const [busy, setBusy] = React.useState(false);
|
|
3458
3453
|
const [progress, setProgress] = React.useState('');
|
|
3459
3454
|
const [error, setError] = React.useState('');
|
|
3460
3455
|
const trigger = React.useRef(null);
|
|
3461
3456
|
const folderInput = React.useRef(null);
|
|
3462
|
-
const
|
|
3457
|
+
const fileInput = React.useRef(null);
|
|
3463
3458
|
const active = React.useRef(null);
|
|
3464
3459
|
const path = hostSkillCatalogPath(projectId, memberId);
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
const catalogPath = refresh ? hostSkillCatalogPath(projectId, memberId, true) : path;
|
|
3468
|
-
const response = await fetch(catalogPath, { signal, headers: { accept: 'application/json' }, cache: 'no-store' });
|
|
3460
|
+
async function readCatalog(signal) {
|
|
3461
|
+
const response = await fetch(path, { signal, headers: { accept: 'application/json' }, cache: 'no-store' });
|
|
3469
3462
|
const body = await response.json().catch(() => null);
|
|
3470
3463
|
if (!response.ok || !Array.isArray(body?.skills)) throw new Error('tcHostUnavailable');
|
|
3471
3464
|
return body;
|
|
@@ -3480,17 +3473,17 @@ window.__ModuleLoader__.load({
|
|
|
3480
3473
|
}).catch(() => {
|
|
3481
3474
|
if (!signal.aborted) setCatalog(false);
|
|
3482
3475
|
});
|
|
3483
|
-
if (canUpload) fetch(SKILL_STATION_API + '/roots', { signal, headers: { accept: 'application/json' } })
|
|
3484
|
-
.then(async (response) => response.ok && Array.isArray((await response.json())?.workspaces))
|
|
3485
|
-
.catch(() => false).then((ready) => { if (!signal.aborted) setStation(ready); });
|
|
3486
3476
|
return () => { controller.abort(); active.current = null; };
|
|
3487
|
-
}, [open, path
|
|
3477
|
+
}, [open, path]);
|
|
3488
3478
|
const choices = (catalog?.skills ?? []).filter((skill) => !selectedNames.includes(skill.name));
|
|
3489
3479
|
const choice = choices.find((skill) => skill.name === selected);
|
|
3490
|
-
const
|
|
3480
|
+
const canImportPack = Boolean(catalog?.targetRoot);
|
|
3481
|
+
const importHint = catalog && !canImportPack ? 'tcHostNoRoot' : '';
|
|
3482
|
+
const title = t(onImportMarkdown ? 'tcImportSkill' : 'tcHostAdd');
|
|
3483
|
+
const fileLabel = t(onImportMarkdown ? (canImportPack ? 'tcImportSkillFiles' : 'tcImport') : 'tcHostArchive');
|
|
3484
|
+
const fileAccept = [onImportMarkdown && '.md,text/markdown,text/plain', canImportPack && '.zip,.skill,application/zip'].filter(Boolean).join(',');
|
|
3491
3485
|
function show() {
|
|
3492
3486
|
setCatalog(null);
|
|
3493
|
-
setStation(null);
|
|
3494
3487
|
setSelected('');
|
|
3495
3488
|
setError('');
|
|
3496
3489
|
setOpen(true);
|
|
@@ -3508,7 +3501,7 @@ window.__ModuleLoader__.load({
|
|
|
3508
3501
|
setBusy(true);
|
|
3509
3502
|
setError('');
|
|
3510
3503
|
try {
|
|
3511
|
-
await action(signal);
|
|
3504
|
+
if (await action(signal) === false) throw new Error(t('tcSkillDup'));
|
|
3512
3505
|
if (!signal.aborted) dismiss();
|
|
3513
3506
|
} catch (err) {
|
|
3514
3507
|
const message = err?.message || String(err);
|
|
@@ -3517,51 +3510,51 @@ window.__ModuleLoader__.load({
|
|
|
3517
3510
|
if (!signal.aborted) { setBusy(false); setProgress(''); }
|
|
3518
3511
|
}
|
|
3519
3512
|
}
|
|
3520
|
-
function
|
|
3513
|
+
function importSelected(event, isFolder) {
|
|
3521
3514
|
const files = Array.from(event.target.files ?? []);
|
|
3522
3515
|
event.target.value = '';
|
|
3523
|
-
if (!files.length
|
|
3516
|
+
if (!files.length) return;
|
|
3517
|
+
const mode = isFolder ? 'folder' : skillImportKind(files[0]);
|
|
3518
|
+
if (mode === 'markdown' && onImportMarkdown) {
|
|
3519
|
+
void perform(() => onImportMarkdown(files[0]));
|
|
3520
|
+
return;
|
|
3521
|
+
}
|
|
3522
|
+
if (mode !== 'folder' && mode !== 'archive') {
|
|
3523
|
+
setError(t(onImportMarkdown ? 'tcImportSkillType' : 'tcHostArchiveType'));
|
|
3524
|
+
return;
|
|
3525
|
+
}
|
|
3526
|
+
if (!canImportPack) {
|
|
3527
|
+
setError(t(importHint || 'tcHostUnavailable'));
|
|
3528
|
+
return;
|
|
3529
|
+
}
|
|
3524
3530
|
void perform(async (signal) => {
|
|
3525
3531
|
setProgress('tcHostImporting');
|
|
3526
|
-
const body = await skillPackRequest(
|
|
3527
|
-
const response = await fetch(
|
|
3532
|
+
const body = await skillPackRequest(mode, files);
|
|
3533
|
+
const response = await fetch(path, {
|
|
3528
3534
|
method: 'POST', signal, headers: { 'content-type': 'application/json', accept: 'application/json' }, body,
|
|
3529
3535
|
});
|
|
3530
3536
|
const result = await response.json().catch(() => null);
|
|
3531
|
-
const
|
|
3532
|
-
|
|
3533
|
-
if (response.status === 404) throw new Error('tcHostStationMissing');
|
|
3537
|
+
const failure = result?.error;
|
|
3538
|
+
const name = failure?.details?.name;
|
|
3534
3539
|
if (response.status === 413) throw new Error('tcHostPackLarge');
|
|
3535
|
-
if (
|
|
3536
|
-
if (
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
}
|
|
3541
|
-
throw new Error(tf(t, 'tcHostConflict', { name: outcome.name }));
|
|
3542
|
-
}
|
|
3543
|
-
if (!response.ok || outcome?.status !== 'imported' || typeof outcome.name !== 'string' || !outcome.name) {
|
|
3544
|
-
throw new Error(tf(t, 'tcHostImportFailed', { error: outcome?.error || result?.error || 'HTTP ' + response.status }));
|
|
3540
|
+
if (failure?.code === 'E_SKILL_WORKSPACE_REQUIRED') throw new Error('tcHostNoRoot');
|
|
3541
|
+
if (failure?.code === 'E_SKILL_EXISTS' && name) {
|
|
3542
|
+
const refreshed = await readCatalog(signal).catch(() => null);
|
|
3543
|
+
if (refreshed && !signal.aborted) setCatalog(refreshed);
|
|
3544
|
+
throw new Error(tf(t, 'tcHostConflict', { name }));
|
|
3545
3545
|
}
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
const refreshed = await readCatalog(signal, attempt === 0).catch(() => null);
|
|
3550
|
-
if (!refreshed || signal.aborted) continue;
|
|
3551
|
-
setCatalog(refreshed);
|
|
3552
|
-
if (hostSkillIsVisible(refreshed, outcome.name, catalog.targetRoot)) {
|
|
3553
|
-
await choose(outcome.name);
|
|
3554
|
-
return;
|
|
3555
|
-
}
|
|
3546
|
+
if (failure?.code === 'E_SKILL_NOT_VISIBLE' && name) throw new Error(tf(t, 'tcHostUnseen', { name }));
|
|
3547
|
+
if (!response.ok || typeof result?.skill?.name !== 'string' || !result.skill.name) {
|
|
3548
|
+
throw new Error(tf(t, 'tcHostImportFailed', { error: failure?.message || 'HTTP ' + response.status }));
|
|
3556
3549
|
}
|
|
3557
|
-
|
|
3550
|
+
if (!selectedNames.includes(result.skill.name)) await choose(result.skill.name);
|
|
3558
3551
|
});
|
|
3559
3552
|
}
|
|
3560
3553
|
const close = () => { if (!busy) dismiss(); };
|
|
3561
3554
|
return h(React.Fragment, null,
|
|
3562
|
-
h('button', { ref: trigger, type: 'button', className: 'at-btn', disabled, 'aria-haspopup': 'dialog', onClick: show }, withIco('plus',
|
|
3563
|
-
open ? h(ModalBack, { onClose: close }, h('div', { className: 'at-modal at-hostskillpicker', role: 'dialog', 'aria-modal': 'true', 'aria-label':
|
|
3564
|
-
h('h2', { className: 'at-modaltitle' },
|
|
3555
|
+
h('button', { ref: trigger, type: 'button', className: 'at-btn', disabled, 'aria-haspopup': 'dialog', onClick: show }, withIco('plus', title)),
|
|
3556
|
+
open ? h(ModalBack, { onClose: close }, h('div', { className: 'at-modal at-hostskillpicker', role: 'dialog', 'aria-modal': 'true', 'aria-label': title },
|
|
3557
|
+
h('h2', { className: 'at-modaltitle' }, title),
|
|
3565
3558
|
h('div', { className: 'at-modalactions' }, h('button', { type: 'button', className: 'at-btn', onClick: close, disabled: busy, autoFocus: true }, withIco('close', t('cancel')))),
|
|
3566
3559
|
catalog === null ? h('div', { className: 'at-modalmeta', role: 'status' }, t('loading'))
|
|
3567
3560
|
: catalog === false ? h('div', { className: 'at-modalerror', role: 'alert' }, t('tcHostUnavailable'))
|
|
@@ -3571,13 +3564,14 @@ window.__ModuleLoader__.load({
|
|
|
3571
3564
|
choices.map((skill) => h('option', { key: skill.name, value: skill.name }, skill.name))),
|
|
3572
3565
|
choice?.description ? h('div', { className: 'at-modalmeta' }, choice.description) : null,
|
|
3573
3566
|
h('div', { className: 'at-tcpick' }, h('button', { type: 'button', className: 'at-btn at-btn-primary', disabled: !choice || busy, onClick: () => void perform(() => choose(choice.name)) }, t('tcAdd')))),
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
h('
|
|
3577
|
-
h('input', { ref:
|
|
3567
|
+
importHint ? h('div', { className: 'at-modalmeta' }, t(importHint)) : null,
|
|
3568
|
+
fileAccept ? h('div', { className: 'at-field' },
|
|
3569
|
+
canImportPack ? h('div', { className: 'at-modalmeta' }, t(catalog.workspace ? 'tcHostProjectRoot' : 'tcHostUserRoot')) : null,
|
|
3570
|
+
canImportPack ? h('input', { ref: folderInput, type: 'file', webkitdirectory: '', multiple: true, hidden: true, 'aria-label': t('tcHostFolder'), onChange: (event) => importSelected(event, true) }) : null,
|
|
3571
|
+
h('input', { ref: fileInput, type: 'file', accept: fileAccept, hidden: true, 'aria-label': fileLabel, onChange: (event) => importSelected(event, false) }),
|
|
3578
3572
|
h('div', { className: 'at-tcpick' },
|
|
3579
|
-
h('button', { type: 'button', className: 'at-btn', disabled: busy, onClick: () =>
|
|
3580
|
-
h('button', { type: 'button', className: 'at-btn', disabled: busy, onClick: () =>
|
|
3573
|
+
h('button', { type: 'button', className: 'at-btn', disabled: busy, onClick: () => fileInput.current?.click() }, fileLabel),
|
|
3574
|
+
canImportPack ? h('button', { type: 'button', className: 'at-btn', disabled: busy, onClick: () => folderInput.current?.click() }, withIco('folderPlus', t('tcHostFolder'))) : null)) : null,
|
|
3581
3575
|
progress ? h('div', { className: 'at-modalmeta', role: 'status' }, t(progress)) : null,
|
|
3582
3576
|
error ? h('div', { className: 'at-modalerror', role: 'alert' }, error) : null)) : null);
|
|
3583
3577
|
}
|
|
@@ -3615,14 +3609,15 @@ window.__ModuleLoader__.load({
|
|
|
3615
3609
|
const name = skName.trim(); if (!name) return;
|
|
3616
3610
|
if (stage({ name, kind: 'write', markdown: skBody })) { setPick(''); setSkName(''); setSkBody(''); }
|
|
3617
3611
|
}
|
|
3618
|
-
function
|
|
3619
|
-
const
|
|
3620
|
-
const
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3612
|
+
async function importMarkdown(file) {
|
|
3613
|
+
const name = (file.name.replace(/\.md$/i, '').replace(/[^A-Za-z0-9._-]/g, '-').slice(0, 64)) || 'skill';
|
|
3614
|
+
const markdown = await new Promise((resolve, reject) => {
|
|
3615
|
+
const reader = new FileReader();
|
|
3616
|
+
reader.onerror = () => reject(reader.error);
|
|
3617
|
+
reader.onload = () => resolve(String(reader.result ?? ''));
|
|
3618
|
+
reader.readAsText(file);
|
|
3619
|
+
});
|
|
3620
|
+
return stage({ name, kind: 'write', markdown });
|
|
3626
3621
|
}
|
|
3627
3622
|
async function save() {
|
|
3628
3623
|
if (!form.name.trim() || busy) return;
|
|
@@ -3670,10 +3665,9 @@ window.__ModuleLoader__.load({
|
|
|
3670
3665
|
h('div', { className: 'at-field' }, h('span', null, t('tcSkills')),
|
|
3671
3666
|
pending.length === 0 ? h('div', { className: 'at-modalmeta' }, t('tcEmpty')) : h('div', { className: 'at-tcskills' }, pending.map((sk) => h('span', { key: sk.name, className: 'at-tcskill' }, sk.name, h('button', { type: 'button', 'aria-label': t('tcRemove'), onClick: () => setPending((pp) => pp.filter((x) => x.name !== sk.name)) }, '×')))),
|
|
3672
3667
|
h('div', { className: 'at-tcpick' },
|
|
3673
|
-
h(HostSkillPicker, { t, selectedNames: pending.map((skill) => skill.name), disabled: busy, onChoose: (name) => stage({ name, kind: 'host' }) }),
|
|
3668
|
+
h(HostSkillPicker, { t, selectedNames: pending.map((skill) => skill.name), disabled: busy, onChoose: (name) => stage({ name, kind: 'host' }), onImportMarkdown: importMarkdown }),
|
|
3674
3669
|
h('button', { type: 'button', className: 'at-btn', onClick: () => setPick(pick === 'existing' ? '' : 'existing') }, withIco('store', t('tcAddExisting'))),
|
|
3675
|
-
h('button', { type: 'button', className: 'at-btn', onClick: () => setPick(pick === 'write' ? '' : 'write') }, withIco('pen', t('tcWriteOwn'))),
|
|
3676
|
-
h('label', { className: 'at-btn' }, withIco('folderPlus', t('tcImport')), h('input', { type: 'file', accept: '.md,text/markdown,text/plain', style: { display: 'none' }, onChange: importFile }))),
|
|
3670
|
+
h('button', { type: 'button', className: 'at-btn', onClick: () => setPick(pick === 'write' ? '' : 'write') }, withIco('pen', t('tcWriteOwn')))),
|
|
3677
3671
|
pick === 'existing' ? h('div', { className: 'at-tcpanel' }, h('select', { value: pickFrom, onChange: (e) => setPickFrom(e.target.value) }, h('option', { value: '' }, t('tcPick')), installable.map((sk) => h('option', { key: sk.talent + '::' + sk.name, value: sk.talent + '::' + sk.name }, sk.name + ' — ' + sk.talentName))), h('button', { type: 'button', className: 'at-btn at-btn-primary', onClick: addExisting }, t('tcAdd'))) : null,
|
|
3678
3672
|
pick === 'write' ? h('div', { className: 'at-tcpanel' }, h('input', { value: skName, placeholder: t('tcSkillName'), onChange: (e) => setSkName(e.target.value) }), h('textarea', { value: skBody, placeholder: t('tcSkillBody'), onChange: (e) => setSkBody(e.target.value) }), h('button', { type: 'button', className: 'at-btn at-btn-primary', onClick: addWritten }, t('tcAdd'))) : null),
|
|
3679
3673
|
error ? h('div', { className: 'at-modalerror', role: 'alert' }, error) : null,
|
package/index.js
CHANGED
|
@@ -12,9 +12,10 @@ import { HOST_SUBAGENT_LIMIT, planDispatch, planIdleRetry, planIdleStaffing, pla
|
|
|
12
12
|
import { pmoHasNews } from './lib/ledger/fold.js';
|
|
13
13
|
import { homedir, tmpdir } from 'node:os';
|
|
14
14
|
import { randomUUID } from 'node:crypto';
|
|
15
|
-
import { join,
|
|
15
|
+
import { isAbsolute, join, relative, sep } from 'node:path';
|
|
16
16
|
import { fileURLToPath } from 'node:url';
|
|
17
17
|
import { existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from 'node:fs';
|
|
18
|
+
import { realpath, stat } from 'node:fs/promises';
|
|
18
19
|
import z from '@deepseek-ai/schemastery';
|
|
19
20
|
import { ProjectRuntime } from './lib/host/project-runtime.js';
|
|
20
21
|
import { ProjectRegistry } from './lib/host/project-registry.js';
|
|
@@ -34,6 +35,7 @@ import { skillKindForMember } from './lib/runtime/core-skill.js';
|
|
|
34
35
|
import { formatSkillSummaries, modelInvocableSkills, readSkillCatalog } from './lib/runtime/skill-catalog.js';
|
|
35
36
|
import { isSkillExcluded } from './lib/runtime/skill-policy.js';
|
|
36
37
|
import { installFileSkillProvider, pickProjectForCwd } from './lib/runtime/skill-provider.js';
|
|
38
|
+
import { installSkillPack, MAX_SKILL_IMPORT_REQUEST_BYTES } from './lib/host/skill-import.js';
|
|
37
39
|
import { apply as applySkillOpt } from './lib/vendor/skillopt/src/index.js';
|
|
38
40
|
import { createAdoptGate, wrapToolsWithAdoptGate } from './lib/skillopt/adopt-gate.js';
|
|
39
41
|
import { wrapToolsWithSkilloptAccess } from './lib/skillopt/tool-access.js';
|
|
@@ -230,12 +232,14 @@ function send(res, body, status = 200) {
|
|
|
230
232
|
res.end(JSON.stringify(body));
|
|
231
233
|
}
|
|
232
234
|
|
|
233
|
-
async function readJson(req) {
|
|
235
|
+
async function readJson(req, limit = 1_000_000) {
|
|
236
|
+
const tooLarge = () => Object.assign(new Error('body too large'), { code: 'E_INVALID_ARGUMENT', status: 413 });
|
|
237
|
+
if (Number(req.headers?.['content-length']) > limit) throw tooLarge();
|
|
234
238
|
const chunks = [];
|
|
235
239
|
let size = 0;
|
|
236
240
|
for await (const chunk of req) {
|
|
237
241
|
size += chunk.length;
|
|
238
|
-
if (size >
|
|
242
|
+
if (size > limit) throw tooLarge();
|
|
239
243
|
chunks.push(chunk);
|
|
240
244
|
}
|
|
241
245
|
if (chunks.length === 0) return {};
|
|
@@ -2554,25 +2558,28 @@ export function apply(ctx, config = {}) {
|
|
|
2554
2558
|
get: await skillsService.get('distilly', {}).then((skill) => skill?.name ?? null).catch(() => null),
|
|
2555
2559
|
});
|
|
2556
2560
|
}
|
|
2557
|
-
if (
|
|
2561
|
+
if (url.pathname === '/ai-team/api/host-skills' && (req.method === 'GET' || req.method === 'POST')) {
|
|
2558
2562
|
const projectId = url.searchParams.get('project');
|
|
2559
2563
|
const memberId = url.searchParams.get('member');
|
|
2560
2564
|
if (projectId === null && memberId !== null) return send(res, { error: { code: 'E_INVALID_ARGUMENT', message: 'project is required with member' } }, 400);
|
|
2565
|
+
const importing = req.method === 'POST';
|
|
2561
2566
|
let workspace = null;
|
|
2562
2567
|
let targetRoot = projectId === null ? 'user-dsh' : null;
|
|
2563
2568
|
if (projectId !== null) {
|
|
2564
2569
|
const runtime = projectRuntime(projectId);
|
|
2565
2570
|
if (runtime === null) return send(res, { error: { code: 'NOT_FOUND', message: 'project not found' } }, 404);
|
|
2571
|
+
if (importing && runtime.service.state.projects?.[projectId]?.status === 'archived') {
|
|
2572
|
+
return send(res, { error: { code: 'E_PROJECT_ARCHIVED', message: 'This project is archived.' } }, 409);
|
|
2573
|
+
}
|
|
2566
2574
|
const member = memberId === null ? undefined : runtime.service.state.members?.[memberId];
|
|
2567
2575
|
if (memberId !== null && member?.kind !== 'agent') return send(res, { error: { code: 'NOT_FOUND', message: 'member not found' } }, 404);
|
|
2568
2576
|
workspace = memberWorkspace(member, runtime) || null;
|
|
2569
|
-
if (workspace !== null) {
|
|
2577
|
+
if (workspace !== null && isAbsolute(workspace)) {
|
|
2570
2578
|
try {
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
targetRoot = `project-dsh:${resolve(workspace)}`;
|
|
2579
|
+
const canonical = await realpath(workspace);
|
|
2580
|
+
if ((await stat(canonical)).isDirectory()) {
|
|
2581
|
+
workspace = canonical;
|
|
2582
|
+
targetRoot = 'project-dsh:' + canonical;
|
|
2576
2583
|
}
|
|
2577
2584
|
} catch (error) {
|
|
2578
2585
|
diag.append({ ev: 'skill.workspace.fail', projectId, workspace, message: error?.message ?? String(error) });
|
|
@@ -2580,11 +2587,49 @@ export function apply(ctx, config = {}) {
|
|
|
2580
2587
|
}
|
|
2581
2588
|
}
|
|
2582
2589
|
// Give the personal view an explicit cwd so the fallback provider cannot adopt the host's startup project.
|
|
2583
|
-
|
|
2584
|
-
|
|
2590
|
+
const cwd = workspace ?? dshHome();
|
|
2591
|
+
if (importing && targetRoot === null) {
|
|
2592
|
+
return send(res, { error: { code: 'E_SKILL_WORKSPACE_REQUIRED', message: 'Set an existing workspace for this project or member.' } }, 400);
|
|
2593
|
+
}
|
|
2594
|
+
const summaries = await lookupHostSkills(cwd, {
|
|
2585
2595
|
requireRegistry: true, refresh: url.searchParams.get('refresh') === '1',
|
|
2586
2596
|
});
|
|
2587
2597
|
if (summaries === null) return send(res, { error: { code: 'E_RUNTIME_UNAVAILABLE', message: 'DSH skill catalog is unavailable' } }, 503);
|
|
2598
|
+
if (importing) {
|
|
2599
|
+
let confirming = false;
|
|
2600
|
+
try {
|
|
2601
|
+
const payload = await readJson(req, MAX_SKILL_IMPORT_REQUEST_BYTES);
|
|
2602
|
+
const source = projectId === null ? 'user-dsh' : 'project-dsh';
|
|
2603
|
+
const installedNames = new Set(summaries.filter((item) => item.source === source).map((item) => item.name));
|
|
2604
|
+
const skill = await installSkillPack(payload, {
|
|
2605
|
+
baseDir: cwd,
|
|
2606
|
+
project: projectId !== null,
|
|
2607
|
+
installedNames,
|
|
2608
|
+
async confirm({ name, path }) {
|
|
2609
|
+
confirming = true;
|
|
2610
|
+
// 子工作区可能处于宿主监视根的下一层。主动刷新,再确认胜出的路径。
|
|
2611
|
+
const updated = await lookupHostSkills(cwd, { requireRegistry: true, refresh: true });
|
|
2612
|
+
const item = modelInvocableSkills(updated ?? []).find((entry) => entry.name === name && entry.source === source);
|
|
2613
|
+
const loadedPath = typeof item?.path === 'string' ? await realpath(item.path).catch(() => null) : null;
|
|
2614
|
+
if (loadedPath === null || relative(path, loadedPath) !== '') {
|
|
2615
|
+
throw Object.assign(new Error('DSH did not resolve the imported skill in the selected scope.'), {
|
|
2616
|
+
code: 'E_SKILL_NOT_VISIBLE', status: 409, details: { name },
|
|
2617
|
+
});
|
|
2618
|
+
}
|
|
2619
|
+
return { name, description: item.description ?? '', source };
|
|
2620
|
+
},
|
|
2621
|
+
});
|
|
2622
|
+
diag.append({ ev: 'skill.import', projectId, memberId, workspace, name: skill.name, source: skill.source });
|
|
2623
|
+
return send(res, { skill }, 201);
|
|
2624
|
+
} catch (error) {
|
|
2625
|
+
if (confirming) disposeSkillProvider.invalidate?.();
|
|
2626
|
+
const status = error?.status ?? (error instanceof SyntaxError ? 400 : 500);
|
|
2627
|
+
const code = error?.code && error?.status ? error.code : 'E_SKILL_IMPORT';
|
|
2628
|
+
diag.append({ ev: 'skill.import.fail', projectId, memberId, workspace, code, status, message: error?.message ?? String(error) });
|
|
2629
|
+
const message = status === 500 ? 'Could not save the package to the DSH skill directory.' : error.message;
|
|
2630
|
+
return send(res, { error: { code, message, details: error.details } }, status);
|
|
2631
|
+
}
|
|
2632
|
+
}
|
|
2588
2633
|
const skills = modelInvocableSkills(summaries)
|
|
2589
2634
|
.filter((skill) => workspace !== null || !skill.source?.startsWith('project-'))
|
|
2590
2635
|
.map((skill) => ({ name: skill.name, description: skill.description ?? '', source: skill.source ?? '' }));
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { lstat, mkdir, mkdtemp, realpath, rename, rm, stat, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { dirname, join, posix, relative } from 'node:path';
|
|
3
|
+
import { buffer } from 'node:stream/consumers';
|
|
4
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
5
|
+
import { crc32 } from 'node:zlib';
|
|
6
|
+
import yauzl from 'yauzl';
|
|
7
|
+
import { inspectFileSkill, MAX_SKILL_BODY_BYTES } from '../runtime/skill-provider.js';
|
|
8
|
+
|
|
9
|
+
export const MAX_SKILL_IMPORT_REQUEST_BYTES = 64 * 1024 * 1024;
|
|
10
|
+
const MAX_FILES = 10_000;
|
|
11
|
+
const MAX_FILE_BYTES = 64 * 1024 * 1024;
|
|
12
|
+
const MAX_EXPANDED_BYTES = 256 * 1024 * 1024;
|
|
13
|
+
const MANIFEST = 'SKILL.md';
|
|
14
|
+
const imports = new Set();
|
|
15
|
+
const publishDelays = [0, 50, 150, 350, 800];
|
|
16
|
+
const transientRenameErrors = new Set(['EACCES', 'EBUSY', 'EPERM']);
|
|
17
|
+
|
|
18
|
+
function importError(message, { code = 'E_INVALID_SKILL_PACK', status = 400, details } = {}) {
|
|
19
|
+
return Object.assign(new Error(message), { code, status, details });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function packTooLarge() {
|
|
23
|
+
return importError('Skill package exceeds the import size limit.', { code: 'E_SKILL_PACK_TOO_LARGE', status: 413 });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function filePath(path) {
|
|
27
|
+
if (typeof path !== 'string' || !path.isWellFormed() || path.split('/').some((part) => (
|
|
28
|
+
part === '' || /[. ]$/.test(part) || /[\x00-\x1f<>:"\\|?*]/.test(part)
|
|
29
|
+
|| /^(?:con|prn|aux|nul|conin\$|conout\$|com[1-9¹²³]|lpt[1-9¹²³])(?:\.|$)/i.test(part)
|
|
30
|
+
))) throw importError('Skill package contains an invalid file path.');
|
|
31
|
+
return path;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function base64(value) {
|
|
35
|
+
if (typeof value !== 'string' || value.length % 4 !== 0 || /[^A-Za-z0-9+/=]|=[^=]|={3}/.test(value)) {
|
|
36
|
+
throw importError('Skill package contains invalid file data.');
|
|
37
|
+
}
|
|
38
|
+
return Buffer.from(value, 'base64');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function zipFiles(encoded) {
|
|
42
|
+
try {
|
|
43
|
+
const zip = await yauzl.fromBufferPromise(base64(encoded), { validateEntrySizes: true });
|
|
44
|
+
if (zip.entryCount > MAX_FILES) throw packTooLarge();
|
|
45
|
+
const files = [];
|
|
46
|
+
let expanded = 0;
|
|
47
|
+
for await (const entry of zip.eachEntry()) {
|
|
48
|
+
const directory = entry.fileName.endsWith('/');
|
|
49
|
+
const path = filePath(directory ? entry.fileName.slice(0, -1) : entry.fileName);
|
|
50
|
+
const kind = (entry.externalFileAttributes >>> 16) & 0o170000;
|
|
51
|
+
if (kind && kind !== (directory ? 0o040000 : 0o100000)) {
|
|
52
|
+
throw importError('Skill package may contain only regular files and directories.');
|
|
53
|
+
}
|
|
54
|
+
if (directory) continue;
|
|
55
|
+
if (entry.uncompressedSize > MAX_FILE_BYTES) throw packTooLarge();
|
|
56
|
+
expanded += entry.uncompressedSize;
|
|
57
|
+
if (expanded > MAX_EXPANDED_BYTES) throw packTooLarge();
|
|
58
|
+
files.push({
|
|
59
|
+
path,
|
|
60
|
+
size: entry.uncompressedSize,
|
|
61
|
+
async read() {
|
|
62
|
+
let bytes;
|
|
63
|
+
try {
|
|
64
|
+
bytes = await buffer(await zip.openReadStreamPromise(entry));
|
|
65
|
+
} catch {
|
|
66
|
+
throw importError('A file in the ZIP skill package could not be read.');
|
|
67
|
+
}
|
|
68
|
+
if (crc32(bytes) !== entry.crc32) throw importError('A file in the ZIP skill package failed its checksum.');
|
|
69
|
+
return bytes;
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return files;
|
|
74
|
+
} catch (error) {
|
|
75
|
+
if (error?.status) throw error;
|
|
76
|
+
throw importError('The ZIP or .skill package could not be opened.');
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async function readPack(payload) {
|
|
81
|
+
const hasArchive = typeof payload?.zipBase64 === 'string';
|
|
82
|
+
const hasFiles = Array.isArray(payload?.files);
|
|
83
|
+
if (hasArchive === hasFiles) throw importError('Upload one skill folder or one ZIP/.skill package.');
|
|
84
|
+
if (hasFiles && payload.files.length > MAX_FILES) throw packTooLarge();
|
|
85
|
+
const files = hasArchive ? await zipFiles(payload.zipBase64) : payload.files.map((file) => {
|
|
86
|
+
const bytes = base64(file?.contentBase64);
|
|
87
|
+
if (bytes.length > MAX_FILE_BYTES) throw packTooLarge();
|
|
88
|
+
return { path: filePath(file?.path), size: bytes.length, read: () => bytes };
|
|
89
|
+
});
|
|
90
|
+
const manifests = files.filter((file) => posix.basename(file.path) === MANIFEST)
|
|
91
|
+
.sort((a, b) => a.path.length - b.path.length);
|
|
92
|
+
if (!manifests.length) throw importError('The skill package is missing SKILL.md.');
|
|
93
|
+
const manifest = manifests[0];
|
|
94
|
+
const folder = posix.dirname(manifest.path);
|
|
95
|
+
const prefix = folder === '.' ? '' : folder + '/';
|
|
96
|
+
if (manifests.some((file) => !file.path.startsWith(prefix))) {
|
|
97
|
+
throw importError('Select one skill package per import.');
|
|
98
|
+
}
|
|
99
|
+
if (manifest.size > MAX_SKILL_BODY_BYTES) throw packTooLarge();
|
|
100
|
+
const selected = files.filter((file) => file.path.startsWith(prefix))
|
|
101
|
+
.map((file) => ({ ...file, path: file.path.slice(prefix.length) }));
|
|
102
|
+
const paths = new Set(selected.map((file) => file.path.normalize('NFC').toLowerCase()));
|
|
103
|
+
if (paths.size !== selected.length) throw importError('The skill package contains duplicate file paths.');
|
|
104
|
+
for (const path of paths) {
|
|
105
|
+
for (let parent = posix.dirname(path); parent !== '.'; parent = posix.dirname(parent)) {
|
|
106
|
+
if (paths.has(parent)) throw importError('The skill package uses a file as a directory.');
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
const markdown = await manifest.read();
|
|
110
|
+
let text;
|
|
111
|
+
try {
|
|
112
|
+
text = new TextDecoder('utf-8', { fatal: true }).decode(markdown);
|
|
113
|
+
} catch {
|
|
114
|
+
throw importError('SKILL.md must be UTF-8 text.');
|
|
115
|
+
}
|
|
116
|
+
const metadata = inspectFileSkill(text);
|
|
117
|
+
if (metadata.problem || metadata.name.length > 64) {
|
|
118
|
+
throw importError('SKILL.md needs a valid skill name, description, and invocation settings.', {
|
|
119
|
+
details: { reason: metadata.problem ?? 'name-too-long' },
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
if (!metadata.invocation.modelInvocable) throw importError('This skill disables model invocation.');
|
|
123
|
+
return { name: filePath(metadata.name), selected, markdown };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async function installRoot(baseDir, project) {
|
|
127
|
+
let root = await realpath(baseDir);
|
|
128
|
+
if (!(await stat(root)).isDirectory()) throw importError('The skill destination must be a directory.');
|
|
129
|
+
for (const segment of project ? ['.dsh', 'skills'] : ['skills']) {
|
|
130
|
+
root = join(root, segment);
|
|
131
|
+
await mkdir(root).catch((error) => { if (error.code !== 'EEXIST') throw error; });
|
|
132
|
+
if (!(await lstat(root)).isDirectory()) throw importError('The skill destination must be a real directory.');
|
|
133
|
+
}
|
|
134
|
+
return root;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async function pathExists(path) {
|
|
138
|
+
try {
|
|
139
|
+
await lstat(path);
|
|
140
|
+
return true;
|
|
141
|
+
} catch (error) {
|
|
142
|
+
if (error.code === 'ENOENT') return false;
|
|
143
|
+
throw error;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Both upload formats create one complete, discoverable DSH skill directory. */
|
|
148
|
+
export async function installSkillPack(payload, { baseDir, project, installedNames, confirm, moveDirectory = rename }) {
|
|
149
|
+
const { name, selected, markdown } = await readPack(payload);
|
|
150
|
+
const conflict = () => importError('A skill with this name is already installed or being imported.', {
|
|
151
|
+
code: 'E_SKILL_EXISTS', status: 409, details: { name },
|
|
152
|
+
});
|
|
153
|
+
if (installedNames?.has(name)) throw conflict();
|
|
154
|
+
const root = await installRoot(baseDir, project);
|
|
155
|
+
const target = join(root, name);
|
|
156
|
+
const checkDestination = async () => {
|
|
157
|
+
if (await pathExists(target) || await pathExists(target + '.md')) throw conflict();
|
|
158
|
+
};
|
|
159
|
+
if (imports.has(target)) throw conflict();
|
|
160
|
+
imports.add(target);
|
|
161
|
+
let temporary;
|
|
162
|
+
try {
|
|
163
|
+
await checkDestination();
|
|
164
|
+
// DSH scans every immediate child of the skill root, including most dot directories.
|
|
165
|
+
temporary = await mkdtemp(join(dirname(root), '.ai-team-skill-'));
|
|
166
|
+
for (const file of selected) {
|
|
167
|
+
const destination = join(temporary, file.path);
|
|
168
|
+
await mkdir(dirname(destination), { recursive: true });
|
|
169
|
+
await writeFile(destination, file.path === MANIFEST ? markdown : await file.read(), { flag: 'wx' });
|
|
170
|
+
}
|
|
171
|
+
for (const [attempt, pause] of publishDelays.entries()) {
|
|
172
|
+
if (pause > 0) await delay(pause);
|
|
173
|
+
await checkDestination();
|
|
174
|
+
try {
|
|
175
|
+
await moveDirectory(temporary, target);
|
|
176
|
+
break;
|
|
177
|
+
} catch (error) {
|
|
178
|
+
if (attempt === publishDelays.length - 1 || !transientRenameErrors.has(error?.code)) {
|
|
179
|
+
await checkDestination();
|
|
180
|
+
throw error;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
// Keep ownership of this newly published directory until the DSH catalog confirms it.
|
|
185
|
+
temporary = target;
|
|
186
|
+
const installed = await confirm({ name, path: join(target, MANIFEST) });
|
|
187
|
+
temporary = undefined;
|
|
188
|
+
return installed;
|
|
189
|
+
} finally {
|
|
190
|
+
try {
|
|
191
|
+
if (temporary) {
|
|
192
|
+
const canonical = await realpath(temporary).catch((error) => {
|
|
193
|
+
if (error.code === 'ENOENT') return null;
|
|
194
|
+
throw error;
|
|
195
|
+
});
|
|
196
|
+
if (canonical !== null && relative(temporary, canonical) === '') {
|
|
197
|
+
await rm(temporary, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
} finally {
|
|
201
|
+
imports.delete(target);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bounded, invocation-neutral view of the DSH skill catalog for a member
|
|
3
|
-
* prompt. Full bodies stay with the `skill` tool; this only makes names,
|
|
4
|
-
* descriptions and "when to use" discoverable so a member can load one on
|
|
5
|
-
* demand instead of guessing.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { isSkillExcluded } from './skill-policy.js';
|
|
9
|
-
|
|
10
|
-
function clean(value, limit) {
|
|
11
|
-
const text = typeof value === 'string' ? value.replace(/\s+/g, ' ').trim() : '';
|
|
12
|
-
return text.length > limit ? `${text.slice(0, limit - 1)}…` : text;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export async function readSkillCatalog(skills, { cwd } = {}) {
|
|
16
|
-
if (typeof skills?.list !== 'function') return [];
|
|
17
|
-
const summaries = await skills.list(cwd ? { cwd } : {});
|
|
18
|
-
return Array.isArray(summaries) ? summaries : [];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function modelInvocableSkills(summaries) {
|
|
22
|
-
// 只注入「模型可以自己调用」的技能:`disable-model-invocation: true` 的技能
|
|
23
|
-
// 是给 Human 显式用的,列进成员 prompt 会把成员引向一个它无权调用的入口。
|
|
24
|
-
// SkillSummary 把这两个开关放在 `invocation` 下;直接读顶层字段会让过滤永远
|
|
25
|
-
// 通过(字段恒为 undefined),被禁的技能照样写进 prompt。
|
|
26
|
-
return summaries.filter((skill) => {
|
|
27
|
-
if (typeof skill?.name !== 'string' || skill.name === '' || isSkillExcluded(skill.name)) return false;
|
|
28
|
-
const modelInvocable = skill?.invocation?.modelInvocable ?? skill?.modelInvocable;
|
|
29
|
-
const disabled = skill?.invocation?.disableModelInvocation ?? skill?.disableModelInvocation;
|
|
30
|
-
if (modelInvocable === false || disabled === true) return false;
|
|
31
|
-
return true;
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function formatSkillSummaries(summaries, options = {}) {
|
|
36
|
-
const assigned = new Set(Array.isArray(options.assigned) ? options.assigned : []);
|
|
37
|
-
const available = modelInvocableSkills(summaries);
|
|
38
|
-
if (available.length === 0) return '';
|
|
39
|
-
const selected = available.filter((skill) => assigned.has(skill.name));
|
|
40
|
-
const limit = Number.isSafeInteger(options.limit) && options.limit > 0 ? options.limit : 12;
|
|
41
|
-
const discoverable = available.filter((skill) => !assigned.has(skill.name)).slice(0, Math.max(0, limit - selected.length));
|
|
42
|
-
const rows = [...selected, ...discoverable].map((skill) => {
|
|
43
|
-
const name = skill.name;
|
|
44
|
-
const description = clean(skill?.description, 240);
|
|
45
|
-
const when = clean(skill?.whenToUse, 180);
|
|
46
|
-
return `- ${name}${assigned.has(name) ? '(已为你配置)' : ''}:${description}${when ? `(何时用:${when})` : ''}`;
|
|
47
|
-
});
|
|
48
|
-
if (rows.length === 0) return '';
|
|
49
|
-
const priority = selected.length > 0 ? '处理匹配任务时优先使用已为你配置的技能。' : '';
|
|
50
|
-
return `\n\n## 可用 DSH 技能\n${rows.join('\n')}\n${priority}需要时用 skill 工具按名字加载完整技能说明;不要凭描述臆造步骤。`;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export async function formatSkillCatalog(skills, options = {}) {
|
|
54
|
-
const summaries = await readSkillCatalog(skills, options).catch(() => []);
|
|
55
|
-
return formatSkillSummaries(summaries, options);
|
|
56
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Bounded, invocation-neutral view of the DSH skill catalog for a member
|
|
3
|
+
* prompt. Full bodies stay with the `skill` tool; this only makes names,
|
|
4
|
+
* descriptions and "when to use" discoverable so a member can load one on
|
|
5
|
+
* demand instead of guessing.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { isSkillExcluded } from './skill-policy.js';
|
|
9
|
+
|
|
10
|
+
function clean(value, limit) {
|
|
11
|
+
const text = typeof value === 'string' ? value.replace(/\s+/g, ' ').trim() : '';
|
|
12
|
+
return text.length > limit ? `${text.slice(0, limit - 1)}…` : text;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export async function readSkillCatalog(skills, { cwd } = {}) {
|
|
16
|
+
if (typeof skills?.list !== 'function') return [];
|
|
17
|
+
const summaries = await skills.list(cwd ? { cwd } : {});
|
|
18
|
+
return Array.isArray(summaries) ? summaries : [];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function modelInvocableSkills(summaries) {
|
|
22
|
+
// 只注入「模型可以自己调用」的技能:`disable-model-invocation: true` 的技能
|
|
23
|
+
// 是给 Human 显式用的,列进成员 prompt 会把成员引向一个它无权调用的入口。
|
|
24
|
+
// SkillSummary 把这两个开关放在 `invocation` 下;直接读顶层字段会让过滤永远
|
|
25
|
+
// 通过(字段恒为 undefined),被禁的技能照样写进 prompt。
|
|
26
|
+
return summaries.filter((skill) => {
|
|
27
|
+
if (typeof skill?.name !== 'string' || skill.name === '' || isSkillExcluded(skill.name)) return false;
|
|
28
|
+
const modelInvocable = skill?.invocation?.modelInvocable ?? skill?.modelInvocable;
|
|
29
|
+
const disabled = skill?.invocation?.disableModelInvocation ?? skill?.disableModelInvocation;
|
|
30
|
+
if (modelInvocable === false || disabled === true) return false;
|
|
31
|
+
return true;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function formatSkillSummaries(summaries, options = {}) {
|
|
36
|
+
const assigned = new Set(Array.isArray(options.assigned) ? options.assigned : []);
|
|
37
|
+
const available = modelInvocableSkills(summaries);
|
|
38
|
+
if (available.length === 0) return '';
|
|
39
|
+
const selected = available.filter((skill) => assigned.has(skill.name));
|
|
40
|
+
const limit = Number.isSafeInteger(options.limit) && options.limit > 0 ? options.limit : 12;
|
|
41
|
+
const discoverable = available.filter((skill) => !assigned.has(skill.name)).slice(0, Math.max(0, limit - selected.length));
|
|
42
|
+
const rows = [...selected, ...discoverable].map((skill) => {
|
|
43
|
+
const name = skill.name;
|
|
44
|
+
const description = clean(skill?.description, 240);
|
|
45
|
+
const when = clean(skill?.whenToUse, 180);
|
|
46
|
+
return `- ${name}${assigned.has(name) ? '(已为你配置)' : ''}:${description}${when ? `(何时用:${when})` : ''}`;
|
|
47
|
+
});
|
|
48
|
+
if (rows.length === 0) return '';
|
|
49
|
+
const priority = selected.length > 0 ? '处理匹配任务时优先使用已为你配置的技能。' : '';
|
|
50
|
+
return `\n\n## 可用 DSH 技能\n${rows.join('\n')}\n${priority}需要时用 skill 工具按名字加载完整技能说明;不要凭描述臆造步骤。`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export async function formatSkillCatalog(skills, options = {}) {
|
|
54
|
+
const summaries = await readSkillCatalog(skills, options).catch(() => []);
|
|
55
|
+
return formatSkillSummaries(summaries, options);
|
|
56
|
+
}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs';
|
|
15
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,40 +132,46 @@ 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,
|
|
@@ -215,7 +239,7 @@ export function createFileSkillProvider({ dshHome, projectCwd, bundledDir, resol
|
|
|
215
239
|
// 读取失败不能把 rejection 冒到 skill 工具:宿主在 agent/pre-step 里
|
|
216
240
|
// await skills.snapshot,一次 EACCES/EBUSY 会打断该 agent 的整个回合。
|
|
217
241
|
try {
|
|
218
|
-
if (statSync(file).size >
|
|
242
|
+
if (statSync(file).size > MAX_SKILL_BODY_BYTES) return undefined;
|
|
219
243
|
const raw = readFileSync(file, 'utf8');
|
|
220
244
|
// 技能按文件原样提供,但 `{{GOAL}}` 这类占位符必须在返回前渲染:成员主动
|
|
221
245
|
// 加载技能时不该看到字面量(与激活注入走同一套变量)。
|
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
|
+
}
|