# pi-workspace-context

Pi extension that lets you add extra local directories as part of the current workspace context.

Useful when a task spans multiple repositories, for example a frontend repo plus a backend repo.

## Install

```bash
pi install npm:pi-workspace-context
```

Try without installing permanently:

```bash
pi -e npm:pi-workspace-context
```

## Local development

```bash
pi -e .
```

## Commands

- `/ctx-add <path> [alias]` — add an extra directory to the current session context.
- `/ctx-list` — list extra directories currently in context.
- `/ctx-remove <alias|path>` — remove one extra directory.
- `/ctx-clear` — remove all extra directories.
- `/ctx-persist [on|off|status]` — persist the extra directories for future pi sessions started in the same workspace.

## Alias usage

After adding a directory, pi will show an alias such as `@backend`.

The extension expands aliases in tool calls:

- `@backend/src/file.ts`
- `$backend/src/file.ts`
- `backend:src/file.ts`

For bash commands, simple `@alias/path` and `$alias/path` tokens are expanded to the absolute path.

## Context behavior

The extension injects the added roots into pi's system prompt and asks the model to treat them as part of the workspace.

If an added root contains `AGENTS.md` or `CLAUDE.md`, the model is instructed to read it before editing that root.

Skill directories under added roots are discovered on reload from:

- `.pi/skills`
- `.agents/skills`

## Security

This extension runs locally inside pi and can influence tool paths/commands by expanding aliases. Review the source before installing, as with any pi package.
