Skip to content

feat(config-state): hoist --format to parent subcommands; add absolute path to logs JSON - #2156

Merged
max-sixty merged 1 commit into
mainfrom
json-logs
Apr 13, 2026
Merged

max-sixty merged 1 commit into
mainfrom
json-logs

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Previously wt config state logs --format=json errored with "unexpected argument '--format'" — the flag only existed on the get action, even though the bare form dispatches to the same list view. Same shape on hints, ci-status, marker.

Consolidates --format to a single global = true flag on each parent; drops the now-duplicate field from the Get actions. --format=json now works regardless of ordering: logs --format=json, logs --format=json get, logs get --format=json.

Logs JSON entries now include path (absolute, forward-slashed) alongside file (relative), so consumers don't need to join with wt_logs_dir() to open the file:

{
  "file": "main-vfz/user/post-switch/zellij-tab-xtr.log",
  "path": "/Users/.../.git/wt/logs/main-vfz/user/post-switch/zellij-tab-xtr.log",
  "size": 124,
  "modified_at": 1776041854
}

logs get --hook=X --format=json also emits {"path": "..."} instead of a bare path line, so JSON consumers get a uniform shape whether they're listing all logs or resolving one hook.

This was written by Claude Code on behalf of Maximilian Roos

… absolute `path` to logs JSON

Before, `wt config state logs --format=json` errored with "unexpected argument
'--format'" because the flag only existed on the `get` action. The parent
subcommands (`logs`, `hints`, `ci-status`, `marker`) dispatch to the same
list/get view when no action is specified, so format should apply there too.

Consolidate `--format` to a single `global = true` flag on each parent;
remove the duplicate field from the `Get` actions. `--format=json` now works
regardless of ordering: `logs --format=json`, `logs --format=json get`,
`logs get --format=json`.

Logs JSON entries now include `path` (absolute, forward-slashed) alongside
`file` (relative), so consumers don't need to join with `wt_logs_dir()` to
open the file. `logs get --hook=X --format=json` emits `{"path": "..."}`
instead of a bare path line, keeping JSON output consistent across all
logs invocations.

Co-Authored-By: Claude <[email protected]>
@max-sixty
max-sixty merged commit 965f8dc into main Apr 13, 2026
24 checks passed
@max-sixty
max-sixty deleted the json-logs branch April 13, 2026 03:00
max-sixty added a commit that referenced this pull request Apr 13, 2026
…h filters (#2161)

Builds on [#2156](#2156)
which hoisted `--format` and added absolute `path`. Two follow-on
changes:

### 1. Structured fields on `hook_output` entries

Hook-output log entries carried a slash-packed relative path in `file` —
consumers had to split on `/` to filter by branch, source, or hook type.
Expose first-class structured fields:

```json
{
  "file": "main/user/post-start/server.log",
  "path": "/.../.git/wt/logs/main/user/post-start/server.log",
  "branch": "main",
  "source": "user",
  "hook_type": "post-start",
  "name": "server",
  "size": 1024,
  "modified_at": 1700000000
}
```

Internal-op entries (e.g., `feature/internal/remove.log`) normalize onto
the same shape with `source: "internal"`, `hook_type: null`, and the op
name in `name`.

### 2. Drop `--hook` / `--branch` filters; use jq

With the structured fields, the old `--hook=SPEC` / `--branch=X`
interface is a jq one-liner:

```bash
wt config state logs --format=json \
  | jq -r '.hook_output[]
           | select(.source == "user"
                    and .hook_type == "post-start"
                    and (.name | startswith("server")))
           | .path'
```

That subsumes the filter flags without the CLI plumbing, the
`HookLog::parse`/`to_spec` roundtrip, or the error-shape tests that
locked in a fragile `source:hook-type:name` grammar. `logs` and `logs
get` now always list — one code path, one shape.

**Breaking change**: `wt config state logs get --hook=...` and
`--branch=...` are removed. The jq pattern is documented in `wt config
state logs --help`.

> _This was written by Claude Code on behalf of Maximilian Roos_

---------

Co-authored-by: Claude <[email protected]>
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.

2 participants