Skip to content

feat(cli): send x-taskless-cli-version header on service requests - #52

Merged
thecodedrift merged 1 commit into
mainfrom
jakob/oss-15-cli-version-header
Jul 7, 2026
Merged

feat(cli): send x-taskless-cli-version header on service requests#52
thecodedrift merged 1 commit into
mainfrom
jakob/oss-15-cli-version-header

Conversation

@thecodedrift

Copy link
Copy Markdown
Member

Closes #45.

The Taskless service gates whether it offers runtime rules on the requesting CLI's capability, which it infers from the CLI's version — but the CLI never told it. This makes the CLI declare its version on every request, so the service has a safe signal to make that call.

What changes

  • x-taskless-cli-version on every CLI→service request — a standing declaration, not a one-off. Added to the openapi-fetch client (rule generation, whoami), the reconcile fetch, and both device-auth-flow fetches (/auth/device, /auth/token). A request without the header is treated by the service as a pre-runtime CLI (the intended safe default; that fallback + the semver gate are the companion server-side change, out of scope here).
  • Single source of truth — new src/version.ts exports CLI_VERSION (from the __VERSION__ build define) and the header name; telemetry.ts now imports it instead of re-declaring.
  • Telemetry — the CLI version is already emitted with the CLI's own telemetry (cliVersion on every event), so usage is recorded client-side rather than inferred when the request lands. No behavior change needed there; centralizing the constant keeps the header and telemetry in lockstep.

Version threshold

The service begins offering runtime rules at CLI 0.10.0 — the release that ships the taskless check runtime harness (landed in #47). The included changeset is a minor bump, so this and the harness ship together as 0.10.0, lining the threshold up with the actual capable release.

Notes for reviewers

  • Verified the header + resolved version are baked into the built bundle, and added an integration test asserting a real reconcile request carries a non-empty, non-"unknown" x-taskless-cli-version.
  • typecheck + lint + full test (340) green.

Refs OSS-15.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TEuUE3F23dgEyrkGPq3FiM

Copilot AI review requested due to automatic review settings July 6, 2026 21:04

Copilot AI left a comment

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.

Pull request overview

Adds a consistent CLI→service version signal by sending an x-taskless-cli-version header on all Taskless service requests, using a centralized version constant, and verifies the behavior via an integration test (supporting the service-side capability gate for runtime rules at 0.10.0).

Changes:

  • Introduces src/version.ts as the single source of truth for CLI_VERSION (build-injected) and CLI_VERSION_HEADER.
  • Attaches x-taskless-cli-version to all Taskless service request paths (openapi-fetch client, reconcile fetch, and device auth flow).
  • Adds an integration test asserting reconcile requests include a non-empty, non-"unknown" CLI version header.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/cli/test/runtime-check.test.ts Captures request headers in the reconcile mock server and asserts x-taskless-cli-version is present and meaningful.
packages/cli/src/version.ts Adds centralized CLI version + header-name constants for reuse across the CLI.
packages/cli/src/telemetry.ts Imports CLI_VERSION from the new version module to keep telemetry consistent with request headers.
packages/cli/src/auth/device-flow.ts Includes x-taskless-cli-version on /auth/device and /auth/token requests.
packages/cli/src/api/reconcile.ts Includes x-taskless-cli-version on reconcile requests.
packages/cli/src/api/client.ts Adds the version header to the shared openapi-fetch client used by rule generation and whoami.
.changeset/cli-version-header.md Declares a minor bump for @taskless/cli and documents the new header behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

The Taskless service gates runtime-rule delivery on the requesting CLI's
capability, inferred from its version — but the CLI never declared it. Send an
x-taskless-cli-version header on every CLI->service request so the service can
make that call; a request without it is treated as a pre-runtime CLI.

- Add src/version.ts as the single source for CLI_VERSION (from the __VERSION__
  build define) and the header name; telemetry.ts now imports it.
- Attach the header on the openapi-fetch client (rule generation, whoami),
  the reconcile fetch, and both device-auth-flow fetches.
- The CLI version is already emitted with telemetry (cliVersion on every event),
  so usage is recorded client-side rather than inferred at the service.

The capability threshold is 0.10.0 (the release that ships the taskless check
runtime harness), so this lands as a minor bump via changeset.

Closes #45. Refs OSS-15.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@thecodedrift
thecodedrift force-pushed the jakob/oss-15-cli-version-header branch from 7d97951 to 252b8aa Compare July 7, 2026 00:36
@thecodedrift
thecodedrift merged commit da74920 into main Jul 7, 2026
4 checks passed
@thecodedrift
thecodedrift deleted the jakob/oss-15-cli-version-header branch July 7, 2026 17:17
thecodedrift added a commit that referenced this pull request Jul 7, 2026
Placeholder anchor for the org-UUID work (blocked on the API team).

Context: the CLI currently identifies the org only by the numeric `orgId` JWT
claim (decodeOrgId -> number; sent in the /cli/api/rule body; telemetry group
key). The runtime-rules gate / Auth needs the org UUID, which the CLI has no
source for yet.

Dependency: the API team decides where the CLI reads the org UUID — likely a new
JWT claim (e.g. orgUuid) or a whoami field. Once that lands, the CLI work
mirrors the x-taskless-cli-version PR (#52): resolve the UUID, send it on
service requests, and stamp it into telemetry. Add a changeset when implemented.
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.

Send x-taskless-cli-version header on service requests (runtime-rules capability gate)

2 participants