Commit Graph

1719 Commits

Author SHA1 Message Date
Paulo Aboim Pinto f1afcf316f fix(tui): restore raw mode conditionally 2026-05-30 19:18:38 -07:00
Paulo Aboim Pinto ab95512c8f fix(tui): gate Windows shell detection 2026-05-30 19:18:38 -07:00
Paulo Aboim Pinto 45e7b12583 style(tui): format shell dispatcher stack 2026-05-30 19:18:38 -07:00
Paulo Aboim Pinto 6e5d8ddf01 feat(shell_dispatcher): harden PowerShell detection and add execution logging
- find_exe(): fall back to known install dirs when PATH lookup fails
  (C:\Program Files\PowerShell\7, System32\WindowsPowerShell\v1.0)
- Encoding prefix: use idiomatic [Console]::OutputEncoding for PowerShell
  instead of cmd.exe chcp 65001 >NUL
- Execution logging: write exec via <ShellKind> entries to
  SHELL_DISPATCHER_LOG when set
- System prompt: use ShellDispatcher detection instead of raw $SHELL
  so model knows it has PowerShell and generates native cmdlets
- display_command(): strip PowerShell encoding prefix for display
- Add tests for find_exe PATH + known-dir fallback

Refs #1779
2026-05-30 19:18:38 -07:00
Paulo Aboim Pinto 29625945de feat: add ShellDispatcher for shell-agnostic command execution
Introduces a central shell abstraction that replaces hardcoded
Command::new("cmd") / Command::new("sh") across the execution path.

- Shell detection at startup (pwsh -> powershell -> cmd -> sh)
- Correct quoting per shell (PowerShell uses -NoProfile -Command)
- Scope guards restore crossterm raw mode on all spawn paths (#1690)
- Direct program+args builder for sandbox ExecEnv integration

Files:
- crates/tui/src/shell_dispatcher.rs (new, 12 tests)
- crates/tui/src/main.rs (register module)
- crates/tui/src/eval.rs (exec_shell delegates to dispatcher)
- crates/tui/src/sandbox/mod.rs (CommandSpec::shell uses dispatcher)
- crates/tui/src/tools/shell.rs (raw mode guards on all spawn paths)

Closes #1690
Refs #1779
2026-05-30 19:18:38 -07:00
reidliu41 e32bd1af6d feat(update): add check-only release diagnostics
Add `codewhale update --check` so users can compare the installed version with
  the latest release without downloading or replacing binaries.

  Surface the same release check in `codewhale doctor`, and share release lookup,
  mirror handling, timeout, and version comparison logic between update and doctor.
2026-05-30 19:18:34 -07:00
LING71671 56d62edad4 fix(prompt): make tool taxonomy mode-aware 2026-05-30 19:18:31 -07:00
LING71671 a8c2728f54 feat(prompt): add core tool taxonomy block 2026-05-30 19:18:31 -07:00
Paulo Aboim Pinto bed328b7b5 test(tui): cover windows verbose state restore 2026-05-30 19:17:59 -07:00
Paulo Aboim Pinto 79cb61c1ac fix(tui): gate verbose snapshot helper on windows 2026-05-30 19:17:59 -07:00
Paulo Aboim Pinto e70f456abd fix(tui): preserve verbose state across windows alt-screen 2026-05-30 19:17:59 -07:00
Paulo Aboim Pinto 2077644ac2 fix(tui): gate verbose suppression behind alt-screen 2026-05-30 19:17:59 -07:00
Paulo Aboim Pinto 007140ec9e fix: suppress verbose CLI logging on Windows alt-screen to prevent TUI leak, restore on cleanup
On Windows, stderr cannot be redirected to the log file (no dup2). Suppress verbose CLI logging once the alt-screen is active so eprintln! calls from crate::logging don't leak into the TUI buffer. Also restores verbose logging on all cleanup paths after leaving alt-screen.
2026-05-30 19:17:59 -07:00
Zhuoran Deng 57625af4f8 docs(docker): tighten toolbox compose defaults 2026-05-30 19:17:55 -07:00
Zhuoran Deng 127f0565dd docs(docker): add toolbox compose template 2026-05-30 19:17:55 -07:00
Zhuoran Deng 2533c5a7e6 fix(tui): avoid live receipt history clones 2026-05-30 19:17:52 -07:00
Zhuoran Deng 17698b1820 fix(tui): receipt live large tool outputs 2026-05-30 19:17:52 -07:00
Zhuoran Deng 5e6b68b995 fix(tui): refine activity detail review feedback 2026-05-30 19:17:49 -07:00
Zhuoran Deng c2b572d969 feat(tui): enrich activity detail context 2026-05-30 19:17:49 -07:00
zhuang biaowei d26c2128b8 Retry MCP calls after stale SSE connections 2026-05-30 19:17:45 -07:00
zhuang biaowei 58c57cb798 Improve MCP SSE error diagnostics 2026-05-30 19:17:45 -07:00
zhuang biaowei 29417b3b37 Require explicit MCP SSE transport 2026-05-30 19:17:45 -07:00
zhuang biaowei 37f936eda4 Address MCP SSE review comments 2026-05-30 19:17:45 -07:00
zhuang biaowei b907ea123c Fix legacy MCP SSE connections 2026-05-30 19:17:45 -07:00
donglovejava 98cc2a6e50 fix: trailing newline in footer_ui.rs (cargo fmt) 2026-05-30 19:17:42 -07:00
donglovejava 9ef5a6d782 fix(tui): replace standalone compacting label with animated working label 2026-05-30 19:17:42 -07:00
Nightt 5c7209af83 fix: harden startup prompt dispatch 2026-05-30 19:17:39 -07:00
Nightt fde5959e3d feat: keep startup prompts interactive 2026-05-30 19:17:39 -07:00
Justin Gao 43f098965e fix: clear last_pinned_prefix_hash on model/provider switch
clear_model_scoped_telemetry() now resets last_pinned_prefix_hash to
None so /cache stats does not show the previous model/provider cache
scope's fingerprint after a switch.
2026-05-30 19:16:32 -07:00
Justin Gao a053d1e07a fix: address code review — stale hash, cache aggregation, hash clearing
- Move pinned_hash extraction after check_and_update() so the reported
  hash reflects the current prefix state, not the previous turn
- Skip non-cache-aware turns (cache_hit_tokens=None) in /cache stats
  aggregation; infer miss tokens when cache_miss_tokens is None
- Clear last_pinned_prefix_hash to None when pinned_combined_hash is
  empty (e.g. switching to a non-caching model/provider)
2026-05-30 19:16:32 -07:00
Justin Gao dd69f66775 chore: cargo fmt fixes for /cache stats PR 2026-05-30 19:16:32 -07:00
Justin Gao bcdaf81a04 feat: add /cache stats — prefix hash/drift exposure and cache-hit summary (#2264)
Surfaces the current pinned prefix fingerprint hash and stability
diagnostics via a new `/cache stats` subcommand, per the low-risk
0.8.x slice agreed on in #2264.

Changes:
- EngineEvent::PrefixCacheChange now carries pinned_combined_hash
  from PrefixStabilityManager so the TUI layer can surface it
- App.last_pinned_prefix_hash stores the hash per-turn for /cache stats
- New /cache stats command renders three sections:
  - Prefix Stability: pct, checks, changes, last-change description
  - Prefix Fingerprint: full SHA-256 hash, short id, drift warning
  - Cache Hit Rate: aggregated token totals + low-hit advisory
- format_tokens() helper for compact K/M token display
- 6 unit tests covering: no-data, stable, drift warning, hit-rate
  summary, low-hit advisory, token formatting

Refs: #2264
2026-05-30 19:16:32 -07:00
cyq 63be80d835 fix(tui): keep render debug logs in codewhale dir 2026-05-30 19:16:29 -07:00
cyq 8f93713860 feat(tui): add render diff debug log 2026-05-30 19:16:29 -07:00
donglovejava 03c4b6bd24 fix: trailing newline in project_context.rs (cargo fmt) 2026-05-30 19:16:25 -07:00
donglovejava 32f424df26 fix(tui): skip hidden worktrees in workspace discovery to prevent TUI saturation 2026-05-30 19:16:25 -07:00
Hunter Bown cb7614a918 fix(tui): skip hidden worktrees in discovery walks 2026-05-30 19:16:25 -07:00
donglovejava da590e5528 fix: remove spurious #[cfg(target_os = windows)] blocking ratatui import on non-Windows 2026-05-30 19:16:21 -07:00
donglovejava 09d3131dc2 fix(windows): restore ENABLE_WINDOW_INPUT console flag after enable_raw_mode for IME support 2026-05-30 19:16:21 -07:00
donglovejava 1ff5db1663 fix: cargo fmt and suppress dead_code warnings for unused paste-burst methods 2026-05-30 19:16:21 -07:00
donglovejava 09b4f7898b fix(tui): route IME-committed Chinese characters directly to composer instead of paste-burst buffer 2026-05-30 19:16:21 -07:00
donglovejava 5d0a1c848e fix(tools): eagerly load all exec_shell companion tools 2026-05-30 19:16:18 -07:00
Nightt 9d3d453c50 fix: use cached branch in footer 2026-05-30 19:16:15 -07:00
Nightt 06aa24a17a feat: show git branch in default footer 2026-05-30 19:16:15 -07:00
hexin 0b7660ddc5 docs(constitution): Tier 5 Local Law covers EngineConfig.instructions paths
Article VII Tier 5 currently lists four hard-coded path conventions
(AGENTS.md / CLAUDE.md / .codewhale/instructions.md / .deepseek/instructions.md)
as the canonical Local Law sources. Embedders that inject instructions via
`EngineConfig.instructions` (rather than placing files at one of those four
paths) get their files classified by path — and since their paths don't
match, the model defaults to treating their imperatives as Tier 7 Memory
(the lowest tier per Article VII), overridable by a single user sentence.

Adds an explicit clause to Tier 5: '...and any file configured via
`EngineConfig.instructions` (rendered as <instructions source=...> blocks
above). ...embedder-declared imperatives are Local Law, not Memory
preferences.'

Pairs naturally with #2311 (InstructionSource enum) but stands alone — this
is a doc/law clarification, not an API change.

Adds `local_law_tier_covers_engine_config_instructions` test pinning the
new clause's presence.
2026-05-30 19:15:41 -07:00
hexin bb4e876139 perf(prompts): move environment block below volatile boundary for per-session workspace embedders
The environment block (`platform`, `shell`, `pwd`, `lang`) was inserted
above the volatile-content boundary as a workspace-static cache layer. The
original comment claimed 'workspace path is fixed for the run' → static-
cacheable — true for the terminal use case where one process owns one
workspace for its lifetime.

It is **not** true for embedders that swap workspaces between sessions:

- IDE/GUI integrations binding the engine to a per-tab workspace
- Multi-engine pools with one engine per session
- Anything sending Op::SyncSession with a new workspace

For these embedders, `pwd` drifts session-to-session, dragging the entire
static prefix (mode prompt, project context, skills, context management,
compact template) out of cache reuse on every session switch. That's a
~30KB+ cache miss for a few-byte path change.

Moves the environment block below the volatile-content boundary, alongside
the configured `instructions = [...]` block. Effect:

- Static prefix stays byte-stable across sessions even when workspace
  changes (better KV prefix cache hit rate)
- Model still sees `pwd` / `platform` / `shell` (needed for exec_shell
  and structured search tools), just in a slightly later position
- No behavior change for terminal callers (workspace fixed → block content
  unchanged → still in same logical place, just below the boundary)

Added a comment explaining the per-session-workspace motivation.
2026-05-30 19:15:38 -07:00
ningjingkun dc6dcdfda2 docs: add first-run user guide 2026-05-30 19:15:34 -07:00
LING71671 02d1145add docs: clarify custom provider configuration 2026-05-30 19:15:31 -07:00
Nightt 402b186aec test: check tui provider enum drift 2026-05-30 19:15:28 -07:00
Hunter Bown e2099dd691 fix: harden provider registry drift check 2026-05-30 19:15:28 -07:00