Move completed CLI migration design and plan to docs/plans/completed/ with a concise completion summary alongside the originals. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2.1 KiB
2.1 KiB
CLI Migration: Manual Switch to Core Framework
Completed: 22 Feb 2026
Commit: 094e457 (refactor: migrate CLI imports from core/go to core/cli)
What Was Done
Replaced LEM's main.go — a 296-line manual switch os.Args[1] with per-command flag.FlagSet — with the Core Go framework's cli.Main() + cli.WithCommands() pattern.
Changes
main.goreduced from 296 lines to 11 lines- New
cmd/lemcmd/package created with 7 files:lem.go— root registration (AddLEMCommands)score.go— score, probe, compare, tier, agent (5 commands)gen.go— distill, expand, conv (3 commands)data.go— import-all, consolidate, normalize, approve (4 commands)export.go— jsonl, parquet, publish, convert (4 commands)mon.go— status, expand-status, inventory, coverage, metrics (5 commands)infra.go— ingest, seed-influx, query, worker (4 commands)
runScoreandrunProbemoved frommain.gotopkg/lem/score_cmd.go(exported)- Import paths updated from
forge.lthn.ai/core/go/pkg/clitoforge.lthn.ai/core/cli/pkg/cli core/cliadded as direct dependency;core/gobecomes indirect
Command Restructuring
All 25 flat commands reorganised into 6 groups:
| Group | Commands |
|---|---|
lem score |
run, probe, compare, tier, agent |
lem gen |
distill, expand, conv |
lem data |
import-all, consolidate, normalize, approve |
lem export |
jsonl, parquet, publish, convert |
lem mon |
status, expand-status, inventory, coverage, metrics |
lem infra |
ingest, seed-influx, query, worker |
What Was Not Changed
- All
pkg/lem/Run*functions — untouched - All business logic in
pkg/lem/— untouched - Config loading, probe loading, scoring — unchanged
Key Outcomes
- LEM now matches the Core fleet pattern (go-ml, go-devops, cli/)
- Signal handling, shell completion, grouped
--help, and TUI primitives available - Pass-through architecture: each cobra command rebuilds
[]stringargs and calls existinglem.Run*()— zero business logic changes - Phase 2 (native cobra flags per command) remains optional, can be done incrementally