Skip to content

Commit e05257d

Browse files
committed
feat: full-OpenAPI coverage + help-reliability fixes from the agent eval
Bumps go-flashduty to the merged docs#67 sync (AuditRecordIDRequest split, progress enum, export_fields enum, post-mortem desc) + the restored toon tag, and lands the CLI-side eval fixes so an SRE agent can call correctly from `--help` alone: - cligen (internal/cmd/cligen): list help states the {request_id,error,data} envelope is unwrapped — pipe `jq '.items[]'` for generated lists, not `.data.items[]`. - incident.go: `incident list` --since/--until window must be < 31 days, --limit max 100. audit.go: `audit search` window < 90 days, --limit max 99. - command.go: WriteRaw streams *export CSV bodies to the writer verbatim so `> file.csv` captures bytes instead of the "OK: POST ..." acknowledgment. - Regenerated all 254 commands against the new SDK (toon keys snake_case; rule-audit-detail --id documented as the audit-record id, not the rule id). go.mod pins go-flashduty to the merged main pseudo-version (no release). Build + go vet green.
1 parent b21322e commit e05257d

34 files changed

Lines changed: 1048 additions & 429 deletions

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/flashcatcloud/flashduty-cli
33
go 1.25.1
44

55
require (
6-
github.com/flashcatcloud/go-flashduty v0.5.2
6+
github.com/flashcatcloud/go-flashduty v0.5.3-0.20260602031007-62b37649b2f0
77
github.com/mattn/go-runewidth v0.0.23
88
github.com/spf13/cobra v1.10.2
99
github.com/spf13/pflag v1.0.10

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
github.com/clipperhouse/uax29/v2 v2.2.0 h1:ChwIKnQN3kcZteTXMgb1wztSgaU+ZemkgWdohwgs8tY=
22
github.com/clipperhouse/uax29/v2 v2.2.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM=
33
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
4-
github.com/flashcatcloud/go-flashduty v0.5.2 h1:mYg/M0jqkil30WTLdICVtTJVGxEIGmae/3zBpRkwLRQ=
5-
github.com/flashcatcloud/go-flashduty v0.5.2/go.mod h1:aA0RtZEs0AYOwwdNKdtVeD8YMOdnmVY1zAlVD+9Ovx8=
4+
github.com/flashcatcloud/go-flashduty v0.5.3-0.20260602031007-62b37649b2f0 h1:mk9ryHQVssVA3qqyH4ryqeWa6sW0tYdww3JWalN3ZH0=
5+
github.com/flashcatcloud/go-flashduty v0.5.3-0.20260602031007-62b37649b2f0/go.mod h1:aA0RtZEs0AYOwwdNKdtVeD8YMOdnmVY1zAlVD+9Ovx8=
66
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
77
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
88
github.com/mattn/go-runewidth v0.0.23 h1:7ykA0T0jkPpzSvMS5i9uoNn2Xy3R383f9HDx3RybWcw=

internal/cli/audit.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func newAuditSearchCmd() *cobra.Command {
2727
cmd := &cobra.Command{
2828
Use: "search",
2929
Short: "Search audit logs",
30-
Long: curatedLong("Search audit logs within a time window, optionally filtered by person and operation type.", "AuditLogs", "Search"),
30+
Long: curatedLong("Search audit logs within a time window, optionally filtered by person and operation type. The --since/--until window must be < 90 days; --limit max is 99.", "AuditLogs", "Search"),
3131
RunE: func(cmd *cobra.Command, args []string) error {
3232
return runCommand(cmd, args, func(ctx *RunContext) error {
3333
startTime, err := timeutil.Parse(since)
@@ -107,7 +107,7 @@ func newAuditSearchCmd() *cobra.Command {
107107
cmd.Flags().StringVar(&since, "since", "7d", "Start time")
108108
cmd.Flags().StringVar(&until, "until", "now", "End time")
109109
cmd.Flags().Int64Var(&person, "person", 0, "Filter by person ID")
110-
cmd.Flags().StringVar(&operation, "operation", "", "Filter by operation type")
110+
cmd.Flags().StringVar(&operation, "operation", "", "Filter by exact operation name(s) from 'fduty audit operation-list' (e.g. monitRule:write:update); comma-separate to match several in one call. Prefixes do NOT match (\"monitRule\" returns nothing).")
111111
cmd.Flags().IntVar(&limit, "limit", 20, "Max results (max 99)")
112112
cmd.Flags().IntVar(&page, "page", 1, "Page number")
113113

internal/cli/command.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ func (ctx *RunContext) WriteResult(message string) {
7373
writeResult(ctx.Writer, message)
7474
}
7575

76+
// WriteRaw writes a non-JSON response body (e.g. a CSV/file download surfaced
77+
// on Response.Raw by the *export endpoints) straight to the output writer, so
78+
// shell redirection (`> file.csv`) captures the bytes verbatim instead of the
79+
// canned "OK: POST ..." acknowledgment.
80+
func (ctx *RunContext) WriteRaw(body []byte) error {
81+
_, err := ctx.Writer.Write(body)
82+
return err
83+
}
84+
7685
// WriteResultJSON outputs structured data in JSON or TOON mode, or a
7786
// human-readable message in table mode. JSON stays indented (byte-compatible
7887
// with the legacy --json path); TOON routes through the SDK marshaller.

internal/cli/incident.go

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func newIncidentListCmd() *cobra.Command {
8080
cmd := &cobra.Command{
8181
Use: "list",
8282
Short: "List incidents",
83-
Long: curatedLong("List incidents matching the given filters.", "Incidents", "List"),
83+
Long: curatedLong("List incidents matching the given filters. The --since/--until window must be < 31 days; --limit max is 100.", "Incidents", "List"),
8484
RunE: func(cmd *cobra.Command, args []string) error {
8585
return runCommand(cmd, args, func(ctx *RunContext) error {
8686
startTime, err := timeutil.Parse(since)
@@ -119,7 +119,7 @@ func newIncidentListCmd() *cobra.Command {
119119
cmd.Flags().StringVar(&severity, "severity", "", "Filter: Critical,Warning,Info")
120120
cmd.Flags().Int64Var(&channelID, "channel", 0, "Filter by channel ID")
121121
cmd.Flags().StringVar(&query, "query", "", "Free-text search across title/labels/content (also resolves a 24-char incident ID or 6-char incident num to a direct lookup)")
122-
cmd.Flags().StringVar(&since, "since", "24h", "Start time (duration, date, datetime, or unix timestamp)")
122+
cmd.Flags().StringVar(&since, "since", "24h", "Start time (duration, date, datetime, or unix timestamp; --since→--until window must be < 31 days)")
123123
cmd.Flags().StringVar(&until, "until", "now", "End time")
124124
cmd.Flags().IntVar(&limit, "limit", 20, "Max results (max 100)")
125125
cmd.Flags().IntVar(&page, "page", 1, "Page number")
@@ -135,25 +135,36 @@ func newIncidentGetCmd() *cobra.Command {
135135
Args: requireArgs("incident_id"),
136136
RunE: func(cmd *cobra.Command, args []string) error {
137137
return runCommand(cmd, args, func(ctx *RunContext) error {
138-
result, _, err := ctx.Client.Incidents.List(cmdContext(ctx.Cmd), &flashduty.ListIncidentsRequest{
139-
IncidentIDs: ctx.Args,
140-
})
141-
if err != nil {
142-
return err
138+
// Fetch each incident by ID via /incident/info: it works for
139+
// any id with no time window. /incident/list cannot serve a
140+
// plain get-by-id — it mandates a start/end window and caps it
141+
// at 31 days, so it 400s ("StartTime is a required field") when
142+
// queried by id alone.
143+
items := make([]flashduty.IncidentInfo, 0, len(ctx.Args))
144+
for _, id := range ctx.Args {
145+
info, _, err := ctx.Client.Incidents.Info(cmdContext(ctx.Cmd), &flashduty.IncidentInfoRequest{
146+
IncidentID: id,
147+
})
148+
if err != nil {
149+
return fmt.Errorf("get incident %s: %w", id, err)
150+
}
151+
if info != nil {
152+
items = append(items, *info)
153+
}
143154
}
144155

145156
if ctx.Structured() {
146-
return ctx.Printer.Print(result.Items, nil)
157+
return ctx.Printer.Print(items, nil)
147158
}
148159

149160
// Single incident: vertical detail view
150-
if len(ctx.Args) == 1 && len(result.Items) == 1 {
151-
printIncidentDetail(ctx.Writer, result.Items[0])
161+
if len(items) == 1 {
162+
printIncidentDetail(ctx.Writer, items[0])
152163
return nil
153164
}
154165

155166
// Multiple: table
156-
return ctx.Printer.Print(result.Items, incidentColumns())
167+
return ctx.Printer.Print(items, incidentColumns())
157168
})
158169
},
159170
}

internal/cli/zz_generated_a2a_agents.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/cli/zz_generated_account.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)