@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.
- package/README.md +142 -57
- package/dist/commands/attach.js +45 -0
- package/dist/commands/auth.js +60 -0
- package/dist/commands/btw.js +78 -0
- package/dist/commands/changes.js +167 -0
- package/dist/commands/chat.js +102 -13
- package/dist/commands/context.js +160 -0
- package/dist/commands/doctor.js +53 -8
- package/dist/commands/files.js +84 -23
- package/dist/commands/help.js +3 -1
- package/dist/commands/history.js +88 -23
- package/dist/commands/login.js +44 -41
- package/dist/commands/logout.js +13 -4
- package/dist/commands/memory.js +162 -0
- package/dist/commands/mode-model.js +39 -3
- package/dist/commands/modes.js +4 -1
- package/dist/commands/project.js +106 -0
- package/dist/commands/repo.js +146 -0
- package/dist/commands/repos.js +61 -0
- package/dist/commands/review.js +92 -0
- package/dist/commands/scope.js +152 -0
- package/dist/commands/search.js +92 -0
- package/dist/commands/sessions.js +219 -65
- package/dist/commands/settings.js +87 -0
- package/dist/commands/update.js +159 -0
- package/dist/commands/upload.js +204 -31
- package/dist/commands/usage.js +212 -16
- package/dist/commands/whoami.js +2 -1
- package/dist/ide/editor-context.js +172 -0
- package/dist/ide/ide-session.js +94 -0
- package/dist/ide/tool-host.js +109 -0
- package/dist/main.js +30 -1
- package/dist/services/api.js +171 -13
- package/dist/services/chat-stream.js +145 -0
- package/dist/services/checkpoints.js +116 -0
- package/dist/services/client-tools.js +260 -0
- package/dist/services/command-coordinator.js +200 -0
- package/dist/services/command-policy.js +404 -0
- package/dist/services/config.js +249 -22
- package/dist/services/context.js +307 -6
- package/dist/services/device-auth.js +261 -0
- package/dist/services/diff.js +196 -0
- package/dist/services/env-policy.js +108 -0
- package/dist/services/file-detect.js +104 -0
- package/dist/services/file-resolver.js +199 -0
- package/dist/services/file-upload.js +126 -0
- package/dist/services/git-tools.js +248 -0
- package/dist/services/glob-match.js +164 -0
- package/dist/services/helper-bin.js +64 -0
- package/dist/services/ignore-rules.js +189 -0
- package/dist/services/job-helper.js +307 -0
- package/dist/services/local-files.js +517 -0
- package/dist/services/local-tools.js +432 -0
- package/dist/services/login-flow.js +120 -10
- package/dist/services/meta.js +3 -1
- package/dist/services/mutation-coordinator.js +161 -0
- package/dist/services/mutations.js +493 -0
- package/dist/services/open-url.js +68 -0
- package/dist/services/output.js +13 -5
- package/dist/services/packaged.js +24 -0
- package/dist/services/process-runner.js +406 -0
- package/dist/services/project-context.js +298 -0
- package/dist/services/redaction.js +201 -0
- package/dist/services/secure-store.js +197 -0
- package/dist/services/session-resolver.js +108 -0
- package/dist/services/sia.js +51 -0
- package/dist/services/spinner.js +23 -1
- package/dist/services/update.js +286 -0
- package/dist/services/workspace-registry.js +309 -0
- package/dist/services/workspace.js +573 -0
- package/dist/shell/shell-chat.js +1115 -59
- package/dist/shell/shell-commands.js +220 -19
- package/dist/shell/shell-prompt.js +89 -37
- package/dist/shell/shell-renderer.js +19 -38
- package/dist/shell/shell-router.js +19 -3
- package/dist/shell/shell.js +232 -44
- package/dist/types/index.js +3 -1
- package/dist/ui/approval.js +81 -0
- package/dist/ui/banner.js +55 -13
- package/dist/ui/btw-overlay.js +230 -0
- package/dist/ui/change-review.js +87 -0
- package/dist/ui/chat-renderer.js +223 -29
- package/dist/ui/color-picker.js +21 -0
- package/dist/ui/colors.js +9 -1
- package/dist/ui/command-filter.js +40 -5
- package/dist/ui/command-palette.js +122 -62
- package/dist/ui/command-registry.js +85 -11
- package/dist/ui/command-review.js +138 -0
- package/dist/ui/composer-layout.js +41 -0
- package/dist/ui/conversation.js +398 -0
- package/dist/ui/interrupt.js +35 -0
- package/dist/ui/live.js +18 -1
- package/dist/ui/markdown.js +63 -9
- package/dist/ui/message.js +14 -31
- package/dist/ui/screen-prompt.js +181 -0
- package/dist/ui/screen.js +289 -0
- package/dist/ui/select.js +193 -29
- package/dist/ui/sia-qa.js +213 -0
- package/dist/ui/text-prompt.js +74 -0
- package/dist/ui/theme.js +17 -0
- package/dist/ui/trust.js +93 -0
- package/dist/ui/ui.js +4 -1
- package/package.json +17 -6
- package/dist/ui/activity.js +0 -77
package/dist/ui/color-picker.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as readline from "node:readline";
|
|
2
2
|
import chalk from "chalk";
|
|
3
3
|
import { c } from "./colors.js";
|
|
4
|
+
import { resumeScreen, screenActive, suspendScreen } from "./screen.js";
|
|
4
5
|
import { THEME_ORDER, accentHex, accentName, setAccent } from "./theme.js";
|
|
5
6
|
/**
|
|
6
7
|
* Claude-style inline /color selector. Renders on a single line:
|
|
@@ -13,6 +14,19 @@ import { THEME_ORDER, accentHex, accentName, setAccent } from "./theme.js";
|
|
|
13
14
|
*
|
|
14
15
|
* Resolves the chosen color, or null on cancel.
|
|
15
16
|
*/
|
|
17
|
+
/**
|
|
18
|
+
* Claude-style confirmation printed after the accent changes: a filled swatch
|
|
19
|
+
* in the new color, dim body text, and the color name shown in that very color
|
|
20
|
+
* so the change is visible, not just described.
|
|
21
|
+
*
|
|
22
|
+
* ● Accent color set to green
|
|
23
|
+
*/
|
|
24
|
+
export function confirmColor(name) {
|
|
25
|
+
const hex = accentHex(name);
|
|
26
|
+
const swatch = chalk.hex(hex)("●");
|
|
27
|
+
const label = chalk.hex(hex).bold(name);
|
|
28
|
+
process.stdout.write(`\n ${swatch} ${chalk.dim("Accent color set to")} ${label}\n\n`);
|
|
29
|
+
}
|
|
16
30
|
export function pickColor() {
|
|
17
31
|
const stdin = process.stdin;
|
|
18
32
|
const stdout = process.stdout;
|
|
@@ -22,6 +36,11 @@ export function pickColor() {
|
|
|
22
36
|
const original = accentName();
|
|
23
37
|
let sel = Math.max(0, options.indexOf(original));
|
|
24
38
|
return new Promise((resolve) => {
|
|
39
|
+
// Suspend the persistent-composer engine so the inline selector owns its
|
|
40
|
+
// line, then repaint the transcript + composer once a color is chosen.
|
|
41
|
+
const suspended = screenActive();
|
|
42
|
+
if (suspended)
|
|
43
|
+
suspendScreen();
|
|
25
44
|
stdin.removeAllListeners("keypress");
|
|
26
45
|
readline.emitKeypressEvents(stdin);
|
|
27
46
|
if (!stdin.isRaw)
|
|
@@ -46,6 +65,8 @@ export function pickColor() {
|
|
|
46
65
|
readline.clearLine(stdout, 0);
|
|
47
66
|
stdout.write("\x1b[?25h");
|
|
48
67
|
stdin.removeListener("keypress", onKey);
|
|
68
|
+
if (suspended)
|
|
69
|
+
resumeScreen(); // repaint the pinned composer + transcript
|
|
49
70
|
resolve(result);
|
|
50
71
|
};
|
|
51
72
|
const onKey = (_s, key) => {
|
package/dist/ui/colors.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
|
-
import { accentHex } from "./theme.js";
|
|
2
|
+
import { accentHex, accentLightHex, BRAND_HEX } from "./theme.js";
|
|
3
3
|
/**
|
|
4
4
|
* Carrier OS design system — the single source of truth for color. Every piece
|
|
5
5
|
* of CLI output pulls from here, so the whole tool stays consistent. All color
|
|
@@ -18,6 +18,10 @@ export const c = {
|
|
|
18
18
|
get neural() {
|
|
19
19
|
return chalk.hex(accentHex());
|
|
20
20
|
},
|
|
21
|
+
get accentLight() {
|
|
22
|
+
return chalk.hex(accentLightHex());
|
|
23
|
+
}, // soft, light tint of the accent (assistant lead dot)
|
|
24
|
+
brandFixed: chalk.hex(BRAND_HEX), // fixed brand green — wordmark + prompt marker, never follows /color
|
|
21
25
|
wordmark: chalk.whiteBright.bold, // CARRIER block logo (never recolored)
|
|
22
26
|
// Text
|
|
23
27
|
title: chalk.whiteBright.bold, // section titles / headings
|
|
@@ -39,6 +43,10 @@ export const c = {
|
|
|
39
43
|
// Command arguments
|
|
40
44
|
arg: chalk.green, // ids / values (mode, model)
|
|
41
45
|
file: chalk.yellow, // file paths
|
|
46
|
+
// SIA / clarification — deliberately not the yellow the turn-shape chips use,
|
|
47
|
+
// because it isn't one: Fast and HIPWR change how the answer is produced,
|
|
48
|
+
// while this changes the question before it's asked.
|
|
49
|
+
magic: chalk.magentaBright,
|
|
42
50
|
// Status
|
|
43
51
|
ok: chalk.green,
|
|
44
52
|
warn: chalk.yellow,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { byGroupThenRank,
|
|
1
|
+
import { byGroupThenRank, visibleCommands } from "./command-item.js";
|
|
2
2
|
import { THEME_COLORS, THEME_ORDER } from "./theme.js";
|
|
3
3
|
/** After `/color ` (or `/theme `), the palette suggests color values. */
|
|
4
4
|
const COLOR_ARG = /^\/(color|theme)\s+(.*)$/i;
|
|
@@ -23,9 +23,9 @@ export function filterCommands(query) {
|
|
|
23
23
|
}
|
|
24
24
|
const term = query.toLowerCase().replace(/^\//, "").trim();
|
|
25
25
|
if (!term)
|
|
26
|
-
return
|
|
26
|
+
return visibleCommands().sort(byGroupThenRank);
|
|
27
27
|
const scored = [];
|
|
28
|
-
for (const cmd of
|
|
28
|
+
for (const cmd of visibleCommands()) {
|
|
29
29
|
const idx = cmd.name.slice(1).toLowerCase().indexOf(term);
|
|
30
30
|
if (idx !== -1)
|
|
31
31
|
scored.push({ cmd, prefix: idx === 0 });
|
|
@@ -40,18 +40,53 @@ export function filterCommands(query) {
|
|
|
40
40
|
* clean prefix of any command (fuzzy-only matches don't ghost).
|
|
41
41
|
*/
|
|
42
42
|
export function ghostCompletion(query) {
|
|
43
|
-
// Complete a color value after `/color
|
|
43
|
+
// Complete a color value after `/color <partial>`. With nothing typed yet the
|
|
44
|
+
// bracketed argHint() is shown instead, so don't ghost a single value there.
|
|
44
45
|
const color = query.match(/^\/(?:color|theme)\s+(\w*)$/i);
|
|
45
46
|
if (color) {
|
|
46
47
|
const p = color[1].toLowerCase();
|
|
48
|
+
if (!p)
|
|
49
|
+
return "";
|
|
47
50
|
const match = THEME_ORDER.find((n) => n.startsWith(p) && n.length > p.length);
|
|
48
51
|
return match ? match.slice(p.length) : "";
|
|
49
52
|
}
|
|
50
53
|
const term = query.toLowerCase().replace(/^\//, "");
|
|
51
54
|
if (!term)
|
|
52
55
|
return "";
|
|
53
|
-
const matches =
|
|
56
|
+
const matches = visibleCommands().filter((cmd) => cmd.name.slice(1).toLowerCase().startsWith(term)).sort((a, b) => a.rank - b.rank);
|
|
54
57
|
if (matches.length === 0)
|
|
55
58
|
return "";
|
|
56
59
|
return matches[0].name.slice(query.length);
|
|
57
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Claude-style inline argument hint: when a command expects a value but none is
|
|
63
|
+
* typed yet, show the options in-line as a dim `[a|b|c]` placeholder — e.g.
|
|
64
|
+
* `/color ` → `[red|blue|green|…]`. Purely a hint (never accepted by Tab). Empty
|
|
65
|
+
* once a value is being typed, or when the command takes no listed options.
|
|
66
|
+
*/
|
|
67
|
+
/**
|
|
68
|
+
* True once the line is "a complete command, then its argument".
|
|
69
|
+
*
|
|
70
|
+
* From that point the palette must stop treating the line as a search — every
|
|
71
|
+
* further keystroke narrows a list that can never match again, ending in a
|
|
72
|
+
* spurious "No matching commands" while you are simply typing an argument.
|
|
73
|
+
*/
|
|
74
|
+
export function isArgMode(input) {
|
|
75
|
+
const typed = /^(\/\w+)\s/.exec(input);
|
|
76
|
+
if (!typed)
|
|
77
|
+
return false;
|
|
78
|
+
const name = typed[1].toLowerCase();
|
|
79
|
+
// /theme is an alias of /color and isn't in the registry as its own entry.
|
|
80
|
+
return name === "/theme" || visibleCommands().some((c) => c.name === name);
|
|
81
|
+
}
|
|
82
|
+
export function argHint(query) {
|
|
83
|
+
if (/^\/(?:color|theme)\s+$/i.test(query))
|
|
84
|
+
return `[${THEME_ORDER.join("|")}]`;
|
|
85
|
+
// Registry-driven, so a command's hint lives with the command rather than in
|
|
86
|
+
// a list here that would drift out of sync.
|
|
87
|
+
const typed = /^(\/\w+)\s+$/.exec(query);
|
|
88
|
+
if (!typed)
|
|
89
|
+
return "";
|
|
90
|
+
const command = visibleCommands().find((c) => c.name === typed[1].toLowerCase());
|
|
91
|
+
return command?.arg ? `[${command.arg}]` : "";
|
|
92
|
+
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import * as readline from "node:readline";
|
|
2
2
|
import { c } from "./colors.js";
|
|
3
|
-
import {
|
|
4
|
-
import { filterCommands, ghostCompletion } from "./command-filter.js";
|
|
3
|
+
import { TAKES_ARG, visibleCommands } from "./command-item.js";
|
|
4
|
+
import { argHint, filterCommands, ghostCompletion, isArgMode } from "./command-filter.js";
|
|
5
5
|
import { paletteView } from "./command-renderer.js";
|
|
6
6
|
import { accentName, isThemeColor, setAccent } from "./theme.js";
|
|
7
7
|
import { MARGIN, contentWidth } from "./composer-layout.js";
|
|
8
|
+
import { screenClear, screenComposer, screenPrint, screenScrollable, screenScrollLines, screenScrollPage, screenScrollToBottom, screenScrollToTop } from "./screen.js";
|
|
9
|
+
const DEBUG_INPUT = Boolean(process.env.COS_DEBUG_INPUT);
|
|
8
10
|
/** Color name inside a `/color <name>` suggestion, or null. */
|
|
9
11
|
function colorOf(name) {
|
|
10
12
|
const m = name.match(/^\/(?:color|theme)\s+(\w+)$/i);
|
|
@@ -34,7 +36,7 @@ export function readCommand(caret, history, footer = "", placeholder = "") {
|
|
|
34
36
|
let cursor = 0;
|
|
35
37
|
let paletteOpen = false;
|
|
36
38
|
let selected = 0;
|
|
37
|
-
let filtered =
|
|
39
|
+
let filtered = visibleCommands();
|
|
38
40
|
let histIdx = history.length;
|
|
39
41
|
const refilter = () => {
|
|
40
42
|
filtered = filterCommands(input);
|
|
@@ -44,15 +46,18 @@ export function readCommand(caret, history, footer = "", placeholder = "") {
|
|
|
44
46
|
// Full-width input bar (Claude-style): a horizontal rule above and below a
|
|
45
47
|
// `❯ ` prompt spanning the whole terminal. "❯ " is 2 visible cols; input
|
|
46
48
|
// starts at column 2. Long lines scroll horizontally to keep the caret in
|
|
47
|
-
// view.
|
|
48
|
-
//
|
|
49
|
+
// view. Rendering is delegated to the screen engine, which pins this bar to
|
|
50
|
+
// the bottom of the terminal and floats the palette directly above it.
|
|
49
51
|
const MARKER_COLS = 2;
|
|
50
|
-
let prevUp = 0;
|
|
51
52
|
// Live theme preview for `/color <name>` suggestions: previewing the accent
|
|
52
53
|
// as the highlighted color changes, restoring it if the user backs out.
|
|
53
54
|
let colorPreviewOrig = null;
|
|
54
55
|
const applyColorPreview = () => {
|
|
55
|
-
|
|
56
|
+
// Preview the accent for the color currently being typed (completing any
|
|
57
|
+
// ghost value), so the whole UI re-themes live; restored if the user backs
|
|
58
|
+
// out. `/color gr` previews green; a bare `/color ` previews nothing.
|
|
59
|
+
const g = paletteOpen && cursor === input.length ? ghostCompletion(input) : "";
|
|
60
|
+
const sel = paletteOpen ? colorOf((input + g).trim()) : null;
|
|
56
61
|
if (sel) {
|
|
57
62
|
if (colorPreviewOrig === null)
|
|
58
63
|
colorPreviewOrig = accentName();
|
|
@@ -63,60 +68,52 @@ export function readCommand(caret, history, footer = "", placeholder = "") {
|
|
|
63
68
|
colorPreviewOrig = null;
|
|
64
69
|
}
|
|
65
70
|
};
|
|
71
|
+
// Build the composer (input bar + optional palette) and hand it to the
|
|
72
|
+
// screen engine, which pins the bar to the bottom of the terminal and floats
|
|
73
|
+
// the palette in the transcript rows directly above it — the bar never moves.
|
|
66
74
|
const render = () => {
|
|
67
75
|
applyColorPreview();
|
|
68
|
-
// Hide the cursor for the duration of the redraw so it doesn't visibly
|
|
69
|
-
// flicker as it's repositioned; it's shown again at its final resting spot.
|
|
70
|
-
stdout.write("\x1b[?25l");
|
|
71
|
-
// Rewind to the top of the previous block and wipe it clean.
|
|
72
|
-
if (prevUp > 0)
|
|
73
|
-
readline.moveCursor(stdout, 0, -prevUp);
|
|
74
|
-
readline.cursorTo(stdout, 0);
|
|
75
|
-
readline.clearScreenDown(stdout);
|
|
76
76
|
// The composer + its divider lines span the full content width (terminal
|
|
77
77
|
// minus a small margin/gutter), recomputed each render so a resize just
|
|
78
78
|
// redraws cleanly at the new width.
|
|
79
79
|
const total = contentWidth();
|
|
80
80
|
const field = Math.max(8, total - MARKER_COLS); // usable text width
|
|
81
|
-
//
|
|
82
|
-
|
|
81
|
+
// Inline trailer at the caret (only when it sits at the end of the input):
|
|
82
|
+
// a ghost completion (`/ver`→`sion`, `/color gr`→`een`), or — when a value
|
|
83
|
+
// is expected but not yet typed — a dim argument hint (`/color `→`[red|…]`).
|
|
84
|
+
const atEnd = paletteOpen && cursor === input.length;
|
|
85
|
+
const ghost = atEnd ? ghostCompletion(input) : "";
|
|
86
|
+
const hint = atEnd && !ghost ? argHint(input) : "";
|
|
87
|
+
const trailer = ghost || hint;
|
|
83
88
|
const start = cursor > field ? cursor - field : 0;
|
|
84
89
|
const visInput = input.slice(start, start + field);
|
|
85
|
-
const
|
|
90
|
+
const visTrailer = start + visInput.length >= input.length ? trailer.slice(0, field - visInput.length) : "";
|
|
86
91
|
// Empty + closed → show the dim italic placeholder (it never becomes part
|
|
87
92
|
// of the message; typing the first char replaces it, deleting brings it
|
|
88
93
|
// back). Otherwise render the typed text and any ghost completion.
|
|
89
94
|
const showPlaceholder = input === "" && !paletteOpen && placeholder !== "";
|
|
90
95
|
const bodyText = showPlaceholder ? placeholder.slice(0, field) : visInput;
|
|
91
96
|
const body = showPlaceholder ? c.placeholder(bodyText) : c.value(bodyText);
|
|
92
|
-
const promptCols = MARKER_COLS + bodyText.length + (showPlaceholder ? 0 :
|
|
97
|
+
const promptCols = MARKER_COLS + bodyText.length + (showPlaceholder ? 0 : visTrailer.length);
|
|
93
98
|
const pad = " ".repeat(Math.max(0, total - promptCols));
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
//
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
};
|
|
113
|
-
const clearBox = () => {
|
|
114
|
-
// Rewind to the top of the block and wipe it, so callers render clean.
|
|
115
|
-
if (prevUp > 0)
|
|
116
|
-
readline.moveCursor(stdout, 0, -prevUp);
|
|
117
|
-
readline.cursorTo(stdout, 0);
|
|
118
|
-
readline.clearScreenDown(stdout);
|
|
119
|
-
prevUp = 0;
|
|
99
|
+
// The two divider rules carry the runtime accent (/color); the prompt
|
|
100
|
+
// marker stays fixed brand green (branding, never recolored).
|
|
101
|
+
const rule = MARGIN + c.brand("─".repeat(total));
|
|
102
|
+
const promptLine = MARGIN + c.brandFixed("❯") + " " + body + (visTrailer ? c.dim(visTrailer) : "") + pad;
|
|
103
|
+
const core = [rule, promptLine, rule, footer]; // fixed 4-row composer core
|
|
104
|
+
// The command palette floats ABOVE the bar when open — except in the
|
|
105
|
+
// value-entry context (`/color <value>`), where the inline arg hint / ghost
|
|
106
|
+
// on the prompt line replaces the list. The caret sits on the prompt line
|
|
107
|
+
// (core index 1) at the text column (1-based).
|
|
108
|
+
// Once a COMPLETE command is followed by a space, the rest of the line is
|
|
109
|
+
// its argument — not a search query. Filtering the whole line against
|
|
110
|
+
// command names from that point on can only ever say "No matching
|
|
111
|
+
// commands", which is both wrong and alarming while you type a question
|
|
112
|
+
// into /btw. The inline arg hint takes the list's place instead.
|
|
113
|
+
const argMode = isArgMode(input);
|
|
114
|
+
const paletteLines = paletteOpen && !argMode ? paletteView(filtered, selected, input) : [];
|
|
115
|
+
const caretCol = MARGIN.length + MARKER_COLS + (cursor - start) + 1;
|
|
116
|
+
screenComposer(paletteLines, core, 1, caretCol);
|
|
120
117
|
};
|
|
121
118
|
const finish = (res) => {
|
|
122
119
|
paletteOpen = false;
|
|
@@ -126,7 +123,12 @@ export function readCommand(caret, history, footer = "", placeholder = "") {
|
|
|
126
123
|
setAccent(colorPreviewOrig);
|
|
127
124
|
colorPreviewOrig = null;
|
|
128
125
|
}
|
|
129
|
-
|
|
126
|
+
// Clear the composer to an empty prompt so the just-submitted text doesn't
|
|
127
|
+
// linger in the bar while the response streams into the transcript above.
|
|
128
|
+
const total = contentWidth();
|
|
129
|
+
const rule = MARGIN + c.brand("─".repeat(total));
|
|
130
|
+
const empty = MARGIN + c.brandFixed("❯") + " " + " ".repeat(Math.max(0, total - MARKER_COLS));
|
|
131
|
+
screenComposer([], [rule, empty, rule, footer], 1, MARGIN.length + MARKER_COLS + 1);
|
|
130
132
|
stdin.removeListener("keypress", onKey);
|
|
131
133
|
// Raw mode is intentionally left ON between prompts (see the setup note);
|
|
132
134
|
// the shell restores cooked mode when it exits.
|
|
@@ -142,6 +144,20 @@ export function readCommand(caret, history, footer = "", placeholder = "") {
|
|
|
142
144
|
}
|
|
143
145
|
render();
|
|
144
146
|
};
|
|
147
|
+
// Input-history recall. On ↑/↓ when there's nothing to scroll, and always on
|
|
148
|
+
// Ctrl+P / Ctrl+N (so history stays reachable even in a long, scrollable chat).
|
|
149
|
+
const histPrev = () => {
|
|
150
|
+
if (!history.length)
|
|
151
|
+
return;
|
|
152
|
+
histIdx = Math.max(0, histIdx - 1);
|
|
153
|
+
setInput(history[histIdx] ?? "", false);
|
|
154
|
+
};
|
|
155
|
+
const histNext = () => {
|
|
156
|
+
if (!history.length)
|
|
157
|
+
return;
|
|
158
|
+
histIdx = Math.min(history.length, histIdx + 1);
|
|
159
|
+
setInput(histIdx === history.length ? "" : history[histIdx], false);
|
|
160
|
+
};
|
|
145
161
|
const acceptGhost = () => {
|
|
146
162
|
const ghost = ghostCompletion(input);
|
|
147
163
|
if (paletteOpen && cursor === input.length && ghost) {
|
|
@@ -163,6 +179,15 @@ export function readCommand(caret, history, footer = "", placeholder = "") {
|
|
|
163
179
|
const handleKey = (str, key) => {
|
|
164
180
|
if (!key)
|
|
165
181
|
return;
|
|
182
|
+
if (DEBUG_INPUT) {
|
|
183
|
+
screenPrint([
|
|
184
|
+
` \x1b[36m[key] name=${key.name ?? "?"} ctrl=${!!key.ctrl} shift=${!!key.shift} meta=${!!key.meta} str=${JSON.stringify(str)}\x1b[0m`
|
|
185
|
+
]);
|
|
186
|
+
}
|
|
187
|
+
// Drop stray CSI fragments (e.g. mouse-report leftovers) so they can never
|
|
188
|
+
// land in the input buffer — wheel scrolling is handled by the screen engine.
|
|
189
|
+
if (key.name === undefined && !str)
|
|
190
|
+
return;
|
|
166
191
|
if (key.ctrl && key.name === "c") {
|
|
167
192
|
if (input.length)
|
|
168
193
|
return setInput("");
|
|
@@ -171,8 +196,7 @@ export function readCommand(caret, history, footer = "", placeholder = "") {
|
|
|
171
196
|
if (key.ctrl && key.name === "d")
|
|
172
197
|
return finish({ type: "exit" });
|
|
173
198
|
if (key.ctrl && key.name === "l") {
|
|
174
|
-
|
|
175
|
-
prevUp = 0;
|
|
199
|
+
screenClear();
|
|
176
200
|
return render();
|
|
177
201
|
}
|
|
178
202
|
if (key.ctrl && (key.name === "u" || key.name === "k"))
|
|
@@ -181,9 +205,37 @@ export function readCommand(caret, history, footer = "", placeholder = "") {
|
|
|
181
205
|
cursor = 0;
|
|
182
206
|
return render();
|
|
183
207
|
}
|
|
208
|
+
// History recall (always available; ↑/↓ scroll the transcript instead when
|
|
209
|
+
// there's history to scroll through).
|
|
210
|
+
if (key.ctrl && key.name === "p")
|
|
211
|
+
return histPrev();
|
|
212
|
+
if (key.ctrl && key.name === "n")
|
|
213
|
+
return histNext();
|
|
214
|
+
// ── Transcript scrolling (composer stays fixed) ──────────────────────
|
|
215
|
+
// Page keys always scroll history; Shift+↑/↓ nudge a line. Home/End scroll
|
|
216
|
+
// to the top/latest only when the input is empty (else they move the
|
|
217
|
+
// cursor). Mouse-wheel scrolling is handled in the screen engine.
|
|
218
|
+
if (key.name === "pageup")
|
|
219
|
+
return screenScrollPage(1);
|
|
220
|
+
if (key.name === "pagedown")
|
|
221
|
+
return screenScrollPage(-1);
|
|
222
|
+
if (key.shift && key.name === "up")
|
|
223
|
+
return screenScrollLines(1);
|
|
224
|
+
if (key.shift && key.name === "down")
|
|
225
|
+
return screenScrollLines(-1);
|
|
226
|
+
if (key.name === "home" && input.length === 0)
|
|
227
|
+
return screenScrollToTop();
|
|
228
|
+
if (key.name === "end" && input.length === 0)
|
|
229
|
+
return screenScrollToBottom();
|
|
184
230
|
if (key.name === "return" || key.name === "enter") {
|
|
185
|
-
//
|
|
186
|
-
//
|
|
231
|
+
// Value-entry (`/color <value>`): run what's typed, completing any ghost
|
|
232
|
+
// first (`/color gr` → `/color green`; a bare `/color ` → the picker).
|
|
233
|
+
if (paletteOpen && /^\/(?:color|theme)\s/i.test(input)) {
|
|
234
|
+
const g = cursor === input.length ? ghostCompletion(input) : "";
|
|
235
|
+
return finish({ type: "line", value: (input + g).trim() });
|
|
236
|
+
}
|
|
237
|
+
// Otherwise a single Enter RUNS the highlighted command (arg-taking ones
|
|
238
|
+
// open their own picker when given none). Tab inserts-and-adds-an-arg.
|
|
187
239
|
if (paletteOpen && filtered.length) {
|
|
188
240
|
return finish({ type: "line", value: filtered[selected].name });
|
|
189
241
|
}
|
|
@@ -196,27 +248,27 @@ export function readCommand(caret, history, footer = "", placeholder = "") {
|
|
|
196
248
|
}
|
|
197
249
|
return;
|
|
198
250
|
}
|
|
251
|
+
// ↑/↓ — palette navigation; else SCROLL the transcript when there's
|
|
252
|
+
// something to scroll (this is also where the mouse WHEEL lands, since the
|
|
253
|
+
// terminal's alternate-scroll mode turns the wheel into ↑/↓ keys); else
|
|
254
|
+
// recall input history. History is always available on Ctrl+P / Ctrl+N.
|
|
199
255
|
if (key.name === "up") {
|
|
200
256
|
if (paletteOpen) {
|
|
201
257
|
selected = Math.max(0, selected - 1);
|
|
202
|
-
render();
|
|
258
|
+
return render();
|
|
203
259
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
return;
|
|
260
|
+
if (screenScrollable())
|
|
261
|
+
return screenScrollLines(1); // wheel/↑ → older
|
|
262
|
+
return histPrev();
|
|
209
263
|
}
|
|
210
264
|
if (key.name === "down") {
|
|
211
265
|
if (paletteOpen) {
|
|
212
266
|
selected = Math.min(filtered.length - 1, selected + 1);
|
|
213
|
-
render();
|
|
214
|
-
}
|
|
215
|
-
else if (history.length) {
|
|
216
|
-
histIdx = Math.min(history.length, histIdx + 1);
|
|
217
|
-
setInput(histIdx === history.length ? "" : history[histIdx], false);
|
|
267
|
+
return render();
|
|
218
268
|
}
|
|
219
|
-
|
|
269
|
+
if (screenScrollable())
|
|
270
|
+
return screenScrollLines(-1); // wheel/↓ → newer
|
|
271
|
+
return histNext();
|
|
220
272
|
}
|
|
221
273
|
if (key.name === "tab") {
|
|
222
274
|
if (acceptGhost())
|
|
@@ -229,6 +281,14 @@ export function readCommand(caret, history, footer = "", placeholder = "") {
|
|
|
229
281
|
}
|
|
230
282
|
return;
|
|
231
283
|
}
|
|
284
|
+
// ←/→ switch chat type ONLY on an empty composer with the palette shut.
|
|
285
|
+
// Any typed text, and they are cursor keys again — otherwise fixing a
|
|
286
|
+
// typo would change which chat you are in. Modals, pickers and the /btw
|
|
287
|
+
// overlay capture stdin themselves, so this handler cannot run while one
|
|
288
|
+
// is open; no extra guard is needed for them.
|
|
289
|
+
if ((key.name === "left" || key.name === "right") && input === "" && !paletteOpen) {
|
|
290
|
+
return finish({ type: "switch", dir: key.name });
|
|
291
|
+
}
|
|
232
292
|
if (key.name === "left") {
|
|
233
293
|
cursor = Math.max(0, cursor - 1);
|
|
234
294
|
return render();
|
|
@@ -1,7 +1,20 @@
|
|
|
1
|
+
// The active chat experience, so the palette can hide commands that don't apply
|
|
2
|
+
// to it. The shell sets this each loop iteration (it already rebuilds the footer
|
|
3
|
+
// from the same state), which keeps the registry a plain data module — no
|
|
4
|
+
// context object threaded through the filter and renderer.
|
|
5
|
+
let _scope = "carrier";
|
|
6
|
+
export function setCommandScope(scope) {
|
|
7
|
+
_scope = scope;
|
|
8
|
+
}
|
|
9
|
+
/** Commands available in the current chat experience. */
|
|
10
|
+
export function visibleCommands() {
|
|
11
|
+
return COMMANDS.filter((c) => !c.chatTypes || c.chatTypes.includes(_scope));
|
|
12
|
+
}
|
|
1
13
|
/** The order groups render in (only groups with matches are shown). */
|
|
2
14
|
export const GROUP_ORDER = [
|
|
3
15
|
"Chat",
|
|
4
16
|
"Sessions",
|
|
17
|
+
"Context",
|
|
5
18
|
"Models",
|
|
6
19
|
"Files",
|
|
7
20
|
"Account",
|
|
@@ -9,33 +22,94 @@ export const GROUP_ORDER = [
|
|
|
9
22
|
];
|
|
10
23
|
export const COMMANDS = [
|
|
11
24
|
{ name: "/chat", desc: "Start chatting with Carrier", group: "Chat", rank: 1 },
|
|
12
|
-
{ name: "/
|
|
13
|
-
{ name: "/
|
|
14
|
-
{ name: "/
|
|
15
|
-
{ name: "/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
25
|
+
{ name: "/switch", desc: "Switch chat: Carrier ⇄ Standard", group: "Chat", rank: 2 },
|
|
26
|
+
{ name: "/websearch", desc: "Search the web — or a query to search now", group: "Chat", rank: 3, arg: "query" },
|
|
27
|
+
{ name: "/sources", desc: "Sources from the last search", group: "Chat", rank: 4 },
|
|
28
|
+
{ name: "/open", desc: "Open a source in your browser", group: "Chat", rank: 5, arg: "n" },
|
|
29
|
+
// Standard chat only — Carrier Chat always uses its own models, so the web
|
|
30
|
+
// doesn't render the toggle there either (shouldShowToggle).
|
|
31
|
+
{
|
|
32
|
+
name: "/fast",
|
|
33
|
+
desc: "Fast mode — quicker, less refinement",
|
|
34
|
+
group: "Models",
|
|
35
|
+
rank: 3,
|
|
36
|
+
chatTypes: ["standard"],
|
|
37
|
+
arg: "on|off"
|
|
38
|
+
},
|
|
39
|
+
{ name: "/hipwr", desc: "High Power — 4-pass refinement", group: "Models", rank: 4, arg: "on|off" },
|
|
40
|
+
{
|
|
41
|
+
name: "/sia",
|
|
42
|
+
desc: "Clarifying questions — Auto lets Carrier OS decide",
|
|
43
|
+
group: "Chat",
|
|
44
|
+
rank: 6,
|
|
45
|
+
chatTypes: ["standard"],
|
|
46
|
+
arg: "auto|off|status"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: "/btw",
|
|
50
|
+
desc: "Ask a quick side question without adding it to the conversation",
|
|
51
|
+
group: "Chat",
|
|
52
|
+
rank: 7,
|
|
53
|
+
arg: "question"
|
|
54
|
+
},
|
|
55
|
+
{ name: "/new", desc: "Start a new conversation", group: "Sessions", rank: 1, arg: "title" },
|
|
56
|
+
{ name: "/sessions", desc: "List conversations, numbered", group: "Sessions", rank: 2 },
|
|
57
|
+
{ name: "/session", desc: "Continue a session — /session 2", group: "Sessions", rank: 3, arg: "n" },
|
|
58
|
+
{ name: "/history", desc: "Transcript — /history 2", group: "Sessions", rank: 4, arg: "n" },
|
|
59
|
+
{ name: "/context", desc: "What the next message is sent with — try /context project", group: "Context", rank: 1, arg: "project" },
|
|
60
|
+
{ name: "/memory", desc: "Snapshots and restructures — /memory 2", group: "Context", rank: 2, arg: "n" },
|
|
61
|
+
{ name: "/model", desc: "List & switch provider model", group: "Models", rank: 1, arg: "model" },
|
|
62
|
+
{ name: "/mode", desc: "List & switch Carrier mode", group: "Models", rank: 2, arg: "mode" },
|
|
63
|
+
{ name: "/upload", desc: "Upload file(s) — many + * globs", group: "Files", rank: 1, arg: "path" },
|
|
64
|
+
{ name: "/attach", desc: "Attach an upload to your next message", group: "Files", rank: 2, arg: "file" },
|
|
65
|
+
{ name: "/detach", desc: "Clear attached files", group: "Files", rank: 3 },
|
|
66
|
+
{ name: "/files", desc: "Local project tree & uploaded files", group: "Files", rank: 4, arg: "local|uploaded" },
|
|
67
|
+
{ name: "/search", desc: "Search the local project for text", group: "Files", rank: 5, arg: "text" },
|
|
68
|
+
{ name: "/review", desc: "Review this repository's changes (read-only)", group: "Files", rank: 1, arg: "repository" },
|
|
69
|
+
{ name: "/changes", desc: "File changes Carrier OS applied here", group: "Files", rank: 6 },
|
|
70
|
+
{ name: "/undo", desc: "Undo the latest change — /undo --repo <name> for another repository", group: "Files", rank: 7, arg: "operation" },
|
|
71
|
+
{ name: "/repo", desc: "Active repository — /repo use <name> to switch", group: "Context", rank: 3, arg: "use" },
|
|
72
|
+
{ name: "/repos", desc: "Repositories in this workspace", group: "Context", rank: 4 },
|
|
22
73
|
{ name: "/whoami", desc: "Current workspace & project", group: "Account", rank: 1 },
|
|
23
74
|
{ name: "/usage", desc: "View API usage", group: "Account", rank: 2 },
|
|
24
|
-
{ name: "/
|
|
75
|
+
{ name: "/settings", desc: "CLI settings — /settings commands on|off", group: "Account", rank: 3, arg: "commands" },
|
|
76
|
+
{ name: "/login", desc: "Sign in via your browser", group: "Account", rank: 3 },
|
|
25
77
|
{ name: "/logout", desc: "Remove saved credentials", group: "Account", rank: 4 },
|
|
26
78
|
{ name: "/help", desc: "Show available commands", group: "Developer", rank: 1 },
|
|
27
79
|
{ name: "/color", desc: "Change the accent color", group: "Developer", rank: 2 },
|
|
28
80
|
{ name: "/doctor", desc: "Run diagnostics", group: "Developer", rank: 3 },
|
|
29
81
|
{ name: "/version", desc: "Show CLI version", group: "Developer", rank: 4 },
|
|
82
|
+
{
|
|
83
|
+
name: "/update",
|
|
84
|
+
desc: "Check for and install the latest CLI version",
|
|
85
|
+
group: "Developer",
|
|
86
|
+
rank: 5
|
|
87
|
+
},
|
|
30
88
|
{ name: "/exit", desc: "Leave the shell", group: "Developer", rank: 5 }
|
|
31
89
|
];
|
|
32
90
|
/** Commands that take an argument — completed with a trailing space. */
|
|
33
91
|
export const TAKES_ARG = new Set([
|
|
34
92
|
"/mode",
|
|
35
93
|
"/model",
|
|
94
|
+
"/websearch",
|
|
95
|
+
"/fast",
|
|
96
|
+
"/hipwr",
|
|
97
|
+
"/sia",
|
|
98
|
+
"/settings",
|
|
99
|
+
"/btw",
|
|
100
|
+
"/open",
|
|
101
|
+
"/memory",
|
|
102
|
+
"/new",
|
|
36
103
|
"/session",
|
|
37
104
|
"/history",
|
|
38
105
|
"/upload",
|
|
106
|
+
"/attach",
|
|
107
|
+
"/files",
|
|
108
|
+
"/search",
|
|
109
|
+
"/review",
|
|
110
|
+
"/repo",
|
|
111
|
+
"/undo",
|
|
112
|
+
"/context",
|
|
39
113
|
"/color",
|
|
40
114
|
"/theme"
|
|
41
115
|
]);
|