@delta-infra/cli 1.0.79 → 1.0.80

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 (51) hide show
  1. package/README.md +17 -27
  2. package/checksums.txt +5 -5
  3. package/package.json +2 -13
  4. package/scripts/install-wizard.js +14 -5
  5. package/skills/delta-science/SKILL.md +128 -149
  6. package/skills/delta-science/agents/openai.yaml +3 -3
  7. package/skills/{antbo-service/references/operations.md → delta-science/references/antbo.md} +59 -4
  8. package/skills/delta-science/references/cli-contract.md +18 -19
  9. package/skills/delta-science/references/delta-bo.md +90 -0
  10. package/skills/{gsasii/references/endpoints.md → delta-science/references/gsasii.md} +13 -27
  11. package/skills/{lammps/references/endpoints.md → delta-science/references/lammps.md} +13 -8
  12. package/skills/{ldm-bo/references/endpoints.md → delta-science/references/ldm-bo.md} +12 -9
  13. package/skills/delta-science/references/ldm.md +72 -0
  14. package/skills/{pubchem/references/endpoints.md → delta-science/references/pubchem.md} +15 -10
  15. package/skills/{pymatgen/references/endpoints.md → delta-science/references/pymatgen.md} +9 -9
  16. package/skills/{rdkit/references/endpoints.md → delta-science/references/rdkit.md} +20 -14
  17. package/skills/delta-science/references/routing-index.md +36 -0
  18. package/skills/delta-science/references/strbo.md +87 -0
  19. package/skills/{synbo-service/references/endpoints.md → delta-science/references/synbo.md} +57 -17
  20. package/skills/delta-science/references/workflows.md +24 -7
  21. package/skills/delta-science/scripts/catalog.py +92 -0
  22. package/skills/delta-science/scripts/invoke.py +162 -79
  23. package/skills/manifest.json +3 -1
  24. package/skills/antbo-ldm-guard/SKILL.md +0 -58
  25. package/skills/antbo-ldm-guard/agents/openai.yaml +0 -4
  26. package/skills/antbo-service/SKILL.md +0 -79
  27. package/skills/antbo-service/agents/openai.yaml +0 -4
  28. package/skills/delta-bo/SKILL.md +0 -36
  29. package/skills/delta-bo/agents/openai.yaml +0 -4
  30. package/skills/delta-bo/references/endpoints.md +0 -263
  31. package/skills/delta-science/references/generated-catalog.md +0 -48
  32. package/skills/delta-science/references/operation-contracts.md +0 -137
  33. package/skills/delta-science/references/services.md +0 -112
  34. package/skills/delta-science/scripts/generated_catalog.py +0 -69
  35. package/skills/gsasii/SKILL.md +0 -42
  36. package/skills/gsasii/agents/openai.yaml +0 -4
  37. package/skills/lammps/SKILL.md +0 -39
  38. package/skills/lammps/agents/openai.yaml +0 -4
  39. package/skills/ldm-bo/SKILL.md +0 -35
  40. package/skills/ldm-bo/agents/openai.yaml +0 -4
  41. package/skills/pubchem/SKILL.md +0 -93
  42. package/skills/pubchem/agents/openai.yaml +0 -4
  43. package/skills/pubchem/references/operations.md +0 -41
  44. package/skills/pymatgen/SKILL.md +0 -54
  45. package/skills/pymatgen/agents/openai.yaml +0 -4
  46. package/skills/rdkit/SKILL.md +0 -112
  47. package/skills/rdkit/agents/openai.yaml +0 -4
  48. package/skills/rdkit/references/operations.md +0 -64
  49. package/skills/science-tools.json +0 -127
  50. package/skills/synbo-service/SKILL.md +0 -36
  51. package/skills/synbo-service/agents/openai.yaml +0 -4
@@ -1,112 +0,0 @@
1
- # 服务与参数参考
2
-
3
- 只读取当前所选服务对应的部分。下文中的 endpoint 是 Delta CLI catalog 名称,不是 URL 路径。
4
-
5
- ## PubChem
6
-
7
- Tool:`pubchem`。
8
-
9
- - 普通名称查询:`compound-summary`,data 为 `{"identifier":"caffeine","namespace":"name"}`。
10
- - 批量查询:`compound-batch-summary`。模糊的多分子比较必须严格使用 `{"identifiers":["aspirin","caffeine"],"namespace":"name"}`。
11
- - 批量查询不要添加 `properties` 或 `synonym_limit`,尤其不能把 `CID` 放进 `properties`。
12
- - 其他 operation:`compound-resolve-cids`、`compound-properties`、`compound-synonyms`。
13
-
14
- 单个 `compound-summary` 的业务字段直接位于 wrapper 的 `native` 顶层:读取
15
- `native.valid`、`native.cid`、`native.properties` 和 `native.synonyms`;不存在
16
- `native.data` 这一层。
17
-
18
- 模糊问题优先使用 summary。按 `CanonicalSMILES`、`ConnectivitySMILES`、`SMILES`、`IsomericSMILES` 的顺序提取 SMILES。PubChem 返回的 `MolecularWeight`、`XLogP` 和 `TPSA` 必须保留为 PubChem 数据。
19
-
20
- 批量 native 输出为 `{"results":[...]}`。每条记录用 `input` 保存原始标签,化合物字段位于嵌套的 `properties`;记录不是平铺结构,集合键也不是 `compounds`。
21
-
22
- ## RDKit
23
-
24
- Tool:`rdkit`。
25
-
26
- - `parse`:`{"input":"CCO","format":"smiles"}`
27
- - `descriptors`:`{"smiles":"CCO","descriptor_set":"basic","sanitize":true}`
28
- - `batch-parse-describe`:`{"molecules":[{"id":"ethanol","smiles":"CCO"}],"descriptor_set":"basic","sanitize":true}`
29
- - `render`:`{"smiles":"CCO","image_format":"png","width":500,"height":400}`
30
- - `similarity`:使用 `query_smiles` 和 `target_smiles`
31
- - `similarity-matrix`:使用 `molecules:[{id,smiles}]`
32
- - `substructure`:使用 `query_smarts` 和 `target_smiles`
33
-
34
- `batch-parse-describe` 使用 `molecules`,不能用 `inputs`;分子字段使用 `smiles`,不能用 `input`。fingerprint 选项是对象,不是布尔值。PubChem `XLogP` 与 RDKit `MolLogP` 使用不同模型。
35
-
36
- `similarity-matrix` 的 `ranked_pairs` 每项是
37
- `{"a": <输入 id>, "b": <输入 id>, "similarity": <数值>}`。不要读取
38
- `i`、`j` 或 `score`。
39
-
40
- ## pymatgen
41
-
42
- Tool:`pymatgen`。
43
-
44
- - 化学式:`composition-parse`,data 为 `{"formula":"LiFePO4","format":"formula"}`
45
- - 结构 operation:`structure-parse`、`structure-summary`、`structure-convert`、`structure-symmetry`
46
-
47
- 结构调用必须发送完整结构文本,不能发送本地文件路径。支持 CIF、POSCAR、JSON、CSSR 和 XSF。不要把 LAMMPS data/dump 文件交给 pymatgen。
48
-
49
- 对无机化学式/式量,只报告当前 native 的 `formula`、`reduced_formula`、
50
- `chemical_system`、`weight` 与元素组成。PubChem 未收录时保留 `not_found`,
51
- 不要编造 CID 或用本地计算补值。
52
-
53
- ## GSAS-II
54
-
55
- Tool:`gsasii`;operation 为 `powder-simulate` 和 `powder-refine`。
56
-
57
- 模拟需要完整 `cif` 文本。字段必须使用 `phase_name`、`include_profile`、`include_reflections`、`t_min`、`t_max` 和 `t_step`。
58
-
59
- 精修需要真实的 `powder_data`、`instrument_parameters` 和 `phases:[{name,cif}]`。依赖模拟结果时,只能从成功调用的 native `profile[*].x` 和 `profile[*].y_calc` 构造粉末数据。
60
-
61
- ## LAMMPS
62
-
63
- Tool:`lammps`。
64
-
65
- - 只读有界示例:`lj-melt-example`,无参数
66
- - 执行:`run`,参数必须是示例返回的精确 native `request`,或用户明确授权的 `input_script`/files
67
-
68
- 绝不能把 CLI 外层信封传给 `run`,只能传 `native["request"]`。LAMMPS 不会自动推断力场。交互式运行必须保持有界。
69
-
70
- 最小示例最终数值从当前 native `last_thermo` 读取;逐字保留 `Step`、`Temp`
71
- 和 `TotEng`,不要除以原子数、换算单位或推测收敛性。
72
-
73
- ## Delta-BO
74
-
75
- Tool:`delta-bo`。
76
-
77
- - 命令目录:`commands`,无参数
78
- - 无状态建议:`generate`,例如 `{"params":[{"name":"x","type":"numeric","low":0,"high":1}],"num_suggestions":2,"algorithm":"random-search","seed":42}`
79
-
80
- 观测少于五条时,除非用户明确要求 BO,否则优先使用 `random-search`。有状态 native session 命令属于变更操作,不能盲目重试。
81
-
82
- ## LDM-BO
83
-
84
- Tool:`ldm-bo`;operation 为 `recommend` 和 `trajectory`。
85
-
86
- 有界测试使用 `bo-tanimoto`。`recommend` 接受 `method`、`pool`、`history:[{smiles,scores}]` 和 `batch_size`。`trajectory` 必须保留 native 连字符字段:`seed-smiles`、`num-evaluations` 和 `batch-size`。
87
-
88
- ## SynBO
89
-
90
- Tool:`synbo`;operation 为 `initialize` 和 `optimize`。
91
-
92
- 二者都使用 `condition_dict`、`opt_metrics` 和 `batch_size`。`optimize` 还要求数值型 `previous_results`,且每条记录必须包含全部条件和指标。有界 CPU 测试使用 `accuracy:"tiny"` 和 `device:"cpu"`,并串行执行。
93
-
94
- 有真实 `previous_results` 的优化请求使用一次 `optimize`;每行必须包含全部条件列和
95
- 数值指标。失败、超时或空 recommendations 时如实报告,禁止本地替代优化。
96
-
97
- ## AntBO
98
-
99
- Tool:`antbo`。
100
-
101
- 当前 CLI catalog 暴露 `health`、`run-default-job`、`run`、`log`、`jobs` 和
102
- `stop`;准确参数见 `operation-contracts.md`。没有 `ldm/suggest`、
103
- `ldm/initialize`、`ldm/evaluate`。遇到 AntBO/CDRH3 的这些 LDM 请求时不要调用工具、
104
- 不要改用小分子 LDM-BO、不要探测目录或直连 HTTP;明确回复“当前 Delta CLI catalog
105
- 未暴露该 operation;未发送远端请求”。
106
-
107
- 启动作业只能根据同一次 native 的 `started`、`pid` 和 `log_name`/`log_path`
108
- 报告;任一字段缺失时标记为未验证,不要重复提交或编造作业信息。
109
-
110
- `health`、`log`、`jobs` 是只读调用。`run-default-job`、`run`、`stop` 会改变远端状态;
111
- `run-default-job` 的 `log_name`、`append`、`timeout_seconds` 使用 `--params-json`。
112
- 没有用户明确授权时不得启动或停止;未知结果不得重试。
@@ -1,69 +0,0 @@
1
- """Generated Science catalog aliases. Do not edit by hand."""
2
-
3
- LEGACY_TOOL_ALIASES = {
4
- "synbo": "synbo-service",
5
- "antbo": "antbo-service",
6
- }
7
-
8
- LEGACY_ENDPOINTS = {
9
- "pubchem": {
10
- "health": "chem_pubchem_health",
11
- "compound-resolve-cids": "chem_pubchem_compound_resolve-cids",
12
- "compound-properties": "chem_pubchem_compound_properties",
13
- "compound-synonyms": "chem_pubchem_compound_synonyms",
14
- "compound-summary": "chem_pubchem_compound_summary",
15
- "compound-batch-summary": "chem_pubchem_compound_batch-summary",
16
- },
17
- "rdkit": {
18
- "health": "chem_rdkit_health",
19
- "parse": "chem_rdkit_parse",
20
- "descriptors": "chem_rdkit_descriptors",
21
- "batch-descriptors": "chem_rdkit_batch-descriptors",
22
- "batch-parse-describe": "chem_rdkit_batch-parse-describe",
23
- "render": "chem_rdkit_render",
24
- "fingerprint": "chem_rdkit_fingerprint",
25
- "similarity": "chem_rdkit_similarity",
26
- "similarity-matrix": "chem_rdkit_similarity-matrix",
27
- "substructure": "chem_rdkit_substructure",
28
- },
29
- "pymatgen": {
30
- "health": "chem_pymatgen_health",
31
- "composition-parse": "chem_pymatgen_composition_parse",
32
- "structure-parse": "chem_pymatgen_structure_parse",
33
- "structure-summary": "chem_pymatgen_structure_summary",
34
- "structure-convert": "chem_pymatgen_structure_convert",
35
- "structure-symmetry": "chem_pymatgen_structure_symmetry",
36
- },
37
- "gsasii": {
38
- "health": "chem_gsasii_health",
39
- "powder-simulate": "chem_gsasii_powder_simulate",
40
- "powder-refine": "chem_gsasii_powder_refine",
41
- },
42
- "lammps": {
43
- "health": "chem_lammps_health",
44
- "lj-melt-example": "chem_lammps_examples_lj-melt",
45
- "run": "chem_lammps_run",
46
- },
47
- "delta-bo": {
48
- "commands": "chem_delta-bo_commands",
49
- "generate": "chem_delta-bo_generate",
50
- },
51
- "ldm-bo": {
52
- "health": "chem_ldm-bo_health",
53
- "recommend": "chem_ldm-bo_recommend",
54
- "trajectory": "chem_ldm-bo_trajectory",
55
- },
56
- "synbo": {
57
- "health": "chem_synbo_health",
58
- "initialize": "chem_synbo_initialize",
59
- "optimize": "chem_synbo_optimize",
60
- },
61
- "antbo": {
62
- "health": "biology_antbo_health",
63
- "run-default-job": "biology_antbo_run_default_job",
64
- "run": "biology_antbo_run",
65
- "log": "biology_antbo_log",
66
- "jobs": "biology_antbo_jobs",
67
- "stop": "biology_antbo_stop",
68
- },
69
- }
@@ -1,42 +0,0 @@
1
- ---
2
- name: gsasii
3
- description: 当用户要求使用真实 CIF 模拟粉末 XRD/中子衍射,或使用真实粉末数据、仪器参数与相模型执行 GSAS-II Rietveld 精修时使用。所有实时请求只走 Delta CLI wrapper;禁止伪造 CIF、粉末数据或仪器文件。
4
- metadata:
5
- allowed-tools:
6
- - read_file
7
- - python_repl
8
- - step_finish
9
- ---
10
-
11
- # GSAS-II 服务
12
-
13
- ## 强制规则
14
-
15
- - 第一个且唯一实时执行工具是 `python_repl`,通过
16
- `$SKILLS_ROOT/delta-science/scripts/invoke.py`,tool=`gsasii`。
17
- - `python_repl` 工具参数只能包含 `code`,禁止 `deps/dependencies/packages`。
18
- - 禁止 Bash、目录/路径探测、字面 CLI 命令、直接 HTTP 和本地 GSAS-II。
19
- - 业务结果直接位于 `r["native"]`,禁止 `native.data`。
20
- - 输入不是 CIF 时先由 pymatgen 成功转换;精修必须有真实 powder data、真实
21
- instrument parameters 和真实 phase CIF,任何失败都不得用合成数据补齐。
22
-
23
- ## operation 选择
24
-
25
- - `health`:明确检查服务状态,无 body。
26
- - `powder-simulate`:最小有界请求包含 `cif`、`phase_name`、`radiation:"CuKa"`、
27
- `t_min/t_max/t_step`、profile/reflection 开关和上限;`t_step` 与 `n_points` 二选一。
28
- - `powder-refine`:包含 `powder_data`、`powder_format`、
29
- `instrument_parameters`、`phases:[{name,cif}]`、`refinement_mode:"rietveld"`、
30
- `refinement_steps`、`max_cycles` 和有界输出上限。
31
-
32
- 完整最小 payload 与字段见同级 `references/endpoints.md`。`pawley`/`lebail` 在当前
33
- 服务未实现时原样报告,不改成 rietveld。长 profile/reflections/project 不在最终答复
34
- 展开,只报告点数、范围、残差、警告和用户要求的有界字段。
35
-
36
- ## 调用与完成
37
-
38
- 在一个 `python_repl` 中用 `subprocess.run(..., shell=False)` 调 wrapper,使用
39
- `--data-json`(health 省略),校验退出码、`ok=true`、`transport="delta-cli"`,
40
- 显式打印从 native 投影的有界 JSON。成功后立即
41
- `step_finish(status="done", summary=<同一 JSON>)`;失败则 `status="failed"`。
42
- 只调用一次,不调试打印,不自动重试。
@@ -1,4 +0,0 @@
1
- interface:
2
- display_name: "GSAS-II 衍射分析"
3
- short_description: "通过 Delta CLI 进行粉末衍射模拟或 Rietveld 精修"
4
- default_prompt: "使用 $gsasii 完成这项粉末衍射模拟或精修任务。"
@@ -1,39 +0,0 @@
1
- ---
2
- name: lammps
3
- description: 当用户要求检查 LAMMPS 服务、运行部署自带的有界 LJ melt 示例,或使用明确的 LAMMPS input/data/force-field 配置执行分子动力学、最小化并读取 thermo/log/dump/data 输出时使用。所有实时调用只走 Delta CLI;成功执行不代表物理收敛或生产可用。
4
- metadata:
5
- allowed-tools:
6
- - read_file
7
- - python_repl
8
- - step_finish
9
- ---
10
-
11
- # LAMMPS 服务
12
-
13
- ## 强制规则
14
-
15
- - 第一个且唯一实时执行工具是 `python_repl`,通过
16
- `$SKILLS_ROOT/delta-science/scripts/invoke.py`,tool=`lammps`。
17
- - `python_repl` 工具参数只能包含 `code`,禁止 `deps/dependencies/packages`。
18
- - 禁止 Bash、路径探测、字面 CLI 命令、直接 HTTP、本地 LAMMPS 和本地回归替代。
19
- - 业务结果是 `r["native"]`,禁止 `native.data` 或把外层 envelope 交给 `run`。
20
- - LAMMPS 不从化学式、CIF 或 POSCAR 自动推断 data、原子类型、势函数与边界条件。
21
-
22
- ## operation 选择
23
-
24
- - `health`:明确健康检查,无 body。
25
- - `lj-melt-example`:返回部署自带的精确 `native["request"]`,本身不执行模拟。
26
- - `run`:只接受前一步已验证的 `native["request"]`,或用户明确提供的
27
- `input_script`、相对路径 `files`、timeout 与有界输出设置。
28
-
29
- 用户说“用最小示例测试 LAMMPS”时,在同一个 `python_repl` 中严格执行两次依赖调用:
30
- 先 `lj-melt-example`,再把其 `request` 原样作为 `run` 的 `--data-json`。不增加 health、
31
- 日志探测或本地可执行文件检查。普通明确 run 只调用一次。
32
-
33
- 最终只逐字复制当前 native 的 `last_thermo`、final step/temperature/total energy、
34
- warnings 和用户要求的输出文件摘要。禁止能量除以原子数、换算单位、替换步数或推断
35
- 收敛性/稳定性。详细 run schema 见 `references/endpoints.md`。
36
-
37
- 显式打印有界 JSON 后立即调用
38
- `step_finish(status="done", summary=<同一 JSON>)` 恰好一次;失败或 timeout 调用
39
- `step_finish(status="failed", summary=<原始错误短摘要>)`,禁止重试和后续工具。
@@ -1,4 +0,0 @@
1
- interface:
2
- display_name: "LAMMPS 分子动力学"
3
- short_description: "通过 Delta CLI 运行有界分子动力学和能量最小化"
4
- default_prompt: "使用 $lammps 运行这项分子动力学任务并报告关键结果。"
@@ -1,35 +0,0 @@
1
- ---
2
- name: ldm-bo
3
- description: 当用户要求对小分子 SMILES 使用 LDM-BO/PDF2Dock、Vina+NN、ReaSyn,生成下一条小分子候选或运行分子 BO trajectory 时使用。不得用于抗体、CDRH3、AntBO 或 /biology/antbo 场景;这些场景必须路由 antbo-service。
4
- metadata:
5
- allowed-tools:
6
- - read_file
7
- - python_repl
8
- - step_finish
9
- ---
10
-
11
- # 小分子 LDM-BO 服务
12
-
13
- ## 强制规则
14
-
15
- - 只用 `python_repl` 执行 `$SKILLS_ROOT/delta-science/scripts/invoke.py`,
16
- tool=`ldm-bo`;禁止 Bash、路径探测、字面 CLI、直接 HTTP 和本地 PDF2Dock。
17
- - `python_repl` 工具参数只能包含 `code`,禁止 `deps/dependencies/packages`。
18
- - 业务结果直接位于 `r["native"]`,禁止 `native.data`。
19
- - provider、模型路径、Vina/ReaSyn/GPU/LLM 配置由服务端注入,不放入请求 JSON。
20
- - 抗体/CDRH3 即使出现 “LDM” 也禁止调用本 Skill。
21
-
22
- ## operation 选择
23
-
24
- - `health`:检查 PDF2Dock/Vina/ReaSyn/NN/LLM 等部署依赖,无 body。
25
- - `recommend`:`method`、小分子 `pool`、真实
26
- `history:[{smiles,scores}]`、`batch_size`。
27
- - `trajectory`:保留连字符键 `seed-smiles`、`num-evaluations`、`batch-size`,以及
28
- method、seed、objective;有界 smoke 使用 `bo-tanimoto` 和很小 evaluation 数。
29
-
30
- 详细最小 payload 和 native 响应见 `references/endpoints.md`。缺 Vina、ReaSyn、模型或
31
- LLM 配置时原样报告后端错误,不切换方法或本地生成候选。
32
-
33
- 通过 wrapper 调用一次并显式打印有界 native 投影;成功后立即
34
- `step_finish(status="done", summary=<同一 JSON>)`,失败则
35
- `step_finish(status="failed", summary=<原始错误短摘要>)`。禁止重试和后续工具。
@@ -1,4 +0,0 @@
1
- interface:
2
- display_name: "LDM-BO 小分子优化"
3
- short_description: "通过 Delta CLI 生成小分子候选或执行分子优化轨迹"
4
- default_prompt: "使用 $ldm-bo 为这个小分子任务推荐下一条候选。"
@@ -1,93 +0,0 @@
1
- ---
2
- name: pubchem
3
- description: 当用户给出化学品、分子、药物名称并询问 CID、同义词、分子式、分子量、SMILES、InChI、IUPAC 名、XLogP、TPSA 或供受体数量时使用;也用于在 RDKit 前批量把名称解析为 SMILES。所有实时请求只走 Delta CLI wrapper,并以当前 WORKSPACE_ROOT 下的有界 JSON 作为权威交接产物。
4
- metadata:
5
- allowed-tools:
6
- - read_file
7
- - python_repl
8
- - step_finish
9
- ---
10
-
11
- # PubChem 服务
12
-
13
- ## 强制执行规则
14
-
15
- 1. 第一个且唯一实时执行工具是 `python_repl`,直接执行
16
- `$SKILLS_ROOT/delta-science/scripts/invoke.py`。
17
- 调用 `python_repl` 时工具参数对象只能包含 `code`;禁止传入 `deps`、
18
- `dependencies`、`packages` 或其他参数。
19
- 2. `SKILLS_ROOT` 只通过 `os.environ["SKILLS_ROOT"]` 读取;禁止 Bash、
20
- `list_dir/read_file/which/where/ls`、wrapper 检查和路径探测。
21
- 3. 禁止执行字面命令 `CLI/cli/delta-cli`,禁止 curl、requests、httpx、浏览器、
22
- PUG-REST 和本地替代。
23
- 4. wrapper 已解包所有 envelope,业务结果直接位于 `r["native"]`;禁止
24
- `native.data` 和递归找值。
25
- 5. 不先调用 health/schema,不为“验证”重复同一请求。
26
-
27
- ## 单化合物默认模板
28
-
29
- ```python
30
- import json, os, subprocess, sys
31
- from pathlib import Path
32
- wrapper=os.path.join(os.environ["SKILLS_ROOT"],"delta-science","scripts","invoke.py")
33
- payload={"identifier":"aspirin","namespace":"name"}
34
- p=subprocess.run([sys.executable,wrapper,"--tool","pubchem","--endpoint","compound-summary",
35
- "--data-json",json.dumps(payload)],capture_output=True,text=True,
36
- encoding="utf-8",errors="replace",shell=False,timeout=150)
37
- if p.returncode != 0: raise RuntimeError(p.stderr or p.stdout)
38
- r=json.loads(p.stdout)
39
- if r.get("ok") is not True or r.get("transport")!="delta-cli": raise RuntimeError(r)
40
- n=r["native"]; x=n["properties"]
41
- out={"transport":r["transport"],"endpoint":r["endpoint"],"valid":n["valid"],
42
- "cid":n.get("cid") or x.get("CID"),"canonical_smiles":x.get("CanonicalSMILES"),
43
- "molecular_formula":x.get("MolecularFormula"),
44
- "molecular_weight":x.get("MolecularWeight")}
45
- output_path=Path(os.environ["WORKSPACE_ROOT"])/"pubchem_result.json"
46
- output_path.write_text(json.dumps(out,ensure_ascii=False,indent=2),encoding="utf-8")
47
- print(json.dumps({"output_ref":str(output_path),"result":out},ensure_ascii=False))
48
- ```
49
-
50
- `out` 只保留用户要求的字段。逐字复制返回值:不得改写等价 SMILES、给公式加排版、
51
- 给数值加单位、添加 URL/链接/用途/机制或未请求属性。
52
-
53
- ## operation 选择
54
-
55
- - 一个名称的基础信息:一次 `compound-summary`。
56
- - 两个及以上名称:一次 `compound-batch-summary`,body 只用
57
- `{"identifiers":[...],"namespace":"name"}`。
58
- - 只解析 CID、只查属性或同义词:分别使用 `compound-resolve-cids`、
59
- `compound-properties`、`compound-synonyms`。
60
- - 每个 operation 的准确情景、payload 和投影见
61
- `references/operations.md`;复杂字段再看 `references/endpoints.md`。
62
-
63
- 批量结果从 `native.results[*]` 读取,原标签是 `input`,化合物字段在嵌套
64
- `properties`。SMILES 回退顺序固定为:
65
-
66
- ```text
67
- CanonicalSMILES || ConnectivitySMILES || SMILES || IsomericSMILES
68
- ```
69
-
70
- 无机材料化学式、组成和式量路由 pymatgen;PubChem not_found 原样保留,不编造 CID
71
- 或本地补算。PubChem `XLogP` 与 RDKit `MolLogP` 不得互换。
72
-
73
- 成功写入有界 JSON 后,用其中的原始字符串和数值构造无 Markdown、无单位的最终文本,
74
- 并立即调用 `step_finish` 恰好一次。例如:
75
-
76
- ```text
77
- 【最终答案,必须逐字转发】
78
- CID: 2244
79
- 规范 SMILES: CC(=O)OC1=CC=CC=C1C(=O)O
80
- 分子式: C9H8O4
81
- 分子量: 180.16
82
- ```
83
-
84
- `status="done"`,`summary` 第一行必须逐字为 `【最终答案,必须逐字转发】`,其余行
85
- 逐字使用当前 out;`output_ref` 必须是刚写入的绝对 `pubchem_result.json` 路径。
86
- 不得使用示例固定值。缺少首行或 output_ref 时不得结束步骤。
87
- Skill 自身的 final_response 和外层 Memento 都必须逐字复制 summary,包括大小写和标点,
88
- 不得改成 Markdown/LaTeX、另一种等价 SMILES、添加单位、链接或说明。失败时调用
89
- `step_finish(status="failed", summary=<原始错误短摘要>)`。调用后禁止自由文本和工具。
90
-
91
- 具名 Skill 返回后,外层若需要核验只能对 `output_ref` 使用一次原子 `read_file`;禁止
92
- `python_repl`、`list_dir`、路径探测或再次调用 PubChem/Science。该文件只是当前会话的
93
- 内部证据交接,不是用户要求的额外交付物。
@@ -1,4 +0,0 @@
1
- interface:
2
- display_name: "PubChem 化合物查询"
3
- short_description: "通过 Delta CLI 查询化合物身份、结构与公共性质"
4
- default_prompt: "使用 $pubchem 查询这个化合物的基础身份和分子性质。"
@@ -1,41 +0,0 @@
1
- # PubChem operation 契约
2
-
3
- 先使用 `SKILL.md` 的唯一 wrapper 模板。下面每行都是对应 operation 的最小设置;
4
- wrapper 成功后的业务结果均为 `r["native"]`,不是 `native.data`。执行一次后调用
5
- `step_finish`,不得重复调用。
6
-
7
- ## health
8
-
9
- - 情景:用户明确询问 PubChem 服务是否可用。
10
- - 代码:`endpoint="health"; data=None; params=None`
11
- - 投影:只保留 `status`、可用性、metadata、limits、warnings 中实际存在的字段。
12
-
13
- ## compound-resolve-cids
14
-
15
- - 情景:把名称、SMILES、InChI 等标识符解析为 CID 列表。
16
- - 代码:`endpoint="compound-resolve-cids"; data={"identifier":"aspirin","namespace":"name","max_records":20}; params=None`
17
- - 投影:输入标签、有效性、CID 列表和错误。
18
-
19
- ## compound-properties
20
-
21
- - 情景:已有标识符,只要求指定 PubChem 属性。
22
- - 代码:`endpoint="compound-properties"; data={"identifier":"aspirin","namespace":"name","properties":["MolecularFormula","MolecularWeight"]}; params=None`
23
- - 投影:只复制本次返回的 CID、请求属性、aliases、valid/error。
24
-
25
- ## compound-synonyms
26
-
27
- - 情景:查询一个化合物的同义词。
28
- - 代码:`endpoint="compound-synonyms"; data={"identifier":"aspirin","namespace":"name","max_synonyms":5}; params=None`
29
- - 投影:CID、有效性和最多用户要求数量的 synonyms。
30
-
31
- ## compound-summary
32
-
33
- - 情景:一个已命名分子的 CID、SMILES、分子式、分子量等基础属性。
34
- - 代码:`endpoint="compound-summary"; data={"identifier":"aspirin","namespace":"name"}; params=None`
35
- - 投影:`native.valid`、`native.cid` 与 `native.properties` 中用户要求的键。
36
-
37
- ## compound-batch-summary
38
-
39
- - 情景:一次解析两个或更多名称,供后续比较或 RDKit 使用。
40
- - 代码:`endpoint="compound-batch-summary"; data={"identifiers":["aspirin","caffeine"],"namespace":"name"}; params=None`
41
- - 投影:`native.results[*]` 的 `input`、valid/error 及嵌套 `properties`;不得加 `properties` 或 `synonym_limit` 请求字段。
@@ -1,54 +0,0 @@
1
- ---
2
- name: pymatgen
3
- description: 当用户需要解析材料化学式与组成、计算式量、解析或总结 CIF/POSCAR/JSON/CSSR/XSF 晶体结构、转换结构格式或分析空间群和对称性时使用。所有实时请求只走 Delta CLI wrapper;无机化学式优先使用本 Skill,不用 PubChem 或本地元素表替代。
4
- metadata:
5
- allowed-tools:
6
- - read_file
7
- - python_repl
8
- - step_finish
9
- ---
10
-
11
- # pymatgen 服务
12
-
13
- ## 强制规则
14
-
15
- - 第一个且唯一实时执行工具是 `python_repl`;直接执行
16
- `$SKILLS_ROOT/delta-science/scripts/invoke.py`,tool 固定为 `pymatgen`。
17
- - `python_repl` 工具参数只能包含 `code`,禁止 `deps/dependencies/packages`。
18
- - `SKILLS_ROOT` 只通过 `os.environ` 读取。禁止 Bash、目录/路径探测、字面 CLI
19
- 命令、直接 HTTP 和本地 pymatgen。
20
- - wrapper 成功后的业务结果是 `r["native"]` 顶层,禁止 `native.data`。
21
- - 结构接口必须发送完整结构文本,不能发送本地文件路径;只支持
22
- `cif/poscar/json/cssr/xsf`,不接收 LAMMPS data/dump。
23
-
24
- ## wrapper 模板
25
-
26
- ```python
27
- import json, os, subprocess, sys
28
- wrapper=os.path.join(os.environ["SKILLS_ROOT"],"delta-science","scripts","invoke.py")
29
- p=subprocess.run([sys.executable,wrapper,"--tool","pymatgen","--endpoint",endpoint,
30
- "--data-json",json.dumps(payload)],capture_output=True,text=True,shell=False)
31
- if p.returncode != 0: raise RuntimeError(p.stderr or p.stdout)
32
- r=json.loads(p.stdout)
33
- if r.get("ok") is not True or r.get("transport")!="delta-cli": raise RuntimeError(r)
34
- n=r["native"]
35
- print(json.dumps(out,ensure_ascii=False))
36
- ```
37
-
38
- `out` 必须从 `n` 投影,不得用记忆补值。
39
-
40
- ## operation 选择
41
-
42
- - `health`:明确健康检查;省略 `--data-json`。
43
- - `composition-parse`:`{"formula":"LiFePO4","format":"formula"}`。
44
- - `structure-parse`:`{"input":结构文本,"format":"cif","primitive":false}`。
45
- - `structure-summary`:同上,用于 formula、density、volume、lattice、species。
46
- - `structure-convert`:`{"input":结构文本,"input_format":"cif","output_format":"poscar","primitive":false}`。
47
- - `structure-symmetry`:`{"input":结构文本,"format":"cif","primitive":false,"symprec":0.01,"angle_tolerance":5.0}`。
48
-
49
- 详细 native 字段见 `references/endpoints.md`。一个请求只调用所需 operation;无机式量
50
- 只报告当前 native 的 `weight`,PubChem not_found 不得改写或本地补算。
51
-
52
- 成功打印有界 JSON 后立即调用 `step_finish(status="done", summary=<同一 JSON>)`
53
- 恰好一次;失败时调用 `step_finish(status="failed", summary=<原始错误短摘要>)`。
54
- 调用后不得输出自由文本或使用其他工具。
@@ -1,4 +0,0 @@
1
- interface:
2
- display_name: "pymatgen 材料分析"
3
- short_description: "通过 Delta CLI 解析材料组成、晶体结构和空间群"
4
- default_prompt: "使用 $pymatgen 分析这个材料的组成或晶体结构。"
@@ -1,112 +0,0 @@
1
- ---
2
- name: rdkit
3
- description: 当用户需要通过已部署的 Delta Science 服务校验或规范化 SMILES/InChI、计算 RDKit 描述符、指纹、相似度、渲染或子结构筛选时使用。所有实时请求只能由 python_repl 直接执行 delta-science Skill 的 invoke.py;禁止 Bash、目录探测、直接 HTTP、本地 RDKit 和 native.data 路径。
4
- metadata:
5
- allowed-tools:
6
- - read_file
7
- - python_repl
8
- - step_finish
9
- ---
10
-
11
- # RDKit 服务
12
-
13
- ## 不可违反的执行规则
14
-
15
- 1. 第一个且唯一允许用于实时 Science 调用的工具是 `python_repl`。
16
- `python_repl` 的工具参数对象只能包含 `code`;禁止 `deps`、`dependencies`、
17
- `packages` 或其他参数。
18
- 2. 在 `python_repl` 中直接执行同级 Skill 的
19
- `$SKILLS_ROOT/delta-science/scripts/invoke.py`。`SKILLS_ROOT` 只能通过
20
- `os.environ["SKILLS_ROOT"]` 读取,不能把 `@SKILLS_ROOT` 当成目录。
21
- 3. 禁止使用 Bash、`list_dir`、`read_file`、`which`、`where`、`ls`,禁止检查
22
- wrapper 或寻找 CLI,禁止执行字面命令 `CLI`、`cli`、`delta-cli`。
23
- 4. 禁止 `curl`、`requests`、`httpx`、浏览器和本地 RDKit 回退。
24
- 5. wrapper 成功后,业务结果就在 `result["native"]` 顶层;绝不读取
25
- `result["native"]["data"]`。
26
- 6. 一个请求只执行完成任务所需的最少调用。失败后不得自行探测路径、改走 HTTP
27
- 或改用本地计算。
28
-
29
- ## 唯一调用模板
30
-
31
- ```python
32
- import json, os, subprocess, sys
33
- wrapper = os.path.join(os.environ["SKILLS_ROOT"], "delta-science", "scripts", "invoke.py")
34
- payload = {
35
- "molecules": [{"id": "aspirin", "smiles": "CC(=O)OC1=CC=CC=C1C(=O)O"}],
36
- "descriptor_set": "basic",
37
- "sanitize": True,
38
- }
39
- p = subprocess.run(
40
- [sys.executable, wrapper, "--tool", "rdkit", "--endpoint", "batch-parse-describe",
41
- "--data-json", json.dumps(payload)],
42
- capture_output=True, text=True, shell=False,
43
- )
44
- if p.returncode != 0:
45
- raise RuntimeError(p.stderr or p.stdout)
46
- r = json.loads(p.stdout)
47
- if r.get("ok") is not True or r.get("transport") != "delta-cli":
48
- raise RuntimeError(r)
49
- n = r["native"]
50
- item = n["results"][0]
51
- answer = {
52
- "endpoint": r["endpoint"],
53
- "valid": item["valid"],
54
- "canonical_smiles": item.get("canonical_smiles"),
55
- "descriptors": item.get("descriptors"),
56
- "warnings": item.get("warnings", []),
57
- }
58
- print(json.dumps(answer, ensure_ascii=False))
59
- ```
60
-
61
- 只替换 payload 和逻辑 endpoint。不要先调用 health,也不要增加第二次 parse 或
62
- descriptors 调用。只要进程退出码、`ok`、`transport` 和解析均成功,本次调用就已
63
- 完成;不得因为界面未显示 Python 表达式值而重复调用,不得通过打印 stdout、stderr
64
- 或完整 native 调试。
65
-
66
- 成功打印有界 JSON 后,立即调用 `step_finish(status="done", summary=<该 JSON>)`
67
- 恰好一次,不设置 `output_ref`,随后不得输出自由文本或调用工具。失败时调用
68
- `step_finish(status="failed", summary=<原始错误的短摘要>)`,禁止重试、调试打印或
69
- 路径探测。
70
-
71
- ## 端点选择
72
-
73
- - 同时要求解析和基础描述符:只调用一次 `batch-parse-describe`,payload 必须使用
74
- `molecules`,每项使用 `id` 和 `smiles`;`descriptor_set` 为 `basic`,
75
- `sanitize` 为 `true`。
76
- - 只解析或规范化一个输入:`parse`,payload 为
77
- `{"input":"...","format":"smiles"}` 或相应 InChI 格式。
78
- - 只计算描述符:`descriptors`;批量只计算描述符:`batch-descriptors`。
79
- - 两个分子的相似度:`similarity`;多个分子的全对相似度:
80
- `similarity-matrix`。
81
- - 渲染:`render`;指纹:`fingerprint`;SMARTS 筛选:`substructure`。
82
-
83
- 非默认 operation 先读 `references/operations.md` 中对应小节;完整字段和允许值再见
84
- `references/endpoints.md`。不要根据其他服务相似端点猜 schema。
85
-
86
- ## 多分子相似度
87
-
88
- 名称必须先由 PubChem Skill 得到 SMILES,再执行一次 `similarity-matrix`:
89
-
90
- ```python
91
- payload = {
92
- "molecules": [{"id": name, "smiles": smiles} for name, smiles in resolved],
93
- "fingerprint": {"type": "morgan", "radius": 2, "n_bits": 2048},
94
- "sanitize": True,
95
- }
96
- ```
97
-
98
- 结果从 `n["matrix"]` 和 `n["ranked_pairs"]` 读取。每个排名项固定为
99
- `{"a": 名称, "b": 名称, "similarity": 数值}`;禁止读取 `i`、`j`、
100
- `score`,禁止自行重算或添加阈值解释。
101
-
102
- ## 结果与失败边界
103
-
104
- - 只报告本次 `native` 返回的字段、数值和警告,不用记忆补值。
105
- - 描述符只能逐项复制 `item["descriptors"]` 中实际存在的键和值;不得补充
106
- `NumAromaticRings`、形式电荷、官能团、手性、结构原因、单位或解释,除非这些字段
107
- 确实由本次 native 返回且用户明确要求。
108
- - `valid: false` 是化学输入校验失败,原样报告 `error`/`warnings`。
109
- - wrapper、CLI 或后端失败时,报告实际阶段和错误;不要继续探测或回退。
110
- - 渲染结果只有在解码后的字节以 PNG magic bytes 开头时才能保存为 `.png`;禁止
111
- 把 JSON envelope 保存成图片。
112
- - PubChem 的 `XLogP` 与 RDKit 的 `MolLogP` 不是同一来源,不得互相替代。
@@ -1,4 +0,0 @@
1
- interface:
2
- display_name: "RDKit 化学信息学"
3
- short_description: "通过 Delta CLI 解析分子并计算描述符、相似度和子结构"
4
- default_prompt: "使用 $rdkit 校验这些分子并完成所需的结构计算。"