Git-based knowledge management system for AI agents
cargo install agent-git
use agent_git::{KnowledgeRepo, Entry};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize a knowledge repo
let repo = KnowledgeRepo::init("./knowledge")?;
// Store knowledge with automatic versioning
let entry = Entry::new("task_123")
.with_content("User prefers concise responses")
.with_tags(vec!["preference", "communication"]);
repo.store(entry)?;
// Query knowledge
let results = repo.query()
.tag("preference")
.since("2024-01-01")
.execute()?;
for entry in results {
println!("{}: {}", entry.id, entry.content);
}
// Branch for experimental knowledge
repo.branch("experiment/new-context")?;
Ok(())
}| Type | Description |
|---|---|
KnowledgeRepo |
Main repository interface, wraps a Git repo |
Entry |
Single knowledge entry with metadata |
Query |
Builder for searching stored knowledge |
Diff |
Represents changes between knowledge states |
KnowledgeRepo
init(path)- Create new knowledge repoopen(path)- Open existing repostore(entry)- Store knowledge entry, returns commit hashquery()- Start a new querybranch(name)- Create knowledge branchmerge(branch)- Merge branch into currenthistory(id)- Get history of specific entry
Query
tag(name)- Filter by tagsince(date)- Filter by datecontent(pattern)- Search contentexecute()- Run query and return results
Entry
new(id)- Create entry with IDwith_content(text)- Add contentwith_tags(tags)- Add tagswith_metadata(key, value)- Add custom metadata
prs welcome. open an issue first for big changes.
MIT