@louisultra/dsh-verymath 0.3.1 → 0.3.3

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 (38) hide show
  1. package/CHANGELOG.md +80 -12
  2. package/README.md +14 -5
  3. package/README_EN.md +10 -5
  4. package/UPSTREAM.json +2 -2
  5. package/docs/capability-examples.md +581 -0
  6. package/docs/examples/README.md +32 -0
  7. package/docs/examples/bad_scan.md +10 -0
  8. package/docs/examples/broken-proof.lean +9 -0
  9. package/docs/examples/claims.md +7 -0
  10. package/docs/examples/knapsack.json +10 -0
  11. package/docs/examples/matrix.json +1 -0
  12. package/docs/examples/points.csv +21 -0
  13. package/docs/examples/qp.json +8 -0
  14. package/docs/examples/research-ws/project/GOALS.yaml +4 -0
  15. package/docs/examples/research-ws/workstreams/ws-lsa/report.md +13 -0
  16. package/docs/examples/research-ws/workstreams/ws-lsa/reviews/r1.json +1 -0
  17. package/docs/examples/research-ws/workstreams/ws-lsa/status.yaml +1 -0
  18. package/docs/examples/source.csv +4 -0
  19. package/lib/core/gates.js +1 -1
  20. package/lib/index.d.ts +20 -0
  21. package/lib/index.js +20 -0
  22. package/lib/tool/index.d.ts +9 -0
  23. package/lib/tool/index.js +68 -19
  24. package/package.json +28 -25
  25. package/skills/lean-formalization/SKILL.md +4 -3
  26. package/skills/after-ocr/tests/test_scripts.py +0 -84
  27. package/skills/lean-formalization/lean-runtime/tests/fixtures/after_bad.lean +0 -4
  28. package/skills/lean-formalization/lean-runtime/tests/fixtures/after_statement_changed.lean +0 -4
  29. package/skills/lean-formalization/lean-runtime/tests/fixtures/before.lean +0 -4
  30. package/skills/lean-formalization/lean-runtime/tests/fixtures/failure.lean +0 -7
  31. package/skills/lean-formalization/lean-runtime/tests/test_check_lean_project.py +0 -59
  32. package/skills/lean-formalization/lean-runtime/tests/test_cli.py +0 -377
  33. package/skills/lean-formalization/lean-runtime/tests/test_common_config.py +0 -84
  34. package/skills/lean-formalization/lean-runtime/tests/test_configure_lean.py +0 -138
  35. package/skills/lean-formalization/lean-runtime/tests/test_detect_sorry.py +0 -24
  36. package/skills/lean-formalization/lean-runtime/tests/test_direct_task.py +0 -69
  37. package/skills/lean-formalization/lean-runtime/tests/test_numina_runtime.py +0 -168
  38. package/skills/lean-formalization/lean-runtime/tests/test_validate_patch.py +0 -29
@@ -1,69 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import sys
4
- import tempfile
5
- import unittest
6
- import os
7
- from pathlib import Path
8
- from unittest.mock import patch
9
-
10
- SCRIPTS = Path(__file__).resolve().parents[1] / "scripts"
11
- sys.path.insert(0, str(SCRIPTS))
12
-
13
- from direct_task import build_direct_task, run_direct_task # noqa: E402
14
-
15
-
16
- class DirectTaskTests(unittest.TestCase):
17
- def test_managed_workspace_routes_standalone_file_to_coding_agent(self) -> None:
18
- with tempfile.TemporaryDirectory() as tmp:
19
- root = Path(tmp)
20
- workspace = root / ".ai4math" / "lean-workspace"
21
- workspace.mkdir(parents=True)
22
- (workspace / "lean-toolchain").write_text("leanprover/lean4:v4.28.0\n", encoding="utf-8")
23
- (workspace / "lakefile.toml").write_text('name = "lean_workspace"\n', encoding="utf-8")
24
- target = root / "Standalone.lean"
25
- target.write_text("example : True := by trivial\n", encoding="utf-8")
26
-
27
- with patch.dict(os.environ, {"AI4MATH_LEAN_WORKSPACE": str(workspace)}, clear=False):
28
- result = build_direct_task("prove", root, target)
29
-
30
- self.assertTrue(result["ok"])
31
- self.assertEqual(result["status"], "coding_agent_task_ready")
32
- self.assertEqual(result["agent_mode"], "coding-agent")
33
- self.assertEqual(result["backend"], "none")
34
- self.assertEqual(result["workspace_mode"], "managed_workspace")
35
- self.assertEqual(result["missing_config"], [])
36
-
37
- def test_missing_workspace_reports_required_input(self) -> None:
38
- with tempfile.TemporaryDirectory() as tmp:
39
- root = Path(tmp)
40
- target = root / "Standalone.lean"
41
- target.write_text("example : True := by trivial\n", encoding="utf-8")
42
-
43
- with patch.dict(os.environ, {"AI4MATH_HOME": str(root / "shared-ai4math"), "AI4MATH_LEAN_WORKSPACE": ""}, clear=False):
44
- result = build_direct_task("prove", root, target)
45
-
46
- self.assertFalse(result["ok"])
47
- self.assertEqual(result["status"], "missing_config")
48
- self.assertIn("lean_workspace", result["missing_config"])
49
- self.assertEqual(result["backend"], "none")
50
-
51
- def test_dry_run_marks_ready_task_without_external_command(self) -> None:
52
- with tempfile.TemporaryDirectory() as tmp:
53
- root = Path(tmp)
54
- (root / "lean-toolchain").write_text("leanprover/lean4:v4.28.0\n", encoding="utf-8")
55
- (root / "lakefile.toml").write_text('name = "proj"\n', encoding="utf-8")
56
- target = root / "Main.lean"
57
- target.write_text("example : True := by trivial\n", encoding="utf-8")
58
-
59
- result = run_direct_task("repair", root, target, dry_run=True)
60
-
61
- self.assertTrue(result["ok"])
62
- self.assertEqual(result["status"], "dry_run")
63
- self.assertEqual(result["backend"], "none")
64
- self.assertIn("direct_workflow", result)
65
- self.assertNotIn("command", result)
66
-
67
-
68
- if __name__ == "__main__":
69
- unittest.main()
@@ -1,168 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import os
4
- import sys
5
- import tempfile
6
- import unittest
7
- from pathlib import Path
8
- from unittest.mock import patch
9
-
10
- SCRIPTS = Path(__file__).resolve().parents[1] / "scripts"
11
- sys.path.insert(0, str(SCRIPTS))
12
-
13
- from common import ensure_ai4math_gitignore # noqa: E402
14
- from numina_runtime import ( # noqa: E402
15
- DEFAULT_UPSTREAM_URL,
16
- build_configure_plan,
17
- build_install_plan,
18
- build_run_plan,
19
- credential_report,
20
- read_numina_env_local,
21
- runtime_paths,
22
- )
23
-
24
-
25
- class NuminaRuntimePathTests(unittest.TestCase):
26
- def test_runtime_paths_default_under_ai4math(self) -> None:
27
- with tempfile.TemporaryDirectory() as tmp:
28
- root = Path(tmp)
29
- shared = root / "shared-ai4math"
30
-
31
- with patch.dict(os.environ, {"AI4MATH_HOME": str(shared), "AI4MATH_NUMINA_HOME": ""}, clear=False):
32
- paths = runtime_paths(root)
33
-
34
- runtime = shared / "numina-runtime"
35
- self.assertEqual(paths["root"], str(runtime))
36
- self.assertEqual(paths["upstream"], str(runtime / "upstream"))
37
- self.assertEqual(paths["results"], str(runtime / "results"))
38
- self.assertEqual(paths["default_upstream_url"], DEFAULT_UPSTREAM_URL)
39
-
40
- def test_runtime_paths_honor_ai4math_numina_home(self) -> None:
41
- with tempfile.TemporaryDirectory() as tmp:
42
- custom = Path(tmp) / "custom-numina"
43
- with patch.dict(os.environ, {"AI4MATH_NUMINA_HOME": str(custom)}, clear=False):
44
- paths = runtime_paths(Path(tmp))
45
-
46
- expected = Path(os.path.abspath(custom))
47
- self.assertEqual(paths["root"], str(expected))
48
- self.assertEqual(paths["upstream"], str(expected / "upstream"))
49
-
50
- def test_numina_runtime_is_ignored(self) -> None:
51
- with tempfile.TemporaryDirectory() as tmp:
52
- gitignore = ensure_ai4math_gitignore(tmp)
53
-
54
- lines = gitignore.read_text(encoding="utf-8").splitlines()
55
-
56
- self.assertIn("numina-runtime/", lines)
57
-
58
-
59
- class NuminaRuntimeCredentialTests(unittest.TestCase):
60
- def test_env_local_is_read_from_numina_runtime_root(self) -> None:
61
- with tempfile.TemporaryDirectory() as tmp:
62
- root = Path(tmp)
63
- shared = root / "shared-ai4math"
64
- env_path = shared / "numina-runtime" / ".env.local"
65
- env_path.parent.mkdir(parents=True)
66
- env_path.write_text(
67
- "export ANTHROPIC_AUTH_TOKEN=secret-token\n"
68
- "OPENAI_API_KEY=placeholder-openai-token\n",
69
- encoding="utf-8",
70
- )
71
-
72
- with patch.dict(os.environ, {"AI4MATH_HOME": str(shared), "AI4MATH_NUMINA_HOME": ""}, clear=False):
73
- values = read_numina_env_local(root)
74
-
75
- self.assertEqual(values["ANTHROPIC_AUTH_TOKEN"], "secret-token")
76
- self.assertEqual(values["OPENAI_API_KEY"], "placeholder-openai-token")
77
-
78
- def test_credential_report_redacts_values(self) -> None:
79
- report = credential_report({
80
- "ANTHROPIC_AUTH_TOKEN": "secret-token",
81
- "OPENAI_API_KEY": "placeholder-openai-token",
82
- })
83
-
84
- self.assertTrue(report["claude"]["configured"])
85
- self.assertEqual(report["claude"]["variables"]["ANTHROPIC_AUTH_TOKEN"], "<redacted>")
86
- self.assertEqual(report["skill_keys"]["OPENAI_API_KEY"], "<redacted>")
87
- self.assertNotIn("secret-token", str(report))
88
-
89
-
90
- class NuminaRuntimePlanTests(unittest.TestCase):
91
- def test_install_plan_clones_official_upstream_when_missing(self) -> None:
92
- with tempfile.TemporaryDirectory() as tmp:
93
- root = Path(tmp)
94
- shared = root / "shared-ai4math"
95
- with patch.dict(os.environ, {"AI4MATH_HOME": str(shared), "AI4MATH_NUMINA_HOME": ""}, clear=False):
96
- plan = build_install_plan(root, dry_run=True)
97
-
98
- self.assertTrue(plan["ok"])
99
- self.assertEqual(plan["status"], "install_plan_ready")
100
- self.assertEqual(plan["actions"][0]["command"][0:2], ["git", "clone"])
101
- self.assertEqual(plan["actions"][0]["command"][2], DEFAULT_UPSTREAM_URL)
102
-
103
- def test_install_plan_blocks_dirty_upstream(self) -> None:
104
- with tempfile.TemporaryDirectory() as tmp:
105
- root = Path(tmp)
106
- shared = root / "shared-ai4math"
107
- upstream = shared / "numina-runtime" / "upstream"
108
- upstream.mkdir(parents=True)
109
- (upstream / ".git").mkdir()
110
-
111
- with patch.dict(os.environ, {"AI4MATH_HOME": str(shared), "AI4MATH_NUMINA_HOME": ""}, clear=False), \
112
- patch("numina_runtime.run_command", return_value={
113
- "ok": True,
114
- "returncode": 0,
115
- "stdout": " M tutorial/foo.py\n",
116
- "stderr": "",
117
- "command": ["git", "status", "--short"],
118
- }):
119
- plan = build_install_plan(root, dry_run=False)
120
-
121
- self.assertFalse(plan["ok"])
122
- self.assertEqual(plan["status"], "dirty_upstream")
123
- self.assertEqual(plan["actions"], [])
124
-
125
- def test_configure_plan_uses_official_setup_and_uv_commands(self) -> None:
126
- with tempfile.TemporaryDirectory() as tmp:
127
- root = Path(tmp)
128
- shared = root / "shared-ai4math"
129
- upstream = shared / "numina-runtime" / "upstream"
130
- (upstream / ".git").mkdir(parents=True)
131
-
132
- with patch.dict(os.environ, {"AI4MATH_HOME": str(shared), "AI4MATH_NUMINA_HOME": ""}, clear=False), \
133
- patch("numina_runtime.run_command", return_value={
134
- "ok": True,
135
- "returncode": 0,
136
- "stdout": "",
137
- "stderr": "",
138
- "command": ["git", "status", "--short"],
139
- }):
140
- plan = build_configure_plan(root, project_name="demo_project", dry_run=True)
141
-
142
- commands = [action["command"] for action in plan["actions"]]
143
- self.assertTrue(plan["ok"])
144
- self.assertIn(["./setup.sh", "demo_project"], commands)
145
- self.assertIn(["uv", "python", "install"], commands)
146
- self.assertIn(["uv", "sync"], commands)
147
- self.assertNotIn(["uv", "run", "scripts/sync_projects.py"], commands)
148
-
149
- def test_run_plan_uses_official_runner_without_executing(self) -> None:
150
- with tempfile.TemporaryDirectory() as tmp:
151
- root = Path(tmp)
152
- theorem = root / "Demo.lean"
153
- theorem.write_text("example : True := by\n trivial\n", encoding="utf-8")
154
- shared = root / "shared-ai4math"
155
- upstream = shared / "numina-runtime" / "upstream"
156
- upstream.mkdir(parents=True)
157
-
158
- with patch.dict(os.environ, {"AI4MATH_HOME": str(shared), "AI4MATH_NUMINA_HOME": ""}, clear=False):
159
- plan = build_run_plan(root, file=theorem, max_iters=3)
160
-
161
- self.assertTrue(plan["ok"])
162
- self.assertEqual(plan["status"], "run_plan_ready")
163
- self.assertEqual(plan["command"][0:5], ["uv", "run", "python", "-m", "scripts.run_claude"])
164
- self.assertIn(str(Path(os.path.abspath(theorem))), plan["command"])
165
-
166
-
167
- if __name__ == "__main__":
168
- unittest.main()
@@ -1,29 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import sys
4
- import unittest
5
- from pathlib import Path
6
-
7
- SCRIPT_DIR = Path(__file__).resolve().parents[1] / "scripts"
8
- sys.path.insert(0, str(SCRIPT_DIR))
9
-
10
- from validate_patch import review_files # noqa: E402
11
-
12
-
13
- FIXTURES = Path(__file__).resolve().parent / "fixtures"
14
-
15
-
16
- class ValidatePatchTests(unittest.TestCase):
17
- def test_rejects_sorry(self) -> None:
18
- result = review_files(FIXTURES / "before.lean", FIXTURES / "after_bad.lean")
19
- self.assertFalse(result["ok"])
20
- self.assertTrue(result["forbidden_findings"])
21
-
22
- def test_rejects_statement_change(self) -> None:
23
- result = review_files(FIXTURES / "before.lean", FIXTURES / "after_statement_changed.lean")
24
- self.assertFalse(result["ok"])
25
- self.assertTrue(result["statement_changes"])
26
-
27
-
28
- if __name__ == "__main__":
29
- unittest.main()