@xevy/cli 0.1.13 → 0.1.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/README.md +4 -0
- package/bin/dev-session.mjs +51 -64
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -154,6 +154,10 @@ Session, or starts one from a linked repository. When several accessible tasks
|
|
|
154
154
|
share a code, or a project has several linked repositories, it presents
|
|
155
155
|
a numbered selector. It restores the recent conversation for the session branch
|
|
156
156
|
and attaches to an already-running agent turn instead of submitting a duplicate.
|
|
157
|
+
Use it like a normal coding-agent conversation: ask questions, inspect the
|
|
158
|
+
workspace, or request changes. Conversational and read-only turns do not create
|
|
159
|
+
empty commits. When a turn changes code, the server commits any remaining edits
|
|
160
|
+
and pushes the resumable Dev Session branch automatically.
|
|
157
161
|
|
|
158
162
|
`xevy dev` is a remote client. It does **not** install or run local Pi, clone the
|
|
159
163
|
repository, open a shell or PTY, use SSH, or invoke Docker. Ctrl+C, terminal EOF,
|
package/bin/dev-session.mjs
CHANGED
|
@@ -80,17 +80,17 @@ export function resolveDevConnection({
|
|
|
80
80
|
return { base, token };
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
export function redactSensitive(value, secrets = []) {
|
|
83
|
+
export function redactSensitive(value, secrets = [], maxLength = 2_000) {
|
|
84
84
|
let text = String(value ?? "");
|
|
85
85
|
for (const secret of secrets) {
|
|
86
86
|
if (!secret) continue;
|
|
87
87
|
text = text.split(String(secret)).join("[redacted]");
|
|
88
88
|
}
|
|
89
|
-
|
|
89
|
+
text = text
|
|
90
90
|
.replace(/xevy_pk_[A-Za-z0-9._~-]+/g, "xevy_pk_[redacted]")
|
|
91
91
|
.replace(/(bearer\s+)[A-Za-z0-9._~+\/-]+/gi, "$1[redacted]")
|
|
92
|
-
.replace(/([?&](?:access_token|token|ticket|capability|launch_ticket)=)[^&#\s]+/gi, "$1[redacted]")
|
|
93
|
-
|
|
92
|
+
.replace(/([?&](?:access_token|token|ticket|capability|launch_ticket)=)[^&#\s]+/gi, "$1[redacted]");
|
|
93
|
+
return maxLength == null ? text : text.slice(0, maxLength);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
export function createSseDecoder(onEvent) {
|
|
@@ -296,7 +296,14 @@ function messageText(message) {
|
|
|
296
296
|
return typeof message?.content === "string" ? message.content.trim() : "";
|
|
297
297
|
}
|
|
298
298
|
|
|
299
|
-
function
|
|
299
|
+
function renderChatBlock(role, text, writeLine) {
|
|
300
|
+
writeLine("");
|
|
301
|
+
writeLine(role === "user" ? "you" : "xevy");
|
|
302
|
+
writeLine(text);
|
|
303
|
+
writeLine("");
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function renderPersistedMessage(message, state, writeLine, { showUser = true } = {}) {
|
|
300
307
|
if (!message || (message.id && state.messageIds.has(message.id))) return;
|
|
301
308
|
if (message.id) state.messageIds.add(message.id);
|
|
302
309
|
const text = messageText(message);
|
|
@@ -305,72 +312,53 @@ function renderPersistedMessage(message, state, writeLine) {
|
|
|
305
312
|
state.currentExecutionAssistantSeen = true;
|
|
306
313
|
state.pendingAssistantText = "";
|
|
307
314
|
}
|
|
308
|
-
if (message.role === "
|
|
309
|
-
|
|
310
|
-
const remaining = state.liveToolMessageBudget.get(key) || 0;
|
|
311
|
-
if (remaining > 0) {
|
|
312
|
-
if (remaining === 1) state.liveToolMessageBudget.delete(key);
|
|
313
|
-
else state.liveToolMessageBudget.set(key, remaining - 1);
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
if (message.role === "user") writeLine(`you> ${text}`);
|
|
318
|
-
else if (message.role === "assistant") writeLine(`xevy> ${text}`);
|
|
319
|
-
else if (message.role === "thinking") writeLine(`thinking> ${text}`);
|
|
320
|
-
else if (message.role === "tool_call") {
|
|
321
|
-
writeLine(`tool> ${message.toolName || "tool"}${text ? ` — ${text}` : ""}`);
|
|
322
|
-
} else if (message.role === "tool_result") {
|
|
323
|
-
writeLine(`tool result> ${message.toolName || "tool"}${text ? ` — ${text}` : ""}`);
|
|
324
|
-
} else if (message.role === "system" && text) writeLine(`system> ${text}`);
|
|
315
|
+
if (message.role === "user" && showUser) renderChatBlock("user", text, writeLine);
|
|
316
|
+
else if (message.role === "assistant") renderChatBlock("assistant", text, writeLine);
|
|
325
317
|
}
|
|
326
318
|
|
|
327
319
|
function renderStreamEvent(eventName, payload, state, writeLine, secrets) {
|
|
328
320
|
const event = payload && typeof payload === "object" ? payload : {};
|
|
329
321
|
const type = event.type || eventName;
|
|
330
322
|
if (type === "message" && event.message) {
|
|
331
|
-
renderPersistedMessage(event.message, state, writeLine);
|
|
323
|
+
renderPersistedMessage(event.message, state, writeLine, { showUser: false });
|
|
332
324
|
return;
|
|
333
325
|
}
|
|
334
326
|
// Persisted message events are the authoritative text. Ignoring deltas avoids
|
|
335
327
|
// printing the same assistant answer again during post-stream reconciliation.
|
|
336
328
|
if (type === "text_delta") {
|
|
337
|
-
|
|
329
|
+
// Only final-answer deltas are eligible for the last-resort fallback. Pi's
|
|
330
|
+
// reasoning/thinking stream must never be rendered as user-facing chat.
|
|
331
|
+
if (event.kind === "assistant" && typeof event.text === "string") {
|
|
332
|
+
state.pendingAssistantText += event.text;
|
|
333
|
+
}
|
|
338
334
|
return;
|
|
339
335
|
}
|
|
340
336
|
if (type === "usage" || type === "heartbeat" || type === "end") return;
|
|
341
337
|
if (type === "tool_start") {
|
|
342
|
-
const streamKey = `tool_start:${event.toolName || "tool"}:${event.summary || ""}`;
|
|
343
|
-
if (state.
|
|
344
|
-
state.
|
|
345
|
-
|
|
346
|
-
state.liveToolMessageBudget.set(messageKey, (state.liveToolMessageBudget.get(messageKey) || 0) + 1);
|
|
347
|
-
writeLine(`tool> ${event.toolName || "tool"}${event.summary ? ` — ${redactSensitive(event.summary, secrets)}` : ""}`);
|
|
338
|
+
const streamKey = `tool_start:${event.toolCallId || event.id || ""}:${event.toolName || "tool"}:${event.summary || ""}`;
|
|
339
|
+
if (state.toolStreamKeys.has(streamKey)) return;
|
|
340
|
+
state.toolStreamKeys.add(streamKey);
|
|
341
|
+
writeLine(` ↳ ${event.toolName || "tool"}${event.summary ? ` · ${redactSensitive(event.summary, secrets)}` : ""}`);
|
|
348
342
|
return;
|
|
349
343
|
}
|
|
350
344
|
if (type === "tool_end") {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
state.
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
writeLine(`tool ${event.ok === false ? "failed" : "done"}> ${event.toolName || "tool"}${event.summary ? ` — ${redactSensitive(event.summary, secrets)}` : ""}`);
|
|
345
|
+
if (event.ok !== false) return;
|
|
346
|
+
const streamKey = `tool_end:${event.toolCallId || event.id || ""}:${event.toolName || "tool"}:${event.summary || ""}`;
|
|
347
|
+
if (state.toolStreamKeys.has(streamKey)) return;
|
|
348
|
+
state.toolStreamKeys.add(streamKey);
|
|
349
|
+
writeLine(` × ${event.toolName || "tool"} failed${event.summary ? ` · ${redactSensitive(event.summary, secrets)}` : ""}`);
|
|
357
350
|
return;
|
|
358
351
|
}
|
|
359
352
|
if (type === "status" || eventName === "snapshot") {
|
|
360
353
|
const status = event.status;
|
|
361
354
|
if (status && status !== state.lastExecutionStatus) {
|
|
362
355
|
state.lastExecutionStatus = status;
|
|
363
|
-
|
|
356
|
+
if (status === "running") writeLine("Working…");
|
|
364
357
|
}
|
|
365
358
|
return;
|
|
366
359
|
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
.split(/\r?\n/)
|
|
370
|
-
.map((line) => line.trim())
|
|
371
|
-
.filter((line) => line.startsWith("[server]") || line.startsWith("[toolbox]"));
|
|
372
|
-
for (const line of safeLines) writeLine(redactSensitive(line, secrets));
|
|
373
|
-
}
|
|
360
|
+
// Raw server/toolbox chunks are operational logs, not chat. They remain
|
|
361
|
+
// available through /logs instead of interrupting the assistant response.
|
|
374
362
|
}
|
|
375
363
|
|
|
376
364
|
async function consumeExecutionStream({ api, taskId, executionId, state, writeLine, secrets, signal }) {
|
|
@@ -419,7 +407,7 @@ async function reconcileExecution({ api, taskId, executionId, state, writeLine }
|
|
|
419
407
|
api.request(`/api/tasks/${encodeURIComponent(taskId)}/ai/executions/${encodeURIComponent(executionId)}/messages`),
|
|
420
408
|
]);
|
|
421
409
|
for (const message of messageResult?.messages || []) {
|
|
422
|
-
renderPersistedMessage(message, state, writeLine);
|
|
410
|
+
renderPersistedMessage(message, state, writeLine, { showUser: false });
|
|
423
411
|
}
|
|
424
412
|
return { execution, messageCount: (messageResult?.messages || []).length };
|
|
425
413
|
}
|
|
@@ -436,8 +424,8 @@ async function followExecution({
|
|
|
436
424
|
}) {
|
|
437
425
|
state.pendingAssistantText = "";
|
|
438
426
|
state.currentExecutionAssistantSeen = false;
|
|
439
|
-
state.
|
|
440
|
-
state.
|
|
427
|
+
state.lastExecutionStatus = null;
|
|
428
|
+
state.toolStreamKeys.clear();
|
|
441
429
|
let reconnects = 0;
|
|
442
430
|
while (true) {
|
|
443
431
|
let streamError = null;
|
|
@@ -476,7 +464,7 @@ async function followExecution({
|
|
|
476
464
|
}
|
|
477
465
|
}
|
|
478
466
|
if (!state.currentExecutionAssistantSeen && state.pendingAssistantText.trim()) {
|
|
479
|
-
|
|
467
|
+
renderChatBlock("assistant", state.pendingAssistantText.trim(), writeLine);
|
|
480
468
|
state.pendingAssistantText = "";
|
|
481
469
|
state.currentExecutionAssistantSeen = true;
|
|
482
470
|
}
|
|
@@ -495,7 +483,7 @@ async function showHistory({ api, taskId, branch, state, writeLine }) {
|
|
|
495
483
|
const result = await api.request(`/api/tasks/${encodeURIComponent(taskId)}/ai/executions`);
|
|
496
484
|
const executions = sessionExecutions(result?.executions || [], branch).slice(0, HISTORY_LIMIT).reverse();
|
|
497
485
|
if (executions.length === 0) return result?.executions || [];
|
|
498
|
-
writeLine("\nRecent
|
|
486
|
+
writeLine("\nRecent conversation");
|
|
499
487
|
for (const execution of executions) {
|
|
500
488
|
const messages = await api.request(
|
|
501
489
|
`/api/tasks/${encodeURIComponent(taskId)}/ai/executions/${encodeURIComponent(execution.id)}/messages`,
|
|
@@ -528,7 +516,7 @@ async function waitForReady({ api, sessionPath, initialSession, writeLine, sleep
|
|
|
528
516
|
const deadline = Date.now() + SESSION_START_TIMEOUT_MS;
|
|
529
517
|
while (!SESSION_READY_STATUSES.has(session.status)) {
|
|
530
518
|
if (session.status !== lastStatus) {
|
|
531
|
-
writeLine(`
|
|
519
|
+
writeLine(`Preparing workspace · ${session.status}`);
|
|
532
520
|
lastStatus = session.status;
|
|
533
521
|
}
|
|
534
522
|
if (SESSION_TERMINAL_STATUSES.has(session.status)) {
|
|
@@ -545,19 +533,19 @@ async function waitForReady({ api, sessionPath, initialSession, writeLine, sleep
|
|
|
545
533
|
if (!result?.session) throw new Error("The Dev Session disappeared while starting.");
|
|
546
534
|
session = result.session;
|
|
547
535
|
}
|
|
548
|
-
if (session.status !== lastStatus) writeLine(
|
|
536
|
+
if (session.status !== lastStatus) writeLine("Dev Session ready");
|
|
549
537
|
return session;
|
|
550
538
|
}
|
|
551
539
|
|
|
552
540
|
function sessionSummary(task, session, writeLine) {
|
|
553
541
|
const url = canonicalSessionUrl(session.hostname);
|
|
554
|
-
writeLine("\nDev Session
|
|
555
|
-
writeLine(`Task
|
|
556
|
-
writeLine(`
|
|
557
|
-
writeLine(`
|
|
558
|
-
writeLine(`
|
|
559
|
-
writeLine(`Expires
|
|
560
|
-
writeLine("
|
|
542
|
+
writeLine("\nDev Session");
|
|
543
|
+
writeLine(` Task ${formatTask(task)}`);
|
|
544
|
+
writeLine(` Site ${url || "not available yet"}`);
|
|
545
|
+
writeLine(` Branch ${session.config?.branch || "unknown"}`);
|
|
546
|
+
writeLine(` Status ${session.status}`);
|
|
547
|
+
writeLine(` Expires ${session.expiresAt || "server-managed"}`);
|
|
548
|
+
writeLine("\n/open · /status · /logs · /finish · /stop · /detach · /help\n");
|
|
561
549
|
}
|
|
562
550
|
|
|
563
551
|
function commandHelp(writeLine) {
|
|
@@ -622,7 +610,7 @@ export async function runDevSession(options) {
|
|
|
622
610
|
const spawnImpl = options.spawnImpl || spawn;
|
|
623
611
|
const sleep = options.sleep || defaultSleep;
|
|
624
612
|
const secrets = [token];
|
|
625
|
-
const writeLine = (value = "") => output.write(`${redactSensitive(value, secrets)}\n`);
|
|
613
|
+
const writeLine = (value = "") => output.write(`${redactSensitive(value, secrets, null)}\n`);
|
|
626
614
|
const writeLaunchLine = (value) => output.write(`${String(value)}\n`);
|
|
627
615
|
|
|
628
616
|
const controllers = new Set();
|
|
@@ -764,13 +752,12 @@ export async function runDevSession(options) {
|
|
|
764
752
|
lastExecutionStatus: null,
|
|
765
753
|
pendingAssistantText: "",
|
|
766
754
|
currentExecutionAssistantSeen: false,
|
|
767
|
-
|
|
768
|
-
lastToolStreamKey: null,
|
|
755
|
+
toolStreamKeys: new Set(),
|
|
769
756
|
};
|
|
770
757
|
const executions = await showHistory({ api, taskId: task.id, branch: session.config.branch, state: renderState, writeLine });
|
|
771
758
|
const active = activeExecutionForSession(executions, session.config.branch);
|
|
772
759
|
if (active) {
|
|
773
|
-
writeLine(
|
|
760
|
+
writeLine("\nResuming the active agent turn…");
|
|
774
761
|
const completed = await followExecution({
|
|
775
762
|
api,
|
|
776
763
|
taskId: task.id,
|
|
@@ -791,7 +778,7 @@ export async function runDevSession(options) {
|
|
|
791
778
|
}
|
|
792
779
|
|
|
793
780
|
while (!detached) {
|
|
794
|
-
const prompt = await ask("
|
|
781
|
+
const prompt = await ask("you › ");
|
|
795
782
|
if (detached) break;
|
|
796
783
|
if (!prompt) continue;
|
|
797
784
|
if (prompt === "/help") {
|
|
@@ -897,7 +884,7 @@ export async function runDevSession(options) {
|
|
|
897
884
|
sleep,
|
|
898
885
|
});
|
|
899
886
|
if (completed.status === "succeeded") {
|
|
900
|
-
writeLine(
|
|
887
|
+
if (!renderState.currentExecutionAssistantSeen) writeLine("Turn complete.");
|
|
901
888
|
} else if (completed.status === "cancelled") {
|
|
902
889
|
writeLine("Agent turn cancelled; the Dev Session remains attached.");
|
|
903
890
|
} else {
|
package/package.json
CHANGED