@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
@@ -0,0 +1,93 @@
1
+ import path from "node:path";
2
+ import { c } from "./colors.js";
3
+ import { pickFromList } from "./select.js";
4
+ /**
5
+ * Workspace trust — the safety check shown the first time the CLI is opened in
6
+ * a folder, before anything reads from it.
7
+ *
8
+ * This is not decoration. `detectLocalFiles` resolves a leading token in your
9
+ * message against the current directory and uploads any file it matches, and
10
+ * `cos upload` reads paths directly — so a bare filename can send a local file
11
+ * to the Carrier OS API. The answer is remembered per folder in the CLI config.
12
+ */
13
+ /** Where the trust decision is explained. Update if a dedicated page lands. */
14
+ const SECURITY_GUIDE_URL = "https://platform.carrieros.ai/docs";
15
+ /** Windows paths are case-insensitive, so compare on a normalized form. */
16
+ function normalize(dir) {
17
+ const resolved = path.resolve(dir);
18
+ return process.platform === "win32" ? resolved.toLowerCase() : resolved;
19
+ }
20
+ export function isTrusted(config, dir = process.cwd()) {
21
+ return (config.get("trustedFolders") ?? []).includes(normalize(dir));
22
+ }
23
+ export function trustFolder(config, dir = process.cwd()) {
24
+ const key = normalize(dir);
25
+ const list = config.get("trustedFolders") ?? [];
26
+ if (list.includes(key))
27
+ return;
28
+ // Bounded so the config can't grow without limit; oldest entries drop first.
29
+ config.set("trustedFolders", [...list, key].slice(-200));
30
+ }
31
+ /** Plain-text word wrap. No ANSI here — color is applied per whole line below. */
32
+ function wrap(text, width) {
33
+ const w = Math.max(20, width);
34
+ const lines = [];
35
+ let cur = "";
36
+ for (const word of text.trim().split(/\s+/).filter(Boolean)) {
37
+ if (cur && cur.length + 1 + word.length > w) {
38
+ lines.push(cur);
39
+ cur = word;
40
+ }
41
+ else {
42
+ cur = cur ? `${cur} ${word}` : word;
43
+ }
44
+ }
45
+ if (cur)
46
+ lines.push(cur);
47
+ return lines;
48
+ }
49
+ /** Exported so the screen can be rendered without a TTY (preview / tests). */
50
+ export function workspaceTrustLines(dir, width) {
51
+ const body = (text) => wrap(text, width).map((l) => " " + c.value(l));
52
+ return [
53
+ " " + c.warn("─".repeat(width)),
54
+ " " + c.warn.bold("Accessing workspace:"),
55
+ "",
56
+ " " + c.title(dir),
57
+ "",
58
+ ...body("Quick safety check: Is this a project you created or one you trust? " +
59
+ "(Like your own code, a well-known open source project, or work from your team). " +
60
+ "If not, take a moment to review what's in this folder first."),
61
+ "",
62
+ ...body("Carrier OS'll be able to read files here and upload them to your workspace when you reference them."),
63
+ "",
64
+ " " + c.dim("Security guide ") + c.dim(SECURITY_GUIDE_URL)
65
+ ];
66
+ }
67
+ /**
68
+ * Ask once per folder. Returns false only when the user declines, which callers
69
+ * treat as "exit without doing anything".
70
+ *
71
+ * Non-TTY runs (pipes, CI) can't answer a prompt, so they proceed — the check
72
+ * is a guard for interactive use, not an authorization boundary.
73
+ */
74
+ export async function ensureWorkspaceTrust(config, dir = process.cwd()) {
75
+ if (!process.stdin.isTTY)
76
+ return true;
77
+ if (isTrusted(config, dir))
78
+ return true;
79
+ const choice = await pickFromList({
80
+ title: "",
81
+ header: (width) => workspaceTrustLines(dir, width),
82
+ choices: [
83
+ { value: "trust", label: "Yes, I trust this folder" },
84
+ { value: "exit", label: "No, exit" }
85
+ ],
86
+ initial: 0,
87
+ confirmOnNumber: true
88
+ });
89
+ if (choice !== "trust")
90
+ return false;
91
+ trustFolder(config, dir);
92
+ return true;
93
+ }
package/dist/ui/ui.js CHANGED
@@ -8,7 +8,10 @@ import { c } from "./colors.js";
8
8
  export const icon = {
9
9
  ok: c.ok("✓"),
10
10
  warn: c.warn("!"),
11
- info: c.info("i"),
11
+ // Informational lines are context, not status — a muted corner-down-right
12
+ // reads as "and then this happened" instead of competing with ✓ / ! / ✕ for
13
+ // attention. U+21B3 is in the base arrows block, so it renders everywhere.
14
+ info: c.dim("↳"),
12
15
  err: c.err("✕"),
13
16
  bullet: c.accent("•"),
14
17
  arrow: c.dim("›"),
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@carrieros/cli",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "private": false,
5
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
6
  "type": "module",
7
- "bin": {
8
- "carrieros": "dist/main.js",
9
- "cos": "dist/main.js"
10
- },
7
+ "bin": {
8
+ "carrieros": "dist/main.js",
9
+ "cos": "dist/main.js"
10
+ },
11
11
  "files": [
12
12
  "dist",
13
13
  "README.md"
@@ -22,7 +22,16 @@
22
22
  "dev": "tsx src/main.ts",
23
23
  "start": "node dist/main.js",
24
24
  "typecheck": "tsc --noEmit",
25
- "prepare": "npm run build"
25
+ "test": "npm run build && node --test \"test/*.test.mjs\"",
26
+ "prepare": "npm run build",
27
+ "test:pty": "npm run build && node test/acceptance/pty-selftest.mjs",
28
+ "test:acceptance": "npm run build && node test/acceptance/live-acceptance.mjs",
29
+ "build:helpers": "node scripts/build-helpers.mjs",
30
+ "bundle": "npm run build && node scripts/bundle.mjs",
31
+ "sea:blob": "node --experimental-sea-config sea-config.json",
32
+ "package:win": "npm run bundle && npm run sea:blob && node -e \"require('fs').copyFileSync(process.execPath,'build/cos.exe')\" && npx --yes postject build/cos.exe NODE_SEA_BLOB build/cos.blob --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2 && npm run build:helpers && node -e \"require('fs').cpSync('vendor/bin','build',{recursive:true})\"",
33
+ "test:exe": "node test/acceptance/packaged-exe.mjs",
34
+ "rehash-helpers": "node scripts/rehash-helpers.mjs"
26
35
  },
27
36
  "keywords": [
28
37
  "carrieros",
@@ -57,7 +66,9 @@
57
66
  "ora": "^8.1.1"
58
67
  },
59
68
  "devDependencies": {
69
+ "@lydell/node-pty": "^1.2.0-beta.15",
60
70
  "@types/node": "^22.10.2",
71
+ "esbuild": "^0.28.2",
61
72
  "tsx": "^4.19.2",
62
73
  "typescript": "^5.7.2"
63
74
  }
@@ -1,77 +0,0 @@
1
- import { c } from "./colors.js";
2
- import { MARGIN } from "./composer-layout.js";
3
- /**
4
- * A live activity timeline — the "thinking" phase, Claude-style but TRUTHFUL to
5
- * the Carrier OS architecture. The CLI only talks to the public API, so steps
6
- * reflect what actually happens (understand the request → select the Carrier
7
- * mode → route to the API → wait for the model), never fabricated file/tool
8
- * actions.
9
- *
10
- * It renders into the composer's transient status region: completed steps dim to
11
- * a ●, and only the current step spins. The shell drives it by emitting phase
12
- * events (request_started → mode_selected → request_sent → waiting → done),
13
- * which map 1:1 to `step()` calls — new backend capabilities (search, files,
14
- * vision, agents…) plug in as extra steps without changing this renderer.
15
- */
16
- const FRAMES = "⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏";
17
- export function startActivity(live) {
18
- const steps = [];
19
- let frame = 0;
20
- const paint = () => {
21
- live.setStatus(steps.map((s, i) => {
22
- const active = !s.done && i === steps.length - 1;
23
- const marker = s.done
24
- ? c.dim("●")
25
- : active
26
- ? c.brand(FRAMES[frame % FRAMES.length])
27
- : c.dim("○");
28
- return MARGIN + marker + " " + c.dim(active ? `${s.label}…` : s.label);
29
- }));
30
- };
31
- const timer = setInterval(() => {
32
- frame++;
33
- paint();
34
- }, 90);
35
- timer.unref?.();
36
- return {
37
- step(label) {
38
- if (steps.length)
39
- steps[steps.length - 1].done = true;
40
- steps.push({ label, done: false });
41
- paint();
42
- },
43
- done() {
44
- for (const s of steps)
45
- s.done = true;
46
- paint();
47
- },
48
- stop() {
49
- clearInterval(timer);
50
- }
51
- };
52
- }
53
- /**
54
- * Truthful activity steps for a chat turn, flavored by the Carrier mode. The
55
- * FIRST steps are brief client-side phases; the LAST step is the one that spins
56
- * while genuinely awaiting the model's response.
57
- */
58
- export function chatActivitySteps(modeLabel) {
59
- const lower = modeLabel.toLowerCase();
60
- if (lower === "code" || lower === "debug") {
61
- return ["Detecting coding task", `Selecting ${modeLabel} mode`, "Routing to Carrier OS", "Generating solution"];
62
- }
63
- if (lower === "research") {
64
- return [
65
- "Understanding your request",
66
- `Selecting ${modeLabel} mode`,
67
- "Routing to Carrier OS",
68
- "Synthesizing response"
69
- ];
70
- }
71
- return [
72
- "Understanding your request",
73
- `Selecting ${modeLabel} mode`,
74
- "Routing to Carrier OS",
75
- "Waiting for the model"
76
- ];
77
- }