@carrieros/cli 0.3.0 → 0.4.1
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 +89 -15
- package/dist/commands/chat.js +6 -6
- package/dist/commands/context.js +40 -0
- package/dist/commands/doctor.js +34 -14
- package/dist/commands/logout.js +2 -0
- package/dist/commands/permissions.js +78 -0
- package/dist/commands/scope.js +9 -6
- package/dist/commands/sessions.js +5 -0
- package/dist/commands/settings.js +83 -10
- package/dist/commands/update.js +177 -51
- package/dist/commands/usage.js +10 -8
- package/dist/commands/version.js +1 -3
- package/dist/commands/whoami.js +12 -9
- package/dist/ide/editor-context.js +115 -12
- package/dist/ide/ide-session.js +288 -18
- package/dist/ide/tool-host.js +6 -6
- package/dist/main.js +10 -1
- package/dist/services/api.js +183 -15
- package/dist/services/auth-origin.js +20 -0
- package/dist/services/auto-update.js +221 -0
- package/dist/services/chat-stream.js +26 -3
- package/dist/services/checkpoints.js +176 -14
- package/dist/services/client-tools.js +123 -27
- 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 +96 -11
- package/dist/services/container-runner.js +254 -0
- package/dist/services/container-supervisor.js +38 -0
- package/dist/services/context.js +98 -25
- package/dist/services/device-auth.js +33 -6
- 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 +44 -13
- package/dist/services/meta.js +27 -0
- 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 +78 -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 +7 -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 +457 -13
- package/dist/services/workspace-registry.js +4 -3
- package/dist/services/workspace.js +8 -1
- package/dist/shell/shell-chat.js +320 -34
- package/dist/shell/shell-commands.js +47 -5
- package/dist/shell/shell-prompt.js +21 -11
- package/dist/shell/shell-renderer.js +1 -1
- package/dist/shell/shell.js +107 -20
- 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 +11 -4
- 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 +9 -5
package/dist/ui/change-review.js
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import { c } from "./colors.js";
|
|
2
|
-
import { MARGIN, contentWidth } from "./composer-layout.js";
|
|
2
|
+
import { MARGIN, contentWidth, visibleWidth } from "./composer-layout.js";
|
|
3
3
|
import { clip, stripControl, wrapText } from "./conversation.js";
|
|
4
|
+
import { approvalCard, cardHeader, statusTrack } from "./agent-cards.js";
|
|
4
5
|
/**
|
|
5
6
|
* How a proposed file change is shown before anyone approves it.
|
|
6
7
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* Source-control style: a summary of every file in the group, then each file
|
|
9
|
+
* with its operation, status and reason, then its hunks with old and new line
|
|
10
|
+
* numbers. Committed to the transcript rather than drawn in the prompt, so it
|
|
11
|
+
* stays on screen as the record of what was approved and a long one can be
|
|
12
|
+
* scrolled back to (PgUp/PgDn). Every changed line is shown in full — long
|
|
13
|
+
* lines wrap under the gutter, never clip — so the decision is made on the
|
|
14
|
+
* whole change. Signs (`+`/`-`) and gutters carry the meaning without color,
|
|
15
|
+
* so a terminal without color, or a copied transcript, reads the same.
|
|
16
|
+
*
|
|
17
|
+
* Everything here is display. The text comes from the plan the mutation layer
|
|
18
|
+
* computed from the current bytes on disk; the limits that decide whether a
|
|
19
|
+
* change is reviewable at all (size, sensitive files, containment) live there.
|
|
11
20
|
*/
|
|
12
21
|
const ACTION = {
|
|
13
22
|
create_file: "create",
|
|
@@ -16,7 +25,92 @@ const ACTION = {
|
|
|
16
25
|
delete_file: "delete",
|
|
17
26
|
revert_change: "revert"
|
|
18
27
|
};
|
|
19
|
-
|
|
28
|
+
/** Source-control status letter for the summary list. */
|
|
29
|
+
const STATUS = {
|
|
30
|
+
create_file: "A",
|
|
31
|
+
write_file: "M",
|
|
32
|
+
edit_file: "M",
|
|
33
|
+
delete_file: "D",
|
|
34
|
+
revert_change: "R"
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* The reviewed diff as numbered lines, parsed from the plan's unified text.
|
|
38
|
+
*
|
|
39
|
+
* Numbers come from the hunk headers the diff engine wrote, so they are the
|
|
40
|
+
* real line numbers of the current file (old) and the proposed file (new).
|
|
41
|
+
*/
|
|
42
|
+
export function numberedLines(unified) {
|
|
43
|
+
const out = [];
|
|
44
|
+
let oldLine = 0;
|
|
45
|
+
let newLine = 0;
|
|
46
|
+
for (const raw of unified.split("\n")) {
|
|
47
|
+
if (raw.startsWith("+++") || raw.startsWith("---"))
|
|
48
|
+
continue;
|
|
49
|
+
const h = raw.match(/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
|
|
50
|
+
if (h) {
|
|
51
|
+
// A zero-length side is written as "start-1,0"; the next line on that side is start.
|
|
52
|
+
oldLine = Number(h[2] === "0" ? Number(h[1]) + 1 : h[1]);
|
|
53
|
+
newLine = Number(h[4] === "0" ? Number(h[3]) + 1 : h[3]);
|
|
54
|
+
out.push({ kind: "hunk", text: raw });
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (!raw && out.length === 0)
|
|
58
|
+
continue;
|
|
59
|
+
const op = raw[0];
|
|
60
|
+
const text = raw.slice(1);
|
|
61
|
+
if (op === "-")
|
|
62
|
+
out.push({ kind: "-", oldLine: oldLine++, text });
|
|
63
|
+
else if (op === "+")
|
|
64
|
+
out.push({ kind: "+", newLine: newLine++, text });
|
|
65
|
+
else if (op === " ")
|
|
66
|
+
out.push({ kind: " ", oldLine: oldLine++, newLine: newLine++, text });
|
|
67
|
+
}
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
70
|
+
/** Split display text into chunks of at most `width` columns, by code point. */
|
|
71
|
+
function chunks(text, width) {
|
|
72
|
+
const w = Math.max(8, width);
|
|
73
|
+
if (visibleWidth(text) <= w)
|
|
74
|
+
return [text];
|
|
75
|
+
const out = [];
|
|
76
|
+
let cur = "";
|
|
77
|
+
for (const ch of text) {
|
|
78
|
+
if (visibleWidth(cur + ch) > w) {
|
|
79
|
+
out.push(cur);
|
|
80
|
+
cur = "";
|
|
81
|
+
}
|
|
82
|
+
cur += ch;
|
|
83
|
+
}
|
|
84
|
+
if (cur || !out.length)
|
|
85
|
+
out.push(cur);
|
|
86
|
+
return out;
|
|
87
|
+
}
|
|
88
|
+
/** Hunk lines with a two-column gutter: sign, old number, new number, rule, code. */
|
|
89
|
+
function hunkLines(plan) {
|
|
90
|
+
const lines = numberedLines(plan.unified);
|
|
91
|
+
const widest = lines.reduce((n, l) => Math.max(n, l.oldLine ?? 0, l.newLine ?? 0), 0);
|
|
92
|
+
const w = Math.max(2, String(widest).length);
|
|
93
|
+
const room = contentWidth() - INDENT.length - (w * 2 + 6) + 1;
|
|
94
|
+
const out = [];
|
|
95
|
+
for (const l of lines) {
|
|
96
|
+
if (l.kind === "hunk") {
|
|
97
|
+
out.push(INDENT + c.accent(clip(safe(l.text), contentWidth() - INDENT.length + 1)));
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
const oldNo = l.oldLine === undefined ? "".padStart(w) : String(l.oldLine).padStart(w);
|
|
101
|
+
const newNo = l.newLine === undefined ? "".padStart(w) : String(l.newLine).padStart(w);
|
|
102
|
+
const sign = l.kind === " " ? " " : l.kind;
|
|
103
|
+
const paint = l.kind === "+" ? c.ok : l.kind === "-" ? c.err : c.dim;
|
|
104
|
+
// Tabs and control bytes would misalign the gutter; show them visibly.
|
|
105
|
+
const text = safe(l.text).replace(/\t/g, " ");
|
|
106
|
+
const parts = chunks(text, room);
|
|
107
|
+
parts.forEach((part, i) => {
|
|
108
|
+
const gutter = i === 0 ? `${sign} ${oldNo} ${newNo} │ ` : ` ${"".padStart(w)} ${"".padStart(w)} ┆ `;
|
|
109
|
+
out.push(INDENT + paint(gutter + part));
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
return out;
|
|
113
|
+
}
|
|
20
114
|
export function riskOf(plan) {
|
|
21
115
|
if (plan.name === "delete_file")
|
|
22
116
|
return "high";
|
|
@@ -27,61 +121,214 @@ export function riskOf(plan) {
|
|
|
27
121
|
const safe = stripControl;
|
|
28
122
|
const INDENT = MARGIN + " ";
|
|
29
123
|
const inner = () => Math.max(24, contentWidth() - 4);
|
|
30
|
-
|
|
124
|
+
/** Explanatory text, wrapped to the terminal at the given indent. */
|
|
125
|
+
const notes = (indent, text) => wrapText(text, Math.max(16, contentWidth() - indent.length - 1)).map((l) => indent + c.dim(l));
|
|
126
|
+
function planLines(plan, index, total, activeRoot) {
|
|
31
127
|
const risk = riskOf(plan);
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
|
|
128
|
+
const riskLabel = risk.toUpperCase();
|
|
129
|
+
const riskText = risk === "high" ? c.err(riskLabel) : risk === "medium" ? c.warn(riskLabel) : c.dim(riskLabel);
|
|
130
|
+
const counter = total > 1 ? `${index + 1}/${total} ` : "";
|
|
131
|
+
const hunks = plan.diff.hunks.length;
|
|
132
|
+
const out = [""];
|
|
133
|
+
// WHICH repository, ABOVE the path — a change can target a repository that is
|
|
134
|
+
// not the active one, so the name is part of what is being approved and must
|
|
135
|
+
// be read before the path it qualifies.
|
|
136
|
+
if (plan.repositoryName)
|
|
137
|
+
out.push(MARGIN + c.dim("Repository ") + c.value(safe(plan.repositoryName)));
|
|
138
|
+
// File boundary: the path (and its position in the group), never clipped —
|
|
139
|
+
// it is what is being approved.
|
|
140
|
+
const head = counter + safe(plan.rel);
|
|
141
|
+
for (const part of chunks(head, contentWidth() - MARGIN.length - 1))
|
|
142
|
+
out.push(MARGIN + c.file(part));
|
|
143
|
+
// The full location is part of what is approved: wrapped, never clipped.
|
|
144
|
+
if (plan.repositoryRoot && plan.repositoryRoot !== activeRoot) {
|
|
145
|
+
chunks(safe(plan.repositoryRoot), contentWidth() - INDENT.length - 10).forEach((part, i) => out.push(INDENT + c.dim(i === 0 ? "Location " : " ") + part));
|
|
46
146
|
}
|
|
47
147
|
if (plan.reverts)
|
|
48
148
|
out.push(INDENT + c.dim(`undoes ${plan.reverts}`));
|
|
49
|
-
for (const [i, l] of wrapText(safe(plan.reason), inner() - 8).entries()) {
|
|
50
|
-
out.push(INDENT + c.dim(i === 0 ? "Why " : " ") + c.dim(l));
|
|
51
|
-
}
|
|
52
149
|
out.push("");
|
|
53
150
|
if (plan.name === "delete_file") {
|
|
54
151
|
out.push(INDENT + c.err(`The whole file (${plan.diff.removed} lines) will be removed.`));
|
|
55
152
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
else if (l.startsWith("+++") || l.startsWith("---"))
|
|
61
|
-
continue; // the path is in the header
|
|
62
|
-
else if (l.startsWith("+"))
|
|
63
|
-
out.push(INDENT + c.ok(l));
|
|
64
|
-
else if (l.startsWith("-"))
|
|
65
|
-
out.push(INDENT + c.err(l));
|
|
66
|
-
else
|
|
67
|
-
out.push(INDENT + c.dim(l));
|
|
153
|
+
out.push(...hunkLines(plan));
|
|
154
|
+
if (plan.lineEndings) {
|
|
155
|
+
const { before, after } = plan.lineEndings;
|
|
156
|
+
out.push(INDENT + c.warn(`${plan.diff.hunks.length ? "Also changes" : "Changes only"} the line endings: ${before} → ${after}.`));
|
|
68
157
|
}
|
|
69
|
-
if (plan.diff.hunks.length === 0)
|
|
158
|
+
else if (plan.diff.hunks.length === 0)
|
|
70
159
|
out.push(INDENT + c.dim("(no line changes)"));
|
|
71
160
|
out.push("");
|
|
161
|
+
// Reason, the operation ID (the one the receipt, journal, audit events and
|
|
162
|
+
// Admin activity already use) and the risk: what the person is deciding on.
|
|
163
|
+
const field = (label, value, paint = c.value) => wrapText(value, Math.max(12, inner() - 14)).map((l, i) => INDENT + c.dim((i === 0 ? label : "").padEnd(14)) + paint(l));
|
|
164
|
+
out.push(...field("Reason", safe(plan.reason), c.dim));
|
|
165
|
+
out.push(...field("Operation ID", safe(plan.operationId)));
|
|
166
|
+
out.push(INDENT + c.dim("Risk".padEnd(14)) + riskText);
|
|
167
|
+
out.push(...field("Change", `${ACTION[plan.name] ?? "change"} · +${plan.diff.added} −${plan.diff.removed} · ${hunks} ${hunks === 1 ? "hunk" : "hunks"}`, c.dim));
|
|
72
168
|
return out;
|
|
73
169
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const
|
|
170
|
+
/** The changed-files list: one row per file in the reviewed group, all expanded below. */
|
|
171
|
+
function fileList(plans) {
|
|
172
|
+
const added = plans.reduce((n, p) => n + p.diff.added, 0);
|
|
173
|
+
const removed = plans.reduce((n, p) => n + p.diff.removed, 0);
|
|
174
|
+
const pathWidth = Math.max(8, Math.min(48, contentWidth() - 24, plans.reduce((n, p) => Math.max(n, visibleWidth(safe(p.rel))), 0)));
|
|
175
|
+
return [
|
|
176
|
+
MARGIN + c.value(`${plans.length} file${plans.length === 1 ? "" : "s"} changed`) + c.dim(" · ") + c.ok(`+${added}`) + " " + c.err(`−${removed}`),
|
|
177
|
+
...(plans.length > 1
|
|
178
|
+
? plans.map((p) => INDENT + c.dim("▾ ") + c.warn(STATUS[p.name] ?? "M") + " " + c.file(clip(safe(p.rel), pathWidth).padEnd(pathWidth)) + c.dim(` +${p.diff.added} −${p.diff.removed}`))
|
|
179
|
+
: [])
|
|
180
|
+
];
|
|
181
|
+
}
|
|
182
|
+
export function renderGroup(plans, correction = false, remaining = 0, activeRoot) {
|
|
183
|
+
const files = plans.length;
|
|
184
|
+
const detail = correction
|
|
185
|
+
? `New diff from fresh reads after the failed validation — the earlier approval does not cover it. Nothing has been written yet (${files} file${files === 1 ? "" : "s"}).`
|
|
186
|
+
: `Nothing has been written yet (${files} file${files === 1 ? "" : "s"}). Tests run only after their own approval.`;
|
|
187
|
+
return [
|
|
188
|
+
...cardHeader(correction ? "CORRECTIVE CHANGE" : "PROPOSED CHANGE", c.title),
|
|
189
|
+
...(plans.length > 1 ? fileList(plans) : []),
|
|
190
|
+
...plans.flatMap((p, i) => planLines(p, i, plans.length, activeRoot)),
|
|
191
|
+
...(remaining ? ["", ...notes(MARGIN, `${remaining} other planned file${remaining === 1 ? "" : "s"} still require review.`)] : []),
|
|
192
|
+
...approvalCard(correction ? "correction" : "change", detail, []),
|
|
193
|
+
...notes(MARGIN, "PgUp/PgDn scrolls the diff."),
|
|
194
|
+
""
|
|
195
|
+
];
|
|
196
|
+
}
|
|
197
|
+
/** The card shown when an approved diff no longer matches the file on disk. */
|
|
198
|
+
export function renderNoLongerValid(rels) {
|
|
199
|
+
return [
|
|
200
|
+
...cardHeader("⚠ CHANGE INVALIDATED", c.warn),
|
|
201
|
+
...rels.flatMap((rel) => wrapText(`${safe(rel)} changed after this proposal.`, Math.max(16, contentWidth() - MARGIN.length - 1)).map((l) => MARGIN + c.value(l))),
|
|
202
|
+
...notes(MARGIN, "The approved diff is no longer based on the current file. No files were modified by it."),
|
|
203
|
+
...notes(MARGIN, "A fresh proposal and a new approval are required."),
|
|
204
|
+
""
|
|
205
|
+
];
|
|
206
|
+
}
|
|
207
|
+
/** The card shown when the person declines a proposed change. */
|
|
208
|
+
export function renderChangeRejected(plans) {
|
|
77
209
|
return [
|
|
78
|
-
"",
|
|
79
|
-
MARGIN + c.
|
|
80
|
-
|
|
81
|
-
|
|
210
|
+
...cardHeader("CHANGE REJECTED", c.warn),
|
|
211
|
+
MARGIN + c.value("No files were modified."),
|
|
212
|
+
...plans.map((p) => INDENT + c.file(safe(p.rel)) + c.dim(` · ${safe(p.operationId)}`)),
|
|
213
|
+
""
|
|
82
214
|
];
|
|
83
215
|
}
|
|
84
|
-
/**
|
|
216
|
+
/**
|
|
217
|
+
* After a planned validation fails: what failed, and what happens next. Built
|
|
218
|
+
* from the workflow's own validation projection — the command identity and
|
|
219
|
+
* exit status it recorded — plus the counts the command result card read from
|
|
220
|
+
* the actual output. Never from model text.
|
|
221
|
+
*/
|
|
222
|
+
export function renderValidationFailed(snapshot, counts = "", failure) {
|
|
223
|
+
const validation = Array.isArray(snapshot.validation) ? snapshot.validation : [];
|
|
224
|
+
const tests = Array.isArray(snapshot.tests) ? snapshot.tests : [];
|
|
225
|
+
const failed = validation.filter((v) => v.status === "FAILED");
|
|
226
|
+
const failedCount = /(\d+) failed/.exec(counts)?.[1];
|
|
227
|
+
const out = [...cardHeader("✗ VALIDATION FAILED", c.err)];
|
|
228
|
+
if (failedCount)
|
|
229
|
+
out.push(MARGIN + c.err(`✗ ${failedCount} test${failedCount === "1" ? "" : "s"} failed`));
|
|
230
|
+
else if (counts)
|
|
231
|
+
out.push(MARGIN + c.dim(safe(counts)));
|
|
232
|
+
if (failure?.name)
|
|
233
|
+
out.push(...wrapText(safe(failure.name), inner()).map((l) => MARGIN + c.value(l)));
|
|
234
|
+
if (failure?.expected)
|
|
235
|
+
out.push(MARGIN + c.dim("Expected: ") + c.ok(clip(safe(failure.expected), Math.max(8, inner() - 12))));
|
|
236
|
+
if (failure?.received)
|
|
237
|
+
out.push(MARGIN + c.dim("Received: ") + c.err(clip(safe(failure.received), Math.max(8, inner() - 12))));
|
|
238
|
+
for (const v of failed) {
|
|
239
|
+
const args = Array.isArray(v.args) ? v.args.filter((a) => typeof a === "string") : [];
|
|
240
|
+
const exit = tests.find((t) => t.id === v.operation_id)?.exit;
|
|
241
|
+
out.push(MARGIN + c.dim(clip(safe([String(v.program ?? ""), ...args].join(" ")), inner() - 16) + ` · exit ${exit ?? "unknown"}`));
|
|
242
|
+
}
|
|
243
|
+
out.push(...notes(MARGIN, "A correction, if any, is a new diff with its own approval."), "");
|
|
244
|
+
return out;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* The coordinator's applied-change confirmations, laid out as an "applying"
|
|
248
|
+
* block. Display only: the coordinator's own text is parsed, never changed, and
|
|
249
|
+
* anything that is not an apply confirmation is shown as it was sent.
|
|
250
|
+
*/
|
|
251
|
+
const APPLIED_LINE = /^✓\s+(\S+)\s+(.+?)\s+\(\+(\d+)\s+−(\d+)\)\s+·\s+Applied\s+·\s+(\S+)$/;
|
|
85
252
|
export function renderChangeSummary(lines) {
|
|
86
|
-
|
|
253
|
+
const applied = lines.map((l) => APPLIED_LINE.exec(stripControl(l).trim())).filter((m) => !!m);
|
|
254
|
+
const other = lines.filter((l) => !APPLIED_LINE.test(stripControl(l).trim()));
|
|
255
|
+
const out = [];
|
|
256
|
+
if (applied.length) {
|
|
257
|
+
out.push("", MARGIN + c.title(applied.length === 1 ? "Applying change…" : `Applying ${applied.length} changes…`));
|
|
258
|
+
for (const [, verb, rel, added, removed] of applied) {
|
|
259
|
+
const what = verb === "Deleted" ? "File deleted" : verb === "Created" ? "File created" : "File updated";
|
|
260
|
+
const counts = ` +${added} −${removed}`;
|
|
261
|
+
const oneLine = `${MARGIN} ✓ ${what} · ${rel}${counts}`;
|
|
262
|
+
if (visibleWidth(oneLine) <= contentWidth() - 1) {
|
|
263
|
+
out.push(MARGIN + " " + c.ok("✓ ") + c.value(what) + c.dim(" · ") + c.file(rel) + c.dim(counts));
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
// A long path wraps on its own lines rather than running off the edge.
|
|
267
|
+
out.push(MARGIN + " " + c.ok("✓ ") + c.value(what) + c.dim(counts));
|
|
268
|
+
for (const part of chunks(rel, contentWidth() - MARGIN.length - 5))
|
|
269
|
+
out.push(MARGIN + " " + c.file(part));
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
out.push(MARGIN + " " + c.ok("✓ ") + c.value(applied.length === 1 ? "Mutation completed" : "Mutations completed"));
|
|
273
|
+
for (const m of applied)
|
|
274
|
+
out.push(MARGIN + " " + c.dim("Operation ID: ") + c.value(m[5]));
|
|
275
|
+
}
|
|
276
|
+
for (const l of other)
|
|
277
|
+
out.push(MARGIN + (l.includes("✓") ? c.ok(l.trim()) : c.warn(l.trim())));
|
|
278
|
+
return out;
|
|
279
|
+
}
|
|
280
|
+
/** Bounded display projection of existing coordinator events, never an authority. */
|
|
281
|
+
export class ActiveChangeView {
|
|
282
|
+
snapshot;
|
|
283
|
+
paint;
|
|
284
|
+
entries = new Map();
|
|
285
|
+
lastActive;
|
|
286
|
+
constructor(snapshot, paint) {
|
|
287
|
+
this.snapshot = snapshot;
|
|
288
|
+
this.paint = paint;
|
|
289
|
+
}
|
|
290
|
+
review(plans) {
|
|
291
|
+
for (const plan of plans)
|
|
292
|
+
this.entries.set(plan.operationId, { plan: { ...plan }, status: "awaiting approval" });
|
|
293
|
+
while (this.entries.size > 8)
|
|
294
|
+
this.entries.delete(this.entries.keys().next().value);
|
|
295
|
+
this.refresh();
|
|
296
|
+
}
|
|
297
|
+
decision(plans, answer) {
|
|
298
|
+
for (const plan of plans) {
|
|
299
|
+
const entry = this.entries.get(plan.operationId);
|
|
300
|
+
if (entry)
|
|
301
|
+
entry.status = answer === "approve" ? "approved; awaiting verified result" : answer === "reject" ? "rejected" : answer;
|
|
302
|
+
}
|
|
303
|
+
this.refresh();
|
|
304
|
+
}
|
|
305
|
+
result(payload) {
|
|
306
|
+
const entry = this.entries.get(payload.tool_call_id);
|
|
307
|
+
if (entry)
|
|
308
|
+
entry.status = payload.ok ? "applied" : payload.error?.code === "MUTATION_REJECTED" ? "rejected" : payload.error?.code === "STALE_FILE" ? "invalidated" : payload.error?.code ?? "unresolved";
|
|
309
|
+
this.refresh();
|
|
310
|
+
}
|
|
311
|
+
commandStatus(value) { void value; this.refresh(); }
|
|
312
|
+
refresh() {
|
|
313
|
+
const state = this.snapshot();
|
|
314
|
+
// The status track appears once there is a coding plan; ordinary
|
|
315
|
+
// questions never get one. It is a projection of CodingWorkflow state.
|
|
316
|
+
if (!state.plan && !this.entries.size)
|
|
317
|
+
return;
|
|
318
|
+
const current = String(state.state ?? "");
|
|
319
|
+
if (!["FAILED", "CANCELLED", "UNRESOLVED"].includes(current))
|
|
320
|
+
this.lastActive = current;
|
|
321
|
+
const lines = [statusTrack(state, this.lastActive)];
|
|
322
|
+
const entries = [...this.entries.values()];
|
|
323
|
+
// Verification is the workflow's: shown only once a change is applied.
|
|
324
|
+
const validation = Array.isArray(state.validation) ? state.validation : [];
|
|
325
|
+
const verification = !validation.length ? "" : validation.every(v => v.status === "PASSED") ? "verification passed" : validation.some(v => v.status === "FAILED") ? "verification failed" : "verification pending";
|
|
326
|
+
for (const { plan, status } of entries.slice(-2)) {
|
|
327
|
+
lines.push(MARGIN + c.file(safe(plan.rel)) + c.dim(` · ${safe(status)}${status === "applied" && verification ? ` · ${verification}` : ""}`));
|
|
328
|
+
}
|
|
329
|
+
if (entries.length > 2)
|
|
330
|
+
lines.push(MARGIN + c.dim(`+${entries.length - 2} earlier changes · PgUp for reviews`));
|
|
331
|
+
this.paint(lines.map(l => clip(l, contentWidth())));
|
|
332
|
+
}
|
|
333
|
+
clear() { this.entries.clear(); this.lastActive = undefined; this.paint([]); }
|
|
87
334
|
}
|
package/dist/ui/chat-renderer.js
CHANGED
|
@@ -5,6 +5,7 @@ import { contentWidth } from "./composer-layout.js";
|
|
|
5
5
|
import { renderMarkdown } from "./markdown.js";
|
|
6
6
|
import { renderUserMessage } from "./message.js";
|
|
7
7
|
import { thinking } from "./spinner.js";
|
|
8
|
+
import { formatCredits } from "./ui.js";
|
|
8
9
|
/**
|
|
9
10
|
* Presentation layer for the conversation, styled after Claude Code:
|
|
10
11
|
* ❯ <your message> (full-width bar — see message.ts)
|
|
@@ -66,9 +67,8 @@ function completionLabel(seconds, spend) {
|
|
|
66
67
|
return `${phrase} ${Math.max(0.1, seconds).toFixed(1)}s${spendSuffix(spend)}`;
|
|
67
68
|
}
|
|
68
69
|
/** Format a number with thousands separators, trimming pointless decimals. */
|
|
69
|
-
const num = (n, dp = 0) => n.toLocaleString("en-US", { minimumFractionDigits: dp, maximumFractionDigits: dp });
|
|
70
70
|
/**
|
|
71
|
-
* " · 412.
|
|
71
|
+
* " · 412.60 credits left"
|
|
72
72
|
*
|
|
73
73
|
* Balance only. Tokens and dollar cost are still returned by the API (and used
|
|
74
74
|
* for request logging), but three numbers on a completion line is a bill, not a
|
|
@@ -85,7 +85,7 @@ export function spendSuffix(spend) {
|
|
|
85
85
|
// cost. The balance itself is unchanged and still shown by /usage.
|
|
86
86
|
if (spend?.unlimited === true) {
|
|
87
87
|
return typeof spend.sessionSpent === "number"
|
|
88
|
-
? ` · Unlimited · session ${
|
|
88
|
+
? ` · Unlimited · session ${formatCredits(spend.sessionSpent)} credits`
|
|
89
89
|
: " · Unlimited";
|
|
90
90
|
}
|
|
91
91
|
const credits = spend?.creditsRemaining;
|
|
@@ -93,8 +93,8 @@ export function spendSuffix(spend) {
|
|
|
93
93
|
return "";
|
|
94
94
|
// A negative balance is an overdraft, not "-556 left" — say what it is.
|
|
95
95
|
return credits < 0
|
|
96
|
-
? ` · ${
|
|
97
|
-
: ` · ${
|
|
96
|
+
? ` · ${formatCredits(Math.abs(credits))} credits overdrawn`
|
|
97
|
+
: ` · ${formatCredits(credits)} credits left`;
|
|
98
98
|
}
|
|
99
99
|
// Rotating tips shown beneath the spinner while Carrier is responding — a chance
|
|
100
100
|
// to surface a handy shortcut, the way Claude Code does.
|
|
@@ -280,7 +280,7 @@ export async function streamAssistant(text) {
|
|
|
280
280
|
md.shift();
|
|
281
281
|
while (md.length && md[md.length - 1].trim() === "")
|
|
282
282
|
md.pop();
|
|
283
|
-
const tty = process.stdout.isTTY;
|
|
283
|
+
const tty = process.stdout.isTTY && process.env.TERM !== "dumb";
|
|
284
284
|
if (tty)
|
|
285
285
|
process.stdout.write("\x1b[?25l"); // hide the caret; ▋ is the cursor
|
|
286
286
|
for (let i = 0; i < md.length; i++) {
|
package/dist/ui/colors.js
CHANGED
|
@@ -24,8 +24,8 @@ export const c = {
|
|
|
24
24
|
brandFixed: chalk.hex(BRAND_HEX), // fixed brand green — wordmark + prompt marker, never follows /color
|
|
25
25
|
wordmark: chalk.whiteBright.bold, // CARRIER block logo (never recolored)
|
|
26
26
|
// Text
|
|
27
|
-
title: chalk.
|
|
28
|
-
value: chalk
|
|
27
|
+
title: chalk.bold, // section titles / headings
|
|
28
|
+
value: chalk, // primary values
|
|
29
29
|
dim: chalk.dim, // secondary text
|
|
30
30
|
subtitle: chalk.dim,
|
|
31
31
|
label: chalk.dim, // metadata labels
|
|
@@ -33,23 +33,23 @@ export const c = {
|
|
|
33
33
|
rule: chalk.dim, // separators / rules
|
|
34
34
|
placeholder: chalk.dim.italic, // composer placeholder (fades into the background)
|
|
35
35
|
// Interactive
|
|
36
|
-
cmd
|
|
37
|
-
key
|
|
38
|
-
accent
|
|
36
|
+
get cmd() { return chalk.hex(accentHex()); }, // slash commands
|
|
37
|
+
get key() { return chalk.hex(accentHex()); }, // keybindings / command keys
|
|
38
|
+
get accent() { return chalk.hex(accentHex()); },
|
|
39
39
|
get sel() {
|
|
40
40
|
return chalk.bgHex(accentHex()).black.bold;
|
|
41
41
|
}, // selected palette bar (accent background)
|
|
42
42
|
group: chalk.dim.bold, // palette group headers
|
|
43
43
|
// Command arguments
|
|
44
|
-
arg: chalk
|
|
45
|
-
file: chalk
|
|
44
|
+
arg: chalk, // ids / values (mode, model)
|
|
45
|
+
file: chalk, // file paths
|
|
46
46
|
// SIA / clarification — deliberately not the yellow the turn-shape chips use,
|
|
47
47
|
// because it isn't one: Fast and HIPWR change how the answer is produced,
|
|
48
48
|
// while this changes the question before it's asked.
|
|
49
|
-
magic
|
|
49
|
+
get magic() { return chalk.hex(accentHex()); },
|
|
50
50
|
// Status
|
|
51
51
|
ok: chalk.green,
|
|
52
52
|
warn: chalk.yellow,
|
|
53
|
-
info
|
|
53
|
+
get info() { return chalk.hex(accentHex()); },
|
|
54
54
|
err: chalk.red
|
|
55
55
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { stripControl } from "./conversation.js";
|
|
2
|
+
// Ephemeral display cache only. The existing result/outbox owns durable evidence.
|
|
3
|
+
const last = new WeakMap();
|
|
4
|
+
export function rememberCommandDetails(ctx, scope, output) {
|
|
5
|
+
last.set(ctx, { scope, output: stripControl(output) });
|
|
6
|
+
}
|
|
7
|
+
export function commandDetails(ctx, scope) {
|
|
8
|
+
const entry = last.get(ctx);
|
|
9
|
+
return entry?.scope === scope ? ["Command output (existing bounded, redacted result)", ...entry.output.split("\n")] : ["No command output available for this session and repository."];
|
|
10
|
+
}
|
|
11
|
+
export function clearCommandDetails(ctx) { last.delete(ctx); }
|
|
@@ -12,8 +12,8 @@ function colorOf(name) {
|
|
|
12
12
|
const m = name.match(/^\/(?:color|theme)\s+(\w+)$/i);
|
|
13
13
|
return m && isThemeColor(m[1].toLowerCase()) ? m[1].toLowerCase() : null;
|
|
14
14
|
}
|
|
15
|
-
export function readCommand(caret, history, footer = "", placeholder = "") {
|
|
16
|
-
if (!process.stdin.isTTY)
|
|
15
|
+
export function readCommand(caret, history, footer = "", placeholder = "", locked = () => false) {
|
|
16
|
+
if (!process.stdin.isTTY || process.env.TERM === "dumb")
|
|
17
17
|
return readSimple(caret);
|
|
18
18
|
return new Promise((resolve) => {
|
|
19
19
|
const stdin = process.stdin;
|
|
@@ -98,9 +98,9 @@ export function readCommand(caret, history, footer = "", placeholder = "") {
|
|
|
98
98
|
const pad = " ".repeat(Math.max(0, total - promptCols));
|
|
99
99
|
// The two divider rules carry the runtime accent (/color); the prompt
|
|
100
100
|
// marker stays fixed brand green (branding, never recolored).
|
|
101
|
-
const rule = MARGIN + c.
|
|
102
|
-
const promptLine = MARGIN + c.
|
|
103
|
-
const core = [rule, promptLine, rule, footer]; // fixed 4-row composer core
|
|
101
|
+
const rule = MARGIN + c.rule("─".repeat(total));
|
|
102
|
+
const promptLine = MARGIN + c.brand("›") + " " + body + (visTrailer ? c.dim(visTrailer) : "") + pad;
|
|
103
|
+
const core = [rule, promptLine, rule, typeof footer === "function" ? footer() : footer]; // fixed 4-row composer core
|
|
104
104
|
// The command palette floats ABOVE the bar when open — except in the
|
|
105
105
|
// value-entry context (`/color <value>`), where the inline arg hint / ghost
|
|
106
106
|
// on the prompt line replaces the list. The caret sits on the prompt line
|
|
@@ -115,6 +115,16 @@ export function readCommand(caret, history, footer = "", placeholder = "") {
|
|
|
115
115
|
const caretCol = MARGIN.length + MARKER_COLS + (cursor - start) + 1;
|
|
116
116
|
screenComposer(paletteLines, core, 1, caretCol);
|
|
117
117
|
};
|
|
118
|
+
process.stdout.on("resize", render);
|
|
119
|
+
let lastFooter = typeof footer === "function" ? footer() : footer;
|
|
120
|
+
const footerTimer = setInterval(() => {
|
|
121
|
+
const next = typeof footer === "function" ? footer() : footer;
|
|
122
|
+
if (next !== lastFooter) {
|
|
123
|
+
lastFooter = next;
|
|
124
|
+
render();
|
|
125
|
+
}
|
|
126
|
+
}, 500);
|
|
127
|
+
footerTimer.unref();
|
|
118
128
|
const finish = (res) => {
|
|
119
129
|
paletteOpen = false;
|
|
120
130
|
// Undo any live color preview — the /color command re-applies + persists
|
|
@@ -126,16 +136,18 @@ export function readCommand(caret, history, footer = "", placeholder = "") {
|
|
|
126
136
|
// Clear the composer to an empty prompt so the just-submitted text doesn't
|
|
127
137
|
// linger in the bar while the response streams into the transcript above.
|
|
128
138
|
const total = contentWidth();
|
|
129
|
-
const rule = MARGIN + c.
|
|
130
|
-
const empty = MARGIN + c.
|
|
131
|
-
screenComposer([], [rule, empty, rule, footer], 1, MARGIN.length + MARKER_COLS + 1);
|
|
139
|
+
const rule = MARGIN + c.rule("─".repeat(total));
|
|
140
|
+
const empty = MARGIN + c.brand("›") + " " + " ".repeat(Math.max(0, total - MARKER_COLS));
|
|
141
|
+
screenComposer([], [rule, empty, rule, typeof footer === "function" ? footer() : footer], 1, MARGIN.length + MARKER_COLS + 1);
|
|
142
|
+
clearInterval(footerTimer);
|
|
143
|
+
process.stdout.removeListener("resize", render);
|
|
132
144
|
stdin.removeListener("keypress", onKey);
|
|
133
145
|
// Raw mode is intentionally left ON between prompts (see the setup note);
|
|
134
146
|
// the shell restores cooked mode when it exits.
|
|
135
147
|
resolve(res);
|
|
136
148
|
};
|
|
137
149
|
const setInput = (next, open) => {
|
|
138
|
-
input = next;
|
|
150
|
+
input = locked() && !next.startsWith("/") ? "" : next;
|
|
139
151
|
cursor = input.length;
|
|
140
152
|
paletteOpen = open ?? input.startsWith("/");
|
|
141
153
|
if (paletteOpen) {
|
|
@@ -228,6 +240,8 @@ export function readCommand(caret, history, footer = "", placeholder = "") {
|
|
|
228
240
|
if (key.name === "end" && input.length === 0)
|
|
229
241
|
return screenScrollToBottom();
|
|
230
242
|
if (key.name === "return" || key.name === "enter") {
|
|
243
|
+
if (locked() && !input.startsWith("/"))
|
|
244
|
+
return render();
|
|
231
245
|
// Value-entry (`/color <value>`): run what's typed, completing any ghost
|
|
232
246
|
// first (`/color gr` → `/color green`; a bare `/color ` → the picker).
|
|
233
247
|
if (paletteOpen && /^\/(?:color|theme)\s/i.test(input)) {
|
|
@@ -329,7 +343,10 @@ export function readCommand(caret, history, footer = "", placeholder = "") {
|
|
|
329
343
|
}
|
|
330
344
|
// Printable character.
|
|
331
345
|
if (str && !key.ctrl && !key.meta && str >= " " && str !== "\x7f") {
|
|
332
|
-
|
|
346
|
+
const next = input.slice(0, cursor) + str + input.slice(cursor);
|
|
347
|
+
if (locked() && !next.startsWith("/"))
|
|
348
|
+
return;
|
|
349
|
+
input = next;
|
|
333
350
|
cursor += str.length;
|
|
334
351
|
if (input.startsWith("/")) {
|
|
335
352
|
paletteOpen = true;
|
|
@@ -21,6 +21,7 @@ export const GROUP_ORDER = [
|
|
|
21
21
|
"Developer"
|
|
22
22
|
];
|
|
23
23
|
export const COMMANDS = [
|
|
24
|
+
{ name: "/details", desc: "Show the last bounded command output", group: "Context", rank: 10 },
|
|
24
25
|
{ name: "/chat", desc: "Start chatting with Carrier", group: "Chat", rank: 1 },
|
|
25
26
|
{ name: "/switch", desc: "Switch chat: Carrier ⇄ Standard", group: "Chat", rank: 2 },
|
|
26
27
|
{ name: "/websearch", desc: "Search the web — or a query to search now", group: "Chat", rank: 3, arg: "query" },
|
|
@@ -53,13 +54,18 @@ export const COMMANDS = [
|
|
|
53
54
|
arg: "question"
|
|
54
55
|
},
|
|
55
56
|
{ name: "/new", desc: "Start a new conversation", group: "Sessions", rank: 1, arg: "title" },
|
|
57
|
+
{ name: "/clear", desc: "Start a new task — the current one stays in /sessions", group: "Sessions", rank: 1 },
|
|
58
|
+
{ name: "/resume", desc: "Continue an earlier conversation (its permission mode, never its approvals)", group: "Sessions", rank: 2 },
|
|
56
59
|
{ name: "/sessions", desc: "List conversations, numbered", group: "Sessions", rank: 2 },
|
|
57
60
|
{ name: "/session", desc: "Continue a session — /session 2", group: "Sessions", rank: 3, arg: "n" },
|
|
58
61
|
{ name: "/history", desc: "Transcript — /history 2", group: "Sessions", rank: 4, arg: "n" },
|
|
59
62
|
{ name: "/context", desc: "What the next message is sent with — try /context project", group: "Context", rank: 1, arg: "project" },
|
|
60
63
|
{ name: "/memory", desc: "Snapshots and restructures — /memory 2", group: "Context", rank: 2, arg: "n" },
|
|
64
|
+
{ name: "/compact", desc: "Summarise earlier messages; keep the task, plan, changes and tests", group: "Context", rank: 2 },
|
|
65
|
+
{ name: "/permissions", desc: "Manual · Plan · Accept Edits · Auto", group: "Chat", rank: 1, arg: "manual|plan|accept-edits|auto" },
|
|
66
|
+
{ name: "/plan", desc: "Plan mode — investigate and plan; no changes or commands", group: "Chat", rank: 1 },
|
|
61
67
|
{ name: "/model", desc: "List & switch provider model", group: "Models", rank: 1, arg: "model" },
|
|
62
|
-
{ name: "/mode", desc: "
|
|
68
|
+
{ name: "/mode", desc: "Carrier mode — or /mode manual|plan|accept-edits for permissions", group: "Models", rank: 2, arg: "mode" },
|
|
63
69
|
{ name: "/upload", desc: "Upload file(s) — many + * globs", group: "Files", rank: 1, arg: "path" },
|
|
64
70
|
{ name: "/attach", desc: "Attach an upload to your next message", group: "Files", rank: 2, arg: "file" },
|
|
65
71
|
{ name: "/detach", desc: "Clear attached files", group: "Files", rank: 3 },
|
|
@@ -70,9 +76,9 @@ export const COMMANDS = [
|
|
|
70
76
|
{ name: "/undo", desc: "Undo the latest change — /undo --repo <name> for another repository", group: "Files", rank: 7, arg: "operation" },
|
|
71
77
|
{ name: "/repo", desc: "Active repository — /repo use <name> to switch", group: "Context", rank: 3, arg: "use" },
|
|
72
78
|
{ name: "/repos", desc: "Repositories in this workspace", group: "Context", rank: 4 },
|
|
73
|
-
{ name: "/whoami", desc: "
|
|
79
|
+
{ name: "/whoami", desc: "Your signed-in account", group: "Account", rank: 1 },
|
|
74
80
|
{ name: "/usage", desc: "View API usage", group: "Account", rank: 2 },
|
|
75
|
-
{ name: "/settings", desc: "CLI settings —
|
|
81
|
+
{ name: "/settings", desc: "CLI settings — commands, updates, channel, update-interval", group: "Account", rank: 3, arg: "commands" },
|
|
76
82
|
{ name: "/login", desc: "Sign in via your browser", group: "Account", rank: 3 },
|
|
77
83
|
{ name: "/logout", desc: "Remove saved credentials", group: "Account", rank: 4 },
|
|
78
84
|
{ name: "/help", desc: "Show available commands", group: "Developer", rank: 1 },
|
|
@@ -81,7 +87,7 @@ export const COMMANDS = [
|
|
|
81
87
|
{ name: "/version", desc: "Show CLI version", group: "Developer", rank: 4 },
|
|
82
88
|
{
|
|
83
89
|
name: "/update",
|
|
84
|
-
desc: "Check for and install the latest CLI version",
|
|
90
|
+
desc: "Check for and install the latest CLI version (your update channel)",
|
|
85
91
|
group: "Developer",
|
|
86
92
|
rank: 5
|
|
87
93
|
},
|
|
@@ -90,6 +96,7 @@ export const COMMANDS = [
|
|
|
90
96
|
/** Commands that take an argument — completed with a trailing space. */
|
|
91
97
|
export const TAKES_ARG = new Set([
|
|
92
98
|
"/mode",
|
|
99
|
+
"/permissions",
|
|
93
100
|
"/model",
|
|
94
101
|
"/websearch",
|
|
95
102
|
"/fast",
|