Implements the /loop runtime command as an automated execute-verify-retry loop.
The hook extracts goal, successCriteria, and maxAttempts from the user's command
text, then instructs the agent to iterate with on-disk per-run history under
.opencode/loop-history/.
createLoopCommandHook() — produces a command hook that registers /loop
with registerCommandHook from command-hook-utils, and intercepts
command.execute.before to rewrite the output..opencode/loop-history/loop-<timestamp>-<shortid>/ path; the agent writes
history-NNN.md results into that directory./loop activation1. User types `/loop <description>`
2. OpenCode invokes command.execute.before for 'loop'
3. Hook clears output and injects the structured loop prompt
4. Agent executes per-attempt: read history, dispatch @fixer, verify, write result
5. History persisted to `.opencode/loop-history/`
6. Loop stops on PASS or exits on FAIL after maxAttempts
src/hooks/command-hook-utils.ts) — provides registerCommandHookcommand.execute.before interception.opencode/loop-history/ filesystem for loop historysrc/utils/internal-initiator.ts — createInternalAgentTextPartsrc/hooks/command-hook-utils.ts — command registration helpersrc/hooks/loop-command/index.test.ts