AGENTS.md@skills/servosity ยท diff
git:20260606.f01c33b to git:20260817.85150e7
21 added, 5 removed. Audit A to A.
# Servosity Printed CLI Agent Guide
This directory is a generated `servosity-cli` printed CLI. It was produced by [CLI Printing Press](https://github.com/mvanhorn/cli-printing-press), so treat systemic fixes as upstream Printing Press fixes first. Keep local edits narrow and document why a generated-tree patch belongs here.
## Local Operating Contract
Start by asking the generated CLI for current runtime truth:
```bash
servosity-cli doctor --json
servosity-cli agent-context --pretty
```
Use runtime discovery instead of relying on a copied command list:
```bash
servosity-cli which "<capability>" --json
servosity-cli <command> --help
```
- Add `--agent` to command invocations for JSON, compact output, non-interactive defaults, no color, and confirmation-safe scripting:
+ Add `--agent` to command invocations for JSON, compact output, non-interactive defaults, and no color:
```bash
servosity-cli <command> --agent
```
Before running an unfamiliar command that may mutate remote state, inspect its help and prefer a dry run:
```bash
servosity-cli <command> --help
servosity-cli <command> --dry-run --agent
```
- Use `--yes --no-input` only after the target, arguments, and side effects are clear.
+ When a command requires confirmation, pass `--yes` explicitly only after the target, arguments, and side effects are clear. `--agent` does not imply `--yes`.
+ ## Self-Learning Loop
+
+ This CLI ships a self-capturing teach/recall loop backed by the local SQLite store. The CLI journals every invocation, derives `flag_alias` candidates from failed-flag + corrected-retry pairs, and synthesizes a playbook candidate when a family is taught without one - no manual failure bookkeeping. The agent's role is judgment:
+
+ 1. On a new user question, call `servosity-cli recall "<question>" --agent` FIRST. If `found=true` and the top result has `entity_match == "exact"` and `confidence >= 2`, skip discovery and go straight to the live fetch for the returned resource IDs. If the store is cold (recall finds nothing and `learnings list` and `learnings candidates` are both empty), skip recall for the rest of the session.
+ 2. When the envelope carries a `candidates` section (warning `candidates_present`), candidates are try-then-confirm, never facts: follow each candidate's two-step `next_action` verbatim (trial command first, then `learnings confirm <id>` only after the trial verified the behavior), and reject wrong ones with `learnings reject <id>`. Never re-teach something recall surfaced as a candidate; confirm or reject it instead.
+ 3. After answering, always fire `servosity-cli teach --query "<question>" --resource <id> --resource-type <type> &` in the background - teaching is unconditional and is the anchor that triggers playbook synthesis. Teach the structural question with identifiers stripped (no names, emails, phone numbers, account ids); the CLI warns on obvious PII shapes but does not block.
+ 4. Use `learnings list` to inspect taught rows, `learnings forget "<question>"` to undo a bad teach, `learnings candidates` for the full open candidate set, and `learnings stats` for the loop's local metrics. `teach-pattern` and `teach-lookup` install manual generalization rules when one teach should cover a whole family.
+ 5. If `learnings confirm` is an unknown command, you are driving an older binary - ignore the candidates guidance and keep the rest of the flow.
+
+ Annotations: `recall`, `learnings list`, `learnings candidates`, and `learnings stats` carry `mcp:read-only=true`; `teach`, `teach-playbook`, `playbook amend`, `learnings confirm`, `teach-pattern`, and `teach-lookup` carry `mcp:local-write=true` (writes land only in the CLI's own local store); `learnings forget` and `learnings reject` keep honest may-write/destructive defaults.
+
+ Measurement is local-only: the `learn_events` table and `learnings stats`; nothing leaves this machine. Judge the loop on recall hit rate and teach-to-reuse at a minimum denominator of 50+ recall events. An empty or thin events table means insufficient adoption, not failure.
+
+ The store's schema stamp is one-way: once a binary carrying the self-learning tables opens the database, an older `servosity-cli` refuses it. Keep the CLI and the MCP server on the same version.
+
+ Disable the loop with `--no-learn` per-invocation or `SERVOSITY_MSP_NO_LEARN=true` for the whole session - useful for deterministic agent flows that don't want a learning row to silently change subsequent query results.
+
For install, auth, examples, and longer product guidance, read `README.md` and `SKILL.md`. This file intentionally stays small so repo-local agents get invariant local guidance without duplicating the generated docs.
## Local Customizations
- This directory is **generated output** -- a fresh print can overwrite the whole tree, so ad-hoc hand-edits don't survive on their own. If you modify the generated code, record each change under `.printing-press-patches/` (parallel to `.printing-press.json`) so a regen carries the intent forward instead of silently dropping it.
-
- The entry shape, and the altitude to write it at -- a durable reprint-guard, not a changelog -- live in the source catalog's `AGENTS.md`, which is the single source of truth; this guide intentionally doesn't duplicate them.
+ This directory is **generated output** -- a fresh print can overwrite the whole tree, so ad-hoc hand-edits don't survive on their own. If you modify the generated code, record each change in `handfixes.json` so the reprint gate (`tools/maintainer/check_handfixes.py`) fails loudly instead of letting a regen silently drop the intent. See [`docs/reprint-survival.md`](../../docs/reprint-survival.md).