@diffci.com/diffci 0.2.13 → 0.3.0-rc.1
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/README.md +41 -16
- package/dist-client/src/client/cli.js +215 -33
- package/dist-client/src/client/install.js +1 -0
- package/dist-client/src/client/mcp.js +66 -0
- package/dist-client/src/client/verify.js +265 -0
- package/dist-client/src/client/workflow-guard.js +11 -2
- package/dist-client/src/client/working-tree.js +65 -0
- package/docs/adoption-metrics.md +1 -1
- package/docs/agent-adoption-kit.md +24 -10
- package/docs/ai-agents.md +25 -10
- package/docs/distribution.md +12 -5
- package/docs/mcp.md +13 -5
- package/glama.json +1 -1
- package/llms.txt +6 -4
- package/package.json +2 -2
- package/server.json +3 -3
package/README.md
CHANGED
|
@@ -6,25 +6,30 @@
|
|
|
6
6
|
[](https://www.npmjs.com/package/@diffci.com/diffci)
|
|
7
7
|
[](https://docs.npmjs.com/generating-provenance-statements)
|
|
8
8
|
[](https://diffci.com/mcp-server)
|
|
9
|
-
[](docs/ai-agents.md)
|
|
10
10
|
[](https://github.com/marketplace/actions/diffci-observer)
|
|
11
11
|
|
|
12
|
-
**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
**The verification layer between AI-generated code and shipping.** DiffCI snapshots an agent's staged,
|
|
13
|
+
unstaged, and non-ignored untracked changes, determines the minimum executable test verification, and
|
|
14
|
+
runs it. Uncertainty broadens to full verification; a failed, incomplete, or changed snapshot blocks.
|
|
15
|
+
The `check` command remains the paired-runtime evaluation surface. `observe` and the Marketplace Action
|
|
16
|
+
remain observation-only; DiffCI also generates a separate blocking verification workflow.
|
|
16
17
|
|
|
17
18
|
## Try DiffCI
|
|
18
19
|
|
|
19
20
|
From a Git repository checkout, with Node.js 22.5+ and Git installed, run:
|
|
20
21
|
|
|
21
22
|
```bash
|
|
22
|
-
npx "@diffci.com/diffci@latest"
|
|
23
|
+
npx "@diffci.com/diffci@latest" verify --changed --json
|
|
23
24
|
```
|
|
24
25
|
|
|
25
|
-
`
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
`verify --changed` covers staged, unstaged, and non-ignored untracked content. It runs the selected
|
|
27
|
+
command when DiffCI can prove one, otherwise the inferred full test command. Exit zero means that exact
|
|
28
|
+
content-addressed snapshot passed and remained unchanged while tests ran. The JSON receipt includes
|
|
29
|
+
`verification`, `safe_to_continue`, selection counts, the command result, and tree identities.
|
|
30
|
+
|
|
31
|
+
For paired full-versus-selected runtime measurement, use `check`. For analysis without test execution,
|
|
32
|
+
use `npx "@diffci.com/diffci@latest" observe --no-send`.
|
|
28
33
|
|
|
29
34
|
To add instructions for coding agents, run:
|
|
30
35
|
|
|
@@ -33,20 +38,26 @@ npx "@diffci.com/diffci@latest" init
|
|
|
33
38
|
```
|
|
34
39
|
|
|
35
40
|
To also pin DiffCI as a development dependency and update the detected npm, pnpm, Yarn, or Bun
|
|
36
|
-
lockfile, pass `--install`. Add `--workflow` for a
|
|
41
|
+
lockfile, pass `--install`. Add `--workflow` for a non-blocking observation job and
|
|
42
|
+
`--verification-workflow` for a blocking commit-range gate:
|
|
37
43
|
|
|
38
44
|
```bash
|
|
39
|
-
npx "@diffci.com/diffci@latest" init --install --workflow
|
|
45
|
+
npx "@diffci.com/diffci@latest" init --install --workflow --verification-workflow
|
|
40
46
|
```
|
|
41
47
|
|
|
42
|
-
`--install` also adds `diffci:check
|
|
48
|
+
`--install` also adds `diffci:verify`, `diffci:check`, and `diffci:observe` package scripts. It preserves same-named
|
|
43
49
|
scripts that the project already owns. After installation, CI or contributors can run
|
|
44
|
-
`npm run diffci:
|
|
50
|
+
`npm run diffci:verify`, `npm run diffci:check`, or `npm run diffci:observe` without knowing the package name or version.
|
|
51
|
+
Generated agent rules use the detected package manager's local script when DiffCI is installed.
|
|
52
|
+
|
|
53
|
+
In CI, `diffci verify --json` resolves the pull-request or push range automatically. It requires a
|
|
54
|
+
clean checkout, refuses when the analyzed head differs from executed `HEAD`, and binds the receipt to
|
|
55
|
+
both the resolved range and checkout tree. Use `--base` and `--head` for an explicit range.
|
|
45
56
|
|
|
46
57
|
On Windows PowerShell, quote the package name:
|
|
47
58
|
|
|
48
59
|
```powershell
|
|
49
|
-
npx "@diffci.com/diffci@latest"
|
|
60
|
+
npx "@diffci.com/diffci@latest" verify --changed --json
|
|
50
61
|
```
|
|
51
62
|
|
|
52
63
|
The [copyable adoption kit](docs/agent-adoption-kit.md) includes an `AGENTS.md` instruction and
|
|
@@ -127,6 +138,20 @@ npx "@diffci.com/diffci@latest" validate-specs --file change-specifications.json
|
|
|
127
138
|
The command exits non-zero and names every conflicting specification ID. This surface is opt-in and
|
|
128
139
|
does not infer semantic targets from source code; callers must provide stable logical target names.
|
|
129
140
|
|
|
141
|
+
## Block in GitHub Actions
|
|
142
|
+
|
|
143
|
+
Generate a dedicated verification check with:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
npx "@diffci.com/diffci@latest" init --verification-workflow
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
The generated `.github/workflows/diffci-verify.yml` checks out the exact pull-request head with full
|
|
150
|
+
history, runs `diffci verify --json`, and uploads the commit-bound receipt even when verification
|
|
151
|
+
fails. It has no `continue-on-error`: configure its **DiffCI verification** job as a required check
|
|
152
|
+
after a successful pilot. A zero exit means the selected verification (or conservative full fallback)
|
|
153
|
+
passed for the exact analyzed commit and checkout tree.
|
|
154
|
+
|
|
130
155
|
## Observe in GitHub Actions
|
|
131
156
|
|
|
132
157
|
Save this as `.github/workflows/diffci.yml` to add a dedicated, non-blocking observation job:
|
|
@@ -150,7 +175,7 @@ jobs:
|
|
|
150
175
|
Then check the workflow locally with `npx "@diffci.com/diffci@latest" verify-workflow`. Keep the observer
|
|
151
176
|
out of required checks and other jobs' `needs` lists. The Action adds a job summary and a
|
|
152
177
|
`diffci-observation` artifact to the run; it does not alter which tests your other jobs execute.
|
|
153
|
-
The example pins release `v0.
|
|
178
|
+
The example pins release `v0.3.0-rc.1` to its qualified feature commit SHA for reproducibility.
|
|
154
179
|
|
|
155
180
|
The CLI sends no report with `--no-send`. The Action uploads a GitHub artifact by default; sending to
|
|
156
181
|
DiffCI's hosted service requires an explicitly configured endpoint and token.
|
|
@@ -181,7 +206,7 @@ npx "@diffci.com/diffci@latest" init
|
|
|
181
206
|
Then ask your coding agent to run:
|
|
182
207
|
|
|
183
208
|
```bash
|
|
184
|
-
npx "@diffci.com/diffci@latest"
|
|
209
|
+
npx "@diffci.com/diffci@latest" verify --changed --json
|
|
185
210
|
```
|
|
186
211
|
|
|
187
212
|
Agent-specific docs:
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* Commands:
|
|
12
12
|
* init seed a repository with AI-agent instructions for using DiffCI
|
|
13
13
|
* mcp run the stdio MCP server
|
|
14
|
+
* verify fail-closed verification of a working-tree snapshot or commit range
|
|
14
15
|
* check analysis plus automatic paired runtime measurement
|
|
15
16
|
* observe analyse the checkout and write an observation report
|
|
16
17
|
* verify-savings run a paired full-versus-selected timing check
|
|
@@ -31,11 +32,12 @@ import { tmpdir } from "node:os";
|
|
|
31
32
|
import { basename, dirname, join, resolve } from "node:path";
|
|
32
33
|
import { observe, isInsideRepository } from "./observe.js";
|
|
33
34
|
import { inferFullCommand, inferSelectedCommand } from "./full-command.js";
|
|
34
|
-
import { addDiffciPackageScripts, installDiffci } from "./install.js";
|
|
35
|
+
import { addDiffciPackageScripts, detectPackageManager, installDiffci } from "./install.js";
|
|
35
36
|
import { submitObservation } from "./submit.js";
|
|
36
37
|
import { githubDeliveryWarning } from "./delivery-warning.js";
|
|
37
38
|
import { sendUsageSignal } from "./usage-signal.js";
|
|
38
39
|
import { detectSpecificationConflicts, readSpecificationFile } from "./spec-conflicts.js";
|
|
40
|
+
import { formatVerificationSummary, verificationExitCode, verifyChanged, verifyRange } from "./verify.js";
|
|
39
41
|
import { formatVerifySavingsSummary, measureCommand, runVerifySavings, writeVerifySavingsReport } from "./verify-savings.js";
|
|
40
42
|
import { auditWorkflows, isNonInterfering } from "./workflow-guard.js";
|
|
41
43
|
function parseArgs(argv) {
|
|
@@ -106,31 +108,33 @@ function defaultReportPath(env) {
|
|
|
106
108
|
}
|
|
107
109
|
// Quoting the scoped package keeps the same command valid in POSIX shells, cmd.exe, and
|
|
108
110
|
// PowerShell, where an unquoted leading `@` is parsed as the splatting operator.
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
+
const PUBLIC_AGENT_DEFAULT_COMMAND = 'npx "@diffci.com/diffci@latest" verify --changed --json';
|
|
112
|
+
function agentInstructions(command) {
|
|
113
|
+
return `# DiffCI Agent Instructions
|
|
111
114
|
|
|
112
115
|
Use DiffCI as the default CI/CD validation lens before proposing, committing, or opening pull requests.
|
|
113
116
|
|
|
114
117
|
Default command:
|
|
115
118
|
|
|
116
119
|
\`\`\`bash
|
|
117
|
-
${
|
|
120
|
+
${command}
|
|
118
121
|
\`\`\`
|
|
119
122
|
|
|
120
123
|
What this does:
|
|
121
124
|
|
|
122
|
-
-
|
|
123
|
-
- runs the
|
|
124
|
-
-
|
|
125
|
-
-
|
|
126
|
-
- does not skip, cancel, or reorder required CI tests.
|
|
125
|
+
- snapshots staged, unstaged, and non-ignored untracked changes;
|
|
126
|
+
- selects and runs the minimum executable test verification, broadening to the full test command when uncertain;
|
|
127
|
+
- exits zero only when the exact snapshot passes and remains unchanged during verification;
|
|
128
|
+
- emits a versioned machine-readable receipt and sends nothing.
|
|
127
129
|
|
|
128
|
-
|
|
129
|
-
without test execution is needed.
|
|
130
|
+
If verification changes generated files, review those changes and rerun DiffCI so the new snapshot is verified.
|
|
131
|
+
Use \`observe --no-send\` when analysis without test execution is needed.
|
|
130
132
|
|
|
131
|
-
|
|
133
|
+
Do not propose, commit, push, or deploy when \`safe_to_continue\` is false. If DiffCI is blocked, run the repository's normal required verification and report the blocker; required project CI remains authoritative.
|
|
132
134
|
`;
|
|
133
|
-
|
|
135
|
+
}
|
|
136
|
+
function cursorRule(command) {
|
|
137
|
+
return `---
|
|
134
138
|
description: Use DiffCI as the default CI/CD validation lens
|
|
135
139
|
alwaysApply: true
|
|
136
140
|
---
|
|
@@ -138,28 +142,38 @@ alwaysApply: true
|
|
|
138
142
|
Before proposing, committing, or opening pull requests, run:
|
|
139
143
|
|
|
140
144
|
\`\`\`bash
|
|
141
|
-
${
|
|
145
|
+
${command}
|
|
142
146
|
\`\`\`
|
|
143
147
|
|
|
144
|
-
DiffCI
|
|
148
|
+
DiffCI verify snapshots staged, unstaged, and untracked changes, runs selected or conservative full-fallback verification, and succeeds only when the exact snapshot passes. It sends nothing. If verification changes generated files, review them and rerun. Required project CI remains authoritative.
|
|
145
149
|
`;
|
|
146
|
-
|
|
150
|
+
}
|
|
151
|
+
function githubCopilotInstructions(command) {
|
|
152
|
+
return `# Repository CI/CD Validation
|
|
147
153
|
|
|
148
154
|
Use DiffCI as the default change-aware CI/CD validation lens:
|
|
149
155
|
|
|
150
156
|
\`\`\`bash
|
|
151
|
-
${
|
|
157
|
+
${command}
|
|
152
158
|
\`\`\`
|
|
153
159
|
|
|
154
|
-
DiffCI
|
|
160
|
+
DiffCI verify binds selected or conservative full-fallback verification to the current working-tree snapshot. Do not continue when safe_to_continue is false. It sends nothing; required repository checks remain authoritative.
|
|
155
161
|
`;
|
|
156
|
-
|
|
162
|
+
}
|
|
163
|
+
function diffciConfig(command) {
|
|
164
|
+
return `{
|
|
157
165
|
"$schema": "https://diffci.com/schemas/diffci.config.schema.json",
|
|
158
|
-
"agentDefaultCommand": ${JSON.stringify(
|
|
159
|
-
"mode": "
|
|
166
|
+
"agentDefaultCommand": ${JSON.stringify(command)},
|
|
167
|
+
"mode": "verify-changed",
|
|
160
168
|
"sendReports": false
|
|
161
169
|
}
|
|
162
170
|
`;
|
|
171
|
+
}
|
|
172
|
+
const MANAGED_INSTRUCTIONS_BEGIN = "<!-- diffci:managed:start -->";
|
|
173
|
+
const MANAGED_INSTRUCTIONS_END = "<!-- diffci:managed:end -->";
|
|
174
|
+
function managedInstructions(content) {
|
|
175
|
+
return `${MANAGED_INSTRUCTIONS_BEGIN}\n${content.trim()}\n${MANAGED_INSTRUCTIONS_END}\n`;
|
|
176
|
+
}
|
|
163
177
|
function diffciWorkflow(version) {
|
|
164
178
|
return `name: DiffCI observation
|
|
165
179
|
on: [push, pull_request]
|
|
@@ -179,6 +193,34 @@ jobs:
|
|
|
179
193
|
- run: npx "@diffci.com/diffci@${version}" observe --no-send
|
|
180
194
|
`;
|
|
181
195
|
}
|
|
196
|
+
function diffciVerificationWorkflow(version) {
|
|
197
|
+
return `name: DiffCI verification
|
|
198
|
+
on: [push, pull_request]
|
|
199
|
+
permissions:
|
|
200
|
+
contents: read
|
|
201
|
+
jobs:
|
|
202
|
+
diffci-verify:
|
|
203
|
+
name: DiffCI verification
|
|
204
|
+
runs-on: ubuntu-latest
|
|
205
|
+
steps:
|
|
206
|
+
- uses: actions/checkout@v4
|
|
207
|
+
with:
|
|
208
|
+
fetch-depth: 0
|
|
209
|
+
ref: \${{ github.event.pull_request.head.sha || github.sha }}
|
|
210
|
+
- uses: actions/setup-node@v4
|
|
211
|
+
with:
|
|
212
|
+
node-version: 22
|
|
213
|
+
- name: Verify changed code
|
|
214
|
+
run: npx "@diffci.com/diffci@${version}" verify --json --out "$RUNNER_TEMP/diffci-verification.json"
|
|
215
|
+
- name: Upload verification receipt
|
|
216
|
+
if: always()
|
|
217
|
+
uses: actions/upload-artifact@v4
|
|
218
|
+
with:
|
|
219
|
+
name: diffci-verification-\${{ github.run_id }}-\${{ github.run_attempt }}
|
|
220
|
+
path: \${{ runner.temp }}/diffci-verification.json
|
|
221
|
+
if-no-files-found: warn
|
|
222
|
+
`;
|
|
223
|
+
}
|
|
182
224
|
function writeInitFile(repoPath, relativePath, content, force) {
|
|
183
225
|
const absolutePath = join(repoPath, relativePath);
|
|
184
226
|
const existed = existsSync(absolutePath);
|
|
@@ -188,21 +230,83 @@ function writeInitFile(repoPath, relativePath, content, force) {
|
|
|
188
230
|
writeFileSync(absolutePath, content, "utf8");
|
|
189
231
|
return `${existed ? "overwrote" : "wrote"} ${relativePath}`;
|
|
190
232
|
}
|
|
233
|
+
function writeManagedInstructionsFile(repoPath, relativePath, content) {
|
|
234
|
+
const absolutePath = join(repoPath, relativePath);
|
|
235
|
+
const block = managedInstructions(content);
|
|
236
|
+
mkdirSync(dirname(absolutePath), { recursive: true });
|
|
237
|
+
if (!existsSync(absolutePath)) {
|
|
238
|
+
writeFileSync(absolutePath, block, "utf8");
|
|
239
|
+
return `wrote ${relativePath}`;
|
|
240
|
+
}
|
|
241
|
+
const existing = readFileSync(absolutePath, "utf8");
|
|
242
|
+
const start = existing.indexOf(MANAGED_INSTRUCTIONS_BEGIN);
|
|
243
|
+
const end = existing.indexOf(MANAGED_INSTRUCTIONS_END);
|
|
244
|
+
let next;
|
|
245
|
+
if (start >= 0 && end >= start) {
|
|
246
|
+
const after = end + MANAGED_INSTRUCTIONS_END.length;
|
|
247
|
+
next = `${existing.slice(0, start)}${block.trimEnd()}${existing.slice(after)}`;
|
|
248
|
+
if (existing.endsWith("\n") && !next.endsWith("\n"))
|
|
249
|
+
next += "\n";
|
|
250
|
+
}
|
|
251
|
+
else if (existing.trimStart().startsWith("# DiffCI Agent Instructions")) {
|
|
252
|
+
// Files generated by DiffCI before managed markers were introduced were dedicated DiffCI files.
|
|
253
|
+
next = block;
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
next = `${existing.trimEnd()}\n\n${block}`;
|
|
257
|
+
}
|
|
258
|
+
if (next === existing)
|
|
259
|
+
return `kept ${relativePath} (managed section current)`;
|
|
260
|
+
writeFileSync(absolutePath, next, "utf8");
|
|
261
|
+
return `updated ${relativePath} (DiffCI managed section)`;
|
|
262
|
+
}
|
|
263
|
+
function writeDiffciConfig(repoPath, force, command) {
|
|
264
|
+
const relativePath = "diffci.config.json";
|
|
265
|
+
const absolutePath = join(repoPath, relativePath);
|
|
266
|
+
const generated = diffciConfig(command);
|
|
267
|
+
if (!existsSync(absolutePath))
|
|
268
|
+
return writeInitFile(repoPath, relativePath, generated, false);
|
|
269
|
+
try {
|
|
270
|
+
const existing = JSON.parse(readFileSync(absolutePath, "utf8"));
|
|
271
|
+
if (existing.$schema === "https://diffci.com/schemas/diffci.config.schema.json") {
|
|
272
|
+
existing.agentDefaultCommand = command;
|
|
273
|
+
existing.mode = "verify-changed";
|
|
274
|
+
if (existing.sendReports === undefined)
|
|
275
|
+
existing.sendReports = false;
|
|
276
|
+
const next = `${JSON.stringify(existing, null, 2)}\n`;
|
|
277
|
+
if (next === readFileSync(absolutePath, "utf8"))
|
|
278
|
+
return `kept ${relativePath} (current)`;
|
|
279
|
+
writeFileSync(absolutePath, next, "utf8");
|
|
280
|
+
return `updated ${relativePath}`;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
catch {
|
|
284
|
+
// An unrelated or invalid existing file is preserved unless the caller explicitly asked to force.
|
|
285
|
+
}
|
|
286
|
+
return writeInitFile(repoPath, relativePath, generated, force);
|
|
287
|
+
}
|
|
288
|
+
function installedDiffciManager(repoPath) {
|
|
289
|
+
const packagePath = join(repoPath, "package.json");
|
|
290
|
+
if (!existsSync(packagePath))
|
|
291
|
+
return undefined;
|
|
292
|
+
try {
|
|
293
|
+
const manifest = JSON.parse(readFileSync(packagePath, "utf8"));
|
|
294
|
+
const installed = [manifest.dependencies, manifest.devDependencies, manifest.optionalDependencies]
|
|
295
|
+
.some((dependencies) => dependencies && typeof dependencies["@diffci.com/diffci"] === "string");
|
|
296
|
+
return installed ? detectPackageManager(repoPath) : undefined;
|
|
297
|
+
}
|
|
298
|
+
catch {
|
|
299
|
+
return undefined;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
191
302
|
function runInit(flags, env) {
|
|
192
303
|
const repoPath = resolve(typeof flags.repo === "string" ? flags.repo : env.GITHUB_WORKSPACE ?? process.cwd());
|
|
193
304
|
const force = flags.force === true;
|
|
194
305
|
const includeWorkflow = flags.workflow === true;
|
|
306
|
+
const includeVerificationWorkflow = flags["verification-workflow"] === true;
|
|
195
307
|
const identity = observerIdentity();
|
|
196
|
-
const writes = [
|
|
197
|
-
writeInitFile(repoPath, "AGENTS.md", AGENT_INSTRUCTIONS, force),
|
|
198
|
-
writeInitFile(repoPath, "CLAUDE.md", AGENT_INSTRUCTIONS, force),
|
|
199
|
-
writeInitFile(repoPath, ".cursor/rules/diffci.mdc", CURSOR_RULE, force),
|
|
200
|
-
writeInitFile(repoPath, ".github/copilot-instructions.md", GITHUB_COPILOT_INSTRUCTIONS, force),
|
|
201
|
-
writeInitFile(repoPath, "diffci.config.json", DIFFCI_CONFIG, force),
|
|
202
|
-
];
|
|
203
|
-
if (includeWorkflow)
|
|
204
|
-
writes.push(writeInitFile(repoPath, ".github/workflows/diffci.yml", diffciWorkflow(identity.version), force));
|
|
205
308
|
let installed;
|
|
309
|
+
let manager = installedDiffciManager(repoPath);
|
|
206
310
|
if (flags.install === true) {
|
|
207
311
|
const { plan, result } = installDiffci(repoPath, identity.version);
|
|
208
312
|
if (result.error)
|
|
@@ -212,12 +316,35 @@ function runInit(flags, env) {
|
|
|
212
316
|
throw new Error(`could not install ${plan.packageSpec}: ${detail}`);
|
|
213
317
|
}
|
|
214
318
|
const scripts = addDiffciPackageScripts(repoPath);
|
|
319
|
+
manager = plan.manager;
|
|
215
320
|
installed = `installed ${plan.packageSpec} as an exact dev dependency with ${plan.manager}`;
|
|
216
321
|
if (scripts.added.length > 0)
|
|
217
322
|
installed += `; added package scripts ${scripts.added.join(", ")}`;
|
|
218
323
|
if (scripts.kept.length > 0)
|
|
219
324
|
installed += `; kept existing package scripts ${scripts.kept.join(", ")}`;
|
|
220
325
|
}
|
|
326
|
+
else if (manager) {
|
|
327
|
+
const scripts = addDiffciPackageScripts(repoPath);
|
|
328
|
+
installed = `found the existing exact or ranged @diffci.com/diffci dependency with ${manager}`;
|
|
329
|
+
if (scripts.added.length > 0)
|
|
330
|
+
installed += `; added package scripts ${scripts.added.join(", ")}`;
|
|
331
|
+
if (scripts.kept.length > 0)
|
|
332
|
+
installed += `; kept existing package scripts ${scripts.kept.join(", ")}`;
|
|
333
|
+
}
|
|
334
|
+
const agentCommand = manager ? `${manager} run diffci:verify` : PUBLIC_AGENT_DEFAULT_COMMAND;
|
|
335
|
+
const instructions = agentInstructions(agentCommand);
|
|
336
|
+
const writes = [
|
|
337
|
+
writeManagedInstructionsFile(repoPath, "AGENTS.md", instructions),
|
|
338
|
+
writeManagedInstructionsFile(repoPath, "CLAUDE.md", instructions),
|
|
339
|
+
writeInitFile(repoPath, ".cursor/rules/diffci.mdc", cursorRule(agentCommand), force),
|
|
340
|
+
writeManagedInstructionsFile(repoPath, ".github/copilot-instructions.md", githubCopilotInstructions(agentCommand)),
|
|
341
|
+
writeDiffciConfig(repoPath, force, agentCommand),
|
|
342
|
+
];
|
|
343
|
+
if (includeWorkflow)
|
|
344
|
+
writes.push(writeInitFile(repoPath, ".github/workflows/diffci.yml", diffciWorkflow(identity.version), force));
|
|
345
|
+
if (includeVerificationWorkflow) {
|
|
346
|
+
writes.push(writeInitFile(repoPath, ".github/workflows/diffci-verify.yml", diffciVerificationWorkflow(identity.version), force));
|
|
347
|
+
}
|
|
221
348
|
console.log(`DiffCI initialized for AI coding agents in ${repoPath}`);
|
|
222
349
|
for (const write of writes)
|
|
223
350
|
console.log(` ${write}`);
|
|
@@ -227,7 +354,9 @@ function runInit(flags, env) {
|
|
|
227
354
|
console.log(" skipped package installation (pass --install to add an exact dev dependency)");
|
|
228
355
|
if (!includeWorkflow)
|
|
229
356
|
console.log(" skipped .github/workflows/diffci.yml (pass --workflow to add it)");
|
|
230
|
-
|
|
357
|
+
if (!includeVerificationWorkflow)
|
|
358
|
+
console.log(" skipped .github/workflows/diffci-verify.yml (pass --verification-workflow to add it)");
|
|
359
|
+
console.log(`\nDefault agent command: ${agentCommand}`);
|
|
231
360
|
return 0;
|
|
232
361
|
}
|
|
233
362
|
function runMcp() {
|
|
@@ -243,6 +372,49 @@ function runMcp() {
|
|
|
243
372
|
throw result.error;
|
|
244
373
|
return 0;
|
|
245
374
|
}
|
|
375
|
+
async function runVerifyCommand(flags, env) {
|
|
376
|
+
const changed = flags.changed === true;
|
|
377
|
+
if (changed && (flags.base !== undefined || flags.head !== undefined)) {
|
|
378
|
+
console.error("diffci verify accepts either --changed or --base/--head, not both");
|
|
379
|
+
return 2;
|
|
380
|
+
}
|
|
381
|
+
const repoPath = resolve(stringFlag(flags, "repo") ?? env.GITHUB_WORKSPACE ?? process.cwd());
|
|
382
|
+
const out = stringFlag(flags, "out");
|
|
383
|
+
const reportPath = out ? resolve(out) : undefined;
|
|
384
|
+
if (reportPath && (reportPath === repoPath || isInsideRepository(repoPath, reportPath))) {
|
|
385
|
+
console.error(`Refusing to write the verification receipt inside the repository: ${reportPath}. Use --out with a path outside the checkout.`);
|
|
386
|
+
return 2;
|
|
387
|
+
}
|
|
388
|
+
const identity = observerIdentity();
|
|
389
|
+
const common = {
|
|
390
|
+
repoPath,
|
|
391
|
+
env: env,
|
|
392
|
+
version: identity.version,
|
|
393
|
+
engineSha: identity.sha,
|
|
394
|
+
timeoutMs: numberFlag(flags, "timeout-ms") ?? 30 * 60 * 1000,
|
|
395
|
+
tailBytes: numberFlag(flags, "tail-bytes") ?? 12_000,
|
|
396
|
+
redactPaths: flags["redact-paths"] === true,
|
|
397
|
+
};
|
|
398
|
+
const report = changed
|
|
399
|
+
? await verifyChanged(common)
|
|
400
|
+
: await verifyRange({
|
|
401
|
+
...common,
|
|
402
|
+
baseOverride: stringFlag(flags, "base"),
|
|
403
|
+
headOverride: stringFlag(flags, "head"),
|
|
404
|
+
});
|
|
405
|
+
if (reportPath) {
|
|
406
|
+
mkdirSync(dirname(reportPath), { recursive: true });
|
|
407
|
+
writeFileSync(reportPath, `${JSON.stringify(report, null, 2)}\n`, "utf8");
|
|
408
|
+
}
|
|
409
|
+
if (flags.json === true)
|
|
410
|
+
console.log(JSON.stringify(report, null, 2));
|
|
411
|
+
else {
|
|
412
|
+
console.log(formatVerificationSummary(report));
|
|
413
|
+
if (reportPath)
|
|
414
|
+
console.log(` receipt: ${reportPath}`);
|
|
415
|
+
}
|
|
416
|
+
return verificationExitCode(report);
|
|
417
|
+
}
|
|
246
418
|
function formatFinding(finding) {
|
|
247
419
|
const where = finding.job ? `${finding.workflow}#${finding.job}` : finding.workflow;
|
|
248
420
|
return ` [${finding.severity}] ${finding.code} (${where})\n ${finding.message}`;
|
|
@@ -661,8 +833,10 @@ function runValidateSpecs(flags) {
|
|
|
661
833
|
const USAGE = `diffci - change-aware CI analysis and paired timing
|
|
662
834
|
|
|
663
835
|
Usage:
|
|
664
|
-
diffci init [--repo <path>] [--workflow] [--install] [--force]
|
|
836
|
+
diffci init [--repo <path>] [--workflow] [--verification-workflow] [--install] [--force]
|
|
665
837
|
diffci mcp
|
|
838
|
+
diffci verify [--changed | --base <sha> --head <sha>] [--repo <path>] [--out <file>] [--json]
|
|
839
|
+
[--redact-paths] [--timeout-ms <ms>]
|
|
666
840
|
diffci check [--repo <path>] [--out <file>] [--base <sha> --head <sha>]
|
|
667
841
|
[--redact-paths] [--json] [--quiet] [--fail-on-error] [--timeout-ms <ms>] [--share-usage]
|
|
668
842
|
diffci pilot --full <command> [--repo <path>] [--out-dir <dir>] [--label <name>]
|
|
@@ -681,8 +855,13 @@ Usage:
|
|
|
681
855
|
init writes AGENTS.md, CLAUDE.md, Cursor rules, Copilot instructions, and diffci.config.json.
|
|
682
856
|
--workflow adds a separate non-blocking observation workflow. --install detects npm, pnpm, Yarn,
|
|
683
857
|
or Bun, installs this DiffCI version as an exact dev dependency, updates the manager's lockfile,
|
|
684
|
-
and adds diffci:check and diffci:observe package scripts without replacing existing scripts.
|
|
858
|
+
and adds diffci:verify, diffci:check, and diffci:observe package scripts without replacing existing scripts.
|
|
859
|
+
--verification-workflow adds a blocking GitHub check that uploads a commit-bound verification receipt.
|
|
685
860
|
mcp runs the stdio MCP server for native agent integrations.
|
|
861
|
+
verify --changed snapshots staged, unstaged, and non-ignored untracked changes, runs the minimum
|
|
862
|
+
executable verification (or full fallback), and exits zero only when that exact snapshot passes.
|
|
863
|
+
verify without --changed resolves the CI event range (or HEAD^..HEAD locally), requires a clean checkout,
|
|
864
|
+
and exits zero only when the analyzed head is the commit that actually passed verification.
|
|
686
865
|
check analyzes the change, runs inferred full and selected commands, and shows measured savings.
|
|
687
866
|
pilot runs observe and verify-savings together, writing reports to ../diffci-output by default.
|
|
688
867
|
observe analyses the checkout and writes one JSON report. It runs nothing and changes nothing.
|
|
@@ -711,6 +890,9 @@ async function main() {
|
|
|
711
890
|
case "mcp":
|
|
712
891
|
process.exitCode = runMcp();
|
|
713
892
|
return;
|
|
893
|
+
case "verify":
|
|
894
|
+
process.exitCode = await runVerifyCommand(flags, env);
|
|
895
|
+
return;
|
|
714
896
|
case "check":
|
|
715
897
|
process.exitCode = await runCheck(flags, env);
|
|
716
898
|
return;
|
|
@@ -2,6 +2,7 @@ import { spawnSync } from "node:child_process";
|
|
|
2
2
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
const DIFFCI_SCRIPTS = {
|
|
5
|
+
"diffci:verify": "diffci verify --changed --json",
|
|
5
6
|
"diffci:check": "diffci check",
|
|
6
7
|
"diffci:observe": "diffci observe --no-send",
|
|
7
8
|
};
|
|
@@ -4,6 +4,34 @@ import { dirname, join, resolve } from "node:path";
|
|
|
4
4
|
import { StringDecoder } from "node:string_decoder";
|
|
5
5
|
const SERVER_INFO = { name: "diffci-mcp", version: "0.1.0" };
|
|
6
6
|
const tools = [
|
|
7
|
+
{
|
|
8
|
+
name: "diffci_verify",
|
|
9
|
+
description: "Verify a clean commit range and return a receipt bound to the checked-out head commit. Resolves the CI event range automatically when base and head are omitted.",
|
|
10
|
+
inputSchema: {
|
|
11
|
+
type: "object",
|
|
12
|
+
properties: {
|
|
13
|
+
repo: { type: "string", description: "Repository path. Defaults to the MCP server working directory." },
|
|
14
|
+
base: { type: "string", description: "Optional base commit SHA. Must be paired with head." },
|
|
15
|
+
head: { type: "string", description: "Optional head commit SHA. Must be paired with base and match checked-out HEAD." },
|
|
16
|
+
timeoutMs: { type: "number", description: "Maximum verification-command runtime in milliseconds." },
|
|
17
|
+
redactPaths: { type: "boolean", description: "Replace paths with stable digests in analysis." },
|
|
18
|
+
},
|
|
19
|
+
additionalProperties: false,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: "diffci_verify_changed",
|
|
24
|
+
description: "Verify the current staged, unstaged, and non-ignored untracked changes. Fails closed unless the exact working-tree snapshot passes selected or full fallback verification.",
|
|
25
|
+
inputSchema: {
|
|
26
|
+
type: "object",
|
|
27
|
+
properties: {
|
|
28
|
+
repo: { type: "string", description: "Repository path. Defaults to the MCP server working directory." },
|
|
29
|
+
timeoutMs: { type: "number", description: "Maximum verification-command runtime in milliseconds." },
|
|
30
|
+
redactPaths: { type: "boolean", description: "Replace paths with stable digests in analysis." },
|
|
31
|
+
},
|
|
32
|
+
additionalProperties: false,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
7
35
|
{
|
|
8
36
|
name: "diffci_check",
|
|
9
37
|
description: "Analyze the repository, run inferred full and selected test commands when available, and report paired runtime. Sends nothing to DiffCI Cloud.",
|
|
@@ -28,6 +56,7 @@ const tools = [
|
|
|
28
56
|
properties: {
|
|
29
57
|
repo: { type: "string", description: "Repository path. Defaults to the MCP server working directory." },
|
|
30
58
|
workflow: { type: "boolean", description: "Also add the non-blocking GitHub Actions observer workflow." },
|
|
59
|
+
verificationWorkflow: { type: "boolean", description: "Also add the blocking GitHub Actions verification workflow." },
|
|
31
60
|
force: { type: "boolean", description: "Overwrite existing instruction files." },
|
|
32
61
|
},
|
|
33
62
|
additionalProperties: false,
|
|
@@ -58,6 +87,33 @@ function booleanArg(args, name) {
|
|
|
58
87
|
function commandForTool(name, args) {
|
|
59
88
|
const repo = stringArg(args, "repo");
|
|
60
89
|
switch (name) {
|
|
90
|
+
case "diffci_verify": {
|
|
91
|
+
const command = ["verify", "--json"];
|
|
92
|
+
if (repo)
|
|
93
|
+
command.push("--repo", resolve(repo));
|
|
94
|
+
for (const flag of ["base", "head"]) {
|
|
95
|
+
const value = stringArg(args, flag);
|
|
96
|
+
if (value)
|
|
97
|
+
command.push(`--${flag}`, value);
|
|
98
|
+
}
|
|
99
|
+
const timeoutMs = args.timeoutMs;
|
|
100
|
+
if (typeof timeoutMs === "number" && Number.isFinite(timeoutMs) && timeoutMs >= 0)
|
|
101
|
+
command.push("--timeout-ms", String(timeoutMs));
|
|
102
|
+
if (booleanArg(args, "redactPaths"))
|
|
103
|
+
command.push("--redact-paths");
|
|
104
|
+
return command;
|
|
105
|
+
}
|
|
106
|
+
case "diffci_verify_changed": {
|
|
107
|
+
const command = ["verify", "--changed", "--json"];
|
|
108
|
+
if (repo)
|
|
109
|
+
command.push("--repo", resolve(repo));
|
|
110
|
+
const timeoutMs = args.timeoutMs;
|
|
111
|
+
if (typeof timeoutMs === "number" && Number.isFinite(timeoutMs) && timeoutMs >= 0)
|
|
112
|
+
command.push("--timeout-ms", String(timeoutMs));
|
|
113
|
+
if (booleanArg(args, "redactPaths"))
|
|
114
|
+
command.push("--redact-paths");
|
|
115
|
+
return command;
|
|
116
|
+
}
|
|
61
117
|
case "diffci_check": {
|
|
62
118
|
const command = ["check"];
|
|
63
119
|
if (repo)
|
|
@@ -81,6 +137,8 @@ function commandForTool(name, args) {
|
|
|
81
137
|
command.push("--repo", resolve(repo));
|
|
82
138
|
if (booleanArg(args, "workflow"))
|
|
83
139
|
command.push("--workflow");
|
|
140
|
+
if (booleanArg(args, "verificationWorkflow"))
|
|
141
|
+
command.push("--verification-workflow");
|
|
84
142
|
if (booleanArg(args, "force"))
|
|
85
143
|
command.push("--force");
|
|
86
144
|
return command;
|
|
@@ -152,9 +210,17 @@ async function handle(request) {
|
|
|
152
210
|
run.stderr.trim() ? `stderr:\n${run.stderr.trim()}` : "",
|
|
153
211
|
`exitCode: ${run.exitCode}`,
|
|
154
212
|
].filter(Boolean).join("\n\n");
|
|
213
|
+
let structuredContent;
|
|
214
|
+
if ((params.name === "diffci_verify" || params.name === "diffci_verify_changed") && run.stdout.trim()) {
|
|
215
|
+
try {
|
|
216
|
+
structuredContent = JSON.parse(run.stdout);
|
|
217
|
+
}
|
|
218
|
+
catch { /* The text and non-zero status still carry the failure. */ }
|
|
219
|
+
}
|
|
155
220
|
success(id, {
|
|
156
221
|
content: [{ type: "text", text }],
|
|
157
222
|
isError: run.exitCode !== 0,
|
|
223
|
+
structuredContent,
|
|
158
224
|
});
|
|
159
225
|
return;
|
|
160
226
|
}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { mkdtempSync, rmSync } from "node:fs";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { join, resolve } from "node:path";
|
|
4
|
+
import { inferFullCommand, inferSelectedCommand } from "./full-command.js";
|
|
5
|
+
import { observe } from "./observe.js";
|
|
6
|
+
import { measureCommand } from "./verify-savings.js";
|
|
7
|
+
import { captureWorkingTreeSnapshot } from "./working-tree.js";
|
|
8
|
+
export const VERIFICATION_SCHEMA = "diffci.verification.v1";
|
|
9
|
+
function receiptRange(range) {
|
|
10
|
+
if (!range)
|
|
11
|
+
return undefined;
|
|
12
|
+
return {
|
|
13
|
+
base_sha: range.baseSha,
|
|
14
|
+
head_sha: range.headSha,
|
|
15
|
+
source: range.source,
|
|
16
|
+
merge_base_sha: range.mergeBaseSha,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function baseReport(snapshot, scope, range) {
|
|
20
|
+
return {
|
|
21
|
+
schema: VERIFICATION_SCHEMA,
|
|
22
|
+
schema_version: "1",
|
|
23
|
+
produced_at: new Date().toISOString(),
|
|
24
|
+
scope,
|
|
25
|
+
commit_range: receiptRange(range),
|
|
26
|
+
snapshot: {
|
|
27
|
+
base_sha: snapshot.baseSha,
|
|
28
|
+
before_tree_sha: snapshot.treeSha,
|
|
29
|
+
unchanged: false,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function blocked(snapshot, scope, reason, analysis, counts = {}, range) {
|
|
34
|
+
return {
|
|
35
|
+
...baseReport(snapshot, scope, range),
|
|
36
|
+
verification: "blocked",
|
|
37
|
+
safe_to_continue: false,
|
|
38
|
+
reason,
|
|
39
|
+
changed_files: counts.changedFiles ?? 0,
|
|
40
|
+
tests_available: counts.testsAvailable ?? 0,
|
|
41
|
+
tests_selected: counts.testsSelected ?? 0,
|
|
42
|
+
selection: "none",
|
|
43
|
+
analysis,
|
|
44
|
+
required_actions: [reason],
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function unknownSnapshot() {
|
|
48
|
+
return { baseSha: "unknown", treeSha: "unknown", commitSha: "unknown", changed: true };
|
|
49
|
+
}
|
|
50
|
+
async function executeObservation(options, scope, before, observation) {
|
|
51
|
+
const result = observation.result;
|
|
52
|
+
const range = observation.commitRange;
|
|
53
|
+
const boundRange = scope === "commit-range" ? range : undefined;
|
|
54
|
+
const counts = {
|
|
55
|
+
changedFiles: result?.changedFileCount ?? 0,
|
|
56
|
+
testsAvailable: result?.totalTestCount ?? 0,
|
|
57
|
+
testsSelected: result?.selectedTests.length ?? 0,
|
|
58
|
+
};
|
|
59
|
+
const analysis = {
|
|
60
|
+
status: observation.status,
|
|
61
|
+
stage: observation.stage,
|
|
62
|
+
mode: result?.mode,
|
|
63
|
+
fallback_reasons: result?.fallbackReasons ?? [],
|
|
64
|
+
error: observation.reason,
|
|
65
|
+
};
|
|
66
|
+
if (observation.status !== "OBSERVED" || !result) {
|
|
67
|
+
return blocked(before, scope, observation.reason ?? "DiffCI analysis did not produce a verification plan", analysis, counts, boundRange);
|
|
68
|
+
}
|
|
69
|
+
if (scope === "commit-range") {
|
|
70
|
+
if (!range)
|
|
71
|
+
return blocked(before, scope, "DiffCI did not resolve a commit range", analysis, counts);
|
|
72
|
+
if (range.headSha !== before.baseSha) {
|
|
73
|
+
return blocked(before, scope, `the analyzed head ${range.headSha} is not the checked-out HEAD ${before.baseSha}`, analysis, counts, range);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
let afterAnalysis;
|
|
77
|
+
try {
|
|
78
|
+
afterAnalysis = captureWorkingTreeSnapshot(options.repoPath);
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
82
|
+
return blocked(before, scope, `could not confirm the post-analysis snapshot: ${message}`, analysis, counts, boundRange);
|
|
83
|
+
}
|
|
84
|
+
if (!observation.nonInterference.worktreeUnchanged || before.baseSha !== afterAnalysis.baseSha || before.treeSha !== afterAnalysis.treeSha) {
|
|
85
|
+
const report = blocked(before, scope, "the working tree changed during DiffCI analysis", analysis, counts, boundRange);
|
|
86
|
+
report.snapshot.after_base_sha = afterAnalysis.baseSha;
|
|
87
|
+
report.snapshot.after_tree_sha = afterAnalysis.treeSha;
|
|
88
|
+
return report;
|
|
89
|
+
}
|
|
90
|
+
let selection;
|
|
91
|
+
let command;
|
|
92
|
+
let reason;
|
|
93
|
+
if (result.mode === "SELECTIVE" && !result.commandRefusalReason && result.proposedCommands.length === 1) {
|
|
94
|
+
const selected = inferSelectedCommand(options.repoPath, result.proposedCommands[0], result.selectedTests);
|
|
95
|
+
if (selected.command) {
|
|
96
|
+
selection = "selected";
|
|
97
|
+
command = selected.command;
|
|
98
|
+
reason = "dependency impact";
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
selection = "full";
|
|
102
|
+
const full = inferFullCommand(options.repoPath);
|
|
103
|
+
command = full.command;
|
|
104
|
+
reason = `selected verification was not executable (${selected.reason}); broadened to full verification`;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
selection = "full";
|
|
109
|
+
const full = inferFullCommand(options.repoPath);
|
|
110
|
+
command = full.command;
|
|
111
|
+
const fallback = result.fallbackReasons[0] ?? result.commandRefusalReason;
|
|
112
|
+
reason = fallback ? `full verification required: ${fallback}` : "full verification required";
|
|
113
|
+
}
|
|
114
|
+
if (!command) {
|
|
115
|
+
const inferred = inferFullCommand(options.repoPath);
|
|
116
|
+
return blocked(before, scope, `no executable verification command is available: ${inferred.reason}`, analysis, counts, boundRange);
|
|
117
|
+
}
|
|
118
|
+
const execution = measureCommand(command, { cwd: options.repoPath, timeoutMs: options.timeoutMs, tailBytes: options.tailBytes });
|
|
119
|
+
let after;
|
|
120
|
+
try {
|
|
121
|
+
after = captureWorkingTreeSnapshot(options.repoPath);
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
125
|
+
return {
|
|
126
|
+
...blocked(before, scope, `could not confirm the post-verification snapshot: ${message}`, analysis, counts, boundRange),
|
|
127
|
+
selection,
|
|
128
|
+
command,
|
|
129
|
+
execution,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
const unchanged = before.baseSha === after.baseSha && before.treeSha === after.treeSha;
|
|
133
|
+
const succeeded = execution.exitCode === 0 && !execution.timedOut;
|
|
134
|
+
const verification = !unchanged ? "blocked" : succeeded ? "passed" : "failed";
|
|
135
|
+
const finalReason = !unchanged
|
|
136
|
+
? "the working tree changed while verification was running; rerun DiffCI for the new snapshot"
|
|
137
|
+
: succeeded
|
|
138
|
+
? reason
|
|
139
|
+
: execution.timedOut
|
|
140
|
+
? `verification timed out after ${options.timeoutMs}ms`
|
|
141
|
+
: `verification command failed with exit code ${String(execution.exitCode)}`;
|
|
142
|
+
return {
|
|
143
|
+
...baseReport(before, scope, boundRange),
|
|
144
|
+
verification,
|
|
145
|
+
safe_to_continue: verification === "passed",
|
|
146
|
+
reason: finalReason,
|
|
147
|
+
changed_files: counts.changedFiles,
|
|
148
|
+
tests_available: counts.testsAvailable,
|
|
149
|
+
tests_selected: selection === "full" ? counts.testsAvailable : counts.testsSelected,
|
|
150
|
+
selection,
|
|
151
|
+
command,
|
|
152
|
+
execution,
|
|
153
|
+
snapshot: {
|
|
154
|
+
...baseReport(before, scope, boundRange).snapshot,
|
|
155
|
+
after_base_sha: after.baseSha,
|
|
156
|
+
after_tree_sha: after.treeSha,
|
|
157
|
+
unchanged,
|
|
158
|
+
},
|
|
159
|
+
analysis,
|
|
160
|
+
required_actions: verification === "passed" ? [] : [finalReason],
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/** Verify exactly the staged, unstaged, and non-ignored untracked content currently on disk. */
|
|
164
|
+
export async function verifyChanged(options) {
|
|
165
|
+
const repoPath = resolve(options.repoPath);
|
|
166
|
+
let before;
|
|
167
|
+
try {
|
|
168
|
+
before = captureWorkingTreeSnapshot(repoPath);
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
172
|
+
return blocked(unknownSnapshot(), "working-tree", message, { status: "ERROR", stage: "context", fallback_reasons: [], error: message });
|
|
173
|
+
}
|
|
174
|
+
if (!before.changed) {
|
|
175
|
+
return {
|
|
176
|
+
...baseReport(before, "working-tree"),
|
|
177
|
+
verification: "passed",
|
|
178
|
+
safe_to_continue: true,
|
|
179
|
+
reason: "no staged, unstaged, or non-ignored untracked changes",
|
|
180
|
+
changed_files: 0,
|
|
181
|
+
tests_available: 0,
|
|
182
|
+
tests_selected: 0,
|
|
183
|
+
selection: "none",
|
|
184
|
+
snapshot: {
|
|
185
|
+
...baseReport(before, "working-tree").snapshot,
|
|
186
|
+
after_base_sha: before.baseSha,
|
|
187
|
+
after_tree_sha: before.treeSha,
|
|
188
|
+
unchanged: true,
|
|
189
|
+
},
|
|
190
|
+
analysis: { status: "not_needed", fallback_reasons: [] },
|
|
191
|
+
required_actions: [],
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
const temporaryDirectory = mkdtempSync(join(tmpdir(), "diffci-verify-"));
|
|
195
|
+
try {
|
|
196
|
+
const observation = await observe({
|
|
197
|
+
repoPath,
|
|
198
|
+
env: options.env,
|
|
199
|
+
version: options.version,
|
|
200
|
+
engineSha: options.engineSha,
|
|
201
|
+
baseOverride: before.baseSha,
|
|
202
|
+
headOverride: before.commitSha,
|
|
203
|
+
redactPaths: options.redactPaths,
|
|
204
|
+
reportPath: join(temporaryDirectory, "observation.json"),
|
|
205
|
+
});
|
|
206
|
+
return await executeObservation({ ...options, repoPath }, "working-tree", before, observation);
|
|
207
|
+
}
|
|
208
|
+
finally {
|
|
209
|
+
rmSync(temporaryDirectory, { recursive: true, force: true });
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/** Verify a real commit range and bind the receipt to the clean commit that was actually executed. */
|
|
213
|
+
export async function verifyRange(options) {
|
|
214
|
+
const repoPath = resolve(options.repoPath);
|
|
215
|
+
let before;
|
|
216
|
+
try {
|
|
217
|
+
before = captureWorkingTreeSnapshot(repoPath);
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
221
|
+
return blocked(unknownSnapshot(), "commit-range", message, { status: "ERROR", stage: "context", fallback_reasons: [], error: message });
|
|
222
|
+
}
|
|
223
|
+
if (before.changed) {
|
|
224
|
+
return blocked(before, "commit-range", "commit-range verification requires a clean checkout; use verify --changed for uncommitted changes", { status: "not_needed", fallback_reasons: [] });
|
|
225
|
+
}
|
|
226
|
+
const temporaryDirectory = mkdtempSync(join(tmpdir(), "diffci-verify-"));
|
|
227
|
+
try {
|
|
228
|
+
const observation = await observe({
|
|
229
|
+
repoPath,
|
|
230
|
+
env: options.env,
|
|
231
|
+
version: options.version,
|
|
232
|
+
engineSha: options.engineSha,
|
|
233
|
+
baseOverride: options.baseOverride,
|
|
234
|
+
headOverride: options.headOverride,
|
|
235
|
+
redactPaths: options.redactPaths,
|
|
236
|
+
reportPath: join(temporaryDirectory, "observation.json"),
|
|
237
|
+
});
|
|
238
|
+
return await executeObservation({ ...options, repoPath }, "commit-range", before, observation);
|
|
239
|
+
}
|
|
240
|
+
finally {
|
|
241
|
+
rmSync(temporaryDirectory, { recursive: true, force: true });
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
export function verificationExitCode(report) {
|
|
245
|
+
if (report.verification === "passed")
|
|
246
|
+
return 0;
|
|
247
|
+
if (report.verification === "failed")
|
|
248
|
+
return 1;
|
|
249
|
+
return 2;
|
|
250
|
+
}
|
|
251
|
+
export function formatVerificationSummary(report) {
|
|
252
|
+
const lines = [
|
|
253
|
+
`DiffCI verification: ${report.verification.toUpperCase()}`,
|
|
254
|
+
` scope: ${report.scope}`,
|
|
255
|
+
` changed files: ${report.changed_files}`,
|
|
256
|
+
` verification: ${report.selection} (${report.tests_selected}/${report.tests_available} test files)`,
|
|
257
|
+
` reason: ${report.reason}`,
|
|
258
|
+
` snapshot: ${report.snapshot.before_tree_sha.slice(0, 12)} (${report.snapshot.unchanged ? "unchanged" : "not confirmed"})`,
|
|
259
|
+
];
|
|
260
|
+
if (report.commit_range)
|
|
261
|
+
lines.splice(2, 0, ` range: ${report.commit_range.base_sha.slice(0, 12)}..${report.commit_range.head_sha.slice(0, 12)}`);
|
|
262
|
+
if (report.command)
|
|
263
|
+
lines.push(` command: ${report.command}`);
|
|
264
|
+
return lines.join("\n");
|
|
265
|
+
}
|
|
@@ -88,6 +88,12 @@ function listWorkflowFiles(repoPath) {
|
|
|
88
88
|
function runReferencesDiffCi(run, actionPattern) {
|
|
89
89
|
return actionPattern.test(commandText(run));
|
|
90
90
|
}
|
|
91
|
+
/** A fail-closed `verify` job is intentionally allowed to affect its own check conclusion. */
|
|
92
|
+
function runInvokesDiffCiVerification(run) {
|
|
93
|
+
const command = commandText(run);
|
|
94
|
+
return /\bdiffci:verify\b/i.test(command) ||
|
|
95
|
+
/\b(?:diffci(?:\.com\/diffci)?(?:@[^\s"']+)?|cli\.(?:js|ts))["']?\s+verify(?=\s|$)/i.test(command);
|
|
96
|
+
}
|
|
91
97
|
/**
|
|
92
98
|
* The part of a `run:` script that can invoke something: shell comments and URLs are removed line by
|
|
93
99
|
* line before matching. A URL is data handed to a command, not a command - DiffCI's own deploy
|
|
@@ -180,7 +186,10 @@ export function auditWorkflows(repoPath, options = {}) {
|
|
|
180
186
|
const steps = asArray(rawJob.steps).filter(isRecord);
|
|
181
187
|
const isDiffCiStep = (step) => (typeof step.uses === "string" && referencesDiffCi(step.uses, repoPath, actionPattern)) ||
|
|
182
188
|
(typeof step.run === "string" && runReferencesDiffCi(step.run, actionPattern));
|
|
183
|
-
const
|
|
189
|
+
const isVerificationStep = (step) => typeof step.run === "string" && runInvokesDiffCiVerification(step.run);
|
|
190
|
+
// This guard proves that observation jobs are inert. A dedicated fail-closed verification job
|
|
191
|
+
// is a different product surface: making its own status check fail is its intended contract.
|
|
192
|
+
const diffciSteps = steps.filter((step) => isDiffCiStep(step) && !isVerificationStep(step));
|
|
184
193
|
if (diffciSteps.length === 0)
|
|
185
194
|
continue;
|
|
186
195
|
observerJobs.push(`${relativePath}#${jobId}`);
|
|
@@ -213,7 +222,7 @@ export function auditWorkflows(repoPath, options = {}) {
|
|
|
213
222
|
// DiffCI became a package rather than an Action it invokes itself with `run:`, and the rule
|
|
214
223
|
// below - "any run: step is real work" - was written when that could not happen. Leaving the
|
|
215
224
|
// order the other way round made the product's own generated workflow fail its own guard.
|
|
216
|
-
if (isDiffCiStep(step))
|
|
225
|
+
if (isDiffCiStep(step) && !isVerificationStep(step))
|
|
217
226
|
return false;
|
|
218
227
|
// Any other shell step in this job IS real work, and DiffCI must not share a job with it.
|
|
219
228
|
if (typeof step.run === "string")
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { mkdtempSync, rmSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join, resolve } from "node:path";
|
|
5
|
+
function runGit(repoPath, args, env, input) {
|
|
6
|
+
const result = spawnSync("git", args, {
|
|
7
|
+
cwd: repoPath,
|
|
8
|
+
env: env ? { ...process.env, ...env } : process.env,
|
|
9
|
+
input,
|
|
10
|
+
encoding: "utf8",
|
|
11
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
12
|
+
windowsHide: true,
|
|
13
|
+
});
|
|
14
|
+
return {
|
|
15
|
+
status: result.status,
|
|
16
|
+
stdout: result.stdout ?? "",
|
|
17
|
+
stderr: result.stderr ?? "",
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function requireGit(repoPath, args, context, env, input) {
|
|
21
|
+
const result = runGit(repoPath, args, env, input);
|
|
22
|
+
if (result.status !== 0) {
|
|
23
|
+
const detail = result.stderr.trim() || result.stdout.trim() || `git exited with status ${String(result.status)}`;
|
|
24
|
+
throw new Error(`${context}: ${detail.split("\n")[0]}`);
|
|
25
|
+
}
|
|
26
|
+
return result.stdout.trim();
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Materialize the current worktree as a Git tree without changing the user's index or checkout.
|
|
30
|
+
*
|
|
31
|
+
* A temporary index begins at HEAD and stages the working tree into that isolated index. Git therefore
|
|
32
|
+
* applies the repository's normal ignore rules, executable-bit handling, symlink handling, and clean
|
|
33
|
+
* filters, while the real index and every source file stay untouched. The resulting tree SHA is a
|
|
34
|
+
* content-addressed verification identity. The synthetic commit is intentionally unreachable and is
|
|
35
|
+
* used only by DiffCI's existing commit-to-commit analyzer.
|
|
36
|
+
*/
|
|
37
|
+
export function captureWorkingTreeSnapshot(repoPathInput) {
|
|
38
|
+
const repoPath = resolve(repoPathInput);
|
|
39
|
+
const baseSha = requireGit(repoPath, ["rev-parse", "--verify", "HEAD^{commit}"], "could not resolve repository HEAD");
|
|
40
|
+
const baseTreeSha = requireGit(repoPath, ["rev-parse", "--verify", "HEAD^{tree}"], "could not resolve repository HEAD tree");
|
|
41
|
+
const unmerged = requireGit(repoPath, ["ls-files", "--unmerged"], "could not inspect the repository index");
|
|
42
|
+
if (unmerged !== "")
|
|
43
|
+
throw new Error("the repository index contains unresolved merge entries");
|
|
44
|
+
const temporaryDirectory = mkdtempSync(join(tmpdir(), "diffci-working-tree-"));
|
|
45
|
+
const temporaryIndex = join(temporaryDirectory, "index");
|
|
46
|
+
const indexEnvironment = { GIT_INDEX_FILE: temporaryIndex };
|
|
47
|
+
try {
|
|
48
|
+
requireGit(repoPath, ["read-tree", baseSha], "could not initialize the verification snapshot", indexEnvironment);
|
|
49
|
+
requireGit(repoPath, ["add", "-A", "--", "."], "could not capture the working tree", indexEnvironment);
|
|
50
|
+
const treeSha = requireGit(repoPath, ["write-tree"], "could not write the verification tree", indexEnvironment);
|
|
51
|
+
const identityEnvironment = {
|
|
52
|
+
GIT_AUTHOR_NAME: "DiffCI",
|
|
53
|
+
GIT_AUTHOR_EMAIL: "snapshot@diffci.local",
|
|
54
|
+
GIT_COMMITTER_NAME: "DiffCI",
|
|
55
|
+
GIT_COMMITTER_EMAIL: "snapshot@diffci.local",
|
|
56
|
+
GIT_AUTHOR_DATE: "2000-01-01T00:00:00Z",
|
|
57
|
+
GIT_COMMITTER_DATE: "2000-01-01T00:00:00Z",
|
|
58
|
+
};
|
|
59
|
+
const commitSha = requireGit(repoPath, ["commit-tree", treeSha, "-p", baseSha], "could not create the verification snapshot", identityEnvironment, "DiffCI working tree snapshot\n");
|
|
60
|
+
return { baseSha, treeSha, commitSha, changed: treeSha !== baseTreeSha };
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
rmSync(temporaryDirectory, { recursive: true, force: true });
|
|
64
|
+
}
|
|
65
|
+
}
|
package/docs/adoption-metrics.md
CHANGED
|
@@ -97,7 +97,7 @@ They are supporting signals only.
|
|
|
97
97
|
|
|
98
98
|
| Signal | Value | Interpretation |
|
|
99
99
|
| --- | ---: | --- |
|
|
100
|
-
| npm latest version | `0.
|
|
100
|
+
| npm latest version | `0.3.0-rc.1` | Current CLI and MCP binaries are publicly available. |
|
|
101
101
|
| npm downloads, last complete registry week (`2026-09-15`–`2026-09-21`) | 1,929 | Distribution activity; not unique users or repositories. |
|
|
102
102
|
| GitHub stars / forks / watchers | 0 / 0 / 0 | No repository-level community conversion yet. |
|
|
103
103
|
| GitHub views, available 14-day window | 18 views / 4 unique visitors | Early discovery signal. |
|
|
@@ -6,12 +6,26 @@ Copy only the integration your repository needs. DiffCI does not replace require
|
|
|
6
6
|
|
|
7
7
|
Add this to `AGENTS.md` or the equivalent agent instruction file:
|
|
8
8
|
|
|
9
|
-
> Before calling a change PR-ready, run `npx "@diffci.com/diffci@latest"
|
|
10
|
-
> root.
|
|
11
|
-
> required CI authoritative. If DiffCI
|
|
9
|
+
> Before calling a change PR-ready, run `npx "@diffci.com/diffci@latest" verify --changed --json`
|
|
10
|
+
> from the repository root. Continue only when the receipt says `safe_to_continue: true`. Keep the
|
|
11
|
+
> repository's required CI authoritative. If DiffCI refuses, errors, fails, or cannot prove a safe
|
|
12
|
+
> selection, run the normal tests and do not treat the change as verified.
|
|
12
13
|
|
|
13
|
-
`
|
|
14
|
-
files.
|
|
14
|
+
`verify --changed` may execute the repository's selected or full test command, which may write
|
|
15
|
+
generated files. DiffCI fails if the content-addressed snapshot changes while verification runs. For
|
|
16
|
+
paired runtime measurement use `check`; for analysis without tests use `observe --no-send`.
|
|
17
|
+
|
|
18
|
+
## Blocking GitHub verification
|
|
19
|
+
|
|
20
|
+
Generate the workflow instead of copying a version-sensitive package command:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npx "@diffci.com/diffci@latest" init --verification-workflow
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The generated **DiffCI verification** job verifies the pull-request or push range, has no
|
|
27
|
+
`continue-on-error`, and uploads its receipt. After a successful pilot, make that job a required
|
|
28
|
+
branch-protection check.
|
|
15
29
|
|
|
16
30
|
## GitHub Action
|
|
17
31
|
|
|
@@ -30,7 +44,7 @@ jobs:
|
|
|
30
44
|
- uses: actions/checkout@v4
|
|
31
45
|
with:
|
|
32
46
|
fetch-depth: 0
|
|
33
|
-
- uses: DiffCI/DiffCI.com@2f72b7fc017cc987fb0fd80c7e2351f33240e7d4 # v0.
|
|
47
|
+
- uses: DiffCI/DiffCI.com@2f72b7fc017cc987fb0fd80c7e2351f33240e7d4 # v0.3.0-rc.1
|
|
34
48
|
```
|
|
35
49
|
|
|
36
50
|
Run `npx "@diffci.com/diffci@latest" verify-workflow` before starting a pilot. The Action uploads a
|
|
@@ -60,9 +74,9 @@ Suggested title: **Add optional DiffCI validation for coding agents**
|
|
|
60
74
|
|
|
61
75
|
Suggested description:
|
|
62
76
|
|
|
63
|
-
> This adds
|
|
64
|
-
>
|
|
65
|
-
>
|
|
77
|
+
> This adds a persistent DiffCI agent instruction and optionally a blocking verification job. DiffCI
|
|
78
|
+
> runs the minimum test command it can justify, falls back to full verification on uncertainty, and
|
|
79
|
+
> emits a machine-readable receipt. Required CI continues to run as before.
|
|
66
80
|
|
|
67
81
|
## Where to point maintainers
|
|
68
82
|
|
|
@@ -76,7 +90,7 @@ If a maintainer is evaluating DiffCI for the first time, ask for one local run b
|
|
|
76
90
|
workflow change:
|
|
77
91
|
|
|
78
92
|
```bash
|
|
79
|
-
npx "@diffci.com/diffci@latest"
|
|
93
|
+
npx "@diffci.com/diffci@latest" verify --changed --json
|
|
80
94
|
```
|
|
81
95
|
|
|
82
96
|
Then use the first-report issue template to capture the result, fallback/refusal reasons, CI shape,
|
package/docs/ai-agents.md
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
# DiffCI for AI Coding Agents
|
|
2
2
|
|
|
3
|
-
DiffCI is
|
|
4
|
-
|
|
3
|
+
DiffCI is a fail-closed verification layer agents run before proposing, committing, or opening a pull
|
|
4
|
+
request. It chooses the narrowest verification it can justify and broadens to the full inferred test
|
|
5
|
+
command when the evidence is incomplete.
|
|
5
6
|
|
|
6
7
|
The default command is:
|
|
7
8
|
|
|
8
9
|
```bash
|
|
9
|
-
npx "@diffci.com/diffci@latest"
|
|
10
|
+
npx "@diffci.com/diffci@latest" verify --changed --json
|
|
10
11
|
```
|
|
11
12
|
|
|
12
|
-
`
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
`verify --changed` snapshots staged, unstaged, and non-ignored untracked content, runs the selected
|
|
14
|
+
command or a conservative full fallback, and fails unless that exact snapshot passes and remains
|
|
15
|
+
unchanged. Its JSON receipt is designed for agents. Use `check` for paired full-versus-selected
|
|
16
|
+
measurement and `observe --no-send` for analysis without test execution.
|
|
15
17
|
|
|
16
18
|
## Install Agent Instructions
|
|
17
19
|
|
|
@@ -29,7 +31,8 @@ This writes:
|
|
|
29
31
|
- `.github/copilot-instructions.md`
|
|
30
32
|
- `diffci.config.json`
|
|
31
33
|
|
|
32
|
-
Existing files are
|
|
34
|
+
Existing instruction files are extended with a managed DiffCI rule when possible; unrelated content
|
|
35
|
+
is preserved. Pass `--force` only when you intentionally want to replace DiffCI-managed output.
|
|
33
36
|
|
|
34
37
|
To also add a non-blocking GitHub Actions observer job:
|
|
35
38
|
|
|
@@ -43,6 +46,15 @@ Then verify the workflow:
|
|
|
43
46
|
npx "@diffci.com/diffci@latest" verify-workflow
|
|
44
47
|
```
|
|
45
48
|
|
|
49
|
+
To add a blocking, commit-range verification check instead:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npx "@diffci.com/diffci@latest" init --verification-workflow
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The generated check uploads a receipt and intentionally does not use `continue-on-error`. Make its
|
|
56
|
+
**DiffCI verification** job required only after it has passed in the repository's normal CI context.
|
|
57
|
+
|
|
46
58
|
## Copy-Paste Adoption
|
|
47
59
|
|
|
48
60
|
For a maintainer-facing snippet, PR template, and GitHub search queries for repositories that already
|
|
@@ -89,9 +101,11 @@ Minimal MCP config:
|
|
|
89
101
|
|
|
90
102
|
Agents should:
|
|
91
103
|
|
|
92
|
-
- run `diffci
|
|
93
|
-
-
|
|
94
|
-
-
|
|
104
|
+
- run `diffci verify --changed --json` before PR-ready answers for local edits;
|
|
105
|
+
- run `diffci verify --json` for a clean CI commit range;
|
|
106
|
+
- call `diffci_verify_changed` locally or `diffci_verify` in CI when connected through MCP;
|
|
107
|
+
- require `safe_to_continue: true` and read the receipt's verification, selected tests, fallback
|
|
108
|
+
reasons, command result, and snapshot identities;
|
|
95
109
|
- use DiffCI output to choose focused follow-up validation;
|
|
96
110
|
- keep the repository's required CI commands authoritative.
|
|
97
111
|
|
|
@@ -99,6 +113,7 @@ Agents should not:
|
|
|
99
113
|
|
|
100
114
|
- skip required CI because DiffCI selected fewer tests;
|
|
101
115
|
- treat `REFUSED` or `ERROR` as a passing validation;
|
|
116
|
+
- continue after a receipt says `safe_to_continue: false`;
|
|
102
117
|
- configure hosted report sending unless the user explicitly supplies an endpoint and token.
|
|
103
118
|
|
|
104
119
|
## Open Core Boundary
|
package/docs/distribution.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# DiffCI Distribution
|
|
2
2
|
|
|
3
|
-
DiffCI has
|
|
4
|
-
|
|
3
|
+
DiffCI has complementary install surfaces: a fail-closed agent verifier, a blocking CI verification
|
|
4
|
+
workflow, and an observation-only Action for measuring opportunities without changing required CI.
|
|
5
5
|
|
|
6
6
|
The product model is open core. The npm CLI and basic GitHub Action are the open-source adoption path;
|
|
7
7
|
DiffCI Cloud adds hosted history, organization dashboards, policies, managed operations, and support.
|
|
@@ -13,8 +13,9 @@ Reviewed 2026-09-22. These channels have different jobs in the same adoption pat
|
|
|
13
13
|
|
|
14
14
|
| Channel | Role for DiffCI | Next step |
|
|
15
15
|
| --- | --- | --- |
|
|
16
|
-
| npm |
|
|
17
|
-
| GitHub
|
|
16
|
+
| npm | Agent-native local and CI verification through `@diffci.com/diffci` | Lead with `verify --changed --json` and its content-bound receipt. |
|
|
17
|
+
| GitHub workflow | Repeatable blocking verification | Generate it with `init --verification-workflow`, pilot it, then make the job required. |
|
|
18
|
+
| GitHub Action | Observation-only adoption | Use the dedicated, non-blocking job below and verify the workflow before a pilot. |
|
|
18
19
|
| GitHub Marketplace | CI-specific discovery of the same Action | [DiffCI observer is live](https://github.com/marketplace/actions/diffci-observer); keep the installation example and release pin current. |
|
|
19
20
|
| MCP directories | Discovery for agents that install stdio tools | Publish matching npm and registry metadata, then submit to the official MCP Registry and Glama. |
|
|
20
21
|
| Tidelift | Potential package maintenance assurance and maintainer income | Pursue package acceptance using the existing submission packet; do not present support as active. |
|
|
@@ -71,7 +72,7 @@ jobs:
|
|
|
71
72
|
- uses: DiffCI/DiffCI.com@2f72b7fc017cc987fb0fd80c7e2351f33240e7d4
|
|
72
73
|
```
|
|
73
74
|
|
|
74
|
-
The example pins release `v0.
|
|
75
|
+
The example pins release `v0.3.0-rc.1` to its qualified feature commit SHA. `npx "@diffci.com/diffci@latest" verify-workflow`
|
|
75
76
|
checks that the job is dedicated, read-only, not required by other jobs, and unable to alter the rest
|
|
76
77
|
of CI.
|
|
77
78
|
|
|
@@ -80,10 +81,16 @@ of CI.
|
|
|
80
81
|
The CLI is the standalone npm package surface. The package name is `@diffci.com/diffci`:
|
|
81
82
|
|
|
82
83
|
```bash
|
|
84
|
+
npx "@diffci.com/diffci@latest" verify --changed --json
|
|
85
|
+
npx "@diffci.com/diffci@latest" verify --json
|
|
83
86
|
npx "@diffci.com/diffci@latest" observe
|
|
84
87
|
npx "@diffci.com/diffci@latest" verify-workflow
|
|
85
88
|
```
|
|
86
89
|
|
|
90
|
+
`verify --changed` covers staged, unstaged, and non-ignored untracked changes. `verify --json` covers
|
|
91
|
+
a clean CI commit range. Both execute the narrowest safe command, broaden to the full inferred test
|
|
92
|
+
command on uncertainty, fail closed, and emit a `diffci.verification.v1` receipt.
|
|
93
|
+
|
|
87
94
|
`observe` writes a JSON report outside the checkout by default. It never runs, skips, cancels, or
|
|
88
95
|
reorders tests. A hosted endpoint is opt-in: reports are sent only when both `DIFFCI_API_URL` and
|
|
89
96
|
`DIFFCI_TOKEN` are set, or when equivalent CLI flags are passed.
|
package/docs/mcp.md
CHANGED
|
@@ -61,16 +61,24 @@ On Windows, keep the same command shape and use a Windows path:
|
|
|
61
61
|
```
|
|
62
62
|
|
|
63
63
|
For Claude Desktop, Claude Code, Cursor, Codex-style MCP clients, and other stdio-compatible agents,
|
|
64
|
-
name the server `diffci` and call
|
|
64
|
+
name the server `diffci` and call the verification tool that matches the change scope before PR-ready
|
|
65
|
+
answers.
|
|
65
66
|
|
|
66
67
|
Available tools:
|
|
67
68
|
|
|
69
|
+
- `diffci_verify_changed` - verifies staged, unstaged, and non-ignored untracked changes and returns a
|
|
70
|
+
machine-readable, content-bound receipt.
|
|
71
|
+
- `diffci_verify` - verifies a clean commit range, resolving the CI range automatically or accepting
|
|
72
|
+
explicit base and head revisions.
|
|
68
73
|
- `diffci_check` - runs `diffci check`, including inferred full and selected test commands.
|
|
69
74
|
- `diffci_init` - runs `diffci init` to seed agent instruction files.
|
|
70
75
|
- `diffci_verify_workflow` - runs `diffci verify-workflow` to check non-interference.
|
|
71
76
|
|
|
72
|
-
The
|
|
73
|
-
|
|
77
|
+
The verification tools return the same `diffci.verification.v1` receipt as the CLI, including
|
|
78
|
+
`verification`, `safe_to_continue`, change and selection counts, fallback reasoning, the executed
|
|
79
|
+
command result, and checkout identities. The stdio MCP server delegates to the same open-source CLI
|
|
80
|
+
and sends nothing to DiffCI Cloud. Verification runs repository test commands; use the CLI's
|
|
81
|
+
`observe --no-send` for analysis only.
|
|
74
82
|
|
|
75
83
|
Keep required project CI authoritative. DiffCI output is a validation lens, not permission to skip
|
|
76
84
|
required checks.
|
|
@@ -88,5 +96,5 @@ Discovery links:
|
|
|
88
96
|
|
|
89
97
|
Short description:
|
|
90
98
|
|
|
91
|
-
>
|
|
92
|
-
> full
|
|
99
|
+
> Fail-closed, change-aware verification for AI coding agents. DiffCI selects the minimum justified
|
|
100
|
+
> test command, broadens to full verification on uncertainty, and returns a machine-readable receipt.
|
package/glama.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "DiffCI",
|
|
3
|
-
"description": "
|
|
3
|
+
"description": "Fail-closed verification, affected-test selection, and workflow safety for AI coding agents.",
|
|
4
4
|
"category": "developer-tools",
|
|
5
5
|
"homepage": "https://diffci.com/mcp-server",
|
|
6
6
|
"repository": "https://github.com/DiffCI/DiffCI.com",
|
package/llms.txt
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# DiffCI
|
|
2
2
|
|
|
3
|
-
DiffCI is
|
|
3
|
+
DiffCI is a fail-closed, change-aware verification layer for AI coding agents and development teams.
|
|
4
4
|
|
|
5
5
|
Default AI-agent command:
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npx "@diffci.com/diffci@latest"
|
|
8
|
+
npx "@diffci.com/diffci@latest" verify --changed --json
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
Initialization command:
|
|
@@ -16,8 +16,10 @@ npx "@diffci.com/diffci@latest" init
|
|
|
16
16
|
|
|
17
17
|
What agents should know:
|
|
18
18
|
|
|
19
|
-
- `diffci
|
|
20
|
-
- It runs
|
|
19
|
+
- `diffci verify --changed --json` verifies staged, unstaged, and non-ignored untracked changes.
|
|
20
|
+
- It runs the selected test command or conservatively falls back to the full inferred command.
|
|
21
|
+
- Continue only when the `diffci.verification.v1` receipt says `safe_to_continue: true`.
|
|
22
|
+
- `diffci check` remains the paired full-versus-selected measurement command.
|
|
21
23
|
- It sends no report unless `DIFFCI_API_URL` and `DIFFCI_TOKEN` are explicitly configured.
|
|
22
24
|
- Treat selected commands as evidence about the change, not as permission to skip required project CI.
|
|
23
25
|
- If DiffCI reports `REFUSED` or `ERROR`, fall back to the repository's normal validation commands.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diffci.com/diffci",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.3.0-rc.1",
|
|
4
|
+
"description": "Fail-closed, change-aware verification for AI coding agents with conservative affected-test selection",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ci",
|
|
7
7
|
"cicd",
|
package/server.json
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
3
|
"name": "io.github.DiffCI/diffci",
|
|
4
4
|
"title": "DiffCI",
|
|
5
|
-
"description": "
|
|
6
|
-
"version": "0.
|
|
5
|
+
"description": "Fail-closed, change-aware verification for AI coding agents with affected-test guidance.",
|
|
6
|
+
"version": "0.3.0-rc.1",
|
|
7
7
|
"websiteUrl": "https://diffci.com/mcp-server",
|
|
8
8
|
"repository": {
|
|
9
9
|
"url": "https://github.com/DiffCI/DiffCI.com",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
{
|
|
23
23
|
"registryType": "npm",
|
|
24
24
|
"identifier": "@diffci.com/diffci",
|
|
25
|
-
"version": "0.
|
|
25
|
+
"version": "0.3.0-rc.1",
|
|
26
26
|
"transport": {
|
|
27
27
|
"type": "stdio"
|
|
28
28
|
},
|