Initial commit: knox knowledge index

This commit is contained in:
2026-08-29 02:52:32 -07:00
commit 8eecde18b4
31 changed files with 6855 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
package cmd
import (
"io"
"log"
"github.com/spf13/cobra"
"github.com/david/knox/internal/db"
"github.com/david/knox/internal/watch"
)
func NewWatchCmd(kdb *db.KnoxDB) *cobra.Command {
var dirs []string
var quiet bool
cmd := &cobra.Command{
Use: "watch",
Short: "Watch directories for new session data and ingest into index",
Run: func(cmd *cobra.Command, args []string) {
if len(dirs) == 0 {
dirs = defaultWatchDirs()
}
if quiet {
log.SetOutput(io.Discard)
}
log.Printf("[knox] starting watcher, scanning %d directories", len(dirs))
w := watch.New(kdb, dirs)
if err := w.Start(); err != nil {
log.Fatalf("watcher error: %v", err)
}
},
}
cmd.Flags().StringSliceVarP(&dirs, "dir", "d", nil, "Directories to watch (default: opencode storage/log + skills)")
cmd.Flags().BoolVarP(&quiet, "quiet", "q", false, "Suppress per-entry log output")
return cmd
}
func defaultWatchDirs() []string {
home, _ := getHomeDir()
return []string{
home + "/.local/share/opencode/storage/session_diff",
home + "/.local/share/opencode/log",
home + "/.skills",
}
}