Files
beardrive/plugin/commands/init.md
T
Snow LeeandClaude Fable 5 10a9998672 feat(sync): fence nested mounts; knowledge-init flows in plugin docs
A subdirectory with its own .bdrive/config.json now syncs only through
its own project: the parent mount never scans into it, materializes
over it, or emits deletes for paths under it (cached paths are dropped
without delete ops, the same posture as newly ignored files). Detection
is presence-based (config.IsMount) so even a corrupt nested config
still fences. This makes the team-knowledge-folder-inside-a-personal-
mount topology safe.

The plugin's init command and skill gain a "connecting knowledge
tooling" playbook: a detection ladder (gbrain -> OKF wiki -> plain
docs folder -> starting-point menu) and two hard rules — one transport
per folder (git-tracked dirs are handed off via git rm --cached +
gitignore before syncing) and knowledge-as-scoped-subfolder (never a
repo root). Conflict copies documented with their exact glob
(*.bdrive-conflict-*), since openknowledge validate cannot see them.

New flow tests: shared-subfolder scope both ways, teammate connect
over identical/divergent local content, nested mount syncing
independently on two projects, and a guard pinning the conflict-copy
filename to the documented glob.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P5cxPQdSGJnjXCYY9GeWXt
2026-07-10 21:42:36 -07:00

3.1 KiB

description, argument-hint
description argument-hint
Start syncing a project in this folder — create a new BearDrive project or connect an existing one, whole folder or a shared subfolder, and start the sync daemon [folder] [--name <project> | --project <p-id>] [--shared <dir>]

Start syncing a project with BearDrive. Arguments: $ARGUMENTS (optional folder, optional --name/--project/--shared).

Follow these steps:

  1. Check the bdrive CLI is installed: run command -v bdrive. If missing, offer to install it (brew install runbear-io/tap/beardrive, or go install github.com/runbear-io/beardrive/cmd/bdrive@latest) and wait for the user's choice before installing.

  2. Sign in if needed: run bdrive login --status. With no server or a stale token, run bdrive login (tell the user a browser window is coming; it completes by itself). Default server is beardrive.ai; pass a self-hosted URL if the user mentioned one.

  3. Detect knowledge tooling (skip if the folder already contains .bdrive/ — then just run bdrive init --yes; it resumes syncing, including after a rename/move). Check, in order — first match wins, ask if two match (full playbook: the beardrive skill's "Connecting knowledge tooling" section):

    • gbrain (gbrain.yml, or a gbrain MCP server / brain-first CLAUDE.md block) → offer to sync the brain's shared subfolder as its own project; never a brain root.
    • OKF wiki (markdown with OKF frontmatter) → offer: connect the wiki dir via --shared, or keep it PR-gated and create a new shared folder.
    • Wiki-ish folder (docs/wiki/notes full of markdown) → check git log -- <dir>; dormant → recommend connecting it, active PR traffic → recommend a new shared folder. Offer an OKF upgrade (openknowledge from) after connecting, as a separate consent.
    • Nothing / empty → offer a starting point in this order: OKF (recommended), gbrain, blank, describe-it.
  4. Initialize — two hard rules:

    • Never sync a repo root: inside a repo, knowledge syncs as a scoped subfolder via --shared. A dedicated knowledge folder (empty dir, standalone vault) may be the mount itself.
    • One transport per folder: a git-tracked dir must leave git tracking before it syncs (git rm -r --cached <dir> + gitignore; stage it, let the user commit). Offer one-way git snapshots if they want a git record; bdrive log -p <path> covers history for most.
    bdrive init --name <project> --yes            # dedicated knowledge folder
    bdrive init --name <project> --shared wiki    # in a repo: only ./wiki syncs
    
  5. Verify: run bdrive status <folder> and confirm the daemon is running and pending is 0. Summarize: project name/id, what syncs, and that edits propagate to every team member within seconds. Offer a consent-gated CLAUDE.md note and tell the user how teammates connect (invite link → bdrive init → same --shared scope, which is per-device).

For the full team setup (CLAUDE.md guidance + per-project sync hooks in .claude/settings.json), suggest /beardrive:install instead.