Files
beads/cmd/bd/onboard.go
Charles P. Cross cb59bb3ec8 fix(ci): resolve lint and test failures
Fix two CI failures that were blocking main:

1. Lint error in cmd/bd/onboard.go:126
   - Unchecked fmt.Fprintf return value
   - Fixed by explicitly ignoring with _, _

2. Test failures in internal/storage/sqlite
   - TestCreateIssues/duplicate_ID_error was passing but
     TestCreateIssuesRollback/rollback_on_conflict_with_existing_ID failed
   - Root cause: CreateIssues used INSERT OR IGNORE which silently
     ignored duplicate IDs instead of returning an error
   - Fixed by adding duplicate ID detection in EnsureIDs():
     a) Check for duplicates within the batch
     b) Check for conflicts with existing database IDs

Both fixes are minimal and targeted to unblock CI.
2025-12-18 17:45:49 -05:00

134 lines
3.8 KiB
Go

package main
import (
"fmt"
"io"
"github.com/fatih/color"
"github.com/spf13/cobra"
)
const copilotInstructionsContent = `# GitHub Copilot Instructions
## Issue Tracking
This project uses **bd (beads)** for issue tracking.
Run ` + "`bd prime`" + ` for workflow context, or install hooks (` + "`bd hooks install`" + `) for auto-injection.
**Quick reference:**
- ` + "`bd ready`" + ` - Find unblocked work
- ` + "`bd create \"Title\" --type task --priority 2`" + ` - Create issue
- ` + "`bd close <id>`" + ` - Complete work
- ` + "`bd sync`" + ` - Sync with git (run at session end)
For full workflow details: ` + "`bd prime`" + ``
const agentsContent = `## Issue Tracking
This project uses **bd (beads)** for issue tracking.
Run ` + "`bd prime`" + ` for workflow context, or install hooks (` + "`bd hooks install`" + `) for auto-injection.
**Quick reference:**
- ` + "`bd ready`" + ` - Find unblocked work
- ` + "`bd create \"Title\" --type task --priority 2`" + ` - Create issue
- ` + "`bd close <id>`" + ` - Complete work
- ` + "`bd sync`" + ` - Sync with git (run at session end)
For full workflow details: ` + "`bd prime`" + ``
func renderOnboardInstructions(w io.Writer) error {
bold := color.New(color.Bold).SprintFunc()
cyan := color.New(color.FgCyan).SprintFunc()
green := color.New(color.FgGreen).SprintFunc()
writef := func(format string, args ...interface{}) error {
_, err := fmt.Fprintf(w, format, args...)
return err
}
writeln := func(text string) error {
_, err := fmt.Fprintln(w, text)
return err
}
writeBlank := func() error {
_, err := fmt.Fprintln(w)
return err
}
if err := writef("\n%s\n\n", bold("bd Onboarding")); err != nil {
return err
}
if err := writeln("Add this minimal snippet to AGENTS.md (or create it):"); err != nil {
return err
}
if err := writeBlank(); err != nil {
return err
}
if err := writef("%s\n", cyan("--- BEGIN AGENTS.MD CONTENT ---")); err != nil {
return err
}
if err := writeln(agentsContent); err != nil {
return err
}
if err := writef("%s\n\n", cyan("--- END AGENTS.MD CONTENT ---")); err != nil {
return err
}
if err := writef("%s\n", bold("For GitHub Copilot users:")); err != nil {
return err
}
if err := writeln("Add the same content to .github/copilot-instructions.md"); err != nil {
return err
}
if err := writeBlank(); err != nil {
return err
}
if err := writef("%s\n", bold("How it works:")); err != nil {
return err
}
if err := writef(" • %s provides dynamic workflow context (~80 lines)\n", cyan("bd prime")); err != nil {
return err
}
if err := writef(" • %s auto-injects bd prime at session start\n", cyan("bd hooks install")); err != nil {
return err
}
if err := writeln(" • AGENTS.md only needs this minimal pointer, not full instructions"); err != nil {
return err
}
if err := writeBlank(); err != nil {
return err
}
if err := writef("%s\n\n", green("This keeps AGENTS.md lean while bd prime provides up-to-date workflow details.")); err != nil {
return err
}
return nil
}
var onboardCmd = &cobra.Command{
Use: "onboard",
Short: "Display minimal snippet for AGENTS.md",
Long: `Display a minimal snippet to add to AGENTS.md for bd integration.
This outputs a small (~10 line) snippet that points to 'bd prime' for full
workflow context. This approach:
• Keeps AGENTS.md lean (doesn't bloat with instructions)
• bd prime provides dynamic, always-current workflow details
• Hooks auto-inject bd prime at session start
The old approach of embedding full instructions in AGENTS.md is deprecated
because it wasted tokens and got stale when bd upgraded.`,
Run: func(cmd *cobra.Command, args []string) {
if err := renderOnboardInstructions(cmd.OutOrStdout()); err != nil {
_, _ = fmt.Fprintf(cmd.ErrOrStderr(), "Error: %v\n", err)
}
},
}
func init() {
rootCmd.AddCommand(onboardCmd)
}