Test that Markdown links in skill content are converted to absolute paths.
()
| 7 | |
| 8 | |
| 9 | def test_markdown_link_processing(): |
| 10 | """Test that Markdown links in skill content are converted to absolute paths.""" |
| 11 | |
| 12 | # Create a temporary directory structure |
| 13 | with tempfile.TemporaryDirectory() as tmpdir: |
| 14 | skills_dir = Path(tmpdir) / "skills" |
| 15 | skill_dir = skills_dir / "test-skill" |
| 16 | skill_dir.mkdir(parents=True) |
| 17 | |
| 18 | # Create subdirectories |
| 19 | (skill_dir / "reference").mkdir() |
| 20 | (skill_dir / "scripts").mkdir() |
| 21 | |
| 22 | # Create various referenced files |
| 23 | doc_file = skill_dir / "reference.md" |
| 24 | doc_file.write_text("# Reference Documentation") |
| 25 | |
| 26 | ref_file = skill_dir / "reference" / "guide.md" |
| 27 | ref_file.write_text("# Guide") |
| 28 | |
| 29 | script_file = skill_dir / "scripts" / "helper.js" |
| 30 | script_file.write_text("// Helper script") |
| 31 | |
| 32 | # Create SKILL.md with various Markdown link formats |
| 33 | skill_content = """--- |
| 34 | name: test-skill |
| 35 | description: Test skill for Markdown link processing |
| 36 | --- |
| 37 | |
| 38 | # Test Skill |
| 39 | |
| 40 | ## Instructions |
| 41 | |
| 42 | 1. Read [`reference.md`](reference.md) for basic documentation. |
| 43 | 2. Load [Guide](./reference/guide.md) for detailed instructions. |
| 44 | 3. Use [helper script](scripts/helper.js) for automation. |
| 45 | 4. See [another reference](./reference.md) without prefix word. |
| 46 | """ |
| 47 | skill_file = skill_dir / "SKILL.md" |
| 48 | skill_file.write_text(skill_content) |
| 49 | |
| 50 | # Load the skill |
| 51 | loader = SkillLoader(skills_dir=str(skills_dir)) |
| 52 | skills = loader.discover_skills() |
| 53 | |
| 54 | # Verify skill was loaded |
| 55 | assert len(skills) == 1 |
| 56 | skill = skills[0] |
| 57 | |
| 58 | # Test 1: Simple filename link |
| 59 | assert str(doc_file) in skill.content, f"Test 1 failed: Simple filename link not converted" |
| 60 | assert "](reference.md)" not in skill.content, "Test 1 failed: Relative path not replaced" |
| 61 | |
| 62 | # Test 2: Link with ./ prefix |
| 63 | assert str(ref_file) in skill.content, f"Test 2 failed: ./reference/ link not converted" |
| 64 | assert "](./reference/guide.md)" not in skill.content, "Test 2 failed: ./reference/ path not replaced" |
| 65 | |
| 66 | # Test 3: Link with directory path |
no test coverage detected