7 Commits

Author SHA1 Message Date
Teknium
3149ad5ef7 refactor(tools): fold thread_context callback pairs, resolve_repo_root guard, final compaction (group I: 885->662 LOC) 2026-09-02 22:37:39 -07:00
Teknium
1b889dbc1e refactor(tools): unify worktree probes, fold terminal_scope config-yaml guard, rewrap hint tables, compact docstrings (group I) 2026-09-02 22:27:29 -07:00
Teknium
922083ab93 refactor(tools): trim subagent_worktree/terminal_scope/terminal_hints/thread_context/slash_confirm — drop no-op HERMES_HOME override, inline single-use constants, unify probes, compact docstrings 2026-09-02 22:00:49 -07:00
Teknium
5c919161d0 refactor(tools/approval): split approval.py into smart/human-wait/gateway-wait modules; dedupe guards 2026-09-02 14:44:14 -07:00
Teknium
d4cec15b47 refactor(tools): first-wave simplification of tools/ (file ops split, lazy_deps, code_exec, approval, browser, delegate, mcp, skills, terminal, voice, media)
Behavior-neutral structural pass over tools/*: god-file extractions into
sibling modules (file_operations_common/lint/search, file_tools_paths/
read_tracking/write, code_execution_env/rpc, tool_search_catalog/names/
validation, tts_command_provider, ...), duplicate helper unification,
if/elif -> dispatch tables, dead-code removal, docstring compaction.
Tool schemas (get_tool_definitions) verified byte-identical to base.
2026-09-02 14:43:45 -07:00
Teknium
8ad055414b fix(terminal): warn when exit_code 0 masks a piped build/test failure
`cargo build 2>&1 | tail -20` exits with tail's 0 even when the build
failed — bash without pipefail reports the last pipeline command's
status, and `cmd || echo failed` swallows the status the same way. The
model reads exit_code: 0 as a strong success signal and can conclude a
build passed while the visible output says it failed (community report,
Windows Rust builds; not platform-specific).

Two-part fix, mirroring OpenCode's prompt-side approach plus a
result-side backstop they don't have:

- Tool description now forbids piping builds/tests through
  tail/head/cat (output is already auto-truncated + spilled to a file)
  and warns that pipes/|| fallbacks mask exit codes.
- New annotate_masked_success() in tools/terminal_hints.py: when
  exit_code == 0, the command shape can mask an upstream status
  (top-level pipe into a passthrough consumer, or || echo/true), AND
  the output carries strong tool-specific failure shapes (rustc,
  cargo, pytest, gcc, npm, make, ninja), attach an advisory 'hint'
  telling the model to treat the run as failed and re-run bare.
  exit_code itself is never modified. Search/content heads
  (grep/rg/echo/printf/...) are excluded to avoid false positives on
  pipelines whose output legitimately contains error text.

E2E-verified through the real terminal tool path: hint fires on masked
cargo-style failures, silent on bare commands, clean pipes, and
grep/printf pipelines. 42 targeted tests pass.
2026-08-15 23:48:15 -07:00
Teknium
677473273e feat(terminal): output-pattern failure hints for common error classes
When a command exits non-zero, scan the first 4KB of output for
well-known failure shapes and attach one short, actionable recovery
hint to the tool result ('hint' field):

- gh 'Unknown JSON field' (9.2k occurrences in a 250k-call window)
- git merge conflicts (1.2k) — stop verbatim retries
- command not found (1.0k), incl. python->python3 and pip->pip3
- ModuleNotFoundError (739) — venv activation guidance
- 'already exists' (633), gh rate limits (133), permission denied
- exit-code-only tier: 124 timeout, 126 not-executable, 137 SIGKILL

Hints are suppressed when the existing exit_code_meaning tier already
explains the code (grep=1 etc). Pattern order = production frequency
from state.db mining; first match wins; pure function, no I/O.
2026-08-02 15:08:35 -07:00