agents: self-contained agent files with embedded prompts
Each agent is a .agent file: JSON config on the first line, blank line, then the raw prompt markdown. Fully self-contained, fully readable. No separate template files needed. Agents dir: checked into repo at poc-memory/agents/. Code looks there first (via CARGO_MANIFEST_DIR), falls back to ~/.claude/memory/agents/. Three agents migrated: replay, linker, transfer. Co-Authored-By: ProofOfConcept <poc@bcachefs.org>
This commit is contained in:
parent
e736471d99
commit
b4e674806d
7 changed files with 783 additions and 1 deletions
|
|
@ -30,7 +30,12 @@ pub fn load_prompt(name: &str, replacements: &[(&str, &str)]) -> Result<String,
|
|||
Ok(content)
|
||||
}
|
||||
|
||||
/// Format topology header for agent prompts — current graph health metrics
|
||||
/// Format topology header for agent prompts — current graph health metrics.
|
||||
/// Public alias for use from defs.rs (config-driven agents).
|
||||
pub fn format_topology_header_pub(graph: &Graph) -> String {
|
||||
format_topology_header(graph)
|
||||
}
|
||||
|
||||
fn format_topology_header(graph: &Graph) -> String {
|
||||
let sigma = graph.small_world_sigma();
|
||||
let alpha = graph.degree_power_law_exponent();
|
||||
|
|
@ -74,6 +79,11 @@ fn format_topology_header(graph: &Graph) -> String {
|
|||
n, e, graph.community_count(), sigma, alpha, gini, avg_cc, hub_list)
|
||||
}
|
||||
|
||||
/// Public alias for use from defs.rs (config-driven agents).
|
||||
pub fn format_nodes_section_pub(store: &Store, items: &[ReplayItem], graph: &Graph) -> String {
|
||||
format_nodes_section(store, items, graph)
|
||||
}
|
||||
|
||||
/// Format node data section for prompt templates
|
||||
fn format_nodes_section(store: &Store, items: &[ReplayItem], graph: &Graph) -> String {
|
||||
let hub_thresh = graph.hub_threshold();
|
||||
|
|
@ -444,6 +454,11 @@ pub fn consolidation_batch(store: &Store, count: usize, auto: bool) -> Result<()
|
|||
/// Returns an AgentBatch with the prompt text and the keys of nodes
|
||||
/// selected for processing (for visit tracking on success).
|
||||
pub fn agent_prompt(store: &Store, agent: &str, count: usize) -> Result<AgentBatch, String> {
|
||||
// Config-driven agents take priority over hardcoded ones
|
||||
if let Some(def) = super::defs::get_def(agent) {
|
||||
return super::defs::run_agent(store, &def, count);
|
||||
}
|
||||
|
||||
let graph = store.build_graph();
|
||||
let topology = format_topology_header(&graph);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue