chatccc 0.2.86 → 0.2.88
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 +1 -1
- package/src/adapters/cursor-adapter.ts +12 -3
- package/src/session.ts +1 -2
package/package.json
CHANGED
|
@@ -268,11 +268,13 @@ function spawnAgent(
|
|
|
268
268
|
shell: true,
|
|
269
269
|
});
|
|
270
270
|
|
|
271
|
+
console.log(`[Cursor debug] spawn: cmd=${CURSOR_AGENT_COMMAND}, args=[${allArgs.join(", ")}], cwd=${cwd ?? "(none)"}, stdinLen=${stdinText?.length ?? 0}, pid=${proc.pid}`);
|
|
272
|
+
|
|
271
273
|
// 收集 stderr,子进程异常退出时输出到日志,方便排查静默失败
|
|
272
274
|
let stderr = "";
|
|
273
275
|
proc.stderr!.on("data", (chunk: Buffer) => { stderr += chunk.toString(); });
|
|
274
276
|
proc.on("close", (code) => {
|
|
275
|
-
if (
|
|
277
|
+
if (stderr.trim()) {
|
|
276
278
|
console.error(`[Cursor stderr] exit=${code}: ${stderr.trim().slice(0, 2000)}`);
|
|
277
279
|
}
|
|
278
280
|
});
|
|
@@ -287,14 +289,18 @@ function spawnAgent(
|
|
|
287
289
|
async function* readJsonLines(
|
|
288
290
|
proc: ChildProcess,
|
|
289
291
|
signal?: AbortSignal,
|
|
292
|
+
debugTag?: string,
|
|
290
293
|
): AsyncGenerator<CursorMessageLine> {
|
|
294
|
+
const tag = debugTag ?? "cursor";
|
|
291
295
|
const rl = createInterface({ input: proc.stdout!, crlfDelay: Infinity });
|
|
292
296
|
// abort 时主动 close readline,避免等待 Windows 管道自然关闭(可能延迟数分钟)
|
|
293
297
|
const onAbort = () => { rl.close(); };
|
|
294
298
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
299
|
+
let lineCount = 0;
|
|
295
300
|
try {
|
|
296
301
|
for await (const line of rl) {
|
|
297
302
|
if (signal?.aborted) break;
|
|
303
|
+
lineCount++;
|
|
298
304
|
const trimmed = line.trim();
|
|
299
305
|
if (!trimmed) continue;
|
|
300
306
|
try {
|
|
@@ -304,6 +310,7 @@ async function* readJsonLines(
|
|
|
304
310
|
} finally {
|
|
305
311
|
signal?.removeEventListener("abort", onAbort);
|
|
306
312
|
rl.close();
|
|
313
|
+
console.log(`[Cursor debug] ${tag} readJsonLines done: ${lineCount} raw lines, signalAborted=${signal?.aborted ?? false}`);
|
|
307
314
|
}
|
|
308
315
|
}
|
|
309
316
|
|
|
@@ -325,7 +332,7 @@ class CursorAdapter implements ToolAdapter {
|
|
|
325
332
|
const proc = spawnAgent(["ok"], cwd);
|
|
326
333
|
this.activeProcs.add(proc);
|
|
327
334
|
|
|
328
|
-
for await (const msg of readJsonLines(proc)) {
|
|
335
|
+
for await (const msg of readJsonLines(proc, undefined, "createSession")) {
|
|
329
336
|
if (msg.type === "system" && msg.subtype === "init" && msg.session_id) {
|
|
330
337
|
const sessionId = msg.session_id;
|
|
331
338
|
await this.metaStore
|
|
@@ -348,6 +355,7 @@ class CursorAdapter implements ToolAdapter {
|
|
|
348
355
|
cwd: string,
|
|
349
356
|
signal?: AbortSignal,
|
|
350
357
|
): AsyncIterable<UnifiedStreamMessage> {
|
|
358
|
+
console.log(`[Cursor debug] prompt start: sessionId=${sessionId}, cwd=${cwd}, userTextLen=${userText.length}`);
|
|
351
359
|
const proc = spawnAgent(["--resume", sessionId], cwd, userText);
|
|
352
360
|
this.activeProcs.add(proc);
|
|
353
361
|
|
|
@@ -357,7 +365,7 @@ class CursorAdapter implements ToolAdapter {
|
|
|
357
365
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
358
366
|
|
|
359
367
|
try {
|
|
360
|
-
for await (const raw of readJsonLines(proc, signal)) {
|
|
368
|
+
for await (const raw of readJsonLines(proc, signal, sessionId)) {
|
|
361
369
|
if (signal?.aborted) break;
|
|
362
370
|
if (
|
|
363
371
|
raw.type === "system" &&
|
|
@@ -376,6 +384,7 @@ class CursorAdapter implements ToolAdapter {
|
|
|
376
384
|
signal?.removeEventListener("abort", onAbort);
|
|
377
385
|
await killProcessTree(proc.pid);
|
|
378
386
|
this.activeProcs.delete(proc);
|
|
387
|
+
console.log(`[Cursor debug] prompt end: sessionId=${sessionId}, signalAborted=${signal?.aborted ?? false}`);
|
|
379
388
|
}
|
|
380
389
|
}
|
|
381
390
|
|
package/src/session.ts
CHANGED
|
@@ -1159,8 +1159,7 @@ export function ensureDisplayLoop(sessionId: string): void {
|
|
|
1159
1159
|
display.cardBusy = true;
|
|
1160
1160
|
try {
|
|
1161
1161
|
const oldSeqBase = display.sequence;
|
|
1162
|
-
const
|
|
1163
|
-
const oldCard = buildProgressCard(oldDisplayContent, { showStop: false, headerTitle: "生成中...(上轮)" });
|
|
1162
|
+
const oldCard = buildProgressCard("", { showStop: false, headerTitle: "完成" });
|
|
1164
1163
|
await p.cardUpdate(display.cardId, oldCard, oldSeqBase + 1).catch(() => {});
|
|
1165
1164
|
const newCardId = await p.cardCreate(buildProgressCard(
|
|
1166
1165
|
"",
|