@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.
- package/CHANGELOG.md +133 -0
- package/LICENSE +21 -0
- package/NOTICE.md +35 -0
- package/README.md +108 -2
- package/README_EN.md +105 -0
- package/UPSTREAM.json +106 -0
- package/cordis.patch.yml +12 -0
- package/docs/capability-examples.md +581 -0
- package/docs/examples/README.md +32 -0
- package/docs/examples/bad_scan.md +10 -0
- package/docs/examples/broken-proof.lean +9 -0
- package/docs/examples/claims.md +7 -0
- package/docs/examples/knapsack.json +10 -0
- package/docs/examples/matrix.json +1 -0
- package/docs/examples/points.csv +21 -0
- package/docs/examples/qp.json +8 -0
- package/docs/examples/research-ws/project/GOALS.yaml +4 -0
- package/docs/examples/research-ws/workstreams/ws-lsa/report.md +13 -0
- package/docs/examples/research-ws/workstreams/ws-lsa/reviews/r1.json +1 -0
- package/docs/examples/research-ws/workstreams/ws-lsa/status.yaml +1 -0
- package/docs/examples/source.csv +4 -0
- package/lib/core/error.d.ts +20 -0
- package/lib/core/error.js +25 -0
- package/lib/core/gates.d.ts +42 -0
- package/lib/core/gates.js +217 -0
- package/lib/core/glossary.d.ts +101 -0
- package/lib/core/glossary.js +243 -0
- package/lib/core/graph.d.ts +118 -0
- package/lib/core/graph.js +460 -0
- package/lib/core/index.d.ts +120 -0
- package/lib/core/index.js +197 -0
- package/lib/core/paper.d.ts +163 -0
- package/lib/core/paper.js +73 -0
- package/lib/core/paths.d.ts +2 -0
- package/lib/core/paths.js +12 -0
- package/lib/core/sage.d.ts +61 -0
- package/lib/core/sage.js +212 -0
- package/lib/core/skills.d.ts +11 -0
- package/lib/core/skills.js +110 -0
- package/lib/tool/index.d.ts +21 -0
- package/lib/tool/index.js +1144 -0
- package/package.json +92 -4
- package/skills/after-ocr/SKILL.md +123 -0
- package/skills/after-ocr/references/audit-schema.md +94 -0
- package/skills/after-ocr/references/error-taxonomy.md +179 -0
- package/skills/after-ocr/scripts/merge_audit_logs.py +329 -0
- package/skills/after-ocr/scripts/scan_markdown_ocr.py +350 -0
- package/skills/after-ocr/tests/test_scripts.py +84 -0
- package/skills/discover-math-problems/SKILL.md +115 -0
- package/skills/discover-math-problems/references/artifact-contract.md +93 -0
- package/skills/discover-math-problems/references/autonomous-research-protocol.md +86 -0
- package/skills/discover-math-problems/references/conjecture-generation-protocol.md +63 -0
- package/skills/discover-math-problems/references/extremal-graph-variants.md +53 -0
- package/skills/graph-theory-paper-reading/SKILL.md +600 -0
- package/skills/invariant-computation/SKILL.md +169 -0
- package/skills/invariant-computation/examples/invariant_summary.example.json +51 -0
- package/skills/invariant-computation/manifest.yaml +46 -0
- package/skills/invariant-computation/references/INDEX.md +20 -0
- package/skills/invariant-computation/references/failure_modes.md +40 -0
- package/skills/invariant-computation/references/method_route_map.md +177 -0
- package/skills/invariant-computation/references/source_notes.md +19 -0
- package/skills/invariant-computation/references/tool_catalog.md +65 -0
- package/skills/invariant-computation/references/validation_checks.md +52 -0
- package/skills/invariant-computation/schema/invariant_summary.schema.json +260 -0
- package/skills/lean-formalization/SKILL.md +111 -0
- package/skills/lean-formalization/lean-runtime/config/env.example +5 -0
- package/skills/lean-formalization/lean-runtime/config/lean_agent.example.toml +28 -0
- package/skills/lean-formalization/lean-runtime/config/numina_runtime.example.toml +12 -0
- package/skills/lean-formalization/lean-runtime/examples/smoke/LocalLeanSmoke.lean +7 -0
- package/skills/lean-formalization/lean-runtime/prompts/complete_sorries.md +3 -0
- package/skills/lean-formalization/lean-runtime/prompts/formalize_statement.md +3 -0
- package/skills/lean-formalization/lean-runtime/prompts/prove_theorem.md +3 -0
- package/skills/lean-formalization/lean-runtime/prompts/repair_lean_file.md +3 -0
- package/skills/lean-formalization/lean-runtime/references/backend_adapter_checklist.md +36 -0
- package/skills/lean-formalization/lean-runtime/references/direct_lean_workflow.md +48 -0
- package/skills/lean-formalization/lean-runtime/references/failure_taxonomy.md +17 -0
- package/skills/lean-formalization/lean-runtime/references/interactive_orchestration.md +83 -0
- package/skills/lean-formalization/lean-runtime/references/lean_agent_capability_map.md +116 -0
- package/skills/lean-formalization/lean-runtime/references/lean_lsp_mcp_adapter.md +219 -0
- package/skills/lean-formalization/lean-runtime/references/lean_runtime_configuration.md +92 -0
- package/skills/lean-formalization/lean-runtime/references/numina_reverse_analysis.md +80 -0
- package/skills/lean-formalization/lean-runtime/references/numina_runtime.md +41 -0
- package/skills/lean-formalization/lean-runtime/references/numina_subagent_troubleshooting.md +77 -0
- package/skills/lean-formalization/lean-runtime/references/review_checklist.md +10 -0
- package/skills/lean-formalization/lean-runtime/references/specialist_agent_patterns.md +65 -0
- package/skills/lean-formalization/lean-runtime/schemas/config.schema.json +12 -0
- package/skills/lean-formalization/lean-runtime/schemas/result.schema.json +33 -0
- package/skills/lean-formalization/lean-runtime/schemas/task.schema.json +30 -0
- package/skills/lean-formalization/lean-runtime/scripts/ai4m_lean.py +222 -0
- package/skills/lean-formalization/lean-runtime/scripts/check_lean_project.py +134 -0
- package/skills/lean-formalization/lean-runtime/scripts/common.py +296 -0
- package/skills/lean-formalization/lean-runtime/scripts/configure_lean.py +222 -0
- package/skills/lean-formalization/lean-runtime/scripts/detect_sorry.py +49 -0
- package/skills/lean-formalization/lean-runtime/scripts/direct_task.py +100 -0
- package/skills/lean-formalization/lean-runtime/scripts/extract_minimal_failure.py +74 -0
- package/skills/lean-formalization/lean-runtime/scripts/numina_runtime.py +414 -0
- package/skills/lean-formalization/lean-runtime/scripts/smoke_test.py +75 -0
- package/skills/lean-formalization/lean-runtime/scripts/tool_status.py +79 -0
- package/skills/lean-formalization/lean-runtime/scripts/validate_patch.py +81 -0
- package/skills/lean-formalization/lean-runtime/scripts/verify_delivery.py +484 -0
- package/skills/lean-formalization/lean-runtime/tests/fixtures/after_bad.lean +4 -0
- package/skills/lean-formalization/lean-runtime/tests/fixtures/after_statement_changed.lean +4 -0
- package/skills/lean-formalization/lean-runtime/tests/fixtures/before.lean +4 -0
- package/skills/lean-formalization/lean-runtime/tests/fixtures/failure.lean +7 -0
- package/skills/lean-formalization/lean-runtime/tests/test_check_lean_project.py +59 -0
- package/skills/lean-formalization/lean-runtime/tests/test_cli.py +377 -0
- package/skills/lean-formalization/lean-runtime/tests/test_common_config.py +84 -0
- package/skills/lean-formalization/lean-runtime/tests/test_configure_lean.py +138 -0
- package/skills/lean-formalization/lean-runtime/tests/test_detect_sorry.py +24 -0
- package/skills/lean-formalization/lean-runtime/tests/test_direct_task.py +69 -0
- package/skills/lean-formalization/lean-runtime/tests/test_numina_runtime.py +168 -0
- package/skills/lean-formalization/lean-runtime/tests/test_validate_patch.py +29 -0
- package/skills/lean-setup/SKILL.md +99 -0
- package/skills/least-squares/README.md +85 -0
- package/skills/least-squares/SKILL.md +613 -0
- package/skills/least-squares/examples.md +380 -0
- package/skills/math-beamer/SKILL.md +325 -0
- package/skills/math-beamer/references/build-and-layout-audit.md +63 -0
- package/skills/math-beamer/references/math-domain-patterns.md +56 -0
- package/skills/math-beamer/references/template-policy.md +43 -0
- package/skills/math-beamer/references/template-source-index.md +51 -0
- package/skills/math-beamer/templates/catalog.yaml +235 -0
- package/skills/math-beamer/templates/packs/algebra-number-theory-talk/main.tex +45 -0
- package/skills/math-beamer/templates/packs/algebra-number-theory-talk/template.yaml +9 -0
- package/skills/math-beamer/templates/packs/algorithm-talk/main.tex +43 -0
- package/skills/math-beamer/templates/packs/algorithm-talk/template.yaml +9 -0
- package/skills/math-beamer/templates/packs/analysis-core-talk/main.tex +49 -0
- package/skills/math-beamer/templates/packs/analysis-core-talk/template.yaml +19 -0
- package/skills/math-beamer/templates/packs/backup-heavy-talk/main.tex +40 -0
- package/skills/math-beamer/templates/packs/backup-heavy-talk/template.yaml +9 -0
- package/skills/math-beamer/templates/packs/beamerposter-a0/main.tex +45 -0
- package/skills/math-beamer/templates/packs/beamerposter-a0/template.yaml +12 -0
- package/skills/math-beamer/templates/packs/combinatorics-graph-talk/main.tex +53 -0
- package/skills/math-beamer/templates/packs/combinatorics-graph-talk/template.yaml +18 -0
- package/skills/math-beamer/templates/packs/control-systems-talk/main.tex +51 -0
- package/skills/math-beamer/templates/packs/control-systems-talk/template.yaml +18 -0
- package/skills/math-beamer/templates/packs/course-lecture-zh/main.tex +43 -0
- package/skills/math-beamer/templates/packs/course-lecture-zh/template.yaml +9 -0
- package/skills/math-beamer/templates/packs/data-experiment-results/main.tex +45 -0
- package/skills/math-beamer/templates/packs/data-experiment-results/template.yaml +9 -0
- package/skills/math-beamer/templates/packs/dynamical-systems-talk/main.tex +42 -0
- package/skills/math-beamer/templates/packs/dynamical-systems-talk/template.yaml +9 -0
- package/skills/math-beamer/templates/packs/geometry-topology-talk/main.tex +43 -0
- package/skills/math-beamer/templates/packs/geometry-topology-talk/template.yaml +9 -0
- package/skills/math-beamer/templates/packs/information-coding-crypto-talk/main.tex +49 -0
- package/skills/math-beamer/templates/packs/information-coding-crypto-talk/template.yaml +18 -0
- package/skills/math-beamer/templates/packs/logic-foundations-category-talk/main.tex +51 -0
- package/skills/math-beamer/templates/packs/logic-foundations-category-talk/template.yaml +18 -0
- package/skills/math-beamer/templates/packs/numerical-analysis-talk/main.tex +51 -0
- package/skills/math-beamer/templates/packs/numerical-analysis-talk/template.yaml +9 -0
- package/skills/math-beamer/templates/packs/optimization-talk/main.tex +58 -0
- package/skills/math-beamer/templates/packs/optimization-talk/template.yaml +9 -0
- package/skills/math-beamer/templates/packs/pde-analysis-talk/main.tex +49 -0
- package/skills/math-beamer/templates/packs/pde-analysis-talk/template.yaml +9 -0
- package/skills/math-beamer/templates/packs/probability-statistics-talk/main.tex +52 -0
- package/skills/math-beamer/templates/packs/probability-statistics-talk/template.yaml +9 -0
- package/skills/math-beamer/templates/packs/reading-group-paper/main.tex +46 -0
- package/skills/math-beamer/templates/packs/reading-group-paper/template.yaml +9 -0
- package/skills/math-beamer/templates/packs/seminar-minimal-en/main.tex +60 -0
- package/skills/math-beamer/templates/packs/seminar-minimal-en/template.yaml +13 -0
- package/skills/math-beamer/templates/packs/seminar-minimal-zh/main.tex +60 -0
- package/skills/math-beamer/templates/packs/seminar-minimal-zh/template.yaml +13 -0
- package/skills/math-beamer/templates/packs/theorem-proof-talk/main.tex +60 -0
- package/skills/math-beamer/templates/packs/theorem-proof-talk/template.yaml +9 -0
- package/skills/math-beamer/templates/packs/thesis-defense/main.tex +42 -0
- package/skills/math-beamer/templates/packs/thesis-defense/template.yaml +9 -0
- package/skills/math-beamer/templates/packs/workshop-tutorial/main.tex +32 -0
- package/skills/math-beamer/templates/packs/workshop-tutorial/template.yaml +9 -0
- package/skills/math-beamer/templates/preview-gallery.md +32 -0
- package/skills/math-beamer/templates/previews/algebra-number-theory-talk-content.png +0 -0
- package/skills/math-beamer/templates/previews/algebra-number-theory-talk-cover.png +0 -0
- package/skills/math-beamer/templates/previews/algorithm-talk-content.png +0 -0
- package/skills/math-beamer/templates/previews/algorithm-talk-cover.png +0 -0
- package/skills/math-beamer/templates/previews/analysis-core-talk-content.png +0 -0
- package/skills/math-beamer/templates/previews/analysis-core-talk-cover.png +0 -0
- package/skills/math-beamer/templates/previews/backup-heavy-talk-content.png +0 -0
- package/skills/math-beamer/templates/previews/backup-heavy-talk-cover.png +0 -0
- package/skills/math-beamer/templates/previews/beamerposter-a0-content.png +0 -0
- package/skills/math-beamer/templates/previews/beamerposter-a0-cover.png +0 -0
- package/skills/math-beamer/templates/previews/combinatorics-graph-talk-content.png +0 -0
- package/skills/math-beamer/templates/previews/combinatorics-graph-talk-cover.png +0 -0
- package/skills/math-beamer/templates/previews/control-systems-talk-content.png +0 -0
- package/skills/math-beamer/templates/previews/control-systems-talk-cover.png +0 -0
- package/skills/math-beamer/templates/previews/course-lecture-zh-content.png +0 -0
- package/skills/math-beamer/templates/previews/course-lecture-zh-cover.png +0 -0
- package/skills/math-beamer/templates/previews/data-experiment-results-content.png +0 -0
- package/skills/math-beamer/templates/previews/data-experiment-results-cover.png +0 -0
- package/skills/math-beamer/templates/previews/dynamical-systems-talk-content.png +0 -0
- package/skills/math-beamer/templates/previews/dynamical-systems-talk-cover.png +0 -0
- package/skills/math-beamer/templates/previews/geometry-topology-talk-content.png +0 -0
- package/skills/math-beamer/templates/previews/geometry-topology-talk-cover.png +0 -0
- package/skills/math-beamer/templates/previews/information-coding-crypto-talk-content.png +0 -0
- package/skills/math-beamer/templates/previews/information-coding-crypto-talk-cover.png +0 -0
- package/skills/math-beamer/templates/previews/logic-foundations-category-talk-content.png +0 -0
- package/skills/math-beamer/templates/previews/logic-foundations-category-talk-cover.png +0 -0
- package/skills/math-beamer/templates/previews/numerical-analysis-talk-content.png +0 -0
- package/skills/math-beamer/templates/previews/numerical-analysis-talk-cover.png +0 -0
- package/skills/math-beamer/templates/previews/optimization-talk-content.png +0 -0
- package/skills/math-beamer/templates/previews/optimization-talk-cover.png +0 -0
- package/skills/math-beamer/templates/previews/pde-analysis-talk-content.png +0 -0
- package/skills/math-beamer/templates/previews/pde-analysis-talk-cover.png +0 -0
- package/skills/math-beamer/templates/previews/probability-statistics-talk-content.png +0 -0
- package/skills/math-beamer/templates/previews/probability-statistics-talk-cover.png +0 -0
- package/skills/math-beamer/templates/previews/reading-group-paper-content.png +0 -0
- package/skills/math-beamer/templates/previews/reading-group-paper-cover.png +0 -0
- package/skills/math-beamer/templates/previews/seminar-minimal-en-content.png +0 -0
- package/skills/math-beamer/templates/previews/seminar-minimal-en-cover.png +0 -0
- package/skills/math-beamer/templates/previews/seminar-minimal-zh-content.png +0 -0
- package/skills/math-beamer/templates/previews/seminar-minimal-zh-cover.png +0 -0
- package/skills/math-beamer/templates/previews/theorem-proof-talk-content.png +0 -0
- package/skills/math-beamer/templates/previews/theorem-proof-talk-cover.png +0 -0
- package/skills/math-beamer/templates/previews/thesis-defense-content.png +0 -0
- package/skills/math-beamer/templates/previews/thesis-defense-cover.png +0 -0
- package/skills/math-beamer/templates/previews/workshop-tutorial-content.png +0 -0
- package/skills/math-beamer/templates/previews/workshop-tutorial-cover.png +0 -0
- package/skills/math-beamer/templates/review-report.md +54 -0
- package/skills/math-beamer/templates/slide-source-ledger.md +22 -0
- package/skills/math-beamer/templates/source-packet.md +50 -0
- package/skills/math-glossary/SKILL.md +347 -0
- package/skills/math-glossary/references/glossary-schema.md +71 -0
- package/skills/math-glossary/references/glossary-usage-guide.md +176 -0
- package/skills/math-glossary/references/glossary-web-template.md +127 -0
- package/skills/math-glossary/references/glossary.schema.json +76 -0
- package/skills/math-glossary/references/user-manual.md +435 -0
- package/skills/math-glossary/requirements-ai.txt +3 -0
- package/skills/math-glossary/requirements.txt +3 -0
- package/skills/math-glossary/scripts/glossary_backup.py +42 -0
- package/skills/math-glossary/scripts/glossary_build.py +467 -0
- package/skills/math-glossary/scripts/glossary_enrich_examples.py +283 -0
- package/skills/math-glossary/scripts/glossary_export.py +333 -0
- package/skills/math-glossary/scripts/glossary_web.py +1265 -0
- package/skills/math-paper-reading/README.md +163 -0
- package/skills/math-paper-reading/SKILL.md +48 -0
- package/skills/math-paper-reading/agent_router.md +36 -0
- package/skills/math-paper-reading/references/proof_pattern_taxonomy.md +123 -0
- package/skills/math-paper-reading/references/quality_rubric.md +36 -0
- package/skills/math-paper-reading/skill_base.md +627 -0
- package/skills/math-paper-reading/skill_literature_search.md +866 -0
- package/skills/math-paper-reading/skill_paper_deep_read.md +1024 -0
- package/skills/math-paper-reading/skill_pathway_proof.md +718 -0
- package/skills/math-paper-reading/skill_reference_manager.md +746 -0
- package/skills/matlab-runner/SKILL.md +217 -0
- package/skills/matlab-runner/examples/README.md +33 -0
- package/skills/matlab-runner/examples/matrix_report.m +28 -0
- package/skills/matlab-runner/examples/plot_damped_sine.m +64 -0
- package/skills/matlab-runner/examples/test_vector_norm.m +12 -0
- package/skills/matlab-runner/references/client-setup.md +24 -0
- package/skills/matlab-runner/references/file-session-safety.md +86 -0
- package/skills/matlab-runner/references/numerical-safety.md +126 -0
- package/skills/matlab-runner/references/resource-safety.md +125 -0
- package/skills/mixed-integer-programming/SKILL.md +119 -0
- package/skills/mixed-integer-programming/lp-examples.md +251 -0
- package/skills/mixed-integer-programming/mip-examples-verified.md +118 -0
- package/skills/open-problem-research-pipeline/SKILL.md +76 -0
- package/skills/open-problem-research-pipeline/skill_literature_analysis.md +201 -0
- package/skills/open-problem-research-pipeline/skill_literature_proof_framework.md +206 -0
- package/skills/open-problem-research-pipeline/skill_literature_search.md +172 -0
- package/skills/open-problem-research-pipeline/skill_qskill.md +177 -0
- package/skills/osqp-solver/SKILL.md +245 -0
- package/skills/osqp-solver/references/citation.md +25 -0
- package/skills/osqp-solver/references/dual-infeasible-example.json +14 -0
- package/skills/osqp-solver/references/feasible-example.json +21 -0
- package/skills/osqp-solver/references/primal-infeasible-example.json +17 -0
- package/skills/osqp-solver/references/python-api.md +95 -0
- package/skills/osqp-solver/references/verification.md +94 -0
- package/skills/osqp-solver/scripts/check_osqp_environment.py +120 -0
- package/skills/osqp-solver/scripts/solve_qp.py +943 -0
- package/skills/paper-writing/SKILL.md +115 -0
- package/skills/paper-writing/skill_claim_evidence_ledger.md +55 -0
- package/skills/paper-writing/skill_formula_environment_and_readability.md +41 -0
- package/skills/paper-writing/skill_latex_build_and_layout_audit.md +73 -0
- package/skills/paper-writing/skill_notation_and_variable_consistency.md +42 -0
- package/skills/paper-writing/skill_paper_skeleton_and_logical_architecture.md +54 -0
- package/skills/paper-writing/skill_proof_obligation_and_assumption_audit.md +57 -0
- package/skills/paper-writing/templates/claim-evidence-ledger.md +23 -0
- package/skills/paper-writing/templates/proof-obligation-ledger.md +22 -0
- package/skills/paper-writing/templates/rapid-prototype-paper-skeleton.md +46 -0
- package/skills/paper-writing/templates/source-packet.md +37 -0
- package/skills/paper-writing/templates/submission-readiness.md +41 -0
- package/skills/proof-blueprint-review/SKILL.md +129 -0
- package/skills/proof-blueprint-review/references/agent-mediated-proof-protocol.md +57 -0
- package/skills/proof-blueprint-review/references/generation-agent.md +45 -0
- package/skills/proof-blueprint-review/references/proof-acceptance-contract.md +41 -0
- package/skills/proof-blueprint-review/references/verification-agent.md +37 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: matlab-runner
|
|
3
|
+
description: "Use when a user explicitly requests MATLAB execution or verification, asks to inspect, test, generate, or modify MATLAB .m files, or needs MATLAB-specific functions, toolboxes, licenses, sessions, or environment evidence."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# MATLAB Runner
|
|
7
|
+
|
|
8
|
+
## DSH Integration Notes
|
|
9
|
+
|
|
10
|
+
- 本技能由 `@louisultra/dsh-verymath` 插件提供。MATLAB MCP Server 已由插件配置:
|
|
11
|
+
MathWorks 官方 `matlab/matlab-mcp-server` v0.14.0(stdio),5 个工具以
|
|
12
|
+
`mcp__matlab__check_matlab_code / evaluate_matlab_code / run_matlab_file /
|
|
13
|
+
run_matlab_test_file / detect_matlab_toolboxes` 暴露——与本技能 §4 的能力清单一一对应。
|
|
14
|
+
- 服务器支持两种执行路径:默认 auto 模式优先附着桌面共享会话(桌面 MATLAB 运行
|
|
15
|
+
`shareMATLABSession()` 后),附着不上则自建 headless 会话(`--matlab-root
|
|
16
|
+
/Applications/MATLAB_R2025b.app`,nodesktop);首次调用可能耗时数十秒(MATLAB 启动),属正常。
|
|
17
|
+
附着桌面会话时执行结果与连接问候直接出现在用户的桌面 MATLAB 中(已验证 getpid 一致)。
|
|
18
|
+
- 用户环境:R2025b Update 7 + Optimization Toolbox + Symbolic Math Toolbox(已验证 license)。
|
|
19
|
+
- 工具不可用时按本技能 §5 报 `MCP_UNAVAILABLE`,并提示检查
|
|
20
|
+
`~/matlab-mcp/matlab-mcp-server` 与 MATLAB 安装。
|
|
21
|
+
|
|
22
|
+
Use an available MATLAB MCP Server as the execution layer. This skill is a lightweight, coding-agent-neutral routing, safety, diagnosis, and reporting layer; it does not replace specialized MATLAB skills or MATLAB's own testing, profiling, and resource-management facilities.
|
|
23
|
+
|
|
24
|
+
## 1. Strict trigger boundary
|
|
25
|
+
|
|
26
|
+
Load `matlab-runner` before the first workflow tool call only when at least one of these conditions is met:
|
|
27
|
+
|
|
28
|
+
- the user explicitly asks to use MATLAB, run MATLAB, or obtain a MATLAB-verified result;
|
|
29
|
+
- the task asks to execute, inspect, test, generate, or modify a MATLAB `.m` file;
|
|
30
|
+
- the task genuinely requires MATLAB-specific functions, toolboxes, files, licenses, shared-session state, or environment evidence.
|
|
31
|
+
|
|
32
|
+
Do not load or run MATLAB merely because MATLAB could solve the problem. In particular, do not trigger for:
|
|
33
|
+
|
|
34
|
+
- ordinary mathematical derivations or calculations that do not request MATLAB evidence;
|
|
35
|
+
- generic programming questions;
|
|
36
|
+
- another language's code or toolchain;
|
|
37
|
+
- MATLAB code-only requests that explicitly require no execution, file creation, inspection, or tools;
|
|
38
|
+
- actions restricted to another named tool.
|
|
39
|
+
|
|
40
|
+
Respect boundaries such as “do not run,” “do not modify,” “do not create files,” “do not overwrite,” and “static analysis only.”
|
|
41
|
+
|
|
42
|
+
When the skill applies, the order is:
|
|
43
|
+
|
|
44
|
+
```text
|
|
45
|
+
Skill "matlab-runner"
|
|
46
|
+
→ optional task-specific reference
|
|
47
|
+
→ required MATLAB MCP or project tool
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Never call MATLAB first and load the skill afterward.
|
|
51
|
+
|
|
52
|
+
## 2. Resolve references relative to this skill
|
|
53
|
+
|
|
54
|
+
The detailed rules are stored beside this file. Resolve every reference path relative to the directory containing this `SKILL.md`; never assume a fixed client-specific installation path.
|
|
55
|
+
|
|
56
|
+
Read only the relevant file:
|
|
57
|
+
|
|
58
|
+
- numerical accuracy, ODEs, residuals, statistics, complex output, or reproducible randomness: `./references/numerical-safety.md`
|
|
59
|
+
- memory, large arrays, Monte Carlo, batching, runtime, or output-volume assessment: `./references/resource-safety.md`
|
|
60
|
+
- file creation, name collisions, shared-session protection, test-file naming, or recovery after errors: `./references/file-session-safety.md`
|
|
61
|
+
|
|
62
|
+
Do not load all references by default. Do not inspect unrelated project files merely to prepare an answer. If the client cannot resolve a required relative reference, keep the core safety rules below and report the limitation instead of guessing another installation path.
|
|
63
|
+
|
|
64
|
+
## 3. Use progressive, lightweight environment checks
|
|
65
|
+
|
|
66
|
+
Do not run a full MATLAB, MCP, version, license, and toolbox preflight before every task.
|
|
67
|
+
|
|
68
|
+
- If the required MATLAB MCP tool is already available, use the narrowest tool directly.
|
|
69
|
+
- A successful tool call is sufficient evidence that the required chain worked for that call; do not repeat installation or connectivity checks afterward.
|
|
70
|
+
- For ordinary base-MATLAB work, do not call toolbox detection.
|
|
71
|
+
- If a task depends on a named toolbox, function, or license, check only that requirement. Prefer one targeted lightweight MATLAB call that collects three genuinely independent evidence channels when relevant: product detection such as `ver`, function resolution such as `which` or `exist`, and the named license test. A successful MATLAB call is not product-detection evidence, and `license('test',...) == 1` does not prove that the product or function is installed and resolvable. Use broad toolbox detection only when the user explicitly asks for an installed-toolbox or version list, or when targeted evidence is insufficient.
|
|
72
|
+
- Describe availability in the current MATLAB environment. If product, function, and license evidence disagree, report the conflict and the practical usability of the required function; do not invent the underlying installation cause. Do not claim a product is definitively uninstalled, misconfigured, or unlicensed unless the returned evidence supports that exact cause.
|
|
73
|
+
- If a call fails, perform only the smallest next check needed to locate the failing layer.
|
|
74
|
+
- Keep lightweight probes syntactically simple. Prefer ordinary top-level statements and a direct `if`/`else` over local or nested helper functions when the same evidence can be collected without them.
|
|
75
|
+
- Never install, reinstall, update, or reconfigure MATLAB, the MCP Server, Agentic Toolkit, or a toolbox unless the user explicitly asks for environment setup.
|
|
76
|
+
|
|
77
|
+
Do not use shell commands as a hidden environment preflight when MATLAB MCP tools are available.
|
|
78
|
+
|
|
79
|
+
## 4. Use MATLAB MCP, not a shell substitute
|
|
80
|
+
|
|
81
|
+
Use MATLAB MCP tools whenever they are available. Do not invoke MATLAB through PowerShell, bash, a terminal, or `matlab.exe -batch` as an unrequested workaround.
|
|
82
|
+
|
|
83
|
+
Never claim that MATLAB ran unless a MATLAB MCP tool returned execution output. If the MCP server is unavailable, report that limitation rather than silently switching execution routes.
|
|
84
|
+
|
|
85
|
+
## 5. Discover and choose the narrowest correct tool
|
|
86
|
+
|
|
87
|
+
Before the first MATLAB call, inspect the current tool catalog and match capabilities and argument schemas. Coding agents may expose the same MCP capability with a bare name, a server prefix, or a namespace. Use the actual exposed tool name and its returned schema. Do not invent a client-specific prefix.
|
|
88
|
+
|
|
89
|
+
Match these logical capabilities rather than literal names:
|
|
90
|
+
|
|
91
|
+
| Task | MATLAB MCP capability |
|
|
92
|
+
|---|---|
|
|
93
|
+
| Short code, direct calculations, targeted lightweight checks | `evaluate_matlab_code` |
|
|
94
|
+
| Run an existing MATLAB program | `run_matlab_file` |
|
|
95
|
+
| Run a MATLAB unit-test file | `run_matlab_test_file` |
|
|
96
|
+
| Static Code Analyzer inspection only | `check_matlab_code` |
|
|
97
|
+
| MATLAB version and installed toolboxes | `detect_matlab_toolboxes` |
|
|
98
|
+
|
|
99
|
+
Do not use a general execution capability when a dedicated test, static-analysis, or toolbox capability fits. If multiple tools appear to match, compare their descriptions and parameter schemas before choosing. If no MATLAB MCP capability is exposed, report `MCP_UNAVAILABLE`; do not fall back to a shell command merely because a MATLAB executable exists.
|
|
100
|
+
|
|
101
|
+
Follow the selected tool's actual argument schema. When an evaluation capability accepts `project_path`, pass the absolute path of the intended project directory. For file and test capabilities, pass an absolute `script_path` when that parameter is present. Never redirect MATLAB to an unrelated folder.
|
|
102
|
+
|
|
103
|
+
## 6. Execution discipline and core safety
|
|
104
|
+
|
|
105
|
+
Before a MATLAB call:
|
|
106
|
+
|
|
107
|
+
1. identify the requested result, precision, file effects, named toolbox needs, output size, and safety constraints;
|
|
108
|
+
2. send the smallest complete code block that can answer the request;
|
|
109
|
+
3. decide what MATLAB must print to support every planned conclusion;
|
|
110
|
+
4. for file writes, check the destination first;
|
|
111
|
+
5. for expensive tasks, assess feasibility before allocating data;
|
|
112
|
+
6. before treating an analytical solution, expected value, reference dataset, or acceptance target as ground truth, validate the reference itself with the cheapest relevant condition or invariant.
|
|
113
|
+
|
|
114
|
+
Never send placeholders, unfinished ellipses, pseudocode, dummy loops, no-op assignments, or incomplete expressions to MATLAB.
|
|
115
|
+
|
|
116
|
+
Keep the requested computation separate from optional diagnostics. Do not append exploratory API calls, default-value probes, version checks, or other diagnostics to a core computation unless the user requested them or they are required to interpret the result. Avoid dumping large arrays or logs; return summaries unless the full output is necessary.
|
|
117
|
+
|
|
118
|
+
Core rules:
|
|
119
|
+
|
|
120
|
+
- Preserve the shared MATLAB session. Do not use `clear`, `clearvars`, `clear all`, `clc`, `close all`, or restart MATLAB unless explicitly requested and necessary.
|
|
121
|
+
- Do not overwrite, delete, rename, or modify an existing file without explicit authorization.
|
|
122
|
+
- Do not create a large array or begin an expensive simulation when a lightweight assessment already shows serious risk.
|
|
123
|
+
- Do not automatically run a safer alternative when the user asked only for an assessment or unexecuted example code.
|
|
124
|
+
- Treat official environment output, theoretical calculations, and unmeasured estimates as different evidence categories.
|
|
125
|
+
- Before pointwise numerical comparison, verify that sample points, lengths, orientation, and dimensions correspond. Do not allow accidental row-versus-column implicit expansion to create a matrix of cross-comparisons.
|
|
126
|
+
- Keep a human in the loop for consequential execution or file changes when permissions request approval.
|
|
127
|
+
|
|
128
|
+
## 7. Classify failures by layer
|
|
129
|
+
|
|
130
|
+
Use the most specific supported category; do not guess. If evidence does not distinguish the layer, use `ENVIRONMENT_UNRESOLVED` and state what remains unknown.
|
|
131
|
+
|
|
132
|
+
| Error type | Use when |
|
|
133
|
+
|---|---|
|
|
134
|
+
| `SKILL_NOT_LOADED` | A MATLAB workflow required this skill, but it was not loaded or the load failed; stop before further MATLAB work. |
|
|
135
|
+
| `MCP_UNAVAILABLE` | The MATLAB MCP server or required MCP tool is not configured, exposed, or connected. |
|
|
136
|
+
| `MCP_TOOL_TIMEOUT` | A dispatched MATLAB MCP call exceeded the client or tool timeout. Do not infer from the timeout alone whether MATLAB executed the code. |
|
|
137
|
+
| `MATLAB_SESSION_UNAVAILABLE` | The MCP layer responds, but no usable MATLAB process or shared session is available. |
|
|
138
|
+
| `TOOLBOX_UNAVAILABLE` | A required toolbox, function, or license is unavailable. State which condition was actually checked. |
|
|
139
|
+
| `MATLAB_EXECUTION_ERROR` | MATLAB accepted the execution request but the code produced a syntax or runtime error. |
|
|
140
|
+
| `MATLAB_TEST_FAILURE` | The MATLAB test tool ran successfully, but one or more tests failed or were incomplete. |
|
|
141
|
+
| `VALIDATION_FAILURE` | MATLAB execution succeeded, but the result failed the requested numerical, file, or acceptance criterion. |
|
|
142
|
+
| `ENVIRONMENT_UNRESOLVED` | Available evidence is insufficient to distinguish MCP, session, installation, or another environment layer. |
|
|
143
|
+
|
|
144
|
+
For an error, report:
|
|
145
|
+
|
|
146
|
+
- error type;
|
|
147
|
+
- stage where it occurred;
|
|
148
|
+
- direct evidence from the tool result;
|
|
149
|
+
- the smallest reasonable next action.
|
|
150
|
+
|
|
151
|
+
Do not call a failed test an execution error, and do not call a numerically unacceptable result a MATLAB runtime error. A reference solution that fails its initial condition, boundary condition, defining equation, or another required invariant makes the intended numerical comparison invalid; classify the unresolved task as `VALIDATION_FAILURE`, even when MATLAB executed without a runtime error.
|
|
152
|
+
|
|
153
|
+
A failed MATLAB MCP call remains part of the execution history even if a later retry succeeds. When recovery completes the requested task, report `Completion status: success (after recovery)` and include the recovered error type, stage, direct evidence, and corrective action. Never replace the failed call with only the successful retry in the final account.
|
|
154
|
+
|
|
155
|
+
Classify a recovered MCP timeout as `MCP_TOOL_TIMEOUT`; do not silently relabel it as an ordinary success. If a validation formula, reference check, residual, dimension check, or acceptance test is corrected after a prior successful MATLAB run, disclose the earlier issue as a recovered `VALIDATION_FAILURE`.
|
|
156
|
+
|
|
157
|
+
Respect call budgets:
|
|
158
|
+
|
|
159
|
+
- An explicit maximum such as “at most one MATLAB call” or “do not call again” is a hard constraint. If the available call fails or produces an invalid validation result, do not exceed the limit; report the task as failed or partial and ask for permission before retrying.
|
|
160
|
+
- A preference or target such as “try to do this in one call” may be exceeded only by the smallest recovery call needed for correctness. Report the real total and state that the preferred call count was not met.
|
|
161
|
+
- Do not retry merely to improve wording, formatting, or optional diagnostics.
|
|
162
|
+
|
|
163
|
+
## 8. Evidence and faithful reporting
|
|
164
|
+
|
|
165
|
+
After execution:
|
|
166
|
+
|
|
167
|
+
1. compare the answer with the actual returned output;
|
|
168
|
+
2. check labels, units, formulas, filenames, function names, and summary values for internal consistency;
|
|
169
|
+
3. separate MATLAB output from interpretation and optional suggestions;
|
|
170
|
+
4. never invent values, license states, runtime, peak memory, accuracy, or success claims;
|
|
171
|
+
5. count every MATLAB MCP call that was dispatched, including failed, corrective, and discarded calls. Do not describe only the final successful call as a single execution when earlier calls occurred.
|
|
172
|
+
|
|
173
|
+
When the user asks for the code actually sent to MATLAB, reproduce the exact relevant MCP payload. Include failed, timed-out, or partially executed calls when they affected the result. Do not delete a failing line and present the remainder as the complete executed code. If comments or sections are omitted, label the result as an excerpt or as executable statements rather than verbatim code.
|
|
174
|
+
|
|
175
|
+
A corrective MATLAB call must recompute every quantity whose validity depends on the corrected formula, reference, shape, or condition. Never hard-code values observed in an earlier call into a follow-up call as a substitute for recomputation or verification.
|
|
176
|
+
|
|
177
|
+
When the user asks to run faulty code unchanged, run it unchanged, return the genuine MATLAB error, and keep any repair separate.
|
|
178
|
+
|
|
179
|
+
## 9. Unified completion summary
|
|
180
|
+
|
|
181
|
+
After any task that invokes MATLAB, checks the MATLAB environment, runs tests, or creates or modifies files, end with a concise completion summary. Use natural wording and omit genuinely inapplicable lines, but always include `Completion status` and `MATLAB execution`.
|
|
182
|
+
|
|
183
|
+
Interpret completion status by whether the user's requested task was completed, not by whether the checked dependency was available:
|
|
184
|
+
|
|
185
|
+
- `success`: the requested calculation, inspection, availability check, or file task was completed;
|
|
186
|
+
- `success (after recovery)`: the task was completed after one or more disclosed failed calls;
|
|
187
|
+
- `partial`: only part of the requested deliverables was completed;
|
|
188
|
+
- `failed`: the requested core task was not completed.
|
|
189
|
+
|
|
190
|
+
For example, a successful check that proves `fmincon` is unavailable has `Completion status: success` and `Error type or limitation: TOOLBOX_UNAVAILABLE`; the unavailable dependency does not make the inspection itself partial.
|
|
191
|
+
|
|
192
|
+
Recommended fields:
|
|
193
|
+
|
|
194
|
+
```text
|
|
195
|
+
Completion status: success / success (after recovery) / partial / failed
|
|
196
|
+
MATLAB execution: yes / no
|
|
197
|
+
MATLAB tool calls: total N; successful S; failed F
|
|
198
|
+
Tools used: ...
|
|
199
|
+
Code or files created/modified: ...
|
|
200
|
+
Tests: passed / failed / not run
|
|
201
|
+
Validation: criterion and outcome
|
|
202
|
+
Result location: absolute path, when applicable
|
|
203
|
+
Recovered error: type, stage, evidence, and action, when applicable
|
|
204
|
+
Constraint compliance: met / not met, when the user imposed a tool-call or execution limit
|
|
205
|
+
Error type or limitation: ..., when applicable
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
The summary must make clear:
|
|
209
|
+
|
|
210
|
+
- what code or files were produced or changed;
|
|
211
|
+
- whether MATLAB actually ran and the truthful total number of MATLAB MCP calls;
|
|
212
|
+
- whether tests ran and passed;
|
|
213
|
+
- what numerical or file validation standard was used;
|
|
214
|
+
- where any result was saved;
|
|
215
|
+
- whether an explicit call-count or execution constraint was met.
|
|
216
|
+
|
|
217
|
+
Do not claim a file was generated when only inline code was shown. Do not relabel a three-call recovery as a one-call task merely because only the last call produced the accepted result. Return exact executed code only when requested; the completion summary is not a substitute for the actual output or error.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# 示例说明
|
|
2
|
+
|
|
3
|
+
三个示例都避免静默覆盖或无必要污染共享基础工作区。
|
|
4
|
+
|
|
5
|
+
## 矩阵报告
|
|
6
|
+
|
|
7
|
+
在 MATLAB 中:
|
|
8
|
+
|
|
9
|
+
```matlab
|
|
10
|
+
A = [1 2 3; 0 1 4; 5 6 0];
|
|
11
|
+
report = matrix_report(A);
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
在 MCP 中使用实际暴露的 `evaluate_matlab_code` 能力;如果其参数包含
|
|
15
|
+
`project_path`,传入项目绝对路径。
|
|
16
|
+
|
|
17
|
+
## 无覆盖绘图
|
|
18
|
+
|
|
19
|
+
```matlab
|
|
20
|
+
outputPath = plot_damped_sine(pwd);
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
如果 `damped_sine.png` 已存在,会使用 `damped_sine_1.png` 等第一个可用名称。函数创建不可见图窗,并只关闭自己创建的图窗。
|
|
24
|
+
|
|
25
|
+
## 单元测试
|
|
26
|
+
|
|
27
|
+
使用 coding agent 当前工具目录中实际暴露的专用能力运行:
|
|
28
|
+
|
|
29
|
+
```text
|
|
30
|
+
run_matlab_test_file
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`script_path` 应是 `test_vector_norm.m` 的绝对路径。预期为 2 个测试通过。
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
function report = matrix_report(A)
|
|
2
|
+
%MATRIX_REPORT Compute and print basic matrix diagnostics.
|
|
3
|
+
% REPORT = MATRIX_REPORT(A) returns rank, determinant (for square A),
|
|
4
|
+
% and the 2-norm condition number. All variables remain local.
|
|
5
|
+
|
|
6
|
+
validateattributes(A, {'numeric'}, {'2d', 'nonempty'}, mfilename, 'A');
|
|
7
|
+
|
|
8
|
+
report = struct();
|
|
9
|
+
report.Size = size(A);
|
|
10
|
+
report.Rank = rank(A);
|
|
11
|
+
|
|
12
|
+
if ismatrix(A) && size(A, 1) == size(A, 2)
|
|
13
|
+
report.Determinant = det(A);
|
|
14
|
+
else
|
|
15
|
+
report.Determinant = NaN;
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
report.ConditionNumber2 = cond(A);
|
|
19
|
+
|
|
20
|
+
fprintf('size = %d-by-%d\n', report.Size(1), report.Size(2));
|
|
21
|
+
fprintf('rank = %d\n', report.Rank);
|
|
22
|
+
if isnan(report.Determinant)
|
|
23
|
+
fprintf('determinant = not defined for a non-square matrix\n');
|
|
24
|
+
else
|
|
25
|
+
fprintf('determinant = %.8g\n', report.Determinant);
|
|
26
|
+
end
|
|
27
|
+
fprintf('2-norm condition number = %.8g\n', report.ConditionNumber2);
|
|
28
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
function outputPath = plot_damped_sine(outputDir)
|
|
2
|
+
%PLOT_DAMPED_SINE Export a damped-sine plot without overwriting files.
|
|
3
|
+
% OUTPUTPATH = PLOT_DAMPED_SINE(OUTPUTDIR) writes damped_sine.png, or the
|
|
4
|
+
% first available suffixed name. The function uses an invisible figure,
|
|
5
|
+
% closes only that figure, and does not pollute the base workspace.
|
|
6
|
+
|
|
7
|
+
if nargin < 1
|
|
8
|
+
outputDir = pwd;
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
if ~(ischar(outputDir) || (isstring(outputDir) && isscalar(outputDir)))
|
|
12
|
+
error('plot_damped_sine:InvalidOutputDir', ...
|
|
13
|
+
'outputDir must be a character vector or string scalar.');
|
|
14
|
+
end
|
|
15
|
+
outputDir = char(outputDir);
|
|
16
|
+
|
|
17
|
+
if ~isfolder(outputDir)
|
|
18
|
+
error('plot_damped_sine:InvalidFolder', ...
|
|
19
|
+
'Output directory does not exist: %s', outputDir);
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
preferredPath = fullfile(outputDir, 'damped_sine.png');
|
|
23
|
+
outputPath = firstAvailablePath(preferredPath);
|
|
24
|
+
|
|
25
|
+
x = linspace(0, 20, 1000);
|
|
26
|
+
y = exp(-0.15 * x) .* sin(2 * x);
|
|
27
|
+
|
|
28
|
+
fig = figure('Visible', 'off');
|
|
29
|
+
cleanupFigure = onCleanup(@() close(fig)); %#ok<NASGU>
|
|
30
|
+
ax = axes('Parent', fig);
|
|
31
|
+
|
|
32
|
+
plot(ax, x, y, 'LineWidth', 1.5);
|
|
33
|
+
title(ax, 'Damped Sine: y = exp(-0.15x) sin(2x)');
|
|
34
|
+
xlabel(ax, 'x');
|
|
35
|
+
ylabel(ax, 'y');
|
|
36
|
+
grid(ax, 'on');
|
|
37
|
+
|
|
38
|
+
exportgraphics(fig, outputPath);
|
|
39
|
+
|
|
40
|
+
if ~isfile(outputPath)
|
|
41
|
+
error('plot_damped_sine:ExportFailed', ...
|
|
42
|
+
'Expected output file was not created: %s', outputPath);
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
fprintf('File path: %s\n', outputPath);
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
function outputPath = firstAvailablePath(preferredPath)
|
|
49
|
+
outputPath = preferredPath;
|
|
50
|
+
if ~isfile(outputPath)
|
|
51
|
+
return
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
[folder, name, extension] = fileparts(preferredPath);
|
|
55
|
+
index = 1;
|
|
56
|
+
while true
|
|
57
|
+
candidate = fullfile(folder, sprintf('%s_%d%s', name, index, extension));
|
|
58
|
+
if ~isfile(candidate)
|
|
59
|
+
outputPath = candidate;
|
|
60
|
+
return
|
|
61
|
+
end
|
|
62
|
+
index = index + 1;
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
function tests = test_vector_norm
|
|
2
|
+
%TEST_VECTOR_NORM Function-based tests for simple vector lengths.
|
|
3
|
+
tests = functiontests(localfunctions);
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
function testNorm3_4(testCase)
|
|
7
|
+
verifyEqual(testCase, norm([3 4]), 5, 'AbsTol', 1e-12);
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
function testHypot5_12(testCase)
|
|
11
|
+
verifyEqual(testCase, hypot(5, 12), 13, 'AbsTol', 1e-12);
|
|
12
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Coding-agent setup
|
|
2
|
+
|
|
3
|
+
Use this reference only when installing or connecting the skill.
|
|
4
|
+
|
|
5
|
+
1. Place the complete `matlab-runner` directory in a location from which the
|
|
6
|
+
coding agent can load skills, or register its canonical `SKILL.md` using the
|
|
7
|
+
client's supported skill mechanism.
|
|
8
|
+
2. Configure a compatible MATLAB MCP Server using that coding agent's MCP
|
|
9
|
+
configuration mechanism. Keep executable paths and local MATLAB settings in
|
|
10
|
+
client configuration, not in this package.
|
|
11
|
+
3. Restart or reload the client if its tool catalog is cached.
|
|
12
|
+
4. Confirm that the client exposes the MATLAB capability needed by the task,
|
|
13
|
+
such as evaluation, file execution, unit testing, static analysis, or
|
|
14
|
+
toolbox detection.
|
|
15
|
+
5. Let the coding agent inspect the exposed tools, compare descriptions and
|
|
16
|
+
parameter schemas, and call the actual tool name shown by that client.
|
|
17
|
+
|
|
18
|
+
Different clients may expose the same capability as a bare name, a
|
|
19
|
+
server-prefixed name, or a namespaced name. The adapter intentionally does not
|
|
20
|
+
hard-code one spelling or installation directory.
|
|
21
|
+
|
|
22
|
+
MATLAB, its license, and the MCP server are separate prerequisites. Do not
|
|
23
|
+
install, reconfigure, or replace them automatically unless the user explicitly
|
|
24
|
+
requests environment setup.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# File and Shared-Session Safety Reference
|
|
2
|
+
|
|
3
|
+
> Path note: this file is addressed from `SKILL.md` as `./references/file-session-safety.md` and must be resolved relative to the directory containing that loaded `SKILL.md`.
|
|
4
|
+
|
|
5
|
+
Load this reference only for tasks involving file creation or modification, name collisions, MATLAB test files, shared-session variables, plots and figures, or recovery after errors.
|
|
6
|
+
|
|
7
|
+
## Shared MATLAB session
|
|
8
|
+
|
|
9
|
+
Assume the active session may contain valuable user state:
|
|
10
|
+
|
|
11
|
+
- variables;
|
|
12
|
+
- current folder;
|
|
13
|
+
- paths;
|
|
14
|
+
- RNG state;
|
|
15
|
+
- open figures;
|
|
16
|
+
- toolbox or application state.
|
|
17
|
+
|
|
18
|
+
Do not use `clear`, `clearvars`, `clear all`, `clc`, `close all`, or restart MATLAB unless the user explicitly requests it and the action is necessary.
|
|
19
|
+
|
|
20
|
+
An execution error is not a reason to clear or restart the session. Report the error and preserve unrelated state.
|
|
21
|
+
|
|
22
|
+
When cross-call persistence matters, verify it with separate MCP calls.
|
|
23
|
+
|
|
24
|
+
## File creation workflow
|
|
25
|
+
|
|
26
|
+
Default to non-destructive behavior:
|
|
27
|
+
|
|
28
|
+
1. determine the intended absolute path;
|
|
29
|
+
2. use MATLAB `isfile`, `isfolder`, or the appropriate test before writing;
|
|
30
|
+
3. if the preferred name exists and overwrite is not authorized, select the first unused suffix such as `_1`, `_2`, and so on;
|
|
31
|
+
4. create the file once the final path is known;
|
|
32
|
+
5. verify that the final file exists;
|
|
33
|
+
6. return the actual absolute path.
|
|
34
|
+
|
|
35
|
+
Do not overwrite, delete, rename, or modify an existing file without explicit authorization.
|
|
36
|
+
|
|
37
|
+
## Test-file naming
|
|
38
|
+
|
|
39
|
+
For MATLAB function-based unit tests:
|
|
40
|
+
|
|
41
|
+
- the primary test-function name must match the final `.m` filename;
|
|
42
|
+
- if a collision changes the filename, change the primary function name too;
|
|
43
|
+
- run the file using the exposed `run_matlab_test_file` capability;
|
|
44
|
+
- report Passed, Failed, and Incomplete counts from the actual result.
|
|
45
|
+
|
|
46
|
+
## Plot and figure safety
|
|
47
|
+
|
|
48
|
+
Prefer function-based examples that keep variables local.
|
|
49
|
+
|
|
50
|
+
- Use an invisible figure for noninteractive output unless the user requests a visible plot.
|
|
51
|
+
- Use `onCleanup` or another reliable mechanism to close only the figure created by the task.
|
|
52
|
+
- Do not call `close all` in a shared session.
|
|
53
|
+
- Check the destination before exporting.
|
|
54
|
+
- Return the actual output path.
|
|
55
|
+
|
|
56
|
+
## Static analysis
|
|
57
|
+
|
|
58
|
+
Static-analysis requests are read-only:
|
|
59
|
+
|
|
60
|
+
- use the exposed `check_matlab_code` capability;
|
|
61
|
+
- do not execute the file;
|
|
62
|
+
- do not modify the file;
|
|
63
|
+
- do not add unrelated project reads unless the user asked for broader inspection.
|
|
64
|
+
|
|
65
|
+
## Existing scripts and faulty code
|
|
66
|
+
|
|
67
|
+
When the user asks to run an existing file unchanged, use its absolute path and do not rewrite it silently.
|
|
68
|
+
|
|
69
|
+
When the user asks to run faulty code unchanged:
|
|
70
|
+
|
|
71
|
+
1. run it unchanged;
|
|
72
|
+
2. return the genuine MATLAB error;
|
|
73
|
+
3. keep any repair separate and clearly labeled;
|
|
74
|
+
4. do not present the repaired run as the original result.
|
|
75
|
+
|
|
76
|
+
## Verification after writes
|
|
77
|
+
|
|
78
|
+
For important artifacts, verify more than existence when appropriate:
|
|
79
|
+
|
|
80
|
+
- reload MAT-file contents;
|
|
81
|
+
- check expected variables or dimensions;
|
|
82
|
+
- verify image or report path;
|
|
83
|
+
- run the generated test file;
|
|
84
|
+
- compare a sentinel value when testing overwrite protection.
|
|
85
|
+
|
|
86
|
+
Use the narrowest verification required by the task. Do not add unrelated file inspection.
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Numerical Safety Reference
|
|
2
|
+
|
|
3
|
+
> Path note: this file is addressed from `SKILL.md` as `./references/numerical-safety.md` and must be resolved relative to the directory containing that loaded `SKILL.md`.
|
|
4
|
+
|
|
5
|
+
Load this reference only for tasks involving numerical accuracy, ODEs, roots and residuals, statistics, complex output, conditioning, convergence, or reproducible randomness.
|
|
6
|
+
|
|
7
|
+
## General evidence rules
|
|
8
|
+
|
|
9
|
+
- Preserve complex values and display real and imaginary parts when interpretation depends on them.
|
|
10
|
+
- Equal real parts do not imply repeated roots.
|
|
11
|
+
- Use unrounded values for validation and round only for presentation.
|
|
12
|
+
- Do not infer multiplicity, conditioning, convergence, stability, or reliability without a calculation or a clearly stated theorem.
|
|
13
|
+
- Never invent a value that MATLAB did not return.
|
|
14
|
+
|
|
15
|
+
## Validate the reference before measuring error
|
|
16
|
+
|
|
17
|
+
An analytical solution, expected answer, reference vector, or benchmark is not automatically ground truth merely because it was supplied in the prompt or produced by the agent. Before using it to judge MATLAB output, apply the cheapest decisive checks.
|
|
18
|
+
|
|
19
|
+
For an ODE reference solution, check at least:
|
|
20
|
+
|
|
21
|
+
1. the initial or boundary condition at full precision;
|
|
22
|
+
2. the defining differential equation through an analytical residual or another justified check;
|
|
23
|
+
3. any domain, parameter, or branch condition that affects correspondence.
|
|
24
|
+
|
|
25
|
+
If a candidate reference fails one of these checks, do not use it to compute or interpret solver error. Either derive and validate a corrected reference, or report `VALIDATION_FAILURE` and stop the accuracy claim. A MATLAB call that runs successfully does not make an invalid reference valid.
|
|
26
|
+
|
|
27
|
+
For pointwise comparisons:
|
|
28
|
+
|
|
29
|
+
- use the same requested sample points for numerical and reference values;
|
|
30
|
+
- make orientation explicit, preferably with a column time vector such as `tq = (0:0.1:5).'`;
|
|
31
|
+
- verify equal element counts and matching dimensions before subtraction;
|
|
32
|
+
- use an assertion such as `assert(isequal(size(yNumerical),size(yReference)))` when shape mistakes would invalidate the result;
|
|
33
|
+
- do not rely on implicit expansion between a column and a row;
|
|
34
|
+
- using `(:)` is acceptable only after confirming that both vectors refer to the same ordered sample points.
|
|
35
|
+
|
|
36
|
+
A vector returned by `max` where a scalar was expected is evidence of a shape or dimension problem. Diagnose it; do not reinterpret the vector as a running maximum or another quantity without proof.
|
|
37
|
+
|
|
38
|
+
## Differential-equation residuals
|
|
39
|
+
|
|
40
|
+
For an equation such as `y' = f(t,y)`, the residual must contain the derivative of the proposed reference solution. Define or derive a separate derivative expression such as `yPrime(t)` and evaluate the residual in the equation's actual form.
|
|
41
|
+
|
|
42
|
+
For example, for `y' = -2y + sin(t)`, use:
|
|
43
|
+
|
|
44
|
+
```matlab
|
|
45
|
+
residual = yPrime(t) + 2*yExact(t) - sin(t);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Do not substitute `yExact(t)` where `yPrime(t)` is required. A residual formula that uses the wrong mathematical quantity invalidates the validation even when MATLAB executes it successfully.
|
|
49
|
+
|
|
50
|
+
When correcting a residual or reference formula:
|
|
51
|
+
|
|
52
|
+
- classify the earlier check as a recovered `VALIDATION_FAILURE`;
|
|
53
|
+
- recompute the residual from the corrected derivative or formula;
|
|
54
|
+
- recompute any reported quantities that depended on the invalid check;
|
|
55
|
+
- do not insert previously observed numerical outputs as constants in the corrective call.
|
|
56
|
+
|
|
57
|
+
## Residuals and backward error
|
|
58
|
+
|
|
59
|
+
An absolute residual alone may be misleading when the problem is scaled.
|
|
60
|
+
|
|
61
|
+
- Use a normalization appropriate to the equation or polynomial.
|
|
62
|
+
- Do not compare an unnormalized residual directly with machine epsilon and announce stability.
|
|
63
|
+
- State the quantity actually computed: absolute residual, relative residual, normalized backward error, or another measure.
|
|
64
|
+
- Do not use a small residual as proof of good conditioning.
|
|
65
|
+
|
|
66
|
+
## Statistics
|
|
67
|
+
|
|
68
|
+
State the convention when it matters.
|
|
69
|
+
|
|
70
|
+
- `std(A,0,'all')` uses `N-1` normalization when applicable.
|
|
71
|
+
- `std(A,1,'all')` uses `N` normalization.
|
|
72
|
+
- If NaN values are excluded by indexing, say that they were filtered before `mean` or `std`; do not say the functions ignored NaN automatically unless an omission option was actually used.
|
|
73
|
+
|
|
74
|
+
## Random experiments
|
|
75
|
+
|
|
76
|
+
For requested reproducibility:
|
|
77
|
+
|
|
78
|
+
1. set an explicit RNG seed;
|
|
79
|
+
2. report the seed and generator when relevant;
|
|
80
|
+
3. verify reproducibility when requested, for example by regenerating and comparing with `isequal`.
|
|
81
|
+
|
|
82
|
+
Do not change the shared session's RNG state unnecessarily. If preserving the prior RNG state matters, save and restore it explicitly.
|
|
83
|
+
|
|
84
|
+
## ODE solver tolerances
|
|
85
|
+
|
|
86
|
+
For `ode45` and other adaptive solvers:
|
|
87
|
+
|
|
88
|
+
- Treat `RelTol` and `AbsTol` as controls on estimated local error, not as guaranteed bounds on the global maximum error.
|
|
89
|
+
- Do not say an observed global error is “below the tolerance threshold” solely because it is numerically smaller than `RelTol`.
|
|
90
|
+
- If an exact solution exists, validate that solution against the initial or boundary data and the differential equation before computing the observed error.
|
|
91
|
+
- To assess improvement from tighter tolerances, rerun with explicit tighter values and compare measured errors.
|
|
92
|
+
- State whether values came from requested output points or interpolation.
|
|
93
|
+
- When the input time vector contains requested points, call them requested output points, not the solver's internal adaptive steps.
|
|
94
|
+
- Do not invent a rule such as “the global error is approximately a fixed multiple of `RelTol`” without a derivation or measurement supporting that specific claim.
|
|
95
|
+
|
|
96
|
+
## Default settings and optional diagnostics
|
|
97
|
+
|
|
98
|
+
When the user asks to compare a solver's default settings with explicit settings:
|
|
99
|
+
|
|
100
|
+
- use the solver without explicit option overrides for the default run;
|
|
101
|
+
- do not query or print exact default option values unless the user requested them or they are necessary to answer the task;
|
|
102
|
+
- keep optional option inspection out of the core computation call;
|
|
103
|
+
- if an optional diagnostic is attempted and fails, disclose it as a recovered `MATLAB_EXECUTION_ERROR` when a later call completes the task.
|
|
104
|
+
|
|
105
|
+
An empty field returned by `odeset()` means that the option was not explicitly set in that options structure. It is not evidence of a display problem. Do not infer or state a specific default value from an empty field. If the exact default is not required, say that the solver used its default settings and report the measured result.
|
|
106
|
+
|
|
107
|
+
## Complex eigenvalues and roots
|
|
108
|
+
|
|
109
|
+
- Print complex values with enough precision to preserve conjugate structure.
|
|
110
|
+
- Do not collapse a complex-conjugate pair into duplicate real numbers.
|
|
111
|
+
- Check algebraic multiplicity separately from numerical closeness.
|
|
112
|
+
- If the task concerns eigenvectors or conditioning, compute the relevant quantities rather than inferring them from eigenvalues alone.
|
|
113
|
+
|
|
114
|
+
## Numerical claims checklist
|
|
115
|
+
|
|
116
|
+
Before answering, verify:
|
|
117
|
+
|
|
118
|
+
- the formula matches the code and the validation reference itself has passed the required initial, boundary, equation, or invariant checks;
|
|
119
|
+
- the reported maximum is the maximum of the stated values;
|
|
120
|
+
- units and normalization are named;
|
|
121
|
+
- default and tightened settings are not mixed;
|
|
122
|
+
- sample points, element counts, orientation, and dimensions match, with no accidental implicit expansion;
|
|
123
|
+
- rounded display values are not reused for validation;
|
|
124
|
+
- every factual numerical conclusion is supported by actual output or a transparent calculation;
|
|
125
|
+
- every differential-equation residual uses the actual derivative term required by the equation;
|
|
126
|
+
- a corrective call recomputed affected quantities instead of hard-coding values from an earlier call.
|