Unify prompt suffix injection with ordered providers#441
Open
tninja wants to merge 6 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors prompt suffix injection into a single, deterministic “provider pipeline” that runs at the send boundary, so feature-specific suffix behaviors (custom suffix, Grill, auto-test/TDD, discussion follow-up) no longer rely on scattered inline logic or long-lived advice.
Changes:
- Introduces
ai-code-prompt-suffix-functionsas an ordered provider hook, with a sharedai-code-prompt-contextand memoized per-prompt classification. - Migrates Grill and harness send-time suffix logic to providers (and removes legacy advice on reload to prevent duplicate behavior in long-lived sessions).
- Adds targeted ERT coverage for provider ordering, memoization semantics (including caching nil), fail-closed behavior, and reload/idempotency concerns.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
ai-code-prompt-mode.el |
Adds the prompt context + ordered suffix provider pipeline and applies it at the ai-code--write-prompt-to-file-and-send boundary via :filter-args. |
ai-code-grill.el |
Replaces prompt-transform advice with a Grill suffix provider, while preserving “origin command” tracking via advice on entry commands. |
ai-code-harness.el |
Moves auto-test and discussion follow-up suffix routing into providers sharing memoized classification; removes legacy around-advice if present. |
test/test_ai-code-prompt-mode.el |
Adds tests for provider order, memoization caching of nil, switch-respecting custom provider behavior, and provider error abort semantics. |
test/test_ai-code-harness.el |
Adds integration-style tests for built-in provider ordering, reload cleanup of legacy advice, Grill independence from the legacy switch, and shared classification. |
test/test_ai-code-grill.el |
Updates Grill tests to validate provider-based behavior and reload cleanup, and keeps direct-command bypass verified via insertion path. |
docs/superpowers/plans/2026-07-15-prompt-suffix-providers.md |
Adds an implementation plan document capturing the intended architecture and verification steps. |
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
ai-code-prompt-suffix-functionsprovider pipeline with a shared prompt context and memoized classification.Why
Prompt suffixes were injected through a mix of inline logic and feature-specific advice. That made ordering implicit, coupled unrelated features, and made future suffix extensions harder to add safely.
Impact
Normal prompt sends now pass through one extensible suffix boundary. Single-token slash commands and raw resend paths continue to bypass suffix providers. The legacy
ai-code-use-prompt-suffixswitch controls the custom, auto-test, and follow-up providers without disabling Grill.Root cause
Suffix ownership was distributed across
ai-code-prompt-mode.el, Grill advice, and harness advice. Long-lived Emacs sessions could also retain the old advice after an upgrade, causing duplicate prompts or classification.Validation
git diff --checkpassed.