@robinpath/cli 2.3.0 → 2.5.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/cli.mjs +60 -8
- 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 ? "2.
|
|
18601
|
+
var CLI_VERSION = true ? "2.5.0" : "2.5.0";
|
|
18602
18602
|
var FLAG_QUIET = false;
|
|
18603
18603
|
var FLAG_VERBOSE = false;
|
|
18604
18604
|
var FLAG_AUTO_ACCEPT = false;
|
|
@@ -22868,7 +22868,7 @@ var MAX_FILE_SIZE = 5e4;
|
|
|
22868
22868
|
var MAX_TOTAL_SIZE = 2e5;
|
|
22869
22869
|
function findFileRefs(prompt) {
|
|
22870
22870
|
const refs = [];
|
|
22871
|
-
const regex =
|
|
22871
|
+
const regex = /@([\w.\-\/\\*]+)/g;
|
|
22872
22872
|
let match;
|
|
22873
22873
|
while ((match = regex.exec(prompt)) !== null) {
|
|
22874
22874
|
refs.push(match[1]);
|
|
@@ -22948,7 +22948,7 @@ ${f.content}
|
|
|
22948
22948
|
}
|
|
22949
22949
|
let cleaned = prompt;
|
|
22950
22950
|
for (const pattern of patterns) {
|
|
22951
|
-
cleaned = cleaned.replace(
|
|
22951
|
+
cleaned = cleaned.replace(`@${pattern}`, "").trim();
|
|
22952
22952
|
}
|
|
22953
22953
|
const expanded = fileBlocks.length > 0 ? `${fileBlocks.join("\n\n")}
|
|
22954
22954
|
|
|
@@ -22965,7 +22965,7 @@ function listReferenceableFiles(cwd, prefix) {
|
|
|
22965
22965
|
try {
|
|
22966
22966
|
const stat2 = statSync4(join10(workDir, entry));
|
|
22967
22967
|
if (stat2.isFile() && stat2.size <= MAX_FILE_SIZE) {
|
|
22968
|
-
const ref =
|
|
22968
|
+
const ref = `@${entry}`;
|
|
22969
22969
|
if (!prefix || ref.startsWith(prefix)) {
|
|
22970
22970
|
results.push(ref);
|
|
22971
22971
|
}
|
|
@@ -24242,7 +24242,7 @@ function Markdown({ children }) {
|
|
|
24242
24242
|
// src/ink-repl.tsx
|
|
24243
24243
|
import { homedir as homedir8, platform as platform7 } from "node:os";
|
|
24244
24244
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
24245
|
-
import { existsSync as existsSync11, readFileSync as readFileSync10, writeFileSync as writeFileSync6 } from "node:fs";
|
|
24245
|
+
import { existsSync as existsSync11, readdirSync as readdirSync6, statSync as statSync6, readFileSync as readFileSync10, writeFileSync as writeFileSync6 } from "node:fs";
|
|
24246
24246
|
import { join as join12 } from "node:path";
|
|
24247
24247
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
24248
24248
|
var nextId = 0;
|
|
@@ -24271,6 +24271,24 @@ function InputArea({ onSubmit, placeholder, statusText }) {
|
|
|
24271
24271
|
return Object.entries(COMMANDS).filter(([cmd]) => cmd.startsWith(value));
|
|
24272
24272
|
}, [value]);
|
|
24273
24273
|
const showHints = value.startsWith("/") && matchingCommands.length > 0;
|
|
24274
|
+
const showFiles = useMemo(() => {
|
|
24275
|
+
const atMatch = value.match(/@(\S*)$/);
|
|
24276
|
+
if (!atMatch) return [];
|
|
24277
|
+
const prefix = atMatch[1] || "";
|
|
24278
|
+
try {
|
|
24279
|
+
const entries = readdirSync6(process.cwd());
|
|
24280
|
+
return entries.filter((e) => !e.startsWith(".") && (!prefix || e.toLowerCase().startsWith(prefix.toLowerCase()))).slice(0, 10).map((e) => {
|
|
24281
|
+
try {
|
|
24282
|
+
const s = statSync6(join12(process.cwd(), e));
|
|
24283
|
+
return { name: e, isDir: s.isDirectory() };
|
|
24284
|
+
} catch {
|
|
24285
|
+
return { name: e, isDir: false };
|
|
24286
|
+
}
|
|
24287
|
+
});
|
|
24288
|
+
} catch {
|
|
24289
|
+
return [];
|
|
24290
|
+
}
|
|
24291
|
+
}, [value]);
|
|
24274
24292
|
useInput((ch, key) => {
|
|
24275
24293
|
if (key.return) {
|
|
24276
24294
|
if (value.endsWith("\\")) {
|
|
@@ -24302,7 +24320,17 @@ function InputArea({ onSubmit, placeholder, statusText }) {
|
|
|
24302
24320
|
return;
|
|
24303
24321
|
}
|
|
24304
24322
|
if (key.tab) {
|
|
24305
|
-
if (matchingCommands.length === 1)
|
|
24323
|
+
if (matchingCommands.length === 1) {
|
|
24324
|
+
setValue(matchingCommands[0][0]);
|
|
24325
|
+
return;
|
|
24326
|
+
}
|
|
24327
|
+
if (showFiles.length > 0) {
|
|
24328
|
+
const atMatch = value.match(/@(\S*)$/);
|
|
24329
|
+
if (atMatch) {
|
|
24330
|
+
const before = value.slice(0, value.length - atMatch[0].length);
|
|
24331
|
+
setValue(before + "@" + showFiles[0].name + " ");
|
|
24332
|
+
}
|
|
24333
|
+
}
|
|
24306
24334
|
return;
|
|
24307
24335
|
}
|
|
24308
24336
|
if (ch === "") {
|
|
@@ -24318,6 +24346,25 @@ function InputArea({ onSubmit, placeholder, statusText }) {
|
|
|
24318
24346
|
const lines = value.split("\n");
|
|
24319
24347
|
const empty = value === "";
|
|
24320
24348
|
const w = Math.min(process.stdout.columns - 4 || 76, 76);
|
|
24349
|
+
function renderLineWithFileRefs(line) {
|
|
24350
|
+
const parts = [];
|
|
24351
|
+
const refRegex = /@([\w.\-]+)/g;
|
|
24352
|
+
let lastIdx = 0;
|
|
24353
|
+
let m;
|
|
24354
|
+
let k2 = 0;
|
|
24355
|
+
while ((m = refRegex.exec(line)) !== null) {
|
|
24356
|
+
if (m.index > lastIdx) parts.push(/* @__PURE__ */ jsx2(Text2, { children: line.slice(lastIdx, m.index) }, k2++));
|
|
24357
|
+
const fileName = m[1];
|
|
24358
|
+
const fileExists = existsSync11(join12(process.cwd(), fileName));
|
|
24359
|
+
parts.push(/* @__PURE__ */ jsxs2(Text2, { color: fileExists ? "cyan" : void 0, bold: fileExists, children: [
|
|
24360
|
+
"@",
|
|
24361
|
+
fileName
|
|
24362
|
+
] }, k2++));
|
|
24363
|
+
lastIdx = m.index + m[0].length;
|
|
24364
|
+
}
|
|
24365
|
+
if (lastIdx < line.length) parts.push(/* @__PURE__ */ jsx2(Text2, { children: line.slice(lastIdx) }, k2++));
|
|
24366
|
+
return parts.length > 0 ? parts : [/* @__PURE__ */ jsx2(Text2, { children: line }, 0)];
|
|
24367
|
+
}
|
|
24321
24368
|
return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", marginTop: 1, children: [
|
|
24322
24369
|
showHints && /* @__PURE__ */ jsx2(Box2, { flexDirection: "column", marginX: 2, marginBottom: 1, children: matchingCommands.slice(0, 8).map(([cmd, desc]) => /* @__PURE__ */ jsxs2(Text2, { children: [
|
|
24323
24370
|
/* @__PURE__ */ jsx2(Text2, { color: "cyan", children: cmd.padEnd(14) }),
|
|
@@ -24330,13 +24377,18 @@ function InputArea({ onSubmit, placeholder, statusText }) {
|
|
|
24330
24377
|
placeholder
|
|
24331
24378
|
] }) : lines.map((line, i) => /* @__PURE__ */ jsxs2(Text2, { children: [
|
|
24332
24379
|
i === 0 ? /* @__PURE__ */ jsx2(Text2, { color: "cyan", children: "> " }) : /* @__PURE__ */ jsx2(Text2, { dimColor: true, children: " " }),
|
|
24333
|
-
line,
|
|
24380
|
+
renderLineWithFileRefs(line),
|
|
24334
24381
|
i === lines.length - 1 ? /* @__PURE__ */ jsx2(Text2, { color: "cyan", children: "\u258E" }) : null
|
|
24335
24382
|
] }, i)) }),
|
|
24336
24383
|
/* @__PURE__ */ jsx2(Text2, { dimColor: true, children: "\u2500".repeat(Math.max(process.stdout.columns || 80, 40)) })
|
|
24337
24384
|
] }),
|
|
24385
|
+
showFiles.length > 0 && /* @__PURE__ */ jsx2(Box2, { flexDirection: "column", paddingX: 2, marginTop: 1, children: showFiles.map((f) => /* @__PURE__ */ jsxs2(Text2, { children: [
|
|
24386
|
+
/* @__PURE__ */ jsx2(Text2, { color: "cyan", children: "+ " }),
|
|
24387
|
+
/* @__PURE__ */ jsx2(Text2, { bold: f.name.endsWith(".rp") || f.name.endsWith(".robin"), children: f.name }),
|
|
24388
|
+
f.isDir ? /* @__PURE__ */ jsx2(Text2, { dimColor: true, children: "/" }) : null
|
|
24389
|
+
] }, f.name)) }),
|
|
24338
24390
|
/* @__PURE__ */ jsxs2(Box2, { paddingX: 2, justifyContent: "space-between", children: [
|
|
24339
|
-
/* @__PURE__ */ jsx2(Text2, { dimColor: true, children: "/ for commands" }),
|
|
24391
|
+
/* @__PURE__ */ jsx2(Text2, { dimColor: true, children: "/ for commands \xB7 @ for files" }),
|
|
24340
24392
|
/* @__PURE__ */ jsx2(Text2, { dimColor: true, children: statusText || "" })
|
|
24341
24393
|
] })
|
|
24342
24394
|
] });
|