feat(cli): auto-enqueue to skill-bus on register

After successful task registration, automatically append a queued
entry to skill-runs.jsonl. This connects the Polaris gate workflow
to the skill-bus tracking system.

Use --no-bus to skip auto-enqueue when not needed.

Closes #93

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
林 駿甫 (Shunsuke Hayashi) 2026-04-10 10:10:18 +09:00
parent 32f034e2b2
commit d52ac2fe12

View file

@ -177,6 +177,9 @@ enum GateCommand {
/// Completion mode
#[arg(long, value_enum, default_value_t = CompletionModeArg::GithubPr)]
completion_mode: CompletionModeArg,
/// Skip skill-bus auto-enqueue
#[arg(long)]
no_bus: bool,
},
/// Show status for one task or the whole ledger
Status {
@ -1269,8 +1272,10 @@ fn handle_gate_command(
soft_dependencies,
priority,
completion_mode,
no_bus,
} => {
let task_id = task_id.unwrap_or_else(|| derive_task_id(issue, &title));
let task_title = title.clone();
protocol
.register(
RegisterTaskRequest {
@ -1295,6 +1300,9 @@ fn handle_gate_command(
} else {
println!("registered: {} ({})", task.id, task.title);
}
if !no_bus {
bus_enqueue(&task.id, &task_title);
}
})
}
GateCommand::Status { task_id } => {
@ -2418,3 +2426,29 @@ fn truncate_str(s: &str, max_len: usize) -> String {
s.to_string()
}
}
fn bus_enqueue(task_id: &str, title: &str) {
let skill_runs_path = std::env::current_dir()
.ok()
.map(|cwd| cwd.join("skills/self-improving-skills/skill-runs.jsonl"));
if let Some(path) = skill_runs_path.filter(|p| p.parent().is_some_and(|d| d.exists())) {
let entry = serde_json::json!({
"ts": chrono::Utc::now().to_rfc3339(),
"agent": std::env::var("POLARIS_AGENT_ID").unwrap_or_else(|_| "system".into()),
"skill": "polaris-ops",
"task": format!("register: {title} ({task_id})"),
"result": "queued",
"score": 0.0,
"notes": "auto-enqueued on register"
});
if let Ok(mut file) = std::fs::OpenOptions::new()
.create(true)
.append(true)
.open(&path)
{
use std::io::Write;
let _ = writeln!(file, "{}", serde_json::to_string(&entry).unwrap_or_default());
}
}
}