Implement bd stale command (bd-c01f, closes #184)
- Add bd stale command to find abandoned/forgotten issues - Support --days (default 30), --status, --limit, --json flags - Implement GetStaleIssues in SQLite and Memory storage - Add full RPC/daemon support - Comprehensive test suite (6 tests, all passing) - Update AGENTS.md documentation Resolves GitHub issue #184 Amp-Thread-ID: https://ampcode.com/threads/T-f021ddb8-54e3-41bf-ba7a-071749663c1d Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -265,6 +265,11 @@ func (c *Client) Ready(args *ReadyArgs) (*Response, error) {
|
||||
return c.Execute(OpReady, args)
|
||||
}
|
||||
|
||||
// Stale gets stale issues via the daemon
|
||||
func (c *Client) Stale(args *StaleArgs) (*Response, error) {
|
||||
return c.Execute(OpStale, args)
|
||||
}
|
||||
|
||||
// Stats gets statistics via the daemon
|
||||
func (c *Client) Stats() (*Response, error) {
|
||||
return c.Execute(OpStats, nil)
|
||||
|
||||
@@ -16,6 +16,7 @@ const (
|
||||
OpList = "list"
|
||||
OpShow = "show"
|
||||
OpReady = "ready"
|
||||
OpStale = "stale"
|
||||
OpStats = "stats"
|
||||
OpDepAdd = "dep_add"
|
||||
OpDepRemove = "dep_remove"
|
||||
@@ -118,6 +119,13 @@ type ReadyArgs struct {
|
||||
SortPolicy string `json:"sort_policy,omitempty"`
|
||||
}
|
||||
|
||||
// StaleArgs represents arguments for the stale command
|
||||
type StaleArgs struct {
|
||||
Days int `json:"days,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Limit int `json:"limit,omitempty"`
|
||||
}
|
||||
|
||||
// DepAddArgs represents arguments for adding a dependency
|
||||
type DepAddArgs struct {
|
||||
FromID string `json:"from_id"`
|
||||
|
||||
@@ -429,6 +429,39 @@ func (s *Server) handleReady(req *Request) Response {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) handleStale(req *Request) Response {
|
||||
var staleArgs StaleArgs
|
||||
if err := json.Unmarshal(req.Args, &staleArgs); err != nil {
|
||||
return Response{
|
||||
Success: false,
|
||||
Error: fmt.Sprintf("invalid stale args: %v", err),
|
||||
}
|
||||
}
|
||||
|
||||
store := s.storage
|
||||
|
||||
filter := types.StaleFilter{
|
||||
Days: staleArgs.Days,
|
||||
Status: staleArgs.Status,
|
||||
Limit: staleArgs.Limit,
|
||||
}
|
||||
|
||||
ctx := s.reqCtx(req)
|
||||
issues, err := store.GetStaleIssues(ctx, filter)
|
||||
if err != nil {
|
||||
return Response{
|
||||
Success: false,
|
||||
Error: fmt.Sprintf("failed to get stale issues: %v", err),
|
||||
}
|
||||
}
|
||||
|
||||
data, _ := json.Marshal(issues)
|
||||
return Response{
|
||||
Success: true,
|
||||
Data: data,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) handleStats(req *Request) Response {
|
||||
store := s.storage
|
||||
|
||||
|
||||
@@ -172,6 +172,8 @@ func (s *Server) handleRequest(req *Request) Response {
|
||||
resp = s.handleResolveID(req)
|
||||
case OpReady:
|
||||
resp = s.handleReady(req)
|
||||
case OpStale:
|
||||
resp = s.handleStale(req)
|
||||
case OpStats:
|
||||
resp = s.handleStats(req)
|
||||
case OpDepAdd:
|
||||
|
||||
Reference in New Issue
Block a user