@amaster.ai/pi-attachments

Pi extension for attachment processing — classifies, parses, and renders file attachments into LLM-visible prompt context

Packages

Package details

extension

Install @amaster.ai/pi-attachments from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@amaster.ai/pi-attachments
Package
@amaster.ai/pi-attachments
Version
0.1.1
Published
Jun 9, 2026
Downloads
4,236/mo · 1,503/wk
Author
qianchuan
License
Apache-2.0
Types
extension
Size
1.8 MB
Dependencies
1 dependency · 1 peer
Pi manifest JSON
{
  "image": "https://raw.githubusercontent.com/TGYD-helige/pi/master/packages/pi-attachments/preview.png",
  "extensions": [
    "./dist/index.js"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

@amaster.ai/pi-attachments

pi-attachments preview

Pi extension that intercepts user input, resolves @-references to local resources, and injects their content into the prompt before the model sees it.

Hooks the input event of @earendil-works/pi-coding-agent. When a recognized mention appears in the user message, the original mention is stripped and replaced with structured context (skill block, attachment listing, or <system-reminder>). Image attachments are passed through as multimodal ImageContent.

Recognized mentions

Syntax Resolves to
@path/to/file.ts File contents (text/doc) or base64 image
@"/path with spaces/file.pdf" Same as above, supports whitespace in paths
@path/to/file.ts#L10-20 Line range syntax preserved in the reference (range applied downstream)
@path/to/dir Directory listing (files + subdirs, ignores .git/node_modules/build outputs)
@skill:<name> Loads SKILL.md for a registered skill

@http(s)://... is not treated as a file reference. Unknown namespaces (e.g. @app:erp-prod) are left alone — neither resolved as a skill nor as a file.

Skill resolution

@skill:<name> searches in this order, first hit wins:

  1. <cwd>/.pi/skills/<name>/SKILL.md — project-level skill
  2. <agentDir>/skills/<name>/SKILL.md — user-level skill (resolved via @amaster.ai/pi-shared's resolveAgentDir(), override with PI_AGENT_HOME)

The order matches loadSkillsFromAllLocations in the pi-coding-agent SDK so a project skill overrides a user-installed one. Frontmatter is stripped; the body is wrapped in <skill name="..." location="...">…</skill> and prepended to the user message.

Output assembly

When at least one mention resolves, the input is rewritten as three optional segments in this order:

<skill name="..." location="...">…</skill>   ← skill blocks (if any)

<original user text with mentions stripped>

<system-reminder>
## file.ts: /abs/path/file.ts
```text
…contents…

Pure-text inputs with no resolvable mentions are left untouched (handler returns undefined).

Configuration

Env var Default Meaning
PI_ATTACHMENT_MAX_TEXT_CHARS 128000 Max chars per text/doc attachment before truncation
PI_AGENT_HOME (from pi-shared) Override for user-level skill search root

Limits

  • Directory listing: capped at 200 entries per directory; remainder is summarized as [Listing truncated: showing 200 of N entries].
  • Ignored directory entries: .git, node_modules, .DS_Store, .next, .turbo, dist, build, .cache.
  • Mention ordering: skills are matched before files, so the resolved mentions[] array groups by kind rather than preserving textual order. Downstream consumers must not rely on textual order.