pi-references is a Pi extension that implements OpenCode-style references in Pi.
It lets you configure external directories and Git repositories by alias, then use them in the Pi prompt with the same style as OpenCode:
@docs
@sdk/src/client.ts
The goal is to bring the behavior described in OpenCode's references documentation to Pi: named project references, autocomplete, local directory support, Git repository materialization, descriptions for agent context, and hidden references.
- OpenCode-style syntax:
@alias@alias/path/to/file
- Local directory references
- Git repository references
- Global and project-level configuration
- JSON and JSONC config files
descriptionsupport: described references are injected into the agent contexthiddensupport: hidden references do not appear in autocomplete but can still be used manually- Autocomplete for reference aliases
- File browsing autocomplete inside reference directories
- Input expansion to resolved filesystem paths
- Git repository cache under
~/.pi/agent/cache/references/
Install directly from this repository with Pi:
pi install git:github.com/Alurith/pi-referencesOr project-local:
pi install -l git:github.com/Alurith/pi-referencesYou can also use the HTTPS URL form:
pi install https://github.com/Alurith/pi-referencesThen restart Pi, or run /reload if the extension is already discoverable in the current session.
If published to npm as pi-references:
pi install npm:pi-referencesIf published as a scoped package, for example @alurith/pi-references:
pi install npm:@alurith/pi-referencesProject-local:
pi install -l npm:@alurith/pi-referencesFrom a project where you want to test the extension:
pi -e /absolute/path/to/pi-references/index.tsFor example:
pi -e /home/alessandro/Work/tries/pi-references/index.tsGlobal:
pi install /absolute/path/to/pi-referencesProject-local:
pi install -l /absolute/path/to/pi-referencesRunning:
npm install Alurith/pi-referencesor:
npm install @alurith/pi-referencesonly installs the package into a Node project. It does not automatically register the extension with Pi.
To make Pi load the extension, use pi install ..., or load it explicitly with pi -e ....
pi-references reads configuration from both global and project locations. Project-local configuration is loaded only when Pi trusts the current project.
.pi/references.json
.pi/references.jsonc
Relative paths in project config are resolved from the project root.
~/.pi/agent/references.json
~/.pi/agent/references.jsonc
Relative paths in global config are resolved from ~/.pi/agent.
Global references are always loaded. Project references are loaded only for trusted projects.
If the same alias exists in both places, the project reference overrides the global one.
{
"references": {
"sdk": {
"repository": "OWNER/sdk-repo",
"branch": "main",
"description": "Use for SDK implementation details"
}
}
}repository accepts:
- GitHub shorthand:
owner/repo - HTTPS Git URL
- SSH Git URL
- local Git repository path
Git repositories are cloned into:
~/.pi/agent/cache/references/
Existing cached checkouts are reused. Git repositories are cloned lazily the first time you browse or use that reference. The extension does not perform aggressive automatic updates.
Like OpenCode, string shorthand is supported:
{
"references": {
"docs": "../docs",
"sdk": "OWNER/sdk-repo"
}
}String values that point to an existing local path are treated as path. Otherwise, values that look like Git references are treated as repository; other strings are treated as local path.
Hidden references
{
"references": {
"internal": {
"path": "../internal-docs",
"description": "Use for internal implementation details",
"hidden": true
}
}
}A hidden reference:
- does not appear in autocomplete
- can still be used manually as
@internalor@internal/file.md - is still added to agent context if it has a
description
Type @ in the Pi prompt to see configured references.
Examples:
Compare the current implementation with @sdk/src/client.ts
Use @docs to check the product behavior before changing this flow
When a reference is used, the extension expands it with its resolved filesystem path before the model receives the prompt. Git references are cloned at this point if needed:
@sdk/src/client.ts [resolved: /home/user/.pi/agent/cache/references/sdk-abc123/src/client.ts]
This keeps the user-facing syntax close to OpenCode while still giving Pi's tools a real path to inspect.
References with a description are added to the system prompt, for example:
Available references:
- docs -> /home/user/product-docs
Use for product behavior and documentation conventions
- sdk -> /home/user/.pi/agent/cache/references/sdk-abc123
Use for SDK implementation details
References without description remain usable through @alias, but are not advertised to the agent automatically.
Reference aliases:
- cannot be empty
- cannot contain
/ - cannot contain whitespace
- cannot contain backticks
- cannot contain commas
Implemented:
- local references
- Git references
- global + project config
- project config loaded only when Pi trusts the project
- JSON + JSONC comments/trailing commas
descriptionhidden- additive alias autocomplete that keeps Pi's native
@file completion - file autocomplete inside references with path escape protection
- lazy Git clone on first browse/use
- atomic Git clone into cache
- input expansion to
[resolved: /real/path] - shared tokenizer for autocomplete and input expansion
Not implemented yet:
- explicit manual sync command
- aggressive automatic Git updates
- persistent file index/cache
- recursive parent-directory config discovery
- symlink boundary hardening
- permission boundary changes
This package is a Pi extension package. The package manifest declares:
{
"pi": {
"extensions": ["./index.ts"]
}
}So Pi can install and load it directly with pi install.
MIT. See LICENSE.
{ "references": { "docs": { "path": "../product-docs", "description": "Use for product behavior and documentation conventions" } } }