@suifei/dsh-ai-team 0.4.149 → 0.4.150
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 +5 -0
- package/README.md +5 -2
- package/client.js +231 -12
- package/index.js +105 -18
- package/lib/domain/catalog.js +14 -6
- package/lib/runtime/skill-catalog.js +27 -12
- package/lib/runtime/skill-provider.js +21 -20
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.150 - 2026-12-02
|
|
4
|
+
|
|
5
|
+
- 成员资料和新建人才可选择 DSH 已安装的技能。在同一 profile 启用 Skill Station 后,桌面端和本机 Web 可导入技能目录、ZIP 或 `.skill`,并把安装成功的技能加入当前表单。DSH 保留整包及相对资源。感谢 @godfay-g 的建议(#109)。
|
|
6
|
+
- 技能选择和成员调用按成员实际工作区解析,避免把宿主启动工作区的技能带入其他项目。将成员存为人才时保留 DSH 技能引用。
|
|
7
|
+
|
|
3
8
|
## 0.4.149 - 2026-12-01
|
|
4
9
|
|
|
5
10
|
- 文渊阁管理的 PMO 和成员会话在标题栏显示看板图标,点击直达该会话所属项目的看板。会话运行时图标有轻微脉冲,并遵循系统的减少动态效果设置。
|
package/README.md
CHANGED
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
|
|
38
38
|
## 最近更新
|
|
39
39
|
|
|
40
|
+
- **给成员装技能包**(0.4.150)。成员资料和新建人才可选择 DSH 已安装的技能。启用 Skill Station 后,也可在原表单导入整个目录、ZIP 或 `.skill`,安装完成后自动加入当前表单的技能列表。感谢 [@godfay-g](https://github.com/godfay-g),[#109](https://github.com/suifei/dsh-ai-team/issues/109)。
|
|
40
41
|
- **会话标题栏看板入口**(0.4.149)。文渊阁管理的 PMO 和成员会话会显示文渊阁图标,点击直达所属项目的看板。运行时的轻微脉冲遵循系统的减少动态效果设置。
|
|
41
42
|
- **安装指引与 503 提示**(0.4.148)。快速开始按入口使用内置 `desktop` 或 `web`。连接服务不可用时,工作台提示核对插件安装的 profile 和启动入口。感谢 [@Arnoldnuo](https://github.com/Arnoldnuo) 的反馈([#102](https://github.com/suifei/dsh-ai-team/issues/102))。
|
|
42
43
|
- **蓝图试跑与项目总览**(0.4.147)。新建项目可按星门项目的团队架构实践,先用两个岗位、一份真实样本跑通交付。开启 PMO 自动后,插件按实测证据派发、确认草稿和扩编复跑。工作台显示当前阶段和下一步,项目总览可查看验收、AI 协作与原始证据。
|
|
@@ -114,8 +115,9 @@ const svg = HashAvatar.svg('墨渊', { gender: 'male', age: 'middle', race: 'asi
|
|
|
114
115
|
- 团队 `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 位人才可在人才市场挑选、组合或自建。
|
|
115
116
|
- 「人员 → 添加成员」先打开人才市场:按分类、关键词挑一位,点「招聘」预填表单,改名、换模型后创建;也可以切到「自定义」从零填写。
|
|
116
117
|
- 自建:人才放 `~/.dsh/ai-team/catalog/user/talents/<人才>/`,团队放 `~/.dsh/ai-team/catalog/user/teams/<团队>/`,同名覆盖内置;插件设置 `teamPreset` 选新项目用哪个团队。
|
|
117
|
-
-
|
|
118
|
-
-
|
|
118
|
+
- 在「添加成员 → 新建人才」填写名号、岗位、职责、性格。可从现成人才复制技能、自写一份、导入 `.md`,或选择 DSH 已安装的技能。自带的 Markdown 技能保存在人才目录,DSH 技能以名称引用。
|
|
119
|
+
- 在成员资料或新建人才里可导入技能目录、ZIP 或 `.skill`。需在文渊阁所用的同一 profile 启用 Skill Station。桌面端可运行 `dsh plugin --profile desktop add dsh-skill-station`,本机 Web 用 `--profile web`。成员导入到已在 DSH 注册的工作区并直接分配技能。新建人才导入到个人技能,保存人才时记下引用。DSH 可读取包内的 `references/` 等相对资源。[Skill Station](https://github.com/WilShi/dsh-skill-station)
|
|
120
|
+
- 成员资料的「存为人才」可保存成员当前的岗位、职责、性格、模型和技能。DSH 技能保留引用,使用时由目标工作区解析。自带的 Markdown 技能随人才保存。新建或存为人才时,重名自动加序号。
|
|
119
121
|
- **组队、建项目选团队**:「新建项目」里选团队(内置或自建),按它种成员、负责人当主理人;「组一个新团队」从人才里挑人(同一人才可招多位)、指定负责人即可保存。插件设置 `teamPreset` 只是不选时的默认值。
|
|
120
122
|
- **改内置人才、进化技能**:内置人才点「复制为可编辑」得到同 id 的副本(随时「恢复内置」);成员资料里技能旁的「进化」会让该成员用 SkillOpt 优化那份技能——内置的先自动复制,插件里的原文件不动。
|
|
121
123
|
- **在线人才库同步**:人才市场顶部「同步在线库」从官方在线人才库 [`@suifei/dsh-ai-team-catalog`](https://www.npmjs.com/package/@suifei/dsh-ai-team-catalog)(npmmirror → jsDelivr → npmjs;registry 下整包核对 integrity)取最新的人才与团队,按 `index.json` 逐文件核对 sha256 后整体替换,落到 `~/.dsh/ai-team/catalog/official/<版本>/`;失败不动现有的。优先级:自建 > 在线 > 内置(插件升级后内置版本更高的人才用内置)。「退回内置」删掉本机在线库。内网可设环境变量 `DSH_AI_TEAM_CATALOG_MIRROR` 指向 npmmirror 同形的私有源。在线人才同样只读,可「复制为可编辑」。
|
|
@@ -358,6 +360,7 @@ round-19 DeepSeek + Zhipu 双 provider
|
|
|
358
360
|
|
|
359
361
|
| 贡献者 | 贡献 | 带来的进展 |
|
|
360
362
|
|---|---|---|
|
|
363
|
+
| [@godfay-g](https://github.com/godfay-g) | 技能目录和 ZIP 的导入建议 [#109](https://github.com/suifei/dsh-ai-team/issues/109) | 成员与自定义人才可在文渊阁选择已安装的技能或导入完整技能包 |
|
|
361
364
|
| [@qq958691165](https://github.com/qq958691165) | 归档项目的成员反馈、团队管理建议 [#103](https://github.com/suifei/dsh-ai-team/issues/103) | 人员池排除归档项目,侧栏集中管理项目成员与团队预设 |
|
|
362
365
|
| [@Arnoldnuo](https://github.com/Arnoldnuo) | 桌面端启动 503 反馈 [#102](https://github.com/suifei/dsh-ai-team/issues/102) | 工作台提供分情况的 503 提示,快速开始说明内置 `desktop` 与 `web` 的安装和启动方式,连接错误提示引导核对 profile |
|
|
363
366
|
| [@Lamooner](https://github.com/Lamooner) | PMO 决策反馈与建议 [#99](https://github.com/suifei/dsh-ai-team/issues/99) | 避免选中「不推荐」项,移除编号偏向并补充括注编号回归 |
|
package/client.js
CHANGED
|
@@ -340,6 +340,13 @@ window.__ModuleLoader__.load({
|
|
|
340
340
|
tcName: '名号', tcRole: '岗位', tcDuty: '职责', tcCategory: '分类', tcTags: '标签', tcTagsHint: '逗号分隔', tcPersonality: '性格', tcPersonalityHint: '它怎么做事、什么风格',
|
|
341
341
|
tcSkills: '技能', tcEmpty: '还没装技能(可选)', tcAddExisting: '从已有装', tcWriteOwn: '自写一份', tcImport: '导入 .md', tcPick: '选一个已有技能…', tcAdd: '加入', tcRemove: '移除',
|
|
342
342
|
tcSkillName: '技能名(英文/数字/-)', tcSkillBody: '技能正文(SKILL.md)', tcSkillDup: '已经装了同名技能', tcSave: '存为我的人才', tcSaving: '保存中…',
|
|
343
|
+
tcHostAdd: '添加 DSH 技能', tcHostPick: '选择已安装的技能', tcHostEmpty: '没有可添加的已安装技能', tcHostUnavailable: 'DSH 技能目录暂不可用,请确认宿主已加载技能服务后重试。',
|
|
344
|
+
tcHostFolder: '导入文件夹', tcHostArchive: '导入 ZIP / .skill', tcHostUserRoot: '完整技能包将安装到 DSH 个人技能目录。', tcHostProjectRoot: '完整技能包将安装到成员工作区的 DSH 技能目录。',
|
|
345
|
+
tcHostStationMissing: '导入完整技能包需要在当前 DSH profile 安装并启用 dsh-skill-station,启用后重新打开此处。',
|
|
346
|
+
tcHostLocalOnly: '请在 DSH 桌面版或本机 HTTP Web 页面打开文渊阁,即可导入完整技能包。', tcHostNoRoot: '请先在 DSH 打开成员的工作区,再导入工作区技能。',
|
|
347
|
+
tcHostFolderType: '请选择包含 SKILL.md 的技能文件夹。', tcHostArchiveType: '请选择 .zip 或 .skill 文件。', tcHostPackLarge: '技能包超过上传容量上限,请精简资源后重试。',
|
|
348
|
+
tcHostImporting: '正在安装技能包…', tcHostVerifying: '正在确认 DSH 已加载技能…', tcHostImportFailed: '技能包导入失败({error})',
|
|
349
|
+
tcHostConflict: '安装目录已存在同名技能 {name}。如需使用已安装的版本,请从上方选择。', tcHostUnseen: '已安装 {name},DSH 目录暂未识别此版本。请检查技能作用域,然后重新打开技能选择。',
|
|
343
350
|
memberSaveAsTalent: '存为人才', tcFromMember: '从成员「{name}」存出:沿用它此刻的岗位、职责、性格与技能,可先修改再保存。', tcModelKept: '沿用模型:{model}', tcMissing: '这些技能找不到正文,没有带上:{skills}', tcDraftFailed: '读取成员草稿失败:{error}',
|
|
344
351
|
teamManagement: '团队管理', teamManageGoal: '管理当前项目成员,或为新项目准备团队预设。', teamActiveProject: '当前项目成员', teamPickProject: '切换活动项目以管理成员', teamNoActiveProject: '请选择一个未归档的项目。', teamPresets: '团队预设', teamPresetHint: '预设用于新建项目,不会更改已创建的项目。', teamNoPresets: '没有可用的团队预设。',
|
|
345
352
|
projectTeam: '团队', teamCompose: '组一个新团队', teamComposeTitle: '组队', teamComposeHint: '从人才里挑人组队:同一人才可以招多位,给其中一位定为负责人(新项目的主理人)。', teamName: '团队名', teamDesc: '说明', teamMembers: '成员', teamPick: '从人才里挑人', teamAdd: '加入', teamLead: '负责人', teamEmptyPick: '还没挑人', teamSave: '保存团队', teamBack: '返回', teamDelete: '删除这个团队', teamDeleteConfirm: '删除自建团队「{name}」?团队文件会被删除,已用它建的项目和其中成员不受影响。', teamLoadFailed: '团队列表读取失败:{error}',
|
|
@@ -843,6 +850,13 @@ window.__ModuleLoader__.load({
|
|
|
843
850
|
tcName: 'Name', tcRole: 'Role', tcDuty: 'Duty', tcCategory: 'Category', tcTags: 'Tags', tcTagsHint: 'comma-separated', tcPersonality: 'Personality', tcPersonalityHint: 'how it works, its style',
|
|
844
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',
|
|
845
852
|
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
|
+
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
|
+
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
|
+
tcHostStationMissing: 'To import a skill package, install and enable dsh-skill-station in this DSH profile, then reopen this dialog.',
|
|
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.',
|
|
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…', tcHostVerifying: 'Waiting for DSH to load the skill…', tcHostImportFailed: 'Skill package import failed ({error})',
|
|
859
|
+
tcHostConflict: 'The install directory already contains {name}. Choose it above to use the installed version.', tcHostUnseen: '{name} was installed, but the DSH catalog has yet to recognize this version. Check the skill scope and reopen the picker.',
|
|
846
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}',
|
|
847
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.',
|
|
848
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}',
|
|
@@ -1628,6 +1642,7 @@ window.__ModuleLoader__.load({
|
|
|
1628
1642
|
.at-tcskill button { border: 0; background: transparent; cursor: pointer; font-size: 14px; line-height: 1; color: inherit; padding: 0; }
|
|
1629
1643
|
.at-tcpick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
|
|
1630
1644
|
.at-tcpanel { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
|
|
1645
|
+
.at-hostskillpicker .at-modalmeta, .at-hostskillpicker .at-modalerror { overflow-wrap: anywhere; }
|
|
1631
1646
|
.at-teamrows { display: flex; flex-direction: column; gap: 6px; }
|
|
1632
1647
|
.at-teamrow { display: grid; grid-template-columns: 24px minmax(0, 1fr) 76px auto auto; gap: 8px; align-items: center; }
|
|
1633
1648
|
.at-teamrow > .at-modalmeta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
@@ -3386,6 +3401,186 @@ window.__ModuleLoader__.load({
|
|
|
3386
3401
|
talent.forked && onRestore ? h('button', { type: 'button', className: 'at-btn at-btn-small', onClick: () => onRestore(talent) }, withIco('undo', t('talentRestore'), 12)) : null,
|
|
3387
3402
|
h('button', { type: 'button', className: 'at-btn at-btn-small at-btn-primary', onClick: () => onHire(talent) }, withIco('userPlus', t('talentHire'), 12))))))));
|
|
3388
3403
|
}
|
|
3404
|
+
// <host-skill-import>
|
|
3405
|
+
const SKILL_STATION_API = '/skill-station/api';
|
|
3406
|
+
const SKILL_PACK_LIMIT = 64 * 1024 * 1024;
|
|
3407
|
+
function hostSkillCatalogPath(projectId, memberId, refresh = false) {
|
|
3408
|
+
const params = new URLSearchParams();
|
|
3409
|
+
if (projectId) params.set('project', projectId);
|
|
3410
|
+
if (memberId) params.set('member', memberId);
|
|
3411
|
+
if (refresh) params.set('refresh', '1');
|
|
3412
|
+
return '/ai-team/api/host-skills' + (params.size ? '?' + params : '');
|
|
3413
|
+
}
|
|
3414
|
+
function skillStationAllowsUpload({ protocol, hostname }) {
|
|
3415
|
+
return (protocol === 'dsh-app:' && hostname === 'app')
|
|
3416
|
+
|| (protocol === 'http:' && ['localhost', '127.0.0.1', '[::1]'].includes(hostname));
|
|
3417
|
+
}
|
|
3418
|
+
function readSkillFileBase64(file) {
|
|
3419
|
+
return new Promise((resolve, reject) => {
|
|
3420
|
+
const reader = new FileReader();
|
|
3421
|
+
reader.onerror = () => reject(reader.error);
|
|
3422
|
+
reader.onload = () => resolve(String(reader.result).split(',', 2)[1]);
|
|
3423
|
+
reader.readAsDataURL(file);
|
|
3424
|
+
});
|
|
3425
|
+
}
|
|
3426
|
+
async function skillPackRequest({ workspace, targetRoot }, mode, files) {
|
|
3427
|
+
const payload = { targetRoot, conflict: 'skip', ...(workspace ? { workspace } : {}) };
|
|
3428
|
+
if (mode === 'folder') {
|
|
3429
|
+
if (files.some((file) => !file.webkitRelativePath)) throw new Error('tcHostFolderType');
|
|
3430
|
+
payload.files = files.map((file) => ({ path: file.webkitRelativePath, contentBase64: '' }));
|
|
3431
|
+
} else {
|
|
3432
|
+
if (!/\.(zip|skill)$/i.test(files[0]?.name ?? '')) throw new Error('tcHostArchiveType');
|
|
3433
|
+
payload.zipBase64 = '';
|
|
3434
|
+
}
|
|
3435
|
+
const metadataBytes = new TextEncoder().encode(JSON.stringify(payload)).length;
|
|
3436
|
+
const contentBytes = files.reduce((sum, file) => sum + Math.ceil(file.size / 3) * 4, 0);
|
|
3437
|
+
if (metadataBytes + contentBytes > SKILL_PACK_LIMIT) throw new Error('tcHostPackLarge');
|
|
3438
|
+
if (mode === 'folder') {
|
|
3439
|
+
for (const [index, file] of files.entries()) payload.files[index].contentBase64 = await readSkillFileBase64(file);
|
|
3440
|
+
} else {
|
|
3441
|
+
payload.zipBase64 = await readSkillFileBase64(files[0]);
|
|
3442
|
+
}
|
|
3443
|
+
return JSON.stringify(payload);
|
|
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
|
+
// </host-skill-import>
|
|
3450
|
+
|
|
3451
|
+
/** 人才和成员共用的 DSH 技能入口。整包由宿主同 profile 的 Skill Station 安装。 */
|
|
3452
|
+
function HostSkillPicker({ t, projectId, memberId, selectedNames = [], disabled, onChoose }) {
|
|
3453
|
+
const [open, setOpen] = React.useState(false);
|
|
3454
|
+
const [catalog, setCatalog] = React.useState(null);
|
|
3455
|
+
const [station, setStation] = React.useState(null);
|
|
3456
|
+
const [selected, setSelected] = React.useState('');
|
|
3457
|
+
const [busy, setBusy] = React.useState(false);
|
|
3458
|
+
const [progress, setProgress] = React.useState('');
|
|
3459
|
+
const [error, setError] = React.useState('');
|
|
3460
|
+
const trigger = React.useRef(null);
|
|
3461
|
+
const folderInput = React.useRef(null);
|
|
3462
|
+
const archiveInput = React.useRef(null);
|
|
3463
|
+
const active = React.useRef(null);
|
|
3464
|
+
const path = hostSkillCatalogPath(projectId, memberId);
|
|
3465
|
+
const canUpload = skillStationAllowsUpload(window.location);
|
|
3466
|
+
async function readCatalog(signal, refresh = false) {
|
|
3467
|
+
const catalogPath = refresh ? hostSkillCatalogPath(projectId, memberId, true) : path;
|
|
3468
|
+
const response = await fetch(catalogPath, { signal, headers: { accept: 'application/json' }, cache: 'no-store' });
|
|
3469
|
+
const body = await response.json().catch(() => null);
|
|
3470
|
+
if (!response.ok || !Array.isArray(body?.skills)) throw new Error('tcHostUnavailable');
|
|
3471
|
+
return body;
|
|
3472
|
+
}
|
|
3473
|
+
React.useEffect(() => {
|
|
3474
|
+
if (!open) return;
|
|
3475
|
+
const controller = new AbortController();
|
|
3476
|
+
const { signal } = controller;
|
|
3477
|
+
active.current = controller;
|
|
3478
|
+
readCatalog(signal).then((body) => {
|
|
3479
|
+
if (!signal.aborted) setCatalog(body);
|
|
3480
|
+
}).catch(() => {
|
|
3481
|
+
if (!signal.aborted) setCatalog(false);
|
|
3482
|
+
});
|
|
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
|
+
return () => { controller.abort(); active.current = null; };
|
|
3487
|
+
}, [open, path, canUpload]);
|
|
3488
|
+
const choices = (catalog?.skills ?? []).filter((skill) => !selectedNames.includes(skill.name));
|
|
3489
|
+
const choice = choices.find((skill) => skill.name === selected);
|
|
3490
|
+
const importHint = !canUpload ? 'tcHostLocalOnly' : !catalog?.targetRoot ? 'tcHostNoRoot' : station === false ? 'tcHostStationMissing' : '';
|
|
3491
|
+
function show() {
|
|
3492
|
+
setCatalog(null);
|
|
3493
|
+
setStation(null);
|
|
3494
|
+
setSelected('');
|
|
3495
|
+
setError('');
|
|
3496
|
+
setOpen(true);
|
|
3497
|
+
}
|
|
3498
|
+
function dismiss() {
|
|
3499
|
+
setOpen(false);
|
|
3500
|
+
trigger.current?.focus({ preventScroll: true });
|
|
3501
|
+
}
|
|
3502
|
+
async function choose(name) {
|
|
3503
|
+
if (selectedNames.includes(name) || await onChoose(name) === false) throw new Error(t('tcSkillDup'));
|
|
3504
|
+
}
|
|
3505
|
+
async function perform(action) {
|
|
3506
|
+
const signal = active.current?.signal;
|
|
3507
|
+
if (busy || !signal) return;
|
|
3508
|
+
setBusy(true);
|
|
3509
|
+
setError('');
|
|
3510
|
+
try {
|
|
3511
|
+
await action(signal);
|
|
3512
|
+
if (!signal.aborted) dismiss();
|
|
3513
|
+
} catch (err) {
|
|
3514
|
+
const message = err?.message || String(err);
|
|
3515
|
+
if (!signal.aborted) setError(message.startsWith('tcHost') ? t(message) : message);
|
|
3516
|
+
} finally {
|
|
3517
|
+
if (!signal.aborted) { setBusy(false); setProgress(''); }
|
|
3518
|
+
}
|
|
3519
|
+
}
|
|
3520
|
+
function importPack(event, mode) {
|
|
3521
|
+
const files = Array.from(event.target.files ?? []);
|
|
3522
|
+
event.target.value = '';
|
|
3523
|
+
if (!files.length || importHint || !station) return;
|
|
3524
|
+
void perform(async (signal) => {
|
|
3525
|
+
setProgress('tcHostImporting');
|
|
3526
|
+
const body = await skillPackRequest(catalog, mode, files);
|
|
3527
|
+
const response = await fetch(SKILL_STATION_API + (mode === 'folder' ? '/upload' : '/upload-zip'), {
|
|
3528
|
+
method: 'POST', signal, headers: { 'content-type': 'application/json', accept: 'application/json' }, body,
|
|
3529
|
+
});
|
|
3530
|
+
const result = await response.json().catch(() => null);
|
|
3531
|
+
const outcome = result?.outcome;
|
|
3532
|
+
if (response.status === 403) throw new Error('tcHostLocalOnly');
|
|
3533
|
+
if (response.status === 404) throw new Error('tcHostStationMissing');
|
|
3534
|
+
if (response.status === 413) throw new Error('tcHostPackLarge');
|
|
3535
|
+
if (result?.code === 'UNKNOWN_WORKSPACE') throw new Error('tcHostNoRoot');
|
|
3536
|
+
if (response.ok && outcome?.status === 'skipped' && outcome.name && !outcome.error) {
|
|
3537
|
+
if (!hostSkillIsVisible(catalog, outcome.name, catalog.targetRoot)) {
|
|
3538
|
+
const refreshed = await readCatalog(signal, true).catch(() => null);
|
|
3539
|
+
if (refreshed && !signal.aborted) setCatalog(refreshed);
|
|
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 }));
|
|
3545
|
+
}
|
|
3546
|
+
setProgress('tcHostVerifying');
|
|
3547
|
+
for (let attempt = 0; attempt < 12 && !signal.aborted; attempt++) {
|
|
3548
|
+
if (attempt) await new Promise((resolve) => setTimeout(resolve, 250));
|
|
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
|
+
}
|
|
3556
|
+
}
|
|
3557
|
+
throw new Error(tf(t, 'tcHostUnseen', { name: outcome.name }));
|
|
3558
|
+
});
|
|
3559
|
+
}
|
|
3560
|
+
const close = () => { if (!busy) dismiss(); };
|
|
3561
|
+
return h(React.Fragment, null,
|
|
3562
|
+
h('button', { ref: trigger, type: 'button', className: 'at-btn', disabled, 'aria-haspopup': 'dialog', onClick: show }, withIco('plus', t('tcHostAdd'))),
|
|
3563
|
+
open ? h(ModalBack, { onClose: close }, h('div', { className: 'at-modal at-hostskillpicker', role: 'dialog', 'aria-modal': 'true', 'aria-label': t('tcHostAdd') },
|
|
3564
|
+
h('h2', { className: 'at-modaltitle' }, t('tcHostAdd')),
|
|
3565
|
+
h('div', { className: 'at-modalactions' }, h('button', { type: 'button', className: 'at-btn', onClick: close, disabled: busy, autoFocus: true }, withIco('close', t('cancel')))),
|
|
3566
|
+
catalog === null ? h('div', { className: 'at-modalmeta', role: 'status' }, t('loading'))
|
|
3567
|
+
: catalog === false ? h('div', { className: 'at-modalerror', role: 'alert' }, t('tcHostUnavailable'))
|
|
3568
|
+
: h('div', { className: 'at-field' },
|
|
3569
|
+
h('select', { value: selected, 'aria-label': t('tcHostPick'), onChange: (event) => setSelected(event.target.value), disabled: busy || !choices.length },
|
|
3570
|
+
h('option', { value: '' }, t(choices.length ? 'tcHostPick' : 'tcHostEmpty')),
|
|
3571
|
+
choices.map((skill) => h('option', { key: skill.name, value: skill.name }, skill.name))),
|
|
3572
|
+
choice?.description ? h('div', { className: 'at-modalmeta' }, choice.description) : null,
|
|
3573
|
+
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
|
+
catalog && (importHint ? h('div', { className: 'at-modalmeta' }, t(importHint)) : station && h('div', { className: 'at-field' },
|
|
3575
|
+
h('div', { className: 'at-modalmeta' }, t(catalog.workspace ? 'tcHostProjectRoot' : 'tcHostUserRoot')),
|
|
3576
|
+
h('input', { ref: folderInput, type: 'file', webkitdirectory: '', multiple: true, hidden: true, 'aria-label': t('tcHostFolder'), onChange: (event) => importPack(event, 'folder') }),
|
|
3577
|
+
h('input', { ref: archiveInput, type: 'file', accept: '.zip,.skill,application/zip', hidden: true, 'aria-label': t('tcHostArchive'), onChange: (event) => importPack(event, 'archive') }),
|
|
3578
|
+
h('div', { className: 'at-tcpick' },
|
|
3579
|
+
h('button', { type: 'button', className: 'at-btn', disabled: busy, onClick: () => folderInput.current?.click() }, withIco('folderPlus', t('tcHostFolder'))),
|
|
3580
|
+
h('button', { type: 'button', className: 'at-btn', disabled: busy, onClick: () => archiveInput.current?.click() }, t('tcHostArchive'))))),
|
|
3581
|
+
progress ? h('div', { className: 'at-modalmeta', role: 'status' }, t(progress)) : null,
|
|
3582
|
+
error ? h('div', { className: 'at-modalerror', role: 'alert' }, error) : null)) : null);
|
|
3583
|
+
}
|
|
3389
3584
|
function TalentCreator({ t, initial, onSaved, onCancel }) {
|
|
3390
3585
|
const seed = initial && initial.draft ? talentCreatorInit(initial) : null;
|
|
3391
3586
|
const [form, setForm] = React.useState(() => (seed ? seed.form : blankTalentForm()));
|
|
@@ -3397,6 +3592,8 @@ window.__ModuleLoader__.load({
|
|
|
3397
3592
|
const [skBody, setSkBody] = React.useState('');
|
|
3398
3593
|
const [busy, setBusy] = React.useState(false);
|
|
3399
3594
|
const [error, setError] = React.useState('');
|
|
3595
|
+
const savedId = React.useRef('');
|
|
3596
|
+
const writtenSkills = React.useRef(new WeakSet());
|
|
3400
3597
|
const set = (key) => (event) => setForm((f) => ({ ...f, [key]: event.target.value }));
|
|
3401
3598
|
React.useEffect(() => {
|
|
3402
3599
|
let live = true;
|
|
@@ -3431,15 +3628,22 @@ window.__ModuleLoader__.load({
|
|
|
3431
3628
|
if (!form.name.trim() || busy) return;
|
|
3432
3629
|
setBusy(true); setError('');
|
|
3433
3630
|
try {
|
|
3434
|
-
const res = await fetch('/ai-team/api/talents', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({
|
|
3631
|
+
const res = await fetch('/ai-team/api/talents', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({
|
|
3632
|
+
...talentFormToBody(form),
|
|
3633
|
+
...(seed?.model ? { model: seed.model } : {}),
|
|
3634
|
+
...(savedId.current ? { id: savedId.current, overwrite: true } : {}),
|
|
3635
|
+
skills: pending.filter((sk) => sk.kind === 'host' || writtenSkills.current.has(sk)).map((sk) => sk.name),
|
|
3636
|
+
}) });
|
|
3435
3637
|
const body = await res.json().catch(() => null);
|
|
3436
3638
|
if (!res.ok) throw new Error((body && body.error && body.error.message) || ('HTTP ' + res.status));
|
|
3437
|
-
|
|
3639
|
+
savedId.current = body.talent.id;
|
|
3438
3640
|
for (const sk of pending) {
|
|
3641
|
+
if (sk.kind === 'host' || writtenSkills.current.has(sk)) continue;
|
|
3439
3642
|
const payload = sk.kind === 'fork' ? { name: sk.name, fromTalent: sk.fromTalent, fromSkill: sk.fromSkill } : sk.kind === 'member' ? { name: sk.name, fromProject: sk.fromProject, fromMember: sk.fromMember } : { name: sk.name, markdown: sk.markdown };
|
|
3440
|
-
const r2 = await fetch('/ai-team/api/talents/' + encodeURIComponent(
|
|
3643
|
+
const r2 = await fetch('/ai-team/api/talents/' + encodeURIComponent(savedId.current) + '/skills', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(payload) });
|
|
3441
3644
|
const b2 = await r2.json().catch(() => null);
|
|
3442
3645
|
if (!r2.ok) throw new Error(((b2 && b2.error && b2.error.message) || ('HTTP ' + r2.status)) + '(' + sk.name + ')');
|
|
3646
|
+
writtenSkills.current.add(sk);
|
|
3443
3647
|
}
|
|
3444
3648
|
onSaved();
|
|
3445
3649
|
} catch (err) {
|
|
@@ -3466,6 +3670,7 @@ window.__ModuleLoader__.load({
|
|
|
3466
3670
|
h('div', { className: 'at-field' }, h('span', null, t('tcSkills')),
|
|
3467
3671
|
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)) }, '×')))),
|
|
3468
3672
|
h('div', { className: 'at-tcpick' },
|
|
3673
|
+
h(HostSkillPicker, { t, selectedNames: pending.map((skill) => skill.name), disabled: busy, onChoose: (name) => stage({ name, kind: 'host' }) }),
|
|
3469
3674
|
h('button', { type: 'button', className: 'at-btn', onClick: () => setPick(pick === 'existing' ? '' : 'existing') }, withIco('store', t('tcAddExisting'))),
|
|
3470
3675
|
h('button', { type: 'button', className: 'at-btn', onClick: () => setPick(pick === 'write' ? '' : 'write') }, withIco('pen', t('tcWriteOwn'))),
|
|
3471
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 }))),
|
|
@@ -3876,14 +4081,16 @@ window.__ModuleLoader__.load({
|
|
|
3876
4081
|
};
|
|
3877
4082
|
}
|
|
3878
4083
|
/**
|
|
3879
|
-
*
|
|
4084
|
+
* 「存为人才」:保留宿主技能引用,暂存可从成员复制的技能,单列找不到的技能。
|
|
3880
4085
|
*/
|
|
3881
4086
|
function talentCreatorInit(initial) {
|
|
3882
4087
|
const draft = (initial && initial.draft) || {};
|
|
3883
4088
|
const skills = Array.isArray(draft.skills) ? draft.skills : [];
|
|
3884
4089
|
return {
|
|
3885
4090
|
form: { name: String(draft.name || ''), role: String(draft.role || ''), duty: ['lead', 'qa', 'executor'].includes(draft.duty) ? draft.duty : 'executor', category: String(draft.category || ''), tags: (Array.isArray(draft.tags) ? draft.tags : []).join(', '), personality: String(draft.personality || ''), avatar: draft.avatar ? { ...draft.avatar } : { ...AVATAR_PICK_DEFAULT } },
|
|
3886
|
-
pending: skills.filter((x) => x && x.found).map((x) =>
|
|
4091
|
+
pending: skills.filter((x) => x && x.found).map((x) => x.host === true
|
|
4092
|
+
? { name: x.name, kind: 'host' }
|
|
4093
|
+
: { name: x.name, kind: 'member', fromProject: initial.projectId, fromMember: initial.memberId }),
|
|
3887
4094
|
missing: skills.filter((x) => x && !x.found).map((x) => x.name),
|
|
3888
4095
|
model: draft.model && (draft.model.provider || draft.model.model) ? draft.model : null,
|
|
3889
4096
|
sourceName: String(draft.name || ''),
|
|
@@ -5307,15 +5514,25 @@ window.__ModuleLoader__.load({
|
|
|
5307
5514
|
setPError(error?.message ?? String(error));
|
|
5308
5515
|
}
|
|
5309
5516
|
}
|
|
5310
|
-
async function addSkill() {
|
|
5311
|
-
|
|
5517
|
+
async function addSkill(name) {
|
|
5518
|
+
const memberId = profileAgent?.id;
|
|
5519
|
+
name = name.trim();
|
|
5520
|
+
if (!memberId || !name) return false;
|
|
5521
|
+
setPError('');
|
|
5522
|
+
const result = await runCommand('member.skill', { memberId, name });
|
|
5523
|
+
setProfileAgent((current) => current?.id === memberId ? result.member : current);
|
|
5524
|
+
void reloadData().catch((error) => setPError(error?.message ?? String(error)));
|
|
5525
|
+
return true;
|
|
5526
|
+
}
|
|
5527
|
+
async function addTypedSkill() {
|
|
5528
|
+
if (pBusy) return;
|
|
5529
|
+
setPBusy(true);
|
|
5312
5530
|
try {
|
|
5313
|
-
|
|
5314
|
-
setPSkill('');
|
|
5315
|
-
setProfileAgent(result.member);
|
|
5316
|
-
await reloadData();
|
|
5531
|
+
if (await addSkill(pSkill)) setPSkill('');
|
|
5317
5532
|
} catch (error) {
|
|
5318
5533
|
setPError(error?.message ?? String(error));
|
|
5534
|
+
} finally {
|
|
5535
|
+
setPBusy(false);
|
|
5319
5536
|
}
|
|
5320
5537
|
}
|
|
5321
5538
|
async function retryProfile() {
|
|
@@ -6274,9 +6491,11 @@ window.__ModuleLoader__.load({
|
|
|
6274
6491
|
h('button', { type: 'button', className: 'at-btn at-btn-small', title: t('skillEvolveHint'), onClick: () => void evolveSkill(profileAgent, name) }, withIco('spark', t('skillEvolve'), 12)))))
|
|
6275
6492
|
: h('div', { key: 'none', className: 'at-modalmeta' }, t('profileSkillsEmpty')),
|
|
6276
6493
|
pEvolve ? h('div', { key: 'ev', className: 'at-modalmeta', role: 'status' }, pEvolve) : null,
|
|
6494
|
+
h('div', { key: 'dsh-' + projectId + '/' + profileAgent.id, className: 'at-tcpick' },
|
|
6495
|
+
h(HostSkillPicker, { t, projectId, memberId: profileAgent.id, selectedNames: profileAgent.skills, disabled: pBusy, onChoose: addSkill })),
|
|
6277
6496
|
h('div', { key: 'add', className: 'at-inlineadd' },
|
|
6278
6497
|
h('input', { value: pSkill, onChange: (event) => setPSkill(event.target.value), placeholder: t('skillPlaceholder') }),
|
|
6279
|
-
h('button', { className: 'at-btn at-btn-small', type: 'button', onClick:
|
|
6498
|
+
h('button', { className: 'at-btn at-btn-small', type: 'button', onClick: addTypedSkill, disabled: pBusy || !pSkill.trim() }, withIco('plus', t('addSkill'), 12))),
|
|
6280
6499
|
] : null,
|
|
6281
6500
|
pTab === 'collab' ? [
|
|
6282
6501
|
h('label', { key: 'succ', className: 'at-field' }, h('span', null, t('successor')),
|
package/index.js
CHANGED
|
@@ -12,7 +12,7 @@ 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, sep } from 'node:path';
|
|
15
|
+
import { join, resolve, sep } from 'node:path';
|
|
16
16
|
import { fileURLToPath } from 'node:url';
|
|
17
17
|
import { existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from 'node:fs';
|
|
18
18
|
import z from '@deepseek-ai/schemastery';
|
|
@@ -31,7 +31,7 @@ import { memberIdentity } from './lib/domain/member-profile.js';
|
|
|
31
31
|
import { blocksBlueprintTask, blueprintFingerprint, blueprintUseCases, buildTeamBlueprint, renderTeamBlueprint } from './lib/domain/team-blueprint.js';
|
|
32
32
|
import { findSkill, findSkillText, loadSkillContext } from './lib/runtime/skill-loader.js';
|
|
33
33
|
import { skillKindForMember } from './lib/runtime/core-skill.js';
|
|
34
|
-
import {
|
|
34
|
+
import { formatSkillSummaries, modelInvocableSkills, readSkillCatalog } from './lib/runtime/skill-catalog.js';
|
|
35
35
|
import { isSkillExcluded } from './lib/runtime/skill-policy.js';
|
|
36
36
|
import { installFileSkillProvider, pickProjectForCwd } from './lib/runtime/skill-provider.js';
|
|
37
37
|
import { apply as applySkillOpt } from './lib/vendor/skillopt/src/index.js';
|
|
@@ -150,14 +150,28 @@ function memberCatalogDirs(member, diag) {
|
|
|
150
150
|
return talent === undefined ? [] : [talent.dir];
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
+
function memberWorkspace(member, runtime) {
|
|
154
|
+
const workspacePath = runtime?.service?.state?.projects?.[runtime.id]?.workspacePath;
|
|
155
|
+
return member?.workspace || (typeof workspacePath === 'string' ? workspacePath.trim() : '');
|
|
156
|
+
}
|
|
157
|
+
|
|
153
158
|
/**
|
|
154
159
|
* 成员技能的查找根(团队规程目录另由 preset 前置):人才自带 → 工作区 `.dsh` → 用户 `~/.dsh` → 项目数据目录。
|
|
155
|
-
*
|
|
160
|
+
* 用于兼容宿主技能目录之外的 Markdown。
|
|
156
161
|
*/
|
|
157
|
-
function memberSkillRoots(member, runtime, diag) {
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
162
|
+
function memberSkillRoots(member, runtime, diag, talentRoots = memberCatalogDirs(member, diag)) {
|
|
163
|
+
const dir = memberWorkspace(member, runtime);
|
|
164
|
+
return [...talentRoots, ...(dir ? [join(dir, '.dsh')] : []), dshHome(), runtime?.dir].filter((root) => typeof root === 'string' && root !== '');
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** 团队、人才自带 Markdown 仍优先;注册表里的整包通过宿主 skill 工具加载。 */
|
|
168
|
+
async function memberHostSkillReferences(names, ownedRoots, summaries) {
|
|
169
|
+
const registered = new Set(summaries.map((skill) => skill?.name));
|
|
170
|
+
const references = new Set();
|
|
171
|
+
for (const name of names) {
|
|
172
|
+
if (registered.has(name) && await findSkill(ownedRoots, name) === null) references.add(name);
|
|
173
|
+
}
|
|
174
|
+
return references;
|
|
161
175
|
}
|
|
162
176
|
|
|
163
177
|
/** 新项目用哪个团队:新建时选的优先,其次插件设置 `teamPreset`,最后内置默认团队。 */
|
|
@@ -1573,6 +1587,17 @@ export function apply(ctx, config = {}) {
|
|
|
1573
1587
|
|
|
1574
1588
|
const skillsService = serviceOf(ctx, 'skills');
|
|
1575
1589
|
let disposeSkillProvider = () => {};
|
|
1590
|
+
const lookupHostSkills = async (cwd, { requireRegistry = false, refresh = false } = {}) => {
|
|
1591
|
+
try {
|
|
1592
|
+
const skills = serviceOf(ctx, 'skills');
|
|
1593
|
+
if (requireRegistry && typeof skills?.list !== 'function') throw new Error('DSH skill registry is unavailable');
|
|
1594
|
+
if (refresh) disposeSkillProvider.invalidate?.();
|
|
1595
|
+
return await readSkillCatalog(skills, { cwd });
|
|
1596
|
+
} catch (error) {
|
|
1597
|
+
diag.append({ ev: 'skill.catalog.fail', cwd, message: error?.message ?? String(error) });
|
|
1598
|
+
return null;
|
|
1599
|
+
}
|
|
1600
|
+
};
|
|
1576
1601
|
try {
|
|
1577
1602
|
// A vendor failure must never fail composition activation: that left
|
|
1578
1603
|
// fresh installs with a half-activated host until a process restart.
|
|
@@ -2193,8 +2218,7 @@ export function apply(ctx, config = {}) {
|
|
|
2193
2218
|
// 无目录项目 fail-closed:成员绝不落到宿主默认目录或插件数据目录
|
|
2194
2219
|
// (projectCwd 的 dir 兜底)里执行。显式判工作目录,不吃兜底。
|
|
2195
2220
|
// 先于 reseat 释放旧句柄——否则无目录的 force 会先杀句柄再 409。
|
|
2196
|
-
const
|
|
2197
|
-
const effectiveDir = member?.workspace || (typeof workspacePath === 'string' ? workspacePath.trim() : '');
|
|
2221
|
+
const effectiveDir = memberWorkspace(member, projectRuntime);
|
|
2198
2222
|
if (effectiveDir === '') {
|
|
2199
2223
|
diag?.append({ ev: 'activate.reject', projectId: projectRuntime.id, memberId: member.id, code: 'E_WORKSPACE_REQUIRED' });
|
|
2200
2224
|
return {
|
|
@@ -2262,17 +2286,34 @@ export function apply(ctx, config = {}) {
|
|
|
2262
2286
|
cwd: effectiveDir,
|
|
2263
2287
|
});
|
|
2264
2288
|
const blueprintRole = project?.blueprint?.roles.find((role) => role.id === member.id);
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2289
|
+
let skillContext;
|
|
2290
|
+
let promptMember = activationMember;
|
|
2291
|
+
if (blueprintRole) {
|
|
2292
|
+
skillContext = `\n\n${blueprintRole.prompt}`;
|
|
2293
|
+
} else {
|
|
2294
|
+
const preset = resolveTeam(talentCatalog(diag), activationMember.team ?? DEFAULT_TEAM, { diag });
|
|
2295
|
+
const assigned = Array.isArray(activationMember.skills) ? activationMember.skills : [];
|
|
2296
|
+
const summaries = await lookupHostSkills(effectiveDir);
|
|
2297
|
+
const talentRoots = memberCatalogDirs(activationMember, diag);
|
|
2298
|
+
const references = await memberHostSkillReferences(assigned, [preset.dir, ...talentRoots], summaries ?? []);
|
|
2299
|
+
const modelSkills = new Set(modelInvocableSkills(summaries ?? []).map((skill) => skill.name));
|
|
2300
|
+
promptMember = {
|
|
2301
|
+
...activationMember,
|
|
2302
|
+
skills: assigned.filter((name) => !isSkillExcluded(name) && (!references.has(name) || modelSkills.has(name))),
|
|
2303
|
+
};
|
|
2304
|
+
const dshSummaries = (summaries ?? []).filter((skill) => !assigned.includes(skill?.name) || references.has(skill.name));
|
|
2305
|
+
const dshSkills = formatSkillSummaries(dshSummaries, { assigned: [...references] });
|
|
2306
|
+
const inlineMember = { ...promptMember, skills: promptMember.skills.filter((name) => !references.has(name)) };
|
|
2307
|
+
const roots = summaries === null ? [...talentRoots, projectRuntime.dir] : memberSkillRoots(activationMember, projectRuntime, diag, talentRoots);
|
|
2308
|
+
skillContext = dshSkills + await loadSkillContext(inlineMember, roots, {
|
|
2268
2309
|
vars: { GOAL: goalForProject(projectRuntime), PROJECT: project?.name ?? '', MEMBER: activationMember.name ?? '', WORKSPACE: effectiveDir },
|
|
2269
|
-
preset
|
|
2310
|
+
preset,
|
|
2270
2311
|
ownerId: project?.ownerMemberId ?? project?.ownerId,
|
|
2271
|
-
})
|
|
2272
|
-
|
|
2312
|
+
});
|
|
2313
|
+
}
|
|
2273
2314
|
const result = await runtime.activate(activationMember, {
|
|
2274
2315
|
// #65:激活时若带着 Human 消息的图片/文件,一并放进首条消息。
|
|
2275
|
-
prompt: messageContent(`${memberIdentity(
|
|
2316
|
+
prompt: messageContent(`${memberIdentity(promptMember)}\n\n${typeof body.payload?.prompt === 'string'
|
|
2276
2317
|
? body.payload.prompt
|
|
2277
2318
|
: '你被加入 AI Team。先读取项目简报与收件箱,再处理分配给你的任务。'}${skillContext}`, body.payload?.attachments),
|
|
2278
2319
|
});
|
|
@@ -2513,6 +2554,43 @@ export function apply(ctx, config = {}) {
|
|
|
2513
2554
|
get: await skillsService.get('distilly', {}).then((skill) => skill?.name ?? null).catch(() => null),
|
|
2514
2555
|
});
|
|
2515
2556
|
}
|
|
2557
|
+
if (req.method === 'GET' && url.pathname === '/ai-team/api/host-skills') {
|
|
2558
|
+
const projectId = url.searchParams.get('project');
|
|
2559
|
+
const memberId = url.searchParams.get('member');
|
|
2560
|
+
if (projectId === null && memberId !== null) return send(res, { error: { code: 'E_INVALID_ARGUMENT', message: 'project is required with member' } }, 400);
|
|
2561
|
+
let workspace = null;
|
|
2562
|
+
let targetRoot = projectId === null ? 'user-dsh' : null;
|
|
2563
|
+
if (projectId !== null) {
|
|
2564
|
+
const runtime = projectRuntime(projectId);
|
|
2565
|
+
if (runtime === null) return send(res, { error: { code: 'NOT_FOUND', message: 'project not found' } }, 404);
|
|
2566
|
+
const member = memberId === null ? undefined : runtime.service.state.members?.[memberId];
|
|
2567
|
+
if (memberId !== null && member?.kind !== 'agent') return send(res, { error: { code: 'NOT_FOUND', message: 'member not found' } }, 404);
|
|
2568
|
+
workspace = memberWorkspace(member, runtime) || null;
|
|
2569
|
+
if (workspace !== null) {
|
|
2570
|
+
try {
|
|
2571
|
+
// Skill Station only accepts an exact registered workspace path.
|
|
2572
|
+
const registered = await serviceOf(ctx, 'workspaceRegistry')?.resolveByPath?.(workspace);
|
|
2573
|
+
if (typeof registered?.path === 'string' && registered.path !== '') {
|
|
2574
|
+
workspace = registered.path;
|
|
2575
|
+
targetRoot = `project-dsh:${resolve(workspace)}`;
|
|
2576
|
+
}
|
|
2577
|
+
} catch (error) {
|
|
2578
|
+
diag.append({ ev: 'skill.workspace.fail', projectId, workspace, message: error?.message ?? String(error) });
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
}
|
|
2582
|
+
// Give the personal view an explicit cwd so the fallback provider cannot adopt the host's startup project.
|
|
2583
|
+
// After an upload, refresh the catalog even if the workspace is nested below the official watcher root.
|
|
2584
|
+
const summaries = await lookupHostSkills(workspace ?? dshHome(), {
|
|
2585
|
+
requireRegistry: true, refresh: url.searchParams.get('refresh') === '1',
|
|
2586
|
+
});
|
|
2587
|
+
if (summaries === null) return send(res, { error: { code: 'E_RUNTIME_UNAVAILABLE', message: 'DSH skill catalog is unavailable' } }, 503);
|
|
2588
|
+
const skills = modelInvocableSkills(summaries)
|
|
2589
|
+
.filter((skill) => workspace !== null || !skill.source?.startsWith('project-'))
|
|
2590
|
+
.map((skill) => ({ name: skill.name, description: skill.description ?? '', source: skill.source ?? '' }));
|
|
2591
|
+
diag.append({ ev: 'skill.catalog', projectId, memberId, workspace, targetRoot, count: skills.length });
|
|
2592
|
+
return send(res, { skills, workspace, targetRoot });
|
|
2593
|
+
}
|
|
2516
2594
|
// 人才市场:「添加成员」弹窗里可招聘的人才(用户自建优先于内置)。
|
|
2517
2595
|
if (req.method === 'GET' && url.pathname === '/ai-team/api/talents') {
|
|
2518
2596
|
return send(res, { talents: listTalents(talentCatalog(diag)) });
|
|
@@ -2591,9 +2669,18 @@ export function apply(ctx, config = {}) {
|
|
|
2591
2669
|
if (member === undefined || member.kind !== 'agent') return send(res, { error: { code: 'NOT_FOUND', message: 'member not found' } }, 404);
|
|
2592
2670
|
const project = runtime.service.state.projects?.[runtime.id];
|
|
2593
2671
|
const draft = talentFromMember(member, skillKindForMember(member, { ownerId: project?.ownerMemberId ?? project?.ownerId }));
|
|
2594
|
-
const
|
|
2672
|
+
const teamDir = resolveTeam(talentCatalog(diag), member.team ?? DEFAULT_TEAM, { diag }).dir;
|
|
2673
|
+
const talentRoots = memberCatalogDirs(member, diag);
|
|
2674
|
+
const roots = [teamDir, ...memberSkillRoots(member, runtime, diag, talentRoots)];
|
|
2675
|
+
const summaries = draft.skills.length > 0 ? await lookupHostSkills(memberWorkspace(member, runtime) || dshHome()) : [];
|
|
2676
|
+
if (summaries === null) return send(res, { error: { code: 'E_RUNTIME_UNAVAILABLE', message: 'DSH skill catalog is unavailable' } }, 503);
|
|
2677
|
+
const references = await memberHostSkillReferences(draft.skills, [teamDir, ...talentRoots], summaries);
|
|
2678
|
+
const available = new Set(modelInvocableSkills(summaries).map((skill) => skill.name));
|
|
2595
2679
|
const skills = [];
|
|
2596
|
-
for (const name of draft.skills)
|
|
2680
|
+
for (const name of draft.skills) {
|
|
2681
|
+
if (references.has(name)) skills.push({ name, found: available.has(name), host: true });
|
|
2682
|
+
else skills.push({ name, found: (await findSkillText(roots, name)) !== null });
|
|
2683
|
+
}
|
|
2597
2684
|
return send(res, { draft: { ...draft, skills }, projectId: runtime.id, memberId: member.id });
|
|
2598
2685
|
}
|
|
2599
2686
|
// 可安装的技能清单(每个人才自带的技能),给「从已有装」挑。
|
package/lib/domain/catalog.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
16
|
-
import { join } from 'node:path';
|
|
16
|
+
import { dirname, join } from 'node:path';
|
|
17
17
|
import { fileURLToPath } from 'node:url';
|
|
18
18
|
import { parse, stringify } from 'yaml';
|
|
19
19
|
import { parseAvatar } from './avatar.js';
|
|
@@ -313,19 +313,23 @@ export function forkTalent(userRoot, talent) {
|
|
|
313
313
|
return { forked: true, dir };
|
|
314
314
|
}
|
|
315
315
|
|
|
316
|
+
function talentSkillPath(talentDir, name) {
|
|
317
|
+
return join(talentDir, 'skills', name, 'SKILL.md');
|
|
318
|
+
}
|
|
319
|
+
|
|
316
320
|
/** 把一份技能装进某人才自己的文件夹:`<talentDir>/skills/<name>/SKILL.md`。返回规范后的技能名。 */
|
|
317
321
|
export function installSkill(talentDir, name, markdown) {
|
|
318
322
|
if (typeof talentDir !== 'string' || talentDir === '') throw new Error('installSkill: 需要 talentDir');
|
|
319
323
|
const safe = skillName(name, '技能名');
|
|
320
|
-
const
|
|
321
|
-
mkdirSync(
|
|
322
|
-
writeFileSync(
|
|
324
|
+
const file = talentSkillPath(talentDir, safe);
|
|
325
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
326
|
+
writeFileSync(file, typeof markdown === 'string' ? markdown : '', 'utf8');
|
|
323
327
|
return safe;
|
|
324
328
|
}
|
|
325
329
|
|
|
326
330
|
/** 读某人才自带技能的正文(给预览与 fork)。 */
|
|
327
331
|
export function readSkillText(talentDir, name) {
|
|
328
|
-
return readFileSync(
|
|
332
|
+
return readFileSync(talentSkillPath(talentDir, skillName(name, '技能名')), 'utf8');
|
|
329
333
|
}
|
|
330
334
|
|
|
331
335
|
/**
|
|
@@ -430,6 +434,10 @@ export function talentFromMember(member, duty) {
|
|
|
430
434
|
/** 列出可安装的技能:当前目录里每个人才自带的技能(名字 + 来源人才),给「从已有装」挑。 */
|
|
431
435
|
export function listInstallableSkills(catalog) {
|
|
432
436
|
const out = [];
|
|
433
|
-
for (const t of catalog.talents.values())
|
|
437
|
+
for (const t of catalog.talents.values()) {
|
|
438
|
+
for (const name of t.skills) {
|
|
439
|
+
if (existsSync(talentSkillPath(t.dir, name))) out.push({ name, talent: t.id, talentName: t.name, source: t.source });
|
|
440
|
+
}
|
|
441
|
+
}
|
|
434
442
|
return out.sort((a, b) => a.name.localeCompare(b.name) || a.talent.localeCompare(b.talent));
|
|
435
443
|
}
|
|
@@ -12,30 +12,45 @@ function clean(value, limit) {
|
|
|
12
12
|
return text.length > limit ? `${text.slice(0, limit - 1)}…` : text;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export async function
|
|
16
|
-
if (
|
|
17
|
-
const summaries = await skills.list({
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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) {
|
|
21
22
|
// 只注入「模型可以自己调用」的技能:`disable-model-invocation: true` 的技能
|
|
22
23
|
// 是给 Human 显式用的,列进成员 prompt 会把成员引向一个它无权调用的入口。
|
|
23
24
|
// SkillSummary 把这两个开关放在 `invocation` 下;直接读顶层字段会让过滤永远
|
|
24
25
|
// 通过(字段恒为 undefined),被禁的技能照样写进 prompt。
|
|
25
|
-
|
|
26
|
-
if (isSkillExcluded(skill
|
|
26
|
+
return summaries.filter((skill) => {
|
|
27
|
+
if (typeof skill?.name !== 'string' || skill.name === '' || isSkillExcluded(skill.name)) return false;
|
|
27
28
|
const modelInvocable = skill?.invocation?.modelInvocable ?? skill?.modelInvocable;
|
|
28
29
|
const disabled = skill?.invocation?.disableModelInvocation ?? skill?.disableModelInvocation;
|
|
29
30
|
if (modelInvocable === false || disabled === true) return false;
|
|
30
31
|
return true;
|
|
31
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);
|
|
32
38
|
if (available.length === 0) return '';
|
|
39
|
+
const selected = available.filter((skill) => assigned.has(skill.name));
|
|
33
40
|
const limit = Number.isSafeInteger(options.limit) && options.limit > 0 ? options.limit : 12;
|
|
34
|
-
const
|
|
35
|
-
|
|
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;
|
|
36
44
|
const description = clean(skill?.description, 240);
|
|
37
45
|
const when = clean(skill?.whenToUse, 180);
|
|
38
|
-
return `- ${name}:${description}${when ? `(何时用:${when})` : ''}`;
|
|
46
|
+
return `- ${name}${assigned.has(name) ? '(已为你配置)' : ''}:${description}${when ? `(何时用:${when})` : ''}`;
|
|
39
47
|
});
|
|
40
|
-
|
|
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);
|
|
41
56
|
}
|
|
@@ -12,7 +12,7 @@
|
|
|
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
16
|
import { isSkillExcluded } from './skill-policy.js';
|
|
17
17
|
import { renderSkillVars } from './skill-loader.js';
|
|
18
18
|
import { reportFail } from '../diaglog.js';
|
|
@@ -151,6 +151,7 @@ function scanCandidate(file, fallbackName, source) {
|
|
|
151
151
|
source,
|
|
152
152
|
provider: 'ai-team-files',
|
|
153
153
|
path: file,
|
|
154
|
+
resourceBase: { kind: 'directory', path: dirname(file) },
|
|
154
155
|
locator: file,
|
|
155
156
|
rank: SOURCE_RANK[source] ?? 500,
|
|
156
157
|
};
|
|
@@ -183,25 +184,21 @@ function scanRoot(root, source) {
|
|
|
183
184
|
export function createFileSkillProvider({ dshHome, projectCwd, bundledDir, resolveVars } = {}) {
|
|
184
185
|
// Bundled last: the official rank order puts disk roots above the packaged
|
|
185
186
|
// 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']);
|
|
187
|
+
const globalRoots = [];
|
|
188
|
+
if (dshHome) globalRoots.push([join(dshHome, 'skills'), 'user-dsh']);
|
|
189
|
+
if (bundledDir) globalRoots.push([join(bundledDir, 'skills'), 'bundled']);
|
|
193
190
|
return {
|
|
194
191
|
name: 'ai-team-files',
|
|
195
192
|
async list(options = {}) {
|
|
196
|
-
const
|
|
193
|
+
const resolveCwd = typeof options.cwd === 'string' && options.cwd !== '' ? options.cwd : projectCwd;
|
|
194
|
+
const projectRoots = resolveCwd
|
|
197
195
|
? [
|
|
198
|
-
[join(
|
|
199
|
-
[join(
|
|
196
|
+
[join(resolveCwd, '.dsh', 'skills'), 'project-dsh'],
|
|
197
|
+
[join(resolveCwd, '.agents', 'skills'), 'project-agents'],
|
|
200
198
|
]
|
|
201
199
|
: [];
|
|
202
200
|
const all = [];
|
|
203
|
-
const
|
|
204
|
-
for (const [root, source] of [...roots, ...extra]) {
|
|
201
|
+
for (const [root, source] of [...projectRoots, ...globalRoots]) {
|
|
205
202
|
for (const candidate of scanRoot(root, source)) all.push({ ...candidate, resolveCwd });
|
|
206
203
|
}
|
|
207
204
|
// Same-name clash: the lowest rank wins, mirroring the registry's
|
|
@@ -237,12 +234,16 @@ export function createFileSkillProvider({ dshHome, projectCwd, bundledDir, resol
|
|
|
237
234
|
export function installFileSkillProvider(skills, options) {
|
|
238
235
|
if (!skills || typeof skills.registerProvider !== 'function') return () => {};
|
|
239
236
|
const provider = createFileSkillProvider(options);
|
|
240
|
-
// SDK
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
237
|
+
// 失效能力属于工厂收到的 SDK control。注册的返回值只负责注销。
|
|
238
|
+
let providerControl;
|
|
239
|
+
const registration = skills.registerProvider((control) => {
|
|
240
|
+
providerControl = control;
|
|
241
|
+
return provider;
|
|
242
|
+
});
|
|
243
|
+
const dispose = typeof registration === 'function' ? registration : () => registration?.dispose?.();
|
|
244
|
+
const release = () => {
|
|
245
|
+
try { dispose(); } catch { /* already disposed */ }
|
|
247
246
|
};
|
|
247
|
+
release.invalidate = () => providerControl?.invalidate?.();
|
|
248
|
+
return release;
|
|
248
249
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suifei/dsh-ai-team",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.150",
|
|
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",
|