🔧 chore(tsl): add playbook sync workflow
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
SCRIPT = ROOT / "scripts" / "build_tsl_playbook.py"
|
||||
|
||||
|
||||
class BuildTslPlaybookTests(unittest.TestCase):
|
||||
def test_builds_minimal_tsl_playbook_tree(self):
|
||||
with tempfile.TemporaryDirectory() as tmp_dir:
|
||||
output = Path(tmp_dir) / "tsl-playbook"
|
||||
|
||||
result = subprocess.run(
|
||||
[sys.executable, str(SCRIPT), "--output", str(output)],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
|
||||
self.assertEqual(result.returncode, 0, msg=result.stderr)
|
||||
self.assertEqual(
|
||||
sorted(path.name for path in output.iterdir()),
|
||||
["AGENTS.md", "docs", "skills"],
|
||||
)
|
||||
self.assertFalse((output / "playbook.toml").exists())
|
||||
self.assertFalse((output / ".agents").exists())
|
||||
self.assertFalse((output / "docs" / "index.md").exists())
|
||||
|
||||
self.assertTrue((output / "docs" / "tsl" / "index.md").is_file())
|
||||
self.assertTrue(
|
||||
(output / "skills" / "tsl-api-reference" / "SKILL.md").is_file()
|
||||
)
|
||||
self.assertTrue(
|
||||
(
|
||||
output
|
||||
/ "skills"
|
||||
/ "tsl-api-reference"
|
||||
/ "scripts"
|
||||
/ "lookup.py"
|
||||
).is_file()
|
||||
)
|
||||
|
||||
agents_text = (output / "AGENTS.md").read_text(encoding="utf-8")
|
||||
self.assertIn("# TSL Agent Instructions", agents_text)
|
||||
self.assertIn("docs/tsl/index.md", agents_text)
|
||||
self.assertIn("tsl-api-reference", agents_text)
|
||||
self.assertNotIn(".agents/index.md", agents_text)
|
||||
self.assertNotIn(".agents/tsl/index.md", agents_text)
|
||||
|
||||
source_docs = count_files(ROOT / "docs" / "tsl")
|
||||
output_docs = count_files(output / "docs" / "tsl")
|
||||
self.assertEqual(output_docs, source_docs)
|
||||
|
||||
source_skill = count_files(ROOT / "skills" / "tsl-api-reference")
|
||||
output_skill = count_files(output / "skills" / "tsl-api-reference")
|
||||
self.assertEqual(output_skill, source_skill)
|
||||
|
||||
|
||||
def count_files(path: Path) -> int:
|
||||
return sum(1 for item in path.rglob("*") if item.is_file())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user