Skip to content

Unify prompt suffix injection with ordered providers#441

Open
tninja wants to merge 6 commits into
mainfrom
feature/prompt-suffix-providers
Open

Unify prompt suffix injection with ordered providers#441
tninja wants to merge 6 commits into
mainfrom
feature/prompt-suffix-providers

Conversation

@tninja

@tninja tninja commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add an ordered ai-code-prompt-suffix-functions provider pipeline with a shared prompt context and memoized classification.
  • Migrate the custom suffix, Grill, auto-test/TDD, and discussion follow-up behaviors to providers in a deterministic order.
  • Preserve Grill command origin, fail closed on provider errors, and remove legacy advice during hot reloads.

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-suffix switch 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

  • Full ERT suite: 1059 tests, 1046 expected, 0 unexpected, 13 optional-dependency skips.
  • Focused prompt-mode, Grill, and harness suite: 143/143 passed.
  • Touched production files byte-compiled successfully with no new warnings.
  • Checkdoc reported no new warnings in touched files.
  • All six touched source/test files are clean versus the diagnostics baseline.
  • git diff --check passed.
  • Independent code review found no remaining Critical, Important, or Minor issues.

@tninja tninja requested a review from Copilot July 16, 2026 02:40
@tninja tninja marked this pull request as ready for review July 16, 2026 02:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-functions as an ordered provider hook, with a shared ai-code-prompt-context and 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants