codemode tool: JS scripts in a QuickJS sandbox that call other tools
This commit is contained in:
1 parent
8ffb5de9e9
commit
9fda1484ce
6 files changed
+555
-1
No files matched your search
@@ -99,6 +99,8 @@ struct Config {
|
||||
max_tokens: Option<u32>,
|
||||
/// Model for read-only `task` subagents; default: the provider's cheapest tier (Haiku / Luna).
|
||||
explore_model: Option<String>,
|
||||
/// Add the `codemode` tool: JS scripts that call the other tools (default false).
|
||||
codemode: Option<bool>,
|
||||
/// Capture the mouse for wheel scrolling (default true; false = terminal selection works without shift).
|
||||
mouse: Option<bool>,
|
||||
/// Reuse the last model chosen with /model or /provider (default true).
|
||||
@@ -150,6 +152,7 @@ impl Config {
|
||||
compact_at: o.compact_at.or(c.compact_at),
|
||||
max_tokens: o.max_tokens.or(c.max_tokens),
|
||||
explore_model: o.explore_model.or(c.explore_model),
|
||||
codemode: o.codemode.or(c.codemode),
|
||||
mouse: o.mouse.or(c.mouse),
|
||||
remember_model: o.remember_model.or(c.remember_model),
|
||||
permissions: o.permissions.or(c.permissions),
|
||||
@@ -409,6 +412,10 @@ async fn main() -> Result<()> {
|
||||
let mut reg = hx_tools::registry();
|
||||
hub.register(&mut reg);
|
||||
reg.add(hx_lens::LspTool::new(mgr.clone()));
|
||||
if cfg.codemode.unwrap_or(false) {
|
||||
let cm = hx_tools::codemode::Codemode::new(®);
|
||||
reg.add(cm);
|
||||
}
|
||||
let full = context::system_prompt(cfg.system_prompt.as_deref(), &home, &cwd);
|
||||
let base = cfg
|
||||
.system_prompt
|
||||
@@ -742,6 +749,11 @@ async fn main() -> Result<()> {
|
||||
}
|
||||
agent.tools.add(task);
|
||||
}
|
||||
if cfg.codemode.unwrap_or(false) {
|
||||
// snapshot after every other tool (MCP, lens, task); codemode itself is not callable inside
|
||||
let cm = hx_tools::codemode::Codemode::new(&agent.tools);
|
||||
agent.tools.add(cm);
|
||||
}
|
||||
let specs = command_specs(&mcp, &cwd, &models, &kinds);
|
||||
trace("ready");
|
||||
if cli.mode == Mode::Rpc {
|
||||
|
||||
Reference in new issue
Block a user