Skip to content

feat: fix-yaml-frontmatter-escaping — escape special characters in YAML frontmatter strings#346

Merged
avoidwork merged 2 commits into
mainfrom
feat/fix-yaml-frontmatter-escaping
Jun 20, 2026
Merged

feat: fix-yaml-frontmatter-escaping — escape special characters in YAML frontmatter strings#346
avoidwork merged 2 commits into
mainfrom
feat/fix-yaml-frontmatter-escaping

Conversation

@avoidwork

Copy link
Copy Markdown
Owner

Description

Fixes YAML frontmatter string escaping in src/memory/writer.js. The writeMemoryFile function now properly escapes backslashes, double quotes, and newlines in string values to prevent malformed YAML output when titles or frontmatter fields contain special characters.

Type of Change

  • Bugfix (non-breaking change which fixes an issue)

Testing

  • Updated buildMemoryContent test helper in tests/unit/memory.test.js to mirror the escaping logic
  • Added unit tests for strings containing double quotes, backslashes, and newlines
  • All existing tests continue to pass

Coverage

  • 100% line coverage maintained

Checklist

  • npm run lint passes
  • Tests pass with 100% line coverage
  • No forbidden patterns used
  • Conventional Commit style applied

@avoidwork

Copy link
Copy Markdown
Owner Author

Implementation Audit Results

Change: fix-yaml-frontmatter-escaping

Goal Fulfillment: ✅ All goals met

  • Goal 1: Add escapeYamlString() helper — ✅ Implemented in src/memory/writer.js
  • Goal 2: Apply escaping to title field — ✅ Applied on line 27
  • Goal 3: Apply escaping to string frontmatter values — ✅ Applied on line 31
  • Goal 4: Update test helper — ✅ buildMemoryContent updated in tests/unit/memory.test.js
  • Goal 5: Add unit tests — ✅ 4 new tests added (quotes, backslashes, newlines, frontmatter)

Spec Compliance: ✅ Matches requirements

  • Modified requirement in specs/memory-system/spec.md for proper YAML escaping
  • escapeYamlString escapes backslashes → double quotes → newlines in correct order
  • All scenarios from the spec are covered by tests

Task Completion: ✅ All 11 tasks completed

  • 1.1-1.3: Implementation complete
  • 2.1-2.5: Test updates complete
  • 3.1: Tests pass (1149 pass, 0 fail, 1 skipped)
  • 3.2: Lint passes (0 warnings, 0 errors)
  • 3.3: Application starts (TUI error is expected in non-TTY environment)

Quality Check: ✅ No issues found

  • Escape order is correct (backslashes first, then quotes, then newlines)
  • Helper is internal (not exported) — clean encapsulation
  • Test helper mirrors production logic exactly
  • New tests cover all special character edge cases
  • No forbidden patterns used
  • Conventional commit style applied

Notes

  • npm start shows "Raw mode not supported" error — this is expected when running Ink TUI in a piped/non-TTY environment. Not a regression.

@avoidwork avoidwork merged commit abd1e05 into main Jun 20, 2026
2 checks passed
@avoidwork avoidwork deleted the feat/fix-yaml-frontmatter-escaping branch June 20, 2026 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant