Skip to content

[0.0.27] feat(cli): add Ghostty-style +list-*/+show-config helper actions (#2464) - #2550

Merged
Xuepoo merged 5 commits into
mainfrom
ctx-1467/feat-cli-plus-actions
Oct 23, 2026
Merged

Xuepoo merged 5 commits into
mainfrom
ctx-1467/feat-cli-plus-actions

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Implements #2464 (CarryCtx CTX-1467) with Ghostty-style +<action> aliases over the existing canonical implementations. bitty list ..., bitty config ..., and bitty extension list remain canonical; the parser maps every alias onto the same dispatch fields, so there is no parallel catalog or validation logic.

New aliases

Alias Canonical implementation
bitty +list-themes bitty list themes
bitty +list-colors bitty list colors (new kind)
bitty +list-fonts bitty list fonts (new kind)
bitty +list-keybinds bitty list keymaps
bitty +list-actions bitty list actions
bitty +list-plugins bitty list plugins
bitty +list-extensions bitty extension list
bitty +show-config bitty config show (new verb; same rows as config check, JSON adds attribution)
bitty +validate-config bitty config validate (new verb)
bitty +edit-config bitty config edit + post-edit validation

Behavior

  • Colors: all 16 ANSI slots plus UI roles (foreground, cursor, selection text/surface, cursor-on-selection, help ring, banner text), with resolved #rrggbb values and contrast measured by the shared bitty-config::theme::contrast_checks policy. Result envelope also carries the canvas background. No parallel contrast rule.
  • Fonts: reuses the renderer's process-wide fontdb scan (bitty-render::font_catalog), not a second discovery mechanism. Rows are unique (family, style, source), sorted, capped at 512, with supported/total/truncated. source is user|system|embedded; absolute paths never appear. No network, no subprocess, no VM; missing fontconfig or headless sessions yield an empty/partial catalog without panicking.
  • Config: config show/config validate emit stable envelope v1 JSON. show projects 30 bounded effective keys, each with value, type, layer, and source attribution from the startup loader. validate exits 2 with a typed E_CONFIG_INVALID envelope on invalid input and no key dump. edit re-validates after the editor exits, never rewrites the user's bytes, and returns 2 on an invalid edit; a failed editor launch leaves the file untouched.
  • Safe mode: --safe selects the built-in safe config for colors/show/validate and keeps theme listing built-in-only; +list-extensions --safe is accepted as a no-op for the static inventory. config edit / +edit-config rejects --safe (exit 2, E_SAFE_UNSUPPORTED) because safe mode never reads the edited file; validating through it would report a false success.
  • Bounded/VM-less: static lists load no plugin VM and open no network; fonts/colors are capped; config projection is capped.
  • Help/completions: top-level help, per-alias --help, bitty help +<action>, completion grammar, and all five golden fixtures cover the new surface. CHANGELOG.md records the feature.

Command examples

bitty +list-themes --format json
bitty +list-colors
bitty +list-fonts --format json
bitty +list-keybinds --format json
bitty +list-actions --format json
bitty +list-plugins --format json
bitty +list-extensions --format json
bitty +show-config --format json
bitty +validate-config --format json
EDITOR=nvim bitty +edit-config

Example +list-colors output (table):

TOKEN VALUE CONTRAST FLOOR RESULT
background #1e1e2e - - canvas
foreground #cdd6f4 11.34:1 4.5:1 pass
ansi0.surface #45475a 1.80:1 1.2:1 pass
ansi1.text #f38ba8 7.08:1 4.5:1 pass
...

Verification

Scoped target dir CARGO_TARGET_DIR=$BITTY_WORKSPACE/.targets/ctx-1446; worktree based on origin/main at 7173d7e0.

  • cargo fmt --all -- --check — clean.
  • cargo clippy -p bitty-terminal -p bitty-render --all-targets --locked -- -D warnings — clean.
  • cargo check -p bitty-terminal -p bitty-render --target x86_64-pc-windows-gnu --all-targets --locked — clean (includes the attribution regression and the Windows per-user font root).
  • All 23 cli_* integration suites — 293 tests passed, including:
    • cli_plus_actions (new) — 13 passed: alias/canonical payload equivalence, JSON schema stability, invalid config, missing editor, post-edit validation, safe edit rejection, editor-failure normalization, profile/policy attribution, safe-mode parity, headless fonts, help, completions.
    • cli_list — 31 passed (updated for the new kinds).
    • cli_completion, cli_help, cli_config_fallback, cli_safe_parity, cli_show_font, cli_theme_contrast, cli_unknown_flag, and the remaining CLI suites.
  • Unit filters:
    • plus:: — 4 passed
    • list::tests:: — 51 passed
    • config_cli::startup_tests:: — 12 passed
    • grammar::tests:: — 7 passed
    • bitty-render font_catalog — 4 passed

Review follow-up (#2550)

Applied on the same branch in 22bf1382:

  1. Portable macOS tests: editor regressions now use PATH-resolved true/false and a PATH-unique missing-editor name; no /bin/true or absolute fixture paths.
  2. Safe edit: config edit / +edit-config rejects --safe with exit 2 and E_SAFE_UNSUPPORTED before spawning an editor; --safe removed from the alias usage/completion flags; regression proves the file is untouched.
  3. Attribution: the profile row now uses LoadedConfig.profile_name/profile_path (layer: profile, source: profile: <path>), and the derived theme.contrast row reports policy/policy; --profile JSON regression added.
  4. P3: truncated is computed from the real row count; editor failures normalize to exit 1 with a message and E_EDITOR_FAILED (no-config-root uses E_CONFIG_PATH); Windows per-user font root (%LOCALAPPDATA%\Microsoft\Windows\Fonts) classified; remaining CTX-1446 code comments renamed to CTX-1467.
  5. Delta review (Windows portability, wording corrected): the profile attribution regression parses the flat keys row and compares decoded value/layer/source fields instead of raw substring matching Path::display(). The decoded profile: source is now compared by canonical path equality: both sides are passed through std::fs::canonicalize and the resulting PathBufs are compared. This handles Windows 8.3 short forms versus long forms without weakening the assertion to a file name. The layer:"profile" and theme.contrast layer:"policy" assertions remain; Windows cross-target cargo check --all-targets is clean.

Docs and manual sync (follow-up in the owning repos)

These pages mention the affected CLI/config surfaces and need synchronization in their own repos (not edited here):

  • bitty-terminal-docs/interfaces/cli.md
  • bitty-terminal-docs/specifications/cli-contract-rfc.md
  • bitty-terminal-docs/configuration/themes.md
  • bitty-manual/en/getting-started/cli.md
  • bitty-manual/en/configuration/overview.md
  • bitty-manual/en/configuration/themes.md
  • bitty-manual/en/faq/troubleshooting.md (plus zh-CN counterparts once i18n ownership/sync is defined)

Notes

  • The durable task is CTX-1467 (the original dispatch named CTX-1446, an unrelated completed task). Code comments and commit headers use CTX-1467; the worktree directory keeps the originally requested name.
  • Head: 564fbef99ecd78e2ea0bd7b7b13346b2e4cb5fb3 (rebased on main at d014721a).
  • No new dependencies, no network paths, no plugin-VM activation. The only write path is the existing config edit editor flow, now followed by read-only validation.

Do not merge; awaiting independent review, CodeRabbit, and CI.

Closes #2464

@Xuepoo Xuepoo added this to the v0.0.27 milestone Oct 23, 2026
@Xuepoo Xuepoo added feat Feature P2 Priority: medium area:cli Area: command-line interface labels Oct 23, 2026
@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 17 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 196d19e1-c5cc-4d29-9ff6-d03fb2544d72
📥 Commits

Reviewing files that changed from the base of the PR and between ccf8659 and 0cea983.

📒 Files selected for processing: 18
  • CHANGELOG.md
  • crates/bitty-render/src/font_catalog.rs
  • crates/bitty-render/src/lib.rs
  • crates/bitty-render/src/shaped.rs
  • crates/bitty-terminal/src/cli.rs
  • crates/bitty-terminal/src/completion.rs
  • crates/bitty-terminal/src/config_cli.rs
  • crates/bitty-terminal/src/grammar.rs
  • crates/bitty-terminal/src/list.rs
  • crates/bitty-terminal/src/main.rs
  • crates/bitty-terminal/src/plus.rs
  • crates/bitty-terminal/tests/cli_list.rs
  • crates/bitty-terminal/tests/cli_plus_actions.rs
  • crates/bitty-terminal/tests/fixtures/completion/bash.txt
  • crates/bitty-terminal/tests/fixtures/completion/fish.txt
  • crates/bitty-terminal/tests/fixtures/completion/nushell.txt
  • crates/bitty-terminal/tests/fixtures/completion/powershell.txt
  • crates/bitty-terminal/tests/fixtures/completion/zsh.txt
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Xuepoo
Xuepoo force-pushed the ctx-1467/feat-cli-plus-actions branch from 7ed511d to 14131a6 Compare October 23, 2026 05:59
Xuepoo added a commit that referenced this pull request Oct 23, 2026
Address the #2550 review findings on the helper-action surface:

- Portable editor tests: use PATH-resolved `true`/`false` and a PATH-unique
  missing-editor name instead of `/bin/true` and an absolute missing path, so
  the Unix-only regressions also run on macOS.
- Reject `config edit`/`+edit-config` with `--safe`: safe mode never reads the
  edited file, so validating through the safe loader would report a false
  success. Exit 2 with `E_SAFE_UNSUPPORTED`, leave the file untouched, and
  remove `--safe` from the alias usage/flags.
- Attribute the `profile` JSON row from `LoadedConfig.profile_name`/
  `profile_path` (never `core-defaults/default`) and mark the derived
  `theme.contrast` row as `policy`/`policy`; add a `--profile` JSON regression.
- Compute `truncated` from the real row count, normalize editor failures to
  exit 1 with a message and `E_EDITOR_FAILED` (no-config-root remains
  `E_CONFIG_PATH`), and classify the Windows per-user font root.
- Rename remaining CTX-1446 code comments to the durable task CTX-1467.

Refs #2464.
@Xuepoo
Xuepoo force-pushed the ctx-1467/feat-cli-plus-actions branch from 56dc8ec to 191fdc6 Compare October 23, 2026 09:00
Xuepoo added a commit that referenced this pull request Oct 23, 2026
Address the #2550 review findings on the helper-action surface:

- Portable editor tests: use PATH-resolved `true`/`false` and a PATH-unique
  missing-editor name instead of `/bin/true` and an absolute missing path, so
  the Unix-only regressions also run on macOS.
- Reject `config edit`/`+edit-config` with `--safe`: safe mode never reads the
  edited file, so validating through the safe loader would report a false
  success. Exit 2 with `E_SAFE_UNSUPPORTED`, leave the file untouched, and
  remove `--safe` from the alias usage/flags.
- Attribute the `profile` JSON row from `LoadedConfig.profile_name`/
  `profile_path` (never `core-defaults/default`) and mark the derived
  `theme.contrast` row as `policy`/`policy`; add a `--profile` JSON regression.
- Compute `truncated` from the real row count, normalize editor failures to
  exit 1 with a message and `E_EDITOR_FAILED` (no-config-root remains
  `E_CONFIG_PATH`), and classify the Windows per-user font root.
- Rename remaining CTX-1446 code comments to the durable task CTX-1467.

Refs #2464.
@Xuepoo
Xuepoo force-pushed the ctx-1467/feat-cli-plus-actions branch from 191fdc6 to 49e2923 Compare October 23, 2026 09:15
@Xuepoo

Xuepoo commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Review finding (canonicalization wording) resolved at final head 564fbef99ecd78e2ea0bd7b7b13346b2e4cb5fb3.

  • Test comments and the assertion message now say canonical path equality: both the decoded profile: path and the fixture path are passed through std::fs::canonicalize, and the resulting PathBufs are compared. It no longer claims file identity.
  • No assertion was weakened or altered: the Windows test still canonicalizes both sides, and the profile layer:"profile" plus theme.contrast layer:"policy" assertions are unchanged.
  • Verified on this content: focused and full Linux cli_plus_actions (13/13), cargo fmt --check, clippy -D warnings, and cargo check -p bitty-terminal -p bitty-render --target x86_64-pc-windows-gnu --all-targets all clean.

Not merged.

@Xuepoo

Xuepoo commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Guard triage (bitty guard cron): CI red is infrastructure, not this diff.

Linux X11 (xvfb) / Linux Wayland fail in the perf-bench step with the hosted-runner disk-exhaustion signature tracked in #2561: bitty-perf statically links the whole crate graph into external/bitty-perf/target on top of the workspace target, the linker dies (SIGBUS / No space left on device on the actions-runner diag cache), and m1-results/*.tsv is never produced, so M1 matrix (Tier 1 aggregate) inherits the red.

One targeted rerun of the failed leaf jobs was attempted from this tick and reproduced the same signature. Per the guard rule this is not rerun-chased further and the PR is not merged past a red check. Every other leg (Quality gates, MSRV, macOS, Windows, supply chain, CodeQL, compat matrices) is green.

Blocked on: #2561 (reduce the bench footprint / move the perf build out of the M1 matrix legs). Re-queue this PR once #2561 lands, or report the green non-bench legs if the owner accepts a bench-leg exception here.

@Xuepoo Xuepoo mentioned this pull request Oct 23, 2026
@Xuepoo Xuepoo modified the milestones: v0.0.27, v0.0.28 Oct 23, 2026
@Xuepoo
Xuepoo force-pushed the ctx-1467/feat-cli-plus-actions branch from 9a668f4 to bba2ac9 Compare October 23, 2026 16:33
Xuepoo added a commit that referenced this pull request Oct 23, 2026
Address the #2550 review findings on the helper-action surface:

- Portable editor tests: use PATH-resolved `true`/`false` and a PATH-unique
  missing-editor name instead of `/bin/true` and an absolute missing path, so
  the Unix-only regressions also run on macOS.
- Reject `config edit`/`+edit-config` with `--safe`: safe mode never reads the
  edited file, so validating through the safe loader would report a false
  success. Exit 2 with `E_SAFE_UNSUPPORTED`, leave the file untouched, and
  remove `--safe` from the alias usage/flags.
- Attribute the `profile` JSON row from `LoadedConfig.profile_name`/
  `profile_path` (never `core-defaults/default`) and mark the derived
  `theme.contrast` row as `policy`/`policy`; add a `--profile` JSON regression.
- Compute `truncated` from the real row count, normalize editor failures to
  exit 1 with a message and `E_EDITOR_FAILED` (no-config-root remains
  `E_CONFIG_PATH`), and classify the Windows per-user font root.
- Rename remaining CTX-1446 code comments to the durable task CTX-1467.

Refs #2464.
…ctions (#2464)

Add bitty +<action> aliases over the canonical implementations instead of
parallel logic: the parser maps each alias onto the existing list, config, or
extension dispatch fields, so both spellings run one code path.

- +list-themes, +list-keybinds, +list-actions, +list-plugins map to list kinds.
- +list-colors adds the effective 16 ANSI + UI token catalog with resolved
  values and the shared theme contrast policy (no parallel rule).
- +list-fonts reuses the renderer's process-wide fontdb scan: family, style,
  and coarse source, sorted, deduplicated, capped at 512 rows, headless safe.
- +list-extensions maps to `extension list`; --safe is accepted as a no-op for
  the static inventory.
- +show-config, +validate-config, +edit-config map to new config show,
  validate, and edit verbs. show/validate emit stable envelope v1 JSON with
  per-key layer/source attribution; validate exits 2 on invalid config; edit
  re-validates after the editor exits without rewriting the user's bytes.
- Static lists load no plugin VM and open no network; --safe keeps builtin
  parity for themes/colors/config.
- Help, completion grammar, and golden fixtures cover every alias; CHANGELOG
  records the new surface. Manual/docs pages needing sync are named in the PR.

Refs #2464.
Address the #2550 review findings on the helper-action surface:

- Portable editor tests: use PATH-resolved `true`/`false` and a PATH-unique
  missing-editor name instead of `/bin/true` and an absolute missing path, so
  the Unix-only regressions also run on macOS.
- Reject `config edit`/`+edit-config` with `--safe`: safe mode never reads the
  edited file, so validating through the safe loader would report a false
  success. Exit 2 with `E_SAFE_UNSUPPORTED`, leave the file untouched, and
  remove `--safe` from the alias usage/flags.
- Attribute the `profile` JSON row from `LoadedConfig.profile_name`/
  `profile_path` (never `core-defaults/default`) and mark the derived
  `theme.contrast` row as `policy`/`policy`; add a `--profile` JSON regression.
- Compute `truncated` from the real row count, normalize editor failures to
  exit 1 with a message and `E_EDITOR_FAILED` (no-config-root remains
  `E_CONFIG_PATH`), and classify the Windows per-user font root.
- Rename remaining CTX-1446 code comments to the durable task CTX-1467.

Refs #2464.
#2464)

The profile-attribution regression built the expected source with
Path::display() and raw substring matching, but the JSON writer escapes
Windows backslashes. Parse the flat key row and compare decoded
value/layer/source fields instead, keeping the layer assertions for the
profile row and the derived theme.contrast policy row.

Verified with the focused Linux test and
`cargo check -p bitty-terminal -p bitty-render --target x86_64-pc-windows-gnu
--all-targets --locked`.

Refs #2464.
…ty (#2464)

Windows may render the same profile path in 8.3 short form in the config
envelope while the fixture holds the long form. Canonicalize the decoded
`profile: ` path and the fixture path before comparing, so the assertion
checks canonical path equality instead of a rendered string. This keeps
the profile `layer:"profile"` and `theme.contrast` `layer:"policy"`
assertions without weakening them to a file name.

Verified with the focused and full Linux cli_plus_actions suites and
`cargo check -p bitty-terminal -p bitty-render --target
x86_64-pc-windows-gnu --all-targets --locked`.

Refs #2464.
@Xuepoo
Xuepoo force-pushed the ctx-1467/feat-cli-plus-actions branch from 9b1ef8a to 41bb66b Compare October 23, 2026 20:00
@Xuepoo
Xuepoo merged commit 92306d9 into main Oct 23, 2026
20 checks passed
@Xuepoo
Xuepoo deleted the ctx-1467/feat-cli-plus-actions branch October 23, 2026 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:cli Area: command-line interface feat Feature P2 Priority: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Ghostty-style +list-* / +show-config helper actions

1 participant