use super::shell_quote;
const MOADIM_SYSTEM_PROMPT: &str = "# Moadim Context\\n\
\\n\
> This section is managed by the moadim daemon. Do not edit it.\\n\
\\n\
You are running inside a moadim-managed agent session. \
Complete the task described in `prompt.md` and exit when done.\\n\
\\n\
## Work log\\n\
\\n\
As you work, append short progress notes to `summary.md` in this workbench (create it if \
it doesn't exist) — what you're doing and why, each time you start a new step. Before you \
exit, write a `## Final summary` section to `summary.md` describing what was accomplished, \
what changed, and anything left unresolved.";
const MOADIM_DISCLOSURE: &str = "## Routine origin disclosure\\n\
\\n\
You act on behalf of the moadim routine named below. In every external, outward-facing \
communication you produce — GitHub issues, pull requests and comments; Slack messages; emails; \
any channel a human or third-party system receives — you MUST disclose that the action \
originates from this moadim routine, naming it (for example: 'This pull request was opened by \
the <routine name> routine of moadim.'). Phrasing may be adapted per channel but must \
include the routine name. This does NOT apply to internal logs or in-repo working files.\\n\
\\n\
Routine name: ";
pub(crate) fn system_prompt_stmts(
user_prompt_path: &str,
routine_title: &str,
instructions_file: &str,
) -> Vec<String> {
let header = shell_quote(MOADIM_SYSTEM_PROMPT);
let disclosure = shell_quote(MOADIM_DISCLOSURE);
let title = shell_quote(routine_title);
let uq = shell_quote(user_prompt_path);
let dest = format!(r#""$WB/{instructions_file}""#);
vec![
format!(
r#"printf '%b\n\n%b%s\n\n**Run date**: %s\n**Timezone**: %s\n' {} {} {} "$(date)" "$(date +%Z)" > {dest} || {{ echo "moadim: failed to write agent instructions disclosure; aborting launch" | tee -a "$WB/agent.log" >&2; exit 1; }}"#,
header, disclosure, title
),
format!(
r"[ -f {uq} ] && {{ printf '\n---\n\n'; cat {uq}; printf '\n'; }} >> {dest} || true",
uq = uq
),
]
}