@diffci.com/diffci 0.3.11 → 0.3.12
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
|
@@ -13,9 +13,9 @@ destination is configured. Keep required project CI authoritative.
|
|
|
13
13
|
|
|
14
14
|
## MCP for coding agents
|
|
15
15
|
|
|
16
|
-
The `diffci-mcp` binary exposes the same local analysis through MCP. Install
|
|
17
|
-
public Codex, Claude Code, or
|
|
18
|
-
[
|
|
16
|
+
The `diffci-mcp` binary exposes the same local analysis through MCP. Install
|
|
17
|
+
the public Codex, Claude Code, Cursor, Grok, or Meta Muse Code integration from
|
|
18
|
+
the [cross-agent installation guide](https://github.com/DiffCI/core/blob/main/docs/agent-installation.md).
|
|
19
19
|
|
|
20
20
|
## Source and license
|
|
21
21
|
|
|
@@ -41,6 +41,7 @@ import { formatVerificationSummary, verificationExitCode, verifyChanged, verifyR
|
|
|
41
41
|
import { formatGrowthPrompt, formatVerifySavingsSummary, measureCommand, runVerifySavings, writeVerifySavingsReport } from "./verify-savings.js";
|
|
42
42
|
import { auditWorkflows, isNonInterfering } from "./workflow-guard.js";
|
|
43
43
|
import { buildPilotWorkflow, renderPilotPacket } from "./pilot-packet.js";
|
|
44
|
+
import { observerIdentity } from "./package-identity.js";
|
|
44
45
|
function parseArgs(argv) {
|
|
45
46
|
const args = argv.slice(2);
|
|
46
47
|
const flags = {};
|
|
@@ -63,55 +64,6 @@ function parseArgs(argv) {
|
|
|
63
64
|
}
|
|
64
65
|
return { command, flags };
|
|
65
66
|
}
|
|
66
|
-
/**
|
|
67
|
-
* The observer's own version and commit. Found by walking up from this file rather than by a fixed
|
|
68
|
-
* relative path, because this module runs both from source (tsx, depth src/client) and from compiled
|
|
69
|
-
* output (node, depth dist-client/src/client) and a hardcoded `../..` is right in exactly one of them.
|
|
70
|
-
*/
|
|
71
|
-
function observerIdentity() {
|
|
72
|
-
let current = dirname(import.meta.filename);
|
|
73
|
-
for (let depth = 0; depth < 8; depth++) {
|
|
74
|
-
const candidate = join(current, "package.json");
|
|
75
|
-
if (existsSync(candidate)) {
|
|
76
|
-
try {
|
|
77
|
-
const parsed = JSON.parse(readFileSync(candidate, "utf8"));
|
|
78
|
-
if (parsed.name === "@diffci/observer")
|
|
79
|
-
return { version: parsed.version ?? "0.0.0", root: current };
|
|
80
|
-
if (parsed.name === "@diffci.com/diffci" || parsed.name === "diffci") {
|
|
81
|
-
let sha;
|
|
82
|
-
try {
|
|
83
|
-
const gitRoot = execFileSync("git", ["rev-parse", "--show-toplevel"], {
|
|
84
|
-
cwd: current,
|
|
85
|
-
encoding: "utf8",
|
|
86
|
-
stdio: ["ignore", "pipe", "ignore"],
|
|
87
|
-
}).trim();
|
|
88
|
-
const packageRoot = resolve(current);
|
|
89
|
-
const normalizedGitRoot = resolve(gitRoot);
|
|
90
|
-
const rootsMatch = process.platform === "win32"
|
|
91
|
-
? packageRoot.toLowerCase() === normalizedGitRoot.toLowerCase()
|
|
92
|
-
: packageRoot === normalizedGitRoot;
|
|
93
|
-
if (rootsMatch) {
|
|
94
|
-
sha = execFileSync("git", ["rev-parse", "HEAD"], { cwd: current, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
catch {
|
|
98
|
-
// Installed from a tarball rather than a checkout: there is no commit to report, and
|
|
99
|
-
// inventing one would be worse than the field being absent.
|
|
100
|
-
}
|
|
101
|
-
return { version: parsed.version ?? "0.0.0", root: current, sha };
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
catch {
|
|
105
|
-
// Keep walking - an unreadable package.json above us says nothing about ours.
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
const parent = dirname(current);
|
|
109
|
-
if (parent === current)
|
|
110
|
-
break;
|
|
111
|
-
current = parent;
|
|
112
|
-
}
|
|
113
|
-
return { version: "0.0.0" };
|
|
114
|
-
}
|
|
115
67
|
function defaultReportPath(env) {
|
|
116
68
|
// RUNNER_TEMP is outside GITHUB_WORKSPACE on every GitHub-hosted runner, which is the property that
|
|
117
69
|
// matters: the report cannot become an untracked file in the repository being observed.
|
|
@@ -3,7 +3,8 @@ import { execFile } from "node:child_process";
|
|
|
3
3
|
import { dirname, join, resolve } from "node:path";
|
|
4
4
|
import { StringDecoder } from "node:string_decoder";
|
|
5
5
|
import { agentChangedFiles, agentSelection } from "./agent-selection.js";
|
|
6
|
-
|
|
6
|
+
import { requireDiffciPackageIdentity } from "./package-identity.js";
|
|
7
|
+
const SERVER_INFO = { name: "diffci-mcp", version: requireDiffciPackageIdentity().version };
|
|
7
8
|
const tools = [
|
|
8
9
|
...["diffci_changed_files", "diffci_select_tests", "diffci_explain_selection", "diffci_run_affected_tests"].map((name) => ({
|
|
9
10
|
name,
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import { dirname, join, resolve } from "node:path";
|
|
4
|
+
function checkoutSha(packageRoot) {
|
|
5
|
+
try {
|
|
6
|
+
const gitRoot = execFileSync("git", ["rev-parse", "--show-toplevel"], {
|
|
7
|
+
cwd: packageRoot,
|
|
8
|
+
encoding: "utf8",
|
|
9
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
10
|
+
}).trim();
|
|
11
|
+
const normalizedPackageRoot = resolve(packageRoot);
|
|
12
|
+
const normalizedGitRoot = resolve(gitRoot);
|
|
13
|
+
const rootsMatch = process.platform === "win32"
|
|
14
|
+
? normalizedPackageRoot.toLowerCase() === normalizedGitRoot.toLowerCase()
|
|
15
|
+
: normalizedPackageRoot === normalizedGitRoot;
|
|
16
|
+
if (!rootsMatch)
|
|
17
|
+
return undefined;
|
|
18
|
+
return execFileSync("git", ["rev-parse", "HEAD"], {
|
|
19
|
+
cwd: packageRoot,
|
|
20
|
+
encoding: "utf8",
|
|
21
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
22
|
+
}).trim();
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
// Installed tarballs intentionally have no checkout SHA.
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Find package metadata without assuming whether this code is running from
|
|
31
|
+
* source, a build directory, or an installed npm tarball.
|
|
32
|
+
*/
|
|
33
|
+
export function findDiffciPackageIdentity() {
|
|
34
|
+
let current = dirname(import.meta.filename);
|
|
35
|
+
for (let depth = 0; depth < 8; depth++) {
|
|
36
|
+
const candidate = join(current, "package.json");
|
|
37
|
+
if (existsSync(candidate)) {
|
|
38
|
+
try {
|
|
39
|
+
const parsed = JSON.parse(readFileSync(candidate, "utf8"));
|
|
40
|
+
if (parsed.name === "@diffci/observer") {
|
|
41
|
+
return { version: parsed.version ?? "0.0.0", root: current };
|
|
42
|
+
}
|
|
43
|
+
if (parsed.name === "@diffci.com/diffci" || parsed.name === "diffci") {
|
|
44
|
+
return { version: parsed.version ?? "0.0.0", root: current, sha: checkoutSha(current) };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
// An unreadable ancestor says nothing about this package; keep walking.
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const parent = dirname(current);
|
|
52
|
+
if (parent === current)
|
|
53
|
+
break;
|
|
54
|
+
current = parent;
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
/** Preserve the CLI's historical unknown-version fallback for diagnostics. */
|
|
59
|
+
export function observerIdentity() {
|
|
60
|
+
return findDiffciPackageIdentity() ?? { version: "0.0.0" };
|
|
61
|
+
}
|
|
62
|
+
/** MCP negotiation must never advertise an invented release version. */
|
|
63
|
+
export function requireDiffciPackageIdentity() {
|
|
64
|
+
const identity = findDiffciPackageIdentity();
|
|
65
|
+
if (!identity) {
|
|
66
|
+
throw new Error("DiffCI MCP must run from an installed @diffci.com/diffci package.");
|
|
67
|
+
}
|
|
68
|
+
return identity;
|
|
69
|
+
}
|