Skip to content

CLI: commands and output for scripts and coding agents - #4173

Merged
OAGr merged 11 commits into
mainfrom
cli-agent-tools
Oct 19, 2026
Merged

OAGr merged 11 commits into
mainfrom
cli-agent-tools

Conversation

@OAGr

@OAGr OAGr commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

First of four PRs that land the Squiggle Studio / relative values work. Merge order: this one, then relative values + Hub, then the Claude Code plugin, then Studio.

What

Makes the squiggle CLI usable by scripts and coding agents.

  • Includes Improve Squiggle CLI error handling and reporting #4102 (CLI error handling: non-zero exit codes, errors on stderr, error type headers, tests). Merging this PR with a merge commit also merges Improve Squiggle CLI error handling and reporting #4102.
  • run --json (values as compact JSON, with distributions summarized), --seed, --sample-count, --watch. Errors include structured locations, stack frames and hints.
  • check command: parse/compile/run without printing output, with warnings.
  • docs command: offline builtin documentation.
  • playground --print-url, agent-friendly help text, README, changeset.
  • squiggle-lang: sqValueToJson, error hints and code warnings (deterministic ports of the Squiggle AI heuristics).

Two small follow-ups to the CLI colors (only emit ANSI colors for TTYs; decide on colors in the entry point rather than at import time, because colors.ts ships in browser bundles) are in the Studio PR, since they sit on top of the integration branch.

🤖 Generated with Claude Code

OAGr and others added 8 commits March 23, 2026 09:38
- Set process.exitCode = 1 on all error paths (run, parse, print-ir)
  so scripts and CI can detect failures
- Output errors to stderr instead of stdout for proper stream separation
- Add error type classification matching the UI ("Compile Error",
  "Runtime Error") with colored headers
- Iterate individual errors from SqErrorList for better multi-error display
- Fix playground command: add missing `open` import
- Add top-level .catch() in index.ts for unhandled errors
- Wrap file-not-found errors in getLinker with user-friendly messages
- Add printError method to CliPrinter for stderr output

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add 28 tests covering all error paths: parse errors, runtime errors,
  compile errors, file-not-found, invalid imports, conflicting flags
- Test exit codes (1 on error, 0 on success) for run, parse, print-ir
- Test that errors go to stderr and success output goes to stdout
- Test error type classification headers (Compile Error, Runtime Error)
- Test stack traces are included in runtime errors
- Update cliHelpers.ts to capture process.exitCode (not just Commander errors)
- Fix file-not-found in loadSrc to use program.error() for clean output

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…tified-uncertainty/squiggle into cli-agent-tools

* 'squiggle-cli-error-handling' of https://github.com/quantified-uncertainty/squiggle:
  Add comprehensive CLI error handling tests
  Improve Squiggle CLI error handling and reporting
sqValueToJson converts values to compact JSON (distributions summarized as
mean/stdev/percentiles). Hints and warnings are deterministic ports of the
Squiggle AI heuristics. Registry exposes documentation for all functions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Errors include structured locations, stack frames and hints.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ngeset

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@OAGr
OAGr requested a review from berekuk as a code owner October 19, 2026 15:55
@github-project-automation github-project-automation Bot moved this to 🆕 To prioritize in Overview Oct 19, 2026
@changeset-bot

changeset-bot Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7faea20

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

This PR includes changesets to release 6 packages
Name Type
@quri/squiggle-lang Minor
@quri/squiggle-components Minor
@quri/prettier-plugin-squiggle Minor
vscode-squiggle Minor
@quri/versioned-squiggle-components Patch
@quri/squiggle-textmate-grammar 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

@vercel

vercel Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
quri-hub Ready Ready Preview Oct 19, 2026 4:06pm UTC
squiggle-components Ready Ready Preview Oct 19, 2026 4:06pm UTC
squiggle-website Ready Ready Preview Oct 19, 2026 4:06pm UTC
2 Skipped Deployments
Project Deployment Actions Updated
fermi-contest-2025-02 Ignored Ignored Preview Oct 19, 2026 4:06pm UTC
quri-ui Ignored Ignored Preview Oct 19, 2026 4:06pm UTC

Request Review

Comment thread packages/squiggle-lang/src/public/hints.ts Fixed
Comment thread packages/squiggle-lang/src/public/hints.ts Fixed
Comment thread packages/squiggle-lang/src/public/hints.ts Fixed
CodeQL flagged three js/polynomial-redos patterns in hints.ts. Strip strings
and line comments in a single pass, remove inline block comments with
indexOf, and check the "bare expression" parse error without `.*`. An
unterminated string now extends to the end of the line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread packages/squiggle-lang/src/public/hints.ts Fixed
OAGr and others added 2 commits October 19, 2026 09:02
getErrorHints takes { message, line }; the test type-checked only under
Jest, so tsc -b (and the Vercel builds) failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
/\w\s*:\s*[A-Z]/ matches the same strings as /\w+\s*:\s*[A-Z]/ without
retrying every suffix of a long word. Addresses CodeQL js/polynomial-redos.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

5 active (2 outdated) deployments
Preview – quri-hub — 7faea201 Deployed Oct 19, 2026 by vercel[bot]
Preview – squiggle-website — 7faea201 Deployed Oct 19, 2026 by vercel[bot]
Preview – squiggle-components — 7faea201 Deployed Oct 19, 2026 by vercel[bot]
Preview – fermi-contest-2025-02 — 721923c8 Deployed Oct 19, 2026 by vercel[bot]
Preview – quri-ui — 721923c8 Deployed Oct 19, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

2 participants