dsh-science-plugin 0.14.0 → 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.
- package/README.md +37 -9
- package/agents/_README.md +5 -5
- package/agents/figure-expert.md +35 -35
- package/agents/presentation.md +78 -78
- package/agents/simulator.md +30 -30
- package/agents/topic-designer.md +26 -26
- package/agents/trainer.md +36 -36
- package/client/client.js +154 -177
- package/client/client.js.map +2 -2
- package/cordis.patch.yml +11 -12
- package/lib/action-cards.js +7 -4
- package/lib/db.js +386 -386
- package/lib/httpdata-auth.js +12 -21
- package/lib/httpdata.js +41 -45
- package/lib/index.js +3 -2
- package/lib/project-experts.js +94 -0
- package/lib/router.js +1 -1
- package/lib/skillmenu.js +87 -52
- package/lib/ssh.js +66 -20
- package/lib/store.js +50 -50
- package/lib/team.js +19 -11
- package/package.json +74 -71
- package/skills/sci-autoresearch/SKILL.md +41 -41
- package/skills/sci-hypothesis/SKILL.md +31 -31
- package/skills/sci-polish/SKILL.md +28 -28
- package/skills/sci-slides/SKILL.md +73 -73
- package/skills/sci-writing/SKILL.md +33 -33
- package/docs/DEVLOG.md +0 -864
- package/docs/SPEC.md +0 -452
- package/docs/research/2026-11-12-academic-figure-skill-/350/257/204/344/274/260.md +0 -33
- 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
- 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
- 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
- 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
- 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/lib/httpdata-auth.js
CHANGED
|
@@ -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 (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
17
|
+
return 401
|
|
24
18
|
}
|
|
25
|
-
|
|
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
|
|
48
|
-
|
|
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,8 @@
|
|
|
19
19
|
// 鉴权:对齐 agent-teams 的 authenticatedWebRoutes 思路——经 ctx.get('connection').requestRejection(req)
|
|
20
20
|
// 复用浏览器会话的认证栅栏(同源 fetch 自带凭证)。
|
|
21
21
|
|
|
22
|
+
import { requestRejectionOf } from './httpdata-auth.js'
|
|
23
|
+
import manifest from '../package.json' with { type: 'json' }
|
|
22
24
|
import { existsSync, readFileSync, readdirSync, realpathSync, statSync } from 'node:fs'
|
|
23
25
|
import { extname, isAbsolute, join, relative, resolve } from 'node:path'
|
|
24
26
|
import { dataDirOf, PKG_ROOT_OF } from './store.js'
|
|
@@ -36,14 +38,15 @@ import { readScope, blueprintViewOf, contentHashOf } from './project-adapter.js'
|
|
|
36
38
|
import { resolveProjectContext, createRecordScopeResolver, isRecordInProjectScope } from './project-context.js'
|
|
37
39
|
// v0.9.0 角色技能库:/state 快照携带 catalog+installed(客户端勾选菜单);POST /skill-manage
|
|
38
40
|
// 承接客户端勾选/自定义链接的安装与删除(鉴权与 state/file 同款会话栅栏)。
|
|
39
|
-
import {
|
|
41
|
+
import { EXPERT_PRESETS, expertConfig, expertScope, changeExpertConfig, globalExpertSkills } from './project-experts.js'
|
|
42
|
+
import { installSkill, removeSkill, skillMenuSnapshot, legacyRoleSkills } from './skillmenu.js'
|
|
40
43
|
|
|
41
44
|
function log(msg) {
|
|
42
45
|
console.log(`[dsh-science httpdata] ${msg}`)
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
const WEB_SERVER_KEYS = ['webServer', 'httpServer']
|
|
46
|
-
const VERSION =
|
|
49
|
+
const VERSION = manifest.version
|
|
47
50
|
const FILE_MAX_BYTES = 20 * 1024 * 1024
|
|
48
51
|
const FILE_TYPES = {
|
|
49
52
|
'.png': 'image/png',
|
|
@@ -199,17 +202,6 @@ function listWorkspaceFiles() {
|
|
|
199
202
|
return out
|
|
200
203
|
}
|
|
201
204
|
|
|
202
|
-
// 浏览器会话认证栅栏:connection 服务缺失时不拦(回环地址本就仅本机可达)
|
|
203
|
-
function requestRejectionOf(ctx, req) {
|
|
204
|
-
try {
|
|
205
|
-
const conn = ctx.get('connection')
|
|
206
|
-
if (conn && typeof conn.requestRejection === 'function') return conn.requestRejection(req)
|
|
207
|
-
} catch {
|
|
208
|
-
/* ignore */
|
|
209
|
-
}
|
|
210
|
-
return undefined
|
|
211
|
-
}
|
|
212
|
-
|
|
213
205
|
function sendJson(res, code, payload) {
|
|
214
206
|
res.writeHead(code, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' })
|
|
215
207
|
res.end(JSON.stringify(payload))
|
|
@@ -361,7 +353,7 @@ function buildLegacyStatePayload(ctx, store) {
|
|
|
361
353
|
})),
|
|
362
354
|
sshJobs: toList(loadJson('ssh-jobs.json')).sort((a, b) => (b.submittedAt || 0) - (a.submittedAt || 0)),
|
|
363
355
|
roles: rolesPayload(),
|
|
364
|
-
skillMenu:
|
|
356
|
+
skillMenu: { installed: {}, catalog: {}, integrations: [] },
|
|
365
357
|
mascotLead: LEAD_MASCOT,
|
|
366
358
|
memberLive: memberLiveOf(ctx, members, team.tasks),
|
|
367
359
|
files: listWorkspaceFiles(),
|
|
@@ -458,7 +450,7 @@ function buildSessionStatePayload(ctx, store, sessionId) {
|
|
|
458
450
|
})),
|
|
459
451
|
sshJobs: toList(loadJson('ssh-jobs.json')).sort((a, b) => (b.submittedAt || 0) - (a.submittedAt || 0)),
|
|
460
452
|
roles: rolesPayload(),
|
|
461
|
-
skillMenu: skillMenuSnapshot(),
|
|
453
|
+
skillMenu: ref.projectId ? skillMenuSnapshot(ref.projectId) : { installed: {}, catalog: {}, integrations: [] },
|
|
462
454
|
mascotLead: LEAD_MASCOT,
|
|
463
455
|
memberLive: memberLiveOf(ctx, members, tasks),
|
|
464
456
|
files: listWorkspaceFiles(),
|
|
@@ -543,9 +535,10 @@ export function registerStateRoute(ctx, opts = {}) {
|
|
|
543
535
|
server.register({
|
|
544
536
|
kind: 'exact',
|
|
545
537
|
path: '/plugins/dsh-science/state',
|
|
546
|
-
|
|
538
|
+
auth: 'required',
|
|
539
|
+
handler: async (req, res, peer) => {
|
|
547
540
|
try {
|
|
548
|
-
const rejection = requestRejectionOf(ctx, req)
|
|
541
|
+
const rejection = requestRejectionOf(ctx, req, peer)
|
|
549
542
|
if (rejection !== undefined) {
|
|
550
543
|
sendJson(res, rejection, { error: rejection === 401 ? 'unauthorized' : 'forbidden' })
|
|
551
544
|
return
|
|
@@ -596,9 +589,10 @@ export function registerStateRoute(ctx, opts = {}) {
|
|
|
596
589
|
server.register({
|
|
597
590
|
kind: 'exact',
|
|
598
591
|
path: '/plugins/dsh-science/file',
|
|
599
|
-
|
|
592
|
+
auth: 'required',
|
|
593
|
+
handler: async (req, res, peer) => {
|
|
600
594
|
try {
|
|
601
|
-
const rejection = requestRejectionOf(ctx, req)
|
|
595
|
+
const rejection = requestRejectionOf(ctx, req, peer)
|
|
602
596
|
if (rejection !== undefined) {
|
|
603
597
|
sendJson(res, rejection, { error: rejection === 401 ? 'unauthorized' : 'forbidden' })
|
|
604
598
|
return
|
|
@@ -678,9 +672,10 @@ export function registerStateRoute(ctx, opts = {}) {
|
|
|
678
672
|
server.register({
|
|
679
673
|
kind: 'exact',
|
|
680
674
|
path: '/plugins/dsh-science/review',
|
|
681
|
-
|
|
675
|
+
auth: 'required',
|
|
676
|
+
handler: async (req, res, peer) => {
|
|
682
677
|
try {
|
|
683
|
-
const rejection = requestRejectionOf(ctx, req)
|
|
678
|
+
const rejection = requestRejectionOf(ctx, req, peer)
|
|
684
679
|
if (rejection !== undefined) {
|
|
685
680
|
sendJson(res, rejection, { error: rejection === 401 ? 'unauthorized' : 'forbidden' })
|
|
686
681
|
return
|
|
@@ -745,9 +740,10 @@ export function registerStateRoute(ctx, opts = {}) {
|
|
|
745
740
|
server.register({
|
|
746
741
|
kind: 'prefix',
|
|
747
742
|
path: '/plugins/dsh-science/assets',
|
|
748
|
-
|
|
743
|
+
auth: 'required',
|
|
744
|
+
handler: async (req, res, peer) => {
|
|
749
745
|
// 与 state/file 路由相同的浏览器会话认证栅栏(同源 <img> 自带凭证)
|
|
750
|
-
const rejection = requestRejectionOf(ctx, req)
|
|
746
|
+
const rejection = requestRejectionOf(ctx, req, peer)
|
|
751
747
|
if (rejection !== undefined) {
|
|
752
748
|
sendJson(res, rejection, { error: rejection === 401 ? 'unauthorized' : 'forbidden' })
|
|
753
749
|
return
|
|
@@ -795,16 +791,11 @@ export function registerStateRoute(ctx, opts = {}) {
|
|
|
795
791
|
server.register({
|
|
796
792
|
kind: 'exact',
|
|
797
793
|
path: '/plugins/dsh-science/skill-manage',
|
|
798
|
-
|
|
794
|
+
auth: 'required',
|
|
795
|
+
handler: async (req, res, peer) => {
|
|
799
796
|
// M2:写路由 fail-closed——connection 栅栏缺失时拒绝(不回环放行)
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
const conn = ctx.get('connection')
|
|
803
|
-
rejection = conn && typeof conn.requestRejection === 'function' ? conn.requestRejection(req) : 401
|
|
804
|
-
} catch {
|
|
805
|
-
rejection = 401
|
|
806
|
-
}
|
|
807
|
-
if (rejection !== undefined && rejection !== false) {
|
|
797
|
+
const rejection = requestRejectionOf(ctx, req, peer, true)
|
|
798
|
+
if (rejection !== undefined) {
|
|
808
799
|
sendJson(res, rejection, { error: rejection === 401 ? 'unauthorized' : 'forbidden' })
|
|
809
800
|
return
|
|
810
801
|
}
|
|
@@ -820,20 +811,25 @@ export function registerStateRoute(ctx, opts = {}) {
|
|
|
820
811
|
const action = String(body.action || '')
|
|
821
812
|
const role = String(body.role || '')
|
|
822
813
|
try {
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
sendJson(res,
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
sendJson(res,
|
|
834
|
-
|
|
835
|
-
|
|
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)
|
|
836
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 }) }
|
|
837
833
|
} catch (err) {
|
|
838
834
|
log(`skill-manage handler failed: ${err && err.message}`)
|
|
839
835
|
sendJson(res, 500, { error: 'internal error' })
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import manifest from '../package.json' with { type: 'json' }
|
|
1
2
|
import { mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs'
|
|
2
3
|
import { join, dirname } from 'node:path'
|
|
3
4
|
import { fileURLToPath } from 'node:url'
|
|
@@ -20,7 +21,7 @@ import { dataDirOf, blockedGateOf, falsificationThresholdOf } from './store.js'
|
|
|
20
21
|
import { statusReportOf } from './status.js'
|
|
21
22
|
|
|
22
23
|
const PKG_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..')
|
|
23
|
-
const VERSION =
|
|
24
|
+
const VERSION = manifest.version
|
|
24
25
|
|
|
25
26
|
export const name = 'dsh-science'
|
|
26
27
|
export const inject = ['tools', 'commands', 'skills', 'sessions', 'agents', 'sessionPersistence', 'subagents', 'workingDirectory', 'systemPrompt']
|
|
@@ -252,7 +253,7 @@ export function apply(ctx) {
|
|
|
252
253
|
// v0.9.0 角色级 skill 菜单(sci_skill_menu/install/remove/installed)——安装走互斥队列,
|
|
253
254
|
// 技能不进全局 skills registry,只经 spawnMember 提示词索引对成员生效。
|
|
254
255
|
try {
|
|
255
|
-
registerSkillMenuTools(ctx, { mirror })
|
|
256
|
+
registerSkillMenuTools(ctx, { mirror, store: projectStore })
|
|
256
257
|
} catch (err) {
|
|
257
258
|
log(`skillmenu tools register failed: ${err && err.message}`)
|
|
258
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
|
|
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
|
'- 成员各自掌握专业技能(文献检索/绘图规范/写作规范/模拟工具档案等),自主使用,无需你逐步指导;你只给目标、输入与期望输出。',
|