//! The standing prompt a project's conversation is opened with. //! //! ONE template, rendered once when the conversation row is born //! (`cotton_tools::session_birth::ensure_conversation`) and carried on the row //! from then on, so the words a conversation was given are readable on the row //! rather than recomputed by whatever opens it next. //! //! **It tells the conversation its own row id**, and that is not decoration: a //! tool call carries no session identity — the MCP surface knows the workspace //! and the caller's scope and nothing about which session made the call — so a //! conversation opening a thread has to PASS its own id as //! `create_session { parentSessionId }`. The prompt is the only place it can //! learn it from. //! //! **Every verb it names is a real tool.** [`names_every_verb_it_relies_on`] //! in the tests below holds the sentence to the surface: a prompt that told a //! conversation to call something the catalogue does not have would be a //! session failing its first instruction. //! //! Plain software terms throughout ([product-language-must-be-plain-software-tool-terms-everywhere-us]): //! a conversation, threads, todos, records. The retired vocabulary is //! `crate::language::retired_terms`, and the MCP sweep //! (`cotton_tools::mcp::language_tests`) reads this text where it lands on the //! row. /// The MCP verbs the standing prompt tells a conversation to use. /// /// Declared here rather than only inside the prose so the test that holds the /// two together has something to walk, and so a verb renamed on the surface /// fails HERE by name rather than in a session six weeks later. pub const CONVERSATION_VERBS: [&str; 7] = [ "get_project", "recall", "search_records", "create_session", "create_todo", "get_session", "list_sessions", ]; /// The template, with `{slug}`, `{name}` and `{session_id}` to fill. /// /// A constant rather than a builder: the whole of what a conversation is told /// is readable in one place, and a change to it is a diff somebody can review /// as prose. pub const CONVERSATION_PROMPT_TEMPLATE: &str = "\ You are the standing conversation for the project {name} (slug: {slug}). Your \ own session row id is {session_id} — pass it as parentSessionId whenever you \ open a thread, so every thread you open hangs off this conversation. This database is your memory. Read it before you answer: get_project for what \ {slug} is and what is open on it, recall for what the owner has said, \ search_records for anything he mentioned without an id. A message from the owner is one of three things, and your job is to decide \ which: 1. Something to do now — open a thread with create_session { project: \ \"{slug}\", prompt: ..., parentSessionId: \"{session_id}\" }. Write the thread \ a prompt it can work from on its own, then tell the owner which thread you \ opened and what you asked it to do. 2. Something for later — create_todo, filed to {slug}. Say that you filed it. 3. A question — answer it from the database. Say where the answer came from. Keep yourself small. You are a conversation, not a worker: never edit code, \ run a build or read a diff in this session. Read a thread's summary with \ get_session and the list with list_sessions { parent: \"{session_id}\" }; when \ a thread is waiting on the owner, say so FIRST, before anything else you were \ going to report. Always name the thread you opened, by title and id. Answer in plain language — \ short sentences, no preamble."; /// The standing prompt for one project's conversation. /// /// `name` is the project's own name and `slug` the address every verb takes; /// `session_id` is the conversation's row, which the caller has already minted /// (it is derived from the project, so it is known before the row is written). #[must_use] pub fn conversation_prompt(slug: &str, name: &str, session_id: &str) -> String { CONVERSATION_PROMPT_TEMPLATE .replace("{name}", name) .replace("{slug}", slug) .replace("{session_id}", session_id) } /// What a conversation's row is TITLED — what a card and a list show. #[must_use] pub fn conversation_title(name: &str) -> String { format!("{name} — conversation") } #[cfg(test)] #[path = "conversation_prompt_tests.rs"] mod tests;