fix: preserve content after frontmatter in parse_instinct_file()
Merged
ER
10mo ago+83+83+01234567890123456789-6-6-0123456789
Summary
parse_instinct_file()appended the instinct and reset state when frontmatter ended (---), before content lines could be collected — causing silent data loss of Action, Evidence, Examples sections during import.- Fix: only set
in_frontmatter = Falseat frontmatter close; defer append to next frontmatter start or EOF, where the logic already exists. - Added pytest test covering multi-section instincts, single instinct, and empty content edge case.
Fixes #148
Reproduction
from parse_instinct_file import ...
content = """
---
id: test-1
trigger: "when coding"
confidence: 0.9
---
## Action
Always write tests first.
## Evidence
TDD improves quality.
"""
# Before fix: [{'id': 'test-1', 'content': ''}]
# After fix: [{'id': 'test-1', 'content': '## Action\nAlways write tests first.\n\n## Evidence\nTDD improves quality.'}]
Test plan
-
pytest skills/continuous-learning-v2/scripts/test_parse_instinct.py -v— 3 passed - Manual verification with multi-instinct file — all content preserved
- Empty content edge case — no error
Summary by CodeRabbit
-
Bug Fixes
- Improved frontmatter parsing to correctly handle instinct boundary processing and content finalization
-
Tests
- Added comprehensive unit tests for instinct parsing covering multiple instincts, single instinct, and empty content scenarios to ensure parsing reliability