@tmustier/pi-files-widget 0.2.1 → 0.2.3

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/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  All notable changes to this extension will be documented in this file.
4
4
 
5
+ ## [0.2.3] - 2026-10-28
6
+
7
+ ### Fixed
8
+ - Render Markdown with `glow` again. The viewer passed `glow` a pipe as standard input, and `glow` renders piped input in preference to its file argument, so it returned nothing and every Markdown file fell back to the raw view. Pressing `m` then appeared to do nothing, because each switch back to the rendered view fell back to raw again. Thanks to @ackalker for the report ([#111](https://github.com/tmustier/pi-extensions/issues/111)).
9
+
10
+ ## [0.2.2] - 2026-10-28
11
+
12
+ ### Fixed
13
+ - Suggest `brew install` only on macOS when `bat`, `delta`, or `glow` is missing, and list only the missing packages. Other systems are pointed to the install instructions in the README, which now cover Debian and Ubuntu, where `bat` installs as `batcat`. Thanks to @curious2improve for the report ([#115](https://github.com/tmustier/pi-extensions/issues/115)).
14
+
5
15
  ## [0.2.1] - 2026-09-22
6
16
 
7
17
  ### Changed
package/README.md CHANGED
@@ -22,10 +22,14 @@ Required deps (needed for /readfiles):
22
22
  # macOS (Homebrew)
23
23
  brew install bat git-delta glow
24
24
 
25
- # Ubuntu/Debian
25
+ # Debian 13+ / Ubuntu 25.04+
26
26
  sudo apt-get install -y bat git-delta glow
27
+ # Debian and Ubuntu install bat as batcat; files-widget looks for bat
28
+ mkdir -p ~/.local/bin && ln -s /usr/bin/batcat ~/.local/bin/bat
27
29
  ```
28
30
 
31
+ On other systems, install [bat](https://github.com/sharkdp/bat#installation), [delta](https://dandavison.github.io/delta/installation.html), and [glow](https://github.com/charmbracelet/glow#installation) with your package manager. The `bat`, `delta`, and `glow` commands must be on your `PATH`.
32
+
29
33
  ```bash
30
34
  pi install git:github.com/tmustier/pi-extensions
31
35
  ```
package/file-viewer.ts CHANGED
@@ -2,8 +2,8 @@ import { visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
2
2
  import { execSync } from "node:child_process";
3
3
  import { readFileSync, statSync } from "node:fs";
4
4
 
5
- import { isGitRepo } from "./git";
6
- import { hasCommand, isMarkdownPath, stripLeadingEmptyLines } from "./utils";
5
+ import { isGitRepo } from "./git.ts";
6
+ import { hasCommand, isMarkdownPath, stripLeadingEmptyLines } from "./utils.ts";
7
7
 
8
8
  const DIFF_CONTENT_PREFIXES = new Set(["+", "-", " "]);
9
9
 
@@ -234,7 +234,12 @@ export function loadFileContent(
234
234
 
235
235
  if (isMarkdown && renderMarkdown && hasCommand("glow")) {
236
236
  try {
237
- const output = execSync(`glow -s dark -w ${termWidth} "${filePath}"`, { encoding: "utf-8", timeout: 10000 });
237
+ // glow renders piped standard input in preference to its file argument.
238
+ const output = execSync(`glow -s dark -w ${termWidth} "${filePath}"`, {
239
+ encoding: "utf-8",
240
+ timeout: 10000,
241
+ stdio: ["ignore", "pipe", "pipe"],
242
+ });
238
243
  if (output.trim()) {
239
244
  return { lines: stripLeadingEmptyLines(output.split("\n")), renderedMarkdown: true };
240
245
  }
package/index.ts CHANGED
@@ -12,7 +12,7 @@ import { isAbsolute, join, resolve } from "node:path";
12
12
 
13
13
  import { POLL_INTERVAL_MS } from "./constants";
14
14
  import { formatCommentMessage } from "./comment";
15
- import { hasCommand } from "./utils";
15
+ import { hasCommand, missingCommandsMessage, REQUIRED_COMMANDS } from "./utils";
16
16
 
17
17
  function resolveInitialPath(arg: string | undefined, cwd: string): { path: string; error?: string } {
18
18
  if (!arg) return { path: cwd };
@@ -38,15 +38,14 @@ function resolveInitialPath(arg: string | undefined, cwd: string): { path: strin
38
38
  export default function editorExtension(pi: ExtensionAPI): void {
39
39
  const cwd = process.cwd();
40
40
  const agentModifiedFiles = new Set<string>();
41
- const requiredDeps = ["bat", "delta", "glow"] as const;
42
- const getMissingDeps = () => requiredDeps.filter((dep) => !hasCommand(dep));
41
+ const getMissingDeps = () => REQUIRED_COMMANDS.filter((dep) => !hasCommand(dep));
43
42
 
44
43
  pi.registerCommand("readfiles", {
45
44
  description: "Open file browser (optional: /readfiles <path> to start outside the current directory)",
46
45
  handler: async (args, ctx) => {
47
46
  const missing = getMissingDeps();
48
47
  if (missing.length > 0) {
49
- ctx.ui.notify(`files-widget requires ${missing.join(", ")}. Install: brew install bat git-delta glow`, "error");
48
+ ctx.ui.notify(missingCommandsMessage(missing), "error");
50
49
  return;
51
50
  }
52
51
 
@@ -119,7 +118,7 @@ export default function editorExtension(pi: ExtensionAPI): void {
119
118
  pi.on("session_start", async (_event, ctx) => {
120
119
  const missing = getMissingDeps();
121
120
  if (missing.length > 0) {
122
- ctx.ui.notify(`files-widget requires ${missing.join(", ")}. Install: brew install bat git-delta glow`, "error");
121
+ ctx.ui.notify(missingCommandsMessage(missing), "error");
123
122
  }
124
123
 
125
124
  agentModifiedFiles.clear();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmustier/pi-files-widget",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "In-terminal file browser and viewer for Pi.",
5
5
  "license": "MIT",
6
6
  "author": "Thomas Mustier",
@@ -19,7 +19,7 @@
19
19
  "@earendil-works/pi-tui": "*"
20
20
  },
21
21
  "scripts": {
22
- "postinstall": "node -e \"console.log('pi-files-widget: required deps: bat, delta, glow. Install with: brew install bat git-delta glow')\""
22
+ "postinstall": "node -e \"console.log('pi-files-widget: required deps: bat, delta, glow. ' + (process.platform === 'darwin' ? 'Install with: brew install bat git-delta glow' : 'Install instructions: https://github.com/tmustier/pi-extensions/tree/main/files-widget#install'))\""
23
23
  },
24
24
  "pi": {
25
25
  "extensions": [
package/utils.ts CHANGED
@@ -38,6 +38,19 @@ export function hasCommand(cmd: string, options: CommandLookupOptions = {}): boo
38
38
  return false;
39
39
  }
40
40
 
41
+ export const REQUIRED_COMMANDS = ["bat", "delta", "glow"] as const;
42
+ export type RequiredCommand = (typeof REQUIRED_COMMANDS)[number];
43
+
44
+ const HOMEBREW_PACKAGES: Record<RequiredCommand, string> = { bat: "bat", delta: "git-delta", glow: "glow" };
45
+ const INSTALL_DOCS_URL = "https://github.com/tmustier/pi-extensions/tree/main/files-widget#install";
46
+
47
+ export function missingCommandsMessage(missing: readonly RequiredCommand[], platform: NodeJS.Platform = process.platform): string {
48
+ const install = platform === "darwin"
49
+ ? `Install: brew install ${missing.map((command) => HOMEBREW_PACKAGES[command]).join(" ")}`
50
+ : `Install with your package manager: ${INSTALL_DOCS_URL}`;
51
+ return `files-widget requires ${missing.join(", ")}. ${install}`;
52
+ }
53
+
41
54
  export function isUntrackedStatus(status?: string): boolean {
42
55
  return status === "?" || status === "??";
43
56
  }