* test(cmd/bd): reset cobra flags between in-process runs; keep them out of parallel tests
runBDInProcess and runBDInProcessAllowError execute the package-level
rootCmd tree again and again in one process, and cobra never resets a
flag between Execute calls: a value one invocation parsed (create's
--title, --labels, list's --status, ...) and its Changed bit stayed on the
FlagSet, so the next invocation saw it, and a slice flag that had been
set appended to the stale value instead of replacing it. With a Dolt test
server (the only setup in which these tests run) that failed about 20
TestCLI_* tests depending on suite order.
TestMain now snapshots every flag of the tree (snapshotCommandFlags,
after all init()s registered them, before any test runs) and both runners
put the tree back before and after each run (resetCommandFlags): the
pointee of each flag.Value is restored (for pflag's scalar types that is
the bound variable; for slice types it also clears the internal "changed"
bit, so the next Set replaces), slice contents via SliceValue.Replace,
and Changed=false. TestResetCommandFlagsRestoresEveryFlag sets every flag
of the real tree and checks the reset. The ad-hoc --title reset in
TestCLI_CreateRejectsEmptyTitle_ProxiedServerMode is no longer needed.
Seven TestCLI_Comment* tests called t.Parallel() around the runners.
inProcessMutex serializes the runners only against each other, so their
chdir, stdio swap, env and config re-initialization raced every other
parallel test (data races on config globals; TestCobraParallelPolicyGuard
failing to read its own source files after a concurrent chdir). They run
serially now, and the guard treats the two runners like rootCmd.Execute.
Also two stale TestCLI_Create* cases: DryRunWithRigPrefix exercised a
create --prefix flag that no longer exists, and the flag-like-title cases
passed "--help" or "--foo-bar" where cobra parses them as flags; they now
pass the title after "--", the only way it reaches create's own guard.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(cmd/bd): fix the ADO round-trip and bulk-delete tests that rotted unseen
Both need the integration tag and a Dolt test server, which no CI lane
gave cmd/bd (BEADS_TEST_SKIP=dolt everywhere), so they failed unnoticed:
- TestADORoundTrip* stored ado.pat in the database. ado.pat is a secret
read only from config.yaml or AZURE_DEVOPS_PAT (config.IsYamlOnlyKey),
so the tracker found no PAT. The fixture sets AZURE_DEVOPS_PAT.
- TestBulkDeleteNoResurrection expected GetIssue to return (nil, nil) for
a deleted issue; the Dolt store reports storage.ErrNotFound.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(cmd/bd): fix parity, completion and notion tests that only fail with a Dolt server
These are Dolt-gated (integration tag + test server), so no CI lane ran
them and they rotted:
- TestParityCreate*/TestParityReopenErrorExits1Silently: bd create
auto-routes via routing.DetectUserRole("."), which warns "beads.role
not configured (GH#2950)" on stderr when the working directory's git
config has no beads.role. The suite pins the configured case, so the
parity env now sets beads.role=maintainer in a test-owned global git
config ($XDG_CONFIG_HOME/git/config; the role lookup scrubs every
GIT_CONFIG_* variable, so those cannot be used).
- TestIssueIDCompletion: issueIDCompletion resolves a database path
before looking at the open store and returns nothing when there is
none; the test now sets dbPath to its store's path.
- TestIssueIDCompletion_UsesWorktreeFallbackWhenStoreNil and
TestGetNotionConfigReadsDBPathWhenStoreUnset: the code under test
reopens the store from metadata.json, which names a database but not
the per-test branch of the shared database that newTestStore uses, so
the reopened store saw none of the test's rows. They now use their own
database (newTestStoreIsolatedDB).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(cmd/bd): fix stale doctor/e2e/autocommit/readonly Dolt-gated tests
These need the integration tag and a Dolt test server, which no CI lane
gave cmd/bd, so they rotted unseen:
- TestE2E_DoctorFixMetadataRoundtrip, TestE2E_MigrateDoltMetadata,
TestDoctorCheckHealthReportsVersionMismatchOnRepoLocalPort: bd init now
defaults to embedded mode, where `bd sql` and `bd dolt start` are
refused. Init with --server on a repo-local server of their own
(repoLocalServerEnv: the suite's shared-server port vars cleared, server
stopped at cleanup) and start it explicitly, since BEADS_TEST_MODE=1 never
auto-starts one. MigrateDoltMetadata's DELETE also needed `key` quoted.
- TestDoctor{Conventions,Pollution}MaxRows_EnvOnly_Exits2: bdRunRaw drops
every BEADS_* variable, so the subprocess hit dolt.New's test-database
firewall (exit 1) before the row cap; pass BEADS_TEST_SERVER=1.
- TestDoltAutoCommit_On_WritesAdvanceHead: the embedded engine keeps its
data under .beads/embeddeddolt, not .beads/dolt; findDoltRepoDir looks
in both.
- TestValidateCheck_AllClean: bd doctor validate runs five checks since
the cross-table duplicates check was added.
- TestConfigValidateReadOnlyIsHermetic: readonly commands take a shared
workspace gate, whose lock file (.beads/dolt.gate.lock) workspacegate
creates on first use by design; compare the .beads tree without gate
lock files.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(cmd/bd): undo each in-process execution's env and storage-mode leaks
Every in-process run of the bd command tree (runBDInProcess and the many
tests that call rootCmd.Execute directly) leaves process state behind:
PersistentPreRun exports the selected workspace as BEADS_DIR, loads its
.beads/.env, and records the workspace's mode in serverMode /
proxiedServerMode. With a Dolt test server, later tests in the same shard
then resolved a deleted fixture ("no active beads workspace found",
"migration sidecar is missing"), ran subprocess bd against the wrong
workspace ("recorded as proxied-server in .beads/metadata.json"), or took
the proxied path in RunE-level tests ("proxied-server UOW provider not
initialized", a nil-UOW panic in reopenProxiedResolve that killed a shard).
TestMain now registers a cobra initializer/finalizer pair
(installExecuteIsolation) that snapshots the environment and the two mode
globals when an execution starts and restores them when it ends; the
runners' restoreEnvSnapshot shares the helper. TestDoltConfigEnvironmentOverrides
used os.Setenv + defer os.Unsetenv, which deleted the suite's
BEADS_DOLT_SERVER_PORT (the test server's port) for every later test; it
uses t.Setenv now.
Full integration-tagged cmd/bd suite against a hermetic dolt (16 shards):
18 order-dependent failures and the shard panic gone; the 27 remaining
failures all fail alone too.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(init): keep --quiet quiet through the Claude/Codex/Cursor auto-setup
`bd init --quiet` ("Suppress output") still printed the project
integration installers' progress to stdout ("Installing Claude hooks for
this project...", "Claude Code integration installed", ...): the
installers write to os.Stdout unconditionally. Point stdout at the null
device around them while quiet; their failures keep going to stderr as
before. Found by TestInitCommand's quiet case, which asserts no output and
had not run in CI (Dolt-gated).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(init): bring the Dolt-gated init tests up to the current init contract
These tests need a Dolt test server, so no CI lane ran them and they
drifted from the product:
- Embedded is init's default mode, so the server-mode assertions
(.beads/dolt, opening the database on the test server, dolt_mode
"server" in metadata.json) now pass --server (TestInitCommand,
TestInitAlreadyInitialized, TestInitRedirect, TestInitBEADS_DIR,
TestInitDoltMetadata, TestInitDoltMetadataNoGit, TestInitDatabaseFlag's
metadata subtests). The in-process ones reset rootCmd's flags around
themselves so --server cannot leak into later in-process inits.
- Each server init gets its own --database: the suite shares one test
server, and a "test" database another test created belongs to another
project (init refuses: PROJECT IDENTITY MISMATCH).
- The marker tests seed a current-era version witness: the legacy-upgrade
guard refuses a non-empty .beads/dolt without one.
- The redirect test provisions the canonical target with config.yaml: bd
ignores a redirect to a directory with no project files (#4692).
- Shared-server inits get a free port of their own
(sharedServerTestEnv): the inherited BEADS_DOLT_SERVER_PORT is the
suite's test server, which a shared-server start refuses as another
project's, and the default shared port is 3308, a developer's live
server.
- --shared-server's config.yaml is now nested YAML (dolt: shared-server:
true); parse it instead of matching the old flat line.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(cmd/bd): run the Dolt-gated tests that skipped on a bare dolt.New
setupTestDB (config, kv and Linear round-trip tests), setupGatedTestDB
(mol ready --gated) and the rename-prefix and bd sql tests opened stores
with dolt.New(&dolt.Config{Path: ...}): no server port, no
CreateIfMissing, so against a running test server they got "database ...
not found" and skipped as "Dolt server not available". They now use the
suite's newTestStore helpers (skip only when no test server runs), and
what that exposed is fixed test-side:
- TestCustomStatusConfig: custom_statuses is read back ORDER BY name;
look statuses up by name / expect name order.
- TestLinearRoundTripCoreFields, TestLinearPullMilestonesCreatesEpicHierarchy:
linear.api_key is a yaml-only secret (LINEAR_API_KEY), push now needs an
explicit linear.state_map, and batch push uses TeamLabels and
issueBatchCreate, which the mock server now answers.
- TestSqlCommand: bd sql refuses in the default embedded mode; set
serverMode for the server-backed store, and stop discarding RunE errors.
- TestE2E_AutoStartedRepoLocalServerPersistsAcrossCommands skipped on
this process's embedded mode although every bd it runs is a subprocess
on a --server workspace; gate on the dolt binary instead and stop the
auto-started server at cleanup.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(cmd/bd): no fixed "unused" port, no swallowed JSON, no leaked front-door server
Three more things the Dolt-backed cmd/bd run exposed:
- TestTestServerConnection, TestSharedServerCfgNilHonorsSharedServer and
the two TestLegacyGuard* e2e tests pointed bd at 127.0.0.1:59999 as a
port nothing listens on. Any process on the host may hold it; a
listener that accepts and resets turns the expected "connection
refused" / "Dolt server unreachable" into another error. They take a
just-freed port from closedLoopbackPort (testutil.FindFreePort) now.
- TestDoltSetConfigJSONOutput and TestDoltSetConfigWithUpdateConfig
created .beads 0755, so bd's permissions warning landed in the JSON
under test and the tests skipped ("output not pure JSON") every run.
The fixture uses 0700, and non-JSON output fails instead of skipping.
- TestMigrateDoltModeFrontDoor's closing show/list auto-start a
repo-local server after the reverse migration; nothing stopped it, so
the suite's leak check failed (when the opt-in
BEADS_TEST_MIGRATION_FRONTDOOR suite runs). It stops it at cleanup.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* ci(bazel): advisory cmd/bd Dolt-server tier (bazel-cmd-dolt)
No CI lane ran cmd/bd's Dolt-gated tests (TestCLI_*, the init and
store-backed suites, the doctor/e2e tests): main.yml's integration shards,
nightly's Full Test Suite, and Bazel's --config=prcore/ci and
--config=integration all pass BEADS_TEST_SKIP=dolt, so cmd/bd's TestMain
never starts a test server and those tests skip; the proxied and embedded
tiers run only their manifests' tests. They rotted unseen.
//cmd/bd:bd_dolt_server_test (tag dolt-server-cmd) runs the whole
integration-tagged cmd/bd suite, the integration build's bd_test, against
a hermetic dolt sql-server: BEADS_TEST_DOLT_SERVER=local starts it from
the pinned dolt in the test wrapper's runfiles, and
BEADS_TEST_REQUIRE_DOLT_CONTAINER=1 fails the target instead of skipping
into a cached pass. No test selection: the Go binary shards itself over
every top-level test (32 shards), so each runs exactly once, and
check_testcases.py fails a shard that ran none. --config=doltserver-cmd
has exactly --config=integration's build flags, so the two lanes share
bd_test's compile; prcore/ci and integration exclude the tag.
bazel.yml's new bazel-cmd-dolt job runs it exactly where bazel-integration
runs (same if: remotely on the farm for same-repo PRs, fork-ro/fork-rw,
and locally with the read-only cache in mode cache for forks). It is
advisory: job-level continue-on-error keeps a failure out of the call's
aggregate (BAZEL), and pr.yml's ci-gate reads its result (BAZEL_CMD_DOLT)
but requires it only while the committed top-level flag
BAZEL_CMD_DOLT_REQUIRED is "true" (now "false"; flipping it is the one
change needed). bazel-gate.sh accepts its skip in modes skip and local.
Policy tests: a third lane category in TestBazelLaneIsGatedAlongsideLegacy
(bazelFlagGatedLanes: gate env wired, never statically required, added by
the run script exactly when the pinned flag is "true"), the gate
simulation over every mode with the flag off (advisory: nothing it
reports reddens the gate) and on (exactly a gated lane), the cache-mode
and execution-mode checks, the tag taxonomy and prcore/integration
exclusions, and TestBazelCmdDoltJob (job steps, timeouts, .bazelrc
config equal to integration's build with no dolt skip or test selection,
the target's dolt-server rules, and bd_test's env repeated).
Measured locally (all fixes in this series, 32 shards, 16 at a time on a
shared host): 3267 top-level tests, all shards pass, max shard 313s (one
5001-issue export test, 214s, sets it), mean 100s.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(init): hand the project installers a writer instead of swapping os.Stdout
The --quiet fix earlier in this series pointed the process-global
os.Stdout at the null device around the Claude/Codex/Cursor installers.
That works, but it mutates a global from inside a cobra Run: anything else
writing to stdout meanwhile (a goroutine, a future concurrent installer)
would vanish, and a concurrent read of os.Stdout is a data race.
The installers already write through env structs with stdout/stderr
fields. setup.ProjectInstallOutput carries the two writers, and
InstallClaudeProjectTo / InstallCodexProjectTo / InstallCursorProjectTo
use them (the old entry points keep the process streams). init passes
QuietProjectInstallOutput() under --quiet: progress discarded, error lines
still on stderr. The proxied-server init path (domain adapter
InstallClaudeProject now takes quiet) does the same, so its
"Installing Claude hooks..." is quiet too.
Consistent error policy under --quiet: errors still reach stderr. init's
own "Warning: failed to setup <installer>" lines were suppressed under
--quiet while the installers' "Error:" lines were not, and some installer
failures (Cursor rules) print nothing themselves; the warnings now print
whether or not quiet, like the installers' errors.
Coverage in required lanes: TestProjectInstallersReportToTheGivenOutput
(cmd/bd/setup) and TestEmbeddedInitA/basic, which now asserts that
`bd init --quiet` with agents enabled installs the Claude hooks and prints
none of the installers' progress (verified to fail with the quiet output
disabled).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(export): exercise the incremental-export fallback with a small threshold
TestTryIncrementalExport_ThresholdExceededFallsBack seeded
incrementalExportThreshold+1 = 5001 issues to cross the threshold. Batch
create is one transaction but still several statements per issue, so under
-race against the shared test server it took ~214 s, the longest test in
cmd/bd's Dolt-backed suite by far. The behaviour under test is only
"more changed issues than the threshold -> full export fallback".
incrementalExportThreshold becomes a var (same value), and the test, which
is not parallel, sets it to 20 and seeds 21 issues: 214 s -> 0.6 s.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(cmd/bd): tighten the flag-reset self-test, guards and canaries
Review follow-ups:
- TestResetCommandFlagsRestoresEveryFlag no longer skips a flag it cannot
set: a flag type without a sample value, a Set error, or a non-pointer
Value (which resetCommandFlags could not restore) is an error, so a new
flag type cannot go untested. resetCommandFlags documents that it also
resets flag-bound package globals.
- TestCobraParallelPolicyGuard treats .ExecuteC/.ExecuteContext/
.ExecuteContextC like .Execute (the per-execution isolation writes the
mode globals; a parallel execution would race).
- TestConfigValidateReadOnlyIsHermetic ignores only the gate a readonly
command takes (.beads/dolt.gate.lock and its .info sidecar), not any
"*.gate.lock*" file, so a new unexpected gate still trips the canary.
- TestCLI_CreateRejectsFlagLikeTitles: a bare `bd create --foo-bar` must
fail and create no issue (bd-2c0's intent), next to the "--" cases.
- TestCustomStatusConfig cites why statuses come back in name order: the
normalized custom_statuses table (#2961, 8537d943b) has no ordinal and is
read ORDER BY name, like custom_types; the test predates it.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* ci(bazel): run the cmd/bd Dolt-server tier in 16 shards
Each shard pays ~30-40 s of fixed cost (TestMain plus its own dolt
sql-server), so 32 shards spent roughly 40% of the lane's executor time on
setup and added 32 farm actions to every PR touching cmd/bd. With the
5001-issue export test cut to under a second, 16 shards measure (locally,
--nocache_test_results): max 186 s, mean 137 s, 2,187 executor-seconds
(vs ~2,800-3,200 at 32), all 3,267 top-level tests, every shard passing.
TestBazelCmdDoltJob pins the count; bazel.yml's timing comment is
restated (cache mode ~20-30 minutes).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(bazel): add internal/testutil/bazeltest runfiles helpers
Repository-path resolution for tests that works identically under plain
go test (package cwd, full checkout), bazel test locally, and remote
execution (declared runfiles only):
- IsBazel, RepoRoot (BEADS_TEST_REPO_ROOT, then the runfiles workspace
root, then a go.mod walk), OverrideRoot (drop-in condition for existing
helpers; empty under plain go test), CallerDir
- Runfile for $(rlocationpath) values, GOROOT for type-checking tests
- ShardFreeEnv for helpers that re-exec a test binary
Every helper reduces to the pre-Bazel behavior under go test.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(bazel): declare source/data reads for 14 scan-guard targets
Source-scanning and repo-file tests read files their Bazel targets never
declared, so they failed under `bazel test` (and could not run on remote
workers at all). Declare narrow inputs as `data` and resolve paths through
bazeltest where the test located the tree via runtime.Caller:
- tools/bazel/go_srcs.py (run by `make bazel-sync` after gazelle) keeps a
managed `go_srcs` filegroup in the packages whose Go source tests scan,
plus `//internal/storage:tree_go_srcs` for the storage-tree walk. Bazel
globs stop at package boundaries, so the aggregate needs one filegroup
per package; the script keeps it in sync and gazelle-stable.
- Hand-written narrow inputs: //internal/storage/schema:migrations,
//:docsync_files, //plugins/beads:plugin_files, and exports of
.gitattributes, .claude-plugin/marketplace.json, cmd/bd list.go and
ready.go, testutil/testdoltcommon.go, scripts README.md and the release
catalog, each visible only to its consumer.
- runtime.Caller-based roots in backend, backend/conformance,
internal/storage, internal/formula and test/docsync now go through
bazeltest.CallerDir / OverrideRoot; relative-path tests need data only.
- integrations/ leaves .bazelignore (it is still gazelle-excluded) so the
docsync link check can declare integrations/beads-mcp/PYPI.md.
Under --config=prcore every target reports the same PASS/SKIP/FAIL test
set as `go test -race -short` for its package, locally and remotely.
Plain `go test` behavior is unchanged.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(bazel): guard generated go_srcs and harden bazeltest root override
- tools/bazel/go_srcs.py: add --check (print diff, exit 1 on stale blocks);
new `make bazel-sync-check` target runs it.
- scripts/bazel_policy_test.go: under go test, assert every tree_go_srcs
(//internal/storage) lists exactly the BUILD.bazel packages below its
root, run go_srcs.py --check, and forbid BUILD files under docs/ and
engdocs/ (they would cut subtrees out of //:docsync_files).
- bazeltest: honor BEADS_TEST_REPO_ROOT only when it holds go.mod
(RepoRoot fails loudly otherwise); drop the unused GOROOT() helper,
whose compiled-in branch could never fire under rules_go.
- scripts/ci/lib/test-env.sh: unset BEADS_TEST_REPO_ROOT.
- Document the hand-listed out-of-tree link targets in //:docsync_files.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* build(bazel): re-sync BUILD files with main
Regenerated with make bazel-sync after commits that landed while the
scaffold PR was in CI (new internal/execenv, gitenv, gitignore packages
and new sources/deps).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(bazel): declare init_safety_help.go for docsync
TestInitSafetyCLIHelpCoversReCloneGotchas (#6431) reads
cmd/bd/init_safety_help.go; export it to //test/docsync only.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* build(bazel): add side-by-side Bazel scaffold (module + gazelle)
Add a Bzlmod Bazel build alongside the Go toolchain. `go build` and
`go test` are unchanged; nothing in CI invokes Bazel yet.
- MODULE.bazel: rules_go 0.63.0, gazelle 0.53.0, Go SDK 1.26.7 (matches
the go.mod toolchain directive), go_deps from go.mod.
- ICU policy (engdocs/ICU-POLICY.md): a go-mysql-server gazelle_override
selects the pure-Go regex backend and excludes regex_cgo.go, and
.bazelrc builds with --@rules_go//go/config:tags=gms_pure_go, so no
target depends on go-icu-regex or links libicu.
- third_party/patches: three module_override patches for dolt deps that
ship WORKSPACE-era BUILD files, adapted from the gascity project.
- .bazelrc: prcore/ci test configs (inert for now; they match pr-core's
test selection, not yet its environment isolation) and a generic
remote-exec config with a bounded remote timeout. Executor endpoints and
TLS credentials come only from a gitignored .bazelrc.local/user.bazelrc
or a CI rc outside the workspace.
- .bazelversion pins Bazel 9.2.0; .bazelignore skips separate modules,
non-Go trees, nested agent worktrees (.claude, .worktrees) and local
data/output dirs (.beads, .dolt, dist, .runtime, tmp), so a primary
checkout neither builds nor gazelle-rewrites nested worktree copies.
- Gazelle-generated BUILD.bazel files for every Go package.
- Makefile: `make bazel-sync` (gazelle + bazel mod tidy).
- .gitignore: bazel-* output symlinks and machine-local rc files.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(bazel): policy tests for the Bazel configuration
Add scripts/bazel_policy_test.go, plain Go tests that run under both
`go test ./scripts` and `bazel test //scripts:scripts_test`:
- MODULE.bazel go_sdk.download version equals the go.mod toolchain.
- ICU policy: .bazelrc sets gms_pure_go for build, the go-mysql-server
gazelle_override excludes regex_cgo.go, and the root BUILD.bazel
carries `# gazelle:build_tags gms_pure_go`.
- .bazelversion pins an exact Bazel release.
- .bazelrc.local and user.bazelrc are gitignored (parsed from .gitignore
and cross-checked with git check-ignore when in a checkout).
- No remote-execution endpoints or credentials in committed bazelrc-like
files, Markdown docs or .github/**: remote/BES/TLS flags
(--remote_executor, --remote_cache, --bes_backend, --remote_header,
--tls_client_certificate, ...) with a literal value, with or without a
URL scheme, and non-loopback gRPC URLs in rc/.github files. Placeholders,
$VARIABLES, and loopback are allowed; Markdown gRPC URLs (OTel exporter
docs) are not flagged. Skipped outside a git checkout, e.g. in the Bazel
sandbox.
Each check is a pure function also exercised against fixtures that break
the invariant. The files the tests read are declared as data via
//:bazel_policy_files so they resolve from runfiles under Bazel.
scripts/check-build-tags.sh now treats Bazel invocations as governed by
.bazelrc: the shell command segment that invokes Bazel (split on &&, ||,
;, |, $( and backticks) is exempt from the per-line `go` tag check, while
a bare `go` in another segment of the same line is still flagged. When
any scanned file invokes Bazel (or .bazelrc exists) .bazelrc must set
--@rules_go//go/config:tags=gms_pure_go for build.
scripts/check_build_tags_test.go covers both in a temp repository.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(scripts): split bazel lines in pure bash so check-build-tags works with BSD sed
BSD sed (macOS) does not expand \n in s/// replacements, so the segment
split never happened and the Bazel-exemption tests failed on macos-latest.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(scripts): skip check-build-tags tests when bash lacks mapfile
macOS runners use /bin/bash 3.2, which has no mapfile; check-build-tags.sh
has always required bash >= 4, so the new tests are skipped there.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(setup/claude): keep settings.json's trailing newline and skip no-op rewrites (#5693)
bd setup claude (and bd init, which calls it) marshalled the Claude settings
map with json.MarshalIndent and wrote it unconditionally. MarshalIndent emits
no trailing newline, so every run stripped the one Claude Code's own writes
leave behind, and re-wrote the file even when no hook changed. Because bd init
git-adds .claude/settings.json, that surfaced as a staged diff with no
semantic content.
The same marshal-then-write pattern appears at four call sites in claude.go:
installClaude's settings write and its settings.local.json migration, and
removeClaude's settings write and its settings.local.json cleanup. Fixing one
would have left the bug live in the other three, so both halves are now shared
helpers -- marshalSettings appends the newline, writeSettingsIfChanged compares
against the bytes already on disk and returns early when they match -- and all
four sites go through them.
Reported by @maphew.
* chore(setup/claude): use the repo spelling "marshaled" in the new comments
The misspell linter flags British "marshalled"; CI pins golangci-lint
v2.10.1 and runs it with --new-from-merge-base, so both new comment lines
are in scope. Comment text only, no behaviour change.
#4838 taught `bd setup claude` to detect a CLAUDE.md that is a thin stub
importing AGENTS.md, and to write the managed beads block to AGENTS.md instead.
isAgentsImportStub decides that by scanning for "@AGENTS.md" on its own line,
with no notion of code blocks — so a CLAUDE.md that merely *documents* the
pattern in a fenced example is classified as a stub.
That is not a cosmetic misread. Once the redirect activates, stripStaleClaudeBlock
removes the managed block from CLAUDE.md, on the reasoning that AGENTS.md now
owns it. For a file that was in fact authoritative, a documentation example
silently moves the block out of it. The new end-to-end test is the one that
matters here: against the parent commit it fails with
CLAUDE.md is authoritative and must carry the beads block;
a fenced example redirected it away
Skipping fenced regions also matches the semantics being detected: Claude Code
does not expand an @-import shown as code, so a fenced directive was never going
to make the file a stub in the first place.
Deliberately narrow in two places, both pinned by tests:
- Four-space-indented lines are still scanned. Indentation is ambiguous in a way
a fence is not — it is equally a list continuation, which is a plausible home
for a real directive — so treating it as code would trade this false positive
for a false negative. "indented directive still counts" pins that.
- A closing fence must match the character that opened the block, so ``` inside a
~~~ block does not terminate it and let a following directive leak through.
An unterminated fence swallows the rest of the file, which is also what a
Markdown renderer does, so the conservative answer there is the correct one
rather than an accident. Both are pinned.
Five of the seven new unit cases fail against the parent commit; the two that
pass in both directions are the over-correction guards ("real directive after a
fenced example still counts", "indented directive still counts") and exist so a
future fix cannot go too far the other way.
This closes the last of the two nits left open on #4838's review; the other
(path-qualified "@./AGENTS.md") was already handled before that PR merged.
Note for whoever looks at CI: `main` is currently red on Test (macos-latest) for
three unrelated failures — see #5210 and #5220. This branch touches only
cmd/bd/setup and does not go near them.
Agent-Signature: claude-opus-5-high on behalf of maphew
Normalize every shared command argument-hint to an explicit YAML string and enforce the schema across LF and CRLF checkouts so Copilot plugin skills load reliably.
Agent-Signature: codex-gpt-5.6-sol-high on behalf of matt wilkie
* feat(setup): redirect beads block to AGENTS.md when CLAUDE.md is a stub
When CLAUDE.md is a thin pointer that imports AGENTS.md via the
@-include convention (e.g. "@AGENTS.md" on its own line), bd setup claude
now writes the managed BEADS INTEGRATION block to AGENTS.md instead of
duplicating it in the stub. This supports the shared-authoritative-file
pattern used by repos that keep AGENTS.md as the single source of agent
instructions.
The redirect applies to install, check, and remove operations. If
AGENTS.md does not exist, the fallback behavior (writing to CLAUDE.md)
is preserved.
Agent-Signature: amp-gpt-5.4-2026-03-05-high on behalf of maphew
* fix(setup): strip stale CLAUDE.md beads block when AGENTS.md redirect activates
An older bd could have written a beads-managed block directly into CLAUDE.md
before a project adopted the "@AGENTS.md" import-stub pattern; once the
redirect to AGENTS.md activates, that block became an orphaned duplicate that
neither install nor remove ever cleaned up. installClaude now strips a stale
block from CLAUDE.md when the redirect is active (preserving the rest of the
stub), and removeClaude strips it too, alongside removing the AGENTS.md copy
as before.
Agent-Signature: claude-fable-5-high on behalf of matt wilkie
* fix(setup): gate CLAUDE.md strip on successful AGENTS.md injection; preserve shared AGENTS.md block on remove
Addresses two major findings from PR #4838 review:
- installClaude stripped the stale CLAUDE.md beads block whenever the
AGENTS.md redirect was active, even when installAgents skipped injection
(e.g. AGENTS.md is a symlink). That deleted the only copy of the beads
block without writing a replacement. Gate the strip on
`redirected && !agentsSkipped`.
- removeClaude with the redirect active called removeAgents against
AGENTS.md, deleting the project-authoritative shared beads section that
bd init/other agents' setup created and other agents rely on. Limit the
redirected remove path to stale CLAUDE.md cleanup and leave the shared
AGENTS.md section intact.
Also addresses minor finding: isAgentsImportStub now also accepts the
`@./AGENTS.md` relative-import form, not just `@AGENTS.md`.
Deferred (minor, ambiguous product intent, needs maintainer input rather
than a guess): blank AGENTS.md gets ProfileMinimal on redirect; whether it
should get the full profile instead is a product decision, not a bug fix.
Added regression tests: TestInstallClaudeRedirectSkipsStripWhenAgentsSymlink,
TestRemoveClaudeRedirectPreservesFullProfileSharedBlock; updated
TestRemoveClaudeRedirectsToAgentsMD and
TestRemoveClaudeRedirectCleansStaleClaudeBlock to assert the shared AGENTS.md
block is preserved on remove; added an @./AGENTS.md case to
TestIsAgentsImportStub.
Agent-Signature: claude-fable-5-high on behalf of matt wilkie
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Recognize the exact historical bd-prime SessionStart pipeline, remove only that nested command, preserve unrelated hooks, and report the legacy-plus-canonical state as stale.
Agent-Signature: codex-gpt-5.6-sol-high on behalf of matt wilkie
Per decision 7, bd's user-facing strings now reference the Mintlify-era
paths: prime policy-profiles help, storage-backend comparison help
(store_factory_nocgo, init --backend), init-safety help (recovery
playbooks now docs/recovery/init-safety.md; the ADR reference now
engdocs/adr/), the pk-fork-refused recovery URL (dolt.go), doctor's plugin
suggestions (claude.go) and managed-handoff pointer, aider setup guidance
and the shared recipe template (quickstart URL), and the agent instruction
templates (sync-concepts URL, quickstart URL). bd mol pour's help no
longer claims molecules are 'synced with git' — they sync via Dolt like
any other bead.
Also corrects the stale claude recipe ProjectPath metadata
(.claude/settings.local.json -> .claude/settings.json; the dedicated
installer has written settings.json since the migration sweep).
This repo's AGENTS.md managed section is refreshed to the new template
body (hash bacef91e, has-remote variant preserved), and agents.md.tmpl's
embedded marker matches. Template tests updated to pin the new fragment;
CLI docs regenerated.
Recorded, not fixed (behavior-level, see the decision record):
routing.mode's maintainer/contributor no-op values and the
sync.require_confirmation_on_mass_delete key with no consumer.
Note: TestCheckBeadsRole_NotConfigured/_NotGitRepo in cmd/bd/doctor fail
on any machine with beads.role in the global git config (no HOME
isolation) — pre-existing, unrelated to this change.
Cursor support is anemic compared to Claude Code and Codex. It ships
only a static rules file: no agent lifecycle hooks, so `bd prime`
context is never injected at session start and is silently lost after
context compaction, and it has no `bd init` auto-install, no `--global`
scope, no shared agent skill, and no `bd doctor` coverage.
This PR brings Cursor up to the same footing as the tier-1 integrations.
- `bd setup cursor` now installs agent lifecycle hooks
(`.cursor/hooks.json`) alongside the rules file, wiring
sessionStart/preCompact/postToolUse to a hidden `bd cursor-hook`
command so Beads context survives compaction:
* sessionStart injects full `bd prime` context into new sessions
* preCompact arms a one-shot refresh marker
* postToolUse re-injects `bd prime` once after a compaction, then
no-ops
- `bd init` auto-installs Cursor (rules + skill + hooks) and stages
`.cursor/`
- `bd setup cursor --global` writes `~/.cursor/hooks.json` +
`~/.agents/skills/beads`
- Canonical rules: `.cursor/rules/beads.mdc` wraps the shared
`recipes.Template` instead of a hand-maintained copy
- Shared agent skill (`.agents/skills/beads`), removed only once neither
Cursor nor Codex still relies on it
- `bd doctor` reports Cursor Integration, Settings Health, and Hook
Completeness checks with agent-mode enrichment
Shared hook mechanics (prime runner + one-shot refresh marker) are
factored into `cmd/bd/agent_hook.go` and reused by codex-hook.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat: Add bd unclaim command to release stuck issues
- Add UnclaimIssue method to storage interface and implementations
- Add bd unclaim CLI command: clears assignee, resets status to 'open'
- Improve claim error message when issue has assignee but status is 'open'
(now suggests using bd unclaim)
- Update documentation: CLI_REFERENCE.md, QUICKSTART.md, setup templates
- Add unclaim tests
- Fix telemetry wrapper to implement UnclaimIssue method
- Add test mocks for UnclaimIssue in jira tests
* docs: regenerate CLI reference for bd unclaim
Runs scripts/generate-cli-docs.sh to add the bd unclaim entry that
gastownhall/beads#3694 introduced but whose CLI_REFERENCE.md/website
delta was lost in the conflict resolution during the cherry-pick.
Scoped to only the unclaim addition; unrelated doc drift already
present on main (formula/lint/types/linear entries) is left untouched.
Agent-Signature: claude-fable-5-medium on behalf of matt wilkie
---------
Co-authored-by: Abner S. Alves Junior <abnersajr@gmail.com>
* feat(no-push): guard dolt push/pull and strip push from rendered templates
- bd dolt push/pull skip silently (exit 0) when no-push: true in config
- RenderOpts gains NoPush bool; !HasRemote || NoPush strips bd dolt push
- NoPush propagated through AgentsFileParams, fs_adapters, init, setup/agents, init_proxied_server
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(no-push): anchor stripDoltPushReferences to prevent 4-space indent false match
Without the newline anchor, ReplaceAll matched any line containing " bd
dolt push\n" as a substring — including 4-space indented code blocks that
happen to share the prefix. Pad body with newlines so the match is anchored
to the start of the line.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(no-push): remove pull guard from bd dolt pull (be-ve2x6)
no-push means "do not publish local state to the remote"; it must not
prevent receiving remote updates. The guard at dolt.go:330 made
bd dolt pull return success without contacting the remote when
no-push: true, leaving contributor clones stale.
Remove the pull guard. Add TestNoPushDoesNotSkipDoltPull to prevent
reintroduction: injects a minimal fake store and asserts Pull() is
called even under no-push: true.
Push guard (dolt.go:257) and template stripping (render.go:217)
are unchanged — both are correct behavior per maphew's review of #4212.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* test(dolt): add TestNoPushSkipsDoltPush for push guard coverage (be-i9e2)
Direct unit test for the no-push guard at cmd/bd/dolt.go:247-249.
Asserts Push() is not called and output contains "skipping push"
when BD_NO_PUSH=true. Mirrors TestNoPushDoesNotSkipDoltPull pattern.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore: release gate PASS for be-i9e2 (no-push dolt push test)
* test(dolt): fix minimalPullStore for current main (ListRemotes drift)
Rebasing #4323 onto current main surfaced a latent defect hidden by cached
green checks: main now routes bd dolt pull failure handling through
isConfirmedNoRemote, which calls st.ListRemotes during error classification
(cmd/bd/dolt.go). minimalPullStore embeds a nil storage.DoltStorage and
overrode only Pull, so TestNoPushDoesNotSkipDoltPull nil-panicked once merged
into current main.
Add a ListRemotes that reports no remotes, keeping the simulated pull failure
on the benign no-remote path (clean exit) so the test still proves the no-push
guard does not short-circuit bd dolt pull. Same fix quad341 applied on #4212.
Verified against current main: TestNoPushSkipsDoltPush, TestNoPushDoesNotSkipDoltPull,
TestIsConfirmedNoRemote, TestDoltPushPullCommitNeedStore all pass.
Agent-Signature: claude-opus-4-8-high on behalf of maphew
---------
Co-authored-by: Jim Wordelman <jim@wordelman.name>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: matt wilkie <maphew@gmail.com>
* fix(setup): match beads plugin name exactly, not by substring (#4244)
bd setup claude decided whether the beads hook plugin was enabled with a
substring test, strings.Contains(lower(key), "beads"). Any enabledPlugins
key merely containing "beads" (e.g. design-to-beads@xexr-marketplace) was
mistaken for the beads hook plugin, so the SessionStart hook write was
skipped and the hook landed nowhere.
enabledPlugins keys are "<pluginName>@<marketplace>"; match the plugin-name
segment exactly instead. A real beads@<marketplace> still matches, so the
GH#3192 double-fire prevention is preserved.
- Split the key on the first "@" and compare the name == "beads"
- Add regression subtests: design-to-beads alone is not detected; a real
beads plugin is still found alongside a *beads* decoy
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(setup): match codex beads plugin name exactly, not by substring (#4244)
bd setup codex decided whether the beads hook plugin was enabled with a
substring test, strings.Contains(lower(table), "beads") on the TOML plugin
table header. Any [plugins.<name>] whose name merely contains "beads" (e.g.
design-to-beads) was mistaken for the beads hook plugin, so the hooks
fallback write was skipped — the codex sibling of the claude.go bug already
fixed in this PR.
Codex plugin tables are [plugins.<name>] or [plugins."<name>@<marketplace>"]
(TOML quotes a key containing "@"). Strip the "plugins." prefix and any
quotes, then match the <name> segment of <name>@<marketplace> exactly,
mirroring the claude.go fix. A real beads@<marketplace> still matches, so the
GH#3192 double-fire prevention is preserved.
- Exact-match the plugin-name segment instead of a substring test
- Add TestCodexConfigEnablesBeadsPlugin: design-to-beads (quoted and bare) is
not detected; a real quoted/bare beads plugin still is, including alongside
a *beads* decoy; a disabled beads plugin is not detected
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
PR #4188 moved hook files from plugins/beads/hooks/ to
plugins/beads/.codex-plugin/hooks/ to stop Claude from discovering
Codex-only hooks. However, the hooks path in .codex-plugin/plugin.json
remained "./hooks/hooks.json" which Codex resolves relative to the
plugin root (plugins/beads/), not relative to .codex-plugin/. This
caused a runtime error:
failed to read .../beads/1.0.5/hooks/hooks.json: No such file or directory
Fix: update the hooks path to "./.codex-plugin/hooks/hooks.json" so
it correctly resolves to plugins/beads/.codex-plugin/hooks/hooks.json.
Update TestPluginLayoutUsesSharedBeadsRoot to assert the corrected path.
Fixes#4210. Follow-up to #4188.
Refuse setup atomic writes through symlinks unless a caller explicitly opts into following the link, and report partial Claude/Mux setup when agent instructions are skipped.
Document repair steps for repositories already affected by corrupted mode-120000 CLAUDE.md entries.
Refs #3722.
_codex-gpt-5.5-medium on behalf of matt wilkie_
Move Codex native hook metadata under the Codex-only plugin directory so Claude keeps using only its inline `bd prime` hooks.
Leave release version bumps to the maintainer release flow while documenting hook metadata isolation under Unreleased.
Refs #3924.
_codex-gpt-5.5-medium on behalf of matt wilkie_
Warn on stderr with the symlink target and a concrete recovery path when setup skips managed-section injection through an agent-file symlink. This keeps the corruption guard explicit without pretending the integration text was written.
Also cover the Lstat inspect-error branch called out in PR review coverage.
_codex-gpt-5.5-medium on behalf of matt wilkie_
Avoid following symlinked agent instruction files when installing managed setup sections. This preserves symlink mode and target content while still allowing normal files to receive integration text.\n\nRefs gastownhall/beads#3722\n\n_codex-gpt-5.5-medium on behalf of matt wilkie_
Run Codex project setup during `bd init` using the existing setup installer, and stage generated Codex project files in the bootstrap commit.
Also refresh the generated setup/init docs for the new default behavior.
Co-authored-by: Eugene Brevdo <ebrevdo@gmail.com>
_codex-gpt-5.5-medium on behalf of CI Bot_
* fix(init): wire git origin as Dolt remote
Default bd init now treats a git origin as the Dolt remote, persists sync.remote, and still skips synthesis in --stealth. JSONL auto-export/import paths now warn or skip based on sync.remote so exports do not masquerade as cross-machine sync.
Docs and generated agent/CLI references now state that Dolt is canonical, refs/dolt/data is the sync channel, and .beads/issues.jsonl is export/interchange/backup only.
_codex-gpt-5-xhigh on behalf of maphew_
* test: keep embedded command stderr out of parsed stdout
Embedded command tests parse IDs and JSON from command output. The new auto-export warnings correctly go to stderr, but several tests used CombinedOutput and treated warnings as stdout, which broke CI shards that parse issue IDs or JSON lists. Capture stdout separately on success while preserving combined output for error diagnostics.\n\n_codex-gpt-5-medium on behalf of CI Bot_
---------
Co-authored-by: CI Bot <ci@beads.test>
Fixes Gemini CLI hook integration by emitting the required SessionStart JSON envelope. Extends the same standard to Claude Code hooks (documented spec, not just tolerated raw text). Adds legacy detection in bd setup gemini --check.
- Add `--hook-json` flag to `bd prime` wrapping output in the cross-CLI `hookSpecificOutput.additionalContext` JSON envelope (Claude Code, Gemini CLI, and Codex all share this contract)
- Update `bd setup gemini` to register `bd prime --hook-json` on SessionStart; remove PreCompress registration (advisory-only, no additionalContext support per Gemini docs v0.40.1)
- Update `bd setup claude` to register `bd prime --hook-json` on SessionStart and PreCompact (JSON form is the documented spec; raw text was merely tolerated)
- Migration sweeps in both setup commands so re-running upgrades bare-command installs cleanly
- `bd setup gemini --check` distinguishes current (`--hook-json`) from legacy (bare `bd prime`) installs and emits upgrade advisory for legacy
- Fix `removeHookCommand` bug: previously dropped entire hook entry on first command match, silently deleting sibling commands; now filters only the matching command and drops the entry only when empty
- Refresh docs and recipes to reflect SessionStart-only Gemini hook behavior
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Test hardcoded forward-slash path literals against output from
filepath.Join, so it failed on Windows even though the production
code (geminiProjectSettingsPath, geminiGlobalSettingsPath) was
correct.
Matches the existing pattern from TestMuxProjectAgentsPath and
TestMuxGlobalAgentsPath in the same package, which compare
filepath.Join(...) on both sides.
Fixes#3554
Mux post-edit hook now calls bd dolt push when only ~/bin/bd is available,
matching the primary branch.
bd setup claude --check scans Claude settings for removed bd sync hook
commands and prints a stderr warning with remediation.
Tests: TestClaudeSettingsUsesRemovedSyncCommand.
When removeHookCommand found a matching command it set keepHook = false and broke out of the loop, discarding the entire hook entry rather than just the matching command. Any sibling commands in the same entry were silently deleted.
Fix: build a remaining slice by filtering only the matching command. The hook entry is dropped only when remaining becomes empty, preserving all sibling commands.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
the claude plugin manifest declared agents at ./skills/beads/agents/, which
also contains openai.yaml (codex interface metadata). claude code's plugin
loader scans that dir and rejects non-md files, failing manifest validation
with 'agents: Invalid input'.
move task-agent.md back to plugins/beads/agents/ (the claude default, what
v1.0.0 used) and drop the explicit agents key from .claude-plugin/plugin.json.
codex's openai.yaml stays at skills/beads/agents/openai.yaml where bd setup
codex writes it and where the embed in internal/templates/ lives.
shared skill tree and dual claude/codex manifests are preserved per #3664.
Fixes#3741
RenderSection() and ReplaceSection() now accept RenderOpts with a
HasRemote flag. When false, "bd dolt push" is stripped from the
session-completion code block (and the Auto-Sync informational bullet
in the full profile). This prevents agents from dutifully running a
no-op every session on solo/local-only projects.
bd init detects the remote via shouldWireInitRemote(); bd setup detects
it by reading sync.remote / sync.git-remote from config.yaml. The
existing no-arg RenderSection() and ReplaceSection() default to
HasRemote=true for full backward compatibility.
Closes beads-ozg.
When both the beads Claude Code plugin and `bd setup claude` are active,
bd prime fires twice per session — wasting ~1-2k tokens each time. The
plugin already declares identical SessionStart/PreCompact hooks in its
plugin.json, so project-level hooks are redundant.
Now `bd setup claude` detects the plugin via enabledPlugins in settings
files and skips writing hooks when the plugin is already providing them.
The CLAUDE.md integration section is still installed since the plugin
does not provide that. `bd setup claude --check` reports "plugin-managed"
as a valid success state instead of "No hooks installed".
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Without YAML frontmatter, Cursor defaults .mdc files to Manual mode,
requiring users to @-reference the rule explicitly. Add alwaysApply: true
so beads context loads automatically every session, consistent with the
Claude and Gemini integrations.
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Changes:
- bd setup claude now defaults to project-local (.claude/settings.json)
instead of global (~/.claude/settings.json)
- bd setup claude --global explicitly installs globally
- bd init automatically runs Claude hook setup (project-local)
- Legacy .claude/settings.local.json hooks are auto-migrated on install
and cleaned on remove
- bd setup claude --check detects legacy installs with migration hint
- bd init stages .claude/settings.json and CLAUDE.md for git commit
Closes#2935
Amp-Thread-ID: https://ampcode.com/threads/T-019d4fc1-6587-75cb-bdcb-1912a98cb1c1
Co-authored-by: Amp <amp@ampcode.com>
Add --agents-file flag to bd init allowing users to specify a custom
filename for agent instructions (default remains AGENTS.md). This
addresses the use case where projects prefer different naming
conventions (e.g. BEADS.md) without requiring a post-init rename.
Changes:
- Add config.AgentsFile() accessor and config.ValidateAgentsFile()
with security validation (path traversal, symlinks, extension check)
- Add --agents-file flag to bd init with config persistence
- Thread configured filename through init_agent.go
- Update setup/agents.go to use config.AgentsFile()
- Update doctor checks to search configured filename
- Update onboard messaging to reference configured filename
- Add DefaultAgentsFile constant for consistent fallback
The filename is persisted to .beads/config.yaml under agents.file
and read by all subsystems via config.AgentsFile().
Fixes#2737
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Introduce ErrServerNotRunning sentinel so callers can distinguish "already
stopped" from real failures. Stop now cleans up leftover PID/port files even
when the server is not running, preventing bd dolt status from reporting stale
state. Consolidate IsAutoStartDisabled into a single exported function covering
both env var and config sources.
PR: #2740
Co-Authored-By: Harry Miller <harry-miller-trimble@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Create agents.ReplaceSection(content, profile) as the single canonical
function for replacing beads integration sections. Both init_agent.go
(upgradeBeadsSection) and setup/agents.go (updateBeadsSectionWithProfile)
now delegate to it.
Key changes:
- Hash-based freshness check skips rewrite when content is current
- Returns error on malformed markers (missing/reversed) instead of
silent append
- Marker format now includes v:1 version field for forward compat
- atomicWriteFile accepts optional permissions param (default 0644)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Task 8: bd init now upgrades legacy beads sections to versioned format
instead of silently skipping them. New files created via EmbeddedDefault()
also get versioned markers.
Task 9: Replace stale bd sync references with bd dolt push in recipes
template. Add bd prime SSOT messaging.
Task 10: installAgents resolves symlinks via ResolveForWrite before
reading content. Profile precedence: if file already has full profile
and minimal is requested, full is preserved to avoid information loss.
Task 11: Added tests for staleness detection, profile extraction,
profile precedence, symlink safety, and legacy-to-new migration.
checkAgents now reports stale/current/missing status.
Task 12: Updated SETUP.md with prime SSOT, profiles, and profile
precedence documentation. Updated CLI_REFERENCE.md with --check
behavior and Gemini integration description.
Amp-Thread-ID: https://ampcode.com/threads/T-019ced7a-0c86-708d-930c-ee35d00eda8d
Co-authored-by: Amp <amp@ampcode.com>
When running 'bd setup claude --project' or 'bd setup gemini --project',
after installing hooks in settings.json, also install a minimal-profile
beads section in AGENTS.md. This provides a quick reference pointer to
'bd prime' for the full workflow, while hooks handle the heavy lifting.
On removal, the beads section is cleaned up from AGENTS.md as well.
The minimal profile contains: quick reference commands, pointer to
bd prime, and the landing-the-plane session close protocol — without
the full issue types, priorities, and sync details that hook-enabled
agents get dynamically from bd prime.
Amp-Thread-ID: https://ampcode.com/threads/T-019ced5e-0acd-7158-93ad-0695c6d02580
Co-authored-by: Amp <amp@ampcode.com>
Set profile: agents.ProfileFull explicitly on codex, factory, mux
(all three layers), and opencode integrations. This makes the profile
intent clear and prepares for adding minimal-profile integrations.
Amp-Thread-ID: https://ampcode.com/threads/T-019ced5e-0acd-7158-93ad-0695c6d02580
Co-authored-by: Amp <amp@ampcode.com>
Implement the foundational pieces for making bd prime the single source
of truth for agent instructions:
Task 1 - Shared render API (internal/templates/agents/render.go):
- Profile type with Full and Minimal constants
- RenderSection(profile) generates sections with marker metadata
- ParseMarker() extracts profile/hash from begin markers
- CurrentHash(profile) for staleness detection
- 8-char SHA-256 hash for deterministic freshness
Task 2 - Template splitting:
- New beads-section-minimal.md for hook-enabled agents (Claude, Gemini)
- Minimal profile: pointer to bd prime + quick reference + landing protocol
- Existing beads-section.md preserved as full profile body
Task 3 - Parser refactor (cmd/bd/setup/agents.go):
- Prefix-based marker matching via containsBeadsMarker/findBeginMarker
- Legacy markers (no metadata) detected and upgradable
- New markers: <!-- BEGIN BEADS INTEGRATION profile:full hash:a1b2c3d4 -->
- agentsIntegration gains profile field (defaults to full)
- updateBeadsSectionWithProfile for profile-aware updates
- createNewAgentsFileWithProfile for new file creation
Backward compatible: EmbeddedBeadsSection/EmbeddedDefault still work.
Legacy markers are auto-upgraded on next bd setup run.
Amp-Thread-ID: https://ampcode.com/threads/T-019ced5e-0acd-7158-93ad-0695c6d02580
Co-authored-by: Amp <amp@ampcode.com>