Skip to content

feat(tui): color SQL, Dockerfiles, config files and scripts in file tools - #54706

Closed
Nowaker wants to merge 1 commit into
anomalyco:v1from
Nowaker:file-languages
Closed

Nowaker wants to merge 1 commit into
anomalyco:v1from
Nowaker:file-languages

Conversation

@Nowaker

@Nowaker Nowaker commented Oct 12, 2026 •

Copy link
Copy Markdown

Note: I'm aware v1 is now the maintenance branch and new features go to v2 only. This PR is here for others to use, and I'll submit the v2 version once I've migrated my whole plugin system to it.

Issue for this PR

Closes #54702

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

  • detectFiletype (util/filetype.ts), used by write, edit, apply_patch and the permission diff: file names (Dockerfile, Containerfile, Makefile, Gemfile, PKGBUILD, shell rc files), dotenv files, ini-style config (.ini, .cfg, .conf including *.d/ drop-ins, .desktop) and systemd units (.service, .socket, .timer, .target, .slice, .scope, .mount, .automount, .swap, .path, .device), networkd (.network, .netdev, .link) and quadlet files (.container, .volume, .pod, .kube, .image, .build), the parser names for shellscript/makefile/terraform, and for a file still unknown the interpreter on its #! line, from the content or a diff whose first hunk starts at line 1. Diffs keep their red/green backgrounds with syntax on top.
  • New parsers: erb from the tree-sitter-embedded-template release (Ruby and HTML injected). SQL, Dockerfile, ini and HAML publish no wasm, so packages/tui/src/parsers bundles builds with their queries and licenses (embedded via file imports); its README names each source commit and the rebuild command. SQL is 2.4 MB, the other three under 100 KB together.
  • A running write already has its whole content, so it shows as a colored block titled "Writing" instead of one line.
  • syntax.files: false goes back to extension-only detection. On by default. Documented in tui.mdx.

How did you verify your code works?

  • bun typecheck; bun test test/util test/config.test.tsx test/cli/tui: 137 pass (38 detection cases).
  • Real worker highlights SQL, Dockerfile, ini/systemd, HAML and ERB; a real TUI shows an edited .sql diff and a written Dockerfile colored.

Screenshots / recordings

CREATE/FROM/RUN keywords, TEXT type over the green added-line background:

← Edit db/schema.sql
  2     id INTEGER PRIMARY KEY,
  3 -   name TEXT NOT NULL
  3 +   name TEXT NOT NULL,
  4 +   active INTEGER DEFAULT 1
# Wrote Dockerfile
 1 FROM oven/bun:1
 4 RUN bun install --frozen-lockfile

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

This PR is AI generated, but under direct supervision and on request of @Nowaker.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Nowaker added a commit to Nowaker/opencode that referenced this pull request Oct 12, 2026
The opencode typecheck failed on the bundled grammar queries since
60edf2a; 8e3a183 declares *.scm, and file-languages (PR anomalyco#54706)
is amended with the same declaration.

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
…ools

write, edit and apply_patch color a file by its extension, and many
files people edit every day came out plain: no parser was registered for
SQL, Dockerfiles, ini/systemd units or HAML, `.sh` files mapped to
"shellscript" while the parser is "bash" (likewise Makefiles and
Terraform), and extensionless files such as Dockerfile, Gemfile,
PKGBUILD or a script with a #! line had no language at all.

`detectFiletype` (packages/tui/src/util/filetype.ts) adds file names,
dotenv files, ini-style config and systemd/quadlet units, the parser
names for shellscript/makefile/terraform, and for a file still unknown
the interpreter on its #! line, read from the content or from a diff
whose first hunk starts at line 1. write, edit, apply_patch and the
permission diff use it; diffs keep their red/green backgrounds with the
syntax colors on top.

New parsers: erb from the tree-sitter-embedded-template release, with
Ruby and HTML injected. SQL, Dockerfile, ini and HAML publish no wasm,
so packages/tui/src/parsers bundles builds of them with their
highlights queries and licenses, embedded in the binary through file
imports; its README names each source commit and the rebuild command.
SQL is 2.4 MB, each of the other three under 50 KB.
packages/opencode/src/audio.d.ts declares `*.scm` beside `*.wasm`: the
opencode program compiles parsers-config.ts without tui's assets.d.ts.

A write that is still running already has its whole content, so it now
shows as a colored block titled "Writing" instead of one line.

`syntax.files: false` in tui.json goes back to extension-only detection.
Nowaker added a commit to Nowaker/opencode that referenced this pull request Oct 13, 2026
Heredoc bodies written to systemd, networkd and quadlet files are
colored as ini (246c6c1); PRs anomalyco#54705 and anomalyco#54706 amended; vt-259 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 41f09c2
AI-Session-ID: ses_ed1e2b932ffe6tTqhsOiGuYXRE
@Nowaker

Nowaker commented Nov 2, 2026

Copy link
Copy Markdown
Author

Closing: this targets the v1 TUI, which upstream now maintains for critical fixes only, so it is not going to be merged. The branch stays on Nowaker/opencode if anyone wants to pick it up.

@Nowaker Nowaker closed this Nov 2, 2026
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