diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..add689d --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,59 @@ +# Keeps the Cargo dependencies and the SHA-pinned actions in .github/workflows current. +# +# Version updates arrive at most monthly, and only for releases at least 7 days old, so a +# compromised release has time to be found and pulled. Minor and patch updates are grouped into +# one PR per ecosystem. Majors open as their own PRs, so one breaking upgrade cannot block the +# rest, and the PR limit leaves room for them beside the group. For a 0.x crate Dependabot counts +# a minor bump (0.28 to 0.29) as a major, as Cargo does. The TUI crates that must move together are +# the exception, in a group of their own. Security updates ignore the version-update groups and +# would open one PR per package, so they get their own group of minor and patch updates, and a +# security major opens on its own. +# +# rust-toolchain.toml sets `channel = "stable"` rather than a version, so it has nothing for +# Dependabot to bump and has no entry here. +# The tools ci.yml installs with taiki-e/install-action are pinned by version in its `tool` input, +# which Dependabot does not read, so those versions are bumped by hand. +version: 2 +updates: + - package-ecosystem: cargo + directory: / + schedule: + interval: monthly + cooldown: + default-days: 7 + open-pull-requests-limit: 5 + groups: + # ansi-to-tui depends on a ratatui version, and ratatui on a crossterm version, that + # ui/tui/Cargo.toml must match. deny.toml rejects duplicate versions, so one moving alone + # fails CI. They arrive as one PR, majors included. Dependabot gives a dependency to the + # first group that matches, so this group comes before the catch-all. + # Security updates move only the vulnerable crate, so a fix that needs a newer crossterm + # than ratatui allows arrives alone and fails deny. cargo audit fails CI meanwhile, and the + # fix is the ratatui upgrade this group proposes. + tui: + applies-to: version-updates + patterns: [ansi-to-tui, crossterm, ratatui] + cargo: + applies-to: version-updates + patterns: ['*'] + update-types: [minor, patch] + cargo-security: + applies-to: security-updates + patterns: ['*'] + update-types: [minor, patch] + - package-ecosystem: github-actions + directory: / + schedule: + interval: monthly + cooldown: + default-days: 7 + open-pull-requests-limit: 5 + groups: + actions: + applies-to: version-updates + patterns: ['*'] + update-types: [minor, patch] + actions-security: + applies-to: security-updates + patterns: ['*'] + update-types: [minor, patch] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6d8b04f..51e0367 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,10 @@ on: branches: [main] pull_request: +# CI only reads the repository, so its token can do nothing else, whatever the repo's default is. +permissions: + contents: read + jobs: check: # hub runs on macOS and is also developed in Linux sandboxes, so every push to main and every @@ -16,16 +20,27 @@ jobs: os: [macos-latest, ubuntu-latest] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 + # Each action is pinned to a full commit SHA, so a moved tag cannot change the action code CI + # runs. Dependabot proposes new pins (.github/dependabot.yml). The `stable` toolchain still + # follows the latest Rust release. + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 - - uses: dtolnay/rust-toolchain@stable - with: - components: rustfmt, clippy + # rustup is already on the hosted runners, so no third-party action installs the toolchain. + - name: install toolchain + run: rustup toolchain install stable --profile minimal --component rustfmt,clippy - - uses: Swatinem/rust-cache@v2 + - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3 - - name: install tools - run: cargo install cargo-audit cargo-deny cargo-nextest --locked + # Prebuilt binaries at exact versions, each checked against the checksum in the action's + # manifest, so CI compiles none of them, and a new release reaches CI only through a commit + # that changes its version here. `fallback: none` fails the step rather than building a + # version the manifest lacks. Dependabot does not read `tool`, so these versions are bumped + # by hand. This runs after rust-cache, so binaries the cache restores into ~/.cargo/bin are + # replaced rather than used. + - uses: taiki-e/install-action@5488ac5a951645ce95062214902ac4b6bc1a1037 # v2.87.32 + with: + tool: cargo-audit@0.22.2,cargo-deny@0.20.2,cargo-nextest@0.9.149,taplo@0.10.0 + fallback: none # rustfmt resolves mod declarations even behind #[cfg(feature = "private")], # so it fails if the private symlinks (from hub-private) aren't present. @@ -41,6 +56,14 @@ jobs: - name: fmt run: cargo fmt --check + # Dependabot edits the Cargo.toml files without running prek's hooks, so CI checks their + # formatting and TOML syntax the way prek.toml does. + - name: taplo fmt + run: taplo fmt --check + + - name: taplo check + run: taplo check + - name: clippy run: cargo clippy --all-targets -- -D warnings diff --git a/AGENTS.md b/AGENTS.md index bd80c6d..c159680 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -157,6 +157,12 @@ commits and the `Fixes #N` lines in them are lost, and the issues they fixed sta #384, 2026-10-28). An independent review of the change still runs before the push, and the user sees its findings first. +**A Dependabot PR that changes `Cargo.toml` or `Cargo.lock` is merged only after `just lint` and +`just test` pass at its head commit, in a checkout where `just setup-private` has linked every +hub-private module.** CI builds only the configuration without hub-private, so a dependency update +that breaks a hub-private build still passes CI. `just check` is not enough here: it rewrites files +and runs no tests. + ## Verifying TUI changes **Every change that alters what the TUI shows or how it behaves is driven live diff --git a/Cargo.lock b/Cargo.lock index 3894caf..7472889 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -919,7 +919,6 @@ dependencies = [ "domain", "futures", "insta", - "itertools", "open", "proptest", "pulldown-cmark", @@ -931,7 +930,6 @@ dependencies = [ "store", "syntect", "tokio", - "tui-textarea", "two-face", "workflows", ] @@ -2647,17 +2645,6 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" -[[package]] -name = "tui-textarea" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a5318dd619ed73c52a9417ad19046724effc1287fb75cdcc4eca1d6ac1acbae" -dependencies = [ - "crossterm", - "ratatui", - "unicode-width 0.2.0", -] - [[package]] name = "two-face" version = "0.5.1" diff --git a/docs/decisions/031-hub-builds-and-tests-on-macos-and-linux.md b/docs/decisions/031-hub-builds-and-tests-on-macos-and-linux.md index 9402aa6..0b808ee 100644 --- a/docs/decisions/031-hub-builds-and-tests-on-macos-and-linux.md +++ b/docs/decisions/031-hub-builds-and-tests-on-macos-and-linux.md @@ -21,8 +21,8 @@ date: 2026-11-01 ## Decision Every commit of hub, with or without each hub-private module, builds, passes clippy and passes its -tests on macOS and on Linux. CI builds, lints and tests every push on both, as a matrix of -`macos-latest` and `ubuntu-latest`. +tests on macOS and on Linux. CI builds, lints and tests every push to `main` and every pull +request on both, as a matrix of `macos-latest` and `ubuntu-latest`. hub runs on macOS. What only macOS has stays macOS-only behind `cfg(target_os = "macos")`: the disclaimed spawn of decision 027's addendum of 2026-11-01, launchd, and the notifications the diff --git a/docs/invariants/hub-builds-with-and-without-each-private-module.md b/docs/invariants/hub-builds-with-and-without-each-private-module.md index ae5a088..29cf83b 100644 --- a/docs/invariants/hub-builds-with-and-without-each-private-module.md +++ b/docs/invariants/hub-builds-with-and-without-each-private-module.md @@ -54,7 +54,7 @@ runs it, `just check` runs `just lint`, and prek runs `just lint` before every c fails, it names the configurations that failed and points here. Public CI checks only the first configuration, because it has no hub-private. It checks it on -both platforms: `.github/workflows/ci.yml` runs fmt, clippy, the tests, audit and deny on +both platforms: `.github/workflows/ci.yml` runs fmt, taplo, clippy, the tests, audit and deny on `macos-latest` and on `ubuntu-latest` for every push to `main` and every pull request. What the check misses: @@ -70,6 +70,9 @@ What the check misses: push, in only the fullest configuration the checkout has, and public CI runs only the one without hub-private. So the private configurations' tests run on Linux only when an orb runs `just test`, and the tests of hub-private without the media module never run on a device that has it. +- **Dependabot's commits.** Dependabot commits on GitHub, where prek never runs `just lint`. + AGENTS.md has a Dependabot PR that changes the Cargo files merged only after `just lint` and + `just test` pass in a checkout with every hub-private module linked. - **Runtime behaviour.** A stub that compiles can still do the wrong thing. `media_stub.rs` has a test asserting that it returns an error. That test runs only on a device without the media module. diff --git a/docs/questions/should-the-tui-be-rebuilt-in-textual.md b/docs/questions/should-the-tui-be-rebuilt-in-textual.md index 83f39fb..eeceaf8 100644 --- a/docs/questions/should-the-tui-be-rebuilt-in-textual.md +++ b/docs/questions/should-the-tui-be-rebuilt-in-textual.md @@ -65,10 +65,10 @@ same discussion and holds regardless of what the spike shows. all. Cost: the browser surface Decision 007 deferred stays expensive to reach, and the hand-drawn chrome plus the 545-line markdown renderer stay hub's to maintain. - **B. Rebuild in Textual.** Strongest case: `textual serve` keeps Decision 007's one reopening - condition cheap; Textual ships the `Markdown` widget, `TextArea` and CSS borders that five - dependencies currently provide (`pulldown-cmark`, `syntect`, `two-face`, `ansi-to-tui`, - `tui-textarea`); and Python is where the Claude Agent SDK lives if hub ever drives investigation - sessions rather than launching them through tmux. Cost: 641 tests and 51 snapshots do not port + condition cheap; Textual ships the `Markdown` widget and CSS borders that four dependencies + currently provide (`pulldown-cmark`, `syntect`, `two-face`, `ansi-to-tui`); and Python is where + the Claude Agent SDK lives if hub ever drives investigation sessions rather than launching them + through tmux. Cost: 641 tests and 51 snapshots do not port mechanically, and the domain newtypes lose compile-time enforcement in exchange for mypy at CI time. - **C. Not yet.** Strongest case: Decisions 021 and 022 are not fully built (the TUI still fetches @@ -91,9 +91,9 @@ into a decision record._ `render/` and `markdown/`, plus `main.rs`; `render/status_bar.rs` imports none of it. - *Measured* (2026-09-16): Textual's latest release is v8.2.8, 30 June 2026, from https://github.com/Textualize/textual/releases. -- *Sourced*: `ui/tui/Cargo.toml` pins ratatui at 0.29 because 0.30 moved `Widget` into a separate - crate, and pins itertools at 0.13 solely to match ratatui's own copy and satisfy `cargo-deny`'s - duplicate-version ban. Both pins carry the reason in a manifest comment. +- *Sourced*: `ui/tui/Cargo.toml` keeps ratatui at 0.29 because `ansi-to-tui` 7 depends on it, and + `ansi-to-tui` 8 moved to `ratatui-core` with ratatui 0.30. `crossterm` follows ratatui's copy to + satisfy `cargo-deny`'s duplicate-version ban. The manifest comments carry both reasons. - *Sourced*: there is no release pipeline. `.github/workflows/ci.yml` runs checks and produces no artifacts; installation is `cargo install --path ui/tui` on the machine that will run it. Neither language has a distribution advantage here until that changes. diff --git a/ui/tui/Cargo.toml b/ui/tui/Cargo.toml index 0e3b664..81f70c1 100644 --- a/ui/tui/Cargo.toml +++ b/ui/tui/Cargo.toml @@ -22,21 +22,16 @@ chrono = "0.4" clients = { path = "../../clients" } config = { path = "../../config" } + # The crossterm version ratatui depends on (0.28 for ratatui 0.29). deny.toml rejects a second + # copy, so this moves with ratatui. crossterm = { version = "0.28", features = ["event-stream"] } domain = { path = "../../domain" } futures = "0.3" - # Pinned to 0.13 to unify with ratatui 0.29, which also depends on itertools 0.13. - # cargo-deny's bans check rejects duplicate versions; only with_position()/Position - # are used here, an API present in both 0.13 and 0.14. Bump in lockstep with ratatui. - itertools = "0.13" open = "5" pulldown-cmark = { version = "0.13", default-features = false } - # Pinned to 0.29 to unify with tui-textarea 0.7, which also depends on 0.29. - # tui-textarea 0.7 implements ratatui 0.29's Widget trait; ratatui 0.30 moved - # Widget into a new ratatui-core crate, making set_block() and direct TextArea - # rendering fail to compile. Before bumping this, check that the target - # tui-textarea version also supports the new ratatui version — and keep - # ansi-to-tui in sync (v8 switched to ratatui-core; v7 uses ratatui 0.29). + # ansi-to-tui must depend on this ratatui version: v7 uses ratatui 0.29, and v8 moved to + # ratatui-core with ratatui 0.30. ratatui, crossterm and ansi-to-tui move together, and + # Dependabot proposes them as one PR (the `tui` group in .github/dependabot.yml). ratatui = "0.29" rusqlite = { version = "0.31", features = ["bundled"] } secrecy = "0.8" @@ -50,7 +45,6 @@ "regex-fancy", ] } tokio = { version = "1", features = ["full"] } - tui-textarea = { version = "0.7", features = ["crossterm"] } two-face = { version = "0.5", default-features = false, features = [ "syntect-fancy", ] } diff --git a/ui/tui/src/markdown/README.md b/ui/tui/src/markdown/README.md index f82e5e4..d9355f0 100644 --- a/ui/tui/src/markdown/README.md +++ b/ui/tui/src/markdown/README.md @@ -4,7 +4,7 @@ Vendored and patched fork of [tui-markdown 0.3.7][tui-markdown] (MIT/Apache-2.0) ## What changed -Two lines in `mod.rs` differ from upstream: +These changes in `render.rs` differ from upstream: 1. **`SYNTAX_SET`** — uses `two_face::syntax::extra_newlines()` instead of `SyntaxSet::load_defaults_newlines()`. This extends the bundled syntax set from @@ -14,6 +14,9 @@ Two lines in `mod.rs` differ from upstream: 2. **`MOCHA_THEME`** — uses `two_face::theme::extra().get(EmbeddedThemeName::CatppuccinMocha)` instead of `base16-ocean.dark`. +3. **`text`** — splits multi-line text with `enumerate()` where upstream uses + `itertools::with_position()`, so hub does not depend on `itertools`. + `style_sheet.rs` adds `CatppuccinStyleSheet`, which the module's `from_str` uses as its default. It styles headings and inline code in Mocha mauve to match `FOCUS_COLOR` in `render/mod.rs`. @@ -24,8 +27,8 @@ avoid the `tracing` dependency. ## Staying in sync with upstream [tui-markdown releases][releases] are infrequent. If a new version ships, diff -`src/lib.rs` from upstream against `mod.rs` here, apply any logic changes, and -re-apply the two patches above. +`src/lib.rs` from upstream against `render.rs` here, apply any logic changes, and +re-apply the patches above. [tui-markdown]: https://github.com/joshka/tui-markdown [releases]: https://github.com/joshka/tui-markdown/releases diff --git a/ui/tui/src/markdown/mod.rs b/ui/tui/src/markdown/mod.rs index c821a18..ada8eaf 100644 --- a/ui/tui/src/markdown/mod.rs +++ b/ui/tui/src/markdown/mod.rs @@ -2,6 +2,7 @@ // - SYNTAX_SET uses two-face's extended syntax set (adds TypeScript, TOML, etc.) // - Theme uses two-face's built-in CatppuccinMocha instead of base16-ocean.dark // - tracing instrumentation removed +// - multi-line text split with enumerate() instead of itertools' with_position() // - pub(crate) visibility throughout pub(crate) mod options; pub(crate) mod render; diff --git a/ui/tui/src/markdown/render.rs b/ui/tui/src/markdown/render.rs index 74676f5..eb44038 100644 --- a/ui/tui/src/markdown/render.rs +++ b/ui/tui/src/markdown/render.rs @@ -2,12 +2,12 @@ // - SYNTAX_SET uses two-face's extended syntax set (adds TypeScript, TOML, etc.) // - Theme uses two-face's built-in CatppuccinMocha instead of base16-ocean.dark // - tracing instrumentation removed +// - multi-line text split with enumerate() instead of itertools' with_position() // - pub(crate) visibility throughout use std::sync::LazyLock; use ansi_to_tui::IntoText; -use itertools::{Itertools, Position}; use pulldown_cmark::{ BlockQuoteKind, CodeBlockKind, CowStr, Event, HeadingLevel, Options as ParseOptions, Parser, Tag, TagEnd, @@ -294,12 +294,12 @@ where return; } - for (position, line) in text.lines().with_position() { + for (i, line) in text.lines().enumerate() { if self.needs_newline { self.push_line(Line::default()); self.needs_newline = false; } - if matches!(position, Position::Middle | Position::Last) { + if i > 0 { self.push_line(Line::default()); } let style = self.inline_styles.last().copied().unwrap_or_default(); @@ -521,6 +521,24 @@ mod tests { ); } + fn line_texts(lines: &[Line]) -> Vec { + lines + .iter() + .map(|l| l.spans.iter().map(|s| s.content.as_ref()).collect()) + .collect() + } + + #[rstest] + #[case::one_line("```\nonly\n```\n", &["```", "only", "```"])] + #[case::two_lines("```\nhello\nworld\n```\n", &["```", "hello", "world", "```"])] + #[case::blank_middle_line("```\na\n\nb\n```\n", &["```", "a", "", "b", "```"])] + fn fence_text_renders_one_line_per_source_line( + #[case] markdown: &str, + #[case] expected: &[&str], + ) { + assert_eq!(line_texts(&from_str(markdown).lines), expected); + } + #[test] fn unlanguaged_fence_delimiters_are_unstyled() { let styles = fence_styles(&from_str("```\nhello\n```\n").lines);