Port flagpls's flag-usage scanner into ldcli as flags usage#742
Port flagpls's flag-usage scanner into ldcli as flags usage#742davidbrackbill wants to merge 1 commit into
flags usage#742Conversation
Copies flagpls's AST scanner, LD API enrichment, and table renderer
(internal/flagusage/{scanner,enrich,render}) with import paths and
config/cache locations rewritten to ldcli's conventions (xdg cache/config
under the ldcli namespace instead of flagpls's own). Wires them up as a
new `ldcli flags usage` subcommand reusing ldcli's existing
--access-token/--base-uri/--project flags instead of flagpls's standalone
token/config-file flow.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 032b957. Configure here.
| if windowLabel == "" { | ||
| windowLabel = "7d" | ||
| } | ||
| render.Enriched(os.Stdout, details, windowLabel, splitNonEmpty(envsRaw), width) |
There was a problem hiding this comment.
Text table omits default environments
High Severity
When --envs is omitted, enrichment still loads per-environment data via DefaultCriticalEnvs, but text rendering passes an empty environment list into render.Enriched. flagRows only prints envs from that list, so the default text table shows all-dash env rows even though JSON and the API layer have real status.
Reviewed by Cursor Bugbot for commit 032b957. Configure here.
| if windowLabel == "" { | ||
| windowLabel = "7d" | ||
| } | ||
| render.Enriched(os.Stdout, details, windowLabel, splitNonEmpty(envsRaw), width) |
There was a problem hiding this comment.
Width zero skips terminal detection
Medium Severity
The --width help says 0 auto-detects the terminal, but runUsage forwards 0 unchanged. render.Enriched treats maxWidth of 0 as unconstrained width, and render.TerminalWidth() is never called despite being added for this purpose.
Reviewed by Cursor Bugbot for commit 032b957. Configure here.
| return err | ||
| } | ||
|
|
||
| cacheSet(key, result) |
There was a problem hiding this comment.
Response cache ignores API token
Medium Severity
Disk cache keys are derived from method, path, optional headers, and body only. The Authorization header is applied after the cache lookup and is not part of the key, so a later run with a different access token can read another identity’s cached API JSON from the shared ldcli cache directory.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 032b957. Configure here.


Summary
internal/flagusage/{scanner,enrich,render}) into ldcli, with import paths and config/cache locations rewritten to ldcli's conventions (xdg-based cache/config under theldclinamespace instead of flagpls's own).ldcli flags usagesubcommand (cmd/flags/usage.go) that reuses ldcli's existing--access-token/--base-uri/--projectflags instead of flagpls's standalone token/config-file flow.go-tree-sitterdependency required by the scanner.Stacked on top of this: #TBD (envs config integration).
Test plan
go build ./...andgo test ./...pass, including the 3 ported test suitesldcli flags usage --helprenders correctly with ldcli's usage templateClaude claude@anthropic.com
Note
Medium Risk
New CLI surface and many LD API/internal monitor calls (token-bearing); logic is read-only but heuristics for “ready to remove” flags could mislead if wrong.
Overview
Adds
ldcli flags usage, wiring a scan → enrich → render pipeline into the existingflagscommand and ldcli auth (--project, access token, base URI).The scanner (tree-sitter) finds flag eval sites in TS/JS and Go, including wrapper factories and auto-discovery via
node_modules. Enrichment pulls flag config, per-env status, batched eval summaries (and optional timeseries / unique-context “exposures”), classifies lifecycle states (e.g. orphaned refs, code-removable rollouts), and caches API responses underxdgldcli/flagusage. Output is a terminal table or--format json.Dependency:
go-tree-sitter. Substantial ported test coverage for scanner, enrich, render, and API client behavior.Reviewed by Cursor Bugbot for commit 032b957. Bugbot is set up for automated code reviews on this repo. Configure here.