Skip to content

feat(cli): cut over use to source API#65

Merged
lentil32 merged 53 commits intomainfrom
feat/cli-source-api-cutover
Apr 10, 2026
Merged

feat(cli): cut over use to source API#65
lentil32 merged 53 commits intomainfrom
feat/cli-source-api-cutover

Conversation

@lentil32
Copy link
Copy Markdown
Contributor

@lentil32 lentil32 commented Apr 9, 2026

One-Line Summary

Replaces onequery use with a source-key based source API client that can describe, dry-run, and execute supported source operations through Connect.

User-Facing Changes

  • onequery use now requires --source <SOURCE_KEY> and resolves operations against the connected source instead of provider-specific markdown skills.
  • onequery use --source <SOURCE_KEY> now describes the source API surface, while --dry-run returns a redacted normalized plan before execution.
  • onequery use now supports source API pagination, slurp, include, silent, jq, typed field patching, raw field patching, and binary/text/JSON response rendering through the same command surface.
  • JSON mode now emits a source-API-shaped response object instead of the generic CLI success envelope, and text mode preserves verbatim text or binary output when the response allows it.
  • Source API support now runs through shared adapters for GitHub, Google Analytics, MongoDB, Mixpanel, PostHog, Sentry, and Amplitude.

Why This Changed

The previous onequery use flow mixed two unrelated responsibilities: markdown skill discovery and direct provider relay execution. That split duplicated source metadata across Rust, protobuf, and TypeScript, bypassed Connect for execution, and kept request validation, authorization, pagination, and output handling fragmented across the stack. Moving use onto a single source API contract makes the source descriptor, normalization rules, and execution path authoritative on the server, while keeping the CLI responsible for deterministic parsing and rendering.

How It Changed

  • Replaced the legacy use.proto contract with source_api.proto, added DescribeSourceApi, NormalizeSourceApi, and ExecuteSourceApi RPCs, and regenerated the CLI transport bindings.
  • Added CLI source API planning and rendering modules so onequery use resolves describe, dry-run, and execute modes from explicit state, then validates headers, fields, input, pagination, and selector rules locally before dispatch.
  • Added shared server-side source API registry, authorization, normalization, pagination, and adapter modules, then wired the CLI server Connect handlers to that flow.
  • Removed the old CLI-server use skill registry and direct provider relay path in favor of source-key based descriptor and execution handlers.
  • Tightened terminal output handling in the CLI so workflows keep request metadata with terminal output, paginated responses preserve final-page metadata, and broken-pipe writes exit cleanly instead of panicking.

Bug Fixes

  • Under --silent, JSON mode, and verbatim response modes, onequery use now preserves the intended source API output contract instead of rewrapping or dropping response semantics.
  • Under paginated source API execution, the assembled CLI response now keeps the final page request metadata and pagination token state.
  • Under closed or piped stdout/stderr, the CLI now exits cleanly on broken pipes instead of panicking while writing command output.
  • Source API content types are normalized before rendering so adapters do not produce inconsistent JSON/text/binary handling.

Extra Context / Decisions (Optional)

  • This PR is a hard cutover from the legacy provider-enum and skill-text model to the source API contract; the removed use transport and skill registry are not kept for backward compatibility.
  • docs/cli-source-api-spec.md is now the active design reference for this command surface, and docs/connect-migration-spec.md is removed.

Verification

  • bun run format
  • cargo test -p onequery-cli
  • bun run proto:check
  • bunx turbo test --json --filter=@onequery/cli-server --filter=@onequery/server
  • Rust coverage includes apps/cli/crates/onequery-cli/src/cli_tests.rs plus the source API, gateway, org, query, and output test modules covering parse outcomes, snapshots, pagination assembly, dry-run rendering, and output-write edge cases.
  • TypeScript coverage includes packages/cli-server/src/connect/service/source_api.test.ts, packages/cli-server/src/connect/service/conversions.test.ts, and packages/server/src/source-api/**/*.test.ts covering authorization, descriptor conversion, normalization, execution, pagination helpers, and adapter content-type handling.

Video / Screenshot (Optional)

  • N/A

lentil32 added 30 commits April 9, 2026 14:07
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0cfec105df

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@lentil32
Copy link
Copy Markdown
Contributor Author

lentil32 commented Apr 9, 2026

will fixl ater

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 59443ee99f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@lentil32 lentil32 merged commit ef8994e into main Apr 10, 2026
7 checks passed
@lentil32 lentil32 deleted the feat/cli-source-api-cutover branch April 10, 2026 07:34
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7ac2ba893f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +43 to +46
!timingSafeEqual(
Buffer.from(signature, "utf8"),
Buffer.from(expectedSignature, "utf8")
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Validate signature length before constant-time compare

decodeOpaquePageToken calls timingSafeEqual on user-supplied signature bytes without checking length first, but Node throws RangeError when buffer lengths differ. A malformed page token with a short/long signature will therefore raise an untyped exception instead of returning a deterministic SourceApiInvalidRequestError, which surfaces as an internal failure path once opaque-token pagination is used.

Useful? React with 👍 / 👎.

lentil32 added a commit that referenced this pull request Apr 10, 2026
You can install any of these versions: `npm install -g @onequery/cli@<version>`
## [0.1.22] - 2026-04-10
### 🚀 Features

- *(web)* Update PostHog connection guide (#62)
- Prepare landing deployment on cloudflare pages (#66)
- Readme self host priority (#67)
- *(cli)* Cut over use to source API (#65)
<!-- generated - do not edit -->
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.

1 participant