style: gofmt all packages
This commit is contained in:
@@ -5,9 +5,9 @@ import (
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/david/knox/internal/db"
|
||||
"github.com/david/knox/internal/ingest"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func NewBrowserCmd(kdb *db.KnoxDB) *cobra.Command {
|
||||
@@ -65,10 +65,10 @@ Run periodically to capture browsing exhaust.`,
|
||||
for _, r := range results {
|
||||
domains[extractDomain(r.Summary)]++
|
||||
}
|
||||
fmt.Println("\nTop domains:")
|
||||
for _, d := range topDomains(domains, 10) {
|
||||
fmt.Printf(" %-40s %d\n", d.Name, d.Count)
|
||||
}
|
||||
fmt.Println("\nTop domains:")
|
||||
for _, d := range topDomains(domains, 10) {
|
||||
fmt.Printf(" %-40s %d\n", d.Name, d.Count)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/david/knox/internal/db"
|
||||
"github.com/david/knox/internal/ingest"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func NewGiteaCmd(kdb *db.KnoxDB) *cobra.Command {
|
||||
|
||||
@@ -3,9 +3,9 @@ package cmd
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/david/knox/internal/db"
|
||||
"github.com/david/knox/internal/watch"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// NewGossipCmd exposes peer status/diff for the gossip protocol.
|
||||
@@ -154,4 +154,4 @@ func min(a, b int) int {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
}
|
||||
|
||||
+73
-73
@@ -5,10 +5,10 @@ import (
|
||||
"log"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/david/knox/internal/db"
|
||||
"github.com/david/knox/internal/ingest"
|
||||
"github.com/david/knox/internal/watch"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func NewIngestCmd(kdb *db.KnoxDB) *cobra.Command {
|
||||
@@ -27,92 +27,92 @@ func NewIngestCmd(kdb *db.KnoxDB) *cobra.Command {
|
||||
ingest.NewSkillsIngester(),
|
||||
}
|
||||
|
||||
var totalNew, totalUpdated int
|
||||
var totalNew, totalUpdated int
|
||||
|
||||
record := func(result *ingest.IngestResult) {
|
||||
_, isNew, err := kdb.RecordObservation(db.ObservationRecord{
|
||||
Fingerprint: result.Fingerprint,
|
||||
SourceID: result.SourceID,
|
||||
SourcePath: result.SourcePath,
|
||||
Project: result.Project,
|
||||
ContentType: result.ContentType,
|
||||
Title: result.Title,
|
||||
Summary: result.Summary,
|
||||
CreatedAt: result.CreatedAt,
|
||||
LineStart: result.LineStart,
|
||||
LineEnd: result.LineEnd,
|
||||
Confidence: result.Confidence,
|
||||
IngesterVersion: result.IngesterVersion,
|
||||
Trigger: "ingest",
|
||||
Provenance: ingest.ProvenanceJSON(result.Provenance),
|
||||
})
|
||||
if err != nil {
|
||||
log.Printf("[knox] db error: %v", err)
|
||||
return
|
||||
}
|
||||
if isNew {
|
||||
totalNew++
|
||||
} else {
|
||||
totalUpdated++
|
||||
}
|
||||
|
||||
if result.SourceID == "opencode-session" {
|
||||
sessionID, _ := result.Provenance["session_id"].(string)
|
||||
if sessionID != "" {
|
||||
kdb.UpsertSession(sessionID, result.Project, result.Title, "active")
|
||||
record := func(result *ingest.IngestResult) {
|
||||
_, isNew, err := kdb.RecordObservation(db.ObservationRecord{
|
||||
Fingerprint: result.Fingerprint,
|
||||
SourceID: result.SourceID,
|
||||
SourcePath: result.SourcePath,
|
||||
Project: result.Project,
|
||||
ContentType: result.ContentType,
|
||||
Title: result.Title,
|
||||
Summary: result.Summary,
|
||||
CreatedAt: result.CreatedAt,
|
||||
LineStart: result.LineStart,
|
||||
LineEnd: result.LineEnd,
|
||||
Confidence: result.Confidence,
|
||||
IngesterVersion: result.IngesterVersion,
|
||||
Trigger: "ingest",
|
||||
Provenance: ingest.ProvenanceJSON(result.Provenance),
|
||||
})
|
||||
if err != nil {
|
||||
log.Printf("[knox] db error: %v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, ing := range ingesters {
|
||||
sid := ing.SourceID()
|
||||
log.Printf("[knox] ingesting %s...", sid)
|
||||
|
||||
for _, dir := range dirs {
|
||||
patterns := []string{
|
||||
dir + "/*",
|
||||
dir + "/*/SKILL.md",
|
||||
if isNew {
|
||||
totalNew++
|
||||
} else {
|
||||
totalUpdated++
|
||||
}
|
||||
for _, pattern := range patterns {
|
||||
entries, _ := filepath.Glob(pattern)
|
||||
for _, path := range entries {
|
||||
if !watch.MatchesIngester(path, sid) {
|
||||
continue
|
||||
}
|
||||
|
||||
result, err := ing.Ingest(path)
|
||||
if err != nil || result == nil {
|
||||
continue
|
||||
}
|
||||
record(result)
|
||||
if result.SourceID == "opencode-session" {
|
||||
sessionID, _ := result.Provenance["session_id"].(string)
|
||||
if sessionID != "" {
|
||||
kdb.UpsertSession(sessionID, result.Project, result.Title, "active")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Non-file sources: obsidian vault, browser history, gitea
|
||||
if vault, err := ingest.DetectObsidianVault(); err == nil {
|
||||
log.Printf("[knox] ingesting obsidian...")
|
||||
if results, err := ingest.NewObsidianIngester(vault).IngestAll(); err == nil {
|
||||
for _, ing := range ingesters {
|
||||
sid := ing.SourceID()
|
||||
log.Printf("[knox] ingesting %s...", sid)
|
||||
|
||||
for _, dir := range dirs {
|
||||
patterns := []string{
|
||||
dir + "/*",
|
||||
dir + "/*/SKILL.md",
|
||||
}
|
||||
for _, pattern := range patterns {
|
||||
entries, _ := filepath.Glob(pattern)
|
||||
for _, path := range entries {
|
||||
if !watch.MatchesIngester(path, sid) {
|
||||
continue
|
||||
}
|
||||
|
||||
result, err := ing.Ingest(path)
|
||||
if err != nil || result == nil {
|
||||
continue
|
||||
}
|
||||
record(result)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Non-file sources: obsidian vault, browser history, gitea
|
||||
if vault, err := ingest.DetectObsidianVault(); err == nil {
|
||||
log.Printf("[knox] ingesting obsidian...")
|
||||
if results, err := ingest.NewObsidianIngester(vault).IngestAll(); err == nil {
|
||||
for _, r := range results {
|
||||
record(r)
|
||||
}
|
||||
}
|
||||
}
|
||||
log.Printf("[knox] ingesting browser-history...")
|
||||
if results, err := ingest.NewBrowserHistoryIngester().IngestAll(); err == nil {
|
||||
for _, r := range results {
|
||||
record(r)
|
||||
}
|
||||
}
|
||||
}
|
||||
log.Printf("[knox] ingesting browser-history...")
|
||||
if results, err := ingest.NewBrowserHistoryIngester().IngestAll(); err == nil {
|
||||
for _, r := range results {
|
||||
record(r)
|
||||
log.Printf("[knox] ingesting gitea...")
|
||||
if results, err := ingest.NewGiteaIngester().IngestAll(); err == nil {
|
||||
for _, r := range results {
|
||||
record(r)
|
||||
}
|
||||
}
|
||||
}
|
||||
log.Printf("[knox] ingesting gitea...")
|
||||
if results, err := ingest.NewGiteaIngester().IngestAll(); err == nil {
|
||||
for _, r := range results {
|
||||
record(r)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Printf("\nIngest complete: %d new entries, %d updated\n", totalNew, totalUpdated)
|
||||
fmt.Printf("\nIngest complete: %d new entries, %d updated\n", totalNew, totalUpdated)
|
||||
},
|
||||
}
|
||||
cmd.Flags().StringSliceVarP(&dirs, "dir", "d", nil, "Directories to scan (default: opencode storage/log + skills)")
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/david/knox/internal/db"
|
||||
"github.com/david/knox/internal/ingest"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func NewObsidianCmd(kdb *db.KnoxDB) *cobra.Command {
|
||||
|
||||
@@ -3,9 +3,9 @@ package cmd
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/david/knox/internal/db"
|
||||
"github.com/david/knox/internal/watch"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// NewReconcileCmd rebuilds all derived state (entries cache, threads) from the
|
||||
@@ -51,4 +51,4 @@ func dryRunReconcile(kdb *db.KnoxDB) error {
|
||||
fmt.Printf("drift: %d entries current, %d from log (%+d), %d threads would be created, %d obs would be linked\n",
|
||||
current, logCount, logCount-current, created, linked)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/david/knox/internal/db"
|
||||
"github.com/david/knox/internal/index"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func paginate(entries []db.Entry, page, limit int) []db.Entry {
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/david/knox/internal/db"
|
||||
"github.com/david/knox/internal/index"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func NewTopicsCmd(kdb *db.KnoxDB) *cobra.Command {
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"io"
|
||||
"log"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/david/knox/internal/db"
|
||||
"github.com/david/knox/internal/watch"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func NewWatchCmd(kdb *db.KnoxDB) *cobra.Command {
|
||||
|
||||
Reference in New Issue
Block a user