merge poc-daemon and poc-hook into poc-memory repo
Move the notification daemon (IRC, Telegram, idle timer) and the
Claude Code hook binary into this repo as additional [[bin]] targets.
Single `cargo install --path .` now installs everything:
poc-memory — memory store CLI
memory-search — hook for memory retrieval
poc-daemon — notification/idle daemon (was claude-daemon)
poc-hook — Claude Code lifecycle hook (was claude-hook)
Renamed from claude-{daemon,hook} to poc-{daemon,hook} since the
infrastructure isn't tied to any specific AI assistant.
Co-Authored-By: ProofOfConcept <poc@bcachefs.org>
This commit is contained in:
parent
85316da471
commit
ecedc86d42
15 changed files with 4260 additions and 9 deletions
61
src/bin/poc-daemon/tmux.rs
Normal file
61
src/bin/poc-daemon/tmux.rs
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
// Tmux interaction: pane detection and prompt injection.
|
||||
|
||||
use std::process::Command;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
use tracing::info;
|
||||
|
||||
/// Find Claude Code's tmux pane by scanning for the "claude" process.
|
||||
pub fn find_claude_pane() -> Option<String> {
|
||||
let out = Command::new("tmux")
|
||||
.args([
|
||||
"list-panes",
|
||||
"-a",
|
||||
"-F",
|
||||
"#{session_name}:#{window_index}.#{pane_index}\t#{pane_current_command}",
|
||||
])
|
||||
.output()
|
||||
.ok()?;
|
||||
|
||||
let stdout = String::from_utf8_lossy(&out.stdout);
|
||||
for line in stdout.lines() {
|
||||
if let Some((pane, cmd)) = line.split_once('\t') {
|
||||
if cmd == "claude" {
|
||||
return Some(pane.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// Send a prompt to a tmux pane. Returns true on success.
|
||||
///
|
||||
/// Sequence: Escape q C-c C-u (clear input), wait, type message, Enter.
|
||||
pub fn send_prompt(pane: &str, msg: &str) -> bool {
|
||||
info!("SEND [{pane}]: {}...", &msg[..msg.len().min(100)]);
|
||||
|
||||
let send = |keys: &[&str]| {
|
||||
Command::new("tmux")
|
||||
.arg("send-keys")
|
||||
.arg("-t")
|
||||
.arg(pane)
|
||||
.args(keys)
|
||||
.output()
|
||||
.is_ok()
|
||||
};
|
||||
|
||||
// Clear any partial input
|
||||
if !send(&["Escape", "q", "C-c", "C-u"]) {
|
||||
return false;
|
||||
}
|
||||
thread::sleep(Duration::from_secs(1));
|
||||
|
||||
// Type the message
|
||||
if !send(&[msg]) {
|
||||
return false;
|
||||
}
|
||||
thread::sleep(Duration::from_millis(500));
|
||||
|
||||
// Submit
|
||||
send(&["Enter"])
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue