3.0 KiB
3.0 KiB
Next-Step Refactor Checklist
This doc tracks remaining reuse/refactor work now that the original plan is done. Each section lists the goal, why it matters, and the concrete steps/tests needed.
1. Shared Tool Schema Cache (Completed)
- Problem:
generate-cliandemit-tsboth fetch & serialize tool schemas independently (andmcporter listre-parses them too). - What we did:
- Added
src/cli/tool-cache.tswithloadToolMetadata()caching tool metadata per runtime/server/options. - Switched
mcporter list(single-server path) andemit-tsto consume the helper, so both reuseToolMetadata. - Added
tests/tool-cache.test.ts+ updated emit-ts tests to ensure the helper is covered.
- Added
- Next: Consider integrating the cache into
generate-cliif we ever reuse runtime instances there.
2. Unified Flag Parsing for Generator-style Commands (Completed)
- Problem:
generate-cli,regenerate-cli, andemit-tseach reimplemented--runtime,--timeout, and--include-optionalhandling. - What we did:
- Added
extractGeneratorFlags()insrc/cli/generate/flag-parser.tsto normalize shared flags while mutatingargsin place. - Updated all three commands to call the helper before parsing command-specific options.
- Added
tests/generator-flag-parser.test.tsto cover runtime/timeout and optional flags.
- Added
3. Test Fixture Reuse (Completed)
- Problem: Emit-ts/tool-cache/unit tests each defined their own tool/definition fixtures, leading to divergence.
- What we did:
- Added
tests/fixtures/tool-fixtures.ts(shared definition + tools). - Updated
tests/emit-ts.test.tsandtests/tool-cache.test.tsto import the shared fixtures (and reuse them viabuildToolMetadata). - Ensured the fixture covers required+optional parameters so both suites hit the same edge cases.
- Added
4. CallResult Helper Extraction (Completed)
- Problem:
call-command.tsand the emit-ts client template both wrapped results withcreateCallResult, but there was no shared helper. - What we did:
- Added
wrapCallResult()toresult-utils.tsand exported it from the package entry. - Updated
call-command.tsand the emit-ts template to reuse the helper so they stay in sync. - Adjusted emit-ts tests to assert the helper is referenced.
- Added
5. CLI Docs Consolidation (Completed)
- Problem: CLI usage guidance was scattered across README,
docs/spec.md, and various feature docs. - What we did:
- Added
docs/cli-reference.mdsummarizinglist,call,generate-cli, andemit-tsflags/modes in one place. - Pointed emit-ts users to that doc so we can converge other references over time (no README/spec churn yet to avoid clobbering parallel work).
- Added
- Next: Once the other doc changes land, update README/spec to link to the reference and drop redundant sections.
Tracking the above here keeps future agents aligned. Update this checklist as items ship (mark sections “Completed” when done, or delete the doc once empty).