Skip to content

Latest commit

 

History

History
121 lines (85 loc) · 3.51 KB

usage.md

File metadata and controls

121 lines (85 loc) · 3.51 KB

Usage

Walkthrough

In about ten minutes you'll start the stack, preview a change, apply it, inspect the audit log and undo it. You need Docker with Compose v2 and about 4 GB of free RAM. An NVIDIA GPU is optional but makes requests about 10× faster.

1. Start the stack

cp .env.example .env
docker compose up -d

The first start pulls qwen2.5:3b (about 2 GB). Wait until the assistant is healthy:

curl -s localhost:7000/health
# {"status":"healthy","circuit_breaker":"closed"}

2. Preview a change

alias ppatch="python3 $(pwd)/cli/ppatch.py"
ppatch "lower the orders cpu limit to 80%"
app: orders
  ~ /workload/container/resources/cpu/limitMilliCPU: 500 → 400
preview only, re-run with --apply to save

Nothing is saved yet. The model returned "80%" and code computed 80% of 500.

3. Apply it

ppatch "lower the orders cpu limit to 80%" --apply

The output is the same diff, followed by saved as revision #1.

4. Read the audit log

ppatch history orders
#1  2026-11-23T10:15:02+00:00  you  lower the orders cpu limit to 80%
  ~ /workload/container/resources/cpu/limitMilliCPU = 400

5. Undo it

ppatch undo orders
reverted #1 as revision #2
  ~ /workload/container/resources/cpu/limitMilliCPU = 500

6. Try something the system should refuse

ppatch "make orders faster"

The command exits with code 1 and a one-line reason. The request names no field and no value, so there's nothing grounded to change. That refusal is deliberate: see why values must come from the request.

CLI reference

cli/ppatch.py is a single file that uses only the Python standard library. Use it as an alias, or link it onto your PATH:

alias ppatch="python3 $(pwd)/cli/ppatch.py"          # this shell
ln -s "$(pwd)/cli/ppatch.py" ~/.local/bin/ppatch     # every shell (it has a shebang)
Command Effect
ppatch "<request>" Preview: print the diff, save nothing.
ppatch "<request>" --apply Save the change and print its revision.
ppatch history APP [--limit N] Audit log, newest first. N is 1–500, default 20.
ppatch undo APP Revert the latest change.

--author NAME works with every command and may come before or after it. The default is your OS user name, or anonymous if there isn't one.

Output. ~ marks a replaced value (old → new), + an added one, - a removed one, and = path (already set) a field that already had the requested value. Colors appear only on a TTY.

Environment. PPATCH_URL sets the assistant's base URL (default http://localhost:7000). A trailing slash is fine.

Exit codes

Code Meaning
0 Success.
1 The server answered with an error, couldn't be reached, or returned something unexpected. One-line message, no traceback.
2 Usage error (argparse).

HTTP

Everything the CLI does is one HTTP call to the assistant:

curl -s localhost:7000/edits -H 'Content-Type: application/json' \
  -d '{"text": "lower the orders cpu limit to 80%"}'                         # preview
curl -s localhost:7000/edits -H 'Content-Type: application/json' \
  -d '{"text": "lower the orders cpu limit to 80%", "apply": true, "author": "you"}'
curl -s localhost:7000/history/orders
curl -s -X POST "localhost:7000/undo/orders?author=you"

Every field, response and status code is listed in api.md.