Problem
polira.config.ts accepts markdown.preserveFrontmatterOrder: true (default) as a documented configuration option (src/core/config.ts:47). However, src/utils/frontmatter.ts:29 calls matter.stringify(body, frontmatter) with no key-ordering logic.
gray-matter's stringify does not guarantee key order; it serialises frontmatter as a plain object, so existing frontmatter field order is not preserved when updateFrontmatterTool writes changes.
Expected behaviour
When preserveFrontmatterOrder: true (the default), stringifyFrontmatter should reconstruct the YAML block with original key order intact, inserting new fields at the end.
When preserveFrontmatterOrder: false, the current behaviour (arbitrary serialisation order) is acceptable.
Files affected
src/utils/frontmatter.ts — stringifyFrontmatter function
src/tools/update-frontmatter/updateFrontmatterTool.ts
src/core/config.ts — config schema entry
Suggestion
Preserve the original key order by building the updated frontmatter object with original keys first, then appending new keys. Pass that ordered object to matter.stringify.
Problem
polira.config.tsacceptsmarkdown.preserveFrontmatterOrder: true(default) as a documented configuration option (src/core/config.ts:47). However,src/utils/frontmatter.ts:29callsmatter.stringify(body, frontmatter)with no key-ordering logic.gray-matter'sstringifydoes not guarantee key order; it serialisesfrontmatteras a plain object, so existing frontmatter field order is not preserved whenupdateFrontmatterToolwrites changes.Expected behaviour
When
preserveFrontmatterOrder: true(the default),stringifyFrontmattershould reconstruct the YAML block with original key order intact, inserting new fields at the end.When
preserveFrontmatterOrder: false, the current behaviour (arbitrary serialisation order) is acceptable.Files affected
src/utils/frontmatter.ts—stringifyFrontmatterfunctionsrc/tools/update-frontmatter/updateFrontmatterTool.tssrc/core/config.ts— config schema entrySuggestion
Preserve the original key order by building the updated frontmatter object with original keys first, then appending new keys. Pass that ordered object to
matter.stringify.