diffprism 0.41.0 → 0.42.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/dist/bin.js CHANGED
@@ -11,14 +11,14 @@ import {
11
11
  } from "./chunk-6J6PSBL2.js";
12
12
  import {
13
13
  demo
14
- } from "./chunk-HEJVY4S7.js";
14
+ } from "./chunk-M6OLXP7N.js";
15
15
  import {
16
16
  ensureServer,
17
17
  isServerAlive,
18
18
  readServerFile,
19
19
  startGlobalServer,
20
20
  submitReviewToServer
21
- } from "./chunk-7UMTB6LW.js";
21
+ } from "./chunk-YOYRCD2I.js";
22
22
  import "./chunk-QGWYCEJN.js";
23
23
  import "./chunk-DHCVZGHE.js";
24
24
  import "./chunk-JSBRDJBE.js";
@@ -379,7 +379,7 @@ async function setupInteractive(flags) {
379
379
  }
380
380
  async function runDemo(dev) {
381
381
  console.log("");
382
- const { demo: demo2 } = await import("./demo-UIN5MTWR.js");
382
+ const { demo: demo2 } = await import("./demo-KXU664AH.js");
383
383
  await demo2({ dev });
384
384
  }
385
385
  async function setupBatch(flags) {
@@ -822,7 +822,7 @@ async function fetchStatus(httpPort) {
822
822
  return await response.json();
823
823
  }
824
824
  function printStatus(status, httpPort) {
825
- const version = true ? "0.41.0" : "0.0.0-dev";
825
+ const version = true ? "0.42.0" : "0.0.0-dev";
826
826
  console.log(`
827
827
  DiffPrism v${version}
828
828
  `);
@@ -862,7 +862,7 @@ async function defaultAction() {
862
862
 
863
863
  // cli/src/index.ts
864
864
  var program = new Command();
865
- program.name("diffprism").description("Local-first code review tool for agent-generated changes").version(true ? "0.41.0" : "0.0.0-dev");
865
+ program.name("diffprism").description("Local-first code review tool for agent-generated changes").version(true ? "0.42.0" : "0.0.0-dev");
866
866
  program.action(defaultAction);
867
867
  program.command("demo").description("Open a sample review to see DiffPrism in action").option("--dev", "Use Vite dev server").action(demo);
868
868
  program.command("review [ref]").description("Open a browser-based diff review (local git ref or GitHub PR ref like owner/repo#123)").option("--staged", "Review staged changes").option("--unstaged", "Review unstaged changes").option("-t, --title <title>", "Review title").option("--reasoning <text>", "Agent reasoning about the changes").option("--dev", "Use Vite dev server with HMR instead of static files").option("--post-to-github", "Automatically post review back to GitHub without prompting").action(review);
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ensureServer,
3
3
  submitReviewToServer
4
- } from "./chunk-7UMTB6LW.js";
4
+ } from "./chunk-YOYRCD2I.js";
5
5
  import {
6
6
  parseDiff
7
7
  } from "./chunk-QGWYCEJN.js";
@@ -355,6 +355,7 @@ import { randomUUID as randomUUID2 } from "crypto";
355
355
  import getPort from "get-port";
356
356
  import open from "open";
357
357
  import { WebSocketServer, WebSocket } from "ws";
358
+ import fs5 from "fs";
358
359
 
359
360
  // packages/core/src/ui-server.ts
360
361
  import http from "http";
@@ -504,7 +505,8 @@ function toSummary(session) {
504
505
  status: session.status,
505
506
  decision: session.result?.decision,
506
507
  createdAt: session.createdAt,
507
- hasNewChanges: session.hasNewChanges
508
+ hasNewChanges: session.hasNewChanges,
509
+ source: session.source
508
510
  };
509
511
  }
510
512
  function readBody(req) {
@@ -686,7 +688,8 @@ async function handleApiRequest(req, res) {
686
688
  pid: process.pid,
687
689
  sessions: sessions.size,
688
690
  uptime: process.uptime(),
689
- uiUrl: serverUiUrl
691
+ uiUrl: serverUiUrl,
692
+ cwd: process.cwd()
690
693
  });
691
694
  return true;
692
695
  }
@@ -696,7 +699,7 @@ async function handleApiRequest(req, res) {
696
699
  const { payload, projectPath, diffRef } = JSON.parse(body);
697
700
  let existingSession;
698
701
  for (const session of sessions.values()) {
699
- if (session.projectPath === projectPath) {
702
+ if (session.projectPath === projectPath && session.source === "agent") {
700
703
  existingSession = session;
701
704
  break;
702
705
  }
@@ -739,6 +742,7 @@ async function handleApiRequest(req, res) {
739
742
  id: sessionId,
740
743
  payload,
741
744
  projectPath,
745
+ source: "agent",
742
746
  status: "pending",
743
747
  createdAt: Date.now(),
744
748
  result: null,
@@ -764,6 +768,79 @@ async function handleApiRequest(req, res) {
764
768
  }
765
769
  return true;
766
770
  }
771
+ if (method === "POST" && url === "/api/projects/open") {
772
+ try {
773
+ const body = await readBody(req);
774
+ const { projectPath, diffRef = "working-copy" } = JSON.parse(body);
775
+ if (!projectPath) {
776
+ jsonResponse(res, 400, { error: "Missing projectPath" });
777
+ return true;
778
+ }
779
+ try {
780
+ const stat = fs5.statSync(projectPath);
781
+ if (!stat.isDirectory()) {
782
+ jsonResponse(res, 400, { error: "Path is not a directory" });
783
+ return true;
784
+ }
785
+ } catch {
786
+ jsonResponse(res, 400, { error: "Path does not exist" });
787
+ return true;
788
+ }
789
+ let diffResult;
790
+ try {
791
+ diffResult = getDiff(diffRef, { cwd: projectPath });
792
+ } catch (err) {
793
+ jsonResponse(res, 400, {
794
+ error: err instanceof Error ? err.message : "Not a git repository"
795
+ });
796
+ return true;
797
+ }
798
+ const { diffSet, rawDiff } = diffResult;
799
+ const briefing = analyze(diffSet);
800
+ let currentBranch;
801
+ try {
802
+ currentBranch = getCurrentBranch({ cwd: projectPath });
803
+ } catch {
804
+ }
805
+ const sessionId = `session-${randomUUID2().slice(0, 8)}`;
806
+ const projectName = projectPath.split("/").pop() || projectPath;
807
+ const payload = {
808
+ reviewId: sessionId,
809
+ diffSet,
810
+ rawDiff,
811
+ briefing,
812
+ metadata: {
813
+ title: projectName,
814
+ currentBranch
815
+ },
816
+ watchMode: true
817
+ };
818
+ const session = {
819
+ id: sessionId,
820
+ payload,
821
+ projectPath,
822
+ source: "manual",
823
+ status: "pending",
824
+ createdAt: Date.now(),
825
+ result: null,
826
+ diffRef,
827
+ lastDiffHash: hashDiff(rawDiff),
828
+ lastDiffSet: diffSet,
829
+ hasNewChanges: false,
830
+ annotations: []
831
+ };
832
+ sessions.set(sessionId, session);
833
+ startSessionWatcher(sessionId);
834
+ broadcastToAll({
835
+ type: "session:added",
836
+ payload: toSummary(session)
837
+ });
838
+ jsonResponse(res, 201, { sessionId, fileCount: diffSet.files.length });
839
+ } catch {
840
+ jsonResponse(res, 400, { error: "Invalid request body" });
841
+ }
842
+ return true;
843
+ }
767
844
  if (method === "GET" && url === "/api/reviews") {
768
845
  const summaries = Array.from(sessions.values()).map(toSummary);
769
846
  jsonResponse(res, 200, { sessions: summaries });
@@ -1216,6 +1293,9 @@ async function startGlobalServer(options = {}) {
1216
1293
  function cleanupExpiredSessions() {
1217
1294
  const now = Date.now();
1218
1295
  for (const [id, session] of sessions.entries()) {
1296
+ if (session.source === "manual" && session.status !== "submitted") {
1297
+ continue;
1298
+ }
1219
1299
  const age = now - session.createdAt;
1220
1300
  const expired = session.status === "submitted" && age > SUBMITTED_TTL_MS || session.status === "pending" && age > ABANDONED_TTL_MS;
1221
1301
  if (expired) {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  demo
3
- } from "./chunk-HEJVY4S7.js";
4
- import "./chunk-7UMTB6LW.js";
3
+ } from "./chunk-M6OLXP7N.js";
4
+ import "./chunk-YOYRCD2I.js";
5
5
  import "./chunk-QGWYCEJN.js";
6
6
  import "./chunk-DHCVZGHE.js";
7
7
  import "./chunk-JSBRDJBE.js";
@@ -12,7 +12,7 @@ import {
12
12
  ensureServer,
13
13
  isServerAlive,
14
14
  submitReviewToServer
15
- } from "./chunk-7UMTB6LW.js";
15
+ } from "./chunk-YOYRCD2I.js";
16
16
  import {
17
17
  getDiff
18
18
  } from "./chunk-QGWYCEJN.js";
@@ -152,7 +152,7 @@ async function handlePrReview(pr, options) {
152
152
  async function startMcpServer() {
153
153
  const server = new McpServer({
154
154
  name: "diffprism",
155
- version: true ? "0.41.0" : "0.0.0-dev"
155
+ version: true ? "0.42.0" : "0.0.0-dev"
156
156
  });
157
157
  server.tool(
158
158
  "open_review",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diffprism",
3
- "version": "0.41.0",
3
+ "version": "0.42.0",
4
4
  "type": "module",
5
5
  "description": "Local-first code review tool for agent-generated code changes",
6
6
  "bin": {