pi-baton 0.2.2
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 +51 -0
- package/LICENSE +21 -0
- package/README.md +116 -0
- package/agents/reviewer.md +15 -0
- package/agents/worker.md +12 -0
- package/docs/examples.md +49 -0
- package/docs/github-template.md +63 -0
- package/docs/release.md +57 -0
- package/docs/repository-settings.md +43 -0
- package/docs/template-checklist.md +140 -0
- package/docs/typescript.md +77 -0
- package/extensions/index.ts +191 -0
- package/lib/agents.ts +133 -0
- package/lib/handoff.ts +81 -0
- package/lib/kebab-case.ts +8 -0
- package/lib/model-routing.ts +14 -0
- package/lib/paths.ts +63 -0
- package/lib/review-contract.ts +85 -0
- package/lib/run-engine.ts +283 -0
- package/lib/run-store.ts +136 -0
- package/lib/run-ui.ts +51 -0
- package/lib/run-widget.ts +110 -0
- package/lib/schema.ts +8 -0
- package/lib/status.ts +15 -0
- package/lib/subagent-runner.ts +181 -0
- package/lib/types.ts +117 -0
- package/lib/workflow-discovery.ts +62 -0
- package/lib/workflow-scaffold.ts +92 -0
- package/lib/workflow-schema.ts +154 -0
- package/package.json +63 -0
- package/workflows/default-review-loop.yaml +49 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
This project follows semantic versioning.
|
|
6
|
+
|
|
7
|
+
## [0.2.2] - 2026-06-13
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Live Baton run widget above the editor during `/baton:run`, showing workflow, brief, active step, agent, judgment, and step checklist.
|
|
12
|
+
- Footer status line (`baton: implement`, `baton: review`, etc.) while a run is in progress.
|
|
13
|
+
|
|
14
|
+
## [0.2.1] - 2026-06-13
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- Ship builtin `worker` and `reviewer` subagent definitions so `default-review-loop` runs without pre-created `.pi/agents/` files.
|
|
19
|
+
- Validate required workflow agents during `/baton:start` and `/baton:run` with clearer missing-agent errors.
|
|
20
|
+
|
|
21
|
+
## [0.2.0] - 2026-06-13
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
|
|
25
|
+
- `/baton:new`, `/baton:start`, `/baton:run`, and `/baton:status` command surface.
|
|
26
|
+
- Builtin `default-review-loop` workflow with `worker` / `reviewer` / `worker` agent mapping.
|
|
27
|
+
- YAML workflow discovery, inline validation, scaffold generation, and run persistence under `.pi/baton/`.
|
|
28
|
+
- Isolated subagent step execution with structured handoff, review contract enforcement, and per-step model routing.
|
|
29
|
+
|
|
30
|
+
## [0.1.2] - 2026-06-04
|
|
31
|
+
|
|
32
|
+
### Changed
|
|
33
|
+
|
|
34
|
+
- README and `docs/template-checklist.md` now follow the Pi OSS minimal-docs policy: `docs/` is optional, with explicit post-generation cleanup for template bootstrap docs.
|
|
35
|
+
- Template bootstrap docs (`github-template.md`, `repository-settings.md`, `typescript.md`) are labeled for delete-or-merge after setup.
|
|
36
|
+
|
|
37
|
+
## [0.1.1] - 2026-06-01
|
|
38
|
+
|
|
39
|
+
### Changed
|
|
40
|
+
|
|
41
|
+
- Publish workflow now supports npm publishing on merged package version bumps in addition to tags, releases, and manual dispatch.
|
|
42
|
+
- Publish workflow now installs a current npm CLI so npm Trusted Publishing OIDC is supported.
|
|
43
|
+
- CI and publish workflow commands no longer include literal trailing `\\n` text.
|
|
44
|
+
|
|
45
|
+
## [0.1.0] - YYYY-MM-DD
|
|
46
|
+
|
|
47
|
+
### Added
|
|
48
|
+
|
|
49
|
+
- Initial Pi package template.
|
|
50
|
+
- Example extension, Agent Skill, prompt, and theme.
|
|
51
|
+
- CI and npm Trusted Publishing workflow.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 YOUR_NAME
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# Pi Baton
|
|
2
|
+
|
|
3
|
+
[](https://github.com/eiei114/pi-baton/actions/workflows/ci.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/pi-baton)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](https://pi.dev/packages)
|
|
7
|
+
|
|
8
|
+
> Run YAML-defined review loops in Pi with per-step model switching and isolated step context.
|
|
9
|
+
|
|
10
|
+
## What this is
|
|
11
|
+
|
|
12
|
+
Pi Baton is a Pi-native workflow baton runner. Define `implement → review → fix` loops in YAML, and let Pi Baton execute them with automatic baton handoff between isolated subagent steps.
|
|
13
|
+
|
|
14
|
+
- **Per-step model switching** — fast model for implement, strong model for review
|
|
15
|
+
- **Isolated step context** — no shared conversation pollution between steps
|
|
16
|
+
- **Structured review contract** — `accept`/`reject` with mandatory findings or acceptance notes
|
|
17
|
+
- **Live progress widget** — see which step is running, its agent, and judgment in real time
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pi install npm:pi-baton
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Project-local:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pi install npm:pi-baton -l
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
GitHub:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pi install git:github.com/eiei114/pi-baton
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Quick start
|
|
38
|
+
|
|
39
|
+
```txt
|
|
40
|
+
/baton:new create a workflow scaffold
|
|
41
|
+
/baton:start choose workflow + task brief → idle run
|
|
42
|
+
/baton:run execute run to terminal state (with live widget)
|
|
43
|
+
/baton:status show the active run summary
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The builtin `Default Review Loop` workflow (implement → review → fix) works out of the box — no agent setup required.
|
|
47
|
+
|
|
48
|
+
## Prerequisites
|
|
49
|
+
|
|
50
|
+
Pi Baton ships builtin `worker` and `reviewer` subagents under `agents/`. They work with your current Pi model.
|
|
51
|
+
|
|
52
|
+
To override with custom agents, place `.md` files under:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
.pi/agents/worker.md
|
|
56
|
+
.pi/agents/reviewer.md
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Discovery order: project `.pi/agents/` → user `~/.pi/agent/agents/` → pi-baton builtin.
|
|
60
|
+
|
|
61
|
+
## Workflow authoring
|
|
62
|
+
|
|
63
|
+
```txt
|
|
64
|
+
/baton:new
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Pick a name and a scaffold from `default-review-loop` is written to `.pi/baton/workflows/` and opened in editor. The scaffold includes `<your-fast-model>` / `<your-strong-model>` placeholders for step-level model overrides.
|
|
68
|
+
|
|
69
|
+
### Workflow YAML reference
|
|
70
|
+
|
|
71
|
+
```yaml
|
|
72
|
+
name: My Review Loop
|
|
73
|
+
iteration_cap: 5
|
|
74
|
+
steps:
|
|
75
|
+
implement:
|
|
76
|
+
agent: worker
|
|
77
|
+
model: openai/gpt-5.4 # optional: fast model
|
|
78
|
+
prompt: work prompt
|
|
79
|
+
next: review
|
|
80
|
+
review:
|
|
81
|
+
agent: reviewer
|
|
82
|
+
model: anthropic/claude-opus-4-5 # optional: strong model
|
|
83
|
+
prompt: review prompt
|
|
84
|
+
on_accept: _complete # or a step name
|
|
85
|
+
on_reject: fix
|
|
86
|
+
fix:
|
|
87
|
+
agent: worker
|
|
88
|
+
model: openai/gpt-5.4
|
|
89
|
+
prompt: fix prompt
|
|
90
|
+
next: review
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
- `on_accept: _complete` ends the run.
|
|
94
|
+
- `iteration_cap` prevents infinite review loops — the run fails at the cap.
|
|
95
|
+
- Review agents must return `accept`/`reject` with findings or acceptance notes.
|
|
96
|
+
|
|
97
|
+
## Package contents
|
|
98
|
+
|
|
99
|
+
| Path | Purpose |
|
|
100
|
+
|---|---|
|
|
101
|
+
| `extensions/` | 4 slash-command entrypoint (`/baton:new`, `/baton:start`, `/baton:run`, `/baton:status`) |
|
|
102
|
+
| `lib/` | Workflow parser, run engine, subagent runner, review contract, UI widget |
|
|
103
|
+
| `agents/` | Builtin `worker` and `reviewer` subagent definitions |
|
|
104
|
+
| `workflows/` | Builtin `default-review-loop.yaml` |
|
|
105
|
+
| `docs/` | Release docs |
|
|
106
|
+
|
|
107
|
+
## Development
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
npm install
|
|
111
|
+
npm run ci
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## License
|
|
115
|
+
|
|
116
|
+
MIT
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: reviewer
|
|
3
|
+
description: Baton review subagent for structured accept/reject judgments
|
|
4
|
+
tools: read, grep, find, ls, bash
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are the reviewer step agent in a Pi Baton review loop.
|
|
8
|
+
|
|
9
|
+
Review the implementation against the task brief. Bash is for read-only inspection only (`git diff`, `git log`, `git show`).
|
|
10
|
+
|
|
11
|
+
Return a structured judgment using the JSON contract in the task prompt:
|
|
12
|
+
- `accept` requires a non-empty `acceptanceNote`
|
|
13
|
+
- `reject` requires non-empty `findings`
|
|
14
|
+
|
|
15
|
+
Be specific and actionable. Include file paths and line numbers when possible.
|
package/agents/worker.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: worker
|
|
3
|
+
description: General-purpose Baton implement/fix subagent with repository tool access
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
You are the worker step agent in a Pi Baton review loop.
|
|
7
|
+
|
|
8
|
+
Work autonomously in an isolated context. Use repository tools to implement or fix the assigned task.
|
|
9
|
+
|
|
10
|
+
Keep changes focused. Prefer small, reviewable diffs.
|
|
11
|
+
|
|
12
|
+
When finished, follow the workflow JSON contract in the task prompt.
|
package/docs/examples.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Examples
|
|
2
|
+
|
|
3
|
+
This template ships one minimal example for each Pi package resource type.
|
|
4
|
+
|
|
5
|
+
## Extension
|
|
6
|
+
|
|
7
|
+
`extensions/hello.ts` registers:
|
|
8
|
+
|
|
9
|
+
- `/template-hello`
|
|
10
|
+
- a small session status indicator
|
|
11
|
+
|
|
12
|
+
Try it with:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pi -e .
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Then run:
|
|
19
|
+
|
|
20
|
+
```txt
|
|
21
|
+
/template-hello YourName
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Agent Skill
|
|
25
|
+
|
|
26
|
+
`skills/example-skill/SKILL.md` demonstrates a minimal Agent Skill.
|
|
27
|
+
|
|
28
|
+
Replace it with your real workflow instructions.
|
|
29
|
+
|
|
30
|
+
## Prompt template
|
|
31
|
+
|
|
32
|
+
`prompts/example.md` demonstrates a tiny prompt template with one variable.
|
|
33
|
+
|
|
34
|
+
## Theme
|
|
35
|
+
|
|
36
|
+
`themes/example-theme.json` is a placeholder theme. Replace it or remove `themes/` if your package does not ship themes.
|
|
37
|
+
|
|
38
|
+
## Typed custom tool
|
|
39
|
+
|
|
40
|
+
`extensions/index.ts` registers:
|
|
41
|
+
|
|
42
|
+
- `/template-info`
|
|
43
|
+
- `template_greet` custom tool
|
|
44
|
+
|
|
45
|
+
The tool demonstrates:
|
|
46
|
+
|
|
47
|
+
- TypeBox object parameters
|
|
48
|
+
- a string enum schema via `StringEnum`
|
|
49
|
+
- shared logic imported from `lib/greeting.ts`
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# GitHub Template Repository
|
|
2
|
+
|
|
3
|
+
> **Template bootstrap doc.** Use while setting up a new repo from this template. Delete this file or merge any project-specific steps into README / Vault notes once setup is done, unless it still adds maintainer value.
|
|
4
|
+
|
|
5
|
+
## Recommended development flow
|
|
6
|
+
|
|
7
|
+
After generating a repo from this template, use this default order:
|
|
8
|
+
|
|
9
|
+
```txt
|
|
10
|
+
Vault notes -> PRD -> Issues -> implement -> ci/check -> release -> save learnings
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
In practice:
|
|
14
|
+
|
|
15
|
+
1. Create Vault notes under `4_Project/<ProjectName>/`.
|
|
16
|
+
2. Add `CONTEXT.md`, `README.md`, `ROADMAP.md`, `Docs/`, `Issues/`, and `Progress/`.
|
|
17
|
+
3. Write the PRD in `Docs/`.
|
|
18
|
+
4. Split approved issue files into `Issues/`.
|
|
19
|
+
5. Implement in the OSS repo created from this template.
|
|
20
|
+
6. Run CI and package checks before release.
|
|
21
|
+
7. Save release notes and follow-up decisions back to the Vault project.
|
|
22
|
+
|
|
23
|
+
Enable template mode on the source repository:
|
|
24
|
+
|
|
25
|
+
```txt
|
|
26
|
+
GitHub repo → Settings → General → Template repository
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Create a public repository from the template:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
gh repo create OWNER/new-pi-extension \
|
|
33
|
+
--public \
|
|
34
|
+
--template OWNER/pi-extension-template \
|
|
35
|
+
--clone
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Create a private repository from the template:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
gh repo create OWNER/new-pi-extension \
|
|
42
|
+
--private \
|
|
43
|
+
--template OWNER/pi-extension-template \
|
|
44
|
+
--clone
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Include all branches if needed:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
gh repo create OWNER/new-pi-extension \
|
|
51
|
+
--public \
|
|
52
|
+
--template OWNER/pi-extension-template \
|
|
53
|
+
--include-all-branches \
|
|
54
|
+
--clone
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
After creation:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
cd new-pi-extension
|
|
61
|
+
npm install
|
|
62
|
+
npm run ci
|
|
63
|
+
```\n
|
package/docs/release.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Release
|
|
2
|
+
|
|
3
|
+
This package uses npm Trusted Publishing with GitHub Actions OIDC.
|
|
4
|
+
|
|
5
|
+
Do not add `NPM_TOKEN` or long-lived npm tokens to GitHub Secrets.
|
|
6
|
+
|
|
7
|
+
## One-time npm setup
|
|
8
|
+
|
|
9
|
+
On npmjs.com, configure Trusted Publishing for this package:
|
|
10
|
+
|
|
11
|
+
- Publisher: GitHub Actions
|
|
12
|
+
- Repository: this GitHub repository
|
|
13
|
+
- Workflow filename: `publish.yml`
|
|
14
|
+
|
|
15
|
+
## Publish
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm version patch
|
|
19
|
+
git push
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
On `main`, `.github/workflows/auto-release.yml` checks `package.json` version. If `v<version>` does not exist yet, it creates the tag, creates the GitHub Release, then explicitly dispatches `.github/workflows/publish.yml` for that tag.
|
|
23
|
+
|
|
24
|
+
The `v*.*.*` tag also triggers `.github/workflows/publish.yml`, which runs CI and publishes to npm when tags are pushed manually.
|
|
25
|
+
Publishing also runs when a GitHub Release is published, and can be run manually from GitHub Actions with `workflow_dispatch`.
|
|
26
|
+
|
|
27
|
+
The workflow skips `name@version` if that exact package version already exists on npm.
|
|
28
|
+
|
|
29
|
+
## Workflow guardrail
|
|
30
|
+
|
|
31
|
+
Do not ship a new Pi OSS package or version bump with only `package.json` changes.
|
|
32
|
+
The repository must include the release workflow pair:
|
|
33
|
+
|
|
34
|
+
- `.github/workflows/auto-release.yml` creates `v<version>` tags and GitHub Releases from `main` version bumps.
|
|
35
|
+
- `.github/workflows/publish.yml` publishes to npm through Trusted Publishing.
|
|
36
|
+
|
|
37
|
+
Important: tags or releases created by `GITHUB_TOKEN` do not reliably fan out into another workflow through normal `push.tags` or `release.published` triggers. The template keeps publishing reliable by having `auto-release.yml` explicitly dispatch `publish.yml` after creating the tag/release. If you change the release flow, keep one explicit handoff path: `workflow_dispatch` from auto-release, `repository_dispatch`, or `workflow_run` on the auto-release workflow.
|
|
38
|
+
|
|
39
|
+
## GitHub Actions requirements
|
|
40
|
+
|
|
41
|
+
- `permissions: id-token: write`
|
|
42
|
+
- `permissions: actions: write` on auto-release so it can dispatch `publish.yml`
|
|
43
|
+
- `auto-release.yml` must call `gh workflow run publish.yml --ref "$TAG" -f ref="$TAG"`, or `publish.yml` must have an equivalent explicit handoff trigger such as `workflow_run`
|
|
44
|
+
- GitHub-hosted runner
|
|
45
|
+
- Node.js 24, so the release job uses a current npm CLI for Trusted Publishing
|
|
46
|
+
- No `NPM_TOKEN`
|
|
47
|
+
- `npm publish` from the configured workflow file
|
|
48
|
+
|
|
49
|
+
## First release checklist
|
|
50
|
+
|
|
51
|
+
- [ ] `package.json` name is final
|
|
52
|
+
- [ ] `repository.url` points to the real GitHub repository
|
|
53
|
+
- [ ] npm Trusted Publisher is configured
|
|
54
|
+
- [ ] `npm run ci` passes
|
|
55
|
+
- [ ] `npm pack --dry-run` contains only intended files
|
|
56
|
+
- [ ] CHANGELOG.md has the release date
|
|
57
|
+
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Repository Settings
|
|
2
|
+
|
|
3
|
+
> **Template bootstrap doc.** Use while configuring GitHub About, topics, and branch protection after generating a repo. Delete this file or merge needed settings into README once setup is done, unless it still adds maintainer value.
|
|
4
|
+
|
|
5
|
+
Use this file after creating a real repository from the template.
|
|
6
|
+
|
|
7
|
+
## GitHub About
|
|
8
|
+
|
|
9
|
+
Suggested fields:
|
|
10
|
+
|
|
11
|
+
- Description: one-line pitch for the Pi package
|
|
12
|
+
- Website: npm package URL or project docs URL
|
|
13
|
+
- Topics:
|
|
14
|
+
- `pi`
|
|
15
|
+
- `pi-package`
|
|
16
|
+
- `agent-skill`
|
|
17
|
+
- `typescript`
|
|
18
|
+
|
|
19
|
+
## Template mode
|
|
20
|
+
|
|
21
|
+
If this repository itself should be reusable as a template:
|
|
22
|
+
|
|
23
|
+
```txt
|
|
24
|
+
Settings → General → Template repository
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Branch protection
|
|
28
|
+
|
|
29
|
+
Recommended for public packages:
|
|
30
|
+
|
|
31
|
+
- Require pull request before merging
|
|
32
|
+
- Require status checks to pass
|
|
33
|
+
- Require `CI` workflow
|
|
34
|
+
- Block force pushes on the default branch
|
|
35
|
+
|
|
36
|
+
## npm package page
|
|
37
|
+
|
|
38
|
+
After first publish:
|
|
39
|
+
|
|
40
|
+
- Confirm README renders correctly
|
|
41
|
+
- Confirm package provenance appears
|
|
42
|
+
- Confirm package contents are intentional
|
|
43
|
+
- Add npm URL to GitHub About and README
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# Template Setup Checklist
|
|
2
|
+
|
|
3
|
+
このテンプレートから新しい Pi 拡張OSSを作った後に埋めること。
|
|
4
|
+
|
|
5
|
+
## Recommended flow
|
|
6
|
+
|
|
7
|
+
- [ ] Vault project notes を `4_Project/<ProjectName>/` に作る
|
|
8
|
+
- [ ] `CONTEXT.md` / `README.md` / `ROADMAP.md` / `Docs/` / `Issues/` / `Progress/` を揃える
|
|
9
|
+
- [ ] PRD を `4_Project/<ProjectName>/Docs/` に置く
|
|
10
|
+
- [ ] approved issue を `4_Project/<ProjectName>/Issues/` に切る
|
|
11
|
+
- [ ] OSS repo 側で実装する
|
|
12
|
+
- [ ] `npm run ci` / `npm test` / `npm pack --dry-run` を通す
|
|
13
|
+
- [ ] release 後に Vault へ learnings / release notes を戻す
|
|
14
|
+
|
|
15
|
+
## Repository
|
|
16
|
+
|
|
17
|
+
- [ ] GitHub repository name を決める
|
|
18
|
+
- [ ] GitHub About 欄を書く
|
|
19
|
+
- [ ] GitHub topics を設定する
|
|
20
|
+
- [ ] `pi`
|
|
21
|
+
- [ ] `pi-package`
|
|
22
|
+
- [ ] `agent-skill`
|
|
23
|
+
- [ ] `typescript`
|
|
24
|
+
- [ ] GitHub Settingsで `Template repository` をONにする
|
|
25
|
+
- [ ] Repository URL を `package.json` に反映する
|
|
26
|
+
- [ ] README の `OWNER/REPO` を実リポジトリに置き換える
|
|
27
|
+
|
|
28
|
+
## Package metadata
|
|
29
|
+
|
|
30
|
+
- [ ] `package.json` の `name` を変更する
|
|
31
|
+
- [ ] `description` を書く
|
|
32
|
+
- [ ] `author` を入れる
|
|
33
|
+
- [ ] `repository.url` を埋める
|
|
34
|
+
- [ ] `bugs.url` を埋める
|
|
35
|
+
- [ ] `homepage` を埋める
|
|
36
|
+
- [ ] `keywords` を見直す
|
|
37
|
+
- [ ] `LICENSE` の年・名前を更新する
|
|
38
|
+
|
|
39
|
+
## README placeholders
|
|
40
|
+
|
|
41
|
+
- [ ] `PACKAGE_DISPLAY_NAME` を置き換える
|
|
42
|
+
- [ ] `PACKAGE_NAME` を置き換える
|
|
43
|
+
- [ ] `OWNER/REPO` を置き換える
|
|
44
|
+
- [ ] one-line pitch を書く
|
|
45
|
+
- [ ] feature list を書く
|
|
46
|
+
- [ ] quick start command を実コマンドにする
|
|
47
|
+
- [ ] npm URL を確認する
|
|
48
|
+
- [ ] GitHub URL を確認する
|
|
49
|
+
|
|
50
|
+
## Pi package manifest
|
|
51
|
+
|
|
52
|
+
- [ ] `pi.extensions` に公開する拡張だけを残す
|
|
53
|
+
- [ ] `pi.skills` に公開する skill だけを残す
|
|
54
|
+
- [ ] 不要なら `prompts/` を消す
|
|
55
|
+
- [ ] 不要なら `themes/` を消す
|
|
56
|
+
- [ ] サンプル名を実名に変える
|
|
57
|
+
|
|
58
|
+
## Documentation
|
|
59
|
+
|
|
60
|
+
`docs/` は固定6ファイル必須ではない。README を正とし、価値がある doc だけ残す。
|
|
61
|
+
|
|
62
|
+
### Required root files (public)
|
|
63
|
+
|
|
64
|
+
- [ ] `README.md` — GitHub/npm の入口。Install / Quick start / Release / Security を含める
|
|
65
|
+
- [ ] `LICENSE`
|
|
66
|
+
- [ ] `SECURITY.md`
|
|
67
|
+
- [ ] `CHANGELOG.md`
|
|
68
|
+
- [ ] Release 手順が README と workflow で明確(Trusted Publishing 設定含む)
|
|
69
|
+
|
|
70
|
+
### Recommended public docs (keep when useful)
|
|
71
|
+
|
|
72
|
+
- [ ] `docs/examples.md` — 例が README に載り切らないとき
|
|
73
|
+
- [ ] `docs/release.md` — Trusted Publishing や release 手順の詳細が README だけでは足りないとき
|
|
74
|
+
- [ ] `docs/usage.md` — 使い方が README に載り切らないとき(必要なら新規作成)
|
|
75
|
+
|
|
76
|
+
### Optional maintainer docs
|
|
77
|
+
|
|
78
|
+
- [ ] `docs/template-checklist.md` — このファイル。成熟 repo では README からの主ナビにしない。不要なら削除可
|
|
79
|
+
|
|
80
|
+
### Post-generation cleanup (delete or merge template setup docs)
|
|
81
|
+
|
|
82
|
+
テンプレート生成直後の bootstrap 用。プロジェクト固有の価値がなければ削除し、必要な内容は README / `docs/release.md` / `docs/examples.md` に統合する。
|
|
83
|
+
|
|
84
|
+
- [ ] `docs/github-template.md` を削除するか、固有の手順だけ README / Vault に移す
|
|
85
|
+
- [ ] `docs/repository-settings.md` を削除するか、About/topics など必要分だけ README に移す
|
|
86
|
+
- [ ] `docs/typescript.md` を削除するか、TypeScript 方針は README Development に要約する
|
|
87
|
+
- [ ] README の Docs 節から、削除したファイルへのリンクを外す
|
|
88
|
+
- [ ] `package.json` の `files` から、削除した `docs/` パスを外す(残す doc だけ明示する)
|
|
89
|
+
|
|
90
|
+
## TypeScript
|
|
91
|
+
|
|
92
|
+
- [ ] `extensions/index.ts` を実装に合わせて更新する
|
|
93
|
+
- [ ] `extensions/hello.ts` が不要なら削除する
|
|
94
|
+
- [ ] 共通ロジックを `lib/` に切り出す
|
|
95
|
+
- [ ] `strict: true` を維持する
|
|
96
|
+
- [ ] custom tool parameters は TypeBox schema で定義する
|
|
97
|
+
- [ ] string choices は `StringEnum` helper を使う
|
|
98
|
+
- [ ] runtime dependency は `dependencies`、Pi提供packageは `peerDependencies` に置く
|
|
99
|
+
- [ ] `package.json.files` に公開対象だけを入れる
|
|
100
|
+
- [ ] 詳細はセットアップ中だけ `docs/typescript.md` を参照し、不要なら post-generation cleanup で削除
|
|
101
|
+
|
|
102
|
+
## GitHub Template repo
|
|
103
|
+
|
|
104
|
+
- [ ] `gh repo create --template OWNER/pi-extension-template` で作成できることを確認する
|
|
105
|
+
- [ ] public/privateどちらの作成例もdocsに載せる(`docs/github-template.md` を残す場合)
|
|
106
|
+
|
|
107
|
+
## CI / Release
|
|
108
|
+
|
|
109
|
+
- [ ] `npm run ci` が通る
|
|
110
|
+
- [ ] `npm pack --dry-run` が通る
|
|
111
|
+
- [ ] npm Trusted Publishing を設定する
|
|
112
|
+
- [ ] npm Trusted Publisher の workflow filename が `publish.yml` になっている
|
|
113
|
+
- [ ] `NPM_TOKEN` を使っていないことを確認する
|
|
114
|
+
- [ ] `auto-release.yml` が `main` の version bump から tag/release を作ることを確認する
|
|
115
|
+
- [ ] `publish.yml` が `workflow_dispatch` と `release.published` に対応していることを確認する
|
|
116
|
+
- [ ] 初回リリースで npm provenance が付いているか確認する
|
|
117
|
+
|
|
118
|
+
### Workflow handoff guard
|
|
119
|
+
|
|
120
|
+
- [ ] `.github/workflows/auto-release.yml` exists before first release
|
|
121
|
+
- [ ] `.github/workflows/publish.yml` exists before first release
|
|
122
|
+
- [ ] `auto-release.yml` has `permissions: actions: write` and `contents: write`
|
|
123
|
+
- [ ] `publish.yml` has `permissions: id-token: write` for npm Trusted Publishing
|
|
124
|
+
- [ ] Auto release explicitly hands off to publish: `gh workflow run publish.yml --ref "$TAG" -f ref="$TAG"`, or `publish.yml` has an equivalent `workflow_run` / `repository_dispatch` trigger
|
|
125
|
+
- [ ] Do not rely only on `push.tags` or `release.published` when the tag/release is created by `GITHUB_TOKEN`; that can leave npm unchanged after merge
|
|
126
|
+
|
|
127
|
+
## npm page
|
|
128
|
+
|
|
129
|
+
- [ ] npm package URL を README に追加する
|
|
130
|
+
- [ ] npm description が適切に表示されるか確認する
|
|
131
|
+
- [ ] provenance が付いているか確認する
|
|
132
|
+
- [ ] 不要なファイルが package に含まれていないか確認する(`npm pack --dry-run` で `docs/` の残し方も確認)
|
|
133
|
+
|
|
134
|
+
## Before first release
|
|
135
|
+
|
|
136
|
+
- [ ] サンプルコードを実機 Pi でロードする
|
|
137
|
+
- [ ] `pi install git:github.com/OWNER/REPO` を試す
|
|
138
|
+
- [ ] `pi -e .` を試す
|
|
139
|
+
- [ ] README のコマンドがコピペで動くか確認する
|
|
140
|
+
- [ ] CHANGELOG に `0.1.0` を書く
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# TypeScript Guide
|
|
2
|
+
|
|
3
|
+
> **Template bootstrap doc.** Use while learning this template's TypeScript layout and dependency rules. Delete this file or summarize the policies you keep in README Development once setup is done, unless it still adds maintainer value.
|
|
4
|
+
|
|
5
|
+
This is a TypeScript-first Pi package template.
|
|
6
|
+
|
|
7
|
+
## Layout
|
|
8
|
+
|
|
9
|
+
```txt
|
|
10
|
+
extensions/*.ts Pi extension entrypoints
|
|
11
|
+
lib/*.ts Shared TypeScript helpers
|
|
12
|
+
skills/*/SKILL.md Agent Skills
|
|
13
|
+
prompts/*.md Prompt templates
|
|
14
|
+
themes/*.json Themes
|
|
15
|
+
tests/*.test.mjs Smoke tests
|
|
16
|
+
tests/*.test.ts Optional TypeScript tests if you add a TS test runner
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Pi loads TypeScript extensions directly, so no build step is required for normal use.
|
|
20
|
+
|
|
21
|
+
## Strict mode
|
|
22
|
+
|
|
23
|
+
`tsconfig.json` keeps `strict: true`. Prefer fixing types over loosening compiler options.
|
|
24
|
+
|
|
25
|
+
## Extension entrypoints
|
|
26
|
+
|
|
27
|
+
Two entrypoint styles are shown:
|
|
28
|
+
|
|
29
|
+
- `extensions/hello.ts`: single-file extension
|
|
30
|
+
- `extensions/index.ts`: index-style extension that imports shared code from `lib/`
|
|
31
|
+
|
|
32
|
+
For larger packages, keep entrypoints thin and put reusable logic in `lib/`.
|
|
33
|
+
|
|
34
|
+
## TypeBox schemas
|
|
35
|
+
|
|
36
|
+
Use TypeBox schemas for custom tool parameters.
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { Type } from "typebox";
|
|
40
|
+
|
|
41
|
+
const parameters = Type.Object({
|
|
42
|
+
name: Type.String({ description: "Name to greet" }),
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## String enums
|
|
47
|
+
|
|
48
|
+
For string choices, use the local `StringEnum` helper from `lib/schema.ts`.
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import { StringEnum } from "../lib/schema.ts";
|
|
52
|
+
|
|
53
|
+
const mode = StringEnum(["short", "friendly"], {
|
|
54
|
+
description: "Greeting style",
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
This emits a JSON Schema `enum`, which is friendlier to model providers than a union of string literals.
|
|
59
|
+
|
|
60
|
+
## Runtime dependencies vs peer dependencies
|
|
61
|
+
|
|
62
|
+
Pi bundles core packages for extension authors. Keep Pi-provided packages as `peerDependencies` and also install them as `devDependencies` for local typechecking.
|
|
63
|
+
|
|
64
|
+
Use `peerDependencies` for:
|
|
65
|
+
|
|
66
|
+
- `@earendil-works/pi-coding-agent`
|
|
67
|
+
- `@earendil-works/pi-ai`
|
|
68
|
+
- `@earendil-works/pi-tui`
|
|
69
|
+
- `typebox`
|
|
70
|
+
|
|
71
|
+
Use `dependencies` for runtime packages your extension imports that Pi does not provide.
|
|
72
|
+
|
|
73
|
+
Use `devDependencies` for local-only tools such as TypeScript, test runners, and linters.
|
|
74
|
+
|
|
75
|
+
## Package contents
|
|
76
|
+
|
|
77
|
+
Control npm package contents with `package.json` `files`. Prefer this over `.npmignore` so the published package stays explicit.
|