← Catalog

pi-file-links

Make relative file links in Pi's assistant replies clickable by resolving them to absolute file:// URLs.

Extension

Install

Install with PiG

pig install npm:pi-file-links

Install with Pi

pi install npm:pi-file-links
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./extensions/file-links.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 0.1.0 (README.md). PiG does not review it.

Makes local file links in Pi's assistant replies clickable.

Models write file links as relative paths: [report](out/report.txt). Pi passes that path to the terminal unchanged as an OSC 8 hyperlink, and terminals can't open a relative target because they don't know which directory Pi is running in. Clicking does nothing, or macOS shows error -50.

This extension resolves those links against the session's working directory before Pi renders them, so the terminal gets file:///abs/path/out/report.txt.

Install

Requires Pi 0.84.0 or later.

pi install npm:pi-file-links

Or try it for one session:

pi -e npm:pi-file-links

What gets rewritten

Link destinationResult
out/report.txt, ./a.md, ../b.mdResolved against the session cwd
/abs/path.mdfile:///abs/path.md
~/notes.mdResolved against your home directory
src/app.ts:42, :42:7, :42-60Line suffix dropped (file URLs have no line syntax)
docs/a.md#section, page.html?x=1Fragment and query after a file extension dropped
https://…, mailto:…, file://…, any other schemeUnchanged
localhost:5173, 127.0.0.1:8080, www.example.com, me@example.comUnchanged
#anchor, ?query, //host/pathUnchanged
  • Only assistant replies and thinking are rewritten. Your own messages are left alone.
  • Links are found with Pi's Markdown lexer settings, so links inside code, math, and escaped brackets are never touched.
  • Display only: the saved session keeps the original Markdown.
  • If the terminal doesn't support hyperlinks, nothing changes, and Pi keeps printing the short relative path.

Limits

  • file:// URLs point at the machine running the terminal. In SSH or container sessions they point at the wrong filesystem.
  • Windows drive paths (C:\…) are not converted.
  • Links resolve against the cwd at render time, so a resumed session resolves old links against its current cwd.
  • Paths aren't checked for existence. A bare domain like example.com is treated as a file.
  • Pi's math and strikethrough rules are copied from Pi 1.4.0 (src/pi-parser.ts), because Pi doesn't export its parser. test/parity.test.ts renders through Pi's own Markdown component to catch drift after a Pi upgrade.

Development

npm install
npm test
npm run typecheck
pi -e ./extensions/file-links.ts

License

MIT