dsh-science-plugin 0.14.1 → 0.14.3

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.
Files changed (23) hide show
  1. package/README.md +26 -10
  2. package/client/client.js +153 -176
  3. package/client/client.js.map +2 -2
  4. package/cordis.patch.yml +6 -5
  5. package/lib/action-cards.js +7 -4
  6. package/lib/httpdata-auth.js +12 -21
  7. package/lib/httpdata.js +39 -44
  8. package/lib/index.js +1 -1
  9. package/lib/project-experts.js +94 -0
  10. package/lib/router.js +1 -1
  11. package/lib/skillmenu.js +85 -51
  12. package/lib/ssh.js +66 -20
  13. package/lib/team.js +19 -11
  14. package/package.json +7 -7
  15. package/skills/sci-hypothesis/SKILL.md +1 -1
  16. package/docs/DEVLOG.md +0 -864
  17. package/docs/SPEC.md +0 -452
  18. package/docs/research/2026-11-12-academic-figure-skill-/350/257/204/344/274/260.md +0 -33
  19. package/docs/research/2026-11-12-/347/247/221/347/240/224/347/273/230/345/233/276/345/274/200/346/272/220/346/226/271/346/241/210/350/260/203/347/240/224.md +0 -52
  20. package/docs/research/2026-11-13-/345/257/271/350/257/235/351/251/261/345/212/250/347/247/221/347/240/224/345/267/245/344/275/234/345/217/260/344/272/247/345/223/201/347/255/226/347/225/245/350/260/203/347/240/224.md +0 -319
  21. package/docs/research/2026-11-13-/350/267/257/347/272/277B/346/212/200/346/234/257/345/217/257/350/241/214/346/200/247/344/270/216/344/275/216/347/274/272/351/231/267/350/256/276/350/256/241/350/260/203/347/240/224.md +0 -65
  22. package/docs/superpowers/specs/2026-11-12-/347/247/221/347/240/224/345/267/245/344/275/234/345/217/260/351/207/215/346/236/204/350/256/276/350/256/241.md +0 -364
  23. package/docs/superpowers/specs/2026-11-13-/345/257/271/350/257/235/344/274/230/345/205/210/347/247/221/347/240/224/345/215/241/347/211/207/345/267/245/344/275/234/345/217/260/351/207/215/346/236/204/350/256/276/350/256/241.md +0 -607
package/cordis.patch.yml CHANGED
@@ -1,10 +1,11 @@
1
1
  - insert:
2
2
  - id: dsh-science
3
3
  name: dsh-science-plugin
4
- # 确认卡(Action Cards):Host 负责 proposal/decision 与 kind 注册;Client 负责在对话回答
5
- # 下方渲染卡片。两者必须同时加载(官方 @deepseek-ai/dsh-personalized-recommendations
6
- # bundle 同样成对声明)。使用当前 DSH 运行时提供的配套版本。
7
- - id: dsh-science-action-cards
4
+ # Older Web profiles lack one or both card entries. Honor any host-configured
5
+ # entry (including disabled entries) and only supply the missing component.
6
+ - id: dsh-science-legacy-cards-host
8
7
  name: '@deepseek-ai/dsh-action-cards'
9
- - id: dsh-science-client-ui-action-cards
8
+ disabled: !!js "ctx[Symbol.for('cordis.entry')].parent.data.some(row => row.name === '@deepseek-ai/dsh-action-cards' && row.id !== 'dsh-science-legacy-cards-host')"
9
+ - id: dsh-science-legacy-cards-client
10
10
  name: '@deepseek-ai/dsh-client-ui-action-cards'
11
+ disabled: !!js "ctx[Symbol.for('cordis.entry')].parent.data.some(row => row.name === '@deepseek-ai/dsh-client-ui-action-cards' && row.id !== 'dsh-science-legacy-cards-client')"
@@ -64,6 +64,9 @@ export function scienceConfirmKind({ store, actionCards }) {
64
64
  if (!gate.ok) {
65
65
  return { status: 'refused', reason: '当前会话没有论文写权限(成员只能提交提案)' }
66
66
  }
67
+ const id = proposal.cardId ?? proposal.callId
68
+ if (typeof id !== 'string' || !id) return { status: 'refused', reason: '确认卡缺少宿主标识' }
69
+ const identity = proposal.cardId ? { cardId: id } : { callId: id }
67
70
  const details = proposal.details
68
71
  if (!details.expectedHash) {
69
72
  return { status: 'refused', reason: '卡片缺少对象内容哈希(expectedHash),请让队长基于最新状态重新发起确认' }
@@ -71,7 +74,7 @@ export function scienceConfirmKind({ store, actionCards }) {
71
74
  if (verb === 'reject') {
72
75
  // T4:退回不写入论文语义,只记录一条可追溯 decision;用户入口回到对话说明修改意见。
73
76
  const decision = {
74
- callId: proposal.callId,
77
+ ...identity,
75
78
  action: SCIENCE_CONFIRM_ACTION,
76
79
  phase: 'rejected',
77
80
  data: {
@@ -90,7 +93,7 @@ export function scienceConfirmKind({ store, actionCards }) {
90
93
  }
91
94
  // 卡片携带用户实际看到的项目 revision:先按它做一次项目级 CAS;若仅无关对象变化导致
92
95
  // 项目 revision 前进,则重读目标对象后允许(对象 revision+hash 未变);目标变化仍拒绝。
93
- const cardOptions = { mutationId: `card-${proposal.callId}`, source: 'action-card' }
96
+ const cardOptions = { mutationId: `card-${id}`, source: 'action-card' }
94
97
  let result = confirmObjectRevision(store, ref, {
95
98
  objectId: details.objectId,
96
99
  expectedObjectRevision: details.objectRevision,
@@ -106,7 +109,7 @@ export function scienceConfirmKind({ store, actionCards }) {
106
109
  if (result.kind === 'applied') {
107
110
  // L6:仅在真正应用时记录 decision——already-applied 重放不追加重复回执
108
111
  const decision = {
109
- callId: proposal.callId,
112
+ ...identity,
110
113
  action: SCIENCE_CONFIRM_ACTION,
111
114
  phase: 'confirmed',
112
115
  data: {
@@ -124,7 +127,7 @@ export function scienceConfirmKind({ store, actionCards }) {
124
127
  return {
125
128
  status: 'settled',
126
129
  decision: {
127
- callId: proposal.callId,
130
+ ...identity,
128
131
  action: SCIENCE_CONFIRM_ACTION,
129
132
  phase: 'confirmed',
130
133
  data: {
@@ -4,27 +4,19 @@
4
4
 
5
5
  const WEB_SERVER_KEYS = ['webServer', 'httpServer']
6
6
 
7
- function requestRejectionOf(ctx, req) {
7
+ export function requestRejectionOf(ctx, req, peer, failClosed = false) {
8
8
  try {
9
+ if (peer) return peer.principal?.kind === 'owner' ? undefined : 403
9
10
  const conn = ctx.get('connection')
10
- if (conn && typeof conn.requestRejection === 'function') return conn.requestRejection(req)
11
- } catch {
12
- /* ignore:回环地址本就仅本机可达 */
13
- }
14
- return undefined
15
- }
16
-
17
- // L3:fail-closed 变体——connection 服务缺失时返回 401(写端点用),读端点保持旧行为。
18
- function requestRejectionStrictOf(ctx, req) {
19
- let conn = null
20
- try {
21
- conn = ctx.get('connection')
11
+ if (typeof conn?.admit === 'function') {
12
+ const admission = conn.admit(req)
13
+ return admission.rejection ?? (admission.peer?.principal?.kind === 'owner' ? undefined : 403)
14
+ }
15
+ if (typeof conn?.requestRejection === 'function') return conn.requestRejection(req) || undefined
22
16
  } catch {
23
- conn = null
17
+ return 401
24
18
  }
25
- if (!conn || typeof conn.requestRejection !== 'function') return 401
26
- const r = conn.requestRejection(req)
27
- return r === undefined ? undefined : r
19
+ return failClosed ? 401 : undefined
28
20
  }
29
21
 
30
22
  /**
@@ -44,9 +36,8 @@ export function registerStateRouteShared(ctx, routes) {
44
36
  if (!server || typeof server.register !== 'function') return
45
37
  for (const route of routes) {
46
38
  const method = (route.method || 'GET').toUpperCase()
47
- const fenceOf = route.failClosed ? requestRejectionStrictOf : requestRejectionOf
48
- const wrapped = async (req, res) => {
49
- const rejection = fenceOf(ctx, req)
39
+ const wrapped = async (req, res, peer) => {
40
+ const rejection = requestRejectionOf(ctx, req, peer, route.failClosed)
50
41
  if (rejection !== undefined) {
51
42
  res.writeHead(rejection, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' })
52
43
  res.end(JSON.stringify({ error: rejection === 401 ? 'unauthorized' : 'forbidden' }))
@@ -75,7 +66,7 @@ export function registerStateRouteShared(ctx, routes) {
75
66
  }
76
67
  }
77
68
  }
78
- ctx.effect(() => server.register({ kind: 'exact', path: route.path, handler: wrapped }), `dsh-science: ${route.path}`)
69
+ ctx.effect(() => server.register({ kind: 'exact', auth: 'required', path: route.path, handler: wrapped }), `dsh-science: ${route.path}`)
79
70
  }
80
71
  registered = true
81
72
  }
package/lib/httpdata.js CHANGED
@@ -19,6 +19,7 @@
19
19
  // 鉴权:对齐 agent-teams 的 authenticatedWebRoutes 思路——经 ctx.get('connection').requestRejection(req)
20
20
  // 复用浏览器会话的认证栅栏(同源 fetch 自带凭证)。
21
21
 
22
+ import { requestRejectionOf } from './httpdata-auth.js'
22
23
  import manifest from '../package.json' with { type: 'json' }
23
24
  import { existsSync, readFileSync, readdirSync, realpathSync, statSync } from 'node:fs'
24
25
  import { extname, isAbsolute, join, relative, resolve } from 'node:path'
@@ -37,7 +38,8 @@ import { readScope, blueprintViewOf, contentHashOf } from './project-adapter.js'
37
38
  import { resolveProjectContext, createRecordScopeResolver, isRecordInProjectScope } from './project-context.js'
38
39
  // v0.9.0 角色技能库:/state 快照携带 catalog+installed(客户端勾选菜单);POST /skill-manage
39
40
  // 承接客户端勾选/自定义链接的安装与删除(鉴权与 state/file 同款会话栅栏)。
40
- import { installSkill, removeSkill, skillMenuSnapshot } from './skillmenu.js'
41
+ import { EXPERT_PRESETS, expertConfig, expertScope, changeExpertConfig, globalExpertSkills } from './project-experts.js'
42
+ import { installSkill, removeSkill, skillMenuSnapshot, legacyRoleSkills } from './skillmenu.js'
41
43
 
42
44
  function log(msg) {
43
45
  console.log(`[dsh-science httpdata] ${msg}`)
@@ -200,17 +202,6 @@ function listWorkspaceFiles() {
200
202
  return out
201
203
  }
202
204
 
203
- // 浏览器会话认证栅栏:connection 服务缺失时不拦(回环地址本就仅本机可达)
204
- function requestRejectionOf(ctx, req) {
205
- try {
206
- const conn = ctx.get('connection')
207
- if (conn && typeof conn.requestRejection === 'function') return conn.requestRejection(req)
208
- } catch {
209
- /* ignore */
210
- }
211
- return undefined
212
- }
213
-
214
205
  function sendJson(res, code, payload) {
215
206
  res.writeHead(code, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' })
216
207
  res.end(JSON.stringify(payload))
@@ -362,7 +353,7 @@ function buildLegacyStatePayload(ctx, store) {
362
353
  })),
363
354
  sshJobs: toList(loadJson('ssh-jobs.json')).sort((a, b) => (b.submittedAt || 0) - (a.submittedAt || 0)),
364
355
  roles: rolesPayload(),
365
- skillMenu: skillMenuSnapshot(),
356
+ skillMenu: { installed: {}, catalog: {}, integrations: [] },
366
357
  mascotLead: LEAD_MASCOT,
367
358
  memberLive: memberLiveOf(ctx, members, team.tasks),
368
359
  files: listWorkspaceFiles(),
@@ -459,7 +450,7 @@ function buildSessionStatePayload(ctx, store, sessionId) {
459
450
  })),
460
451
  sshJobs: toList(loadJson('ssh-jobs.json')).sort((a, b) => (b.submittedAt || 0) - (a.submittedAt || 0)),
461
452
  roles: rolesPayload(),
462
- skillMenu: skillMenuSnapshot(),
453
+ skillMenu: ref.projectId ? skillMenuSnapshot(ref.projectId) : { installed: {}, catalog: {}, integrations: [] },
463
454
  mascotLead: LEAD_MASCOT,
464
455
  memberLive: memberLiveOf(ctx, members, tasks),
465
456
  files: listWorkspaceFiles(),
@@ -544,9 +535,10 @@ export function registerStateRoute(ctx, opts = {}) {
544
535
  server.register({
545
536
  kind: 'exact',
546
537
  path: '/plugins/dsh-science/state',
547
- handler: async (req, res) => {
538
+ auth: 'required',
539
+ handler: async (req, res, peer) => {
548
540
  try {
549
- const rejection = requestRejectionOf(ctx, req)
541
+ const rejection = requestRejectionOf(ctx, req, peer)
550
542
  if (rejection !== undefined) {
551
543
  sendJson(res, rejection, { error: rejection === 401 ? 'unauthorized' : 'forbidden' })
552
544
  return
@@ -597,9 +589,10 @@ export function registerStateRoute(ctx, opts = {}) {
597
589
  server.register({
598
590
  kind: 'exact',
599
591
  path: '/plugins/dsh-science/file',
600
- handler: async (req, res) => {
592
+ auth: 'required',
593
+ handler: async (req, res, peer) => {
601
594
  try {
602
- const rejection = requestRejectionOf(ctx, req)
595
+ const rejection = requestRejectionOf(ctx, req, peer)
603
596
  if (rejection !== undefined) {
604
597
  sendJson(res, rejection, { error: rejection === 401 ? 'unauthorized' : 'forbidden' })
605
598
  return
@@ -679,9 +672,10 @@ export function registerStateRoute(ctx, opts = {}) {
679
672
  server.register({
680
673
  kind: 'exact',
681
674
  path: '/plugins/dsh-science/review',
682
- handler: async (req, res) => {
675
+ auth: 'required',
676
+ handler: async (req, res, peer) => {
683
677
  try {
684
- const rejection = requestRejectionOf(ctx, req)
678
+ const rejection = requestRejectionOf(ctx, req, peer)
685
679
  if (rejection !== undefined) {
686
680
  sendJson(res, rejection, { error: rejection === 401 ? 'unauthorized' : 'forbidden' })
687
681
  return
@@ -746,9 +740,10 @@ export function registerStateRoute(ctx, opts = {}) {
746
740
  server.register({
747
741
  kind: 'prefix',
748
742
  path: '/plugins/dsh-science/assets',
749
- handler: async (req, res) => {
743
+ auth: 'required',
744
+ handler: async (req, res, peer) => {
750
745
  // 与 state/file 路由相同的浏览器会话认证栅栏(同源 <img> 自带凭证)
751
- const rejection = requestRejectionOf(ctx, req)
746
+ const rejection = requestRejectionOf(ctx, req, peer)
752
747
  if (rejection !== undefined) {
753
748
  sendJson(res, rejection, { error: rejection === 401 ? 'unauthorized' : 'forbidden' })
754
749
  return
@@ -796,16 +791,11 @@ export function registerStateRoute(ctx, opts = {}) {
796
791
  server.register({
797
792
  kind: 'exact',
798
793
  path: '/plugins/dsh-science/skill-manage',
799
- handler: async (req, res) => {
794
+ auth: 'required',
795
+ handler: async (req, res, peer) => {
800
796
  // M2:写路由 fail-closed——connection 栅栏缺失时拒绝(不回环放行)
801
- let rejection
802
- try {
803
- const conn = ctx.get('connection')
804
- rejection = conn && typeof conn.requestRejection === 'function' ? conn.requestRejection(req) : 401
805
- } catch {
806
- rejection = 401
807
- }
808
- if (rejection !== undefined && rejection !== false) {
797
+ const rejection = requestRejectionOf(ctx, req, peer, true)
798
+ if (rejection !== undefined) {
809
799
  sendJson(res, rejection, { error: rejection === 401 ? 'unauthorized' : 'forbidden' })
810
800
  return
811
801
  }
@@ -821,20 +811,25 @@ export function registerStateRoute(ctx, opts = {}) {
821
811
  const action = String(body.action || '')
822
812
  const role = String(body.role || '')
823
813
  try {
824
- if (action === 'install') {
825
- const result = await installSkill({
826
- role,
827
- catalogId: body.repoId ? String(body.repoId) : null,
828
- repoUrl: body.repoUrl ? String(body.repoUrl) : null,
829
- name: body.name ? String(body.name) : null,
830
- })
831
- sendJson(res, result.ok ? 200 : 400, result)
832
- } else if (action === 'remove') {
833
- const result = await removeSkill({ role, name: body.name ? String(body.name) : null })
834
- sendJson(res, result.ok ? 200 : 400, result)
835
- } else {
836
- sendJson(res, 400, { error: 'action 必须是 install | remove' })
814
+ let ref
815
+ try { ref = expertScope(ctx, store, body.sessionId, action !== 'inspect') }
816
+ catch (error) { return sendJson(res, 403, { error: error.message }) }
817
+ const { projectId } = ref
818
+ if (body.expectedProjectId !== projectId) return sendJson(res, 409, { error: '当前项目已切换,请重新打开项目专家' })
819
+ if (action === 'inspect') {
820
+ const legacy = Object.fromEntries(Object.keys(ROLES).map(r => [r, legacyRoleSkills(r).map(e => e.name)]))
821
+ return sendJson(res, 200, { config: expertConfig(projectId), roles: rolesPayload(), presets: EXPERT_PRESETS, installed: skillMenuSnapshot(projectId).installed, global: await globalExpertSkills(ctx), legacy, writable: ref.capabilities.dispatch })
822
+ }
823
+ if (action === 'install' || action === 'remove') {
824
+ if (!expertConfig(projectId).roles.includes(role)) return sendJson(res, 400, { error: '请先选择该项目专家' })
825
+ const result = action === 'install' ? await installSkill({ role, projectId, catalogId: body.repoId, repoUrl: body.repoUrl, name: body.name })
826
+ : await removeSkill({ role, projectId, name: body.name })
827
+ return sendJson(res, result.ok ? 200 : 400, result)
837
828
  }
829
+ const choices = action === 'link' && body.kind === 'global' ? await globalExpertSkills(ctx) :
830
+ action === 'link' && body.kind === 'legacy' && Object.hasOwn(ROLES,role) ? legacyRoleSkills(role) : []
831
+ try { return sendJson(res, 200, { ok: true, config: changeExpertConfig(projectId, body, choices) }) }
832
+ catch (error) { return sendJson(res, 400, { error: error.message }) }
838
833
  } catch (err) {
839
834
  log(`skill-manage handler failed: ${err && err.message}`)
840
835
  sendJson(res, 500, { error: 'internal error' })
package/lib/index.js CHANGED
@@ -253,7 +253,7 @@ export function apply(ctx) {
253
253
  // v0.9.0 角色级 skill 菜单(sci_skill_menu/install/remove/installed)——安装走互斥队列,
254
254
  // 技能不进全局 skills registry,只经 spawnMember 提示词索引对成员生效。
255
255
  try {
256
- registerSkillMenuTools(ctx, { mirror })
256
+ registerSkillMenuTools(ctx, { mirror, store: projectStore })
257
257
  } catch (err) {
258
258
  log(`skillmenu tools register failed: ${err && err.message}`)
259
259
  }
@@ -0,0 +1,94 @@
1
+ import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs'
2
+ import { join } from 'node:path'
3
+ import { dataDirOf } from './store.js'
4
+ import { ROLES } from './roles.js'
5
+ import { resolveProjectContext } from './project-context.js'
6
+
7
+ export const EXPERT_PRESETS = {
8
+ literature: { label: '文献调研', roles: ['literature-scout', 'topic-designer'] },
9
+ data: { label: '数据分析', roles: ['analyst', 'figure-expert'] },
10
+ writing: { label: '论文写作', roles: ['writer', 'reviewer'] },
11
+ }
12
+
13
+ export function expertDirectory(projectId) {
14
+ if (typeof projectId !== 'string' || !/^[a-zA-Z0-9_-]{1,100}$/.test(projectId)) throw new Error('项目标识无效')
15
+ return join(dataDirOf(), 'project-experts', projectId)
16
+ }
17
+
18
+ export function expertConfig(projectId) {
19
+ if (projectId) {
20
+ try { return JSON.parse(readFileSync(join(expertDirectory(projectId), 'experts.json'), 'utf8')) }
21
+ catch (error) { if (error.code !== 'ENOENT') throw error }
22
+ }
23
+ let roles = []
24
+ if (projectId) {
25
+ try {
26
+ const team = JSON.parse(readFileSync(join(dataDirOf(), 'team.json'), 'utf8'))
27
+ roles = [...new Set((team.members || []).filter(m => m.projectId === projectId && Object.hasOwn(ROLES, m.role)).map(m => m.role))]
28
+ } catch (error) { if (error.code !== 'ENOENT') throw error }
29
+ }
30
+ return { roles, links: {}, configured: false }
31
+ }
32
+
33
+ export function expertScope(ctx, store, sessionId, write = false) {
34
+ if (!store) throw new Error('科研项目服务不可用')
35
+ const scope = resolveProjectContext(ctx, sessionId, { store })
36
+ if (!scope.ok || !scope.ref.projectId) throw new Error('请在已绑定的科研项目中配置专家')
37
+ if (!(write ? scope.ref.capabilities.dispatch : scope.ref.capabilities.read)) throw new Error('当前会话没有此项目的操作权限')
38
+ return scope.ref
39
+ }
40
+
41
+ export async function globalExpertSkills(ctx) {
42
+ const service = ctx.skills || ctx.get?.('skills')
43
+ if (!service?.list) return []
44
+ const entries = await service.list()
45
+ return entries.filter(s => s.invocation?.modelInvocable !== false && !String(s.source).startsWith('project-'))
46
+ .map(({ name, source, provider, path }) => ({ name, source, provider, ...(path ? { path } : {}) }))
47
+ .sort((a,b) => a.name.localeCompare(b.name))
48
+ }
49
+
50
+ function pluginSource(value) {
51
+ try {
52
+ const url = new URL(value)
53
+ if (url.protocol === 'https:' && !url.username && !url.password && !url.port &&
54
+ (((url.hostname === 'github.com' || url.hostname === 'gitlab.com') && /^\/[\w.-]+\/[\w.-]+\/?$/.test(url.pathname)) ||
55
+ (['npmjs.com','www.npmjs.com'].includes(url.hostname) && /^\/package\/(?:@[\w.-]+\/)?[\w.-]+\/?$/.test(url.pathname)))) return url.origin + url.pathname.replace(/\/$/, '')
56
+ } catch {}
57
+ throw new Error('请输入 GitHub、GitLab 仓库首页或 npm 包链接')
58
+ }
59
+
60
+ // Apply one user action to the latest file. All read/modify/rename operations
61
+ // are synchronous within the host process, including concurrent browser tabs.
62
+ export function changeExpertConfig(projectId, { action, role, value, kind }, choices = []) {
63
+ const config = expertConfig(projectId)
64
+ if (action === 'preset') {
65
+ if (!Object.hasOwn(EXPERT_PRESETS, value)) throw new Error('未知方案')
66
+ config.roles = [...new Set([...config.roles, ...EXPERT_PRESETS[value].roles])]
67
+ } else {
68
+ if (!Object.hasOwn(ROLES, role)) throw new Error('未知专家')
69
+ if (action === 'add') config.roles = [...new Set([...config.roles, role])]
70
+ else if (action === 'hide') config.roles = config.roles.filter(r => r !== role)
71
+ else {
72
+ if (!config.roles.includes(role)) throw new Error('请先选择该专家')
73
+ const links = config.links[role] || []
74
+ if (action === 'unlink') config.links[role] = links.filter(l => l.kind !== kind || l.value !== value)
75
+ else if (action === 'link') {
76
+ let item
77
+ if (kind === 'plugin') item = { kind, value: pluginSource(value) }
78
+ else if (kind === 'global' || kind === 'legacy') {
79
+ const skill = choices.find(s => s.name === value)
80
+ if (!skill) throw new Error('此技能已经不可用')
81
+ item = { kind, value, ...(kind === 'global' ? { provider: skill.provider, source: skill.source } : {}) }
82
+ } else throw new Error('未知扩展类型')
83
+ config.links[role] = [...links.filter(l => l.kind !== kind || l.value !== item.value), item]
84
+ } else throw new Error('未知配置操作')
85
+ }
86
+ }
87
+ config.configured = true
88
+ const dir = expertDirectory(projectId)
89
+ mkdirSync(dir, { recursive: true })
90
+ const file = join(dir, 'experts.json')
91
+ writeFileSync(file + '.tmp', JSON.stringify(config), 'utf8')
92
+ renameSync(file + '.tmp', file)
93
+ return config
94
+ }
package/lib/router.js CHANGED
@@ -29,7 +29,7 @@ export function routerText() {
29
29
  roleMapText() + '。',
30
30
  '- 用户要汇报/总结成 PPT(组会汇报/进展汇报/答辩准备):派 presenter 成员,输入 = sci_blueprint_overview 输出(核心主张/Results/claims)+ sci_figure_list 输出(登记图表)+ 任务回报摘要;产出放工作区 slides/ 目录。成稿后建议派 sci_review_send scope=journal 对汇报做模拟审稿。',
31
31
  '- 简单对话、澄清提问、面向用户的简短答复由你直接回答,不必派单。',
32
- '- 派单统一用 sci_team_dispatch(建任务 + 指派 + 唤醒成员);成员尚未生成时先 sci_team_spawn(或 sci_team_spawn_all 整队生成)。用 sci_team_status 查看成员与任务板现状。',
32
+ '- 派单统一用 sci_team_dispatch(建任务 + 指派 + 唤醒成员);成员尚未生成时先 sci_team_spawn(sci_team_spawn_all 仅启动「项目专家」中已选的角色)。用 sci_team_status 查看成员与任务板现状。',
33
33
  '- 负例:即使一条 SQL、一张图也走 sci_team_dispatch 派给对应成员——除非用户明确要求你亲自做。',
34
34
  '- 例外(只读抽查,X4):队长可用 sci_db_query 对数据库做只读抽查(SELECT 类点查/计数,用于核对成员回报的数值是否属实);不写结论、不改数据、不产出图表——凡进入文章的证据性分析(支撑 claim 的查询/统计/建模/绘图)一律派单给对应成员。',
35
35
  '- 成员各自掌握专业技能(文献检索/绘图规范/写作规范/模拟工具档案等),自主使用,无需你逐步指导;你只给目标、输入与期望输出。',