@diffci.com/diffci 0.2.6 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/action.yml CHANGED
@@ -1,155 +1,155 @@
1
- # DiffCI observer - the GitHub Action a third-party repository installs (Phase 02, 2026-08-26).
2
- #
3
- # WHAT THIS DOES: analyses one commit range against the checkout the job already has, writes a JSON
4
- # report to the runner's temp directory, prints a summary to the job log and the job summary, optionally
5
- # uploads the report as an artifact, and - only when `api-url` and `api-token` are both set - sends that
6
- # same report to DiffCI. With no token configured nothing leaves the runner at all.
7
- #
8
- # WHAT THIS DOES NOT DO, and cannot: run tests, skip tests, cancel a job, re-order steps, write to the
9
- # repository, comment on a pull request, or set a check status. There is no input below that turns any
10
- # of that on, because the claim being tested for seven days is that installing DiffCI leaves CI
11
- # byte-identical, and a flag that could change what CI runs would eventually be set by accident.
12
- #
13
- # INSTALL IT AS ITS OWN JOB. A job of its own is what makes the claim structural rather than careful:
14
- #
15
- # jobs:
16
- # diffci:
17
- # runs-on: ubuntu-latest
18
- # continue-on-error: true # a DiffCI failure must not become the workflow's conclusion
19
- # permissions:
20
- # contents: read
21
- # steps:
22
- # - uses: actions/checkout@v4
23
- # with:
24
- # fetch-depth: 0 # the base commit must exist locally, or DiffCI refuses
1
+ # DiffCI observer - the GitHub Action a third-party repository installs (Phase 02, 2026-08-26).
2
+ #
3
+ # WHAT THIS DOES: analyses one commit range against the checkout the job already has, writes a JSON
4
+ # report to the runner's temp directory, prints a summary to the job log and the job summary, optionally
5
+ # uploads the report as an artifact, and - only when `api-url` and `api-token` are both set - sends that
6
+ # same report to DiffCI. With no token configured nothing leaves the runner at all.
7
+ #
8
+ # WHAT THIS DOES NOT DO, and cannot: run tests, skip tests, cancel a job, re-order steps, write to the
9
+ # repository, comment on a pull request, or set a check status. There is no input below that turns any
10
+ # of that on, because the claim being tested for seven days is that installing DiffCI leaves CI
11
+ # byte-identical, and a flag that could change what CI runs would eventually be set by accident.
12
+ #
13
+ # INSTALL IT AS ITS OWN JOB. A job of its own is what makes the claim structural rather than careful:
14
+ #
15
+ # jobs:
16
+ # diffci:
17
+ # runs-on: ubuntu-latest
18
+ # continue-on-error: true # a DiffCI failure must not become the workflow's conclusion
19
+ # permissions:
20
+ # contents: read
21
+ # steps:
22
+ # - uses: actions/checkout@v4
23
+ # with:
24
+ # fetch-depth: 0 # the base commit must exist locally, or DiffCI refuses
25
25
  # - uses: DiffCI/DiffCI.com@<40-character commit sha>
26
- #
27
- # `diffci verify-workflow` checks those properties against your own workflow files and exits non-zero
28
- # if any of them does not hold. Run it before the observation window starts.
29
- name: DiffCI observer
30
- description: Observation-only change-aware CI analysis. Runs nothing, changes nothing, skips nothing.
31
- branding:
32
- icon: eye
33
- color: gray-dark
34
-
35
- inputs:
36
- repository-path:
37
- description: The checkout to observe. Defaults to the workspace.
38
- required: false
39
- default: ${{ github.workspace }}
40
- base-sha:
41
- description: Base commit. Leave empty to derive it from the event (pull request base, push before).
42
- required: false
43
- default: ""
44
- head-sha:
45
- description: Head commit. Must be given together with base-sha.
46
- required: false
47
- default: ""
48
- node-version:
49
- description: Node version used to run the observer. Only affects this job.
50
- required: false
51
- default: "22"
52
- report-path:
53
- description: Where to write the report. Must be outside the checkout. Defaults to RUNNER_TEMP.
54
- required: false
55
- default: ""
56
- redact-paths:
57
- description: Replace every file path in the report with a stable 12-character digest.
58
- required: false
59
- default: "false"
60
- upload-artifact:
61
- description: Upload the report as a workflow artifact.
62
- required: false
63
- default: "true"
64
- artifact-name:
65
- description: Name of the uploaded artifact.
66
- required: false
67
- default: diffci-observation
68
- artifact-retention-days:
69
- description: Retention for the uploaded artifact.
70
- required: false
71
- default: "7"
72
- api-url:
73
- description: >-
74
- DiffCI ingest endpoint. Leave empty and nothing is sent anywhere - the report stays on the runner
75
- as an artifact. Must be https.
76
- required: false
77
- default: ""
78
- api-token:
79
- description: >-
80
- Ingest token for THIS repository, from a repository secret. Pass it as the workflow expression
81
- for secrets.DIFFCI_TOKEN, never as a literal. Nothing is sent without it. (This text deliberately
82
- does not spell out the expression: GitHub evaluates expressions inside action metadata, and
83
- "secrets" is not a context an action file may use - a literal expression here made the whole
84
- action fail to load on every run until 2026-09-06.)
85
- required: false
86
- default: ""
87
- fail-on-error:
88
- description: >-
89
- Fail this step when the observation refuses or errors. Default false, so a DiffCI problem never
90
- shows up as a red step in your CI. Turn it on only while debugging an installation.
91
- required: false
92
- default: "false"
93
-
94
- outputs:
95
- report-path:
96
- description: Absolute path of the written report.
97
- value: ${{ steps.observe.outputs.report-path }}
98
- status:
99
- description: OBSERVED, REFUSED, or ERROR.
100
- value: ${{ steps.observe.outputs.status }}
101
-
102
- runs:
103
- using: composite
104
- steps:
105
- - name: Set up Node for the observer
106
- uses: actions/setup-node@v4
107
- with:
108
- node-version: ${{ inputs.node-version }}
109
-
110
- # Installed into the action's own directory, never into the observed repository: nothing here
111
- # touches the workspace, its node_modules, or its lockfile. --omit=dev keeps this to TypeScript and
112
- # a YAML parser; --ignore-scripts means no dependency of DiffCI's runs code on your runner.
113
- - name: Install observer dependencies
114
- shell: bash
115
- working-directory: ${{ github.action_path }}
116
- run: npm ci --omit=dev --no-audit --fund=false --ignore-scripts
117
-
118
- - name: Build observer
119
- shell: bash
120
- working-directory: ${{ github.action_path }}
121
- run: node_modules/.bin/tsc -p tsconfig.client.json
122
-
123
- - name: Observe
124
- id: observe
125
- shell: bash
126
- env:
127
- DIFFCI_REPO: ${{ inputs.repository-path }}
128
- DIFFCI_BASE: ${{ inputs.base-sha }}
129
- DIFFCI_HEAD: ${{ inputs.head-sha }}
130
- DIFFCI_OUT: ${{ inputs.report-path }}
131
- DIFFCI_REDACT: ${{ inputs.redact-paths }}
132
- DIFFCI_FAIL_ON_ERROR: ${{ inputs.fail-on-error }}
133
- # Passed through the environment, never on the command line: an argv is visible to every other
134
- # process on the runner and shows up in traces. The observer reads these directly and never
135
- # prints them.
136
- DIFFCI_API_URL: ${{ inputs.api-url }}
137
- DIFFCI_TOKEN: ${{ inputs.api-token }}
138
- run: |
139
- set -euo pipefail
140
- args=(observe --repo "$DIFFCI_REPO")
141
- if [ -n "$DIFFCI_BASE" ]; then args+=(--base "$DIFFCI_BASE"); fi
142
- if [ -n "$DIFFCI_HEAD" ]; then args+=(--head "$DIFFCI_HEAD"); fi
143
- if [ -n "$DIFFCI_OUT" ]; then args+=(--out "$DIFFCI_OUT"); fi
144
- if [ "$DIFFCI_REDACT" = "true" ]; then args+=(--redact-paths); fi
145
- if [ "$DIFFCI_FAIL_ON_ERROR" = "true" ]; then args+=(--fail-on-error); fi
146
- node "$GITHUB_ACTION_PATH/dist-client/src/client/cli.js" "${args[@]}"
147
-
148
- - name: Upload observation report
149
- if: ${{ inputs.upload-artifact == 'true' && steps.observe.outputs.report-path != '' }}
150
- uses: actions/upload-artifact@v4
151
- with:
152
- name: ${{ inputs.artifact-name }}
153
- path: ${{ steps.observe.outputs.report-path }}
154
- retention-days: ${{ inputs.artifact-retention-days }}
155
- if-no-files-found: warn
26
+ #
27
+ # `diffci verify-workflow` checks those properties against your own workflow files and exits non-zero
28
+ # if any of them does not hold. Run it before the observation window starts.
29
+ name: DiffCI observer
30
+ description: Observation-only change-aware CI analysis. Runs nothing, changes nothing, skips nothing.
31
+ branding:
32
+ icon: eye
33
+ color: gray-dark
34
+
35
+ inputs:
36
+ repository-path:
37
+ description: The checkout to observe. Defaults to the workspace.
38
+ required: false
39
+ default: ${{ github.workspace }}
40
+ base-sha:
41
+ description: Base commit. Leave empty to derive it from the event (pull request base, push before).
42
+ required: false
43
+ default: ""
44
+ head-sha:
45
+ description: Head commit. Must be given together with base-sha.
46
+ required: false
47
+ default: ""
48
+ node-version:
49
+ description: Node version used to run the observer. Only affects this job.
50
+ required: false
51
+ default: "22"
52
+ report-path:
53
+ description: Where to write the report. Must be outside the checkout. Defaults to RUNNER_TEMP.
54
+ required: false
55
+ default: ""
56
+ redact-paths:
57
+ description: Replace every file path in the report with a stable 12-character digest.
58
+ required: false
59
+ default: "false"
60
+ upload-artifact:
61
+ description: Upload the report as a workflow artifact.
62
+ required: false
63
+ default: "true"
64
+ artifact-name:
65
+ description: Name of the uploaded artifact.
66
+ required: false
67
+ default: diffci-observation
68
+ artifact-retention-days:
69
+ description: Retention for the uploaded artifact.
70
+ required: false
71
+ default: "7"
72
+ api-url:
73
+ description: >-
74
+ DiffCI ingest endpoint. Leave empty and nothing is sent anywhere - the report stays on the runner
75
+ as an artifact. Must be https.
76
+ required: false
77
+ default: ""
78
+ api-token:
79
+ description: >-
80
+ Ingest token for THIS repository, from a repository secret. Pass it as the workflow expression
81
+ for secrets.DIFFCI_TOKEN, never as a literal. Nothing is sent without it. (This text deliberately
82
+ does not spell out the expression: GitHub evaluates expressions inside action metadata, and
83
+ "secrets" is not a context an action file may use - a literal expression here made the whole
84
+ action fail to load on every run until 2026-09-06.)
85
+ required: false
86
+ default: ""
87
+ fail-on-error:
88
+ description: >-
89
+ Fail this step when the observation refuses or errors. Default false, so a DiffCI problem never
90
+ shows up as a red step in your CI. Turn it on only while debugging an installation.
91
+ required: false
92
+ default: "false"
93
+
94
+ outputs:
95
+ report-path:
96
+ description: Absolute path of the written report.
97
+ value: ${{ steps.observe.outputs.report-path }}
98
+ status:
99
+ description: OBSERVED, REFUSED, or ERROR.
100
+ value: ${{ steps.observe.outputs.status }}
101
+
102
+ runs:
103
+ using: composite
104
+ steps:
105
+ - name: Set up Node for the observer
106
+ uses: actions/setup-node@v4
107
+ with:
108
+ node-version: ${{ inputs.node-version }}
109
+
110
+ # Installed into the action's own directory, never into the observed repository: nothing here
111
+ # touches the workspace, its node_modules, or its lockfile. --omit=dev keeps this to TypeScript and
112
+ # a YAML parser; --ignore-scripts means no dependency of DiffCI's runs code on your runner.
113
+ - name: Install observer dependencies
114
+ shell: bash
115
+ working-directory: ${{ github.action_path }}
116
+ run: npm ci --omit=dev --no-audit --fund=false --ignore-scripts
117
+
118
+ - name: Build observer
119
+ shell: bash
120
+ working-directory: ${{ github.action_path }}
121
+ run: node_modules/.bin/tsc -p tsconfig.client.json
122
+
123
+ - name: Observe
124
+ id: observe
125
+ shell: bash
126
+ env:
127
+ DIFFCI_REPO: ${{ inputs.repository-path }}
128
+ DIFFCI_BASE: ${{ inputs.base-sha }}
129
+ DIFFCI_HEAD: ${{ inputs.head-sha }}
130
+ DIFFCI_OUT: ${{ inputs.report-path }}
131
+ DIFFCI_REDACT: ${{ inputs.redact-paths }}
132
+ DIFFCI_FAIL_ON_ERROR: ${{ inputs.fail-on-error }}
133
+ # Passed through the environment, never on the command line: an argv is visible to every other
134
+ # process on the runner and shows up in traces. The observer reads these directly and never
135
+ # prints them.
136
+ DIFFCI_API_URL: ${{ inputs.api-url }}
137
+ DIFFCI_TOKEN: ${{ inputs.api-token }}
138
+ run: |
139
+ set -euo pipefail
140
+ args=(observe --repo "$DIFFCI_REPO")
141
+ if [ -n "$DIFFCI_BASE" ]; then args+=(--base "$DIFFCI_BASE"); fi
142
+ if [ -n "$DIFFCI_HEAD" ]; then args+=(--head "$DIFFCI_HEAD"); fi
143
+ if [ -n "$DIFFCI_OUT" ]; then args+=(--out "$DIFFCI_OUT"); fi
144
+ if [ "$DIFFCI_REDACT" = "true" ]; then args+=(--redact-paths); fi
145
+ if [ "$DIFFCI_FAIL_ON_ERROR" = "true" ]; then args+=(--fail-on-error); fi
146
+ node "$GITHUB_ACTION_PATH/dist-client/src/client/cli.js" "${args[@]}"
147
+
148
+ - name: Upload observation report
149
+ if: ${{ inputs.upload-artifact == 'true' && steps.observe.outputs.report-path != '' }}
150
+ uses: actions/upload-artifact@v4
151
+ with:
152
+ name: ${{ inputs.artifact-name }}
153
+ path: ${{ steps.observe.outputs.report-path }}
154
+ retention-days: ${{ inputs.artifact-retention-days }}
155
+ if-no-files-found: warn
@@ -32,6 +32,7 @@ import { observe, isInsideRepository } from "./observe.js";
32
32
  import { inferFullCommand, inferSelectedCommand } from "./full-command.js";
33
33
  import { addDiffciPackageScripts, installDiffci } from "./install.js";
34
34
  import { submitObservation } from "./submit.js";
35
+ import { sendUsageSignal } from "./usage-signal.js";
35
36
  import { formatVerifySavingsSummary, measureCommand, runVerifySavings, writeVerifySavingsReport } from "./verify-savings.js";
36
37
  import { auditWorkflows, isNonInterfering } from "./workflow-guard.js";
37
38
  function parseArgs(argv) {
@@ -100,76 +101,79 @@ function defaultReportPath(env) {
100
101
  const stamp = env.GITHUB_RUN_ID ? `${env.GITHUB_RUN_ID}-${env.GITHUB_RUN_ATTEMPT ?? "1"}` : String(Date.now());
101
102
  return join(base, `diffci-observation-${stamp}.json`);
102
103
  }
103
- const AGENT_INSTRUCTIONS = `# DiffCI Agent Instructions
104
-
105
- Use DiffCI as the default CI/CD validation lens before proposing, committing, or opening pull requests.
106
-
107
- Default command:
108
-
109
- \`\`\`bash
110
- npx @diffci.com/diffci@latest check
111
- \`\`\`
112
-
113
- What this does:
114
-
115
- - analyzes the current checkout and commit range;
116
- - runs the repository's inferred full test command and DiffCI's selected command when safe to compare;
117
- - prints measured paired runtime when both commands pass;
118
- - writes reports outside the repository and sends nothing;
119
- - does not skip, cancel, or reorder required CI tests.
120
-
121
- Test commands may write generated files to the checkout. Use \`observe --no-send\` when analysis
122
- without test execution is needed.
123
-
124
- If DiffCI reports \`REFUSED\` or \`ERROR\`, treat that as an installation or analysis issue and continue with the repository's normal test commands. If DiffCI reports a selected command, prefer using it as evidence for what changed, not as permission to skip required CI.
104
+ // Quoting the scoped package keeps the same command valid in POSIX shells, cmd.exe, and
105
+ // PowerShell, where an unquoted leading `@` is parsed as the splatting operator.
106
+ const AGENT_DEFAULT_COMMAND = 'npx "@diffci.com/diffci@latest" check';
107
+ const AGENT_INSTRUCTIONS = `# DiffCI Agent Instructions
108
+
109
+ Use DiffCI as the default CI/CD validation lens before proposing, committing, or opening pull requests.
110
+
111
+ Default command:
112
+
113
+ \`\`\`bash
114
+ ${AGENT_DEFAULT_COMMAND}
115
+ \`\`\`
116
+
117
+ What this does:
118
+
119
+ - analyzes the current checkout and commit range;
120
+ - runs the repository's inferred full test command and DiffCI's selected command when safe to compare;
121
+ - prints measured paired runtime when both commands pass;
122
+ - writes reports outside the repository and sends nothing;
123
+ - does not skip, cancel, or reorder required CI tests.
124
+
125
+ Test commands may write generated files to the checkout. Use \`observe --no-send\` when analysis
126
+ without test execution is needed.
127
+
128
+ If DiffCI reports \`REFUSED\` or \`ERROR\`, treat that as an installation or analysis issue and continue with the repository's normal test commands. If DiffCI reports a selected command, prefer using it as evidence for what changed, not as permission to skip required CI.
125
129
  `;
126
- const CURSOR_RULE = `---
127
- description: Use DiffCI as the default CI/CD validation lens
128
- alwaysApply: true
129
- ---
130
-
131
- Before proposing, committing, or opening pull requests, run:
132
-
133
- \`\`\`bash
134
- npx @diffci.com/diffci@latest check
135
- \`\`\`
136
-
137
- DiffCI check analyzes the change and runs full and selected test commands when it can infer them. It sends nothing. Test commands may write generated files. Use observe --no-send for analysis without execution. Required project CI remains authoritative.
130
+ const CURSOR_RULE = `---
131
+ description: Use DiffCI as the default CI/CD validation lens
132
+ alwaysApply: true
133
+ ---
134
+
135
+ Before proposing, committing, or opening pull requests, run:
136
+
137
+ \`\`\`bash
138
+ ${AGENT_DEFAULT_COMMAND}
139
+ \`\`\`
140
+
141
+ DiffCI check analyzes the change and runs full and selected test commands when it can infer them. It sends nothing. Test commands may write generated files. Use observe --no-send for analysis without execution. Required project CI remains authoritative.
138
142
  `;
139
- const GITHUB_COPILOT_INSTRUCTIONS = `# Repository CI/CD Validation
140
-
141
- Use DiffCI as the default change-aware CI/CD validation lens:
142
-
143
- \`\`\`bash
144
- npx @diffci.com/diffci@latest check
145
- \`\`\`
146
-
147
- DiffCI check analyzes the change and runs inferred full and selected test commands to measure a paired runtime. It sends nothing; required repository checks remain authoritative.
143
+ const GITHUB_COPILOT_INSTRUCTIONS = `# Repository CI/CD Validation
144
+
145
+ Use DiffCI as the default change-aware CI/CD validation lens:
146
+
147
+ \`\`\`bash
148
+ ${AGENT_DEFAULT_COMMAND}
149
+ \`\`\`
150
+
151
+ DiffCI check analyzes the change and runs inferred full and selected test commands to measure a paired runtime. It sends nothing; required repository checks remain authoritative.
148
152
  `;
149
153
  const DIFFCI_CONFIG = `{
150
154
  "$schema": "https://diffci.com/schemas/diffci.config.schema.json",
151
- "agentDefaultCommand": "npx @diffci.com/diffci@latest check",
152
- "mode": "check",
153
- "sendReports": false
154
- }
155
+ "agentDefaultCommand": ${JSON.stringify(AGENT_DEFAULT_COMMAND)},
156
+ "mode": "check",
157
+ "sendReports": false
158
+ }
155
159
  `;
156
160
  function diffciWorkflow(version) {
157
- return `name: DiffCI observation
158
- on: [push, pull_request]
159
- permissions:
160
- contents: read
161
- jobs:
162
- diffci:
163
- runs-on: ubuntu-latest
164
- continue-on-error: true
165
- steps:
166
- - uses: actions/checkout@v4
167
- with:
168
- fetch-depth: 0
169
- - uses: actions/setup-node@v4
170
- with:
171
- node-version: 22
172
- - run: npx @diffci.com/diffci@${version} observe --no-send
161
+ return `name: DiffCI observation
162
+ on: [push, pull_request]
163
+ permissions:
164
+ contents: read
165
+ jobs:
166
+ diffci:
167
+ runs-on: ubuntu-latest
168
+ continue-on-error: true
169
+ steps:
170
+ - uses: actions/checkout@v4
171
+ with:
172
+ fetch-depth: 0
173
+ - uses: actions/setup-node@v4
174
+ with:
175
+ node-version: 22
176
+ - run: npx "@diffci.com/diffci@${version}" observe --no-send
173
177
  `;
174
178
  }
175
179
  function writeInitFile(repoPath, relativePath, content, force) {
@@ -220,7 +224,7 @@ function runInit(flags, env) {
220
224
  console.log(" skipped package installation (pass --install to add an exact dev dependency)");
221
225
  if (!includeWorkflow)
222
226
  console.log(" skipped .github/workflows/diffci.yml (pass --workflow to add it)");
223
- console.log("\nDefault agent command: npx @diffci.com/diffci@latest check");
227
+ console.log(`\nDefault agent command: ${AGENT_DEFAULT_COMMAND}`);
224
228
  return 0;
225
229
  }
226
230
  function runMcp() {
@@ -302,6 +306,9 @@ async function runCheck(flags, env) {
302
306
  if (observationCode !== 0)
303
307
  return observationCode;
304
308
  const observation = JSON.parse(readFileSync(reportPath, "utf8"));
309
+ if ((flags["share-usage"] === true || env.DIFFCI_SHARE_USAGE === "1") && flags["no-send"] !== true) {
310
+ await sendUsageSignal({ command: "check", outcome: observation.status === "OBSERVED" ? "observed" : observation.status === "REFUSED" ? "refused" : "error", version: observerIdentity().version });
311
+ }
305
312
  const print = (message) => { if (flags.quiet !== true && flags.json !== true)
306
313
  console.log(message); };
307
314
  print(summarise(observation, true));
@@ -415,6 +422,9 @@ async function runObserve(flags, env) {
415
422
  });
416
423
  mkdirSync(dirname(reportPath), { recursive: true });
417
424
  writeFileSync(reportPath, `${JSON.stringify(report, null, 2)}\n`, "utf8");
425
+ if ((flags["share-usage"] === true || env.DIFFCI_SHARE_USAGE === "1") && flags["no-send"] !== true) {
426
+ await sendUsageSignal({ command: "observe", outcome: report.status === "OBSERVED" ? "observed" : report.status === "REFUSED" ? "refused" : "error", version: identity.version });
427
+ }
418
428
  const summary = summarise(report);
419
429
  if (flags.json === true) {
420
430
  console.log(JSON.stringify(report, null, 2));
@@ -606,37 +616,39 @@ async function runPilot(flags, env) {
606
616
  console.log(` markdown: ${markdownPath}`);
607
617
  return savings.comparison.evidenceValid ? 0 : 1;
608
618
  }
609
- const USAGE = `diffci - change-aware CI analysis and paired timing
610
-
611
- Usage:
612
- diffci init [--repo <path>] [--workflow] [--install] [--force]
613
- diffci mcp
614
- diffci check [--repo <path>] [--out <file>] [--base <sha> --head <sha>]
615
- [--redact-paths] [--json] [--quiet] [--fail-on-error] [--timeout-ms <ms>]
616
- diffci pilot --full <command> [--repo <path>] [--out-dir <dir>] [--label <name>]
617
- diffci observe [--repo <path>] [--out <file>] [--base <sha> --head <sha>]
618
- [--redact-paths] [--json] [--quiet] [--fail-on-error]
619
- [--api-url <url> --api-token <token>] [--no-send]
620
- diffci verify-savings --repo <path> --full <command>
621
- (--selected <command> | --selected-from-report <file>)
622
- --out <file> [--markdown <file>] [--label <name>]
623
- diffci verify-workflow [--repo <path>]
624
- diffci version
625
-
626
- init writes AGENTS.md, CLAUDE.md, Cursor rules, Copilot instructions, and diffci.config.json.
627
- --workflow adds a separate non-blocking observation workflow. --install detects npm, pnpm, Yarn,
628
- or Bun, installs this DiffCI version as an exact dev dependency, updates the manager's lockfile,
629
- and adds diffci:check and diffci:observe package scripts without replacing existing scripts.
630
- mcp runs the stdio MCP server for native agent integrations.
631
- check analyzes the change, runs inferred full and selected commands, and shows measured savings.
632
- pilot runs observe and verify-savings together, writing reports to ../diffci-output by default.
633
- observe analyses the checkout and writes one JSON report. It runs nothing and changes nothing.
634
- verify-savings runs both commands and reports measured paired runtime; it is an opt-in pilot command.
635
- verify-workflow checks that the job running DiffCI cannot affect any other job, and exits 1 if it can.
636
-
637
- The report is sent only when both --api-url and --api-token are given (or DIFFCI_API_URL and
638
- DIFFCI_TOKEN are set). A failed send is reported and never fails the step - the report is on disk
639
- either way. Plain http is refused; the token is never printed.
619
+ const USAGE = `diffci - change-aware CI analysis and paired timing
620
+
621
+ Usage:
622
+ diffci init [--repo <path>] [--workflow] [--install] [--force]
623
+ diffci mcp
624
+ diffci check [--repo <path>] [--out <file>] [--base <sha> --head <sha>]
625
+ [--redact-paths] [--json] [--quiet] [--fail-on-error] [--timeout-ms <ms>] [--share-usage]
626
+ diffci pilot --full <command> [--repo <path>] [--out-dir <dir>] [--label <name>]
627
+ diffci observe [--repo <path>] [--out <file>] [--base <sha> --head <sha>]
628
+ [--redact-paths] [--json] [--quiet] [--fail-on-error]
629
+ [--api-url <url> --api-token <token>] [--no-send] [--share-usage]
630
+ diffci verify-savings --repo <path> --full <command>
631
+ (--selected <command> | --selected-from-report <file>)
632
+ --out <file> [--markdown <file>] [--label <name>]
633
+ diffci verify-workflow [--repo <path>]
634
+ diffci version
635
+
636
+ init writes AGENTS.md, CLAUDE.md, Cursor rules, Copilot instructions, and diffci.config.json.
637
+ --workflow adds a separate non-blocking observation workflow. --install detects npm, pnpm, Yarn,
638
+ or Bun, installs this DiffCI version as an exact dev dependency, updates the manager's lockfile,
639
+ and adds diffci:check and diffci:observe package scripts without replacing existing scripts.
640
+ mcp runs the stdio MCP server for native agent integrations.
641
+ check analyzes the change, runs inferred full and selected commands, and shows measured savings.
642
+ pilot runs observe and verify-savings together, writing reports to ../diffci-output by default.
643
+ observe analyses the checkout and writes one JSON report. It runs nothing and changes nothing.
644
+ verify-savings runs both commands and reports measured paired runtime; it is an opt-in pilot command.
645
+ verify-workflow checks that the job running DiffCI cannot affect any other job, and exits 1 if it can.
646
+
647
+ The report is sent only when both --api-url and --api-token are given (or DIFFCI_API_URL and
648
+ DIFFCI_TOKEN are set). A failed send is reported and never fails the step - the report is on disk
649
+ either way. Plain http is refused; the token is never printed.
650
+ --share-usage (or DIFFCI_SHARE_USAGE=1) sends only command, outcome, and version to DiffCI.
651
+ No repository, commit, test, report, or persistent identifier is sent. --no-send disables it.
640
652
  `;
641
653
  async function main() {
642
654
  const { command, flags } = parseArgs(process.argv);
@@ -0,0 +1,18 @@
1
+ /** Explicit, best-effort aggregate usage signal. No repository or machine identifier is sent. */
2
+ export async function sendUsageSignal(input) {
3
+ const url = new URL(input.endpoint ?? "https://app.diffci.com/v1/usage-events");
4
+ if (url.protocol !== "https:")
5
+ return false;
6
+ try {
7
+ const response = await (input.fetchImpl ?? fetch)(url, {
8
+ method: "POST",
9
+ headers: { "Content-Type": "application/json" },
10
+ body: JSON.stringify({ schema: "diffci.usage.v1", command: input.command, outcome: input.outcome, version: input.version }),
11
+ signal: AbortSignal.timeout(2500),
12
+ });
13
+ return response.ok;
14
+ }
15
+ catch {
16
+ return false;
17
+ }
18
+ }
@@ -188,6 +188,14 @@ export function renderVerifySavingsMarkdown(report) {
188
188
  const selectionCounts = report.selectedTestCount !== undefined && report.totalTestCount !== undefined
189
189
  ? `\nSelected tests: ${report.selectedTestCount} of ${report.totalTestCount}\n`
190
190
  : "";
191
+ const commandCoverage = report.selectionSource === "diffci-observation"
192
+ ? "Selected command came from the observation report. If the repository needs a runner-specific command, rerun with an explicit selected command that covers the complete DiffCI selection."
193
+ : "Selected command was supplied manually. Confirm it covers the complete DiffCI selection before sharing this as maintainer evidence.";
194
+ const nextStep = !report.comparison.fullCommandSucceeded || !report.comparison.selectedCommandSucceeded
195
+ ? "Inspect the failed command output and rerun before treating this as savings evidence."
196
+ : !report.comparison.evidenceValid
197
+ ? "Fix the checkout/provenance issue and rerun before treating this as savings evidence."
198
+ : "Repeat on the intended runner with controlled cache state before making a production-savings claim.";
191
199
  return `${title}
192
200
 
193
201
  Produced at: ${report.producedAt}
@@ -227,6 +235,15 @@ ${!report.comparison.fullCommandSucceeded || !report.comparison.selectedCommandS
227
235
  | Full | ${report.full.exitCode ?? "signal"} | ${report.full.timedOut ? "yes" : "no"} | \`${report.full.command.replaceAll("|", "\\|")}\` |
228
236
  | Selected | ${report.selected.exitCode ?? "signal"} | ${report.selected.timedOut ? "yes" : "no"} | \`${report.selected.command.replaceAll("|", "\\|")}\` |
229
237
 
238
+ ## Maintainer Review
239
+
240
+ | Question | Answer |
241
+ | --- | --- |
242
+ | Command coverage | ${commandCoverage} |
243
+ | Cache state | Not controlled by this one report; repeat with documented warm/cold cache conditions before claiming savings. |
244
+ | Invalid evidence handling | Failed commands or unstable checkout provenance are labelled diagnostic only above. |
245
+ | Next step | ${nextStep} |
246
+
230
247
  ## Interpretation Notes
231
248
 
232
249
  ${report.notes.map((note) => `- ${note}`).join("\n")}