| name | pi-package-manager |
| description | Manage pi-packages in the 0xKobold monorepo. Use when creating new packages, syncing with individual repos, publishing to npm, or checking package compliance with pi-package standards. |
pi-package-manager Skill
Manages the bidirectional sync between the 0xKobold monorepo and individual pi-package repos on GitHub.
Architecture Overview
0xKobold Monorepo
├── packages/
│ ├── pi-learn/ ← Develop here
│ ├── pi-ollama/ ← Develop here
│ └── ... ← All pi-packages
├── .github/workflows/
│ ├── publish.yml ← Push monorepo → individual repos + npm
│ └── sync-from-individual.yml ← Pull individual repos → monorepo
└── scripts/
└── sync-packages.sh ← Manual sync script
Core Workflows
1. Develop in Monorepo → Auto-publish to Individual Repos
When you merge to main:
- CI detects changes in
packages/pi-*/
- Extracts package using
git subtree split
- Pushes to
git@github.com:0xKobold/<package>.git
- Publishes to npm (if version bumped)
Files changed: .github/workflows/publish.yml
2. External Contributions → Sync Back to Monorepo
When someone PRs to an individual repo:
- CI runs hourly (cron:
0 * * * *)
- Fetches all individual repos
- Uses
git subtree pull to merge changes
- Creates PR to monorepo for review
Files changed: .github/workflows/sync-from-individual.yml
Common Tasks
Check Package Status
Run this before starting any work:
ls packages/pi-*/package.json
for pkg in packages/pi-*/; do
name=$(basename "$pkg")
repo_exists=$(curl -s -o /dev/null -w "%{http_code}" \
"https://api.github.com/repos/0xKobold/$name")
echo "$name: $repo_exists"
done
Create a New pi-package
Prerequisites:
- Package must be in
packages/pi-<name>/
- Must have
package.json with:
"keywords": ["pi-package"]
"pi": { "extensions": [...] }
"prepublishOnly": "rm -rf dist && tsc" script
"repository" pointing to individual repo
Steps:
mkdir -p packages/pi-myextension/src
cat > packages/pi-myextension/package.json << 'EOF'
{
"name": "@0xkobold/pi-myextension",
"version": "0.1.0",
"keywords": ["pi-package"],
"pi": {
"extensions": ["./src/index.ts"]
},
"scripts": {
"prepublishOnly": "rm -rf dist && tsc"
},
"peerDependencies": {
"@mariozechner/pi-coding-agent": ">=0.6.0"
}
}
EOF
gh repo create 0xKobold/pi-myextension --public
cd packages/pi-myextension
git init -b main
git remote add origin git@github.com:0xKobold/pi-myextension.git
git add .
git commit -m "Initial commit"
git push -u origin main
cd -
Sync a Package Manually
Use the sync script for one-off syncs:
./scripts/sync-packages.sh
git subtree pull \
--prefix=packages/pi-learn \
git@github.com:0xKobold/pi-learn.git \
main \
--squash \
-m "sync: pull pi-learn from individual repo"
Trigger CI Sync
To push monorepo changes to individual repos:
git push origin main
gh workflow run publish.yml --ref main
gh workflow run publish.yml \
--field package=pi-learn
To trigger sync from individual repos:
gh workflow run sync-from-individual.yml
gh workflow run sync-from-individual.yml \
--field package=pi-ollama
Publish to npm
-
Version bump in the package directory:
cd packages/pi-learn
npm version patch
cd -
git add packages/pi-learn/package.json
git commit -m "chore: bump pi-learn to v0.x.x"
-
Create GitHub release (triggers npm publish):
gh release create v0.x.x \
--title "Release v0.x.x" \
--notes "Release notes here"
-
Or trigger publish.yml directly:
gh workflow run publish.yml
Package Checklist
When creating or reviewing a pi-package, ensure:
File Reference
| File | Purpose |
|---|
.github/workflows/publish.yml | Push monorepo → individual + npm |
.github/workflows/sync-from-individual.yml | Pull individual → monorepo |
scripts/sync-packages.sh | Manual sync helper |
packages/.gitignore | Excludes node_modules/dist from commits |
Troubleshooting
"fatal: couldn't find remote ref refs/heads/main"
Individual repo has no main branch. Push to it first:
cd packages/pi-<name>
git init -b main
git remote add origin git@github.com:0xKobold/pi-<name>.git
git add .
git commit -m "Initial commit"
git push -u origin main
"subtree push" failed
Check that the individual repo exists and you have access:
gh repo view 0xKobold/pi-<name>
Package not publishing to npm
- Check
NPM_TOKEN secret is set in GitHub repo
- Verify version was bumped (npm won't republish same version)
- Check workflow logs at: GitHub repo → Actions → publish.yml
Sync conflicts
If subtree pull has conflicts:
git status
git add <resolved-files>
git commit -m "resolve: sync conflicts"
git subtree pull --prefix=packages/<pkg> <remote> main --squash
Best Practices
- Develop in monorepo - Easier to test integrations
- Sync often - Run sync script or let CI handle it
- Version bump before release - Prevents npm conflicts
- Test before commit - Always
bun run build in package dir
- Keep package.json consistent - Same structure across all packages
- Use prepublishOnly - Prevents ghost files in npm package