claude_cli: permission prompts via --permission-prompt-tool, bridged to the hx TUI
This commit is contained in:
1 parent
b06c06ad80
commit
0032a5a952
8 files changed
+248
-46
No files matched your search
@@ -18,8 +18,8 @@ pub struct ClaudeCli {
|
||||
bin: String,
|
||||
/// extra args, e.g. `["--permission-mode", "acceptEdits"]`
|
||||
args: Vec<String>,
|
||||
/// `hx mcp-serve` entry (command, args) offered to claude as MCP server "hx"
|
||||
mcp: Option<(String, Vec<String>)>,
|
||||
/// `hx mcp-serve` entry (command, args, env) offered to claude as MCP server "hx"
|
||||
mcp: Option<(String, Vec<String>, Value)>,
|
||||
session: Arc<Mutex<Option<String>>>,
|
||||
}
|
||||
|
||||
@@ -33,8 +33,9 @@ impl ClaudeCli {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_mcp(mut self, command: String, args: Vec<String>) -> Self {
|
||||
self.mcp = Some((command, args));
|
||||
/// `env` also carries the permission socket: claude then asks hx (`mcp__hx__approve`) before tools run.
|
||||
pub fn with_mcp(mut self, command: String, args: Vec<String>, env: Value) -> Self {
|
||||
self.mcp = Some((command, args, env));
|
||||
self
|
||||
}
|
||||
|
||||
@@ -110,9 +111,12 @@ impl Provider for ClaudeCli {
|
||||
if !req.system.is_empty() {
|
||||
cmd.args(["--append-system-prompt", &req.system]);
|
||||
}
|
||||
if let Some((c, a)) = &self.mcp {
|
||||
let cfg = json!({"mcpServers": {"hx": {"command": c, "args": a}}});
|
||||
if let Some((c, a, env)) = &self.mcp {
|
||||
let cfg = json!({"mcpServers": {"hx": {"command": c, "args": a, "env": env}}});
|
||||
cmd.args(["--mcp-config", &cfg.to_string()]);
|
||||
if !env.is_null() {
|
||||
cmd.args(["--permission-prompt-tool", "mcp__hx__approve"]);
|
||||
}
|
||||
}
|
||||
cmd.args(&self.args)
|
||||
.arg("--")
|
||||
|
||||
Reference in new issue
Block a user