@carrieros/cli 0.1.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 +305 -0
- package/dist/commands/chat.js +93 -0
- package/dist/commands/doctor.js +54 -0
- package/dist/commands/files.js +33 -0
- package/dist/commands/help.js +35 -0
- package/dist/commands/history.js +47 -0
- package/dist/commands/login.js +59 -0
- package/dist/commands/logout.js +15 -0
- package/dist/commands/mode-model.js +28 -0
- package/dist/commands/models.js +28 -0
- package/dist/commands/modes.js +27 -0
- package/dist/commands/sessions.js +123 -0
- package/dist/commands/upload.js +50 -0
- package/dist/commands/usage.js +31 -0
- package/dist/commands/version.js +28 -0
- package/dist/commands/whoami.js +40 -0
- package/dist/main.js +94 -0
- package/dist/services/api.js +115 -0
- package/dist/services/config.js +72 -0
- package/dist/services/context.js +42 -0
- package/dist/services/login-flow.js +15 -0
- package/dist/services/meta.js +13 -0
- package/dist/services/output.js +54 -0
- package/dist/services/spinner.js +18 -0
- package/dist/shell/shell-chat.js +280 -0
- package/dist/shell/shell-commands.js +168 -0
- package/dist/shell/shell-prompt.js +48 -0
- package/dist/shell/shell-renderer.js +70 -0
- package/dist/shell/shell-router.js +21 -0
- package/dist/shell/shell.js +139 -0
- package/dist/types/index.js +4 -0
- package/dist/ui/activity.js +77 -0
- package/dist/ui/banner.js +70 -0
- package/dist/ui/chat-renderer.js +269 -0
- package/dist/ui/code-block.js +52 -0
- package/dist/ui/color-picker.js +79 -0
- package/dist/ui/colors.js +47 -0
- package/dist/ui/command-filter.js +57 -0
- package/dist/ui/command-item.js +6 -0
- package/dist/ui/command-palette.js +306 -0
- package/dist/ui/command-registry.js +47 -0
- package/dist/ui/command-renderer.js +55 -0
- package/dist/ui/composer-layout.js +27 -0
- package/dist/ui/live.js +124 -0
- package/dist/ui/logo.js +58 -0
- package/dist/ui/markdown.js +151 -0
- package/dist/ui/message.js +38 -0
- package/dist/ui/select.js +114 -0
- package/dist/ui/spinner.js +23 -0
- package/dist/ui/sticky-stream.js +64 -0
- package/dist/ui/theme.js +63 -0
- package/dist/ui/ui.js +75 -0
- package/package.json +64 -0
package/dist/ui/ui.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { c } from "./colors.js";
|
|
2
|
+
/**
|
|
3
|
+
* Reusable, cross-platform UI primitives built on the design system. Pure
|
|
4
|
+
* Unicode + Chalk — nothing terminal-specific — so everything renders the same
|
|
5
|
+
* in Windows Terminal, PowerShell, CMD, Git Bash, WSL, macOS and Linux.
|
|
6
|
+
*/
|
|
7
|
+
/** Consistent status icons (never emojis). */
|
|
8
|
+
export const icon = {
|
|
9
|
+
ok: c.ok("✓"),
|
|
10
|
+
warn: c.warn("!"),
|
|
11
|
+
info: c.info("i"),
|
|
12
|
+
err: c.err("✕"),
|
|
13
|
+
bullet: c.accent("•"),
|
|
14
|
+
arrow: c.dim("›"),
|
|
15
|
+
active: c.brand("►")
|
|
16
|
+
};
|
|
17
|
+
/** Current terminal width (columns), with a sane fallback. */
|
|
18
|
+
export function termWidth(fallback = 80) {
|
|
19
|
+
const w = process.stdout.columns;
|
|
20
|
+
return w && w > 0 ? w : fallback;
|
|
21
|
+
}
|
|
22
|
+
/** Visible length of a string, ignoring ANSI color codes. */
|
|
23
|
+
export function visibleLen(s) {
|
|
24
|
+
// eslint-disable-next-line no-control-regex
|
|
25
|
+
return [...s.replace(/\[[0-9;]*m/g, "")].length;
|
|
26
|
+
}
|
|
27
|
+
/** A section header: ── Chat ─────────────────── (width-aware). */
|
|
28
|
+
export function sectionHeader(title) {
|
|
29
|
+
const width = Math.min(termWidth(), 66);
|
|
30
|
+
const left = "── ";
|
|
31
|
+
const used = left.length + [...title].length + 1;
|
|
32
|
+
const fill = "─".repeat(Math.max(2, width - used));
|
|
33
|
+
return c.rule(left) + c.title(title) + " " + c.rule(fill);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Two aligned columns (e.g. command → description). Pads the left column to the
|
|
37
|
+
* widest entry BEFORE coloring, so alignment is never thrown off by ANSI codes.
|
|
38
|
+
*/
|
|
39
|
+
export function twoCol(pairs, left = c.cmd, right = c.dim, gap = 2, indent = " ") {
|
|
40
|
+
const w = Math.max(0, ...pairs.map(([l]) => [...l].length));
|
|
41
|
+
return pairs.map(([l, r]) => indent + left(l.padEnd(w)) + " ".repeat(gap) + right(r));
|
|
42
|
+
}
|
|
43
|
+
/** A premium empty state: a dim title and an optional hint with a command. */
|
|
44
|
+
export function emptyState(title, hint, cmd) {
|
|
45
|
+
const lines = ["", " " + c.dim(title)];
|
|
46
|
+
if (hint && cmd)
|
|
47
|
+
lines.push(" " + c.dim(hint + " ") + c.cmd(cmd));
|
|
48
|
+
else if (hint)
|
|
49
|
+
lines.push(" " + c.dim(hint));
|
|
50
|
+
lines.push("");
|
|
51
|
+
return lines;
|
|
52
|
+
}
|
|
53
|
+
/** A determinate progress bar, e.g. ████████░░░░░░ 60%. */
|
|
54
|
+
export function progressBar(fraction, width = 24) {
|
|
55
|
+
const f = Math.max(0, Math.min(1, fraction));
|
|
56
|
+
const filled = Math.round(f * width);
|
|
57
|
+
return (c.brand("█".repeat(filled)) +
|
|
58
|
+
c.dim("░".repeat(width - filled)) +
|
|
59
|
+
" " +
|
|
60
|
+
c.dim(`${Math.round(f * 100)}%`));
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Colorize a slash-command line for echoing: the command in cyan, and its
|
|
64
|
+
* argument colored by kind (files yellow, other values green).
|
|
65
|
+
*/
|
|
66
|
+
export function colorizeCommand(input) {
|
|
67
|
+
const [cmd, ...rest] = input.split(/\s+/);
|
|
68
|
+
if (!cmd.startsWith("/"))
|
|
69
|
+
return input;
|
|
70
|
+
const arg = rest.join(" ");
|
|
71
|
+
if (!arg)
|
|
72
|
+
return c.cmd(cmd);
|
|
73
|
+
const isFile = /[./\\]/.test(arg) && /\.[a-z0-9]+$/i.test(arg);
|
|
74
|
+
return c.cmd(cmd) + " " + (isFile ? c.file(arg) : c.arg(arg));
|
|
75
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@carrieros/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Carrier OS command-line interface — an interactive shell plus commands for the Carrier OS developer platform (chat, sessions, files, usage) over the public /v1 API.",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"carrieros": "dist/main.js",
|
|
9
|
+
"cos": "dist/main.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=18"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
20
|
+
"prebuild": "npm run clean",
|
|
21
|
+
"build": "tsc -p tsconfig.json",
|
|
22
|
+
"dev": "tsx src/main.ts",
|
|
23
|
+
"start": "node dist/main.js",
|
|
24
|
+
"typecheck": "tsc --noEmit",
|
|
25
|
+
"prepare": "npm run build"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"carrieros",
|
|
29
|
+
"carrier-os",
|
|
30
|
+
"cli",
|
|
31
|
+
"cos",
|
|
32
|
+
"ai",
|
|
33
|
+
"developer-platform",
|
|
34
|
+
"chat",
|
|
35
|
+
"llm",
|
|
36
|
+
"shell"
|
|
37
|
+
],
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git+https://github.com/carrieros-ai/carrieros-cli.git"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://github.com/carrieros-ai/carrieros-cli#readme",
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/carrieros-ai/carrieros-cli/issues"
|
|
45
|
+
},
|
|
46
|
+
"author": "Carrier OS",
|
|
47
|
+
"license": "UNLICENSED",
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@inquirer/prompts": "^7.2.0",
|
|
53
|
+
"axios": "^1.7.9",
|
|
54
|
+
"chalk": "^5.3.0",
|
|
55
|
+
"commander": "^12.1.0",
|
|
56
|
+
"form-data": "^4.0.1",
|
|
57
|
+
"ora": "^8.1.1"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@types/node": "^22.10.2",
|
|
61
|
+
"tsx": "^4.19.2",
|
|
62
|
+
"typescript": "^5.7.2"
|
|
63
|
+
}
|
|
64
|
+
}
|