Skip to content

feat: add wt step eval for template expression evaluation#1004

Draft
max-sixty wants to merge 2 commits intomainfrom
arbitrary-data
Draft

feat: add wt step eval for template expression evaluation#1004
max-sixty wants to merge 2 commits intomainfrom
arbitrary-data

Conversation

@max-sixty
Copy link
Owner

Summary

  • Add experimental wt step eval subcommand that evaluates a minijinja template in the current worktree context and prints the result to stdout
  • Reuses existing hook template infrastructure — all variables (branch, repo, worktree_path, etc.) and filters (hash_port, sanitize, sanitize_db) are available
  • Output goes to stdout with no decoration or shell escaping, designed for scripting and shell substitution
$ wt step eval '{{ branch | hash_port }}'
16066

$ curl http://localhost:$(wt step eval '{{ branch | hash_port }}')/health

This is the first step from the IDEAS.md design doc, directly addressing the user request in #947 — "found no way to run it on a single branch."

Test plan

  • 6 integration tests: basic branch, hash_port, multiple values, sanitize_db, conditionals, template error
  • Help text and completion snapshots updated
  • stdout guard allowlisted
  • Doc pages auto-synced
  • All lints pass
  • 2360 tests pass (5 pre-existing shell_wrapper failures excluded)

Ref #947

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

…ntal)

Evaluates a minijinja template in the current worktree context and prints
the result to stdout. Reuses the existing hook template infrastructure
(variables, filters like hash_port/sanitize/sanitize_db).

Designed for scripting — no shell escaping, no decoration, output to
stdout only.

```
$ wt step eval '{{ branch | hash_port }}'
16066

$ curl http://localhost:$(wt step eval '{{ branch | hash_port }}')/health
```

Ref #947

Co-Authored-By: Claude <noreply@anthropic.com>
@max-sixty
Copy link
Owner Author

Follow-up PR for per-branch kv state: #1006

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

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