feat: add always-on command log for hooks and LLM commands#1088
Merged
feat: add always-on command log for hooks and LLM commands#1088
Conversation
Log hook executions and LLM commit generation to .git/wt-logs/commands.jsonl as JSONL for post-hoc debugging. - New command_log module with lazy file/directory creation - .external() builder on Cmd for automatic logging in run()/stream() - Foreground hooks logged via execute_command_in_worktree - Background hooks logged directly with null exit/duration - Growth control: rotates at 1MB to commands.jsonl.old Co-Authored-By: Claude <noreply@anthropic.com>
- Replace writeln! with single write_all to prevent interleaving from concurrent wt processes - Use char_indices().nth() for single-scan truncation instead of double-scanning with chars().count() + chars().take() Co-Authored-By: Claude <noreply@anthropic.com>
worktrunk-bot
approved these changes
Feb 17, 2026
Commands are user-configured and can be long (especially LLM commands with inline flags). The log rotates at 1MB so there's no cost to being liberal with the truncation limit. Co-Authored-By: Claude <noreply@anthropic.com>
The inner Option<CommandLog> in the Mutex was redundant since OnceLock already handles the uninitialized case. This simplifies the lock pattern and removes an unreachable branch that hurt coverage. Co-Authored-By: Claude <noreply@anthropic.com>
Separate the LOG FILES display in `wt config state` into two sections: COMMAND LOG (commands.jsonl) and HOOK OUTPUT (*.log). Update JSON output to use `command_log` and `hook_output` keys. Document the command log in the FAQ. Co-Authored-By: Claude <noreply@anthropic.com>
worktrunk-bot
approved these changes
Feb 18, 2026
Extract write logic into CommandLog::write() method for direct testing. Add tests for lazy file creation, append behavior, and rotation at the size limit. Fixes codecov/patch coverage gap. Co-Authored-By: Claude <noreply@anthropic.com>
worktrunk-bot
approved these changes
Feb 18, 2026
max-sixty
pushed a commit
that referenced
this pull request
Feb 19, 2026
- Fix approved-hook-commands migration note to reference `wt config update` instead of the old `wt config show` command - Add command log (commands.jsonl) documentation to `wt config state logs` help text — the feature was added in #1088 but help text wasn't updated - Add documentation accuracy checklist to PR review skill so the CI reviewer catches stale docs in future PRs https://claude.ai/code/session_015Dv1n6s3s79EJCsPoxByC6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.git/wt-logs/commands.jsonl.external(label)builder onCmdfor automatic logging inrun()/stream()commands.jsonl.oldat 1MB (~2MB worst case)wt config statelog display into COMMAND LOG and HOOK OUTPUT sectionsExample log entries (parseable with
jq):{"ts":"2026-02-17T10:23:45Z","wt":"wt merge","label":"pre-merge user:lint","cmd":"pre-commit run --all-files","exit":0,"dur_ms":12345} {"ts":"2026-02-17T10:24:00Z","wt":"wt switch","label":"post-start user:server","cmd":"npm run dev","exit":null,"dur_ms":null}Test plan
pre-commit run --all-files)wt config statetests