Skip to content

REPL: prefer OpenAPI paths in completer and split lookup logic#1881

Merged
pmcelhaney merged 3 commits intomainfrom
copilot/update-completer-repl-openapi
Apr 16, 2026
Merged

REPL: prefer OpenAPI paths in completer and split lookup logic#1881
pmcelhaney merged 3 commits intomainfrom
copilot/update-completer-repl-openapi

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 15, 2026

Summary

REPL route autocomplete now prefers OpenAPI path templates (when available) instead of registry-derived paths, so completions reflect canonical spec routes like /example/hello/{name}. The completer logic was also decomposed into focused lookup helpers to make behavior explicit and easier to evolve.

  • Route source selection

    • Added OpenAPI-first route source resolution with registry fallback.
    • Preserves existing behavior when no OpenAPI paths are present.
  • Completer decomposition

    • Split createCompleter() into dedicated helpers for:
      • .scenario completions
      • route-builder method completions
      • route string completions
      • route source resolution
  • Coverage + docs

    • Added a regression test proving OpenAPI path completion is preferred over registry path aliases.
    • Updated REPL docs to state that Tab completion uses OpenAPI templates when loaded.
const completer = createCompleter(
  registry,
  undefined,
  { paths: { "/example/hello/{name}": { get: {} } } },
);

const [completions] = await callCompleter(completer, 'client.get("/example/h');
// completions => ["/example/hello/{name}"]
Original Prompt
  1. The completer in the REPL currently relies on registry to get a list of valid routes. If an OpenAPI document is available, it should rely on that instead.

  2. Break up the createCompleter() function -- delegate each lookup to a smaller function.

  3. The completer should know about the prefix "/example/hello/{name}" not "/hello/name".

Manual acceptance tests

  • With an OpenAPI document loaded, typing client.get("/example/h in REPL and pressing Tab suggests /example/hello/{name}.
  • With an OpenAPI document loaded, typing route("/example/h and pressing Tab suggests /example/hello/{name}.
  • Without OpenAPI paths, route completion still uses registry routes (existing behavior).
  • Typing route("/pets"). still suggests RouteBuilder methods (method(, query(, send(, etc.).
  • .scenario completion still suggests index exports and file-prefix/function combinations as before.

Tasks

  • Refactored createCompleter() into focused helper functions for each completion domain.
  • Added OpenAPI-first route lookup (openApiDocument.paths), with registry fallback.
  • Updated startRepl() completer wiring to pass the OpenAPI document into createCompleter().
  • Added REPL unit test asserting OpenAPI path-template completion precedence.
  • Updated REPL docs and added a patch changeset entry.

Copilot AI linked an issue Apr 15, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Update completer in REPL to use OpenAPI REPL: prefer OpenAPI paths in completer and split lookup logic Apr 15, 2026
Copilot AI requested a review from pmcelhaney April 15, 2026 20:57
@pmcelhaney pmcelhaney marked this pull request as ready for review April 16, 2026 14:07
@pmcelhaney pmcelhaney enabled auto-merge April 16, 2026 14:07
@pmcelhaney pmcelhaney added this pull request to the merge queue Apr 16, 2026
Merged via the queue into main with commit 1650211 Apr 16, 2026
8 of 9 checks passed
@pmcelhaney pmcelhaney deleted the copilot/update-completer-repl-openapi branch April 16, 2026 14:17
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.

Update completer in REPL to use OpenAPI

2 participants