@carrieros/cli 0.2.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 (97) hide show
  1. package/README.md +142 -57
  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 +80 -14
  6. package/dist/commands/context.js +160 -0
  7. package/dist/commands/doctor.js +46 -1
  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/memory.js +162 -0
  13. package/dist/commands/mode-model.js +39 -3
  14. package/dist/commands/modes.js +4 -1
  15. package/dist/commands/project.js +106 -0
  16. package/dist/commands/repo.js +146 -0
  17. package/dist/commands/repos.js +61 -0
  18. package/dist/commands/review.js +92 -0
  19. package/dist/commands/search.js +92 -0
  20. package/dist/commands/sessions.js +219 -65
  21. package/dist/commands/settings.js +87 -0
  22. package/dist/commands/update.js +159 -0
  23. package/dist/commands/upload.js +204 -31
  24. package/dist/commands/usage.js +212 -16
  25. package/dist/ide/editor-context.js +172 -0
  26. package/dist/ide/ide-session.js +94 -0
  27. package/dist/ide/tool-host.js +109 -0
  28. package/dist/main.js +26 -1
  29. package/dist/services/api.js +140 -6
  30. package/dist/services/chat-stream.js +145 -0
  31. package/dist/services/checkpoints.js +116 -0
  32. package/dist/services/client-tools.js +260 -0
  33. package/dist/services/command-coordinator.js +200 -0
  34. package/dist/services/command-policy.js +404 -0
  35. package/dist/services/config.js +247 -22
  36. package/dist/services/context.js +265 -20
  37. package/dist/services/device-auth.js +42 -30
  38. package/dist/services/diff.js +196 -0
  39. package/dist/services/env-policy.js +108 -0
  40. package/dist/services/file-detect.js +104 -0
  41. package/dist/services/file-resolver.js +199 -0
  42. package/dist/services/file-upload.js +126 -0
  43. package/dist/services/git-tools.js +248 -0
  44. package/dist/services/glob-match.js +164 -0
  45. package/dist/services/helper-bin.js +64 -0
  46. package/dist/services/ignore-rules.js +189 -0
  47. package/dist/services/job-helper.js +307 -0
  48. package/dist/services/local-files.js +517 -0
  49. package/dist/services/local-tools.js +432 -0
  50. package/dist/services/login-flow.js +15 -8
  51. package/dist/services/meta.js +3 -1
  52. package/dist/services/mutation-coordinator.js +161 -0
  53. package/dist/services/mutations.js +493 -0
  54. package/dist/services/open-url.js +68 -0
  55. package/dist/services/output.js +5 -2
  56. package/dist/services/packaged.js +24 -0
  57. package/dist/services/process-runner.js +406 -0
  58. package/dist/services/project-context.js +298 -0
  59. package/dist/services/redaction.js +201 -0
  60. package/dist/services/secure-store.js +197 -0
  61. package/dist/services/session-resolver.js +108 -0
  62. package/dist/services/sia.js +51 -0
  63. package/dist/services/update.js +286 -0
  64. package/dist/services/workspace-registry.js +309 -0
  65. package/dist/services/workspace.js +573 -0
  66. package/dist/shell/shell-chat.js +1028 -57
  67. package/dist/shell/shell-commands.js +200 -11
  68. package/dist/shell/shell-prompt.js +81 -8
  69. package/dist/shell/shell-renderer.js +7 -19
  70. package/dist/shell/shell-router.js +19 -3
  71. package/dist/shell/shell.js +185 -17
  72. package/dist/types/index.js +3 -1
  73. package/dist/ui/approval.js +81 -0
  74. package/dist/ui/banner.js +39 -0
  75. package/dist/ui/btw-overlay.js +230 -0
  76. package/dist/ui/change-review.js +87 -0
  77. package/dist/ui/chat-renderer.js +206 -13
  78. package/dist/ui/colors.js +4 -0
  79. package/dist/ui/command-filter.js +26 -5
  80. package/dist/ui/command-palette.js +17 -4
  81. package/dist/ui/command-registry.js +84 -9
  82. package/dist/ui/command-review.js +138 -0
  83. package/dist/ui/composer-layout.js +41 -0
  84. package/dist/ui/conversation.js +398 -0
  85. package/dist/ui/interrupt.js +35 -0
  86. package/dist/ui/live.js +3 -1
  87. package/dist/ui/markdown.js +63 -9
  88. package/dist/ui/message.js +14 -31
  89. package/dist/ui/screen-prompt.js +181 -0
  90. package/dist/ui/screen.js +1 -1
  91. package/dist/ui/select.js +185 -29
  92. package/dist/ui/sia-qa.js +213 -0
  93. package/dist/ui/text-prompt.js +74 -0
  94. package/dist/ui/trust.js +93 -0
  95. package/dist/ui/ui.js +4 -1
  96. package/package.json +13 -2
  97. 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";
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";
6
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, pickChatType, pickMode, pickModel, setChatType, 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 };
@@ -111,15 +125,111 @@ export async function handleSlash(ctx, program, client, input) {
111
125
  case "model":
112
126
  await setModel(ctx, client, argStr);
113
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.
114
180
  case "new":
181
+ await newSession(ctx, argStr.trim());
182
+ return STAY;
115
183
  case "clear":
116
- ctx.config.set("sessionId", undefined);
117
- 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);
118
205
  return STAY;
119
206
  // โ”€โ”€ Routed to the existing command implementations โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
120
207
  case "whoami":
121
208
  await route(program, ["whoami"]);
122
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;
123
233
  case "doctor":
124
234
  await route(program, ["doctor"]);
125
235
  return STAY;
@@ -127,7 +237,33 @@ export async function handleSlash(ctx, program, client, input) {
127
237
  await route(program, ["usage"]);
128
238
  return STAY;
129
239
  case "files":
130
- 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());
131
267
  return STAY;
132
268
  case "version":
133
269
  await route(program, ["version"]);
@@ -138,26 +274,79 @@ export async function handleSlash(ctx, program, client, input) {
138
274
  case "login":
139
275
  await route(program, ["login", ...rest]);
140
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.
141
281
  case "sessions":
142
- 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]);
143
286
  return STAY;
287
+ // `/history`, `/history 2`, `/history <id>` โ€” the resolver handles all three.
144
288
  case "history":
145
- await route(program, ["history", ...rest]);
289
+ await showHistory(ctx, client, rest[0]);
146
290
  return STAY;
147
291
  case "upload":
148
292
  if (rest.length === 0) {
149
293
  errorLine("Usage: /upload <file>");
150
294
  return STAY;
151
295
  }
296
+ // In the shell the upload command uploads + auto-attaches + prints "Ready.".
152
297
  await route(program, ["upload", ...rest]);
153
298
  return STAY;
154
- 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();
155
323
  if (rest.length === 0) {
156
- errorLine("Usage: /session use [id] | /session delete <id>");
324
+ await pickSession(ctx, client);
325
+ return STAY;
326
+ }
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]);
157
340
  return STAY;
158
341
  }
159
- await route(program, ["session", ...rest]);
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]);
160
348
  return STAY;
349
+ }
161
350
  default:
162
351
  errorLine(`Unknown command: /${cmd}. Type /help for the list.`);
163
352
  return STAY;
@@ -168,7 +357,7 @@ async function runHelpMenu(ctx, program, client) {
168
357
  const chosen = await pickFromList({
169
358
  title: "Commands",
170
359
  description: "Type a message to chat, or pick a command to run.",
171
- choices: COMMANDS.map((entry) => ({
360
+ choices: visibleCommands().map((entry) => ({
172
361
  value: entry.name,
173
362
  label: entry.name,
174
363
  description: entry.desc
@@ -1,6 +1,9 @@
1
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 { 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
8
  export const CARET = c.brand("โฏ") + " ";
6
9
  /** Light purple used for the "Standard chat" footer label (distinct from the
@@ -15,13 +18,83 @@ const STANDARD_LABEL = chalk.hex("#c4a7ff");
15
18
  export function buildFooter(ctx) {
16
19
  const mode = modeLabelShort(ctx);
17
20
  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
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.
21
26
  const isStandard = ctx.chatType === "standard";
22
- const label = isStandard ? "Standard" : mode;
23
- const paintLabel = isStandard ? STANDARD_LABEL : c.accent;
27
+ const label = isStandard ? "Standard" : "Carrier OS";
28
+ const paintLabel = isStandard ? STANDARD_LABEL : c.brandFixed;
24
29
  const dot = c.dim(" ยท ");
25
- const context = paintLabel(label) + c.dim(" chat") + dot + c.file(model);
26
- return " " + c.dim("โ€– ") + context;
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}`);
88
+ }
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("") + "โ€ฆ";
27
100
  }
@@ -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. */
@@ -26,25 +27,12 @@ export function renderWelcomeBack(_scope, 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
  }