@diffci.com/diffci 0.2.8 → 0.2.10
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/LICENSE +1 -1
- package/README.md +351 -306
- package/action.yml +154 -154
- package/dist-client/src/client/cli.js +136 -91
- package/dist-client/src/client/mcp.js +0 -0
- package/dist-client/src/client/spec-conflicts.js +50 -0
- package/dist-client/src/client/verify-savings.js +311 -34
- package/dist-client/src/preflight/fingerprint.js +61 -0
- package/dist-client/src/preflight/taxonomy.js +7 -0
- package/docs/adoption-metrics.md +34 -34
- package/docs/adoption-outreach.md +67 -67
- package/docs/agent-adoption-kit.md +66 -66
- package/docs/agent-adoption-targets.md +61 -61
- package/docs/ai-agents.md +108 -102
- package/docs/distribution.md +144 -131
- package/docs/language-support.md +118 -118
- package/docs/mcp.md +89 -67
- package/docs/npm-adoption.md +144 -138
- package/glama.json +2 -2
- package/llms.txt +39 -39
- package/node_modules/@babel/parser/CHANGELOG.md +1073 -0
- package/node_modules/@babel/parser/bin/babel-parser.js +0 -0
- package/node_modules/estree-walker/CHANGELOG.md +92 -0
- package/node_modules/nanoid/bin/nanoid.cjs +0 -0
- package/node_modules/typescript/bin/tsc +0 -0
- package/node_modules/typescript/bin/tsserver +0 -0
- package/node_modules/yaml/bin.mjs +0 -0
- package/package.json +161 -153
- package/server.json +43 -28
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
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* check analysis plus automatic paired runtime measurement
|
|
15
15
|
* observe analyse the checkout and write an observation report
|
|
16
16
|
* verify-savings run a paired full-versus-selected timing check
|
|
17
|
+
* validate-specs block conflicting same-turn change specifications
|
|
17
18
|
* verify-workflow check that a DiffCI job in this repository's workflows cannot affect other jobs
|
|
18
19
|
* version print the observer version
|
|
19
20
|
*
|
|
@@ -33,6 +34,7 @@ import { inferFullCommand, inferSelectedCommand } from "./full-command.js";
|
|
|
33
34
|
import { addDiffciPackageScripts, installDiffci } from "./install.js";
|
|
34
35
|
import { submitObservation } from "./submit.js";
|
|
35
36
|
import { sendUsageSignal } from "./usage-signal.js";
|
|
37
|
+
import { detectSpecificationConflicts, readSpecificationFile } from "./spec-conflicts.js";
|
|
36
38
|
import { formatVerifySavingsSummary, measureCommand, runVerifySavings, writeVerifySavingsReport } from "./verify-savings.js";
|
|
37
39
|
import { auditWorkflows, isNonInterfering } from "./workflow-guard.js";
|
|
38
40
|
function parseArgs(argv) {
|
|
@@ -104,75 +106,75 @@ function defaultReportPath(env) {
|
|
|
104
106
|
// Quoting the scoped package keeps the same command valid in POSIX shells, cmd.exe, and
|
|
105
107
|
// PowerShell, where an unquoted leading `@` is parsed as the splatting operator.
|
|
106
108
|
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
|
|
109
|
+
const AGENT_INSTRUCTIONS = `# DiffCI Agent Instructions
|
|
110
|
+
|
|
111
|
+
Use DiffCI as the default CI/CD validation lens before proposing, committing, or opening pull requests.
|
|
112
|
+
|
|
113
|
+
Default command:
|
|
114
|
+
|
|
115
|
+
\`\`\`bash
|
|
114
116
|
${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.
|
|
117
|
+
\`\`\`
|
|
118
|
+
|
|
119
|
+
What this does:
|
|
120
|
+
|
|
121
|
+
- analyzes the current checkout and commit range;
|
|
122
|
+
- runs the repository's inferred full test command and DiffCI's selected command when safe to compare;
|
|
123
|
+
- prints measured paired runtime when both commands pass;
|
|
124
|
+
- writes reports outside the repository and sends nothing;
|
|
125
|
+
- does not skip, cancel, or reorder required CI tests.
|
|
126
|
+
|
|
127
|
+
Test commands may write generated files to the checkout. Use \`observe --no-send\` when analysis
|
|
128
|
+
without test execution is needed.
|
|
129
|
+
|
|
130
|
+
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.
|
|
129
131
|
`;
|
|
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
|
|
132
|
+
const CURSOR_RULE = `---
|
|
133
|
+
description: Use DiffCI as the default CI/CD validation lens
|
|
134
|
+
alwaysApply: true
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
Before proposing, committing, or opening pull requests, run:
|
|
138
|
+
|
|
139
|
+
\`\`\`bash
|
|
138
140
|
${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.
|
|
141
|
+
\`\`\`
|
|
142
|
+
|
|
143
|
+
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.
|
|
142
144
|
`;
|
|
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
|
|
145
|
+
const GITHUB_COPILOT_INSTRUCTIONS = `# Repository CI/CD Validation
|
|
146
|
+
|
|
147
|
+
Use DiffCI as the default change-aware CI/CD validation lens:
|
|
148
|
+
|
|
149
|
+
\`\`\`bash
|
|
148
150
|
${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.
|
|
151
|
+
\`\`\`
|
|
152
|
+
|
|
153
|
+
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.
|
|
152
154
|
`;
|
|
153
155
|
const DIFFCI_CONFIG = `{
|
|
154
156
|
"$schema": "https://diffci.com/schemas/diffci.config.schema.json",
|
|
155
157
|
"agentDefaultCommand": ${JSON.stringify(AGENT_DEFAULT_COMMAND)},
|
|
156
|
-
"mode": "check",
|
|
157
|
-
"sendReports": false
|
|
158
|
-
}
|
|
158
|
+
"mode": "check",
|
|
159
|
+
"sendReports": false
|
|
160
|
+
}
|
|
159
161
|
`;
|
|
160
162
|
function diffciWorkflow(version) {
|
|
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
|
|
163
|
+
return `name: DiffCI observation
|
|
164
|
+
on: [push, pull_request]
|
|
165
|
+
permissions:
|
|
166
|
+
contents: read
|
|
167
|
+
jobs:
|
|
168
|
+
diffci:
|
|
169
|
+
runs-on: ubuntu-latest
|
|
170
|
+
continue-on-error: true
|
|
171
|
+
steps:
|
|
172
|
+
- uses: actions/checkout@v4
|
|
173
|
+
with:
|
|
174
|
+
fetch-depth: 0
|
|
175
|
+
- uses: actions/setup-node@v4
|
|
176
|
+
with:
|
|
177
|
+
node-version: 22
|
|
176
178
|
- run: npx "@diffci.com/diffci@${version}" observe --no-send
|
|
177
179
|
`;
|
|
178
180
|
}
|
|
@@ -378,6 +380,10 @@ async function runCheck(flags, env) {
|
|
|
378
380
|
cwd: repoPath,
|
|
379
381
|
timeoutMs,
|
|
380
382
|
tailBytes,
|
|
383
|
+
repetitions: numberFlag(flags, "repetitions"),
|
|
384
|
+
cacheState: parseCacheState(flags),
|
|
385
|
+
cachePreparationCommand: stringFlag(flags, "cache-prepare"),
|
|
386
|
+
alternateOrder: flags["fixed-order"] === true ? false : undefined,
|
|
381
387
|
});
|
|
382
388
|
writeVerifySavingsReport(savings, { out: savingsPath, markdown: markdownPath });
|
|
383
389
|
print(formatVerifySavingsSummary(savings));
|
|
@@ -516,6 +522,14 @@ function numberFlag(flags, name) {
|
|
|
516
522
|
throw new Error(`--${name} must be a non-negative number`);
|
|
517
523
|
return parsed;
|
|
518
524
|
}
|
|
525
|
+
function parseCacheState(flags) {
|
|
526
|
+
const value = stringFlag(flags, "cache-state");
|
|
527
|
+
if (value === undefined)
|
|
528
|
+
return undefined;
|
|
529
|
+
if (value !== "cold" && value !== "warm" && value !== "unknown")
|
|
530
|
+
throw new Error("--cache-state must be cold, warm, or unknown");
|
|
531
|
+
return value;
|
|
532
|
+
}
|
|
519
533
|
function parseVerifySavingsOptions(flags, env) {
|
|
520
534
|
const full = stringFlag(flags, "full");
|
|
521
535
|
const selected = stringFlag(flags, "selected");
|
|
@@ -541,6 +555,10 @@ function parseVerifySavingsOptions(flags, env) {
|
|
|
541
555
|
timeoutMs: numberFlag(flags, "timeout-ms") ?? 30 * 60 * 1000,
|
|
542
556
|
analysisOverheadMs: numberFlag(flags, "analysis-overhead-ms"),
|
|
543
557
|
tailBytes: numberFlag(flags, "tail-bytes") ?? 12_000,
|
|
558
|
+
repetitions: numberFlag(flags, "repetitions"),
|
|
559
|
+
cacheState: parseCacheState(flags),
|
|
560
|
+
cachePreparationCommand: stringFlag(flags, "cache-prepare"),
|
|
561
|
+
alternateOrder: flags["fixed-order"] === true ? false : undefined,
|
|
544
562
|
};
|
|
545
563
|
}
|
|
546
564
|
function runVerifySavingsCommand(flags, env) {
|
|
@@ -609,6 +627,10 @@ async function runPilot(flags, env) {
|
|
|
609
627
|
timeoutMs: numberFlag(flags, "timeout-ms") ?? 30 * 60 * 1000,
|
|
610
628
|
analysisOverheadMs: numberFlag(flags, "analysis-overhead-ms"),
|
|
611
629
|
tailBytes: numberFlag(flags, "tail-bytes") ?? 12_000,
|
|
630
|
+
repetitions: numberFlag(flags, "repetitions"),
|
|
631
|
+
cacheState: parseCacheState(flags),
|
|
632
|
+
cachePreparationCommand: stringFlag(flags, "cache-prepare"),
|
|
633
|
+
alternateOrder: flags["fixed-order"] === true ? false : undefined,
|
|
612
634
|
});
|
|
613
635
|
writeVerifySavingsReport(savings, { out: savingsPath, markdown: markdownPath });
|
|
614
636
|
console.log(formatVerifySavingsSummary(savings));
|
|
@@ -616,39 +638,59 @@ async function runPilot(flags, env) {
|
|
|
616
638
|
console.log(` markdown: ${markdownPath}`);
|
|
617
639
|
return savings.comparison.evidenceValid ? 0 : 1;
|
|
618
640
|
}
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
pilot
|
|
643
|
-
observe
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
--
|
|
651
|
-
|
|
641
|
+
function runValidateSpecs(flags) {
|
|
642
|
+
const file = stringFlag(flags, "file");
|
|
643
|
+
if (!file)
|
|
644
|
+
throw new Error("validate-specs requires --file <json>");
|
|
645
|
+
const report = detectSpecificationConflicts(readSpecificationFile(file));
|
|
646
|
+
if (flags.json === true)
|
|
647
|
+
console.log(JSON.stringify(report, null, 2));
|
|
648
|
+
else if (report.valid)
|
|
649
|
+
console.log(`DiffCI specification validation: no conflicts across ${report.specificationsChecked} specification(s) and ${report.logicalTargetsChecked} logical target(s).`);
|
|
650
|
+
else {
|
|
651
|
+
console.log(`DiffCI specification validation: BLOCKED (${report.conflicts.length} logical-target conflict${report.conflicts.length === 1 ? "" : "s"})`);
|
|
652
|
+
for (const blocker of report.blockers)
|
|
653
|
+
console.log(` ${blocker}`);
|
|
654
|
+
}
|
|
655
|
+
return report.valid ? 0 : 1;
|
|
656
|
+
}
|
|
657
|
+
const USAGE = `diffci - change-aware CI analysis and paired timing
|
|
658
|
+
|
|
659
|
+
Usage:
|
|
660
|
+
diffci init [--repo <path>] [--workflow] [--install] [--force]
|
|
661
|
+
diffci mcp
|
|
662
|
+
diffci check [--repo <path>] [--out <file>] [--base <sha> --head <sha>]
|
|
663
|
+
[--redact-paths] [--json] [--quiet] [--fail-on-error] [--timeout-ms <ms>] [--share-usage]
|
|
664
|
+
diffci pilot --full <command> [--repo <path>] [--out-dir <dir>] [--label <name>]
|
|
665
|
+
diffci observe [--repo <path>] [--out <file>] [--base <sha> --head <sha>]
|
|
666
|
+
[--redact-paths] [--json] [--quiet] [--fail-on-error]
|
|
667
|
+
[--api-url <url> --api-token <token>] [--no-send] [--share-usage]
|
|
668
|
+
diffci verify-savings --repo <path> --full <command>
|
|
669
|
+
(--selected <command> | --selected-from-report <file>)
|
|
670
|
+
--out <file> [--markdown <file>] [--label <name>]
|
|
671
|
+
[--repetitions <1-20>] [--cache-state cold|warm|unknown]
|
|
672
|
+
[--cache-prepare <command>] [--fixed-order]
|
|
673
|
+
diffci validate-specs --file <json> [--json]
|
|
674
|
+
diffci verify-workflow [--repo <path>]
|
|
675
|
+
diffci version
|
|
676
|
+
|
|
677
|
+
init writes AGENTS.md, CLAUDE.md, Cursor rules, Copilot instructions, and diffci.config.json.
|
|
678
|
+
--workflow adds a separate non-blocking observation workflow. --install detects npm, pnpm, Yarn,
|
|
679
|
+
or Bun, installs this DiffCI version as an exact dev dependency, updates the manager's lockfile,
|
|
680
|
+
and adds diffci:check and diffci:observe package scripts without replacing existing scripts.
|
|
681
|
+
mcp runs the stdio MCP server for native agent integrations.
|
|
682
|
+
check analyzes the change, runs inferred full and selected commands, and shows measured savings.
|
|
683
|
+
pilot runs observe and verify-savings together, writing reports to ../diffci-output by default.
|
|
684
|
+
observe analyses the checkout and writes one JSON report. It runs nothing and changes nothing.
|
|
685
|
+
verify-savings runs both commands and reports measured paired runtime; it is an opt-in pilot command.
|
|
686
|
+
validate-specs checks an explicit list of specification IDs and logical targets and blocks duplicates.
|
|
687
|
+
verify-workflow checks that the job running DiffCI cannot affect any other job, and exits 1 if it can.
|
|
688
|
+
|
|
689
|
+
The report is sent only when both --api-url and --api-token are given (or DIFFCI_API_URL and
|
|
690
|
+
DIFFCI_TOKEN are set). A failed send is reported and never fails the step - the report is on disk
|
|
691
|
+
either way. Plain http is refused; the token is never printed.
|
|
692
|
+
--share-usage (or DIFFCI_SHARE_USAGE=1) sends only command, outcome, and version to DiffCI.
|
|
693
|
+
No repository, commit, test, report, or persistent identifier is sent. --no-send disables it.
|
|
652
694
|
`;
|
|
653
695
|
async function main() {
|
|
654
696
|
const { command, flags } = parseArgs(process.argv);
|
|
@@ -677,6 +719,9 @@ async function main() {
|
|
|
677
719
|
case "verify-savings":
|
|
678
720
|
process.exitCode = runVerifySavingsCommand(flags, env);
|
|
679
721
|
return;
|
|
722
|
+
case "validate-specs":
|
|
723
|
+
process.exitCode = runValidateSpecs(flags);
|
|
724
|
+
return;
|
|
680
725
|
case "verify-workflow":
|
|
681
726
|
process.exitCode = runVerifyWorkflow(flags, env);
|
|
682
727
|
return;
|
|
File without changes
|