Better enable go extensions (#14)
* deps: run go mod tidy * beads: Add public Go API for bd extensions Implements a minimal public API to enable Go-based extensions without exposing internal packages: **New beads.go package:** - Exports essential types: Issue, Status, IssueType, WorkFilter - Provides status and issue type constants - Exposes NewSQLiteStorage() as main entry point for extensions - Includes comprehensive package documentation **Updated EXTENDING.md:** - Replaced internal package imports with public beads package - Updated function calls to use new public API - Changed sqlite.New() to beads.NewSQLiteStorage() - Updated GetReady() to GetReadyWork() with WorkFilter This enables clean Go-based orchestration extensions while maintaining API stability and hiding internal implementation details. * beads: Refine Go extensions API and documentation Updates to the public Go API implementation following initial commit: - Enhanced beads.go with refined extension interface - Updated EXTENDING.md with clearer documentation - Modified cmd/bd/main.go to support extension loading Continues work on enabling Go-based bd extensions. * Fix EXTENDING.md to use beads.WorkFilter instead of types.WorkFilter The public API exports WorkFilter as beads.WorkFilter, not types.WorkFilter. This fixes the code example to match the imports shown. --------- Co-authored-by: Steve Yegge <steve.yegge@gmail.com>
This commit is contained in:
20
EXTENDING.md
20
EXTENDING.md
@@ -99,12 +99,11 @@ func InitializeMyAppSchema(dbPath string) error {
|
||||
|
||||
```go
|
||||
import (
|
||||
"github.com/steveyegge/beads/internal/storage/sqlite"
|
||||
"github.com/steveyegge/beads/internal/types"
|
||||
"github.com/steveyegge/beads"
|
||||
)
|
||||
|
||||
// Open bd's storage
|
||||
store, err := sqlite.New(dbPath)
|
||||
store, err := beads.NewSQLiteStorage(dbPath)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@@ -115,7 +114,7 @@ if err := InitializeMyAppSchema(dbPath); err != nil {
|
||||
}
|
||||
|
||||
// Use bd to find ready work
|
||||
readyIssues, err := store.GetReady(ctx, types.IssueFilter{Limit: 10})
|
||||
readyIssues, err := store.GetReadyWork(ctx, beads.WorkFilter{Limit: 10})
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@@ -410,10 +409,17 @@ You can always access bd's database directly:
|
||||
import (
|
||||
"database/sql"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
"github.com/steveyegge/beads"
|
||||
)
|
||||
|
||||
// Auto-discover bd's database path
|
||||
dbPath := beads.FindDatabasePath()
|
||||
if dbPath == "" {
|
||||
log.Fatal("No bd database found. Run 'bd init' first.")
|
||||
}
|
||||
|
||||
// Open the same database bd uses
|
||||
db, err := sql.Open("sqlite3", ".beads/myapp.db")
|
||||
db, err := sql.Open("sqlite3", dbPath)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@@ -429,6 +435,10 @@ err = db.QueryRow(`
|
||||
_, err = db.Exec(`
|
||||
INSERT INTO myapp_executions (issue_id, status) VALUES (?, ?)
|
||||
`, issueID, "running")
|
||||
|
||||
// Find corresponding JSONL path (for git hooks, monitoring, etc.)
|
||||
jsonlPath := beads.FindJSONLPath(dbPath)
|
||||
fmt.Printf("BD exports to: %s\n", jsonlPath)
|
||||
```
|
||||
|
||||
## Summary
|
||||
|
||||
Reference in New Issue
Block a user