Skip to content

refactor: split CLI and flight-booking example into cohesive modules - #130

Open
jpsiddharth2008 wants to merge 4 commits into
nitrocloudofficial:developfrom
jpsiddharth2008:feature/issue-119-cli-example-refactor
Open

jpsiddharth2008 wants to merge 4 commits into
nitrocloudofficial:developfrom
jpsiddharth2008:feature/issue-119-cli-example-refactor

Conversation

@jpsiddharth2008

Copy link
Copy Markdown
Collaborator

Purpose

Closes #119.

Split the oversized CLI entry module and flight-booking example into cohesive implementation modules without changing command behavior, generated content, or example startup.

Changes

  • Reduce nitrostack/cli/main.py from 2,020 to 328 physical lines. Keep entry points, exported constants/helpers, public signatures and dispatch; extract command bodies, argument declarations, prompts and runtime helpers into focused private modules.
  • Pass dependencies explicitly from compatibility wrappers at call time, retaining existing monkeypatch points without circular imports or rebinding function globals.
  • Move 25 multiline template strings to packaged text assets, preserving evaluated values exactly. Move project defaults and official template names to a configuration module.
  • Reduce examples/flight_booking_server.py from 582 to 67 lines. Separate models, guards, Duffel service, tools, prompts/resources/health definitions, and application composition into an example-local package; retain original imports and startup behavior through the entry script.
  • Every resulting hand-maintained Python module is at most 328 lines. No size exceptions or new dependencies are required.

Compatibility and validation

  • Tracked tests are unchanged, as required by the issue's scope.
  • Existing CLI/example regression selection: 114 passed on baseline and 114 passed after extraction.
  • Full collection: 1,342 tests.
  • Baseline snapshots match for CLI signatures, template/default values, example MCP metadata, mock results and startup output.
  • Moved command bodies and example declarations are AST-identical; import graph checks find no cycles, and extracted modules import independently.
  • CLI help/error behavior matches in 13 cases. Both direct-script and module example startup paths are verified; actual stdio tools/list output and clean EOF shutdown match baseline from outside the checkout.
  • Built wheels and source distributions contain all 25 exact template assets. An installed wheel outside the checkout supports both CLI entry points and tool/widget generation.
Environment Result Coverage
Linux Python 3.10 1,342 passed 87.74%
Linux Python 3.11 1,342 passed 87.73%
Linux Python 3.12 1,342 passed 87.73%
Windows Python 3.10 1,324 passed, 17 existing skips, 1 failure 85.72%
Windows Python 3.11 1,325 passed, 17 existing skips 85.70%
Windows Python 3.12 1,325 passed, 17 existing skips 85.70%

Runs use MCP 2.3.0 and a 180-second per-test timeout, with no exclusions or new skips/xfails. Linux uses native QuickJS 1.19.4. These are local validation results; hosted CI is tracked in the PR checks.

Windows Python 3.10 failed test_discovery_dcr_404_when_disabled_or_missing_client_id with WinError 10053. The same test and error reproduced on unchanged develop under the same interpreter (baseline OAuth module: 32 passed, 2 socket failures). This does not constitute an all-green Windows matrix.

Python whitespace checks pass. An unrestricted diff check flags only whitespace already present inside three extracted template text assets, retained deliberately for exact string compatibility. Template identity checks confirm it is unchanged.

No other existing examples, SDK project templates, dependency declarations, package metadata, or release versions are changed.

This branch has not been deployed

No deployments
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.

1 participant