Skip to content

feat: add wt config state kv for arbitrary per-branch data#1006

Draft
max-sixty wants to merge 6 commits intomainfrom
kv-state
Draft

feat: add wt config state kv for arbitrary per-branch data#1006
max-sixty wants to merge 6 commits intomainfrom
kv-state

Conversation

@max-sixty
Copy link
Owner

@max-sixty max-sixty commented Feb 13, 2026

Summary

  • Adds wt config state kv set/get/list/clear commands for storing arbitrary key-value data per branch in git config (worktrunk.state.{branch}.kv.{key})
  • Makes kv data available in all template contexts via {{ kv.key }} syntax (hooks, wt step eval)
  • {{ kv.key | default('fallback') }} works when no data is set
  • Includes kv data in wt list --format=json output as a kv object field

Builds on #1004 (wt step eval). Part of #947.

Test plan

  • Unit tests for kv template injection (empty, with data, no branch)
  • Integration tests for kv CLI commands (set, get, list, clear, clear --all)
  • Integration tests for kv in wt step eval (dot notation, default filter)
  • Integration tests for kv in JSON output (present with data, absent when empty)
  • All 1041 integration + 489 unit tests pass
  • Pre-commit clean

This was written by Claude Code on behalf of @max-sixty

🤖 Generated with Claude Code

max-sixty and others added 3 commits February 13, 2026 21:18
Adds `wt config state kv set/get/list/clear` commands for storing
arbitrary key-value data per branch in git config. KV data is also
available in templates via `{{ kv.key }}` syntax, working in hooks
and `wt step eval`.

Part of #947

Co-Authored-By: Claude <noreply@anthropic.com>
Adds a `kv` object field to JSON output containing per-branch
key-value data. Absent when no kv data is set for the branch.

Co-Authored-By: Claude <noreply@anthropic.com>
- Skip kv lookup in expand_template when template doesn't reference kv
- Remove empty println!() for missing kv keys (match git config behavior)
- Inline get_kv_entries wrapper (no added value over repo.kv_entries())
- Extract parse_all_kv helper to deduplicate show_json/show_table parsing

Co-Authored-By: Claude <noreply@anthropic.com>
@max-sixty max-sixty changed the base branch from arbitrary-data to main February 14, 2026 05:19
max-sixty and others added 3 commits February 15, 2026 21:59
Co-Authored-By: Claude <noreply@anthropic.com>
`[experimental]` was interpreted as an intra-doc link by rustdoc,
causing `cargo doc -Dwarnings` to fail.

Co-Authored-By: Claude <noreply@anthropic.com>
- Add KV data to comprehensive state get tests (table and JSON)
- Add tests for kv clear nonexistent key, clear --all when empty
- Add tests for kv list/clear with --branch flag
- Escape [experimental] in rustdoc to fix broken intra-doc link

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant