@louisultra/dsh-verymath 0.0.0-stage → 0.3.2

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 (284) hide show
  1. package/CHANGELOG.md +133 -0
  2. package/LICENSE +21 -0
  3. package/NOTICE.md +35 -0
  4. package/README.md +108 -2
  5. package/README_EN.md +105 -0
  6. package/UPSTREAM.json +106 -0
  7. package/cordis.patch.yml +12 -0
  8. package/docs/capability-examples.md +581 -0
  9. package/docs/examples/README.md +32 -0
  10. package/docs/examples/bad_scan.md +10 -0
  11. package/docs/examples/broken-proof.lean +9 -0
  12. package/docs/examples/claims.md +7 -0
  13. package/docs/examples/knapsack.json +10 -0
  14. package/docs/examples/matrix.json +1 -0
  15. package/docs/examples/points.csv +21 -0
  16. package/docs/examples/qp.json +8 -0
  17. package/docs/examples/research-ws/project/GOALS.yaml +4 -0
  18. package/docs/examples/research-ws/workstreams/ws-lsa/report.md +13 -0
  19. package/docs/examples/research-ws/workstreams/ws-lsa/reviews/r1.json +1 -0
  20. package/docs/examples/research-ws/workstreams/ws-lsa/status.yaml +1 -0
  21. package/docs/examples/source.csv +4 -0
  22. package/lib/core/error.d.ts +20 -0
  23. package/lib/core/error.js +25 -0
  24. package/lib/core/gates.d.ts +42 -0
  25. package/lib/core/gates.js +217 -0
  26. package/lib/core/glossary.d.ts +101 -0
  27. package/lib/core/glossary.js +243 -0
  28. package/lib/core/graph.d.ts +118 -0
  29. package/lib/core/graph.js +460 -0
  30. package/lib/core/index.d.ts +120 -0
  31. package/lib/core/index.js +197 -0
  32. package/lib/core/paper.d.ts +163 -0
  33. package/lib/core/paper.js +73 -0
  34. package/lib/core/paths.d.ts +2 -0
  35. package/lib/core/paths.js +12 -0
  36. package/lib/core/sage.d.ts +61 -0
  37. package/lib/core/sage.js +212 -0
  38. package/lib/core/skills.d.ts +11 -0
  39. package/lib/core/skills.js +110 -0
  40. package/lib/tool/index.d.ts +21 -0
  41. package/lib/tool/index.js +1144 -0
  42. package/package.json +92 -4
  43. package/skills/after-ocr/SKILL.md +123 -0
  44. package/skills/after-ocr/references/audit-schema.md +94 -0
  45. package/skills/after-ocr/references/error-taxonomy.md +179 -0
  46. package/skills/after-ocr/scripts/merge_audit_logs.py +329 -0
  47. package/skills/after-ocr/scripts/scan_markdown_ocr.py +350 -0
  48. package/skills/after-ocr/tests/test_scripts.py +84 -0
  49. package/skills/discover-math-problems/SKILL.md +115 -0
  50. package/skills/discover-math-problems/references/artifact-contract.md +93 -0
  51. package/skills/discover-math-problems/references/autonomous-research-protocol.md +86 -0
  52. package/skills/discover-math-problems/references/conjecture-generation-protocol.md +63 -0
  53. package/skills/discover-math-problems/references/extremal-graph-variants.md +53 -0
  54. package/skills/graph-theory-paper-reading/SKILL.md +600 -0
  55. package/skills/invariant-computation/SKILL.md +169 -0
  56. package/skills/invariant-computation/examples/invariant_summary.example.json +51 -0
  57. package/skills/invariant-computation/manifest.yaml +46 -0
  58. package/skills/invariant-computation/references/INDEX.md +20 -0
  59. package/skills/invariant-computation/references/failure_modes.md +40 -0
  60. package/skills/invariant-computation/references/method_route_map.md +177 -0
  61. package/skills/invariant-computation/references/source_notes.md +19 -0
  62. package/skills/invariant-computation/references/tool_catalog.md +65 -0
  63. package/skills/invariant-computation/references/validation_checks.md +52 -0
  64. package/skills/invariant-computation/schema/invariant_summary.schema.json +260 -0
  65. package/skills/lean-formalization/SKILL.md +111 -0
  66. package/skills/lean-formalization/lean-runtime/config/env.example +5 -0
  67. package/skills/lean-formalization/lean-runtime/config/lean_agent.example.toml +28 -0
  68. package/skills/lean-formalization/lean-runtime/config/numina_runtime.example.toml +12 -0
  69. package/skills/lean-formalization/lean-runtime/examples/smoke/LocalLeanSmoke.lean +7 -0
  70. package/skills/lean-formalization/lean-runtime/prompts/complete_sorries.md +3 -0
  71. package/skills/lean-formalization/lean-runtime/prompts/formalize_statement.md +3 -0
  72. package/skills/lean-formalization/lean-runtime/prompts/prove_theorem.md +3 -0
  73. package/skills/lean-formalization/lean-runtime/prompts/repair_lean_file.md +3 -0
  74. package/skills/lean-formalization/lean-runtime/references/backend_adapter_checklist.md +36 -0
  75. package/skills/lean-formalization/lean-runtime/references/direct_lean_workflow.md +48 -0
  76. package/skills/lean-formalization/lean-runtime/references/failure_taxonomy.md +17 -0
  77. package/skills/lean-formalization/lean-runtime/references/interactive_orchestration.md +83 -0
  78. package/skills/lean-formalization/lean-runtime/references/lean_agent_capability_map.md +116 -0
  79. package/skills/lean-formalization/lean-runtime/references/lean_lsp_mcp_adapter.md +219 -0
  80. package/skills/lean-formalization/lean-runtime/references/lean_runtime_configuration.md +92 -0
  81. package/skills/lean-formalization/lean-runtime/references/numina_reverse_analysis.md +80 -0
  82. package/skills/lean-formalization/lean-runtime/references/numina_runtime.md +41 -0
  83. package/skills/lean-formalization/lean-runtime/references/numina_subagent_troubleshooting.md +77 -0
  84. package/skills/lean-formalization/lean-runtime/references/review_checklist.md +10 -0
  85. package/skills/lean-formalization/lean-runtime/references/specialist_agent_patterns.md +65 -0
  86. package/skills/lean-formalization/lean-runtime/schemas/config.schema.json +12 -0
  87. package/skills/lean-formalization/lean-runtime/schemas/result.schema.json +33 -0
  88. package/skills/lean-formalization/lean-runtime/schemas/task.schema.json +30 -0
  89. package/skills/lean-formalization/lean-runtime/scripts/ai4m_lean.py +222 -0
  90. package/skills/lean-formalization/lean-runtime/scripts/check_lean_project.py +134 -0
  91. package/skills/lean-formalization/lean-runtime/scripts/common.py +296 -0
  92. package/skills/lean-formalization/lean-runtime/scripts/configure_lean.py +222 -0
  93. package/skills/lean-formalization/lean-runtime/scripts/detect_sorry.py +49 -0
  94. package/skills/lean-formalization/lean-runtime/scripts/direct_task.py +100 -0
  95. package/skills/lean-formalization/lean-runtime/scripts/extract_minimal_failure.py +74 -0
  96. package/skills/lean-formalization/lean-runtime/scripts/numina_runtime.py +414 -0
  97. package/skills/lean-formalization/lean-runtime/scripts/smoke_test.py +75 -0
  98. package/skills/lean-formalization/lean-runtime/scripts/tool_status.py +79 -0
  99. package/skills/lean-formalization/lean-runtime/scripts/validate_patch.py +81 -0
  100. package/skills/lean-formalization/lean-runtime/scripts/verify_delivery.py +484 -0
  101. package/skills/lean-formalization/lean-runtime/tests/fixtures/after_bad.lean +4 -0
  102. package/skills/lean-formalization/lean-runtime/tests/fixtures/after_statement_changed.lean +4 -0
  103. package/skills/lean-formalization/lean-runtime/tests/fixtures/before.lean +4 -0
  104. package/skills/lean-formalization/lean-runtime/tests/fixtures/failure.lean +7 -0
  105. package/skills/lean-formalization/lean-runtime/tests/test_check_lean_project.py +59 -0
  106. package/skills/lean-formalization/lean-runtime/tests/test_cli.py +377 -0
  107. package/skills/lean-formalization/lean-runtime/tests/test_common_config.py +84 -0
  108. package/skills/lean-formalization/lean-runtime/tests/test_configure_lean.py +138 -0
  109. package/skills/lean-formalization/lean-runtime/tests/test_detect_sorry.py +24 -0
  110. package/skills/lean-formalization/lean-runtime/tests/test_direct_task.py +69 -0
  111. package/skills/lean-formalization/lean-runtime/tests/test_numina_runtime.py +168 -0
  112. package/skills/lean-formalization/lean-runtime/tests/test_validate_patch.py +29 -0
  113. package/skills/lean-setup/SKILL.md +99 -0
  114. package/skills/least-squares/README.md +85 -0
  115. package/skills/least-squares/SKILL.md +613 -0
  116. package/skills/least-squares/examples.md +380 -0
  117. package/skills/math-beamer/SKILL.md +325 -0
  118. package/skills/math-beamer/references/build-and-layout-audit.md +63 -0
  119. package/skills/math-beamer/references/math-domain-patterns.md +56 -0
  120. package/skills/math-beamer/references/template-policy.md +43 -0
  121. package/skills/math-beamer/references/template-source-index.md +51 -0
  122. package/skills/math-beamer/templates/catalog.yaml +235 -0
  123. package/skills/math-beamer/templates/packs/algebra-number-theory-talk/main.tex +45 -0
  124. package/skills/math-beamer/templates/packs/algebra-number-theory-talk/template.yaml +9 -0
  125. package/skills/math-beamer/templates/packs/algorithm-talk/main.tex +43 -0
  126. package/skills/math-beamer/templates/packs/algorithm-talk/template.yaml +9 -0
  127. package/skills/math-beamer/templates/packs/analysis-core-talk/main.tex +49 -0
  128. package/skills/math-beamer/templates/packs/analysis-core-talk/template.yaml +19 -0
  129. package/skills/math-beamer/templates/packs/backup-heavy-talk/main.tex +40 -0
  130. package/skills/math-beamer/templates/packs/backup-heavy-talk/template.yaml +9 -0
  131. package/skills/math-beamer/templates/packs/beamerposter-a0/main.tex +45 -0
  132. package/skills/math-beamer/templates/packs/beamerposter-a0/template.yaml +12 -0
  133. package/skills/math-beamer/templates/packs/combinatorics-graph-talk/main.tex +53 -0
  134. package/skills/math-beamer/templates/packs/combinatorics-graph-talk/template.yaml +18 -0
  135. package/skills/math-beamer/templates/packs/control-systems-talk/main.tex +51 -0
  136. package/skills/math-beamer/templates/packs/control-systems-talk/template.yaml +18 -0
  137. package/skills/math-beamer/templates/packs/course-lecture-zh/main.tex +43 -0
  138. package/skills/math-beamer/templates/packs/course-lecture-zh/template.yaml +9 -0
  139. package/skills/math-beamer/templates/packs/data-experiment-results/main.tex +45 -0
  140. package/skills/math-beamer/templates/packs/data-experiment-results/template.yaml +9 -0
  141. package/skills/math-beamer/templates/packs/dynamical-systems-talk/main.tex +42 -0
  142. package/skills/math-beamer/templates/packs/dynamical-systems-talk/template.yaml +9 -0
  143. package/skills/math-beamer/templates/packs/geometry-topology-talk/main.tex +43 -0
  144. package/skills/math-beamer/templates/packs/geometry-topology-talk/template.yaml +9 -0
  145. package/skills/math-beamer/templates/packs/information-coding-crypto-talk/main.tex +49 -0
  146. package/skills/math-beamer/templates/packs/information-coding-crypto-talk/template.yaml +18 -0
  147. package/skills/math-beamer/templates/packs/logic-foundations-category-talk/main.tex +51 -0
  148. package/skills/math-beamer/templates/packs/logic-foundations-category-talk/template.yaml +18 -0
  149. package/skills/math-beamer/templates/packs/numerical-analysis-talk/main.tex +51 -0
  150. package/skills/math-beamer/templates/packs/numerical-analysis-talk/template.yaml +9 -0
  151. package/skills/math-beamer/templates/packs/optimization-talk/main.tex +58 -0
  152. package/skills/math-beamer/templates/packs/optimization-talk/template.yaml +9 -0
  153. package/skills/math-beamer/templates/packs/pde-analysis-talk/main.tex +49 -0
  154. package/skills/math-beamer/templates/packs/pde-analysis-talk/template.yaml +9 -0
  155. package/skills/math-beamer/templates/packs/probability-statistics-talk/main.tex +52 -0
  156. package/skills/math-beamer/templates/packs/probability-statistics-talk/template.yaml +9 -0
  157. package/skills/math-beamer/templates/packs/reading-group-paper/main.tex +46 -0
  158. package/skills/math-beamer/templates/packs/reading-group-paper/template.yaml +9 -0
  159. package/skills/math-beamer/templates/packs/seminar-minimal-en/main.tex +60 -0
  160. package/skills/math-beamer/templates/packs/seminar-minimal-en/template.yaml +13 -0
  161. package/skills/math-beamer/templates/packs/seminar-minimal-zh/main.tex +60 -0
  162. package/skills/math-beamer/templates/packs/seminar-minimal-zh/template.yaml +13 -0
  163. package/skills/math-beamer/templates/packs/theorem-proof-talk/main.tex +60 -0
  164. package/skills/math-beamer/templates/packs/theorem-proof-talk/template.yaml +9 -0
  165. package/skills/math-beamer/templates/packs/thesis-defense/main.tex +42 -0
  166. package/skills/math-beamer/templates/packs/thesis-defense/template.yaml +9 -0
  167. package/skills/math-beamer/templates/packs/workshop-tutorial/main.tex +32 -0
  168. package/skills/math-beamer/templates/packs/workshop-tutorial/template.yaml +9 -0
  169. package/skills/math-beamer/templates/preview-gallery.md +32 -0
  170. package/skills/math-beamer/templates/previews/algebra-number-theory-talk-content.png +0 -0
  171. package/skills/math-beamer/templates/previews/algebra-number-theory-talk-cover.png +0 -0
  172. package/skills/math-beamer/templates/previews/algorithm-talk-content.png +0 -0
  173. package/skills/math-beamer/templates/previews/algorithm-talk-cover.png +0 -0
  174. package/skills/math-beamer/templates/previews/analysis-core-talk-content.png +0 -0
  175. package/skills/math-beamer/templates/previews/analysis-core-talk-cover.png +0 -0
  176. package/skills/math-beamer/templates/previews/backup-heavy-talk-content.png +0 -0
  177. package/skills/math-beamer/templates/previews/backup-heavy-talk-cover.png +0 -0
  178. package/skills/math-beamer/templates/previews/beamerposter-a0-content.png +0 -0
  179. package/skills/math-beamer/templates/previews/beamerposter-a0-cover.png +0 -0
  180. package/skills/math-beamer/templates/previews/combinatorics-graph-talk-content.png +0 -0
  181. package/skills/math-beamer/templates/previews/combinatorics-graph-talk-cover.png +0 -0
  182. package/skills/math-beamer/templates/previews/control-systems-talk-content.png +0 -0
  183. package/skills/math-beamer/templates/previews/control-systems-talk-cover.png +0 -0
  184. package/skills/math-beamer/templates/previews/course-lecture-zh-content.png +0 -0
  185. package/skills/math-beamer/templates/previews/course-lecture-zh-cover.png +0 -0
  186. package/skills/math-beamer/templates/previews/data-experiment-results-content.png +0 -0
  187. package/skills/math-beamer/templates/previews/data-experiment-results-cover.png +0 -0
  188. package/skills/math-beamer/templates/previews/dynamical-systems-talk-content.png +0 -0
  189. package/skills/math-beamer/templates/previews/dynamical-systems-talk-cover.png +0 -0
  190. package/skills/math-beamer/templates/previews/geometry-topology-talk-content.png +0 -0
  191. package/skills/math-beamer/templates/previews/geometry-topology-talk-cover.png +0 -0
  192. package/skills/math-beamer/templates/previews/information-coding-crypto-talk-content.png +0 -0
  193. package/skills/math-beamer/templates/previews/information-coding-crypto-talk-cover.png +0 -0
  194. package/skills/math-beamer/templates/previews/logic-foundations-category-talk-content.png +0 -0
  195. package/skills/math-beamer/templates/previews/logic-foundations-category-talk-cover.png +0 -0
  196. package/skills/math-beamer/templates/previews/numerical-analysis-talk-content.png +0 -0
  197. package/skills/math-beamer/templates/previews/numerical-analysis-talk-cover.png +0 -0
  198. package/skills/math-beamer/templates/previews/optimization-talk-content.png +0 -0
  199. package/skills/math-beamer/templates/previews/optimization-talk-cover.png +0 -0
  200. package/skills/math-beamer/templates/previews/pde-analysis-talk-content.png +0 -0
  201. package/skills/math-beamer/templates/previews/pde-analysis-talk-cover.png +0 -0
  202. package/skills/math-beamer/templates/previews/probability-statistics-talk-content.png +0 -0
  203. package/skills/math-beamer/templates/previews/probability-statistics-talk-cover.png +0 -0
  204. package/skills/math-beamer/templates/previews/reading-group-paper-content.png +0 -0
  205. package/skills/math-beamer/templates/previews/reading-group-paper-cover.png +0 -0
  206. package/skills/math-beamer/templates/previews/seminar-minimal-en-content.png +0 -0
  207. package/skills/math-beamer/templates/previews/seminar-minimal-en-cover.png +0 -0
  208. package/skills/math-beamer/templates/previews/seminar-minimal-zh-content.png +0 -0
  209. package/skills/math-beamer/templates/previews/seminar-minimal-zh-cover.png +0 -0
  210. package/skills/math-beamer/templates/previews/theorem-proof-talk-content.png +0 -0
  211. package/skills/math-beamer/templates/previews/theorem-proof-talk-cover.png +0 -0
  212. package/skills/math-beamer/templates/previews/thesis-defense-content.png +0 -0
  213. package/skills/math-beamer/templates/previews/thesis-defense-cover.png +0 -0
  214. package/skills/math-beamer/templates/previews/workshop-tutorial-content.png +0 -0
  215. package/skills/math-beamer/templates/previews/workshop-tutorial-cover.png +0 -0
  216. package/skills/math-beamer/templates/review-report.md +54 -0
  217. package/skills/math-beamer/templates/slide-source-ledger.md +22 -0
  218. package/skills/math-beamer/templates/source-packet.md +50 -0
  219. package/skills/math-glossary/SKILL.md +347 -0
  220. package/skills/math-glossary/references/glossary-schema.md +71 -0
  221. package/skills/math-glossary/references/glossary-usage-guide.md +176 -0
  222. package/skills/math-glossary/references/glossary-web-template.md +127 -0
  223. package/skills/math-glossary/references/glossary.schema.json +76 -0
  224. package/skills/math-glossary/references/user-manual.md +435 -0
  225. package/skills/math-glossary/requirements-ai.txt +3 -0
  226. package/skills/math-glossary/requirements.txt +3 -0
  227. package/skills/math-glossary/scripts/glossary_backup.py +42 -0
  228. package/skills/math-glossary/scripts/glossary_build.py +467 -0
  229. package/skills/math-glossary/scripts/glossary_enrich_examples.py +283 -0
  230. package/skills/math-glossary/scripts/glossary_export.py +333 -0
  231. package/skills/math-glossary/scripts/glossary_web.py +1265 -0
  232. package/skills/math-paper-reading/README.md +163 -0
  233. package/skills/math-paper-reading/SKILL.md +48 -0
  234. package/skills/math-paper-reading/agent_router.md +36 -0
  235. package/skills/math-paper-reading/references/proof_pattern_taxonomy.md +123 -0
  236. package/skills/math-paper-reading/references/quality_rubric.md +36 -0
  237. package/skills/math-paper-reading/skill_base.md +627 -0
  238. package/skills/math-paper-reading/skill_literature_search.md +866 -0
  239. package/skills/math-paper-reading/skill_paper_deep_read.md +1024 -0
  240. package/skills/math-paper-reading/skill_pathway_proof.md +718 -0
  241. package/skills/math-paper-reading/skill_reference_manager.md +746 -0
  242. package/skills/matlab-runner/SKILL.md +217 -0
  243. package/skills/matlab-runner/examples/README.md +33 -0
  244. package/skills/matlab-runner/examples/matrix_report.m +28 -0
  245. package/skills/matlab-runner/examples/plot_damped_sine.m +64 -0
  246. package/skills/matlab-runner/examples/test_vector_norm.m +12 -0
  247. package/skills/matlab-runner/references/client-setup.md +24 -0
  248. package/skills/matlab-runner/references/file-session-safety.md +86 -0
  249. package/skills/matlab-runner/references/numerical-safety.md +126 -0
  250. package/skills/matlab-runner/references/resource-safety.md +125 -0
  251. package/skills/mixed-integer-programming/SKILL.md +119 -0
  252. package/skills/mixed-integer-programming/lp-examples.md +251 -0
  253. package/skills/mixed-integer-programming/mip-examples-verified.md +118 -0
  254. package/skills/open-problem-research-pipeline/SKILL.md +76 -0
  255. package/skills/open-problem-research-pipeline/skill_literature_analysis.md +201 -0
  256. package/skills/open-problem-research-pipeline/skill_literature_proof_framework.md +206 -0
  257. package/skills/open-problem-research-pipeline/skill_literature_search.md +172 -0
  258. package/skills/open-problem-research-pipeline/skill_qskill.md +177 -0
  259. package/skills/osqp-solver/SKILL.md +245 -0
  260. package/skills/osqp-solver/references/citation.md +25 -0
  261. package/skills/osqp-solver/references/dual-infeasible-example.json +14 -0
  262. package/skills/osqp-solver/references/feasible-example.json +21 -0
  263. package/skills/osqp-solver/references/primal-infeasible-example.json +17 -0
  264. package/skills/osqp-solver/references/python-api.md +95 -0
  265. package/skills/osqp-solver/references/verification.md +94 -0
  266. package/skills/osqp-solver/scripts/check_osqp_environment.py +120 -0
  267. package/skills/osqp-solver/scripts/solve_qp.py +943 -0
  268. package/skills/paper-writing/SKILL.md +115 -0
  269. package/skills/paper-writing/skill_claim_evidence_ledger.md +55 -0
  270. package/skills/paper-writing/skill_formula_environment_and_readability.md +41 -0
  271. package/skills/paper-writing/skill_latex_build_and_layout_audit.md +73 -0
  272. package/skills/paper-writing/skill_notation_and_variable_consistency.md +42 -0
  273. package/skills/paper-writing/skill_paper_skeleton_and_logical_architecture.md +54 -0
  274. package/skills/paper-writing/skill_proof_obligation_and_assumption_audit.md +57 -0
  275. package/skills/paper-writing/templates/claim-evidence-ledger.md +23 -0
  276. package/skills/paper-writing/templates/proof-obligation-ledger.md +22 -0
  277. package/skills/paper-writing/templates/rapid-prototype-paper-skeleton.md +46 -0
  278. package/skills/paper-writing/templates/source-packet.md +37 -0
  279. package/skills/paper-writing/templates/submission-readiness.md +41 -0
  280. package/skills/proof-blueprint-review/SKILL.md +129 -0
  281. package/skills/proof-blueprint-review/references/agent-mediated-proof-protocol.md +57 -0
  282. package/skills/proof-blueprint-review/references/generation-agent.md +45 -0
  283. package/skills/proof-blueprint-review/references/proof-acceptance-contract.md +41 -0
  284. package/skills/proof-blueprint-review/references/verification-agent.md +37 -0
@@ -0,0 +1,718 @@
1
+ # 论文证明路径生成、引理/定理关系图构建 — Data-Driven Graph Engine
2
+
3
+ > **定位**:`skill_base` 生成的结构化 JSON 的下游图计算与渲染引擎。
4
+ >
5
+ > **核心架构**:**数据驱动模式**。本模块**不再读取论文原始文本**提取逻辑关系,而是直接消费 `<slug>_structure.json` 的全量结构化数据,进行拓扑计算、节点渲染和阅读路径合成,达到 100% 的拓扑严谨性。
6
+
7
+ ---
8
+
9
+ ## 一、角色定位
10
+
11
+ 你是**逻辑拓扑架构师与图计算引擎**。你的工作前提是:所有实体和依赖关系已经在 `skill_base` 阶段提取完毕并存放在 `<slug>_structure.json` 中。你的任务是对这份结构化数据进行**纯计算和渲染**:
12
+
13
+ 1. **拓扑计算**:读取 JSON `entities[]` 数组,遍历 `dependencies` / `cited_by` 字段,计算每个节点的入度(In-degree)和出度(Out-degree)。
14
+ 2. **依赖图渲染**:将 JSON 实体关系映射为 Mermaid 代码块。
15
+ 3. **阅读路径合成**:基于依赖图拓扑排序,自动生成 Top-down(目标导向)和 Bottom-up(基石构建)两种阅读路径。
16
+ 4. **逻辑漏洞检测**:从 JSON `completeness_check` 和 `uncertain_log` 中的结构标记派生预警信息。
17
+
18
+ ### 数据输入优先级
19
+
20
+ | 优先级 | 数据源 | 来源 | 用途 |
21
+ |:---|:---|:---|:---|
22
+ | **1(Ground Truth)** | `<slug>_structure.json` | `skill_base` 生成 | 实体、依赖、审查报告的惟一事实来源 |
23
+ | **2(回退)** | `<slug>_structure_analysis.md` | `skill_base` 生成 | 标记文件路径补偿 |
24
+ | 3 | 论文原文 | 用户原始输入 | **仅当 JSON 和 Markdown 均不可用时** |
25
+
26
+ **禁止**:自行从论文原文中提取实体、脑补依赖关系。所有拓扑计算必须基于 JSON 的硬数据。
27
+
28
+ ---
29
+
30
+ ## 二、逻辑实体分类规范
31
+
32
+ ### 2.1 JSON 类型 → 符号映射表
33
+
34
+ 本模块消费 JSON `entities[].type` 字段值,映射到统一符号系统:
35
+
36
+ | JSON `type` 值 | 符号 | 复杂度标识 | JSON 对应字段 |
37
+ |:---|:---|:---|:---|
38
+ | `DEFINITION` | 🧱 | — | `type: "DEFINITION"` |
39
+ | `AXIOM`(无直接映射时视为 DEFINITION 变体) | 🧱 | — | — |
40
+ | `ASSUMPTION`(无直接映射时视为 DEFINITION 变体) | 🧱 | — | — |
41
+ | `CLAIM` | 🔶 | 🔧 技术 | `type: "CLAIM"`, `parent_result`, `auto_labeled` |
42
+ | `LEMMA` | 🔧 | ⭐ 核心 / 🔧 技术 | `type: "LEMMA"` |
43
+ | `PROPOSITION` | 📐 | ⭐ 核心 / 🔧 技术 | `type: "PROPOSITION"` |
44
+ | `THEOREM` | ⭐ | ⭐ 核心 | `type: "THEOREM"` |
45
+ | `COROLLARY` | 📎 | 💡 基础 | `type: "COROLLARY"` |
46
+ | `OBSERVATION` | 💡 | 💡 基础 | `type: "OBSERVATION"` |
47
+ | `REMARK` | 💡 | 💡 基础 | `type: "REMARK"` |
48
+ | `CONSTRUCTION` | 🧱 | 🔧 技术 | `type: "CONSTRUCTION"` |
49
+ | `TABLE` | 📊 | — | `type: "TABLE"` |
50
+
51
+ ### 2.2 拓扑计算规则(脚本强制模式)
52
+
53
+ 图谱渲染的核心是拓扑度量(入度、出度、共享节点标志)。由于 LLM 存在计数和图遍历的注意力缺陷,**严禁** LLM 手工统计 JSON 数组长度或手动构造依赖表。
54
+
55
+ **DSH 宿主首选(@louisultra/dsh-verymath 插件)**:直接调用 `verymath_paper_graph` 工具(传 `path` 指向 `<slug>_structure.json`)。工具在插件内部完成全部拓扑计算(入度/出度/`shared_node`/环检测/双向阅读路径),返回 label 级节点表与可选 Mermaid 图,无需 Python。需要某实体的传递依赖闭包与阅读路径时传 `focus: "<label>"`。
56
+
57
+ **回退流程(无 verymath 插件的宿主)**:所有拓扑度量必须通过生成并执行 Python 脚本计算,将计算结果回写至 JSON 后,再基于更新后的 JSON 渲染 Mermaid 图:
58
+
59
+ 1. Agent 动态生成 `compute_topology.py`(参考下方模板)。
60
+ 2. 通过 Bash 执行 `python3 compute_topology.py <slug>_structure.json`。
61
+ 3. Agent 读取脚本执行成功的输出后,再根据 JSON 中新增的 `in_degree` 和 `out_degree` 字段生成节点分析表格。
62
+ 4. **绝对禁止**在分析表格中手动“目测”填写入度/出度数值。
63
+
64
+ **Python 脚本模板 (`compute_topology.py`)**:
65
+
66
+ ```python
67
+ #!/usr/bin/env python3
68
+ import json
69
+ import sys
70
+
71
+ def compute_topology(data):
72
+ entities = data.get("entities", [])
73
+
74
+ # 1. 建立 Label 索引与临时度数容器
75
+ label_to_entity = {e["label"]: e for e in entities}
76
+ for e in entities:
77
+ e["in_degree"] = 0
78
+ e["types_citing_me"] = set() # 记录依赖该实体的父节点类型,用于 shared_node 判断
79
+ # 出度:明确依赖 + 不确定依赖的数量
80
+ e["out_degree"] = len(e.get("dependencies", [])) + len(e.get("uncertain_dependencies", []))
81
+
82
+ # 2. 遍历正向边,精确构建反向图(不依赖原有的 cited_by 字段)
83
+ for e in entities:
84
+ deps = e.get("dependencies", [])
85
+ # 清洗 UNCERTAIN 标签,提取真实 Label
86
+ uncertain_deps = [d.split(" [")[0] for d in e.get("uncertain_dependencies", [])]
87
+ all_deps = deps + uncertain_deps
88
+
89
+ for target_label in all_deps:
90
+ if target_label in label_to_entity:
91
+ target_entity = label_to_entity[target_label]
92
+ target_entity["in_degree"] += 1
93
+ target_entity["types_citing_me"].add(e["type"])
94
+
95
+ # 3. 计算 shared_node 并清理临时变量
96
+ for e in entities:
97
+ types_citing_me = e.pop("types_citing_me")
98
+ # 共享枢纽判定:入度 >= 2 且被至少一个 THEOREM 依赖
99
+ e["shared_node"] = (e["in_degree"] >= 2) and ("THEOREM" in types_citing_me)
100
+
101
+ return data
102
+
103
+ if __name__ == "__main__":
104
+ if len(sys.argv) < 2:
105
+ print("Error: Missing JSON file argument.", file=sys.stderr)
106
+ sys.exit(1)
107
+
108
+ file_path = sys.argv[1]
109
+ try:
110
+ with open(file_path, "r", encoding="utf-8") as f:
111
+ data = json.load(f)
112
+
113
+ data = compute_topology(data)
114
+
115
+ with open(file_path, "w", encoding="utf-8") as f:
116
+ json.dump(data, f, indent=2, ensure_ascii=False)
117
+
118
+ print(f"✅ Topology computed successfully for {len(data.get('entities', []))} entities.")
119
+ except Exception as e:
120
+ print(f"Error: {e}", file=sys.stderr)
121
+ sys.exit(1)
122
+ ---
123
+
124
+ ## 三、数据映射规范(JSON → Mermaid)
125
+
126
+ ### 3.1 JSON 字段 → Mermaid 节点渲染规则
127
+
128
+ | Mermaid 要素 | JSON 字段 | 处理规则 |
129
+ |:---|:---|:---|
130
+ | 节点 ID | `entities[].label` | 去除非字母数字字符,保留连字符;如 `Lemma 3.1` → `Lem31` |
131
+ | 节点显示文本 | `entities[].label` + `entities[].type` | `Lem31[🔧 Lemma 3.1]` — 见 3.2 防崩溃 |
132
+ | 节点样式 | — | `:::lemma`, `:::theorem` 等 CSS class |
133
+ | 有向边 | `entities[].dependencies` + `entities[].cited_by` | 正向依赖 `A --> B`;见 3.3 |
134
+ | 不确定边 | `entities[].uncertain_dependencies` | 虚线 `A -.-> B` + 标注 `[UNCERTAIN]` |
135
+ | 外部引用边 | `entities[].external_refs` | 虚线 `A -.-> extB` + 标注 `[EXTERNAL]` |
136
+ | 共享节点 | `entities[].shared_node: true` | 节点文本追加 `[*]` |
137
+ | AUTO-LABELED | `entities[].auto_labeled: true` | 节点文本追加 `[AUTO]` |
138
+
139
+ ### 3.2 防崩溃原则(Mermaid 安全渲染)
140
+
141
+ 从 JSON 读取 `label` 和 `statement` 时,执行以下清洗操作,防止 Mermaid 渲染失败:
142
+
143
+ **节点显示文本清洗规则**:
144
+
145
+ | 原始 JSON 内容 | 清洗后 |
146
+ |:---|:---|
147
+ | `Lemma $x_i \in \mathbb{R}^d$` | `Lemma: x_i in R^d` |
148
+ | `Theorem 3.1 (Convergence of $\eta_t$)` | `Theorem 3.1: Convergence of eta_t` |
149
+ | `$\|x\|_2 \leq C$` | `norm(x) <= C` |
150
+ | 含 `\mathbb{}`、`\mathcal{}` 等渲染命令的 LaTeX | 剥离渲染命令,保留变量和下标(如 `\mathbb{R}^d` → `R^d`) |
151
+ | 含 `^`、`_`、`~` 的轻量数学符号 | 用双引号包裹节点文本防止语法崩溃,保留 `x_i`、`eta_t` 等可读形式 |
152
+
153
+ **具体步骤**:
154
+ 1. 从 JSON `entities[].label` 取标签
155
+ 2. 从 JSON `entities[].statement` 提取一句话梗概(**仅用于 Mermaid 节点显示,不用于推导**)
156
+ 3. 对梗概执行去 LaTeX 化:移除 `$...$` 定界符,将 `\mathbb{}`、`\mathcal{}` 等渲染命令剥离为纯文本(如 `\mathbb{R}^d` → `R^d`),但保留变量名、下标、上标等轻量数学符号(如 `x_i`、`eta_t`)
157
+ 4. 对梗概执行去特殊字符化:移除 `{`、`}` 等 Mermaid 语法敏感字符;对含 `^`、`_`、`~` 的节点文本使用双引号包裹(`["text with ^ and _"]`)防止语法崩溃
158
+ 5. 截断至 50 字符以内,超出部分用 `...` 省略
159
+
160
+ **完整公式保留在上方的逻辑实体表格中,Mermaid 节点只写自然语言简述。**
161
+
162
+ ### 3.3 不确定性继承(视觉标注)
163
+
164
+ 当 JSON 中出现带有 `[UNCERTAIN]` 或 `[EXTERNAL]` 标签的依赖关系时,在 Mermaid 图中使用**特殊连线规则**:
165
+
166
+ | JSON 标签 | 边样式 | Mermaid 示例 | 颜色约定 |
167
+ |:---|:---|:---|:---|
168
+ | 无(正常依赖) | 实线 | `A --> B` | 默认(黑色) |
169
+ | `[UNCERTAIN]` | 虚线 + 标注 | `A -.->|\"⚠️ UNCERTAIN\"| B` | 橙色/红色 |
170
+ | `[EXTERNAL]` | 虚线 + 标注 | `A -.->|\"📎 EXTERNAL\"| extB` | 蓝色 |
171
+
172
+ **节点文本标注**:
173
+
174
+ ```
175
+ Lem31[🔧 Lemma 3.1] -->|UNCERTAIN| ThmX[⭐ Theorem X]
176
+ Lem23[🔧 Lemma 2.3] -.->|📎 EXTERNAL [9]| extRef9(📎 Ref [9])
177
+ ```
178
+
179
+ ### 3.4 孤立节点预警
180
+
181
+ 直接从 JSON `completeness_check.isolated_results` 字段读取孤立节点:
182
+
183
+ ```json
184
+ // JSON 中的字段
185
+ "isolated_results": [
186
+ { "label": "Proposition 2.7", "possible_reasons": ["独立的延伸结论", "skill-3 分析不完整"] }
187
+ ]
188
+ ```
189
+
190
+ **渲染规则**:
191
+ - 在主依赖图 **下方** 单独列出孤立节点区块
192
+ - 每个孤立节点写为:`Prop27(📐 Proposition 2.7)`
193
+ - 标注原因(来自 `possible_reasons` 数组第一条)
194
+ - **严禁**:为了画面美观将孤立节点强行连入主树
195
+
196
+ ```
197
+ ### ⚠️ 孤立节点警告(未连入主依赖链)
198
+
199
+ 来自 JSON completeness_check.isolated_results:
200
+
201
+ Prop27(📐 Proposition 2.7) — 原因:独立的延伸结论
202
+ ```
203
+
204
+ ---
205
+
206
+ ## 四、依赖图构建规则
207
+
208
+ ### 4.1 双向追踪
209
+
210
+ 每个节点同时标注入度和出度,数据**严格从 JSON 遍历计算**:
211
+
212
+ | 方向 | 计算方式 | JSON 数据源 | 示例 |
213
+ |:---|:---|:---|:---|
214
+ | **出度(Out-degree)** | `entities[i].dependencies.length + entities[i].uncertain_dependencies.length` | `entities[].dependencies` + `entities[].uncertain_dependencies` | 2(其中 1 个 UNCERTAIN) |
215
+ | **入度(In-degree)** | 遍历所有实体的 `dependencies` / `cited_by`,统计标签出现次数 | `entities[].cited_by` + 全局扫描 `dependencies` | 5(被 5 个节点引用) |
216
+
217
+ ### 4.2 引理分级
218
+
219
+ | 等级 | 判定依据(JSON 字段) | 定义 |
220
+ |:---|:---|:---|
221
+ | 核心引理 | `in-degree >= 3` 或 `shared_node: true` 或 `cited_by` 包含主定理 | 承载论文主要创新思想或关键突破 |
222
+ | 技术引理 | 上述条件均不满足 | 纯计算、放缩、代数变形等辅助步骤 |
223
+
224
+ ### 4.3 外部依赖标注
225
+
226
+ | 来源 | 标注格式 | JSON 数据源 |
227
+ |:---|:---|:---|
228
+ | 外部文献 | `📎 [文献ID] 作者年份` | `entities[].external_refs` 数组 |
229
+ | UNCERTAIN | `⚠️ [UNCERTAIN: 原因]` | `entities[].uncertain_dependencies` 数组 |
230
+
231
+ ### 4.4 图规模降级与子图保护机制
232
+
233
+ **强制约束:当 JSON 实体总数 > 40 时,必须执行以下降级策略:**
234
+
235
+ 1. **降级渲染**:渲染以**所有** `type: "THEOREM"` 节点为根、深度限制为 2 层的子图集合
236
+ - 每个 THEOREM 节点 → 直接依赖(深度 1)→ 直接依赖的直接依赖(深度 2)
237
+ - 多个 THEOREM 子图在同一个 Mermaid 块中并列渲染,用 `subgraph` 分组区分
238
+ - 其余节点在主图外以文字清单列出(不渲染为 Mermaid 节点)
239
+ 2. **自动引导语**:图上方自动附加:
240
+ ```
241
+ ⚠️ 全文节点数超过 40,已自动降级为多根深度 2 子图(以所有 THEOREM 节点为中心)。
242
+ 输入 `/graph full` 可强制渲染全量图(可能包含未清洗的特殊字符)。
243
+ ```
244
+ 3. **用户覆盖**:用户可通过 `/graph full` 命令强制渲染全局图(此时风险由用户承担)
245
+
246
+ **逻辑实体清单同步降级**:节点数 > 15 时,实体清单表仅列出核心节点(`shared_node: true` 或入度 ≥ 3),其余标注 `[TECH: 共 N 个技术节点,详见 JSON]`。
247
+
248
+ ---
249
+
250
+ ## 五、阅读路径生成
251
+
252
+ 始终提供两种路径,基于拓扑排序自动生成:
253
+
254
+ | 路径 | 方向 | 起点→终点 | 适合场景 |
255
+ |:---|:---|:---|:---|
256
+ | **Top-down** | 目标导向 | Main Theorem → 逐层下探必需引理 | 快速把握核心价值 |
257
+ | **Bottom-up** | 基石构建 | 基础定义/假设 → 逐层向上推导 | 完全复现证明过程 |
258
+
259
+ **生成算法**:
260
+ - **Top-down**:从 JSON `main_theorems[].label` 出发,沿 `dependencies` 反向边 BFS
261
+ - **Bottom-up**:从入度为 0 的节点出发,沿 `cited_by` 正向边 BFS/DFS
262
+
263
+ ---
264
+
265
+ ## 六、可视化规范
266
+
267
+ ### 6.1 统一符号系统
268
+
269
+ | 符号 | JSON type | 说明 |
270
+ |:---|:---|:---|
271
+ | ⭐ | THEOREM / 核心引理 | |
272
+ | 🔧 | LEMMA / 技术引理 | |
273
+ | 📐 | PROPOSITION | |
274
+ | 🔶 | CLAIM | |
275
+ | 🧱 | DEFINITION / CONSTRUCTION / ASSUMPTION | |
276
+ | 📎 | COROLLARY / 外部依赖 | |
277
+ | 💡 | OBSERVATION / REMARK | |
278
+ | 📊 | TABLE | |
279
+
280
+ ### 6.2 Mermaid 图类型
281
+
282
+ | 图类型 | 方向 | 使用场景 |
283
+ |:---|:---|:---|
284
+ | `graph TD` | 自底向上(从依赖到结论) | 依赖图 |
285
+ | `graph LR` | 自顶向下(从目标到基石) | 证明路径图 |
286
+
287
+ ### 6.3 Subgraph 分组规则
288
+
289
+ 为提升多分支依赖图的视觉清晰度,当渲染完整依赖图(非降级子图)或渲染多个 THEOREM 根节点的子图集合时,必须使用 Mermaid `subgraph` 语法将节点按拓扑深度或类型分组:
290
+
291
+ | 分组名 | 包含节点 | 分组依据 |
292
+ |:---|:---|:---|
293
+ | `subgraph Assumptions` | 出度 ≥ 1 且入度 = 0 的 DEFINITION / ASSUMPTION 类型节点 | 拓扑深度 0 |
294
+ | `subgraph Core Lemmas` | 入度 ≥ 2 或 `shared_node: true` 的 LEMMA / PROPOSITION 类型节点 | 依赖图中间层 |
295
+ | `subgraph Technical Lemmas` | 其余(非核心) LEMMA / CLAIM 类型节点 | 依赖图中间层 |
296
+ | `subgraph Main Results` | THEOREM / COROLLARY 类型节点 | 拓扑顶层 |
297
+
298
+ **示例**:
299
+ ```mermaid
300
+ graph TD
301
+ subgraph Assumptions
302
+ Def1[🧱 Definition 1.2]
303
+ Assum2[🧱 Assumption 2.1]
304
+ end
305
+ subgraph Core Lemmas
306
+ Lem31[🔧 Lemma 3.1]
307
+ Lem32[🔧 Lemma 3.2]
308
+ end
309
+ subgraph Main Results
310
+ Thm2[⭐ Theorem 2]
311
+ Cor1[📎 Corollary 2.1]
312
+ end
313
+ Def1 --> Lem31
314
+ Assum2 --> Lem31
315
+ Lem31 --> Thm2
316
+ Lem32 -.->|⚠️ UNCERTAIN| Thm2
317
+ Thm2 --> Cor1
318
+ ```
319
+
320
+ **规则**:
321
+ - `subgraph` 区块按拓扑顺序自底向上排列(Assumptions → Lemmas → Results)
322
+ - 跨 `subgraph` 的边正常绘制(Mermaid 原生支持跨组连线)
323
+ - 降级模式(节点 > 40)渲染多根子图时,每个 THEOREM 根的子图内部也使用 `subgraph` 分组
324
+
325
+ ### 6.4 防崩溃原则
326
+
327
+ 节点显示文本须符合 §3.2 防崩溃清洗规则。
328
+
329
+ ---
330
+
331
+ ## 七、黑盒与逻辑漏洞检测(基于 JSON 审查报告)
332
+
333
+ 本模块不自行验证数学正确性,所有预警派生自 JSON `completeness_check` 中的结构化分析:
334
+
335
+ | 预警类型 | 标识 | JSON 数据源 | 处理建议 |
336
+ |:---|:---|:---|:---|
337
+ | 依赖链缺失 | ⚠️ | `completeness_check.dependency_integrity[].status === "missing"` | 标注缺失节点,提示人工核查 |
338
+ | 外部依赖 | 📎 | `completeness_check.external_deps` | 单独列出清单,建议优先回顾 |
339
+ | 循环依赖 | 🚨 | `completeness_check.circular_deps` | 加粗标红,提示核对定义域 |
340
+ | 孤立节点 | ⚠️ | `completeness_check.isolated_results` | 在主图外单独列出,禁止并入主树 |
341
+ | UNCERTAIN 依赖 | ⚠️ | `uncertain_log` + `entities[].uncertain_dependencies` | 虚线标注 + 橙色预警 |
342
+ | 断链无法补全 | 🔍 | `completeness_check.backquery_results[].status === "warning"` | "上下文严重缺失,无法准确推断" |
343
+
344
+ ---
345
+
346
+ ## 八、API 级调用响应(System Call Handler)
347
+
348
+ ### 8.1 接收规范
349
+
350
+ 当接收到来自深度阅读助手(`skill_paper_deep_read`)或其他外部模块的标准化请求时,本模块应自动进入 API 模式。
351
+
352
+ **请求格式**(`[SYSTEM-CALL → skill_pathway_proof]`):
353
+
354
+ ```
355
+ [SYSTEM-CALL → skill_pathway_proof]
356
+ URI_Target: "paper:arxiv:2401.0001#Thm-2"
357
+ JSON_Source: "<slug>_structure.json"
358
+ Extracted_Dependencies: ["Lemma 3.1", "Lemma 3.2", "Corollary 2.1"]
359
+ Request: "render_subgraph | full_graph"
360
+ ```
361
+
362
+ > **操作指引**:看到此 SYSTEM-CALL 后,由接收模块自动处理依赖图渲染,用户无需手动操作。若需自定义渲染范围(如限定某条依赖路径),请提供具体定理/引理 ID。
363
+
364
+ **数据源优先级规则(强制)**:
365
+
366
+ | 优先级 | 数据源 | 作用 |
367
+ |:---|:---|:---|
368
+ | **Ground Truth** | `JSON_Source` → 其 `dependencies` 字段 | 所有拓扑计算、入度/出度统计、节点关系的**绝对唯一来源** |
369
+ | **Fallback / Filter** | `Extracted_Dependencies` | 仅作为子图渲染的**范围指示器**(scope filter):当 `Request: "render_subgraph"` 时,由此字段决定渲染哪些节点的子树;不参与拓扑事实的构建。当 `Extracted_Dependencies` 与 JSON `dependencies` 冲突时,**以 JSON 为准**。 |
370
+
371
+ **规则**:
372
+ - 拓扑事实(入度、出度、依赖链)**只能**从 JSON `dependencies` / `cited_by` 字段计算,绝不从 `Extracted_Dependencies` 推导
373
+ - `Extracted_Dependencies` 仅用于裁剪渲染范围("只画这些节点的子图"),不影响拓扑数据本身
374
+
375
+ ### 8.2 响应规范
376
+
377
+ **API 模式输出规则**:
378
+
379
+ 1. **只输出纯粹的技术内容**,不包含寒暄语、问候、或引导性提问
380
+ 2. 输出内容格式:
381
+
382
+ ```
383
+ [SYSTEM-RESPONSE → skill_paper_deep_read]
384
+ URI: paper:arxiv:2401.0001#Thm-2
385
+ JSON_Source: <slug>_structure.json
386
+ Subgraph_Type: render_subgraph
387
+ ---
388
+ ### 节点分析
389
+
390
+ | 节点 | 入度 | 出度 | 共享 | 标注 |
391
+ |:---|:---:|:---:|:---:|:---:|
392
+ | Thm-2 | 0 | 2 | false | — |
393
+ | Lem-3.1 | 2 | 1 | true | — |
394
+ | Lem-3.2 | 1 | 0 | false | — |
395
+ | Claim-Lem3.1-1 | 0 | 1 | false | [AUTO-LABELED] |
396
+
397
+ ### 依赖图(Mermaid)
398
+
399
+ ```mermaid
400
+ graph TD
401
+ Def12[🧱 Definition 1.2] --> Lem31[🔧 Lemma 3.1]
402
+ Lem31 --> Thm2[⭐ Theorem 2]
403
+ Lem32[🔧 Lemma 3.2] -.->|⚠️ UNCERTAIN| Thm2
404
+ ClaimLem311[🔶 Claim-Lem3.1-1 AUTO] --> Lem31
405
+ ```
406
+
407
+ ### 预警
408
+ - ⚠️ Lemma 3.2 → Theorem 2:UNCERTAIN 依赖(JSON 原因:上下文推断,无明确引用句)
409
+ ```
410
+
411
+ ### 8.3 响应约束
412
+
413
+ | 规则 | 说明 |
414
+ |:---|:---|
415
+ | 无前缀引导 | 禁止输出"好的"、"收到"、"正在为你分析"等 |
416
+ | 无情感后缀 | 禁止输出"希望对你有所帮助"、"欢迎继续提问"等 |
417
+ | 无交叉询问 | 禁止在响应结尾反问"是否需要深入分析XXX" |
418
+ | Mermaid 独占 | Mermaid 代码块后不附加 ASCII 手工图作为"补充" |
419
+ | 错误静默 | 若 JSON 中找不到目标 URI,输出 `[ERROR: URI not found in JSON]` 后静默结束 |
420
+ | 子图截取 | `Request: "render_subgraph"` 时只输出目标 URI 的直接依赖子树,不输出全局图 |
421
+
422
+ ---
423
+
424
+ ## 九、输出模板
425
+
426
+ ### 模板A:单一定理分析(基于 JSON 解析)
427
+
428
+ ```markdown
429
+ ## 📐 证明路径:[定理编号]
430
+
431
+ > **数据来源**:`<slug>_structure.json`
432
+
433
+ ### 0. 元信息
434
+ | 字段 | 内容 |
435
+ |:---|:---|
436
+ | 数据源 | `<slug>_structure.json` |
437
+ | 论文 | [标题](来自 JSON `paper.title`) |
438
+ | 定理名 | [编号 + 名称](来自 JSON `main_theorems[].label`) |
439
+ | 核心结论 | [JSON `main_theorems[].statement` 一句话梗概] |
440
+ | 证明策略 | [JSON `main_theorems[].proof_methods[].method`] |
441
+ | 复杂度 | [⭐核心 / 🔧技术] |
442
+
443
+ ### 1. 逻辑实体清单(基于 JSON `entities[]`)
444
+
445
+ | ID | 类型 | 符号 | 入度 | 出度 | UNCERTAIN | EXTERNAL | 备注 |
446
+ |:---|:---|:---|:---:|:---:|:---:|:---:|:---|
447
+ | ThmX | THEOREM | ⭐ | 2 | 0 | 0 | 0 | — |
448
+ | LemA | LEMMA | 🔧 | 1 | 1 | 1 | 0 | 1 个 UNCERTAIN 依赖 |
449
+ | Def1 | DEFINITION | 🧱 | 0 | 1 | 0 | 0 | — |
450
+
451
+ ### 2. 依赖关系
452
+
453
+ **出度(ThmX 被以下节点依赖)**:
454
+ - 🔧 LemA → [JSON `entities[label="LemA"].statement` 一句话梗概]
455
+ - ⚠️ LemB → UNCERTAIN(JSON 原因:[`entities[label="LemB"].uncertain_dependencies[0]`])
456
+ - 📎 Ref[3] → EXTERNAL([`entities[label="LemB"].external_refs[0]`])
457
+
458
+ **入度(依赖 ThmX 的节点)**:
459
+ - CorY ← ThmX(JSON `entities[label="CorY"].cited_by` 包含 ThmX)
460
+
461
+ ### 3. 依赖关系图
462
+
463
+ ```mermaid
464
+ graph TD
465
+ Def1[🧱 Def1] --> LemA[🔧 LemA]
466
+ LemA --> ThmX[⭐ ThmX]
467
+ LemB -.->|⚠️ UNCERTAIN| ThmX
468
+ ```
469
+
470
+ ### 4. 阅读路径
471
+ - **Top-down**:ThmX → LemA → Def1(可跳过技术细节)
472
+ - **Bottom-up**:Def1 → LemA → ThmX
473
+
474
+ ### 5. 预警(基于 JSON `completeness_check`)
475
+
476
+ | 类型 | 节点 | 说明 |
477
+ |:---|:---|:---|
478
+ | ⚠️ UNCERTAIN | LemB → ThmX | JSON 未提供明确引用句 |
479
+ | 📎 EXTERNAL | Ref[3] | 当前仅假定其成立 |
480
+
481
+ ### 6. 下一步
482
+ - [ ] 展开 LemA 证明骨架
483
+ - [ ] 查看全文依赖图
484
+ ```
485
+
486
+ ### 模板B:全文全局分析(基于 JSON 解析)
487
+
488
+ ```markdown
489
+ ## 🗺️ 全文依赖图谱
490
+
491
+ > **数据来源**:`<slug>_structure.json`
492
+
493
+ ### 0. 元信息
494
+ | 字段 | 内容 |
495
+ |:---|:---|
496
+ | 数据源 | `<slug>_structure.json` |
497
+ | 标题 | [JSON `paper.title`] |
498
+ | 作者 | [JSON `paper.authors`] |
499
+ | 年份 | [JSON `paper.year`] |
500
+ | 主定理 | [JSON `main_theorems[].label`] |
501
+
502
+ ### 1. 节点清单(按拓扑排序,入度/出度基于 JSON 遍历)
503
+
504
+ | ID | 类型 | 符号 | 入度 | 出度 | 共享 |
505
+ |:---|:---|:---|:---:|:---:|:---:|
506
+ | Def1 | DEFINITION | 🧱 | 0 | 2 | false |
507
+ | Lem2 | LEMMA | 🔧 | 1 | 3 | true |
508
+ | ThmX | THEOREM | ⭐ | 4 | 0 | false |
509
+ | ClaimX | CLAIM | 🔶 | 0 | 1 | false |
510
+
511
+ ### 2. 全局依赖图
512
+
513
+ ```mermaid
514
+ graph TD
515
+ Def1[🧱 Def1] --> Lem2[🔧 Lemma 2]
516
+ Lem2 --> ThmX[⭐ Theorem X]
517
+ ClaimX[🔶 Claim-X AUTO] --> Lem2
518
+ Lem3[🔧 Lemma 3] -.->|⚠️ UNCERTAIN| ThmX
519
+ RefExt(📎 Ref [9]) -.->|EXTERNAL| Lem2
520
+ ```
521
+
522
+ ### 3. 关键路径识别
523
+ - **最长依赖链**:Def1 → Lem3 → Lem2 → ThmX
524
+ - **核心枢纽**:Lem2(in-degree = 5,JSON `shared_node: true`)
525
+ - **共享节点**:Lem2 同时被 ThmX 和 ThmY 使用
526
+
527
+ ### 4. 复现执行顺序(Bottom-up)
528
+ 1. 处理无上游依赖的节点(Def1, Def2, Assumption1)
529
+ 2. 处理第一层派生节点(Lem2, Lem3)
530
+ 3. 最终组合主定理(ThmX)
531
+
532
+ ### 5. 预警与外部依赖清单
533
+
534
+ **外部依赖**(JSON `completeness_check.external_deps`):
535
+
536
+ | 引用 | 来源 | 用途 |
537
+ |:---|:---|:---|
538
+ | 📎 [9] | Lemma 2.3 | 标准不等式 |
539
+
540
+ **孤立节点**(JSON `completeness_check.isolated_results`):
541
+ - ⚠️ Proposition 2.7 [ISOLATED] — 未被任何主定理依赖链覆盖
542
+ - 可能原因:独立的延伸结论
543
+
544
+ **UNCERTAIN 依赖**(JSON `uncertain_log`):
545
+ - ⚠️ Lemma 3.1 → Lemma 3.4:严重程度 LOW(上下文推断)
546
+ - ⚠️ Theorem 1.1 某步骤:严重程度 HIGH(陈述不完整)
547
+
548
+ ---
549
+
550
+ ## 十、异常处理规范
551
+
552
+ | 情况 | 处理方式 |
553
+ |:---|:---|
554
+ | JSON 不可用 | "当前未提供 `<slug>_structure.json`,请先运行 skill_base 生成结构化数据。" |
555
+ | JSON 中目标 URI 不存在 | `[ERROR: URI not found in JSON]` |
556
+ | 依赖关系带 `[UNCERTAIN]` 标签 | 虚线标注 + `⚠️ UNCERTAIN` 标注;在预警中列出 JSON 原因 |
557
+ | 外部依赖过多(> 5 个) | 单独列出清单,建议优先回顾 |
558
+ | JSON 存在循环依赖(`completeness_check.circular_deps` 非空) | 🚨 警告 + JSON 中的循环路径 |
559
+ | JSON 中发现 AUTO-LABELED 实体 | 节点文本追加 `[AUTO]`,备注中写明"标签由 skill_base 自动生成" |
560
+
561
+ ---
562
+
563
+ ## 十一、联动说明
564
+
565
+ 本模块是 `skill_base` → `skill_paper_deep_read` → `skill_pathway_proof` 数据流水线的末端渲染引擎。
566
+
567
+ ```
568
+ skill_base(结构提取)
569
+ ↓ <slug>_structure.json
570
+ skill_paper_deep_read(深度解读,消费 JSON)
571
+ ↓ 读取 skill_pathway_proof.md,执行图渲染流程
572
+ skill_pathway_proof(图渲染,纯消费 JSON)
573
+ ↓ Mermaid 依赖图 + 拓扑分析
574
+ ```
575
+
576
+ 生成的数据和图表可作为:
577
+ - **论文深度阅读助手** L3.4 依赖图的直接渲染源
578
+ - **文献管理助手** 的双向链接原子节点
579
+
580
+ **模块调用说明**:
581
+
582
+ | 调用方式 | 入口 | 输出 |
583
+ |:---|:---|:---|
584
+ | 独立运行(用户直接调用) | 提供 JSON 文件路径 | 模板A 或 模板B |
585
+ | 子模块调用(API 模式) | `[SYSTEM-CALL → skill_pathway_proof]` | 纯 Mermaid + 节点分析(无寒暄) |
586
+
587
+ 当你发现入度极高(被多次依赖)的核心枢纽节点(shared_node: true 或 in-degree ≥ 3)时,必须主动询问用户:
588
+ "检测到引理 X.Y 是本文的逻辑咽喉(JSON `shared_node: true`,in-degree = N),是否需要将其单独抽离为一张【知识卡片】,存入文献管理库供未来其他论文复用?"
589
+
590
+ ---
591
+
592
+ ## 十二、快捷指令台 (Slash Commands)
593
+
594
+ - `/load_json <slug>`:加载 `<slug>_structure.json` 文件作为当前会话的数据源,不执行分析,仅回复"JSON 已加载,共 N 个实体,M 条依赖关系"。
595
+ - `/graph [scope]`:渲染依赖图。scope 可选 `full`(全文)或 `sub:Thm-X`(指定定理子图)。
596
+ - `/zoom [ID]`:调用【模板A】,对指定节点进行显微镜级别的逻辑展开。
597
+ - `/feynman [ID]`:跳出严谨模板,用极度通俗的生活隐喻解释该定理的核心思想。
598
+ - `/fix [ID]`:针对带有预警(⚠️/🔍/🚨)的节点,尝试推导并补全缺失的证明步骤。
599
+
600
+ **初始指令**:回复:”**📐 逻辑拓扑架构师已就绪。请提供 `<slug>_structure.json` 文件路径,或使用 `/load_json <slug>` 指定数据源。**”
601
+
602
+ ---
603
+
604
+ ## 十三、输出自检清单(Agent 必须自查)
605
+
606
+ ### 数据源
607
+ - [ ] **JSON 已消费**:所有拓扑计算基于 JSON `entities[]` 的 `dependencies` 和 `cited_by` 的硬数据
608
+ - [ ] **禁止脑补**:未自行从原始文本提取任何实体或依赖关系
609
+ - [ ] **JSON 来源声明**:每个模板开头标注了数据来源为 `<slug>_structure.json`
610
+
611
+ ### 映射与渲染
612
+ - [ ] **类型符号映射**:JSON `type` 已正确映射到 §2.1 的符号系统
613
+ - [ ] **防崩溃清洗**:Mermaid 节点文本已执行去 LaTeX 化和去特殊字符化
614
+ - [ ] **不确定性可视化**:`[UNCERTAIN]` 依赖已用虚线 `-.->` + `⚠️` 标注
615
+ - [ ] **外部依赖可视化**:`[EXTERNAL]` 依赖已用虚线 `-.->` + `📎` 标注
616
+ - [ ] **AUTO-LABELED 保留**:`auto_labeled: true` 的节点已追加 `[AUTO]` 标注
617
+ - [ ] **共享节点标注**:`shared_node: true` 的节点已追加 `[*]`
618
+
619
+ ### 拓扑计算
620
+ - [ ] **入度/出度已计算**:所有入度/出度值基于 JSON 遍历,非估算
621
+ - [ ] **节点 >40 时核心节点优先**:已按 §2.2 仅计算核心节点精度,非核心标记 `[TECH]`
622
+ - [ ] **孤立节点已单独列出**:从 `completeness_check.isolated_results` 读取,未并入主树
623
+ - [ ] **循环依赖已检测**:从 `completeness_check.circular_deps` 读取(或写为"无")
624
+
625
+ ### 图规模降级
626
+ - [ ] **节点数已检查**:已确认 JSON 实体总数并判断是否触发降级
627
+ - [ ] **>40 时已降级**:已仅渲染多根深度 2 子图(所有 THEOREM 节点),非核心节点以文字清单列出
628
+ - [ ] **降级引导语已附加**:图上方已附加 `⚠️ 全文节点数超过 40` 提示
629
+ - [ ] **用户覆盖路径已提供**:已告知 `/graph full` 可强制渲染全量图
630
+
631
+ ### 预警
632
+ - [ ] **依赖链缺失已标注**:从 `completeness_check.dependency_integrity` 读取
633
+ - [ ] **外部依赖清单已生成**:从 `completeness_check.external_deps` 读取
634
+ - [ ] **UNCERTAIN 日志已查询**:从 `uncertain_log` 读取并渲染
635
+
636
+ ### API 模式
637
+ - [ ] **纯技术输出**:API 模式输出不含寒暄语、问候、引导性提问
638
+ - [ ] **子图截取精确**:`render_subgraph` 请求只输出目标 URI 的直接子树
639
+ - [ ] **错误静默**:URI 不存在时输出 `[ERROR]` 后静默结束
640
+
641
+ ### 保存
642
+ - [ ] **文件写入已尝试**:已尝试使用 `Write` 工具、Bash 命令或 Python 脚本保存 `.md` 文件
643
+ - [ ] **回退方案已执行**(如文件写入不可用):已输出完整 Markdown 代码 fence + 手动保存提醒
644
+ - [ ] JSON 分析记录已保存为 `.json` 文件
645
+
646
+ ---
647
+
648
+ ## 十四、输出保存指引
649
+
650
+ 依赖图谱、证明路径分析应保存为独立文件以便跨论文复用。
651
+
652
+ ### 推荐文件命名
653
+
654
+ | 输出类型 | 推荐扩展名 | 文件名模板 | 说明 |
655
+ |:---|:---|:---|:---|
656
+ | 全局依赖图谱 | `.md` | `[论文简称]_全局依赖图_YYYY-MM-DD.md` | 全文依赖图 |
657
+ | 定理分析报告 | `.md` | `[论文简称]_[Thm-ID]_证明路径.md` | 单定理分析 |
658
+ | 引理关系图 | `.md` | `[论文简称]_引理关系_YYYY-MM-DD.md` | 引理拓扑 |
659
+ | 知识卡片 | `.md` | `[论文简称]_[核心引理ID]_知识卡片.md` | 独立知识卡片 |
660
+
661
+ ### 文件名规范
662
+ - 使用论文核心关键词作为前缀
663
+ - 定理/引理编号体现在文件名中
664
+ - 日期格式:`YYYY-MM-DD`
665
+ - 知识卡片突出核心引理标识
666
+
667
+ ### 示例
668
+ ```
669
+ Wu_Optimization_全局依赖图_2024-04-27.md
670
+ Wu_Optimization_Thm2_证明路径.md
671
+ Wu_Optimization_引理关系_2024-04-27.md
672
+ Wu_Optimization_Lem3.2_知识卡片.md
673
+ ```
674
+
675
+ ### 自动保存规则(适应 Agentic 环境)
676
+
677
+ 每次生成 Mermaid 依赖图后,**必须自动保存为独立文件**,不得仅以对话内文本形式输出。
678
+
679
+ **步骤 1:尝试使用宿主环境的文件写入能力**
680
+
681
+ 按以下优先级尝试写入文件:
682
+
683
+ | 优先级 | 方法 | 适用场景 |
684
+ |:---|:---|:---|
685
+ | 1 | 调用文件系统工具(如 `fs.write`、`Write` 工具、`FileSave` API、Python `open().write()`) | 宿主环境提供了文件系统访问能力 |
686
+ | 2 | 使用 Bash 命令(如 `cat > file.md << 'EOF' ... EOF`) | 宿主环境提供 shell 执行能力 |
687
+ | 3 | 使用 Python 脚本(`with open(...) as f: f.write(...)`) | 宿主环境提供 Python 解释器 |
688
+
689
+ **写入目标路径**:
690
+ | 条件 | 路径 |
691
+ |:---|:---|
692
+ | 当前工作目录包含 `memory/` 子目录 | `<workdir>/memory/<filename>` |
693
+ | 环境变量 `MEMORY_DIR` 已设置 | `$MEMORY_DIR/<filename>` |
694
+ | 两者均不可用时 | 当前工作目录下的 `graphs/` 子目录(自动创建) |
695
+
696
+ **保存格式与文件名**(与之前一致):
697
+
698
+ | 条件 | 保存格式 | 文件名模板 |
699
+ |:---|:---|:---|
700
+ | 全文全局依赖图(模板B) | `.md` (代码块 + Mermaid) | `[论文简称]_全局依赖图_YYYY-MM-DD.md` |
701
+ | 全局依赖图(纯 HTML) | `.html` | `[论文简称]_全局依赖图_YYYY-MM-DD.html` |
702
+ | 单定理分析(模板A) | `.md` | `[论文简称]_[Thm-ID]_证明路径.md` |
703
+
704
+ **步骤 2:回退方案(当文件写入不可用时)**
705
+
706
+ 如果当前运行时环境**不提供任何文件写入工具**,则:
707
+
708
+ 1. 将完整的 Markdown 内容(含 Mermaid 代码块)包裹在标准 Markdown 代码 fence 中输出
709
+ 2. 在代码块下方附加以下提醒:
710
+
711
+ > **📄 文件保存提醒**:当前运行时环境不支持自动写入文件。请将上方代码块内容复制保存为独立文件(按上表命名规则),手动放置到项目的 `memory/` 目录或 `graphs/` 目录中。
712
+
713
+ **注意**:此回退方案仅在**确认文件写入工具不可用**时使用。Agent 不得以此为借口跳过保存步骤 — 优先尝试写入,写入失败再回退。
714
+
715
+ **检查机制**:输出结束前自检是否已执行以下任一操作:
716
+ - ✅ 已经通过工具调用写入了文件
717
+ - ✅ 已经输出了完整 Markdown 代码 fence + 手动保存提醒
718
+ - ❌ 未执行以上任一操作 → 视为违反规则