Files
beardrive/plugin/commands/init.md
T
0236e1b272 feat(cli): multi-folder --shared at init + bdrive scope to edit the sync scope (#53)
* feat(cli): init --shared accepts multiple subfolders (repeatable or comma-separated)

--shared is now a slice flag: `--shared wiki --shared docs` or
`--shared wiki,docs` sync several subfolders into one project
(include list ["wiki/", "docs/"]). The interactive scope prompt takes a
space- or comma-separated list. Entries resolving to ".", "", or ".."
error out — silently dropping them would widen scope to the whole folder.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AubcaQscjcQucXwh578vqG

* docs(plugin): skills/commands propose multiple --shared folders at init

The init/install flows now scan for all knowledge folder candidates and
offer them as one --shared list (one project, one permission set), noting
that folders needing different access belong in separate projects.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AubcaQscjcQucXwh578vqG

* feat(cli): bdrive scope — add/remove shared subfolders without editing JSON

`bdrive scope` shows the include list; `scope add`/`scope rm` edit it from
the mount root. The daemon re-reads config each tick, so changes apply in
seconds. rm deletes nothing (newly filtered paths drop from the cache with
no delete op); removing the last entry is refused since an empty include
list means whole-folder sync. add onto a whole-folder project is refused
for the same narrowing hazard. Skill/README/docs updated; scope added to
the cli-sync diagram's command list.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AubcaQscjcQucXwh578vqG

* docs+cli: scoping guide covers multi-folder --shared and bdrive scope; init hints on ignored --shared at resume

The scoping guide (the dedicated page for this feature) now shows
--shared wiki,docs and a "Change the scope later" section for bdrive
scope; setup-by-hand and project-files point at it. init resume with an
explicit --shared now says the flag is ignored instead of staying silent.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AubcaQscjcQucXwh578vqG

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-27 14:49:58 +09:00

4.8 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 shared subfolders, and start the sync daemon [folder] [--name <project> | --project <p-id>] [--shared <dirs>]

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 valid session, tell the user a browser window is coming, then run bare bdrive login (BearDrive Cloud — signing up auto-creates a free personal workspace; a pending team invite routes them into that team). If the user says their team runs its own hub, use bdrive login https://their-hub instead. Either way it completes by itself.

  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, and one enrichment owner per shared folder (everyone else indexes read-only — see the skill).
    • 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 scoped subfolders via --shared (one or more — several folders can share one project when the same people should see all of them; folders needing different access go in separate projects). 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
    bdrive init --name <project> --shared wiki,docs    # several shared subfolders, one project
    
  5. Register agent sync hooks: run bdrive hooks install <folder>. It detects the agent platforms in use (Claude Code, Codex, Gemini CLI, Hermes — by their config dirs in the project or home) and idempotently merges beardrive's sync hooks into each platform's own hook config, so files pull at every turn start, push after edits, every change is stamped with the agent session that made it, and agent file reads — native reads, grep matches, and files named in shell commands — feed the hub's read heatmap (queued locally by bdrive read-log, reported on the next sync). Tell the user which platforms got hooks; if Codex is among them, mention they must run /hooks inside Codex once to trust the project's .codex layer.

  6. 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 the two-file agent orientation, each part as its own consent (full flow: the skill's "Teaching agents the folder" section): a synced <shared>/AGENTS.md mapping the folder — draft it if this user is creating the project, read and follow it if joining — and, for --shared mounts inside a repo, a short pointer to it in the repo root's AGENTS.md/CLAUDE.md (the only file Codex loads, and what makes any agent aware the folder matters). Then tell the user how teammates connect (invite link → bdrive init → same --shared scope, which is per-device).

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