@astralyn/pi 0.82.2 → 0.82.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/README.md +70 -634
- package/dist/core/extensions/types.d.ts +2 -0
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/model-resolver.d.ts +1 -0
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +13 -3
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +19 -1
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +3 -0
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +6 -0
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts +3 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +10 -2
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +22 -13
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +28 -16
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/docs/bundled/README.md +38 -0
- package/docs/bundled/extensions/README.md +18 -0
- package/docs/{distribution → bundled}/extensions/question.md +0 -11
- package/docs/{distribution → bundled}/extensions/rewind.md +0 -10
- package/docs/{distribution → bundled}/extensions/router.md +1 -14
- package/docs/{distribution → bundled}/extensions/statusline.md +1 -2
- package/docs/{distribution → bundled}/extensions/subagent.md +0 -7
- package/docs/bundled/extensions/todo.md +28 -0
- package/docs/{distribution → bundled}/themes.md +4 -11
- package/docs/{distribution → bundled}/tool-presentation.md +4 -10
- package/docs/compaction.md +12 -12
- package/docs/custom-provider.md +8 -8
- package/docs/docs.json +57 -9
- package/docs/extensions.md +10 -11
- package/docs/index.md +12 -7
- package/docs/json.md +4 -4
- package/docs/providers.md +1 -1
- package/docs/rpc.md +3 -9
- package/docs/session-format.md +5 -5
- package/docs/skills.md +1 -1
- package/docs/themes.md +4 -8
- package/docs/tui.md +1 -1
- package/examples/extensions/README.md +0 -1
- package/examples/extensions/custom-provider-anthropic/index.ts +4 -4
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +2 -2
- package/examples/extensions/dynamic-resources/dynamic.json +1 -1
- package/examples/extensions/gondolin/index.ts +4 -6
- package/examples/extensions/message-renderer.ts +2 -2
- package/examples/extensions/overlay-qa-tests.ts +2 -2
- package/examples/extensions/project-trust.ts +2 -2
- package/examples/sdk/README.md +38 -44
- package/npm-shrinkwrap.json +2 -2
- package/package.json +6 -2
- package/docs/development.md +0 -68
- package/docs/distribution/README.md +0 -34
- package/docs/distribution/architecture.md +0 -102
- package/docs/distribution/extensions/README.md +0 -17
- package/docs/distribution/maintenance.md +0 -121
- package/docs/distribution/release.md +0 -85
- package/examples/extensions/subagent/README.md +0 -175
- package/examples/extensions/subagent/agents/planner.md +0 -37
- package/examples/extensions/subagent/agents/reviewer.md +0 -35
- package/examples/extensions/subagent/agents/scout.md +0 -50
- package/examples/extensions/subagent/agents/worker.md +0 -24
- package/examples/extensions/subagent/agents.ts +0 -126
- package/examples/extensions/subagent/index.ts +0 -1009
- package/examples/extensions/subagent/prompts/implement-and-review.md +0 -10
- package/examples/extensions/subagent/prompts/implement.md +0 -10
- package/examples/extensions/subagent/prompts/scout-and-plan.md +0 -9
- /package/docs/{distribution → bundled}/extensions/deepwiki.md +0 -0
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
# Distribution maintenance
|
|
2
|
-
|
|
3
|
-
This guide describes how to keep the standalone `@astralyn/pi` package aligned with upstream Pi. The repository contract in [`AGENTS.md`](../../AGENTS.md) is authoritative; publishing is covered separately in [`release.md`](release.md).
|
|
4
|
-
|
|
5
|
-
## Repository model
|
|
6
|
-
|
|
7
|
-
```text
|
|
8
|
-
origin private distribution repository
|
|
9
|
-
upstream earendil-works/pi monorepo
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
`main` contains a standalone package, not an upstream monorepo checkout. Upstream tags must therefore be inspected and selectively imported; never merge an upstream tag directly into `main`, because that would recreate every workspace.
|
|
13
|
-
|
|
14
|
-
## Ownership layers
|
|
15
|
-
|
|
16
|
-
| Layer | Typical paths | Policy |
|
|
17
|
-
|---|---|---|
|
|
18
|
-
| Upstream-aligned coding-agent | most of `src/**`, `test/**`, `docs/**`, `examples/**` | Import compatible changes from an upstream release tag. |
|
|
19
|
-
| Distribution-owned | `docs/distribution/**`, bundled personal extensions, ice-cream themes, release workflow, package identity | Preserve local design and update deliberately. |
|
|
20
|
-
| Hybrid | `src/core/agent-session.ts`, native tool presentation, built-in tools, keybindings, extension registration, `package.json`, `CHANGELOG.md` | Review function by function; retain upstream lifecycle semantics and local behavior. |
|
|
21
|
-
| Registry boundary | exact upstream AI, Agent core, and TUI dependencies | Upgrade together with the imported coding-agent release; never patch their installed files. |
|
|
22
|
-
|
|
23
|
-
Recurring hybrid hotspots include:
|
|
24
|
-
|
|
25
|
-
```text
|
|
26
|
-
src/extensions/index.ts
|
|
27
|
-
src/core/agent-session.ts
|
|
28
|
-
src/core/keybindings.ts
|
|
29
|
-
src/core/tools/*.ts
|
|
30
|
-
src/modes/interactive/components/tool-execution.ts
|
|
31
|
-
src/modes/interactive/interactive-mode.ts
|
|
32
|
-
src/modes/interactive/theme/theme.ts
|
|
33
|
-
package.json
|
|
34
|
-
CHANGELOG.md
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## Synchronization workflow
|
|
38
|
-
|
|
39
|
-
Synchronize only against upstream release tags, never upstream `main`. Start from a clean branch and fetch tags:
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
git status --short
|
|
43
|
-
git fetch upstream --tags
|
|
44
|
-
git tag --list 'v<upstream-minor>.*'
|
|
45
|
-
git switch -c sync/upstream-<version> main
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Extract the upstream coding-agent subtree into a temporary directory without changing the current checkout:
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
tmp="$(mktemp -d)"
|
|
52
|
-
git archive v<version> packages/coding-agent | tar -x -C "$tmp"
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
Review `$tmp/packages/coding-agent/` against the standalone root. Import upstream changes in bounded groups:
|
|
56
|
-
|
|
57
|
-
1. Review source and tests, paying special attention to the hybrid hotspots above.
|
|
58
|
-
2. Update product/API documentation and examples while retaining distribution-specific references.
|
|
59
|
-
3. Adapt upstream package and TypeScript changes to the standalone root rather than copying monorepo-relative paths.
|
|
60
|
-
4. Set the exact `@earendil-works/pi-ai`, `@earendil-works/pi-agent-core`, and `@earendil-works/pi-tui` versions published for that upstream release.
|
|
61
|
-
5. Run `npm install --ignore-scripts` to refresh `npm-shrinkwrap.json`, then inspect dependency and lifecycle-script changes.
|
|
62
|
-
|
|
63
|
-
Do not copy these upstream monorepo assumptions into the standalone repository:
|
|
64
|
-
|
|
65
|
-
- workspace declarations or `packages/*` paths;
|
|
66
|
-
- TypeScript or Vitest aliases to sibling source workspaces;
|
|
67
|
-
- Server, storage, model-catalog, binary, or multi-package release scripts;
|
|
68
|
-
- cross-package source modifications needed only by an unreleased upstream checkout.
|
|
69
|
-
|
|
70
|
-
If imported coding-agent code requires an API absent from the published upstream dependencies, stop and use a later compatible release. Do not solve the mismatch by vendoring or locally forking another package.
|
|
71
|
-
|
|
72
|
-
## Conflict policy
|
|
73
|
-
|
|
74
|
-
When reconciling upstream changes:
|
|
75
|
-
|
|
76
|
-
1. Preserve security fixes, protocol correctness, execution semantics, and public API compatibility first.
|
|
77
|
-
2. Keep local behavior only where it is intentionally documented and tested.
|
|
78
|
-
3. For native UI, integrate upstream execution changes before adapting presentation.
|
|
79
|
-
4. Keep model-facing output bounded and avoid schema/result changes for display-only work.
|
|
80
|
-
5. Prefer a small local type intersection or adapter over changing an upstream dependency API.
|
|
81
|
-
|
|
82
|
-
Git may detect many imports as renames from the historical `packages/coding-agent` path. Review content, not rename percentages.
|
|
83
|
-
|
|
84
|
-
## Dependency and lock maintenance
|
|
85
|
-
|
|
86
|
-
All direct registry dependencies are exact. When package metadata changes:
|
|
87
|
-
|
|
88
|
-
```bash
|
|
89
|
-
npm install --ignore-scripts
|
|
90
|
-
npm run check:pinned-deps
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
`npm-shrinkwrap.json` is both the development lock and the lock published with `@astralyn/pi`. Review new or changed transitive packages, platform-specific optional packages, and lifecycle scripts before accepting it. The pre-commit hook requires an explicit `PI_ALLOW_LOCKFILE_CHANGE=1` acknowledgment when committing an intentional shrinkwrap change.
|
|
94
|
-
|
|
95
|
-
## Verification
|
|
96
|
-
|
|
97
|
-
At minimum:
|
|
98
|
-
|
|
99
|
-
```bash
|
|
100
|
-
npm run build
|
|
101
|
-
npm run check
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
Run focused tests for each changed subsystem. For native transcript changes, verify pending, success, error, collapsed, and expanded states, plus `Ctrl+O`, `/reload`, and `/tree` in a real TTY. The Ubuntu CI workflow runs Build, Check, and the full test suite.
|
|
105
|
-
|
|
106
|
-
Before integrating a synchronization branch:
|
|
107
|
-
|
|
108
|
-
```bash
|
|
109
|
-
git status --short
|
|
110
|
-
git diff --stat main...HEAD
|
|
111
|
-
git log --oneline main..HEAD
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
## Changelog and release ownership
|
|
115
|
-
|
|
116
|
-
- `CHANGELOG.md` is the runtime and release changelog for `@astralyn/pi`.
|
|
117
|
-
- `docs/**` remains structurally close to upstream coding-agent user/API documentation.
|
|
118
|
-
- `docs/distribution/**` records standalone architecture, bundled behavior, maintenance, and release operations.
|
|
119
|
-
- Dependency package changelogs are not copied; consult their upstream releases during synchronization.
|
|
120
|
-
|
|
121
|
-
After synchronization and verification, follow the [release checklist](release.md).
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
# Release checklist
|
|
2
|
-
|
|
3
|
-
This repository publishes one npm package from its root: `@astralyn/pi`. It does not use the upstream multi-package, binary, source-archive, or model-catalog release flows. Upstream synchronization is documented in [maintenance.md](maintenance.md).
|
|
4
|
-
|
|
5
|
-
## Scope and versioning
|
|
6
|
-
|
|
7
|
-
Track the upstream Pi `major.minor` line and reserve the patch number for this distribution's release sequence:
|
|
8
|
-
|
|
9
|
-
```text
|
|
10
|
-
upstream 0.82.x -> Fork 0.82.0, 0.82.1, 0.82.2, ...
|
|
11
|
-
upstream 0.83.x -> Fork 0.83.0, 0.83.1, 0.83.2, ...
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
The first distribution release after moving to a new upstream minor uses patch `0`. Every later release on that line uses the next unused patch, including releases that absorb an upstream patch update. Use `pi-v<full-version>` Git tags so they remain distinct from fetched upstream tags such as `v0.82.0`.
|
|
15
|
-
|
|
16
|
-
## Prepare the release
|
|
17
|
-
|
|
18
|
-
1. Start from a clean `main` branch and choose the next unused distribution version.
|
|
19
|
-
2. Move current `CHANGELOG.md` entries from `[Unreleased]` into one `## [<version>] - YYYY-MM-DD` section, then leave a new empty `[Unreleased]` section.
|
|
20
|
-
3. Update `package.json` version.
|
|
21
|
-
4. Refresh and review the authoritative shrinkwrap:
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
npm install --package-lock-only --ignore-scripts
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
Direct dependencies are exact. If a synchronized upstream release is still blocked by the `.npmrc` age gate, prefer waiting; use `--min-release-age=0` only after explicitly verifying the package versions, provenance, and release contents.
|
|
28
|
-
|
|
29
|
-
Confirm `package.json` and the root entry in `npm-shrinkwrap.json` carry the same `@astralyn/pi` version and that the intended exact upstream AI, Agent core, and TUI versions are locked.
|
|
30
|
-
|
|
31
|
-
## Verify
|
|
32
|
-
|
|
33
|
-
Local development verification:
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
npm run build
|
|
37
|
-
npm run check
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
Release verification runs on Ubuntu through GitHub Actions. The CI and publish workflows both install from `npm-shrinkwrap.json`, build, check, verify that generated files remain clean, and run the complete test suite.
|
|
41
|
-
|
|
42
|
-
## Review the package
|
|
43
|
-
|
|
44
|
-
After building, inspect the root package:
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
npm pack --dry-run
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
The tarball must contain the built `dist`, product documentation, examples, README, changelog, and `npm-shrinkwrap.json`. It must not contain source workspaces or local configuration. For stronger verification, create a real tarball, install it in a temporary directory outside the repository, and run `pi --version` and `pi --list-models`.
|
|
51
|
-
|
|
52
|
-
## Publish and tag
|
|
53
|
-
|
|
54
|
-
Publishing uses npm Trusted Publishing through GitHub Actions OIDC. Configure the package once on npm:
|
|
55
|
-
|
|
56
|
-
```text
|
|
57
|
-
Publisher: GitHub Actions
|
|
58
|
-
Organization or user: ming-kang
|
|
59
|
-
Repository: pi
|
|
60
|
-
Workflow filename: publish-npm.yml
|
|
61
|
-
Environment name: (blank)
|
|
62
|
-
Allowed action: Allow npm publish
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
After the release commit is pushed and CI passes, trigger the workflow from an authenticated GitHub CLI session:
|
|
66
|
-
|
|
67
|
-
```bash
|
|
68
|
-
gh workflow run publish-npm.yml --repo ming-kang/pi --ref main -f version=0.82.0
|
|
69
|
-
|
|
70
|
-
gh run list --repo ming-kang/pi --workflow publish-npm.yml --limit 1
|
|
71
|
-
gh run watch <run-id> --repo ming-kang/pi --exit-status
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
The workflow validates the requested version, repeats Ubuntu Build/Check/Test, publishes the repository root with provenance, and verifies the registry version. A normal push to `main` never publishes.
|
|
75
|
-
|
|
76
|
-
After publication, verify the registry and perform a global-install/self-update smoke test from a separate shell or after restarting Pi. Do not replace the package currently running the release session.
|
|
77
|
-
|
|
78
|
-
Finally tag the exact release commit:
|
|
79
|
-
|
|
80
|
-
```bash
|
|
81
|
-
git tag pi-v<full-version>
|
|
82
|
-
git push origin pi-v<full-version>
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
No other package is published from this repository.
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
# Subagent Example
|
|
2
|
-
|
|
3
|
-
Delegate tasks to specialized subagents with isolated context windows.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- **Isolated context**: Each subagent runs in a separate `pi` process
|
|
8
|
-
- **Streaming output**: See tool calls and progress as they happen
|
|
9
|
-
- **Parallel streaming**: All parallel tasks stream updates simultaneously
|
|
10
|
-
- **Markdown rendering**: Final output rendered with proper formatting (expanded view)
|
|
11
|
-
- **Usage tracking**: Shows turns, tokens, cost, and context usage per agent
|
|
12
|
-
- **Abort support**: Ctrl+C propagates to kill subagent processes
|
|
13
|
-
|
|
14
|
-
## Structure
|
|
15
|
-
|
|
16
|
-
```
|
|
17
|
-
subagent/
|
|
18
|
-
├── README.md # This file
|
|
19
|
-
├── index.ts # The extension (entry point)
|
|
20
|
-
├── agents.ts # Agent discovery logic
|
|
21
|
-
├── agents/ # Sample agent definitions
|
|
22
|
-
│ ├── scout.md # Fast recon, returns compressed context
|
|
23
|
-
│ ├── planner.md # Creates implementation plans
|
|
24
|
-
│ ├── reviewer.md # Code review
|
|
25
|
-
│ └── worker.md # General-purpose (full capabilities)
|
|
26
|
-
└── prompts/ # Workflow presets (prompt templates)
|
|
27
|
-
├── implement.md # scout -> planner -> worker
|
|
28
|
-
├── scout-and-plan.md # scout -> planner (no implementation)
|
|
29
|
-
└── implement-and-review.md # worker -> reviewer -> worker
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Installation
|
|
33
|
-
|
|
34
|
-
From the repository root, symlink the files:
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
# Symlink the extension (must be in a subdirectory with index.ts)
|
|
38
|
-
mkdir -p ~/.pi/agent/extensions/subagent
|
|
39
|
-
ln -sf "$(pwd)/packages/coding-agent/examples/extensions/subagent/index.ts" ~/.pi/agent/extensions/subagent/index.ts
|
|
40
|
-
ln -sf "$(pwd)/packages/coding-agent/examples/extensions/subagent/agents.ts" ~/.pi/agent/extensions/subagent/agents.ts
|
|
41
|
-
|
|
42
|
-
# Symlink agents
|
|
43
|
-
mkdir -p ~/.pi/agent/agents
|
|
44
|
-
for f in packages/coding-agent/examples/extensions/subagent/agents/*.md; do
|
|
45
|
-
ln -sf "$(pwd)/$f" ~/.pi/agent/agents/$(basename "$f")
|
|
46
|
-
done
|
|
47
|
-
|
|
48
|
-
# Symlink workflow prompts
|
|
49
|
-
mkdir -p ~/.pi/agent/prompts
|
|
50
|
-
for f in packages/coding-agent/examples/extensions/subagent/prompts/*.md; do
|
|
51
|
-
ln -sf "$(pwd)/$f" ~/.pi/agent/prompts/$(basename "$f")
|
|
52
|
-
done
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Security Model
|
|
56
|
-
|
|
57
|
-
This tool executes a separate `pi` subprocess with a delegated system prompt and tool/model configuration.
|
|
58
|
-
|
|
59
|
-
**Project-local agents** (`.pi/agents/*.md`) are repo-controlled prompts that can instruct the model to read files, run bash commands, etc.
|
|
60
|
-
|
|
61
|
-
**Default behavior:** Only loads **user-level agents** from `~/.pi/agent/agents`.
|
|
62
|
-
|
|
63
|
-
To enable project-local agents, pass `agentScope: "both"` (or `"project"`). Only do this for repositories you trust.
|
|
64
|
-
|
|
65
|
-
When running interactively, the tool prompts for confirmation before running project-local agents. Set `confirmProjectAgents: false` to disable.
|
|
66
|
-
|
|
67
|
-
## Usage
|
|
68
|
-
|
|
69
|
-
### Single agent
|
|
70
|
-
```
|
|
71
|
-
Use scout to find all authentication code
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
### Parallel execution
|
|
75
|
-
```
|
|
76
|
-
Run 2 scouts in parallel: one to find models, one to find providers
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
### Chained workflow
|
|
80
|
-
```
|
|
81
|
-
Use a chain: first have scout find the read tool, then have planner suggest improvements
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### Workflow prompts
|
|
85
|
-
```
|
|
86
|
-
/implement add Redis caching to the session store
|
|
87
|
-
/scout-and-plan refactor auth to support OAuth
|
|
88
|
-
/implement-and-review add input validation to API endpoints
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
## Tool Modes
|
|
92
|
-
|
|
93
|
-
| Mode | Parameter | Description |
|
|
94
|
-
|------|-----------|-------------|
|
|
95
|
-
| Single | `{ agent, task }` | One agent, one task |
|
|
96
|
-
| Parallel | `{ tasks: [...] }` | Multiple agents run concurrently (max 8, 4 concurrent) |
|
|
97
|
-
| Chain | `{ chain: [...] }` | Sequential with `{previous}` placeholder |
|
|
98
|
-
|
|
99
|
-
## Output Display
|
|
100
|
-
|
|
101
|
-
**Collapsed view** (default):
|
|
102
|
-
- Status icon (✓/✗/⏳) and agent name
|
|
103
|
-
- Last 5-10 items (tool calls and text)
|
|
104
|
-
- Usage stats: `3 turns ↑input ↓output RcacheRead WcacheWrite $cost ctx:contextTokens model`
|
|
105
|
-
|
|
106
|
-
**Expanded view** (Ctrl+O):
|
|
107
|
-
- Full task text
|
|
108
|
-
- All tool calls with formatted arguments
|
|
109
|
-
- Final output rendered as Markdown
|
|
110
|
-
- Per-task usage (for chain/parallel)
|
|
111
|
-
|
|
112
|
-
**Parallel mode streaming**:
|
|
113
|
-
- Shows all tasks with live status (⏳ running, ✓ done, ✗ failed)
|
|
114
|
-
- Updates as each task makes progress
|
|
115
|
-
- Shows "2/3 done, 1 running" status
|
|
116
|
-
- Returns each completed task's final output to the parent model, capped at 50 KB per task
|
|
117
|
-
- Returns failure diagnostics from stderr/error messages when a child exits before producing output
|
|
118
|
-
|
|
119
|
-
**Tool call formatting** (mimics built-in tools):
|
|
120
|
-
- `$ command` for bash
|
|
121
|
-
- `read ~/path:1-10` for read
|
|
122
|
-
- `grep /pattern/ in ~/path` for grep
|
|
123
|
-
- etc.
|
|
124
|
-
|
|
125
|
-
## Agent Definitions
|
|
126
|
-
|
|
127
|
-
Agents are markdown files with YAML frontmatter:
|
|
128
|
-
|
|
129
|
-
```markdown
|
|
130
|
-
---
|
|
131
|
-
name: my-agent
|
|
132
|
-
description: What this agent does
|
|
133
|
-
tools: read, grep, find, ls
|
|
134
|
-
model: claude-haiku-4-5
|
|
135
|
-
---
|
|
136
|
-
|
|
137
|
-
System prompt for the agent goes here.
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
**Locations:**
|
|
141
|
-
- `~/.pi/agent/agents/*.md` - User-level (always loaded)
|
|
142
|
-
- `.pi/agents/*.md` - Project-level (only with `agentScope: "project"` or `"both"`)
|
|
143
|
-
|
|
144
|
-
Project agents override user agents with the same name when `agentScope: "both"`.
|
|
145
|
-
|
|
146
|
-
## Sample Agents
|
|
147
|
-
|
|
148
|
-
| Agent | Purpose | Model | Tools |
|
|
149
|
-
|-------|---------|-------|-------|
|
|
150
|
-
| `scout` | Fast codebase recon | Haiku | read, grep, find, ls, bash |
|
|
151
|
-
| `planner` | Implementation plans | Sonnet | read, grep, find, ls |
|
|
152
|
-
| `reviewer` | Code review | Sonnet | read, grep, find, ls, bash |
|
|
153
|
-
| `worker` | General-purpose | Sonnet | (all default) |
|
|
154
|
-
|
|
155
|
-
## Workflow Prompts
|
|
156
|
-
|
|
157
|
-
| Prompt | Flow |
|
|
158
|
-
|--------|------|
|
|
159
|
-
| `/implement <query>` | scout → planner → worker |
|
|
160
|
-
| `/scout-and-plan <query>` | scout → planner |
|
|
161
|
-
| `/implement-and-review <query>` | worker → reviewer → worker |
|
|
162
|
-
|
|
163
|
-
## Error Handling
|
|
164
|
-
|
|
165
|
-
- **Exit code != 0**: Tool returns error with stderr/output
|
|
166
|
-
- **stopReason "error"**: LLM error propagated with error message
|
|
167
|
-
- **stopReason "aborted"**: User abort (Ctrl+C) kills subprocess, throws error
|
|
168
|
-
- **Chain mode**: Stops at first failing step, reports which step failed
|
|
169
|
-
|
|
170
|
-
## Limitations
|
|
171
|
-
|
|
172
|
-
- Output truncated to last 10 items in collapsed view (expand to see all)
|
|
173
|
-
- Parallel model-visible output is capped at 50 KB per task; full results remain in tool details
|
|
174
|
-
- Agents discovered fresh on each invocation (allows editing mid-session)
|
|
175
|
-
- Parallel mode limited to 8 tasks, 4 concurrent
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: planner
|
|
3
|
-
description: Creates implementation plans from context and requirements
|
|
4
|
-
tools: read, grep, find, ls
|
|
5
|
-
model: claude-sonnet-4-5
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
You are a planning specialist. You receive context (from a scout) and requirements, then produce a clear implementation plan.
|
|
9
|
-
|
|
10
|
-
You must NOT make any changes. Only read, analyze, and plan.
|
|
11
|
-
|
|
12
|
-
Input format you'll receive:
|
|
13
|
-
- Context/findings from a scout agent
|
|
14
|
-
- Original query or requirements
|
|
15
|
-
|
|
16
|
-
Output format:
|
|
17
|
-
|
|
18
|
-
## Goal
|
|
19
|
-
One sentence summary of what needs to be done.
|
|
20
|
-
|
|
21
|
-
## Plan
|
|
22
|
-
Numbered steps, each small and actionable:
|
|
23
|
-
1. Step one - specific file/function to modify
|
|
24
|
-
2. Step two - what to add/change
|
|
25
|
-
3. ...
|
|
26
|
-
|
|
27
|
-
## Files to Modify
|
|
28
|
-
- `path/to/file.ts` - what changes
|
|
29
|
-
- `path/to/other.ts` - what changes
|
|
30
|
-
|
|
31
|
-
## New Files (if any)
|
|
32
|
-
- `path/to/new.ts` - purpose
|
|
33
|
-
|
|
34
|
-
## Risks
|
|
35
|
-
Anything to watch out for.
|
|
36
|
-
|
|
37
|
-
Keep the plan concrete. The worker agent will execute it verbatim.
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: reviewer
|
|
3
|
-
description: Code review specialist for quality and security analysis
|
|
4
|
-
tools: read, grep, find, ls, bash
|
|
5
|
-
model: claude-sonnet-4-5
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
You are a senior code reviewer. Analyze code for quality, security, and maintainability.
|
|
9
|
-
|
|
10
|
-
Bash is for read-only commands only: `git diff`, `git log`, `git show`. Do NOT modify files or run builds.
|
|
11
|
-
Assume tool permissions are not perfectly enforceable; keep all bash usage strictly read-only.
|
|
12
|
-
|
|
13
|
-
Strategy:
|
|
14
|
-
1. Run `git diff` to see recent changes (if applicable)
|
|
15
|
-
2. Read the modified files
|
|
16
|
-
3. Check for bugs, security issues, code smells
|
|
17
|
-
|
|
18
|
-
Output format:
|
|
19
|
-
|
|
20
|
-
## Files Reviewed
|
|
21
|
-
- `path/to/file.ts` (lines X-Y)
|
|
22
|
-
|
|
23
|
-
## Critical (must fix)
|
|
24
|
-
- `file.ts:42` - Issue description
|
|
25
|
-
|
|
26
|
-
## Warnings (should fix)
|
|
27
|
-
- `file.ts:100` - Issue description
|
|
28
|
-
|
|
29
|
-
## Suggestions (consider)
|
|
30
|
-
- `file.ts:150` - Improvement idea
|
|
31
|
-
|
|
32
|
-
## Summary
|
|
33
|
-
Overall assessment in 2-3 sentences.
|
|
34
|
-
|
|
35
|
-
Be specific with file paths and line numbers.
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: scout
|
|
3
|
-
description: Fast codebase recon that returns compressed context for handoff to other agents
|
|
4
|
-
tools: read, grep, find, ls, bash
|
|
5
|
-
model: claude-haiku-4-5
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
You are a scout. Quickly investigate a codebase and return structured findings that another agent can use without re-reading everything.
|
|
9
|
-
|
|
10
|
-
Your output will be passed to an agent who has NOT seen the files you explored.
|
|
11
|
-
|
|
12
|
-
Thoroughness (infer from task, default medium):
|
|
13
|
-
- Quick: Targeted lookups, key files only
|
|
14
|
-
- Medium: Follow imports, read critical sections
|
|
15
|
-
- Thorough: Trace all dependencies, check tests/types
|
|
16
|
-
|
|
17
|
-
Strategy:
|
|
18
|
-
1. grep/find to locate relevant code
|
|
19
|
-
2. Read key sections (not entire files)
|
|
20
|
-
3. Identify types, interfaces, key functions
|
|
21
|
-
4. Note dependencies between files
|
|
22
|
-
|
|
23
|
-
Output format:
|
|
24
|
-
|
|
25
|
-
## Files Retrieved
|
|
26
|
-
List with exact line ranges:
|
|
27
|
-
1. `path/to/file.ts` (lines 10-50) - Description of what's here
|
|
28
|
-
2. `path/to/other.ts` (lines 100-150) - Description
|
|
29
|
-
3. ...
|
|
30
|
-
|
|
31
|
-
## Key Code
|
|
32
|
-
Critical types, interfaces, or functions:
|
|
33
|
-
|
|
34
|
-
```typescript
|
|
35
|
-
interface Example {
|
|
36
|
-
// actual code from the files
|
|
37
|
-
}
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
```typescript
|
|
41
|
-
function keyFunction() {
|
|
42
|
-
// actual implementation
|
|
43
|
-
}
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Architecture
|
|
47
|
-
Brief explanation of how the pieces connect.
|
|
48
|
-
|
|
49
|
-
## Start Here
|
|
50
|
-
Which file to look at first and why.
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: worker
|
|
3
|
-
description: General-purpose subagent with full capabilities, isolated context
|
|
4
|
-
model: claude-sonnet-4-5
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
You are a worker agent with full capabilities. You operate in an isolated context window to handle delegated tasks without polluting the main conversation.
|
|
8
|
-
|
|
9
|
-
Work autonomously to complete the assigned task. Use all available tools as needed.
|
|
10
|
-
|
|
11
|
-
Output format when finished:
|
|
12
|
-
|
|
13
|
-
## Completed
|
|
14
|
-
What was done.
|
|
15
|
-
|
|
16
|
-
## Files Changed
|
|
17
|
-
- `path/to/file.ts` - what changed
|
|
18
|
-
|
|
19
|
-
## Notes (if any)
|
|
20
|
-
Anything the main agent should know.
|
|
21
|
-
|
|
22
|
-
If handing off to another agent (e.g. reviewer), include:
|
|
23
|
-
- Exact file paths changed
|
|
24
|
-
- Key functions/types touched (short list)
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent discovery and configuration
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import * as fs from "node:fs";
|
|
6
|
-
import * as path from "node:path";
|
|
7
|
-
import { CONFIG_DIR_NAME, getAgentDir, parseFrontmatter } from "@astralyn/pi";
|
|
8
|
-
|
|
9
|
-
export type AgentScope = "user" | "project" | "both";
|
|
10
|
-
|
|
11
|
-
export interface AgentConfig {
|
|
12
|
-
name: string;
|
|
13
|
-
description: string;
|
|
14
|
-
tools?: string[];
|
|
15
|
-
model?: string;
|
|
16
|
-
systemPrompt: string;
|
|
17
|
-
source: "user" | "project";
|
|
18
|
-
filePath: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface AgentDiscoveryResult {
|
|
22
|
-
agents: AgentConfig[];
|
|
23
|
-
projectAgentsDir: string | null;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function loadAgentsFromDir(dir: string, source: "user" | "project"): AgentConfig[] {
|
|
27
|
-
const agents: AgentConfig[] = [];
|
|
28
|
-
|
|
29
|
-
if (!fs.existsSync(dir)) {
|
|
30
|
-
return agents;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
let entries: fs.Dirent[];
|
|
34
|
-
try {
|
|
35
|
-
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
36
|
-
} catch {
|
|
37
|
-
return agents;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
for (const entry of entries) {
|
|
41
|
-
if (!entry.name.endsWith(".md")) continue;
|
|
42
|
-
if (!entry.isFile() && !entry.isSymbolicLink()) continue;
|
|
43
|
-
|
|
44
|
-
const filePath = path.join(dir, entry.name);
|
|
45
|
-
let content: string;
|
|
46
|
-
try {
|
|
47
|
-
content = fs.readFileSync(filePath, "utf-8");
|
|
48
|
-
} catch {
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const { frontmatter, body } = parseFrontmatter<Record<string, string>>(content);
|
|
53
|
-
|
|
54
|
-
if (!frontmatter.name || !frontmatter.description) {
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const tools = frontmatter.tools
|
|
59
|
-
?.split(",")
|
|
60
|
-
.map((t: string) => t.trim())
|
|
61
|
-
.filter(Boolean);
|
|
62
|
-
|
|
63
|
-
agents.push({
|
|
64
|
-
name: frontmatter.name,
|
|
65
|
-
description: frontmatter.description,
|
|
66
|
-
tools: tools && tools.length > 0 ? tools : undefined,
|
|
67
|
-
model: frontmatter.model,
|
|
68
|
-
systemPrompt: body,
|
|
69
|
-
source,
|
|
70
|
-
filePath,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return agents;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function isDirectory(p: string): boolean {
|
|
78
|
-
try {
|
|
79
|
-
return fs.statSync(p).isDirectory();
|
|
80
|
-
} catch {
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function findNearestProjectAgentsDir(cwd: string): string | null {
|
|
86
|
-
let currentDir = cwd;
|
|
87
|
-
while (true) {
|
|
88
|
-
const candidate = path.join(currentDir, CONFIG_DIR_NAME, "agents");
|
|
89
|
-
if (isDirectory(candidate)) return candidate;
|
|
90
|
-
|
|
91
|
-
const parentDir = path.dirname(currentDir);
|
|
92
|
-
if (parentDir === currentDir) return null;
|
|
93
|
-
currentDir = parentDir;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export function discoverAgents(cwd: string, scope: AgentScope): AgentDiscoveryResult {
|
|
98
|
-
const userDir = path.join(getAgentDir(), "agents");
|
|
99
|
-
const projectAgentsDir = findNearestProjectAgentsDir(cwd);
|
|
100
|
-
|
|
101
|
-
const userAgents = scope === "project" ? [] : loadAgentsFromDir(userDir, "user");
|
|
102
|
-
const projectAgents = scope === "user" || !projectAgentsDir ? [] : loadAgentsFromDir(projectAgentsDir, "project");
|
|
103
|
-
|
|
104
|
-
const agentMap = new Map<string, AgentConfig>();
|
|
105
|
-
|
|
106
|
-
if (scope === "both") {
|
|
107
|
-
for (const agent of userAgents) agentMap.set(agent.name, agent);
|
|
108
|
-
for (const agent of projectAgents) agentMap.set(agent.name, agent);
|
|
109
|
-
} else if (scope === "user") {
|
|
110
|
-
for (const agent of userAgents) agentMap.set(agent.name, agent);
|
|
111
|
-
} else {
|
|
112
|
-
for (const agent of projectAgents) agentMap.set(agent.name, agent);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return { agents: Array.from(agentMap.values()), projectAgentsDir };
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export function formatAgentList(agents: AgentConfig[], maxItems: number): { text: string; remaining: number } {
|
|
119
|
-
if (agents.length === 0) return { text: "none", remaining: 0 };
|
|
120
|
-
const listed = agents.slice(0, maxItems);
|
|
121
|
-
const remaining = agents.length - listed.length;
|
|
122
|
-
return {
|
|
123
|
-
text: listed.map((a) => `${a.name} (${a.source}): ${a.description}`).join("; "),
|
|
124
|
-
remaining,
|
|
125
|
-
};
|
|
126
|
-
}
|