feat(common): add FlagHints + did-you-mean unknown-flag error enhancemen#906
feat(common): add FlagHints + did-you-mean unknown-flag error enhancemen#906xzcong0820 wants to merge 2 commits into
Conversation
…ment Add framework-level unknown-flag error interception in shortcuts/common/. When a user or AI agent passes an unrecognized flag, cobra's FlagErrorFunc now returns structured JSON (via output.ExitError) instead of plain-text, with an optional "did you mean: --X?" hint. Changes: - types.go: add FlagHints map[string]string field to Shortcut struct - flag_suggest.go: implement extractUnknownFlagName, editDistance, min3, flagSuggestThreshold, collectKnownFlagNamesFromCmd, didYouMeanFlag, wrapFlagError with four-priority logic (FlagHints > edit-distance > no-match > non-unknown-flag) - runner.go: add SilenceUsage: true to cobra.Command literal and register SetFlagErrorFunc before parent.AddCommand in mountDeclarative - mail shortcuts: populate FlagHints for +draft-edit, +message, +thread, +triage, +send with domain-specific misuse mappings sprint: S2
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdded a flag suggestion system that recommends corrections for unknown flag names using rune-aware Levenshtein distance and per-shortcut FlagHints; integrated into the shortcut framework and configured with domain-specific mail shortcut hints. ChangesFlag suggestion system with mail shortcut hints
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (2 warnings, 1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@b06ba1647a95b8c92132a9812c6329f7b58abb32🧩 Skill updatenpx skills add xzcong0820/larksuite-cli#feat/8f59c0d -y -g |
wrapFlagError priority-3 (no match) and priority-4 (non-unknown-flag error) were calling output.ErrValidation which hardcodes type="validation"; tech-design §处理优先级 lines 115/116 require type="validation_error". Replace both callsites with output.Errorf(output.ExitValidation, "validation_error", msg) so the type string matches the spec without touching the global ErrValidation helper.
Generated by the harness-coding skill.
Sprints
Source specs
This MR was created autonomously. Quality gates were enforced by the repo's own pre-commit hooks.
Summary by CodeRabbit
New Features
Bug Fixes
Tests