llmiterate
Manual editor-save bridge from comment markers to background Pi edits.
Install / load
Loaded through the root pi-ext package. See ../../README.md.
Commands / tools / settings
Commands:
/llmiterate toggle on/off for current cwd
/llmiterate on start watcher for current cwd + initial scan
/llmiterate off stop watcher + worker
/llmiterate status show scope/counts/state path
/llmiterate explain <path> explain include/exclude/marker decision
/llmiterate log render latest worker transcript and open it in $VISUAL/$EDITOR
Debug commands, registered but not autocompleted:
/llmiterate scan scan current scope now
/llmiterate forget forget run state
/llmiterate reload reload config + watcher
Tools: none.
Hooks:
session_start: stores UI context and renders statussession_shutdown: stops watcher/worker and releases lock
Settings namespace:
llmiterate in global Pi settings and <scope>/.pi/settings.json.
| setting | default | behavior |
|---|---|---|
enabled |
true |
false blocks /llmiterate on |
include |
["**/*"] |
glob allow-list |
exclude |
built-in metadata/build/cache dirs/files | merged with user excludes |
debounceMs |
3000 |
save debounce before scan |
maxFileBytes |
1000000 |
larger files skipped |
timeoutMs |
600000 |
RPC prompt timeout |
maxWatchDirs |
10000 |
watcher directory cap |
commentPrefixes |
built-ins by extension | appended by extension key |
model |
unset | passed to worker as --model when set |
thinking |
unset | off | minimal | low | medium | high | xhigh; passed as --thinking when set |
notify |
errors |
off | errors | done | all; worker-run notifications currently emit only errors unless off |
Example:
{
"llmiterate": {
"enabled": true,
"include": ["src/**/*.{ts,tsx,rs,java,md}", "docs/**/*.md"],
"exclude": ["**/target/**", "**/dist/**"],
"debounceMs": 3000,
"maxFileBytes": 1000000,
"timeoutMs": 600000,
"maxWatchDirs": 10000,
"model": "zai/glm-5.1",
"thinking": "high",
"notify": "errors",
"commentPrefixes": {
"foo": ["COMMENT"],
"lua": ["--"]
}
}
}
Behavior
llmiterate does not autostart.
/llmiterate or /llmiterate on starts it for the exact real cwd.
It loads global Pi settings, then <scope>/.pi/settings.json; there is no
upward project-root search.
Start sequence:
- resolve cwd
- load config and state
- acquire singleton lock for the scope hash
- start watcher
- run initial scan
- queue matching markers
Only one watcher may own an exact real cwd at a time. Another Pi session in the same cwd enters standby and reports the lock owner. Parent and child dirs are independent.
Watcher behavior:
- uses
fs.watch - respects
.gitignoreand.ignore - applies
include/exclude - skips files over
maxFileBytes - debounces file events by
debounceMs - refreshes watched dirs after directory changes
- stops at
maxWatchDirs
llmiterate itself does not edit source files. It queues prompts. A background Pi RPC worker performs edits with normal Pi tools.
Worker args:
--mode rpc
--offline
--session-dir <state>/sessions
--append-system-prompt <llmiterate worker rules>
--model <optional>
--thinking <optional>
Worker env:
LLMITERATE_WORKER=1
LLMITERATE_WORKER=1 prevents recursive llmiterate watchers while keeping other
extensions available.
State file:
<platform-state-dir>/pi/llmiterate/<sha256(scope)>/state.json
Linux default:
${XDG_STATE_HOME:-~/.local/state}/pi/llmiterate/<sha256(scope)>/state.json
Statuses:
queued | running | done | failed
Duplicate saves do not start duplicate queued/running jobs.
Failed markers remain retryable on next save or scan.
Queued/running markers from a previous Pi process are reset to failed on state
load.
A marker becomes done after the worker finishes and the original
same-line/same-hash marker no longer exists.
UI channels:
- source file: final edits only
- footer/status: watching/standby/queued/running/watch errors
- notifications: command results and worker errors
/llmiterate log: latest worker JSONL transcript rendered as markdown at<state>/logs/latest.md
Marker syntax
One marker only:
llmiterate:
Marker must appear after a known comment prefix. Raw markers never run.
void main(final String[] a) {
// llmiterate: implement argument validation
if (a.length == 0) {
// llmiterate: print usage and exit non-zero
}
}
def parse(src):
# llmiterate: implement parser fast path
-- llmiterate: add index for lookup query
Rules:
- raw
llmiterate:is ignored - legacy
LLM/PROMPTis ignored - consecutive marker lines are grouped
- empty marker lines are ignored
!llmiteratein a comment disables the whole file
<!-- !llmiterate -->
Comment prefixes
Prefixes are extension-scoped. Built-ins include:
.c/.cc/.cpp/.cs/.cts/.go/.h/.hpp/.java/.js/.jsx/.kt/.kts/.mts/.php/.scala/.swift/.ts/.tsx // /// /* /**
.rs // /// //! /* /**
.css /* /**
.scss/.less // /* /**
.py/.sh/.bash/.zsh/.fish/.rb/.pl/.pm/.r/.toml/.yaml/.yml/.dockerfile/.ex/.exs #
.md/.mdx/.html/.htm/.xml <!-- -->
.sql/.lua/.hs --
.lisp/.el/.clj/.scm ; ;; ;;;
.tex % %%
.erl %
.f/.f90 !
Unknown extensions do not run markers.
Markdown only accepts HTML comments, so headings or bullets containing
llmiterate: are inert.
Config commentPrefixes appends by extension:
{
"llmiterate": {
"commentPrefixes": {
"foo": ["COMMENT"],
"lua": ["--"]
}
}
}
Replacement behavior
For each marker block, the worker receives a prompt containing:
- source location:
@file:startLine - marker text
- marker span to replace
- instruction to work in/around the file
- instruction to remove the marker unless impossible
Before a job starts, llmiterate rechecks that the marker still exists at the same line with the same prompt hash. If it changed, the job is failed as stale and skipped.
After the worker finishes, llmiterate rechecks the file. If the same marker is still present at the same line with the same prompt hash, the job is marked failed. Otherwise that job is marked done.