@robinpath/cli 1.82.0 → 1.84.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 (2) hide show
  1. package/dist/cli.mjs +169 -53
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -18598,7 +18598,7 @@ function getNativeModules() {
18598
18598
  import { join as join3, basename as basename2 } from "node:path";
18599
18599
  import { homedir as homedir2, platform as platform2 } from "node:os";
18600
18600
  import { existsSync as existsSync2 } from "node:fs";
18601
- var CLI_VERSION = true ? "1.82.0" : "1.82.0";
18601
+ var CLI_VERSION = true ? "1.84.0" : "1.84.0";
18602
18602
  var FLAG_QUIET = false;
18603
18603
  var FLAG_VERBOSE = false;
18604
18604
  var FLAG_AUTO_ACCEPT = false;
@@ -21938,11 +21938,6 @@ async function fetchBrainStream(prompt, { onToken, conversationHistory, provider
21938
21938
  if (onToken) onToken(delta);
21939
21939
  } else if (eventType === "validation") {
21940
21940
  if (parsed.retrying) {
21941
- const lines = fullText.split("\n").length;
21942
- for (let i = 0; i < lines; i++) {
21943
- process.stdout.write("\x1B[2K\x1B[1A");
21944
- }
21945
- process.stdout.write("\x1B[2K\r");
21946
21941
  fullText = "";
21947
21942
  if (onToken) {
21948
21943
  onToken("\x1B[RETRY]");
@@ -22571,13 +22566,7 @@ function executeShellCommand(command, timeout = 3e4) {
22571
22566
  stdio: ["pipe", "pipe", "pipe"]
22572
22567
  });
22573
22568
  child.stdout.on("data", (data) => {
22574
- const chunk = data.toString();
22575
- stdout += chunk;
22576
- const lines = chunk.replace(/\n$/, "").split("\n");
22577
- for (const line of lines) {
22578
- if (line.trim()) process.stdout.write(color.dim(` ${line}
22579
- `));
22580
- }
22569
+ stdout += data.toString();
22581
22570
  });
22582
22571
  child.stderr.on("data", (data) => {
22583
22572
  stderr += data.toString();
@@ -24156,11 +24145,115 @@ ${resultSummary}`
24156
24145
 
24157
24146
  // src/ink-repl.tsx
24158
24147
  import { useState, useCallback, useEffect, useMemo } from "react";
24159
- import { render, Box, Text, Static, useInput, useApp } from "ink";
24148
+ import { render, Box as Box2, Text as Text2, Static, useInput, useApp } from "ink";
24160
24149
  import InkSpinner from "ink-spinner";
24150
+
24151
+ // src/ui/Markdown.tsx
24152
+ import { Box, Text } from "ink";
24153
+ import { jsx, jsxs } from "react/jsx-runtime";
24154
+ function parseBlocks(text) {
24155
+ const blocks = [];
24156
+ const codeBlockRegex = /```(\w*)\n([\s\S]*?)```/g;
24157
+ let lastIndex = 0;
24158
+ let match;
24159
+ while ((match = codeBlockRegex.exec(text)) !== null) {
24160
+ if (match.index > lastIndex) {
24161
+ blocks.push({ type: "text", content: text.slice(lastIndex, match.index) });
24162
+ }
24163
+ blocks.push({ type: "code", content: match[2].trimEnd(), lang: match[1] || void 0 });
24164
+ lastIndex = match.index + match[0].length;
24165
+ }
24166
+ if (lastIndex < text.length) {
24167
+ blocks.push({ type: "text", content: text.slice(lastIndex) });
24168
+ }
24169
+ return blocks;
24170
+ }
24171
+ function renderInlineMarkdown(line) {
24172
+ const parts = [];
24173
+ let remaining = line;
24174
+ let key = 0;
24175
+ while (remaining.length > 0) {
24176
+ const boldMatch = remaining.match(/^\*\*(.*?)\*\*/);
24177
+ if (boldMatch) {
24178
+ parts.push(/* @__PURE__ */ jsx(Text, { bold: true, children: boldMatch[1] }, key++));
24179
+ remaining = remaining.slice(boldMatch[0].length);
24180
+ continue;
24181
+ }
24182
+ const codeMatch = remaining.match(/^`([^`]+)`/);
24183
+ if (codeMatch) {
24184
+ parts.push(/* @__PURE__ */ jsx(Text, { color: "yellow", children: codeMatch[1] }, key++));
24185
+ remaining = remaining.slice(codeMatch[0].length);
24186
+ continue;
24187
+ }
24188
+ const nextSpecial = remaining.search(/\*\*|`/);
24189
+ if (nextSpecial === -1) {
24190
+ parts.push(/* @__PURE__ */ jsx(Text, { children: remaining }, key++));
24191
+ break;
24192
+ }
24193
+ parts.push(/* @__PURE__ */ jsx(Text, { children: remaining.slice(0, nextSpecial) }, key++));
24194
+ remaining = remaining.slice(nextSpecial);
24195
+ }
24196
+ return parts;
24197
+ }
24198
+ function TextBlock({ content }) {
24199
+ const lines = content.split("\n");
24200
+ return /* @__PURE__ */ jsx(Box, { flexDirection: "column", children: lines.map((line, i) => {
24201
+ const trimmed = line.trimStart();
24202
+ if (!trimmed) return /* @__PURE__ */ jsx(Text, { children: " " }, i);
24203
+ if (trimmed.startsWith("## ")) {
24204
+ return /* @__PURE__ */ jsx(Text, { bold: true, children: trimmed.slice(3) }, i);
24205
+ }
24206
+ if (trimmed.startsWith("# ")) {
24207
+ return /* @__PURE__ */ jsx(Text, { bold: true, children: trimmed.slice(2) }, i);
24208
+ }
24209
+ if (trimmed.startsWith("- ") || trimmed.startsWith("* ")) {
24210
+ return /* @__PURE__ */ jsxs(Text, { children: [
24211
+ /* @__PURE__ */ jsx(Text, { color: "cyan", children: " \u2022 " }),
24212
+ renderInlineMarkdown(trimmed.slice(2))
24213
+ ] }, i);
24214
+ }
24215
+ const numMatch = trimmed.match(/^(\d+)\.\s/);
24216
+ if (numMatch) {
24217
+ return /* @__PURE__ */ jsxs(Text, { children: [
24218
+ /* @__PURE__ */ jsxs(Text, { color: "cyan", children: [
24219
+ " ",
24220
+ numMatch[1],
24221
+ ". "
24222
+ ] }),
24223
+ renderInlineMarkdown(trimmed.slice(numMatch[0].length))
24224
+ ] }, i);
24225
+ }
24226
+ return /* @__PURE__ */ jsx(Text, { wrap: "wrap", children: renderInlineMarkdown(line) }, i);
24227
+ }) });
24228
+ }
24229
+ function CodeBlock({ content, lang }) {
24230
+ const w = Math.min(process.stdout.columns - 6 || 72, 72);
24231
+ const allLines = content.split("\n");
24232
+ const MAX_CODE_LINES = 30;
24233
+ const truncated = allLines.length > MAX_CODE_LINES;
24234
+ const lines = truncated ? [...allLines.slice(0, 20), `... (${allLines.length - 25} lines hidden)`, ...allLines.slice(-5)] : allLines;
24235
+ return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginY: 1, marginX: 1, children: [
24236
+ /* @__PURE__ */ jsxs(Text, { children: [
24237
+ /* @__PURE__ */ jsx(Text, { dimColor: true, children: " \u250C" }),
24238
+ lang ? /* @__PURE__ */ jsx(Text, { dimColor: true, children: ` ${lang} ` }) : null,
24239
+ /* @__PURE__ */ jsx(Text, { dimColor: true, children: "\u2500".repeat(Math.max(0, w - (lang ? lang.length + 5 : 3))) })
24240
+ ] }),
24241
+ lines.map((line, i) => /* @__PURE__ */ jsxs(Text, { children: [
24242
+ /* @__PURE__ */ jsx(Text, { dimColor: true, children: " \u2502 " }),
24243
+ /* @__PURE__ */ jsx(Text, { color: "white", children: line.slice(0, w - 5) })
24244
+ ] }, i)),
24245
+ /* @__PURE__ */ jsx(Text, { dimColor: true, children: " \u2514" + "\u2500".repeat(w - 3) })
24246
+ ] });
24247
+ }
24248
+ function Markdown({ children }) {
24249
+ const blocks = parseBlocks(children);
24250
+ return /* @__PURE__ */ jsx(Box, { flexDirection: "column", children: blocks.map((block, i) => block.type === "code" ? /* @__PURE__ */ jsx(CodeBlock, { content: block.content, lang: block.lang }, i) : /* @__PURE__ */ jsx(TextBlock, { content: block.content }, i)) });
24251
+ }
24252
+
24253
+ // src/ink-repl.tsx
24161
24254
  import { platform as platform7 } from "node:os";
24162
24255
  import { randomUUID as randomUUID4 } from "node:crypto";
24163
- import { jsx, jsxs } from "react/jsx-runtime";
24256
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
24164
24257
  var nextId = 0;
24165
24258
  var COMMANDS = {
24166
24259
  "/model": "Switch AI model",
@@ -24234,33 +24327,33 @@ function InputArea({ onSubmit, placeholder }) {
24234
24327
  const lines = value.split("\n");
24235
24328
  const empty = value === "";
24236
24329
  const w = Math.min(process.stdout.columns - 4 || 76, 76);
24237
- return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginTop: 1, children: [
24238
- showHints && /* @__PURE__ */ jsx(Box, { flexDirection: "column", marginX: 2, marginBottom: 1, children: matchingCommands.slice(0, 8).map(([cmd, desc]) => /* @__PURE__ */ jsxs(Text, { children: [
24239
- /* @__PURE__ */ jsx(Text, { color: "cyan", children: cmd.padEnd(14) }),
24240
- /* @__PURE__ */ jsx(Text, { dimColor: true, children: desc })
24330
+ return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", marginTop: 1, children: [
24331
+ showHints && /* @__PURE__ */ jsx2(Box2, { flexDirection: "column", marginX: 2, marginBottom: 1, children: matchingCommands.slice(0, 8).map(([cmd, desc]) => /* @__PURE__ */ jsxs2(Text2, { children: [
24332
+ /* @__PURE__ */ jsx2(Text2, { color: "cyan", children: cmd.padEnd(14) }),
24333
+ /* @__PURE__ */ jsx2(Text2, { dimColor: true, children: desc })
24241
24334
  ] }, cmd)) }),
24242
- /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginX: 1, children: [
24243
- /* @__PURE__ */ jsx(Text, { dimColor: true, children: "\u2500".repeat(w) }),
24244
- /* @__PURE__ */ jsx(Box, { paddingX: 1, flexDirection: "column", children: empty ? /* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
24335
+ /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", marginX: 1, children: [
24336
+ /* @__PURE__ */ jsx2(Text2, { dimColor: true, children: "\u2500".repeat(w) }),
24337
+ /* @__PURE__ */ jsx2(Box2, { paddingX: 1, flexDirection: "column", children: empty ? /* @__PURE__ */ jsxs2(Text2, { dimColor: true, children: [
24245
24338
  "> ",
24246
24339
  placeholder
24247
- ] }) : lines.map((line, i) => /* @__PURE__ */ jsxs(Text, { children: [
24248
- i === 0 ? /* @__PURE__ */ jsx(Text, { color: "cyan", children: "> " }) : /* @__PURE__ */ jsx(Text, { dimColor: true, children: " " }),
24340
+ ] }) : lines.map((line, i) => /* @__PURE__ */ jsxs2(Text2, { children: [
24341
+ i === 0 ? /* @__PURE__ */ jsx2(Text2, { color: "cyan", children: "> " }) : /* @__PURE__ */ jsx2(Text2, { dimColor: true, children: " " }),
24249
24342
  line,
24250
- i === lines.length - 1 ? /* @__PURE__ */ jsx(Text, { color: "cyan", children: "\u258E" }) : null
24343
+ i === lines.length - 1 ? /* @__PURE__ */ jsx2(Text2, { color: "cyan", children: "\u258E" }) : null
24251
24344
  ] }, i)) }),
24252
- /* @__PURE__ */ jsx(Text, { dimColor: true, children: "\u2500".repeat(w) })
24345
+ /* @__PURE__ */ jsx2(Text2, { dimColor: true, children: "\u2500".repeat(w) })
24253
24346
  ] }),
24254
- /* @__PURE__ */ jsx(Box, { marginX: 2, children: /* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
24255
- /* @__PURE__ */ jsx(Text, { color: "gray", children: "enter" }),
24347
+ /* @__PURE__ */ jsx2(Box2, { marginX: 2, children: /* @__PURE__ */ jsxs2(Text2, { dimColor: true, children: [
24348
+ /* @__PURE__ */ jsx2(Text2, { color: "gray", children: "enter" }),
24256
24349
  " send ",
24257
- /* @__PURE__ */ jsx(Text, { color: "gray", children: "\\" }),
24350
+ /* @__PURE__ */ jsx2(Text2, { color: "gray", children: "\\" }),
24258
24351
  " newline ",
24259
- /* @__PURE__ */ jsx(Text, { color: "gray", children: "/" }),
24352
+ /* @__PURE__ */ jsx2(Text2, { color: "gray", children: "/" }),
24260
24353
  " commands ",
24261
- /* @__PURE__ */ jsx(Text, { color: "gray", children: "tab" }),
24354
+ /* @__PURE__ */ jsx2(Text2, { color: "gray", children: "tab" }),
24262
24355
  " complete ",
24263
- /* @__PURE__ */ jsx(Text, { color: "gray", children: "@/" }),
24356
+ /* @__PURE__ */ jsx2(Text2, { color: "gray", children: "@/" }),
24264
24357
  " files"
24265
24358
  ] }) })
24266
24359
  ] });
@@ -24304,35 +24397,35 @@ function ChatApp({ engine }) {
24304
24397
  engine.updateStatus();
24305
24398
  }, [engine]);
24306
24399
  const isFirst = messages.length === 0;
24307
- return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", padding: 1, children: [
24308
- /* @__PURE__ */ jsx(Box, { marginBottom: 1, children: /* @__PURE__ */ jsxs(Text, { children: [
24309
- /* @__PURE__ */ jsx(Text, { color: "cyan", bold: true, children: "\u25C6" }),
24400
+ return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", padding: 1, children: [
24401
+ /* @__PURE__ */ jsx2(Box2, { marginBottom: 1, children: /* @__PURE__ */ jsxs2(Text2, { children: [
24402
+ /* @__PURE__ */ jsx2(Text2, { color: "cyan", bold: true, children: "\u25C6" }),
24310
24403
  " ",
24311
- /* @__PURE__ */ jsx(Text, { bold: true, children: "RobinPath" }),
24404
+ /* @__PURE__ */ jsx2(Text2, { bold: true, children: "RobinPath" }),
24312
24405
  " ",
24313
- /* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
24406
+ /* @__PURE__ */ jsxs2(Text2, { dimColor: true, children: [
24314
24407
  "v",
24315
24408
  CLI_VERSION
24316
24409
  ] })
24317
24410
  ] }) }),
24318
- /* @__PURE__ */ jsx(Static, { items: messages, children: (msg) => /* @__PURE__ */ jsx(Box, { paddingX: 1, marginBottom: msg.text.startsWith("\u276F") ? 0 : 1, children: msg.text.startsWith("\u276F") ? /* @__PURE__ */ jsxs(Text, { children: [
24319
- /* @__PURE__ */ jsx(Text, { color: "cyan", bold: true, children: "\u276F" }),
24320
- /* @__PURE__ */ jsx(Text, { bold: true, children: msg.text.slice(1) })
24321
- ] }) : msg.dim ? /* @__PURE__ */ jsx(Text, { dimColor: true, wrap: "wrap", children: msg.text }) : /* @__PURE__ */ jsx(Text, { wrap: "wrap", children: msg.text }) }, msg.id) }),
24322
- loading ? /* @__PURE__ */ jsx(Box, { flexDirection: "column", paddingX: 1, children: streaming ? /* @__PURE__ */ jsxs(Text, { wrap: "wrap", children: [
24323
- streaming,
24324
- /* @__PURE__ */ jsx(Text, { color: "cyan", children: "\u258D" })
24325
- ] }) : /* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
24326
- /* @__PURE__ */ jsx(InkSpinner, { type: "dots" }),
24411
+ /* @__PURE__ */ jsx2(Static, { items: messages, children: (msg) => /* @__PURE__ */ jsx2(Box2, { paddingX: 1, marginBottom: msg.text.startsWith("\u276F") ? 0 : 1, flexDirection: "column", children: msg.text.startsWith("\u276F") ? /* @__PURE__ */ jsxs2(Text2, { children: [
24412
+ /* @__PURE__ */ jsx2(Text2, { color: "cyan", bold: true, children: "\u276F" }),
24413
+ /* @__PURE__ */ jsx2(Text2, { bold: true, children: msg.text.slice(1) })
24414
+ ] }) : msg.dim ? /* @__PURE__ */ jsx2(Text2, { dimColor: true, wrap: "wrap", children: msg.text }) : /* @__PURE__ */ jsx2(Markdown, { children: msg.text }) }, msg.id) }),
24415
+ loading ? /* @__PURE__ */ jsx2(Box2, { flexDirection: "column", paddingX: 1, children: streaming ? /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", children: [
24416
+ /* @__PURE__ */ jsx2(Markdown, { children: streaming }),
24417
+ /* @__PURE__ */ jsx2(Text2, { color: "cyan", children: "\u258D" })
24418
+ ] }) : /* @__PURE__ */ jsxs2(Text2, { dimColor: true, children: [
24419
+ /* @__PURE__ */ jsx2(InkSpinner, { type: "dots" }),
24327
24420
  " Thinking"
24328
- ] }) }) : /* @__PURE__ */ jsx(
24421
+ ] }) }) : /* @__PURE__ */ jsx2(
24329
24422
  InputArea,
24330
24423
  {
24331
24424
  onSubmit: handleSubmit,
24332
24425
  placeholder: isFirst ? "Anything to automate with RobinPath?" : "Ask anything..."
24333
24426
  }
24334
24427
  ),
24335
- status ? /* @__PURE__ */ jsx(Box, { marginTop: 1, paddingX: 1, children: /* @__PURE__ */ jsx(Text, { dimColor: true, children: status }) }) : null
24428
+ status ? /* @__PURE__ */ jsx2(Box2, { marginTop: 1, paddingX: 1, children: /* @__PURE__ */ jsx2(Text2, { dimColor: true, children: status }) }) : null
24336
24429
  ] });
24337
24430
  }
24338
24431
  var ReplEngine = class {
@@ -24559,18 +24652,41 @@ Type / to see available commands.`;
24559
24652
  break;
24560
24653
  }
24561
24654
  if (cleaned) ui?.addMessage(cleaned);
24655
+ const cmdResults = [];
24562
24656
  for (const cmd of commands) {
24563
24657
  const preview = cmd.split("\n")[0].slice(0, 80);
24564
24658
  ui?.addMessage(`$ ${preview}${cmd.includes("\n") ? " ..." : ""}`, true);
24565
24659
  const r = await executeShellCommand(cmd);
24660
+ cmdResults.push({ command: cmd, stdout: r.stdout || "", stderr: r.stderr || "", exitCode: r.exitCode });
24566
24661
  if (r.exitCode === 0 && r.stdout?.trim()) {
24567
- ui?.addMessage(r.stdout.trim().split("\n").slice(0, 5).join("\n"), true);
24662
+ const lines = r.stdout.trim().split("\n");
24663
+ if (lines.length <= 15) {
24664
+ ui?.addMessage(lines.join("\n"), true);
24665
+ } else {
24666
+ ui?.addMessage(
24667
+ `${lines.slice(0, 5).join("\n")}
24668
+ ... (${lines.length - 10} lines hidden)
24669
+ ${lines.slice(-5).join("\n")}`,
24670
+ true
24671
+ );
24672
+ }
24568
24673
  } else if (r.exitCode !== 0) {
24569
- ui?.addMessage(`exit ${r.exitCode}: ${(r.stderr || "").slice(0, 100)}`, true);
24674
+ ui?.addMessage(`exit ${r.exitCode}: ${(r.stderr || "").slice(0, 200)}`, true);
24675
+ } else {
24676
+ ui?.addMessage("done", true);
24570
24677
  }
24571
24678
  }
24572
- const summary = commands.map((cmd) => `$ ${cmd}
24573
- (executed)`).join("\n");
24679
+ const summary = cmdResults.map((r) => {
24680
+ let out = `$ ${r.command}
24681
+ `;
24682
+ if (r.exitCode === 0) out += (r.stdout || "(no output)").slice(0, 5e3);
24683
+ else {
24684
+ out += `Exit: ${r.exitCode}
24685
+ `;
24686
+ if (r.stderr) out += r.stderr.slice(0, 2e3);
24687
+ }
24688
+ return out;
24689
+ }).join("\n\n");
24574
24690
  this.conversationMessages.push({ role: "user", content: `[Results]
24575
24691
  ${summary}` });
24576
24692
  ui?.setStreaming("");
@@ -24582,7 +24698,7 @@ ${summary}` });
24582
24698
  };
24583
24699
  async function startInkREPL(initialPrompt, resumeSessionId, opts = {}) {
24584
24700
  const engine = new ReplEngine(resumeSessionId, opts);
24585
- const { waitUntilExit } = render(/* @__PURE__ */ jsx(ChatApp, { engine }));
24701
+ const { waitUntilExit } = render(/* @__PURE__ */ jsx2(ChatApp, { engine }));
24586
24702
  global.__rpExit = () => engine.exit();
24587
24703
  if (initialPrompt) {
24588
24704
  await new Promise((r) => setTimeout(r, 200));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robinpath/cli",
3
- "version": "1.82.0",
3
+ "version": "1.84.0",
4
4
  "description": "AI-powered scripting CLI — automate anything from your terminal",
5
5
  "type": "module",
6
6
  "license": "MIT",