@diffci.com/diffci 0.3.42 → 0.3.44

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.
@@ -15,9 +15,17 @@ export declare function ignoredWrites(repoPath: string, results: readonly string
15
15
  * instruction. Growth depends on the agent finding DiffCI's tools in the repository without anyone
16
16
  * installing a plugin, so one `diffci init` now registers them. Each write keeps files and servers
17
17
  * DiffCI did not write.
18
+ *
19
+ * 2026-11-14: also the hyperscalers' coding agents. Kiro gets `.kiro/settings/mcp.json` (the read-only
20
+ * tools auto-approved; it still asks before tests run) and `.kiro/skills`; Antigravity CLI gets
21
+ * `.agents/mcp_config.json` and `.agents/skills`, which Codex reads too. GitHub Copilot needs no file of
22
+ * its own for these: VS Code reads the root `.mcp.json`, and Copilot reads `.claude/skills`.
18
23
  */
19
- export declare const MCP_CONFIG_PATHS: readonly [".mcp.json", ".cursor/mcp.json"];
24
+ export declare const MCP_CONFIG_PATHS: readonly [".mcp.json", ".cursor/mcp.json", ".kiro/settings/mcp.json", ".agents/mcp_config.json"];
20
25
  export declare const SKILL_PATH = ".claude/skills/diffci-verify/SKILL.md";
26
+ export declare const SKILL_PATHS: readonly [".claude/skills/diffci-verify/SKILL.md", ".agents/skills/diffci-verify/SKILL.md", ".kiro/skills/diffci-verify/SKILL.md"];
27
+ /** MCP tools that only read the checkout; Kiro runs them without asking. */
28
+ export declare const KIRO_AUTO_APPROVE: readonly ["diffci_changed_files", "diffci_select_tests", "diffci_explain_selection"];
21
29
  /** Same launcher as the portable agent plugin: `npx` through cmd.exe on Windows, where agents cannot spawn `npx.cmd` directly. */
22
30
  export declare function mcpServerEntry(version: string): {
23
31
  command: string;
@@ -32,10 +40,16 @@ export declare const DIFFCI_VERIFY_SKILL = "---\nname: diffci-verify\ndescriptio
32
40
  * agent's project hook file. Claude Code and Codex share one shape (`Stop` > group > handlers); Cursor has
33
41
  * its own (`version: 1`, `stop` > handlers). A hook is DiffCI's when its command runs `agent-stop` from
34
42
  * the DiffCI package; those are replaced, every other hook is kept.
43
+ *
44
+ * GitHub Copilot (2026-11-14): `agentStop` in `.github/hooks/diffci.json` (`version: 1`, handlers with
45
+ * `bash` and `powershell` commands), read by Copilot CLI, the cloud agent and VS Code. Its documented
46
+ * `{"decision": "block", "reason"}` output forces another turn. Kiro has no hook here: its `Stop`
47
+ * trigger is documented as unable to block, so it could not make the agent fix a failure.
35
48
  */
36
- export declare const AGENT_HOOK_PATHS: Record<"claude" | "codex" | "cursor", string>;
49
+ export type SetupHookAgent = "claude" | "codex" | "cursor" | "copilot";
50
+ export declare const AGENT_HOOK_PATHS: Record<SetupHookAgent, string>;
37
51
  /** Seconds the agent waits for the hook; verify's own timeout stays below it (cli.ts, agent-stop). */
38
52
  export declare const AGENT_HOOK_TIMEOUT_SECONDS = 1200;
39
- export declare function writeAgentStopHook(repoPath: string, agent: "claude" | "codex" | "cursor", launcher: string): string;
53
+ export declare function writeAgentStopHook(repoPath: string, agent: SetupHookAgent, launcher: string): string;
40
54
  /** A skill file DiffCI wrote is recognised by its frontmatter name and updated; any other file is kept. */
41
- export declare function writeSkill(repoPath: string, force: boolean): string;
55
+ export declare function writeSkill(repoPath: string, force: boolean, relativePath?: string): string;
@@ -32,9 +32,22 @@ export function ignoredWrites(repoPath, results) {
32
32
  * instruction. Growth depends on the agent finding DiffCI's tools in the repository without anyone
33
33
  * installing a plugin, so one `diffci init` now registers them. Each write keeps files and servers
34
34
  * DiffCI did not write.
35
+ *
36
+ * 2026-11-14: also the hyperscalers' coding agents. Kiro gets `.kiro/settings/mcp.json` (the read-only
37
+ * tools auto-approved; it still asks before tests run) and `.kiro/skills`; Antigravity CLI gets
38
+ * `.agents/mcp_config.json` and `.agents/skills`, which Codex reads too. GitHub Copilot needs no file of
39
+ * its own for these: VS Code reads the root `.mcp.json`, and Copilot reads `.claude/skills`.
35
40
  */
36
- export const MCP_CONFIG_PATHS = [".mcp.json", ".cursor/mcp.json"];
41
+ export const MCP_CONFIG_PATHS = [".mcp.json", ".cursor/mcp.json", ".kiro/settings/mcp.json", ".agents/mcp_config.json"];
37
42
  export const SKILL_PATH = ".claude/skills/diffci-verify/SKILL.md";
43
+ export const SKILL_PATHS = [SKILL_PATH, ".agents/skills/diffci-verify/SKILL.md", ".kiro/skills/diffci-verify/SKILL.md"];
44
+ const SKILL_AGENTS = {
45
+ [SKILL_PATH]: "Claude Code and Copilot skill",
46
+ ".agents/skills/diffci-verify/SKILL.md": "Antigravity CLI and Codex skill",
47
+ ".kiro/skills/diffci-verify/SKILL.md": "Kiro skill",
48
+ };
49
+ /** MCP tools that only read the checkout; Kiro runs them without asking. */
50
+ export const KIRO_AUTO_APPROVE = ["diffci_changed_files", "diffci_select_tests", "diffci_explain_selection"];
38
51
  /** Same launcher as the portable agent plugin: `npx` through cmd.exe on Windows, where agents cannot spawn `npx.cmd` directly. */
39
52
  export function mcpServerEntry(version) {
40
53
  return {
@@ -52,6 +65,8 @@ function isDiffciEntry(entry) {
52
65
  export function writeMcpConfig(repoPath, relativePath, version, force) {
53
66
  const absolutePath = join(repoPath, relativePath);
54
67
  const entry = mcpServerEntry(version);
68
+ if (relativePath === ".kiro/settings/mcp.json")
69
+ entry.autoApprove = [...KIRO_AUTO_APPROVE];
55
70
  let config = {};
56
71
  let existing;
57
72
  if (existsSync(absolutePath)) {
@@ -115,16 +130,11 @@ counts, outcome, and any outstanding required checks. Never infer passed suites,
115
130
  test cases, skipped CI jobs, or measured savings from selection counts. Required
116
131
  project CI stays authoritative.
117
132
  `;
118
- /**
119
- * Stop hooks that run `diffci agent-stop` when the agent ends a turn (agent-stop.ts, 2026-11-06), in each
120
- * agent's project hook file. Claude Code and Codex share one shape (`Stop` > group > handlers); Cursor has
121
- * its own (`version: 1`, `stop` > handlers). A hook is DiffCI's when its command runs `agent-stop` from
122
- * the DiffCI package; those are replaced, every other hook is kept.
123
- */
124
133
  export const AGENT_HOOK_PATHS = {
125
134
  claude: ".claude/settings.json",
126
135
  codex: ".codex/hooks.json",
127
136
  cursor: ".cursor/hooks.json",
137
+ copilot: ".github/hooks/diffci.json",
128
138
  };
129
139
  /** Seconds the agent waits for the hook; verify's own timeout stays below it (cli.ts, agent-stop). */
130
140
  export const AGENT_HOOK_TIMEOUT_SECONDS = 1200;
@@ -154,6 +164,15 @@ export function writeAgentStopHook(repoPath, agent, launcher) {
154
164
  const stop = Array.isArray(hooks.stop) ? hooks.stop.filter((entry) => !isDiffciHook(entry?.command)) : [];
155
165
  config = { ...config, version: typeof config.version === "number" ? config.version : 1, hooks: { ...hooks, stop: [...stop, { command, loop_limit: 3 }] } };
156
166
  }
167
+ else if (agent === "copilot") {
168
+ const ours = (entry) => ["bash", "powershell", "command"].some((key) => isDiffciHook(entry?.[key]));
169
+ const stop = Array.isArray(hooks.agentStop) ? hooks.agentStop.filter((entry) => !ours(entry)) : [];
170
+ config = {
171
+ ...config,
172
+ version: typeof config.version === "number" ? config.version : 1,
173
+ hooks: { ...hooks, agentStop: [...stop, { type: "command", bash: command, powershell: command, timeoutSec: AGENT_HOOK_TIMEOUT_SECONDS }] },
174
+ };
175
+ }
157
176
  else {
158
177
  const groups = (Array.isArray(hooks.Stop) ? hooks.Stop : []).flatMap((group) => {
159
178
  const handlers = Array.isArray(group?.hooks) ? group.hooks : [];
@@ -170,19 +189,19 @@ export function writeAgentStopHook(repoPath, agent, launcher) {
170
189
  return `${existing === undefined ? "wrote" : "updated"} ${relativePath} (DiffCI stop hook)`;
171
190
  }
172
191
  /** A skill file DiffCI wrote is recognised by its frontmatter name and updated; any other file is kept. */
173
- export function writeSkill(repoPath, force) {
174
- const absolutePath = join(repoPath, SKILL_PATH);
192
+ export function writeSkill(repoPath, force, relativePath = SKILL_PATH) {
193
+ const absolutePath = join(repoPath, relativePath);
175
194
  if (existsSync(absolutePath)) {
176
195
  const existing = readFileSync(absolutePath, "utf8");
177
196
  if (existing.replace(/\r\n/g, "\n") === DIFFCI_VERIFY_SKILL)
178
- return `kept ${SKILL_PATH} (current)`;
197
+ return `kept ${relativePath} (current)`;
179
198
  if (!/^---\r?\nname: diffci-verify\r?\n/.test(existing) && !force) {
180
- return `kept ${SKILL_PATH} (existing file not written by DiffCI; pass --force to replace it)`;
199
+ return `kept ${relativePath} (existing file not written by DiffCI; pass --force to replace it)`;
181
200
  }
182
201
  writeFileSync(absolutePath, DIFFCI_VERIFY_SKILL, "utf8");
183
- return `updated ${SKILL_PATH}`;
202
+ return `updated ${relativePath}`;
184
203
  }
185
204
  mkdirSync(dirname(absolutePath), { recursive: true });
186
205
  writeFileSync(absolutePath, DIFFCI_VERIFY_SKILL, "utf8");
187
- return `wrote ${SKILL_PATH} (Claude Code skill)`;
206
+ return `wrote ${relativePath} (${SKILL_AGENTS[relativePath] ?? "skill"})`;
188
207
  }
@@ -6,24 +6,26 @@ import type { VerificationReport } from "./verify.js";
6
6
  * verify is advice an agent can skip; a hook on the end of its turn is not. The agent finds out what its
7
7
  * change broke before it tells anyone the work is done.
8
8
  *
9
- * WHAT. `diffci agent-stop --agent claude|codex|cursor` is the command the agent's stop hook runs
9
+ * WHAT. `diffci agent-stop --agent claude|codex|cursor|copilot` is the command the agent's stop hook runs
10
10
  * (Claude Code `Stop` in .claude/settings.json, Codex `Stop` in .codex/hooks.json, Cursor `stop` in
11
- * .cursor/hooks.json; `diffci init` installs them). It reads the hook's JSON from stdin, verifies the
11
+ * .cursor/hooks.json, GitHub Copilot `agentStop` in .github/hooks/diffci.json; `diffci init` installs them). It reads the hook's JSON from stdin, verifies the
12
12
  * uncommitted changes, and:
13
13
  * - passes quietly when nothing changed or verification passed;
14
14
  * - when tests or checks fail, asks the agent to continue with the failures as the reason (Claude Code
15
- * and Codex: `{"decision": "block", "reason"}`; Cursor: `{"followup_message"}`);
15
+ * Codex and Copilot: `{"decision": "block", "reason"}`; Cursor: `{"followup_message"}`);
16
16
  * - never holds the agent when verification could not run (blocked analysis, no command): that is
17
17
  * reported to the person, not turned into work for the agent;
18
18
  * - hands back to the person after DIFFCI_AGENT_HOOK_MAX failed attempts in one session (default 3),
19
19
  * counted in .git/diffci/agent-hook.json and reset by a pass, on top of the agents' own loop limits.
20
20
  * DIFFCI_AGENT_HOOK=0 turns it off. Repeats on an unchanged tree are instant through result reuse.
21
21
  */
22
- export type HookAgent = "claude" | "codex" | "cursor";
22
+ export type HookAgent = "claude" | "codex" | "cursor" | "copilot";
23
23
  export declare const HOOK_AGENTS: readonly HookAgent[];
24
24
  export declare const DEFAULT_MAX_ATTEMPTS = 3;
25
25
  export interface StopPayload {
26
26
  session_id?: string;
27
+ /** GitHub Copilot's `agentStop` payload. */
28
+ sessionId?: string;
27
29
  conversation_id?: string;
28
30
  cwd?: string;
29
31
  workspace_roots?: string[];
@@ -2,7 +2,7 @@ import { execFileSync } from "node:child_process";
2
2
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
3
  import { dirname, join } from "node:path";
4
4
  import { outcomeLogPath } from "./outcome-log.js";
5
- export const HOOK_AGENTS = ["claude", "codex", "cursor"];
5
+ export const HOOK_AGENTS = ["claude", "codex", "cursor", "copilot"];
6
6
  export const DEFAULT_MAX_ATTEMPTS = 3;
7
7
  export function parseStopPayload(text) {
8
8
  try {
@@ -24,7 +24,7 @@ export function stopRepoPath(payload, env, fallback) {
24
24
  }
25
25
  }
26
26
  function sessionKey(payload) {
27
- return payload.session_id ?? payload.conversation_id ?? "unknown";
27
+ return payload.session_id ?? payload.sessionId ?? payload.conversation_id ?? "unknown";
28
28
  }
29
29
  function attemptsPath(repoPath) {
30
30
  const log = outcomeLogPath(repoPath);
@@ -76,7 +76,8 @@ function failureReason(report, attempt, max) {
76
76
  */
77
77
  export function decideStop(agent, report, failuresSoFar, max) {
78
78
  const allow = (message) => ({
79
- stdout: JSON.stringify(message && agent !== "cursor" ? { systemMessage: message } : {}),
79
+ // Cursor and Copilot document no field for a message to the person.
80
+ stdout: JSON.stringify(message && agent !== "cursor" && agent !== "copilot" ? { systemMessage: message } : {}),
80
81
  failures: 0,
81
82
  });
82
83
  if (!report)
@@ -12,6 +12,9 @@
12
12
  * init seed a repository with AI-agent instructions for using DiffCI
13
13
  * mcp run the stdio MCP server
14
14
  * verify fail-closed verification of a working-tree snapshot or commit range
15
+ * watch verify changes after each save
16
+ * agent-stop verify changes when an AI agent finishes a turn
17
+ * telemetry configure anonymous usage reporting
15
18
  * gate run a build's whole gate and record what DiffCI would have skipped (observe)
16
19
  * check analysis plus automatic paired runtime measurement
17
20
  * plan print Core's advisory JSON plan for a commit range (the input check-plan reads)
@@ -19,9 +22,13 @@
19
22
  * red-builds count a repository's red PR builds a check before the push could have prevented
20
23
  * observe analyse the checkout and write an observation report
21
24
  * verify-savings run a paired full-versus-selected timing check
25
+ * pilot run observation and verification savings
26
+ * pilot-packet generate a shareable compatibility packet
22
27
  * validate-specs block conflicting same-turn change specifications
23
28
  * verify-workflow check that a DiffCI job in this repository's workflows cannot affect other jobs
24
29
  * enforce-misses after a full run on main, find failures enforce mode would have skipped
30
+ * coverage build a test coverage map
31
+ * outcomes summarize previous verification outcomes
25
32
  * version print the observer version
26
33
  *
27
34
  * Exit codes: `observe` exits 0 even when it refuses or errors, because a broken observer must not
@@ -40,13 +47,13 @@ import { resolveObservationAgent } from "./agent-identity.js";
40
47
  import { inferFullCommand, inferComparableSelectedCommand, inferWorkspaceComparison } from "./full-command.js";
41
48
  import { addDiffciPackageScripts, detectPackageManager, installDiffci } from "./install.js";
42
49
  import { hookCommand, installPrePushHook, isGitRepository } from "./hook.js";
43
- import { AGENT_HOOK_TIMEOUT_SECONDS, ignoredWrites, MCP_CONFIG_PATHS, SKILL_PATH, writeAgentStopHook, writeMcpConfig, writeSkill } from "./agent-setup.js";
50
+ import { AGENT_HOOK_TIMEOUT_SECONDS, ignoredWrites, MCP_CONFIG_PATHS, SKILL_PATHS, writeAgentStopHook, writeMcpConfig, writeSkill } from "./agent-setup.js";
44
51
  import { submitObservation } from "./submit.js";
45
52
  import { configureGraphCache } from "./shared-graph-cache.js";
46
53
  import { GraphCache } from "@diffci.com/core/cache/graph-cache";
47
54
  import { githubDeliveryWarning } from "./delivery-warning.js";
48
55
  import { formatJobSummary } from "./job-summary.js";
49
- import { configureTelemetry, readTelemetryPreference, recordUsage } from "./telemetry.js";
56
+ import { configureTelemetry, readTelemetryPreference, recordUsage, telemetryNotice } from "./telemetry.js";
50
57
  import { formatFeedbackPrompt, markFeedbackPromptShown, shouldShowFeedbackPrompt } from "./feedback-prompt.js";
51
58
  import { detectSpecificationConflicts, readSpecificationFile } from "./spec-conflicts.js";
52
59
  import { formatVerificationSummary, verificationExitCode, verifyChanged, verifyRange } from "./verify.js";
@@ -118,9 +125,10 @@ function readCheckPlanInput(path) {
118
125
  closeSync(descriptor);
119
126
  }
120
127
  }
121
- const PLAN_USAGE = "Usage: diffci plan --base <commit> [--head HEAD] [--repo <clean-checkout>]\nPrints Core's advisory JSON plan, the input check-plan reads. Accepts --flag=value. Does not run, skip or cancel tests.";
128
+ const PLAN_USAGE = "Usage: diffci plan --base <commit> [--head HEAD] [--repo <clean-checkout>]\nPrints Core's advisory JSON plan, the input check-plan reads. Accepts --flag=value. Does not run, skip or cancel tests.\nCounts the run with the repository name (see diffci telemetry); DO_NOT_TRACK=1 stops counting.";
122
129
  /** Same output and exit codes as Core's own `plan` command, so saved plans stay interchangeable. */
123
130
  async function runPlanCommand(args) {
131
+ let repoPath;
124
132
  try {
125
133
  if (args.length === 1 && (args[0] === "--help" || args[0] === "-h")) {
126
134
  console.log(PLAN_USAGE);
@@ -144,12 +152,16 @@ async function runPlanCommand(args) {
144
152
  if (!base)
145
153
  throw new Error("Expected: diffci plan --base <commit> [--head HEAD] [--repo <path>]");
146
154
  const { analyzeCheckout } = await import("@diffci.com/core/analyze");
147
- const plan = await analyzeCheckout({ repoPath: values.get("--repo") ?? process.cwd(), base, head: values.get("--head") ?? "HEAD" });
155
+ repoPath = values.get("--repo") ?? process.cwd();
156
+ const plan = await analyzeCheckout({ repoPath, base, head: values.get("--head") ?? "HEAD" });
148
157
  console.log(JSON.stringify(plan, null, 2));
158
+ await recordUsage("plan", plan.plan.mode === "SELECTIVE" ? "selective" : "full", observerIdentity().version, {}, process.env, repoPath);
149
159
  return 0;
150
160
  }
151
161
  catch (error) {
152
162
  console.error(JSON.stringify({ error: error instanceof Error ? error.message : String(error), recommendation: "RUN_FULL_CI" }));
163
+ if (repoPath !== undefined)
164
+ await recordUsage("plan", "error", observerIdentity().version, {}, process.env, repoPath);
153
165
  return 1;
154
166
  }
155
167
  }
@@ -410,9 +422,10 @@ function runInit(flags, env) {
410
422
  for (const path of MCP_CONFIG_PATHS)
411
423
  writes.push(writeMcpConfig(repoPath, path, identity.version, force));
412
424
  if (flags["no-skill"] === true)
413
- skipped.push(`skipped ${SKILL_PATH} (--no-skill)`);
425
+ skipped.push("skipped the diffci-verify skills (--no-skill)");
414
426
  else
415
- writes.push(writeSkill(repoPath, force));
427
+ for (const path of SKILL_PATHS)
428
+ writes.push(writeSkill(repoPath, force, path));
416
429
  if (flags["no-agent-hooks"] === true)
417
430
  skipped.push("skipped the agent stop hooks (--no-agent-hooks)");
418
431
  else
@@ -445,7 +458,7 @@ function runInit(flags, env) {
445
458
  if (!includeVerificationWorkflow)
446
459
  console.log(" skipped .github/workflows/diffci-verify.yml (pass --verification-workflow to add it)");
447
460
  console.log(`\nDefault agent command: ${agentCommand}`);
448
- console.log("\nOptional telemetry is off unless you have opted in. Use diffci telemetry --mode anonymous for execution counts, or --mode installations to also share a random installation ID. No repository content is sent. Use --mode off to disable; --no-send always overrides consent.");
461
+ console.log("\nDiffCI counts plan, check, observe and verify runs with the repository name (host/owner/repo), never its content. diffci telemetry --mode count-only drops the name; DO_NOT_TRACK=1 stops counting.");
449
462
  return 0;
450
463
  }
451
464
  function runMcp() {
@@ -625,7 +638,7 @@ async function runVerifyCommand(flags, env) {
625
638
  headOverride: stringFlag(flags, "head"),
626
639
  policy,
627
640
  });
628
- await recordUsage("verify", report.verification, identity.version, flags, env);
641
+ await recordUsage("verify", report.verification, identity.version, flags, env, repoPath);
629
642
  if (flags["no-log"] !== true)
630
643
  appendOutcome(repoPath, report, env);
631
644
  if (reportPath) {
@@ -831,11 +844,11 @@ function summarise(report, executionFollows = false) {
831
844
  async function runCheck(flags, env) {
832
845
  const repoPath = resolve(stringFlag(flags, "repo") ?? env.GITHUB_WORKSPACE ?? process.cwd());
833
846
  const reportPath = resolve(stringFlag(flags, "out") ?? defaultReportPath(env));
834
- const observationCode = await runObserve({ ...flags, out: reportPath, quiet: true, "no-send": true }, env);
847
+ const observationCode = await runObserve({ ...flags, out: reportPath, quiet: true, "no-send": true, "skip-usage": true }, env);
835
848
  if (observationCode !== 0)
836
849
  return observationCode;
837
850
  const observation = JSON.parse(readFileSync(reportPath, "utf8"));
838
- await recordUsage("check", observation.status === "OBSERVED" ? "observed" : observation.status === "REFUSED" ? "refused" : "error", observerIdentity().version, flags, env);
851
+ await recordUsage("check", observation.status === "OBSERVED" ? "observed" : observation.status === "REFUSED" ? "refused" : "error", observerIdentity().version, flags, env, repoPath);
839
852
  const print = (message) => { if (flags.quiet !== true && flags.json !== true)
840
853
  console.log(message); };
841
854
  print(summarise(observation, true));
@@ -978,7 +991,9 @@ async function runObserve(flags, env) {
978
991
  });
979
992
  mkdirSync(dirname(reportPath), { recursive: true });
980
993
  writeFileSync(reportPath, `${JSON.stringify(report, null, 2)}\n`, "utf8");
981
- await recordUsage("observe", report.status === "OBSERVED" ? "observed" : report.status === "REFUSED" ? "refused" : "error", identity.version, flags, env);
994
+ // check counts itself; its inner observation is not a second run.
995
+ if (flags["skip-usage"] !== true)
996
+ await recordUsage("observe", report.status === "OBSERVED" ? "observed" : report.status === "REFUSED" ? "refused" : "error", identity.version, flags, env, repoPath);
982
997
  const summary = summarise(report);
983
998
  if (flags.json === true) {
984
999
  console.log(JSON.stringify(report, null, 2));
@@ -1407,18 +1422,18 @@ Usage:
1407
1422
  diffci init [--repo <path>] [--workflow] [--verification-workflow] [--install] [--no-hook] [--no-mcp] [--no-skill]
1408
1423
  [--no-agent-hooks] [--force]
1409
1424
  diffci watch [--repo <path>] [--checks] [--debounce-ms <ms>] [--no-log]
1410
- diffci agent-stop --agent claude|codex|cursor (run by the agent stop hooks init installs; reads the hook JSON on stdin)
1425
+ diffci agent-stop --agent claude|codex|cursor|copilot (run by the agent stop hooks init installs; reads the hook JSON on stdin)
1411
1426
  diffci mcp
1412
1427
  diffci verify [--changed | --base <sha> --head <sha>] [--policy enforce] [--repo <path>] [--out <file>] [--json]
1413
1428
  [--redact-paths] [--timeout-ms <ms>] [--baseline-on-failure] [--no-checks | --checks]
1414
1429
  [--share-usage] [--no-send] [--no-log] [--no-reuse] [--no-rank] [--fail-fast]
1415
1430
  [--shard <i/N> [--timings <file>]] [--no-coverage]
1416
- diffci telemetry [--mode off|anonymous|installations] [--internal-usage]
1431
+ diffci telemetry [--mode repo|count-only] [--internal-usage]
1417
1432
  diffci check [--repo <path>] [--out <file>] [--base <sha> --head <sha>]
1418
1433
  [--redact-paths] [--json] [--quiet] [--fail-on-error] [--timeout-ms <ms>] [--share-usage]
1419
1434
  diffci plan --base <sha> [--head <sha>] [--repo <path>]
1420
1435
  diffci check-plan --plan <plan.json> --results <junit.xml>
1421
- diffci red-builds <owner/repo> [--runs <n>] [--workflow <id|file>] [--json <file>]
1436
+ diffci red-builds <owner/repo> [--runs <n>] [--workflow <id|file>] [--json <file>] [--check-jobs <regex>] [--ci-only-jobs <regex>]
1422
1437
  diffci pilot --full <command> [--selected <command>] [--repo <path>] [--out-dir <dir>] [--label <name>]
1423
1438
  diffci pilot-packet [--repo <path>] [--out-dir <dir>] [--base <sha> --head <sha>]
1424
1439
  [--label <name>] [--repository-url <https-url>] [--redact-paths]
@@ -1445,9 +1460,11 @@ Usage:
1445
1460
  diffci version
1446
1461
 
1447
1462
  init writes AGENTS.md, CLAUDE.md, Cursor rules, Copilot instructions, and diffci.config.json. It also
1448
- registers the DiffCI MCP server in .mcp.json (Claude Code) and .cursor/mcp.json (Cursor), keeping other
1449
- servers, adds the diffci-verify skill to .claude/skills, installs the pre-push hook, and adds stop hooks
1450
- (.claude/settings.json, .codex/hooks.json, .cursor/hooks.json) that run diffci agent-stop when an agent ends a
1463
+ registers the DiffCI MCP server in .mcp.json (Claude Code, VS Code), .cursor/mcp.json (Cursor),
1464
+ .kiro/settings/mcp.json (Kiro) and .agents/mcp_config.json (Antigravity CLI), keeping other servers, adds the
1465
+ diffci-verify skill to .claude/skills, .agents/skills and .kiro/skills, installs the pre-push hook, and adds stop
1466
+ hooks (.claude/settings.json, .codex/hooks.json, .cursor/hooks.json, .github/hooks/diffci.json for GitHub
1467
+ Copilot) that run diffci agent-stop when an agent ends a
1451
1468
  turn: it verifies the uncommitted changes and, when tests or checks fail, asks the agent to fix them before
1452
1469
  finishing, at most DIFFCI_AGENT_HOOK_MAX times a session (default 3; DIFFCI_AGENT_HOOK=0 turns it off).
1453
1470
  --no-mcp, --no-skill, --no-hook and --no-agent-hooks leave each out. --workflow adds a separate non-blocking observation workflow. --install detects npm, pnpm, Yarn,
@@ -1516,10 +1533,12 @@ either way. Plain http is refused; the token is never printed.
1516
1533
  directory outside the checkout. --shared-graph-cache (or DIFFCI_SHARED_GRAPH_CACHE=1) also shares them via
1517
1534
  DiffCI Cloud (Team/Business) using the api-url and api-token; DIFFCI_GRAPH_CACHE_SECRET encrypts them
1518
1535
  client-side. Graphs hold paths and import edges, never file contents; a cache failure only means a local build.
1519
- --share-usage (or DIFFCI_SHARE_USAGE=1) opts in to command, outcome, version, surface and activity reporting.
1520
- diffci telemetry --mode anonymous saves consent; --mode installations also shares a random local installation ID.
1521
- --mode off disables saved consent and deletes the ID. --internal-usage labels tests/internal activity.
1522
- No repository, commit, test, report, paths, or machine details are sent. --no-send or DIFFCI_NO_SEND=1 disables it.
1536
+ Usage counting is on: plan, check, observe and verify send command, outcome, version, surface, CI or local,
1537
+ activity, a random local installation ID and the repository name (host/owner/repo from GITHUB_REPOSITORY,
1538
+ GitLab CI or the origin remote). diffci telemetry --mode count-only drops the name and the ID; --mode repo
1539
+ restores them. --internal-usage labels tests/internal activity. No commit, path, test, report, content or
1540
+ machine details are sent. Only DO_NOT_TRACK=1, DIFFCI_NO_SEND=1 or DIFFCI_SHARE_USAGE=0 stop counting;
1541
+ --no-send stops report uploads only.
1523
1542
  Interactive check and observe runs print feedback links to stderr at most weekly; they send nothing.
1524
1543
  CI, MCP, --json and --quiet never show them; DIFFCI_NO_FEEDBACK_PROMPT=1 hides them.
1525
1544
  `;
@@ -1557,7 +1576,7 @@ async function main() {
1557
1576
  const mode = stringFlag(flags, "mode");
1558
1577
  const preference = mode ? configureTelemetry(mode, flags["internal-usage"] === true, env) : readTelemetryPreference(env);
1559
1578
  console.log(`DiffCI telemetry: ${preference.mode}; activity: ${preference.internal ? "internal" : "external"}.`);
1560
- console.log("Reporting includes command, outcome, version, surface and activity. Installation mode adds a random local ID; installations are not people. No repository content or machine details are sent. --no-send always overrides consent.");
1579
+ console.log(telemetryNotice(preference.mode));
1561
1580
  process.exitCode = 0;
1562
1581
  return;
1563
1582
  }
@@ -27,8 +27,8 @@ export function formatFeedbackPrompt(telemetry) {
27
27
  " volunteer a pilot: https://diffci.com/#pilot",
28
28
  " star the engine: https://github.com/DiffCI/core",
29
29
  ];
30
- if (telemetry === "off")
31
- lines.push(" share anonymous run counts: diffci telemetry --mode anonymous (no repository content)");
30
+ if (telemetry === "repo")
31
+ lines.push(" run counts include this repository name; diffci telemetry --mode count-only drops it");
32
32
  lines.push("Shown at most weekly; DIFFCI_NO_FEEDBACK_PROMPT=1 hides it.");
33
33
  return lines.join("\n");
34
34
  }
@@ -53,7 +53,7 @@ const tools = [
53
53
  },
54
54
  {
55
55
  name: "diffci_check",
56
- description: "Analyze the repository, run inferred full and selected test commands when available, and report paired runtime. No report is uploaded. Optional aggregate telemetry follows the user's saved consent; DIFFCI_NO_SEND=1 overrides it.",
56
+ description: "Analyze the repository, run inferred full and selected test commands when available, and report paired runtime. No report is uploaded. The run is counted with the repository name unless the user chose count-only; DO_NOT_TRACK=1 stops counting.",
57
57
  inputSchema: {
58
58
  type: "object",
59
59
  properties: {
@@ -36,6 +36,9 @@ export declare function bucketJob(job: JobSummary, patterns?: Patterns): JobBuck
36
36
  export declare function isAggregateJob(job: JobSummary): boolean;
37
37
  /** Failure signatures of one job: annotation path, title and first message line, with volatile parts blurred. */
38
38
  export declare function signatures(annotations: Annotation[]): Set<string>;
39
+ /** A red run where no job started (zero jobs, or all skipped): a workflow that failed to start, typically a fork
40
+ * PR's run that GitHub rejected. Nothing was checked, so it is not a red build of the change. */
41
+ export declare function nothingRan(jobs: JobSummary[]): boolean;
39
42
  export interface RedRun {
40
43
  run: number;
41
44
  workflow: string;
@@ -79,7 +82,10 @@ export interface RedBuildsReport {
79
82
  to: string;
80
83
  } | null;
81
84
  pullRequestRuns: number;
85
+ /** Red runs where at least one job ran. */
82
86
  redRuns: number;
87
+ /** Runs GitHub marked failed although no job started (workflow startup failures); left out of redRuns. */
88
+ neverStarted: number;
83
89
  analysed: number;
84
90
  unreadable: number;
85
91
  verdicts: Record<Verdict, {
@@ -90,7 +96,7 @@ export interface RedBuildsReport {
90
96
  stoppedEarly: string | null;
91
97
  rows: RedRun[];
92
98
  }
93
- export declare function summarise(repository: string, runs: RunSummary[], rows: RedRun[], stoppedEarly: string | null): RedBuildsReport;
99
+ export declare function summarise(repository: string, runs: RunSummary[], rows: RedRun[], stoppedEarly: string | null, neverStarted?: number): RedBuildsReport;
94
100
  export declare function formatReport(report: RedBuildsReport): string;
95
101
  export type GitHubGet = (path: string) => Promise<{
96
102
  status: number;
@@ -82,6 +82,11 @@ export function signatures(annotations) {
82
82
  }
83
83
  return out;
84
84
  }
85
+ /** A red run where no job started (zero jobs, or all skipped): a workflow that failed to start, typically a fork
86
+ * PR's run that GitHub rejected. Nothing was checked, so it is not a red build of the change. */
87
+ export function nothingRan(jobs) {
88
+ return jobs.every((job) => !job.startedAt || job.conclusion === "skipped");
89
+ }
85
90
  function minutes(job) {
86
91
  if (!job.startedAt || !job.completedAt)
87
92
  return 0;
@@ -112,7 +117,7 @@ export function classify(input) {
112
117
  const rows = [];
113
118
  for (const run of input.runs) {
114
119
  const jobs = input.jobs.get(run.id);
115
- if (run.conclusion !== "failure" || !jobs)
120
+ if (run.conclusion !== "failure" || !jobs || nothingRan(jobs))
116
121
  continue;
117
122
  const allFailing = failingOf(jobs);
118
123
  // A gate job that only reports "something else failed" says nothing on its own.
@@ -174,7 +179,7 @@ export function agentMarker(message, branch) {
174
179
  return { written: true, marker: "branch prefix" };
175
180
  return { written: false, marker: "" };
176
181
  }
177
- export function summarise(repository, runs, rows, stoppedEarly) {
182
+ export function summarise(repository, runs, rows, stoppedEarly, neverStarted = 0) {
178
183
  const verdicts = Object.fromEntries(VERDICTS.map((v) => [v, { runs: 0, runnerMinutes: 0 }]));
179
184
  for (const row of rows) {
180
185
  verdicts[row.verdict].runs++;
@@ -183,7 +188,7 @@ export function summarise(repository, runs, rows, stoppedEarly) {
183
188
  for (const v of VERDICTS)
184
189
  verdicts[v].runnerMinutes = Math.round(verdicts[v].runnerMinutes);
185
190
  const times = runs.map((r) => r.createdAt).sort();
186
- const red = runs.filter((r) => r.conclusion === "failure").length;
191
+ const red = runs.filter((r) => r.conclusion === "failure").length - neverStarted;
187
192
  return {
188
193
  schemaVersion: RED_BUILDS_SCHEMA,
189
194
  repository,
@@ -191,6 +196,7 @@ export function summarise(repository, runs, rows, stoppedEarly) {
191
196
  window: times.length ? { from: times[0], to: times.at(-1) } : null,
192
197
  pullRequestRuns: runs.length,
193
198
  redRuns: red,
199
+ neverStarted,
194
200
  analysed: rows.length,
195
201
  unreadable: red - rows.length,
196
202
  verdicts,
@@ -223,6 +229,8 @@ export function formatReport(report) {
223
229
  return lines.join("\n");
224
230
  }
225
231
  lines.push(`${report.window.from.slice(0, 16).replace("T", " ")} to ${report.window.to.slice(0, 16).replace("T", " ")} UTC · ${report.pullRequestRuns} pull request runs, ${report.redRuns} red (${pct(report.redRuns, report.pullRequestRuns)})`);
232
+ if (report.neverStarted > 0)
233
+ lines.push(`${report.neverStarted} more runs were marked failed although no job started (the workflow failed to start); they are not counted as red.`);
226
234
  if (report.unreadable > 0)
227
235
  lines.push(`${report.unreadable} red runs could not be read and are left out.`);
228
236
  if (report.analysed === 0) {
@@ -416,7 +424,8 @@ export async function collectRedBuilds(options) {
416
424
  stoppedEarly = error.message;
417
425
  }
418
426
  }
419
- const report = summarise(repository, runs, rows, stoppedEarly);
427
+ const neverStarted = runs.filter((r) => r.conclusion === "failure" && jobs.has(r.id) && nothingRan(jobs.get(r.id))).length;
428
+ const report = summarise(repository, runs, rows, stoppedEarly, neverStarted);
420
429
  report.workflow = workflowLabel || runs[0]?.workflowName || null;
421
430
  return report;
422
431
  }
@@ -1,13 +1,27 @@
1
1
  import { type UsageCommand, type UsageOutcome } from "./usage-signal.js";
2
- export type TelemetryMode = "off" | "anonymous" | "installations";
2
+ /**
3
+ * Usage counting is on by default. "repo" (the default) also names the repository (host/owner/repo from
4
+ * the Git remote); "count-only" drops the name. Only DO_NOT_TRACK=1, DIFFCI_NO_SEND=1 or
5
+ * DIFFCI_SHARE_USAGE=0 stop the count. No repository content, paths, commits or machine details are sent.
6
+ */
7
+ export type TelemetryMode = "repo" | "count-only";
3
8
  interface Preference {
4
9
  mode: TelemetryMode;
5
10
  installationId?: string;
6
11
  internal: boolean;
12
+ noticeShown: boolean;
7
13
  }
8
14
  type Flags = Record<string, string | boolean>;
15
+ export declare const TELEMETRY_DOCS = "https://github.com/DiffCI/core/blob/main/docs/telemetry.md";
9
16
  export declare function preferencePath(env: NodeJS.ProcessEnv): string;
10
17
  export declare function readTelemetryPreference(env: NodeJS.ProcessEnv): Preference;
11
18
  export declare function configureTelemetry(mode: string, internal: boolean, env: NodeJS.ProcessEnv): Preference;
12
- export declare function recordUsage(command: UsageCommand, outcome: UsageOutcome, version: string, flags: Flags, env: NodeJS.ProcessEnv): Promise<void>;
19
+ /** True when the environment turns usage counting off entirely. Flags cannot: only the environment can. */
20
+ export declare function usageCountingDisabled(env: NodeJS.ProcessEnv): boolean;
21
+ /** host/owner/repo from a Git remote URL, without credentials, scheme or .git; undefined if unrecognised. */
22
+ export declare function normaliseRemote(remote: string): string | undefined;
23
+ export declare function repositoryName(repoPath: string | undefined, env: NodeJS.ProcessEnv): string | undefined;
24
+ export declare function telemetryNotice(mode: TelemetryMode): string;
25
+ /** Best effort: never throws and never changes the exit code. `flags` are read for --internal-usage only. */
26
+ export declare function recordUsage(command: UsageCommand, outcome: UsageOutcome, version: string, flags: Flags, env: NodeJS.ProcessEnv, repoPath?: string): Promise<void>;
13
27
  export {};
@@ -1,46 +1,134 @@
1
+ import { execFileSync } from "node:child_process";
1
2
  import { randomUUID } from "node:crypto";
2
3
  import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
4
  import { homedir } from "node:os";
4
5
  import { dirname, join } from "node:path";
5
6
  import { deliverUsageSignal } from "./usage-signal.js";
7
+ const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
8
+ export const TELEMETRY_DOCS = "https://github.com/DiffCI/core/blob/main/docs/telemetry.md";
6
9
  export function preferencePath(env) {
7
10
  return join(env.DIFFCI_TELEMETRY_HOME ?? join(homedir(), ".diffci"), "telemetry.json");
8
11
  }
12
+ /** Older saved choices: off and anonymous never shared more than a count, so they keep the name out. */
13
+ function normaliseMode(mode) {
14
+ if (mode === "repo" || mode === "installations")
15
+ return "repo";
16
+ if (mode === "count-only" || mode === "anonymous" || mode === "off")
17
+ return "count-only";
18
+ return undefined;
19
+ }
9
20
  export function readTelemetryPreference(env) {
10
21
  try {
11
22
  const value = JSON.parse(readFileSync(preferencePath(env), "utf8"));
12
- if (!["off", "anonymous", "installations"].includes(value.mode))
23
+ const mode = normaliseMode(value.mode);
24
+ if (!mode)
13
25
  throw new Error("invalid preference");
14
- if (value.mode === "installations" && !/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value.installationId ?? ""))
15
- throw new Error("invalid identifier");
16
- return { mode: value.mode, internal: value.internal === true, ...(value.mode === "installations" ? { installationId: value.installationId } : {}) };
26
+ const installationId = typeof value.installationId === "string" && UUID.test(value.installationId) ? value.installationId : undefined;
27
+ return { mode, internal: value.internal === true, noticeShown: value.noticeShown === true,
28
+ ...(mode === "repo" && installationId ? { installationId } : {}) };
17
29
  }
18
30
  catch {
19
- return { mode: "off", internal: false };
31
+ return { mode: "repo", internal: false, noticeShown: false };
20
32
  }
21
33
  }
22
- export function configureTelemetry(mode, internal, env) {
23
- if (!["off", "anonymous", "installations"].includes(mode))
24
- throw new Error("Choose off, anonymous, or installations.");
25
- const previous = readTelemetryPreference(env);
26
- const value = { mode: mode, internal,
27
- ...(mode === "installations" ? { installationId: previous.installationId ?? randomUUID() } : {}) };
34
+ function writePreference(value, env) {
28
35
  const path = preferencePath(env);
29
36
  mkdirSync(dirname(path), { recursive: true });
30
37
  writeFileSync(path, `${JSON.stringify(value)}\n`, { encoding: "utf8", mode: 0o600 });
38
+ }
39
+ export function configureTelemetry(mode, internal, env) {
40
+ const normalised = normaliseMode(mode);
41
+ if (!normalised)
42
+ throw new Error("Choose repo or count-only. DO_NOT_TRACK=1 stops usage counting.");
43
+ const previous = readTelemetryPreference(env);
44
+ const value = { mode: normalised, internal, noticeShown: true,
45
+ ...(normalised === "repo" ? { installationId: previous.installationId ?? randomUUID() } : {}) };
46
+ writePreference(value, env);
31
47
  return value;
32
48
  }
33
- export async function recordUsage(command, outcome, version, flags, env) {
34
- // Explicit denial overrides saved consent and every opt-in route.
35
- if (flags["no-send"] === true || env.DIFFCI_SHARE_USAGE === "0" || env.DIFFCI_NO_SEND === "1")
36
- return;
37
- const preference = readTelemetryPreference(env);
38
- if (flags["share-usage"] !== true && env.DIFFCI_SHARE_USAGE !== "1" && preference.mode === "off")
39
- return;
40
- const result = await deliverUsageSignal({ command, outcome, version,
41
- surface: env.DIFFCI_MCP === "1" ? "local-mcp" : "cli",
42
- activity: flags["internal-usage"] === true || env.DIFFCI_USAGE_INTERNAL === "1" || preference.internal ? "internal" : "external",
43
- ...(preference.mode === "installations" ? { installationId: preference.installationId } : {}),
44
- });
45
- console.error(`DiffCI telemetry: ${result.status}${result.httpStatus ? ` (HTTP ${result.httpStatus})` : ""}. No repository content sent.`);
49
+ /** True when the environment turns usage counting off entirely. Flags cannot: only the environment can. */
50
+ export function usageCountingDisabled(env) {
51
+ const on = (value) => value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
52
+ return on(env.DO_NOT_TRACK) || env.DIFFCI_NO_SEND === "1" || env.DIFFCI_SHARE_USAGE === "0";
53
+ }
54
+ /** host/owner/repo from a Git remote URL, without credentials, scheme or .git; undefined if unrecognised. */
55
+ export function normaliseRemote(remote) {
56
+ let value = remote.trim();
57
+ const scp = /^[\w.-]+@([\w.-]+):(.+)$/.exec(value);
58
+ if (scp)
59
+ value = `${scp[1]}/${scp[2]}`;
60
+ else {
61
+ try {
62
+ const url = new URL(value);
63
+ if (!["https:", "http:", "ssh:", "git:"].includes(url.protocol))
64
+ return undefined;
65
+ value = `${url.hostname}${url.pathname}`;
66
+ }
67
+ catch {
68
+ return undefined;
69
+ }
70
+ }
71
+ value = value.replace(/\.git$/i, "").replace(/\/+$/, "").toLowerCase();
72
+ return /^[a-z0-9.-]+(\/[\w.-]+){2,5}$/.test(value) && value.length <= 200 ? value : undefined;
73
+ }
74
+ export function repositoryName(repoPath, env) {
75
+ if (env.GITHUB_REPOSITORY && /^[\w.-]+\/[\w.-]+$/.test(env.GITHUB_REPOSITORY)) {
76
+ let host = "github.com";
77
+ try {
78
+ if (env.GITHUB_SERVER_URL)
79
+ host = new URL(env.GITHUB_SERVER_URL).hostname;
80
+ }
81
+ catch { /* keep github.com */ }
82
+ return normaliseRemote(`https://${host}/${env.GITHUB_REPOSITORY}`);
83
+ }
84
+ if (env.CI_SERVER_HOST && env.CI_PROJECT_PATH)
85
+ return normaliseRemote(`https://${env.CI_SERVER_HOST}/${env.CI_PROJECT_PATH}`);
86
+ if (!repoPath)
87
+ return undefined;
88
+ try {
89
+ const remote = execFileSync("git", ["-C", repoPath, "remote", "get-url", "origin"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 2000 });
90
+ return normaliseRemote(remote);
91
+ }
92
+ catch {
93
+ return undefined;
94
+ }
95
+ }
96
+ function surfaceOf(env) {
97
+ if (env.DIFFCI_MCP === "1")
98
+ return "local-mcp";
99
+ if (env.DIFFCI_SURFACE === "github-action" || env.DIFFCI_SURFACE === "gitlab-component")
100
+ return env.DIFFCI_SURFACE;
101
+ return "cli";
102
+ }
103
+ function isCi(env) {
104
+ return Boolean(env.CI && env.CI !== "false" && env.CI !== "0") || Boolean(env.GITHUB_ACTIONS || env.GITLAB_CI || env.BUILDKITE || env.CIRCLECI);
105
+ }
106
+ export function telemetryNotice(mode) {
107
+ return mode === "repo"
108
+ ? `DiffCI counts runs with this repository's name (host/owner/repo), never its content. \`diffci telemetry --mode count-only\` drops the name; DO_NOT_TRACK=1 stops counting. ${TELEMETRY_DOCS}`
109
+ : `DiffCI counts runs without repository names or content. DO_NOT_TRACK=1 stops counting. ${TELEMETRY_DOCS}`;
110
+ }
111
+ /** Best effort: never throws and never changes the exit code. `flags` are read for --internal-usage only. */
112
+ export async function recordUsage(command, outcome, version, flags, env, repoPath) {
113
+ try {
114
+ if (usageCountingDisabled(env))
115
+ return;
116
+ const preference = readTelemetryPreference(env);
117
+ if (!preference.noticeShown) {
118
+ console.error(telemetryNotice(preference.mode));
119
+ try {
120
+ writePreference({ ...preference, noticeShown: true }, env);
121
+ }
122
+ catch { /* read-only home: show it again next time */ }
123
+ }
124
+ const repository = preference.mode === "repo" ? repositoryName(repoPath, env) : undefined;
125
+ await deliverUsageSignal({ command, outcome, version,
126
+ surface: surfaceOf(env),
127
+ ci: isCi(env),
128
+ activity: flags["internal-usage"] === true || env.DIFFCI_USAGE_INTERNAL === "1" || preference.internal ? "internal" : "external",
129
+ ...(preference.installationId ? { installationId: preference.installationId } : {}),
130
+ ...(repository ? { repository } : {}),
131
+ });
132
+ }
133
+ catch { /* usage counting never affects a run */ }
46
134
  }
@@ -1,13 +1,16 @@
1
- /** Explicit, best-effort usage signal. Never includes repository or machine details. */
2
- export type UsageCommand = "check" | "observe" | "verify";
3
- export type UsageOutcome = "observed" | "refused" | "error" | "passed" | "failed" | "blocked";
1
+ /** Best-effort usage signal. Carries a repository name only when given one; never content, paths or machine details. */
2
+ export type UsageCommand = "check" | "observe" | "verify" | "plan";
3
+ export type UsageOutcome = "observed" | "refused" | "error" | "passed" | "failed" | "blocked" | "selective" | "full";
4
+ export type UsageSurface = "cli" | "local-mcp" | "github-action" | "gitlab-component";
4
5
  export interface UsageSignal {
5
6
  command: UsageCommand;
6
7
  outcome: UsageOutcome;
7
8
  version: string;
8
- surface?: "cli" | "local-mcp";
9
+ surface?: UsageSurface;
9
10
  activity?: "internal" | "external";
11
+ ci?: boolean;
10
12
  installationId?: string;
13
+ repository?: string;
11
14
  endpoint?: string;
12
15
  fetchImpl?: typeof fetch;
13
16
  }
@@ -9,9 +9,11 @@ export async function deliverUsageSignal(input) {
9
9
  body: JSON.stringify({ schema: "diffci.usage.v1", command: input.command, outcome: input.outcome, version: input.version,
10
10
  ...(input.surface ? { surface: input.surface } : {}),
11
11
  ...(input.activity ? { activity: input.activity } : {}),
12
+ ...(input.ci !== undefined ? { ci: input.ci } : {}),
12
13
  ...(input.installationId ? { installation_id: input.installationId } : {}),
14
+ ...(input.repository ? { repository: input.repository } : {}),
13
15
  }),
14
- signal: AbortSignal.timeout(5000),
16
+ signal: AbortSignal.timeout(3000),
15
17
  });
16
18
  return { status: !response.ok ? "failed" : response.status === 202 ? "accepted" : "delivered", httpStatus: response.status };
17
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diffci.com/diffci",
3
- "version": "0.3.42",
3
+ "version": "0.3.44",
4
4
  "description": "Verification for AI coding agents: runs the tests and checks a change affects, with full fallback and a receipt",
5
5
  "keywords": [
6
6
  "ci",