feat(tsl-syntax): add section lookup core

This commit is contained in:
csh
2026-07-13 09:16:52 +08:00
parent ce1b92bbde
commit 5e31a7ccf6
3 changed files with 570 additions and 4 deletions
+14 -4
View File
@@ -36,7 +36,6 @@ TOPIC_REFERENCES = {
"23_fmarray.md",
"24_object_overloads_and_iteration.md",
}
EXPECTED_REFERENCES = {"index.md", *TOPIC_REFERENCES}
MARKDOWN_LINK = re.compile(r"!?\[[^\]]*\]\(([^)]+)\)")
@@ -83,9 +82,20 @@ class TslSyntaxReferenceSkillStructureTest(unittest.TestCase):
self.assertRegex(description, r"(?i)\bTSF\b")
self.assertRegex(description, r"写|编写|修改|审查|解释|语法错误")
def test_reference_inventory_is_exact(self) -> None:
actual = {path.name for path in REFERENCES_DIR.iterdir()}
self.assertEqual(actual, EXPECTED_REFERENCES)
def test_reference_inventory_contains_topics_without_router(self) -> None:
actual = {path.name for path in REFERENCES_DIR.iterdir() if path.is_file()}
self.assertEqual(actual, TOPIC_REFERENCES)
self.assertFalse((REFERENCES_DIR / "index.md").exists())
def test_lookup_script_is_bundled(self) -> None:
self.assertTrue((SKILL_DIR / "scripts" / "lookup.py").is_file())
def test_manual_router_protocol_is_absent(self) -> None:
corpus = read_text(SKILL_FILE) + "\n" + "\n".join(
read_text(path) for path in REFERENCES_DIR.glob("*.md")
)
for forbidden in ("路由中心", "选择一个主专题", "候选页继续判断"):
self.assertNotIn(forbidden, corpus)
def test_json_router_is_absent(self) -> None:
self.assertFalse((REFERENCES_DIR / "00_agent_index.json").exists())