@carrieros/cli 0.2.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.
Files changed (124) hide show
  1. package/README.md +170 -64
  2. package/dist/commands/attach.js +45 -0
  3. package/dist/commands/btw.js +78 -0
  4. package/dist/commands/changes.js +167 -0
  5. package/dist/commands/chat.js +81 -15
  6. package/dist/commands/context.js +200 -0
  7. package/dist/commands/doctor.js +63 -3
  8. package/dist/commands/files.js +84 -23
  9. package/dist/commands/help.js +1 -0
  10. package/dist/commands/history.js +88 -23
  11. package/dist/commands/login.js +31 -7
  12. package/dist/commands/logout.js +1 -0
  13. package/dist/commands/memory.js +162 -0
  14. package/dist/commands/mode-model.js +39 -3
  15. package/dist/commands/modes.js +4 -1
  16. package/dist/commands/permissions.js +77 -0
  17. package/dist/commands/project.js +106 -0
  18. package/dist/commands/repo.js +146 -0
  19. package/dist/commands/repos.js +61 -0
  20. package/dist/commands/review.js +92 -0
  21. package/dist/commands/scope.js +9 -6
  22. package/dist/commands/search.js +92 -0
  23. package/dist/commands/sessions.js +224 -65
  24. package/dist/commands/settings.js +94 -0
  25. package/dist/commands/update.js +229 -0
  26. package/dist/commands/upload.js +204 -31
  27. package/dist/commands/usage.js +213 -17
  28. package/dist/commands/whoami.js +12 -9
  29. package/dist/ide/editor-context.js +275 -0
  30. package/dist/ide/ide-session.js +355 -0
  31. package/dist/ide/tool-host.js +109 -0
  32. package/dist/main.js +26 -1
  33. package/dist/services/api.js +315 -15
  34. package/dist/services/auth-origin.js +20 -0
  35. package/dist/services/chat-stream.js +168 -0
  36. package/dist/services/checkpoints.js +278 -0
  37. package/dist/services/client-tools.js +352 -0
  38. package/dist/services/code-intel.js +243 -0
  39. package/dist/services/code-symbols.js +94 -0
  40. package/dist/services/coding-workflow.js +554 -0
  41. package/dist/services/command-coordinator.js +273 -0
  42. package/dist/services/command-policy.js +434 -0
  43. package/dist/services/config.js +311 -24
  44. package/dist/services/container-runner.js +254 -0
  45. package/dist/services/container-supervisor.js +38 -0
  46. package/dist/services/context.js +296 -23
  47. package/dist/services/device-auth.js +72 -35
  48. package/dist/services/diff.js +196 -0
  49. package/dist/services/env-policy.js +108 -0
  50. package/dist/services/execution-platform.js +30 -0
  51. package/dist/services/file-detect.js +104 -0
  52. package/dist/services/file-resolver.js +199 -0
  53. package/dist/services/file-upload.js +126 -0
  54. package/dist/services/folder-key.js +22 -0
  55. package/dist/services/git-tools.js +429 -0
  56. package/dist/services/glob-match.js +164 -0
  57. package/dist/services/helper-bin.js +85 -0
  58. package/dist/services/ignore-rules.js +189 -0
  59. package/dist/services/instruction-resolver.js +54 -0
  60. package/dist/services/job-helper.js +328 -0
  61. package/dist/services/local-files.js +639 -0
  62. package/dist/services/local-tools.js +937 -0
  63. package/dist/services/login-flow.js +55 -17
  64. package/dist/services/meta.js +3 -1
  65. package/dist/services/mutation-coordinator.js +327 -0
  66. package/dist/services/mutation-groups.js +309 -0
  67. package/dist/services/mutation-recovery.js +159 -0
  68. package/dist/services/mutations.js +679 -0
  69. package/dist/services/open-url.js +68 -0
  70. package/dist/services/output.js +5 -2
  71. package/dist/services/packaged-update.js +403 -0
  72. package/dist/services/packaged.js +39 -0
  73. package/dist/services/permission-mode.js +60 -0
  74. package/dist/services/process-runner.js +412 -0
  75. package/dist/services/project-context.js +298 -0
  76. package/dist/services/redaction.js +201 -0
  77. package/dist/services/result-reconciliation.js +49 -0
  78. package/dist/services/secure-store.js +217 -0
  79. package/dist/services/session-resolver.js +113 -0
  80. package/dist/services/sia.js +51 -0
  81. package/dist/services/supported-runtime.js +59 -0
  82. package/dist/services/task-context.js +212 -0
  83. package/dist/services/task-snapshot.js +38 -0
  84. package/dist/services/tool-result-outbox.js +195 -0
  85. package/dist/services/update.js +311 -0
  86. package/dist/services/workspace-registry.js +310 -0
  87. package/dist/services/workspace.js +580 -0
  88. package/dist/shell/shell-chat.js +1297 -59
  89. package/dist/shell/shell-commands.js +243 -12
  90. package/dist/shell/shell-prompt.js +94 -11
  91. package/dist/shell/shell-renderer.js +8 -20
  92. package/dist/shell/shell-router.js +19 -3
  93. package/dist/shell/shell.js +252 -22
  94. package/dist/shell/task-context-view.js +40 -0
  95. package/dist/types/index.js +3 -1
  96. package/dist/ui/agent-cards.js +111 -0
  97. package/dist/ui/agent-presentation.js +131 -0
  98. package/dist/ui/approval.js +111 -0
  99. package/dist/ui/banner.js +31 -48
  100. package/dist/ui/btw-overlay.js +230 -0
  101. package/dist/ui/change-review.js +334 -0
  102. package/dist/ui/chat-renderer.js +207 -14
  103. package/dist/ui/colors.js +12 -8
  104. package/dist/ui/command-details.js +11 -0
  105. package/dist/ui/command-filter.js +26 -5
  106. package/dist/ui/command-palette.js +44 -14
  107. package/dist/ui/command-registry.js +92 -10
  108. package/dist/ui/command-review.js +187 -0
  109. package/dist/ui/composer-layout.js +48 -1
  110. package/dist/ui/conversation.js +450 -0
  111. package/dist/ui/interrupt.js +35 -0
  112. package/dist/ui/live.js +4 -2
  113. package/dist/ui/markdown.js +63 -9
  114. package/dist/ui/message.js +14 -31
  115. package/dist/ui/screen-prompt.js +181 -0
  116. package/dist/ui/screen.js +19 -11
  117. package/dist/ui/select.js +191 -29
  118. package/dist/ui/sia-qa.js +213 -0
  119. package/dist/ui/task-context-card.js +99 -0
  120. package/dist/ui/text-prompt.js +74 -0
  121. package/dist/ui/trust.js +88 -0
  122. package/dist/ui/ui.js +27 -1
  123. package/package.json +18 -4
  124. package/dist/ui/activity.js +0 -77
@@ -1,12 +1,32 @@
1
+ import { commandDetails } from "../ui/command-details.js";
2
+ import { workspaceRoot } from "../services/local-files.js";
3
+ import { line } from "../services/output.js";
1
4
  import { CommanderError } from "commander";
2
5
  import { ApiError } from "../services/api.js";
3
6
  import { AuthRequiredError } from "../services/context.js";
4
7
  import { errorLine, info } from "../services/output.js";
5
- import { COMMANDS } from "../ui/command-item.js";
8
+ import { askSideQuestion } from "../commands/btw.js";
9
+ import { runUpdate } from "../commands/update.js";
10
+ import { runSearch } from "../commands/search.js";
11
+ import { useRepository } from "../commands/repo.js";
12
+ import { showRepositories } from "../commands/repos.js";
13
+ import { runSettings } from "../commands/settings.js";
14
+ import { runReview } from "../commands/review.js";
15
+ import { runUndo, showChanges } from "../commands/changes.js";
16
+ import { runProject } from "../commands/project.js";
17
+ import { showContext } from "../commands/context.js";
18
+ import { listMemory, showArtifact } from "../commands/memory.js";
19
+ import { showHistory } from "../commands/history.js";
20
+ import { deleteSession, newSession, pickSession, switchTo } from "../commands/sessions.js";
21
+ import { clearActiveSession } from "../services/session-resolver.js";
22
+ import { runCompact, runPermissions } from "../commands/permissions.js";
23
+ import { parsePermissionMode } from "../services/permission-mode.js";
24
+ import { visibleCommands } from "../ui/command-item.js";
6
25
  import { confirmColor, pickColor } from "../ui/color-picker.js";
7
26
  import { pickFromList } from "../ui/select.js";
8
27
  import { isThemeColor, setAccent, THEME_ORDER } from "../ui/theme.js";
9
- import { chatTurn, pickChatType, pickMode, pickModel, setChatType, setMode, setModel } from "./shell-chat.js";
28
+ import { armWebSearch, chatTurn, isWebSearchStateArg, openSource, pickChatType, pickMode, pickModel, searchNow, setChatType, setFast, setHighPower, setSia, setMode, setModel, setWebSearch, showSources, fastInEffect } from "./shell-chat.js";
29
+ import { c } from "../ui/colors.js";
10
30
  import { buildFooter } from "./shell-prompt.js";
11
31
  import { printShellHelp } from "./shell-renderer.js";
12
32
  const STAY = { exit: false };
@@ -47,6 +67,10 @@ export async function handleSlash(ctx, program, client, input) {
47
67
  case "exit":
48
68
  case "quit":
49
69
  return { exit: true };
70
+ case "details":
71
+ for (const row of commandDetails(ctx, JSON.stringify([client.mutationRecoveryScope(), ctx.config.get("sessionId"), workspaceRoot()])))
72
+ line(row);
73
+ return STAY;
50
74
  case "help":
51
75
  // In a TTY, /help is an arrow-navigable menu (Enter runs the picked
52
76
  // command); piped/non-interactive falls back to the static list.
@@ -106,20 +130,135 @@ export async function handleSlash(ctx, program, client, input) {
106
130
  await pickModel(ctx, client);
107
131
  return STAY;
108
132
  case "mode":
109
- await setMode(ctx, client, argStr);
133
+ // `/mode manual|plan|accept-edits` is the permission mode; any other
134
+ // argument (general, code, …) is the Carrier chat mode, as before.
135
+ // "auto" stays the chat mode's Auto here — the Auto PERMISSION mode is
136
+ // `/permissions auto`, so an existing `/mode auto` never grants change authority.
137
+ if (parsePermissionMode(argStr) && parsePermissionMode(argStr) !== "auto")
138
+ await runPermissions(ctx, argStr);
139
+ else
140
+ await setMode(ctx, client, argStr);
141
+ return STAY;
142
+ case "permissions":
143
+ await runPermissions(ctx, argStr);
144
+ return STAY;
145
+ case "plan":
146
+ await runPermissions(ctx, "plan");
147
+ return STAY;
148
+ case "compact":
149
+ await runCompact(ctx, client);
110
150
  return STAY;
111
151
  case "model":
112
152
  await setModel(ctx, client, argStr);
113
153
  return STAY;
154
+ // One command, three jobs — the argument decides which:
155
+ // /websearch arm the next message
156
+ // /websearch on|off|auto|status change or show the standing preference
157
+ // /websearch <anything else> search for it right now
158
+ // Anything that isn't a recognised state word is treated as a query, so
159
+ // "/websearch latest AI news" does what it looks like it should.
160
+ case "websearch":
161
+ case "web": {
162
+ const arg = argStr.trim();
163
+ if (!arg)
164
+ armWebSearch(ctx);
165
+ else if (isWebSearchStateArg(arg))
166
+ setWebSearch(ctx, arg);
167
+ else
168
+ await searchNow(ctx, client, arg, buildFooter(ctx));
169
+ return STAY;
170
+ }
171
+ // Turn shaping. Bare toggles; an explicit on|off sets.
172
+ case "fast":
173
+ await setFast(ctx, argStr, client);
174
+ return STAY;
175
+ case "hipwr":
176
+ case "highpower":
177
+ setHighPower(ctx, argStr);
178
+ return STAY;
179
+ case "sia":
180
+ await setSia(ctx, argStr);
181
+ return STAY;
182
+ // A side question about this conversation. Never becomes a turn — see
183
+ // commands/btw.ts and POST /v1/sessions/:id/ask.
184
+ case "btw":
185
+ // While a main turn renders, it owns the transient region — the answer is
186
+ // committed to the transcript instead of shown as a dismissible panel.
187
+ await askSideQuestion(ctx, client, argStr, ctx.mainTurnRunning);
188
+ return STAY;
189
+ // One command: checks, and offers to install when something newer exists.
190
+ case "update":
191
+ await runUpdate();
192
+ return STAY;
193
+ case "sources":
194
+ showSources(ctx);
195
+ return STAY;
196
+ case "open":
197
+ if (rest.length === 0) {
198
+ errorLine("Usage: /open <n> (see /sources)");
199
+ return STAY;
200
+ }
201
+ openSource(ctx, rest[0]);
202
+ return STAY;
203
+ // `/new` is the preferred form; `/clear` stays as the original spelling.
204
+ // A title needs POST /v1/sessions, which only creates Standard chats — the
205
+ // command says so rather than downgrading a Carrier chat silently.
114
206
  case "new":
207
+ await newSession(ctx, argStr.trim());
208
+ return STAY;
209
+ // A new task: the current one stays in history (/sessions), with its audit
210
+ // and recovery records; attachments, Plan and Accept Edits do not carry over.
115
211
  case "clear":
116
- ctx.config.set("sessionId", undefined);
117
- info("Started a new session.");
212
+ clearActiveSession(ctx);
213
+ ctx.clearAttachments();
214
+ info("New task. Your next message starts it — the previous one is kept in /sessions; permissions are back to Manual.");
215
+ return STAY;
216
+ case "context":
217
+ if ((rest[0] ?? "").toLowerCase() === "project") {
218
+ // `/context project [attach|detach|--preview] [--repo <name>]`
219
+ const flags = rest.slice(1);
220
+ const repoAt = flags.findIndex((f) => f === "--repo" || f === "-r");
221
+ const repository = repoAt !== -1 ? flags[repoAt + 1] : undefined;
222
+ const verb = flags.find((f) => !f.startsWith("-") && f !== repository);
223
+ await runProject(ctx, verb, flags.includes("--preview"), repository);
224
+ return STAY;
225
+ }
226
+ await showContext(ctx, client);
227
+ return STAY;
228
+ // `/memory` lists what the engine has compressed; `/memory 2` reads one.
229
+ case "memory":
230
+ if (argStr.trim())
231
+ await showArtifact(ctx, client, argStr.trim());
232
+ else
233
+ await listMemory(ctx, client);
118
234
  return STAY;
119
235
  // ── Routed to the existing command implementations ───────────────────────
120
236
  case "whoami":
121
237
  await route(program, ["whoami"]);
122
238
  return STAY;
239
+ case "repo": {
240
+ const [verb, target] = rest;
241
+ if ((verb ?? "").toLowerCase() === "use") {
242
+ await useRepository(ctx, target);
243
+ return STAY;
244
+ }
245
+ await route(program, ["repo"]);
246
+ return STAY;
247
+ }
248
+ case "repos":
249
+ showRepositories();
250
+ return STAY;
251
+ case "settings":
252
+ runSettings(ctx, argStr);
253
+ return STAY;
254
+ case "review":
255
+ // A review shares the keyboard with a running turn's approvals — wait.
256
+ if (ctx.mainTurnRunning) {
257
+ errorLine("Wait for the current response to finish before starting a review.");
258
+ return STAY;
259
+ }
260
+ await runReview(ctx, client, rest[0], buildFooter(ctx));
261
+ return STAY;
123
262
  case "doctor":
124
263
  await route(program, ["doctor"]);
125
264
  return STAY;
@@ -127,7 +266,33 @@ export async function handleSlash(ctx, program, client, input) {
127
266
  await route(program, ["usage"]);
128
267
  return STAY;
129
268
  case "files":
130
- await route(program, ["files"]);
269
+ await route(program, ["files", ...rest]);
270
+ return STAY;
271
+ case "changes":
272
+ showChanges();
273
+ return STAY;
274
+ case "undo":
275
+ // The undo prompt and a running turn's change review would fight over
276
+ // the keyboard, and the turn may be about to touch the same file.
277
+ if (ctx.mainTurnRunning) {
278
+ errorLine("Wait for the current response to finish before undoing.");
279
+ return STAY;
280
+ }
281
+ {
282
+ // `/undo [operation] [--repo <name>]` — the repository is explicit or
283
+ // it is the active one; there is no "latest anywhere".
284
+ const repoAt = rest.findIndex((t) => t === "--repo" || t === "-r");
285
+ const repository = repoAt !== -1 ? rest[repoAt + 1] : undefined;
286
+ const operation = rest.find((t, i) => !t.startsWith("-") && i !== repoAt + 1);
287
+ await runUndo(client, operation, repository);
288
+ }
289
+ return STAY;
290
+ case "search":
291
+ if (!argStr.trim()) {
292
+ errorLine("Usage: /search <text>");
293
+ return STAY;
294
+ }
295
+ await runSearch(ctx, argStr.trim());
131
296
  return STAY;
132
297
  case "version":
133
298
  await route(program, ["version"]);
@@ -138,26 +303,84 @@ export async function handleSlash(ctx, program, client, input) {
138
303
  case "login":
139
304
  await route(program, ["login", ...rest]);
140
305
  return STAY;
306
+ // In a TTY the list IS the picker — printing a numbered list you can't act
307
+ // on just forces a second command. Matches /modes and /models, which are
308
+ // both pickers. Piped output, or an explicit flag like `-n 50`, still gets
309
+ // the plain printed list.
310
+ case "resume":
141
311
  case "sessions":
142
- await route(program, ["sessions", ...rest]);
312
+ if (rest.length === 0 && process.stdin.isTTY)
313
+ await pickSession(ctx, client);
314
+ else
315
+ await route(program, ["sessions", ...rest]);
143
316
  return STAY;
317
+ // `/history`, `/history 2`, `/history <id>` — the resolver handles all three.
144
318
  case "history":
145
- await route(program, ["history", ...rest]);
319
+ await showHistory(ctx, client, rest[0]);
146
320
  return STAY;
147
321
  case "upload":
322
+ if (refuseFilesInFastMode(ctx))
323
+ return STAY;
148
324
  if (rest.length === 0) {
149
325
  errorLine("Usage: /upload <file>");
150
326
  return STAY;
151
327
  }
328
+ // In the shell the upload command uploads + auto-attaches + prints "Ready.".
152
329
  await route(program, ["upload", ...rest]);
153
330
  return STAY;
154
- case "session":
331
+ case "attach": {
332
+ if (refuseFilesInFastMode(ctx))
333
+ return STAY;
334
+ const uploads = ctx.config.get("uploads") ?? [];
335
+ let target = rest[0];
336
+ if (!target) {
337
+ if (uploads.length === 0) {
338
+ errorLine("No uploads yet. Run /upload <file> first.");
339
+ return STAY;
340
+ }
341
+ target = uploads[0].file_id; // most recent
342
+ }
343
+ ctx.attachFile(target);
344
+ const named = uploads.find((u) => u.file_id === target);
345
+ info(`Attached ${named ? `"${named.filename}"` : target}. ` +
346
+ `${ctx.attachedFileIds.length} file(s) will ride along; /detach to clear.`);
347
+ return STAY;
348
+ }
349
+ case "detach":
350
+ ctx.clearAttachments();
351
+ info("Cleared attached files.");
352
+ return STAY;
353
+ // `/session` picker · `/session 2` · `/session <id>` · and the original
354
+ // `/session use|current|delete|rename …` sub-verbs, all still working.
355
+ case "session": {
356
+ const sub = (rest[0] ?? "").toLowerCase();
155
357
  if (rest.length === 0) {
156
- errorLine("Usage: /session use [id] | /session delete <id>");
358
+ await pickSession(ctx, client);
359
+ return STAY;
360
+ }
361
+ if (sub === "delete") {
362
+ if (!rest[1]) {
363
+ errorLine("Usage: /session delete <n> (see /sessions)");
364
+ return STAY;
365
+ }
366
+ await deleteSession(ctx, client, rest[1]);
367
+ return STAY;
368
+ }
369
+ if (sub === "use") {
370
+ if (!rest[1])
371
+ await pickSession(ctx, client);
372
+ else
373
+ await switchTo(ctx, client, rest[1]);
157
374
  return STAY;
158
375
  }
159
- await route(program, ["session", ...rest]);
376
+ if (sub === "current" || sub === "rename") {
377
+ await route(program, ["session", ...rest]);
378
+ return STAY;
379
+ }
380
+ // Bare reference: a number from /sessions, or an id.
381
+ await switchTo(ctx, client, rest[0]);
160
382
  return STAY;
383
+ }
161
384
  default:
162
385
  errorLine(`Unknown command: /${cmd}. Type /help for the list.`);
163
386
  return STAY;
@@ -168,7 +391,7 @@ async function runHelpMenu(ctx, program, client) {
168
391
  const chosen = await pickFromList({
169
392
  title: "Commands",
170
393
  description: "Type a message to chat, or pick a command to run.",
171
- choices: COMMANDS.map((entry) => ({
394
+ choices: visibleCommands().map((entry) => ({
172
395
  value: entry.name,
173
396
  label: entry.name,
174
397
  description: entry.desc
@@ -178,3 +401,11 @@ async function runHelpMenu(ctx, program, client) {
178
401
  return STAY; // Esc, or avoid reopening
179
402
  return handleSlash(ctx, program, client, chosen);
180
403
  }
404
+ /** Fast Mode's model can't read files — as the web disables its paperclip. True when refused. */
405
+ function refuseFilesInFastMode(ctx) {
406
+ if (!fastInEffect(ctx))
407
+ return false;
408
+ errorLine("Fast mode can't read files — its model is text-only.");
409
+ line(" " + c.dim("Run ") + c.cmd("/fast off") + c.dim(" to attach files."));
410
+ return true;
411
+ }
@@ -1,11 +1,14 @@
1
- import chalk from "chalk";
1
+ import { getPermissionMode, permissionModeLabel } from "../services/permission-mode.js";
2
+ import { attachedFilenames } from "../services/file-upload.js";
3
+ import { branchLabel, peekWorkspace } from "../services/workspace.js";
4
+ import { activeRepository, inWorkspaceMode, peekRepositoryDetails } from "../services/workspace-registry.js";
2
5
  import { c } from "../ui/colors.js";
3
- import { modeLabelShort, modelLabelShort } from "./shell-chat.js";
6
+ import { modeLabelShort, modelLabelShort, turnShapeLabels, webSearchLabelShort } from "./shell-chat.js";
4
7
  /** The green caret the shell prompt uses (non-TTY fallback). */
5
- export const CARET = c.brand("❯") + " ";
8
+ export const CARET = c.brand("›") + " ";
6
9
  /** Light purple used for the "Standard chat" footer label (distinct from the
7
10
  * accent-green Carrier Chat label). */
8
- const STANDARD_LABEL = chalk.hex("#c4a7ff");
11
+ const STANDARD_LABEL = c.value;
9
12
  /**
10
13
  * The dim status footer shown directly beneath the input box, Claude-style:
11
14
  * ‖ Carrier OS chat · Grok 4.1 Fast
@@ -13,15 +16,95 @@ const STANDARD_LABEL = chalk.hex("#c4a7ff");
13
16
  * while the palette is open.
14
17
  */
15
18
  export function buildFooter(ctx) {
19
+ if (ctx.chatType === "carrier" && ctx.carrierMaintenance !== false) {
20
+ const state = ctx.carrierMaintenance === true ? "Carrier Chat paused" : "Carrier Chat status unavailable";
21
+ return repoPart() + c.dim(" · ") + c.warn(state) + c.dim(" · /switch standard");
22
+ }
16
23
  const mode = modeLabelShort(ctx);
17
24
  const model = modelLabelShort(ctx);
18
- // The leading token reflects the CHAT TYPE, so carrier vs standard is obvious:
19
- // • carrier → "<mode> chat" (e.g. "Carrier OS chat" / "Code chat"), accent
20
- // • standard → "Standard chat", light purple — a clearly different colour
25
+ // The leading token reflects the CHAT TYPE:
26
+ // • carrier → "Carrier OS chat" (brand, theme-light green). Carrier chat
27
+ // always uses the General mode, so the mode is NOT shown.
28
+ // • standard → "Standard chat" (light purple) followed by the active mode,
29
+ // since Standard chat is where modes actually vary.
21
30
  const isStandard = ctx.chatType === "standard";
22
- const label = isStandard ? "Standard" : mode;
23
- const paintLabel = isStandard ? STANDARD_LABEL : c.accent;
31
+ const label = isStandard ? "Standard" : "Carrier OS";
32
+ const paintLabel = isStandard ? STANDARD_LABEL : c.brand;
24
33
  const dot = c.dim(" · ");
25
- const context = paintLabel(label) + c.dim(" chat") + dot + c.file(model);
26
- return " " + c.dim("‖ ") + context;
34
+ // Show the active mode ONLY in standard chat: "Standard chat · Code · Grok".
35
+ const modePart = isStandard ? dot + c.value(mode) : "";
36
+ const context = paintLabel(label) + c.dim(" chat") + modePart + dot + c.file(model);
37
+ // Web search rides in the footer as a capability chip next to the model —
38
+ // the point is that you can tell at a glance whether the NEXT message will
39
+ // search. Silent on the workspace default and when explicitly off: the CLI
40
+ // can't see the workspace toggle, so claiming a state there would be a lie,
41
+ // and "off" is the quiet baseline that needs no chip.
42
+ const webLabel = webSearchLabelShort(ctx);
43
+ const webPart = webLabel ? dot + c.accent(webLabel) : "";
44
+ // Turn-shaping toggles (Fast, HIPWR) — shown only when on, so the default
45
+ // footer stays quiet and an enabled one actually stands out.
46
+ // Already coloured by turnShapeLabels — each chip carries its own meaning.
47
+ const shapePart = turnShapeLabels(ctx)
48
+ .map((l) => dot + l)
49
+ .join("");
50
+ // Active conversation. Set apart from the dot-chain on purpose: everything
51
+ // before it is a SETTING for the next message, while this is WHERE you are.
52
+ // Chained with a dot in matching weight it reads as another setting — which
53
+ // is exactly how a title like "AWS outage research" gets mistaken for a mode.
54
+ // Only shown once the title is known (from /sessions, /session or /new); a
55
+ // fresh chat has none until the backend generates one, and a placeholder
56
+ // would be worse than saying nothing.
57
+ // Quoted, because titles are auto-generated from the first message and are
58
+ // often a short lowercase phrase — unquoted, `in hi` reads as a broken
59
+ // sentence rather than the name of a conversation. Matches how the session
60
+ // commands already refer to them ("Switched to “hi”.").
61
+ const title = ctx.config.get("sessionTitle");
62
+ const convo = title ? " " + c.dim(`in “${clip(title, 26)}”`) : "";
63
+ // Attachment indicator: one file shows its name, several show a compact count.
64
+ const names = attachedFilenames(ctx);
65
+ const attach = names.length === 1
66
+ ? dot + c.accent(`Attached: ${names[0]}`)
67
+ : names.length > 1
68
+ ? dot + c.accent(`${names.length} attached`)
69
+ : "";
70
+ // Permission mode: always shown, so what the next message may do is never a guess.
71
+ const permission = getPermissionMode(ctx.config);
72
+ const paintPermission = permission === "auto" ? c.err : permission === "accept_edits" ? c.warn : permission === "plan" ? c.accent : c.dim;
73
+ const permissionPart = dot + paintPermission(permissionModeLabel(permission));
74
+ return repoPart() + c.dim(" · ") + (ctx.mainTurnRunning ? c.dim("Working · Ctrl+C stops") + permissionPart : context + permissionPart + convo + shapePart + webPart + attach);
75
+ }
76
+ /**
77
+ * Where you are on disk, trailing the footer: "my-app · main".
78
+ *
79
+ * peek, not get: this runs on every keystroke, and the workspace must never be
80
+ * something the composer can spawn a Git process for. The descriptor is built
81
+ * once at startup; if it somehow is not there, the footer simply says nothing.
82
+ *
83
+ * Omitted entirely outside a repository. The project name alone would just
84
+ * repeat the folder you can already see in your own prompt, and a footer earns
85
+ * its width by telling you something you would otherwise have to ask for —
86
+ * which branch you are about to work against.
87
+ */
88
+ function repoPart() {
89
+ // A workspace names the repository you are acting on; that is the thing that
90
+ // changes under you, and the one fact a stray `/repo use` would make stale.
91
+ if (inWorkspaceMode()) {
92
+ const active = activeRepository();
93
+ const details = peekRepositoryDetails(active);
94
+ const branch = (process.stdout.columns ?? 80) >= 80 && details?.branch ? ` · ${clip(details.branch, 20)}` : "";
95
+ return " " + c.dim(`${clip(active.name, 24)}${branch}`);
96
+ }
97
+ const ws = peekWorkspace();
98
+ if (!ws)
99
+ return "";
100
+ if (ws.repository.state !== "detected")
101
+ return " " + c.dim(clip(ws.project.name, 24));
102
+ const branch = branchLabel(ws.repository);
103
+ if (!branch)
104
+ return "";
105
+ return " " + c.dim(`${clip(ws.project.name, 20)}${(process.stdout.columns ?? 80) >= 80 ? ` · ${clip(branch, 22)}` : ""}`);
106
+ }
107
+ /** Trim a title to keep the footer on one row. */
108
+ function clip(s, max) {
109
+ return [...s].length <= max ? s : [...s].slice(0, max - 1).join("") + "…";
27
110
  }
@@ -2,6 +2,7 @@ import chalk from "chalk";
2
2
  import { kv, line } from "../services/output.js";
3
3
  import { renderBrandmark } from "../ui/banner.js";
4
4
  import { c } from "../ui/colors.js";
5
+ import { byGroupThenRank, visibleCommands } from "../ui/command-item.js";
5
6
  import { twoCol } from "../ui/ui.js";
6
7
  /** First-run welcome shown when there's no session — just the brandmark; the
7
8
  * device-login flow prints the "Welcome to Carrier OS" line + guidance. */
@@ -22,29 +23,16 @@ export function renderWelcomeBack(_scope, developerName) {
22
23
  line(" " + c.brand("│") + chalk.bold(inner) + c.brand("│"));
23
24
  line(" " + c.brand("└" + rule + "┘"));
24
25
  line();
25
- kv("Developer", developerName);
26
+ kv("User", developerName);
26
27
  line();
27
28
  }
28
29
  export function printShellHelp() {
29
- // A single flat list — no category sections — with white command names.
30
- const rows = [
31
- ["/mode <id>", "switch Carrier mode · /modes to pick"],
32
- ["/model <id>", "set provider model · /models to pick · /model auto"],
33
- ["/clear", "start a fresh session"],
34
- ["/sessions", "list conversations"],
35
- ["/session use [id]", "switch session"],
36
- ["/session delete <id>", "delete a session"],
37
- ["/history [id]", "print a transcript"],
38
- ["/upload <file>", "upload + process a file"],
39
- ["/files", "list your uploads"],
40
- ["/whoami", "workspace / project / account"],
41
- ["/doctor", "diagnostics"],
42
- ["/usage", "requests, tokens, cost"],
43
- ["/login · /logout", "sign in / out"],
44
- ["/version", "CLI + API versions"],
45
- ["/help", "show this help"],
46
- ["/exit", "leave the shell · or Ctrl+D"]
47
- ];
30
+ // Generated from the same registry the palette uses, so this list can't drift
31
+ // out of sync with the commands that actually exist — and it hides whatever
32
+ // doesn't apply to the current chat type, exactly as the palette does.
33
+ const rows = visibleCommands()
34
+ .sort(byGroupThenRank)
35
+ .map((cmd) => [cmd.name, cmd.desc]);
48
36
  line();
49
37
  line(" " + c.dim("Type a message to chat, or run a slash command:"));
50
38
  line();
@@ -1,11 +1,25 @@
1
- import { chatTurn } from "./shell-chat.js";
1
+ import { chatInputWithFiles } from "./shell-chat.js";
2
2
  import { handleSlash } from "./shell-commands.js";
3
3
  import { buildFooter } from "./shell-prompt.js";
4
4
  /**
5
5
  * Route one line of shell input: a `/…` line goes to the slash-command handler;
6
6
  * anything else is a chat message sent through the shared chat turn.
7
7
  */
8
- export async function dispatchLine(ctx, program, client, input) {
8
+ /**
9
+ * True when `input` starts a MAIN conversation turn (a chat message) rather
10
+ * than a command. The shell needs to know before dispatching, because a main
11
+ * turn runs in the background while commands stay awaited — and this must use
12
+ * exactly the same rules as dispatchLine below, or the two would disagree about
13
+ * what a line is.
14
+ */
15
+ export function isMainTurn(input) {
16
+ const prefixed = input.match(/^(?:cos|carrieros)\s+(.+)$/i);
17
+ const line = prefixed ? prefixed[1].trim() : input;
18
+ return !line.startsWith("/") && !prefixed;
19
+ }
20
+ export async function dispatchLine(ctx, program, client, input,
21
+ /** Abort handle for the main turn; the shell owns Ctrl+C. */
22
+ signal) {
9
23
  // Forgive users who type the binary name inside the shell, e.g.
10
24
  // "cos models" → treat it as the "/models" command.
11
25
  const prefixed = input.match(/^(?:cos|carrieros)\s+(.+)$/i);
@@ -16,6 +30,8 @@ export async function dispatchLine(ctx, program, client, input) {
16
30
  if (input.startsWith("/")) {
17
31
  return handleSlash(ctx, program, client, input);
18
32
  }
19
- await chatTurn(ctx, client, input, { footer: buildFooter(ctx) });
33
+ // Chat: intelligently detect a leading/quoted local file path, upload+attach
34
+ // it, and strip it from the prompt before sending (the model never sees paths).
35
+ await chatInputWithFiles(ctx, client, input, buildFooter(ctx), signal);
20
36
  return { exit: false };
21
37
  }