chore: checkpoint uncommitted work before session store fix

Pre-existing work-in-progress in the tree: karakeep, snippets,
skills-health and redaction ingesters, the opencode.db session sweep,
gossip and metrics changes. Checkpointed as-is so the adapter fix in the
next commit stays reviewable on its own.
This commit is contained in:
2026-11-01 13:33:36 -08:00
parent 876d2aa45f
commit edf6c03a7c
43 changed files with 6828 additions and 492 deletions
+59
View File
@@ -157,6 +157,10 @@ func (g *GitIngester) repoToResult(repoPath string) *IngestResult {
createdAt := status.LastCommit
// Carry the repo's README + config source so an agent can see what the repo
// actually contains, not just its last commit.
content := repoContent(repoPath)
return &IngestResult{
Fingerprint: fp,
SourceID: g.SourceID(),
@@ -165,9 +169,13 @@ func (g *GitIngester) repoToResult(repoPath string) *IngestResult {
ContentType: "git-status",
Title: name,
Summary: summary,
Content: content,
CreatedAt: createdAt,
Confidence: 0.9,
IngesterVersion: g.Version,
// Change signal covers status AND content, so status flips (dirty,
// ahead/behind) and code changes both refresh; unchanged repos no-op.
ContentHash: Fingerprint([]byte(fmt.Sprintf("git|%s|%s|%d|%d|%d", status.Head, content, status.Dirty, status.Ahead, status.Behind))),
Provenance: map[string]any{
"type": "git_status",
"path": repoPath,
@@ -178,10 +186,61 @@ func (g *GitIngester) repoToResult(repoPath string) *IngestResult {
"behind": status.Behind,
"last_commit": status.LastCommit,
"subject": status.Subject,
"content_len": len(content),
},
}
}
// Bounded repo content limits (kept small so a 10-minute sweep over many repos
// stays cheap).
const (
maxRepoContentBytes = 64 * 1024
maxRepoFileBytes = 16 * 1024
)
// repoContent assembles a bounded digest of a repository: its README, a
// tracked-file listing, and the contents of infrastructure/config files
// (Terraform, and common homelab formats). Empty when nothing is readable.
func repoContent(repoPath string) string {
var b strings.Builder
for _, name := range []string{"README.md", "README.rst", "README.txt", "README", "readme.md"} {
if data, err := os.ReadFile(filepath.Join(repoPath, name)); err == nil {
b.WriteString("## " + name + "\n")
b.WriteString(truncate(string(data), maxRepoFileBytes))
b.WriteString("\n\n")
break
}
}
if out, err := gitOut(repoPath, "ls-files"); err == nil && out != "" {
b.WriteString("## files\n")
b.WriteString(truncate(out, 4096))
b.WriteString("\n\n")
}
// Contents of infra/config files, newest-relevant first (git order).
files, _ := gitOut(repoPath, "ls-files", "--", "*.tf", "*.tfvars", "*.hcl", "*.yaml", "*.yml", "*.toml")
for _, f := range strings.Split(files, "\n") {
f = strings.TrimSpace(f)
if f == "" {
continue
}
if b.Len() >= maxRepoContentBytes {
break
}
data, err := os.ReadFile(filepath.Join(repoPath, f))
if err != nil {
continue
}
b.WriteString("## " + f + "\n")
b.WriteString(truncate(string(data), maxRepoFileBytes))
b.WriteString("\n\n")
}
return strings.TrimSpace(b.String())
}
func gitStatus(repoPath string) GitStatus {
out, err := gitOut(repoPath, "status", "--porcelain")
if err != nil {