- seq log: monotonic project/file seq with change source - minimal LSP JSON-RPC client (no lsp-types): framing, requests with timeout, server->client requests, publishDiagnostics with versions, $/progress + rust-analyzer serverStatus busy tracking - manager: built-in table (rust-analyzer, tsserver, pyright, gopls, clangd), outermost-root detection, lazy spawn, idle eviction, crash restart with 2-failure breaker, degradation notes, ContentModified retry, session-start warmup, config overrides/disable - turn-end hook: diagnostics for files changed this turn, errors first, per-file cap, total cap, unchanged findings not repeated, one 'no problems' after a fix; agent_end/off modes - lsp tool: diagnostics, definition, references, hover, symbols - tests: real rust-analyzer + pyright (skipped if absent); tests/lens_e2e.sh proves an introduced type error is surfaced and fixed without prompting Closes #21, closes #22, closes #23, closes #24, closes #25, closes #26
This commit is contained in:
1 parent
89c9833e43
commit
9b8cf48e21
13 files changed
+1522
-17
No files matched your search
+44
-11
@@ -31,8 +31,14 @@ pub struct Setup {
|
||||
pub default_model: fn(Kind) -> String,
|
||||
/// Pricing lookup for the footer; None = unknown.
|
||||
pub pricing: fn(&str) -> Option<hx_ai::Pricing>,
|
||||
/// `/lsp` status lines.
|
||||
pub lsp_status: LspStatus,
|
||||
}
|
||||
|
||||
pub type LspStatus = Box<
|
||||
dyn Fn() -> std::pin::Pin<Box<dyn std::future::Future<Output = Vec<String>> + Send>> + Send,
|
||||
>;
|
||||
|
||||
enum Ui {
|
||||
Ev(Event),
|
||||
Done(Result<(), String>),
|
||||
@@ -67,7 +73,7 @@ struct App {
|
||||
}
|
||||
|
||||
const HELP: &str = "enter send · alt-enter/ctrl-j newline · esc/ctrl-c abort · ctrl-o expand tools · pgup/pgdn scroll · tab @file · \
|
||||
/model <m> · /provider claude|codex · /compact · /clear · /quit";
|
||||
/model <m> · /provider claude|codex · /compact · /clear · /lsp · /quit";
|
||||
|
||||
fn project_files(root: &std::path::Path) -> Vec<String> {
|
||||
ignore::WalkBuilder::new(root)
|
||||
@@ -106,6 +112,7 @@ pub async fn run(setup: Setup) -> std::io::Result<()> {
|
||||
make_provider,
|
||||
default_model,
|
||||
pricing,
|
||||
lsp_status,
|
||||
} = setup;
|
||||
let (tx, mut rx) = mpsc::unbounded_channel();
|
||||
agent.bus.add(Forward(tx.clone()));
|
||||
@@ -146,6 +153,14 @@ pub async fn run(setup: Setup) -> std::io::Result<()> {
|
||||
)));
|
||||
let agent = Arc::new(Mutex::new(agent));
|
||||
|
||||
let ctx = Ctx {
|
||||
agent: &agent,
|
||||
tx: &tx,
|
||||
make_provider: &make_provider,
|
||||
default_model,
|
||||
cwd: &cwd,
|
||||
lsp_status: &lsp_status,
|
||||
};
|
||||
let mut term = ratatui::init();
|
||||
let mut keys = EventStream::new();
|
||||
let mut tick = tokio::time::interval(std::time::Duration::from_millis(50));
|
||||
@@ -161,7 +176,7 @@ pub async fn run(setup: Setup) -> std::io::Result<()> {
|
||||
match ev {
|
||||
TEvent::Key(k) if k.kind != KeyEventKind::Release => {
|
||||
if let Some(line) = on_key(&mut app, k, &abort) {
|
||||
submit(&mut app, line, &agent, &tx, &make_provider, default_model, &cwd).await;
|
||||
submit(&mut app, line, &ctx).await;
|
||||
}
|
||||
}
|
||||
TEvent::Paste(s) => app.ed.insert(&s),
|
||||
@@ -186,7 +201,7 @@ pub async fn run(setup: Setup) -> std::io::Result<()> {
|
||||
Ok(()) => {}
|
||||
}
|
||||
if let Some(next) = app.queue.pop_front() {
|
||||
submit(&mut app, next, &agent, &tx, &make_provider, default_model, &cwd).await;
|
||||
submit(&mut app, next, &ctx).await;
|
||||
}
|
||||
}
|
||||
Ui::Compacted(r) => {
|
||||
@@ -292,15 +307,25 @@ fn on_key(app: &mut App, k: KeyEvent, abort: &AbortHandle) -> Option<String> {
|
||||
None
|
||||
}
|
||||
|
||||
async fn submit(
|
||||
app: &mut App,
|
||||
line: String,
|
||||
agent: &Arc<Mutex<Agent>>,
|
||||
tx: &mpsc::UnboundedSender<Ui>,
|
||||
make_provider: &MakeProvider,
|
||||
/// Everything `submit` needs besides the app state.
|
||||
struct Ctx<'a> {
|
||||
agent: &'a Arc<Mutex<Agent>>,
|
||||
tx: &'a mpsc::UnboundedSender<Ui>,
|
||||
make_provider: &'a MakeProvider,
|
||||
default_model: fn(Kind) -> String,
|
||||
cwd: &std::path::Path,
|
||||
) {
|
||||
cwd: &'a std::path::Path,
|
||||
lsp_status: &'a LspStatus,
|
||||
}
|
||||
|
||||
async fn submit(app: &mut App, line: String, c: &Ctx<'_>) {
|
||||
let Ctx {
|
||||
agent,
|
||||
tx,
|
||||
make_provider,
|
||||
default_model,
|
||||
cwd,
|
||||
lsp_status,
|
||||
} = *c;
|
||||
app.scroll = 0;
|
||||
if let Some(cmd) = line.strip_prefix('/') {
|
||||
let (c, arg) = cmd
|
||||
@@ -313,6 +338,14 @@ async fn submit(
|
||||
match c {
|
||||
"quit" | "exit" => app.quit = true,
|
||||
"help" => app.t.push(Item::Info(HELP.into())),
|
||||
"lsp" => {
|
||||
let st = lsp_status().await;
|
||||
app.t.push(Item::Info(if st.is_empty() {
|
||||
"lsp: no servers started".into()
|
||||
} else {
|
||||
format!("lsp:\n{}", st.join("\n"))
|
||||
}));
|
||||
}
|
||||
"model" if arg.is_empty() => app.t.push(Item::Info(format!("model: {}", app.model))),
|
||||
"model" => {
|
||||
agent.lock().await.model = arg.into();
|
||||
|
||||
Reference in new issue
Block a user