beads/cmd/bd/setup/cursor.go
matt wilkie 0c47b3c5ac
fix(init): use git origin as default Dolt remote (#3909)
* 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>
2026-05-13 07:02:39 -07:00

100 lines
2.9 KiB
Go

package setup
import (
"fmt"
"os"
"path/filepath"
)
const cursorRulesTemplate = `---
alwaysApply: true
---
# Beads Issue Tracking
# Auto-generated by 'bd setup cursor' - do not remove these markers
# BEGIN BEADS INTEGRATION
This project uses [Beads (bd)](https://github.com/steveyegge/beads) for issue tracking.
## Core Rules
- Track ALL work in bd (never use markdown TODOs or comment-based task lists)
- Use ` + "`bd ready`" + ` to find available work
- Use ` + "`bd create`" + ` to track new issues/tasks/bugs
- Use ` + "`bd dolt push`" + ` at end of session to sync with the Dolt remote
- Git hooks refresh exports and legacy fallbacks; Dolt remotes handle sync
## Quick Reference
` + "```bash" + `
bd prime # Load complete workflow context
bd ready # Show issues ready to work (no blockers)
bd list --status=open # List all open issues
bd create --title="..." --type=task # Create new issue
bd update <id> --claim # Claim work atomically
bd close <id> # Mark complete
bd dep add <issue> <depends-on> # Add dependency (issue depends on depends-on)
bd dolt push # Sync with Dolt remote
` + "```" + `
## Workflow
1. Check for ready work: ` + "`bd ready`" + `
2. Claim an issue atomically: ` + "`bd update <id> --claim`" + `
3. Do the work
4. Mark complete: ` + "`bd close <id>`" + `
5. Sync: ` + "`bd dolt push`" + `
## Context Loading
Run ` + "`bd prime`" + ` to get complete workflow documentation in AI-optimized format (~1-2k tokens).
For detailed docs: see AGENTS.md, QUICKSTART.md, or run ` + "`bd --help`" + `
# END BEADS INTEGRATION
`
// InstallCursor installs Cursor IDE integration
func InstallCursor() {
rulesPath := ".cursor/rules/beads.mdc"
fmt.Println("Installing Cursor integration...")
// Ensure parent directory exists
if err := EnsureDir(filepath.Dir(rulesPath), 0755); err != nil {
FatalError("%v", err)
}
// Write beads rules file (overwrite if exists)
if err := atomicWriteFile(rulesPath, []byte(cursorRulesTemplate)); err != nil {
FatalError("write rules: %v", err)
}
fmt.Printf("\n✓ Cursor integration installed\n")
fmt.Printf(" Rules: %s\n", rulesPath)
fmt.Println("\nRestart Cursor for changes to take effect.")
}
// CheckCursor checks if Cursor integration is installed
func CheckCursor() {
rulesPath := ".cursor/rules/beads.mdc"
if !FileExists(rulesPath) {
FatalErrorWithHint("Cursor integration not installed", "Run: bd setup cursor")
}
fmt.Println("✓ Cursor integration installed:", rulesPath)
}
// RemoveCursor removes Cursor integration
func RemoveCursor() {
rulesPath := ".cursor/rules/beads.mdc"
fmt.Println("Removing Cursor integration...")
if err := os.Remove(rulesPath); err != nil {
if os.IsNotExist(err) {
fmt.Println("No rules file found")
return
}
FatalError("failed to remove file: %v", err)
}
fmt.Println("✓ Removed Cursor integration")
}