M8: command registry, skills as slash commands, completion engine + popup, rpc complete
ci / check (push) Canceled after 0s
ci / check (pull_request) Canceled after 0s

Closes #68, closes #69, closes #70, closes #71, closes #72
This commit is contained in:
hermes committed 2026-09-30 22:05:04 +00:00
1 parent 6f0addcd47
commit 65765ce2b3
10 files changed
+651 -125

No files matched your search

+24 -3
View File
@@ -44,8 +44,14 @@ 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`. One prompt at a time.
pub async fn serve(mut agent: Agent, abort: AbortHandle) -> Result<()> {
/// `state`, `messages`, `fork {id}`, `clear`, `set_model {model}`, `compact`,
/// `complete {line, cursor?}` (cursor = byte offset, default end). One prompt at a time.
pub async fn serve(
mut agent: Agent,
abort: AbortHandle,
specs: Vec<hx_core::command::CmdSpec>,
files: Vec<String>,
) -> Result<()> {
agent.bus.add(Notify);
let agent = Arc::new(Mutex::new(agent));
let busy = Arc::new(std::sync::atomic::AtomicBool::new(false));
@@ -62,7 +68,22 @@ pub async fn serve(mut agent: Agent, abort: AbortHandle) -> Result<()> {
let id = m["id"].clone();
let p = &m["params"];
let method = m["method"].as_str().unwrap_or_default();
// abort must work while a prompt holds the agent lock
// 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()));
continue;
};
let cur = p["cursor"].as_u64().map_or(line.len(), |c| c as usize);
let c = hx_core::command::complete(line, cur, &specs, &files);
let items: Vec<_> = c
.items
.iter()
.map(|i| json!({"label": i.label, "detail": i.detail}))
.collect();
reply(&id, Ok(json!({"start": c.start, "items": items})));
continue;
}
if method == "abort" {
abort.abort();
reply(&id, Ok(json!({})));