Skip to content

feat(cli): migrate list command to adapter API (#264)#294

Merged
tikazyq merged 1 commit into
mainfrom
claude/implement-issue-264-Cpzaz
May 18, 2026
Merged

feat(cli): migrate list command to adapter API (#264)#294
tikazyq merged 1 commit into
mainfrom
claude/implement-issue-264-Cpzaz

Conversation

@tikazyq

@tikazyq tikazyq commented May 18, 2026

Copy link
Copy Markdown
Contributor

Closes #264

Summary

Reference implementation for the CLI adapter migration. leanspec list is now the canonical template every subsequent command migration (specs 390–392) will follow.

  • Schema-driven filter translation. --status, --priority, --tag, and --assignee are translated into ListFilter::fields via SpecSchema::key_for_semantic. A flag with no matching semantic on the active adapter is silently dropped (e.g. --priority high against an adapter without a priority field).
  • Schema-driven row rendering. Status emoji + truecolor pulled from EnumOption::color instead of hard-coded SpecStatus matches. Tags/assignee/priority read via field_str / field_strings against semantic keys.
  • --specs-dir only applies to markdown. When passed against a non-markdown project, the command returns a clean --specs-dir is not applicable to the 'github' adapter error before ever trying to authenticate. Powered by a new AdapterRegistry::project_config accessor that loads adapter config without instantiating the adapter (important — GitHub-style adapters demand env vars at construction).
  • Hierarchy via links. Parent/child tree is built from doc.links filtered by link_type == "parent", working for any adapter that populates links.
  • No SpecLoader/SpecInfo/SpecStatus/SpecPriority/SpecFilterOptions imports remain in list.rs.

Stubs for the rest of the CLI

Commit ea92e01 (#285) intentionally left leanspec-cli and leanspec-http broken as a "compiler-guided migration map." Because the issue's test plan needs a buildable binary, I've stubbed every still-broken command (analyze, archive, backfill, board, check, children, create, deps, files, gantt, open, rel, search, stats, timeline, tokens, update, validate, view, tui) with a Err("not yet migrated to the adapter API") body. CreateParams and RelArgs are preserved because main.rs constructs them. The TUI submodules are unwired from tui/mod.rs but left on disk so the downstream migration can crib from them.

These stubs will be replaced one-for-one by specs 390–392 (and the TUI's own migration spec). E2E tests for those commands fail predictably with the stub message until then.

Test plan

  • cargo test -p leanspec-cli --test list — 11/11 pass (markdown filtering, JSON output, --specs-dir on non-markdown errors cleanly, --priority on adapter without the field is a no-op).
  • cargo test -p leanspec-cli --bin leanspec — 13/13 pass (includes 6 new unit tests in commands/list.rs covering semantic-hint translation, silent-drop, hex parsing, and parent_id extraction).
  • cargo test -p leanspec-core --lib — 219/219 pass (includes the new project_config lookup in adapters::registry).
  • cargo test -p leanspec-http --lib adapter_resolution — 4/4 pass.
  • cargo build -p leanspec-cli — binary now builds.
  • cargo clippy -p leanspec-cli --bin leanspec --tests -- -D warnings — clean.
  • cargo fmt --check — clean.

https://claude.ai/code/session_01P3WTP6T4Dtc8LYsVFfaHNx


Generated by Claude Code

Reference implementation for the CLI adapter migration. `leanspec list`
now reads the project's configured adapter (markdown or GitHub), uses
`SpecSchema` semantic hints to translate `--status`, `--priority`,
`--tag`, and `--assignee` into a generic `ListFilter::fields` map, and
renders rows from `SpecDoc.fields` using the schema's declared enum
colors. The `--specs-dir` flag now errors cleanly when the project
adapter is non-markdown rather than silently overriding it.

Adds `AdapterRegistry::project_config` so callers can inspect the
configured adapter name before instantiating it — important for
adapters like GitHub that require auth at construction time.

Other CLI commands that still reach into `SpecLoader`/`SpecInfo` are
left as stubs returning a "not yet migrated" error. They cover the
same set of broken commands flagged by ea92e01 as the migration map
for downstream specs (390+). The TUI stays in this stubbed bucket.

Test plan
- New unit tests in `commands/list.rs` cover the semantic-hint
  translation, the silent-drop behaviour for missing fields, hex
  parsing, and parent-link extraction.
- E2E tests in `tests/list.rs` create markdown specs directly on disk
  (because `create`/`update` are stubbed) and exercise the markdown
  filter, JSON output, the `--specs-dir`-on-GitHub error, and the
  `--priority`-on-empty-project no-op.
Copilot AI review requested due to automatic review settings May 18, 2026 14:39
@tikazyq tikazyq merged commit 4b7c83e into main May 18, 2026
2 of 4 checks passed
@tikazyq tikazyq deleted the claude/implement-issue-264-Cpzaz branch May 18, 2026 14:41
@tikazyq tikazyq removed the request for review from Copilot May 18, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

spec(cli): list Command Migration (Reference Implementation)

2 participants