@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,460 @@
1
+ /**
2
+ * Dependency-graph engine for math-paper-reading structure artifacts,
3
+ * aligned with the upstream skill_pathway_proof contract: batch merging,
4
+ * cited_by reconstruction, shared_node computation, topology metrics,
5
+ * cycle detection, reading paths, and degraded Mermaid rendering.
6
+ * All computations are deterministic pure functions — the upstream skill
7
+ * forbids model-side manual graph traversal.
8
+ * @module @louisultra/dsh-verymath/core
9
+ */
10
+ import { VeryMathError } from "./error.js";
11
+ /** Type guard: `Array.isArray` cannot narrow `readonly T[]` unions, so this
12
+ * predicate provides reliable narrowing for both branches. */
13
+ export function isSingleStructure(input) {
14
+ return !Array.isArray(input);
15
+ }
16
+ /** Strip the upstream `[UNCERTAIN: reason]` suffix from a dependency label. */
17
+ export function stripUncertain(dependency) {
18
+ const index = dependency.indexOf(' [');
19
+ return index >= 0 ? dependency.slice(0, index).trim() : dependency.trim();
20
+ }
21
+ /** Normalize any input shape into the document list. */
22
+ function documentsOf(input) {
23
+ return isSingleStructure(input) ? [input] : input;
24
+ }
25
+ /**
26
+ * Unique entities across one or more batch artifacts, keyed by label
27
+ * (first occurrence wins, duplicates counted). Order follows input order.
28
+ * @param input - one artifact or a list of batch artifacts.
29
+ */
30
+ export function collectEntities(input) {
31
+ const documents = documentsOf(input);
32
+ const unique = new Map();
33
+ let duplicates = 0;
34
+ for (const document of documents) {
35
+ for (const entity of document.entities ?? []) {
36
+ if (unique.has(entity.label))
37
+ duplicates += 1;
38
+ else
39
+ unique.set(entity.label, entity);
40
+ }
41
+ }
42
+ return { entities: [...unique.values()], duplicates };
43
+ }
44
+ /**
45
+ * Merge batch artifacts per the upstream Skill-2 protocol: dedupe by label,
46
+ * rebuild the reverse index (`cited_by`) from forward `dependencies` and
47
+ * cleaned `uncertain_dependencies`, and compute `shared_node` (in-degree ≥ 2
48
+ * with at least one citing THEOREM). Input artifacts are never mutated; the
49
+ * returned entities are rebuilt copies.
50
+ * @param input - one artifact or a list of batch artifacts.
51
+ * @returns rebuilt entities plus a merge report.
52
+ */
53
+ export function mergeBatches(input) {
54
+ const { entities: uniqueEntities, duplicates } = collectEntities(input);
55
+ const known = new Set(uniqueEntities.map(entity => entity.label));
56
+ const citedBy = new Map();
57
+ const citingTypes = new Map();
58
+ const dangling = new Set();
59
+ let rebuiltCitedBy = 0;
60
+ for (const entity of uniqueEntities) {
61
+ const forward = [
62
+ ...(entity.dependencies ?? []),
63
+ ...(entity.uncertain_dependencies ?? []).map(stripUncertain),
64
+ ];
65
+ for (const rawDependency of forward) {
66
+ const dependency = stripUncertain(rawDependency);
67
+ if (!known.has(dependency)) {
68
+ dangling.add(`${entity.label} -> ${dependency}`);
69
+ continue;
70
+ }
71
+ rebuiltCitedBy += 1;
72
+ const cited = citedBy.get(dependency) ?? new Set();
73
+ cited.add(entity.label);
74
+ citedBy.set(dependency, cited);
75
+ const types = citingTypes.get(dependency) ?? new Set();
76
+ types.add(entity.type);
77
+ citingTypes.set(dependency, types);
78
+ }
79
+ }
80
+ const sharedNodes = [];
81
+ const entities = uniqueEntities.map(entity => {
82
+ const cited = citedBy.get(entity.label);
83
+ const shared = cited !== undefined && cited.size >= 2 && citingTypes.get(entity.label)?.has('THEOREM') === true;
84
+ if (shared)
85
+ sharedNodes.push(entity.label);
86
+ return {
87
+ ...entity,
88
+ cited_by: cited === undefined ? [] : [...cited].sort(),
89
+ shared_node: shared,
90
+ };
91
+ });
92
+ return {
93
+ entities,
94
+ report: {
95
+ totalEntities: entities.length,
96
+ mergedDuplicates: duplicates,
97
+ danglingEdges: [...dangling].sort(),
98
+ rebuiltCitedBy,
99
+ sharedNodes,
100
+ },
101
+ };
102
+ }
103
+ /** Detect dependency cycles via colored DFS over forward edges. */
104
+ function findCycles(labels, edges) {
105
+ const state = new Map();
106
+ const stack = [];
107
+ const cycles = [];
108
+ const visit = (label) => {
109
+ const marker = state.get(label);
110
+ if (marker === 2)
111
+ return;
112
+ if (marker === 1) {
113
+ const start = stack.indexOf(label);
114
+ if (start >= 0)
115
+ cycles.push({ labels: [...stack.slice(start), label] });
116
+ return;
117
+ }
118
+ state.set(label, 1);
119
+ stack.push(label);
120
+ for (const next of edges.get(label) ?? [])
121
+ visit(next);
122
+ stack.pop();
123
+ state.set(label, 2);
124
+ };
125
+ for (const label of labels)
126
+ visit(label);
127
+ return cycles;
128
+ }
129
+ /**
130
+ * Compute the full topology of a (possibly batched) artifact: per-entity
131
+ * metrics, cycles, both reading directions, longest chain, and orphans.
132
+ * @param input - one artifact or merged batches.
133
+ * @param mainTheoremLabels - explicit theorem roots; defaults to the artifact's `main_theorems`.
134
+ */
135
+ export function computeTopology(input, mainTheoremLabels) {
136
+ const { entities } = mergeBatches(input);
137
+ const artifact = isSingleStructure(input) ? input : undefined;
138
+ const theorems = artifact?.main_theorems ?? [];
139
+ const theoremLabels = mainTheoremLabels ?? theorems.map(theorem => theorem.label);
140
+ const byLabel = new Map(entities.map(entity => [entity.label, entity]));
141
+ const dependenciesOf = (entity) => [
142
+ ...(entity.dependencies ?? []).map(stripUncertain),
143
+ ...(entity.uncertain_dependencies ?? []).map(stripUncertain),
144
+ ].filter(label => byLabel.has(label));
145
+ const dependentsOf = (entity) => (entity.cited_by ?? []).filter(label => byLabel.has(label));
146
+ const edges = new Map(entities.map((entity) => [entity.label, dependenciesOf(entity)]));
147
+ const reverseEdges = new Map(entities.map((entity) => [entity.label, dependentsOf(entity)]));
148
+ const cycles = findCycles(entities.map(entity => entity.label), edges);
149
+ // Transitive main-theorem support: reverse BFS from theorem roots.
150
+ const supports = new Set();
151
+ const supportQueue = [...theoremLabels];
152
+ while (supportQueue.length > 0) {
153
+ const label = supportQueue.pop();
154
+ if (label === undefined || supports.has(label))
155
+ continue;
156
+ supports.add(label);
157
+ for (const dependency of edges.get(label) ?? [])
158
+ supportQueue.push(dependency);
159
+ }
160
+ const metrics = entities.map(entity => ({
161
+ label: entity.label,
162
+ type: entity.type,
163
+ inDegree: dependentsOf(entity).length,
164
+ outDegree: dependenciesOf(entity).length,
165
+ sharedNode: entity.shared_node === true,
166
+ supportsMainTheorem: supports.has(entity.label),
167
+ uncertainDependencies: entity.uncertain_dependencies ?? [],
168
+ }));
169
+ // Bottom-up Kahn layers over forward dependency edges.
170
+ const remaining = new Map(entities.map((entity) => [entity.label, dependenciesOf(entity).length]));
171
+ let frontier = entities.filter(entity => dependenciesOf(entity).length === 0).map(entity => entity.label);
172
+ const bottomUpLevels = [];
173
+ const visited = new Set();
174
+ while (frontier.length > 0) {
175
+ bottomUpLevels.push([...frontier].sort());
176
+ for (const label of frontier)
177
+ visited.add(label);
178
+ const next = [];
179
+ for (const label of frontier) {
180
+ for (const dependent of reverseEdges.get(label) ?? []) {
181
+ if (visited.has(dependent))
182
+ continue;
183
+ const count = (remaining.get(dependent) ?? 0) - 1;
184
+ remaining.set(dependent, count);
185
+ if (count === 0)
186
+ next.push(dependent);
187
+ }
188
+ }
189
+ frontier = [...new Set(next)];
190
+ }
191
+ if (cycles.length > 0) {
192
+ // Nodes stuck in or behind cycles never reach in-degree 0; surface them as a trailing level.
193
+ const stuck = entities.map(entity => entity.label).filter(label => !visited.has(label));
194
+ if (stuck.length > 0)
195
+ bottomUpLevels.push([...stuck].sort());
196
+ }
197
+ // Top-down BFS from main theorems along dependency edges.
198
+ const topDown = [];
199
+ const seen = new Set();
200
+ const bfsQueue = [...theoremLabels.filter((label) => byLabel.has(label))];
201
+ while (bfsQueue.length > 0) {
202
+ const label = bfsQueue.shift();
203
+ if (label === undefined || seen.has(label))
204
+ continue;
205
+ seen.add(label);
206
+ topDown.push(label);
207
+ for (const dependency of edges.get(label) ?? [])
208
+ bfsQueue.push(dependency);
209
+ }
210
+ // Longest dependency chain via memoized DFS with cycle guard.
211
+ const depth = new Map();
212
+ const chainFor = (label, active) => {
213
+ const cached = depth.get(label);
214
+ if (cached !== undefined)
215
+ return cached;
216
+ if (active.has(label))
217
+ return { length: 0, chain: [label] };
218
+ active.add(label);
219
+ let best = { length: 0, chain: [label] };
220
+ for (const dependency of edges.get(label) ?? []) {
221
+ const sub = chainFor(dependency, active);
222
+ if (sub.length + 1 > best.length)
223
+ best = { length: sub.length + 1, chain: [label, ...sub.chain] };
224
+ }
225
+ active.delete(label);
226
+ depth.set(label, best);
227
+ return best;
228
+ };
229
+ let longestChain = [];
230
+ for (const label of entities.map(entity => entity.label)) {
231
+ const candidate = chainFor(label, new Set());
232
+ if (candidate.chain.length > longestChain.length)
233
+ longestChain = candidate.chain;
234
+ }
235
+ const isolated = entities
236
+ .filter(entity => dependenciesOf(entity).length === 0 && dependentsOf(entity).length === 0)
237
+ .map(entity => entity.label)
238
+ .sort();
239
+ return {
240
+ metrics,
241
+ cycles,
242
+ bottomUpLevels,
243
+ topDownOrder: topDown,
244
+ longestChain,
245
+ isolated,
246
+ degradedRendering: entities.length > 40,
247
+ };
248
+ }
249
+ const TYPE_SYMBOLS = {
250
+ THEOREM: '⭐', LEMMA: '🔧', PROPOSITION: '📐', CLAIM: '🔶',
251
+ DEFINITION: '🧱', CONSTRUCTION: '🧱', OBSERVATION: '💡', REMARK: '💡',
252
+ COROLLARY: '📎',
253
+ };
254
+ /** Mermaid node id: alphanumerics and hyphens only. */
255
+ function mermaidId(label) {
256
+ const id = label.replace(/[^A-Za-z0-9-]/g, '');
257
+ if (id.length > 0)
258
+ return id;
259
+ let hash = 0;
260
+ for (const char of label)
261
+ hash = ((hash << 5) - hash + char.charCodeAt(0)) | 0;
262
+ return `n${Math.abs(hash)}`;
263
+ }
264
+ /** Clean one statement into a safe ≤50-char Mermaid display text (upstream §3.2):
265
+ * strip $ delimiters and render commands but keep the inner content (e.g.
266
+ * \mathbb{R}^d → R^d), then sanitize and truncate. */
267
+ export function mermaidDisplayText(label, statement) {
268
+ const cleaned = statement
269
+ .replace(/\\(mathbb|mathcal|mathfrak|mathrm)/g, '')
270
+ .replace(/\$\s*/g, '')
271
+ .replace(/\\[a-zA-Z]+/g, ' ')
272
+ .replace(/[{}]/g, '')
273
+ .replace(/\s+/g, ' ')
274
+ .trim();
275
+ const summary = cleaned.length > 0 ? `${label}: ${cleaned}` : label;
276
+ const text = summary.length > 50 ? `${summary.slice(0, 47)}...` : summary;
277
+ return /[\^_~]/.test(text) ? `"${text.replace(/"/g, '')}"` : text;
278
+ }
279
+ /**
280
+ * Render a full or degraded Mermaid dependency graph (upstream §3/§4/§6):
281
+ * subgraph layering, UNCERTAIN/EXTERNAL dashed edges, shared/auto markers,
282
+ * and the >40-node degradation to depth-2 THEOREM-rooted subgraphs.
283
+ * @param structure - the structure artifact holding the entities.
284
+ * @param options - force full rendering even above the degradation threshold.
285
+ */
286
+ export function renderMermaid(structure, options = {}) {
287
+ requireStructure(structure);
288
+ const { entities } = mergeBatches(structure);
289
+ const byLabel = new Map(entities.map(entity => [entity.label, entity]));
290
+ const lines = ['graph TD'];
291
+ const edgeLines = [];
292
+ const declared = new Set();
293
+ const declare = (entity) => {
294
+ if (declared.has(entity.label))
295
+ return;
296
+ declared.add(entity.label);
297
+ const symbol = TYPE_SYMBOLS[entity.type] ?? '💡';
298
+ const markers = [
299
+ entity.shared_node === true ? ' [*]' : '',
300
+ entity.auto_labeled === true ? ' [AUTO]' : '',
301
+ ].join('');
302
+ lines.push(` ${mermaidId(entity.label)}[${symbol} ${mermaidDisplayText(entity.label, entity.statement)}]${markers}`);
303
+ };
304
+ const renderEdges = (labels) => {
305
+ for (const entity of entities) {
306
+ if (!labels.has(entity.label))
307
+ continue;
308
+ for (const dependency of (entity.dependencies ?? []).map(stripUncertain)) {
309
+ if (!byLabel.has(dependency) || !labels.has(dependency))
310
+ continue;
311
+ edgeLines.push(` ${mermaidId(entity.label)} --> ${mermaidId(dependency)}`);
312
+ }
313
+ for (const raw of entity.uncertain_dependencies ?? []) {
314
+ const dependency = stripUncertain(raw);
315
+ if (!byLabel.has(dependency) || !labels.has(dependency))
316
+ continue;
317
+ edgeLines.push(` ${mermaidId(entity.label)} -.->|⚠️ UNCERTAIN| ${mermaidId(dependency)}`);
318
+ }
319
+ for (const ref of entity.external_refs ?? []) {
320
+ const id = `ext${mermaidId(ref)}`;
321
+ if (!declared.has(id)) {
322
+ declared.add(id);
323
+ lines.push(` ${id}(📎 ${ref.replace(/[{}"]/g, '')})`);
324
+ }
325
+ edgeLines.push(` ${mermaidId(entity.label)} -.->|📎 EXTERNAL| ${id}`);
326
+ }
327
+ }
328
+ };
329
+ const degraded = entities.length > 40 && options.forceFull !== true;
330
+ if (degraded) {
331
+ // Upstream degradation: THEOREM-rooted depth-2 subgraphs only.
332
+ lines.push(' %% ⚠️ >40 entities: degraded to THEOREM-rooted depth-2 subgraphs');
333
+ const roots = entities.filter(entity => entity.type === 'THEOREM');
334
+ for (const root of roots) {
335
+ lines.push(` subgraph ${mermaidId(root.label)}_sub`);
336
+ const scope = new Set([root.label]);
337
+ declare(root);
338
+ for (const dependency of (root.dependencies ?? []).map(stripUncertain)) {
339
+ const entity = byLabel.get(dependency);
340
+ if (entity === undefined)
341
+ continue;
342
+ scope.add(dependency);
343
+ declare(entity);
344
+ for (const nested of (entity.dependencies ?? []).map(stripUncertain)) {
345
+ const nestedEntity = byLabel.get(nested);
346
+ if (nestedEntity === undefined)
347
+ continue;
348
+ scope.add(nested);
349
+ declare(nestedEntity);
350
+ }
351
+ }
352
+ renderEdges(scope);
353
+ lines.push(' end');
354
+ }
355
+ const unrendered = entities.filter(entity => !declared.has(entity.label)).map(entity => entity.label);
356
+ if (unrendered.length > 0) {
357
+ lines.push(` %% Text list of ${unrendered.length} non-core nodes: ${unrendered.slice(0, 10).join(', ')}${unrendered.length > 10 ? ' …' : ''}`);
358
+ }
359
+ }
360
+ else {
361
+ // Full rendering with upstream subgraph grouping, bottom-up order.
362
+ const layers = [
363
+ { title: 'Assumptions', filter: entity => entity.type === 'DEFINITION' || entity.type === 'CONSTRUCTION' },
364
+ { title: 'CoreLemmas', filter: entity => (entity.type === 'LEMMA' || entity.type === 'PROPOSITION') && (entity.shared_node === true || (entity.cited_by?.length ?? 0) >= 2) },
365
+ { title: 'TechnicalLemmas', filter: entity => (entity.type === 'LEMMA' || entity.type === 'CLAIM') && entity.shared_node !== true && (entity.cited_by?.length ?? 0) < 2 },
366
+ { title: 'MainResults', filter: entity => entity.type === 'THEOREM' || entity.type === 'COROLLARY' },
367
+ ];
368
+ const grouped = new Set();
369
+ for (const layer of layers) {
370
+ const members = entities.filter(entity => layer.filter(entity) && !grouped.has(entity.label));
371
+ if (members.length === 0)
372
+ continue;
373
+ for (const member of members)
374
+ grouped.add(member.label);
375
+ lines.push(` subgraph ${layer.title}`);
376
+ for (const member of members)
377
+ declare(member);
378
+ lines.push(' end');
379
+ }
380
+ for (const other of entities.filter(entity => !grouped.has(entity.label)))
381
+ declare(other);
382
+ // Render every node's edges (both endpoints exist by construction).
383
+ renderEdges(new Set(entities.map(entity => entity.label)));
384
+ // External references hang off entities that may have no forward edges;
385
+ // declare their ext nodes regardless so they always render.
386
+ for (const entity of entities) {
387
+ for (const ref of entity.external_refs ?? []) {
388
+ const id = `ext${mermaidId(ref)}`;
389
+ if (!declared.has(id)) {
390
+ declared.add(id);
391
+ lines.push(` ${id}(📎 ${ref.replace(/[{}"\[\]]/g, '')})`);
392
+ }
393
+ edgeLines.push(` ${mermaidId(entity.label)} -.->|📎 EXTERNAL| ${id}`);
394
+ }
395
+ }
396
+ }
397
+ return [...lines, ...edgeLines].join('\n');
398
+ }
399
+ /** Throw a structured error when a structure artifact cannot be processed. */
400
+ export function requireStructure(value) {
401
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
402
+ throw new VeryMathError('paper structure input must be a JSON object', 'VERYMATH_PAPER_INVALID');
403
+ }
404
+ return value;
405
+ }
406
+ /**
407
+ * Compute the transitive dependency closure and layered reading path for one
408
+ * entity (upstream skill_pathway_proof §5 reading-path generation, which the
409
+ * skill currently delegates to unreliable model-side BFS).
410
+ * @param input - one artifact or merged batches.
411
+ * @param label - the focus entity label.
412
+ */
413
+ export function focusClosure(input, label) {
414
+ const { entities } = mergeBatches(input);
415
+ const artifact = isSingleStructure(input) ? input : undefined;
416
+ const theorems = artifact?.main_theorems ?? [];
417
+ // Labels resolve against the merged namespace: entities plus main_theorems
418
+ // (upstream top-down reading paths start at main_theorems, which the
419
+ // compact v4.2 form may omit from entities[]). Main theorems absent from
420
+ // entities participate as leaf nodes with no recorded forward edges.
421
+ const byLabel = new Map(entities.map(entity => [entity.label, entity]));
422
+ const mergedNamespace = new Map(byLabel);
423
+ for (const theorem of theorems) {
424
+ if (!mergedNamespace.has(theorem.label)) {
425
+ mergedNamespace.set(theorem.label, {
426
+ type: 'THEOREM',
427
+ label: theorem.label,
428
+ statement: theorem.statement,
429
+ });
430
+ }
431
+ }
432
+ if (!mergedNamespace.has(label)) {
433
+ return { label, closure: [], levels: [], found: false };
434
+ }
435
+ const dependenciesOf = (entity) => [
436
+ ...(entity.dependencies ?? []).map(stripUncertain),
437
+ ...(entity.uncertain_dependencies ?? []).map(stripUncertain),
438
+ ].filter(dependency => mergedNamespace.has(dependency));
439
+ const levels = [[label]];
440
+ const seen = new Set([label]);
441
+ let frontier = [label];
442
+ while (frontier.length > 0) {
443
+ const next = [];
444
+ for (const current of frontier) {
445
+ const entity = mergedNamespace.get(current);
446
+ if (entity === undefined)
447
+ continue;
448
+ for (const dependency of dependenciesOf(entity)) {
449
+ if (!seen.has(dependency)) {
450
+ seen.add(dependency);
451
+ next.push(dependency);
452
+ }
453
+ }
454
+ }
455
+ if (next.length > 0)
456
+ levels.push([...new Set(next)].sort((left, right) => (left < right ? -1 : left > right ? 1 : 0)));
457
+ frontier = next;
458
+ }
459
+ return { label, closure: [...seen].sort((left, right) => (left < right ? -1 : left > right ? 1 : 0)), levels, found: true };
460
+ }
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Service Definition for the VeryMath capability seam (`ctx.verymath`):
3
+ * glossary library resolution and querying, Python interpreter discovery for
4
+ * the upstream `math-glossary` scripts, and registration of the bundled
5
+ * VeryMath skills into the DSH skill registry.
6
+ * @module @louisultra/dsh-verymath/core
7
+ */
8
+ import { Context, Service } from '@deepseek-ai/cordis';
9
+ import z from '@deepseek-ai/schemastery';
10
+ import { type GlossaryHit, type GlossaryQueryOptions, type GlossaryTerm } from './glossary.ts';
11
+ export { VeryMathError, isVeryMathError } from './error.ts';
12
+ export { bundledSkillsDir } from './paths.ts';
13
+ export { VeryMathSkillProvider } from './skills.ts';
14
+ export { parseGlossary, queryGlossary, sortGlossary, upsertTerms, validateGlossaryInvariants } from './glossary.ts';
15
+ export type { GlossaryHit, GlossaryQueryOptions, GlossaryTerm, TermUpsert, UpsertResult } from './glossary.ts';
16
+ export { parsePaperStructure, dependencySummary } from './paper.ts';
17
+ export { checkGate, checkGoalApproval, checkWorkstreamCompletion, checkFinalRender, loadGoals, listWorkstreams, hasSection, } from './gates.ts';
18
+ export type { GateResult } from './gates.ts';
19
+ export { loadManifest, searchSageRefs, scoreRow, termsFor, findExcerpt, readCorpusDoc, readCorpusDocWindow, resolveCorpusRoot, defaultCorpusRoot, docPath, } from './sage.ts';
20
+ export type { SageRefRow, SageRefHit } from './sage.ts';
21
+ export { mergeBatches, collectEntities, computeTopology, renderMermaid, focusClosure, mermaidDisplayText, stripUncertain, isSingleStructure, requireStructure, } from './graph.ts';
22
+ export type { StructureInput, MergeReport, EntityTopology, DependencyCycle, GraphTopology, FocusResult, } from './graph.ts';
23
+ export type { PaperStructure, PaperMeta, PaperSection, PaperEntity, PaperTable, MainTheorem, ProofMethod, ProofFramework, CompletenessCheck, RelatedWorkEntry, } from './paper.ts';
24
+ declare module '@deepseek-ai/cordis' {
25
+ interface Context {
26
+ verymath: VeryMathRuntime;
27
+ }
28
+ }
29
+ /** Where one glossary lives and what it contains. */
30
+ export interface GlossaryLibrary {
31
+ /** Absolute path of the glossary JSON document. */
32
+ readonly path: string;
33
+ /** Parsed terms in stored order. */
34
+ readonly terms: GlossaryTerm[];
35
+ }
36
+ /** Result of running one upstream Python script. */
37
+ export interface PythonRunResult {
38
+ readonly exitCode: number;
39
+ readonly stdout: string;
40
+ readonly stderr: string;
41
+ }
42
+ /** Config for the VeryMath seam. */
43
+ export interface VeryMathRuntimeConfig {
44
+ /**
45
+ * Explicit Python executable used for the upstream `math-glossary` scripts.
46
+ * Omitted resolves `DSH_OFFICE_PYTHON`, then `python3`, then `python`.
47
+ */
48
+ readonly pythonExecutable?: string;
49
+ /** Default hit cap for glossary queries. */
50
+ readonly queryMaxHits?: number;
51
+ }
52
+ /**
53
+ * The VeryMath access service, registered as `ctx.verymath`. Owns glossary
54
+ * parsing/querying, Python discovery, and bundled-skill registration.
55
+ */
56
+ export declare class VeryMathRuntime extends Service {
57
+ /** The bundled-skill provider needs the host skill registry. */
58
+ static inject: string[];
59
+ static Config: z<VeryMathRuntimeConfig>;
60
+ /** Resolved service config with every default applied. */
61
+ readonly config: Required<VeryMathRuntimeConfig>;
62
+ private readonly glossaryCache;
63
+ private pythonProbe;
64
+ constructor(ctx: Context, config?: VeryMathRuntimeConfig);
65
+ /**
66
+ * Register the bundled-skill provider on the DSH skill registry when the
67
+ * host provides one. Registration is global-layer (unscoped context); the
68
+ * returned disposer is folded into this service's lifecycle so plugin
69
+ * unload removes the provider and invalidates skill catalogs.
70
+ */
71
+ private registerBundledSkills;
72
+ /**
73
+ * Load and validate a glossary JSON document from disk. Valid documents are
74
+ * cached by absolute path; invalid ones raise `VERYMATH_GLOSSARY_*`.
75
+ * @param path - absolute or workspace-relative path of `glossary.json`.
76
+ * @param signal - cancels the read.
77
+ */
78
+ loadGlossary(path: string, signal?: AbortSignal): Promise<GlossaryLibrary>;
79
+ /** Forget any cached glossary for `path` so a later load re-reads from disk. */
80
+ invalidateGlossary(path: string): void;
81
+ /** Forget every cached glossary (used when a build script's output path is unknown). */
82
+ invalidateAllGlossaries(): void;
83
+ /**
84
+ * Query a glossary document for terms matching a bilingual query.
85
+ * @param path - glossary document path.
86
+ * @param query - English term, Chinese term, term_id, or subfield name.
87
+ * @param signal - cancels the load.
88
+ */
89
+ queryGlossaryFile(path: string, query: string, options?: GlossaryQueryOptions & {
90
+ signal?: AbortSignal;
91
+ }): Promise<{
92
+ hits: GlossaryHit[];
93
+ total: number;
94
+ }>;
95
+ /**
96
+ * Locate a Python interpreter able to run the upstream `math-glossary`
97
+ * scripts: the configured executable, then `python3`, then `python`.
98
+ * Resolution runs once and is cached; missing interpreters map to
99
+ * `VERYMATH_PYTHON_UNAVAILABLE` at call sites.
100
+ * @returns the resolved executable, or undefined when none was found.
101
+ */
102
+ resolvePython(): Promise<string | undefined>;
103
+ private probePython;
104
+ /**
105
+ * Run one upstream `math-glossary` script with the resolved interpreter.
106
+ * @param script - script filename inside the upstream `scripts/` directory.
107
+ * @param args - argument list passed to the script.
108
+ * @param timeoutMs - hard kill timeout (default 120s).
109
+ */
110
+ runGlossaryScript(script: string, args: readonly string[], timeoutMs?: number): Promise<PythonRunResult>;
111
+ /**
112
+ * Run a Python executable directly with an explicit argument list. Public on
113
+ * purpose for skill-script bridges (e.g. the after-ocr scanner) whose files
114
+ * are bundled inside the plugin package; call sites must keep the script
115
+ * path inside the package and the argument list fully constructed.
116
+ */
117
+ runPythonCommand(executable: string, args: readonly string[], timeoutMs?: number): Promise<PythonRunResult>;
118
+ private runPython;
119
+ }
120
+ export default VeryMathRuntime;