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 bd is built from a Windows checkout (default core.autocrlf=true),
//go:embed reads CRLF bytes from the working tree for
internal/templates/agents/defaults/beads-section.md. templateBody()'s
LF-only TrimPrefix/TrimSuffix then failed to strip the legacy markers
inside the embedded body, so RenderSection wrapped them with fresh
markers — producing two nested BEGIN/END pairs in any AGENTS.md
written by bd setup mux/claude/etc.
bd setup mux --remove only stripped the outer pair (find-first
semantics), leaving a stray <!-- END BEADS INTEGRATION --> in the
user's file. TestRemoveMuxProjectRemovesBothLayers caught this on
Windows.
Two complementary fixes:
1. Pin internal/templates/agents/defaults/*.md to eol=lf in
.gitattributes. Embedded templates are shipped data, not
user-edited text, and should never carry CRLF.
2. Normalize CRLF→LF in templateBody() before stripping markers.
Defensive against future templates added without a gitattributes
pin.
Adds TestRenderSectionFullSingleMarkers as a direct regression guard
(asserts exactly one BEGIN and one END in RenderSection output).
Fixes#3552
bd init creates a complete AGENTS.md but tells users to "Run bd onboard
to get started", which suggests different/conflicting content. Replace
with "Run bd prime" which is the correct entry point for workflow context.
Also migrates the Claude settings prompt from bd onboard to bd prime,
with backward-compatible detection of existing onboard references.
Closes#2902
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
internal/templates/roles/ contained deacon.md.tmpl, witness.md.tmpl,
refinery.md.tmpl — Gas Town agent role templates that belong in the GT
repo, not beads. No Go code in beads references or embeds these files.
GT maintains its own copies in gastown/*/internal/templates/roles/.
Surfaces existing but undiscoverable commands in bd prime output (CLI mode)
and beads-section.md template. Adds doctor --check=conventions as a composite
of lint, stale, and orphan checks (advisory only).
Fix-merge changes:
- Remove Close Reason Format section (not an established convention yet)
- Fix --by to --with for bd supersede (matches actual flag name)
Co-Authored-By: seanmartinsmith <114885497+seanmartinsmith@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>
Update agents.md.tmpl to match canonical beads-section.md content:
- 'Version-controlled: Built on Dolt with cell-level merge' →
'Git-friendly: Dolt-powered version control with native sync'
- JSONL-based sync description → Dolt push/pull sync model
- Legacy markers → versioned markers (profile:full hash:d4f96305)
This ensures EmbeddedDefault() output has a beads section body
identical to beads-section.md, so upgradeBeadsSection() in bd init
is a no-op for freshly created files.
Ref: #2139
Amp-Thread-ID: https://ampcode.com/threads/T-019ced8e-4a10-7404-b1f6-83cc78d1996c
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>
Export: sanitize zero-value time.Time fields (year 0001) to Unix epoch
before JSON marshaling. NULL datetime columns from Dolt scan as
time.Time{} which causes MarshalJSON to fail.
Templates: replace stale 'bd sync' with 'bd dolt push' in agent
instruction templates generated by bd setup factory.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Update documentation to reflect that only dolt-native sync mode is supported:
- docs/CONFIG.md: Remove git-portable and belt-and-suspenders references
- docs/DOLT-BACKEND.md: Simplify sync mode section
- FEDERATION-SETUP.md: Remove deprecated sync mode table
- agents.md.tmpl: Update "Git-friendly: JSONL" to "Version-controlled: Dolt"
The sync mode code was already cleaned up (only SyncModeDoltNative is valid
in internal/config/sync.go), but documentation still referenced removed modes.
w-bd-004
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
bd init appended the "Landing the Plane" section outside the
<!-- BEGIN/END BEADS INTEGRATION --> markers, making it unmanaged
debris that removeBeadsSection() could never clean up.
Move landing content into beads-section.md and agents.md.tmpl within
the markers, simplify updateAgentFile() to stop separately appending
it, invert TestBeadsSectionDoesNotContainLanding, and add a round-trip
test proving add→remove leaves no beads content behind.
Closes#2265
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Polecats are ephemeral — they die after submitting their MR via `gt done`.
The refinery cannot send work back to a dead polecat. All failure handling
must go through the witness (MERGE_FAILED protocol), which manages polecat
lifecycles and can re-sling work.
Changes:
- Add explicit warning that polecats are ephemeral (near role definition)
- ZFC table: route failures to witness, not polecat
- Conflict examples: send MERGE_FAILED to witness
- handle-failures: branch failures → reopen issue + notify witness
- Remove "fix it yourself" option for pre-existing failures (refinery is
mechanical, not a developer)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Polecats hang indefinitely when macOS shell aliases add -i (interactive)
flags to cp/mv/rm. This adds a Claude Code PreToolUse hook that blocks
these commands unless -f flag or alias-bypass (command prefix, absolute
path) is present.
Changes:
- New hook: .claude/hooks/block-interactive-cmds.sh
- Register hook in .claude/settings.json
- Add non-interactive guidance to default agents.md template
Executed-By: beads/polecats/jasper
Rig: beads
Role: polecats
Move AGENTS.md content from Go string concatenation into embedded template
files using embed.FS. Add --agents-template flag to bd init for custom
templates. Inspired by PR #1879.
- New internal/templates/agents/ package with EmbeddedDefault() and
EmbeddedBeadsSection() loaders
- Remove landingThePlaneSection and agentsBeadsSection string constants
- bd init --agents-template <path> overrides the embedded default
- Net -86 lines of code
Co-authored-by: iliyafa <20426296+iliyafa@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Executed-By: beads/crew/emma
Rig: beads
Role: crew
- Add witness, deacon, refinery role templates
- Ignore bd_test binary (bd-test was already ignored)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>