@suifei/dsh-ai-team 0.4.148 → 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 CHANGED
@@ -1,5 +1,14 @@
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
+
8
+ ## 0.4.149 - 2026-12-01
9
+
10
+ - 文渊阁管理的 PMO 和成员会话在标题栏显示看板图标,点击直达该会话所属项目的看板。会话运行时图标有轻微脉冲,并遵循系统的减少动态效果设置。
11
+
3
12
  ## 0.4.148 - 2026-12-01
4
13
 
5
14
  - README 快速开始按入口使用内置 profile。桌面应用使用 `desktop`,从终端启动的浏览器界面使用 `web`。宿主连接服务不可用时,中英文 503 提示引导检查插件安装的 profile 和启动入口。感谢 @Arnoldnuo 的反馈(#102),见 #106。
package/README.md CHANGED
@@ -37,6 +37,8 @@
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)。
41
+ - **会话标题栏看板入口**(0.4.149)。文渊阁管理的 PMO 和成员会话会显示文渊阁图标,点击直达所属项目的看板。运行时的轻微脉冲遵循系统的减少动态效果设置。
40
42
  - **安装指引与 503 提示**(0.4.148)。快速开始按入口使用内置 `desktop` 或 `web`。连接服务不可用时,工作台提示核对插件安装的 profile 和启动入口。感谢 [@Arnoldnuo](https://github.com/Arnoldnuo) 的反馈([#102](https://github.com/suifei/dsh-ai-team/issues/102))。
41
43
  - **蓝图试跑与项目总览**(0.4.147)。新建项目可按星门项目的团队架构实践,先用两个岗位、一份真实样本跑通交付。开启 PMO 自动后,插件按实测证据派发、确认草稿和扩编复跑。工作台显示当前阶段和下一步,项目总览可查看验收、AI 协作与原始证据。
42
44
  - **归档项目与团队管理**(0.4.146)。人员池只汇总未归档项目的成员与任务,归档任务和会话仍可查阅。侧栏新增「团队管理」,集中管理项目成员和团队预设。感谢 [@qq958691165](https://github.com/qq958691165) 的反馈([#103](https://github.com/suifei/dsh-ai-team/issues/103))。
@@ -113,8 +115,9 @@ const svg = HashAvatar.svg('墨渊', { gender: 'male', age: 'middle', race: 'asi
113
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 位人才可在人才市场挑选、组合或自建。
114
116
  - 「人员 → 添加成员」先打开人才市场:按分类、关键词挑一位,点「招聘」预填表单,改名、换模型后创建;也可以切到「自定义」从零填写。
115
117
  - 自建:人才放 `~/.dsh/ai-team/catalog/user/talents/<人才>/`,团队放 `~/.dsh/ai-team/catalog/user/teams/<团队>/`,同名覆盖内置;插件设置 `teamPreset` 选新项目用哪个团队。
116
- - **新建自定义人才(界面)**:「添加成员 → 新建人才」填名号、岗位、职责、性格,再按需装技能——从现成人才 fork、自写一份、或导入 `.md`,存成可复用的人才(落用户根)。内置没有的角色能自己攒;技能装进人才自己的文件夹,自包含、可分享。走 `POST /api/talents` 与 `POST /api/talents/:id/skills`,内置只读、装删回 `409`。
117
- - **存为人才**:成员资料「存为人才」把项目里这位成员此刻的岗位、职责、性格、模型与技能存成可复用的人才(技能按成员实际读取的路径拷进人才文件夹,找不到正文的会提示),换个项目照样招。新建与存为都不会静默覆盖已有人才,撞名自动加序号。
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 技能随人才保存。新建或存为人才时,重名自动加序号。
118
121
  - **组队、建项目选团队**:「新建项目」里选团队(内置或自建),按它种成员、负责人当主理人;「组一个新团队」从人才里挑人(同一人才可招多位)、指定负责人即可保存。插件设置 `teamPreset` 只是不选时的默认值。
119
122
  - **改内置人才、进化技能**:内置人才点「复制为可编辑」得到同 id 的副本(随时「恢复内置」);成员资料里技能旁的「进化」会让该成员用 SkillOpt 优化那份技能——内置的先自动复制,插件里的原文件不动。
120
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 同形的私有源。在线人才同样只读,可「复制为可编辑」。
@@ -357,6 +360,7 @@ round-19 DeepSeek + Zhipu 双 provider
357
360
 
358
361
  | 贡献者 | 贡献 | 带来的进展 |
359
362
  |---|---|---|
363
+ | [@godfay-g](https://github.com/godfay-g) | 技能目录和 ZIP 的导入建议 [#109](https://github.com/suifei/dsh-ai-team/issues/109) | 成员与自定义人才可在文渊阁选择已安装的技能或导入完整技能包 |
360
364
  | [@qq958691165](https://github.com/qq958691165) | 归档项目的成员反馈、团队管理建议 [#103](https://github.com/suifei/dsh-ai-team/issues/103) | 人员池排除归档项目,侧栏集中管理项目成员与团队预设 |
361
365
  | [@Arnoldnuo](https://github.com/Arnoldnuo) | 桌面端启动 503 反馈 [#102](https://github.com/suifei/dsh-ai-team/issues/102) | 工作台提供分情况的 503 提示,快速开始说明内置 `desktop` 与 `web` 的安装和启动方式,连接错误提示引导核对 profile |
362
366
  | [@Lamooner](https://github.com/Lamooner) | PMO 决策反馈与建议 [#99](https://github.com/suifei/dsh-ai-team/issues/99) | 避免选中「不推荐」项,移除编号偏向并补充括注编号回归 |
package/client.js CHANGED
@@ -25,6 +25,8 @@ window.__ModuleLoader__.load({
25
25
 
26
26
  const zh = {
27
27
  panel: '文渊阁',
28
+ sessionBoard: '打开文渊阁看板',
29
+ sessionProjectBoard: '打开「{project}」看板',
28
30
  back: '项目总览',
29
31
  inbox: '收件箱',
30
32
  board: '任务看板',
@@ -338,6 +340,13 @@ window.__ModuleLoader__.load({
338
340
  tcName: '名号', tcRole: '岗位', tcDuty: '职责', tcCategory: '分类', tcTags: '标签', tcTagsHint: '逗号分隔', tcPersonality: '性格', tcPersonalityHint: '它怎么做事、什么风格',
339
341
  tcSkills: '技能', tcEmpty: '还没装技能(可选)', tcAddExisting: '从已有装', tcWriteOwn: '自写一份', tcImport: '导入 .md', tcPick: '选一个已有技能…', tcAdd: '加入', tcRemove: '移除',
340
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 目录暂未识别此版本。请检查技能作用域,然后重新打开技能选择。',
341
350
  memberSaveAsTalent: '存为人才', tcFromMember: '从成员「{name}」存出:沿用它此刻的岗位、职责、性格与技能,可先修改再保存。', tcModelKept: '沿用模型:{model}', tcMissing: '这些技能找不到正文,没有带上:{skills}', tcDraftFailed: '读取成员草稿失败:{error}',
342
351
  teamManagement: '团队管理', teamManageGoal: '管理当前项目成员,或为新项目准备团队预设。', teamActiveProject: '当前项目成员', teamPickProject: '切换活动项目以管理成员', teamNoActiveProject: '请选择一个未归档的项目。', teamPresets: '团队预设', teamPresetHint: '预设用于新建项目,不会更改已创建的项目。', teamNoPresets: '没有可用的团队预设。',
343
352
  projectTeam: '团队', teamCompose: '组一个新团队', teamComposeTitle: '组队', teamComposeHint: '从人才里挑人组队:同一人才可以招多位,给其中一位定为负责人(新项目的主理人)。', teamName: '团队名', teamDesc: '说明', teamMembers: '成员', teamPick: '从人才里挑人', teamAdd: '加入', teamLead: '负责人', teamEmptyPick: '还没挑人', teamSave: '保存团队', teamBack: '返回', teamDelete: '删除这个团队', teamDeleteConfirm: '删除自建团队「{name}」?团队文件会被删除,已用它建的项目和其中成员不受影响。', teamLoadFailed: '团队列表读取失败:{error}',
@@ -525,6 +534,8 @@ window.__ModuleLoader__.load({
525
534
  };
526
535
  const en = {
527
536
  panel: 'Wenyuan Pavilion',
537
+ sessionBoard: 'Open Wenyuan Pavilion board',
538
+ sessionProjectBoard: 'Open board for {project}',
528
539
  back: 'Overview',
529
540
  inbox: 'Inbox',
530
541
  board: 'All tasks',
@@ -839,6 +850,13 @@ window.__ModuleLoader__.load({
839
850
  tcName: 'Name', tcRole: 'Role', tcDuty: 'Duty', tcCategory: 'Category', tcTags: 'Tags', tcTagsHint: 'comma-separated', tcPersonality: 'Personality', tcPersonalityHint: 'how it works, its style',
840
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',
841
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.',
842
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}',
843
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.',
844
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}',
@@ -1147,6 +1165,31 @@ window.__ModuleLoader__.load({
1147
1165
  }
1148
1166
 
1149
1167
  const CSS = `
1168
+ .at-session-board {
1169
+ position: relative; flex: 0 0 auto; display: inline-grid; place-items: center;
1170
+ inline-size: 28px; block-size: 28px; padding: 0; border: 0;
1171
+ border-radius: var(--dsw-radius-sm, 6px); background: transparent;
1172
+ color: var(--dsw-alias-label-secondary); cursor: pointer;
1173
+ }
1174
+ .at-session-board:hover, .at-session-board:focus-visible {
1175
+ color: var(--dsw-alias-state-business-primary);
1176
+ background: var(--dsw-alias-interactive-bg-hover);
1177
+ }
1178
+ .at-session-board:focus-visible {
1179
+ outline: 2px solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary)); outline-offset: -2px;
1180
+ }
1181
+ .at-session-board svg { animation: at-session-board-in .18s ease-out; transition: transform .15s ease-out; }
1182
+ .at-session-board:hover svg, .at-session-board:focus-visible svg { transform: translateY(-1px); }
1183
+ .at-session-board[data-running]::after {
1184
+ content: ''; position: absolute; inset-block-start: 3px; inset-inline-end: 3px;
1185
+ inline-size: 5px; block-size: 5px; border-radius: 50%; pointer-events: none;
1186
+ background: var(--dsw-alias-state-business-primary); animation: at-session-board-pulse 1.8s ease-out infinite;
1187
+ }
1188
+ @keyframes at-session-board-in { from { opacity: 0; transform: translateY(2px); } }
1189
+ @keyframes at-session-board-pulse {
1190
+ 0% { box-shadow: 0 0 0 0 var(--dsw-alias-state-business-primary); }
1191
+ 65%, 100% { box-shadow: 0 0 0 4px transparent; }
1192
+ }
1150
1193
  .at-root { height: 100%; min-height: 0; display: flex; flex-direction: column; position: relative; overflow: hidden; color: var(--dsw-alias-label-primary); background: var(--dsw-alias-bg-base); font-family: var(--dsw-font-family); font-size: 13px; line-height: 21px; container-type: inline-size; container-name: at-wb; }
1151
1194
  .at-root *, .at-root *::before, .at-root *::after { box-sizing: border-box; }
1152
1195
  .at-toaststack { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: flex; flex-direction: column; align-items: flex-end; gap: 7px; max-width: min(360px, calc(100vw - 36px)); pointer-events: none; }
@@ -1599,6 +1642,7 @@ window.__ModuleLoader__.load({
1599
1642
  .at-tcskill button { border: 0; background: transparent; cursor: pointer; font-size: 14px; line-height: 1; color: inherit; padding: 0; }
1600
1643
  .at-tcpick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
1601
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; }
1602
1646
  .at-teamrows { display: flex; flex-direction: column; gap: 6px; }
1603
1647
  .at-teamrow { display: grid; grid-template-columns: 24px minmax(0, 1fr) 76px auto auto; gap: 8px; align-items: center; }
1604
1648
  .at-teamrow > .at-modalmeta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@@ -1715,6 +1759,8 @@ window.__ModuleLoader__.load({
1715
1759
  .at-send { margin-left: auto; }
1716
1760
  }
1717
1761
  @media (prefers-reduced-motion: reduce) {
1762
+ .at-session-board svg, .at-session-board[data-running]::after { animation: none; transition: none; }
1763
+ .at-session-board:hover svg, .at-session-board:focus-visible svg { transform: none; }
1718
1764
  .at-root *, .at-root *::before, .at-root *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
1719
1765
  }
1720
1766
  `;
@@ -3355,6 +3401,186 @@ window.__ModuleLoader__.load({
3355
3401
  talent.forked && onRestore ? h('button', { type: 'button', className: 'at-btn at-btn-small', onClick: () => onRestore(talent) }, withIco('undo', t('talentRestore'), 12)) : null,
3356
3402
  h('button', { type: 'button', className: 'at-btn at-btn-small at-btn-primary', onClick: () => onHire(talent) }, withIco('userPlus', t('talentHire'), 12))))))));
3357
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
+ }
3358
3584
  function TalentCreator({ t, initial, onSaved, onCancel }) {
3359
3585
  const seed = initial && initial.draft ? talentCreatorInit(initial) : null;
3360
3586
  const [form, setForm] = React.useState(() => (seed ? seed.form : blankTalentForm()));
@@ -3366,6 +3592,8 @@ window.__ModuleLoader__.load({
3366
3592
  const [skBody, setSkBody] = React.useState('');
3367
3593
  const [busy, setBusy] = React.useState(false);
3368
3594
  const [error, setError] = React.useState('');
3595
+ const savedId = React.useRef('');
3596
+ const writtenSkills = React.useRef(new WeakSet());
3369
3597
  const set = (key) => (event) => setForm((f) => ({ ...f, [key]: event.target.value }));
3370
3598
  React.useEffect(() => {
3371
3599
  let live = true;
@@ -3400,15 +3628,22 @@ window.__ModuleLoader__.load({
3400
3628
  if (!form.name.trim() || busy) return;
3401
3629
  setBusy(true); setError('');
3402
3630
  try {
3403
- const res = await fetch('/ai-team/api/talents', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ ...talentFormToBody(form), ...(seed && seed.model ? { model: seed.model } : {}) }) });
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
+ }) });
3404
3637
  const body = await res.json().catch(() => null);
3405
3638
  if (!res.ok) throw new Error((body && body.error && body.error.message) || ('HTTP ' + res.status));
3406
- const id = body && body.talent && body.talent.id;
3639
+ savedId.current = body.talent.id;
3407
3640
  for (const sk of pending) {
3641
+ if (sk.kind === 'host' || writtenSkills.current.has(sk)) continue;
3408
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 };
3409
- const r2 = await fetch('/ai-team/api/talents/' + encodeURIComponent(id) + '/skills', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(payload) });
3643
+ const r2 = await fetch('/ai-team/api/talents/' + encodeURIComponent(savedId.current) + '/skills', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(payload) });
3410
3644
  const b2 = await r2.json().catch(() => null);
3411
3645
  if (!r2.ok) throw new Error(((b2 && b2.error && b2.error.message) || ('HTTP ' + r2.status)) + '(' + sk.name + ')');
3646
+ writtenSkills.current.add(sk);
3412
3647
  }
3413
3648
  onSaved();
3414
3649
  } catch (err) {
@@ -3435,6 +3670,7 @@ window.__ModuleLoader__.load({
3435
3670
  h('div', { className: 'at-field' }, h('span', null, t('tcSkills')),
3436
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)) }, '×')))),
3437
3672
  h('div', { className: 'at-tcpick' },
3673
+ h(HostSkillPicker, { t, selectedNames: pending.map((skill) => skill.name), disabled: busy, onChoose: (name) => stage({ name, kind: 'host' }) }),
3438
3674
  h('button', { type: 'button', className: 'at-btn', onClick: () => setPick(pick === 'existing' ? '' : 'existing') }, withIco('store', t('tcAddExisting'))),
3439
3675
  h('button', { type: 'button', className: 'at-btn', onClick: () => setPick(pick === 'write' ? '' : 'write') }, withIco('pen', t('tcWriteOwn'))),
3440
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 }))),
@@ -3845,14 +4081,16 @@ window.__ModuleLoader__.load({
3845
4081
  };
3846
4082
  }
3847
4083
  /**
3848
- * 「存为人才」:服务端草稿 → 新建人才页的初值。找得到正文的技能按「从成员拷」暂存,找不到的单列出来。
4084
+ * 「存为人才」:保留宿主技能引用,暂存可从成员复制的技能,单列找不到的技能。
3849
4085
  */
3850
4086
  function talentCreatorInit(initial) {
3851
4087
  const draft = (initial && initial.draft) || {};
3852
4088
  const skills = Array.isArray(draft.skills) ? draft.skills : [];
3853
4089
  return {
3854
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 } },
3855
- pending: skills.filter((x) => x && x.found).map((x) => ({ name: x.name, kind: 'member', fromProject: initial.projectId, fromMember: initial.memberId })),
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 }),
3856
4094
  missing: skills.filter((x) => x && !x.found).map((x) => x.name),
3857
4095
  model: draft.model && (draft.model.provider || draft.model.model) ? draft.model : null,
3858
4096
  sourceName: String(draft.name || ''),
@@ -3974,13 +4212,13 @@ window.__ModuleLoader__.load({
3974
4212
  return new Error(label + '. ' + t('bootUnknown503'));
3975
4213
  }
3976
4214
 
3977
- function Workbench({ t, ctx }) {
4215
+ function Workbench({ t, ctx, initialBoardProject = '' }) {
3978
4216
  const [phase, setPhase] = React.useState('loading');
3979
4217
  const [data, setData] = React.useState(null);
3980
4218
  const [loadError, setLoadError] = React.useState('');
3981
- const [projectId, setProjectId] = React.useState('');
4219
+ const [projectId, setProjectId] = React.useState(initialBoardProject);
3982
4220
  const [scope, setScope] = React.useState('project');
3983
- const [tab, setTab] = React.useState('main');
4221
+ const [tab, setTab] = React.useState(initialBoardProject ? 'board' : 'main');
3984
4222
  const [selected, setSelected] = React.useState('');
3985
4223
  const [threadOpen, setThreadOpen] = React.useState(false);
3986
4224
  const [draftMode, setMode] = React.useState('discuss');
@@ -4218,6 +4456,9 @@ window.__ModuleLoader__.load({
4218
4456
  const next = normalizePayload(await response.json());
4219
4457
  if (!next) throw new Error('invalid bootstrap payload');
4220
4458
  if (!alive || seq !== loadSeqRef.current) return;
4459
+ if (!dataRef.current && initialBoardProject && !next.projects.some((project) => project.id === initialBoardProject)) {
4460
+ throw new Error(t('archivedNote'));
4461
+ }
4221
4462
  applyData(next);
4222
4463
  setLoadError('');
4223
4464
  setPhase('ready');
@@ -5273,15 +5514,25 @@ window.__ModuleLoader__.load({
5273
5514
  setPError(error?.message ?? String(error));
5274
5515
  }
5275
5516
  }
5276
- async function addSkill() {
5277
- if (!profileAgent || !pSkill.trim()) return;
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);
5278
5530
  try {
5279
- const result = await runCommand('member.skill', { memberId: profileAgent.id, name: pSkill.trim() });
5280
- setPSkill('');
5281
- setProfileAgent(result.member);
5282
- await reloadData();
5531
+ if (await addSkill(pSkill)) setPSkill('');
5283
5532
  } catch (error) {
5284
5533
  setPError(error?.message ?? String(error));
5534
+ } finally {
5535
+ setPBusy(false);
5285
5536
  }
5286
5537
  }
5287
5538
  async function retryProfile() {
@@ -6240,9 +6491,11 @@ window.__ModuleLoader__.load({
6240
6491
  h('button', { type: 'button', className: 'at-btn at-btn-small', title: t('skillEvolveHint'), onClick: () => void evolveSkill(profileAgent, name) }, withIco('spark', t('skillEvolve'), 12)))))
6241
6492
  : h('div', { key: 'none', className: 'at-modalmeta' }, t('profileSkillsEmpty')),
6242
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 })),
6243
6496
  h('div', { key: 'add', className: 'at-inlineadd' },
6244
6497
  h('input', { value: pSkill, onChange: (event) => setPSkill(event.target.value), placeholder: t('skillPlaceholder') }),
6245
- h('button', { className: 'at-btn at-btn-small', type: 'button', onClick: addSkill, disabled: !pSkill.trim() }, withIco('plus', t('addSkill'), 12))),
6498
+ h('button', { className: 'at-btn at-btn-small', type: 'button', onClick: addTypedSkill, disabled: pBusy || !pSkill.trim() }, withIco('plus', t('addSkill'), 12))),
6246
6499
  ] : null,
6247
6500
  pTab === 'collab' ? [
6248
6501
  h('label', { key: 'succ', className: 'at-field' }, h('span', null, t('successor')),
@@ -6374,6 +6627,37 @@ window.__ModuleLoader__.load({
6374
6627
  return h('span', { style: { display: 'inline-flex', alignItems: 'center', justifyContent: 'center', color: 'inherit' } }, h(PavilionMark, { size: 18 }));
6375
6628
  }
6376
6629
 
6630
+ function SessionBoardShortcut({ sessionId, useSession, t, openBoard }) {
6631
+ const running = useSession((snapshot) => snapshot.running);
6632
+ const [target, setTarget] = React.useState(null);
6633
+ React.useEffect(() => {
6634
+ if (!sessionId) return;
6635
+ const controller = new AbortController();
6636
+ fetch('/ai-team/api/session-project?session=' + encodeURIComponent(sessionId), {
6637
+ headers: { accept: 'application/json' },
6638
+ signal: controller.signal,
6639
+ })
6640
+ .then((response) => response.ok ? response.json() : null)
6641
+ .then((project) => {
6642
+ if (!controller.signal.aborted) setTarget(project?.projectId ? { ...project, sessionId } : null);
6643
+ })
6644
+ .catch((error) => {
6645
+ if (!controller.signal.aborted) console.error(PKG + ': session board lookup failed', error);
6646
+ });
6647
+ return () => controller.abort();
6648
+ }, [sessionId]);
6649
+ if (!target || target.sessionId !== sessionId) return null;
6650
+ const label = target.projectName ? tf(t, 'sessionProjectBoard', { project: target.projectName }) : t('sessionBoard');
6651
+ return h('button', {
6652
+ className: 'at-session-board',
6653
+ type: 'button',
6654
+ title: label,
6655
+ 'aria-label': label,
6656
+ 'data-running': running || undefined,
6657
+ onClick: () => openBoard(target.projectId),
6658
+ }, h(PavilionMark, { size: 18 }));
6659
+ }
6660
+
6377
6661
  function apply(ctx) {
6378
6662
  ctx.effect(() => {
6379
6663
  const tag = document.createElement('style');
@@ -6384,10 +6668,33 @@ window.__ModuleLoader__.load({
6384
6668
  }, `${PKG}: styles`);
6385
6669
  ctx.effect(() => ctx.locale.register(NS, { zh, en }), `${PKG}: locale`);
6386
6670
  const t = ctx.locale.bind(NS);
6671
+ // 宿主以 main slot 的 key 切换面板,跳转意图在工作台挂载时消费一次。
6672
+ let boardEntry = null;
6673
+ const layout = () => ctx.get?.('layout');
6674
+ const openBoard = (projectId) => {
6675
+ const entry = { projectId };
6676
+ boardEntry = entry;
6677
+ try {
6678
+ layout().selectPanel('ai-team');
6679
+ } catch (error) {
6680
+ if (boardEntry === entry) boardEntry = null;
6681
+ console.error(PKG + ': opening session board failed', error);
6682
+ }
6683
+ };
6684
+ function TeamPanel() {
6685
+ const [entry] = React.useState(() => boardEntry);
6686
+ React.useEffect(() => {
6687
+ if (entry === boardEntry) boardEntry = null;
6688
+ }, [entry]);
6689
+ return h(Boundary, { t }, h(Workbench, { t, ctx, initialBoardProject: entry?.projectId }));
6690
+ }
6387
6691
  ctx.slots.inject('sidebar.panellist', () => ctx.slots.register({
6388
6692
  name: 'sidebar.panellist', id: 'ai-team', order: 25, label: () => ctx.locale.bind(NS)('panel'),
6389
6693
  }, PanelIcon));
6390
- ctx.slots.inject('main', () => ctx.slots.register({ name: 'main', key: 'ai-team' }, () => h(Boundary, { t }, h(Workbench, { t, ctx }))));
6694
+ ctx.slots.inject('main', () => ctx.slots.register({ name: 'main', key: 'ai-team' }, () => h(TeamPanel)));
6695
+ ctx.slots.inject('conversation.session.header.actions', () => ctx.slots.register({
6696
+ name: 'conversation.session.header.actions', id: 'ai-team-board', order: 25,
6697
+ }, (props) => typeof layout()?.selectPanel === 'function' && h(SessionBoardShortcut, { ...props, t, openBoard })));
6391
6698
  }
6392
6699
 
6393
6700
  return { inject: ['slots', 'locale'], apply };
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 { formatSkillCatalog } from './lib/runtime/skill-catalog.js';
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 workspacePath = runtime?.service?.state?.projects?.[runtime.id]?.workspacePath;
159
- const dir = member?.workspace || (typeof workspacePath === 'string' ? workspacePath.trim() : '');
160
- return [...memberCatalogDirs(member, diag), ...(dir ? [join(dir, '.dsh')] : []), dshHome(), runtime?.dir].filter((root) => typeof root === 'string' && root !== '');
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`,最后内置默认团队。 */
@@ -419,6 +433,7 @@ export function apply(ctx, config = {}) {
419
433
  };
420
434
  /** 会话属于哪个团队(PMO 宿主会话或成员会话):停止守卫与推进纪律共用这一份判定。 */
421
435
  const teamProjectOf = (sessionId) => {
436
+ if (typeof sessionId !== 'string' || sessionId === '') return null;
422
437
  for (const runtime of booted?.runtimes?.values() ?? []) {
423
438
  const state = runtime.service.state;
424
439
  const inTeam = state.hostSessionId === sessionId
@@ -1572,6 +1587,17 @@ export function apply(ctx, config = {}) {
1572
1587
 
1573
1588
  const skillsService = serviceOf(ctx, 'skills');
1574
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
+ };
1575
1601
  try {
1576
1602
  // A vendor failure must never fail composition activation: that left
1577
1603
  // fresh installs with a half-activated host until a process restart.
@@ -2192,8 +2218,7 @@ export function apply(ctx, config = {}) {
2192
2218
  // 无目录项目 fail-closed:成员绝不落到宿主默认目录或插件数据目录
2193
2219
  // (projectCwd 的 dir 兜底)里执行。显式判工作目录,不吃兜底。
2194
2220
  // 先于 reseat 释放旧句柄——否则无目录的 force 会先杀句柄再 409。
2195
- const workspacePath = projectRuntime?.service?.state?.projects?.[projectRuntime.id]?.workspacePath;
2196
- const effectiveDir = member?.workspace || (typeof workspacePath === 'string' ? workspacePath.trim() : '');
2221
+ const effectiveDir = memberWorkspace(member, projectRuntime);
2197
2222
  if (effectiveDir === '') {
2198
2223
  diag?.append({ ev: 'activate.reject', projectId: projectRuntime.id, memberId: member.id, code: 'E_WORKSPACE_REQUIRED' });
2199
2224
  return {
@@ -2261,17 +2286,34 @@ export function apply(ctx, config = {}) {
2261
2286
  cwd: effectiveDir,
2262
2287
  });
2263
2288
  const blueprintRole = project?.blueprint?.roles.find((role) => role.id === member.id);
2264
- const skillContext = blueprintRole ? `\n\n${blueprintRole.prompt}` : (
2265
- await formatSkillCatalog(skillsService, { cwd: effectiveDir }) +
2266
- await loadSkillContext(activationMember, memberSkillRoots(activationMember, projectRuntime, diag), {
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, {
2267
2309
  vars: { GOAL: goalForProject(projectRuntime), PROJECT: project?.name ?? '', MEMBER: activationMember.name ?? '', WORKSPACE: effectiveDir },
2268
- preset: resolveTeam(talentCatalog(diag), activationMember.team ?? DEFAULT_TEAM, { diag }),
2310
+ preset,
2269
2311
  ownerId: project?.ownerMemberId ?? project?.ownerId,
2270
- })
2271
- );
2312
+ });
2313
+ }
2272
2314
  const result = await runtime.activate(activationMember, {
2273
2315
  // #65:激活时若带着 Human 消息的图片/文件,一并放进首条消息。
2274
- prompt: messageContent(`${memberIdentity(activationMember)}\n\n${typeof body.payload?.prompt === 'string'
2316
+ prompt: messageContent(`${memberIdentity(promptMember)}\n\n${typeof body.payload?.prompt === 'string'
2275
2317
  ? body.payload.prompt
2276
2318
  : '你被加入 AI Team。先读取项目简报与收件箱,再处理分配给你的任务。'}${skillContext}`, body.payload?.attachments),
2277
2319
  });
@@ -2512,6 +2554,43 @@ export function apply(ctx, config = {}) {
2512
2554
  get: await skillsService.get('distilly', {}).then((skill) => skill?.name ?? null).catch(() => null),
2513
2555
  });
2514
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
+ }
2515
2594
  // 人才市场:「添加成员」弹窗里可招聘的人才(用户自建优先于内置)。
2516
2595
  if (req.method === 'GET' && url.pathname === '/ai-team/api/talents') {
2517
2596
  return send(res, { talents: listTalents(talentCatalog(diag)) });
@@ -2590,9 +2669,18 @@ export function apply(ctx, config = {}) {
2590
2669
  if (member === undefined || member.kind !== 'agent') return send(res, { error: { code: 'NOT_FOUND', message: 'member not found' } }, 404);
2591
2670
  const project = runtime.service.state.projects?.[runtime.id];
2592
2671
  const draft = talentFromMember(member, skillKindForMember(member, { ownerId: project?.ownerMemberId ?? project?.ownerId }));
2593
- const roots = [resolveTeam(talentCatalog(diag), member.team ?? DEFAULT_TEAM, { diag }).dir, ...memberSkillRoots(member, runtime, diag)];
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));
2594
2679
  const skills = [];
2595
- for (const name of draft.skills) skills.push({ name, found: (await findSkillText(roots, name)) !== null });
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
+ }
2596
2684
  return send(res, { draft: { ...draft, skills }, projectId: runtime.id, memberId: member.id });
2597
2685
  }
2598
2686
  // 可安装的技能清单(每个人才自带的技能),给「从已有装」挑。
@@ -2964,6 +3052,14 @@ export function apply(ctx, config = {}) {
2964
3052
  },
2965
3053
  });
2966
3054
  }
3055
+ if (req.method === 'GET' && url.pathname === '/ai-team/api/session-project') {
3056
+ const sessionId = url.searchParams.get('session');
3057
+ const team = teamProjectOf(sessionId);
3058
+ const project = team && projectRuntime(team.projectId)?.service.state.projects?.[team.projectId];
3059
+ if (!project || project.status === 'archived') return send(res, { projectId: null });
3060
+ diag.append({ ev: 'session.board.lookup', sessionId, projectId: team.projectId });
3061
+ return send(res, { projectId: team.projectId, projectName: team.projectName });
3062
+ }
2967
3063
  if (req.method === 'GET' && url.pathname === '/ai-team/api/bootstrap') {
2968
3064
  const requested = url.searchParams.get('project');
2969
3065
  const requestedRuntime = requested === null ? null : projectRuntime(requested);
@@ -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 dir = join(talentDir, 'skills', safe);
321
- mkdirSync(dir, { recursive: true });
322
- writeFileSync(join(dir, 'SKILL.md'), typeof markdown === 'string' ? markdown : '', 'utf8');
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(join(talentDir, 'skills', skillName(name, '技能名'), 'SKILL.md'), 'utf8');
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()) for (const name of t.skills) out.push({ name, talent: t.id, talentName: t.name, source: t.source });
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 formatSkillCatalog(skills, options = {}) {
16
- if (!skills || typeof skills.list !== 'function') return '';
17
- const summaries = await skills.list({
18
- ...(options.cwd ? { cwd: options.cwd } : {}),
19
- }).catch(() => []);
20
- if (!Array.isArray(summaries) || summaries.length === 0) return '';
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
- const available = summaries.filter((skill) => {
26
- if (isSkillExcluded(skill?.name)) return false;
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 rows = available.slice(0, limit).map((skill) => {
35
- const name = clean(skill?.name, 80);
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
- return `\n\n## 可用 DSH 技能\n${rows.join('\n')}\n需要时用 skill 工具按名字加载完整技能说明;不要凭描述臆造步骤。`;
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 roots = [];
187
- if (projectCwd) {
188
- roots.push([join(projectCwd, '.dsh', 'skills'), 'project-dsh']);
189
- roots.push([join(projectCwd, '.agents', 'skills'), 'project-agents']);
190
- }
191
- if (dshHome) roots.push([join(dshHome, 'skills'), 'user-dsh']);
192
- if (bundledDir) roots.push([join(bundledDir, 'skills'), 'bundled']);
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 extra = options.cwd && options.cwd !== projectCwd
193
+ const resolveCwd = typeof options.cwd === 'string' && options.cwd !== '' ? options.cwd : projectCwd;
194
+ const projectRoots = resolveCwd
197
195
  ? [
198
- [join(options.cwd, '.dsh', 'skills'), 'project-dsh'],
199
- [join(options.cwd, '.agents', 'skills'), 'project-agents'],
196
+ [join(resolveCwd, '.dsh', 'skills'), 'project-dsh'],
197
+ [join(resolveCwd, '.agents', 'skills'), 'project-agents'],
200
198
  ]
201
199
  : [];
202
200
  const all = [];
203
- const resolveCwd = typeof options.cwd === 'string' && options.cwd !== '' ? options.cwd : projectCwd;
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 契约(dsh-skill.md):`registerProvider` 同步注册、**返回 disposer**,
241
- // 没有 invalidate 这一档。旧实现按「可能返回 { dispose, invalidate }」处理,
242
- // invalidate 分支永远不可达,属于死代码——这里只保留真实的两种返回形态。
243
- const control = skills.registerProvider(() => provider);
244
- const dispose = typeof control === 'function' ? control : control?.dispose;
245
- return () => {
246
- try { dispose?.(); } catch { /* already disposed */ }
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.148",
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",