Skip to content

repl: support group-qualified .scenario in multi-API sessions#1921

Merged
pmcelhaney merged 5 commits intomainfrom
copilot/add-group-qualified-scenario-command
Apr 16, 2026
Merged

repl: support group-qualified .scenario in multi-API sessions#1921
pmcelhaney merged 5 commits intomainfrom
copilot/add-group-qualified-scenario-command

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 16, 2026

Summary

Extended REPL .scenario to be mode-aware: single-runner keeps .scenario <path>, while multi-API now requires .scenario <group> <path> and executes against the selected runner’s scenario registry/context helpers.

  • Command parsing
    • Added dual syntax handling by mode (<path> vs <group> <path>).
    • Preserved single-runner path semantics (entire argument remains the scenario path).
  • Runner-qualified execution
    • Scenario module/function resolution now uses the selected group binding in multi-API mode.
    • Scenario function receives the selected binding’s context, loadContext, route, and routes.
  • Error/usage UX
    • Unknown group errors now include available group keys.
    • Usage output is mode-specific.
  • Docs/tests
    • Updated REPL docs with multi-API .scenario <group> <path> usage.
    • Added unit coverage for multi-API parsing, unknown group handling, usage errors, and group-isolated context/routes behavior.
// Multi-API REPL
.scenario billing soldPets
Original Prompt

Issue: repl: add group-qualified .scenario command for multi-API

Extend .scenario so multi-API sessions can choose which API runner's scenario registry and context are used.

Context

Scenario scripts are loaded per runner (<base>/<group>/scenarios). In multi-runner mode, .scenario needs an API qualifier to avoid ambiguity and to execute against the intended context/route helpers.

Proposed change

Add dual command syntax:

  • single-runner: .scenario <path> (existing behavior)
  • multi-runner: .scenario <group> <path>

The command should resolve the selected group, load that group's scenario module, and pass the group's context, loadContext, route, and routes into the scenario function.

Acceptance criteria

  • .scenario <group> <path> executes scenarios for the selected group in multi-runner mode
  • Unknown group names produce a clear error message with available group keys
  • Invalid or missing arguments print mode-appropriate usage help
  • Single-runner .scenario <path> behavior remains unchanged
  • Unit tests cover parsing, error cases, and context binding for both single- and multi-runner modes

Manual acceptance tests

  • In a single-API session, .scenario soldPets still applies the same scenario function as before.
  • In a multi-API session, .scenario billing soldPets applies only billing context/routes and does not mutate other groups.
  • In a multi-API session, .scenario payments soldPets shows an unknown-group error listing available groups.
  • In a multi-API session, invalid args (e.g. .scenario, .scenario billing) show usage: .scenario <group> <path>.
  • Path traversal input (e.g. .scenario billing ../seed) is rejected with the existing path-segment error.

Tasks

  • Updated .scenario command handling in src/repl/repl.ts to support mode-aware argument parsing and group-qualified execution.
  • Wired scenario invocation in multi-API mode to the selected binding’s scenario registry + context helpers (context, loadContext, route, routes).
  • Added unknown-group and mode-specific usage messaging.
  • Expanded .scenario REPL tests in test/repl/repl.test.ts for multi/single parsing, error handling, and group isolation.
  • Updated docs/features/repl.md with multi-API .scenario <group> <path> usage.
  • Added a patch changeset describing the REPL behavior update.

Copilot AI changed the title [WIP] Add group-qualified .scenario command for multi-API support repl: support group-qualified .scenario in multi-API sessions Apr 16, 2026
Copilot AI requested a review from pmcelhaney April 16, 2026 17:38
@pmcelhaney pmcelhaney marked this pull request as ready for review April 16, 2026 18:44
@pmcelhaney pmcelhaney enabled auto-merge April 16, 2026 18:47
@pmcelhaney pmcelhaney added this pull request to the merge queue Apr 16, 2026
Merged via the queue into main with commit 3bde212 Apr 16, 2026
8 of 9 checks passed
@pmcelhaney pmcelhaney deleted the copilot/add-group-qualified-scenario-command branch April 16, 2026 18:56
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.

repl: add group-qualified .scenario command for multi-API

2 participants