@counterfact-labs/cli 0.1.2 → 0.2.3

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.
Files changed (184) hide show
  1. package/README.md +178 -38
  2. package/bundle/client-release.json +7 -0
  3. package/bundle/sealed.json +908 -0
  4. package/dist/adapters/anthropic.js +151 -0
  5. package/dist/adapters/completion.js +112 -0
  6. package/dist/adapters/durable-write.js +34 -0
  7. package/dist/adapters/files.js +140 -0
  8. package/dist/adapters/folder-path.js +6 -0
  9. package/dist/adapters/git-ignore.js +49 -0
  10. package/dist/adapters/git.js +44 -0
  11. package/dist/adapters/ignored-files.js +36 -0
  12. package/dist/adapters/instructions.js +35 -0
  13. package/dist/adapters/models.js +51 -0
  14. package/dist/adapters/output-paths.js +92 -0
  15. package/dist/adapters/prompt-cache.js +28 -0
  16. package/dist/adapters/public-instructions.js +36 -0
  17. package/dist/adapters/quality.js +6 -0
  18. package/dist/adapters/relay-plan.js +15 -0
  19. package/dist/adapters/release.js +57 -0
  20. package/dist/adapters/report.js +29 -0
  21. package/dist/adapters/repository-files.js +199 -0
  22. package/dist/adapters/repository-root.js +120 -0
  23. package/dist/adapters/results.js +9 -0
  24. package/dist/adapters/settings.js +25 -0
  25. package/dist/adapters/snapshot.js +68 -0
  26. package/dist/analysis-core/analysis/analysis-flags.js +1 -0
  27. package/dist/analysis-core/analysis/code-agents/skipped-files.js +1 -0
  28. package/dist/analysis-core/analysis/finding-quality/config.js +1 -0
  29. package/dist/analysis-core/analysis/finding-quality/policy.js +1 -0
  30. package/dist/analysis-core/analysis/headlines/attachment.js +1 -0
  31. package/dist/analysis-core/analysis/headlines/input.js +1 -0
  32. package/dist/analysis-core/analysis/headlines/types.js +1 -0
  33. package/dist/analysis-core/analysis/schemas.js +1 -0
  34. package/dist/analysis-core/analysis/source-notes/types.js +1 -0
  35. package/dist/analysis-core/chunks/2PSNOSJ2.js +1 -0
  36. package/dist/analysis-core/chunks/3227KXHF.js +1 -0
  37. package/dist/analysis-core/chunks/326F4XNG.js +1 -0
  38. package/dist/analysis-core/chunks/3MTXB4MK.js +6 -0
  39. package/dist/analysis-core/chunks/4F6ZIHXU.js +1 -0
  40. package/dist/analysis-core/chunks/57M4OQJM.js +1 -0
  41. package/dist/analysis-core/chunks/6YCABS5T.js +1 -0
  42. package/dist/analysis-core/chunks/724WZMYW.js +2 -0
  43. package/dist/analysis-core/chunks/74FPPPIG.js +1 -0
  44. package/dist/analysis-core/chunks/7QDOHWSY.js +27 -0
  45. package/dist/analysis-core/chunks/BZNHHLNP.js +1 -0
  46. package/dist/analysis-core/chunks/DTMHXKP6.js +7 -0
  47. package/dist/analysis-core/chunks/E7TFIHC5.js +1 -0
  48. package/dist/analysis-core/chunks/EH3QQ3T4.js +1 -0
  49. package/dist/analysis-core/chunks/EQTIRIMU.js +37 -0
  50. package/dist/analysis-core/chunks/FSLWD2PE.js +1 -0
  51. package/dist/analysis-core/chunks/G322LST6.js +1 -0
  52. package/dist/analysis-core/chunks/HTLIRVP7.js +1 -0
  53. package/dist/analysis-core/chunks/IBCFGUHI.js +1 -0
  54. package/dist/analysis-core/chunks/IL2KRP3T.js +1 -0
  55. package/dist/analysis-core/chunks/J4AXGE5W.js +1 -0
  56. package/dist/analysis-core/chunks/JF4GYMOZ.js +1 -0
  57. package/dist/analysis-core/chunks/KEKTZDIK.js +1 -0
  58. package/dist/analysis-core/chunks/KU5DINLW.js +1 -0
  59. package/dist/analysis-core/chunks/M7MMAUAK.js +1 -0
  60. package/dist/analysis-core/chunks/OFBJNHC6.js +1 -0
  61. package/dist/analysis-core/chunks/ORCYIIHB.js +60 -0
  62. package/dist/analysis-core/chunks/PVPEY7NF.js +1 -0
  63. package/dist/analysis-core/chunks/PYKAERZZ.js +1 -0
  64. package/dist/analysis-core/chunks/QDYMR6KS.js +1 -0
  65. package/dist/analysis-core/chunks/QPXNXMLC.js +1 -0
  66. package/dist/analysis-core/chunks/SL27GMEN.js +1 -0
  67. package/dist/analysis-core/chunks/STZOC7LN.js +1 -0
  68. package/dist/analysis-core/chunks/T5TREZCQ.js +1 -0
  69. package/dist/analysis-core/chunks/TDNTU4TF.js +1 -0
  70. package/dist/analysis-core/chunks/U5HOEVPE.js +1 -0
  71. package/dist/analysis-core/chunks/UEWL3GMQ.js +1 -0
  72. package/dist/analysis-core/chunks/VER355VN.js +1 -0
  73. package/dist/analysis-core/chunks/VFENG4MR.js +1 -0
  74. package/dist/analysis-core/chunks/VGYWI4X2.js +1 -0
  75. package/dist/analysis-core/chunks/Y5AUKKYG.js +1 -0
  76. package/dist/analysis-core/chunks/Y7JGSUOA.js +1 -0
  77. package/dist/analysis-core/chunks/YVDCJN7D.js +14 -0
  78. package/dist/analysis-core/chunks/ZAA44GPI.js +1 -0
  79. package/dist/analysis-core/chunks/ZMUBMYWN.js +1 -0
  80. package/dist/analysis-core/contracts/requests.js +1 -0
  81. package/dist/analysis-core/conventions/file-admission.js +1 -0
  82. package/dist/analysis-core/data/finding-types.js +1 -0
  83. package/dist/analysis-core/errors.js +1 -0
  84. package/dist/analysis-core/findings/presentation.js +1 -0
  85. package/dist/analysis-core/github/repo-key.js +1 -0
  86. package/dist/analysis-core/import/outside-loader-sources.js +1 -0
  87. package/dist/analysis-core/index.js +6 -0
  88. package/dist/analysis-core/llm/cache-policy.js +1 -0
  89. package/dist/analysis-core/llm/cost.js +1 -0
  90. package/dist/analysis-core/llm/execution.js +1 -0
  91. package/dist/analysis-core/llm/output-limit.js +1 -0
  92. package/dist/analysis-core/llm/slots.js +1 -0
  93. package/dist/analysis-core/llm/stable-json.js +1 -0
  94. package/dist/analysis-core/llm/structured-output-error.js +1 -0
  95. package/dist/analysis-core/map-limit.js +1 -0
  96. package/dist/analysis-core/requests/answer-formats.js +1 -0
  97. package/dist/analysis-core/requests/check-diagnostics.js +1 -0
  98. package/dist/analysis-core/requests/headline-request.js +1 -0
  99. package/dist/analysis-core/requests/instruction-text.js +1 -0
  100. package/dist/analysis-core/requests/local-plan.js +1 -0
  101. package/dist/analysis-core/requests/registry.js +1 -0
  102. package/dist/analysis-core/requests/schema-descriptions.js +1 -0
  103. package/dist/analysis-core/requests/shape-finding-input.js +1 -0
  104. package/dist/analysis-core/requests/template-version.js +1 -0
  105. package/dist/analysis-core/requests/tools.js +1 -0
  106. package/dist/analysis-core/settings.js +1 -0
  107. package/dist/bundle/seal/deserialise.js +75 -0
  108. package/dist/bundle/seal/encryption.js +25 -0
  109. package/dist/bundle/seal/metadata.js +69 -0
  110. package/dist/bundle/seal/open.js +38 -0
  111. package/dist/bundle/seal/planned-calls.js +20 -0
  112. package/dist/bundle/seal/signature.js +51 -0
  113. package/dist/cli/agent-folder.js +17 -0
  114. package/dist/cli/api-types.js +2 -0
  115. package/dist/cli/api.js +1 -0
  116. package/dist/cli/browser.js +23 -0
  117. package/dist/cli/claude-code-permission.js +20 -0
  118. package/dist/cli/commands/analyze.js +73 -0
  119. package/dist/cli/commands/login.js +51 -0
  120. package/dist/cli/completion-recovery.js +18 -0
  121. package/dist/cli/context.js +22 -0
  122. package/dist/cli/email-sign-in.js +56 -0
  123. package/dist/cli/git.js +39 -0
  124. package/dist/cli/intake-payload.js +18 -0
  125. package/dist/{main.js → cli/main.js} +23 -12
  126. package/dist/cli/mcp.js +297 -0
  127. package/dist/cli/output.js +10 -0
  128. package/dist/cli/relay-check.js +239 -0
  129. package/dist/cli/relay-preparation.js +31 -0
  130. package/dist/cli/sign-in-input.js +97 -0
  131. package/dist/cli/sign-in.js +37 -0
  132. package/dist/cli/suggested-email.js +10 -0
  133. package/dist/cli/summary.js +30 -0
  134. package/dist/contract/cli-api-messages.js +5 -0
  135. package/dist/contract/cli-refusals.js +22 -0
  136. package/dist/contract/cli-version.js +1 -0
  137. package/dist/contract/console-url.js +8 -0
  138. package/dist/contract/console.js +111 -0
  139. package/dist/contract/email-sign-in-messages.js +18 -0
  140. package/dist/contract/messages.js +252 -0
  141. package/dist/contract/release-key.js +2 -0
  142. package/dist/contract/runtime-environment.js +37 -0
  143. package/dist/core/analysis/finding-quality/config.js +4 -0
  144. package/dist/core/analysis/run-to-end.js +55 -0
  145. package/dist/core/analysis/structural-run.js +16 -0
  146. package/dist/gatekeeper/attestation.js +67 -0
  147. package/dist/gatekeeper/certificate-algorithms.js +18 -0
  148. package/dist/gatekeeper/certificate-path.js +99 -0
  149. package/dist/gatekeeper/cli-api.js +174 -0
  150. package/dist/gatekeeper/client.js +76 -0
  151. package/dist/gatekeeper/connection-exchange.js +60 -0
  152. package/dist/gatekeeper/connection.js +140 -0
  153. package/dist/gatekeeper/console.js +168 -0
  154. package/dist/gatekeeper/loopback.js +5 -0
  155. package/dist/gatekeeper/model.js +70 -0
  156. package/dist/gatekeeper/production-attestation.js +149 -0
  157. package/dist/gatekeeper/trust/hardware.js +21 -0
  158. package/dist/gatekeeper/trust/policy.js +42 -0
  159. package/dist/gatekeeper/trust/production.json +25 -0
  160. package/dist/setup-pings/client.js +31 -0
  161. package/dist/setup-pings/contract.js +2 -0
  162. package/dist/setup-pings/policy.js +3 -0
  163. package/dist/setup-pings/state.js +261 -0
  164. package/dist/setup-pings/worker.js +95 -0
  165. package/dist/transport/base64url.js +9 -0
  166. package/dist/transport/http-response.js +89 -0
  167. package/dist/transport/tls-exporter.js +5 -0
  168. package/package.json +57 -11
  169. package/LICENSE +0 -1
  170. package/dist/api-types.js +0 -2
  171. package/dist/api.js +0 -97
  172. package/dist/commands/check.js +0 -104
  173. package/dist/commands/login.js +0 -21
  174. package/dist/context.js +0 -27
  175. package/dist/files.js +0 -99
  176. package/dist/git.js +0 -21
  177. package/dist/gitignore.js +0 -70
  178. package/dist/mcp.js +0 -165
  179. package/dist/output.js +0 -23
  180. package/dist/secret-files.js +0 -5
  181. /package/dist/{commands → cli/commands}/balance.js +0 -0
  182. /package/dist/{commands → cli/commands}/finding.js +0 -0
  183. /package/dist/{commands → cli/commands}/logout.js +0 -0
  184. /package/dist/{credentials.js → cli/credentials.js} +0 -0
package/README.md CHANGED
@@ -1,60 +1,200 @@
1
- # Counterfact command line
1
+ # counterfact-local
2
2
 
3
- Check an agent's prompt, skills and tool definitions from your terminal or coding agent. Requires Node.js 20 or later.
3
+ Counterfact analysis that runs on the customer's machine. In a source checkout, the development runner reads a local
4
+ folder, sends selected analysis inputs directly to Anthropic with your developer key, and saves the results locally.
5
+ The customer CLI archive contains compiled analysis code and a signed encrypted instruction bundle. Relay execution
6
+ needs no provider key or readable instructions locally. The installed command connects through the production gatekeeper and saves only cleaned findings and their provenance
7
+ to the console. An analysis charges the balance directly; it has no price confirmation step. Reviewed public release pins are required before it can run.
4
8
 
5
- ```sh
6
- npm install -g @counterfact-labs/cli
7
- counterfact-labs login
8
- counterfact-labs check ./support-agent
9
+ The local and hosted products remain supported. Shared rules and request instructions live in this repository's
10
+ private workspace package, `@counterfact-labs/analysis-core`. A future pinned release will let the hosted product
11
+ use this owner after benchmark parity and a tested rollback; this workspace move does not switch hosted analysis.
12
+
13
+ ## Run a local analysis
14
+
15
+ Use Node.js 22 or later and install the pinned dependencies:
16
+
17
+ ```bash
18
+ npm ci
19
+ ```
20
+
21
+ Set `ANTHROPIC_API_KEY` in your shell to your Anthropic development key, then run these commands from this checkout:
22
+
23
+ ```bash
24
+ npx tsx cli/check.ts --help
25
+ npx tsx cli/check.ts /path/to/agent
26
+ npx tsx cli/check.ts /path/to/agent --output /path/to/results
9
27
  ```
10
28
 
11
- The command lists the selected files and shows the server's price before asking to continue. Use `--yes` after agreeing to that price. Use `--dry-run` to see the files and quote without starting analysis or charging your balance. A quote requires uploading the selected files, including in a dry run.
29
+ Analysis makes paid model calls and needs a provider connection. The command reads source files without modifying
30
+ them, prints a readable summary, and writes `findings.json` and `summary.md` to the agent's `.counterfact/` directory
31
+ by default. `--output` chooses another directory. Reports can contain source excerpts; existing reports at those
32
+ paths are replaced after a completed analysis. Exit status is zero when analysis completes, including when it finds
33
+ problems, and nonzero for invalid arguments, a missing key or a failed run.
12
34
 
13
- ```sh
14
- counterfact-labs check ./support-agent --dry-run
15
- counterfact-labs check ./support-agent --yes
16
- counterfact-labs finding <finding-id>
17
- counterfact-labs balance
18
- counterfact-labs logout
35
+ For a free run of the complete findings flow using committed recordings, with no key or network access:
36
+
37
+ ```bash
38
+ npm run bench:replay
19
39
  ```
20
40
 
21
- Checks return exit code 0 on success, 1 on error and 2 when the balance is too low. The server chooses the files, sets the price and writes the result summary. The first eligible check is free. Failed checks are not charged.
41
+ The replay prints precision, recall and comparison with the saved baseline, and fails if either score leaves its noise
42
+ band. It cannot buy missing model answers. See [how local analysis works](docs/how-local-analysis-works.md) for file
43
+ selection, limits, switches and request construction.
22
44
 
23
- The console is at `https://app.counterfactlabs.com`. Sign in again after moving from the old address; saved sign-in belongs to the server address.
45
+ The current code lives in `packages/core/` (shared rules, types, requests and trusted instructions),
46
+ `cli/` (runner and summary), `core/` (local model-driving steps and orchestration), `adapters/` (runtime I/O), `bundle/` (local
47
+ instruction loading, execution wiring and sealing), and `bench/` (offline parity checks). The
48
+ [canonical analysis guide](packages/core/docs/how-we-analyze-an-agent.md) explains shared rules. Working rules are in
49
+ [AGENTS.md](AGENTS.md); copied-code sources are in [provenance.md](docs/provenance.md).
24
50
 
25
- Add the local MCP server to Codex:
51
+ ## Running the tests
26
52
 
27
- ```sh
28
- codex mcp add counterfact -- npx -y @counterfact-labs/cli@latest mcp
53
+ ```bash
54
+ npm run typecheck
55
+ npm run lint
56
+ npm test
29
57
  ```
30
58
 
31
- Checks can take several minutes. Codex has a [60-second tool timeout by default](https://learn.chatgpt.com/docs/extend/mcp?surface=cli). In `~/.codex/config.toml`, add `tool_timeout_sec = 900` to the existing `[mcp_servers.counterfact]` section. It should look like this; keep any other settings already in that section:
59
+ Tests use scripted answers, fake transports and committed recordings, with no real model calls. The instruction guard
60
+ runs with `npm test`, or by itself:
32
61
 
33
- ```toml
34
- [mcp_servers.counterfact]
35
- command = "npx"
36
- args = ["-y", "@counterfact-labs/cli@latest", "mcp"]
37
- tool_timeout_sec = 900
62
+ ```bash
63
+ npx tsx --test core/instruction-text.test.ts core/test/instruction-text.test.ts
38
64
  ```
39
65
 
40
- Cancellation stops the local wait. A confirmed check keeps running on the server after cancellation or a timeout, and its result appears on the console's Checks page.
66
+ ## Verify live API acceptance
67
+
68
+ With `ANTHROPIC_API_KEY` set, this developer command sends one request for every registered template and answer
69
+ format, using the committed fictional Golu example and production model choices:
70
+
71
+ ```bash
72
+ npx tsx scripts/relay/live-acceptance.ts --budget-ledger /tmp/relay-acceptance-budget.json
73
+ ```
74
+
75
+ It prints JSON with each route's acceptance or exact API error and measured dollar cost, and exits nonzero if any
76
+ request was not accepted. Output is limited to 64 tokens per request; incomplete answers still establish API
77
+ acceptance. The persistent ledger reserves counted input and maximum output before spending, with a hard $3 cap.
78
+ Reuse the ledger to preserve that cap across invocations; each run gives its entries a unique run identifier.
79
+ Duplicate entries report `duplicate_entry` rather than `budget`; uncertain charges still stop further spending.
80
+ The ledger holds a `<ledger-file>.lock` file while running. If a run is killed and later runs print
81
+ `Live acceptance failed.`, remove only that lock file after confirming no capture process is still running.
82
+ Keep the ledger itself so earlier spending and uncertain charges remain reserved.
83
+ Second opinions are disabled in local analysis, so that registered route uses the existing Anthropic parity
84
+ fixture's checker model. This command is separate from offline tests and must be run explicitly.
85
+
86
+ ## Use the published CLI
87
+
88
+ The package is `@counterfact-labs/cli` 0.2.0 and requires Node.js 22 or later. Its executable is
89
+ `counterfact-labs`. Login keeps browser sign-in and adds `--email` and verify-only `--code`. MCP adds
90
+ `sign_in_with_code` and optional email arguments; logout, balance and finding lookup retain their commands and tool names.
91
+ With `CF_EMAIL_SIGN_IN=0`, login help, arguments and the full MCP tool/status contract retain their previous behavior.
92
+ `mcp` exposes `analyze_agent` and reports `analyzeToolAllowed`; the old analysis command and tool names are refused.
93
+ `analyze [path]` runs locally through the relay; `--yes`, `--dry-run`, and the MCP
94
+ `confirm` argument are removed. Each requested analysis runs once without a price prompt. Prices belong on the website
95
+ and top-up page; an uncovered balance refuses with a top-up link.
96
+
97
+ The archive also ships `bundle/client-release.json` with its public Ed25519 verification key and local/relay versions,
98
+ and the gatekeeper's public production trust policy. Production trust has no environment override. With exactly
99
+ `CF_RELAY_DEV=1`, development startup accepts separate issuer trust, a bundle and public release pins through
100
+ `CF_RELAY_DEV_TRUST`, `CF_RELAY_DEV_BUNDLE` and `CF_RELAY_DEV_RELEASE`. This exception permits only HTTPS loopback
101
+ connections (`localhost`, `127.x.x.x` or `::1`) and does not establish sealed execution.
102
+ The checked-in release pins and production image trust remain unconfigured; installing reviewed pins and ciphertext
103
+ is a release prerequisite.
104
+
105
+ The npx commands below work once 0.2.0 is tagged `latest`.
106
+ Use npx to run the newest release:
107
+
108
+ ```bash
109
+ npx -y @counterfact-labs/cli@latest login
110
+ npx -y @counterfact-labs/cli@latest balance
111
+ npx -y @counterfact-labs/cli@latest analyze ./agent
112
+ npx -y @counterfact-labs/cli@latest finding <id>
113
+ npx -y @counterfact-labs/cli@latest mcp
114
+ ```
115
+
116
+ To sign in with an emailed code, run:
117
+
118
+ ```bash
119
+ npx -y @counterfact-labs/cli@latest login --email reader@example.test
120
+ ```
41
121
 
42
- Add this to your project's `AGENTS.md`:
122
+ Enter the code from your email when prompted. Without a terminal, this command sends the code and prints how to finish. Complete sign-in with:
43
123
 
44
- ```markdown
45
- When I ask to check an agent, use Counterfact's check_agent tool with its folder path.
46
- Call it without confirm first. Show me the selected files and price, and get my
47
- agreement before calling again with confirm: true. If the files or price change,
48
- show me a fresh preview and ask again. Use get_finding for an explanation, quoted
49
- lines and suggested fixes. Use get_balance for the balance and top-up link.
50
- After editing prompts, skills or tool definitions, suggest a check and wait for
51
- me to ask for it.
124
+ ```bash
125
+ npx -y @counterfact-labs/cli@latest login --email reader@example.test --code <code>
52
126
  ```
53
127
 
54
- The MCP server reads local files and communicates over stdin and stdout. Its tools are `check_agent(path, confirm?)`, `get_finding(id)` and `get_balance()`. Each result's structured content repeats the tool's text, and completed checks add their finding ids. Keep the preview and confirmation in the same MCP session.
128
+ The command saves your sign-in on this computer. Run login without --email to use browser sign-in.
55
129
 
56
- Privacy: only files requested by the server are uploaded. The tool skips `.git`, `node_modules`, `.gitignore` matches, symlinks and secret file names such as `.env` and private keys. Uploaded files are kept with the check while the workspace exists, and deleted with the check or workspace. Sign-in is saved in `~/.config/counterfact-labs/credentials` with owner-only permissions. `logout` removes that local sign-in; revoke the token from your account to disable it elsewhere.
130
+ Passing --code puts the code in process arguments and may leave it in your shell history. Use the hidden terminal prompt to avoid that.
57
131
 
58
- Set `COUNTERFACT_URL` to use another server. It defaults to `https://app.counterfactlabs.com`. Sign-in is tied to the server address; sign in again when changing it.
132
+ Set CF_EMAIL_SIGN_IN=0 before starting the command or MCP server to restore the original browser sign-in tools and terminal commands. Restart the MCP server after changing this setting.
133
+
134
+ MCP sign_in_with_code receives the code as a tool argument, so it remains in your MCP client's transcript. Counterfact does not repeat it in tool results, logs, or reports. Use the hidden terminal prompt if you want to keep the code out of the MCP transcript.
135
+
136
+ Or install globally: `npm install -g @counterfact-labs/cli@latest`.
137
+
138
+ If you use Claude Code's sandbox, allow relay.counterfactlabs.com and app.counterfactlabs.com when Claude Code asks,
139
+ or add both to the sandbox's allowed domains.
140
+
141
+ The command uses the existing saved sign-in and sends `X-Counterfact-CLI-Version: 0.2.0`. It asks
142
+ `/api/cli/checks/mode` before reading source or starting paid work. Upload, paused, update-required and unavailable
143
+ responses stop the analysis; the command never falls back to uploading files. Settings are captured at command start.
144
+ The analysis uses a committed Git folder. Admitted files must match that commit; unrelated local output files are ignored.
145
+ The console owns prices, expressed in millionths of a dollar.
146
+
147
+ The installed command uses the relay address in `bundle/client-release.json` and saved sign-in. The relay runner sends
148
+ repository facts and the admitted file list (paths and sizes, without contents or absolute checkout paths) to
149
+ `POST /api/cli/checks` to start local analysis. The console decides the project and returns its id. Development can
150
+ override `CF_RELAY_URL`; normal use needs no transport switches or provider key. `COUNTERFACT_URL` retains the
151
+ development server override.
152
+
153
+ Release stays blocked while `relayUrl` and `projectContext` are unconfigured in the checked-in metadata. Set
154
+ `projectContext` to `checks` only after local start support is reviewed. The release validator requires both settings
155
+ along with the signed bundle and trust pins; an environment override cannot bypass the project-context pin.
156
+
157
+ ## Build and release the customer CLI archive
158
+
159
+ Generate `bundle/sealed.json` with the existing release tooling and externally supplied release keys. Install the
160
+ reviewed public verification key, matching local/relay versions, HTTPS relay origin and reviewed project-context support
161
+ in `bundle/client-release.json`, and the reviewed
162
+ production trust policy in `gatekeeper/trust/production.json`. These trust files cannot be overridden through the
163
+ environment. Then run:
164
+
165
+ ```bash
166
+ npm run release:cli
167
+ ```
168
+
169
+ The release command builds, packs, verifies the archive contents and prints its SHA-256 hash. Only compiled runtime
170
+ modules, the encrypted bundle and release metadata ship, together with npm's mandatory package metadata and README.
171
+ The trusted core remains a development dependency; its readable instructions are excluded from the installed CLI.
172
+ The installed runtime dependencies also exclude TypeScript. The trusted shared-core archive used by hosted
173
+ integrations continues to ship its readable instructions.
174
+ The archive exposes `@counterfact-labs/cli/gatekeeper` for injected verified connections.
175
+
176
+ The release workflow runs only through a manual GitHub Actions trigger and publishes the verified archive with
177
+ `--tag next`, using the `NPM_TOKEN` secret. It refuses unconfigured bundle and trust pins. No release or publish is
178
+ performed by this implementation task. After the launch decision, move the public default explicitly:
179
+
180
+ ```bash
181
+ npm dist-tag add @counterfact-labs/cli@0.2.0 latest
182
+ ```
59
183
 
60
- From this repository, `npm run cli:test` copies the API types and secret-file rule from their server owners, compiles the package with TypeScript and runs its offline tests. No additional npm dependencies are needed.
184
+ The source-only `cli/check.ts` development runner accepts `CF_LOCAL_RELAY=1`, `CF_RELAY_URL`, `CF_CONSOLE_URL`,
185
+ and `CF_CONSOLE_TOKEN`. Other switch values retain direct source execution. The installed command
186
+ uses the saved sign-in and release configuration described above. Completed runs save local reports and a private
187
+ `completion.json` record containing the exact findings payload and analysis identity, with no bearer or reservation
188
+ capability. A pending upload is retried on the next invocation using current credentials. The source runner's
189
+ `--retry-upload` explicitly retries a previously completed upload without buying another analysis. Keep this record
190
+ private because findings can contain excerpts. The source runner prints the saved analysis id and project findings
191
+ link; the installed command prints finding ids and the full-results link. Failures report only trusted settlement/status
192
+ facts; a local error cannot promise a refund. Customer source
193
+ files travel only through the gatekeeper to the attested relay. Relay failures stop the run.
194
+
195
+ Offline package tests install real archives in a clean temporary directory, inspect the installed dependencies for
196
+ readable instructions, run the linked executable and complete the analysis stages with a scripted provider and an
197
+ injected verified connection. A separate end-to-end test uses real loopback gatekeeper TLS and the real relay runtime.
198
+ Server storage and settlement still require the disposable PostgreSQL integration run.
199
+ Reviewed server compatibility for variable-size check batches, split scope limits, settings-selected variants and the
200
+ optional headline stage remains a launch gate; offline fakes do not establish those production contracts.
@@ -0,0 +1,7 @@
1
+ {
2
+ "verificationKey": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAbBab1PYdmBKXxCvoJ47toJhQvxPevo9nlZnb0zbDWoc=\n-----END PUBLIC KEY-----\n",
3
+ "relayVersion": "relay-1.0.1",
4
+ "localVersion": "0.2.3",
5
+ "relayUrl": "https://relay.counterfactlabs.com:8443",
6
+ "projectContext": "checks"
7
+ }