Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
39a4e0c625 | ||
|
|
dc0a329ae1 | ||
|
|
ca6b917b17 | ||
|
|
042f1ed3b5 | ||
|
|
9843e5305c | ||
|
|
047e781ca4 | ||
|
|
cfb517e806 | ||
|
|
dac2320503 | ||
|
|
130704b8b3 |
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"version": "0.1.0",
|
"version": "0.1.3",
|
||||||
"sha256": {
|
"sha256": {
|
||||||
"aarch64-apple-darwin": "b6c5b91a839ceb80be69d24a94fb8114f4150a039b7f8873381aa1efcb35a26c",
|
"aarch64-apple-darwin": "0fa455f5cc4c63df942224602ecad0b83ee91847cef6fde8f0e4704bf0913810",
|
||||||
"x86_64-unknown-linux-musl": "a5079b8655af0046b4cca0af76e118b3d91c3048f6c3eab4f763a1bd4f85ba62"
|
"x86_64-unknown-linux-musl": "8bc56e52a403088229e25470ccd12b2b7fe9e1195062206827beff9be630f3f7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1117,6 +1117,26 @@ async fn main() -> Result<()> {
|
|||||||
}) as _)
|
}) as _)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
reload: {
|
||||||
|
let (mcp, cwd, models, kinds) =
|
||||||
|
(mcp.clone(), cwd.clone(), models.clone(), kinds.clone());
|
||||||
|
Box::new(move || {
|
||||||
|
let cfg = Config::load(&cwd).map_err(|e| e.to_string())?;
|
||||||
|
let mut sys = format!(
|
||||||
|
"{}{}",
|
||||||
|
cfg.system_prompt
|
||||||
|
.as_deref()
|
||||||
|
.unwrap_or(context::DEFAULT_PROMPT),
|
||||||
|
context::prompt_tail(&context::hx_home(), &cwd)
|
||||||
|
);
|
||||||
|
let idx = mcp.system_prompt();
|
||||||
|
if !idx.is_empty() {
|
||||||
|
sys.push_str("\n\n");
|
||||||
|
sys.push_str(&idx);
|
||||||
|
}
|
||||||
|
Ok((sys, command_specs(&mcp, &cwd, &models, &kinds)))
|
||||||
|
})
|
||||||
|
},
|
||||||
lsp_status: {
|
lsp_status: {
|
||||||
let (m, l) = (mgr.clone(), lens_ref.clone());
|
let (m, l) = (mgr.clone(), lens_ref.clone());
|
||||||
Box::new(move || {
|
Box::new(move || {
|
||||||
|
|||||||
@@ -243,6 +243,10 @@ impl Agent {
|
|||||||
self.effort = e;
|
self.effort = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn system(&self) -> &str {
|
||||||
|
&self.system
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_system(&mut self, system: impl Into<String>) {
|
pub fn set_system(&mut self, system: impl Into<String>) {
|
||||||
self.system = system.into();
|
self.system = system.into();
|
||||||
self.publish();
|
self.publish();
|
||||||
|
|||||||
@@ -78,7 +78,12 @@ pub async fn serve(path: &Path, cx: ToolCtx) -> std::io::Result<()> {
|
|||||||
}
|
}
|
||||||
let v: Value = serde_json::from_str(&line).unwrap_or_default();
|
let v: Value = serde_json::from_str(&line).unwrap_or_default();
|
||||||
// hx tools run by `codemode` inside mcp-serve ask for their own permission
|
// hx tools run by `codemode` inside mcp-serve ask for their own permission
|
||||||
let ok = if let Some(q) = v.get("permit") {
|
let mut input = None;
|
||||||
|
let ok = if v["tool_name"] == "AskUserQuestion" {
|
||||||
|
// claude's own question tool: show hx's popup, hand the answers back as input
|
||||||
|
input = ask(&cx, &v["input"]).await;
|
||||||
|
input.is_some()
|
||||||
|
} else if let Some(q) = v.get("permit") {
|
||||||
let s = |k: &str| q[k].as_str().unwrap_or_default().to_string();
|
let s = |k: &str| q[k].as_str().unwrap_or_default().to_string();
|
||||||
gate(
|
gate(
|
||||||
&cx,
|
&cx,
|
||||||
@@ -96,13 +101,40 @@ pub async fn serve(path: &Path, cx: ToolCtx) -> std::io::Result<()> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
let _ = w
|
let _ = w
|
||||||
.write_all(format!("{}\n", json!({"allow": ok})).as_bytes())
|
.write_all(format!("{}\n", json!({"allow": ok, "input": input})).as_bytes())
|
||||||
.await;
|
.await;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn roundtrip(path: &Path, msg: Value) -> bool {
|
/// Run each `AskUserQuestion` question through the popup; `input` plus `answers` (question -> label(s)).
|
||||||
|
/// None = no frontend or dismissed.
|
||||||
|
async fn ask(cx: &ToolCtx, input: &Value) -> Option<Value> {
|
||||||
|
let mut answers = serde_json::Map::new();
|
||||||
|
for q in input["questions"].as_array()? {
|
||||||
|
let text = q["question"].as_str().unwrap_or_default();
|
||||||
|
let options = q["options"].as_array().into_iter().flatten().map(|o| {
|
||||||
|
let s = |k| o[k].as_str().unwrap_or_default().to_string();
|
||||||
|
(s("label"), s("description"))
|
||||||
|
});
|
||||||
|
let r = cx
|
||||||
|
.state
|
||||||
|
.choose(crate::Question {
|
||||||
|
text: text.into(),
|
||||||
|
options: options.collect(),
|
||||||
|
multi: q["multiSelect"].as_bool().unwrap_or(false),
|
||||||
|
other: true,
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.ok()??;
|
||||||
|
answers.insert(text.into(), r.join(", ").into());
|
||||||
|
}
|
||||||
|
let mut out = input.clone();
|
||||||
|
out["answers"] = answers.into();
|
||||||
|
Some(out)
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn roundtrip(path: &Path, msg: Value) -> Option<Value> {
|
||||||
let ask = async {
|
let ask = async {
|
||||||
let mut c = UnixStream::connect(path).await?;
|
let mut c = UnixStream::connect(path).await?;
|
||||||
c.write_all(format!("{msg}\n").as_bytes()).await?;
|
c.write_all(format!("{msg}\n").as_bytes()).await?;
|
||||||
@@ -113,7 +145,7 @@ async fn roundtrip(path: &Path, msg: Value) -> bool {
|
|||||||
ask.await
|
ask.await
|
||||||
.ok()
|
.ok()
|
||||||
.and_then(|l| serde_json::from_str::<Value>(&l).ok())
|
.and_then(|l| serde_json::from_str::<Value>(&l).ok())
|
||||||
.is_some_and(|v| v["allow"] == true)
|
.filter(|v| v["allow"] == true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Permission hook for tools that run in another process (`hx mcp-serve`): ask the owner of the socket.
|
/// Permission hook for tools that run in another process (`hx mcp-serve`): ask the owner of the socket.
|
||||||
@@ -125,7 +157,7 @@ pub fn remote_permit(path: PathBuf) -> crate::permit::Permit {
|
|||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
let m = json!({"permit": {"tool": r.tool, "detail": r.detail, "rule": r.rule}});
|
let m = json!({"permit": {"tool": r.tool, "detail": r.detail, "rule": r.rule}});
|
||||||
// the owner stores "always" itself; here a yes is a plain yes
|
// the owner stores "always" itself; here a yes is a plain yes
|
||||||
if roundtrip(&path, m).await {
|
if roundtrip(&path, m).await.is_some() {
|
||||||
Decision::Once
|
Decision::Once
|
||||||
} else {
|
} else {
|
||||||
Decision::Deny
|
Decision::Deny
|
||||||
@@ -149,9 +181,10 @@ impl Tool for Approve {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
async fn call(&self, args: Value, _cx: &ToolCtx) -> ToolResult {
|
async fn call(&self, args: Value, _cx: &ToolCtx) -> ToolResult {
|
||||||
let ok = roundtrip(&self.0, args.clone()).await;
|
let r = roundtrip(&self.0, args.clone()).await;
|
||||||
ToolResult::ok(if ok {
|
ToolResult::ok(if let Some(r) = r {
|
||||||
json!({"behavior": "allow", "updatedInput": args["input"]})
|
let input = if r["input"].is_null() { &args["input"] } else { &r["input"] };
|
||||||
|
json!({"behavior": "allow", "updatedInput": input})
|
||||||
} else {
|
} else {
|
||||||
json!({"behavior": "deny", "message": "denied by the user; do not retry, ask what to do instead"})
|
json!({"behavior": "deny", "message": "denied by the user; do not retry, ask what to do instead"})
|
||||||
}
|
}
|
||||||
@@ -179,6 +212,20 @@ mod tests {
|
|||||||
assert_eq!(question("Foo", &json!({})).unwrap().rule, "claude:Foo");
|
assert_eq!(question("Foo", &json!({})).unwrap().rule, "claude:Foo");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn ask_user_question_uses_popup() {
|
||||||
|
let cx = ToolCtx {
|
||||||
|
cwd: ".".into(),
|
||||||
|
state: Default::default(),
|
||||||
|
};
|
||||||
|
let inp = json!({"questions": [{"question": "Which?", "options": [{"label": "A"}, {"label": "B"}]}]});
|
||||||
|
assert!(ask(&cx, &inp).await.is_none(), "no frontend = deny");
|
||||||
|
let _ = cx.state.choose.set(std::sync::Arc::new(|q| {
|
||||||
|
Box::pin(async move { Some(vec![q.options[1].0.clone()]) })
|
||||||
|
}));
|
||||||
|
assert_eq!(ask(&cx, &inp).await.unwrap()["answers"]["Which?"], "B");
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn socket_round_trip_allows_and_denies() {
|
async fn socket_round_trip_allows_and_denies() {
|
||||||
use crate::permit::Decision;
|
use crate::permit::Decision;
|
||||||
|
|||||||
@@ -98,6 +98,11 @@ pub fn builtins(models: &[&str]) -> Vec<CmdSpec> {
|
|||||||
),
|
),
|
||||||
b("btw", "side question; no tools, not saved", Free),
|
b("btw", "side question; no tools, not saved", Free),
|
||||||
b("skills", "list skills and where they load from", None),
|
b("skills", "list skills and where they load from", None),
|
||||||
|
b(
|
||||||
|
"reload",
|
||||||
|
"re-read AGENTS.md, skills, config, MCP prompt index",
|
||||||
|
None,
|
||||||
|
),
|
||||||
b(
|
b(
|
||||||
"resume",
|
"resume",
|
||||||
"resume a session file; no arg opens /sessions",
|
"resume a session file; no arg opens /sessions",
|
||||||
|
|||||||
@@ -97,6 +97,34 @@ struct Front {
|
|||||||
argument_hint: Option<String>,
|
argument_hint: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Fallback for frontmatter that is not valid YAML: `key: value` on one line, value taken verbatim
|
||||||
|
/// (surrounding quotes stripped). None when no known key is found.
|
||||||
|
fn lenient_front(fm: &str) -> Option<Front> {
|
||||||
|
let mut f = Front::default();
|
||||||
|
let mut found = false;
|
||||||
|
for line in fm.lines() {
|
||||||
|
let Some((k, v)) = line.split_once(':') else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
let v = v.trim();
|
||||||
|
let v = v
|
||||||
|
.strip_prefix('"')
|
||||||
|
.and_then(|x| x.strip_suffix('"'))
|
||||||
|
.unwrap_or(v)
|
||||||
|
.to_string();
|
||||||
|
match k {
|
||||||
|
"name" => f.name = Some(v),
|
||||||
|
"description" => f.description = Some(v),
|
||||||
|
"load" => f.load = Some(v),
|
||||||
|
"disable-model-invocation" => f.disable_model_invocation = Some(v == "true"),
|
||||||
|
"argument-hint" => f.argument_hint = Some(v),
|
||||||
|
_ => continue,
|
||||||
|
}
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
found.then_some(f)
|
||||||
|
}
|
||||||
|
|
||||||
/// Skill dirs, lowest priority first: `~/.claude/skills`, `~/.agents/skills` (shared with other agents),
|
/// Skill dirs, lowest priority first: `~/.claude/skills`, `~/.agents/skills` (shared with other agents),
|
||||||
/// `<hx home>/skills`, `<project>/.agents/skills`, `<project>/.claude/skills`, `<project>/.hx/skills`.
|
/// `<hx home>/skills`, `<project>/.agents/skills`, `<project>/.claude/skills`, `<project>/.hx/skills`.
|
||||||
pub fn skill_dirs(home: &Path, cwd: &Path) -> Vec<PathBuf> {
|
pub fn skill_dirs(home: &Path, cwd: &Path) -> Vec<PathBuf> {
|
||||||
@@ -133,7 +161,11 @@ pub fn parse_skill(p: &Path, s: &str) -> Result<Skill, String> {
|
|||||||
let f: Front = if fm.trim().is_empty() {
|
let f: Front = if fm.trim().is_empty() {
|
||||||
Front::default()
|
Front::default()
|
||||||
} else {
|
} else {
|
||||||
serde_norway::from_str(fm).map_err(|e| e.to_string())?
|
match serde_norway::from_str(fm) {
|
||||||
|
Ok(f) => f,
|
||||||
|
// strict YAML failed (e.g. unquoted `: ` in a description): read single-line top-level keys
|
||||||
|
Err(e) => lenient_front(fm).ok_or_else(|| e.to_string())?,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
let load = match f.load.as_deref() {
|
let load = match f.load.as_deref() {
|
||||||
Some("always") => Load::Always,
|
Some("always") => Load::Always,
|
||||||
@@ -307,7 +339,7 @@ mod tests {
|
|||||||
assert!(!k.model_invocable && k.load == Load::Auto);
|
assert!(!k.model_invocable && k.load == Load::Auto);
|
||||||
let k = parse_skill(p, "---\nname: n\ndescription: |\n a\n b\n---\n").unwrap();
|
let k = parse_skill(p, "---\nname: n\ndescription: |\n a\n b\n---\n").unwrap();
|
||||||
assert_eq!(k.description, "a b");
|
assert_eq!(k.description, "a b");
|
||||||
assert!(parse_skill(p, "---\ndescription: [oops\n---\nB").is_err());
|
assert!(parse_skill(p, "---\noops: [oops\n---\nB").is_err());
|
||||||
let k = parse_skill(p, "no frontmatter").unwrap();
|
let k = parse_skill(p, "no frontmatter").unwrap();
|
||||||
assert_eq!((k.name.as_str(), k.body.as_str()), ("n", "no frontmatter"));
|
assert_eq!((k.name.as_str(), k.body.as_str()), ("n", "no frontmatter"));
|
||||||
assert!(
|
assert!(
|
||||||
@@ -329,7 +361,8 @@ load: manual
|
|||||||
for (n, fm) in [
|
for (n, fm) in [
|
||||||
("ok", "description: fine"),
|
("ok", "description: fine"),
|
||||||
("hid", "description: secret\ndisable-model-invocation: true"),
|
("hid", "description: secret\ndisable-model-invocation: true"),
|
||||||
("bad", "description: [oops"),
|
("bad", "oops: [oops"),
|
||||||
|
("colon", "description: before code exists: when asked"),
|
||||||
] {
|
] {
|
||||||
let d = t.path().join("s").join(n);
|
let d = t.path().join("s").join(n);
|
||||||
std::fs::create_dir_all(&d).unwrap();
|
std::fs::create_dir_all(&d).unwrap();
|
||||||
@@ -337,7 +370,8 @@ load: manual
|
|||||||
}
|
}
|
||||||
let (sk, warn) = scan_skills(&[t.path().join("s")]);
|
let (sk, warn) = scan_skills(&[t.path().join("s")]);
|
||||||
let names: Vec<_> = sk.iter().map(|k| k.name.as_str()).collect();
|
let names: Vec<_> = sk.iter().map(|k| k.name.as_str()).collect();
|
||||||
assert_eq!(names, ["hid", "ok"]);
|
assert_eq!(names, ["colon", "hid", "ok"]);
|
||||||
|
assert_eq!(sk[0].description, "before code exists: when asked");
|
||||||
assert!(
|
assert!(
|
||||||
warn.len() == 1 && warn[0].contains("bad/SKILL.md"),
|
warn.len() == 1 && warn[0].contains("bad/SKILL.md"),
|
||||||
"{warn:?}"
|
"{warn:?}"
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ pub struct Setup {
|
|||||||
pub pricing: fn(&str) -> Option<hx_ai::Pricing>,
|
pub pricing: fn(&str) -> Option<hx_ai::Pricing>,
|
||||||
/// `/lsp` status lines.
|
/// `/lsp` status lines.
|
||||||
pub lsp_status: LspStatus,
|
pub lsp_status: LspStatus,
|
||||||
|
pub reload: Reload,
|
||||||
/// Extra slash commands (MCP prompts, `/mcp`): `(name, arg)` -> None = not mine,
|
/// Extra slash commands (MCP prompts, `/mcp`): `(name, arg)` -> None = not mine,
|
||||||
/// Some(Ok(Send(text))) = send as a user prompt, Some(Ok(Show(text))) = show, Some(Err) = error.
|
/// Some(Ok(Send(text))) = send as a user prompt, Some(Ok(Show(text))) = show, Some(Err) = error.
|
||||||
pub commands: Commands,
|
pub commands: Commands,
|
||||||
@@ -88,6 +89,9 @@ pub type Commands = Box<
|
|||||||
+ Sync,
|
+ Sync,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
|
/// Rebuilds `(system prompt, slash commands)` from disk for `/reload`.
|
||||||
|
pub type Reload = Box<dyn Fn() -> Result<(String, Vec<CmdSpec>), String> + Send + Sync>;
|
||||||
|
|
||||||
pub type LspStatus = Box<
|
pub type LspStatus = Box<
|
||||||
dyn Fn() -> std::pin::Pin<Box<dyn std::future::Future<Output = Vec<String>> + Send>> + Send,
|
dyn Fn() -> std::pin::Pin<Box<dyn std::future::Future<Output = Vec<String>> + Send>> + Send,
|
||||||
>;
|
>;
|
||||||
@@ -259,6 +263,7 @@ pub async fn run(setup: Setup) -> std::io::Result<()> {
|
|||||||
switcher,
|
switcher,
|
||||||
pricing,
|
pricing,
|
||||||
lsp_status,
|
lsp_status,
|
||||||
|
reload,
|
||||||
commands,
|
commands,
|
||||||
specs,
|
specs,
|
||||||
open_sessions,
|
open_sessions,
|
||||||
@@ -394,6 +399,7 @@ pub async fn run(setup: Setup) -> std::io::Result<()> {
|
|||||||
tx: &tx,
|
tx: &tx,
|
||||||
cwd: &cwd,
|
cwd: &cwd,
|
||||||
lsp_status: &lsp_status,
|
lsp_status: &lsp_status,
|
||||||
|
reload: &reload,
|
||||||
commands: &commands,
|
commands: &commands,
|
||||||
};
|
};
|
||||||
let mut term = ratatui::init();
|
let mut term = ratatui::init();
|
||||||
@@ -1290,6 +1296,7 @@ struct Ctx<'a> {
|
|||||||
tx: &'a mpsc::UnboundedSender<Ui>,
|
tx: &'a mpsc::UnboundedSender<Ui>,
|
||||||
cwd: &'a std::path::Path,
|
cwd: &'a std::path::Path,
|
||||||
lsp_status: &'a LspStatus,
|
lsp_status: &'a LspStatus,
|
||||||
|
reload: &'a Reload,
|
||||||
commands: &'a Commands,
|
commands: &'a Commands,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1299,6 +1306,7 @@ async fn submit(app: &mut App, mut line: String, c: &Ctx<'_>) {
|
|||||||
tx,
|
tx,
|
||||||
cwd,
|
cwd,
|
||||||
lsp_status,
|
lsp_status,
|
||||||
|
reload,
|
||||||
commands,
|
commands,
|
||||||
} = *c;
|
} = *c;
|
||||||
app.scroll.end();
|
app.scroll.end();
|
||||||
@@ -1376,6 +1384,23 @@ async fn submit(app: &mut App, mut line: String, c: &Ctx<'_>) {
|
|||||||
let r = status::report(&app.st, status::now_secs());
|
let r = status::report(&app.st, status::now_secs());
|
||||||
show(app, "usage", r);
|
show(app, "usage", r);
|
||||||
}
|
}
|
||||||
|
"reload" => match reload() {
|
||||||
|
Err(e) => app.t.push(Item::Error(format!("/reload: {e}"))),
|
||||||
|
Ok((sys, specs)) => {
|
||||||
|
let mut a = agent.lock().await;
|
||||||
|
// unchanged prompt: leave it alone, a rewrite would drop the prompt cache
|
||||||
|
let same = a.system() == sys;
|
||||||
|
if !same {
|
||||||
|
a.set_system(sys);
|
||||||
|
}
|
||||||
|
let (old, new) = (app.specs.len(), specs.len());
|
||||||
|
app.specs = specs;
|
||||||
|
app.t.push(Item::Info(format!(
|
||||||
|
"reloaded: prompt {}, commands {old} → {new}",
|
||||||
|
if same { "unchanged" } else { "updated" }
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
},
|
||||||
"skills" => {
|
"skills" => {
|
||||||
let dirs = hx_core::context::skill_dirs(&hx_core::context::hx_home(), cwd);
|
let dirs = hx_core::context::skill_dirs(&hx_core::context::hx_home(), cwd);
|
||||||
let mut l = skills_list(&app.specs, &dirs);
|
let mut l = skills_list(&app.specs, &dirs);
|
||||||
@@ -2775,16 +2800,27 @@ mod tests {
|
|||||||
let (tx, _rx) = mpsc::unbounded_channel();
|
let (tx, _rx) = mpsc::unbounded_channel();
|
||||||
let ls: LspStatus = Box::new(|| Box::pin(async { vec![] }));
|
let ls: LspStatus = Box::new(|| Box::pin(async { vec![] }));
|
||||||
let cmds: Commands = Box::new(|_, _| None);
|
let cmds: Commands = Box::new(|_, _| None);
|
||||||
|
let rl: Reload = Box::new(|| Ok(("sys".into(), cmd::builtins(&[]))));
|
||||||
let ctx = Ctx {
|
let ctx = Ctx {
|
||||||
agent: &agent,
|
agent: &agent,
|
||||||
tx: &tx,
|
tx: &tx,
|
||||||
cwd: t.path(),
|
cwd: t.path(),
|
||||||
lsp_status: &ls,
|
lsp_status: &ls,
|
||||||
|
reload: &rl,
|
||||||
commands: &cmds,
|
commands: &cmds,
|
||||||
};
|
};
|
||||||
let mut app = test_app();
|
let mut app = test_app();
|
||||||
app.session_path = old.clone();
|
app.session_path = old.clone();
|
||||||
app.title = Some("first".into());
|
app.title = Some("first".into());
|
||||||
|
// /reload swaps prompt + commands; same prompt twice is reported unchanged
|
||||||
|
app.specs = vec![];
|
||||||
|
submit(&mut app, "/reload".into(), &ctx).await;
|
||||||
|
assert_eq!(agent.lock().await.system(), "sys");
|
||||||
|
assert!(app.specs.iter().any(|s| s.name == "reload"));
|
||||||
|
submit(&mut app, "/reload".into(), &ctx).await;
|
||||||
|
assert!(
|
||||||
|
matches!(app.t.items.last(), Some(Item::Info(m)) if m.contains("prompt unchanged"))
|
||||||
|
);
|
||||||
submit(&mut app, "/clear".into(), &ctx).await;
|
submit(&mut app, "/clear".into(), &ctx).await;
|
||||||
let new = agent.lock().await.session().path().to_path_buf();
|
let new = agent.lock().await.session().path().to_path_buf();
|
||||||
assert_ne!(new, old);
|
assert_ne!(new, old);
|
||||||
@@ -2825,11 +2861,13 @@ mod tests {
|
|||||||
models.extend(hx_ai::models::fallback(Kind::Codex));
|
models.extend(hx_ai::models::fallback(Kind::Codex));
|
||||||
let ls: LspStatus = Box::new(|| Box::pin(async { vec![] }));
|
let ls: LspStatus = Box::new(|| Box::pin(async { vec![] }));
|
||||||
let cmds: Commands = Box::new(|_, _| None);
|
let cmds: Commands = Box::new(|_, _| None);
|
||||||
|
let rl: Reload = Box::new(|| Ok(("sys".into(), cmd::builtins(&[]))));
|
||||||
let ctx = Ctx {
|
let ctx = Ctx {
|
||||||
agent: &agent,
|
agent: &agent,
|
||||||
tx: &tx,
|
tx: &tx,
|
||||||
cwd: t.path(),
|
cwd: t.path(),
|
||||||
lsp_status: &ls,
|
lsp_status: &ls,
|
||||||
|
reload: &rl,
|
||||||
commands: &cmds,
|
commands: &cmds,
|
||||||
};
|
};
|
||||||
let mut app = test_app();
|
let mut app = test_app();
|
||||||
|
|||||||
Reference in new issue
Block a user