返回 CodeWhale
AGENTS.md
根目录 / crates / tui / AGENTS.md
1 # TUI agent guidance
2
3 Scope: the terminal UI, its embedded runtime engine, and user-visible behavior.
4 Read the repository guidance first.
5
6 ## UI contracts
7
8 - One owner per fact: mode, permission and live counts in the posture bar
9 (`phase_strip.rs`, row 1 under the composer); model, context and the
10 session metrics — cost, ttft, tok/s, output tokens — in the metrics line
11 (`infoline.rs`, row 2); the roster and to-do in the work surface; receipts,
12 the active row and the phase in the transcript. Key hints come from the
13 `shell_key_routing` binding table, never from a string literal.
14 - Status-bar ink goes through `codewhale_palette::grammar` (`docs/design/STATUS_BAR_COLOR_GRAMMAR.md`).
15 Do not invent an eighth semantic or spend Failure red on non-failure chrome.
16 - Derive state from typed enums such as `ShellPhase` and `OceanTreatment`.
17 Renderers must not infer state from English strings or invent lifecycle state.
18 - Keep settled output still. Motion is semantic, bounded, and fully disabled by
19 reduced-motion settings.
20 - Route notices through the toast system, with typed level and lifetime; do not
21 add new writes to the legacy `status_message` sink.
22 - Compact layouts remove chrome before content. Selectable rows need recorded
23 hitboxes, visible focus, keyboard/mouse parity, and confirmation for
24 destructive actions.
25 - User-visible prose uses `tr(locale, MessageId::...)`. Commands, key names, and
26 glyphs are composed in code. Follow `locales/AGENTS.md` for string changes.
27
28 ## Runtime API has a consumer outside this repo
29
30 `runtime_api.rs` is the only API of the community VS Code extension
31 (`HengQuWorld/CodeWhale-VSCode`): it spawns `codewhale serve --http` and drives
32 every feature through `/v1/*` (`src/api/api-client.ts`). No test here exercises
33 that client, so an incompatible change lands silently. Additive routes and
34 optional fields are safe; renaming, removing, or changing a shipped route
35 (path, method, status, required fields, enum spelling) needs the extension's
36 client updated in the same change, or both shapes kept.
37
38 - The extension feature-detects by probing a route with the wrong method and
39 reading anything but `404` as present. Do not add a fallback that answers
40 `404` for an unrouted method; it disables those features rather than failing.
41 - It reads the listener port from `RUNTIME_LISTENING_PREFIX` on stdout and
42 rejects any other port, then requires `401` anonymously and `200` with the
43 bearer token.
44 - Advertise a `/v1/runtime/info` capability flag only while all its routes
45 exist; the extension cannot probe a family whose detail routes answer `404`.
46
47 `docs/RUNTIME_API.md` is the written contract. That repository also holds the
48 TUI/GUI parity rules for endpoint changes.
49
50 ## Verification
51
52 Select the smallest evidence that answers the actual risk. Direct PTY or
53 terminal behavior is stronger evidence for visible UX than an assertion over
54 render internals. Use a focused existing test for safety, data integrity,
55 protocol, or a reproduced regression when useful. Do not add tests by default,
56 and do not require both full suites or workspace Clippy for an unrelated leaf
57 change. These are available release/cross-cutting gates, not per-edit ritual:
58
59 ```sh
60 cargo test -p codewhale-tui --lib --locked
61 cargo test -p codewhale-tui --tests --locked
62 cargo clippy --workspace --all-targets --locked -- -D warnings
63 ```
64
65 `--lib` and `--tests` are disjoint; choose the target that owns the behavior.
66 Use both or the workspace gate only when the risk genuinely spans both.
67 `scripts/dev-test.sh <area|path> [filter]` prints and runs the fastest
68 targeted invocation for a source path (for example
69 `scripts/dev-test.sh crates/command-contract/src/elapsed.rs`). It uses `cargo nextest
70 run` when nextest is installed (`CODEWHALE_DEV_NEXTEST=0` forces libtest)
71 and applies `scripts/dev-cache.sh` to the canonical checkout's Cargo build-dir,
72 respecting existing cache settings. Keep the same checkout on `main`; do not
73 create a worktree for parallel edits or a build. For PTY
74 failures, reproduce the behavior directly before changing it. Script one input
75 at a time and capture after the UI settles. Choose the terminal sizes relevant
76 to the change from 40x12, 60x16, 80x24, 100x32, and 140x40; judge motion from
77 repeated frames, not a single screenshot. Remove inherited `NO_COLOR`,
78 `TERM=dumb`, and tmux motion overrides when they would invalidate the
79 observation.
80
80 lines MARKDOWN