|
1 | | -"""Anti-drift: thinking lenses, engineering/agent/context/domain/repo prompts, and workflow skills cross-link.""" |
| 1 | +"""Anti-drift: thinking lenses, core/engineering/agent/context/domain/repo prompts, and workflow skills cross-link.""" |
2 | 2 |
|
3 | 3 | import re |
4 | 4 | from pathlib import Path |
5 | 5 |
|
6 | 6 | import pytest |
7 | 7 |
|
8 | 8 | LIBRARY_ROOT = Path(__file__).parent.parent.parent |
| 9 | +CORE_DIR = LIBRARY_ROOT / "00-core" |
9 | 10 | THINKING_DIR = LIBRARY_ROOT / "01-thinking" |
10 | 11 | ENGINEERING_DIR = LIBRARY_ROOT / "02-engineering" |
11 | 12 | AGENT_DIR = LIBRARY_ROOT / "04-agent" |
|
14 | 15 | REPO_DIR = LIBRARY_ROOT / "06-repo" |
15 | 16 | SKILLS_DIR = LIBRARY_ROOT / "skills" |
16 | 17 |
|
| 18 | +CORE_THINKING_LINKS: dict[str, tuple[str, ...]] = { |
| 19 | + "core-full.md": ( |
| 20 | + "01-thinking/why-what-how-done.md", |
| 21 | + "01-thinking/critical-thinking-check.md", |
| 22 | + ), |
| 23 | + "core-minimal.md": ("01-thinking/why-what-how-done.md",), |
| 24 | + "core-short.md": ("01-thinking/why-what-how-done.md",), |
| 25 | + "custom-instruction-en.md": (), |
| 26 | + "custom-instruction-zh.md": (), |
| 27 | + "daily-minimal.md": ( |
| 28 | + "01-thinking/falsifiability.md", |
| 29 | + "01-thinking/why-what-how-done.md", |
| 30 | + ), |
| 31 | + "global-controller.md": ("01-thinking/why-what-how-done.md",), |
| 32 | + "important-task-full.md": ( |
| 33 | + "01-thinking/socratic-reviewer.md", |
| 34 | + "01-thinking/critical-thinking-check.md", |
| 35 | + ), |
| 36 | + "master-prompt.md": ( |
| 37 | + "01-thinking/socratic-reviewer.md", |
| 38 | + "01-thinking/critical-thinking-check.md", |
| 39 | + ), |
| 40 | +} |
| 41 | + |
| 42 | +CORE_SKILL_LINKS: dict[str, tuple[str, ...]] = { |
| 43 | + "core-full.md": ("reflective-brief", "reflective-dispatch"), |
| 44 | + "core-minimal.md": ("reflective-brief",), |
| 45 | + "core-short.md": ("reflective-brief", "reflective-dispatch"), |
| 46 | + "custom-instruction-en.md": ("reflective-brief",), |
| 47 | + "custom-instruction-zh.md": ("reflective-brief",), |
| 48 | + "daily-minimal.md": ("reflective-brief",), |
| 49 | + "global-controller.md": ("reflective-dispatch",), |
| 50 | + "important-task-full.md": ("reflective-brief", "reflective-research"), |
| 51 | + "master-prompt.md": ("reflective-brief", "reflective-dispatch"), |
| 52 | +} |
| 53 | + |
17 | 54 | ENGINEERING_THINKING_LINKS: dict[str, tuple[str, ...]] = { |
18 | 55 | "task-start.md": ( |
19 | 56 | "01-thinking/why-what-how-done.md", |
|
159 | 196 | } |
160 | 197 |
|
161 | 198 |
|
| 199 | +CORE_PROMPTS = tuple(sorted(CORE_DIR.glob("*.md"))) |
162 | 200 | THINKING_PROMPTS = tuple(sorted(THINKING_DIR.glob("*.md"))) |
163 | 201 | ENGINEERING_PROMPTS = tuple(sorted(ENGINEERING_DIR.glob("*.md"))) |
164 | 202 | AGENT_PROMPTS = tuple(sorted(AGENT_DIR.glob("*.md"))) |
@@ -277,6 +315,47 @@ def _prompt_sources_section(skill_path: Path) -> str: |
277 | 315 | return text.split(marker, 1)[1].split("##", 1)[0] |
278 | 316 |
|
279 | 317 |
|
| 318 | + |
| 319 | +@pytest.mark.parametrize("prompt_name,thinking_refs", CORE_THINKING_LINKS.items()) |
| 320 | +def test_core_prompt_links_thinking_lens(prompt_name: str, thinking_refs: tuple[str, ...]): |
| 321 | + path = CORE_DIR / prompt_name |
| 322 | + preamble = _preamble(path) |
| 323 | + for ref in thinking_refs: |
| 324 | + assert ref in preamble, f"{prompt_name} preamble should reference {ref}" |
| 325 | + |
| 326 | + |
| 327 | +def test_all_core_prompts_have_thinking_cross_link(): |
| 328 | + assert set(CORE_THINKING_LINKS) == {p.name for p in CORE_PROMPTS} |
| 329 | + |
| 330 | + |
| 331 | +def test_all_core_prompts_have_skill_link(): |
| 332 | + assert set(CORE_SKILL_LINKS) == {p.name for p in CORE_PROMPTS} |
| 333 | + |
| 334 | + |
| 335 | +@pytest.mark.parametrize("prompt_name,skill_refs", CORE_SKILL_LINKS.items()) |
| 336 | +def test_core_prompt_maps_workflow_skill(prompt_name: str, skill_refs: tuple[str, ...]): |
| 337 | + preamble = _preamble(CORE_DIR / prompt_name) |
| 338 | + for skill in skill_refs: |
| 339 | + assert skill in preamble, f"{prompt_name} preamble should reference {skill}" |
| 340 | + |
| 341 | + |
| 342 | +@pytest.mark.parametrize("prompt_name,skill_refs", CORE_SKILL_LINKS.items()) |
| 343 | +def test_core_prompt_primary_surfaces_match_skill_links( |
| 344 | + prompt_name: str, skill_refs: tuple[str, ...] |
| 345 | +): |
| 346 | + preamble = _preamble(CORE_DIR / prompt_name) |
| 347 | + listed = _primary_workflow_surfaces_skills(preamble) |
| 348 | + assert listed == tuple(sorted(skill_refs)), ( |
| 349 | + f"{prompt_name} Primary workflow surfaces {listed} != {skill_refs}" |
| 350 | + ) |
| 351 | + |
| 352 | + |
| 353 | +def test_thinking_lens_files_exist_for_core_links(): |
| 354 | + linked = {ref for refs in CORE_THINKING_LINKS.values() for ref in refs} |
| 355 | + for ref in linked: |
| 356 | + assert (LIBRARY_ROOT / ref).is_file(), f"missing thinking lens file {ref}" |
| 357 | + |
| 358 | + |
280 | 359 | @pytest.mark.parametrize("prompt_name,thinking_refs", ENGINEERING_THINKING_LINKS.items()) |
281 | 360 | def test_engineering_prompt_links_thinking_lens(prompt_name: str, thinking_refs: tuple[str, ...]): |
282 | 361 | path = ENGINEERING_DIR / prompt_name |
|
0 commit comments