Skip to content

feat(query): replace readline with read-multiline in REPL#895

Open
dqn wants to merge 14 commits intomainfrom
feat/query-repl-read-multiline
Open

feat(query): replace readline with read-multiline in REPL#895
dqn wants to merge 14 commits intomainfrom
feat/query-repl-read-multiline

Conversation

@dqn
Copy link
Copy Markdown
Contributor

@dqn dqn commented Apr 2, 2026

Replace Node.js readline with @toiroakr/read-multiline for native multiline editing in the query REPL

Before / After

Before: Single-line readline with manual line buffering. Multi-line SQL/GraphQL required pressing Enter after each line, with no way to edit previous lines.

After: True multiline editor with validation-based submit, undo/redo, and history navigation.

sql>
SELECT *
FROM users
WHERE id = 1;

Main Changes

  • Replace node:readline with @toiroakr/read-multiline for built-in multiline editing, validation, and history
  • Add persistent REPL history stored in XDG config directory (~/.config/tailor-platform/)
  • Simplify REPL loop by removing manual line buffering, abort controller wiring, and custom Ctrl+C handling
  • Update help text to reflect new key bindings (Ctrl+J for newline, undo/redo, history navigation)

Notes

  • History files are not yet scoped per workspace/profile (documented as TODO)
  • REPL commands and empty input are saved to history due to library limitations (documented as TODO)
  • In Claude Code, newlines are entered with Shift+Enter (macOS) or Ctrl+Enter (Windows), which may be confused with REPL submit

dqn added 9 commits April 1, 2026 17:52
Replace node:readline/promises with @toiroakr/read-multiline for the
interactive query REPL, enabling full multi-line editing with cursor
navigation, undo/redo, bracketed paste, and persistent history.

- Enter inserts newline, modified-Enter (Shift/Ctrl/Alt) submits
- Validate on submit: SQL requires ';' terminator, GraphQL requires
  complete document
- File-based history per engine (~/.config/tailor-platform/)
- Remove obsolete line-buffering logic and interrupt handling
…text

- Check raw value length instead of trimmed length on Ctrl+C cancel so
  whitespace-only drafts do not exit the REPL (regression from readline)
- Replace hardcoded Enter/Shift+Enter key bindings in \help with
  terminal-agnostic Ctrl+J and a reference to the auto-detected footer
- Note that history is shared across workspaces/profiles
- Note that empty input and REPL commands are saved to history
Use the discriminated union on QueryDispatchResult.engine to branch
print logic after a single execute() call, removing the redundant
per-engine assertion guards.
@dqn dqn requested review from remiposo and toiroakr as code owners April 2, 2026 08:03
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 2, 2026

🦋 Changeset detected

Latest commit: ba775d3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@tailor-platform/sdk Minor
@tailor-platform/create-sdk Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 2, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@tailor-platform/create-sdk@895

commit: ba775d3

@claude
Copy link
Copy Markdown

claude bot commented Apr 2, 2026

📖 Docs Consistency Check

✅ No inconsistencies found between documentation and implementation.

Checked areas:

  • CLI command documentation (cli-reference.md and cli/*.md files)
  • CLI documentation generation config (docs.test.ts)
  • Project documentation (CLAUDE.md)
  • Example code patterns

Analysis:

The query command is intentionally undocumented:

  • Not included in docs.test.ts command list
  • No docs/cli/query.md file exists
  • Not referenced in any other documentation

All user-facing changes are properly reflected in the implementation:

  • REPL help text updated with new key bindings (Ctrl+J for newline, Ctrl+Z/Y for undo/redo, Up/Down for history)
  • Ctrl+C behavior documented (Cancel current input)
  • Persistent history feature is implementation detail (XDG config directory)

PR Changes Summary:

  • Replaced node:readline with @toiroakr/read-multiline for multiline editing
  • Added persistent REPL history (stored in ~/.config/tailor-platform/)
  • Updated REPL help text to reflect new key bindings
  • Removed resolveReplInterruptAction tests (function removed)

Since the query command has no external documentation and all user-visible information is displayed via the in-REPL help command (which was updated), there are no documentation files requiring changes.


@github-actions

This comment has been minimized.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 5 additional findings.

Open in Devin Review

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Comment on lines +573 to +577
logger.log(
engine === "sql"
? "Submit executes when input ends with ';'."
: "Submit executes when input is a complete GraphQL document.",
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might not be correct anymore.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in fd7b2336.

Copy link
Copy Markdown
Contributor

@toiroakr toiroakr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also like to support features such as syntax highlighting and automatic bracket insertion. Please refer to the read-multiline example.

@github-actions

This comment has been minimized.

dqn added 2 commits April 5, 2026 07:48
Bumps @toiroakr/read-multiline to 0.3.0 which adds highlight and
transform callback options used by the REPL syntax highlighting and
auto-close bracket support. Adds sql-highlight for SQL tokenization
and promotes graphql from a transitive to a direct dependency for
GraphQL Lexer access.
Wire the new highlight and transform options from read-multiline 0.3.0 into
the query REPL: per-engine syntax highlighting (SQL via sql-highlight,
GraphQL via the official graphql Lexer) and auto-closing brackets with
auto-indent on newline. The editor module is lazy-imported inside runRepl
so graphql and sql-highlight are not pulled in on every CLI startup.
@dqn
Copy link
Copy Markdown
Contributor Author

dqn commented Apr 4, 2026

#895 (review)
Addressed in ba775d34.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 4, 2026

Code Metrics Report (packages/sdk)

main (0be43dd) #895 (a76d4f3) +/-
Coverage 57.0% 57.5% +0.5%
Code to Test Ratio 1:0.4 1:0.4 -0.1
Details
  |                    | main (0be43dd) | #895 (a76d4f3) |  +/-  |
  |--------------------|----------------|----------------|-------|
+ | Coverage           |          57.0% |          57.5% | +0.5% |
  |   Files            |            337 |            338 |    +1 |
  |   Lines            |          11035 |          11154 |  +119 |
+ |   Covered          |           6292 |           6418 |  +126 |
- | Code to Test Ratio |          1:0.4 |          1:0.4 |  -0.1 |
  |   Code             |          67220 |          67500 |  +280 |
+ |   Test             |          27489 |          27588 |   +99 |

Code coverage of files in pull request scope (46.8% → 63.5%)

Files Coverage +/- Status
packages/sdk/src/cli/query/index.ts 49.4% +2.6% modified
packages/sdk/src/cli/query/repl-editor.ts 91.4% +91.4% added

SDK Configure Bundle Size

main (0be43dd) #895 (a76d4f3) +/-
configure-index-size 12.69KB 12.69KB 0KB
dependency-chunks-size 33.36KB 33.36KB 0KB
total-bundle-size 46.04KB 46.04KB 0KB

Runtime Performance

main (0be43dd) #895 (a76d4f3) +/-
Generate Median 2,683ms 2,603ms -80ms
Generate Max 2,775ms 2,656ms -119ms
Apply Build Median 2,702ms 2,625ms -77ms
Apply Build Max 2,815ms 2,662ms -153ms

Type Performance (instantiations)

main (0be43dd) #895 (a76d4f3) +/-
tailordb-basic 42,484 42,484 0
tailordb-optional 3,826 3,826 0
tailordb-relation 3,970 3,970 0
tailordb-validate 2,824 2,824 0
tailordb-hooks 5,689 5,689 0
tailordb-object 11,470 11,470 0
tailordb-enum 2,720 2,720 0
resolver-basic 9,239 9,239 0
resolver-nested 25,626 25,626 0
resolver-array 17,862 17,862 0
executor-schedule 4,244 4,244 0
executor-webhook 883 883 0
executor-record 4,746 4,746 0
executor-resolver 4,273 4,273 0
executor-operation-function 877 877 0
executor-operation-gql 879 879 0
executor-operation-webhook 898 898 0
executor-operation-workflow 2,290 2,290 0

Reported by octocov

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.

2 participants