CLI reference / 7 minute read
Scripted runs with JEXL
Run Elyxis commands from a script, check Assistant responses, and export JSON reports for repeatable tests.
Last verified 2026-11-13Write your first script
JEXL (Java Expression Language) lets you save CLI actions and checks in a .jexl file. Each cli.run(...) sends one natural-language request or slash command and waits for it to finish. Use variables to keep results and conditions to decide what should happen next.
Save this example as check-environment.jexl. It uses the beta Environment Ready to explore. For another setup, replace that name in both places with the name of an Environment you can access.
cli.selectEnvironment("Ready to explore");
cli.print("Checking the Environment list");
var result = cli.run("List the environments I can access.");
cli.assertMatches(result.text, "Ready to explore",
"Expected Ready to explore in the Environment list");
cli.print("Passed the Environment list check");
cli.selectEnvironment(...) accepts an exact, case-sensitive name or a stable Environment ID. If two accessible Environments share a name, use the ID for selection and the expected displayed name for the assertion.
Review a script before running it. Script actions use your account's permissions and can change real resources. A later failure leaves completed actions in place.
Run interactively or in batch mode
From the directory containing the script, start the CLI and enter this at Elyxis >.
/run check-environment.jexl
An interactive run uses the current session. The example explicitly selects its Environment. When it finishes, you can continue working at the CLI prompt.
For an unattended run, sign in to the CLI first, close the CLI with /exit, then launch it with --batch. Use the path to your executable if elyxis-cli is unavailable on your shell's path.
elyxis-cli --batch check-environment.jexl
Batch mode verifies your saved login and starts a fresh session. The script selects an Environment before its first Assistant request. The process exits with code 0 on success and a nonzero code on failure. A missing or expired login, failed action or assertion, unexpected question, or 10-minute timeout can stop the run.
In a terminal that supports cursor movement, the progress display updates in place and clears when the current action finishes. In a basic terminal or with redirected output, progress appears line by line on standard error. Messages from cli.print(...) stay visible between actions, so you can see which case is running and which checks have passed.
Check Northstar records
Try a scripted Willowbrook check after the walkthrough has prepared an onboarding review App. Save this as check-northstar.jexl. It checks that DOC-006 is pending internal approval and that COM-005 is cited as the latest inbound message at the cutoff. Guided beta walkthrough
cli.planCases(["Willowbrook at the October 14 cutoff"]);
cli.selectEnvironment("Ready to explore");
cli.testCase("Willowbrook at the October 14 cutoff", () -> {
cli.print("Checking Willowbrook onboarding on October 14");
var result = cli.run(
"Review Willowbrook Service Desk Onboarding as of noon UTC on October 14, 2026. "
+ "Check the requirements pack and find the latest inbound client message at that cutoff. "
+ "Give each finding on its own line. Start the line with the record ID, then give its status or what it represents. "
+ "Use the label Pending internal approval for a received document that still needs approval. "
+ "Use the label Latest inbound client message for the communication. "
+ "Do not send messages or change business records.");
cli.assertMatches(result.text, "(?i)\\bDOC-006\\b[^\\r\\n]*Pending internal approval",
"Expected DOC-006 to be pending internal approval");
cli.assertMatches(result.text, "(?i)\\bCOM-005\\b[^\\r\\n]*latest inbound",
"Expected COM-005 to be the latest inbound message");
cli.print("Passed the Willowbrook cutoff check");
});
result.text holds the Assistant's Markdown answer from the response. If the answer has no Markdown, the CLI uses result.summary as a fallback. Use result.summary directly when your check specifically targets the short recap. These fields are independent of terminal colors and progress output. Successful slash commands return a command result with empty text and summary.
cli.assertMatches searches the text for a Java regular expression. The (?i) flag ignores case and \\b in the JEXL string passes a word boundary to the regex. The example keeps each record ID and its finding on the same line so an unrelated mention of the ID cannot satisfy the check by itself. Match stable evidence such as IDs or figures when the surrounding wording can vary.
Handle a clarification or confirmation
An action that needs a reply stops the script unless that action supplies a callback. This example answers a clarification about which project to review. The callback runs only when the Assistant asks a question and can run more than once for a request.
cli.selectEnvironment("Ready to explore");
var result = cli.run(
"Review Willowbrook onboarding as of noon UTC on October 14, 2026. "
+ "Include supporting record IDs. Do not send messages or change business records.",
question -> {
var text = question.text.toLowerCase();
if (question.type == "clarification" && text.contains("which project")) {
return cli.reply("Willowbrook Service Desk Onboarding (PRJ-002)");
}
return cli.fail("Unexpected " + question.type + " during onboarding review");
});
cli.assertMatches(result.text, "Willowbrook Service Desk Onboarding",
"Expected the Willowbrook Service Desk Onboarding review");
For question.type == "confirmation", return cli.approve() or cli.deny() only after checking question.text against the action you expect. cli.fail(...) stops the script with your reason and the script location.
Export a JSON report
Run the Northstar example with a new report filename. If the file already exists, the CLI stops before executing the script.
elyxis-cli --batch check-northstar.jexl --report northstar-report.json
Declare case names once, before setup, with cli.planCases([...]). Put each case's actions and assertions inside cli.testCase(name, () -> { ... }). If a case fails, the batch stops and reports any planned cases that never ran as skipped. A script without planned cases still reports the overall outcome and action count.
A successful run of the Northstar example produces a report like this. Durations are in milliseconds.
{
"schemaVersion": 1,
"status": "passed",
"exitCode": 0,
"durationMillis": 13420,
"actionsCompleted": 1,
"counts": { "total": 1, "passed": 1, "failed": 0, "skipped": 0 },
"cases": [
{ "name": "Willowbrook at the October 14 cutoff", "status": "passed", "durationMillis": 12940 }
]
}
A failed run includes a diagnostic with the reason. A case that fails while running also gets its own diagnostic. actionsCompleted counts successful cli.run(...) calls, so the count can include the request whose response later fails an assertion.
The report omits Assistant responses by default. Add --include-results along with --report to capture eligible responses as redacted text and summary fields. Review the export before sharing it because it can contain business data.