mirror of
https://github.com/johnkerl/miller.git
synced 2026-07-18 00:45:47 +00:00
* Add JSON index and mlr which capability router (#2098) PR 2 of the AI-friendly roadmap (plans/plan-2098-llm.md): - `mlr help --as-json --index` emits a lightweight [{kind,name,summary}] index across all 651 catalog items (verbs, functions, flags, keywords), sorted by kind then name. Agents use this as a cheap first call to pick a verb before fetching its full entry. - `mlr which "<query>"` is a new terminal that tokenizes a natural-language query, scores every catalog item (name match +20/token, body match +5/token), and returns ranked JSON [{kind,name,score,summary}]. Exit code 0 means a confident match (at least one token hit the item name); exit code 2 means low confidence. Agents branch on the exit code rather than parsing prose. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> * Move mlr which into pkg/terminals/help, deduplicate firstLine pkg/terminals/which/ was a misplaced package: it imported the same four catalog registries as pkg/terminals/help/ and duplicated the firstLine helper. Moving the logic into help/entry_which.go fixes both issues: - WhichMain and all which helpers now live alongside the other --as-json catalog machinery in pkg/terminals/help/ - indexFirstLine (entry_json.go) and firstLine (which/entry.go) collapse into a single firstLine shared by both files - pkg/terminals/terminals.go calls help.WhichMain directly; the pkg/terminals/which/ package is deleted No behavior change. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> * Fix five Go-purity issues found in code review 1. Exit-code false positive: whichScore now returns (int, bool) where the bool records whether any token hit the item name. WhichMain uses results[0].nameHit for exit-code 0, so 4 body-only token hits (4×5=20) no longer incorrectly signal a confident match. 2. Flag Summary inconsistency: whichSearch was setting Summary: fl.Help directly for flags while using firstLine(...) for functions and keywords. Changed to firstLine(fl.Help) so all four kinds behave consistently. 3+5. kindOrder/whichKindRank duplication: the verb<function<flag<keyword ordering was encoded twice — as a local map[string]int in buildIndex and as a switch in whichKindRank. Replaced both with a single package-level kindRank() function. The map lookup also silently returned 0 (= verb rank) for unknown kinds; the switch correctly returns 4 (sorts last). 4. extractIndexFlag/extractAsJSONFlag duplication: both had identical loop bodies differing only in the sentinel string. Introduced a generic extractFlag(args, flag) helper; both are now one-liners. Also promoted whichStopwords to a package-level var so whichTokenize does not allocate a new map on every call. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| auxents | ||
| bifs | ||
| cli | ||
| climain | ||
| colorizer | ||
| dkvpx | ||
| dsl | ||
| entrypoint | ||
| go-csv | ||
| input | ||
| lib | ||
| mlrval | ||
| output | ||
| parsing | ||
| pbnjay-strptime | ||
| platform | ||
| runtime | ||
| scan | ||
| stream | ||
| terminals | ||
| transformers | ||
| types | ||
| version | ||
| README.md | ||
Please see ../../README-dev.md for an overview; please see each subdirectory for details about it.