@aliou/pi-dev-kit 0.4.9 → 0.6.0
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/README.md +60 -0
- package/package.json +63 -2
- package/src/commands/index.ts +6 -0
- package/src/commands/update.ts +144 -0
- package/src/index.ts +8 -0
- package/src/prompts/setup-demo.md +35 -0
- package/src/skills/demo-setup/SKILL.md +217 -0
- package/src/skills/pi-extension/SKILL.md +154 -0
- package/src/skills/pi-extension/references/additional-apis.md +304 -0
- package/src/skills/pi-extension/references/commands.md +100 -0
- package/src/skills/pi-extension/references/components.md +166 -0
- package/src/skills/pi-extension/references/documentation.md +54 -0
- package/src/skills/pi-extension/references/hooks.md +244 -0
- package/src/skills/pi-extension/references/messages.md +169 -0
- package/src/skills/pi-extension/references/modes.md +156 -0
- package/src/skills/pi-extension/references/providers.md +134 -0
- package/src/skills/pi-extension/references/publish.md +139 -0
- package/src/skills/pi-extension/references/state.md +56 -0
- package/src/skills/pi-extension/references/structure.md +522 -0
- package/src/skills/pi-extension/references/testing.md +183 -0
- package/src/skills/pi-extension/references/tools.md +948 -0
- package/src/tools/changelog-tool.ts +484 -0
- package/src/tools/docs-tool.ts +181 -0
- package/src/tools/index.ts +12 -0
- package/src/tools/package-manager-tool.ts +194 -0
- package/src/tools/utils.ts +38 -0
- package/src/tools/version-tool.ts +70 -0
package/README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Pi Dev Kit
|
|
2
|
+
|
|
3
|
+
Tools and commands for building, maintaining, and updating Pi extensions.
|
|
4
|
+
|
|
5
|
+
## Demo
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
https://github.com/user-attachments/assets/44a96009-0653-4803-8590-d5a8a5131f4c
|
|
10
|
+
|
|
11
|
+
<small>
|
|
12
|
+
<a href="https://assets.aliou.me/pi-extensions/2026-02-02-pi-extension-dev-demo.mp4">Non sped-up version</a>
|
|
13
|
+
</small>
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pi install npm:@aliou/pi-dev-kit
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Or from git:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pi install git:github.com/aliou/pi-dev-kit
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Formerly `@aliou/pi-extension-dev`. This package continues from the same release line under a new name.
|
|
29
|
+
|
|
30
|
+
## Commands
|
|
31
|
+
|
|
32
|
+
### `/extensions:update [VERSION]`
|
|
33
|
+
|
|
34
|
+
Update Pi extensions to a target version. Without an argument, checks npm for the latest version and lets you choose between latest and installed. With a version argument, targets that version directly.
|
|
35
|
+
|
|
36
|
+
Runs a guided workflow: detects the package manager, compares versions, reads changelogs and docs, analyzes source files for breaking changes, presents an update plan, and applies changes after confirmation.
|
|
37
|
+
|
|
38
|
+
## Tools
|
|
39
|
+
|
|
40
|
+
### `detect_package_manager`
|
|
41
|
+
|
|
42
|
+
Detects the package manager used in the current project. Checks the `packageManager` field in `package.json` first, then falls back to lockfile detection (`pnpm-lock.yaml`, `yarn.lock`, `package-lock.json`, `bun.lockb`). Walks up from the working directory to the git root.
|
|
43
|
+
|
|
44
|
+
Returns the package manager name, version (if declared), lockfile path, and install/run commands.
|
|
45
|
+
|
|
46
|
+
### `pi_version`
|
|
47
|
+
|
|
48
|
+
Returns the version of the currently running Pi instance.
|
|
49
|
+
|
|
50
|
+
### `pi_docs`
|
|
51
|
+
|
|
52
|
+
Lists all Pi documentation files from the Pi installation: `README.md`, individual files in `docs/`, and the `examples/` directory path.
|
|
53
|
+
|
|
54
|
+
### `pi_changelog`
|
|
55
|
+
|
|
56
|
+
Parses the Pi changelog and returns entries for a specific version (or the latest). When the requested version is newer than the installed Pi, fetches the changelog from GitHub.
|
|
57
|
+
|
|
58
|
+
## Compatibility
|
|
59
|
+
|
|
60
|
+
Compatible with Pi 0.50.x and 0.51.0+. Tools that need the extension context use a runtime shim to handle the execute signature difference between versions.
|
package/package.json
CHANGED
|
@@ -1,9 +1,70 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aliou/pi-dev-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"private": false,
|
|
7
|
+
"keywords": [
|
|
8
|
+
"pi-package",
|
|
9
|
+
"pi-extension",
|
|
10
|
+
"pi",
|
|
11
|
+
"dev-kit",
|
|
12
|
+
"meta"
|
|
13
|
+
],
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/aliou/pi-dev-kit"
|
|
17
|
+
},
|
|
18
|
+
"pi": {
|
|
19
|
+
"extensions": [
|
|
20
|
+
"./src/index.ts"
|
|
21
|
+
],
|
|
22
|
+
"skills": [
|
|
23
|
+
"./src/skills"
|
|
24
|
+
],
|
|
25
|
+
"prompts": [
|
|
26
|
+
"./src/prompts"
|
|
27
|
+
],
|
|
28
|
+
"video": "https://assets.aliou.me/pi-extensions/2026-02-02-pi-extension-dev-demo.mp4"
|
|
29
|
+
},
|
|
6
30
|
"publishConfig": {
|
|
7
31
|
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"src",
|
|
35
|
+
"README.md"
|
|
36
|
+
],
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@aliou/pi-utils-ui": "^0.1.0",
|
|
39
|
+
"@sinclair/typebox": "^0.34.41"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"@mariozechner/pi-coding-agent": "0.64.0",
|
|
43
|
+
"@mariozechner/pi-tui": "0.64.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@biomejs/biome": "^2.3.13",
|
|
47
|
+
"@changesets/cli": "^2.27.11",
|
|
48
|
+
"@mariozechner/pi-coding-agent": "0.64.0",
|
|
49
|
+
"@mariozechner/pi-tui": "0.64.0",
|
|
50
|
+
"@types/node": "^25.0.10",
|
|
51
|
+
"husky": "^9.1.7",
|
|
52
|
+
"typescript": "^5.9.3"
|
|
53
|
+
},
|
|
54
|
+
"peerDependenciesMeta": {
|
|
55
|
+
"@mariozechner/pi-coding-agent": {
|
|
56
|
+
"optional": true
|
|
57
|
+
},
|
|
58
|
+
"@mariozechner/pi-tui": {
|
|
59
|
+
"optional": true
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"typecheck": "tsc --noEmit",
|
|
64
|
+
"lint": "biome check",
|
|
65
|
+
"format": "biome check --write",
|
|
66
|
+
"changeset": "changeset",
|
|
67
|
+
"version": "changeset version",
|
|
68
|
+
"release": "pnpm changeset publish"
|
|
8
69
|
}
|
|
9
|
-
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
2
|
+
import { VERSION } from "@mariozechner/pi-coding-agent";
|
|
3
|
+
|
|
4
|
+
const NPM_REGISTRY_URL =
|
|
5
|
+
"https://registry.npmjs.org/@mariozechner/pi-coding-agent/latest";
|
|
6
|
+
|
|
7
|
+
async function fetchLatestVersion(): Promise<string | null> {
|
|
8
|
+
try {
|
|
9
|
+
const res = await fetch(NPM_REGISTRY_URL);
|
|
10
|
+
if (!res.ok) return null;
|
|
11
|
+
const data = (await res.json()) as { version?: string };
|
|
12
|
+
return data.version ?? null;
|
|
13
|
+
} catch {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const UPDATE_PROMPT = `# Update Pi Extensions
|
|
19
|
+
|
|
20
|
+
Update this project's Pi extensions, themes, and components to the specified target Pi version.
|
|
21
|
+
|
|
22
|
+
## Steps
|
|
23
|
+
|
|
24
|
+
### 1. Detect Package Manager
|
|
25
|
+
|
|
26
|
+
Use \`detect_package_manager\` to identify the package manager (npm, pnpm, yarn, bun). Use its install and run commands for all subsequent steps.
|
|
27
|
+
|
|
28
|
+
### 2. Version Check
|
|
29
|
+
|
|
30
|
+
The target Pi version is provided above. Read \`./package.json\` to find the current Pi package versions. The relevant packages are any of:
|
|
31
|
+
- \`@mariozechner/pi-ai\`
|
|
32
|
+
- \`@mariozechner/pi-coding-agent\`
|
|
33
|
+
- \`@mariozechner/pi-tui\`
|
|
34
|
+
- \`@mariozechner/pi-agent-core\`
|
|
35
|
+
|
|
36
|
+
Report the current version in package.json vs the target version. If versions match, stop here -- nothing to update.
|
|
37
|
+
|
|
38
|
+
### 3. Gather Documentation
|
|
39
|
+
|
|
40
|
+
If there's a version mismatch:
|
|
41
|
+
1. Use \`pi_changelog\` to get changelog entries for versions between current and target
|
|
42
|
+
2. Use \`pi_docs\` to get paths to Pi documentation
|
|
43
|
+
3. Read the relevant docs, especially:
|
|
44
|
+
- \`docs/extensions.md\` for extension API changes
|
|
45
|
+
- Any migration guides or breaking changes noted in changelogs
|
|
46
|
+
|
|
47
|
+
### 4. Analyze Source
|
|
48
|
+
|
|
49
|
+
Scan all source files that import from Pi packages:
|
|
50
|
+
1. Find all \`.ts\` and \`.tsx\` files that import from \`@mariozechner/pi-*\`
|
|
51
|
+
2. For each file, identify API usage that needs updating based on changelog/docs
|
|
52
|
+
3. Check overridden tools or tool wrappers for delegated \`tool.execute(...)\` calls; update forwarded parameter order and optional args
|
|
53
|
+
4. Note deprecated patterns or new recommended approaches
|
|
54
|
+
5. Look for custom utility functions that duplicate functionality now available in the Pi SDK -- if the SDK provides an equivalent, flag it for replacement
|
|
55
|
+
|
|
56
|
+
### 5. Create Update Plan
|
|
57
|
+
|
|
58
|
+
Present a detailed plan:
|
|
59
|
+
- Package version updates needed (in root and any sub-package.json files with peerDependencies)
|
|
60
|
+
- For each affected file:
|
|
61
|
+
- Specific API migrations required
|
|
62
|
+
- Breaking changes and how to address them
|
|
63
|
+
- New features from the changelog that could improve existing code
|
|
64
|
+
- Custom utilities replaceable by SDK exports
|
|
65
|
+
|
|
66
|
+
### 6. User Confirmation
|
|
67
|
+
|
|
68
|
+
Present the plan and ask for confirmation before proceeding. Wait for feedback. Iterate on the plan based on user input until agreement is reached.
|
|
69
|
+
|
|
70
|
+
### 7. Execute Updates
|
|
71
|
+
|
|
72
|
+
Once confirmed:
|
|
73
|
+
1. Update Pi package versions in \`./package.json\` and any sub-package files (peerDependencies) to the exact target version. Use exact versions (e.g., \`0.51.0\`), not ranges.
|
|
74
|
+
2. Apply the planned code changes
|
|
75
|
+
3. Run the install command from step 1
|
|
76
|
+
4. Run typecheck (\`tsc --build\` or the project's typecheck script)
|
|
77
|
+
5. Run lint if the project has a lint script
|
|
78
|
+
6. Report results and any issues encountered
|
|
79
|
+
|
|
80
|
+
### 8. Commit Changes
|
|
81
|
+
|
|
82
|
+
After successful verification:
|
|
83
|
+
1. Check \`git status\` to see all changed files
|
|
84
|
+
2. Stage only files changed by this update -- do not use \`git add .\`
|
|
85
|
+
3. Commit with message format: \`chore: update pi packages to X.Y.Z\`
|
|
86
|
+
4. Include a brief summary of breaking changes addressed in the commit body
|
|
87
|
+
|
|
88
|
+
## Fallback
|
|
89
|
+
|
|
90
|
+
If the extension tools (\`pi_changelog\`, \`pi_docs\`, \`detect_package_manager\`) fail -- which can happen when the very update being applied changes the tool calling convention -- fall back to:
|
|
91
|
+
- Changelog: read \`CHANGELOG.md\` from the Pi installation directory
|
|
92
|
+
- Docs: read \`README.md\` and list \`docs/\` from the Pi installation directory
|
|
93
|
+
- Package manager: check for lockfiles manually (\`pnpm-lock.yaml\`, \`yarn.lock\`, \`package-lock.json\`, \`bun.lockb\`)
|
|
94
|
+
|
|
95
|
+
## Important
|
|
96
|
+
|
|
97
|
+
- Preserve existing functionality while updating to new APIs
|
|
98
|
+
- Keep changes minimal and focused on API compatibility
|
|
99
|
+
- If unsure about a migration, ask for clarification`;
|
|
100
|
+
|
|
101
|
+
export function registerUpdateCommand(pi: ExtensionAPI) {
|
|
102
|
+
pi.registerCommand("extensions:update", {
|
|
103
|
+
description: "Update Pi extensions to a target version (current or latest)",
|
|
104
|
+
handler: async (args, ctx) => {
|
|
105
|
+
if (!ctx.hasUI) return;
|
|
106
|
+
|
|
107
|
+
let targetVersion: string;
|
|
108
|
+
|
|
109
|
+
if (args?.trim()) {
|
|
110
|
+
// Version passed as argument.
|
|
111
|
+
targetVersion = args.trim().replace(/^v/, "");
|
|
112
|
+
} else {
|
|
113
|
+
// Fetch latest and let user choose.
|
|
114
|
+
ctx.ui.setStatus("extensions:update", "Checking latest version...");
|
|
115
|
+
const latest = await fetchLatestVersion();
|
|
116
|
+
ctx.ui.setStatus("extensions:update", undefined);
|
|
117
|
+
|
|
118
|
+
if (!latest || latest === VERSION) {
|
|
119
|
+
// Either fetch failed or already on latest -- use installed version.
|
|
120
|
+
targetVersion = VERSION;
|
|
121
|
+
if (!latest) {
|
|
122
|
+
ctx.ui.notify(
|
|
123
|
+
"Could not fetch latest version from npm, using installed version.",
|
|
124
|
+
"warning",
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
} else {
|
|
128
|
+
const choice = await ctx.ui.select(
|
|
129
|
+
`Installed: ${VERSION}, Latest: ${latest}`,
|
|
130
|
+
[`${latest} (latest)`, `${VERSION} (installed)`],
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
if (choice === undefined) return; // cancelled
|
|
134
|
+
|
|
135
|
+
targetVersion = choice.startsWith(latest) ? latest : VERSION;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
pi.sendUserMessage(
|
|
140
|
+
`Target Pi version: ${targetVersion}\n\n${UPDATE_PROMPT}`,
|
|
141
|
+
);
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Create a demo environment for a Pi extension
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Set up a demo directory for a Pi extension. Load the `demo-setup` skill first, then follow these steps:
|
|
6
|
+
|
|
7
|
+
## 1. Find the extension
|
|
8
|
+
|
|
9
|
+
If the current directory contains a `package.json` with a `pi` key, use it. Otherwise, ask the user for the path to the extension.
|
|
10
|
+
|
|
11
|
+
Read the extension's `package.json`, `README.md`, and source files to understand:
|
|
12
|
+
- What tools it registers
|
|
13
|
+
- What commands it provides
|
|
14
|
+
- What hooks it uses
|
|
15
|
+
- Whether it's a provider, theme, or standard extension
|
|
16
|
+
|
|
17
|
+
## 2. Create the demo directory
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
demo_dir=$(mktemp -d -t pi-demo-XXXXXX)
|
|
21
|
+
mkdir -p "$demo_dir/.pi/prompts"
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 3. Set up the demo
|
|
25
|
+
|
|
26
|
+
Follow the `demo-setup` skill to create:
|
|
27
|
+
- `.pi/settings.json` registering the extension by absolute path
|
|
28
|
+
- `.pi/prompts/demo.md` with steps covering each feature
|
|
29
|
+
- Fixture files appropriate for the extension type
|
|
30
|
+
- `AGENTS.md` if the agent needs behavioral instructions
|
|
31
|
+
- `.pi/extensions/<name>.json` if config overrides are needed
|
|
32
|
+
|
|
33
|
+
## 4. Print the result
|
|
34
|
+
|
|
35
|
+
Print the demo directory path and instructions for the user.
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: demo-setup
|
|
3
|
+
description: Set up demo environments for Pi extensions to record videos or screenshots for the Pi package browser. Use when preparing a demo, recording a video, or creating preview assets for an extension or theme.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Demo Setup
|
|
7
|
+
|
|
8
|
+
Set up self-contained demo directories for Pi extensions. The demo directory contains everything needed to showcase an extension: a prompt that runs through the features, fixture files, and pi configuration.
|
|
9
|
+
|
|
10
|
+
## Pi Package Browser
|
|
11
|
+
|
|
12
|
+
The Pi website has a package browser at `buildwithpi.ai/packages`. Packages can display preview media.
|
|
13
|
+
|
|
14
|
+
### Adding Preview Media to package.json
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
{
|
|
18
|
+
"pi": {
|
|
19
|
+
"extensions": ["./index.ts"],
|
|
20
|
+
"video": "https://example.com/demo.mp4",
|
|
21
|
+
"image": "https://example.com/preview.png"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Both `video` and `image` are optional. Video takes precedence when present.
|
|
27
|
+
|
|
28
|
+
### Video/Image Specs
|
|
29
|
+
|
|
30
|
+
- **Aspect ratio**: 16:9 (enforced by `aspect-ratio: 16/9` CSS)
|
|
31
|
+
- **Recommended resolution**: 1920x1080
|
|
32
|
+
- **Object fit**: `contain` on black background
|
|
33
|
+
- **Modal max width**: 900px
|
|
34
|
+
- **Format**: `.mp4` for video, `.png`/`.jpg`/`.jpeg`/`.webp`/`.gif` for image
|
|
35
|
+
- **Caching**: Client-side localStorage, 15-minute TTL. New visitors or cleared cache see updates immediately.
|
|
36
|
+
|
|
37
|
+
### For Themes
|
|
38
|
+
|
|
39
|
+
Themes show better as images (screenshots of dark and light variants side by side). A single 16:9 image with both variants is ideal.
|
|
40
|
+
|
|
41
|
+
## Northwind Base Project
|
|
42
|
+
|
|
43
|
+
Northwind is a fictive Node.js REST API project used as the base environment for demos. It provides a realistic project structure with shell scripts, config files, and database workflows that extensions can hook into.
|
|
44
|
+
|
|
45
|
+
Use Northwind when the demo needs a project context. Customize it freely -- add files, remove scripts, tweak behavior to highlight the extension's features. Northwind is a starting point, not a rigid template.
|
|
46
|
+
|
|
47
|
+
### Project context
|
|
48
|
+
|
|
49
|
+
Northwind is a trading company API with:
|
|
50
|
+
- Customers, products, orders, categories, suppliers
|
|
51
|
+
- PostgreSQL database with migrations and seed data
|
|
52
|
+
- A "shipping address" feature being developed (used for stateful test flows)
|
|
53
|
+
- Config files: `.env`, `.env.example`, `drizzle.config.ts`
|
|
54
|
+
- Common project files: `package.json`, `tsconfig.json`, `scripts/`
|
|
55
|
+
|
|
56
|
+
### Available scripts
|
|
57
|
+
|
|
58
|
+
These are the full set. Pick only what your demo needs.
|
|
59
|
+
|
|
60
|
+
| Script | Command | Behavior |
|
|
61
|
+
|--------|---------|----------|
|
|
62
|
+
| `scripts/server.sh` | `npm run server` | Long-running API server with request logs on port 4000 |
|
|
63
|
+
| `scripts/dev.sh` | `npm run dev` | Long-running dev server with HMR updates |
|
|
64
|
+
| `scripts/test.sh` | `npm run test` | Stateful test suite (see below) |
|
|
65
|
+
| `scripts/migrate.sh` | `npm run migrate` | Runs migrations (creates `/tmp/northwind-migrated`) |
|
|
66
|
+
| `scripts/seed.sh` | `npm run seed` | Seeds fake data (creates `/tmp/northwind-seeded`) |
|
|
67
|
+
| `scripts/reset.sh` | `npm run reset` | Clears state files for re-runs |
|
|
68
|
+
| `scripts/build.sh` | `npm run build` | 5-step production build, exits 0 |
|
|
69
|
+
| `scripts/lint.sh` | `npm run lint` | Lint check with warnings and errors, exits 1 |
|
|
70
|
+
| `scripts/typecheck.sh` | `npm run typecheck` | Type check with 2 errors, exits 1 |
|
|
71
|
+
| `scripts/test-watch.sh` | `npm run test:watch` | Continuous test watcher |
|
|
72
|
+
|
|
73
|
+
### Stateful test flow
|
|
74
|
+
|
|
75
|
+
The test script uses marker files (`/tmp/northwind-migrated`, `/tmp/northwind-seeded`) to determine which stage the project is at:
|
|
76
|
+
|
|
77
|
+
1. **No migration**: tests fail with `relation "shipping_addresses" does not exist`
|
|
78
|
+
2. **Migrated, no seed**: tests fail with `customer.shippingAddress` undefined
|
|
79
|
+
3. **Migrated + seeded**: all tests pass
|
|
80
|
+
|
|
81
|
+
Run `npm run reset` before each demo to clear state.
|
|
82
|
+
|
|
83
|
+
### Customizing Northwind for your extension
|
|
84
|
+
|
|
85
|
+
You should adapt the project to create scenarios that naturally exercise your extension. Examples:
|
|
86
|
+
|
|
87
|
+
- **Guardrails**: add `.env` with real-looking secrets, `.env.example` with safe patterns, `drizzle.config.ts` for ORM config. The demo prompt can ask the agent to manually write a migration file (which guardrails should block, since the project uses `drizzle-kit generate`).
|
|
88
|
+
- **Processes**: use the long-running scripts (server, dev, test-watch) to show background process management.
|
|
89
|
+
- **Custom tools**: add project files that the tool operates on.
|
|
90
|
+
- **Hooks**: add files or configs that trigger hook patterns (blocked and allowed cases).
|
|
91
|
+
|
|
92
|
+
Add whatever files make sense: `.env`, `drizzle.config.ts`, `src/` stubs, `docker-compose.yml`, etc. The scripts are just bash with sleep/echo -- easy to create new ones or modify existing ones.
|
|
93
|
+
|
|
94
|
+
## Demo Directory Structure
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
<demo-dir>/
|
|
98
|
+
├── northwind/ # The fake project (agent runs pi here)
|
|
99
|
+
│ ├── .pi/
|
|
100
|
+
│ │ ├── settings.json # Registers the extension as a local path
|
|
101
|
+
│ │ └── prompts/
|
|
102
|
+
│ │ └── <demo-name>.md # The demo prompt
|
|
103
|
+
│ ├── AGENTS.md # Agent instructions
|
|
104
|
+
│ ├── package.json # npm scripts pointing to shell scripts
|
|
105
|
+
│ └── scripts/ # Simulated shell scripts
|
|
106
|
+
├── shell.nix # Nix dev environment (outside northwind)
|
|
107
|
+
└── .envrc # direnv config (outside northwind)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
The outer directory holds the Nix/direnv setup. The inner `northwind/` directory is where pi runs. This way oh-my-posh (or similar prompt tools) display "northwind" in the terminal prompt.
|
|
111
|
+
|
|
112
|
+
## Setup Workflow
|
|
113
|
+
|
|
114
|
+
### 1. Detect the Extension
|
|
115
|
+
|
|
116
|
+
Check `package.json` in the target directory for a `pi` key with `extensions`, `themes`, or `skills`. Read the README and source to understand what the extension provides: tools, commands, hooks, providers, themes.
|
|
117
|
+
|
|
118
|
+
### 2. Create Demo Directory
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
demo_dir="<path>"
|
|
122
|
+
mkdir -p "$demo_dir/northwind/.pi/prompts"
|
|
123
|
+
mkdir -p "$demo_dir/northwind/scripts"
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### 3. Register the Extension
|
|
127
|
+
|
|
128
|
+
Create `northwind/.pi/settings.json` pointing to the extension's absolute path:
|
|
129
|
+
|
|
130
|
+
```json
|
|
131
|
+
{
|
|
132
|
+
"packages": [
|
|
133
|
+
"/absolute/path/to/extension"
|
|
134
|
+
],
|
|
135
|
+
"defaultThinkingLevel": "off"
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Use `defaultThinkingLevel: "off"` to keep responses fast and visible during demos.
|
|
140
|
+
|
|
141
|
+
### 4. Write the Demo Prompt
|
|
142
|
+
|
|
143
|
+
Create `northwind/.pi/prompts/<demo-name>.md`. Name it after what the demo shows (e.g., `test-shipping-feature.md`). Structure it as numbered steps that run without user confirmation between steps.
|
|
144
|
+
|
|
145
|
+
```markdown
|
|
146
|
+
---
|
|
147
|
+
description: Showcase the <extension-name> extension
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
Demo the <extension-name> extension by <scenario>. Run through all steps without waiting for confirmation. Keep messages short.
|
|
151
|
+
|
|
152
|
+
## 1. <Step Name>
|
|
153
|
+
|
|
154
|
+
<What to do.>
|
|
155
|
+
|
|
156
|
+
## 2. <Next Step>
|
|
157
|
+
|
|
158
|
+
...
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### 5. Add Fixture Files
|
|
162
|
+
|
|
163
|
+
Start from the Northwind base and customize:
|
|
164
|
+
|
|
165
|
+
- Copy relevant scripts into `northwind/scripts/`
|
|
166
|
+
- Create `northwind/package.json` with npm script entries
|
|
167
|
+
- Add project files the extension needs (`.env`, config files, source stubs, etc.)
|
|
168
|
+
- Create new scripts if the demo needs behaviors Northwind doesn't provide
|
|
169
|
+
|
|
170
|
+
### 6. Add AGENTS.md
|
|
171
|
+
|
|
172
|
+
Always add a `northwind/AGENTS.md` that:
|
|
173
|
+
- Describes the project briefly
|
|
174
|
+
- Lists available scripts and project files
|
|
175
|
+
- Instructs the agent to NOT search the codebase or read source files
|
|
176
|
+
- Tells the agent to just run the scripts and use the files as-is
|
|
177
|
+
|
|
178
|
+
The AGENTS.md should make the agent feel like it's working in a real project. Tailor it to the extension -- for guardrails, mention the ORM and conventions; for processes, emphasize which scripts are long-running.
|
|
179
|
+
|
|
180
|
+
## Demo Prompt Patterns by Extension Type
|
|
181
|
+
|
|
182
|
+
### Extensions with Tools
|
|
183
|
+
|
|
184
|
+
Build a narrative workflow (like "test a new feature" or "set up the project") that naturally exercises the tools. The agent should encounter problems and react to them, not just call tools in sequence.
|
|
185
|
+
|
|
186
|
+
### Extensions with Hooks
|
|
187
|
+
|
|
188
|
+
Build a workflow where the agent naturally triggers hooks. Include both blocked and allowed cases so the demo shows the extension intervening and also stepping aside. For example: the agent tries to manually write a migration (blocked), then uses the ORM generate command instead (allowed).
|
|
189
|
+
|
|
190
|
+
### Extensions with Commands
|
|
191
|
+
|
|
192
|
+
Run each command (e.g., `/extension:command`) to show the interactive UI.
|
|
193
|
+
|
|
194
|
+
### Extensions with Providers
|
|
195
|
+
|
|
196
|
+
1. Switch to the provider: `/model <provider>`
|
|
197
|
+
2. Send a test message
|
|
198
|
+
3. Show provider-specific commands (quotas, usage, balance)
|
|
199
|
+
4. If the provider has tools (web search), use them
|
|
200
|
+
5. Switch back to default provider
|
|
201
|
+
|
|
202
|
+
### Themes
|
|
203
|
+
|
|
204
|
+
Themes don't need Northwind. Just switch themes and write a code file for syntax highlighting.
|
|
205
|
+
|
|
206
|
+
## Output
|
|
207
|
+
|
|
208
|
+
After creating the demo directory, print the path and instructions:
|
|
209
|
+
|
|
210
|
+
```
|
|
211
|
+
Demo ready at: <path>
|
|
212
|
+
|
|
213
|
+
cd <path>/northwind
|
|
214
|
+
pi
|
|
215
|
+
|
|
216
|
+
Then type /<demo-name> to start.
|
|
217
|
+
```
|