fix: make /rewrite preserve formatting, structure, and verbatim content#207
Merged
Conversation
Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>
Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Overview
/rewritewas destroying the structure of anything it touched. Pasting a Markdown message (a bold header, a bulleted list of links, a relayed blockquote) and running/rewritereturned a single flattened prose paragraph: the list collapsed into a sentence, the blockquote and its>were stripped, and@mentionswere dropped. The root cause was a prompt rule,"No markdown, bullets, or decorative icons,"that told the model to remove every bit of formatting the user wrote.This makes
/rewriteformat-preserving: it mirrors whatever formatting the input has and only improves the prose inside it.How it works
The
/rewriteprompt template is reworked around a single principle: mirror the original's formatting, change only the wording.>), fenced and inline code, raw URLs, link targets,@mentions, and#channelsare reproduced character for character. The wording inside a quote or code block is not changed at all.The rule list was also consolidated (eleven rules down to seven) to cut redundancy, which matters because Thuki targets small local models that follow a dense, focused prompt more reliably than a long one. Two worked examples were added covering the exact failure modes (a Markdown link list and a relayed blockquote), and one redundant example was removed. The user-facing behavior text and generated docs are updated to match.
/refineis intentionally left unchanged.Testing
/rewriteprompt carries the format-mirroring and verbatim-zone instructions, preserves@mentions/#channels, and no longer contains the old Markdown-stripping rule.Note: this is a prompt-level guarantee rather than deterministic post-processing, so on a small model it is high-reliability rather than absolute. A deterministic parse-and-restitch approach was considered and rejected because it cannot preserve a quote's position or a list's structure without reimplementing a Markdown round-tripper, and it would strip the surrounding context the model needs to rewrite well.