@withgauge/cli 0.8.0 → 0.9.0-internal.20261020.5495b54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,65 +1,818 @@
1
1
  # @withgauge/cli
2
2
 
3
3
  `gauge` — the [Gauge](https://agents.withgauge.com) command-line interface.
4
- Manage your eval sets, Agent Preference prompts, run presets, and agent runs,
5
- and watch runs live from your terminal.
4
+ Manage your eval sets, Agent Preference prompts, and agent runs, and watch runs
5
+ live from your terminal.
6
6
 
7
7
  ```sh
8
8
  npm install -g @withgauge/cli
9
- gauge onboard # sign in, create a workspace, seed starter measurements
9
+ gauge update # update the CLI to the latest published version
10
+ gauge onboard # sign in and create a workspace (account only)
10
11
  gauge auth login # (or just sign in)
11
12
  gauge orgs use <org> # set your default organization
13
+ gauge init # initialize a workspace; local is the default
14
+ gauge init --hosted # set a private hosted backend preference
15
+ gauge init --cases # optionally scaffold shared gauge-cases/
12
16
  ```
13
17
 
14
- Requires Node.js ≥ 22.12.
18
+ Requires Node.js ≥ 22.13.
19
+
20
+ ## Workspace and local storage
21
+
22
+ `gauge init --local` works without Git. It writes a minimal shared manifest:
23
+
24
+ ```json
25
+ { "version": 2, "inputs": {} }
26
+ ```
27
+
28
+ The private `.gauge/config.json` contains `{ "version": 1, "backend": "local" }`.
29
+ `.gauge/.gitignore` ignores all workspace state. SQLite in `.gauge/gauge.sqlite`
30
+ stores saved measurements, revisions, launch/session summaries, and published
31
+ analyses. Raw transcripts, normalized events, diffs, and diagnostics remain under
32
+ `.gauge/runs/`; input blobs and batch lifecycle files remain alongside them.
33
+
34
+ Moving the workspace preserves identity. Fresh clones or linked worktrees start
35
+ independently; switching Git branches keeps local history. Do not treat `.gauge/`
36
+ as a disposable cache. Credentials and user preferences stay user-level.
37
+ `gauge run repair --local` rebuilds session summaries from durable artifacts while
38
+ preserving authored measurements and analyses. It does not rerun sessions or judges.
39
+
40
+ ## Analyze local sessions
41
+
42
+ Your coding agent reads evidence and publishes a structured analysis:
43
+
44
+ ```sh
45
+ gauge instructions session-analysis --local
46
+ gauge run analysis schema --local > analysis.schema.json
47
+ gauge run get <run-id> --logs --local -o json
48
+ # Author analysis.json against the printed schema and session evidence.
49
+ gauge run analysis save <run-id> --file analysis.json --local
50
+ gauge run insight <run-id> --local
51
+ ```
52
+
53
+ Publication validates the versioned schema, criterion coverage, and evidence
54
+ references, then saves findings, product choices, and criterion judgments in one
55
+ transaction. Reanalysis creates a revision and updates the current analysis.
56
+ `run insight` leads with Friction, Objections, and Opportunities in either backend.
57
+ A Markdown file alone does not mark a session analyzed. Unknown future schema
58
+ versions produce an upgrade error without altering saved data. Database schema
59
+ migrations preserve analyses and never silently reinterpret old judgments.
60
+
61
+ ## Local Docker runtime
62
+
63
+ Local runs need Docker running Linux containers and an agent credential. Linux
64
+ is the container OS, not a requirement for your host: Docker Desktop on macOS
65
+ provides a Linux daemon and shares the local files used by sessions.
66
+ Install the runtime without a Gauge account or a source checkout:
67
+
68
+ ```sh
69
+ gauge local runtime pull
70
+ gauge local runtime inspect -o json
71
+ gauge run --local --dry-run
72
+ ```
73
+
74
+ Each CLI release pins its tested public `ghcr.io/gauge-sh/gauge-runtime` image by
75
+ immutable digest. Inspection reports the reference, local image ID, registry
76
+ digest, contract, platform, and readiness errors. `ready` covers local image
77
+ metadata; agent credential checks happen separately. Neither inspection nor a
78
+ dry run downloads an image. `pull` explicitly downloads the supported image;
79
+ previously pulled images can be reused offline (agent calls still need network
80
+ access). Pull progress goes to stderr so JSON output remains parseable.
81
+
82
+ The runtime includes native `linux/amd64` and `linux/arm64` images. Docker selects
83
+ the matching image on Intel/AMD or Apple Silicon/ARM machines. No architecture
84
+ emulation is needed. Docker must be able to bind-mount this machine's temporary
85
+ and input directories; an unrelated remote Docker server cannot access them.
86
+ On Windows, run the CLI inside WSL because Gauge uses Unix sockets and UID/GID.
87
+
88
+ ## Local agent credentials
89
+
90
+ Local provider credentials are separate from a Gauge account and hosted credential
91
+ brokering. Use native harness logins or configure a named environment reference:
92
+
93
+ ```sh
94
+ gauge local profiles set work --agent CODEX_CLI --provider openai --auth api_key --env TEAM_OPENAI_KEY
95
+ gauge local profiles use work
96
+ gauge local profiles inspect work -o json
97
+ gauge run --local --profile work --dry-run -o json
98
+ ```
99
+
100
+ `--env` takes the variable's name, never its secret value. Profiles store only
101
+ references; list and inspect output do not expose credentials. Update a profile
102
+ with `set ... --replace` or remove it with `remove <profile>` without deleting
103
+ the native login. Local readiness checks do not verify provider acceptance or
104
+ model access. Use `gauge local profiles --help` for profile commands and
105
+ `gauge instructions --local` for the local workflow.
106
+
107
+ ## Anonymous CLI telemetry
108
+
109
+ The installed CLI collects command usage by default to help improve Gauge.
110
+ Opt out for your user account or for a single process:
111
+
112
+ ```sh
113
+ gauge telemetry disable
114
+ gauge telemetry status
115
+ gauge telemetry enable
116
+ GAUGE_TELEMETRY_DISABLED=1 gauge run --verify
117
+ ```
118
+
119
+ The environment variable overrides the saved preference. These controls work
120
+ without an account or network access and support `-o json`. They apply to CLI
121
+ command telemetry; authenticated Gauge API requests have separate server-side
122
+ usage analytics.
123
+
124
+ Each `cli_command_invoked` event contains only the canonical command name
125
+ (for example, `run list`), its UTC invocation timestamp, CLI version, and a
126
+ random installation UUID. Arguments, flag values, file paths, prompts, file
127
+ contents, environment variables, errors, and account identifiers are excluded.
128
+ The UUID is independent of login and is never linked to your Gauge account.
129
+ This is pseudonymous usage tracking: an installation can be recognized across
130
+ commands, but no personal identity is sent. HTTP requests necessarily expose a
131
+ source IP to the receiving infrastructure; event properties mask IP addresses,
132
+ disable GeoIP enrichment, and disable person-profile creation.
133
+
134
+ Preferences live in `~/.config/gauge/telemetry.json` and the UUID in
135
+ `~/.config/gauge/telemetry-id` (respecting `XDG_CONFIG_HOME`). They are shared
136
+ across repositories, independently of each repository's `.gauge/` results.
137
+ Deleting `telemetry-id` resets the identity on the next collected command.
138
+ Consumers are installations, not necessarily individual people. Session
139
+ analysis can group an installation's events using a 30-minute inactivity gap;
140
+ the CLI does not generate a different identity for each invocation.
141
+
142
+ Collection occurs when a parsed command is about to run, including commands
143
+ whose handlers subsequently fail. Help, version, parsing errors, telemetry
144
+ controls, and source development runs are excluded. A detached worker handles
145
+ all telemetry storage and network access, with a two-second request timeout
146
+ and a three-second worker lifetime. Commands never wait for delivery, and
147
+ failures are silent. There are no retries or offline queue, so events may be
148
+ lost. Corrupt or unreadable preferences suppress collection until repaired.
149
+
150
+ Events go to Gauge's existing PostHog project using its public ingestion key.
151
+ The [capture API](https://posthog.com/docs/api/capture) and
152
+ [anonymous event controls](https://posthog.com/docs/product-analytics/capture-events#advanced-anonymous-vs-identified-events)
153
+ describe the transport and person-profile behavior.
154
+
155
+ ## Local or hosted
156
+
157
+ Execution backend is independent of definition source. Resolve an explicit
158
+ `--local`/`--hosted` flag, then `.gauge/config.json`, user preference, and finally
159
+ local. Signing in does not change the backend. `gauge.json` is the shared project
160
+ manifest for named inputs, optional case discovery, and GitHub checks. It never
161
+ contains the execution preference. Git is optional for workspace initialization.
162
+
163
+ | Workflow | Local | Hosted |
164
+ |---|---|---|
165
+ | Skill, npm package (CLI or SDK), and `files` inputs | yes | yes |
166
+ | Docs supplied as `files` inputs | yes | yes |
167
+ | Eval and Agent Preference cases in `gauge-cases/` | yes (you read the sessions) | yes (judged) |
168
+ | `run`, `run list`, `run compare --local`, `models list`, `cleanup`, `feedback` | yes | yes |
169
+ | Binary, website, and MCP inputs | no | yes |
170
+ | Saved eval sets and preference prompts | yes | yes |
171
+ | Findings and summary queries | yes, supported fields | yes |
172
+ | Personas, recurring schedules, PR checks | no | yes |
173
+ | Optimizations (managed docs rewriting) | no | yes |
174
+ | Stored credentials for MCP servers and connections | no | yes |
175
+ | Additional reporting datasets, dashboards, org settings | no | yes |
176
+
177
+ Local runs need Docker and the agent's own login (`claude` or
178
+ `ANTHROPIC_API_KEY` for Claude Code; `codex login` for Codex, Pi, and
179
+ OpenCode). They do not need a Gauge account. Hosted runs need a Gauge account
180
+ (`gauge onboard`) and use credits. In local mode, a hosted-only command says so
181
+ and prints the next step.
182
+
183
+ For coding agents, we recommend the
184
+ [`gauge-agents` skill](https://github.com/gauge-sh/gauge-skills/tree/main/gauge-agents).
185
+ It makes Gauge CLI guidance and repository setup workflows discoverable in future
186
+ sessions. Install it separately from repo setup, running from your project root:
187
+
188
+ ```sh
189
+ gauge install-skill
190
+ ```
191
+
192
+ Select your coding agent and installation scope in the installer. Project scope
193
+ adds skill files to this repo; global scope makes the skill available across projects.
194
+ The command runs the pinned `skills@1.5.0` installer through npx and forwards its
195
+ prompts and output. For automated installation after choosing an agent:
196
+
197
+ ```sh
198
+ gauge install-skill --agent claude-code --yes # this project
199
+ gauge install-skill --agent codex --global --yes # across projects
200
+ ```
201
+
202
+ Repeat `--agent` to target multiple agents. `--yes` requires an explicit agent
203
+ target; `--copy` copies files instead of creating symlinks.
15
204
 
16
205
  ## Usage
17
206
 
18
207
  ```sh
19
208
  gauge status # the org at a glance
20
- gauge evals list # judged agent-experience measurements
21
- gauge preference list # Agent Preference prompts and measurements
22
- gauge presets list # run configurations (repo × persona × agents × skills × MCP)
209
+ gauge eval list # saved eval sets
210
+ gauge preference list # saved Agent Preference prompts
23
211
  gauge models list # supported model × harness × provider targets
24
- gauge evals attach <id> --preset <presetId> # schedule a preset on an eval (prints the bill first)
25
- gauge evals run <id> # launch now (ORG-funded, credit-gated)
26
- gauge runs watch <run-id> # follow a run as the agent works
212
+ gauge eval edit <id> --cadence weekly --samples 3 # when and how much it runs
213
+ gauge run --eval <id> # launch now (ORG-funded, credit-gated)
214
+ gauge run watch <run-id> # follow a run as the agent works
27
215
  gauge stats rankings -o json # brand rankings (share of voice) as JSON
28
216
  gauge query -d ecosystem -m installs,install_rate -o json # a flexible report
29
217
  ```
30
218
 
219
+ `gauge instructions` prints a Gauge overview, CLI setup and usage rules, and
220
+ roughly 100 words of essential guidance per module. Each summary points to
221
+ `gauge instructions <topic>` for the full page. `gauge --help` points agents at
222
+ it, or write the file into the repo with `gauge instructions --install`.
223
+ The text ships inside the CLI, so it
224
+ never drifts from the commands it describes.
225
+
226
+ Use `gauge instructions run` before writing evals or starting runs: it covers
227
+ developer tasks, model selection, observable judging criteria, and a complete
228
+ migration example. Use `gauge instructions eval` and `gauge instructions preference` to save eval sets and
229
+ preference prompts, and `gauge instructions session-analysis` to investigate
230
+ product choices, source exposure, and interventions, from individual traces to
231
+ larger cohorts.
232
+ Use `gauge instructions optimization` for the full optimization workflow.
233
+ `gauge instructions --list` shows available topics.
234
+ `gauge instructions run --install` installs the eval guidance as a local skill.
235
+
31
236
  Run `gauge --help` (or `gauge <command> --help`) for the full command set:
32
- evals, preference, presets, models, personas, skills, mcp, cycles, repos, runs,
33
- experiments, batches, brands, tags, actions, impl, dashboards, members, org,
34
- provider keys, billing, usage, stats, query, and more.
35
-
36
- **Run presets** are the unit of configuration: an eval set or preference
37
- prompt runs whatever presets are attached to it, every cycle. `gauge presets
38
- create --name api-main --repo https://github.com/acme/api --agent
39
- claude-code:claude-opus-4-8 --skill acme-cli@1.2.0` authors one;
40
- `gauge evals attach` / `gauge preference attach` schedules it. Attaching
41
- spends money on a schedule, so `attach` and `run` print the per-cycle run
42
- arithmetic and ask before acting (`--yes` skips the prompt for scripts).
237
+ run, eval, preference, models, personas, skills, mcp, repos, optimizations,
238
+ brands, tags, actions, dashboards, members, org, provider keys,
239
+ billing, usage, stats, query, and more.
240
+
241
+ ## Run committed Markdown evals
242
+
243
+ File evals keep the task, run settings, and judged criteria in Git. Create
244
+ `gauge-cases/healthcheck.md` with YAML frontmatter and a Markdown task body:
245
+
246
+ ```markdown
247
+ ---
248
+ criteria:
249
+ - name: Healthcheck responds
250
+ rubric: The endpoint returns HTTP 200 without authentication.
251
+ config:
252
+ repoUrl: https://github.com/acme/app
253
+ repoRef: main
254
+ agents:
255
+ - agent: CODEX_CLI
256
+ ---
257
+
258
+ Add a /health endpoint and run the relevant app checks.
259
+ ```
260
+
261
+ Check your setup, then commit the files before planning and running with Git inputs:
262
+
263
+ ```sh
264
+ gauge run --verify # local; includes uncommitted working-tree edits
265
+ gauge run --verify -o json # versioned global/per-input yes/no/unknown checklist
266
+ gauge run --dry-run
267
+ gauge run --yes
268
+ gauge run wait <request-id> -o json
269
+ ```
270
+
271
+ Cases default to `gauge-cases/**/*.md`. `--files` accepts quoted paths/globs and overrides
272
+ that convention for `--dry-run` and `run`. Interactive CLI launches snapshot current
273
+ working-tree definitions in either backend, including uncommitted edits. Selected
274
+ filesystem inputs are packaged for local execution or hosted upload; explicit remote
275
+ artifacts retain their declared source. GitHub checks fetch committed definitions.
276
+ Content digests identify the exact bytes separately from Git provenance.
277
+ Each case owns its agents, models, consumer repository/ref, Persona and criteria.
278
+ The optional `config.inputs` selects named inputs; all attach by default.
279
+
280
+ `verify` reads the repository's current files, including non-ignored untracked files,
281
+ without login, network access, a PR, built CI artifacts, or sandbox compute. It checks
282
+ configuration, case input references, Git input paths, and recognizable workflow
283
+ checkout/upload declarations. An input-only repository with no cases is valid setup.
284
+ Each attempted global/per-input check reports `yes` (established locally), `no`
285
+ (a definite problem), or `unknown` (a specific static question could not be resolved,
286
+ such as an expression-based artifact name or a referenced reusable workflow).
287
+ Missing optional configuration and zero cases are informational findings, excluded
288
+ from checklist counts. Eligible workflow triggers are checked as declarations;
289
+ event filters and runtime conditions are not evaluated against a candidate PR.
290
+ Live input delivery, artifact contents, sandbox execution, App activation, and
291
+ account settings are outside this command's scope and do not create unknown rows.
292
+ Exit 1 means at least one `no`; exit 0 means no definite static problem was found.
293
+ No workflow code is executed.
294
+
295
+ `gauge run --verify -o json` writes exactly one JSON object to stdout, including on
296
+ validation failure. The versioned report provides:
297
+
298
+ - `version: 1` and `mode: "local-static"` identify the report contract and scope.
299
+ - `status` is `failed` if any check is `no`, otherwise `incomplete` if any check is
300
+ `unknown`, otherwise `passed`. It describes static checks only.
301
+ - `summary` contains `yes`, `no`, and `unknown` counts.
302
+ - `global` and `inputs[].checks` contain checks with stable `id`, `state`, and
303
+ explanatory `detail` fields; `inputs[].name` identifies each input.
304
+ - `facts.configFilePresent` and `facts.caseCount` expose discovered facts without
305
+ parsing prose. A `null` value means inspection did not reach that fact; zero cases
306
+ is distinct from case discovery being skipped or failing.
307
+ - `info` contains informational findings with stable `id` and `detail` fields.
308
+ - `notChecked` lists excluded capabilities as machine-readable identifiers.
309
+
310
+ For example, an agent can select unresolved checks with:
311
+
312
+ ```sh
313
+ gauge run --verify -o json | jq '{status, facts, global: [.global[] | select(.state != "yes")], inputs: [.inputs[] | {name, checks: [.checks[] | select(.state != "yes")]}]}'
314
+ ```
315
+
316
+ An optional `gauge.json` declares inputs produced by your normal CI or committed
317
+ alongside your product:
318
+
319
+ ```json
320
+ {
321
+ "version": 2,
322
+ "org": "my-org",
323
+ "inputs": {
324
+ "cli": {
325
+ "type": "npm-package",
326
+ "source": { "type": "github-actions", "workflow": ".github/workflows/package.yml" },
327
+ "path": "*.tgz",
328
+ "install": "environment"
329
+ },
330
+ "docs": {
331
+ "type": "files",
332
+ "source": { "type": "git" },
333
+ "paths": ["docs/**/*.md"]
334
+ }
335
+ }
336
+ }
337
+ ```
338
+
339
+ Gauge waits for your PR build and tests its uploaded artifacts. Keep the workflow's
340
+ existing checkout settings, including GitHub's default merge checkout. Omit
341
+ `source.artifact` when the workflow uploads one artifact, or select it by name.
342
+
343
+ For automatic checks, connect the Gauge GitHub App with repository access and
344
+ Actions read permission. Set `org` and enable the repository and target branches
345
+ in **Settings → GitHub**. Waiting for inputs starts no sessions and spends no
346
+ session credits.
347
+ Fork pull requests are disabled by default. Check **Allow fork pull requests** to let
348
+ workspace members authorize an evaluation from its GitHub check. Authorization
349
+ covers one PR revision and uses workspace credits; new revisions and explicit
350
+ reruns require fresh approval. Configured inputs determine when an authorized
351
+ evaluation is ready to run.
352
+ A failed run or absent/expired artifact returns an actionable input failure.
353
+ Absent runs have a five-minute discovery grace period; known running or queued
354
+ CI can continue past an hour. Abandoned requests expire after seven days. Reruns retain captured bytes. CI metadata reports a revision; it
355
+ does not independently prove which checkout the workflow compiled.
356
+
357
+ To run automatic PR checks only when relevant files change, add `checks` to
358
+ `gauge.json`:
359
+
360
+ ```json
361
+ "checks": {
362
+ "paths": ["agents/**", "docs.json", "snippets/**"]
363
+ }
364
+ ```
365
+
366
+ Paths are repository-relative, case-sensitive globs; matching any pattern runs
367
+ the checks. `**` matches nested directories, including hidden files. Use 1–32
368
+ patterns; exclusions (`!`) are not supported. Changes to `gauge.json` or your
369
+ configured case paths always count. Deleted files and both names of renamed
370
+ files are included. Without root `checks`, every eligible PR update reaches case
371
+ selection.
372
+
373
+ With CLI 0.16.0 or later, a case can narrow its own automatic PR triggers in its
374
+ Markdown frontmatter (alongside its other `config` settings):
375
+
376
+ ```yaml
377
+ config:
378
+ agents:
379
+ - agent: CODEX_CLI
380
+ checks:
381
+ paths: ["cli/**", "packages/shared/**"]
382
+ ```
383
+
384
+ Root `checks.paths`, when present, must match first. The App then runs matching
385
+ cases and all cases without a filter. Changes to `gauge.json` select every case;
386
+ editing a case selects that case regardless of its filter. If no cases match,
387
+ the check is skipped before preparing inputs or reserving credits. `config.inputs`
388
+ only chooses inputs; it does not define change triggers.
389
+
390
+ The first check uses the PR diff. After a passing evaluation, later updates
391
+ compare against that evaluated commit, so unrelated follow-up edits can skip.
392
+ A failed or unfinished evaluation, a changed target branch, or an unavailable
393
+ or incomplete diff causes a run. Skipped checks start no sessions and reserve
394
+ no credits. GitHub's rerun action runs regardless of paths; explicit CLI runs
395
+ also ignore this automatic-check filter.
396
+
397
+ File inputs stay outside the consumer repository and their paths are provided to
398
+ the agent. npm packages install with ordinary npm using the VM's Node/npm runtime.
399
+ `install` defaults to `environment`: a separate tools directory with the package's
400
+ own declared commands on PATH, including login shells. `workspace` adds a consumer
401
+ application dependency and accepts libraries without commands. Transitive registry
402
+ dependency ranges remain live. Plan output shows the installation destination and,
403
+ when a previous matching preparation captured it, command metadata. Otherwise it
404
+ reports that commands will be determined during preparation; planning never downloads
405
+ archives or starts VMs.
406
+
407
+ Native executables use `type: "binary"`, with already unpacked files in a GitHub
408
+ Actions artifact (or small committed Git files):
409
+
410
+ ```json
411
+ "gh": {
412
+ "type": "binary",
413
+ "source": {
414
+ "type": "github-actions",
415
+ "workflow": ".github/workflows/package.yml",
416
+ "artifact": "gh-linux"
417
+ },
418
+ "paths": ["dist/**"],
419
+ "platform": "linux-x64",
420
+ "commands": { "gh": "dist/bin/gh" }
421
+ }
422
+ ```
423
+
424
+ Paths are relative to the uploaded artifact root. Use your normal PR build;
425
+ for `actions/upload-artifact@v7`, use `archive: true`. Include companion files in
426
+ `paths` and explicitly map 1–32 command names to ordinary selected files. Gauge
427
+ validates Linux x86-64 ELF executables in its isolated artifact processor, restores
428
+ executable permissions, preserves the bundle outside the consumer repository, and
429
+ exposes the commands on PATH, including login shells. A candidate command overrides
430
+ an installed product command with the same name; two inputs selected by the same
431
+ case cannot expose the same command (including captured npm environment commands).
432
+
433
+ The first version supports ELF executables and PIE binaries compatible with the
434
+ consumer Linux runtime. It does not unpack nested release archives, install OS
435
+ packages, alter library search paths, or run arbitrary installation/version-check
436
+ commands. Prefer a static binary or build against a compatible Linux runtime;
437
+ header validation cannot prove shared-library compatibility. Scripts, macOS,
438
+ Windows, and ARM executables are unsupported. A missing loader/library encountered
439
+ when the agent invokes the command appears in session execution evidence, not in
440
+ static validation. Harness/runtime names (including shells, Node/npm, Python, Git,
441
+ archive/setup utilities, and agent commands) are reserved; use a different alias
442
+ for such a candidate. `GAUGE_INPUTS` gives the preserved bundle path.
443
+
444
+ A Skill input has `type: "skill"` and `path: "skills/product"`, or a path to a ZIP,
445
+ `.tar.gz`, or `.tgz` whose root contains `SKILL.md`. Use `path: "."` for a Skill at
446
+ the source root. Gauge validates and extracts selected archives in isolation and
447
+ stages the Skill in the coding agent's native discovery location. File inputs use
448
+ `paths` to select committed files or files inside an Actions artifact.
449
+
450
+ Gauge tests the artifact uploaded by your PR's successful build. Keep your
451
+ existing checkout settings. The GitHub check links to the selected build;
452
+ rerun Gauge to test the latest build.
453
+
454
+ ### Run from your own CI or local build
455
+
456
+ With CLI 0.18.0 or later, supply built inputs directly to run without the GitHub App:
457
+
458
+ ```sh
459
+ gauge --org my-org run --input product-analytics=./dist/skill.zip --yes -o json > request.json
460
+ gauge --org my-org run wait "$(jq -er '.runRequestId' request.json)" --check -o json > results.json
461
+ ```
462
+
463
+ `--check` fails the job unless the verdict is `PASSED` or `MEASURED`. Without
464
+ it, `run wait` exits 0 once the request settles, whatever the verdict.
465
+
466
+ Set `GAUGE_API_TOKEN` as a CI secret and replace `my-org` with your workspace slug.
467
+ This can run immediately after your build in the same CI job.
468
+
469
+ Repeat `--input name=path` for each input. Skills accept a directory containing
470
+ `SKILL.md` or a ZIP/tar.gz archive; npm inputs accept a packed `.tgz`. Files and
471
+ binary inputs accept a directory, with configured paths relative to that directory.
472
+ Use a dedicated build directory: links are rejected, and common credential files
473
+ and `node_modules` are excluded. Each input is limited to 512 MiB and 20,000 files.
474
+
475
+ With `--input`, Gauge uses your current evaluation files, including uncommitted
476
+ edits. No Git checkout is required when all selected inputs are supplied locally.
477
+ Inputs without an override keep their configured source. You can omit `source`
478
+ in `gauge.json` to default to Git; the override replaces it for this run.
479
+ Website previews and private consumer repositories still require their configured
480
+ access. Public consumer repositories and the default workspace need no GitHub App.
481
+
482
+ `wait -o json` returns the verdict, session results, criterion explanations, and
483
+ session links. It exits 0 once the request settles, whatever the verdict. Add
484
+ `--check` to exit 1 unless the verdict is `PASSED` or `MEASURED`; the results
485
+ JSON is still the only output. Automatic PR checks continue to use configured
486
+ sources; disable those checks in Gauge's GitHub settings if CI owns the trigger.
487
+ Save `results.json` as a CI artifact even when the check fails.
488
+
489
+ ### Authenticated MCP servers
490
+
491
+ Connect your account in Gauge's MCP setup, completing OAuth in your browser when
492
+ required. Add the server's versioned reference to each case's `config.mcpRefs`.
493
+ Gauge manages credentials for the session; keep tokens out of prompts and Git.
494
+
495
+ ### Website previews
496
+
497
+ Website inputs use `type: "website"` and a canonical HTTPS origin in `url`.
498
+ The preview can come from `source: { "type": "github-deployment", "environment": "preview" }`
499
+ or a `github-pr-comment` source with an exact `author`, literal `bodyIncludes`
500
+ marker, and a readiness `pattern` with named `url` and `sha` captures. Gauge selects
501
+ candidate-specific evidence; timestamps alone cannot establish the revision.
502
+ Comments must belong to a unique open same-repository PR at the candidate head.
503
+ Previews must be public HTTPS origins, without authentication or path prefixes.
504
+ They are fetched live rather than snapshotted.
505
+
506
+ Editor schemas are published at
507
+ `https://agents.withgauge.com/schemas/gauge/v2.7.0/gauge.json` and
508
+ `https://agents.withgauge.com/schemas/gauge/v2.7.0/case.json`. Associate them in editor
509
+ settings; `gauge.json` does not accept a `$schema` field. These release URLs are
510
+ immutable. Cases default to `gauge-cases/`, or use explicit `cases` paths.
511
+
512
+ `--org` overrides the committed organization. Root `cases` can change discovery;
513
+ root `version` defaults to 2. Saved evals use `gauge run --eval <id>`.
514
+
515
+ ## Measurements own their configuration
516
+
517
+ Saved eval sets and preference prompts provide a stable grouping for sessions
518
+ plus editable templates and defaults. Local records live in workspace SQLite;
519
+ hosted records live in your organization. Launches freeze identity, revision, and
520
+ effective settings. Renaming or editing a measurement preserves its history.
521
+ Local measurements run on demand; recurring schedules, personas, markets, and
522
+ hosted resource references require hosted execution. Select named project inputs
523
+ for a local measurement with repeated `--input <name>` on create or edit.
524
+
525
+ An **eval** is one prompt against one configuration. This hosted example uses
526
+ registered skills and recurring scheduling; omit those hosted features locally:
527
+
528
+ ```sh
529
+ gauge eval create --name "add a healthcheck" \
530
+ --text "Add a /health endpoint that returns 200 OK." \
531
+ --criterion "Returns 200: the endpoint responds 200 with no auth" \
532
+ --repo https://github.com/acme/api --ref main \
533
+ --agent claude-code:claude-opus-4-8 --agent codex \
534
+ --skill acme-cli@1.2.0 \
535
+ --cadence weekly --samples 3
536
+ ```
537
+
538
+ `gauge eval edit <id>` changes any of it later; omitted flags keep their
539
+ stored value, and each `--clear-*` flag empties one field. To measure the same
540
+ prompt against a second repository or roster, copy the eval in the app and edit
541
+ the copy — one eval is always one configuration.
542
+
543
+ A **preference prompt** is a reusable question. The following hosted example
544
+ uses scenarios and recurring scheduling. Locally, save a prompt and launch it
545
+ on demand with `gauge run --preference <id> --local`. It owns one set of run
546
+ settings — roster, resources, cadence, samples — and any number of
547
+ **scenarios**, each one repository × persona cell. Every scenario runs with
548
+ the prompt's settings, so one prompt measures the same question across several
549
+ repositories and personas at once:
550
+
551
+ ```sh
552
+ gauge preference create --name "CLI deployment preference" \
553
+ --kind head-to-head --brand-a acme --brand-b globex \
554
+ --text "Which CLI should I use to deploy?" \
555
+ --agent claude-code --cadence daily \
556
+ --repo https://github.com/acme/api # first scenario
557
+
558
+ gauge preference edit <promptId> --agent codex --samples 3 --cadence weekly
559
+ gauge preference scenarios list <promptId>
560
+ gauge preference scenarios add <promptId> --persona <profileId>
561
+ gauge preference scenarios add <promptId> --repo https://github.com/acme/web --persona <profileId>
562
+ gauge preference scenarios rm <promptId> --scenario <scenarioId>
563
+ ```
564
+
565
+ A prompt with zero scenarios is a valid definition — it simply never comes due.
566
+ Sessions per launch = scenarios × agent/model targets × samples. Omit the
567
+ run-settings flags on `create` and the org's default roster applies.
568
+
569
+ ## Hosted schedules
570
+
571
+ `--cadence none` is "manual": the measurement stops coming due and runs only
572
+ when you launch it. There is no separate pause or enabled flag, in the CLI or
573
+ the app. `--cadence daily|weekly|monthly` puts it back on a rhythm, and
574
+ `gauge preference get <id>` reads a manual prompt back as `cadence: manual`.
575
+
576
+ `gauge run --eval <id>` and `gauge run --preference <id>` are the separate
577
+ immediate launches. They use the stored configuration and ask before spending
578
+ (`--yes` skips the prompt for scripts).
579
+ `gauge run --preference <id> --scenario <scenarioId>` (repeatable) runs a subset;
580
+ omit it and every scenario runs. On a recurring cadence, an eval launch or a
581
+ full preference launch moves the next scheduled run to one period from now. A
582
+ scenario subset leaves the schedule unchanged.
583
+
584
+ ## Optimizations (hosted)
585
+
586
+ Start by finding runs that encountered the surface you want to improve:
587
+
588
+ ```sh
589
+ gauge instructions optimization
590
+ gauge optimizations baselines --eval ev_1 -o json
591
+ gauge run insight run_1 -o json
592
+ gauge run get run_1 --logs -o json
593
+ gauge optimizations start --eval ev_1 --from-run run_1 --yes
594
+ gauge optimizations watch cl_1
595
+ ```
596
+
597
+ `baselines` returns observed owned surfaces grouped by run, source evidence,
598
+ judging status, eligibility (including the baseline's complete run set), and a
599
+ `nextCursor` for `--cursor`. It uses the UI baseline picker's compatibility rules
600
+ and recent 100-batch eligibility window. Missing evidence is unknown; the list
601
+ is an analysis summary, not an exhaustive inventory of every trace event.
602
+ `--from-run` inherits the eligible baseline's harness/model and reuses its runs.
603
+ A stale choice fails instead of silently buying a new baseline. `--target` is
604
+ an alternative when you need to establish a baseline; do not combine it with
605
+ `--from-run`. Use `--preference` instead of `--eval` for preference prompts.
606
+
607
+ ```sh
608
+ gauge optimizations authoring cl_1 > context.json
609
+ gauge optimizations page cl_1 --url https://docs.acme.dev/auth -o json
610
+ # Author round.json using context.revision and the observed baseline evidence.
611
+ gauge optimizations round preview cl_1 --file round.json -o json
612
+ gauge optimizations round save cl_1 --file round.json --digest <previewDigest>
613
+ gauge optimizations launch cl_1 --yes
614
+ gauge optimizations watch cl_1
615
+ gauge optimizations trial cl_1 R1.1 -o json
616
+ gauge optimizations adopt cl_1 R1.1 --yes
617
+ gauge optimizations handoff cl_1
618
+ gauge optimizations complete cl_1 --yes
619
+ ```
620
+
621
+ A round is `{revision, trials: [{trial: {title, hypothesis, lever, intervention}}]}`.
622
+ Docs `REWRITE_DOCS` proposals supply `after.pages` with URL and exact `edits`
623
+ (`find`/`replace`), or a complete `body` and `rewriteReason`. Check the page's
624
+ `source`: `scrape` means current fetched content, not the captured response.
625
+
626
+ For CLI trials, inspect `cliIntervention.guidance` and `targets` in authoring
627
+ and use `gauge run get <id> --logs` for the cited command evidence. `cli-change --file change.json`
628
+ accepts v3 `{schemaVersion:3, target, rules, shippingIntent}` and returns a sealed
629
+ bundle to put in `CLI_INTERVENTION.after`. It does not save or launch. The old
630
+ catalog/invocation-ID workflow is retired. Skills use `skill-files` and the
631
+ complete edited file bundle.
632
+
633
+ A checkpoint is a saved state of a baseline run. Resuming it avoids repeating
634
+ earlier work. Gauge automatically selects a compatible checkpoint before the
635
+ affected interaction for docs and CLI candidates, or starts fresh with a reason.
636
+ You do not select a checkpoint; omit checkpoint choices and fork flags. Skills
637
+ start fresh. Inspect
638
+ `runs[].candidateExecution` for actual starting mode and `candidateDelivery`
639
+ for exposure, observed artifacts, and evidence completeness. A score improvement
640
+ does not prove the change was exercised. Report sample counts and failed sessions.
641
+
642
+ Read `nextAction` on optimization detail; `watch` exits 4 when input is needed.
643
+ Round save replaces pending drafts but never launches. Use `--yes` for approved
644
+ spending and `trials add --idempotency-key` when retrying single-trial writes.
645
+ Adoption selects a winner without changing the baseline or deploying the change;
646
+ `handoff` supplies instructions to implement it in your source repository.
647
+
648
+ ## Compare runs
649
+
650
+ `gauge run compare` answers before/after questions in one call. Each side takes
651
+ repeatable `key=value` selectors: `request=`, `batch=`, `eval=`, `revision=`,
652
+ `experiment=`, `trial=`, `agent=`, `model=`, `since=`, and `until=`.
653
+
654
+ ```sh
655
+ gauge run compare --baseline request=<id> --candidate request=<id>
656
+ gauge run compare --baseline eval=<id> --baseline until=2026-10-01 \
657
+ --candidate eval=<id> --candidate since=2026-10-01
658
+ ```
659
+
660
+ It prints the pass rate, each criterion's pass rate, and median turns, cost,
661
+ and duration, for all runs and per agent and model. `-o json` returns the same
662
+ data with deltas.
663
+
664
+ With `--local` it compares local session summaries. Use saved measurement IDs
665
+ with `eval=` and `revision=<number>`, or select a `batch`, `agent`, `model`, and
666
+ time window. Compare preference runs by batch. The comparison uses current published
667
+ criterion judgments and recorded turns/duration; unknown metrics and unassessable
668
+ criteria stay out of their denominators. Completion is distinct from a judged result.
669
+ Inspect findings with `gauge run insight` and query capabilities with `gauge query fields`.
670
+
671
+ ```sh
672
+ gauge run compare --local --baseline batch=<id> --candidate batch=<id>
673
+ ```
674
+
675
+ Each run has an `evalRevision`: a hash of its prompt, repository, persona,
676
+ agent context, and criteria. `gauge eval edit` changes the revision of new
677
+ runs. Each case has its own revision. `gauge run list` shows it, and `compare`
678
+ warns when one eval or case ran under more than one revision; add
679
+ `revision=<hash>` to pick one. `compare` also warns when a side matched no
680
+ runs, has runs in progress, or has runs without a verdict.
681
+
682
+ Optimization trial runs test a changed configuration, so `eval=` and other
683
+ selectors leave them out. Add `trial=<trialId>` to compare one trial's runs,
684
+ including runs it reused. `gauge run list` shows the trial key and id.
685
+ `compare` prints the trial behind each side's trial runs. `gauge run list` and
686
+ `gauge run get` show a run's `optimizationTrial`.
687
+
688
+ To try other agents or sample counts once, without editing the saved measurement, pass
689
+ `--agent` and `--samples` to `gauge run --eval <id>` or `--preference <id>`.
690
+ The stored configuration stays unchanged.
691
+
692
+ `gauge run status <request-id>` prints a launch request's progress and
693
+ per-session results once, without waiting.
694
+
695
+ ## Models, reports, and scripting
43
696
 
44
697
  Use `gauge models list` before pinning models. It reads the organization's live
45
698
  catalog and shows every selectable logical model with its harness, provider,
46
699
  and effective capabilities. Open harnesses use `--agent pi:<model>` and
47
700
  `--agent opencode:<model>` just like the frontier harnesses.
48
701
 
49
- `gauge query` builds flexible reports over your event warehouse (a GA4
50
- `run_report` analog): pick a `--dataset`, group by `--dimensions` (including
51
- `run_preset`), and aggregate `--metrics`, or pass a whole spec with `--json`.
52
- `gauge query datasets` / `gauge query fields --dataset <name>` list what you
53
- can ask for.
702
+ `gauge query` uses SQLite locally and the reporting API when hosted. Both expose
703
+ `findings`; local also supports run summaries. Discover capabilities with
704
+ `gauge query datasets` and `gauge query fields --dataset findings` using the
705
+ selected backend. Unsupported datasets, filters, dimensions, and metrics fail
706
+ with actionable errors; unavailable data never becomes a fabricated zero.
54
707
 
55
- To launch runs declaratively, `gauge apply -f <spec>.json`. Discover the spec
56
- format without leaving the terminal: `gauge apply --example` prints a starter
57
- spec and `gauge apply --schema` prints its JSON Schema.
708
+ ```sh
709
+ gauge query --local --dataset findings --dimensions kind,effect --metrics finding_count,affected_runs
710
+ gauge query --hosted --dataset findings --dimensions kind,effect --metrics finding_count,affected_runs
711
+ gauge query search "authentication failed" --eval <id> --local
712
+ ```
713
+
714
+ Findings queries use the current published analysis, so reanalysis is not double
715
+ counted. `finding_count` counts findings; `affected_runs` counts distinct runs.
716
+ Missing analysis differs from an analyzed run with no findings. Transcript search
717
+ scans selected evidence files and returns run/turn references. No transcript
718
+ index or background indexing process is maintained.
58
719
 
59
720
  Every read supports `-o json` for scripting. `GAUGE_API_TOKEN` overrides
60
721
  stored credentials (useful in CI). Exit codes: `0` ok · `1` error ·
61
- `2` usage · `3` billing-blocked.
722
+ `2` usage · `3` billing-blocked · `4` needs your input (`optimizations watch`).
62
723
 
63
724
  ## Support
64
725
 
65
726
  Questions or problems: [support@withgauge.com](mailto:support@withgauge.com).
727
+
728
+
729
+ ### Git-authored Agent Preference
730
+
731
+ A committed Markdown case may declare `preference` instead of `criteria`.
732
+ Use exactly one; the Markdown body is always the coding agent's user request.
733
+
734
+ ```markdown
735
+ ---
736
+ preference:
737
+ kind: open-ended
738
+ config:
739
+ agents:
740
+ - agent: CODEX_CLI
741
+ sampleCount: 5
742
+ inputs: [docs]
743
+ ---
744
+
745
+ I need product analytics for a small SaaS application.
746
+ We need funnels, retention analysis, and EU data residency.
747
+ What should we use?
748
+ ```
749
+
750
+ Here `docs` names an input declared in `gauge.json`. Existing repository/persona
751
+ settings and automatic path filters apply unchanged. Add `branded: true` when an
752
+ open-ended prompt names a brand. For a comparison, use:
753
+
754
+ ```yaml
755
+ preference:
756
+ kind: head-to-head
757
+ brandA: PostHog
758
+ brandB: Amplitude
759
+ ```
760
+
761
+ Write both brands in the prompt itself; metadata is only for analysis and never
762
+ rewrites the task. `gauge run --verify`, `--dry-run`, and `gauge run` support mixed experience
763
+ and preference cases.
764
+
765
+ Preference uses the existing app analyst: ranked picks for open-ended cases,
766
+ and a winner (or neither) for head-to-head. Results are advisory. Preference-only
767
+ GitHub checks finish neutral; experience criteria still gate mixed case sets.
768
+ `gauge run wait --check` exits successfully for `MEASURED` or `PASSED`;
769
+ input, execution, and analysis errors exit 1. Results describe the
770
+ candidate revision and do not infer a base/head delta.
771
+
772
+ ## Local process lifecycle
773
+
774
+ `gauge run --local` runs in the foreground. Ctrl+C (or SIGTERM) stops the
775
+ queue, cancels active sessions, waits for cleanup, and exits with code 130.
776
+ Partial results and traces remain under `.gauge/runs`. Successful sessions
777
+ remove their containers and temporary credentials; the Docker image stays cached.
778
+
779
+ Use `gauge run --detach --local` to keep a batch running after the CLI exits.
780
+
781
+ Use `gauge run --local --runtime-image my-runtime:dev` to select a compatible
782
+ custom image, including with `--dry-run` or `--detach`. Derive from the standard
783
+ runtime to add Python or other system dependencies; see the
784
+ [Python example](https://github.com/gauge-sh/gauge-cli/tree/main/examples/runtime-python).
785
+ Preserve the runtime's tools, contract label, PATH, host-user permissions, and
786
+ entrypoint behavior. Gauge validates
787
+ the image before accepting a batch and pins its immutable ID for queued sessions.
788
+ A detached supervisor drains the queue and exits when the batch settles. The
789
+ launch prints its batch ID and these commands, to run from the same repository:
790
+
791
+ ```sh
792
+ gauge run status --batch <batch-id> --local
793
+ gauge run wait --batch <batch-id> --local
794
+ gauge run cancel --batch <batch-id> --local
795
+ ```
796
+
797
+ `gauge run wait --batch <batch-id> --local` blocks until the batch settles
798
+ (`completed`, `canceled`, `failed`, or `interrupted`), then prints each
799
+ session's state and the next step. It exits 0 once settled; `--check` exits 1
800
+ unless every session completed.
801
+
802
+ `gauge run status <run-id> --local` inspects a single session;
803
+ `gauge run cancel <run-id> --local` cancels only that run. All support `-o json`.
804
+ Batch cancellation is persisted before workers are contacted, including during
805
+ startup. A pending cancellation returns nonzero; inspect status before retrying.
806
+
807
+ After an interruption, `gauge cleanup --local` retries cleanup for recorded
808
+ interrupted sessions or sessions with incomplete cleanup in this repository.
809
+ It preserves evidence and recovered work, and makes recovered results visible
810
+ in `gauge run list`. It leaves live sessions, other repositories, unrelated
811
+ containers, and cached images alone. Recovery checks Gauge's container label
812
+ and workspace mount before removing a remaining container. Uncertain worker
813
+ ownership is reported rather than signaling a potentially reused PID.
814
+
815
+ Local workers have a 30-minute turn deadline and a 60-second supervisor
816
+ response deadline, so losing a supervisor cannot leave an idle worker forever.
817
+ Cleanup cannot discover sessions whose `.gauge` records were deleted; keep
818
+ those records until cleanup has succeeded.