@orbit-build/cli 0.1.0 → 0.1.2

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/dist/index.js CHANGED
@@ -118,7 +118,7 @@ import { join as join6 } from "path";
118
118
  // src/tui/FullscreenTui.ts
119
119
  import { join as join4, dirname as dirname2 } from "path";
120
120
  import { homedir as homedir3 } from "os";
121
- import { existsSync as existsSync4, readFileSync as readFileSync3, writeFileSync as writeFileSync2, mkdirSync } from "fs";
121
+ import { existsSync as existsSync4, readFileSync as readFileSync3, writeFileSync as writeFileSync2, mkdirSync, statSync } from "fs";
122
122
  import { exec } from "child_process";
123
123
  import readline from "readline";
124
124
  import { Prompt as Prompt2, Renderer } from "@orbit-build/tui";
@@ -128,7 +128,7 @@ import { ConfigSchema } from "@orbit-build/config";
128
128
  import { Prompt } from "@orbit-build/tui";
129
129
  import picocolors4 from "picocolors";
130
130
  import glob from "fast-glob";
131
- import { existsSync as existsSync3, readFileSync as readFileSync2, readdirSync as readdirSync2 } from "fs";
131
+ import { existsSync as existsSync3, readFileSync as readFileSync2, readdirSync as readdirSync2, unlinkSync } from "fs";
132
132
  import { join as join3, dirname, resolve } from "path";
133
133
  import { homedir as homedir2 } from "os";
134
134
  import { PermissionEngine } from "@orbit-build/permissions";
@@ -241,7 +241,8 @@ var BUILTIN_SLASH_COMMANDS = [
241
241
  "/add",
242
242
  "/drop",
243
243
  "/mode",
244
- "/copy"
244
+ "/copy",
245
+ "/update"
245
246
  ];
246
247
  var CommandRouter = class {
247
248
  constructor(cwd, config, providerInstance, setProviderInstance, loop, tui, useFullscreenTui, getCandidates, setCandidates, getLocalState2, saveLocalState, tuiInteraction, multi) {
@@ -421,6 +422,7 @@ Running shell command: ${shellCmd}...`)
421
422
  ` ${picocolors4.green("/config")} ${picocolors4.cyan("[k=v]")} - \u67E5\u770B\u6216\u4EA4\u4E92\u5F0F/\u76F4\u63A5\u4FEE\u6539\u914D\u7F6E\u53C2\u6570`,
422
423
  ` ${picocolors4.green("/model")} ${picocolors4.cyan("[name]")} - \u52A8\u6001\u67E5\u8BE2\u6216\u5207\u6362\u6B63\u5728\u4F7F\u7528\u7684 AI \u8BED\u8A00\u5927\u6A21\u578B`,
423
424
  ` ${picocolors4.green("/mode")} ${picocolors4.cyan("[mode]")} - \u5207\u6362\u5B89\u5168\u786E\u8BA4\u6A21\u5F0F (strict, normal, auto, plan)`,
425
+ ` ${picocolors4.green("/update")} - \u68C0\u6D4B\u5E76\u66F4\u65B0\u9879\u76EE\u4F9D\u8D56\u5305 (\u5982 npm install)`,
424
426
  "",
425
427
  picocolors4.bold(picocolors4.yellow(" [ Git \u63D0\u4EA4 (Git) ]")),
426
428
  ` ${picocolors4.green("/commit")} ${picocolors4.cyan("[msg]")} - \u6682\u5B58\u5DE5\u4F5C\u533A\u4FEE\u6539\u5E76\u751F\u6210\u63D0\u4EA4 (\u7A7A\u6D88\u606F\u65F6\u4F7F\u7528 LLM \u81EA\u52A8\u751F\u6210)`,
@@ -429,7 +431,7 @@ Running shell command: ${shellCmd}...`)
429
431
  ` ${picocolors4.green("/help")} - \u663E\u793A\u6B64\u5E2E\u52A9\u4FE1\u606F`,
430
432
  ` ${picocolors4.green("/exit")} / ${picocolors4.green("/quit")} - \u5B89\u5168\u9000\u51FA\u4EA4\u4E92\u5F0F\u7EC8\u7AEF`,
431
433
  "",
432
- picocolors4.bold(picocolors4.cyan(" [ Shell \u547D\u4EE4\u76F4\u63A5\u8FD0\u884C ]")),
434
+ picocolors4.bold(picocolors4.cyan(" [ \u7CFB\u7EDF\u63A7\u5236 (System) ]")),
433
435
  ` ${picocolors4.green("!<cmd>")} - \u76F4\u63A5\u6267\u884C\u7CFB\u7EDF\u539F\u751F Shell \u547D\u4EE4 (\u4F8B\u5982: !git diff)`,
434
436
  ""
435
437
  ].join("\n");
@@ -453,6 +455,7 @@ Running shell command: ${shellCmd}...`)
453
455
  ` ${picocolors4.green("/config")} ${picocolors4.cyan("[k=v]")} - View or modify configurations interactively or via key=value`,
454
456
  ` ${picocolors4.green("/model")} ${picocolors4.cyan("[name]")} - Query or dynamically swap the active AI model`,
455
457
  ` ${picocolors4.green("/mode")} ${picocolors4.cyan("[mode]")} - Switch permission safety mode (strict, normal, auto, plan)`,
458
+ ` ${picocolors4.green("/update")} - Detect and update project dependencies (npm/pnpm/yarn install)`,
456
459
  "",
457
460
  picocolors4.bold(picocolors4.yellow(" [ Git Operations ]")),
458
461
  ` ${picocolors4.green("/commit")} ${picocolors4.cyan("[msg]")} - Stage all changes and commit (generates message via LLM if empty)`,
@@ -538,7 +541,7 @@ Running shell command: ${shellCmd}...`)
538
541
  try {
539
542
  const fullP = resolve(cwd, file);
540
543
  if (existsSync3(fullP)) {
541
- import("fs").then((fs) => fs.unlinkSync(fullP));
544
+ unlinkSync(fullP);
542
545
  }
543
546
  } catch {
544
547
  }
@@ -568,6 +571,53 @@ Running shell command: ${shellCmd}...`)
568
571
  }
569
572
  return { shouldExit: false, processed: true };
570
573
  }
574
+ if (command === "/update") {
575
+ const isZh = config.language === "zh";
576
+ const wasActive = useFullscreenTui && tui.isActive;
577
+ const packageJsonPath = join3(cwd, "package.json");
578
+ if (!existsSync3(packageJsonPath)) {
579
+ console.log(
580
+ isZh ? picocolors4.yellow("\u5F53\u524D\u5DE5\u4F5C\u533A\u6CA1\u6709\u68C0\u6D4B\u5230 package.json\uFF0C\u4E0D\u652F\u6301 npm \u66F4\u65B0\u3002") : picocolors4.yellow("No package.json found in the workspace. npm update not supported.")
581
+ );
582
+ return { shouldExit: false, processed: true };
583
+ }
584
+ let installCmd = "npm install";
585
+ if (existsSync3(join3(cwd, "pnpm-lock.yaml"))) {
586
+ installCmd = "pnpm install";
587
+ } else if (existsSync3(join3(cwd, "yarn.lock"))) {
588
+ installCmd = "yarn install";
589
+ } else if (existsSync3(join3(cwd, "bun.lockb"))) {
590
+ installCmd = "bun install";
591
+ }
592
+ if (wasActive) tui.stop();
593
+ try {
594
+ const approved = await Prompt.askApproval(
595
+ isZh ? `\u68C0\u6D4B\u5230\u9879\u76EE\u4F9D\u8D56\u9700\u8981\u66F4\u65B0\uFF0C\u662F\u5426\u8FD0\u884C "${installCmd}"\uFF1F` : `NPM dependencies need update. Run "${installCmd}"?`
596
+ );
597
+ if (approved) {
598
+ console.log(picocolors4.cyan(`
599
+ \u25CF Running "${installCmd}"...`));
600
+ const { execSync: execSync2 } = await import("child_process");
601
+ execSync2(installCmd, { cwd, stdio: "inherit" });
602
+ console.log(picocolors4.green(`\u2714 Dependencies updated successfully.
603
+ `));
604
+ tui.npmNeedsUpdate = false;
605
+ tui.lastNpmCheckTime = Date.now();
606
+ } else {
607
+ console.log(picocolors4.yellow(`
608
+ \u2716 Update cancelled by user.
609
+ `));
610
+ }
611
+ } catch (err) {
612
+ console.log(picocolors4.red(`
613
+ \u2716 Update failed: ${err.message}
614
+ `));
615
+ } finally {
616
+ tui.syncFromLoop(loop);
617
+ if (wasActive) tui.start(config.budgetLimit);
618
+ }
619
+ return { shouldExit: false, processed: true };
620
+ }
571
621
  if (command === "/status") {
572
622
  const activeConfig = loop.getConfig();
573
623
  const activeModel = loop.getModelOverride() || activeConfig.models.default;
@@ -932,14 +982,6 @@ Running shell command: ${shellCmd}...`)
932
982
  {
933
983
  value: "deepseek-v4-pro",
934
984
  label: "deepseek-v4-pro (DeepSeek-V4 / Advanced & Pro)"
935
- },
936
- {
937
- value: "deepseek-chat",
938
- label: "deepseek-chat (DeepSeek-V3 / Chat)"
939
- },
940
- {
941
- value: "deepseek-reasoner",
942
- label: "deepseek-reasoner (DeepSeek-R1 / Reasoner)"
943
985
  }
944
986
  ];
945
987
  } else if (providerId === "ollama") {
@@ -1199,7 +1241,7 @@ ${diff.substring(0, 2e4)}`
1199
1241
  return { shouldExit: false, processed: true };
1200
1242
  }
1201
1243
  const { isAbsolute, relative, resolve: pathResolve } = await import("path");
1202
- const { statSync } = await import("fs");
1244
+ const { statSync: statSync2 } = await import("fs");
1203
1245
  const absPath = isAbsolute(fileArg) ? fileArg : pathResolve(cwd, fileArg);
1204
1246
  const relPath = relative(cwd, absPath).replace(/\\/g, "/");
1205
1247
  if (!existsSync3(absPath)) {
@@ -1245,7 +1287,7 @@ ${matched.map((m) => ` \u2022 ${m}`).join("\n")}`
1245
1287
  return { shouldExit: false, processed: true };
1246
1288
  }
1247
1289
  try {
1248
- const stat = statSync(absPath);
1290
+ const stat = statSync2(absPath);
1249
1291
  if (stat.isDirectory()) {
1250
1292
  const files = await glob("**/*", {
1251
1293
  cwd: absPath,
@@ -1514,7 +1556,7 @@ ${matched.map((m) => ` \u2022 ${m}`).join("\n")}`
1514
1556
  idToDelete = await Prompt.askSelect(
1515
1557
  "Choose a session to delete:",
1516
1558
  deleteOptions
1517
- );
1559
+ ) ?? "";
1518
1560
  } else {
1519
1561
  const idx = parseInt(idToDelete, 10);
1520
1562
  if (!isNaN(idx) && idx >= 1 && idx <= sessions.length) {
@@ -1541,7 +1583,7 @@ ${matched.map((m) => ` \u2022 ${m}`).join("\n")}`
1541
1583
  { value: "yes", label: "Yes, delete it" },
1542
1584
  { value: "no", label: "No, cancel" }
1543
1585
  ]
1544
- );
1586
+ ) ?? "no";
1545
1587
  }
1546
1588
  if (confirm === "yes") {
1547
1589
  handleDelete(idToDelete);
@@ -1635,6 +1677,7 @@ ${matched.map((m) => ` \u2022 ${m}`).join("\n")}`
1635
1677
  value: "cancel",
1636
1678
  label: "Cancel"
1637
1679
  });
1680
+ stopTuiIfNeeded();
1638
1681
  const selectedSessionId = await Prompt.askSelect(
1639
1682
  "Choose a session to load:",
1640
1683
  sessionOptions
@@ -2034,6 +2077,22 @@ async function pageText(text) {
2034
2077
  process.stdin.pause();
2035
2078
  }
2036
2079
  }
2080
+ var MORANDI = {
2081
+ user: (s) => `\x1B[38;2;142;163;175m${s}\x1B[0m`,
2082
+ userBold: (s) => `\x1B[1;38;2;142;163;175m${s}\x1B[0m`,
2083
+ asst: (s) => `\x1B[38;2;143;153;129m${s}\x1B[0m`,
2084
+ asstBold: (s) => `\x1B[1;38;2;143;153;129m${s}\x1B[0m`,
2085
+ cyan: (s) => `\x1B[38;2;142;163;175m${s}\x1B[0m`,
2086
+ accent: (s) => `\x1B[38;2;200;170;120m${s}\x1B[0m`,
2087
+ completed: (s) => `\x1B[38;2;135;165;130m${s}\x1B[0m`,
2088
+ failed: (s) => `\x1B[38;2;180;120;120m${s}\x1B[0m`,
2089
+ warn: (s) => `\x1B[38;2;180;140;130m${s}\x1B[0m`,
2090
+ white: (s) => `\x1B[38;2;230;225;215m${s}\x1B[0m`,
2091
+ whiteBold: (s) => `\x1B[1;38;2;230;225;215m${s}\x1B[0m`,
2092
+ gray: (s) => `\x1B[38;2;150;150;150m${s}\x1B[0m`,
2093
+ dim: (s) => `\x1B[2;38;2;110;110;110m${s}\x1B[0m`
2094
+ };
2095
+ var INPUT_PREFIX_WIDTH = 12;
2037
2096
  var FullscreenTui = class {
2038
2097
  constructor(cwd, modelName, version, config) {
2039
2098
  this.cwd = cwd;
@@ -2080,6 +2139,9 @@ var FullscreenTui = class {
2080
2139
  thoughtElapsed = 0;
2081
2140
  isThinking = false;
2082
2141
  sessionCost = 0;
2142
+ lastNpmCheckTime = 0;
2143
+ isCheckingNpm = false;
2144
+ npmNeedsUpdate = false;
2083
2145
  totalInputTokens = 0;
2084
2146
  totalCacheReadTokens = 0;
2085
2147
  totalOutputTokens = 0;
@@ -2099,6 +2161,8 @@ var FullscreenTui = class {
2099
2161
  modelNameGetter = () => this.modelName;
2100
2162
  permissionsMode = "normal";
2101
2163
  hideAutocomplete = false;
2164
+ /** Cached logo-line widths — static strings, computed once. */
2165
+ _cachedLogoWidths = null;
2102
2166
  cachedPlanLines = [];
2103
2167
  lastPlanReadTime = 0;
2104
2168
  activeContextFiles = [];
@@ -2133,7 +2197,7 @@ var FullscreenTui = class {
2133
2197
  const planItems = [];
2134
2198
  for (const line of lines) {
2135
2199
  const trimmed = line.trim();
2136
- if (trimmed.startsWith("- [ ") || trimmed.startsWith("- [x") || trimmed.startsWith("- [/") || trimmed.startsWith("- [x]") || trimmed.startsWith("- [ ]") || trimmed.startsWith("- [/]")) {
2200
+ if (trimmed.startsWith("- [ ") || trimmed.startsWith("- [x") || trimmed.startsWith("- [/")) {
2137
2201
  planItems.push(trimmed);
2138
2202
  }
2139
2203
  }
@@ -2291,6 +2355,69 @@ var FullscreenTui = class {
2291
2355
  }
2292
2356
  process.stdout.write = this.originalWrite;
2293
2357
  }
2358
+ getNpmNeedsUpdate() {
2359
+ const now = Date.now();
2360
+ if (now - this.lastNpmCheckTime > 8e3) {
2361
+ this.refreshNpmStatusAsync().catch(() => {
2362
+ });
2363
+ }
2364
+ return this.npmNeedsUpdate;
2365
+ }
2366
+ async refreshNpmStatusAsync() {
2367
+ if (this.isCheckingNpm) return;
2368
+ this.isCheckingNpm = true;
2369
+ this.lastNpmCheckTime = Date.now();
2370
+ try {
2371
+ const packageJsonPath = join4(this.cwd, "package.json");
2372
+ if (!existsSync4(packageJsonPath)) {
2373
+ this.npmNeedsUpdate = false;
2374
+ this.isCheckingNpm = false;
2375
+ return;
2376
+ }
2377
+ const nodeModulesPath = join4(this.cwd, "node_modules");
2378
+ if (!existsSync4(nodeModulesPath)) {
2379
+ this.npmNeedsUpdate = true;
2380
+ this.isCheckingNpm = false;
2381
+ this.draw();
2382
+ return;
2383
+ }
2384
+ const lockfiles = ["package-lock.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb"];
2385
+ let maxLockfileMtime = 0;
2386
+ let hasLockfile = false;
2387
+ for (const lf of lockfiles) {
2388
+ const lfPath = join4(this.cwd, lf);
2389
+ if (existsSync4(lfPath)) {
2390
+ hasLockfile = true;
2391
+ const stat = statSync(lfPath);
2392
+ if (stat.mtimeMs > maxLockfileMtime) {
2393
+ maxLockfileMtime = stat.mtimeMs;
2394
+ }
2395
+ }
2396
+ }
2397
+ const configMtimeToCheck = hasLockfile ? maxLockfileMtime : statSync(packageJsonPath).mtimeMs;
2398
+ let maxInstallStateMtime = statSync(nodeModulesPath).mtimeMs;
2399
+ const stateFiles = [
2400
+ join4(nodeModulesPath, ".modules.yaml"),
2401
+ // pnpm
2402
+ join4(nodeModulesPath, ".package-lock.json")
2403
+ // npm
2404
+ ];
2405
+ for (const sf of stateFiles) {
2406
+ if (existsSync4(sf)) {
2407
+ const stat = statSync(sf);
2408
+ if (stat.mtimeMs > maxInstallStateMtime) {
2409
+ maxInstallStateMtime = stat.mtimeMs;
2410
+ }
2411
+ }
2412
+ }
2413
+ this.npmNeedsUpdate = configMtimeToCheck > maxInstallStateMtime;
2414
+ } catch {
2415
+ this.npmNeedsUpdate = false;
2416
+ } finally {
2417
+ this.isCheckingNpm = false;
2418
+ this.draw();
2419
+ }
2420
+ }
2294
2421
  getGitSummary() {
2295
2422
  const now = Date.now();
2296
2423
  if (!this.cachedGitSummary) {
@@ -2416,7 +2543,7 @@ var FullscreenTui = class {
2416
2543
  if (this.handleScrollInput(str, key)) {
2417
2544
  return;
2418
2545
  }
2419
- if (key && key.ctrl && key.name === "c") {
2546
+ if (key && (key.name === "escape" || key.ctrl && key.name === "c")) {
2420
2547
  if (this.inputBuffer.length > 0) {
2421
2548
  this.inputBuffer = "";
2422
2549
  this.cursorPosition = 0;
@@ -2610,16 +2737,12 @@ var FullscreenTui = class {
2610
2737
  if (defaultProvider?.includes("deepseek")) {
2611
2738
  models = [
2612
2739
  "deepseek-v4-flash",
2613
- "deepseek-v4-pro",
2614
- "deepseek-chat",
2615
- "deepseek-reasoner"
2740
+ "deepseek-v4-pro"
2616
2741
  ];
2617
2742
  } else {
2618
2743
  models = [
2619
2744
  "gpt-4o",
2620
- "gpt-4o-mini",
2621
- "deepseek-chat",
2622
- "deepseek-reasoner"
2745
+ "gpt-4o-mini"
2623
2746
  ];
2624
2747
  }
2625
2748
  } else if (providerType === "ollama") {
@@ -2727,11 +2850,13 @@ var FullscreenTui = class {
2727
2850
  const localIdx = localAsstIdx[i];
2728
2851
  if (localIdx !== void 0) {
2729
2852
  this.history[localIdx].text = textBlock.text;
2853
+ this.history[localIdx].model = loopMsg.metadata?.model;
2730
2854
  } else {
2731
2855
  this.history.push({
2732
2856
  role: "assistant",
2733
2857
  text: textBlock.text,
2734
- attempt: i + 1
2858
+ attempt: i + 1,
2859
+ model: loopMsg.metadata?.model
2735
2860
  });
2736
2861
  }
2737
2862
  }
@@ -2759,7 +2884,8 @@ var FullscreenTui = class {
2759
2884
  this.history.push({
2760
2885
  role: "assistant",
2761
2886
  text: textBlock?.text || "",
2762
- attempt
2887
+ attempt,
2888
+ model: msg.metadata?.model
2763
2889
  });
2764
2890
  } else if (msg.role === "system") {
2765
2891
  const text = msg.content.map((c) => c.type === "text" ? c.text : "").join("");
@@ -3066,7 +3192,13 @@ var FullscreenTui = class {
3066
3192
  }
3067
3193
  } else if (key && key.name === "escape") {
3068
3194
  this.activeCommandIndex = 0;
3069
- this.hideAutocomplete = true;
3195
+ if (!this.hideAutocomplete) {
3196
+ this.hideAutocomplete = true;
3197
+ } else if (this.inputBuffer.length > 0) {
3198
+ this.inputBuffer = "";
3199
+ this.cursorPosition = 0;
3200
+ }
3201
+ this.render();
3070
3202
  } else if (str && !/[\u0000-\u001f\u007f]/.test(str) && (!key || !key.ctrl && !key.meta && key.name !== "tab")) {
3071
3203
  this.activeCommandIndex = 0;
3072
3204
  this.hideAutocomplete = false;
@@ -3180,21 +3312,7 @@ var FullscreenTui = class {
3180
3312
  render(forceFull = false) {
3181
3313
  const columns = Math.max(40, process.stdout.columns || 80);
3182
3314
  const rows = Math.max(10, process.stdout.rows || 24);
3183
- const morandi = {
3184
- user: (s) => `\x1B[38;2;142;163;175m${s}\x1B[0m`,
3185
- userBold: (s) => `\x1B[1;38;2;142;163;175m${s}\x1B[0m`,
3186
- asst: (s) => `\x1B[38;2;143;153;129m${s}\x1B[0m`,
3187
- asstBold: (s) => `\x1B[1;38;2;143;153;129m${s}\x1B[0m`,
3188
- cyan: (s) => `\x1B[38;2;142;163;175m${s}\x1B[0m`,
3189
- accent: (s) => `\x1B[38;2;200;170;120m${s}\x1B[0m`,
3190
- completed: (s) => `\x1B[38;2;135;165;130m${s}\x1B[0m`,
3191
- failed: (s) => `\x1B[38;2;180;120;120m${s}\x1B[0m`,
3192
- warn: (s) => `\x1B[38;2;180;140;130m${s}\x1B[0m`,
3193
- white: (s) => `\x1B[38;2;230;225;215m${s}\x1B[0m`,
3194
- whiteBold: (s) => `\x1B[1;38;2;230;225;215m${s}\x1B[0m`,
3195
- gray: (s) => `\x1B[38;2;150;150;150m${s}\x1B[0m`,
3196
- dim: (s) => `\x1B[2;38;2;110;110;110m${s}\x1B[0m`
3197
- };
3315
+ const morandi = MORANDI;
3198
3316
  const isWaitingInput = this.resolveInput !== null;
3199
3317
  const isInputActive = isWaitingInput || this.thinkingKeypressListener !== null;
3200
3318
  const hasInput = isInputActive && this.inputBuffer.length > 0;
@@ -3302,7 +3420,7 @@ var FullscreenTui = class {
3302
3420
  let rightPart = "";
3303
3421
  let rightW = 0;
3304
3422
  if (hint) {
3305
- const availableRightW = maxPopupWidth - leftW - 2 - 4;
3423
+ const availableRightW = maxPopupWidth - leftW - 1 - 4;
3306
3424
  if (availableRightW >= 5) {
3307
3425
  const rawRightW = this.getStringWidth(hint);
3308
3426
  if (rawRightW <= availableRightW) {
@@ -3370,20 +3488,25 @@ var FullscreenTui = class {
3370
3488
  );
3371
3489
  bottomLines.push(" " + statusText + " ".repeat(spacing) + keybindings);
3372
3490
  const bottomHeight = bottomLines.length;
3373
- const cleanModel = this.modelNameGetter().replace(/\[1m\]/g, "");
3491
+ const cleanModel = this.modelNameGetter().replace(/\x1b\[[0-9;]*[a-zA-Z]/g, "");
3374
3492
  const gitSummary = this.getGitSummary();
3375
3493
  const gitBranch = gitSummary.branch;
3494
+ const heartColor = this.getNpmNeedsUpdate() ? `\x1B[5m\x1B[38;2;230;190;80m` : `\x1B[38;2;230;110;110m`;
3376
3495
  const logoLines = [
3377
3496
  `\x1B[38;2;142;163;175m /\\___/\\ \x1B[0m`,
3378
3497
  `\x1B[38;2;142;163;175m ( o.o ) \x1B[0m`,
3379
- `\x1B[38;2;142;163;175m / >\x1B[38;2;230;110;110m\u2665\x1B[38;2;142;163;175m< \\ \x1B[0m`,
3498
+ `\x1B[38;2;142;163;175m / >${heartColor}\u2665\x1B[25m\x1B[38;2;142;163;175m< \\ \x1B[0m`,
3380
3499
  `\x1B[38;2;142;163;175m (__/ \\__) \x1B[0m`
3381
3500
  ];
3382
- const w0 = this.getStringWidth(logoLines[0]);
3383
- const w1 = this.getStringWidth(logoLines[1]);
3384
- const w2 = this.getStringWidth(logoLines[2]);
3385
- const w3 = this.getStringWidth(logoLines[3]);
3386
- const maxLogoW = Math.max(w0, w1, w2, w3);
3501
+ if (!this._cachedLogoWidths) {
3502
+ const w02 = this.getStringWidth(logoLines[0]);
3503
+ const w12 = this.getStringWidth(logoLines[1]);
3504
+ const w22 = this.getStringWidth(logoLines[2]);
3505
+ const w32 = this.getStringWidth(logoLines[3]);
3506
+ const maxW = Math.max(w02, w12, w22, w32);
3507
+ this._cachedLogoWidths = { w0: w02, w1: w12, w2: w22, w3: w32, maxW };
3508
+ }
3509
+ const { w0, w1, w2, w3, maxW: maxLogoW } = this._cachedLogoWidths;
3387
3510
  const pad0 = " ".repeat(maxLogoW - w0);
3388
3511
  const pad1 = " ".repeat(maxLogoW - w1);
3389
3512
  const pad2 = " ".repeat(maxLogoW - w2);
@@ -3439,19 +3562,17 @@ var FullscreenTui = class {
3439
3562
  const cleanHeaderModel = cleanModel.split("/").pop() || cleanModel;
3440
3563
  let headerLines;
3441
3564
  if (columns < 76) {
3442
- const modelWidth = Math.max(8, columns - 16);
3443
- const displayModel = this.getStringWidth(cleanHeaderModel) > modelWidth ? this.truncateToWidth(cleanHeaderModel, modelWidth - 3) + "..." : cleanHeaderModel;
3444
3565
  const compactPath = truncatePath(shortCwd, Math.max(8, columns - 15));
3445
3566
  const compactBranch = gitBranch === "no-git" ? "" : ` \xB7 ${gitBranch.length > 12 ? gitBranch.slice(0, 9) + "..." : gitBranch}`;
3446
3567
  headerLines = [
3447
- ` ${morandi.whiteBold("O R B I T")} ${morandi.dim("\xB7")} ${morandi.accent(displayModel)}`,
3568
+ ` ${morandi.whiteBold("O R B I T")}`,
3448
3569
  ` ${morandi.dim("workspace:")} ${morandi.gray(compactPath)}`,
3449
3570
  ` ${morandi.dim(cacheText)}${morandi.dim(compactBranch)}`
3450
3571
  ];
3451
3572
  } else {
3452
- const headerLine1 = ` ${logoLines[0]}${pad0} ${morandi.whiteBold("O R B I T")} ${morandi.dim("\xB7")} ${morandi.accent(cleanHeaderModel)}`;
3453
- const headerLine2 = ` ${logoLines[1]}${pad1} ${" ".repeat(20)}${morandi.dim("workspace:")} ${morandi.gray(displayPath)}${branchText}`;
3454
- const headerLine3 = ` ${logoLines[2]}${pad2} ${" ".repeat(20)}${morandi.dim(cacheText)}`;
3573
+ const headerLine1 = ` ${logoLines[0]}${pad0}`;
3574
+ const headerLine2 = ` ${logoLines[1]}${pad1} ${morandi.whiteBold("O R B I T")} ${morandi.dim("workspace:")} ${morandi.gray(displayPath)}${branchText}`;
3575
+ const headerLine3 = ` ${logoLines[2]}${pad2} ${morandi.dim(cacheText)}`;
3455
3576
  const headerLine4 = ` ${logoLines[3]}${pad3}`;
3456
3577
  headerLines = [headerLine1, headerLine2, headerLine3, headerLine4];
3457
3578
  }
@@ -3576,13 +3697,15 @@ var FullscreenTui = class {
3576
3697
  }
3577
3698
  asstLines.push(...asstObj._formattedCached);
3578
3699
  }
3700
+ const turnModel = turn.assistant?.model || cleanModel;
3701
+ const cleanTurnModel = turnModel.replace(/\x1b\[[0-9;]*[a-zA-Z]/g, "");
3579
3702
  let footerStatusLine = "";
3580
3703
  const lastSys = turn.system[turn.system.length - 1];
3581
3704
  if (lastSys && lastSys.text.includes("Failed")) {
3582
- footerStatusLine = `${morandi.failed("failed")} \xB7 ${morandi.dim(cleanModel)}`;
3705
+ footerStatusLine = `${morandi.failed("failed")} \xB7 ${morandi.dim(cleanTurnModel)}`;
3583
3706
  } else if (turn.assistant.totalTime !== void 0) {
3584
3707
  const sec = (turn.assistant.totalTime / 1e3).toFixed(1);
3585
- footerStatusLine = `${morandi.completed("completed")} \xB7 ${morandi.dim(cleanModel)} \xB7 ${morandi.dim(sec + "s")}`;
3708
+ footerStatusLine = `${morandi.completed("completed")} \xB7 ${morandi.dim(cleanTurnModel)} \xB7 ${morandi.dim(sec + "s")}`;
3586
3709
  }
3587
3710
  if (footerStatusLine) {
3588
3711
  asstLines.push("");
@@ -3593,7 +3716,7 @@ var FullscreenTui = class {
3593
3716
  wrappedAsstLines.push(...this.wrapLine(line, columns - 10));
3594
3717
  }
3595
3718
  renderedLines.push(
3596
- " " + morandi.asstBold(`\u{1F916} Orbit (${cleanModel})`)
3719
+ " " + morandi.asstBold(`\u{1F916} Orbit (${cleanTurnModel})`)
3597
3720
  );
3598
3721
  renderedLines.push(aBorder);
3599
3722
  for (const line of wrappedAsstLines) {
@@ -3738,7 +3861,7 @@ var FullscreenTui = class {
3738
3861
  }
3739
3862
  tempLen += line.length;
3740
3863
  }
3741
- const lineStartX = cursorLineIndex === 0 ? this.getStringWidth(" \u2502 orbit > ") : 12;
3864
+ const lineStartX = cursorLineIndex === 0 ? INPUT_PREFIX_WIDTH : 12;
3742
3865
  const targetX = lineStartX + xOffset;
3743
3866
  const linesUp = formattedLines.length - cursorLineIndex + 1;
3744
3867
  cursorSequence2 = `\x1B[${linesUp}A\x1B[${targetX + 1}G\x1B[?25h`;
@@ -3767,7 +3890,7 @@ var FullscreenTui = class {
3767
3890
  }
3768
3891
  tempLen += line.length;
3769
3892
  }
3770
- const lineStartX = cursorLineIndex === 0 ? this.getStringWidth(" \u2502 orbit > ") : 12;
3893
+ const lineStartX = cursorLineIndex === 0 ? INPUT_PREFIX_WIDTH : 12;
3771
3894
  const targetX = lineStartX + xOffset;
3772
3895
  const linesUp = formattedLines.length - cursorLineIndex + 1;
3773
3896
  cursorSequence = `\x1B[${linesUp}A\x1B[${targetX + 1}G\x1B[?25h`;
@@ -3959,7 +4082,7 @@ import {
3959
4082
  eventBus,
3960
4083
  AutocompleteEngine
3961
4084
  } from "@orbit-build/core";
3962
- import { Prompt as Prompt3, Renderer as Renderer2 } from "@orbit-build/tui";
4085
+ import { Prompt as Prompt3, Renderer as Renderer2, DiffView } from "@orbit-build/tui";
3963
4086
  import picocolors5 from "picocolors";
3964
4087
  import { existsSync as existsSync5, readFileSync as readFileSync4, writeFileSync as writeFileSync3, mkdirSync as mkdirSync2, watch } from "fs";
3965
4088
  import { join as join5, dirname as dirname3, resolve as resolve2 } from "path";
@@ -4122,6 +4245,12 @@ Risk Warning: ${reason}`);
4122
4245
  });
4123
4246
  if (resumeSessionId && useFullscreenTui) {
4124
4247
  tui.loadHistory(loop.getHistory());
4248
+ tui.setCost(
4249
+ loop.getSessionCost(),
4250
+ loop.getTotalInputTokens(),
4251
+ loop.getTotalCacheReadTokens(),
4252
+ loop.getTotalOutputTokens()
4253
+ );
4125
4254
  }
4126
4255
  tui.setModelNameGetter(
4127
4256
  () => loop.getModelOverride() || this.config.models.default
@@ -4433,10 +4562,10 @@ async function runAgent(cwd, task, cliOverrides, multi, options) {
4433
4562
  }
4434
4563
  if (config.models) {
4435
4564
  if (config.models.default) {
4436
- config.models.default = config.models.default.replace(/\[1m\]/g, "");
4565
+ config.models.default = config.models.default.replace(/\x1b\[[0-9;]*[a-zA-Z]/g, "");
4437
4566
  }
4438
4567
  if (config.models.fast) {
4439
- config.models.fast = config.models.fast.replace(/\[1m\]/g, "");
4568
+ config.models.fast = config.models.fast.replace(/\x1b\[[0-9;]*[a-zA-Z]/g, "");
4440
4569
  }
4441
4570
  }
4442
4571
  const providerName = config.provider.default;
package/package.json CHANGED
@@ -1,27 +1,40 @@
1
1
  {
2
2
  "name": "@orbit-build/cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "orbit": "./dist/index.js"
7
7
  },
8
8
  "main": "./dist/index.js",
9
9
  "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./dist/index.js",
13
+ "types": "./dist/index.d.ts"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "README.md"
19
+ ],
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
10
23
  "dependencies": {
11
24
  "picocolors": "^1.0.1",
12
25
  "commander": "^12.1.0",
13
26
  "fast-glob": "^3.3.2",
14
27
  "yaml": "^2.4.5",
15
28
  "zod": "^3.23.8",
16
- "@orbit-build/shared": "0.1.0",
17
- "@orbit-build/config": "0.1.0",
18
- "@orbit-build/core": "0.1.0",
19
- "@orbit-build/model-providers": "0.1.0",
20
- "@orbit-build/context-engine": "0.1.0",
21
- "@orbit-build/permissions": "0.1.0",
22
- "@orbit-build/tui": "0.1.0"
29
+ "@orbit-build/core": "0.1.2",
30
+ "@orbit-build/shared": "0.1.2",
31
+ "@orbit-build/config": "0.1.2",
32
+ "@orbit-build/tui": "0.1.2",
33
+ "@orbit-build/model-providers": "0.1.2",
34
+ "@orbit-build/permissions": "0.1.2",
35
+ "@orbit-build/context-engine": "0.1.2"
23
36
  },
24
37
  "scripts": {
25
- "build": "tsup src/index.ts --format esm --dts"
38
+ "build": "tsup src/index.ts --format esm --dts --clean"
26
39
  }
27
40
  }
@@ -1,14 +0,0 @@
1
- import {
2
- FullscreenTui,
3
- nextCodePointIndex,
4
- pageText,
5
- parseMouseWheelDirection,
6
- previousCodePointIndex
7
- } from "./chunk-QYRH36M4.js";
8
- export {
9
- FullscreenTui,
10
- nextCodePointIndex,
11
- pageText,
12
- parseMouseWheelDirection,
13
- previousCodePointIndex
14
- };