@tuned-tensor/cli 0.7.0 → 0.8.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/dist/index.js CHANGED
@@ -948,6 +948,32 @@ function errorMessage(error) {
948
948
  var successMark = () => chalk.green("\u2713");
949
949
  var errorMark = () => chalk.red("\u2717");
950
950
  var accent = chalk.hex("#8B5CF6");
951
+ var ANSI_BOLD = "\x1B[1m";
952
+ var ANSI_BOLD_OFF = "\x1B[22m";
953
+ var ANSI_CLEAR_TO_END = "\x1B[K";
954
+ var ANSI_RESET = "\x1B[0m";
955
+ function inputColorCodes() {
956
+ if (chalk.level === 0) return null;
957
+ if (chalk.level === 1) {
958
+ return {
959
+ background: "\x1B[100m",
960
+ accent: "\x1B[95m",
961
+ text: "\x1B[97m"
962
+ };
963
+ }
964
+ if (chalk.level === 2) {
965
+ return {
966
+ background: "\x1B[48;5;238m",
967
+ accent: "\x1B[38;5;183m",
968
+ text: "\x1B[38;5;255m"
969
+ };
970
+ }
971
+ return {
972
+ background: "\x1B[48;2;50;52;67m",
973
+ accent: "\x1B[38;2;196;181;253m",
974
+ text: "\x1B[38;2;245;243;255m"
975
+ };
976
+ }
951
977
  var DETAIL_LABEL_WIDTH = 15;
952
978
  function styleDetailLines(lines) {
953
979
  return lines.map((line) => {
@@ -1012,30 +1038,38 @@ function helpText(mode, query, palette = false) {
1012
1038
  function activeModelLabel(snapshot) {
1013
1039
  return snapshot.mode === "local" ? snapshot.context.local.activeModelId ?? "base" : snapshot.context.spec?.baseModel ?? "\u2014";
1014
1040
  }
1015
- function logoRows() {
1016
- const muted = chalk.dim("\u2588\u2588");
1017
- return [
1018
- `${chalk.hex("#A78BFA")("\u2588\u2588")} ${muted} ${muted}`,
1019
- `${muted} ${accent("\u2588\u2588")} ${muted}`,
1020
- `${muted} ${muted} ${chalk.hex("#7C3AED")("\u2588\u2588")}`
1021
- ];
1022
- }
1023
1041
  function renderShellBanner(snapshot) {
1024
1042
  const spec = snapshot.context.spec?.name ?? snapshot.context.spec?.path ?? "no spec";
1025
- const heading = snapshot.version ? `${accent.bold("Tuned Tensor")} ${chalk.dim(`v${snapshot.version}`)}` : accent.bold("Tuned Tensor");
1026
- const textRows = [
1043
+ const heading = snapshot.version ? `${accent.bold("tt")} ${chalk.dim(`v${snapshot.version}`)}` : accent.bold("tt");
1044
+ const lines = [
1027
1045
  heading,
1028
- `${chalk.bold(snapshot.mode)} \xB7 ${snapshot.context.projectName} \xB7 ${spec} \xB7 model ${activeModelLabel(snapshot)}`,
1029
- chalk.dim("Ask TT anything \xB7 known commands run directly \xB7 /help for more")
1046
+ chalk.dim(
1047
+ `${snapshot.mode} \xB7 ${snapshot.context.projectName} \xB7 ${spec} \xB7 model ${activeModelLabel(snapshot)}`
1048
+ ),
1049
+ chalk.dim("ctrl+c stop/clear \xB7 ctrl+d exit \xB7 /help commands \xB7 tab complete"),
1050
+ "",
1051
+ chalk.dim("Ask TT anything. Known commands run directly.")
1030
1052
  ];
1031
- const logo = logoRows();
1032
- const lines = textRows.map((row, index) => `${logo[index]} ${row}`);
1033
1053
  return `${lines.join("\n")}
1034
1054
 
1035
1055
  `;
1036
1056
  }
1037
- function renderShellPrompt(snapshot) {
1038
- return `${accent("tt")} ${chalk.bold(snapshot.mode)} ${chalk.dim(snapshot.context.projectName)} \u203A `;
1057
+ function renderShellPrompt() {
1058
+ const colors = inputColorCodes();
1059
+ if (!colors) return "\u203A ";
1060
+ return [
1061
+ colors.background,
1062
+ colors.accent,
1063
+ ANSI_BOLD,
1064
+ "\u203A",
1065
+ ANSI_BOLD_OFF,
1066
+ colors.text,
1067
+ " ",
1068
+ ANSI_CLEAR_TO_END
1069
+ ].join("");
1070
+ }
1071
+ function resetShellPromptStyle() {
1072
+ return chalk.level === 0 ? "" : ANSI_RESET;
1039
1073
  }
1040
1074
  var TunedTensorShellSession = class _TunedTensorShellSession {
1041
1075
  constructor(runner, io, agent, env, contextProvider, version, initialContext) {
@@ -1082,7 +1116,7 @@ var TunedTensorShellSession = class _TunedTensorShellSession {
1082
1116
  };
1083
1117
  }
1084
1118
  prompt() {
1085
- return renderShellPrompt(this.snapshot());
1119
+ return renderShellPrompt();
1086
1120
  }
1087
1121
  banner() {
1088
1122
  return renderShellBanner(this.snapshot());
@@ -1312,10 +1346,12 @@ async function startInteractiveShell(options) {
1312
1346
  });
1313
1347
  readline.on("SIGINT", () => {
1314
1348
  if (session.interruptAgent()) {
1315
- output.write("\n");
1349
+ output.write(`${resetShellPromptStyle()}
1350
+ `);
1316
1351
  return;
1317
1352
  }
1318
- output.write("\n");
1353
+ output.write(`${resetShellPromptStyle()}
1354
+ `);
1319
1355
  readline?.setPrompt(session.prompt());
1320
1356
  readline?.write(null, { ctrl: true, name: "u" });
1321
1357
  });
@@ -1324,15 +1360,18 @@ async function startInteractiveShell(options) {
1324
1360
  readline.prompt();
1325
1361
  try {
1326
1362
  for await (const line of readline) {
1363
+ output.write(resetShellPromptStyle());
1327
1364
  const action = await session.handleLine(line);
1328
1365
  if (action === "exit") {
1329
1366
  readline.close();
1330
1367
  break;
1331
1368
  }
1369
+ output.write("\n");
1332
1370
  readline.setPrompt(session.prompt());
1333
1371
  readline.prompt();
1334
1372
  }
1335
1373
  } finally {
1374
+ output.write(resetShellPromptStyle());
1336
1375
  readline.close();
1337
1376
  }
1338
1377
  }
@@ -1422,6 +1461,7 @@ var TunedTensorAgentSession = class {
1422
1461
  pendingActions = /* @__PURE__ */ new Map();
1423
1462
  activeRequest = null;
1424
1463
  responseStarted = false;
1464
+ reasoningActive = false;
1425
1465
  lineOpen = false;
1426
1466
  get busy() {
1427
1467
  return this.activeRequest !== null;
@@ -1440,6 +1480,7 @@ var TunedTensorAgentSession = class {
1440
1480
  endOpenLine() {
1441
1481
  if (this.lineOpen) this.options.io.write("\n");
1442
1482
  this.lineOpen = false;
1483
+ this.reasoningActive = false;
1443
1484
  }
1444
1485
  renderAction(action) {
1445
1486
  this.endOpenLine();
@@ -1472,15 +1513,32 @@ ${chalk2.yellow.bold("Approval required")} ${chalk2.dim(action.id.slice(0, 8))}
1472
1513
  if (event.type === "text_delta") {
1473
1514
  const delta = stringValue2(payload.delta) ?? stringValue2(payload.text) ?? stringValue2(payload.content);
1474
1515
  if (!delta) return;
1516
+ const followsReasoning = this.reasoningActive;
1517
+ if (followsReasoning) this.endOpenLine();
1475
1518
  if (!this.responseStarted) {
1476
- this.options.io.write(`${accent2.bold("TT")} `);
1519
+ this.options.io.write(`
1520
+ ${accent2.bold("tt")} `);
1477
1521
  this.responseStarted = true;
1478
1522
  this.lineOpen = true;
1523
+ } else if (followsReasoning) {
1524
+ this.options.io.write("\n");
1479
1525
  }
1480
1526
  this.options.io.write(delta);
1481
1527
  this.lineOpen = !delta.endsWith("\n");
1482
1528
  return;
1483
1529
  }
1530
+ if (event.type === "reasoning_delta") {
1531
+ const delta = stringValue2(payload.delta) ?? stringValue2(payload.text) ?? stringValue2(payload.content);
1532
+ if (!delta) return;
1533
+ if (!this.reasoningActive) {
1534
+ this.endOpenLine();
1535
+ this.options.io.write("\n");
1536
+ this.reasoningActive = true;
1537
+ }
1538
+ this.options.io.write(chalk2.dim.italic(delta));
1539
+ this.lineOpen = !delta.endsWith("\n");
1540
+ return;
1541
+ }
1484
1542
  if (event.type === "tool_call") {
1485
1543
  this.endOpenLine();
1486
1544
  const name = stringValue2(payload.name) ?? stringValue2(isRecord(payload.tool_call) ? payload.tool_call.name : null) ?? "tool";
@@ -1538,6 +1596,7 @@ ${chalk2.yellow.bold("Approval required")} ${chalk2.dim(action.id.slice(0, 8))}
1538
1596
  const controller = new AbortController();
1539
1597
  this.activeRequest = controller;
1540
1598
  this.responseStarted = false;
1599
+ this.reasoningActive = false;
1541
1600
  this.lineOpen = false;
1542
1601
  try {
1543
1602
  const result = await operation(controller.signal);
@@ -1556,6 +1615,7 @@ ${chalk2.yellow.bold("Approval required")} ${chalk2.dim(action.id.slice(0, 8))}
1556
1615
  } finally {
1557
1616
  this.activeRequest = null;
1558
1617
  this.responseStarted = false;
1618
+ this.reasoningActive = false;
1559
1619
  this.lineOpen = false;
1560
1620
  }
1561
1621
  }
@@ -6989,7 +7049,7 @@ async function runCli(version, runtime = {}) {
6989
7049
  }
6990
7050
 
6991
7051
  // src/index.ts
6992
- runCli("0.7.0").catch((err) => {
7052
+ runCli("0.8.0").catch((err) => {
6993
7053
  reportError(err);
6994
7054
  process.exit(1);
6995
7055
  });