newpr 1.0.8 → 1.0.11
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/package.json
CHANGED
|
@@ -94,7 +94,7 @@ function MediaEmbed({ src }: { src: string }) {
|
|
|
94
94
|
);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
const ANCHOR_RE = /\[\[(group|file):(
|
|
97
|
+
const ANCHOR_RE = /\[\[(group|file):(.*?)\]\]/g;
|
|
98
98
|
|
|
99
99
|
const BOLD_CJK_RE = /\*\*(.+?)\*\*/g;
|
|
100
100
|
|
|
@@ -131,16 +131,14 @@ function replaceLineAnchors(text: string): string {
|
|
|
131
131
|
result += text.slice(i, start);
|
|
132
132
|
|
|
133
133
|
const idStart = start + OPEN.length;
|
|
134
|
-
const
|
|
135
|
-
if (
|
|
134
|
+
const closeBrackets = text.indexOf("]]", idStart);
|
|
135
|
+
if (closeBrackets === -1) {
|
|
136
136
|
result += text.slice(start);
|
|
137
137
|
break;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
const id = text.slice(idStart,
|
|
141
|
-
let afterClose =
|
|
142
|
-
|
|
143
|
-
if (text[afterClose] === "]") afterClose++;
|
|
140
|
+
const id = text.slice(idStart, closeBrackets);
|
|
141
|
+
let afterClose = closeBrackets + 2;
|
|
144
142
|
|
|
145
143
|
let label: string | null = null;
|
|
146
144
|
if (text[afterClose] === "(") {
|
|
@@ -157,8 +155,6 @@ function replaceLineAnchors(text: string): string {
|
|
|
157
155
|
}
|
|
158
156
|
}
|
|
159
157
|
|
|
160
|
-
if (text[afterClose] === "]") afterClose++;
|
|
161
|
-
|
|
162
158
|
const encoded = encodeURIComponent(id);
|
|
163
159
|
if (label) {
|
|
164
160
|
result += `<span data-line-ref="${encoded}">${inlineMarkdownToHtml(label)}</span>`;
|
package/src/web/server/routes.ts
CHANGED
|
@@ -953,9 +953,22 @@ Before posting an inline comment, ALWAYS call \`get_file_diff\` first to find th
|
|
|
953
953
|
const encoder = new TextEncoder();
|
|
954
954
|
const stream = new ReadableStream({
|
|
955
955
|
async start(controller) {
|
|
956
|
+
let closed = false;
|
|
956
957
|
const send = (eventType: string, data: string) => {
|
|
958
|
+
if (closed) return;
|
|
957
959
|
controller.enqueue(encoder.encode(`event: ${eventType}\ndata: ${data}\n\n`));
|
|
958
960
|
};
|
|
961
|
+
const safeClose = () => {
|
|
962
|
+
if (closed) return;
|
|
963
|
+
closed = true;
|
|
964
|
+
clearInterval(heartbeat);
|
|
965
|
+
setTimeout(() => { try { controller.close(); } catch {} }, 50);
|
|
966
|
+
};
|
|
967
|
+
const heartbeat = setInterval(() => {
|
|
968
|
+
if (closed) return;
|
|
969
|
+
try { controller.enqueue(encoder.encode(":keepalive\n\n")); } catch { safeClose(); }
|
|
970
|
+
}, 15_000);
|
|
971
|
+
|
|
959
972
|
try {
|
|
960
973
|
if (config.openrouter_api_key) {
|
|
961
974
|
await chatWithTools(
|
|
@@ -999,7 +1012,7 @@ Before posting an inline comment, ALWAYS call \`get_file_diff\` first to find th
|
|
|
999
1012
|
} catch (err) {
|
|
1000
1013
|
send("chat_error", JSON.stringify({ message: err instanceof Error ? err.message : String(err) }));
|
|
1001
1014
|
} finally {
|
|
1002
|
-
|
|
1015
|
+
safeClose();
|
|
1003
1016
|
}
|
|
1004
1017
|
},
|
|
1005
1018
|
});
|
|
@@ -1424,9 +1437,21 @@ Before posting an inline comment, ALWAYS call \`get_file_diff\` first to find th
|
|
|
1424
1437
|
const encoder = new TextEncoder();
|
|
1425
1438
|
const stream = new ReadableStream({
|
|
1426
1439
|
async start(controller) {
|
|
1440
|
+
let closed = false;
|
|
1427
1441
|
const send = (eventType: string, data: string) => {
|
|
1442
|
+
if (closed) return;
|
|
1428
1443
|
controller.enqueue(encoder.encode(`event: ${eventType}\ndata: ${data}\n\n`));
|
|
1429
1444
|
};
|
|
1445
|
+
const safeClose = () => {
|
|
1446
|
+
if (closed) return;
|
|
1447
|
+
closed = true;
|
|
1448
|
+
clearInterval(heartbeat);
|
|
1449
|
+
setTimeout(() => { try { controller.close(); } catch {} }, 50);
|
|
1450
|
+
};
|
|
1451
|
+
const heartbeat = setInterval(() => {
|
|
1452
|
+
if (closed) return;
|
|
1453
|
+
try { controller.enqueue(encoder.encode(":keepalive\n\n")); } catch { safeClose(); }
|
|
1454
|
+
}, 15_000);
|
|
1430
1455
|
|
|
1431
1456
|
let fullText = "";
|
|
1432
1457
|
const collectedToolCalls: ChatToolCall[] = [];
|
|
@@ -1526,7 +1551,7 @@ Before posting an inline comment, ALWAYS call \`get_file_diff\` first to find th
|
|
|
1526
1551
|
} catch (err) {
|
|
1527
1552
|
send("chat_error", JSON.stringify({ message: err instanceof Error ? err.message : String(err) }));
|
|
1528
1553
|
} finally {
|
|
1529
|
-
|
|
1554
|
+
safeClose();
|
|
1530
1555
|
}
|
|
1531
1556
|
},
|
|
1532
1557
|
});
|
package/src/web/server.ts
CHANGED
|
@@ -17,17 +17,30 @@ interface WebServerOptions {
|
|
|
17
17
|
|
|
18
18
|
function getCssPaths() {
|
|
19
19
|
const webDir = import.meta.dir;
|
|
20
|
-
|
|
20
|
+
|
|
21
|
+
let bin: string;
|
|
22
|
+
try {
|
|
23
|
+
const resolved = import.meta.resolve("@tailwindcss/cli/package.json");
|
|
24
|
+
const cliDir = resolved.replace(/^file:\/\//, "").replace(/\/package\.json$/, "");
|
|
25
|
+
bin = join(cliDir, "dist", "index.mjs");
|
|
26
|
+
} catch {
|
|
27
|
+
const packageRoot = join(webDir, "..", "..");
|
|
28
|
+
bin = join(packageRoot, "node_modules", ".bin", "tailwindcss");
|
|
29
|
+
}
|
|
30
|
+
|
|
21
31
|
return {
|
|
22
32
|
input: join(webDir, "styles", "globals.css"),
|
|
23
33
|
output: join(webDir, "styles", "built.css"),
|
|
24
|
-
bin
|
|
34
|
+
bin,
|
|
25
35
|
};
|
|
26
36
|
}
|
|
27
37
|
|
|
28
38
|
async function buildCss(bin: string, input: string, output: string): Promise<void> {
|
|
39
|
+
const args = bin.endsWith(".mjs") || bin.endsWith(".js")
|
|
40
|
+
? ["bun", bin, "-i", input, "-o", output, "--minify"]
|
|
41
|
+
: [bin, "-i", input, "-o", output, "--minify"];
|
|
29
42
|
const proc = Bun.spawn(
|
|
30
|
-
|
|
43
|
+
args,
|
|
31
44
|
{ cwd: process.cwd(), stderr: "pipe", stdout: "pipe" },
|
|
32
45
|
);
|
|
33
46
|
const exitCode = await proc.exited;
|