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

-12
View File
@@ -1,5 +1,3 @@
//! Machine interfaces: NDJSON event stream (`--mode json`) and JSON-RPC over stdio (`--mode rpc`).
use anyhow::Result;
use hx_core::agent::{AbortHandle, Agent};
use hx_core::hook::{Event, Hook, HookAction};
@@ -9,14 +7,12 @@ use std::sync::Arc;
use tokio::io::AsyncBufReadExt;
use tokio::sync::Mutex;
/// One JSON line on stdout.
pub fn emit(v: &Value) {
let mut o = std::io::stdout().lock();
let _ = writeln!(o, "{v}");
let _ = o.flush();
}
/// `--mode json`: every bus event as one NDJSON line.
pub struct Ndjson;
#[async_trait::async_trait]
impl Hook for Ndjson {
@@ -26,7 +22,6 @@ impl Hook for Ndjson {
}
}
/// RPC mode forwards events as `event` notifications.
struct Notify;
#[async_trait::async_trait]
impl Hook for Notify {
@@ -43,10 +38,6 @@ fn reply(id: &Value, r: Result<Value, String>) {
});
}
/// Methods: `prompt {text}` (replies when the run ends; events stream meanwhile), `abort`,
/// `state`, `messages`, `fork {id}`, `clear`, `set_model {model}`, `compact`,
/// `complete {line, cursor?}` (cursor = byte offset, default end), `sessions {scope?: project|all}`,
/// `new`, `resume {path}`. One prompt at a time.
pub struct Ctx {
pub specs: Vec<hx_core::command::CmdSpec>,
pub files: Vec<String>,
@@ -77,7 +68,6 @@ pub async fn serve(mut agent: Agent, abort: AbortHandle, cx: Ctx) -> Result<()>
let id = m["id"].clone();
let p = &m["params"];
let method = m["method"].as_str().unwrap_or_default();
// abort and complete must work while a prompt holds the agent lock
if method == "complete" {
let Some(line) = p["line"].as_str() else {
reply(&id, Err("params.line required".into()));
@@ -141,7 +131,6 @@ pub async fn serve(mut agent: Agent, abort: AbortHandle, cx: Ctx) -> Result<()>
.map(|_| json!({"session": a.session().path()}))
.map_err(|e| e.to_string()),
"set_model" => match p["model"].as_str() {
// switches provider too when the model belongs to another one
Some(m) => switcher
.set_model(&mut a, m)
.map(|sw| {
@@ -185,7 +174,6 @@ pub async fn serve(mut agent: Agent, abort: AbortHandle, cx: Ctx) -> Result<()>
reply(&id, r);
}
}
// stdin closed: let a running prompt finish
for h in running {
let _ = h.await;
}