fix(workflow): improve input mode detection and error hint

- hasLocalTriageInput now also detects triage-specific flags (--body,
  --number, --author, --url, --labels) to enter local input mode.
- hasLocalHealthInput now checks all health-related flags to prevent
  invalid values like --open-issues=abc from silently falling through
  to remote fetch instead of being validated.
- Remote fetch failure in +triage now includes a hint suggesting
  --title or --from for local analysis.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
wbtiger 2026-05-26 16:27:29 +08:00
parent b3f139801b
commit 6b355e19e2
1 changed files with 23 additions and 3 deletions

View File

@ -122,7 +122,7 @@ func runTriage(ctx *common.RuntimeContext) error {
Since: ctx.Arg("since"),
})
if err != nil {
return err
return fmt.Errorf("%w\nhint: use --title or --from issues.json for local rule analysis", err)
}
results := make([]TriageResult, 0, len(issues))
for _, issue := range issues {
@ -199,11 +199,31 @@ func collectIssuesFromArgs(ctx *common.RuntimeContext) ([]IssueInput, error) {
}
func hasLocalTriageInput(ctx *common.RuntimeContext) bool {
return strings.TrimSpace(ctx.Arg("from")) != "" || strings.TrimSpace(ctx.Arg("title")) != ""
if strings.TrimSpace(ctx.Arg("from")) != "" || strings.TrimSpace(ctx.Arg("title")) != "" {
return true
}
// When user passes triage-specific flags without --title or --from,
// treat it as local input so argument validation kicks in early.
for _, name := range []string{"body", "number", "author", "url", "labels"} {
if strings.TrimSpace(ctx.Arg(name)) != "" {
return true
}
}
return false
}
func hasLocalHealthInput(ctx *common.RuntimeContext) bool {
return strings.TrimSpace(ctx.Arg("from")) != "" || strings.TrimSpace(ctx.Arg("repository")) != ""
if strings.TrimSpace(ctx.Arg("from")) != "" || strings.TrimSpace(ctx.Arg("repository")) != "" {
return true
}
// When user passes any health-flag value (even invalid ones like
// --open-issues abc), stay in local mode so parseIntArg validates them.
for _, name := range []string{"open-issues", "stale-issues", "open-prs", "stale-prs", "recent-activity-known", "recent-activity-days", "release-known", "has-recent-release", "ci-known", "ci-passing", "has-readme", "has-license", "has-contributing", "agent-readiness-known", "agent-readiness-score"} {
if strings.TrimSpace(ctx.Arg(name)) != "" {
return true
}
}
return false
}
func collectHealthFromArgs(ctx *common.RuntimeContext) (HealthInput, error) {