@primitive.ai/prim 0.1.0-alpha.125 → 0.1.0-alpha.127

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 (45) hide show
  1. package/README.md +140 -1
  2. package/SKILL.md +6 -1
  3. package/dist/{chunk-JFWJN2ME.js → chunk-72NIZMZN.js} +114 -5
  4. package/dist/{chunk-2BEUR3DU.js → chunk-A5VTE43F.js} +2 -2
  5. package/dist/{chunk-6OPSSJHO.js → chunk-C4QNBSWB.js} +24 -9
  6. package/dist/{chunk-BFYJLI7V.js → chunk-F3FDVHR7.js} +1 -1
  7. package/dist/{chunk-YP4OXKNX.js → chunk-H6X52UVF.js} +1 -1
  8. package/dist/{chunk-ND6TYHNI.js → chunk-H74RDXKP.js} +2 -2
  9. package/dist/{chunk-NJBN3WXF.js → chunk-HZI5PBN4.js} +785 -154
  10. package/dist/{chunk-FYYHBOOM.js → chunk-JCKOW45X.js} +2 -2
  11. package/dist/{chunk-DT7E3SD5.js → chunk-KFRGVHGB.js} +4 -4
  12. package/dist/{chunk-TI37ME2D.js → chunk-L6IL4N6Y.js} +16 -7
  13. package/dist/{chunk-HPA7RGSZ.js → chunk-MGKSZSTV.js} +7 -8
  14. package/dist/{chunk-ZKXNJB6U.js → chunk-NVDPKW7Z.js} +69 -29
  15. package/dist/{chunk-NBNQI3YJ.js → chunk-O65UVJZH.js} +6 -3
  16. package/dist/{chunk-74DQDWLW.js → chunk-R4EYLEIK.js} +7 -2
  17. package/dist/{chunk-R35M4RCY.js → chunk-RV3JFSMX.js} +4 -4
  18. package/dist/{chunk-PPZ56EVJ.js → chunk-TNWI3JWK.js} +1 -1
  19. package/dist/{chunk-6KXQQ7CQ.js → chunk-URYZDQFH.js} +3 -3
  20. package/dist/{chunk-L32WYFJT.js → chunk-UUQT5GMO.js} +135 -12
  21. package/dist/{chunk-EZXIKEMA.js → chunk-VVFVENU4.js} +6 -4
  22. package/dist/{chunk-O73J3KQQ.js → chunk-WGTUNUIS.js} +5 -2
  23. package/dist/daemon/server.js +805 -218
  24. package/dist/hook-runtime/daemon/server.js +805 -218
  25. package/dist/hook-runtime/hooks/post-commit.js +286 -59
  26. package/dist/hook-runtime/hooks/post-rewrite.js +278 -51
  27. package/dist/hook-runtime/hooks/post-tool-use.js +672 -194
  28. package/dist/hook-runtime/hooks/pre-commit.js +536 -88
  29. package/dist/hook-runtime/hooks/pre-tool-use-worker.js +616 -165
  30. package/dist/hook-runtime/hooks/prim-hook.js +642 -167
  31. package/dist/hook-runtime/hooks/session-end.js +263 -47
  32. package/dist/hook-runtime/hooks/session-start.js +1103 -476
  33. package/dist/hook-runtime/index.js +3645 -2120
  34. package/dist/hook-runtime/statusline-main.js +257 -29
  35. package/dist/hooks/post-commit.js +7 -7
  36. package/dist/hooks/post-rewrite.js +6 -6
  37. package/dist/hooks/post-tool-use.js +15 -15
  38. package/dist/hooks/pre-commit.js +4 -4
  39. package/dist/hooks/pre-tool-use-worker.js +14 -15
  40. package/dist/hooks/prim-hook.js +16 -16
  41. package/dist/hooks/session-end.js +4 -4
  42. package/dist/hooks/session-start.js +49 -18
  43. package/dist/index.js +1014 -271
  44. package/dist/statusline-main.js +257 -29
  45. package/package.json +1 -1
package/README.md CHANGED
@@ -154,6 +154,132 @@ process (auth → session hooks → daemon → skill → activate this repositor
154
154
  step-by-step the agent follows — and the manual fallback — live in
155
155
  [`setup.md`](./setup.md).
156
156
 
157
+ ### Claude Code cloud environments
158
+
159
+ Prim runs in [Claude Code cloud sessions](https://code.claude.com/docs/en/claude-code-on-the-web).
160
+ Configure it once; each session then connects without manual steps. The repository must
161
+ already be connected to Primitive (`prim github connect`, from your own machine).
162
+
163
+ 1. **Mint credentials for the environment** on your own machine. This signs you in once,
164
+ enrolls a separate installation in your name, and prints its credentials. Nothing is
165
+ stored locally, and your machine's own credentials are untouched:
166
+
167
+ ```bash
168
+ prim auth enroll --new-installation "Claude Code cloud" --print-env
169
+ ```
170
+
171
+ 2. **Configure the [cloud environment](https://code.claude.com/docs/en/cloud-environments)**:
172
+ - **Network access**: Limited, with `api.getprimitive.ai` and `signin.getprimitive.ai`
173
+ under Allowed domains (both are blocked by default), and **Allow package managers**
174
+ left on so the setup script can install prim. A change to Allowed domains reaches
175
+ prim only in sessions started after it: a running session keeps the network rules
176
+ it started with.
177
+ - **Credentials**: give the secret to the environment's proxy, which no session can
178
+ read back. Under **Network secrets**, add a **Username and password** secret for host
179
+ `signin.getprimitive.ai`: the `PRIM_M2M_CLIENT_ID` value step 1 printed as the
180
+ username, the `PRIM_M2M_CLIENT_SECRET` value as the password. Then set these
181
+ **Environment variables**, leaving the `PRIM_M2M_CLIENT_SECRET` line out and
182
+ keeping any other line step 1 printed, such as `PRIM_API_URL`:
183
+
184
+ ```text
185
+ PRIM_M2M_CLIENT_ID=client_...
186
+ PRIM_M2M_CLIENT_AUTH=network-secret
187
+ ```
188
+
189
+ The simpler alternative is to paste every line step 1 printed into the variables.
190
+ Anyone who uses the environment can read its variables, so do that only in an
191
+ environment you keep to yourself.
192
+ - **Setup script**:
193
+
194
+ ```bash
195
+ #!/bin/bash
196
+ set -euo pipefail
197
+ npm install -g @primitive.ai/prim@latest
198
+ prim setup --cloud --prepare
199
+ ```
200
+
201
+ `--prepare` needs no credentials or network to Primitive. It wires prim into the
202
+ VM's user-scope Claude Code settings, which every session reads at startup, so
203
+ repositories need no commit. It marks the environment so sessions activate the
204
+ repositories they open, and turns the daemon off: the VM pauses between messages, so
205
+ capture delivers directly instead. `prim disable` opts a repository out for the rest of
206
+ that session only, because each session starts from a fresh clone. To keep prim out of
207
+ a repository for good, run `prim disable --scope project` in it and commit
208
+ `.claude/settings.json` (with `git add -f` where the repository ignores `.claude`;
209
+ prim says so): that records `PRIM_ACTIVE=false` there, every clone carries
210
+ it, and prim then stays off in that repository unless someone turns it on themselves
211
+ (`prim enable` in their own clone). `prim enable --scope project` removes it again.
212
+
213
+ With the network secret, the proxy adds the secret to prim's token request as HTTP Basic
214
+ authentication, so no process in the session can read the secret or carry it out of the
215
+ VM; processes in the
216
+ session can still obtain short-lived tokens through the proxy, as prim does. Keep
217
+ `signin.getprimitive.ai` under Allowed domains. Prim's token broker, the one process
218
+ that requests tokens, sends its own requests through that proxy; nothing else in the VM
219
+ has to. An environment set up for an earlier prim may still carry `NODE_USE_ENV_PROXY=1`
220
+ (and `NODE_NO_WARNINGS=1`) in its variables: both are harmless and can be removed.
221
+
222
+ To keep the tokens out of the VM as well, let the proxy request them. In the settings
223
+ of an existing environment (the New environment dialog offers only the simpler secret
224
+ types), add a **Network secret** of type **OAuth 2.0 client credentials** in place of
225
+ the username-and-password secret:
226
+
227
+ - **Allowed websites**: `api.getprimitive.ai`
228
+ - **Token URL**: `https://signin.getprimitive.ai/oauth2/token`
229
+ - **Client ID** and **Client secret**: the `PRIM_M2M_CLIENT_ID` and
230
+ `PRIM_M2M_CLIENT_SECRET` values step 1 printed
231
+ - **Scopes**, **Resource** and **Audience**: leave empty
232
+
233
+ and set the variables to:
234
+
235
+ ```text
236
+ PRIM_M2M_CLIENT_ID=client_...
237
+ PRIM_M2M_CLIENT_AUTH=network-token
238
+ ```
239
+
240
+ The proxy then obtains the tokens itself and attaches one to each request for
241
+ `api.getprimitive.ai`. Prim requests no token and sends no credential: its commands and
242
+ hooks hand their API requests to prim's broker, the one process that sends through the
243
+ proxy, and `prim auth status` verifies the identity the proxy authenticates as. No
244
+ process in the session can read the secret or a token, though any process in it can
245
+ still reach Primitive through the proxy as that installation, so keep the environment
246
+ personal. Only `api.getprimitive.ai` has to be under Allowed domains in this mode, and
247
+ `prim setup --cloud` names the network secret's fields if the proxy's token is refused.
248
+
249
+ Running plain `prim setup` inside a cloud session (for example through the agent prompt
250
+ above) detects the session and does the cloud setup; browser sign-in, the daemon, and
251
+ onboarding are skipped there, and `prim auth login` explains why it cannot run.
252
+ `--prepare` belongs in the setup script: Claude Code reads its hooks when it starts, and
253
+ new sessions start from the environment's image. Run inside a session, it wires only
254
+ that VM and says the image was not prepared by that run (a VM the image had already
255
+ prepared stays prepared).
256
+
257
+ Each session, prim's SessionStart hook activates the repository the session was started
258
+ on and connects it to Primitive. If the hook cannot connect it, it says why: missing
259
+ credentials, a blocked domain, or a checkout that does not identify its repository. The
260
+ git pre-commit check is not wired automatically; run `prim setup --cloud` in a session to
261
+ verify it step by step and install it. A second repository the agent clones during the
262
+ session is not connected or given git hooks at session start; run `prim setup --cloud`
263
+ from that clone to set it up. Decisions captured in the environment belong to you; an
264
+ organization admin can revoke the installation in Settings → Developer installations.
265
+
266
+ Prim identifies the repository from its GitHub origin. A session started with
267
+ `claude --cloud` from a checkout the Claude GitHub App cannot clone receives an upload
268
+ with no origin. For those, commit prim's project install from a clone whose origin is on
269
+ GitHub; besides the hooks, it records the repository declaration (`PRIM_REPOSITORY`) in
270
+ `.claude/settings.json`:
271
+
272
+ ```bash
273
+ prim claude install --scope project
274
+ git add .claude/settings.json && git commit -m "chore: enable prim in Claude Code"
275
+ ```
276
+
277
+ A repository that commits prim's project install keeps using it: the user-scope hooks
278
+ step aside there, so nothing fires twice. Committed hooks run for everyone who opens the
279
+ repository in Claude Code; where prim is not installed they do nothing. Upgrade prim
280
+ across a team before committing a new project install: older releases fail `prim doctor`
281
+ on such a file, and the reinstall they suggest restores the earlier text.
282
+
157
283
  ## Commands
158
284
 
159
285
  ### Setup
@@ -165,6 +291,8 @@ prim setup --agent codex # Same, for OpenAI Codex
165
291
  prim setup --agent hermes # Same, for Hermes Agent (global-only config)
166
292
  prim setup --no-daemon # Stop it and persistently opt out of supervised delivery
167
293
  prim setup --global-hooks-path # Also route every repository's git hooks through prim
294
+ prim setup --cloud --prepare # Claude Code cloud setup script: stage the hook runtime
295
+ prim setup --cloud # Claude Code cloud session: verify credentials, wire git hooks, activate
168
296
  ```
169
297
 
170
298
  Orchestrates auth → session hooks → supervised daemon → git hooks (`--scope project`, or `--global-hooks-path`) → skill → activate this repo (which wires its git hooks) → capture-health gate → welcome,
@@ -199,6 +327,7 @@ prim auth login # Authenticate via browser
199
327
  prim auth set-token <token> # Save a bearer token (e.g. for CI)
200
328
  prim auth clear # Remove saved tokens
201
329
  prim auth status # Check authentication status
330
+ prim auth enroll --new-installation <name> --print-env # Credentials for a cloud environment
202
331
  prim auth api-keys mint --name <name> [--expires-at <epoch-ms>] # Mint a user key; secret prints once
203
332
  prim auth api-keys list [--limit <count>] [--after <api-key-id>] # List user-key metadata
204
333
  prim auth api-keys revoke <api-key-id> # Revoke a user key
@@ -263,7 +392,17 @@ but the edit gate sees the changed gameplan path.
263
392
 
264
393
  Passive capture is repo-scoped even when these integrations are installed at user
265
394
  scope. `prim enable` marks the current Git repo active; `prim disable` makes it
266
- inactive. A project-scoped install activates its repo automatically. In an inactive
395
+ inactive. A project-scoped install activates its repo automatically. Both commands
396
+ act on your clone alone. `prim disable --scope project` also records the repository's
397
+ own opt-out, `PRIM_ACTIVE=false` under `env` in `.claude/settings.json`, for you to
398
+ commit: prim reads it from that file (never from the environment), and it turns off
399
+ automatic activation in every clone, including a project-scoped install's and a
400
+ prepared Claude Code cloud environment's. A `prim.active=true` you set yourself still
401
+ wins: `prim enable` in a clone, or the global flag for every repository. A clone that
402
+ prim had already activated automatically is turned off at its next agent session
403
+ after it receives the opt-out; one activated that way by an earlier prim version
404
+ cannot be told apart from `prim enable` and stays on until `prim disable`.
405
+ `prim enable --scope project` removes the opt-out. In an inactive
267
406
  repo, session content is not passively captured. Here “inactive” means Prim's normal
268
407
  effective capture check is false, including an explicit local `prim.active=false`.
269
408
 
package/SKILL.md CHANGED
@@ -17,6 +17,8 @@ Low-level capture runs automatically in active repos through the session hooks i
17
17
 
18
18
  Run `npx --yes @primitive.ai/prim auth status` first. It exits **0 if authenticated, 1 if not** -- branch on the exit code, don't parse the message.
19
19
 
20
+ **Claude Code cloud sessions** (`CLAUDE_CODE_REMOTE=true`): never run `auth login` or `auth enroll` there; prim authenticates cloud sessions only with credentials from the environment and refuses interactive sign-in. Use machine credentials (a fixed `PRIM_TOKEN` also works): `PRIM_M2M_CLIENT_ID` with `PRIM_M2M_CLIENT_SECRET`, or with `PRIM_M2M_CLIENT_AUTH=network-secret` when the secret is a network secret, or `PRIM_M2M_CLIENT_AUTH=network-token` when the environment's proxy holds the tokens too (an OAuth 2.0 client credentials network secret). When `auth status` fails, run `npx --yes @primitive.ai/prim setup --cloud` and relay each entry of its `remedies` to the user; the user mints credentials on their own machine with `prim auth enroll --new-installation "Claude Code cloud" --print-env`.
21
+
20
22
  Three ways to authenticate, in priority order:
21
23
 
22
24
  1. **`PRIM_TOKEN` environment variable** -- preferred for agents and CI. Set it before invoking prim and you're done; no interactive flow, no token files.
@@ -108,7 +110,10 @@ These questions share the interruption budget below; never ask separate question
108
110
 
109
111
  When passive capture is inactive for the current repo, do not silently turn a durable
110
112
  decision into a write. “Inactive” means Prim's effective repo-capture check is false;
111
- an explicit local `prim.active=false` is always inactive. Every
113
+ an explicit local `prim.active=false` is always inactive, and so is a repository
114
+ that commits its own opt-out (`PRIM_ACTIVE=false` under `env` in
115
+ `.claude/settings.json`) unless the user turned prim on themselves (`prim enable`
116
+ in that clone, or a global `prim.active=true`). Every
112
117
  `prim decisions create` invocation needs fresh user approval:
113
118
 
114
119
  - An explicit request to record or create that Decision is approval for that one
@@ -9,25 +9,34 @@ import {
9
9
  hookBlockContractVersion,
10
10
  inspectGitHookEntrypoint,
11
11
  managedHookBlock
12
- } from "./chunk-L32WYFJT.js";
12
+ } from "./chunk-UUQT5GMO.js";
13
13
  import {
14
14
  HttpError,
15
- getClient
16
- } from "./chunk-ZKXNJB6U.js";
15
+ getClient,
16
+ getSiteUrl
17
+ } from "./chunk-NVDPKW7Z.js";
17
18
  import {
19
+ CLOUD_CREDENTIALS_REMEDY,
20
+ MachineAuthError,
21
+ NETWORK_TOKEN_AUTH,
18
22
  atomicWriteFile,
19
23
  binFile,
20
24
  compareSemver,
21
25
  gitToplevel,
22
26
  githubRepositoryFullName,
27
+ hasMachineConfiguration,
28
+ isClaudeCloudSession,
23
29
  isValidRepoSyncId,
30
+ machineApiUrl,
31
+ originIdentifiesRepository,
24
32
  pinnedHookCommand,
25
33
  pinnedNpxCommand,
26
34
  primConfigDirectory,
35
+ resolveStoredCredential,
27
36
  setRepoSyncId,
28
37
  setRepositoryBindingState,
29
38
  withFileLock
30
- } from "./chunk-NJBN3WXF.js";
39
+ } from "./chunk-HZI5PBN4.js";
31
40
 
32
41
  // src/commands/skill.ts
33
42
  import { createHash as createHash3 } from "crypto";
@@ -790,6 +799,99 @@ function registerSkillCommands(program) {
790
799
  });
791
800
  }
792
801
 
802
+ // src/lib/cloud-session.ts
803
+ function isCloudMachineSession(env = process.env) {
804
+ if (!isClaudeCloudSession(env)) return false;
805
+ try {
806
+ return hasMachineConfiguration({ env });
807
+ } catch {
808
+ return true;
809
+ }
810
+ }
811
+ var PRODUCTION_SIGN_IN_HOST = "signin.getprimitive.ai";
812
+ var PROBE_TIMEOUT_MS = 3e3;
813
+ function repositoryIdentityRemedy(root) {
814
+ return originIdentifiesRepository(root) ? "this checkout's origin is not a GitHub repository in owner/name form; Primitive connects GitHub repositories only" : "this checkout does not identify its GitHub repository. Commit the repository declaration: run `prim claude install --scope project` in a clone whose origin is on GitHub, which records PRIM_REPOSITORY in .claude/settings.json";
815
+ }
816
+ function hostOf(url, fallback) {
817
+ try {
818
+ return new URL(url).hostname || fallback;
819
+ } catch {
820
+ return fallback;
821
+ }
822
+ }
823
+ function cloudAllowedDomains(siteUrl = getSiteUrl(), signInHost = PRODUCTION_SIGN_IN_HOST, env = process.env) {
824
+ const api = hostOf(siteUrl, "api.getprimitive.ai");
825
+ return env.PRIM_M2M_CLIENT_AUTH === NETWORK_TOKEN_AUTH ? [api] : [.../* @__PURE__ */ new Set([api, signInHost])];
826
+ }
827
+ function cloudEgressRemedy(siteUrl, signInHost, env) {
828
+ return `add ${cloudAllowedDomains(siteUrl, signInHost, env).join(" and ")} to the cloud environment's Allowed domains (Network access: Limited), then start a new cloud session (a running session keeps the network rules it started with)`;
829
+ }
830
+ function probeFailure(error) {
831
+ const name = error instanceof Error ? error.name : "";
832
+ if (name === "TimeoutError" || name === "AbortError") return "timeout";
833
+ const cause = error?.cause;
834
+ const code = typeof cause?.code === "string" ? cause.code : "";
835
+ const message = typeof cause?.message === "string" ? cause.message : "";
836
+ if (code === "ENOTFOUND" || code === "EAI_AGAIN") return "blocked";
837
+ if (/cancel|tunnel|\(403\)/iu.test(message) && !/\(5\d\d\)/u.test(message)) return "blocked";
838
+ return code || "network error";
839
+ }
840
+ async function probe(url, fetchImpl) {
841
+ try {
842
+ const response = await fetchImpl(url, {
843
+ redirect: "manual",
844
+ signal: AbortSignal.timeout(PROBE_TIMEOUT_MS)
845
+ });
846
+ return { ok: true, response };
847
+ } catch (error) {
848
+ return { ok: false, failure: probeFailure(error) };
849
+ }
850
+ }
851
+ function unreachable(what, failure, remedy) {
852
+ if (failure === "blocked") return `this environment cannot reach ${what}. To fix it, ${remedy}.`;
853
+ if (failure === "timeout")
854
+ return `${what} did not answer in time. If this persists, check that you ${remedy.replace(/^add /u, "added ")}.`;
855
+ return `${what} could not be reached (${failure}). Check the environment's network access: ${remedy}.`;
856
+ }
857
+ async function diagnoseCloudSession(options = {}) {
858
+ const env = options.env ?? process.env;
859
+ if (!isClaudeCloudSession(env)) return void 0;
860
+ const prefix = "Primitive is not connected in this Claude Code cloud session";
861
+ let machine;
862
+ try {
863
+ machine = hasMachineConfiguration({ env });
864
+ } catch (error) {
865
+ if (error instanceof MachineAuthError && (error.code === "conflicting_credentials" || env.PRIM_M2M_CLIENT_AUTH !== void 0))
866
+ return `${prefix}: ${error.message}`;
867
+ return `${prefix}: ${error instanceof MachineAuthError ? error.message : "its machine credentials are incomplete."} To fix it, ${CLOUD_CREDENTIALS_REMEDY}.`;
868
+ }
869
+ if (!machine && !resolveStoredCredential(env))
870
+ return `${prefix}: it has no credentials. To fix it, ${CLOUD_CREDENTIALS_REMEDY}.`;
871
+ if (options.cwd !== void 0 && !githubRepositoryFullName(options.cwd))
872
+ return `${prefix}: ${repositoryIdentityRemedy(options.cwd)}.`;
873
+ const fetchImpl = options.fetch ?? fetch;
874
+ const siteUrl = options.siteUrl ?? getSiteUrl();
875
+ const config = await probe(`${siteUrl.replace(/\/+$/u, "")}/api/cli/auth/m2m/config`, fetchImpl);
876
+ if (!config.ok)
877
+ return `${prefix}: ${unreachable("Primitive", config.failure, cloudEgressRemedy(siteUrl, void 0, env))}`;
878
+ if (machine && env.PRIM_M2M_CLIENT_AUTH !== NETWORK_TOKEN_AUTH) {
879
+ let issuer;
880
+ try {
881
+ const body = await config.response.json();
882
+ issuer = typeof body.issuer === "string" ? machineApiUrl(body.issuer) : void 0;
883
+ } catch {
884
+ issuer = void 0;
885
+ }
886
+ if (issuer) {
887
+ const signIn = await probe(issuer, fetchImpl);
888
+ if (!signIn.ok)
889
+ return `${prefix}: ${unreachable("Primitive's sign-in service", signIn.failure, cloudEgressRemedy(siteUrl, hostOf(issuer, PRODUCTION_SIGN_IN_HOST)))}`;
890
+ }
891
+ }
892
+ return `${prefix}: the repository could not be connected. Run \`prim setup --cloud\` for details.`;
893
+ }
894
+
793
895
  // src/lib/bin-cache.ts
794
896
  import { chmodSync, mkdirSync as mkdirSync2 } from "fs";
795
897
  import { homedir as homedir4 } from "os";
@@ -1881,7 +1983,9 @@ var InvalidRepositoryBindingResponseError = class extends Error {
1881
1983
  async function resolveRepositoryBindingWithClient(root, client, options) {
1882
1984
  const repositoryFullName = githubRepositoryFullName(root);
1883
1985
  if (!repositoryFullName) {
1884
- throw new Error("origin must be a GitHub HTTPS/SSH remote in owner/name form");
1986
+ throw new Error(
1987
+ originIdentifiesRepository(root) ? "origin must be a GitHub HTTPS/SSH remote in owner/name form" : "origin does not identify this checkout's repository; commit its repository declaration (`prim claude install --scope project`, run in a clone whose origin is on GitHub, records PRIM_REPOSITORY in .claude/settings.json)"
1988
+ );
1885
1989
  }
1886
1990
  let response;
1887
1991
  try {
@@ -1963,6 +2067,11 @@ function kickDaemonEnsure(options = {}) {
1963
2067
  }
1964
2068
 
1965
2069
  export {
2070
+ isCloudMachineSession,
2071
+ repositoryIdentityRemedy,
2072
+ cloudAllowedDomains,
2073
+ cloudEgressRemedy,
2074
+ diagnoseCloudSession,
1966
2075
  warmBinCache,
1967
2076
  isLegacyOwnedGlobalHook,
1968
2077
  gitHooksMode,
@@ -11,10 +11,10 @@ import {
11
11
  saveRun,
12
12
  sessionExcluded,
13
13
  sessionKey
14
- } from "./chunk-HPA7RGSZ.js";
14
+ } from "./chunk-MGKSZSTV.js";
15
15
  import {
16
16
  packageVersion
17
- } from "./chunk-NJBN3WXF.js";
17
+ } from "./chunk-HZI5PBN4.js";
18
18
 
19
19
  // src/demo/isolation.ts
20
20
  import { existsSync } from "fs";
@@ -1,23 +1,23 @@
1
1
  import {
2
2
  analyzeShellTargets,
3
3
  extractFileTargets
4
- } from "./chunk-HPA7RGSZ.js";
4
+ } from "./chunk-MGKSZSTV.js";
5
5
  import {
6
6
  DEFAULT_RULES,
7
7
  scrub
8
- } from "./chunk-74DQDWLW.js";
8
+ } from "./chunk-R4EYLEIK.js";
9
9
  import {
10
10
  boundedHealthError,
11
11
  isPreflightResponseV4
12
- } from "./chunk-O73J3KQQ.js";
12
+ } from "./chunk-WGTUNUIS.js";
13
13
  import {
14
14
  getClient,
15
15
  terminalSafeLine
16
- } from "./chunk-ZKXNJB6U.js";
16
+ } from "./chunk-NVDPKW7Z.js";
17
17
  import {
18
18
  canonicalGitRoot,
19
19
  canonicalRepositoryPath
20
- } from "./chunk-NJBN3WXF.js";
20
+ } from "./chunk-HZI5PBN4.js";
21
21
 
22
22
  // src/hooks/approval-copy.ts
23
23
  var MAX_EXCERPT_CHARS = 80;
@@ -55,9 +55,14 @@ function decisionLabel(conflict) {
55
55
  const title = typeof conflict.title === "string" ? displayText(conflict.title, MAX_TITLE_CHARS) : "";
56
56
  return title ? `Decision ${id}: \u201C${title}\u201D.` : `Decision ${id}: details unavailable; inspect it before approving.`;
57
57
  }
58
+ function isEmptyCheck(check) {
59
+ const coverage = check.evaluationCoverage;
60
+ return coverage?.status === "not_run" && coverage.candidateCount === 0 && (check.verdict === "allow" || check.verdict === "warn") && check.conflicts.length === 0;
61
+ }
58
62
  function incomplete(evidence) {
59
63
  const coverage = evidence.evaluationCoverage;
60
- return Array.isArray(coverage?.selectionOmissions) && coverage.selectionOmissions.length > 0 || Array.isArray(coverage?.evidenceOmissions) && coverage.evidenceOmissions.length > 0 || coverage?.status !== void 0 && coverage.status !== "completed" || ["candidate_set_truncated", "evidence_incomplete", "coverage_unverified"].includes(
64
+ const settled = coverage?.status === void 0 || coverage.status === "completed" || isEmptyCheck(evidence);
65
+ return Array.isArray(coverage?.selectionOmissions) && coverage.selectionOmissions.length > 0 || Array.isArray(coverage?.evidenceOmissions) && coverage.evidenceOmissions.length > 0 || !settled || ["candidate_set_truncated", "evidence_incomplete", "coverage_unverified"].includes(
61
66
  evidence.reasonCode
62
67
  );
63
68
  }
@@ -191,8 +196,16 @@ function proposedChangeExcerpt(proposal) {
191
196
  }
192
197
  return boundedHealthError(proposal);
193
198
  }
199
+ var COVERAGE_NOTE = "[primitive] Decision coverage is incomplete; some candidates or evidence were not evaluated.";
200
+ function coverageNote(response) {
201
+ const coverage = response.evaluationCoverage;
202
+ if (!coverage) return "";
203
+ const settled = coverage.status === "completed" || isEmptyCheck(response);
204
+ return !settled || coverage.selectionOmissions?.length || coverage.evidenceOmissions?.length ? COVERAGE_NOTE : "";
205
+ }
194
206
  function resultForPreflight(response, preview = "Review the requested change.", invocation, proposalTruncated = false) {
195
207
  const verdict = response.verdict === "block" ? "deny" : response.verdict;
208
+ const silentCoverageOutcome = response.reasonCode === "coverage_unverified" || response.reasonCode === "candidate_set_truncated";
196
209
  const message = boundedHealthError(response.message) ?? "";
197
210
  const unavailable = message || boundedHealthError(response.reasonCode);
198
211
  const safe = /^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;
@@ -220,16 +233,17 @@ function resultForPreflight(response, preview = "Review the requested change.",
220
233
  "Sandbox escalation, automatic review, prefix permissions, --yes, and an agent's assertion of approval do not authorize an override."
221
234
  ] : [];
222
235
  const guidance = [message, ...editContext, ...new Set(directives), ...approvalContext].filter(Boolean).join("\n");
223
- const reason = response.conflicts.length > 0 || response.verdict === "ask" || response.verdict === "block" ? approvalSummary(
236
+ const reason = silentCoverageOutcome ? "" : response.conflicts.length > 0 || response.verdict === "ask" || response.verdict === "block" ? approvalSummary(
224
237
  {
225
238
  conflicts: response.conflicts,
226
239
  message,
227
240
  reasonCode: response.reasonCode,
241
+ verdict: response.verdict,
228
242
  evaluationCoverage: response.evaluationCoverage
229
243
  },
230
244
  preview
231
245
  ) : message;
232
- const disclosureContext = decisionDisclosureContext(response);
246
+ const disclosureContext = silentCoverageOutcome ? "" : decisionDisclosureContext(response);
233
247
  const truncationNote = proposalTruncated ? "[primitive] shell proposal was truncated; the complete change was not verified" : "";
234
248
  return {
235
249
  verdict,
@@ -238,7 +252,7 @@ function resultForPreflight(response, preview = "Review the requested change.",
238
252
  additionalContext: [
239
253
  disclosureContext,
240
254
  truncationNote,
241
- ["warn", "ask", "block"].includes(response.verdict) ? guidance : ""
255
+ !silentCoverageOutcome && ["warn", "ask", "block"].includes(response.verdict) ? guidance : ""
242
256
  ].filter(Boolean).join("\n"),
243
257
  truncated: false,
244
258
  unavailable: response.verdict === "unavailable" ? unavailable : void 0
@@ -469,6 +483,7 @@ export {
469
483
  proposalFor,
470
484
  proposalIsTruncated,
471
485
  requestPreflight,
486
+ coverageNote,
472
487
  resultForPreflight,
473
488
  unverifiedResult,
474
489
  PREFLIGHT_PROTOCOL_VERSION2 as PREFLIGHT_PROTOCOL_VERSION,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  atomicWriteFile,
3
3
  repoActiveFlag
4
- } from "./chunk-NJBN3WXF.js";
4
+ } from "./chunk-HZI5PBN4.js";
5
5
 
6
6
  // src/lib/commit-heartbeat.ts
7
7
  import { execFileSync } from "child_process";
@@ -4,7 +4,7 @@ import {
4
4
  machineContext,
5
5
  primConfigDirectory,
6
6
  resolveAuthCredential
7
- } from "./chunk-NJBN3WXF.js";
7
+ } from "./chunk-HZI5PBN4.js";
8
8
 
9
9
  // src/daemon/principal.ts
10
10
  import { createHash } from "crypto";
@@ -2,10 +2,10 @@ import {
2
2
  cursorHooksPath,
3
3
  hasExactCursorHandler,
4
4
  readCursorHooks
5
- } from "./chunk-L32WYFJT.js";
5
+ } from "./chunk-UUQT5GMO.js";
6
6
  import {
7
7
  resolveRepositoryContext
8
- } from "./chunk-NJBN3WXF.js";
8
+ } from "./chunk-HZI5PBN4.js";
9
9
 
10
10
  // src/hooks/cursor-coexistence.ts
11
11
  var CURSOR_EVENTS = /* @__PURE__ */ new Set([