@carrieros/cli 0.1.0 → 0.3.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 (104) hide show
  1. package/README.md +142 -57
  2. package/dist/commands/attach.js +45 -0
  3. package/dist/commands/auth.js +60 -0
  4. package/dist/commands/btw.js +78 -0
  5. package/dist/commands/changes.js +167 -0
  6. package/dist/commands/chat.js +102 -13
  7. package/dist/commands/context.js +160 -0
  8. package/dist/commands/doctor.js +53 -8
  9. package/dist/commands/files.js +84 -23
  10. package/dist/commands/help.js +3 -1
  11. package/dist/commands/history.js +88 -23
  12. package/dist/commands/login.js +44 -41
  13. package/dist/commands/logout.js +13 -4
  14. package/dist/commands/memory.js +162 -0
  15. package/dist/commands/mode-model.js +39 -3
  16. package/dist/commands/modes.js +4 -1
  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 +152 -0
  22. package/dist/commands/search.js +92 -0
  23. package/dist/commands/sessions.js +219 -65
  24. package/dist/commands/settings.js +87 -0
  25. package/dist/commands/update.js +159 -0
  26. package/dist/commands/upload.js +204 -31
  27. package/dist/commands/usage.js +212 -16
  28. package/dist/commands/whoami.js +2 -1
  29. package/dist/ide/editor-context.js +172 -0
  30. package/dist/ide/ide-session.js +94 -0
  31. package/dist/ide/tool-host.js +109 -0
  32. package/dist/main.js +30 -1
  33. package/dist/services/api.js +171 -13
  34. package/dist/services/chat-stream.js +145 -0
  35. package/dist/services/checkpoints.js +116 -0
  36. package/dist/services/client-tools.js +260 -0
  37. package/dist/services/command-coordinator.js +200 -0
  38. package/dist/services/command-policy.js +404 -0
  39. package/dist/services/config.js +249 -22
  40. package/dist/services/context.js +307 -6
  41. package/dist/services/device-auth.js +261 -0
  42. package/dist/services/diff.js +196 -0
  43. package/dist/services/env-policy.js +108 -0
  44. package/dist/services/file-detect.js +104 -0
  45. package/dist/services/file-resolver.js +199 -0
  46. package/dist/services/file-upload.js +126 -0
  47. package/dist/services/git-tools.js +248 -0
  48. package/dist/services/glob-match.js +164 -0
  49. package/dist/services/helper-bin.js +64 -0
  50. package/dist/services/ignore-rules.js +189 -0
  51. package/dist/services/job-helper.js +307 -0
  52. package/dist/services/local-files.js +517 -0
  53. package/dist/services/local-tools.js +432 -0
  54. package/dist/services/login-flow.js +120 -10
  55. package/dist/services/meta.js +3 -1
  56. package/dist/services/mutation-coordinator.js +161 -0
  57. package/dist/services/mutations.js +493 -0
  58. package/dist/services/open-url.js +68 -0
  59. package/dist/services/output.js +13 -5
  60. package/dist/services/packaged.js +24 -0
  61. package/dist/services/process-runner.js +406 -0
  62. package/dist/services/project-context.js +298 -0
  63. package/dist/services/redaction.js +201 -0
  64. package/dist/services/secure-store.js +197 -0
  65. package/dist/services/session-resolver.js +108 -0
  66. package/dist/services/sia.js +51 -0
  67. package/dist/services/spinner.js +23 -1
  68. package/dist/services/update.js +286 -0
  69. package/dist/services/workspace-registry.js +309 -0
  70. package/dist/services/workspace.js +573 -0
  71. package/dist/shell/shell-chat.js +1115 -59
  72. package/dist/shell/shell-commands.js +220 -19
  73. package/dist/shell/shell-prompt.js +89 -37
  74. package/dist/shell/shell-renderer.js +19 -38
  75. package/dist/shell/shell-router.js +19 -3
  76. package/dist/shell/shell.js +232 -44
  77. package/dist/types/index.js +3 -1
  78. package/dist/ui/approval.js +81 -0
  79. package/dist/ui/banner.js +55 -13
  80. package/dist/ui/btw-overlay.js +230 -0
  81. package/dist/ui/change-review.js +87 -0
  82. package/dist/ui/chat-renderer.js +223 -29
  83. package/dist/ui/color-picker.js +21 -0
  84. package/dist/ui/colors.js +9 -1
  85. package/dist/ui/command-filter.js +40 -5
  86. package/dist/ui/command-palette.js +122 -62
  87. package/dist/ui/command-registry.js +85 -11
  88. package/dist/ui/command-review.js +138 -0
  89. package/dist/ui/composer-layout.js +41 -0
  90. package/dist/ui/conversation.js +398 -0
  91. package/dist/ui/interrupt.js +35 -0
  92. package/dist/ui/live.js +18 -1
  93. package/dist/ui/markdown.js +63 -9
  94. package/dist/ui/message.js +14 -31
  95. package/dist/ui/screen-prompt.js +181 -0
  96. package/dist/ui/screen.js +289 -0
  97. package/dist/ui/select.js +193 -29
  98. package/dist/ui/sia-qa.js +213 -0
  99. package/dist/ui/text-prompt.js +74 -0
  100. package/dist/ui/theme.js +17 -0
  101. package/dist/ui/trust.js +93 -0
  102. package/dist/ui/ui.js +4 -1
  103. package/package.json +17 -6
  104. package/dist/ui/activity.js +0 -77
@@ -2,11 +2,25 @@ import { CommanderError } from "commander";
2
2
  import { ApiError } from "../services/api.js";
3
3
  import { AuthRequiredError } from "../services/context.js";
4
4
  import { errorLine, info } from "../services/output.js";
5
- import { COMMANDS } from "../ui/command-item.js";
6
- import { pickColor } from "../ui/color-picker.js";
5
+ import { askSideQuestion } from "../commands/btw.js";
6
+ import { runUpdate } from "../commands/update.js";
7
+ import { runSearch } from "../commands/search.js";
8
+ import { useRepository } from "../commands/repo.js";
9
+ import { showRepositories } from "../commands/repos.js";
10
+ import { runSettings } from "../commands/settings.js";
11
+ import { runReview } from "../commands/review.js";
12
+ import { runUndo, showChanges } from "../commands/changes.js";
13
+ import { runProject } from "../commands/project.js";
14
+ import { showContext } from "../commands/context.js";
15
+ import { listMemory, showArtifact } from "../commands/memory.js";
16
+ import { showHistory } from "../commands/history.js";
17
+ import { deleteSession, newSession, pickSession, switchTo } from "../commands/sessions.js";
18
+ import { clearActiveSession } from "../services/session-resolver.js";
19
+ import { visibleCommands } from "../ui/command-item.js";
20
+ import { confirmColor, pickColor } from "../ui/color-picker.js";
7
21
  import { pickFromList } from "../ui/select.js";
8
22
  import { isThemeColor, setAccent, THEME_ORDER } from "../ui/theme.js";
9
- import { chatTurn, pickMode, pickModel, setMode, setModel } from "./shell-chat.js";
23
+ import { armWebSearch, chatTurn, isWebSearchStateArg, openSource, pickChatType, pickMode, pickModel, searchNow, setChatType, setFast, setHighPower, setSia, setMode, setModel, setWebSearch, showSources } from "./shell-chat.js";
10
24
  import { buildFooter } from "./shell-prompt.js";
11
25
  import { printShellHelp } from "./shell-renderer.js";
12
26
  const STAY = { exit: false };
@@ -64,7 +78,7 @@ export async function handleSlash(ctx, program, client, input) {
64
78
  if (isThemeColor(arg)) {
65
79
  setAccent(arg);
66
80
  ctx.config.set("theme", { accent: arg });
67
- info(`Accent color set to ${arg}.`);
81
+ confirmColor(arg);
68
82
  }
69
83
  else {
70
84
  errorLine(`Unknown color "${arg}". Try: ${THEME_ORDER.join(", ")}.`);
@@ -74,17 +88,29 @@ export async function handleSlash(ctx, program, client, input) {
74
88
  const chosen = await pickColor();
75
89
  if (chosen) {
76
90
  ctx.config.set("theme", { accent: chosen });
77
- info(`Accent color set to ${chosen}.`);
91
+ confirmColor(chosen);
78
92
  }
79
93
  return STAY;
80
94
  }
81
- // In the shell you're already chatting — /chat <text> sends a message, and
82
- // bare /chat just reminds you that typing directly is enough.
83
- case "chat":
84
- if (argStr)
95
+ // `/chat` selects the chat experience: bare shows current, `/chat carrier`
96
+ // and `/chat standard` switch. `/chat <other text>` still sends a message
97
+ // (you're already in the shell, so typing directly also works).
98
+ case "chat": {
99
+ const t = argStr.trim().toLowerCase();
100
+ const isTypeArg = ["", "carrier", "carrieros", "standard", "plain", "normal"].includes(t);
101
+ if (isTypeArg)
102
+ setChatType(ctx, argStr);
103
+ else
85
104
  await chatTurn(ctx, client, argStr, { footer: buildFooter(ctx) });
105
+ return STAY;
106
+ }
107
+ // `/switch` — arrow-key picker for the chat experience (Carrier ⇄ Standard).
108
+ // An explicit arg (`/switch standard`) sets it directly.
109
+ case "switch":
110
+ if (argStr.trim())
111
+ setChatType(ctx, argStr);
86
112
  else
87
- info("You're in the shell — just type your message to chat.");
113
+ await pickChatType(ctx);
88
114
  return STAY;
89
115
  // ── Chat behavior — handled here so the prompt reflects it immediately ────
90
116
  case "modes":
@@ -99,15 +125,111 @@ export async function handleSlash(ctx, program, client, input) {
99
125
  case "model":
100
126
  await setModel(ctx, client, argStr);
101
127
  return STAY;
128
+ // One command, three jobs — the argument decides which:
129
+ // /websearch arm the next message
130
+ // /websearch on|off|auto|status change or show the standing preference
131
+ // /websearch <anything else> search for it right now
132
+ // Anything that isn't a recognised state word is treated as a query, so
133
+ // "/websearch latest AI news" does what it looks like it should.
134
+ case "websearch":
135
+ case "web": {
136
+ const arg = argStr.trim();
137
+ if (!arg)
138
+ armWebSearch(ctx);
139
+ else if (isWebSearchStateArg(arg))
140
+ setWebSearch(ctx, arg);
141
+ else
142
+ await searchNow(ctx, client, arg, buildFooter(ctx));
143
+ return STAY;
144
+ }
145
+ // Turn shaping. Bare toggles; an explicit on|off sets.
146
+ case "fast":
147
+ setFast(ctx, argStr);
148
+ return STAY;
149
+ case "hipwr":
150
+ case "highpower":
151
+ setHighPower(ctx, argStr);
152
+ return STAY;
153
+ case "sia":
154
+ await setSia(ctx, argStr);
155
+ return STAY;
156
+ // A side question about this conversation. Never becomes a turn — see
157
+ // commands/btw.ts and POST /v1/sessions/:id/ask.
158
+ case "btw":
159
+ // While a main turn renders, it owns the transient region — the answer is
160
+ // committed to the transcript instead of shown as a dismissible panel.
161
+ await askSideQuestion(ctx, client, argStr, ctx.mainTurnRunning);
162
+ return STAY;
163
+ // One command: checks, and offers to install when something newer exists.
164
+ case "update":
165
+ await runUpdate();
166
+ return STAY;
167
+ case "sources":
168
+ showSources(ctx);
169
+ return STAY;
170
+ case "open":
171
+ if (rest.length === 0) {
172
+ errorLine("Usage: /open <n> (see /sources)");
173
+ return STAY;
174
+ }
175
+ openSource(ctx, rest[0]);
176
+ return STAY;
177
+ // `/new` is the preferred form; `/clear` stays as the original spelling.
178
+ // A title needs POST /v1/sessions, which only creates Standard chats — the
179
+ // command says so rather than downgrading a Carrier chat silently.
102
180
  case "new":
181
+ await newSession(ctx, argStr.trim());
182
+ return STAY;
103
183
  case "clear":
104
- ctx.config.set("sessionId", undefined);
105
- info("Started a new session.");
184
+ clearActiveSession(ctx);
185
+ info("Cleared. Your next message starts a fresh session.");
186
+ return STAY;
187
+ case "context":
188
+ if ((rest[0] ?? "").toLowerCase() === "project") {
189
+ // `/context project [attach|detach|--preview] [--repo <name>]`
190
+ const flags = rest.slice(1);
191
+ const repoAt = flags.findIndex((f) => f === "--repo" || f === "-r");
192
+ const repository = repoAt !== -1 ? flags[repoAt + 1] : undefined;
193
+ const verb = flags.find((f) => !f.startsWith("-") && f !== repository);
194
+ await runProject(ctx, verb, flags.includes("--preview"), repository);
195
+ return STAY;
196
+ }
197
+ await showContext(ctx, client);
198
+ return STAY;
199
+ // `/memory` lists what the engine has compressed; `/memory 2` reads one.
200
+ case "memory":
201
+ if (argStr.trim())
202
+ await showArtifact(ctx, client, argStr.trim());
203
+ else
204
+ await listMemory(ctx, client);
106
205
  return STAY;
107
206
  // ── Routed to the existing command implementations ───────────────────────
108
207
  case "whoami":
109
208
  await route(program, ["whoami"]);
110
209
  return STAY;
210
+ case "repo": {
211
+ const [verb, target] = rest;
212
+ if ((verb ?? "").toLowerCase() === "use") {
213
+ await useRepository(ctx, target);
214
+ return STAY;
215
+ }
216
+ await route(program, ["repo"]);
217
+ return STAY;
218
+ }
219
+ case "repos":
220
+ showRepositories();
221
+ return STAY;
222
+ case "settings":
223
+ runSettings(ctx, argStr);
224
+ return STAY;
225
+ case "review":
226
+ // A review shares the keyboard with a running turn's approvals — wait.
227
+ if (ctx.mainTurnRunning) {
228
+ errorLine("Wait for the current response to finish before starting a review.");
229
+ return STAY;
230
+ }
231
+ await runReview(ctx, client, rest[0], buildFooter(ctx));
232
+ return STAY;
111
233
  case "doctor":
112
234
  await route(program, ["doctor"]);
113
235
  return STAY;
@@ -115,7 +237,33 @@ export async function handleSlash(ctx, program, client, input) {
115
237
  await route(program, ["usage"]);
116
238
  return STAY;
117
239
  case "files":
118
- await route(program, ["files"]);
240
+ await route(program, ["files", ...rest]);
241
+ return STAY;
242
+ case "changes":
243
+ showChanges();
244
+ return STAY;
245
+ case "undo":
246
+ // The undo prompt and a running turn's change review would fight over
247
+ // the keyboard, and the turn may be about to touch the same file.
248
+ if (ctx.mainTurnRunning) {
249
+ errorLine("Wait for the current response to finish before undoing.");
250
+ return STAY;
251
+ }
252
+ {
253
+ // `/undo [operation] [--repo <name>]` — the repository is explicit or
254
+ // it is the active one; there is no "latest anywhere".
255
+ const repoAt = rest.findIndex((t) => t === "--repo" || t === "-r");
256
+ const repository = repoAt !== -1 ? rest[repoAt + 1] : undefined;
257
+ const operation = rest.find((t, i) => !t.startsWith("-") && i !== repoAt + 1);
258
+ await runUndo(client, operation, repository);
259
+ }
260
+ return STAY;
261
+ case "search":
262
+ if (!argStr.trim()) {
263
+ errorLine("Usage: /search <text>");
264
+ return STAY;
265
+ }
266
+ await runSearch(ctx, argStr.trim());
119
267
  return STAY;
120
268
  case "version":
121
269
  await route(program, ["version"]);
@@ -126,26 +274,79 @@ export async function handleSlash(ctx, program, client, input) {
126
274
  case "login":
127
275
  await route(program, ["login", ...rest]);
128
276
  return STAY;
277
+ // In a TTY the list IS the picker — printing a numbered list you can't act
278
+ // on just forces a second command. Matches /modes and /models, which are
279
+ // both pickers. Piped output, or an explicit flag like `-n 50`, still gets
280
+ // the plain printed list.
129
281
  case "sessions":
130
- await route(program, ["sessions", ...rest]);
282
+ if (rest.length === 0 && process.stdin.isTTY)
283
+ await pickSession(ctx, client);
284
+ else
285
+ await route(program, ["sessions", ...rest]);
131
286
  return STAY;
287
+ // `/history`, `/history 2`, `/history <id>` — the resolver handles all three.
132
288
  case "history":
133
- await route(program, ["history", ...rest]);
289
+ await showHistory(ctx, client, rest[0]);
134
290
  return STAY;
135
291
  case "upload":
136
292
  if (rest.length === 0) {
137
293
  errorLine("Usage: /upload <file>");
138
294
  return STAY;
139
295
  }
296
+ // In the shell the upload command uploads + auto-attaches + prints "Ready.".
140
297
  await route(program, ["upload", ...rest]);
141
298
  return STAY;
142
- case "session":
299
+ case "attach": {
300
+ const uploads = ctx.config.get("uploads") ?? [];
301
+ let target = rest[0];
302
+ if (!target) {
303
+ if (uploads.length === 0) {
304
+ errorLine("No uploads yet. Run /upload <file> first.");
305
+ return STAY;
306
+ }
307
+ target = uploads[0].file_id; // most recent
308
+ }
309
+ ctx.attachFile(target);
310
+ const named = uploads.find((u) => u.file_id === target);
311
+ info(`Attached ${named ? `"${named.filename}"` : target}. ` +
312
+ `${ctx.attachedFileIds.length} file(s) will ride along; /detach to clear.`);
313
+ return STAY;
314
+ }
315
+ case "detach":
316
+ ctx.clearAttachments();
317
+ info("Cleared attached files.");
318
+ return STAY;
319
+ // `/session` picker · `/session 2` · `/session <id>` · and the original
320
+ // `/session use|current|delete|rename …` sub-verbs, all still working.
321
+ case "session": {
322
+ const sub = (rest[0] ?? "").toLowerCase();
143
323
  if (rest.length === 0) {
144
- errorLine("Usage: /session use [id] | /session delete <id>");
324
+ await pickSession(ctx, client);
145
325
  return STAY;
146
326
  }
147
- await route(program, ["session", ...rest]);
327
+ if (sub === "delete") {
328
+ if (!rest[1]) {
329
+ errorLine("Usage: /session delete <n> (see /sessions)");
330
+ return STAY;
331
+ }
332
+ await deleteSession(ctx, client, rest[1]);
333
+ return STAY;
334
+ }
335
+ if (sub === "use") {
336
+ if (!rest[1])
337
+ await pickSession(ctx, client);
338
+ else
339
+ await switchTo(ctx, client, rest[1]);
340
+ return STAY;
341
+ }
342
+ if (sub === "current" || sub === "rename") {
343
+ await route(program, ["session", ...rest]);
344
+ return STAY;
345
+ }
346
+ // Bare reference: a number from /sessions, or an id.
347
+ await switchTo(ctx, client, rest[0]);
148
348
  return STAY;
349
+ }
149
350
  default:
150
351
  errorLine(`Unknown command: /${cmd}. Type /help for the list.`);
151
352
  return STAY;
@@ -156,7 +357,7 @@ async function runHelpMenu(ctx, program, client) {
156
357
  const chosen = await pickFromList({
157
358
  title: "Commands",
158
359
  description: "Type a message to chat, or pick a command to run.",
159
- choices: COMMANDS.map((entry) => ({
360
+ choices: visibleCommands().map((entry) => ({
160
361
  value: entry.name,
161
362
  label: entry.name,
162
363
  description: entry.desc
@@ -1,48 +1,100 @@
1
- import { capitalize } from "../services/output.js";
1
+ import chalk from "chalk";
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 { 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
8
  export const CARET = c.brand("❯") + " ";
9
+ /** Light purple used for the "Standard chat" footer label (distinct from the
10
+ * accent-green Carrier Chat label). */
11
+ const STANDARD_LABEL = chalk.hex("#c4a7ff");
6
12
  /**
7
13
  * The dim status footer shown directly beneath the input box, Claude-style:
8
- * ‖ Test CLI · Project A · Code mode · Auto / for commands
9
- * Workspace/project fade to dim; the active mode (cyan) and model (yellow) keep
10
- * a subtle accent so they read at a glance. Hidden while the palette is open.
14
+ * ‖ Carrier OS chat · Grok 4.1 Fast
15
+ * The active chat/mode leads (accent), and the model (yellow) trails. Hidden
16
+ * while the palette is open.
11
17
  */
12
18
  export function buildFooter(ctx) {
13
- const scope = ctx.config.get("scope");
14
- let ws = scope?.workspace.name ?? "—";
15
- let proj = scope?.project.name ?? "—";
16
- const mode = capitalize(ctx.mode);
19
+ const mode = modeLabelShort(ctx);
17
20
  const model = modelLabelShort(ctx);
18
- const w = process.stdout.columns && process.stdout.columns > 0 ? process.stdout.columns : 80;
19
- const trunc = (str, max) => (str.length > max ? str.slice(0, max - 1) + "…" : str);
20
- const rawPrefix = " ‖ ";
21
- const rawModeModel = ` · ${mode} mode · ${model}`;
22
- const rawHint = ` / for commands`;
23
- const fullMax = w - rawPrefix.length - rawModeModel.length - rawHint.length - 3;
24
- let hintStr = c.dim(" / ") + c.dim("for commands");
25
- if (fullMax < ws.length + proj.length) {
26
- hintStr = "";
27
- const noHintMax = w - rawPrefix.length - rawModeModel.length - 3;
28
- if (noHintMax < ws.length + proj.length) {
29
- if (noHintMax > 8) {
30
- const half = Math.floor(noHintMax / 2);
31
- ws = trunc(ws, half);
32
- proj = trunc(proj, noHintMax - ws.length);
33
- }
34
- else {
35
- ws = "";
36
- proj = "";
37
- }
38
- }
39
- }
21
+ // The leading token reflects the CHAT TYPE:
22
+ // • carrier → "Carrier OS chat" (brand, theme-light green). Carrier chat
23
+ // always uses the General mode, so the mode is NOT shown.
24
+ // • standard → "Standard chat" (light purple) followed by the active mode,
25
+ // since Standard chat is where modes actually vary.
26
+ const isStandard = ctx.chatType === "standard";
27
+ const label = isStandard ? "Standard" : "Carrier OS";
28
+ const paintLabel = isStandard ? STANDARD_LABEL : c.brandFixed;
40
29
  const dot = c.dim(" · ");
41
- let context = "";
42
- if (ws || proj) {
43
- context += c.dim(ws) + dot + c.dim(proj) + dot;
30
+ // Show the active mode ONLY in standard chat: "Standard chat · Code · Grok".
31
+ const modePart = isStandard ? dot + c.value(mode) : "";
32
+ const context = paintLabel(label) + c.dim(" chat") + modePart + dot + c.file(model);
33
+ // Web search rides in the footer as a capability chip next to the model —
34
+ // the point is that you can tell at a glance whether the NEXT message will
35
+ // search. Silent on the workspace default and when explicitly off: the CLI
36
+ // can't see the workspace toggle, so claiming a state there would be a lie,
37
+ // and "off" is the quiet baseline that needs no chip.
38
+ const webLabel = webSearchLabelShort(ctx);
39
+ const webPart = webLabel ? dot + c.accent(`🌐 ${webLabel}`) : "";
40
+ // Turn-shaping toggles (Fast, HIPWR) — shown only when on, so the default
41
+ // footer stays quiet and an enabled one actually stands out.
42
+ // Already coloured by turnShapeLabels — each chip carries its own meaning.
43
+ const shapePart = turnShapeLabels(ctx)
44
+ .map((l) => dot + l)
45
+ .join("");
46
+ // Active conversation. Set apart from the dot-chain on purpose: everything
47
+ // before it is a SETTING for the next message, while this is WHERE you are.
48
+ // Chained with a dot in matching weight it reads as another setting — which
49
+ // is exactly how a title like "AWS outage research" gets mistaken for a mode.
50
+ // Only shown once the title is known (from /sessions, /session or /new); a
51
+ // fresh chat has none until the backend generates one, and a placeholder
52
+ // would be worse than saying nothing.
53
+ // Quoted, because titles are auto-generated from the first message and are
54
+ // often a short lowercase phrase — unquoted, `in hi` reads as a broken
55
+ // sentence rather than the name of a conversation. Matches how the session
56
+ // commands already refer to them ("Switched to “hi”.").
57
+ const title = ctx.config.get("sessionTitle");
58
+ const convo = title ? " " + c.dim(`in “${clip(title, 26)}”`) : "";
59
+ // Attachment indicator: one file shows its name, several show a compact count.
60
+ const names = attachedFilenames(ctx);
61
+ const attach = names.length === 1
62
+ ? dot + c.accent(`📎 ${names[0]}`)
63
+ : names.length > 1
64
+ ? dot + c.accent(`📎 ${names.length} attached`)
65
+ : "";
66
+ return " " + c.dim("‖ ") + context + convo + shapePart + webPart + attach + repoPart();
67
+ }
68
+ /**
69
+ * Where you are on disk, trailing the footer: "my-app · main".
70
+ *
71
+ * peek, not get: this runs on every keystroke, and the workspace must never be
72
+ * something the composer can spawn a Git process for. The descriptor is built
73
+ * once at startup; if it somehow is not there, the footer simply says nothing.
74
+ *
75
+ * Omitted entirely outside a repository. The project name alone would just
76
+ * repeat the folder you can already see in your own prompt, and a footer earns
77
+ * its width by telling you something you would otherwise have to ask for —
78
+ * which branch you are about to work against.
79
+ */
80
+ function repoPart() {
81
+ // A workspace names the repository you are acting on; that is the thing that
82
+ // changes under you, and the one fact a stray `/repo use` would make stale.
83
+ if (inWorkspaceMode()) {
84
+ const active = activeRepository();
85
+ const details = peekRepositoryDetails(active);
86
+ const branch = details?.branch ? ` · ${clip(details.branch, 20)}` : "";
87
+ return " " + c.dim(`${clip(active.name, 24)}${branch}`);
44
88
  }
45
- context += c.accent(mode) + c.dim(" mode") + dot + c.file(model);
46
- const finalStr = " " + c.dim("‖ ") + context + hintStr;
47
- return finalStr;
89
+ const ws = peekWorkspace();
90
+ if (!ws || ws.repository.state !== "detected")
91
+ return "";
92
+ const branch = branchLabel(ws.repository);
93
+ if (!branch)
94
+ return "";
95
+ return " " + c.dim(`${clip(ws.project.name, 20)} · ${clip(branch, 22)}`);
96
+ }
97
+ /** Trim a title to keep the footer on one row. */
98
+ function clip(s, max) {
99
+ return [...s].length <= max ? s : [...s].slice(0, max - 1).join("") + "…";
48
100
  }
@@ -2,56 +2,37 @@ 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
- /** First-run welcome shown when no API key is configured — branded. */
7
+ /** First-run welcome shown when there's no session — just the brandmark; the
8
+ * device-login flow prints the "Welcome to Carrier OS" line + guidance. */
7
9
  export function printWelcome() {
8
10
  line();
9
11
  for (const l of renderBrandmark())
10
12
  line(l);
11
13
  line();
12
- line(" " + c.brand("Welcome to Carrier OS"));
13
- line();
14
- line(" No API key configured.");
15
- line();
16
- line(" Paste your Carrier API Secret Key");
17
- line(chalk.dim(" (or type /exit)"));
18
- line();
19
14
  }
20
- /** Confirmation after a successful first-run login. */
21
- export function printAuthSuccess(scope) {
22
- line();
23
- line(`${chalk.green("✓")} ${chalk.bold("Authentication Successful")}`);
24
- line();
25
- if (scope.user)
26
- kv("Developer", scope.user.email);
27
- kv("Workspace", scope.workspace.name);
28
- kv("Project", scope.project.name);
15
+ /** The post-login welcome screen (Claude-style boxed header + account summary),
16
+ * shown right before the shell opens. */
17
+ export function renderWelcomeBack(_scope, developerName) {
18
+ const title = "Welcome to Carrier OS";
19
+ const inner = ` ${title} `;
20
+ const rule = "─".repeat(inner.length);
29
21
  line();
30
- line(chalk.dim(" Configuration saved."));
22
+ line(" " + c.brand("┌" + rule + "┐"));
23
+ line(" " + c.brand("│") + chalk.bold(inner) + c.brand("│"));
24
+ line(" " + c.brand("└" + rule + "┘"));
31
25
  line();
32
- line(chalk.bold(" Ready."));
26
+ kv("Developer", developerName);
33
27
  line();
34
28
  }
35
29
  export function printShellHelp() {
36
- // A single flat list — no category sections — with white command names.
37
- const rows = [
38
- ["/mode <id>", "switch Carrier mode · /modes to pick"],
39
- ["/model <id>", "set provider model · /models to pick · /model auto"],
40
- ["/clear", "start a fresh session"],
41
- ["/sessions", "list conversations"],
42
- ["/session use [id]", "switch session"],
43
- ["/session delete <id>", "delete a session"],
44
- ["/history [id]", "print a transcript"],
45
- ["/upload <file>", "upload + process a file"],
46
- ["/files", "list your uploads"],
47
- ["/whoami", "workspace / project / account"],
48
- ["/doctor", "diagnostics"],
49
- ["/usage", "requests, tokens, cost"],
50
- ["/login · /logout", "sign in / out"],
51
- ["/version", "CLI + API versions"],
52
- ["/help", "show this help"],
53
- ["/exit", "leave the shell · or Ctrl+D"]
54
- ];
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]);
55
36
  line();
56
37
  line(" " + c.dim("Type a message to chat, or run a slash command:"));
57
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
  }