PromptLibrary.h header

#include <ew/app/PromptLibrary.h>

Namespace ew::app

PromptCommand struct

struct ew::app::PromptCommand

A reusable AI command: a display name and the instruction applied to the user's text (e.g. "Tighten this prose", "List continuity risks in this scene"). Unlike a persona (which sets the assistant's voice, see PersonaStore), a command is a task the user invokes on a selection; it is applied by using its instruction as the rewrite instruction of an AiPrompts rewrite request, and can be run in batch across many objects or chained (see BatchAi).

Members

QString ew::app::PromptCommand::name

The command's display name.

QString ew::app::PromptCommand::instruction

The instruction applied to the user's text when the command is run.

bool operator==(const PromptCommand &, const PromptCommand &)=default

Commands compare equal when both fields match.

Functions

std::vector< PromptCommand > ew::app::builtInPromptCommands()

The prompt commands offered out of the box (tighten, fix grammar, summarize, list continuity risks, heighten tension), used when the user has not defined their own.

std::vector< PromptCommand > ew::app::loadPromptCommands(const Settings &settings)

Loads the user's saved commands from a Settings store; returns builtInPromptCommands() when none are saved or the stored value is malformed. Pure with respect to the store, so it is unit-testable with an in-memory Settings.

std::vector< PromptCommand > ew::app::loadPromptCommands(const Settings &settings, const ContributionRegistry &contributions)

The user's effective command list (loadPromptCommands(settings)) with every plugin-contributed command (contributions) that is not already present by name appended. Precedence: the user's saved commands override the built-ins (unchanged), and a user/built-in command shadows a plugin command of the same name – so a newly installed plugin's commands always appear without disturbing the user's customizations.

void ew::app::savePromptCommands(Settings &settings, const std::vector< PromptCommand > &commands)

Saves commands to settings (as a JSON array under the "ai/commands" key), replacing any existing list. Saving an empty list clears the key, so the built-ins return on the next load.