feat: add daemon RPC endpoints for config and mol stale (bd-ag35)

Add two new RPC endpoints to allow CLI commands to work in daemon mode:

1. GetConfig (OpGetConfig) - Retrieves config values from the daemon database.
   Used by bd create to validate issue prefix in daemon mode.

2. MolStale (OpMolStale) - Finds stale molecules (complete-but-unclosed
   epics). Used by bd mol stale command in daemon mode.

Changes:
- internal/rpc/protocol.go: Add operation constants and request/response types
- internal/rpc/client.go: Add client methods GetConfig() and MolStale()
- internal/rpc/server_issues_epics.go: Add handler implementations
- internal/rpc/server_routing_validation_diagnostics.go: Register handlers
- cmd/bd/create.go: Use GetConfig RPC instead of skipping validation
- cmd/bd/mol_stale.go: Use MolStale RPC instead of requiring --no-daemon
- internal/rpc/coverage_test.go: Add tests for new endpoints

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-30 06:59:51 -08:00
parent 7f5378ba26
commit 06c8855873
7 changed files with 423 additions and 13 deletions

View File

@@ -222,8 +222,12 @@ var createCmd = &cobra.Command{
// Get database prefix from config
var dbPrefix string
if daemonClient != nil {
// TODO(bd-ag35): Add RPC method to get config in daemon mode
// For now, skip validation in daemon mode (needs RPC enhancement)
// Daemon mode - use RPC to get config
configResp, err := daemonClient.GetConfig(&rpc.GetConfigArgs{Key: "issue_prefix"})
if err == nil {
dbPrefix = configResp.Value
}
// If error, continue without validation (non-fatal)
} else {
// Direct mode - check config
dbPrefix, _ = store.GetConfig(ctx, "issue_prefix")

View File

@@ -6,6 +6,7 @@ import (
"os"
"github.com/spf13/cobra"
"github.com/steveyegge/beads/internal/rpc"
"github.com/steveyegge/beads/internal/storage"
"github.com/steveyegge/beads/internal/types"
"github.com/steveyegge/beads/internal/ui"
@@ -63,19 +64,40 @@ func runMolStale(cmd *cobra.Command, args []string) {
var err error
if daemonClient != nil {
// For now, stale check requires direct store access
// TODO(bd-ag35): Add RPC endpoint for stale check
fmt.Fprintf(os.Stderr, "Error: mol stale requires direct database access\n")
fmt.Fprintf(os.Stderr, "Hint: use --no-daemon flag: bd --no-daemon mol stale\n")
os.Exit(1)
}
// Daemon mode - use RPC to get stale molecules
rpcResp, rpcErr := daemonClient.MolStale(&rpc.MolStaleArgs{
BlockingOnly: blockingOnly,
UnassignedOnly: unassignedOnly,
ShowAll: showAll,
})
if rpcErr != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", rpcErr)
os.Exit(1)
}
// Convert RPC response to local StaleResult
result = &StaleResult{
TotalCount: rpcResp.TotalCount,
BlockingCount: rpcResp.BlockingCount,
}
for _, mol := range rpcResp.StaleMolecules {
result.StaleMolecules = append(result.StaleMolecules, &StaleMolecule{
ID: mol.ID,
Title: mol.Title,
TotalChildren: mol.TotalChildren,
ClosedChildren: mol.ClosedChildren,
Assignee: mol.Assignee,
BlockingIssues: mol.BlockingIssues,
BlockingCount: mol.BlockingCount,
})
}
} else {
if store == nil {
fmt.Fprintf(os.Stderr, "Error: no database connection\n")
os.Exit(1)
}
if store == nil {
fmt.Fprintf(os.Stderr, "Error: no database connection\n")
os.Exit(1)
result, err = findStaleMolecules(ctx, store, blockingOnly, unassignedOnly, showAll)
}
result, err = findStaleMolecules(ctx, store, blockingOnly, unassignedOnly, showAll)
if err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)