@diffci.com/diffci 0.3.2 → 0.3.3

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.
Files changed (50) hide show
  1. package/.agents/plugins/marketplace.json +12 -0
  2. package/README.md +23 -3
  3. package/dist-client/src/client/agent-selection.js +67 -0
  4. package/dist-client/src/client/cli.js +36 -7
  5. package/dist-client/src/client/full-command.js +30 -0
  6. package/dist-client/src/client/mcp.js +74 -7
  7. package/dist-client/src/client/observe.js +1 -0
  8. package/dist-client/src/client/verify-savings.js +24 -7
  9. package/dist-client/src/client/verify.js +29 -24
  10. package/docs/adoption-metrics.md +31 -5
  11. package/docs/adoption-outreach.md +43 -8
  12. package/docs/agent-adoption-kit.md +1 -1
  13. package/docs/agent-plugin.md +80 -0
  14. package/docs/claude-code.md +4 -4
  15. package/docs/codex.md +4 -4
  16. package/docs/cursor.md +5 -4
  17. package/docs/distribution.md +4 -2
  18. package/docs/mcp.md +4 -0
  19. package/docs/npm-adoption.md +1 -1
  20. package/node_modules/@diffci.com/core/README.md +41 -2
  21. package/node_modules/@diffci.com/core/dist/cache/graph-cache.d.ts +1 -1
  22. package/node_modules/@diffci.com/core/dist/cache/graph-cache.js +1 -1
  23. package/node_modules/@diffci.com/core/dist/planner/test-command.js +76 -0
  24. package/node_modules/@diffci.com/core/dist/planner/test-command.js.map +1 -1
  25. package/node_modules/@diffci.com/core/dist/repo/analyzer.js +19 -1
  26. package/node_modules/@diffci.com/core/dist/repo/analyzer.js.map +1 -1
  27. package/node_modules/@diffci.com/core/dist/repo/graph.js +34 -6
  28. package/node_modules/@diffci.com/core/dist/repo/graph.js.map +1 -1
  29. package/node_modules/@diffci.com/core/dist/repo/test-discovery.d.ts +7 -0
  30. package/node_modules/@diffci.com/core/dist/repo/test-discovery.js +58 -0
  31. package/node_modules/@diffci.com/core/dist/repo/test-discovery.js.map +1 -1
  32. package/node_modules/@diffci.com/core/dist/repo/types.d.ts +5 -0
  33. package/node_modules/@diffci.com/core/dist/repo/workspaces.d.ts +2 -0
  34. package/node_modules/@diffci.com/core/dist/repo/workspaces.js +37 -0
  35. package/node_modules/@diffci.com/core/dist/repo/workspaces.js.map +1 -0
  36. package/node_modules/@diffci.com/core/src/cache/graph-cache.ts +1 -1
  37. package/node_modules/@diffci.com/core/src/planner/test-command.ts +59 -0
  38. package/node_modules/@diffci.com/core/src/repo/analyzer.ts +18 -1
  39. package/node_modules/@diffci.com/core/src/repo/graph.ts +33 -6
  40. package/node_modules/@diffci.com/core/src/repo/test-discovery.ts +54 -0
  41. package/node_modules/@diffci.com/core/src/repo/types.ts +2 -0
  42. package/node_modules/@diffci.com/core/src/repo/workspaces.ts +29 -0
  43. package/package.json +10 -4
  44. package/packaging/agent-plugin/.claude-plugin/plugin.json +6 -0
  45. package/packaging/agent-plugin/.codex-plugin/plugin.json +8 -0
  46. package/packaging/agent-plugin/.mcp.json +13 -0
  47. package/packaging/agent-plugin/skills/diffci-verify/SKILL.md +35 -0
  48. package/server.json +2 -2
  49. package/site/assets/calcom-runtime-evidence.svg +11 -0
  50. package/site/llms.txt +44 -0
@@ -0,0 +1,37 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-only
2
+ import { existsSync, readFileSync, readdirSync } from "node:fs";
3
+ import { join } from "node:path";
4
+ import { parse } from "yaml";
5
+ import { matchesGlob } from "./test-discovery.js";
6
+ /** Read declared workspace membership without executing manifests or following symlinks. */
7
+ export function declaredWorkspaceRoots(repoPath) {
8
+ let pkg;
9
+ try {
10
+ pkg = JSON.parse(readFileSync(join(repoPath, "package.json"), "utf8"));
11
+ }
12
+ catch {
13
+ return [];
14
+ }
15
+ const declared = Array.isArray(pkg.workspaces) ? pkg.workspaces : pkg.workspaces?.packages;
16
+ let patterns = declared;
17
+ const pnpm = join(repoPath, "pnpm-workspace.yaml");
18
+ if (existsSync(pnpm))
19
+ patterns = parse(readFileSync(pnpm, "utf8"))?.packages;
20
+ if (!Array.isArray(patterns) || patterns.some(p => typeof p !== "string" || p.startsWith("/") || p.includes("\\") || p.split("/").includes("..")))
21
+ return [];
22
+ const candidates = [];
23
+ const ignored = new Set(["node_modules", "dist", "build", "coverage", "tmp", "temp"]);
24
+ function walk(root) {
25
+ for (const entry of readdirSync(join(repoPath, root), { withFileTypes: true })) {
26
+ if (!entry.isDirectory() || ignored.has(entry.name) || entry.name.startsWith("."))
27
+ continue;
28
+ const path = root ? `${root}/${entry.name}` : entry.name;
29
+ if (existsSync(join(repoPath, path, "package.json")))
30
+ candidates.push(path);
31
+ walk(path);
32
+ }
33
+ }
34
+ walk("");
35
+ return candidates.filter(path => patterns.some(p => !p.startsWith("!") && matchesGlob(path, p)) && !patterns.some(p => p.startsWith("!") && matchesGlob(path, p.slice(1)))).sort();
36
+ }
37
+ //# sourceMappingURL=workspaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspaces.js","sourceRoot":"","sources":["../../src/repo/workspaces.ts"],"names":[],"mappings":"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"}
@@ -4,7 +4,7 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
4
4
  import { resolve } from "node:path";
5
5
  import type { DependencyGraphResult } from "../repo/types.js";
6
6
 
7
- export const GRAPH_CACHE_SCHEMA_VERSION = "1";
7
+ export const GRAPH_CACHE_SCHEMA_VERSION = "2";
8
8
 
9
9
  export interface GraphCacheKeyInputs {
10
10
  commitSha: string;
@@ -133,6 +133,64 @@ export function planSelectiveTestCommands(
133
133
  ): SelectiveTestCommandPlan {
134
134
  const blockers = profile.adapterBlockers ?? profile.adapters?.flatMap((adapter) => adapter.blockers) ?? [];
135
135
  if (blockers.length) return { commands: [], groups: [], unroutedPaths: [...selectedPaths], refusalReason: blockers.join("; ") };
136
+ if (profile.workspaceTestPackages?.length) {
137
+ const suites = profile.workspaceTestPackages;
138
+ const refuse = (reason: string): SelectiveTestCommandPlan => ({ commands: [], groups: [], unroutedPaths: [...selectedPaths], refusalReason: reason });
139
+ if (!["pnpm", "npm"].includes(profile.packageManager) || suites.some(s => suites.some(other => other !== s && s.packageRoot.startsWith(`${other.packageRoot}/`)))) return refuse("Workspace routing requires non-overlapping declared npm or pnpm packages");
140
+ if (selectedPaths.some(path => !suites.some(s => path.startsWith(`${s.packageRoot}/`) && s.profile.testFilePaths.includes(path.slice(s.packageRoot.length + 1))))) return refuse("A selected test has no verified workspace owner");
141
+ const groups: SelectiveTestCommandGroup[] = [];
142
+ for (const suite of suites) {
143
+ const child = suite.profile;
144
+ const script = child.packageJson.scripts.test?.trim();
145
+ if (!/^vitest(?: run)?(?: --typecheck)?$/.test(script ?? "") || child.packageJson.scripts.pretest || child.packageJson.scripts.posttest || child.testUniverse?.blindSpot || child.testUniverse?.declaredFrameworks.length !== 1 || child.testUniverse.declaredFrameworks[0] !== "vitest" || child.workspaceTestPackages?.length) return refuse("Workspace test scripts require a single declared Vitest phase without lifecycle hooks or discovery blind spots");
146
+ const paths = selectedPaths.filter(path => path.startsWith(`${suite.packageRoot}/`)).map(path => path.slice(suite.packageRoot.length + 1));
147
+ const wrap = (args: string[]): CommandSpec => profile.packageManager === "npm"
148
+ ? { executable: "npm", args: ["exec", "--offline", `--workspace=${suite.packageRoot}`, "--", "vitest", ...args] }
149
+ : { executable: "pnpm", args: ["--dir", suite.packageRoot, "exec", "vitest", ...args] };
150
+ const projectConfigs = child.testRunnerConfigs?.filter(config => config.projects !== undefined) ?? [];
151
+ if (projectConfigs.length) {
152
+ if (projectConfigs.length !== 1 || child.testRunnerConfigs?.length !== 1 || !projectConfigs[0]!.projects) return refuse("Vitest projects must be statically declared inline in one configuration");
153
+ const config = projectConfigs[0]!;
154
+ const projects = config.projects!;
155
+ if (paths.some(path => !projects.some(project => project.includes.some(glob => matchesGlob(path, glob))))) return refuse("Selected test has no declared Vitest project");
156
+ for (const project of projects) {
157
+ // Only conventional runtime-only globs are narrowed. Type/property or
158
+ // unfamiliar projects always retain their full original configuration.
159
+ const runtimeOnly = project.runtimeSelectionSafe && project.includes.every(glob => glob.endsWith(".test.ts"));
160
+ const selected = paths.filter(path => project.includes.some(glob => matchesGlob(path, glob)));
161
+ if (runtimeOnly && !selected.length) continue;
162
+ const args = ["run", "--config", config.file, "--project", project.name, ...(runtimeOnly ? selected : [])];
163
+ if (args.join(" ").length > 3500) return refuse("Vitest project selection exceeds the safe command length");
164
+ groups.push({ runnerId: `${suite.packageRoot}:project:${project.name}`, label: runtimeOnly ? "Selected runtime project" : "Full auxiliary project", paths: runtimeOnly ? selected.map(path => `${suite.packageRoot}/${path}`) : [], commandSpec: wrap(args) });
165
+ }
166
+ continue;
167
+ }
168
+ if (child.testRunnerConfigs?.some(config => config.runtimeSelectionUnsafe)) {
169
+ // Preserve state-sharing files together in the original package process.
170
+ // Only whole unaffected packages may be omitted, never files within it.
171
+ if (paths.length) groups.push({ runnerId: `${suite.packageRoot}:full`, label: "Full non-isolated workspace suite", paths: child.testFilePaths.map(path => `${suite.packageRoot}/${path}`), commandSpec: wrap(["run", ...(script?.endsWith(" --typecheck") ? ["--typecheck"] : [])]) });
172
+ else if (script?.endsWith(" --typecheck")) groups.push({ runnerId: `${suite.packageRoot}:types`, label: "Full workspace type tests", paths: [], commandSpec: wrap(["run", "--typecheck.only", "--passWithNoTests"]) });
173
+ continue;
174
+ }
175
+ const local = planSelectiveTestCommands({ ...child, packageManager: "pnpm" }, paths);
176
+ if (local.refusalReason) return refuse(local.refusalReason);
177
+ for (const group of local.groups) {
178
+ const prefix = group.commandSpec.args.slice(0, group.commandSpec.args.length - group.paths.length);
179
+ const batches: string[][] = [[]];
180
+ for (const path of group.paths) {
181
+ if (path.length > 3000) return refuse("Workspace test path exceeds the safe command length");
182
+ const batch = batches[batches.length - 1]!;
183
+ if (batch.length && batch.join(" ").length + path.length > 3500) batches.push([path]);
184
+ else batch.push(path);
185
+ }
186
+ for (const [index, batch] of batches.entries()) groups.push({ ...group, runnerId: `${suite.packageRoot}:${group.runnerId}:${index}`, paths: batch.map(path => `${suite.packageRoot}/${path}`), commandSpec: wrap([...prefix.slice(2), ...batch]) });
187
+ }
188
+ // Type-test files are not runtime selection candidates. Retain the entire type suite.
189
+ if (script?.endsWith(" --typecheck")) groups.push({ runnerId: `${suite.packageRoot}:types`, label: "Full workspace type tests", paths: [], commandSpec: wrap(["run", "--typecheck.only", "--passWithNoTests"]) });
190
+ }
191
+ if (!groups.some(group => group.paths.length)) return refuse("No workspace runtime suite can be safely narrowed; full validation is required");
192
+ return { commands: groups.map(g => g.commandSpec), groups, unroutedPaths: [] };
193
+ }
136
194
  if (profile.vueScope) {
137
195
  const scope = profile.vueScope;
138
196
  const known = new Set(profile.testFilePaths);
@@ -184,6 +242,7 @@ export function planSelectiveTestCommands(
184
242
 
185
243
  const frameworks = profile.testUniverse?.declaredFrameworks ?? [];
186
244
  const configs = profile.testRunnerConfigs ?? [];
245
+ if (configs.some(config => config.runtimeSelectionUnsafe)) return { commands: [], groups: [], unroutedPaths: paths, refusalReason: "Non-isolated or ambiguous Vitest isolation requires full validation" };
187
246
 
188
247
  if (frameworks.length === 0 && configs.length === 0) {
189
248
  return {
@@ -14,6 +14,7 @@ import { createTestFileMatcher, discoverTestRunnerConfigs, matchesGlob, type Tes
14
14
  import { compileIgnoreRegexes, isIgnoredPath, isUnderRoots } from "./runner-universe.js";
15
15
  import { defaultExcludesFor, defaultIncludesFor, detectDeclaredFrameworks } from "./test-framework.js";
16
16
  import { readRepositoryConfig } from "./repo-config.js";
17
+ import { declaredWorkspaceRoots } from "./workspaces.js";
17
18
 
18
19
  const IGNORED_DIRS = new Set([
19
20
  "node_modules",
@@ -464,7 +465,7 @@ export function analyzeRepository(
464
465
  excludeDirs,
465
466
  );
466
467
 
467
- const testFileCount = testFilePaths.length;
468
+ let testFileCount = testFilePaths.length;
468
469
  const lockfile =
469
470
  packageManager === "npm"
470
471
  ? "package-lock.json"
@@ -478,7 +479,23 @@ export function analyzeRepository(
478
479
 
479
480
  const nextConfigFile = findConfig(repoPath, "next.config");
480
481
 
482
+ const workspaceTestPackages = existsSync(join(repoPath, "package.json"))
483
+ ? declaredWorkspaceRoots(repoPath).flatMap(packageRoot => {
484
+ const child = analyzeRepository({ repoPath: join(repoPath, packageRoot), excludeDirs });
485
+ return child.packageJson.scripts.test ? [{ packageRoot, profile: child }] : [];
486
+ }) : [];
487
+ for (const suite of workspaceTestPackages) {
488
+ for (const path of suite.profile.testFilePaths) {
489
+ const scoped = `${suite.packageRoot}/${path}`;
490
+ if (!testFilePaths.includes(scoped)) testFilePaths.push(scoped);
491
+ }
492
+ for (const glob of suite.profile.testPatterns ?? []) testPatterns.push(`${suite.packageRoot}/${glob}`);
493
+ }
494
+ testFilePaths.sort();
495
+ testFileCount = testFilePaths.length;
496
+
481
497
  return {
498
+ ...(workspaceTestPackages.length ? { workspaceTestPackages } : {}),
482
499
  packageManager,
483
500
  packageJson: {
484
501
  name: packageJsonRaw?.name,
@@ -287,7 +287,7 @@ function resolveProjectReferenceInputs(
287
287
  if (visited.has(normalized)) return collected; // guard against reference cycles
288
288
  visited.add(normalized);
289
289
 
290
- const { config, error } = ts.readConfigFile(configPath, ts.sys.readFile);
290
+ const { config, error } = ts.readConfigFile(toPosix(configPath), ts.sys.readFile);
291
291
  if (error || !config) return collected;
292
292
 
293
293
  const parsed = ts.parseJsonConfigFileContent(config, ts.sys, dirname(configPath), undefined, configPath);
@@ -406,7 +406,7 @@ function createProgram(
406
406
  let configFileParsingDiagnostics: readonly ts.Diagnostic[] = [];
407
407
 
408
408
  if (configPath) {
409
- const { config, error } = ts.readConfigFile(configPath, ts.sys.readFile);
409
+ const { config, error } = ts.readConfigFile(toPosix(configPath), ts.sys.readFile);
410
410
  if (error) {
411
411
  throw new Error(ts.flattenDiagnosticMessageText(error.messageText, "\n"));
412
412
  }
@@ -755,11 +755,38 @@ export async function buildDependencyGraph(
755
755
  let filesParsed = sourceFiles.length;
756
756
  let followedImplementationFiles = 0;
757
757
 
758
+ // Resolve each importer with its own nearest project, never another package's
759
+ // aliases. Invalid project configuration remains a hard safety blocker.
760
+ const projectOptions = new Map<string, ts.CompilerOptions>();
761
+ function optionsFor(file: string): ts.CompilerOptions {
762
+ let directory = dirname(file);
763
+ while (toRelativeInternal(repoPath, directory) !== undefined) {
764
+ const config = join(directory, "tsconfig.json");
765
+ if (existsSync(config)) {
766
+ if (!projectOptions.has(config)) {
767
+ const read = ts.readConfigFile(toPosix(config), ts.sys.readFile);
768
+ const parsed = read.error ? undefined : ts.parseJsonConfigFileContent(read.config, ts.sys, directory, undefined, config);
769
+ // No-input diagnostics do not invalidate module-resolution options.
770
+ if (!parsed || parsed.errors.some(error => error.code !== 18003)) {
771
+ adapterBlockers.push(`Invalid importer TypeScript configuration: ${toRelativeInternal(repoPath, config)}`);
772
+ projectOptions.set(config, compilerOptions);
773
+ } else projectOptions.set(config, parsed.options);
774
+ }
775
+ return projectOptions.get(config)!;
776
+ }
777
+ if (directory === repoPath || dirname(directory) === directory) break;
778
+ directory = dirname(directory);
779
+ }
780
+ return compilerOptions;
781
+ }
782
+
758
783
  for (const sf of sourceFiles) {
759
784
  const importerRel = toRelativeInternal(repoPath, sf.fileName);
760
785
  if (!importerRel || !isSourceFileName(sf.fileName)) continue;
761
786
  if (isExcludedPath(importerRel, options.excludeDirs ?? [])) continue;
762
787
 
788
+ const importerOptions = optionsFor(sf.fileName);
789
+
763
790
  const refs = extractImportRefs(sf);
764
791
  if (scope && sf.referencedFiles.length) adapterBlockers.push(`Triple-slash file references in the scoped suite require full validation: ${importerRel}`);
765
792
  for (const ref of refs) {
@@ -778,8 +805,8 @@ export async function buildDependencyGraph(
778
805
  const resolvableSpecifier = specifierCategory === "relative" || specifierCategory === "absolute" || specifierCategory === "alias" ? stripImportQuery(ref.specifier) : ref.specifier;
779
806
  // TypeScript may resolve a Vue import to a declaration shim. Preserve the actual SFC edge.
780
807
  if (resolvableSpecifier.endsWith(".vue")) {
781
- const compilerAliases = Object.entries(compilerOptions.paths ?? {}).map(([pattern, substitutions]) => ({ pattern, substitutions }));
782
- const candidate = findAssetCandidate(sf.fileName, resolvableSpecifier, compilerAliases.length ? compilerAliases : profile.pathAliases, compilerOptions.baseUrl ?? repoPath);
808
+ const compilerAliases = Object.entries(importerOptions.paths ?? {}).map(([pattern, substitutions]) => ({ pattern, substitutions }));
809
+ const candidate = findAssetCandidate(sf.fileName, resolvableSpecifier, compilerAliases.length ? compilerAliases : profile.pathAliases, importerOptions.baseUrl ?? dirname(sf.fileName));
783
810
  const target = candidate && toRelativeInternal(repoPath, candidate);
784
811
  if (target && internalSourcePaths.has(target)) {
785
812
  addEdge(importerRel, target, ref.kind);
@@ -793,7 +820,7 @@ export async function buildDependencyGraph(
793
820
  const resolution = ts.resolveModuleName(
794
821
  resolvableSpecifier,
795
822
  sf.fileName,
796
- compilerOptions,
823
+ importerOptions,
797
824
  ts.sys,
798
825
  moduleResolutionCache,
799
826
  );
@@ -838,7 +865,7 @@ export async function buildDependencyGraph(
838
865
  }
839
866
 
840
867
  if (targetRel && isSourceFileName(resolved)) {
841
- if (scope && !resolved.endsWith(".d.ts") && !internalSourcePaths.has(targetRel)) {
868
+ if (!resolved.endsWith(".d.ts") && !internalSourcePaths.has(targetRel)) {
842
869
  // A real import can reach generated implementation excluded from the
843
870
  // initial walk. Parse it (and its imports) rather than silently dropping
844
871
  // the edge or loading every TypeScript declaration library again.
@@ -23,10 +23,14 @@
23
23
  import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
24
24
  import { compileIgnoreRegexes, extractTestPatterns, isIgnoredPath, isUnderRoots } from "./runner-universe.js";
25
25
  import { join } from "node:path";
26
+ import ts from "typescript";
26
27
 
27
28
  export type TestFamily = "unit" | "snapshot" | "e2e" | "integration" | "benchmark";
28
29
 
29
30
  export interface TestRunnerConfig {
31
+ /** Inline Vitest projects; undefined means no projects, null means ambiguous. */
32
+ projects?: { name: string; includes: string[]; runtimeSelectionSafe: boolean }[] | null;
33
+ runtimeSelectionUnsafe?: boolean;
30
34
  /** Repo-relative config file, e.g. "vitest.e2e.config.ts". */
31
35
  file: string;
32
36
  runner: "vitest" | "jest";
@@ -57,6 +61,54 @@ export interface TestRunnerConfig {
57
61
  authoritative: boolean;
58
62
  }
59
63
 
64
+ function runtimeIsolationUnsafe(source: string): boolean {
65
+ const ast = ts.createSourceFile("config.ts", source, ts.ScriptTarget.Latest, true);
66
+ let unsafe = false;
67
+ const visit = (node: ts.Node): void => {
68
+ if (ts.isPropertyAssignment(node) && (ts.isIdentifier(node.name) || ts.isStringLiteral(node.name)) && node.name.text === "isolate" && node.initializer.kind !== ts.SyntaxKind.TrueKeyword) unsafe = true;
69
+ ts.forEachChild(node, visit);
70
+ };
71
+ visit(ast);
72
+ return unsafe;
73
+ }
74
+
75
+ function inlineProjects(source: string): TestRunnerConfig["projects"] {
76
+ const ast = ts.createSourceFile("config.ts", source, ts.ScriptTarget.Latest, true);
77
+ let found: ts.Node[] = [];
78
+ let sharedState = false;
79
+ const visit = (node: ts.Node): void => {
80
+ if (ts.isPropertyAssignment(node) && node.name.getText(ast) === "projects") found.push(node.initializer);
81
+ if (ts.isPropertyAssignment(node) && node.name.getText(ast) === "isolate" && node.initializer.kind !== ts.SyntaxKind.TrueKeyword) sharedState = true;
82
+ ts.forEachChild(node, visit);
83
+ };
84
+ visit(ast);
85
+ if (!found.length) return undefined;
86
+ if (found.length !== 1 || !ts.isArrayLiteralExpression(found[0]!)) return null;
87
+ const properties = (node: ts.Node): Map<string, ts.Expression> | undefined => {
88
+ if (!ts.isObjectLiteralExpression(node)) return;
89
+ const values = new Map<string, ts.Expression>();
90
+ for (const property of node.properties) {
91
+ if (!ts.isPropertyAssignment(property) || !ts.isIdentifier(property.name) || values.has(property.name.text)) return;
92
+ values.set(property.name.text, property.initializer);
93
+ }
94
+ return values;
95
+ };
96
+ const projects: NonNullable<TestRunnerConfig["projects"]> = [];
97
+ const inherited = properties(found[0].parent.parent);
98
+ const inheritedSafe = inherited && [...inherited.keys()].every(key => ["projects", "coverage", "setupFiles", "globalSetup", "isolate"].includes(key));
99
+ for (const element of found[0].elements) {
100
+ const project = properties(element);
101
+ const test = project?.get("test");
102
+ const fields = test && properties(test);
103
+ const name = fields?.get("name");
104
+ const include = fields?.get("include");
105
+ if (!project || project.size !== 2 || project.get("extends")?.kind !== ts.SyntaxKind.TrueKeyword || !fields || !name || !ts.isStringLiteral(name) || !/^[\w-]+$/.test(name.text) || !include || !ts.isArrayLiteralExpression(include) || !include.elements.length || include.elements.some(value => !ts.isStringLiteral(value))) return null;
106
+ if (projects.some(value => value.name === name.text)) return null;
107
+ projects.push({ name: name.text, includes: include.elements.map(value => (value as ts.StringLiteral).text), runtimeSelectionSafe: Boolean(inheritedSafe) && !sharedState && [...fields.keys()].every(key => ["name", "include", "isolate"].includes(key)) });
108
+ }
109
+ return projects.length ? projects : null;
110
+ }
111
+
60
112
  export interface TestDiscovery {
61
113
  configs: TestRunnerConfig[];
62
114
  /**
@@ -218,6 +270,8 @@ export function discoverTestRunnerConfigs(repoPath: string, scripts: Record<stri
218
270
  const isDefault = m[2] === undefined;
219
271
  const extracted = extractTestPatterns(source);
220
272
  configs.push({
273
+ ...(runner === "vitest" ? { projects: inlineProjects(source) } : {}),
274
+ ...(runner === "vitest" && runtimeIsolationUnsafe(source) ? { runtimeSelectionUnsafe: true } : {}),
221
275
  file: name,
222
276
  runner,
223
277
  includes: extracted.includes,
@@ -39,6 +39,8 @@ export interface EntryPoint {
39
39
  }
40
40
 
41
41
  export interface RepositoryProfile {
42
+ /** Declared package ownership; child profiles retain package-local runner configuration. */
43
+ workspaceTestPackages?: { packageRoot: string; profile: RepositoryProfile }[];
42
44
  /** Adapter coverage and concrete Go test-file to package routing. */
43
45
  adapters?: { id: string; version: string; blockers: string[] }[];
44
46
  adapterBlockers?: string[];
@@ -0,0 +1,29 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-only
2
+ import { existsSync, readFileSync, readdirSync } from "node:fs";
3
+ import { join } from "node:path";
4
+ import { parse } from "yaml";
5
+ import { matchesGlob } from "./test-discovery.js";
6
+
7
+ /** Read declared workspace membership without executing manifests or following symlinks. */
8
+ export function declaredWorkspaceRoots(repoPath: string): string[] {
9
+ let pkg;
10
+ try { pkg = JSON.parse(readFileSync(join(repoPath, "package.json"), "utf8")); }
11
+ catch { return []; }
12
+ const declared = Array.isArray(pkg.workspaces) ? pkg.workspaces : pkg.workspaces?.packages;
13
+ let patterns: unknown = declared;
14
+ const pnpm = join(repoPath, "pnpm-workspace.yaml");
15
+ if (existsSync(pnpm)) patterns = parse(readFileSync(pnpm, "utf8"))?.packages;
16
+ if (!Array.isArray(patterns) || patterns.some(p => typeof p !== "string" || p.startsWith("/") || p.includes("\\") || p.split("/").includes(".."))) return [];
17
+ const candidates: string[] = [];
18
+ const ignored = new Set(["node_modules", "dist", "build", "coverage", "tmp", "temp"]);
19
+ function walk(root: string): void {
20
+ for (const entry of readdirSync(join(repoPath, root), { withFileTypes: true })) {
21
+ if (!entry.isDirectory() || ignored.has(entry.name) || entry.name.startsWith(".")) continue;
22
+ const path = root ? `${root}/${entry.name}` : entry.name;
23
+ if (existsSync(join(repoPath, path, "package.json"))) candidates.push(path);
24
+ walk(path);
25
+ }
26
+ }
27
+ walk("");
28
+ return candidates.filter(path => patterns.some(p => !p.startsWith("!") && matchesGlob(path, p)) && !patterns.some(p => p.startsWith("!") && matchesGlob(path, p.slice(1)))).sort();
29
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diffci.com/diffci",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Fail-closed, change-aware verification for AI coding agents with conservative affected-test selection",
5
5
  "keywords": [
6
6
  "ci",
@@ -41,6 +41,7 @@
41
41
  "dist-client/src/client",
42
42
  "dist-client/src/preflight",
43
43
  "README.md",
44
+ "site/assets/calcom-runtime-evidence.svg",
44
45
  "server.json",
45
46
  "glama.json",
46
47
  "llms.txt",
@@ -60,7 +61,10 @@
60
61
  "docs/language-support.md",
61
62
  "SECURITY.md",
62
63
  "SUPPORT.md",
63
- "COMMERCIAL.md"
64
+ "COMMERCIAL.md",
65
+ ".agents/plugins/marketplace.json",
66
+ "docs/agent-plugin.md",
67
+ "packaging/agent-plugin"
64
68
  ],
65
69
  "exports": {
66
70
  "./*": {
@@ -108,7 +112,9 @@
108
112
  "product:deploy": "wrangler deploy --config wrangler.product.jsonc",
109
113
  "product:migrate": "tsx scripts/migrate-product-db.ts",
110
114
  "site:dev": "wrangler dev --config wrangler.site.jsonc --port 8788",
111
- "site:deploy": "wrangler deploy --config wrangler.site.jsonc",
115
+ "site:check": "tsx --test tests/site/seo.test.ts tests/site/site-worker.test.ts",
116
+ "site:prepare": "npm run site:sitemap && npm run site:check",
117
+ "site:deploy": "npm run site:prepare && wrangler deploy --config wrangler.site.jsonc && npm run site:indexnow",
112
118
  "site:sitemap": "node scripts/generate-site-sitemap.mjs",
113
119
  "site:indexnow": "node scripts/submit-indexnow.mjs",
114
120
  "release:sync": "node scripts/sync-public-metadata.mjs",
@@ -146,7 +152,7 @@
146
152
  "registry:verify": "node scripts/verify-mcp-registry.mjs"
147
153
  },
148
154
  "dependencies": {
149
- "@diffci.com/core": "git+https://github.com/DiffCI/core.git#cdf3bf288715261666cdc074c4a335e8653d4f9a",
155
+ "@diffci.com/core": "git+https://github.com/DiffCI/core.git#0c844e92184a1173a0d50f381f19462fd8966407",
150
156
  "@types/node": "^22.15.12",
151
157
  "@vue/compiler-sfc": "3.5.42",
152
158
  "typescript": "^5.8.3",
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "diffci",
3
+ "version": "0.1.0",
4
+ "description": "Verify coding changes with affected tests and conservative full fallback.",
5
+ "license": "AGPL-3.0-only"
6
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "diffci",
3
+ "version": "0.1.0",
4
+ "description": "Verify coding changes with affected tests and conservative full fallback.",
5
+ "license": "AGPL-3.0-only",
6
+ "skills": "./skills/",
7
+ "mcpServers": "./.mcp.json"
8
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "mcpServers": {
3
+ "diffci": {
4
+ "command": "npx",
5
+ "args": [
6
+ "--yes",
7
+ "--package",
8
+ "@diffci.com/diffci@0.3.3",
9
+ "diffci-mcp"
10
+ ]
11
+ }
12
+ }
13
+ }
@@ -0,0 +1,35 @@
1
+ ---
2
+ name: diffci-verify
3
+ description: Select and verify affected tests after editing code in a local Git repository, using DiffCI MCP tools or the DiffCI CLI before reporting the change ready.
4
+ ---
5
+
6
+ Pass the absolute path of the edited repository as `repo` on every tool call.
7
+
8
+ Use `diffci_changed_files` to inspect staged, unstaged, and non-ignored untracked
9
+ changes. Use `diffci_select_tests` or `diffci_explain_selection` when you need the
10
+ affected-test plan, command, or reasons for full fallback. These tools run no tests;
11
+ their counts describe test files, not passing test cases. A plan is not verification.
12
+
13
+ Before reporting an edited change ready, call `diffci_run_affected_tests`. It
14
+ recomputes the selection and verifies the current snapshot. Accept a passing result
15
+ only when `safe_to_continue` is true and `snapshot.unchanged` is true. After further
16
+ edits, rerun verification. For a clean committed change, use `diffci_verify` with the
17
+ intended base/head range instead; no uncommitted changes does not mean the commit
18
+ has been tested.
19
+
20
+ If MCP is unavailable, use the installed CLI:
21
+
22
+ ```bash
23
+ diffci verify --changed --repo /absolute/path/to/repository --json
24
+ ```
25
+
26
+ If DiffCI is not installed, use `npx "@diffci.com/diffci@latest" verify --changed`
27
+ with the same repo and JSON flags. On blocked analysis or installation failure,
28
+ run the repository's normal verification and report the limitation. On a test
29
+ failure, fix the cause and rerun. On snapshot changes from generated files, inspect
30
+ the files and rerun for that snapshot.
31
+
32
+ Report executed command, selection scope (affected or full fallback), test-file
33
+ counts, outcome, and any outstanding required checks. Never infer passed suites,
34
+ test cases, skipped CI jobs, or measured savings from selection counts. Required
35
+ project CI stays authoritative.
package/server.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "name": "io.github.DiffCI/diffci",
4
4
  "title": "DiffCI",
5
5
  "description": "Fail-closed, change-aware verification for AI coding agents with affected-test guidance.",
6
- "version": "0.3.2",
6
+ "version": "0.3.3",
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.3.2",
25
+ "version": "0.3.3",
26
26
  "transport": {
27
27
  "type": "stdio"
28
28
  },
@@ -0,0 +1,11 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="780" height="240" viewBox="0 0 780 240" role="img" aria-labelledby="title desc">
2
+ <title id="title">Recorded Cal.com sandbox comparison: 44.2% net reduction</title>
3
+ <desc id="desc">Full install, pretest and test runtime was 657.7 seconds. Selected runtime was 356.9 seconds plus about 10.1 seconds of analysis. One controlled sandbox comparison, not production savings.</desc>
4
+ <rect width="780" height="240" rx="12" fill="#0c0e11"/>
5
+ <g fill="#e5e7eb" font-family="monospace" font-size="18">
6
+ <text x="26" y="40">Cal.com · recorded sandbox evidence</text>
7
+ <text x="26" y="82">Full workload 657.7s</text>
8
+ <text x="26" y="118">Selected workload 356.9s + ~10.1s analysis</text>
9
+ <text x="26" y="158" fill="#5eead4">Net job-equivalent runtime reduction: 44.2%</text>
10
+ <text x="26" y="202" font-size="14">One comparison · install + pretest + test · not production savings</text>
11
+ </g></svg>
package/site/llms.txt ADDED
@@ -0,0 +1,44 @@
1
+ # DiffCI
2
+
3
+ DiffCI is a change-aware verification layer and conservative test-selection tool for AI coding agents and development teams.
4
+
5
+ Default AI-agent command:
6
+
7
+ ```bash
8
+ npx "@diffci.com/diffci@latest" verify --changed --json
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 verify --changed --json` binds selected or conservative full-fallback testing to the current staged, unstaged, and untracked snapshot.
20
+ - `diffci verify --json` verifies a clean commit range and binds the receipt to checked-out HEAD.
21
+ - `diffci init --verification-workflow` creates a blocking GitHub verification check.
22
+ - Continue only when `safe_to_continue` is true. If tests change generated files, review them and rerun for the new snapshot.
23
+ - Use `diffci check` for paired runtime measurement and `diffci observe --no-send` for analysis without test execution.
24
+ - DiffCI never skips, cancels, reorders, or changes required CI jobs.
25
+ - It sends no report unless `DIFFCI_API_URL` and `DIFFCI_TOKEN` are explicitly configured.
26
+ - Required project CI remains authoritative. If DiffCI is blocked, fall back to the repository's normal validation commands.
27
+ - Remote MCP tools are available at https://diffci.com/mcp; they provide stateless validation planning, report interpretation, and workflow-text checks without executing commands.
28
+
29
+ Useful docs:
30
+
31
+ - [AI agents](https://diffci.com/docs/ai-agents)
32
+ - [Codex](https://diffci.com/docs/codex)
33
+ - [Claude Code](https://diffci.com/docs/claude-code)
34
+ - [Cursor](https://diffci.com/docs/cursor)
35
+ - [GitHub Copilot](https://diffci.com/docs/copilot)
36
+ - [Grok](https://diffci.com/docs/grok)
37
+ - [Test impact analysis for GitHub Actions](https://diffci.com/test-impact-analysis/github-actions)
38
+ - [Running affected tests safely](https://diffci.com/guides/affected-tests)
39
+ - [Open evidence study](https://diffci.com/research/diffci-open-evidence-2026)
40
+ - [Adoption kit](https://github.com/DiffCI/DiffCI.com/blob/main/docs/agent-adoption-kit.md)
41
+ - [MCP server](https://github.com/DiffCI/DiffCI.com/blob/main/docs/mcp.md)
42
+ - [MCP server setup](https://diffci.com/mcp-server)
43
+ - [MCP Server Card](https://diffci.com/mcp/server-card)
44
+ - [Language support](https://github.com/DiffCI/DiffCI.com/blob/main/docs/language-support.md)