feat: customise default system prompts #5

Merged
hegdeatri merged 12 commits from feature/custom-system-prompts into master 2026-05-18 23:44:42 +01:00
Owner

Summary

  • Six prompt slots (3 main per AgentMode + summarization + extend + title) now overridable from a new Behavior subtab UI; persisted in AppSettings.prompt_overrides.
  • GET /prompts/defaults returns rendered defaults for the editor pre-fill; POST /settings validates each slot (8 KB cap, CRLF → LF, strip \0, trim-to-None).
  • Telemetry tooltip surfaces "Using your custom Main · prompt" when the active mode's slot is overridden.
  • Layout fixes: Ctrl+1 / Ctrl+2 confined to chat view (disabled in settings); narrow-screen rule no longer hides the main pane in settings sections; all settings right panels removed and the indexer progress bar moved into the main Status card.

Spec & plan

  • Spec: docs/superpowers/specs/2026-05-18-custom-system-prompts-design.md
  • Plan: docs/superpowers/plans/2026-05-18-custom-system-prompts.md

Test plan

  • cargo test (101 passing, 15 new)
  • cargo clippy -D warnings
  • bun run lint
  • bun run build
  • Manual smoke test: edit Main · Normal → save → see sidebar dot + telemetry tooltip → reset
  • Manual: 8 KB cap rejection at the textarea
  • Manual: CRLF normalisation persists as LF
  • Manual: Indexer Reindex shows live progress bar in-pane
  • Manual: Behavior at narrow widths keeps both subtab sidebar and main pane visible
## Summary - Six prompt slots (3 main per AgentMode + summarization + extend + title) now overridable from a new Behavior subtab UI; persisted in `AppSettings.prompt_overrides`. - `GET /prompts/defaults` returns rendered defaults for the editor pre-fill; `POST /settings` validates each slot (8 KB cap, CRLF → LF, strip `\0`, trim-to-`None`). - Telemetry tooltip surfaces "Using your custom Main · <Mode> prompt" when the active mode's slot is overridden. - Layout fixes: Ctrl+1 / Ctrl+2 confined to chat view (disabled in settings); narrow-screen rule no longer hides the main pane in settings sections; all settings right panels removed and the indexer progress bar moved into the main Status card. ## Spec & plan - Spec: docs/superpowers/specs/2026-05-18-custom-system-prompts-design.md - Plan: docs/superpowers/plans/2026-05-18-custom-system-prompts.md ## Test plan - [x] cargo test (101 passing, 15 new) - [x] cargo clippy -D warnings - [x] bun run lint - [x] bun run build - [ ] Manual smoke test: edit Main · Normal → save → see sidebar dot + telemetry tooltip → reset - [ ] Manual: 8 KB cap rejection at the textarea - [ ] Manual: CRLF normalisation persists as LF - [ ] Manual: Indexer Reindex shows live progress bar in-pane - [ ] Manual: Behavior at narrow widths keeps both subtab sidebar and main pane visible
Six-slot prompt-override design (3 main per AgentMode + summarization +
extend + title), stored as Option<String> on AppSettings. Custom main
prompts replace the stable prefix while the volatile vault-context
suffix is auto-appended. Behavior section restructures to Indexer-style
subsection sidebar.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Nine-task plan covering: pre-refactor of default-prompt locations,
PromptOverrides + serde, build_system_prompt override arg + resolvers,
GET /prompts/defaults endpoint + settings POST validation, frontend
types/hooks, BehaviorSubtab shell state, Behavior subtab UI with
per-slot PromptEditor, telemetry tooltip indicator, end-to-end smoke
tests.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Rename SUMMARIZATION_SYSTEM_PROMPT and EXTEND_SUMMARIZATION_PROMPT to
DEFAULT_* form. Move TITLE_SYSTEM_PROMPT out of server::routes into
agent::prompts as DEFAULT_TITLE_SYSTEM_PROMPT so all four default
prompts live in one place. Extract default_stable_prefix so the main
prompt's stable portion is callable independently (used by the
upcoming GET /prompts/defaults endpoint). No behaviour change.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Six Option<String> slots: main_fast / main_normal / main_deep_research,
summarization, extend_summarization, title. All default to None, and
the field has #[serde(default)] so legacy settings.json files round-trip
cleanly. Settings stub in history.rs tests updated for the new field.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
build_system_prompt gains an Option<&str> override_prompt arg. When the
slot is non-empty/non-whitespace, it replaces the stable prefix while
the volatile suffix (date / schema / top tags / note count) still
auto-appends, preserving the cache-friendly prefix/suffix split.

New resolver functions summarization_prompt / extend_summarization_prompt
/ title_system_prompt borrow from &PromptOverrides and fall back to the
DEFAULT_* constants on None or whitespace-only. providers::create_chat_stream
picks the right main-slot per AgentMode; history::Compressor and
routes::title route through the resolvers.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
/prompts/defaults returns the rendered default stable prefix for each
of the three main slots plus the three default constants for the short
prompts. No volatile context, no DB read required — works even when no
vault is active. The UI uses this to show "Default - what runs if you
leave this empty" and to power the Copy-default-into-editor button.

POST /settings now normalises each prompt_overrides slot (CRLF -> LF,
strip \0, trim-empty -> None) and rejects slots over 8 KB with 400.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds the matching TypeScript types for the new backend PromptOverrides
struct, an EMPTY_PROMPT_OVERRIDES constant for safe defaults, and the
getPromptDefaults fetcher for the new endpoint. fetchSettings now
normalises raw.prompt_overrides to an empty object when the server
predates the field. New query-key prefix `prompts` with a defaults()
factory.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Behavior section restructures from .no-history flat scroll to an
Appearance-style subtab sidebar. The existing default-backend and
default-agent-mode controls move under a "Defaults" subtab; six new
subtabs each render a PromptEditor for one slot of PromptOverrides.

Editor surfaces: default-prompt preview (collapsible), monospace
textarea, byte counter against the 8 KB cap (warning at 7.5 KB, error
past 8 KB), Save / Reset / Copy-default buttons, "verbatim" warning
copy. The subtab sidebar shows a dot next to slots that currently have
an override.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Telemetry now accepts the current per-chat agentMode. When the active
main-prompt slot has an override set, the prompt-token chip tooltip
appends "Using your custom Main · <Mode> prompt" so the user can see
at a glance that the prompt feeding this turn isn't the built-in.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The narrow-screen layout was hiding the main content pane in Behavior
because the responsive rule .pkma-body:not(.no-history) .thread {display:
none} applied to every section, not just chat. Toggling Ctrl+1 also
hid the subtab sidebar in settings views, where it serves as navigation
rather than as a togglable column.

Changes:
- Add section-<name> class to .pkma-body so CSS can target chat vs
  non-chat layouts.
- Scope the responsive "hide thread when history visible" rule to
  .section-chat only. Non-chat narrow layouts now keep both the
  subtab sidebar and main pane side-by-side.
- Gate the Ctrl+1 / Ctrl+2 keyboard handler and toolbar buttons to
  chat view (disabled state + non-chat tooltip).
- Drop BehaviorRight - the panel only duplicated info already visible
  in the main pane and the subtab sidebar dot. Apply no-telemetry
  in Behavior so the freed column width goes to the main pane.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Remove VaultsRight, ModelsRight, IndexerRight, and AppearanceRight.
They duplicated info already in the main pane (or, in Appearance's
case, a preview that doesn't earn its own column on a desktop with
narrow widths). Non-chat sections now always apply no-telemetry,
giving the main pane the full width.

The IndexerRight progress bar moves into IndexerMain's Status card:
the live progress bar now appears under the phase line whenever a
run is active, so users can watch the index build without needing the
right column.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
hegdeatri merged commit 070461efd6 into master 2026-05-18 23:44:42 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
hegdeatri/pkma-rs!5
No description provided.