feat: add elastic esql command group#254
Draft
Anaethelion wants to merge 10 commits into
Draft
Conversation
Exposes an internal setter so unit tests can inject a custom Transport instance (e.g. with maxRetries: 0) without going through the full initialisation path.
Thin wrapper around the shared Transport that executes ES|QL queries and surfaces structured EsqlError on API failures.
Renders ES|QL response columns/values as table, json, ndjson, csv, or tsv. Includes stats printing and partial-result warnings.
inject.ts rewrites an ES|QL query to append or merge a WHERE predicate.
saved-queries.ts handles named query persistence and {{placeholder}}
param substitution.
Provides completion/suggestion hints for ES|QL keywords and functions, used by the REPL.
- query: execute one or more ES|QL queries with format, time-filter, param substitution, and output-file options - watch: re-run a query on an interval, clearing the screen each cycle - tail: stream new rows matching a query as they arrive - check: validate query syntax without executing - save / queries: persist and list named queries
Launches when `elastic esql` is invoked on a TTY with no sub-command. Supports history, hints, and multi-line input.
registerEsqlCommands() assembles the `esql` command group. cli.ts lazy-loads it only when the first argument is `esql`, keeping startup fast for all other commands.
Covers client, formatter, inject, saved-queries, hints, REPL, and each sub-command (query, tail, check) including time-flag parsing and stats.
✅MegaLinter analysis: Success
See detailed reports in MegaLinter artifacts MegaLinter is graciously provided by OX Security |
watch.ts: remove unused handleError import that triggered @typescript-eslint/no-unused-expressions via a bare-expression hack. client.test.ts: replace real HTTP server + UndiciConnection approach with mock transports. UndiciConnection crashes under Bun (response.headers undefined at UndiciConnection.js:159). Auth header tests are rewritten to inspect the connection pool directly, which avoids any actual network I/O and works on both Node and Bun.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
elastic esqlcommand group with sub-commands:query,watch,tail,check,save, andquerieselastic esqlis invoked on a TTY with no sub-commandPorted from https://github.com/elastic/esqlcli.
Commits
The work is split into 9 atomic commits: transport test seam → ES|QL client → formatter → inject/saved-queries → hints → sub-commands → REPL → CLI wiring → tests.
Test plan
npm testpasses (build + unit + license)elastic esql query 'FROM <index> | LIMIT 5'returns resultselastic esqlon a TTY launches the REPLelastic esql --helplists all sub-commandsecho "FROM logs | LIMIT 1" | elastic esql query -