Skip to content

Commit 0d814cb

Browse files
committed
docs(forklog): record tool output coloring by language
syntax.tool_output colors plugin and MCP tool output by tool name or glob, with a cached JSON sniff for auto (0ab6637); issue anomalyco#54957, PR anomalyco#54968; the plugin SDK content-type idea is kept as a future note; vt-252 on desktop and m4max. AI-Model: anthropic/claude-opus-5-5 AI-Variant: high AI-Tool: opencode 1.19.0-vt-227-dfb56f76c7 AI-Platform: linux AI-Harness: Vibeterm e6434eb AI-Session-ID: ses_ed1e2b932ffe6tTqhsOiGuYXRE
1 parent 0ab6637 commit 0d814cb

3 files changed

Lines changed: 75 additions & 8 deletions

File tree

‎.vibeterm/forklog/README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ carries every feature forward unchanged. That commit includes the full
115115

116116
- [2026-10-12 `ses_ed1e2b932ffe6tTqhsOiGuYXRE`](./sessions/2026-10-12-tool-input-compact.md)
117117
- Tool input block: one row per value while collapsed, compact YAML lists;
118-
PR #54707 amended; build and install on both hosts.
118+
PR #54707 amended; opencode `*.scm` typecheck fix; tool output colored
119+
by `syntax.tool_output` (PR #54968); build and install on both hosts.
119120

120121
- [2026-10-11 `ses_ed1e2b932ffe6tTqhsOiGuYXRE`](./sessions/2026-10-11-tool-syntax-coloring.md)
121122
- Syntax coloring in tool calls: bash command, heredocs by consumer, file

‎.vibeterm/forklog/features/2026-10-11-tool-syntax-coloring.md‎

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Syntax coloring in tool calls: bash, heredocs, file languages, tool input
1+
# Syntax coloring in tool calls: bash, heredocs, file languages, tool input and output
22

33
## Identity
44

@@ -7,17 +7,19 @@
77
- Development branch(es): `syntax-integration` (worktree off `dev-nowaker`);
88
upstream branches `bash-syntax` (`b0d93392c2`), `heredoc-syntax`
99
(`bf7cffb240`, stacked on `bash-syntax`), `file-languages` (`d6087eb738`),
10-
`tool-input-block` (`491363e6cf`), all off `github/v1` `dfb56f76c7`
10+
`tool-input-block` (`491363e6cf`), all off `github/v1` `dfb56f76c7`;
11+
`tool-output-syntax` (`e9809aa4f3`, stacked on `bash-syntax`)
1112
- First local commit: `dfbf7f6836`
1213
- Current local commit(s): `dfbf7f6836`, `65861b2734`, `60edf2a182`, `8a360b4aa0`,
13-
`b23685155c`, `91e33c557e`, `84d27d0f49`, `8e3a183698`
14+
`b23685155c`, `91e33c557e`, `84d27d0f49`, `8e3a183698`, `0ab6637c9d`
1415
- Upstream base when introduced: `dfb56f76c7` (upstream `v1`, `v1.19.0`)
1516
- Last checked against upstream: `dfb56f76c7`
16-
- Upstream: issues #54700-#54703; PRs
17+
- Upstream: issues #54700-#54703, #54957; PRs
1718
[#54704](https://github.com/anomalyco/opencode/pull/54704) (bash),
1819
[#54705](https://github.com/anomalyco/opencode/pull/54705) (heredoc, stacked on #54704),
1920
[#54706](https://github.com/anomalyco/opencode/pull/54706) (file languages),
20-
[#54707](https://github.com/anomalyco/opencode/pull/54707) (tool input), all against `v1`.
21+
[#54707](https://github.com/anomalyco/opencode/pull/54707) (tool input),
22+
[#54968](https://github.com/anomalyco/opencode/pull/54968) (tool output, stacked on #54704), all against `v1`.
2123
**Needs a v2 port later.**
2224

2325
## Original request
@@ -70,6 +72,7 @@ approved "Build all four". The user's words on defaults:
7072
| `b23685155c` | 2026-10-11 | bash command as one `<text>` of spans (layout identical to plain); non-red `toolSyntax` for command and heredocs | `ShellCommand`, `CommandSpans`, `shellHighlights` in `routes/session/index.tsx`; `theme/tool-code.ts` `toolCodeTheme`; `toolSyntax` in `context/theme.tsx`; `highlightCached`; `test/cli/tui/shell-command.test.tsx`, `test/tool-code-theme.test.ts` |
7173
| `91e33c557e` | 2026-10-11 | tool input keys and values from `toolCodeTheme` | `code` memo in `GenericTool` |
7274
| `8e3a183698` | 2026-10-12 | opencode typecheck: declare `*.scm` imports | `packages/opencode/src/audio.d.ts` |
75+
| `0ab6637c9d` | 2026-10-12 | generic tool output colored by `syntax.tool_output` (tool name or glob -> language, `auto`, `none`; unset = plain); JSON sniff for `auto`; collapsed preview takes the whole output's highlights | `outputLanguage`, `detectOutputLanguage`, `previewHighlights` in `util/tool-output.ts`; `ToolOutputText`, `StyledOutput` in `routes/session/index.tsx`; `test/cli/tui/tool-output.test.tsx`, `test/util/tool-output.test.ts` |
7376
| `84d27d0f49` | 2026-10-12 | collapsed tool input: one row per value cut to the measured width; compact YAML lists | `formatToolInput(input, width)` in `util/tool-input.ts`; `inputWidth`/`onWidth` in `GenericTool`/`ToolInput`; `test/cli/tui/tool-input.test.tsx` |
7477

7578
Docs: `Syntax highlighting` section in `packages/web/src/content/docs/tui.mdx`.
@@ -94,6 +97,19 @@ Reported by `ses_ed1e2b932ffe6tTqhsOiGuYXRE`; see its
9497
Values now take one row each, and lists are compact YAML; PR #54707 amended.
9598
Evidence: `84d27d0f49`; frames at 40/80/160; PTY at 80/160; A/B vs vt-241.
9699

100+
- 2026-10-12 [`ses_ed1e2b932ffe6tTqhsOiGuYXRE`](../sessions/2026-10-12-tool-input-compact.md) -
101+
user feedback: JSON returned by `browser` was drawn plain. `syntax.tool_output`
102+
added, `auto` ships (sniff measured cheap); issue #54957, PR #54968.
103+
Evidence: `0ab6637c9d`; frames at 40/80/160; PTY at 80/160; A/B on vt-252.
104+
105+
## Future ideas
106+
107+
- A tool declaring its output's content type, so the TUI colors it without
108+
config: a plugin SDK property such as
109+
`tool({ ..., output: { contentType: "application/json" } })`, and an MCP
110+
result's `mimeType`, mapped to a language before `syntax.tool_output` is
111+
consulted. Raised as a follow-up in PR #54968. Not built.
112+
97113
## Current maintenance notes
98114

99115
- The four upstream branches carry no AI trailers; the fork commits do.

‎.vibeterm/forklog/sessions/2026-10-12-tool-input-compact.md‎

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Tool input block: one row per value, compact YAML
1+
# Tool input block: one row per value, compact YAML; tool output coloring
22

33
## Identity
44

@@ -9,7 +9,8 @@
99
- Integration branch: `dev-nowaker`
1010
- Development branch(es): `syntax-integration` (off `dev-nowaker`); upstream `tool-input-block`
1111
- Upstream base: `dfb56f76c7` (upstream `v1`, `v1.19.0`); unchanged
12-
- Source result commit(s): `84d27d0f49`; `8e3a183698` (opencode `*.scm` declaration)
12+
- Source result commit(s): `84d27d0f49`; `8e3a183698` (opencode `*.scm` declaration);
13+
`0ab6637c9d` (tool output coloring)
1314
- Forklog commit: this file's introducing commit
1415

1516
## User requests
@@ -39,6 +40,8 @@ Relayed by coordinator `ses_ef8235798ffejGr4sa22eXmVNv` after a collapsed
3940
| `opencode` | `dev-nowaker` | `3d554e9df1` | `84d27d0f49` + forklog `bfc03b0daf` | fix commit, fast-forward; pushed to both remotes |
4041
| `opencode` | `dev-nowaker` | `bfc03b0daf` | `8e3a183698` + this record's second forklog commit | opencode typecheck fix, fast-forward; pushed to both remotes |
4142
| `opencode` | `file-languages` | `f885d7e3ba` | `d6087eb738` | amended with the same declaration; PR #54706 |
43+
| `opencode` | `tool-output-syntax` | - | `e9809aa4f3` | new, stacked on `bash-syntax`; issue #54957, PR #54968 |
44+
| `opencode` | `dev-nowaker` | `c1c1d4fb1a` | `0ab6637c9d` + this record's third forklog commit | feature commit, fast-forward; pushed to both remotes |
4245

4346
## Features touched
4447

@@ -74,6 +77,52 @@ does not include tui's `parsers/assets.d.ts`. Turbo replayed a cached
7477
packages/tui typecheck clean on `file-languages`.
7578
- Not rebuilt or installed: a type declaration does not change the binary.
7679

80+
## Tool output coloring
81+
82+
Relayed by the coordinator: a `browser` result that was plain JSON was drawn
83+
uncolored. User, verbatim:
84+
85+
> returned json wasn't picked up as json. is it because there is no detection
86+
> of content/type of the tool call result? (...probably expensive and not worth
87+
> it?) maybe we should provide some configurability for per-tool calls syntax
88+
> highlighting [...] could be come a property in plugin sdk where each tool call
89+
> can define the content type of their output for syntax highlighting purposes
90+
> [make a note for future on that].
91+
92+
- Cause: `GenericTool` drew output as `<text>{limited()}</text>`; nothing
93+
recorded or detected its type (plugin tools return strings, MCP text results
94+
carry no content type).
95+
- `syntax.tool_output`: tool name or glob -> language id, `auto` or `none`;
96+
unset by default. Separate PR stacked on #54704 rather than folded into
97+
#54707: it reuses #54704's highlight cache and non-red palette, and
98+
`tool-input-block` is not built on `bash-syntax`.
99+
- Sniff cost: 564 generic outputs from the 6154-part session, 6.1 us each
100+
cold, 2.1 us warm; a 46 KB candidate 0.05 ms.
101+
- A first PTY run showed the collapsed preview losing key colors after the
102+
cut: the preview was highlighted on its own and did not parse. Fixed by
103+
highlighting the whole output and keeping the highlights inside the shared
104+
prefix (`previewHighlights`).
105+
- packages/tui on `syntax-integration` (rebased on `c1c1d4fb1a`): typecheck
106+
clean; full suite 619 pass, 1 skip, 0 fail; packages/opencode typecheck 0
107+
errors. `tool-output-syntax`: 129 focused tests pass.
108+
- Real PTY (vt-252, throwaway tmux socket, generic output shown, `browser`
109+
JSON and a plain-text result under `"*": "auto"`) at 80 and 160 columns:
110+
screen text byte-identical with the setting on and off; keys peach, strings
111+
green in the collapsed preview; plain text stays plain; no red cell.
112+
- A/B/B/A, same vt-252 binary, setting off vs on (`browser: json`,
113+
`*: auto`), worldmodern session copy (5623 parts, 86 JSON results, generic
114+
output shown), 60 samples per run: scroll p50 19.7 -> 17.3 ms, p95
115+
42.5 -> 49.0 ms; keystroke p50 24.6 -> 25.3 ms, p95 41.3 -> 54.0 ms
116+
(per-run keystroke p50 22.3-29.5 ms in each arm); idle CPU 1.9% both; RSS
117+
766/792 -> 810/837 MB. Keystrokes from the first frame, while colors land:
118+
p50 10.7-12.5 ms in all four runs. Run-to-run spread covers each difference.
119+
- Installed `1.19.0-vt-252-dfb56f76c7`: desktop inode `49962238`, m4max
120+
inode `31336912`; gate PASSED on both; retry marker present; retry patch
121+
reverse-applied on both; `opencode-serve-tailscale` still PID `4038768`.
122+
- `syntax.tool_output: {"browser": "json", "*": "auto"}` set in
123+
`~/.config/opencode/tui.json` on desktop and m4max; backups
124+
`tui.json.bak-before-syntax-tool-output`.
125+
77126
## Build and install
78127

79128
- Build command: `VIBETERM_V2_GUARD=<opencode-tools>/vibeterm-opencode-client/bin/vibeterm-v2-guard .vibeterm/build.sh`
@@ -89,6 +138,7 @@ does not include tui's `parsers/assets.d.ts`. Turbo replayed a cached
89138

90139
- `84d27d0f49` - show every tool input value on one row, in compact YAML
91140
- `8e3a183698` - declare .scm imports for the opencode typecheck
141+
- `0ab6637c9d` - color plugin and MCP tool output by language
92142
- Required trailer: `AI-Session-ID: ses_ed1e2b932ffe6tTqhsOiGuYXRE`
93143

94144
```sh

0 commit comments

Comments
 (0)