diffprism 0.2.13 → 0.2.14
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/dist/bin.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
startReview
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-WTTAKQX3.js";
|
|
5
5
|
|
|
6
6
|
// cli/src/index.ts
|
|
7
7
|
import { Command } from "commander";
|
|
@@ -41,7 +41,7 @@ async function serve() {
|
|
|
41
41
|
|
|
42
42
|
// cli/src/index.ts
|
|
43
43
|
var program = new Command();
|
|
44
|
-
program.name("diffprism").description("Local-first code review tool for agent-generated changes").version(true ? "0.2.
|
|
44
|
+
program.name("diffprism").description("Local-first code review tool for agent-generated changes").version(true ? "0.2.14" : "0.0.0-dev");
|
|
45
45
|
program.command("review [ref]").description("Open a browser-based diff review").option("--staged", "Review staged changes").option("--unstaged", "Review unstaged changes").option("-t, --title <title>", "Review title").action(review);
|
|
46
46
|
program.command("serve").description("Start the MCP server for Claude Code integration").action(serve);
|
|
47
47
|
program.parse();
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
// packages/core/src/pipeline.ts
|
|
2
2
|
import http from "http";
|
|
3
3
|
import fs from "fs";
|
|
4
|
-
import
|
|
4
|
+
import path3 from "path";
|
|
5
5
|
import getPort from "get-port";
|
|
6
6
|
import open from "open";
|
|
7
7
|
import { fileURLToPath } from "url";
|
|
8
8
|
|
|
9
9
|
// packages/git/src/local.ts
|
|
10
10
|
import { execSync } from "child_process";
|
|
11
|
+
import { readFileSync } from "fs";
|
|
12
|
+
import path from "path";
|
|
11
13
|
function getGitDiff(ref, options) {
|
|
12
14
|
const cwd = options?.cwd ?? process.cwd();
|
|
13
15
|
try {
|
|
@@ -25,36 +27,85 @@ function getGitDiff(ref, options) {
|
|
|
25
27
|
);
|
|
26
28
|
}
|
|
27
29
|
let command;
|
|
30
|
+
let includeUntracked = false;
|
|
28
31
|
switch (ref) {
|
|
29
32
|
case "staged":
|
|
30
33
|
command = "git diff --staged --no-color";
|
|
31
34
|
break;
|
|
32
35
|
case "unstaged":
|
|
33
36
|
command = "git diff --no-color";
|
|
37
|
+
includeUntracked = true;
|
|
34
38
|
break;
|
|
35
39
|
case "all":
|
|
36
40
|
command = "git diff HEAD --no-color";
|
|
41
|
+
includeUntracked = true;
|
|
37
42
|
break;
|
|
38
43
|
default:
|
|
39
44
|
command = `git diff --no-color ${ref}`;
|
|
40
45
|
break;
|
|
41
46
|
}
|
|
47
|
+
let output;
|
|
42
48
|
try {
|
|
43
|
-
|
|
49
|
+
output = execSync(command, {
|
|
44
50
|
cwd,
|
|
45
51
|
encoding: "utf-8",
|
|
46
52
|
maxBuffer: 50 * 1024 * 1024
|
|
47
53
|
// 50 MB
|
|
48
54
|
});
|
|
49
|
-
return output;
|
|
50
55
|
} catch (err) {
|
|
51
56
|
const message = err instanceof Error ? err.message : String(err);
|
|
52
57
|
throw new Error(`git diff failed: ${message}`);
|
|
53
58
|
}
|
|
59
|
+
if (includeUntracked) {
|
|
60
|
+
output += getUntrackedDiffs(cwd);
|
|
61
|
+
}
|
|
62
|
+
return output;
|
|
63
|
+
}
|
|
64
|
+
function getUntrackedDiffs(cwd) {
|
|
65
|
+
let untrackedList;
|
|
66
|
+
try {
|
|
67
|
+
untrackedList = execSync(
|
|
68
|
+
"git ls-files --others --exclude-standard",
|
|
69
|
+
{ cwd, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }
|
|
70
|
+
).trim();
|
|
71
|
+
} catch {
|
|
72
|
+
return "";
|
|
73
|
+
}
|
|
74
|
+
if (!untrackedList) return "";
|
|
75
|
+
const files = untrackedList.split("\n");
|
|
76
|
+
let result = "";
|
|
77
|
+
for (const file of files) {
|
|
78
|
+
const absPath = path.resolve(cwd, file);
|
|
79
|
+
let content;
|
|
80
|
+
try {
|
|
81
|
+
content = readFileSync(absPath, "utf-8");
|
|
82
|
+
} catch {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
const lines = content.split("\n");
|
|
86
|
+
const hasTrailingNewline = content.length > 0 && content[content.length - 1] === "\n";
|
|
87
|
+
const contentLines = hasTrailingNewline ? lines.slice(0, -1) : lines;
|
|
88
|
+
result += `diff --git a/${file} b/${file}
|
|
89
|
+
`;
|
|
90
|
+
result += "new file mode 100644\n";
|
|
91
|
+
result += "--- /dev/null\n";
|
|
92
|
+
result += `+++ b/${file}
|
|
93
|
+
`;
|
|
94
|
+
result += `@@ -0,0 +1,${contentLines.length} @@
|
|
95
|
+
`;
|
|
96
|
+
for (const line of contentLines) {
|
|
97
|
+
result += `+${line}
|
|
98
|
+
`;
|
|
99
|
+
}
|
|
100
|
+
if (!hasTrailingNewline) {
|
|
101
|
+
result += "\\n";
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return result;
|
|
54
105
|
}
|
|
55
106
|
|
|
56
107
|
// packages/git/src/parser.ts
|
|
57
|
-
import
|
|
108
|
+
import path2 from "path";
|
|
58
109
|
var EXTENSION_MAP = {
|
|
59
110
|
ts: "typescript",
|
|
60
111
|
tsx: "typescript",
|
|
@@ -88,7 +139,7 @@ var FILENAME_MAP = {
|
|
|
88
139
|
Makefile: "makefile"
|
|
89
140
|
};
|
|
90
141
|
function detectLanguage(filePath) {
|
|
91
|
-
const basename =
|
|
142
|
+
const basename = path2.basename(filePath);
|
|
92
143
|
if (FILENAME_MAP[basename]) {
|
|
93
144
|
return FILENAME_MAP[basename];
|
|
94
145
|
}
|
|
@@ -506,14 +557,14 @@ var MIME_TYPES = {
|
|
|
506
557
|
};
|
|
507
558
|
function resolveUiDist() {
|
|
508
559
|
const thisFile = fileURLToPath(import.meta.url);
|
|
509
|
-
const thisDir =
|
|
510
|
-
const publishedUiDist =
|
|
511
|
-
if (fs.existsSync(
|
|
560
|
+
const thisDir = path3.dirname(thisFile);
|
|
561
|
+
const publishedUiDist = path3.resolve(thisDir, "..", "ui-dist");
|
|
562
|
+
if (fs.existsSync(path3.join(publishedUiDist, "index.html"))) {
|
|
512
563
|
return publishedUiDist;
|
|
513
564
|
}
|
|
514
|
-
const workspaceRoot =
|
|
515
|
-
const devUiDist =
|
|
516
|
-
if (fs.existsSync(
|
|
565
|
+
const workspaceRoot = path3.resolve(thisDir, "..", "..", "..");
|
|
566
|
+
const devUiDist = path3.join(workspaceRoot, "packages", "ui", "dist");
|
|
567
|
+
if (fs.existsSync(path3.join(devUiDist, "index.html"))) {
|
|
517
568
|
return devUiDist;
|
|
518
569
|
}
|
|
519
570
|
throw new Error(
|
|
@@ -523,11 +574,11 @@ function resolveUiDist() {
|
|
|
523
574
|
function createStaticServer(distPath, port) {
|
|
524
575
|
const server = http.createServer((req, res) => {
|
|
525
576
|
const urlPath = req.url?.split("?")[0] ?? "/";
|
|
526
|
-
let filePath =
|
|
577
|
+
let filePath = path3.join(distPath, urlPath === "/" ? "index.html" : urlPath);
|
|
527
578
|
if (!fs.existsSync(filePath)) {
|
|
528
|
-
filePath =
|
|
579
|
+
filePath = path3.join(distPath, "index.html");
|
|
529
580
|
}
|
|
530
|
-
const ext =
|
|
581
|
+
const ext = path3.extname(filePath);
|
|
531
582
|
const contentType = MIME_TYPES[ext] ?? "application/octet-stream";
|
|
532
583
|
try {
|
|
533
584
|
const content = fs.readFileSync(filePath);
|
package/dist/mcp-server.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
startReview
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-WTTAKQX3.js";
|
|
4
4
|
|
|
5
5
|
// packages/mcp-server/src/index.ts
|
|
6
6
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
@@ -9,7 +9,7 @@ import { z } from "zod";
|
|
|
9
9
|
async function startMcpServer() {
|
|
10
10
|
const server = new McpServer({
|
|
11
11
|
name: "diffprism",
|
|
12
|
-
version: true ? "0.2.
|
|
12
|
+
version: true ? "0.2.14" : "0.0.0-dev"
|
|
13
13
|
});
|
|
14
14
|
server.tool(
|
|
15
15
|
"open_review",
|