d6d2a24ddc
Applies gofmt to the 18 files that were already unformatted at HEAD (pre-existing debt — 122 insertions / 122 deletions, whitespace plus import-block reorderings only; `git diff -w` confirms no semantic changes). Kept on its own branch so the functional change set (see the review-hardening PR) stays reviewable without formatting noise. Verified: go build, go vet, go test ./... pass on this branch; a merge simulation with the functional branch produces a clean 3-way merge with all tests green. Reviewed-on: #4 Co-authored-by: David Gwilliam <dhgwilliam@gmail.com> Co-committed-by: David Gwilliam <dhgwilliam@gmail.com>
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
package cmd
|
|
|
|
import (
|
|
"io"
|
|
"log"
|
|
|
|
"github.com/david/knox/internal/db"
|
|
"github.com/david/knox/internal/watch"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
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",
|
|
}
|
|
}
|