mirror of
https://github.com/runbear-io/beardrive.git
synced 2026-08-25 08:08:08 +02:00
Phase 3 of the read heatmap: `bdrive read-log` parses any platform's hook event JSON from stdin and queues in-project file reads (mount-relative, ignore/include-filtered) in a per-volume spool — no network on the hook path. The sync cycle drains the spool best-effort to the hub's new POST /api/p/<id>/reads via the remote ReadReporter capability (https backend only); a failed report retries next cycle and never fails or offlines the cycle. `bdrive hooks install` now registers a third hook per platform on its read-tool matcher (claude Read, codex read_file best-effort, gemini read_file|read_many_files, hermes read_file), each idempotent on its own marker so sync-only configs upgrade in place. Agent reads land as agent traffic in the heat view, actor = device id. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01P5cxPQdSGJnjXCYY9GeWXt
84 lines
2.0 KiB
Go
84 lines
2.0 KiB
Go
// bdrive is the BearDrive CLI: mount a folder, and its
|
|
// contents stay synchronized across devices through cloud object storage,
|
|
// with full per-file change history and offline support.
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/runbear-io/beardrive/internal/config"
|
|
)
|
|
|
|
// version is set at release time via -ldflags "-X main.version=...".
|
|
var version = "0.1.0-dev"
|
|
|
|
func main() {
|
|
root := &cobra.Command{
|
|
Use: "bdrive",
|
|
Short: "BearDrive: a synced file system for AI agents",
|
|
Long: `bdrive — the BearDrive CLI. A mountable, offline-first, synced file
|
|
system for AI agents.
|
|
|
|
Mount any folder and BearDrive keeps it synchronized across your devices through
|
|
cloud object storage (Amazon S3, Google Cloud Storage, or a plain shared
|
|
directory). Every change is journaled — you can always see which device and
|
|
author changed which file, and when. Files are real files on disk, so
|
|
everything keeps working offline; changes sync when the remote is reachable.`,
|
|
SilenceUsage: true,
|
|
}
|
|
root.AddCommand(
|
|
loginCmd(),
|
|
logoutCmd(),
|
|
initCmd(),
|
|
shareCmd(),
|
|
stopCmd(),
|
|
syncCmd(),
|
|
readLogCmd(),
|
|
hooksCmd(),
|
|
statusCmd(),
|
|
logCmd(),
|
|
webCmd(),
|
|
whoamiCmd(),
|
|
daemonCmd(),
|
|
versionCmd(),
|
|
)
|
|
if err := root.Execute(); err != nil {
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func versionCmd() *cobra.Command {
|
|
return &cobra.Command{
|
|
Use: "version",
|
|
Short: "Print the bdrive version",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
fmt.Println("beardrive", version)
|
|
},
|
|
}
|
|
}
|
|
|
|
func whoamiCmd() *cobra.Command {
|
|
return &cobra.Command{
|
|
Use: "whoami",
|
|
Short: "Show this device's identity used in change tracking",
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
dev, err := config.LoadDevice()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
home, err := config.Home()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
fmt.Printf("device id: %s\n", dev.ID)
|
|
fmt.Printf("device name: %s\n", dev.Name)
|
|
fmt.Printf("author: %s\n", dev.Author)
|
|
fmt.Printf("beardrive home: %s\n", home)
|
|
return nil
|
|
},
|
|
}
|
|
}
|