-
-
Notifications
You must be signed in to change notification settings - Fork 19
Yaml frontmatter fix #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
stefanstr
wants to merge
10
commits into
vasylenko:main
Choose a base branch
from
stefanstr:yaml-frontmatter-fix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Yaml frontmatter fix #111
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d86067b
feat(note-conventions): add parseFrontmatter and formatTagsAsInlineSy…
6b66bc0
test(note-conventions): add unit tests for parseFrontmatter and forma…
88b6951
feat(bear-create-note): auto-detect and preserve YAML frontmatter
a318830
feat(bear-add-tag): preserve frontmatter when adding tags
8878bf1
test(system): add frontmatter integration tests for create-note and a…
8bfc620
docs: add Frontmatter handling section to README and update CHANGELOG
0a21763
chore: add SUMMARY.md with diff overview, test results, and blockers
47aea56
chore: update progress and summary after API validation and commit split
0ddc394
Fix frontmatter tag placement
stefanstr bddd8cb
Remove stale API findings
stefanstr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # Progress: yaml-frontmatter-fix | ||
|
|
||
| ## Status: Complete | ||
|
|
||
| ## What was done | ||
|
|
||
| ### Task 1: API Validation (FINDINGS.md) | ||
| - Fetched official Bear x-callback-url docs | ||
| - Confirmed `mode=replace_all` is a documented, supported value for `/add-text` | ||
| - Confirmed `/replace-note` does not exist (BRIEF.md was mistaken about this alternative) | ||
| - No code changes required | ||
|
|
||
| ### Task 2: Commit split | ||
| - Commit 26fd648 (mixed bear-create-note + bear-add-tag changes) split into two atomic commits | ||
| - Note: TASK.md expected 3 commits from 26fd648, but the bear-urls.ts change was already in d86067b; the correct split yielded 2 commits from that mixed change | ||
| - Final branch structure: 8 commits on top of main, including this follow-up documentation refresh | ||
|
|
||
| ### Task 3: Documentation refresh | ||
| - SUMMARY.md updated with new commit SHAs, API validation result, resolved blockers | ||
| - PROGRESS.md updated (this file) | ||
|
|
||
| ## Remaining work (for PR author) | ||
| - Run system tests with Bear open: `npm run test:system` | ||
| - Manual verification: create a frontmatter note via MCP, add a tag, confirm structure in Bear | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| # Branch Summary: yaml-frontmatter-fix | ||
|
|
||
| ## What Changed | ||
|
|
||
| 8 commits on top of `main` (26fd648 was split into two atomic commits; see FINDINGS.md for why the expected 3-way split became 2 commits from that mixed change): | ||
|
|
||
| | SHA | Description | | ||
| |-----|-------------| | ||
| | d86067b | feat(note-conventions): add parseFrontmatter and formatTagsAsInlineSyntax helpers; add replace_all to BearUrlParams.mode | | ||
| | 6b66bc0 | test(note-conventions): add unit tests for parseFrontmatter and formatTagsAsInlineSyntax | | ||
| | 88b6951 | feat(bear-create-note): auto-detect and preserve YAML frontmatter | | ||
| | a318830 | feat(bear-add-tag): preserve frontmatter when adding tags | | ||
| | 8878bf1 | test(system): add frontmatter integration tests for create-note and add-tag | | ||
| | 8bfc620 | docs: add Frontmatter handling section to README and update CHANGELOG | | ||
| | 0a21763 | chore: add SUMMARY.md / PROGRESS.md | | ||
| | a76da24 | chore: update progress and summary after API validation and commit split | | ||
|
|
||
| ## Files Modified | ||
|
|
||
| - **`src/operations/note-conventions.ts`** — added `parseFrontmatter` and `formatTagsAsInlineSyntax`; refactored `applyNoteConventions` to use the extracted helper | ||
| - **`src/infra/bear-urls.ts`** — added `'replace_all'` to `BearUrlParams.mode` union type | ||
| - **`src/tools/note-tools.ts`** — Fix 1 (bear-create-note) and Fix 2 (bear-add-tag) | ||
| - **`src/operations/note-conventions.test.ts`** — 10 new unit tests for the two new helpers | ||
| - **`tests/system/frontmatter.test.ts`** — new integration test suite (4 tests, requires Bear) | ||
| - **`README.md`** — new "Frontmatter Handling" section under Configuration | ||
| - **`CHANGELOG.md`** — [Unreleased] entries for both fixes | ||
|
|
||
| ## Fix 1: bear-create-note | ||
|
|
||
| When `text` starts with `---\n…\n---`, the handler now: | ||
| 1. Parses the frontmatter block using `parseFrontmatter` | ||
| 2. Assembles the note as `frontmatter → # title → #tag line → body` (joined with `\n`) | ||
| 3. Passes the assembled string as `text` only — no separate `title` or `tags` URL params — so Bear uses the H1 as the title and does not insert anything outside the frontmatter block | ||
|
|
||
| Backward compat: if no frontmatter is detected, the original code path runs unchanged. | ||
|
|
||
| ## Fix 2: bear-add-tag | ||
|
|
||
| When the existing note text (read from SQLite) starts with `---\n`, the handler: | ||
| 1. Parses the frontmatter block | ||
| 2. Builds a new full-note text: `frontmatter\n<tag line>\n<body>` | ||
| 3. Writes it back using `add-text?mode=replace_all` (replaces entire note content) | ||
|
|
||
| When no frontmatter: original `mode=prepend` + `tags` URL param, unchanged. | ||
|
|
||
| ## API Validation (Task 1) | ||
|
|
||
| `mode=replace_all` is **officially documented** in the Bear x-callback-url docs. The original concern in TASK.md was unfounded — no redesign is needed. See FINDINGS.md for the full verification. | ||
|
|
||
| The `/replace-note` endpoint mentioned in BRIEF.md as an alternative does not exist in the Bear API. | ||
|
|
||
| ## Test Results | ||
|
|
||
| ``` | ||
| Unit tests: 47 passed / 0 failed (includes 10 new parseFrontmatter/formatTagsAsInlineSyntax tests) | ||
| Build: tsc clean, 0 errors | ||
| Integration: tests/system/frontmatter.test.ts — NOT run (requires Bear app running) | ||
| ``` | ||
|
|
||
| ## Blockers / Open Questions | ||
|
|
||
| 1. **ZTEXT storage format**: the implementation assumes that for notes created with frontmatter (via Fix 1), Bear stores ZTEXT starting with `---` (i.e., Bear does not prepend a `# Title` line automatically). This needs system test validation. | ||
|
|
||
| 2. **Note title after replace_all**: the Bear docs don't specify whether `replace_all` updates ZTITLE from the first H1. If it doesn't, the SQLite title remains unchanged (which is fine — the title hasn't changed). Either way, the operation is safe. | ||
|
|
||
| ## Suggested PR Description | ||
|
|
||
| ### Summary | ||
| - `bear-create-note`: auto-detects YAML frontmatter (`---`…`---` at start of `text`) and assembles the note content so frontmatter, title (H1), and tags appear in the right order without Bear interfering | ||
| - `bear-add-tag`: detects frontmatter in the existing note text and inserts new tags immediately after the closing `---` instead of clobbering it with a blind prepend | ||
| - `mode=replace_all` is an officially documented Bear API parameter — verified against the Bear x-callback-url documentation | ||
| - Backward compatible: notes without frontmatter follow the exact same code paths as before | ||
|
|
||
| ### Test plan | ||
| - [x] All 47 unit tests pass (`npm test`) | ||
| - [x] TypeScript build clean (`npm run build`) | ||
| - [ ] Run `npm run test:system` with Bear open to validate integration tests in `tests/system/frontmatter.test.ts` | ||
| - [ ] Manually verify a note created with frontmatter shows the correct structure in Bear | ||
| - [ ] Manually verify `bear-add-tag` on a frontmatter note places tags after the `---` block | ||
|
vasylenko marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PROGRESS.md is tracking branch-specific execution status and references internal task artifacts (e.g., FINDINGS.md) that aren’t present in the repo. This kind of progress log tends to go stale quickly once merged; consider removing it from the repository root or relocating it to a more appropriate place (e.g., PR description or contributor docs) if you want to preserve the narrative.