@diffci.com/diffci 0.1.9 → 0.1.11

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 CHANGED
@@ -12,7 +12,13 @@ the opt-in `pilot` and `verify-savings` commands execute tests.
12
12
  From an existing repository checkout, with Node.js 22.5+ and Git installed:
13
13
 
14
14
  ```bash
15
- npx @diffci.com/diffci@latest observe --no-send
15
+ npx @diffci.com/diffci@latest check
16
+ ```
17
+
18
+ For AI coding agents, seed the repository with default instructions:
19
+
20
+ ```bash
21
+ npx @diffci.com/diffci@latest init
16
22
  ```
17
23
 
18
24
  For the fastest self-serve runtime pilot, run one paired check from the repository root:
@@ -43,6 +49,9 @@ comparison, add `--base <base-sha> --head <head-sha>`. DiffCI prints the selecti
43
49
  and the path to a JSON report outside your checkout. `REFUSED` or `ERROR` is not a successful analysis;
44
50
  check the reported status even when the command exits successfully. See the
45
51
  [support matrix](docs/language-support.md) for setup requirements and supported workloads.
52
+ `check` is an agent-friendly alias for `observe --no-send`: it runs no tests, changes no CI behavior,
53
+ and sends nothing by default. See [`docs/ai-agents.md`](docs/ai-agents.md) for Claude Code, Codex,
54
+ Cursor, GitHub Copilot, and similar tools.
46
55
 
47
56
  **Measured example:** a controlled Cal.com replay showed **44.2% net reduction in a job-equivalent
48
57
  install + pretest + test workload**, including analysis overhead. This is one sandbox comparison,
@@ -91,9 +100,8 @@ DiffCI's hosted service requires an explicitly configured endpoint and token.
91
100
  | Surface | Use it for | Current distribution |
92
101
  | --- | --- | --- |
93
102
  | [`@diffci.com/diffci`](https://www.npmjs.com/package/@diffci.com/diffci) | Try `observe` locally, run an opt-in runtime pilot, or install the GitHub Action from this repository | Published npm CLI and Action |
94
- | [`DiffCI/core`](https://github.com/DiffCI/core) | Study or build on the dependency-analysis and conservative-planning engine | Public AGPL source; included in the CLI package |
95
103
 
96
- The CLI bundles a pinned revision of the Core engine from GitHub. Users install only
104
+ The CLI bundles a pinned revision of the [Core engine](https://github.com/DiffCI/core) from GitHub. Users install only
97
105
  `@diffci.com/diffci`; the `pilot` command above stays the same. Core performs Git analysis,
98
106
  dependency graphs, impact, path baseline, and selected-command planning. The report format and
99
107
  non-interfering GitHub Action remain in this repository. See
@@ -217,6 +225,8 @@ DiffCI is intended to be installable as infrastructure, not only as a hosted sha
217
225
 
218
226
  ```bash
219
227
  npx @diffci.com/diffci@latest observe
228
+ npx @diffci.com/diffci@latest check
229
+ npx @diffci.com/diffci@latest init
220
230
  npx @diffci.com/diffci@latest verify-workflow
221
231
  ```
222
232
 
@@ -13,6 +13,8 @@
13
13
  * the observer is exactly what Phase 02 shipped: a local analysis whose output never leaves the runner.
14
14
  *
15
15
  * Commands:
16
+ * init seed a repository with AI-agent instructions for using DiffCI
17
+ * check agent-friendly alias for observe --no-send
16
18
  * observe analyse the checkout and write an observation report
17
19
  * verify-savings run a paired full-versus-selected timing check
18
20
  * verify-workflow check that a DiffCI job in this repository's workflows cannot affect other jobs
@@ -97,6 +99,106 @@ function defaultReportPath(env) {
97
99
  const stamp = env.GITHUB_RUN_ID ? `${env.GITHUB_RUN_ID}-${env.GITHUB_RUN_ATTEMPT ?? "1"}` : String(Date.now());
98
100
  return join(base, `diffci-observation-${stamp}.json`);
99
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
+
112
+ What this does:
113
+
114
+ - analyzes the current checkout and commit range;
115
+ - writes a JSON report outside the repository by default;
116
+ - prints selected tests, fallback reasons, and proposed commands;
117
+ - sends nothing unless an endpoint and token are explicitly configured;
118
+ - runs, skips, cancels, or reorders no tests.
119
+
120
+ 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.
121
+ `;
122
+ const CURSOR_RULE = `---
123
+ description: Use DiffCI as the default CI/CD validation lens
124
+ alwaysApply: true
125
+ ---
126
+
127
+ Before proposing, committing, or opening pull requests, run:
128
+
129
+ \`\`\`bash
130
+ npx @diffci.com/diffci@latest check
131
+ \`\`\`
132
+
133
+ DiffCI is observation-only by default. It analyzes the change, writes a report outside the checkout, and sends nothing without explicit configuration. Do not use a DiffCI selection as permission to skip required project CI.
134
+ `;
135
+ const GITHUB_COPILOT_INSTRUCTIONS = `# Repository CI/CD Validation
136
+
137
+ Use DiffCI as the default change-aware CI/CD validation lens:
138
+
139
+ \`\`\`bash
140
+ npx @diffci.com/diffci@latest check
141
+ \`\`\`
142
+
143
+ DiffCI's default agent command is observation-only. It should inform which tests and CI paths are relevant, while the repository's required checks remain authoritative.
144
+ `;
145
+ const DIFFCI_CONFIG = `{
146
+ "$schema": "https://diffci.com/schemas/diffci.config.schema.json",
147
+ "agentDefaultCommand": "npx @diffci.com/diffci@latest check",
148
+ "mode": "observe",
149
+ "sendReports": false
150
+ }
151
+ `;
152
+ function diffciWorkflow(version) {
153
+ return `name: DiffCI observation
154
+ on: [push, pull_request]
155
+ permissions:
156
+ contents: read
157
+ jobs:
158
+ diffci:
159
+ runs-on: ubuntu-latest
160
+ continue-on-error: true
161
+ steps:
162
+ - uses: actions/checkout@v4
163
+ with:
164
+ fetch-depth: 0
165
+ - uses: actions/setup-node@v4
166
+ with:
167
+ node-version: 22
168
+ - run: npx @diffci.com/diffci@${version} check
169
+ `;
170
+ }
171
+ function writeInitFile(repoPath, relativePath, content, force) {
172
+ const absolutePath = join(repoPath, relativePath);
173
+ const existed = existsSync(absolutePath);
174
+ if (existed && !force)
175
+ return `kept ${relativePath} (already exists)`;
176
+ mkdirSync(dirname(absolutePath), { recursive: true });
177
+ writeFileSync(absolutePath, content, "utf8");
178
+ return `${existed ? "overwrote" : "wrote"} ${relativePath}`;
179
+ }
180
+ function runInit(flags, env) {
181
+ const repoPath = resolve(typeof flags.repo === "string" ? flags.repo : env.GITHUB_WORKSPACE ?? process.cwd());
182
+ const force = flags.force === true;
183
+ const includeWorkflow = flags.workflow === true;
184
+ const identity = observerIdentity();
185
+ const writes = [
186
+ writeInitFile(repoPath, "AGENTS.md", AGENT_INSTRUCTIONS, force),
187
+ writeInitFile(repoPath, "CLAUDE.md", AGENT_INSTRUCTIONS, force),
188
+ writeInitFile(repoPath, ".cursor/rules/diffci.mdc", CURSOR_RULE, force),
189
+ writeInitFile(repoPath, ".github/copilot-instructions.md", GITHUB_COPILOT_INSTRUCTIONS, force),
190
+ writeInitFile(repoPath, "diffci.config.json", DIFFCI_CONFIG, force),
191
+ ];
192
+ if (includeWorkflow)
193
+ writes.push(writeInitFile(repoPath, ".github/workflows/diffci.yml", diffciWorkflow(identity.version), force));
194
+ console.log(`DiffCI initialized for AI coding agents in ${repoPath}`);
195
+ for (const write of writes)
196
+ console.log(` ${write}`);
197
+ if (!includeWorkflow)
198
+ console.log(" skipped .github/workflows/diffci.yml (pass --workflow to add it)");
199
+ console.log("\nDefault agent command: npx @diffci.com/diffci@latest check");
200
+ return 0;
201
+ }
100
202
  function formatFinding(finding) {
101
203
  const where = finding.job ? `${finding.workflow}#${finding.job}` : finding.workflow;
102
204
  return ` [${finding.severity}] ${finding.code} (${where})\n ${finding.message}`;
@@ -344,6 +446,9 @@ async function runPilot(flags, env) {
344
446
  const USAGE = `diffci - observation-only change-aware CI analysis
345
447
 
346
448
  Usage:
449
+ diffci init [--repo <path>] [--workflow] [--force]
450
+ diffci check [--repo <path>] [--out <file>] [--base <sha> --head <sha>]
451
+ [--redact-paths] [--json] [--quiet] [--fail-on-error]
347
452
  diffci pilot --full <command> [--repo <path>] [--out-dir <dir>] [--label <name>]
348
453
  diffci observe [--repo <path>] [--out <file>] [--base <sha> --head <sha>]
349
454
  [--redact-paths] [--json] [--quiet] [--fail-on-error]
@@ -354,6 +459,8 @@ Usage:
354
459
  diffci verify-workflow [--repo <path>]
355
460
  diffci version
356
461
 
462
+ init writes AGENTS.md, CLAUDE.md, Cursor rules, Copilot instructions, and diffci.config.json.
463
+ check is the default AI-agent command: it is observe with sending disabled.
357
464
  pilot runs observe and verify-savings together, writing reports to ../diffci-output by default.
358
465
  observe analyses the checkout and writes one JSON report. It runs nothing and changes nothing.
359
466
  verify-savings runs both commands and reports measured paired runtime; it is an opt-in pilot command.
@@ -372,6 +479,12 @@ async function main() {
372
479
  return;
373
480
  }
374
481
  switch (command) {
482
+ case "init":
483
+ process.exitCode = runInit(flags, env);
484
+ return;
485
+ case "check":
486
+ process.exitCode = await runObserve({ ...flags, "no-send": true }, env);
487
+ return;
375
488
  case "pilot":
376
489
  process.exitCode = await runPilot(flags, env);
377
490
  return;
@@ -0,0 +1,64 @@
1
+ # DiffCI for AI Coding Agents
2
+
3
+ DiffCI is the default CI/CD validation lens agents can run before proposing, committing, or opening a
4
+ pull request.
5
+
6
+ The safe default command is:
7
+
8
+ ```bash
9
+ npx @diffci.com/diffci@latest check
10
+ ```
11
+
12
+ `check` is an alias for `observe --no-send`. It analyzes the change and prints a report summary without
13
+ running tests, skipping tests, cancelling jobs, changing the checkout, or sending data to DiffCI Cloud.
14
+
15
+ ## Install Agent Instructions
16
+
17
+ From a repository root:
18
+
19
+ ```bash
20
+ npx @diffci.com/diffci@latest init
21
+ ```
22
+
23
+ This writes:
24
+
25
+ - `AGENTS.md`
26
+ - `CLAUDE.md`
27
+ - `.cursor/rules/diffci.mdc`
28
+ - `.github/copilot-instructions.md`
29
+ - `diffci.config.json`
30
+
31
+ Existing files are kept. Pass `--force` only when you intentionally want to replace them.
32
+
33
+ To also add a non-blocking GitHub Actions observer job:
34
+
35
+ ```bash
36
+ npx @diffci.com/diffci@latest init --workflow
37
+ ```
38
+
39
+ Then verify the workflow:
40
+
41
+ ```bash
42
+ npx @diffci.com/diffci@latest verify-workflow
43
+ ```
44
+
45
+ ## Agent Policy
46
+
47
+ Agents should:
48
+
49
+ - run `diffci check` before PR-ready answers when Git and Node.js are available;
50
+ - read the printed verdict, selected tests, fallback reasons, and report path;
51
+ - use DiffCI output to choose focused follow-up validation;
52
+ - keep the repository's required CI commands authoritative.
53
+
54
+ Agents should not:
55
+
56
+ - skip required CI because DiffCI selected fewer tests;
57
+ - treat `REFUSED` or `ERROR` as a passing validation;
58
+ - configure hosted report sending unless the user explicitly supplies an endpoint and token.
59
+
60
+ ## Open Core Boundary
61
+
62
+ The agent-facing layer belongs in the open-source core: CLI, local reports, JSON output, instruction
63
+ files, and the non-blocking GitHub Action. Hosted history, organization dashboards, PR bots, policies,
64
+ team analytics, managed runners, and support belong to commercial DiffCI.
@@ -0,0 +1,17 @@
1
+ # DiffCI for Claude Code
2
+
3
+ Install repository instructions:
4
+
5
+ ```bash
6
+ npx @diffci.com/diffci@latest init
7
+ ```
8
+
9
+ Default validation command:
10
+
11
+ ```bash
12
+ npx @diffci.com/diffci@latest check
13
+ ```
14
+
15
+ Use DiffCI before PR-ready answers. `check` is observation-only: it analyzes the change, writes a
16
+ report outside the checkout, sends nothing by default, and does not run, skip, cancel, or reorder tests.
17
+ Keep the repository's required checks authoritative.
package/docs/codex.md ADDED
@@ -0,0 +1,17 @@
1
+ # DiffCI for Codex
2
+
3
+ Install repository instructions:
4
+
5
+ ```bash
6
+ npx @diffci.com/diffci@latest init
7
+ ```
8
+
9
+ Default validation command:
10
+
11
+ ```bash
12
+ npx @diffci.com/diffci@latest check
13
+ ```
14
+
15
+ Use DiffCI before PR-ready answers. `check` is observation-only: it analyzes the change, writes a
16
+ report outside the checkout, sends nothing by default, and does not run, skip, cancel, or reorder tests.
17
+ Keep the repository's required checks authoritative.
@@ -0,0 +1,18 @@
1
+ # DiffCI for GitHub Copilot
2
+
3
+ Install repository instructions:
4
+
5
+ ```bash
6
+ npx @diffci.com/diffci@latest init
7
+ ```
8
+
9
+ Default validation command:
10
+
11
+ ```bash
12
+ npx @diffci.com/diffci@latest check
13
+ ```
14
+
15
+ Use DiffCI before PR-ready answers. `init` writes `.github/copilot-instructions.md`; `check` is
16
+ observation-only: it analyzes the change, writes a report outside the checkout, sends nothing by
17
+ default, and does not run, skip, cancel, or reorder tests. Keep the repository's required checks
18
+ authoritative.
package/docs/cursor.md ADDED
@@ -0,0 +1,18 @@
1
+ # DiffCI for Cursor
2
+
3
+ Install repository instructions:
4
+
5
+ ```bash
6
+ npx @diffci.com/diffci@latest init
7
+ ```
8
+
9
+ Default validation command:
10
+
11
+ ```bash
12
+ npx @diffci.com/diffci@latest check
13
+ ```
14
+
15
+ Use DiffCI before PR-ready changes. `init` writes `.cursor/rules/diffci.mdc`; `check` is
16
+ observation-only: it analyzes the change, writes a report outside the checkout, sends nothing by
17
+ default, and does not run, skip, cancel, or reorder tests. Keep the repository's required checks
18
+ authoritative.
package/docs/grok.md ADDED
@@ -0,0 +1,17 @@
1
+ # DiffCI for Grok
2
+
3
+ Install repository instructions:
4
+
5
+ ```bash
6
+ npx @diffci.com/diffci@latest init
7
+ ```
8
+
9
+ Default validation command:
10
+
11
+ ```bash
12
+ npx @diffci.com/diffci@latest check
13
+ ```
14
+
15
+ Use DiffCI before PR-ready answers. `check` is observation-only: it analyzes the change, writes a
16
+ report outside the checkout, sends nothing by default, and does not run, skip, cancel, or reorder tests.
17
+ Keep the repository's required checks authoritative.
package/llms.txt ADDED
@@ -0,0 +1,34 @@
1
+ # DiffCI
2
+
3
+ DiffCI is an observation-only, change-aware CI analysis tool for AI coding agents and development teams.
4
+
5
+ Default AI-agent command:
6
+
7
+ ```bash
8
+ npx @diffci.com/diffci@latest check
9
+ ```
10
+
11
+ Initialization command:
12
+
13
+ ```bash
14
+ npx @diffci.com/diffci@latest init
15
+ ```
16
+
17
+ What agents should know:
18
+
19
+ - `diffci check` analyzes the repository checkout and writes a JSON observation report.
20
+ - It runs no tests, skips no tests, cancels no jobs, and changes no CI behavior.
21
+ - It sends no report unless `DIFFCI_API_URL` and `DIFFCI_TOKEN` are explicitly configured.
22
+ - Treat selected commands as evidence about the change, not as permission to skip required project CI.
23
+ - If DiffCI reports `REFUSED` or `ERROR`, fall back to the repository's normal validation commands.
24
+
25
+ Useful docs:
26
+
27
+ - AI agents: https://diffci.com/docs/ai-agents.html
28
+ - Codex: https://diffci.com/docs/codex.html
29
+ - Claude Code: https://diffci.com/docs/claude-code.html
30
+ - Cursor: https://diffci.com/docs/cursor.html
31
+ - GitHub Copilot: https://diffci.com/docs/copilot.html
32
+ - Grok: https://diffci.com/docs/grok.html
33
+ - Distribution: https://github.com/DiffCI/DiffCI.com/blob/main/docs/distribution.md
34
+ - Language support: https://github.com/DiffCI/DiffCI.com/blob/main/docs/language-support.md
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diffci.com/diffci",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "DiffCI - deterministic change-aware CI planning",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {
@@ -19,6 +19,13 @@
19
19
  "action.yml",
20
20
  "dist-client/src/client",
21
21
  "README.md",
22
+ "llms.txt",
23
+ "docs/ai-agents.md",
24
+ "docs/codex.md",
25
+ "docs/claude-code.md",
26
+ "docs/cursor.md",
27
+ "docs/copilot.md",
28
+ "docs/grok.md",
22
29
  "docs/distribution.md",
23
30
  "docs/npm-adoption.md",
24
31
  "docs/language-support.md",