@hasna/coders 0.1.7 → 0.1.9
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 +72 -68
- package/dist/cli.mjs.map +3 -3
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -62587,29 +62587,40 @@ function renderBlockquote(token) {
|
|
|
62587
62587
|
}
|
|
62588
62588
|
function renderTable(token, maxWidth) {
|
|
62589
62589
|
const lines = [];
|
|
62590
|
-
const
|
|
62590
|
+
const stripMd = (s) => s.replace(/\*\*(.+?)\*\*/g, "$1").replace(/`([^`]+)`/g, "$1").replace(/\[([^\]]+)\]\([^)]+\)/g, "$1");
|
|
62591
|
+
const colWidths = token.header.map((h) => stripMd(h.text).length);
|
|
62591
62592
|
for (const row of token.rows) {
|
|
62592
62593
|
for (let i = 0; i < row.length; i++) {
|
|
62593
|
-
colWidths[i] = Math.max(colWidths[i] ?? 0, row[i].text.length);
|
|
62594
|
+
colWidths[i] = Math.max(colWidths[i] ?? 0, stripMd(row[i].text).length);
|
|
62594
62595
|
}
|
|
62595
62596
|
}
|
|
62596
|
-
const
|
|
62597
|
-
|
|
62598
|
-
|
|
62597
|
+
const overhead = colWidths.length * 3 + 1;
|
|
62598
|
+
const maxTable = maxWidth - 4;
|
|
62599
|
+
const totalWidth = colWidths.reduce((a, b) => a + b, 0) + overhead;
|
|
62600
|
+
if (totalWidth > maxTable) {
|
|
62601
|
+
const available = maxTable - overhead;
|
|
62602
|
+
const total = colWidths.reduce((a, b) => a + b, 0);
|
|
62599
62603
|
for (let i = 0; i < colWidths.length; i++) {
|
|
62600
|
-
colWidths[i] = Math.max(
|
|
62604
|
+
colWidths[i] = Math.max(4, Math.floor(colWidths[i] / total * available));
|
|
62601
62605
|
}
|
|
62602
62606
|
}
|
|
62603
|
-
const headerLine = token.header.map((h, i) =>
|
|
62607
|
+
const headerLine = token.header.map((h, i) => padRendered(renderInline(h.text), stripMd(h.text), colWidths[i])).join(` ${FG_GRAY}\u2502${FG_DEFAULT} `);
|
|
62604
62608
|
lines.push(`${BOLD}${headerLine}${BOLD_OFF}`);
|
|
62605
62609
|
const sepLine = colWidths.map((w) => "\u2500".repeat(w)).join(`\u2500\u253C\u2500`);
|
|
62606
62610
|
lines.push(`${FG_GRAY}${sepLine}${FG_DEFAULT}`);
|
|
62607
62611
|
for (const row of token.rows) {
|
|
62608
|
-
const rowLine = row.map((cell, i) =>
|
|
62612
|
+
const rowLine = row.map((cell, i) => padRendered(renderInline(cell.text), stripMd(cell.text), colWidths[i])).join(` ${FG_GRAY}\u2502${FG_DEFAULT} `);
|
|
62609
62613
|
lines.push(rowLine);
|
|
62610
62614
|
}
|
|
62611
62615
|
return lines;
|
|
62612
62616
|
}
|
|
62617
|
+
function padRendered(rendered, plain, width) {
|
|
62618
|
+
if (plain.length >= width) {
|
|
62619
|
+
const truncPlain = plain.slice(0, width - 1) + "\u2026";
|
|
62620
|
+
return renderInline(truncPlain);
|
|
62621
|
+
}
|
|
62622
|
+
return rendered + " ".repeat(width - plain.length);
|
|
62623
|
+
}
|
|
62613
62624
|
function renderInline(text) {
|
|
62614
62625
|
return renderInlineWithRestore(text, "");
|
|
62615
62626
|
}
|
|
@@ -62641,10 +62652,6 @@ function highlightSyntax(line, lang) {
|
|
|
62641
62652
|
result = result.replace(/\b(\d+\.?\d*)\b/g, `${FG_YELLOW}$1${FG_DEFAULT}`);
|
|
62642
62653
|
return result;
|
|
62643
62654
|
}
|
|
62644
|
-
function pad(text, width) {
|
|
62645
|
-
if (text.length >= width) return text.slice(0, width);
|
|
62646
|
-
return text + " ".repeat(width - text.length);
|
|
62647
|
-
}
|
|
62648
62655
|
var ESC2, RESET, BOLD, BOLD_OFF, DIM, DIM_OFF, ITALIC, ITALIC_OFF, UNDERLINE, UNDERLINE_OFF, STRIKETHROUGH, STRIKE_OFF, FG_CYAN, FG_YELLOW, FG_GREEN, FG_BLUE, FG_MAGENTA, FG_GRAY, FG_DEFAULT, BG_GRAY, BG_DEFAULT;
|
|
62649
62656
|
var init_markdown = __esm({
|
|
62650
62657
|
"src/ui/components/markdown.tsx"() {
|
|
@@ -65026,7 +65033,7 @@ var require_fill_range = __commonJS({
|
|
|
65026
65033
|
}
|
|
65027
65034
|
return options2.stringify === true;
|
|
65028
65035
|
};
|
|
65029
|
-
var
|
|
65036
|
+
var pad = (input, maxLength, toNumber) => {
|
|
65030
65037
|
if (maxLength > 0) {
|
|
65031
65038
|
let dash = input[0] === "-" ? "-" : "";
|
|
65032
65039
|
if (dash) input = input.slice(1);
|
|
@@ -65128,7 +65135,7 @@ var require_fill_range = __commonJS({
|
|
|
65128
65135
|
if (options2.toRegex === true && step > 1) {
|
|
65129
65136
|
push(a);
|
|
65130
65137
|
} else {
|
|
65131
|
-
range.push(
|
|
65138
|
+
range.push(pad(format(a, index), maxLen, toNumber));
|
|
65132
65139
|
}
|
|
65133
65140
|
a = descending ? a - step : a + step;
|
|
65134
65141
|
index++;
|
|
@@ -90236,24 +90243,36 @@ function createToolHandlers(mcpHandlers) {
|
|
|
90236
90243
|
}
|
|
90237
90244
|
return builtinHandlers;
|
|
90238
90245
|
}
|
|
90246
|
+
function shortPath(p) {
|
|
90247
|
+
if (!p) return "";
|
|
90248
|
+
const cwd2 = process.cwd();
|
|
90249
|
+
if (p.startsWith(cwd2 + "/")) return p.slice(cwd2.length + 1);
|
|
90250
|
+
if (p.startsWith(cwd2)) return p.slice(cwd2.length) || ".";
|
|
90251
|
+
const segs = p.split("/").filter(Boolean);
|
|
90252
|
+
return segs.length > 2 ? `\u2026/${segs.slice(-2).join("/")}` : p;
|
|
90253
|
+
}
|
|
90239
90254
|
function toolSummary(name, input) {
|
|
90240
90255
|
switch (name) {
|
|
90241
|
-
case "Bash":
|
|
90242
|
-
|
|
90256
|
+
case "Bash": {
|
|
90257
|
+
let cmd = String(input.command ?? "");
|
|
90258
|
+
const cwd2 = process.cwd();
|
|
90259
|
+
if (cwd2 && cmd.includes(cwd2)) cmd = cmd.replaceAll(cwd2, ".");
|
|
90260
|
+
return cmd.slice(0, 60);
|
|
90261
|
+
}
|
|
90243
90262
|
case "Read":
|
|
90244
|
-
return String(input.file_path ?? "");
|
|
90263
|
+
return shortPath(String(input.file_path ?? ""));
|
|
90245
90264
|
case "Edit":
|
|
90246
|
-
return String(input.file_path ?? "");
|
|
90265
|
+
return shortPath(String(input.file_path ?? ""));
|
|
90247
90266
|
case "Write":
|
|
90248
|
-
return String(input.file_path ?? "");
|
|
90267
|
+
return shortPath(String(input.file_path ?? ""));
|
|
90249
90268
|
case "Glob":
|
|
90250
90269
|
return String(input.pattern ?? "");
|
|
90251
90270
|
case "Grep":
|
|
90252
90271
|
return String(input.pattern ?? "");
|
|
90253
90272
|
case "Agent":
|
|
90254
|
-
return String(input.description ?? input.prompt ?? "").slice(0,
|
|
90273
|
+
return String(input.description ?? input.prompt ?? "").slice(0, 50);
|
|
90255
90274
|
case "TaskCreate":
|
|
90256
|
-
return String(input.subject ?? "").slice(0,
|
|
90275
|
+
return String(input.subject ?? "").slice(0, 50);
|
|
90257
90276
|
case "TaskGet":
|
|
90258
90277
|
return `#${input.taskId ?? ""}`;
|
|
90259
90278
|
case "TaskList":
|
|
@@ -90263,17 +90282,17 @@ function toolSummary(name, input) {
|
|
|
90263
90282
|
case "AskUserQuestion":
|
|
90264
90283
|
return `${input.questions?.length ?? 0} question(s)`;
|
|
90265
90284
|
case "WebSearch":
|
|
90266
|
-
return String(input.query ?? "").slice(0,
|
|
90285
|
+
return String(input.query ?? "").slice(0, 50);
|
|
90267
90286
|
case "WebFetch":
|
|
90268
|
-
return String(input.url ?? "").slice(0,
|
|
90287
|
+
return String(input.url ?? "").slice(0, 50);
|
|
90269
90288
|
case "LSP":
|
|
90270
|
-
return `${input.operation ?? ""} ${input.filePath ?? ""}`.trim();
|
|
90289
|
+
return `${input.operation ?? ""} ${shortPath(String(input.filePath ?? ""))}`.trim();
|
|
90271
90290
|
case "EnterPlanMode":
|
|
90272
90291
|
return "";
|
|
90273
90292
|
case "ExitPlanMode":
|
|
90274
90293
|
return "";
|
|
90275
90294
|
case "ToolSearch":
|
|
90276
|
-
return String(input.query ?? "").slice(0,
|
|
90295
|
+
return String(input.query ?? "").slice(0, 50);
|
|
90277
90296
|
case "CronCreate":
|
|
90278
90297
|
return String(input.cron ?? "");
|
|
90279
90298
|
case "CronDelete":
|
|
@@ -90285,7 +90304,7 @@ function toolSummary(name, input) {
|
|
|
90285
90304
|
case "ExitWorktree":
|
|
90286
90305
|
return String(input.action ?? "");
|
|
90287
90306
|
case "NotebookEdit":
|
|
90288
|
-
return String(input.notebook_path ?? "");
|
|
90307
|
+
return shortPath(String(input.notebook_path ?? ""));
|
|
90289
90308
|
case "Config":
|
|
90290
90309
|
return String(input.setting ?? "");
|
|
90291
90310
|
case "SendMessage":
|
|
@@ -90300,40 +90319,30 @@ function SpinnerDot() {
|
|
|
90300
90319
|
}
|
|
90301
90320
|
function ToolItem({ tool }) {
|
|
90302
90321
|
const f = useSpinner(tool.status === "running");
|
|
90303
|
-
const icon = tool.status === "running" ?
|
|
90304
|
-
const color = tool.status === "running" ? "
|
|
90305
|
-
const toolArgs = tool.summary ? `
|
|
90306
|
-
const
|
|
90307
|
-
|
|
90322
|
+
const icon = tool.status === "running" ? f : "\u25CF";
|
|
90323
|
+
const color = tool.status === "running" ? "cyan" : tool.status === "error" ? "red" : "cyan";
|
|
90324
|
+
const toolArgs = tool.summary ? ` ${tool.summary.slice(0, 50)}` : "";
|
|
90325
|
+
const dur = tool.durationMs != null ? ` (${(tool.durationMs / 1e3).toFixed(1)}s)` : "";
|
|
90326
|
+
const resultLine = tool.result && tool.status === "done" ? formatToolResult(tool.name, tool.result)[0] ?? "" : "";
|
|
90327
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box_default, { flexDirection: "column", marginTop: 0, children: [
|
|
90308
90328
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box_default, { children: [
|
|
90309
90329
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { color, children: [
|
|
90310
|
-
|
|
90330
|
+
icon,
|
|
90311
90331
|
" "
|
|
90312
90332
|
] }),
|
|
90313
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { bold: true, children: tool.name }),
|
|
90314
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
90315
|
-
|
|
90316
|
-
|
|
90317
|
-
(tool.durationMs / 1e3).toFixed(1),
|
|
90318
|
-
"s)"
|
|
90333
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { bold: true, color, children: tool.name }),
|
|
90334
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { dimColor: true, children: [
|
|
90335
|
+
toolArgs,
|
|
90336
|
+
dur
|
|
90319
90337
|
] })
|
|
90320
90338
|
] }),
|
|
90321
|
-
|
|
90322
|
-
|
|
90323
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { dimColor: true, children: [
|
|
90324
|
-
" ",
|
|
90325
|
-
CONN,
|
|
90326
|
-
" "
|
|
90327
|
-
] }),
|
|
90328
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: line.slice(0, 100) })
|
|
90329
|
-
] }, i)),
|
|
90330
|
-
resultPreview.length > 2 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box_default, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { dimColor: true, children: [
|
|
90339
|
+
resultLine && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box_default, { children: [
|
|
90340
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { dimColor: true, children: [
|
|
90331
90341
|
" ",
|
|
90332
90342
|
CONN,
|
|
90333
|
-
"
|
|
90334
|
-
|
|
90335
|
-
|
|
90336
|
-
] }) })
|
|
90343
|
+
" "
|
|
90344
|
+
] }),
|
|
90345
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { dimColor: true, children: resultLine.slice(0, 90) })
|
|
90337
90346
|
] }),
|
|
90338
90347
|
tool.error && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box_default, { children: [
|
|
90339
90348
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { dimColor: true, children: [
|
|
@@ -90341,7 +90350,7 @@ function ToolItem({ tool }) {
|
|
|
90341
90350
|
CONN,
|
|
90342
90351
|
" "
|
|
90343
90352
|
] }),
|
|
90344
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: "red", children: tool.error.slice(0,
|
|
90353
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: "red", children: tool.error.slice(0, 90) })
|
|
90345
90354
|
] })
|
|
90346
90355
|
] });
|
|
90347
90356
|
}
|
|
@@ -90352,24 +90361,21 @@ function formatToolResult(toolName, result) {
|
|
|
90352
90361
|
case "Bash": {
|
|
90353
90362
|
if (result.includes("Exit code:")) return [result.split("\n").find((l) => l.includes("Exit code:")) ?? "Done"];
|
|
90354
90363
|
const firstLine = result.split("\n").find((l) => l.trim()) ?? "Done";
|
|
90355
|
-
|
|
90356
|
-
return [firstLine.slice(0, 100)];
|
|
90364
|
+
return totalLines > 1 ? [`${shortPath(firstLine).slice(0, 70)}\u2026 +${totalLines - 1} lines`] : [shortPath(firstLine).slice(0, 80)];
|
|
90357
90365
|
}
|
|
90358
90366
|
case "Read":
|
|
90359
90367
|
return [`Read ${totalLines} lines`];
|
|
90360
90368
|
case "Edit":
|
|
90361
|
-
|
|
90362
|
-
if (result.includes("replacement")) return [result.split("\n")[0].slice(0, 100)];
|
|
90363
|
-
return [`Edited (${totalLines} lines changed)`];
|
|
90369
|
+
return [result.includes("Successfully") ? shortPath(result.split("\n")[0]).slice(0, 80) : `Edited (${totalLines} lines changed)`];
|
|
90364
90370
|
case "Write":
|
|
90365
|
-
return [result.split("\n")
|
|
90371
|
+
return [shortPath(result.split("\n").filter((l) => l.trim()).join(" ")).slice(0, 80)];
|
|
90366
90372
|
case "Glob":
|
|
90367
90373
|
return [`Found ${result.split("\n").filter((l) => l.trim()).length} files`];
|
|
90368
90374
|
case "Grep":
|
|
90369
90375
|
if (result.includes("No matches")) return ["No matches found"];
|
|
90370
90376
|
return [`${result.split("\n").filter((l) => l.trim()).length} matches`];
|
|
90371
90377
|
default:
|
|
90372
|
-
return [result.split("\n")[0]
|
|
90378
|
+
return [shortPath(result.split("\n")[0] ?? "Done").slice(0, 70)];
|
|
90373
90379
|
}
|
|
90374
90380
|
}
|
|
90375
90381
|
function ThinkingBlock({ text }) {
|
|
@@ -90901,11 +90907,12 @@ function App2({ model, mode, dangerouslySkipPermissions, initialPrompt, resumedS
|
|
|
90901
90907
|
else if (!key.ctrl && !key.meta && ch) setInput((p) => p + ch);
|
|
90902
90908
|
});
|
|
90903
90909
|
const cols = stdout?.columns ?? 80;
|
|
90904
|
-
const
|
|
90910
|
+
const pad = 2;
|
|
90911
|
+
const sep = "\u2500".repeat(Math.min(cols - pad, 120));
|
|
90905
90912
|
const hasRunningTools = activeTools.some((t) => t.status === "running");
|
|
90906
90913
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
90907
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Static, { items: msgs, children: (msg) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box_default, { flexDirection: "column", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MessageView, { msg }) }, msg.id) }),
|
|
90908
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box_default, { flexDirection: "column", children: [
|
|
90914
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Static, { items: msgs, children: (msg) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box_default, { flexDirection: "column", paddingLeft: 1, paddingRight: 1, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MessageView, { msg }) }, msg.id) }),
|
|
90915
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box_default, { flexDirection: "column", paddingLeft: 1, paddingRight: 1, children: [
|
|
90909
90916
|
busy && activeTools.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box_default, { flexDirection: "column", children: activeTools.map((t) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToolItem, { tool: t }, t.id)) }),
|
|
90910
90917
|
busy && thinkingText && !streaming && activeTools.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box_default, { flexDirection: "column", children: [
|
|
90911
90918
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box_default, { children: [
|
|
@@ -90919,10 +90926,7 @@ function App2({ model, mode, dangerouslySkipPermissions, initialPrompt, resumedS
|
|
|
90919
90926
|
line.slice(0, 120)
|
|
90920
90927
|
] }) }, i))
|
|
90921
90928
|
] }),
|
|
90922
|
-
busy && streaming && /* @__PURE__ */ (0, import_jsx_runtime.
|
|
90923
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: "green", children: "\u25CF " }),
|
|
90924
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: streaming.split("\n").filter((l) => l.trim()).slice(-3).join("\n").slice(-200) })
|
|
90925
|
-
] }),
|
|
90929
|
+
busy && streaming && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box_default, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: streaming.split("\n").filter((l) => l.trim()).slice(-3).join("\n").slice(-200) }) }),
|
|
90926
90930
|
busy && !streaming && !thinkingText && activeTools.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box_default, { children: [
|
|
90927
90931
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SpinnerDot, {}),
|
|
90928
90932
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { dimColor: true, children: " Thinking..." })
|
|
@@ -93429,7 +93433,7 @@ var VERSION, BUILD_TIME, PACKAGE_NAME, ISSUES_URL, startupTimestamps, originalCw
|
|
|
93429
93433
|
var init_index = __esm({
|
|
93430
93434
|
"src/cli/index.ts"() {
|
|
93431
93435
|
VERSION = "0.1.2";
|
|
93432
|
-
BUILD_TIME = "2026-03-20T18:
|
|
93436
|
+
BUILD_TIME = "2026-03-20T18:42:45.981Z";
|
|
93433
93437
|
PACKAGE_NAME = "@hasna/coders";
|
|
93434
93438
|
ISSUES_URL = "https://github.com/hasnaxyz/open-coders/issues";
|
|
93435
93439
|
startupTimestamps = {};
|