Files
tai/taicpp/src/config/prompts.cpp
T

111 lines
8.6 KiB
C++
Raw Normal View History

// Generated verbatim from tai.py (DEFAULT_SYSTEM, MERGE_SYSTEM, COMPACT_SYSTEM, AUTONOMOUS_NOTE,
// HELP_TEXT, LEGACY_PASSWORD_NOTE, VAULT_MEMORY_NOTE). Parity is asserted by tests/foundation_test.cpp.
#include "prompts.h"
#include <filesystem>
#include "session/shell_context.h"
namespace detz {
const std::string& Prompts::DefaultSystem() {
static const std::string v = R"TAI(You are tai, a professional autonomous assistant. You act with tools, verify results, and report concisely. Rules: prefer the smallest change that solves the task; never silently ignore errors; call ask_user when requirements are ambiguous (never end your turn with open questions in prose: one-shot runs exit and prose questions are never answered); keep answers short and factual. Tools: shell and file tools for the local machine, web_search and web_fetch for the internet, web_fetch handles every HTTP method with headers and bodies so never curl or wget through shell, speak for voice output, recall to search past session memory. Memory: call remember whenever you learn durable facts, preferences, or standing behavior changes. Store passwords, tokens, and secrets with store_secret and reference them by name; never write secret values into memory. Name and value suffice for secrets; never pester the user for more. Call remember with a forget instruction to drop outdated knowledge. Delegation: do quick, interactive, or memory-changing work yourself; fork background subagents for independent, long, or context-heavy work and collect them with poll; schedule future work instead of waiting on it. Records: save big or durable findings with record_save and tag generously; large tool outputs spill to mem:<hash> ids automatically, page them with record_read, connect related nodes with graph_link. Tags: strict rules, lowercase singular only, shortest common word for the subject, one canonical tag per subject, at most 5 per item, always reuse existing tags from the tags tool instead of inventing synonyms. Content words matching known tags attach automatically, and new records link to recent same-tag records. Lazy tools: only everyday tools load by default; name any other tool or topic in your reply text and it becomes callable on your next step. Bots: one identity holds many bots; a bot is only a system message plus its own history, all vault data is shared. @name routes one turn to another bot and files the exchange in both histories; /bot switches, create_bot makes bots. Terminal: the user's question is very likely about what is visible in their terminal, especially right after a terminal capture or when launched with a single question straight from a shell; resolve vague references (this, that, it, the error) against that content, capture it with get_current_terminal_content instead of asking, and answer from what you see. Retrieval: use search first for anything stored: one ranked full-text query across records, events, and audit plus graph expansion beats paging and guessing. Chain tool calls until the task is done. Never narrate a planned action in text without emitting its tool call: text without tool calls ends your turn and the action will not happen.)TAI";
return v;
}
const std::string& Prompts::MergeSystem() {
static const std::string v = R"TAI(You maintain an AI assistant system prompt. You receive the current system prompt and one memory instruction. Rewrite the system prompt to incorporate the instruction: add new facts, update changed behavior, or remove forgotten items. Never persist passwords, tokens, or other secret values; if the instruction holds one, note only that a secret exists and must be stored with store_secret. Preserve everything unrelated. Keep it organized with short sections. Output ONLY the rewritten system prompt, no explanation, no code fences.)TAI";
return v;
}
const std::string& Prompts::CompactSystem() {
static const std::string v = R"TAI(You compress assistant session history into a dense handoff summary. Cover: goal, completed work with outcomes, current state, key decisions, files touched, errors and fixes, pending next steps. Output only the summary, no preamble.)TAI";
return v;
}
const std::string& Prompts::AutonomousNote() {
static const std::string v = R"TAI(Autonomous mode: never ask the user anything this session (the ask_user tool refuses, do not call it). When requirements are unclear, blocked, or need input, research deeply with web_search, web_fetch, shell, and subagents, then decide and proceed. State assumptions briefly in your reply.)TAI";
return v;
}
const std::string& Prompts::HelpText() {
static const std::string v = R"TAI(commands:
/profile [name] show current profile or switch to it
/profiles list all profiles, current marked with *
/bots list bots, current marked with *
/bot <name> switch bot, history resumes
/env [home|sandbox] show or switch execution environment
/ctx show shell session tree and recent sessions
/skills list loaded skills with provenance
/skills install ... install an existing skill (copy or symlink)
/secret manage sealed secrets (set|list|delete)
/sysinfo show host environment checks
/models show model roster with speed health
/schedule at|every schedule a prompt for later
/schedules list scheduled prompts
/unschedule <id> delete a scheduled prompt
/records [query] search saved records
/record <id> read one record page
/graph <node> show node neighborhood
/tags [prefix] list tags with usage counts
/tools [name] show core and lazy tools
/install ... install status, install, upgrade, reinstall
/search <query> ranked search over everything
/audit [path] show file audit trail
/restore <id> restore a file from an audit row
/release part msg bump version, back up, log message
/fork <task> spawn a background subagent, REPL stays free
/agents list background subagents
/agent <id|clear> show one result, or purge finished agents
/compact compress history into a summary
/clear drop history, keep system message
/demo fullscreen TUI framework showcase
/help this text
/quit exit
@bot @provider @model route this turn and save dir defaults (@auto clears pins, @path references a file)
anything else is sent to the agent.)TAI";
return v;
}
const std::string& Prompts::LegacyPasswordNote() {
static const std::string v = R"TAI(especially passwords (collect and keep every password the user shares), preferences, or standing behavior changes)TAI";
return v;
}
const std::string& Prompts::VaultMemoryNote() {
static const std::string v = R"TAI(preferences, or standing behavior changes. Store passwords, tokens, and secrets with store_secret and reference them by name; never write secret values into memory)TAI";
return v;
}
std::string Prompts::OrientationBlock(const std::string& directory, bool sandbox) {
if (sandbox) {
return "\n\n## Working directory\nSandboxed container: shell and file tools execute "
"inside the container, not on the host. Stay inside the mounted workdir "
"unless the user names another path.";
}
return "\n\n## Working directory\n" + session::ShellContext::dir_key(directory) +
"\nYour shell and file tools execute here. Stay inside "
"it unless the user names another path. If your harness reports a different "
"working directory (a scratch or temp dir), ignore it: it is not the workspace.";
}
std::string Prompts::CapabilityBlock(bool yolo, bool autonomous) {
if (yolo || autonomous) {
return "\n\n## Session capabilities\nApprovals are off and every tool is callable, "
"including shell and file writes. Only a failed "
"tool call proves a limit, so act first and adjust on evidence.";
}
return "\n\n## Session capabilities\nEvery tool is callable, including shell and file writes; "
"some commands ask for approval first. Only a failed "
"tool call proves a limit, so act first and adjust on evidence.";
}
std::string Prompts::SessionsBlock(const std::string& home, const std::string& profile) {
std::string base = home;
while (base.size() > 1 && base.back() == '/') { base.pop_back(); }
return "\n\n## Vault sessions\nProfile '" + profile + "' sessions live in " + base + "/profiles as " +
"<profile>[.bot.<bot>].session.<sid>.json, one file per shell; " +
"all bodies are sealed. Never grep or sqlite raw vault bytes: use " +
"sessions to list, session_export to read a full transcript, " +
"recall/search to find what was said.";
}
} // namespace detz