@heyhuynhgiabuu/pi-pretty 0.6.1 → 0.6.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/package.json +1 -1
- package/src/render.ts +0 -1
- package/src/tools/bash.ts +1 -1
- package/src/tools/read.ts +9 -7
- package/test/bash-rendering.test.ts +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heyhuynhgiabuu/pi-pretty",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "Pretty terminal output for pi — syntax-highlighted file reads, colored bash output, tree-view directory listings, and more.",
|
|
5
5
|
"author": "huynhgiabuu",
|
|
6
6
|
"license": "MIT",
|
package/src/render.ts
CHANGED
|
@@ -212,7 +212,6 @@ export async function renderFileContent(
|
|
|
212
212
|
out.push(`${lnum(ln, nw)} ${FG_RULE}│${RST} ${display}${RST}`);
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
-
out.push(rule(tw));
|
|
216
215
|
if (total > maxLines) {
|
|
217
216
|
out.push(`${FG_DIM} … ${total - maxLines} more lines (${total} total)${RST}`);
|
|
218
217
|
}
|
package/src/tools/bash.ts
CHANGED
|
@@ -80,7 +80,7 @@ export function registerBashTool(
|
|
|
80
80
|
if (!output.trim()) return fillToolBackground(header, bg, w);
|
|
81
81
|
const max = ctx.expanded ? lineCount : MAX_PREVIEW_LINES;
|
|
82
82
|
const show = output.split("\n").slice(0, max);
|
|
83
|
-
const out = [header, rule(w), ...show.map((l: string) => ` ${l}`)
|
|
83
|
+
const out = [header, rule(w), ...show.map((l: string) => ` ${l}`)];
|
|
84
84
|
if (lineCount > max) out.push(`${FG_DIM} \u2026 ${lineCount - max} more lines${RST}`);
|
|
85
85
|
return fillToolBackground(out.join("\n"), bg, w);
|
|
86
86
|
};
|
package/src/tools/read.ts
CHANGED
|
@@ -57,9 +57,7 @@ export function registerReadTool(
|
|
|
57
57
|
resolveBaseBackground(theme);
|
|
58
58
|
|
|
59
59
|
const text = ctx.lastComponent ?? new TC("", 0, 0);
|
|
60
|
-
|
|
61
|
-
const off = typeof args.offset === "number" ? `:${args.offset}` : "";
|
|
62
|
-
text.setText(fillToolBackground(`\n ${theme.fg("toolTitle", theme.bold("read"))} ${theme.fg("accent", p)}${theme.fg("dim", off)}`, ctx.isError ? BG_ERROR : undefined));
|
|
60
|
+
text.setText("");
|
|
63
61
|
return text;
|
|
64
62
|
},
|
|
65
63
|
|
|
@@ -103,7 +101,10 @@ export function registerReadTool(
|
|
|
103
101
|
const gw = nw + 3;
|
|
104
102
|
const cw = Math.max(1, tw - gw);
|
|
105
103
|
|
|
106
|
-
const
|
|
104
|
+
const p2 = shortPath(cwd, home, String(d.filePath ?? ""));
|
|
105
|
+
const off2 = typeof d.offset === "number" ? `:${d.offset}` : "";
|
|
106
|
+
const header = `${theme.fg("toolTitle", theme.bold("read"))} ${theme.fg("accent", p2)}${theme.fg("dim", off2)}`;
|
|
107
|
+
const out: string[] = ["", ` ${header}`];
|
|
107
108
|
out.push(` ${FG_RULE}${"─".repeat(tw - 2)}${RST}`);
|
|
108
109
|
for (let i = 0; i < show.length; i++) {
|
|
109
110
|
const ln = (d.offset || 0) + i + 1;
|
|
@@ -112,10 +113,10 @@ export function registerReadTool(
|
|
|
112
113
|
const lineNo = String(ln);
|
|
113
114
|
out.push(` ${FG_LNUM}${" ".repeat(Math.max(0, nw - lineNo.length))}${lineNo}${RST} ${FG_RULE}│${RST} ${display}${RST}`);
|
|
114
115
|
}
|
|
115
|
-
out.push(` ${FG_RULE}${"─".repeat(tw - 2)}${RST}`);
|
|
116
116
|
if (total > maxShow) {
|
|
117
117
|
out.push(` ${FG_DIM} … ${total - maxShow} more lines (${total} total)${RST}`);
|
|
118
118
|
}
|
|
119
|
+
out.push("");
|
|
119
120
|
const rendered = out.join("\n");
|
|
120
121
|
text.setText(fillToolBackground(rendered));
|
|
121
122
|
(ctx as any).state._rt = rendered;
|
|
@@ -123,8 +124,9 @@ export function registerReadTool(
|
|
|
123
124
|
// Async syntax highlighting via Shiki
|
|
124
125
|
renderFileContent(d.content, d.filePath, d.offset || 0, maxShow, tw).then(hl => {
|
|
125
126
|
const padded = hl.split("\n").map(l => ` ${l}`).join("\n");
|
|
126
|
-
|
|
127
|
-
(
|
|
127
|
+
const rendered = `\n ${header}\n${padded}\n`;
|
|
128
|
+
text.setText(fillToolBackground(rendered));
|
|
129
|
+
(ctx as any).state._rt = rendered;
|
|
128
130
|
}).catch(() => {});
|
|
129
131
|
|
|
130
132
|
return text;
|