Add prompt editing support for task files - #493
Draft
tninja wants to merge 2 commits into
Draft
Conversation
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.
Summary
Task files are becoming the main place I write prompts, so this adds editing support aimed at that workflow:
@reference gating, outline navigation, long-form writing helpers, and reuse of prompts already written.The immediate motivation was that
@completion fired on every@character. Prompt files routinely contain pasted Java or Python, where@is an annotation, not a file reference, so pasting code triggered a blocking completion prompt repeatedly. A single guard,ai-code--prompt-reference-position-p, now decides:@must be outside any literal Org block and must begin a word. Both the capf path and thepost-self-insert-hookpath call that one guard, so they cannot drift apart. The explicitC-c @command deliberately bypasses it, so completion is still reachable inside a src block when you actually want it.Changes
org-in-src-block-p, so it also holds in non-org buffers); rejects@Overrideanduser@, accepts@at word start. Opts the mode out of helm'scompletion-in-regionvia helm's own supported option rather than advising helm internals, and enablescompany-capfbuffer-locally soglobal-company-modestays off.#+STARTUP: content; folding applies only to files under the task directory, so the globalorg-startup-foldedsetting is untouched.C-c bwraps a region in a block, and an opt-inai-code-prompt-writing-modefor visual wrapping. Display only; buffer text is never rewritten, so what gets sent to the agent is unchanged.All new keybindings are bound at load time rather than inside the mode body, so
describe-modelists them before the mode has been activated. Every soft dependency (helm, company, visual-fill-column, yasnippet) degrades silently when absent, with tests on the missing-dependency path.Verification
A gauntlet script (
test/run_ai_code_prompt_editing_gauntlet.sh) runs eight layers as fail-closed gates: 62 focused tests green, full suite at 1482 tests with the 13 pre-existing failures unchanged (names verified identical to baseline), byte compilation clean, checkdoc clean, 6/6 mutants killed by failing assertions, a negative control proving the guard tests actually bite, and real execution against a live task file in a real Emacs.Two findings worth flagging, both fixed: a
void-variableon helm's option aborted mode activation entirely and was caught only by the real-execution layer — the unit tests had been masking it — and one mutant initially "killed" the suite by making the file unloadable rather than by being detected, so the gauntlet now treats an incomplete run as a failure instead of evidence.Scope
Additive. No change to the backend send path, no new hard dependencies, and the existing snippets are untouched. The pre-existing
version<bug intest/test_00-bootstrap.elis out of scope; the gauntlet works around it with an isolatedpackage-user-dir.