← Catalog

pi-monofold

Pi extension that folds multiple repositories and folders into a guarded virtual monorepo for AI agents.

Extension

Install

Install with PiG

pig install npm:pi-monofold

Install with Pi

pi install npm:pi-monofold
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": [
    "./index.ts"
  ]
}

README

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

pi-monofold

Join dotfield.xyz on Discord

CI Publish npm version npm downloads License: MIT Pi Package Trusted Publishing Buy Me A Coffee

Pi extension that folds multiple local repositories and folders into a guarded Virtual Monorepo for AI agents.

What this is

Pi Monofold (pi-monofold) keeps repositories physically separate while giving Pi a lightweight manifest, routed writes, workspace-aware reads, guarded commands, and explicit git flows. Documentation, rules, product context, and implementation code can appear as one connected system without migrating everything into a single git repository.

See docs/usage.md for configuration, commands, agent tools, and guard behavior.

Features

  • Virtual monorepo manifest — declare workspaces and project workspaces in .pi/monofold.yaml
  • Multi-runtime path overlays — keep one logical workspace definition while swapping absolute repo roots per runtime
  • Routed Markdown writes — route PRDs, progress notes, and other doc types to configured folders
  • Workspace-aware reads — list, read, search, and tree views scoped to readable workspaces, with bounded previews by default
  • Capability guard — block or confirm read / write / edit / grep / find / bash based on workspace tags
  • Focus presets — tag-based focus targets for the control workspace
  • Natural-language commands — /monofold:explore, /monofold:write, /monofold:config, /monofold:git, and more
  • Strict agent tools — monofold_* tools for programmatic access behind the command surface
  • Config migration — upgrade legacy .pi/monofold.yml with backups and validation

Install

Pi Monofold is a Pi package. Install it with Pi's package installer from git or npm.

Security: Pi packages run with full system access. Review packages before installing third-party code.

From git

pi install git:github.com/eiei114/pi-monofold

Project-local install:

pi install -l git:github.com/eiei114/pi-monofold

Pin a version:

pi install git:github.com/eiei114/pi-monofold@v0.12.16

Try without installing:

pi -e git:github.com/eiei114/pi-monofold

From npm

pi install npm:pi-monofold

Project-local install:

pi install -l npm:pi-monofold

Pin a version:

pi install npm:pi-monofold@0.12.16

Try without installing:

pi -e npm:pi-monofold

Quick start

  1. Install the extension (see Install).
  2. In your control repository, create .pi/monofold.yaml with at least one workspace entry (or run /monofold:init).
  3. Start Pi in the control repository and run /monofold:explore show the project workspaces.
  4. Use /monofold:focus, ctrl+shift+m, or shift+ctrl+f to switch focus presets when focusPresets are configured. Active Focus is restored automatically on the next Pi session in the same control repository.
  5. Use /monofold:write for routed Markdown outputs and /monofold:git for guarded git workflows.

Example command flows: docs/examples.md.

Usage summary

SurfacePurpose
/monofold:exploreList, read, search, or inspect workspace trees
/monofold:writeCreate routed Markdown outputs
/monofold:configAdd or change workspaces and project workspaces
/monofold:gitRun guarded git status, commit, push, or commit+push
/monofold:focusSelect the active focus preset from a TUI list
/monofold:focus-prevCycle Active Focus backward through focusPresets YAML order
/monofold:guideInteractive guide for common flows
/monofold:initCreate or update .pi/monofold.yaml
/monofold:updateMigrate legacy config and optionally request config edits

Default focus shortcuts: ctrl+shift+m cycles Active Focus forward and shift+ctrl+f cycles backward through focusPresets YAML order. Both wrap at the start/end of the list.

When Active Focus is set, Pi Monofold injects the active preset's contextFiles into each agent turn under Focus Context Injection and recomposes the manifest so active Workspace Targets are shown first while non-active targets are collapsed to one-line summaries. Tag-based target inference in monofold_read, monofold_write, and monofold_git also prefers Workspace Targets that belong to the active preset when a tag query would otherwise match multiple candidates; explicit targetId / workspace name selectors and uniquely matching targets are unchanged. If multiple in-focus targets still tie, the existing workspace selection flow applies. The MVP uses provisional context-injection caps that are intentionally temporary and exposed as constants for future tuning:

  • Max 6 context files per active preset.
  • Max 6,000 characters per file, with … [truncated] appended when a file is cut.
  • Max 12,000 injected file-content characters per turn; remaining files are skipped and a warning is surfaced once for that turn.

Agent tools (monofold_list, monofold_read, monofold_write, monofold_git, monofold_init) sit behind these commands. Use monofold_list as the first-line Active Focus health check (preset, route override, unresolved targets, and warnings). Full reference: docs/usage.md.

Safe read defaults

monofold_read can reach files across multiple configured workspaces. Returning full file bodies or unbounded search/tree output by default would flood the agent chat and can bias later turns. Pi Monofold therefore uses preview-first, capped-by-default reads.

monofold_read modeDefault output
filePath, size, line/character counts, modified time, then a bounded preview (first 20 lines, up to 2,000 characters). Files that already fit those bounds are shown in full without a truncation marker.
searchUp to 50 match lines and 8,000 characters of ripgrep output.
treeUp to 200 entries; traversal depth is capped at 5.

When output is cut, the tool response includes a [truncated] marker (file mode) or a [truncated: …] footer (search/tree) that states what was shown and how to request more.

Request more content intentionally:

Goalmonofold_read parameters
Full file bodymode: "file", includeContent: true
Larger bounded file slicehead, tail, and/or maxChars (positive integers)
More search resultsHigher maxMatches and/or maxChars, or a narrower path / query
Larger directory treeHigher maxEntries, lower depth, or a narrower path

Agents should call monofold_read (not guess at raw Pi read). Humans should use /monofold:explore with natural language. Legacy slash commands such as /monofold:read apply the same caps for compatibility but are not the preferred human-facing surface—see docs/usage.md.

Package contents

pi-monofold/
├── .github/workflows/
│   ├── auto-release.yml            # Manually authorized tag + release
│   ├── ci.yml                      # Validate on PR / push
│   └── publish.yml                 # Publish to npm (Trusted Publishing)
├── docs/
│   ├── usage.md                    # Config, commands, agent API, guard
│   ├── examples.md                 # Command examples
│   └── release.md                  # Release and publish flow
├── scripts/
│   ├── check-version-bump.mjs      # PR version bump guard (CI)
│   ├── pi-sdk-smoke.mjs            # Actual pinned Pi RPC lifecycle smoke
│   ├── pi-sdk-smoke-contract.mjs   # Behavior-v2 smoke assertions
│   └── release-trigger-contract.mjs # Release/publish trigger guard
├── tests/
│   ├── file-read-preview.test.ts
│   ├── focus-command.test.ts
│   ├── focus-context-injection.test.ts
│   ├── focus-decision-note-integration.test.ts
│   ├── focus-decision-note.test.ts
│   ├── focus-inference-bias.test.ts
│   ├── focus-preset.test.ts
│   ├── focus-route-override-integration.test.ts
│   ├── focus-route-override.test.ts
│   ├── focus-session-restore.test.ts
│   ├── focus-session-state.test.ts
│   ├── focus-skills-auto-load.test.ts
│   ├── focus-skills.test.ts
│   ├── changelog-hygiene.test.ts
│   ├── contributing-docs.test.ts
│   ├── github-actions-pin.test.ts
│   ├── monofold-read-caps.test.ts
│   ├── monofold-read-ops.test.ts
│   ├── path-normalize.test.ts
│   ├── pi-sdk-smoke-contract.test.ts
│   ├── readme-package-contents.test.ts
│   ├── release-docs.test.ts
│   ├── release-trigger-contract.test.ts
│   ├── readme-version-pin.test.ts
│   ├── runtime-path-overlays.test.ts
│   ├── tsconfig-publishable-files.test.ts
│   ├── unknown-path-allows.test.ts
│   └── workspace-path-lookup.test.ts
├── CHANGELOG.md
├── SECURITY.md
├── file-read-preview.ts
├── focus-decision-note.ts
├── focus-preset.ts
├── focus-route-override.ts
├── focus-session-state.ts
├── focus-skills.ts
├── index.ts
├── LICENSE
├── monofold-read-ops.ts
├── package.json
├── path-normalize.ts
├── read-caps.ts
├── README.md
├── unknown-path-allows.ts
├── validation.ts
├── workspace-path-lookup.ts
└── tsconfig.json

Development

Clone and validate:

git clone https://github.com/eiei114/pi-monofold.git
cd pi-monofold
npm install
npm run check

Try the local checkout without installing:

pi -e .

Release

Releases require an explicit workflow dispatch from main; merging a maintenance PR runs CI only. See docs/release.md for details.

  1. Bump version in package.json and update CHANGELOG.md.
  2. Merge the PR to main; this does not create a tag, release, or publish.
  3. After separate release authorization, dispatch Release (manual) from main.
  4. The workflow creates the version tag and GitHub release; Publish then publishes to npm with OIDC provenance.

Security

Pi Monofold intercepts standard Pi tool calls when monofold config is present. Writes and shell commands are allowed only when the resolved workspace grants the matching capability. Git commit/push via raw bash is blocked; use /monofold:git or monofold_git instead.

Report vulnerabilities per SECURITY.md.

License

MIT