feat: multi-project sync hub, bdrive login/init onboarding, .bdrive rename

The web server (bdrive web) becomes a full sync hub, and client devices
get one-command onboarding — without ever seeing storage info or holding
cloud credentials:

- bdrive web -c config.json: server configurable from a JSON file
  (remote/addr/upload/upload_ttl/projects_db); explicit flags win.
- Hub mode: pointing bdrive web at a storage root hosts many projects,
  each under <root>/<project-id>/ (remote.Prefixed). Projects live in a
  file-backed registry (projects.json — loaded at open, rewritten
  atomically per change) with create-or-join-by-name semantics.
- Per-project APIs: /api/projects (list/create/get) and
  /api/p/<id>/{tree,file,render,download,upload/*,store/*}. The web UI
  grows a project list with per-project browsing and hash deep links.
- Browser uploads and a store proxy for syncing devices: presigned
  direct-to-storage PUTs when the backend can sign (S3 presign, GCS V4
  signed URLs; expiring, credential-free), relayed through the server
  otherwise. Journals are never presigned — only immutable blobs.
  Blobs-before-journal and one-writer-per-journal invariants hold.
- https:// remote backend: a device syncs one hub project through
  /api/p/<id>/store/* — mnt/sync/daemon/log all work unchanged.
- bdrive login <url>: verify a hub and remember it as the device default
  (settings.json). bdrive init: create-or-join a project named after the
  folder (--name/--project override), write .bdrive, seed a starter
  .bdriveignore, mount, and start the daemon — one command per project.
- Hard-break rename: .beardrive->.bdrive, .beardriveignore->.bdriveignore,
  ~/.beardrive->~/.bdrive, BEARDRIVE_HOME->BDRIVE_HOME, temp/conflict
  prefixes; old names are no longer read.
- Tests: presigning, project registry persistence, store API validation
  and gating, project isolation over live HTTP, browser upload flows, and
  two-device convergence through a hub (incl. read-only pull-only mode).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R7Q9ZKSZRTdvrSJkYLUmYs
This commit is contained in:
Snow Lee
2026-07-08 07:13:00 -07:00
co-authored by Claude Fable 5
parent fafb7fe24d
commit a7bb790615
41 changed files with 3097 additions and 313 deletions
+2 -2
View File
@@ -106,7 +106,7 @@ func Stop(volDir, mountID string) (bool, error) {
return true, nil
}
// overlayProject applies the folder's .beardrive settings on top of the registry
// overlayProject applies the folder's .bdrive settings on top of the registry
// entry; the project file wins so hand-edits take effect on the next tick.
func overlayProject(folder string, mi config.MountInfo) config.MountInfo {
proj, ok, err := config.LoadProject(folder)
@@ -167,7 +167,7 @@ func Run(folder string, scanInterval, remoteInterval time.Duration) error {
var lastRemote time.Time
for {
// Pick up `bdrive remote set`, .beardrive edits, and `bdrive umnt --forget`
// Pick up `bdrive remote set`, .bdrive edits, and `bdrive umnt --forget`
// without restarting.
if m, err := config.LoadMounts(); err == nil {
cur, ok := m[folder]