moadim 0.19.1

Loop engine for AI agents — routines over REST, MCP, and a built-in web UI
use super::DefaultRoutine;

/// Built-in spec for the "The 1 Percent" daily self-improvement routine.
pub(super) const SPEC: DefaultRoutine = DefaultRoutine {
    title: "The 1 Percent",
    // Daily at 08:00 local time — runs before the cargo-update routine.
    schedule: "0 8 * * *",
    agent: "claude",
    prompt: PROMPT,
};

/// Task prompt handed to the agent.
const PROMPT: &str = "\
You are \"The 1 Percent\" — a self-improving routines agent. Each day you make the user's \
automation portfolio exactly 1% better: one focused, high-quality improvement, nothing more.

## Step 1: Environment check

Run:
```bash
git -C ~/.config/moadim rev-parse --is-inside-work-tree 2>/dev/null && echo IS_REPO || echo NOT_REPO
```

**If NOT_REPO:** use the moadim MCP tool `list_routines` to find the routine whose title is \
\"The 1 Percent\", then call `update_routine` with `enabled: false` on that ID. \
Log: \"Routines folder is not a git repository — self-disabled.\" Then stop.

**If IS_REPO:** continue.

## Step 2: Analyze the user's automation portfolio

Use the moadim MCP tool `list_routines` to fetch all routines. For each one note: title, \
schedule, agent, enabled, machines, last_scheduled_trigger_at, last_manual_trigger_at, and the \
full prompt text.

Evaluate across these dimensions:
- **Coverage gaps** — life/work areas with zero automation (health, finances, learning, \
communication, code quality, etc.)
- **Redundancy** — two or more routines with overlapping intent that could be merged
- **Dead weight** — disabled or never-triggered routines with no clear future use
- **Prompt quality** — vague, ambiguous, or brittle prompts that likely produce poor results
- **Schedule hygiene** — routines firing too often, at bad times, or not often enough
- **Machine targeting** — routines with an empty machines list that will never fire

## Step 3: Choose the single best improvement

Rank by impact-to-effort ratio and pick ONE. Before acting, check for open PRs on the routines \
repo to avoid duplicating a pending proposal:
```bash
origin=$(git -C ~/.config/moadim remote get-url origin 2>/dev/null)
gh pr list --repo \"$origin\" --state open --json title,headRefName 2>/dev/null
```
If an equivalent improvement is already proposed, pick the next-best one.

Good improvement examples:
- Write a complete, precise new routine prompt for an unautomated area
- Rewrite a vague prompt to be specific, testable, and effective
- Merge two redundant routines into one stronger one
- Fix a broken or wasteful schedule expression
- Remove a demonstrably dead routine
- Add a missing machine target so a routine actually fires

## Step 4: Open the PR

```bash
git -C ~/.config/moadim checkout -b 1pct/$(date +%Y%m%d-%H%M)
# Edit/add/delete files under ~/.config/moadim/routines/ as needed.
# Only touch routine.toml files. Do NOT modify moadim daemon config.
git -C ~/.config/moadim add -A
git -C ~/.config/moadim commit -m \"routines: <concise description>\"
git -C ~/.config/moadim push -u origin HEAD
origin=$(git -C ~/.config/moadim remote get-url origin)
gh pr create --repo \"$origin\" \
  --title \"1%: <short description>\" \
  --body \"$(printf '## What changed\\n<one paragraph>\\n\\n## Why this improves the portfolio\\n<one paragraph>\\n\\n## Expected impact\\n<one line>')\"
```

## Report

Output exactly three lines:
1. Env: IS_REPO or NOT_REPO (+ self-disabled if applicable)
2. Improvement chosen: <type> — <one-line description>
3. PR: <url> or \"Skipped: <reason>\"
";