-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Problem Description
The -w:code flag is designed to extract raw source code by instructing the AI to omit Markdown fences (```). However, when a response is long enough to trigger the auto-continue mechanism, the extraction often fails in subsequent chunks.
Root Causes
- Instruction Loss: While the initial prompt contains the CODE_ONLY_SUFFIX, the subsequent "continue" prompts (generated by _make_continue_prompt) do not carry the same strict "no-fence" constraints. The AI often reverts to its default Markdown behavior for the second or third chunk.
- Markdown Triggering: The current "continue" prompt uses triple backticks to wrap the "tail" of the previous message for alignment. This inadvertently signals the AI to continue using Markdown formatting in its reply.
Proposed Solution
-
Enhance
CODE_ONLY_SUFFIX
Update the suffix to explicitly define the scope as the "entire request," including all continuation chunks. -
Mode-Aware Continuation Prompts
Update_make_continue_promptto accept amodeargument. Whenmode="code", the function will inject strict formatting rules into every continuation request:
- Force "Code Only" output.
- Explicitly forbid Markdown fences (``` or
~~~). - Prevent any explanatory text or greetings in the middle of the code stream.
- Replace Context Delimiters
Avoid using backticks to present the "tail" to the AI. Instead, use custom delimiters (e.g.,<<<TAIL_START) to prevent the model from entering "Markdown mode."
Implementation Plan
- Modify
CODE_ONLY_SUFFIXconstant. - Update
_make_continue_prompt(tail, mode="raw")signature and logic. - Update all
AIEngine.askimplementations to pass the currentmodeto the continuation helper. - Verify that multi-chunk code generation results in a single, seamless, fence-less file.
Expected Outcome
Files saved with -w:code will contain pure source code even if the generation requires multiple API rounds, eliminating the need for manual cleanup of Markdown tags in the middle of files.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels