xtrm-tools 2.1.5 → 2.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -3
- package/cli/dist/index.cjs +991 -908
- package/cli/dist/index.cjs.map +1 -1
- package/cli/package.json +4 -1
- package/config/hooks.json +5 -0
- package/hooks/README.md +19 -0
- package/hooks/beads-stop-gate.mjs +1 -0
- package/hooks/main-guard-post-push.mjs +71 -0
- package/hooks/main-guard.mjs +10 -1
- package/package.json +17 -5
- package/project-skills/{ts-quality-gate → quality-gates}/.claude/hooks/quality-check.cjs +36 -1
- package/project-skills/{py-quality-gate → quality-gates}/.claude/hooks/quality-check.py +15 -2
- package/project-skills/{py-quality-gate → quality-gates}/.claude/settings.json +10 -0
- package/project-skills/quality-gates/.claude/skills/using-quality-gates/SKILL.md +254 -0
- package/project-skills/quality-gates/README.md +109 -0
- package/project-skills/quality-gates/evals/evals.json +181 -0
- package/project-skills/quality-gates/workspace/iteration-1/FINAL-EVAL-SUMMARY.md +75 -0
- package/project-skills/quality-gates/workspace/iteration-1/edge-case-auto-fix-verification/with_skill/outputs/response.md +59 -0
- package/project-skills/quality-gates/workspace/iteration-1/edge-case-mixed-language-project/with_skill/outputs/response.md +60 -0
- package/project-skills/quality-gates/workspace/iteration-1/eval-summary.md +105 -0
- package/project-skills/quality-gates/workspace/iteration-1/partial-install-python-only/with_skill/outputs/response.md +93 -0
- package/project-skills/quality-gates/workspace/iteration-1/python-refactor-request/with_skill/outputs/response.md +104 -0
- package/project-skills/quality-gates/workspace/iteration-1/quality-gate-error-fix/with_skill/outputs/response.md +74 -0
- package/project-skills/quality-gates/workspace/iteration-1/should-not-trigger-general-chat/with_skill/outputs/response.md +18 -0
- package/project-skills/quality-gates/workspace/iteration-1/should-not-trigger-math-question/with_skill/outputs/response.md +18 -0
- package/project-skills/quality-gates/workspace/iteration-1/should-not-trigger-unrelated-coding/with_skill/outputs/response.md +56 -0
- package/project-skills/quality-gates/workspace/iteration-1/tdd-guard-blocking-confusion/with_skill/outputs/response.md +67 -0
- package/project-skills/quality-gates/workspace/iteration-1/typescript-feature-with-tests/with_skill/outputs/response.md +97 -0
- package/project-skills/service-skills-set/install-service-skills.py +41 -11
- package/project-skills/tdd-guard/.claude/hooks/tdd-guard-pretool-bridge.cjs +0 -1
- package/project-skills/tdd-guard/reporters/jest/src/JestReporter.test-data.ts +199 -0
- package/project-skills/tdd-guard/reporters/jest/src/JestReporter.test.ts +302 -0
- package/project-skills/tdd-guard/reporters/jest/src/JestReporter.ts +201 -0
- package/project-skills/tdd-guard/reporters/jest/src/index.ts +4 -0
- package/project-skills/tdd-guard/reporters/jest/src/types.ts +42 -0
- package/project-skills/tdd-guard/reporters/jest/tsconfig.json +11 -0
- package/project-skills/tdd-guard/reporters/vitest/src/VitestReporter.test-data.ts +85 -0
- package/project-skills/tdd-guard/reporters/vitest/src/VitestReporter.test.ts +446 -0
- package/project-skills/tdd-guard/reporters/vitest/src/VitestReporter.ts +110 -0
- package/project-skills/tdd-guard/reporters/vitest/src/index.ts +4 -0
- package/project-skills/tdd-guard/reporters/vitest/src/types.ts +39 -0
- package/project-skills/tdd-guard/reporters/vitest/tsconfig.json +11 -0
- package/hooks/__pycache__/agent_context.cpython-314.pyc +0 -0
- package/project-skills/py-quality-gate/.claude/skills/using-py-quality-gate/SKILL.md +0 -112
- package/project-skills/py-quality-gate/README.md +0 -147
- package/project-skills/service-skills-set/.claude/git-hooks/__pycache__/doc_reminder.cpython-314.pyc +0 -0
- package/project-skills/service-skills-set/.claude/git-hooks/__pycache__/skill_staleness.cpython-314.pyc +0 -0
- package/project-skills/service-skills-set/.claude/skills/creating-service-skills/scripts/__pycache__/bootstrap.cpython-314.pyc +0 -0
- package/project-skills/service-skills-set/.claude/skills/updating-service-skills/scripts/__pycache__/drift_detector.cpython-314.pyc +0 -0
- package/project-skills/service-skills-set/.claude/skills/using-service-skills/scripts/__pycache__/cataloger.cpython-314.pyc +0 -0
- package/project-skills/service-skills-set/.claude/skills/using-service-skills/scripts/__pycache__/skill_activator.cpython-314.pyc +0 -0
- package/project-skills/service-skills-set/.claude/skills/using-service-skills/scripts/__pycache__/test_skill_activator.cpython-314-pytest-9.0.2.pyc +0 -0
- package/project-skills/service-skills-set/.claude/skills/using-service-skills/scripts/test_skill_activator.py +0 -58
- package/project-skills/service-skills-set/__pycache__/install-service-skills.cpython-314.pyc +0 -0
- package/project-skills/ts-quality-gate/.claude/settings.json +0 -16
- package/project-skills/ts-quality-gate/.claude/skills/using-ts-quality-gate/SKILL.md +0 -81
- package/project-skills/ts-quality-gate/README.md +0 -115
- package/skills/documenting/scripts/__pycache__/drift_detector.cpython-314.pyc +0 -0
- package/skills/documenting/scripts/__pycache__/orchestrator.cpython-314.pyc +0 -0
- package/skills/documenting/scripts/__pycache__/validate_metadata.cpython-314.pyc +0 -0
- package/skills/documenting/scripts/changelog/__pycache__/__init__.cpython-314.pyc +0 -0
- package/skills/documenting/scripts/changelog/__pycache__/add_entry.cpython-314.pyc +0 -0
- package/skills/documenting/scripts/changelog/__pycache__/bump_release.cpython-314.pyc +0 -0
- package/skills/documenting/scripts/changelog/__pycache__/validate_changelog.cpython-314.pyc +0 -0
- package/skills/documenting/tests/__pycache__/test_changelog.cpython-314-pytest-9.0.2.pyc +0 -0
- package/skills/documenting/tests/__pycache__/test_drift_detector.cpython-314-pytest-9.0.2.pyc +0 -0
- package/skills/documenting/tests/__pycache__/test_orchestrator.cpython-314-pytest-9.0.2.pyc +0 -0
- package/skills/documenting/tests/__pycache__/test_validate_metadata.cpython-314-pytest-9.0.2.pyc +0 -0
- package/skills/documenting/tests/integration_test.sh +0 -70
- package/skills/documenting/tests/test_changelog.py +0 -201
- package/skills/documenting/tests/test_drift_detector.py +0 -80
- package/skills/documenting/tests/test_orchestrator.py +0 -52
- package/skills/documenting/tests/test_validate_metadata.py +0 -64
- /package/project-skills/{ts-quality-gate → quality-gates}/.claude/hooks/hook-config.json +0 -0
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""Tests for CHANGELOG management scripts."""
|
|
3
|
-
|
|
4
|
-
import pytest
|
|
5
|
-
from pathlib import Path
|
|
6
|
-
from scripts.changelog.validate_changelog import validate_changelog
|
|
7
|
-
from scripts.changelog.add_entry import add_entry, ChangeCategory
|
|
8
|
-
from scripts.changelog.bump_release import bump_release
|
|
9
|
-
from datetime import date
|
|
10
|
-
import tempfile
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def test_valid_changelog_passes():
|
|
14
|
-
"""Valid Keep a Changelog format should pass validation."""
|
|
15
|
-
valid_content = """# Changelog
|
|
16
|
-
|
|
17
|
-
All notable changes to this project will be documented in this file.
|
|
18
|
-
|
|
19
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
20
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
21
|
-
|
|
22
|
-
## [Unreleased]
|
|
23
|
-
|
|
24
|
-
### Added
|
|
25
|
-
- New feature description
|
|
26
|
-
|
|
27
|
-
## [1.0.0] - 2026-02-01
|
|
28
|
-
|
|
29
|
-
### Added
|
|
30
|
-
- Initial release
|
|
31
|
-
"""
|
|
32
|
-
result = validate_changelog(valid_content)
|
|
33
|
-
assert result["valid"] is True
|
|
34
|
-
assert len(result["errors"]) == 0
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def test_missing_unreleased_section_fails():
|
|
38
|
-
"""CHANGELOG without [Unreleased] section should fail."""
|
|
39
|
-
invalid_content = """# Changelog
|
|
40
|
-
|
|
41
|
-
## [1.0.0] - 2026-02-01
|
|
42
|
-
|
|
43
|
-
### Added
|
|
44
|
-
- Initial release
|
|
45
|
-
"""
|
|
46
|
-
result = validate_changelog(invalid_content)
|
|
47
|
-
assert result["valid"] is False
|
|
48
|
-
assert any("Unreleased" in err for err in result["errors"])
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
def test_invalid_semver_fails():
|
|
52
|
-
"""CHANGELOG with invalid semver should fail."""
|
|
53
|
-
invalid_content = """# Changelog
|
|
54
|
-
|
|
55
|
-
## [Unreleased]
|
|
56
|
-
|
|
57
|
-
## [1.0] - 2026-02-01
|
|
58
|
-
|
|
59
|
-
### Added
|
|
60
|
-
- Initial release
|
|
61
|
-
"""
|
|
62
|
-
result = validate_changelog(invalid_content)
|
|
63
|
-
assert result["valid"] is False
|
|
64
|
-
assert any("semantic version" in err.lower() for err in result["errors"])
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
def test_invalid_category_fails():
|
|
68
|
-
"""CHANGELOG with invalid category should fail."""
|
|
69
|
-
invalid_content = """# Changelog
|
|
70
|
-
|
|
71
|
-
## [Unreleased]
|
|
72
|
-
|
|
73
|
-
### InvalidCategory
|
|
74
|
-
- Some change
|
|
75
|
-
|
|
76
|
-
## [1.0.0] - 2026-02-01
|
|
77
|
-
|
|
78
|
-
### Added
|
|
79
|
-
- Initial release
|
|
80
|
-
"""
|
|
81
|
-
result = validate_changelog(invalid_content)
|
|
82
|
-
assert result["valid"] is False
|
|
83
|
-
assert any("category" in err.lower() for err in result["errors"])
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
def test_add_entry_to_unreleased():
|
|
87
|
-
"""Adding entry should place it under [Unreleased] in correct category."""
|
|
88
|
-
changelog_content = """# Changelog
|
|
89
|
-
|
|
90
|
-
## [Unreleased]
|
|
91
|
-
|
|
92
|
-
## [1.0.0] - 2026-02-01
|
|
93
|
-
|
|
94
|
-
### Added
|
|
95
|
-
- Initial release
|
|
96
|
-
"""
|
|
97
|
-
|
|
98
|
-
result = add_entry(
|
|
99
|
-
changelog_content,
|
|
100
|
-
category=ChangeCategory.ADDED,
|
|
101
|
-
description="New feature X"
|
|
102
|
-
)
|
|
103
|
-
|
|
104
|
-
assert "### Added" in result
|
|
105
|
-
assert "- New feature X" in result
|
|
106
|
-
# Should be under [Unreleased], not under [1.0.0]
|
|
107
|
-
unreleased_section = result.split("## [1.0.0]")[0]
|
|
108
|
-
assert "- New feature X" in unreleased_section
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
def test_add_entry_creates_category_if_missing():
|
|
112
|
-
"""Adding entry should create category section if it doesn't exist."""
|
|
113
|
-
changelog_content = """# Changelog
|
|
114
|
-
|
|
115
|
-
## [Unreleased]
|
|
116
|
-
|
|
117
|
-
## [1.0.0] - 2026-02-01
|
|
118
|
-
|
|
119
|
-
### Added
|
|
120
|
-
- Initial release
|
|
121
|
-
"""
|
|
122
|
-
|
|
123
|
-
result = add_entry(
|
|
124
|
-
changelog_content,
|
|
125
|
-
category=ChangeCategory.FIXED,
|
|
126
|
-
description="Bug fix Y"
|
|
127
|
-
)
|
|
128
|
-
|
|
129
|
-
assert "### Fixed" in result
|
|
130
|
-
assert "- Bug fix Y" in result
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
def test_add_entry_maintains_category_order():
|
|
134
|
-
"""Categories should be ordered: Added, Changed, Deprecated, Removed, Fixed, Security."""
|
|
135
|
-
changelog_content = """# Changelog
|
|
136
|
-
|
|
137
|
-
## [Unreleased]
|
|
138
|
-
|
|
139
|
-
### Added
|
|
140
|
-
- Feature A
|
|
141
|
-
|
|
142
|
-
### Fixed
|
|
143
|
-
- Bug B
|
|
144
|
-
|
|
145
|
-
## [1.0.0] - 2026-02-01
|
|
146
|
-
"""
|
|
147
|
-
|
|
148
|
-
result = add_entry(
|
|
149
|
-
changelog_content,
|
|
150
|
-
category=ChangeCategory.CHANGED,
|
|
151
|
-
description="Change C"
|
|
152
|
-
)
|
|
153
|
-
|
|
154
|
-
# Changed should appear between Added and Fixed
|
|
155
|
-
lines = result.split('\n')
|
|
156
|
-
added_idx = next(i for i, line in enumerate(lines) if "### Added" in line)
|
|
157
|
-
changed_idx = next(i for i, line in enumerate(lines) if "### Changed" in line)
|
|
158
|
-
fixed_idx = next(i for i, line in enumerate(lines) if "### Fixed" in line)
|
|
159
|
-
|
|
160
|
-
assert added_idx < changed_idx < fixed_idx
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
def test_bump_release_moves_unreleased():
|
|
164
|
-
"""Bumping release should move [Unreleased] to [X.Y.Z] - DATE."""
|
|
165
|
-
changelog_content = """# Changelog
|
|
166
|
-
|
|
167
|
-
## [Unreleased]
|
|
168
|
-
|
|
169
|
-
### Added
|
|
170
|
-
- New feature
|
|
171
|
-
|
|
172
|
-
## [1.0.0] - 2026-01-01
|
|
173
|
-
|
|
174
|
-
### Added
|
|
175
|
-
- Initial release
|
|
176
|
-
"""
|
|
177
|
-
|
|
178
|
-
result = bump_release(changelog_content, "1.1.0")
|
|
179
|
-
|
|
180
|
-
# Should have new version section
|
|
181
|
-
assert "## [1.1.0]" in result
|
|
182
|
-
assert f"## [1.1.0] - {date.today().strftime('%Y-%m-%d')}" in result
|
|
183
|
-
|
|
184
|
-
# New feature should be under 1.1.0 now
|
|
185
|
-
version_section = result.split("## [1.0.0]")[0]
|
|
186
|
-
assert "- New feature" in version_section
|
|
187
|
-
|
|
188
|
-
# [Unreleased] should be empty
|
|
189
|
-
unreleased_section = result.split("## [1.1.0]")[0]
|
|
190
|
-
assert "## [Unreleased]" in unreleased_section
|
|
191
|
-
# No ### categories under [Unreleased]
|
|
192
|
-
unreleased_lines = unreleased_section.split("## [Unreleased]")[1].split('\\n')
|
|
193
|
-
assert not any(line.startswith("###") for line in unreleased_lines)
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
def test_bump_release_validates_semver():
|
|
197
|
-
"""Bumping with invalid semver should raise error."""
|
|
198
|
-
changelog_content = "## [Unreleased]"
|
|
199
|
-
|
|
200
|
-
with pytest.raises(ValueError, match="semantic version"):
|
|
201
|
-
bump_release(changelog_content, "1.0")
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
import sys
|
|
4
|
-
sys.path.insert(0, str(Path(__file__).parent.parent / "scripts"))
|
|
5
|
-
from drift_detector import extract_tracks, match_files_to_tracks, format_scan_report
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
MEMORY_WITH_TRACKS = """---
|
|
9
|
-
title: Test SSOT
|
|
10
|
-
version: 1.0.0
|
|
11
|
-
updated: 2026-02-01
|
|
12
|
-
tracks:
|
|
13
|
-
- "cli/src/**/*.ts"
|
|
14
|
-
- "hooks/**/*.py"
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
## Purpose
|
|
18
|
-
Test memory.
|
|
19
|
-
"""
|
|
20
|
-
|
|
21
|
-
MEMORY_NO_TRACKS = """---
|
|
22
|
-
title: No Tracks
|
|
23
|
-
version: 1.0.0
|
|
24
|
-
updated: 2026-02-01
|
|
25
|
-
---
|
|
26
|
-
|
|
27
|
-
## Purpose
|
|
28
|
-
No tracking.
|
|
29
|
-
"""
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
def test_extract_tracks_finds_globs():
|
|
33
|
-
tracks = extract_tracks(MEMORY_WITH_TRACKS)
|
|
34
|
-
assert tracks == ["cli/src/**/*.ts", "hooks/**/*.py"]
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def test_extract_tracks_empty_when_missing():
|
|
38
|
-
tracks = extract_tracks(MEMORY_NO_TRACKS)
|
|
39
|
-
assert tracks == []
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def test_match_files_to_tracks_hit():
|
|
43
|
-
files = ["cli/src/core/diff.ts", "hooks/skill-suggestion.py"]
|
|
44
|
-
tracks = ["cli/src/**/*.ts", "hooks/**/*.py"]
|
|
45
|
-
matched = match_files_to_tracks(files, tracks)
|
|
46
|
-
assert "cli/src/core/diff.ts" in matched
|
|
47
|
-
assert "hooks/skill-suggestion.py" in matched
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
def test_match_files_to_tracks_miss():
|
|
51
|
-
files = ["docs/README.md"]
|
|
52
|
-
tracks = ["cli/src/**/*.ts"]
|
|
53
|
-
assert match_files_to_tracks(files, tracks) == []
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
def test_format_scan_report_stale():
|
|
57
|
-
stale = {"my_memory": {"files": ["cli/src/core/diff.ts"], "updated": "2026-02-01"}}
|
|
58
|
-
report = format_scan_report(stale)
|
|
59
|
-
assert "my_memory" in report
|
|
60
|
-
assert "cli/src/core/diff.ts" in report
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
def test_format_scan_report_clean():
|
|
64
|
-
report = format_scan_report({})
|
|
65
|
-
assert any(word in report.lower() for word in ["clean", "no stale", "up to date"])
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
def test_match_files_to_tracks_no_false_positive():
|
|
69
|
-
"""A .py file in an unrelated dir must NOT match hooks/**/*.py"""
|
|
70
|
-
files = ["cli/src/transform.py", "docs/something.py"]
|
|
71
|
-
tracks = ["hooks/**/*.py"]
|
|
72
|
-
assert match_files_to_tracks(files, tracks) == []
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
def test_match_files_to_tracks_direct_child():
|
|
76
|
-
"""hooks/**/*.py must match files directly under hooks/ (no subdir)"""
|
|
77
|
-
files = ["hooks/skill-suggestion.py"]
|
|
78
|
-
tracks = ["hooks/**/*.py"]
|
|
79
|
-
matched = match_files_to_tracks(files, tracks)
|
|
80
|
-
assert "hooks/skill-suggestion.py" in matched
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""Tests for documentation orchestrator."""
|
|
3
|
-
|
|
4
|
-
import pytest
|
|
5
|
-
from pathlib import Path
|
|
6
|
-
from scripts.orchestrator import DocumentingOrchestrator, ChangeType
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def test_orchestrator_routes_to_correct_docs(tmp_path):
|
|
10
|
-
"""Orchestrator should update relevant docs based on change type."""
|
|
11
|
-
# Setup test project
|
|
12
|
-
project_root = tmp_path / "test_project"
|
|
13
|
-
project_root.mkdir()
|
|
14
|
-
|
|
15
|
-
changelog = project_root / "CHANGELOG.md"
|
|
16
|
-
changelog.write_text("""# Changelog
|
|
17
|
-
|
|
18
|
-
## [Unreleased]
|
|
19
|
-
|
|
20
|
-
## [0.1.0] - 2026-02-01
|
|
21
|
-
|
|
22
|
-
### Added
|
|
23
|
-
- Initial release
|
|
24
|
-
""", encoding="utf-8")
|
|
25
|
-
|
|
26
|
-
serena_memories = project_root / ".serena" / "memories"
|
|
27
|
-
serena_memories.mkdir(parents=True)
|
|
28
|
-
|
|
29
|
-
orchestrator = DocumentingOrchestrator(project_root)
|
|
30
|
-
|
|
31
|
-
result = orchestrator.document_change(
|
|
32
|
-
change_type=ChangeType.FEATURE,
|
|
33
|
-
description="Add new API endpoint",
|
|
34
|
-
details={
|
|
35
|
-
"scope": "api-endpoints",
|
|
36
|
-
"category": "backend",
|
|
37
|
-
"files_changed": ["server.py", "routes/api.py"]
|
|
38
|
-
}
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
# Should update CHANGELOG
|
|
42
|
-
assert result["changelog_updated"] is True
|
|
43
|
-
# Should create/update SSOT
|
|
44
|
-
assert result["ssot_updated"] is False # Placeholder impl in plan returns False
|
|
45
|
-
# Should suggest README update
|
|
46
|
-
assert "readme_suggestions" in result
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
def test_orchestrator_validates_all_docs():
|
|
50
|
-
"""Orchestrator should validate all documentation after updates."""
|
|
51
|
-
# Test validation integration
|
|
52
|
-
pass
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
import sys
|
|
4
|
-
sys.path.insert(0, str(Path(__file__).parent.parent / "scripts"))
|
|
5
|
-
from validate_metadata import extract_headings, generate_index_table, inject_index
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
SAMPLE = """---
|
|
9
|
-
title: Test
|
|
10
|
-
version: 1.0.0
|
|
11
|
-
updated: 2026-02-24
|
|
12
|
-
scope: test
|
|
13
|
-
category: ssot
|
|
14
|
-
subcategory: test
|
|
15
|
-
domain: [test]
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
<!-- INDEX: auto-generated by validate_metadata.py — do not edit manually -->
|
|
19
|
-
| Section | Summary |
|
|
20
|
-
|---|---|
|
|
21
|
-
| old | old |
|
|
22
|
-
<!-- END INDEX -->
|
|
23
|
-
|
|
24
|
-
## Architecture
|
|
25
|
-
Handles the core routing logic for all requests.
|
|
26
|
-
|
|
27
|
-
## Hook Wiring
|
|
28
|
-
Three hooks fire on session events.
|
|
29
|
-
|
|
30
|
-
## Installer
|
|
31
|
-
Single-purpose script, idempotent.
|
|
32
|
-
"""
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def test_extract_headings():
|
|
36
|
-
headings = extract_headings(SAMPLE)
|
|
37
|
-
assert headings == [
|
|
38
|
-
("Architecture", "Handles the core routing logic for all requests"),
|
|
39
|
-
("Hook Wiring", "Three hooks fire on session events"),
|
|
40
|
-
("Installer", "Single-purpose script, idempotent"),
|
|
41
|
-
]
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
def test_generate_index_table():
|
|
45
|
-
headings = [("Architecture", "Core routing."), ("Installer", "Idempotent.")]
|
|
46
|
-
table = generate_index_table(headings)
|
|
47
|
-
assert "| [Architecture](#architecture) |" in table
|
|
48
|
-
assert "Core routing." in table
|
|
49
|
-
assert "| [Installer](#installer) |" in table
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
def test_inject_index_replaces_existing():
|
|
53
|
-
new_table = "| Section | Summary |\n|---|---|\n| [Architecture](#architecture) | Core. |\n"
|
|
54
|
-
result = inject_index(SAMPLE, new_table)
|
|
55
|
-
assert "| old | old |" not in result
|
|
56
|
-
assert "| [Architecture](#architecture) | Core. |" in result
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
def test_inject_index_adds_when_missing():
|
|
60
|
-
content = "---\ntitle: T\n---\n\n## Foo\nBar baz.\n"
|
|
61
|
-
new_table = "| Section | Summary |\n|---|---|\n| [Foo](#foo) | Bar baz. |\n"
|
|
62
|
-
result = inject_index(content, new_table)
|
|
63
|
-
assert "<!-- INDEX:" in result
|
|
64
|
-
assert "| [Foo](#foo) | Bar baz. |" in result
|
|
File without changes
|