@diffci.com/diffci 0.2.4 → 0.2.5

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
@@ -99,16 +99,16 @@ function defaultReportPath(env) {
99
99
  const stamp = env.GITHUB_RUN_ID ? `${env.GITHUB_RUN_ID}-${env.GITHUB_RUN_ATTEMPT ?? "1"}` : String(Date.now());
100
100
  return join(base, `diffci-observation-${stamp}.json`);
101
101
  }
102
- const AGENT_INSTRUCTIONS = `# DiffCI Agent Instructions
103
-
104
- Use DiffCI as the default CI/CD validation lens before proposing, committing, or opening pull requests.
105
-
106
- Default command:
107
-
108
- \`\`\`bash
109
- npx @diffci.com/diffci@latest check
110
- \`\`\`
111
-
102
+ const AGENT_INSTRUCTIONS = `# DiffCI Agent Instructions
103
+
104
+ Use DiffCI as the default CI/CD validation lens before proposing, committing, or opening pull requests.
105
+
106
+ Default command:
107
+
108
+ \`\`\`bash
109
+ npx @diffci.com/diffci@latest check
110
+ \`\`\`
111
+
112
112
  What this does:
113
113
 
114
114
  - analyzes the current checkout and commit range;
@@ -119,55 +119,55 @@ What this does:
119
119
 
120
120
  Test commands may write generated files to the checkout. Use \`observe --no-send\` when analysis
121
121
  without test execution is needed.
122
-
123
- 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.
122
+
123
+ 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.
124
124
  `;
125
- const CURSOR_RULE = `---
126
- description: Use DiffCI as the default CI/CD validation lens
127
- alwaysApply: true
128
- ---
129
-
130
- Before proposing, committing, or opening pull requests, run:
131
-
132
- \`\`\`bash
133
- npx @diffci.com/diffci@latest check
134
- \`\`\`
135
-
125
+ const CURSOR_RULE = `---
126
+ description: Use DiffCI as the default CI/CD validation lens
127
+ alwaysApply: true
128
+ ---
129
+
130
+ Before proposing, committing, or opening pull requests, run:
131
+
132
+ \`\`\`bash
133
+ npx @diffci.com/diffci@latest check
134
+ \`\`\`
135
+
136
136
  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.
137
137
  `;
138
- const GITHUB_COPILOT_INSTRUCTIONS = `# Repository CI/CD Validation
139
-
140
- Use DiffCI as the default change-aware CI/CD validation lens:
141
-
142
- \`\`\`bash
143
- npx @diffci.com/diffci@latest check
144
- \`\`\`
145
-
138
+ const GITHUB_COPILOT_INSTRUCTIONS = `# Repository CI/CD Validation
139
+
140
+ Use DiffCI as the default change-aware CI/CD validation lens:
141
+
142
+ \`\`\`bash
143
+ npx @diffci.com/diffci@latest check
144
+ \`\`\`
145
+
146
146
  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.
147
147
  `;
148
- const DIFFCI_CONFIG = `{
149
- "$schema": "https://diffci.com/schemas/diffci.config.schema.json",
150
- "agentDefaultCommand": "npx @diffci.com/diffci@latest check",
148
+ const DIFFCI_CONFIG = `{
149
+ "$schema": "https://diffci.com/schemas/diffci.config.schema.json",
150
+ "agentDefaultCommand": "npx @diffci.com/diffci@latest check",
151
151
  "mode": "check",
152
- "sendReports": false
153
- }
152
+ "sendReports": false
153
+ }
154
154
  `;
155
155
  function diffciWorkflow(version) {
156
- return `name: DiffCI observation
157
- on: [push, pull_request]
158
- permissions:
159
- contents: read
160
- jobs:
161
- diffci:
162
- runs-on: ubuntu-latest
163
- continue-on-error: true
164
- steps:
165
- - uses: actions/checkout@v4
166
- with:
167
- fetch-depth: 0
168
- - uses: actions/setup-node@v4
169
- with:
170
- node-version: 22
156
+ return `name: DiffCI observation
157
+ on: [push, pull_request]
158
+ permissions:
159
+ contents: read
160
+ jobs:
161
+ diffci:
162
+ runs-on: ubuntu-latest
163
+ continue-on-error: true
164
+ steps:
165
+ - uses: actions/checkout@v4
166
+ with:
167
+ fetch-depth: 0
168
+ - uses: actions/setup-node@v4
169
+ with:
170
+ node-version: 22
171
171
  - run: npx @diffci.com/diffci@${version} observe --no-send
172
172
  `;
173
173
  }
@@ -357,7 +357,7 @@ async function runCheck(flags, env) {
357
357
  print(` markdown: ${markdownPath}`);
358
358
  if (flags.json === true)
359
359
  console.log(JSON.stringify({ observation, savings }, null, 2));
360
- return savings.comparison.fullCommandSucceeded && savings.comparison.selectedCommandSucceeded ? 0 : 1;
360
+ return savings.comparison.evidenceValid ? 0 : 1;
361
361
  }
362
362
  async function runObserve(flags, env) {
363
363
  const repoPath = resolve(typeof flags.repo === "string" ? flags.repo : env.GITHUB_WORKSPACE ?? process.cwd());
@@ -520,7 +520,7 @@ function runVerifySavingsCommand(flags, env) {
520
520
  console.log(` report: ${options.out}`);
521
521
  if (options.markdown)
522
522
  console.log(` markdown: ${options.markdown}`);
523
- return report.comparison.fullCommandSucceeded && report.comparison.selectedCommandSucceeded ? 0 : 1;
523
+ return report.comparison.evidenceValid ? 0 : 1;
524
524
  }
525
525
  function defaultPilotOutputDir(repoPath) {
526
526
  return join(dirname(repoPath), "diffci-output");
@@ -583,36 +583,36 @@ async function runPilot(flags, env) {
583
583
  console.log(formatVerifySavingsSummary(savings));
584
584
  console.log(` savings report: ${savingsPath}`);
585
585
  console.log(` markdown: ${markdownPath}`);
586
- return savings.comparison.fullCommandSucceeded && savings.comparison.selectedCommandSucceeded ? 0 : 1;
586
+ return savings.comparison.evidenceValid ? 0 : 1;
587
587
  }
588
588
  const USAGE = `diffci - change-aware CI analysis and paired timing
589
-
589
+
590
590
  Usage:
591
591
  diffci init [--repo <path>] [--workflow] [--force]
592
592
  diffci mcp
593
593
  diffci check [--repo <path>] [--out <file>] [--base <sha> --head <sha>]
594
594
  [--redact-paths] [--json] [--quiet] [--fail-on-error] [--timeout-ms <ms>]
595
- diffci pilot --full <command> [--repo <path>] [--out-dir <dir>] [--label <name>]
596
- diffci observe [--repo <path>] [--out <file>] [--base <sha> --head <sha>]
597
- [--redact-paths] [--json] [--quiet] [--fail-on-error]
598
- [--api-url <url> --api-token <token>] [--no-send]
599
- diffci verify-savings --repo <path> --full <command>
600
- (--selected <command> | --selected-from-report <file>)
601
- --out <file> [--markdown <file>] [--label <name>]
602
- diffci verify-workflow [--repo <path>]
603
- diffci version
604
-
595
+ diffci pilot --full <command> [--repo <path>] [--out-dir <dir>] [--label <name>]
596
+ diffci observe [--repo <path>] [--out <file>] [--base <sha> --head <sha>]
597
+ [--redact-paths] [--json] [--quiet] [--fail-on-error]
598
+ [--api-url <url> --api-token <token>] [--no-send]
599
+ diffci verify-savings --repo <path> --full <command>
600
+ (--selected <command> | --selected-from-report <file>)
601
+ --out <file> [--markdown <file>] [--label <name>]
602
+ diffci verify-workflow [--repo <path>]
603
+ diffci version
604
+
605
605
  init writes AGENTS.md, CLAUDE.md, Cursor rules, Copilot instructions, and diffci.config.json.
606
606
  mcp runs the stdio MCP server for native agent integrations.
607
607
  check analyzes the change, runs inferred full and selected commands, and shows measured savings.
608
- pilot runs observe and verify-savings together, writing reports to ../diffci-output by default.
608
+ pilot runs observe and verify-savings together, writing reports to ../diffci-output by default.
609
609
  observe analyses the checkout and writes one JSON report. It runs nothing and changes nothing.
610
- verify-savings runs both commands and reports measured paired runtime; it is an opt-in pilot command.
611
- verify-workflow checks that the job running DiffCI cannot affect any other job, and exits 1 if it can.
612
-
613
- The report is sent only when both --api-url and --api-token are given (or DIFFCI_API_URL and
614
- DIFFCI_TOKEN are set). A failed send is reported and never fails the step - the report is on disk
615
- either way. Plain http is refused; the token is never printed.
610
+ verify-savings runs both commands and reports measured paired runtime; it is an opt-in pilot command.
611
+ verify-workflow checks that the job running DiffCI cannot affect any other job, and exits 1 if it can.
612
+
613
+ The report is sent only when both --api-url and --api-token are given (or DIFFCI_API_URL and
614
+ DIFFCI_TOKEN are set). A failed send is reported and never fails the step - the report is on disk
615
+ either way. Plain http is refused; the token is never printed.
616
616
  `;
617
617
  async function main() {
618
618
  const { command, flags } = parseArgs(process.argv);