Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion cmd/askgod/cmd_admin_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import (
"github.com/nsec/askgod/internal/utils"
)

func (c *client) cmdAdminHistory(ctx context.Context, _ *cli.Command) error {
func (c *client) cmdAdminHistory(ctx context.Context, cmd *cli.Command) error {
flagIDs := cmd.Int64Slice("flags")

// Get the scores
scores := []api.AdminScore{}

Expand Down Expand Up @@ -51,6 +53,10 @@ func (c *client) cmdAdminHistory(ctx context.Context, _ *cli.Command) error {
table.SetAutoWrapText(false)

for _, entry := range scores {
if !matchesFlagIDs(entry.FlagID, flagIDs) {
continue
}

// Get the team
team := api.AdminTeam{}

Expand Down
6 changes: 6 additions & 0 deletions cmd/askgod/cmd_admin_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ func (c *client) cmdAdminMonitorLog(_ context.Context, cmd *cli.Command) error {
}

func (c *client) cmdAdminMonitorFlags(_ context.Context, cmd *cli.Command) error {
flagIDs := cmd.Int64Slice("flags")

humanOnly := cmd.Bool("human")

// Connection handler
Expand Down Expand Up @@ -115,6 +117,10 @@ func (c *client) cmdAdminMonitorFlags(_ context.Context, cmd *cli.Command) error
continue
}

if !flagMatchesIDs(score.Flag, flagIDs) {
continue
}

if humanOnly && (strings.Contains(score.Source, "agent") || strings.Contains(score.Source, "mcp")) {
continue
}
Expand Down
12 changes: 11 additions & 1 deletion cmd/askgod/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ func main() {
Usage: "Show a live stream of submitted flags",
Category: "server",
Flags: []cli.Flag{
&cli.Int64SliceFlag{
Name: "flags",
Usage: "Only show entries for flags with the given IDs",
},
&cli.BoolFlag{
Name: "human",
Usage: "Only show submissions from human sources (excludes agent/mcp)",
Expand Down Expand Up @@ -195,7 +199,13 @@ func main() {
Name: "history",
Usage: "List the global flag history",
Category: "scores",
Action: c.cmdAdminHistory,
Flags: []cli.Flag{
&cli.Int64SliceFlag{
Name: "flags",
Usage: "Only show entries for flags with the given IDs",
},
},
Action: c.cmdAdminHistory,
},
{
Name: "stats",
Expand Down
22 changes: 22 additions & 0 deletions cmd/askgod/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,34 @@ package main
import (
"fmt"
"reflect"
"slices"
"strconv"
"strings"

"github.com/nsec/askgod/api"
"github.com/nsec/askgod/internal/utils"
)

func matchesFlagIDs(flagID int64, flagIDs []int64) bool {
if len(flagIDs) == 0 {
return true
}

return slices.Contains(flagIDs, flagID)
}

func flagMatchesIDs(flag *api.AdminFlag, flagIDs []int64) bool {
if len(flagIDs) == 0 {
return true
}

if flag == nil {
return false
}

return matchesFlagIDs(flag.ID, flagIDs)
}

func getStructField(base reflect.Value, key string) (reflect.Value, error) {
field := base

Expand Down
Loading