dsh-science-plugin 0.0.0-stage → 0.14.0

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 (95) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +78 -2
  3. package/agents/_README.md +5 -0
  4. package/agents/analyst.md +27 -0
  5. package/agents/figure-expert.md +35 -0
  6. package/agents/literature-scout.md +32 -0
  7. package/agents/presentation.md +78 -0
  8. package/agents/reviewer.md +32 -0
  9. package/agents/simulator.md +30 -0
  10. package/agents/topic-designer.md +26 -0
  11. package/agents/trainer.md +36 -0
  12. package/agents/writer.md +44 -0
  13. package/assets/mascots/analyst.svg +33 -0
  14. package/assets/mascots/designer.svg +33 -0
  15. package/assets/mascots/figure.svg +35 -0
  16. package/assets/mascots/idle.svg +9 -0
  17. package/assets/mascots/lead.svg +33 -0
  18. package/assets/mascots/presentation.svg +40 -0
  19. package/assets/mascots/reviewer.svg +31 -0
  20. package/assets/mascots/scout.svg +31 -0
  21. package/assets/mascots/simulator.svg +33 -0
  22. package/assets/mascots/thinking.svg +23 -0
  23. package/assets/mascots/trainer.svg +32 -0
  24. package/assets/mascots/working.svg +9 -0
  25. package/assets/mascots/writer.svg +33 -0
  26. package/client/client.js +3425 -0
  27. package/client/client.js.map +7 -0
  28. package/cordis.patch.yml +12 -0
  29. package/docs/DEVLOG.md +864 -0
  30. package/docs/SPEC.md +452 -0
  31. package/docs/recipes/agent-teams-science.md +46 -0
  32. package/docs/research/2026-11-12-academic-figure-skill-/350/257/204/344/274/260.md +33 -0
  33. package/docs/research/2026-11-12-/347/224/237/347/211/251/347/247/221/347/240/224/350/203/275/345/212/233/344/270/216/345/267/245/344/275/234/345/217/260/351/233/206/346/210/220/350/260/203/347/240/224.md +169 -0
  34. 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 +52 -0
  35. 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 +319 -0
  36. 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 +65 -0
  37. 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 +364 -0
  38. 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 +607 -0
  39. package/icon.svg +6 -0
  40. package/lib/action-cards.js +194 -0
  41. package/lib/artifact-index.js +131 -0
  42. package/lib/blueprint.js +1487 -0
  43. package/lib/dag.js +69 -0
  44. package/lib/db.js +386 -0
  45. package/lib/figureqa.js +290 -0
  46. package/lib/figures.js +732 -0
  47. package/lib/httpdata-auth.js +91 -0
  48. package/lib/httpdata.js +862 -0
  49. package/lib/index.js +329 -0
  50. package/lib/lit.js +100 -0
  51. package/lib/paperspine.js +287 -0
  52. package/lib/project-adapter.js +259 -0
  53. package/lib/project-catalog.js +227 -0
  54. package/lib/project-context.js +282 -0
  55. package/lib/project-domain.js +849 -0
  56. package/lib/project-remote.js +348 -0
  57. package/lib/project-store.js +653 -0
  58. package/lib/rail-team.js +47 -0
  59. package/lib/resources.js +94 -0
  60. package/lib/reviewcov.js +238 -0
  61. package/lib/reviewer.js +638 -0
  62. package/lib/reviewruns.js +95 -0
  63. package/lib/roles.js +41 -0
  64. package/lib/router.js +133 -0
  65. package/lib/skeleton-context.js +181 -0
  66. package/lib/skillmenu.js +993 -0
  67. package/lib/ssh.js +637 -0
  68. package/lib/status.js +138 -0
  69. package/lib/store.js +50 -0
  70. package/lib/team.js +945 -0
  71. package/lib/vendor/ssh2.bundle.cjs +20124 -0
  72. package/lib/workspace-key.js +64 -0
  73. package/locale/en.json +7 -0
  74. package/locale/zh.json +7 -0
  75. package/package.json +71 -6
  76. package/skills/sci-autoresearch/SKILL.md +41 -0
  77. package/skills/sci-figures/SKILL.md +91 -0
  78. package/skills/sci-figures/references/journal-requirements.md +22 -0
  79. package/skills/sci-figures/references/r-figures.md +106 -0
  80. package/skills/sci-figures/scripts/figure_export.py +45 -0
  81. package/skills/sci-figures/scripts/style_presets.py +82 -0
  82. package/skills/sci-hypothesis/SKILL.md +37 -0
  83. package/skills/sci-polish/SKILL.md +28 -0
  84. package/skills/sci-remote-jobs/SKILL.md +48 -0
  85. package/skills/sci-simulation/SKILL.md +70 -0
  86. package/skills/sci-simulation/references/tool-dossiers/_TEMPLATE.md +25 -0
  87. package/skills/sci-simulation/references/tool-dossiers/ase.md +42 -0
  88. package/skills/sci-simulation/references/tool-dossiers/gaussian.md +42 -0
  89. package/skills/sci-simulation/references/tool-dossiers/gromacs.md +37 -0
  90. package/skills/sci-simulation/references/tool-dossiers/lammps.md +34 -0
  91. package/skills/sci-simulation/references/tool-dossiers/quantum-espresso.md +34 -0
  92. package/skills/sci-simulation/references/universal-tool-onboarding.md +117 -0
  93. package/skills/sci-slides/SKILL.md +73 -0
  94. package/skills/sci-slides/scripts/make_deck.py +332 -0
  95. package/skills/sci-writing/SKILL.md +33 -0
package/lib/status.js ADDED
@@ -0,0 +1,138 @@
1
+ // dsh-science — /sci-status 实时体检
2
+ // 读当前状态文件并给出计数、配置与唯一的下一步;空状态就是首次使用引导。
3
+ // 输出保持短行、可扫读,不罗列静态功能清单。
4
+
5
+ import { reviewSummariesOf } from './reviewruns.js'
6
+
7
+ function isObj(v) {
8
+ return v !== null && typeof v === 'object' && !Array.isArray(v)
9
+ }
10
+
11
+ function entriesOf(raw) {
12
+ if (Array.isArray(raw)) return raw.filter(isObj)
13
+ if (isObj(raw)) return Object.values(raw).filter(isObj)
14
+ return []
15
+ }
16
+
17
+ function oneLine(s, max = 80) {
18
+ const t = String(s ?? '').replace(/\s+/g, ' ').trim()
19
+ const chars = Array.from(t)
20
+ return chars.length > max ? `${chars.slice(0, max - 1).join('')}…` : t
21
+ }
22
+
23
+ // 超出 Date 可表示范围的毫秒值(如纳秒戳 1e20)会让 toISOString 抛 RangeError
24
+ const MAX_TIME_MS = 8.64e15
25
+
26
+ function isoMinuteOf(ms) {
27
+ if (!Number.isFinite(ms) || Math.abs(ms) > MAX_TIME_MS) return ''
28
+ return new Date(ms).toISOString().slice(0, 16).replace('T', ' ')
29
+ }
30
+
31
+ export function statusReportOf(input) {
32
+ const version = String((input && input.version) || '')
33
+ const dataDir = oneLine(input && input.dataDir, 120)
34
+ const workspaceRoot = oneLine(input && input.workspaceRoot, 120)
35
+ const bp = isObj(input && input.blueprint) ? input.blueprint : {}
36
+ const core = isObj(bp.core) ? bp.core : {}
37
+ const coreClaim = String(core.claim ?? '').trim()
38
+ const results = Array.isArray(bp.results) ? bp.results.filter(isObj) : []
39
+ const confirmedResults = results.filter((r) => r.confirmed === true).length
40
+ const team = isObj(input && input.team) ? input.team : {}
41
+ const members = Array.isArray(team.members) ? team.members.filter(isObj).length : 0
42
+ const allTasks = Array.isArray(team.tasks) ? team.tasks.filter(isObj) : []
43
+ const isDeleted = (t) => String(t.status ?? '').toLowerCase() === 'deleted'
44
+ const tasks = allTasks.filter((t) => !isDeleted(t))
45
+ const deletedTasks = allTasks.length - tasks.length
46
+ const doneTasks = tasks.filter((t) => t.status === 'completed').length
47
+
48
+ const summaries = reviewSummariesOf(input && input.reviews)
49
+ let fail = 0
50
+ let warn = 0
51
+ let abnormal = 0
52
+ let latest = 0
53
+ for (const s of summaries) {
54
+ fail += s.counts.fail
55
+ warn += s.counts.warn
56
+ if (s.status === 'parse-failed' || s.status === 'failed') abnormal++
57
+ latest = Math.max(latest, s.finishedAt || s.startedAt || 0)
58
+ }
59
+ const stateErrors = Array.isArray(input && input.stateErrors)
60
+ ? input.stateErrors.filter((x) => typeof x === 'string')
61
+ : []
62
+
63
+ const figures = entriesOf(input && input.figures).length
64
+ const dbProfiles = entriesOf(input && input.dbProfiles).length
65
+ const sshProfiles = entriesOf(input && input.sshProfiles).length
66
+ const sshJobs = entriesOf(input && input.sshJobs).length
67
+
68
+ const cfg = isObj(input && input.config) ? input.config : {}
69
+ const gate = String(cfg.blockedGate ?? '').trim().toLowerCase() === 'hard' ? 'hard' : 'warn'
70
+ const rawThreshold = cfg.falsificationThreshold
71
+ const thresholdNum =
72
+ typeof rawThreshold === 'number'
73
+ ? rawThreshold
74
+ : typeof rawThreshold === 'string' && /^\d+$/.test(rawThreshold.trim())
75
+ ? Number(rawThreshold.trim())
76
+ : NaN
77
+ const threshold = Number.isSafeInteger(thresholdNum) && thresholdNum >= 1 ? thresholdNum : 2
78
+
79
+ const error = oneLine(input && input.blueprintError, 80)
80
+ let bpLine
81
+ if (!coreClaim) bpLine = `未开始${error ? ` · ${error}` : ''}`
82
+ else bpLine = `核心已定 · ${results.length} 结果(已确认 ${confirmedResults})${error ? ` · ${error}` : ''}`
83
+
84
+ const latestText = latest
85
+ ? isoMinuteOf(latest)
86
+ ? ` · 最近 ${isoMinuteOf(latest)}`
87
+ : ' · 最近 时间异常'
88
+ : ''
89
+ const abnormalText = abnormal ? ` · 异常 ${abnormal}` : ''
90
+ const reviewLine = summaries.length
91
+ ? `${summaries.length} 次 · fail ${fail} / warn ${warn}${abnormalText}${latestText}`
92
+ : '0 次'
93
+ const stateErrorText = stateErrors.length ? ` · ${stateErrors.length} 个状态文件无法解析` : ''
94
+
95
+ let hint
96
+ if (!coreClaim) {
97
+ hint = '首次使用:sci_blueprint_set 写核心主张 → sci_result_add 拆 3–5 条可证伪结果 → sci_team_spawn / sci_team_dispatch 派任务;起草用 /sci-write。'
98
+ } else if (results.length === 0) {
99
+ hint = '下一步:sci_result_add 拆 3–5 条可证伪结果,再给结果挂任务与图表。'
100
+ } else if (tasks.length === 0) {
101
+ hint = '下一步:sci_team_spawn 组队后 sci_team_dispatch 派任务,或 /sci-write 直接起草。'
102
+ } else if (summaries.length === 0) {
103
+ hint = '下一步:/sci-review 审查最近一轮,结论会进入蓝图主张覆盖。'
104
+ } else if (core.confirmed === true) {
105
+ hint = '下一步:/sci-polish 或 sci_blueprint_export 整理写作材料。'
106
+ } else {
107
+ hint = '下一步:sci_blueprint_confirm 确认核心主张,再 /sci-polish 整理写作。'
108
+ }
109
+
110
+ return {
111
+ counts: {
112
+ members,
113
+ tasks: tasks.length,
114
+ deletedTasks,
115
+ doneTasks,
116
+ results: results.length,
117
+ confirmedResults,
118
+ reviews: summaries.length,
119
+ fail,
120
+ warn,
121
+ reviewAbnormal: abnormal,
122
+ stateErrors: stateErrors.length,
123
+ figures,
124
+ dbProfiles,
125
+ sshProfiles,
126
+ sshJobs,
127
+ },
128
+ lines: [
129
+ `dsh-science ${version} · 数据 ${dataDir || '—'} · 工作区 ${workspaceRoot || '—'}`,
130
+ `团队 ${members} 成员 · 任务 ${tasks.length}(完成 ${doneTasks})${deletedTasks ? ` · 已删 ${deletedTasks}` : ''}`,
131
+ `蓝图 ${bpLine}`,
132
+ `审查 ${reviewLine}`,
133
+ `资产 图表 ${figures} · DB ${dbProfiles} · SSH ${sshProfiles} / 作业 ${sshJobs}`,
134
+ `配置 依赖闸门 ${gate} · 证伪阈值 ${threshold}${stateErrorText}`,
135
+ hint,
136
+ ],
137
+ }
138
+ }
package/lib/store.js ADDED
@@ -0,0 +1,50 @@
1
+ // dsh-science — 共享存储路径(host 侧各模块共用)
2
+ import { existsSync, mkdirSync, readFileSync } from 'node:fs'
3
+ import { join } from 'node:path'
4
+ import { homedir } from 'node:os'
5
+
6
+ export function dataDirOf() {
7
+ const home = process.env.DSH_HOME || join(homedir(), '.dsh')
8
+ const dir = join(home, 'dsh-science')
9
+ if (!existsSync(dir)) mkdirSync(dir, { recursive: true })
10
+ return dir
11
+ }
12
+
13
+ import { dirname } from 'node:path'
14
+ import { fileURLToPath } from 'node:url'
15
+
16
+ /** 插件包根目录(lib/ 的上一级) */
17
+ export function PKG_ROOT_OF() {
18
+ return join(dirname(fileURLToPath(import.meta.url)), '..')
19
+ }
20
+
21
+ // 用户配置($DSH_HOME/dsh-science/config.json,手动编辑,改即生效):
22
+ // falsificationThreshold — 证伪风险触发的 negative 数阈值(正整数,默认 2)
23
+ // blockedGate — 派单依赖闸门:"warn"(默认,记录+提示)| "hard"(依赖未完成拒绝派发)
24
+ export function configOf() {
25
+ try {
26
+ const parsed = JSON.parse(readFileSync(join(dataDirOf(), 'config.json'), 'utf8'))
27
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) return parsed
28
+ } catch (err) {
29
+ if (err && err.code !== 'ENOENT') {
30
+ console.error(`[dsh-science] config.json 读取失败(按默认配置运行): ${err && err.message}`)
31
+ }
32
+ }
33
+ return {}
34
+ }
35
+
36
+ export function falsificationThresholdOf() {
37
+ // 只接受数字或纯十进制整数字符串;拒绝布尔(true→1)/十六进制串('0x10'→16)等 Number() 强转陷阱
38
+ const raw = configOf().falsificationThreshold
39
+ let v
40
+ if (typeof raw === 'number') v = raw
41
+ else if (typeof raw === 'string' && /^\d+$/.test(raw.trim())) v = Number(raw.trim())
42
+ else return 2
43
+ return Number.isSafeInteger(v) && v >= 1 ? v : 2
44
+ }
45
+
46
+ export function blockedGateOf() {
47
+ // 大小写/首尾空白不敏感,避免 'HARD' 一类笔误静默 fail-open 回退到 warn
48
+ const v = String(configOf().blockedGate ?? '').trim().toLowerCase()
49
+ return v === 'hard' ? 'hard' : 'warn'
50
+ }