port digest-link-parser, journal-agent, apply-consolidation to Rust
Three Python scripts (858 lines) replaced with native Rust subcommands: - digest-links [--apply]: parses ## Links sections from episodic digests, normalizes keys, applies to graph with section-level fallback - journal-enrich JSONL TEXT [LINE]: extracts conversation from JSONL transcript, calls Sonnet for link proposals and source location - apply-consolidation [--apply]: reads consolidation reports, sends to Sonnet for structured action extraction (links, categorizations, manual items) Shared infrastructure: call_sonnet now pub(crate), new parse_json_response helper for Sonnet output parsing with markdown fence stripping.
This commit is contained in:
parent
91122fe1d1
commit
59e2f39479
2 changed files with 818 additions and 2 deletions
59
src/main.rs
59
src/main.rs
|
|
@ -89,6 +89,9 @@ fn main() {
|
|||
"daily-check" => cmd_daily_check(),
|
||||
"apply-agent" => cmd_apply_agent(&args[2..]),
|
||||
"digest" => cmd_digest(&args[2..]),
|
||||
"digest-links" => cmd_digest_links(&args[2..]),
|
||||
"journal-enrich" => cmd_journal_enrich(&args[2..]),
|
||||
"apply-consolidation" => cmd_apply_consolidation(&args[2..]),
|
||||
"trace" => cmd_trace(&args[2..]),
|
||||
"list-keys" => cmd_list_keys(),
|
||||
"list-edges" => cmd_list_edges(),
|
||||
|
|
@ -146,6 +149,11 @@ Commands:
|
|||
digest daily [DATE] Generate daily episodic digest (default: today)
|
||||
digest weekly [DATE] Generate weekly digest (any date in target week)
|
||||
digest monthly [YYYY-MM] Generate monthly digest (default: current month)
|
||||
digest-links [--apply] Parse and apply links from digest files
|
||||
journal-enrich JSONL TEXT [LINE]
|
||||
Enrich journal entry with conversation links
|
||||
apply-consolidation [--apply] [--report FILE]
|
||||
Extract and apply actions from consolidation reports
|
||||
trace KEY Walk temporal links: semantic ↔ episodic ↔ conversation
|
||||
list-keys List all node keys (one per line)
|
||||
list-edges List all edges (tsv: source target strength type)
|
||||
|
|
@ -655,6 +663,57 @@ fn cmd_digest(args: &[String]) -> Result<(), String> {
|
|||
}
|
||||
}
|
||||
|
||||
fn cmd_digest_links(args: &[String]) -> Result<(), String> {
|
||||
let do_apply = args.iter().any(|a| a == "--apply");
|
||||
|
||||
let links = digest::parse_all_digest_links();
|
||||
println!("Found {} unique links from digest files", links.len());
|
||||
|
||||
if !do_apply {
|
||||
for (i, link) in links.iter().enumerate() {
|
||||
println!(" {:3}. {} → {}", i + 1, link.source, link.target);
|
||||
if !link.reason.is_empty() {
|
||||
println!(" ({})", &link.reason[..link.reason.len().min(80)]);
|
||||
}
|
||||
}
|
||||
println!("\nTo apply: poc-memory digest-links --apply");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let mut store = capnp_store::Store::load()?;
|
||||
let (applied, skipped, fallbacks) = digest::apply_digest_links(&mut store, &links);
|
||||
println!("\nApplied: {} ({} file-level fallbacks) Skipped: {}", applied, fallbacks, skipped);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn cmd_journal_enrich(args: &[String]) -> Result<(), String> {
|
||||
if args.len() < 2 {
|
||||
return Err("Usage: poc-memory journal-enrich JSONL_PATH ENTRY_TEXT [GREP_LINE]".into());
|
||||
}
|
||||
let jsonl_path = &args[0];
|
||||
let entry_text = &args[1];
|
||||
let grep_line: usize = args.get(2)
|
||||
.and_then(|a| a.parse().ok())
|
||||
.unwrap_or(0);
|
||||
|
||||
if !std::path::Path::new(jsonl_path.as_str()).is_file() {
|
||||
return Err(format!("JSONL not found: {}", jsonl_path));
|
||||
}
|
||||
|
||||
let mut store = capnp_store::Store::load()?;
|
||||
digest::journal_enrich(&mut store, jsonl_path, entry_text, grep_line)
|
||||
}
|
||||
|
||||
fn cmd_apply_consolidation(args: &[String]) -> Result<(), String> {
|
||||
let do_apply = args.iter().any(|a| a == "--apply");
|
||||
let report_file = args.windows(2)
|
||||
.find(|w| w[0] == "--report")
|
||||
.map(|w| w[1].as_str());
|
||||
|
||||
let mut store = capnp_store::Store::load()?;
|
||||
digest::apply_consolidation(&mut store, do_apply, report_file)
|
||||
}
|
||||
|
||||
fn cmd_trace(args: &[String]) -> Result<(), String> {
|
||||
if args.is_empty() {
|
||||
return Err("Usage: poc-memory trace KEY".into());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue