diffprism 0.2.0
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 +124 -0
- package/dist/bin.js +47 -0
- package/dist/chunk-AUPKNXCS.js +597 -0
- package/dist/mcp-server.js +63 -0
- package/package.json +41 -0
- package/ui-dist/assets/index-Bs9RqYMb.css +1 -0
- package/ui-dist/assets/index-D1OHLP8P.js +134 -0
- package/ui-dist/index.html +13 -0
package/README.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# DiffPrism
|
|
2
|
+
|
|
3
|
+
Local-first code review tool for agent-generated code changes. Opens a browser-based diff viewer from the CLI or Claude Code (via MCP).
|
|
4
|
+
|
|
5
|
+
DiffPrism gives you a visual review step for AI-written code — stage your changes, run the tool, and a browser window opens with a syntax-highlighted diff viewer. Approve or request changes, and the result is returned as structured JSON.
|
|
6
|
+
|
|
7
|
+
## Quick Start
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Clone and install
|
|
11
|
+
git clone <repo-url> && cd diffprism
|
|
12
|
+
pnpm install
|
|
13
|
+
|
|
14
|
+
# Review staged changes
|
|
15
|
+
pnpm cli review --staged
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
A browser window opens with the diff viewer. Click **Approve** or **Request Changes**, and the result prints to stdout as JSON.
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
### CLI
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Review staged changes (default)
|
|
26
|
+
pnpm cli review
|
|
27
|
+
pnpm cli review --staged
|
|
28
|
+
|
|
29
|
+
# Review unstaged changes
|
|
30
|
+
pnpm cli review --unstaged
|
|
31
|
+
|
|
32
|
+
# Review a specific ref range
|
|
33
|
+
pnpm cli review HEAD~3
|
|
34
|
+
pnpm cli review main..feature-branch
|
|
35
|
+
|
|
36
|
+
# Add a title to the review
|
|
37
|
+
pnpm cli review --staged --title "Add auth middleware"
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Output:** A `ReviewResult` JSON object:
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"decision": "approved",
|
|
45
|
+
"comments": [],
|
|
46
|
+
"summary": ""
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Decisions are one of: `approved`, `changes_requested`, or `approved_with_comments`.
|
|
51
|
+
|
|
52
|
+
### Claude Code (MCP)
|
|
53
|
+
|
|
54
|
+
DiffPrism ships an MCP server so Claude Code can open reviews during a coding session.
|
|
55
|
+
|
|
56
|
+
**Setup:** Add to your Claude Code MCP config (`.mcp.json` or project settings):
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"mcpServers": {
|
|
61
|
+
"diffprism": {
|
|
62
|
+
"command": "npx",
|
|
63
|
+
"args": ["diffprism", "serve"]
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Tool:** `open_review`
|
|
70
|
+
|
|
71
|
+
| Parameter | Required | Description |
|
|
72
|
+
|---------------|----------|--------------------------------------|
|
|
73
|
+
| `diff_ref` | yes | Git diff reference: `"staged"`, `"unstaged"`, or a ref range |
|
|
74
|
+
| `title` | no | Title shown in the review UI |
|
|
75
|
+
| `description` | no | Description of the changes |
|
|
76
|
+
| `reasoning` | no | Agent reasoning about why changes were made |
|
|
77
|
+
|
|
78
|
+
The tool opens a browser, blocks until you submit a review, and returns the `ReviewResult` to Claude Code.
|
|
79
|
+
|
|
80
|
+
**Auto-approve the tool:** By default Claude Code prompts for confirmation each time. To skip that, add `mcp__diffprism__open_review` to the `permissions.allow` array in your project's `.claude/settings.json` or your user-level `~/.claude/settings.json`:
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"permissions": {
|
|
85
|
+
"allow": [
|
|
86
|
+
"mcp__diffprism__open_review"
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## How It Works
|
|
93
|
+
|
|
94
|
+
1. **Extract** — runs `git diff` and parses the output into a structured `DiffSet`
|
|
95
|
+
2. **Analyze** — generates a `ReviewBriefing` with file stats, impact detection, and triage
|
|
96
|
+
3. **Serve** — starts a Vite dev server (React UI) and WebSocket bridge on random ports
|
|
97
|
+
4. **Review** — opens a browser to the diff viewer, waits for your decision
|
|
98
|
+
5. **Return** — cleans up servers and returns the `ReviewResult`
|
|
99
|
+
|
|
100
|
+
## Development
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
pnpm install # Install all deps
|
|
104
|
+
pnpm test # Run all tests (Vitest)
|
|
105
|
+
npx tsc --noEmit -p packages/core/tsconfig.json # Type-check a package
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Project Structure
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
packages/core — Shared types, pipeline orchestrator, WebSocket bridge
|
|
112
|
+
packages/git — Git diff extraction + unified diff parser
|
|
113
|
+
packages/analysis — Deterministic review briefing generation
|
|
114
|
+
packages/ui — React 19 + Vite + Tailwind diff viewer
|
|
115
|
+
packages/mcp-server — MCP tool server (open_review)
|
|
116
|
+
packages/github — Placeholder (future GitHub integration)
|
|
117
|
+
cli/ — Commander CLI entry point
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Requirements
|
|
121
|
+
|
|
122
|
+
- Node.js >= 20
|
|
123
|
+
- pnpm
|
|
124
|
+
- Git
|
package/dist/bin.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
startReview
|
|
4
|
+
} from "./chunk-AUPKNXCS.js";
|
|
5
|
+
|
|
6
|
+
// cli/src/index.ts
|
|
7
|
+
import { Command } from "commander";
|
|
8
|
+
|
|
9
|
+
// cli/src/commands/review.ts
|
|
10
|
+
async function review(ref, flags) {
|
|
11
|
+
let diffRef;
|
|
12
|
+
if (flags.staged) {
|
|
13
|
+
diffRef = "staged";
|
|
14
|
+
} else if (flags.unstaged) {
|
|
15
|
+
diffRef = "unstaged";
|
|
16
|
+
} else if (ref) {
|
|
17
|
+
diffRef = ref;
|
|
18
|
+
} else {
|
|
19
|
+
diffRef = "staged";
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
const result = await startReview({
|
|
23
|
+
diffRef,
|
|
24
|
+
title: flags.title,
|
|
25
|
+
cwd: process.cwd()
|
|
26
|
+
});
|
|
27
|
+
console.log(JSON.stringify(result, null, 2));
|
|
28
|
+
process.exit(0);
|
|
29
|
+
} catch (err) {
|
|
30
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
31
|
+
console.error(`Error: ${message}`);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// cli/src/commands/serve.ts
|
|
37
|
+
async function serve() {
|
|
38
|
+
const { startMcpServer } = await import("./mcp-server.js");
|
|
39
|
+
await startMcpServer();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// cli/src/index.ts
|
|
43
|
+
var program = new Command();
|
|
44
|
+
program.name("diffprism").description("Local-first code review tool for agent-generated changes").version("0.0.1");
|
|
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
|
+
program.command("serve").description("Start the MCP server for Claude Code integration").action(serve);
|
|
47
|
+
program.parse();
|