Files
mp-ai-module-controller/AGENTS.md
T

102 lines
5.6 KiB
Markdown
Raw Normal View History

2026-07-21 11:10:20 -05:00
# AGENTS.md
## Project
2026-07-21 11:25:45 -05:00
`mp-ai-module-controller` is a Rust CLI scaffold for local llama.cpp-driven action dispatch. It starts a local `llama-server`, generates verbose and compact action dictionaries for small-model training/runtime lookup, queries the server through its OpenAI-compatible chat endpoint, and dispatches exact-match Rust scripts.
2026-07-21 11:10:20 -05:00
## Commands
- Build: `cargo build`
- Test: `cargo test`
- Generate dictionary: `cargo run -- dictionary generate`
- Start llama.cpp: `cargo run -- serve`
- Query local model: `cargo run -- query "log hello from codex"`
- Direct proof-of-concept dispatch: `cargo run -- run logger --payload '{"message":"hello from codex"}'`
2026-07-21 11:38:11 -05:00
- Direct math dispatch: `cargo run -- run calculate --payload '{"expression":"2 + 2 * 3"}'`
- Direct text dispatch: `cargo run -- run to_slug --payload '{"text":"Hello, World!"}'`
- Direct file dispatch: `cargo run -- run write_note --payload '{"filename":"hello.txt","content":"hello"}'`
2026-07-21 11:10:20 -05:00
- Codex setup: `scripts/codex-setup.sh`
- Codex logger smoke test: `scripts/codex-run-logger.sh`
- Precommit/CI check: `scripts/precommit-check.sh`
2026-07-21 11:13:54 -05:00
- Codex environment: `.codex/environments/environment.toml`
2026-07-21 13:14:52 -05:00
- Training data dry run: `python3 scripts/generate_training_data.py --dry-run`
- Local training data bridge: `python3 scripts/generate_training_data.py`
2026-07-22 09:13:54 -05:00
- Deploy training data to Zoe: `scripts/deploy_training_data.sh`
2026-07-21 11:10:20 -05:00
## Environment
Configuration is read from environment variables:
- `LLAMA_MODEL_PATH`: required GGUF model path for `cargo run -- serve`.
- `LLAMA_HOST`: llama.cpp host. Default: `127.0.0.1`.
- `LLAMA_PORT`: llama.cpp port. Default: `8080`.
- `LLAMA_CONTEXT_SIZE`: optional value passed as `--ctx-size`.
- `LLAMA_EXTRA_ARGS`: optional shell-split arguments appended to `llama-server`.
- `CONTROLLER_LOG_LEVEL`: tracing log level. Default: `info`.
Use `.env` for local values and keep it out of git. Update `.env.example`, `README.md`, `manifest.llm.json`, and `llm.txt` when environment variables or commands change.
## Dictionary Rules
2026-07-21 11:25:45 -05:00
- `src/registry.rs` is the source of truth for executable action definitions.
- `dictionary/static-base.json` is the tracked static compact-code base. Change it only when the compact protocol changes.
- `dictionary/actions.jsonl` is generated canonical verbose training/action data.
- `dictionary/actions.index.json` is the generated verbose runtime lookup file.
- `dictionary/model.codebook.json` is the generated model-facing compact codebook.
- `dictionary/model.examples.jsonl` is generated template/example data for future synthetic-data tooling.
2026-07-21 11:38:11 -05:00
- Registered action suites are Math & Conversion, Text Utilities, File Operations, and Logger.
2026-07-21 11:10:20 -05:00
- Regenerate dictionary files with `cargo run -- dictionary generate` after changing registered actions.
- Do not manually edit generated dictionary files.
2026-07-21 11:25:45 -05:00
- Generated metadata includes `dictionary_version`, `registry_checksum`, `static_base_checksum`, and `codebook_checksum`.
2026-07-21 11:10:20 -05:00
2026-07-21 13:14:52 -05:00
## SDG Bridge Rules
- `SDG_BRIDGE_PLAN.md` documents the local-to-Data-Designer bridge design.
- `scripts/generate_training_data.py` reads generated dictionary artifacts and produces instruction-format seed datasets.
2026-07-22 09:13:54 -05:00
- Default output is `/Volumes/Zoe/custom-local-llm/training-data/module_controller_intents_<unix_ts>/`.
- Default manifest patch target is `/Volumes/Zoe/custom-local-llm/manifest.llm.json`.
- `/Volumes/Zoe/custom-local-llm` has its own `README.md`, `AGENTS.md`, `manifest.llm.json`, and `llm.txt`.
2026-07-21 13:14:52 -05:00
- Use `--dry-run` for validation; it must not write output data or patch manifests.
- Mimir/Data Designer expansion only runs when `--sdg-host`, `--sdg-user`, and `--sdg-key` are all provided.
- Do not start or restart Mimir llama.cpp/Keiro from this bridge.
- If Mimir expansion fails, the bridge keeps the local seed dataset, writes `SDG_ERROR.txt`, patches the manifest with `generated_local_remote_failed`, and exits non-zero.
2026-07-22 09:13:54 -05:00
- Woodpecker deploys training data on main-branch pushes with `scripts/deploy_training_data.sh`.
2026-07-21 13:14:52 -05:00
2026-07-21 11:10:20 -05:00
## Dispatch Rules
- Dispatch only exact `action_id` values present in `dictionary/actions.index.json`.
2026-07-21 11:25:45 -05:00
- Compact model outputs must include matching `v` and `c` values from `dictionary/model.codebook.json` before expansion.
2026-07-21 11:10:20 -05:00
- Aliases and intent examples are training hints only; they are not executable ids.
- Unknown, malformed, ambiguous, missing, or empty action ids must be rejected without running scripts.
- Script processes are detached. The controller spawns them and does not monitor completion.
- Keep script payload validation strict and local to the script module.
2026-07-21 11:38:11 -05:00
- File operation scripts must remain confined to project-local `notes/` paths and reject absolute paths or path traversal.
2026-07-21 11:10:20 -05:00
## Generated Paths
- `target/`
- `logs/`
- `runtime/`
2026-07-21 11:38:11 -05:00
- `notes/`
2026-07-21 11:10:20 -05:00
- `dictionary/actions.jsonl`
- `dictionary/actions.index.json`
2026-07-21 11:25:45 -05:00
- `dictionary/model.codebook.json`
- `dictionary/model.examples.jsonl`
2026-07-21 11:10:20 -05:00
## CI And Hooks
2026-07-21 11:13:54 -05:00
- Codex environment actions live at `.codex/environments/environment.toml`.
2026-07-21 11:10:20 -05:00
- Gitea Actions workflow lives at `.gitea/workflows/ci.yml`.
- Woodpecker workflow lives at `.woodpecker.yml`.
- The committed pre-commit hook lives at `.githooks/pre-commit`.
- Configure local hooks with `git config core.hooksPath .githooks`.
2026-07-21 11:25:45 -05:00
- All CI and pre-commit checks should call `scripts/precommit-check.sh` so full dictionary generation stays validated consistently.
2026-07-21 11:10:20 -05:00
## Coding Guidelines
- Keep the CLI Rust-first and small.
- Prefer adding scripts under `src/scripts/` and registering them in `src/registry.rs`.
- Add focused tests for parsing, dictionary generation, action lookup, and payload validation.
2026-07-21 13:14:52 -05:00
- Add stdlib Python tests for bridge behavior in `tests/` when changing `scripts/generate_training_data.py`.
2026-07-21 11:10:20 -05:00
- Run `cargo test` before handing off code changes.