@suifei/dsh-ai-team 0.4.149 → 0.4.151
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +6 -2
- package/client.js +235 -22
- package/index.js +152 -20
- package/lib/domain/catalog.js +14 -6
- package/lib/host/skill-import.js +204 -0
- package/lib/runtime/skill-catalog.js +56 -41
- package/lib/runtime/skill-provider.js +69 -44
- package/package.json +75 -74
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.151 - 2026-12-02
|
|
4
|
+
|
|
5
|
+
- 统一新建人才的技能导入入口。单个 Markdown、完整技能文件夹、ZIP 与 `.skill` 都从「导入技能」进入。
|
|
6
|
+
- 文渊阁直接校验、安装并回读完整技能包,可安装到个人目录或成员实际工作区。项目导入以文渊阁工作目录为准。感谢 @godfay-g 提出技能包导入建议(#109)。
|
|
7
|
+
- 完整包在 DSH 扫描范围外暂存,准备就绪后一次发布。Windows 临时占用导致重命名失败时自动重试。
|
|
8
|
+
|
|
9
|
+
## 0.4.150 - 2026-12-02
|
|
10
|
+
|
|
11
|
+
- 成员资料和新建人才可选择 DSH 已安装的技能。在同一 profile 启用 Skill Station 后,桌面端和本机 Web 可导入技能目录、ZIP 或 `.skill`,并把安装成功的技能加入当前表单。DSH 保留整包及相对资源。感谢 @godfay-g 的建议(#109)。
|
|
12
|
+
- 技能选择和成员调用按成员实际工作区解析,避免把宿主启动工作区的技能带入其他项目。将成员存为人才时保留 DSH 技能引用。
|
|
13
|
+
|
|
3
14
|
## 0.4.149 - 2026-12-01
|
|
4
15
|
|
|
5
16
|
- 文渊阁管理的 PMO 和成员会话在标题栏显示看板图标,点击直达该会话所属项目的看板。会话运行时图标有轻微脉冲,并遵循系统的减少动态效果设置。
|
package/README.md
CHANGED
|
@@ -37,6 +37,8 @@
|
|
|
37
37
|
|
|
38
38
|
## 最近更新
|
|
39
39
|
|
|
40
|
+
- **文渊阁直接导入技能包**(0.4.151)。「导入技能」可选 Markdown、技能文件夹、ZIP 和 `.skill`。只需安装文渊阁,即可安装完整包并在 DSH 确认可加载后加入技能列表。感谢 [@godfay-g](https://github.com/godfay-g),[#109](https://github.com/suifei/dsh-ai-team/issues/109)。
|
|
41
|
+
- **给成员装技能包**(0.4.150)。成员资料和新建人才增加已安装技能选择和完整技能包导入。感谢 [@godfay-g](https://github.com/godfay-g),[#109](https://github.com/suifei/dsh-ai-team/issues/109)。
|
|
40
42
|
- **会话标题栏看板入口**(0.4.149)。文渊阁管理的 PMO 和成员会话会显示文渊阁图标,点击直达所属项目的看板。运行时的轻微脉冲遵循系统的减少动态效果设置。
|
|
41
43
|
- **安装指引与 503 提示**(0.4.148)。快速开始按入口使用内置 `desktop` 或 `web`。连接服务不可用时,工作台提示核对插件安装的 profile 和启动入口。感谢 [@Arnoldnuo](https://github.com/Arnoldnuo) 的反馈([#102](https://github.com/suifei/dsh-ai-team/issues/102))。
|
|
42
44
|
- **蓝图试跑与项目总览**(0.4.147)。新建项目可按星门项目的团队架构实践,先用两个岗位、一份真实样本跑通交付。开启 PMO 自动后,插件按实测证据派发、确认草稿和扩编复跑。工作台显示当前阶段和下一步,项目总览可查看验收、AI 协作与原始证据。
|
|
@@ -114,8 +116,9 @@ const svg = HashAvatar.svg('墨渊', { gender: 'male', age: 'middle', race: 'asi
|
|
|
114
116
|
- 团队 `teams/<团队>/team.yml`:只引用人才(可覆盖名字、岗位、性格,追加技能),`skills/` 放这个团队的三份岗位规程(`ai-team-core` / `ai-team-qa` / `ai-team-executor`),`procedures` 可换成自己的规程。内置默认团队见 [`teams/default/`](teams/default/)。还预置了**逆向工程队** [`teams/reverse/`](teams/reverse/):静态分析、动态调试、OLLVM 去混淆、移动端逆向、算法复刻与行为对账(`teamPreset: reverse` 启用)。此外预置了文档(`docs`)、视频(`video`)、游戏(`game`)、自媒体写作(`content`)、深度研究(`research`)、科学研究(`science`)、中小学教育软件(`education`)等团队,共 44 位人才可在人才市场挑选、组合或自建。
|
|
115
117
|
- 「人员 → 添加成员」先打开人才市场:按分类、关键词挑一位,点「招聘」预填表单,改名、换模型后创建;也可以切到「自定义」从零填写。
|
|
116
118
|
- 自建:人才放 `~/.dsh/ai-team/catalog/user/talents/<人才>/`,团队放 `~/.dsh/ai-team/catalog/user/teams/<团队>/`,同名覆盖内置;插件设置 `teamPreset` 选新项目用哪个团队。
|
|
117
|
-
-
|
|
118
|
-
-
|
|
119
|
+
- 在「添加成员 → 新建人才」填写名号、岗位、职责、性格。点「导入技能」可选择 DSH 已安装的技能,或选择文件导入 `.md`、ZIP、`.skill`,也可以选择整个技能文件夹。人才还能从现有角色复制技能或自写一份。自带的 Markdown 保存在人才目录,DSH 技能以名称引用。
|
|
120
|
+
- 文渊阁直接安装并校验完整包。新建人才的完整包写入 DSH 个人技能目录。成员资料里的「添加 DSH 技能」写入成员实际工作区的 `.dsh/skills/`,由文渊阁自动分配。DSH 保留包内的 `references/` 等相对资源。同名技能可以直接从已安装列表选用。
|
|
121
|
+
- 成员资料的「存为人才」可保存成员当前的岗位、职责、性格、模型和技能。DSH 技能保留引用,使用时由目标工作区解析。自带的 Markdown 技能随人才保存。新建或存为人才时,重名自动加序号。
|
|
119
122
|
- **组队、建项目选团队**:「新建项目」里选团队(内置或自建),按它种成员、负责人当主理人;「组一个新团队」从人才里挑人(同一人才可招多位)、指定负责人即可保存。插件设置 `teamPreset` 只是不选时的默认值。
|
|
120
123
|
- **改内置人才、进化技能**:内置人才点「复制为可编辑」得到同 id 的副本(随时「恢复内置」);成员资料里技能旁的「进化」会让该成员用 SkillOpt 优化那份技能——内置的先自动复制,插件里的原文件不动。
|
|
121
124
|
- **在线人才库同步**:人才市场顶部「同步在线库」从官方在线人才库 [`@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 +361,7 @@ round-19 DeepSeek + Zhipu 双 provider
|
|
|
358
361
|
|
|
359
362
|
| 贡献者 | 贡献 | 带来的进展 |
|
|
360
363
|
|---|---|---|
|
|
364
|
+
| [@godfay-g](https://github.com/godfay-g) | 技能目录和 ZIP 的导入建议 [#109](https://github.com/suifei/dsh-ai-team/issues/109) | 成员与自定义人才可在文渊阁选择已安装的技能或导入完整技能包。0.4.151 统一新建人才的导入入口,并由文渊阁直接安装整包 |
|
|
361
365
|
| [@qq958691165](https://github.com/qq958691165) | 归档项目的成员反馈、团队管理建议 [#103](https://github.com/suifei/dsh-ai-team/issues/103) | 人员池排除归档项目,侧栏集中管理项目成员与团队预设 |
|
|
362
366
|
| [@Arnoldnuo](https://github.com/Arnoldnuo) | 桌面端启动 503 反馈 [#102](https://github.com/suifei/dsh-ai-team/issues/102) | 工作台提供分情况的 503 提示,快速开始说明内置 `desktop` 与 `web` 的安装和启动方式,连接错误提示引导核对 profile |
|
|
363
367
|
| [@Lamooner](https://github.com/Lamooner) | PMO 决策反馈与建议 [#99](https://github.com/suifei/dsh-ai-team/issues/99) | 避免选中「不推荐」项,移除编号偏向并补充括注编号回归 |
|
package/client.js
CHANGED
|
@@ -339,7 +339,14 @@ window.__ModuleLoader__.load({
|
|
|
339
339
|
tcHint: '填好职责与性格,按需装几份技能,存成可复用的人才。',
|
|
340
340
|
tcName: '名号', tcRole: '岗位', tcDuty: '职责', tcCategory: '分类', tcTags: '标签', tcTagsHint: '逗号分隔', tcPersonality: '性格', tcPersonalityHint: '它怎么做事、什么风格',
|
|
341
341
|
tcSkills: '技能', tcEmpty: '还没装技能(可选)', tcAddExisting: '从已有装', tcWriteOwn: '自写一份', tcImport: '导入 .md', tcPick: '选一个已有技能…', tcAdd: '加入', tcRemove: '移除',
|
|
342
|
+
tcImportSkill: '导入技能', tcImportSkillFiles: '导入 .md / ZIP / .skill', tcImportSkillType: '请选择 .md、ZIP 或 .skill 文件。',
|
|
342
343
|
tcSkillName: '技能名(英文/数字/-)', tcSkillBody: '技能正文(SKILL.md)', tcSkillDup: '已经装了同名技能', tcSave: '存为我的人才', tcSaving: '保存中…',
|
|
344
|
+
tcHostAdd: '添加 DSH 技能', tcHostPick: '选择已安装的技能', tcHostEmpty: '没有可添加的已安装技能', tcHostUnavailable: 'DSH 技能目录暂不可用,请确认宿主已加载技能服务后重试。',
|
|
345
|
+
tcHostFolder: '导入文件夹', tcHostArchive: '导入 ZIP / .skill', tcHostUserRoot: '完整技能包将安装到 DSH 个人技能目录。', tcHostProjectRoot: '完整技能包将安装到成员工作区的 DSH 技能目录。',
|
|
346
|
+
tcHostNoRoot: '请先在文渊阁设置成员或项目的工作目录。',
|
|
347
|
+
tcHostFolderType: '请选择包含 SKILL.md 的技能文件夹。', tcHostArchiveType: '请选择 .zip 或 .skill 文件。', tcHostPackLarge: '技能包超过上传容量上限,请精简资源后重试。',
|
|
348
|
+
tcHostImporting: '正在安装技能包…', tcHostImportFailed: '技能包导入失败({error})',
|
|
349
|
+
tcHostConflict: '技能 {name} 已存在或正在导入。可以从已安装技能中选择。', tcHostUnseen: 'DSH 未在目标目录识别到 {name},请检查同名技能后重试。',
|
|
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}',
|
|
@@ -842,7 +849,14 @@ window.__ModuleLoader__.load({
|
|
|
842
849
|
tcHint: 'Set the duty and personality, install a few skills, save a reusable talent.',
|
|
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',
|
|
852
|
+
tcImportSkill: 'Import skill', tcImportSkillFiles: 'Import .md / ZIP / .skill', tcImportSkillType: 'Choose a .md, ZIP, or .skill file.',
|
|
845
853
|
tcSkillName: 'Skill name (a-z, 0-9, -)', tcSkillBody: 'Skill body (SKILL.md)', tcSkillDup: 'That skill name is already staged', tcSave: 'Save as my talent', tcSaving: 'Saving…',
|
|
854
|
+
tcHostAdd: 'Add DSH skill', tcHostPick: 'Choose an installed skill', tcHostEmpty: 'No installed skills to add', tcHostUnavailable: 'The DSH skill catalog is unavailable. Make sure the host skill service is running, then try again.',
|
|
855
|
+
tcHostFolder: 'Import folder', tcHostArchive: 'Import ZIP / .skill', tcHostUserRoot: 'Skill packages will be installed in your DSH user skill directory.', tcHostProjectRoot: 'Skill packages will be installed in the member workspace’s DSH skill directory.',
|
|
856
|
+
tcHostNoRoot: 'Set an existing workspace for the member or project in Wenyuan.',
|
|
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…', tcHostImportFailed: 'Skill package import failed ({error})',
|
|
859
|
+
tcHostConflict: '{name} is already installed or being imported. Choose it from the installed skills.', tcHostUnseen: 'DSH could not resolve {name} in the selected directory. Check for a skill with the same name and try again.',
|
|
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,180 @@ 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_PACK_LIMIT = 64 * 1024 * 1024;
|
|
3406
|
+
function hostSkillCatalogPath(projectId, memberId) {
|
|
3407
|
+
const params = new URLSearchParams();
|
|
3408
|
+
if (projectId) params.set('project', projectId);
|
|
3409
|
+
if (memberId) params.set('member', memberId);
|
|
3410
|
+
return '/ai-team/api/host-skills' + (params.size ? '?' + params : '');
|
|
3411
|
+
}
|
|
3412
|
+
function skillImportKind(file) {
|
|
3413
|
+
const name = file?.name ?? '';
|
|
3414
|
+
if (/\.(zip|skill)$/i.test(name)) return 'archive';
|
|
3415
|
+
if (/\.md$/i.test(name) || /^text\/(markdown|plain)$/.test(file?.type ?? '')) return 'markdown';
|
|
3416
|
+
return null;
|
|
3417
|
+
}
|
|
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(mode, files) {
|
|
3427
|
+
const payload = {};
|
|
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 (skillImportKind(files[0]) !== 'archive') 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
|
+
// </host-skill-import>
|
|
3446
|
+
|
|
3447
|
+
/** 人才和成员共用的技能入口。宿主安装并确认 DSH 可调用后再分配。 */
|
|
3448
|
+
function HostSkillPicker({ t, projectId, memberId, selectedNames = [], disabled, onChoose, onImportMarkdown }) {
|
|
3449
|
+
const [open, setOpen] = React.useState(false);
|
|
3450
|
+
const [catalog, setCatalog] = React.useState(null);
|
|
3451
|
+
const [selected, setSelected] = React.useState('');
|
|
3452
|
+
const [busy, setBusy] = React.useState(false);
|
|
3453
|
+
const [progress, setProgress] = React.useState('');
|
|
3454
|
+
const [error, setError] = React.useState('');
|
|
3455
|
+
const trigger = React.useRef(null);
|
|
3456
|
+
const folderInput = React.useRef(null);
|
|
3457
|
+
const fileInput = React.useRef(null);
|
|
3458
|
+
const active = React.useRef(null);
|
|
3459
|
+
const path = hostSkillCatalogPath(projectId, memberId);
|
|
3460
|
+
async function readCatalog(signal) {
|
|
3461
|
+
const response = await fetch(path, { signal, headers: { accept: 'application/json' }, cache: 'no-store' });
|
|
3462
|
+
const body = await response.json().catch(() => null);
|
|
3463
|
+
if (!response.ok || !Array.isArray(body?.skills)) throw new Error('tcHostUnavailable');
|
|
3464
|
+
return body;
|
|
3465
|
+
}
|
|
3466
|
+
React.useEffect(() => {
|
|
3467
|
+
if (!open) return;
|
|
3468
|
+
const controller = new AbortController();
|
|
3469
|
+
const { signal } = controller;
|
|
3470
|
+
active.current = controller;
|
|
3471
|
+
readCatalog(signal).then((body) => {
|
|
3472
|
+
if (!signal.aborted) setCatalog(body);
|
|
3473
|
+
}).catch(() => {
|
|
3474
|
+
if (!signal.aborted) setCatalog(false);
|
|
3475
|
+
});
|
|
3476
|
+
return () => { controller.abort(); active.current = null; };
|
|
3477
|
+
}, [open, path]);
|
|
3478
|
+
const choices = (catalog?.skills ?? []).filter((skill) => !selectedNames.includes(skill.name));
|
|
3479
|
+
const choice = choices.find((skill) => skill.name === selected);
|
|
3480
|
+
const canImportPack = Boolean(catalog?.targetRoot);
|
|
3481
|
+
const importHint = catalog && !canImportPack ? 'tcHostNoRoot' : '';
|
|
3482
|
+
const title = t(onImportMarkdown ? 'tcImportSkill' : 'tcHostAdd');
|
|
3483
|
+
const fileLabel = t(onImportMarkdown ? (canImportPack ? 'tcImportSkillFiles' : 'tcImport') : 'tcHostArchive');
|
|
3484
|
+
const fileAccept = [onImportMarkdown && '.md,text/markdown,text/plain', canImportPack && '.zip,.skill,application/zip'].filter(Boolean).join(',');
|
|
3485
|
+
function show() {
|
|
3486
|
+
setCatalog(null);
|
|
3487
|
+
setSelected('');
|
|
3488
|
+
setError('');
|
|
3489
|
+
setOpen(true);
|
|
3490
|
+
}
|
|
3491
|
+
function dismiss() {
|
|
3492
|
+
setOpen(false);
|
|
3493
|
+
trigger.current?.focus({ preventScroll: true });
|
|
3494
|
+
}
|
|
3495
|
+
async function choose(name) {
|
|
3496
|
+
if (selectedNames.includes(name) || await onChoose(name) === false) throw new Error(t('tcSkillDup'));
|
|
3497
|
+
}
|
|
3498
|
+
async function perform(action) {
|
|
3499
|
+
const signal = active.current?.signal;
|
|
3500
|
+
if (busy || !signal) return;
|
|
3501
|
+
setBusy(true);
|
|
3502
|
+
setError('');
|
|
3503
|
+
try {
|
|
3504
|
+
if (await action(signal) === false) throw new Error(t('tcSkillDup'));
|
|
3505
|
+
if (!signal.aborted) dismiss();
|
|
3506
|
+
} catch (err) {
|
|
3507
|
+
const message = err?.message || String(err);
|
|
3508
|
+
if (!signal.aborted) setError(message.startsWith('tcHost') ? t(message) : message);
|
|
3509
|
+
} finally {
|
|
3510
|
+
if (!signal.aborted) { setBusy(false); setProgress(''); }
|
|
3511
|
+
}
|
|
3512
|
+
}
|
|
3513
|
+
function importSelected(event, isFolder) {
|
|
3514
|
+
const files = Array.from(event.target.files ?? []);
|
|
3515
|
+
event.target.value = '';
|
|
3516
|
+
if (!files.length) return;
|
|
3517
|
+
const mode = isFolder ? 'folder' : skillImportKind(files[0]);
|
|
3518
|
+
if (mode === 'markdown' && onImportMarkdown) {
|
|
3519
|
+
void perform(() => onImportMarkdown(files[0]));
|
|
3520
|
+
return;
|
|
3521
|
+
}
|
|
3522
|
+
if (mode !== 'folder' && mode !== 'archive') {
|
|
3523
|
+
setError(t(onImportMarkdown ? 'tcImportSkillType' : 'tcHostArchiveType'));
|
|
3524
|
+
return;
|
|
3525
|
+
}
|
|
3526
|
+
if (!canImportPack) {
|
|
3527
|
+
setError(t(importHint || 'tcHostUnavailable'));
|
|
3528
|
+
return;
|
|
3529
|
+
}
|
|
3530
|
+
void perform(async (signal) => {
|
|
3531
|
+
setProgress('tcHostImporting');
|
|
3532
|
+
const body = await skillPackRequest(mode, files);
|
|
3533
|
+
const response = await fetch(path, {
|
|
3534
|
+
method: 'POST', signal, headers: { 'content-type': 'application/json', accept: 'application/json' }, body,
|
|
3535
|
+
});
|
|
3536
|
+
const result = await response.json().catch(() => null);
|
|
3537
|
+
const failure = result?.error;
|
|
3538
|
+
const name = failure?.details?.name;
|
|
3539
|
+
if (response.status === 413) throw new Error('tcHostPackLarge');
|
|
3540
|
+
if (failure?.code === 'E_SKILL_WORKSPACE_REQUIRED') throw new Error('tcHostNoRoot');
|
|
3541
|
+
if (failure?.code === 'E_SKILL_EXISTS' && name) {
|
|
3542
|
+
const refreshed = await readCatalog(signal).catch(() => null);
|
|
3543
|
+
if (refreshed && !signal.aborted) setCatalog(refreshed);
|
|
3544
|
+
throw new Error(tf(t, 'tcHostConflict', { name }));
|
|
3545
|
+
}
|
|
3546
|
+
if (failure?.code === 'E_SKILL_NOT_VISIBLE' && name) throw new Error(tf(t, 'tcHostUnseen', { name }));
|
|
3547
|
+
if (!response.ok || typeof result?.skill?.name !== 'string' || !result.skill.name) {
|
|
3548
|
+
throw new Error(tf(t, 'tcHostImportFailed', { error: failure?.message || 'HTTP ' + response.status }));
|
|
3549
|
+
}
|
|
3550
|
+
if (!selectedNames.includes(result.skill.name)) await choose(result.skill.name);
|
|
3551
|
+
});
|
|
3552
|
+
}
|
|
3553
|
+
const close = () => { if (!busy) dismiss(); };
|
|
3554
|
+
return h(React.Fragment, null,
|
|
3555
|
+
h('button', { ref: trigger, type: 'button', className: 'at-btn', disabled, 'aria-haspopup': 'dialog', onClick: show }, withIco('plus', title)),
|
|
3556
|
+
open ? h(ModalBack, { onClose: close }, h('div', { className: 'at-modal at-hostskillpicker', role: 'dialog', 'aria-modal': 'true', 'aria-label': title },
|
|
3557
|
+
h('h2', { className: 'at-modaltitle' }, title),
|
|
3558
|
+
h('div', { className: 'at-modalactions' }, h('button', { type: 'button', className: 'at-btn', onClick: close, disabled: busy, autoFocus: true }, withIco('close', t('cancel')))),
|
|
3559
|
+
catalog === null ? h('div', { className: 'at-modalmeta', role: 'status' }, t('loading'))
|
|
3560
|
+
: catalog === false ? h('div', { className: 'at-modalerror', role: 'alert' }, t('tcHostUnavailable'))
|
|
3561
|
+
: h('div', { className: 'at-field' },
|
|
3562
|
+
h('select', { value: selected, 'aria-label': t('tcHostPick'), onChange: (event) => setSelected(event.target.value), disabled: busy || !choices.length },
|
|
3563
|
+
h('option', { value: '' }, t(choices.length ? 'tcHostPick' : 'tcHostEmpty')),
|
|
3564
|
+
choices.map((skill) => h('option', { key: skill.name, value: skill.name }, skill.name))),
|
|
3565
|
+
choice?.description ? h('div', { className: 'at-modalmeta' }, choice.description) : null,
|
|
3566
|
+
h('div', { className: 'at-tcpick' }, h('button', { type: 'button', className: 'at-btn at-btn-primary', disabled: !choice || busy, onClick: () => void perform(() => choose(choice.name)) }, t('tcAdd')))),
|
|
3567
|
+
importHint ? h('div', { className: 'at-modalmeta' }, t(importHint)) : null,
|
|
3568
|
+
fileAccept ? h('div', { className: 'at-field' },
|
|
3569
|
+
canImportPack ? h('div', { className: 'at-modalmeta' }, t(catalog.workspace ? 'tcHostProjectRoot' : 'tcHostUserRoot')) : null,
|
|
3570
|
+
canImportPack ? h('input', { ref: folderInput, type: 'file', webkitdirectory: '', multiple: true, hidden: true, 'aria-label': t('tcHostFolder'), onChange: (event) => importSelected(event, true) }) : null,
|
|
3571
|
+
h('input', { ref: fileInput, type: 'file', accept: fileAccept, hidden: true, 'aria-label': fileLabel, onChange: (event) => importSelected(event, false) }),
|
|
3572
|
+
h('div', { className: 'at-tcpick' },
|
|
3573
|
+
h('button', { type: 'button', className: 'at-btn', disabled: busy, onClick: () => fileInput.current?.click() }, fileLabel),
|
|
3574
|
+
canImportPack ? h('button', { type: 'button', className: 'at-btn', disabled: busy, onClick: () => folderInput.current?.click() }, withIco('folderPlus', t('tcHostFolder'))) : null)) : null,
|
|
3575
|
+
progress ? h('div', { className: 'at-modalmeta', role: 'status' }, t(progress)) : null,
|
|
3576
|
+
error ? h('div', { className: 'at-modalerror', role: 'alert' }, error) : null)) : null);
|
|
3577
|
+
}
|
|
3389
3578
|
function TalentCreator({ t, initial, onSaved, onCancel }) {
|
|
3390
3579
|
const seed = initial && initial.draft ? talentCreatorInit(initial) : null;
|
|
3391
3580
|
const [form, setForm] = React.useState(() => (seed ? seed.form : blankTalentForm()));
|
|
@@ -3397,6 +3586,8 @@ window.__ModuleLoader__.load({
|
|
|
3397
3586
|
const [skBody, setSkBody] = React.useState('');
|
|
3398
3587
|
const [busy, setBusy] = React.useState(false);
|
|
3399
3588
|
const [error, setError] = React.useState('');
|
|
3589
|
+
const savedId = React.useRef('');
|
|
3590
|
+
const writtenSkills = React.useRef(new WeakSet());
|
|
3400
3591
|
const set = (key) => (event) => setForm((f) => ({ ...f, [key]: event.target.value }));
|
|
3401
3592
|
React.useEffect(() => {
|
|
3402
3593
|
let live = true;
|
|
@@ -3418,28 +3609,36 @@ window.__ModuleLoader__.load({
|
|
|
3418
3609
|
const name = skName.trim(); if (!name) return;
|
|
3419
3610
|
if (stage({ name, kind: 'write', markdown: skBody })) { setPick(''); setSkName(''); setSkBody(''); }
|
|
3420
3611
|
}
|
|
3421
|
-
function
|
|
3422
|
-
const
|
|
3423
|
-
const
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3612
|
+
async function importMarkdown(file) {
|
|
3613
|
+
const name = (file.name.replace(/\.md$/i, '').replace(/[^A-Za-z0-9._-]/g, '-').slice(0, 64)) || 'skill';
|
|
3614
|
+
const markdown = await new Promise((resolve, reject) => {
|
|
3615
|
+
const reader = new FileReader();
|
|
3616
|
+
reader.onerror = () => reject(reader.error);
|
|
3617
|
+
reader.onload = () => resolve(String(reader.result ?? ''));
|
|
3618
|
+
reader.readAsText(file);
|
|
3619
|
+
});
|
|
3620
|
+
return stage({ name, kind: 'write', markdown });
|
|
3429
3621
|
}
|
|
3430
3622
|
async function save() {
|
|
3431
3623
|
if (!form.name.trim() || busy) return;
|
|
3432
3624
|
setBusy(true); setError('');
|
|
3433
3625
|
try {
|
|
3434
|
-
const res = await fetch('/ai-team/api/talents', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({
|
|
3626
|
+
const res = await fetch('/ai-team/api/talents', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({
|
|
3627
|
+
...talentFormToBody(form),
|
|
3628
|
+
...(seed?.model ? { model: seed.model } : {}),
|
|
3629
|
+
...(savedId.current ? { id: savedId.current, overwrite: true } : {}),
|
|
3630
|
+
skills: pending.filter((sk) => sk.kind === 'host' || writtenSkills.current.has(sk)).map((sk) => sk.name),
|
|
3631
|
+
}) });
|
|
3435
3632
|
const body = await res.json().catch(() => null);
|
|
3436
3633
|
if (!res.ok) throw new Error((body && body.error && body.error.message) || ('HTTP ' + res.status));
|
|
3437
|
-
|
|
3634
|
+
savedId.current = body.talent.id;
|
|
3438
3635
|
for (const sk of pending) {
|
|
3636
|
+
if (sk.kind === 'host' || writtenSkills.current.has(sk)) continue;
|
|
3439
3637
|
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(
|
|
3638
|
+
const r2 = await fetch('/ai-team/api/talents/' + encodeURIComponent(savedId.current) + '/skills', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(payload) });
|
|
3441
3639
|
const b2 = await r2.json().catch(() => null);
|
|
3442
3640
|
if (!r2.ok) throw new Error(((b2 && b2.error && b2.error.message) || ('HTTP ' + r2.status)) + '(' + sk.name + ')');
|
|
3641
|
+
writtenSkills.current.add(sk);
|
|
3443
3642
|
}
|
|
3444
3643
|
onSaved();
|
|
3445
3644
|
} catch (err) {
|
|
@@ -3466,9 +3665,9 @@ window.__ModuleLoader__.load({
|
|
|
3466
3665
|
h('div', { className: 'at-field' }, h('span', null, t('tcSkills')),
|
|
3467
3666
|
pending.length === 0 ? h('div', { className: 'at-modalmeta' }, t('tcEmpty')) : h('div', { className: 'at-tcskills' }, pending.map((sk) => h('span', { key: sk.name, className: 'at-tcskill' }, sk.name, h('button', { type: 'button', 'aria-label': t('tcRemove'), onClick: () => setPending((pp) => pp.filter((x) => x.name !== sk.name)) }, '×')))),
|
|
3468
3667
|
h('div', { className: 'at-tcpick' },
|
|
3668
|
+
h(HostSkillPicker, { t, selectedNames: pending.map((skill) => skill.name), disabled: busy, onChoose: (name) => stage({ name, kind: 'host' }), onImportMarkdown: importMarkdown }),
|
|
3469
3669
|
h('button', { type: 'button', className: 'at-btn', onClick: () => setPick(pick === 'existing' ? '' : 'existing') }, withIco('store', t('tcAddExisting'))),
|
|
3470
|
-
h('button', { type: 'button', className: 'at-btn', onClick: () => setPick(pick === 'write' ? '' : 'write') }, withIco('pen', t('tcWriteOwn'))),
|
|
3471
|
-
h('label', { className: 'at-btn' }, withIco('folderPlus', t('tcImport')), h('input', { type: 'file', accept: '.md,text/markdown,text/plain', style: { display: 'none' }, onChange: importFile }))),
|
|
3670
|
+
h('button', { type: 'button', className: 'at-btn', onClick: () => setPick(pick === 'write' ? '' : 'write') }, withIco('pen', t('tcWriteOwn')))),
|
|
3472
3671
|
pick === 'existing' ? h('div', { className: 'at-tcpanel' }, h('select', { value: pickFrom, onChange: (e) => setPickFrom(e.target.value) }, h('option', { value: '' }, t('tcPick')), installable.map((sk) => h('option', { key: sk.talent + '::' + sk.name, value: sk.talent + '::' + sk.name }, sk.name + ' — ' + sk.talentName))), h('button', { type: 'button', className: 'at-btn at-btn-primary', onClick: addExisting }, t('tcAdd'))) : null,
|
|
3473
3672
|
pick === 'write' ? h('div', { className: 'at-tcpanel' }, h('input', { value: skName, placeholder: t('tcSkillName'), onChange: (e) => setSkName(e.target.value) }), h('textarea', { value: skBody, placeholder: t('tcSkillBody'), onChange: (e) => setSkBody(e.target.value) }), h('button', { type: 'button', className: 'at-btn at-btn-primary', onClick: addWritten }, t('tcAdd'))) : null),
|
|
3474
3673
|
error ? h('div', { className: 'at-modalerror', role: 'alert' }, error) : null,
|
|
@@ -3876,14 +4075,16 @@ window.__ModuleLoader__.load({
|
|
|
3876
4075
|
};
|
|
3877
4076
|
}
|
|
3878
4077
|
/**
|
|
3879
|
-
*
|
|
4078
|
+
* 「存为人才」:保留宿主技能引用,暂存可从成员复制的技能,单列找不到的技能。
|
|
3880
4079
|
*/
|
|
3881
4080
|
function talentCreatorInit(initial) {
|
|
3882
4081
|
const draft = (initial && initial.draft) || {};
|
|
3883
4082
|
const skills = Array.isArray(draft.skills) ? draft.skills : [];
|
|
3884
4083
|
return {
|
|
3885
4084
|
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) =>
|
|
4085
|
+
pending: skills.filter((x) => x && x.found).map((x) => x.host === true
|
|
4086
|
+
? { name: x.name, kind: 'host' }
|
|
4087
|
+
: { name: x.name, kind: 'member', fromProject: initial.projectId, fromMember: initial.memberId }),
|
|
3887
4088
|
missing: skills.filter((x) => x && !x.found).map((x) => x.name),
|
|
3888
4089
|
model: draft.model && (draft.model.provider || draft.model.model) ? draft.model : null,
|
|
3889
4090
|
sourceName: String(draft.name || ''),
|
|
@@ -5307,15 +5508,25 @@ window.__ModuleLoader__.load({
|
|
|
5307
5508
|
setPError(error?.message ?? String(error));
|
|
5308
5509
|
}
|
|
5309
5510
|
}
|
|
5310
|
-
async function addSkill() {
|
|
5311
|
-
|
|
5511
|
+
async function addSkill(name) {
|
|
5512
|
+
const memberId = profileAgent?.id;
|
|
5513
|
+
name = name.trim();
|
|
5514
|
+
if (!memberId || !name) return false;
|
|
5515
|
+
setPError('');
|
|
5516
|
+
const result = await runCommand('member.skill', { memberId, name });
|
|
5517
|
+
setProfileAgent((current) => current?.id === memberId ? result.member : current);
|
|
5518
|
+
void reloadData().catch((error) => setPError(error?.message ?? String(error)));
|
|
5519
|
+
return true;
|
|
5520
|
+
}
|
|
5521
|
+
async function addTypedSkill() {
|
|
5522
|
+
if (pBusy) return;
|
|
5523
|
+
setPBusy(true);
|
|
5312
5524
|
try {
|
|
5313
|
-
|
|
5314
|
-
setPSkill('');
|
|
5315
|
-
setProfileAgent(result.member);
|
|
5316
|
-
await reloadData();
|
|
5525
|
+
if (await addSkill(pSkill)) setPSkill('');
|
|
5317
5526
|
} catch (error) {
|
|
5318
5527
|
setPError(error?.message ?? String(error));
|
|
5528
|
+
} finally {
|
|
5529
|
+
setPBusy(false);
|
|
5319
5530
|
}
|
|
5320
5531
|
}
|
|
5321
5532
|
async function retryProfile() {
|
|
@@ -6274,9 +6485,11 @@ window.__ModuleLoader__.load({
|
|
|
6274
6485
|
h('button', { type: 'button', className: 'at-btn at-btn-small', title: t('skillEvolveHint'), onClick: () => void evolveSkill(profileAgent, name) }, withIco('spark', t('skillEvolve'), 12)))))
|
|
6275
6486
|
: h('div', { key: 'none', className: 'at-modalmeta' }, t('profileSkillsEmpty')),
|
|
6276
6487
|
pEvolve ? h('div', { key: 'ev', className: 'at-modalmeta', role: 'status' }, pEvolve) : null,
|
|
6488
|
+
h('div', { key: 'dsh-' + projectId + '/' + profileAgent.id, className: 'at-tcpick' },
|
|
6489
|
+
h(HostSkillPicker, { t, projectId, memberId: profileAgent.id, selectedNames: profileAgent.skills, disabled: pBusy, onChoose: addSkill })),
|
|
6277
6490
|
h('div', { key: 'add', className: 'at-inlineadd' },
|
|
6278
6491
|
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:
|
|
6492
|
+
h('button', { className: 'at-btn at-btn-small', type: 'button', onClick: addTypedSkill, disabled: pBusy || !pSkill.trim() }, withIco('plus', t('addSkill'), 12))),
|
|
6280
6493
|
] : null,
|
|
6281
6494
|
pTab === 'collab' ? [
|
|
6282
6495
|
h('label', { key: 'succ', className: 'at-field' }, h('span', null, t('successor')),
|