chore: delete code comments, add ratchet lint and ADRs

Classify every comment as tautology, stale, excuse or decision record.
Tautology/stale/excuse comments are deleted (excuses filed as issues
#196-#236), decisions moved to docs/adr/0001-0034.

- scripts/lint-comments.sh + .comment-baseline: per-file comment count
  may only go down; wired into tests/all.sh
- .claude/skills/delete-comment: repeatable audit workflow
- cargo fmt applied to touched crates

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
johannesandClaude Sonnet 5.5 committed 2026-11-21 13:37:32 +01:00
1 parent 0545702fe0
commit a94632ea3d
131 files changed
+1051 -1746

No files matched your search

-29
View File
@@ -1,5 +1,3 @@
//! Transcript model and rendering (markdown-ish text, tool calls, diffs).
use crate::theme;
use hx_ai::StreamEvent;
use hx_core::hook::Event;
@@ -23,16 +21,13 @@ pub enum Item {
},
Info(String),
Error(String),
/// Hook reports injected at turn end (`[lens] …`), shown as the lens block.
Lens(Vec<String>),
}
#[derive(Default)]
pub struct Transcript {
pub items: Vec<Item>,
/// live output tails of running bash calls by command (copied from `State::live` per draw)
pub live: std::collections::HashMap<String, String>,
/// true while the last Assistant/Thinking item is still streaming
streaming: bool,
}
@@ -94,7 +89,6 @@ impl Transcript {
}
}
/// Rendered lines for a transcript `width` columns wide (tool headers right-align to it).
pub fn lines(&self, expanded: bool, width: u16) -> Vec<Line<'static>> {
let mut out = vec![];
for (n, it) in self.items.iter().enumerate() {
@@ -110,7 +104,6 @@ impl Transcript {
{
live_tail(tail, width as usize, &mut out);
}
// consecutive tool calls stack without a gap
let tool = |i: Option<&Item>| matches!(i, Some(Item::Tool { .. }));
if !(tool(Some(it)) && tool(self.items.get(n + 1))) {
out.push(Line::default());
@@ -119,7 +112,6 @@ impl Transcript {
out
}
/// The tool running right now, for the activity line.
pub fn running(&self) -> Option<(String, Instant)> {
self.items.iter().rev().find_map(|i| match i {
Item::Tool {
@@ -133,8 +125,6 @@ impl Transcript {
}
}
/// `⠹ working 38s · bash · ↓ 4.1k tokens esc to abort` — `frame` picks the spinner
/// glyph, `tokens` = output tokens of this run so far.
pub fn activity_line(
what: &str,
elapsed: Duration,
@@ -166,10 +156,8 @@ pub fn activity_line(
Line::from(l)
}
/// Last [`LIVE_LINES`] non-empty lines of a running command, dim and indented.
fn live_tail(tail: &str, width: usize, out: &mut Vec<Line<'static>>) {
let th = theme::t();
// carriage returns (progress bars): keep what's after the last one per line
let ls: Vec<&str> = tail
.lines()
.map(|l| l.rsplit('\r').next().unwrap_or(l))
@@ -193,7 +181,6 @@ fn target(args: &Value) -> String {
s.lines().next().unwrap_or_default().to_string()
}
/// Right-aligned outcome on the tool header: `+3 −1`, `12 lines`, `ok`, `exit 2`.
fn outcome(name: &str, content: &str, err: bool) -> String {
let m = theme::t().sym.minus;
if err {
@@ -216,7 +203,6 @@ fn outcome(name: &str, content: &str, err: bool) -> String {
.rsplit_once('(')
.map_or("ok".into(), |(_, r)| r.trim_end_matches(')').to_string()),
"read" => format!("{} lines", content.lines().count()),
// `[task explore · 12 tool calls · 41k tok · 38s]` is the last line of a task result
"task" => content
.lines()
.last()
@@ -234,7 +220,6 @@ fn fmt_dur(d: Duration) -> String {
}
}
/// Truncate to `w` display columns, adding an ellipsis when cut.
fn fit(s: &str, w: usize) -> String {
if Span::raw(s).width() <= w {
return s.to_string();
@@ -250,7 +235,6 @@ fn fit(s: &str, w: usize) -> String {
out + ell
}
/// `● edit src/a.rs ············ +3 −1 · 0.2s ▸`; running: spinner and live seconds.
fn tool_header(
name: &str,
args: &Value,
@@ -304,7 +288,6 @@ fn tool_header(
])
}
/// Prefix the first line with `mark` (styled) and indent the rest by two columns.
fn lead(lines: Vec<Line<'static>>, mark: &str, st: Style, out: &mut Vec<Line<'static>>) {
for (i, mut l) in lines.into_iter().enumerate() {
let p = if i == 0 {
@@ -372,8 +355,6 @@ fn render(it: &Item, expanded: bool, width: usize, out: &mut Vec<Line<'static>>)
}
}
/// `┄ lens ┄┄┄` rule, then per report a summary line (errors red, all-pass green) and,
/// collapsed, the first findings; `ctrl-o` shows all.
fn lens_block(texts: &[String], expanded: bool, width: usize, out: &mut Vec<Line<'static>>) {
let th = theme::t();
out.push(Line::styled(th.rule("lens", width), th.dim()));
@@ -385,7 +366,6 @@ fn lens_block(texts: &[String], expanded: bool, width: usize, out: &mut Vec<Line
.unwrap_or(first)
.trim_end_matches(':');
let rest: Vec<&str> = lines.collect();
// counts only mean something for diagnostics; test output quotes compiler lines
let diag = title.starts_with("diagnostics");
let count = |k: &str| rest.iter().filter(|l| diag && l.contains(k)).count();
let (errors, warnings) = (count(" error: "), count(" warning: "));
@@ -455,9 +435,6 @@ const LENS_PREVIEW: usize = 4;
const DIFF_PREVIEW: usize = 6;
const ERR_TAIL: usize = 5;
/// Body lines behind a gutter. Collapsed: edit diff preview, error tail, nothing otherwise.
/// Diffs get new-file line numbers from the `@@` headers. Returns true when output was
/// hidden (header shows the fold marker).
fn tool_body(
name: &str,
content: &str,
@@ -467,7 +444,6 @@ fn tool_body(
) -> bool {
let th = theme::t();
let is_diff = name == "edit" && !err;
// the edit tool's first line ("edited x") repeats the header
let lines: Vec<&str> = content.lines().skip(usize::from(is_diff)).collect();
let (show, before, after) = if expanded {
(&lines[..], 0, 0)
@@ -480,7 +456,6 @@ fn tool_body(
} else {
(&lines[..0], 0, lines.len())
};
// number column wide enough for the biggest new-file line in the hunks
let nw = if is_diff {
lines
.iter()
@@ -529,11 +504,9 @@ fn tool_body(
th.sym.ellipsis, th.sym.info
)));
}
// write output is just the header's "N lines"
!expanded && after > 0 && !is_diff && name != "write"
}
/// `@@ -a,b +c,d @@` → `c`.
fn hunk_start(l: &str) -> Option<usize> {
let r = l
.strip_prefix("@@ ")?
@@ -543,7 +516,6 @@ fn hunk_start(l: &str) -> Option<usize> {
r.split(',').next()?.parse().ok()
}
/// New-file line number for the line after `l`.
fn advance(cur: Option<usize>, l: &str) -> Option<usize> {
if let Some(n) = hunk_start(l) {
return Some(n);
@@ -616,7 +588,6 @@ mod tests {
.find(|l| text(std::slice::from_ref(l))[0] == " │ -old")
.unwrap();
assert_eq!(minus.spans[1].style.fg, theme::t().err().fg);
// new-file line numbers from the hunk header
assert!(s.contains(&" 1 │ +new".to_string()), "{s:?}");
}