feat(typescript): add standards docs and sync rewrite coverage

This commit is contained in:
csh
2026-02-24 17:30:43 +08:00
parent 872c1afc24
commit 1f46203299
12 changed files with 360 additions and 12 deletions
+52
View File
@@ -16,6 +16,15 @@ def run_cli(*args):
)
def run_script(script_path: Path, *args, cwd: Path | None = None):
return subprocess.run(
[sys.executable, str(script_path), *args],
capture_output=True,
text=True,
cwd=str(cwd) if cwd else None,
)
class SyncTemplatesPlaceholdersTests(unittest.TestCase):
def test_main_language_placeholder_replaced(self):
with tempfile.TemporaryDirectory() as tmp_dir:
@@ -44,6 +53,49 @@ langs = [\"cpp\", \"tsl\"]
self.assertIn("docs/standards/playbook/scripts/plan_progress.py", rules_text)
self.assertNotIn("{{PLAYBOOK_SCRIPTS}}", rules_text)
def test_sync_standards_rewrites_typescript_docs_prefix_for_vendored_playbook(self):
with tempfile.TemporaryDirectory() as tmp_dir:
root = Path(tmp_dir)
vendor_config = root / "vendor.toml"
vendor_config.write_text(
f"""
[playbook]
project_root = "{tmp_dir}"
[vendor]
langs = ["typescript"]
""",
encoding="utf-8",
)
vendor_result = run_cli("-config", str(vendor_config))
self.assertEqual(vendor_result.returncode, 0, msg=vendor_result.stderr)
sync_config = root / "sync.toml"
sync_config.write_text(
f"""
[playbook]
project_root = "{tmp_dir}"
[sync_standards]
langs = ["typescript"]
""",
encoding="utf-8",
)
vendored_script = (
root / "docs" / "standards" / "playbook" / "scripts" / "playbook.py"
)
sync_result = run_script(
vendored_script, "-config", str(sync_config), cwd=root
)
self.assertEqual(sync_result.returncode, 0, msg=sync_result.stderr)
agents_index = root / ".agents" / "typescript" / "index.md"
text = agents_index.read_text(encoding="utf-8")
self.assertIn("`docs/standards/playbook/docs/typescript/", text)
self.assertNotIn("`docs/typescript/", text)
if __name__ == "__main__":
unittest.main()