@carrieros/cli 0.3.0 → 0.4.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 +34 -13
- package/dist/commands/chat.js +3 -3
- package/dist/commands/context.js +40 -0
- package/dist/commands/doctor.js +27 -12
- package/dist/commands/logout.js +1 -0
- package/dist/commands/permissions.js +77 -0
- package/dist/commands/scope.js +9 -6
- package/dist/commands/sessions.js +5 -0
- package/dist/commands/settings.js +8 -1
- package/dist/commands/update.js +79 -9
- package/dist/commands/usage.js +5 -5
- package/dist/commands/whoami.js +12 -9
- package/dist/ide/editor-context.js +115 -12
- package/dist/ide/ide-session.js +274 -13
- package/dist/ide/tool-host.js +2 -2
- package/dist/main.js +0 -0
- package/dist/services/api.js +178 -12
- package/dist/services/auth-origin.js +20 -0
- package/dist/services/chat-stream.js +26 -3
- package/dist/services/checkpoints.js +176 -14
- package/dist/services/client-tools.js +113 -21
- package/dist/services/code-intel.js +243 -0
- package/dist/services/code-symbols.js +94 -0
- package/dist/services/coding-workflow.js +554 -0
- package/dist/services/command-coordinator.js +85 -12
- package/dist/services/command-policy.js +34 -4
- package/dist/services/config.js +67 -5
- package/dist/services/container-runner.js +254 -0
- package/dist/services/container-supervisor.js +38 -0
- package/dist/services/context.js +45 -17
- package/dist/services/device-auth.js +30 -5
- package/dist/services/execution-platform.js +30 -0
- package/dist/services/file-resolver.js +1 -1
- package/dist/services/folder-key.js +22 -0
- package/dist/services/git-tools.js +181 -0
- package/dist/services/helper-bin.js +56 -35
- package/dist/services/instruction-resolver.js +54 -0
- package/dist/services/job-helper.js +31 -10
- package/dist/services/local-files.js +148 -26
- package/dist/services/local-tools.js +540 -35
- package/dist/services/login-flow.js +43 -12
- package/dist/services/mutation-coordinator.js +186 -20
- package/dist/services/mutation-groups.js +309 -0
- package/dist/services/mutation-recovery.js +159 -0
- package/dist/services/mutations.js +264 -78
- package/dist/services/packaged-update.js +403 -0
- package/dist/services/packaged.js +15 -0
- package/dist/services/permission-mode.js +60 -0
- package/dist/services/process-runner.js +7 -1
- package/dist/services/project-context.js +4 -4
- package/dist/services/result-reconciliation.js +49 -0
- package/dist/services/secure-store.js +21 -1
- package/dist/services/session-resolver.js +5 -0
- package/dist/services/supported-runtime.js +59 -0
- package/dist/services/task-context.js +212 -0
- package/dist/services/task-snapshot.js +38 -0
- package/dist/services/tool-result-outbox.js +195 -0
- package/dist/services/update.js +37 -12
- package/dist/services/workspace-registry.js +4 -3
- package/dist/services/workspace.js +8 -1
- package/dist/shell/shell-chat.js +299 -32
- package/dist/shell/shell-commands.js +46 -4
- package/dist/shell/shell-prompt.js +21 -11
- package/dist/shell/shell-renderer.js +1 -1
- package/dist/shell/shell.js +69 -7
- package/dist/shell/task-context-view.js +40 -0
- package/dist/ui/agent-cards.js +111 -0
- package/dist/ui/agent-presentation.js +131 -0
- package/dist/ui/approval.js +46 -16
- package/dist/ui/banner.js +31 -87
- package/dist/ui/change-review.js +293 -46
- package/dist/ui/chat-renderer.js +6 -6
- package/dist/ui/colors.js +9 -9
- package/dist/ui/command-details.js +11 -0
- package/dist/ui/command-palette.js +27 -10
- package/dist/ui/command-registry.js +9 -2
- package/dist/ui/command-review.js +77 -28
- package/dist/ui/composer-layout.js +26 -20
- package/dist/ui/conversation.js +77 -25
- package/dist/ui/live.js +1 -1
- package/dist/ui/screen.js +19 -11
- package/dist/ui/select.js +6 -0
- package/dist/ui/task-context-card.js +99 -0
- package/dist/ui/trust.js +7 -12
- package/dist/ui/ui.js +23 -0
- package/package.json +8 -5
package/dist/ui/conversation.js
CHANGED
|
@@ -33,6 +33,8 @@ export function clipCommand(text, width) {
|
|
|
33
33
|
const plain = stripControl(text);
|
|
34
34
|
if (visibleWidth(plain) <= width)
|
|
35
35
|
return plain;
|
|
36
|
+
if (width < 22)
|
|
37
|
+
return clip(plain, width);
|
|
36
38
|
const keepEnd = Math.max(8, Math.floor((width - 3) * 0.35));
|
|
37
39
|
const keepStart = Math.max(8, width - 3 - keepEnd);
|
|
38
40
|
return [...plain].slice(0, keepStart).join("") + " … " + [...plain].slice(-keepEnd).join("");
|
|
@@ -42,7 +44,7 @@ export function clipCommand(text, width) {
|
|
|
42
44
|
* for anything a person needs in full: a command, a path, a reason.
|
|
43
45
|
*/
|
|
44
46
|
export function wrapText(text, width) {
|
|
45
|
-
const w = Math.max(
|
|
47
|
+
const w = Math.max(1, width);
|
|
46
48
|
const out = [];
|
|
47
49
|
for (const paragraph of text.split("\n")) {
|
|
48
50
|
let cur = "";
|
|
@@ -84,6 +86,8 @@ export function isNoiseLine(line) {
|
|
|
84
86
|
const t = line.trim();
|
|
85
87
|
if (!t)
|
|
86
88
|
return true;
|
|
89
|
+
if (/\b(error|warn|warning|failed|failure)\b/i.test(t))
|
|
90
|
+
return false;
|
|
87
91
|
return (/^\(node:\d+\)\s+ExperimentalWarning/.test(t) ||
|
|
88
92
|
/^\(Use `node --trace-warnings/.test(t) ||
|
|
89
93
|
// Winston / pino style structured logs: "info:", "debug:", "http:", plus a
|
|
@@ -161,32 +165,36 @@ export function createRenderer(live) {
|
|
|
161
165
|
let command = null;
|
|
162
166
|
let preview = "";
|
|
163
167
|
let paused = false;
|
|
164
|
-
|
|
168
|
+
let frame = 0;
|
|
169
|
+
const width = () => Math.max(8, contentWidth() - 4);
|
|
165
170
|
const dot = () => c.accentLight("•");
|
|
166
171
|
const paint = () => {
|
|
167
172
|
if (paused)
|
|
168
173
|
return;
|
|
169
174
|
const lines = [];
|
|
175
|
+
const activity = () => c.accentLight(["·", "•", "◦", "•"][frame++ % 4]) + " ";
|
|
170
176
|
if (command) {
|
|
171
|
-
lines.push(MARGIN + " " + c.value(clip(command.label, width() -
|
|
177
|
+
lines.push(MARGIN + " " + activity() + c.value(clip(command.label, width() - 14)) + c.dim(elapsedLabel(command.since)));
|
|
172
178
|
lines.push(MARGIN + " " + c.dim("└ $ " + clipCommand(command.command, width() - 8)));
|
|
173
179
|
for (const l of command.tail.view(width() - 6))
|
|
174
180
|
lines.push(MARGIN + " " + c.dim(l));
|
|
175
181
|
}
|
|
176
|
-
else if (step) {
|
|
177
|
-
lines.push(MARGIN + " " + c.value(clip(step.label, width() -
|
|
182
|
+
else if (step && step.running.length) {
|
|
183
|
+
lines.push(MARGIN + " " + activity() + c.value(clip(step.label, width() - 14)) + c.dim(elapsedLabel(step.started)));
|
|
178
184
|
if (step.running.length > 1) {
|
|
179
|
-
for (const [i, label] of step.running.entries()) {
|
|
185
|
+
for (const [i, label] of step.running.slice(0, 3).entries()) {
|
|
180
186
|
const branch = i === step.running.length - 1 ? "└ " : "├ ";
|
|
181
187
|
lines.push(MARGIN + " " + c.dim(branch + clip(label, width() - 6)));
|
|
182
188
|
}
|
|
189
|
+
if (step.running.length > 3)
|
|
190
|
+
lines.push(MARGIN + " " + c.dim(`+${step.running.length - 3} more`));
|
|
183
191
|
}
|
|
184
192
|
}
|
|
185
193
|
else if (preview) {
|
|
186
194
|
lines.push(MARGIN + dot() + " " + c.dim(clip(preview, width())));
|
|
187
195
|
}
|
|
188
196
|
else if (statusLabel) {
|
|
189
|
-
lines.push(MARGIN + " " + c.dim(clip(statusLabel, width())) + c.dim(elapsedLabel(statusSince)));
|
|
197
|
+
lines.push(MARGIN + " " + activity() + c.dim(clip(statusLabel, width() - 2)) + c.dim(elapsedLabel(statusSince)));
|
|
190
198
|
}
|
|
191
199
|
live.setStatus(lines);
|
|
192
200
|
};
|
|
@@ -196,7 +204,7 @@ export function createRenderer(live) {
|
|
|
196
204
|
return {
|
|
197
205
|
user(text) {
|
|
198
206
|
const lines = wrapText(text.trim(), contentWidth() - 3);
|
|
199
|
-
live.commit(["", ...lines.map((l, i) => MARGIN + (i === 0 ? c.
|
|
207
|
+
live.commit(["", ...lines.map((l, i) => MARGIN + (i === 0 ? c.brand("›") : " ") + " " + c.title(l)), ""]);
|
|
200
208
|
},
|
|
201
209
|
assistant(text) {
|
|
202
210
|
const md = renderMarkdown(text.trim());
|
|
@@ -227,19 +235,30 @@ export function createRenderer(live) {
|
|
|
227
235
|
},
|
|
228
236
|
toolStart(label, kind) {
|
|
229
237
|
if (!step)
|
|
230
|
-
step = { label, started: Date.now(), running: [], counts: blankCounts() };
|
|
231
|
-
step.counts[kind] += 1;
|
|
238
|
+
step = { label, started: Date.now(), running: [], kinds: [], counts: blankCounts(), targets: { read: [], search: [], list: [] } };
|
|
232
239
|
step.running.push(label);
|
|
240
|
+
step.kinds.push(kind);
|
|
233
241
|
// One tool at a time reads better as itself than as a group.
|
|
234
|
-
step.label = step.running.length === 1 ? label :
|
|
242
|
+
step.label = step.running.length === 1 ? label : "Inspecting repository";
|
|
235
243
|
paint();
|
|
236
244
|
},
|
|
237
245
|
toolEnd(label, kind, summary, ok = true) {
|
|
238
246
|
if (!step)
|
|
239
247
|
return;
|
|
240
248
|
const i = step.running.indexOf(label);
|
|
241
|
-
if (i !== -1)
|
|
249
|
+
if (i !== -1) {
|
|
242
250
|
step.running.splice(i, 1);
|
|
251
|
+
const originalKind = step.kinds.splice(i, 1)[0];
|
|
252
|
+
const k = kind ?? originalKind;
|
|
253
|
+
if (ok)
|
|
254
|
+
step.counts[k] += 1;
|
|
255
|
+
// Name what was looked at, so investigation is visible without a line per read.
|
|
256
|
+
if (ok && (k === "read" || k === "search" || k === "list")) {
|
|
257
|
+
const target = stepTarget(label);
|
|
258
|
+
if (target && !step.targets[k].includes(target))
|
|
259
|
+
step.targets[k].push(target);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
243
262
|
if (step.running.length === 1)
|
|
244
263
|
step.label = step.running[0];
|
|
245
264
|
// A failed tool says so, concisely, right where it happened.
|
|
@@ -258,12 +277,14 @@ export function createRenderer(live) {
|
|
|
258
277
|
return;
|
|
259
278
|
// Inspections already left their own ✓ lines; the aggregate is the reads
|
|
260
279
|
// and searches that were kept quiet during the step.
|
|
261
|
-
const summary = summariseStep({ ...step.counts, inspect: 0 });
|
|
280
|
+
const summary = summariseStep({ ...step.counts, inspect: 0, command: 0, change: 0, other: 0 });
|
|
262
281
|
const took = elapsedLabel(step.started);
|
|
263
282
|
const hadInspect = step.counts.inspect > 0;
|
|
283
|
+
const targets = step.targets;
|
|
284
|
+
const counts = step.counts;
|
|
264
285
|
step = null;
|
|
265
286
|
if (summary)
|
|
266
|
-
live.commit([
|
|
287
|
+
live.commit([...investigationBlock(counts, targets, took, width()), ""]);
|
|
267
288
|
else if (hadInspect)
|
|
268
289
|
live.commit([""]); // spacer after the ✓ inspection lines
|
|
269
290
|
paint();
|
|
@@ -306,19 +327,36 @@ export function createRenderer(live) {
|
|
|
306
327
|
}
|
|
307
328
|
};
|
|
308
329
|
}
|
|
330
|
+
/**
|
|
331
|
+
* The grouped record of what a step read, searched and listed: one heading and
|
|
332
|
+
* a row per kind, each naming its targets (paths and queries only — never model
|
|
333
|
+
* text). Rows are clipped to the terminal; the full list is the tool record.
|
|
334
|
+
*/
|
|
335
|
+
function investigationBlock(counts, targets, took, width) {
|
|
336
|
+
const plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
|
|
337
|
+
const named = (list) => (list.length ? " · " + list.slice(0, 4).join(", ") + (list.length > 4 ? `, +${list.length - 4} more` : "") : "");
|
|
338
|
+
// Phases in the order an investigation runs, each present only when a tool
|
|
339
|
+
// of that kind actually ran — never inferred from model text.
|
|
340
|
+
const rows = [
|
|
341
|
+
[counts.list + counts.inspect > 0, "Inspecting repository structure", named(targets.list)],
|
|
342
|
+
[counts.search > 0, "Searching for related code", named(targets.search)],
|
|
343
|
+
[counts.read > 0, `Reading relevant files (${plural(counts.read, "file", "files")})`, named(targets.read)]
|
|
344
|
+
];
|
|
345
|
+
return [
|
|
346
|
+
MARGIN + c.title("Agent investigation") + c.dim(took),
|
|
347
|
+
...rows.filter(([ran]) => ran).map(([, text, list]) => MARGIN + " " + c.ok("✓ ") + c.value(clip(text, width - 4)) + c.dim(clip(list, Math.max(0, width - 6 - visibleWidth(text)))))
|
|
348
|
+
];
|
|
349
|
+
}
|
|
350
|
+
/** "Reading src/a.ts" → "src/a.ts"; a label with no target names nothing. */
|
|
351
|
+
function stepTarget(label) {
|
|
352
|
+
const m = stripControl(label).match(/^(?:Reading|Searching|Finding files|Finding file|Finding definition|Finding usages|Outlining|Inspecting repository|Listing)\s+(.+)$/);
|
|
353
|
+
const target = m ? m[1].trim().slice(0, 80) : "";
|
|
354
|
+
// Generic activity words name nothing the user could look at.
|
|
355
|
+
return /^(project files|the project|repository|files)$/i.test(target) ? "" : target;
|
|
356
|
+
}
|
|
309
357
|
function blankCounts() {
|
|
310
358
|
return { read: 0, list: 0, search: 0, inspect: 0, command: 0, change: 0, other: 0 };
|
|
311
359
|
}
|
|
312
|
-
/** What to call a step that is doing several things at once. */
|
|
313
|
-
function groupLabel(counts) {
|
|
314
|
-
if (counts.command > 1)
|
|
315
|
-
return "Running commands";
|
|
316
|
-
if (counts.change > 1)
|
|
317
|
-
return "Preparing changes";
|
|
318
|
-
if (counts.search && !counts.read)
|
|
319
|
-
return "Searching the project";
|
|
320
|
-
return "Inspecting the project";
|
|
321
|
-
}
|
|
322
360
|
/**
|
|
323
361
|
* The compact result line for one completed tool, or undefined when the step's
|
|
324
362
|
* aggregate should speak for it instead.
|
|
@@ -368,7 +406,13 @@ export function toolSummary(name, ok, detail) {
|
|
|
368
406
|
return "git_diff · no changes";
|
|
369
407
|
return `git_diff · ${n(r.files_changed)} ${n(r.files_changed) === 1 ? "file" : "files"} · +${n(r.additions)} −${n(r.deletions)}`;
|
|
370
408
|
}
|
|
371
|
-
|
|
409
|
+
if (name === "git_log")
|
|
410
|
+
return `git_log · ${arr(r.commits)} ${arr(r.commits) === 1 ? "commit" : "commits"}${r.path ? ` · ${r.path}` : ""}`;
|
|
411
|
+
if (name === "git_blame")
|
|
412
|
+
return `git_blame · ${r.path ?? ""} lines ${n(r.start_line)}–${n(r.end_line)}`;
|
|
413
|
+
if (name === "git_show")
|
|
414
|
+
return `git_show · ${r.short ?? ""} ${typeof r.subject === "string" ? r.subject.slice(0, 60) : ""}`.trimEnd();
|
|
415
|
+
// read_file / list_files / find_files / search_files are aggregated by the step summary.
|
|
372
416
|
return undefined;
|
|
373
417
|
}
|
|
374
418
|
/** The kind of activity a tool name represents, for the step summary. */
|
|
@@ -378,11 +422,19 @@ export function toolKind(name) {
|
|
|
378
422
|
return "read";
|
|
379
423
|
case "list_files":
|
|
380
424
|
return "list";
|
|
425
|
+
case "find_files":
|
|
381
426
|
case "search_files":
|
|
427
|
+
case "find_symbol":
|
|
428
|
+
case "find_references":
|
|
382
429
|
return "search";
|
|
430
|
+
case "code_outline":
|
|
431
|
+
return "read";
|
|
383
432
|
case "resolve_local_file":
|
|
384
433
|
case "git_status":
|
|
385
434
|
case "git_diff":
|
|
435
|
+
case "git_log":
|
|
436
|
+
case "git_blame":
|
|
437
|
+
case "git_show":
|
|
386
438
|
return "inspect";
|
|
387
439
|
case "run_command":
|
|
388
440
|
return "command";
|
package/dist/ui/live.js
CHANGED
|
@@ -28,7 +28,7 @@ export function startLiveComposer(footer = "") {
|
|
|
28
28
|
stop: () => screenTransient([])
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
if (!stdout.isTTY)
|
|
31
|
+
if (!stdout.isTTY || process.env.TERM === "dumb")
|
|
32
32
|
return passthrough;
|
|
33
33
|
let status = [];
|
|
34
34
|
let shown = []; // the transient region currently on screen (status + bar)
|
package/dist/ui/screen.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { clampAnsi, wrapAnsi } from "./composer-layout.js";
|
|
1
2
|
/**
|
|
2
3
|
* Persistent bottom-composer TUI engine (Claude Code–style).
|
|
3
4
|
*
|
|
@@ -43,6 +44,7 @@ const MAX_SCROLLBACK = 5000;
|
|
|
43
44
|
let active = false;
|
|
44
45
|
let committed = []; // permanent transcript lines
|
|
45
46
|
let transient = []; // in-progress tail (spinner / streaming), below `committed`
|
|
47
|
+
let task = []; // existing task review projection, pinned while active
|
|
46
48
|
let palette = []; // slash-palette overlay (empty when closed)
|
|
47
49
|
let bar = []; // the fixed composer core (CORE_H lines)
|
|
48
50
|
let caretBarIndex = 1; // which composer row the caret sits on (1 = prompt line)
|
|
@@ -65,10 +67,11 @@ function metrics() {
|
|
|
65
67
|
const core = bar.length || CORE_H;
|
|
66
68
|
const tb = Math.max(1, h - core); // transcript occupies rows 1..tb
|
|
67
69
|
const pH = Math.min(palette.length, Math.max(0, tb - 1)); // overlay never covers the whole region
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
+
const taskH = Math.min(task.length, Math.max(0, Math.floor((tb - pH) / 2)));
|
|
71
|
+
const contentH = Math.max(0, tb - pH - taskH); // transcript rows above the palette overlay
|
|
72
|
+
const all = (transient.length ? committed.concat(transient) : committed).flatMap(line => wrapAnsi(line, Math.max(1, (out.columns ?? 80) - 1)));
|
|
70
73
|
const maxOffset = Math.max(0, all.length - contentH);
|
|
71
|
-
return { h, core, tb, pH, contentH, all, maxOffset };
|
|
74
|
+
return { h, core, tb, pH, taskH, contentH, all, maxOffset };
|
|
72
75
|
}
|
|
73
76
|
/** Clamp the scroll offset into range and recompute the pinned flag. */
|
|
74
77
|
function clampScroll() {
|
|
@@ -94,7 +97,7 @@ function onContentGrew(added) {
|
|
|
94
97
|
}
|
|
95
98
|
/** Build the full desired screen: [transcript window][palette][composer core]. */
|
|
96
99
|
function compose() {
|
|
97
|
-
const { h, tb, pH, contentH, all, maxOffset } = metrics();
|
|
100
|
+
const { h, tb, pH, taskH, contentH, all, maxOffset } = metrics();
|
|
98
101
|
if (scrollOffset > maxOffset)
|
|
99
102
|
scrollOffset = maxOffset; // stay valid across resizes
|
|
100
103
|
// The visible window into `all`. offset 0 = last `contentH` lines (the tail);
|
|
@@ -103,17 +106,19 @@ function compose() {
|
|
|
103
106
|
const start = Math.max(0, end - contentH);
|
|
104
107
|
const win = all.slice(start, end);
|
|
105
108
|
const desired = new Array(h).fill("");
|
|
109
|
+
for (let i = 0; i < taskH; i++)
|
|
110
|
+
desired[i] = task[i] ?? "";
|
|
106
111
|
for (let i = 0; i < contentH; i++)
|
|
107
|
-
desired[i] = win[i] ?? "";
|
|
112
|
+
desired[taskH + i] = win[i] ?? "";
|
|
108
113
|
// A subtle "more below" hint on the last transcript row when scrolled up.
|
|
109
114
|
if (scrollOffset > 0 && contentH > 0) {
|
|
110
|
-
desired[contentH - 1] = `${ESC}2m ↓ ${scrollOffset} more line${scrollOffset === 1 ? "" : "s"} - End to jump to latest${ESC}0m`;
|
|
115
|
+
desired[taskH + contentH - 1] = `${ESC}2m ↓ ${scrollOffset} more line${scrollOffset === 1 ? "" : "s"} - End to jump to latest${ESC}0m`;
|
|
111
116
|
}
|
|
112
117
|
for (let i = 0; i < pH; i++)
|
|
113
|
-
desired[contentH + i] = palette[i] ?? "";
|
|
118
|
+
desired[taskH + contentH + i] = palette[i] ?? "";
|
|
114
119
|
for (let i = 0; i < (bar.length || CORE_H); i++)
|
|
115
120
|
desired[tb + i] = bar[i] ?? "";
|
|
116
|
-
return desired;
|
|
121
|
+
return desired.map(line => clampAnsi(line, Math.max(1, (out.columns ?? 80) - 1)));
|
|
117
122
|
}
|
|
118
123
|
/** Diff the desired screen against what's on-screen; rewrite only changed rows. */
|
|
119
124
|
function flush() {
|
|
@@ -132,15 +137,16 @@ function flush() {
|
|
|
132
137
|
const caretRow = rows() - core + 1 + caretBarIndex;
|
|
133
138
|
// The composer is a permanent region, so its caret shows whenever the composer
|
|
134
139
|
// is active — independent of where the transcript is scrolled.
|
|
135
|
-
s += showCaret ? `${ESC}${caretRow};${caretCol}H${SHOW}` : HIDE;
|
|
140
|
+
s += showCaret ? `${ESC}${caretRow};${Math.min(caretCol, out.columns ?? 80)}H${SHOW}` : HIDE;
|
|
136
141
|
write(s);
|
|
137
142
|
}
|
|
138
143
|
/** Enter TUI mode: alt-screen, alt-scroll (wheel→arrows), clear, hide caret. */
|
|
139
144
|
export function startScreen() {
|
|
140
|
-
if (!out.isTTY)
|
|
145
|
+
if (!out.isTTY || process.env.TERM === "dumb")
|
|
141
146
|
return;
|
|
142
147
|
active = true;
|
|
143
148
|
committed = [];
|
|
149
|
+
task = [];
|
|
144
150
|
transient = [];
|
|
145
151
|
palette = [];
|
|
146
152
|
bar = [];
|
|
@@ -279,7 +285,7 @@ export function suspendScreen() {
|
|
|
279
285
|
}
|
|
280
286
|
/** Resume TUI mode after suspendScreen(), repainting the preserved transcript. */
|
|
281
287
|
export function resumeScreen() {
|
|
282
|
-
if (!out.isTTY)
|
|
288
|
+
if (!out.isTTY || process.env.TERM === "dumb")
|
|
283
289
|
return;
|
|
284
290
|
active = true;
|
|
285
291
|
shown = [];
|
|
@@ -287,3 +293,5 @@ export function resumeScreen() {
|
|
|
287
293
|
flush();
|
|
288
294
|
out.on("resize", screenResize);
|
|
289
295
|
}
|
|
296
|
+
/** Pin task evidence without changing transcript, approval or keyboard ownership. */
|
|
297
|
+
export function screenTask(lines) { task = lines.slice(0, 24); clampScroll(); flush(); }
|
package/dist/ui/select.js
CHANGED
|
@@ -154,6 +154,10 @@ export function pickFromList(opts) {
|
|
|
154
154
|
stdin.removeAllListeners("keypress");
|
|
155
155
|
readline.emitKeypressEvents(stdin);
|
|
156
156
|
const prevRaw = stdin.isRaw ?? false;
|
|
157
|
+
// A one-shot command (e.g. the trust prompt before `cos files`) must not
|
|
158
|
+
// leave stdin flowing behind it, or the finished command never exits.
|
|
159
|
+
// (isPaused() is false for a stream never resumed, so test flowing state.)
|
|
160
|
+
const wasPaused = stdin.readableFlowing !== true;
|
|
157
161
|
if (stdin.isTTY)
|
|
158
162
|
stdin.setRawMode(true);
|
|
159
163
|
stdin.resume();
|
|
@@ -175,6 +179,8 @@ export function pickFromList(opts) {
|
|
|
175
179
|
readline.clearScreenDown(stdout);
|
|
176
180
|
stdin.removeListener("keypress", onKey);
|
|
177
181
|
stdin.setRawMode(prevRaw);
|
|
182
|
+
if (wasPaused)
|
|
183
|
+
stdin.pause();
|
|
178
184
|
if (suspended)
|
|
179
185
|
resumeScreen(); // repaint the pinned composer + transcript
|
|
180
186
|
resolve(val);
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { c } from "./colors.js";
|
|
2
|
+
import { MARGIN } from "./composer-layout.js";
|
|
3
|
+
import { INDENT, cardHeader, cardWidth } from "./agent-cards.js";
|
|
4
|
+
import { clip, stripControl, wrapText } from "./conversation.js";
|
|
5
|
+
/**
|
|
6
|
+
* Task Context presentation: a compact card when a conversation with earlier
|
|
7
|
+
* coding work is resumed, and one restored-context line when a coding turn
|
|
8
|
+
* starts in it. Never the whole context — the existing workflow cards remain
|
|
9
|
+
* the primary record of what happens in the turn.
|
|
10
|
+
*/
|
|
11
|
+
const STATE_WORDS = { COMPLETED: "Completed", UNRESOLVED: "Unresolved" };
|
|
12
|
+
const RUN_WORDS = { passed: "passed", failed: "failed", not_approved: "not approved", not_run: "not run", cancelled: "cancelled", timed_out: "timed out", pending: "pending", unresolved: "unresolved", completed: "ran" };
|
|
13
|
+
const LABEL = 13;
|
|
14
|
+
/** `Label value`, with a long value wrapped under itself rather than clipped. */
|
|
15
|
+
function field(name, value) {
|
|
16
|
+
const room = Math.max(12, cardWidth() - LABEL - 2);
|
|
17
|
+
const pad = MARGIN + " ".repeat(LABEL + 2);
|
|
18
|
+
return wrapText(stripControl(value), room).map((part, i) => (i === 0 ? MARGIN + c.dim(name.padEnd(LABEL) + " ") : pad) + c.value(part));
|
|
19
|
+
}
|
|
20
|
+
/** Dim prose that wraps at the card width. */
|
|
21
|
+
const note = (text, prefix = INDENT) => wrapText(text, Math.max(12, cardWidth() - (prefix.length - INDENT.length))).map((l) => prefix + c.dim(l));
|
|
22
|
+
const plural = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
|
|
23
|
+
function filesLine(ctx, state) {
|
|
24
|
+
const t = ctx.current;
|
|
25
|
+
const read = t.investigation.files.length + t.investigation.files_omitted;
|
|
26
|
+
const changed = state.filter((e) => e.status !== "unchanged").length;
|
|
27
|
+
const parts = [`${plural(read, "file")} read`];
|
|
28
|
+
if (t.changes.applied)
|
|
29
|
+
parts.push(`${t.changes.applied} changed by the task`);
|
|
30
|
+
if (changed)
|
|
31
|
+
parts.push(`${changed} changed on disk since`);
|
|
32
|
+
return parts.join(" · ");
|
|
33
|
+
}
|
|
34
|
+
function testsLine(ctx) {
|
|
35
|
+
const last = ctx.current.validation.runs.at(-1);
|
|
36
|
+
if (!last)
|
|
37
|
+
return "none run";
|
|
38
|
+
return `${last.command ?? "command"} ${RUN_WORDS[last.outcome] ?? last.outcome}`;
|
|
39
|
+
}
|
|
40
|
+
const relevantFiles = (ctx) => ctx.current.references ? ctx.current.references.items.length + ctx.current.references.omitted : ctx.current.investigation.files.length + ctx.current.investigation.files_omitted;
|
|
41
|
+
const previousChanges = (ctx) => ctx.current.changes.applied + ctx.earlier_tasks.reduce((n, e) => n + e.files_changed.length, 0);
|
|
42
|
+
/** "shop · main", and whether it is the repository the earlier work used. */
|
|
43
|
+
function repositoryLine(name, repo) {
|
|
44
|
+
const where = repo?.branch ? `${name} · ${repo.branch}` : name;
|
|
45
|
+
if (repo?.same_repository === false)
|
|
46
|
+
return `${where} — a different repository than the earlier work`;
|
|
47
|
+
return where;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Shown when the CLI starts (or resumes) into a conversation with earlier
|
|
51
|
+
* coding work. Small by design: what is being continued, and that the context
|
|
52
|
+
* — never an approval or an operation — was restored.
|
|
53
|
+
*/
|
|
54
|
+
export function renderTaskContextCard(ctx, state = [], repo) {
|
|
55
|
+
const t = ctx.current;
|
|
56
|
+
const out = [...cardHeader("CONTINUING TASK")];
|
|
57
|
+
out.push(...field("Repository", repositoryLine(t.repository ?? repo?.name ?? "this repository", repo)));
|
|
58
|
+
out.push(...field("Previous task", t.title));
|
|
59
|
+
const status = STATE_WORDS[t.verified_state] ?? t.verified_state;
|
|
60
|
+
out.push(...field("Status", t.workflow_state && t.verified_state !== "COMPLETED" ? `${status} · workflow ${t.workflow_state}` : status));
|
|
61
|
+
out.push(...field("Files", filesLine(ctx, state)));
|
|
62
|
+
if (t.corrections_total)
|
|
63
|
+
out.push(...field("Corrections", String(t.corrections_total)));
|
|
64
|
+
out.push(...field("Tests", testsLine(ctx)));
|
|
65
|
+
if (t.pending_operations.length) {
|
|
66
|
+
out.push(...field("Unresolved", `${plural(t.pending_operations.length, "operation")} — never resumed; propose again to continue`));
|
|
67
|
+
}
|
|
68
|
+
if (ctx.earlier_tasks.length)
|
|
69
|
+
out.push(...field("Earlier", plural(ctx.earlier_tasks.length + ctx.earlier_tasks_omitted, "task")));
|
|
70
|
+
out.push(repo?.same_repository === false
|
|
71
|
+
? MARGIN + c.warn("Context not reused: this is a different repository.")
|
|
72
|
+
: MARGIN + c.ok("Context restored ✓"));
|
|
73
|
+
out.push(...note("Context only: files are read again and every change needs new approval.", MARGIN));
|
|
74
|
+
return out;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A small note at the start of a coding turn in a conversation that has a Task
|
|
78
|
+
* Context — never the context itself. Previous changes counts the applied
|
|
79
|
+
* changes the platform recorded across this conversation's coding tasks.
|
|
80
|
+
*/
|
|
81
|
+
export function renderTaskContextRestored(ctx, state = [], repository, repo) {
|
|
82
|
+
const t = ctx.current;
|
|
83
|
+
const changedOnDisk = state.filter((e) => e.status !== "unchanged").length;
|
|
84
|
+
const row = (name, value) => MARGIN + " " + c.dim(name.padEnd(18)) + c.value(clip(stripControl(value), Math.max(8, cardWidth() - 20)));
|
|
85
|
+
if (repo?.same_repository === false) {
|
|
86
|
+
return ["", MARGIN + c.warn("Previous task context not reused"), row("Repository", repo.branch ? `${repo.name} · ${repo.branch}` : repo.name),
|
|
87
|
+
...note("This is a different repository than the earlier work, so this task starts fresh.", MARGIN + " ")];
|
|
88
|
+
}
|
|
89
|
+
return [
|
|
90
|
+
"",
|
|
91
|
+
MARGIN + c.title("Using previous task context"),
|
|
92
|
+
row("Repository", repositoryLine(t.repository ?? repository ?? "this repository", repo)),
|
|
93
|
+
row("Previous task", t.title),
|
|
94
|
+
row("Relevant files", String(relevantFiles(ctx))),
|
|
95
|
+
row("Previous changes", String(previousChanges(ctx))),
|
|
96
|
+
...(changedOnDisk ? [row("Changed on disk", `${changedOnDisk} file${changedOnDisk === 1 ? "" : "s"} since then`)] : []),
|
|
97
|
+
...note("Context only: files are read again and every change needs new approval.", MARGIN + " ")
|
|
98
|
+
];
|
|
99
|
+
}
|
package/dist/ui/trust.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { folderKey, isTrustedFolder } from "../services/folder-key.js";
|
|
2
2
|
import { c } from "./colors.js";
|
|
3
3
|
import { pickFromList } from "./select.js";
|
|
4
4
|
/**
|
|
@@ -10,15 +10,10 @@ import { pickFromList } from "./select.js";
|
|
|
10
10
|
* `cos upload` reads paths directly — so a bare filename can send a local file
|
|
11
11
|
* to the Carrier OS API. The answer is remembered per folder in the CLI config.
|
|
12
12
|
*/
|
|
13
|
-
/**
|
|
14
|
-
const
|
|
15
|
-
/** Windows paths are case-insensitive, so compare on a normalized form. */
|
|
16
|
-
function normalize(dir) {
|
|
17
|
-
const resolved = path.resolve(dir);
|
|
18
|
-
return process.platform === "win32" ? resolved.toLowerCase() : resolved;
|
|
19
|
-
}
|
|
13
|
+
/** Trust keys are canonical folder identities — see services/folder-key.ts. */
|
|
14
|
+
const normalize = folderKey;
|
|
20
15
|
export function isTrusted(config, dir = process.cwd()) {
|
|
21
|
-
return (config.get("trustedFolders") ?? []
|
|
16
|
+
return isTrustedFolder(config.get("trustedFolders") ?? [], dir);
|
|
22
17
|
}
|
|
23
18
|
export function trustFolder(config, dir = process.cwd()) {
|
|
24
19
|
const key = normalize(dir);
|
|
@@ -51,7 +46,7 @@ export function workspaceTrustLines(dir, width) {
|
|
|
51
46
|
const body = (text) => wrap(text, width).map((l) => " " + c.value(l));
|
|
52
47
|
return [
|
|
53
48
|
" " + c.warn("─".repeat(width)),
|
|
54
|
-
" " + c.warn.bold("Accessing
|
|
49
|
+
" " + c.warn.bold("Accessing local repository:"),
|
|
55
50
|
"",
|
|
56
51
|
" " + c.title(dir),
|
|
57
52
|
"",
|
|
@@ -59,9 +54,9 @@ export function workspaceTrustLines(dir, width) {
|
|
|
59
54
|
"(Like your own code, a well-known open source project, or work from your team). " +
|
|
60
55
|
"If not, take a moment to review what's in this folder first."),
|
|
61
56
|
"",
|
|
62
|
-
...body("Carrier OS
|
|
57
|
+
...body("Carrier OS can read referenced files in this repository and send their contents to Carrier OS using your signed-in user account and CLI device session. File changes and commands require their own approval."),
|
|
63
58
|
"",
|
|
64
|
-
"
|
|
59
|
+
...body("Normal CLI login uses your CarrierOS account. No Developer Platform workspace, project or API key is required.")
|
|
65
60
|
];
|
|
66
61
|
}
|
|
67
62
|
/**
|
package/dist/ui/ui.js
CHANGED
|
@@ -22,6 +22,29 @@ export function termWidth(fallback = 80) {
|
|
|
22
22
|
const w = process.stdout.columns;
|
|
23
23
|
return w && w > 0 ? w : fallback;
|
|
24
24
|
}
|
|
25
|
+
const UNITS = [[1e9, "B"], [1e6, "M"], [1e3, "K"]];
|
|
26
|
+
/**
|
|
27
|
+
* A large number the way dashboards show it: 12.47K, 1.25M — at most two
|
|
28
|
+
* decimals, trailing zeros dropped. Below 1,000, `small` formats it.
|
|
29
|
+
*/
|
|
30
|
+
export function compactNumber(n, small) {
|
|
31
|
+
for (const [size, unit] of UNITS) {
|
|
32
|
+
// 999.996 rounds to 1,000.00 — that is "1K", not "1,000.00".
|
|
33
|
+
if (Math.abs(n) >= size * 0.999995)
|
|
34
|
+
return (n / size).toLocaleString("en-US", { maximumFractionDigits: 2 }) + unit;
|
|
35
|
+
}
|
|
36
|
+
return small(n);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A credit amount, everywhere credits appear: compact from 1,000 up (12.47K,
|
|
40
|
+
* 1.25M) and two decimals below it (23.67). A non-zero amount too small to
|
|
41
|
+
* show reads "<0.01" rather than a misleading "0.00".
|
|
42
|
+
*/
|
|
43
|
+
export function formatCredits(n) {
|
|
44
|
+
if (n !== 0 && Math.abs(n) < 0.005)
|
|
45
|
+
return "<0.01";
|
|
46
|
+
return compactNumber(n, (v) => v.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 }));
|
|
47
|
+
}
|
|
25
48
|
/** Visible length of a string, ignoring ANSI color codes. */
|
|
26
49
|
export function visibleLen(s) {
|
|
27
50
|
// eslint-disable-next-line no-control-regex
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carrieros/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Carrier OS command-line interface — an interactive shell plus commands for the Carrier OS developer platform (chat, sessions, files, usage) over the public /v1 API.",
|
|
6
6
|
"type": "module",
|
|
@@ -18,18 +18,19 @@
|
|
|
18
18
|
"scripts": {
|
|
19
19
|
"clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
20
20
|
"prebuild": "npm run clean",
|
|
21
|
-
"build": "tsc -p tsconfig.json",
|
|
21
|
+
"build": "tsc -p tsconfig.json && node -e \"require('node:fs').chmodSync('dist/main.js', 0o755)\"",
|
|
22
22
|
"dev": "tsx src/main.ts",
|
|
23
23
|
"start": "node dist/main.js",
|
|
24
24
|
"typecheck": "tsc --noEmit",
|
|
25
25
|
"test": "npm run build && node --test \"test/*.test.mjs\"",
|
|
26
|
-
"
|
|
26
|
+
"prepack": "npm run build",
|
|
27
27
|
"test:pty": "npm run build && node test/acceptance/pty-selftest.mjs",
|
|
28
|
+
"test:execution": "npm run build && node scripts/validate-execution.mjs",
|
|
28
29
|
"test:acceptance": "npm run build && node test/acceptance/live-acceptance.mjs",
|
|
29
30
|
"build:helpers": "node scripts/build-helpers.mjs",
|
|
30
31
|
"bundle": "npm run build && node scripts/bundle.mjs",
|
|
31
32
|
"sea:blob": "node --experimental-sea-config sea-config.json",
|
|
32
|
-
"package:win": "
|
|
33
|
+
"package:win": "node scripts/package-win.mjs",
|
|
33
34
|
"test:exe": "node test/acceptance/packaged-exe.mjs",
|
|
34
35
|
"rehash-helpers": "node scripts/rehash-helpers.mjs"
|
|
35
36
|
},
|
|
@@ -63,12 +64,14 @@
|
|
|
63
64
|
"chalk": "^5.3.0",
|
|
64
65
|
"commander": "^12.1.0",
|
|
65
66
|
"form-data": "^4.0.1",
|
|
66
|
-
"ora": "^8.1.1"
|
|
67
|
+
"ora": "^8.1.1",
|
|
68
|
+
"string-width": "7.2.0"
|
|
67
69
|
},
|
|
68
70
|
"devDependencies": {
|
|
69
71
|
"@lydell/node-pty": "^1.2.0-beta.15",
|
|
70
72
|
"@types/node": "^22.10.2",
|
|
71
73
|
"esbuild": "^0.28.2",
|
|
74
|
+
"postject": "1.0.0-alpha.6",
|
|
72
75
|
"tsx": "^4.19.2",
|
|
73
76
|
"typescript": "^5.7.2"
|
|
74
77
|
}
|