pi-producthunt 0.1.1
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 +21 -0
- package/LICENSE +21 -0
- package/README.md +171 -0
- package/docs/examples.md +49 -0
- package/docs/github-template.md +61 -0
- package/docs/release.md +45 -0
- package/docs/repository-settings.md +41 -0
- package/docs/template-checklist.md +98 -0
- package/docs/typescript.md +75 -0
- package/extensions/index.ts +295 -0
- package/lib/api.ts +110 -0
- package/lib/auth-store.ts +68 -0
- package/lib/client.ts +265 -0
- package/lib/config.ts +61 -0
- package/lib/format.ts +154 -0
- package/lib/identity.ts +56 -0
- package/lib/queries.ts +89 -0
- package/lib/schema.ts +8 -0
- package/lib/types.ts +79 -0
- package/package.json +61 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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.1.1] - 2026-06-01
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- Publish workflow now supports npm publishing on merged package version bumps in addition to tags, releases, and manual dispatch.
|
|
12
|
+
- Publish workflow now installs a current npm CLI so npm Trusted Publishing OIDC is supported.
|
|
13
|
+
- CI and publish workflow commands no longer include literal trailing `\\n` text.
|
|
14
|
+
|
|
15
|
+
## [0.1.0] - YYYY-MM-DD
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- Initial Pi package template.
|
|
20
|
+
- Example extension, Agent Skill, prompt, and theme.
|
|
21
|
+
- 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,171 @@
|
|
|
1
|
+
# Pi Product Hunt
|
|
2
|
+
|
|
3
|
+
[](https://github.com/eiei114/pi-producthunt/actions/workflows/ci.yml)
|
|
4
|
+
[](https://github.com/eiei114/pi-producthunt/actions/workflows/publish.yml)
|
|
5
|
+
[](https://www.npmjs.com/package/pi-producthunt)
|
|
6
|
+
[](https://www.npmjs.com/package/pi-producthunt)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
[](https://pi.dev/packages)
|
|
9
|
+
|
|
10
|
+
> Product Hunt research and digest workflows inside Pi.
|
|
11
|
+
|
|
12
|
+
Pi Product Hunt is a read-only Pi extension package for Product Hunt market research. It calls the Product Hunt GraphQL API directly, adds interactive `/producthunt:*` commands for humans, and exposes structured tools for agents to gather launches, post details, comments, and digest-ready research notes.
|
|
13
|
+
|
|
14
|
+
## Features
|
|
15
|
+
|
|
16
|
+
- Daily Product Hunt launch scans.
|
|
17
|
+
- Product/post search for competitor and trend research.
|
|
18
|
+
- Post detail and comment collection for user-reaction analysis.
|
|
19
|
+
- Digest-ready Markdown with sections for signals, reactions, and watchlists.
|
|
20
|
+
- Persistent login that stores your Product Hunt token in the Pi agent directory.
|
|
21
|
+
- Agent tools with typed parameters for autonomous Product Hunt research.
|
|
22
|
+
|
|
23
|
+
## Install
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pi install npm:pi-producthunt
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Or install from GitHub:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pi install git:github.com/eiei114/pi-producthunt
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Try without installing permanently:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pi -e npm:pi-producthunt
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
For local development from a checkout:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pi -e .
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Authentication
|
|
48
|
+
|
|
49
|
+
Use the interactive login command:
|
|
50
|
+
|
|
51
|
+
```txt
|
|
52
|
+
/producthunt:login
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
This stores your token in:
|
|
56
|
+
|
|
57
|
+
```txt
|
|
58
|
+
~/.pi/agent/pi-producthunt-auth.json
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
You can remove the stored token with:
|
|
62
|
+
|
|
63
|
+
```txt
|
|
64
|
+
/producthunt:logout
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
You can also provide a token through the environment. Environment auth takes priority over the stored login token:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
export PRODUCTHUNT_ACCESS_TOKEN=...
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Commands
|
|
74
|
+
|
|
75
|
+
Commands are human-facing and require no fixed inline arguments. If input is needed, Pi asks interactively.
|
|
76
|
+
|
|
77
|
+
```txt
|
|
78
|
+
/producthunt:status
|
|
79
|
+
/producthunt:login
|
|
80
|
+
/producthunt:logout
|
|
81
|
+
/producthunt:today
|
|
82
|
+
/producthunt:search
|
|
83
|
+
/producthunt:post
|
|
84
|
+
/producthunt:comments
|
|
85
|
+
/producthunt:digest
|
|
86
|
+
/producthunt:research
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Example flows:
|
|
90
|
+
|
|
91
|
+
```txt
|
|
92
|
+
/producthunt:today # today's launch list
|
|
93
|
+
/producthunt:search # asks for a search query
|
|
94
|
+
/producthunt:post # asks for slug, ID, or URL
|
|
95
|
+
/producthunt:comments # asks for slug, ID, or URL
|
|
96
|
+
/producthunt:digest # asks for today / yesterday / custom date
|
|
97
|
+
/producthunt:research # asks for a research topic
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Agent tools
|
|
101
|
+
|
|
102
|
+
Agents can call these typed tools directly:
|
|
103
|
+
|
|
104
|
+
```txt
|
|
105
|
+
producthunt_status
|
|
106
|
+
producthunt_get_posts
|
|
107
|
+
producthunt_search_posts
|
|
108
|
+
producthunt_get_post
|
|
109
|
+
producthunt_get_post_comments
|
|
110
|
+
producthunt_research_topic
|
|
111
|
+
producthunt_digest
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Examples:
|
|
115
|
+
|
|
116
|
+
```txt
|
|
117
|
+
producthunt_search_posts({ query: "AI coding agent", limit: 10 })
|
|
118
|
+
producthunt_get_post({ ref: "example-product-slug" })
|
|
119
|
+
producthunt_get_post_comments({ ref: "example-product-slug", limit: 10 })
|
|
120
|
+
producthunt_digest({ date: "2026-06-01", limit: 10 })
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Package contents
|
|
124
|
+
|
|
125
|
+
| Path | Purpose |
|
|
126
|
+
|---|---|
|
|
127
|
+
| `extensions/` | Pi extension entrypoint and command/tool registration |
|
|
128
|
+
| `lib/` | Product Hunt API client, auth store, formatters, schemas, helpers |
|
|
129
|
+
| `docs/` | Release and package setup docs |
|
|
130
|
+
| `tests/` | Node test suite |
|
|
131
|
+
|
|
132
|
+
## Development
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
npm install
|
|
136
|
+
npm run ci
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
`npm run ci` runs:
|
|
140
|
+
|
|
141
|
+
- TypeScript typecheck
|
|
142
|
+
- Node tests
|
|
143
|
+
- `npm pack --dry-run`
|
|
144
|
+
|
|
145
|
+
## Release
|
|
146
|
+
|
|
147
|
+
This package supports npm Trusted Publishing, but you can also publish manually when needed:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
npm publish --access public --otp <OTP>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Do not store long-lived npm tokens in this repo.
|
|
154
|
+
|
|
155
|
+
## Security
|
|
156
|
+
|
|
157
|
+
Pi packages execute with your local permissions. Review source before installing third-party packages.
|
|
158
|
+
|
|
159
|
+
Product Hunt tokens are never committed by this package. `/producthunt:login` stores the token locally in `~/.pi/agent/pi-producthunt-auth.json`; `/producthunt:logout` deletes that stored file. `PRODUCTHUNT_ACCESS_TOKEN` is never modified by logout.
|
|
160
|
+
|
|
161
|
+
For vulnerability reporting, see [`SECURITY.md`](SECURITY.md).
|
|
162
|
+
|
|
163
|
+
## Links
|
|
164
|
+
|
|
165
|
+
- npm: https://www.npmjs.com/package/pi-producthunt
|
|
166
|
+
- GitHub: https://github.com/eiei114/pi-producthunt
|
|
167
|
+
- Issues: https://github.com/eiei114/pi-producthunt/issues
|
|
168
|
+
|
|
169
|
+
## License
|
|
170
|
+
|
|
171
|
+
MIT
|
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,61 @@
|
|
|
1
|
+
# GitHub Template Repository
|
|
2
|
+
|
|
3
|
+
## Recommended development flow
|
|
4
|
+
|
|
5
|
+
After generating a repo from this template, use this default order:
|
|
6
|
+
|
|
7
|
+
```txt
|
|
8
|
+
Vault notes -> PRD -> Issues -> implement -> ci/check -> release -> save learnings
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
In practice:
|
|
12
|
+
|
|
13
|
+
1. Create Vault notes under `4_Project/<ProjectName>/`.
|
|
14
|
+
2. Add `CONTEXT.md`, `README.md`, `ROADMAP.md`, `Docs/`, `Issues/`, and `Progress/`.
|
|
15
|
+
3. Write the PRD in `Docs/`.
|
|
16
|
+
4. Split approved issue files into `Issues/`.
|
|
17
|
+
5. Implement in the OSS repo created from this template.
|
|
18
|
+
6. Run CI and package checks before release.
|
|
19
|
+
7. Save release notes and follow-up decisions back to the Vault project.
|
|
20
|
+
|
|
21
|
+
Enable template mode on the source repository:
|
|
22
|
+
|
|
23
|
+
```txt
|
|
24
|
+
GitHub repo → Settings → General → Template repository
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Create a public repository from the template:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
gh repo create OWNER/new-pi-extension \
|
|
31
|
+
--public \
|
|
32
|
+
--template OWNER/pi-extension-template \
|
|
33
|
+
--clone
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Create a private repository from the template:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
gh repo create OWNER/new-pi-extension \
|
|
40
|
+
--private \
|
|
41
|
+
--template OWNER/pi-extension-template \
|
|
42
|
+
--clone
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Include all branches if needed:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
gh repo create OWNER/new-pi-extension \
|
|
49
|
+
--public \
|
|
50
|
+
--template OWNER/pi-extension-template \
|
|
51
|
+
--include-all-branches \
|
|
52
|
+
--clone
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
After creation:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
cd new-pi-extension
|
|
59
|
+
npm install
|
|
60
|
+
npm run ci
|
|
61
|
+
```\n
|
package/docs/release.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
## GitHub Actions requirements
|
|
30
|
+
|
|
31
|
+
- `permissions: id-token: write`
|
|
32
|
+
- `permissions: actions: write` on auto-release so it can dispatch `publish.yml`
|
|
33
|
+
- GitHub-hosted runner
|
|
34
|
+
- Node.js 24, so the release job uses a current npm CLI for Trusted Publishing
|
|
35
|
+
- No `NPM_TOKEN`
|
|
36
|
+
- `npm publish` from the configured workflow file
|
|
37
|
+
|
|
38
|
+
## First release checklist
|
|
39
|
+
|
|
40
|
+
- [ ] `package.json` name is final
|
|
41
|
+
- [ ] `repository.url` points to the real GitHub repository
|
|
42
|
+
- [ ] npm Trusted Publisher is configured
|
|
43
|
+
- [ ] `npm run ci` passes
|
|
44
|
+
- [ ] `npm pack --dry-run` contains only intended files
|
|
45
|
+
- [ ] `CHANGELOG.md` has the release date\n
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Repository Settings
|
|
2
|
+
|
|
3
|
+
Use this file after creating a real repository from the template.
|
|
4
|
+
|
|
5
|
+
## GitHub About
|
|
6
|
+
|
|
7
|
+
Suggested fields:
|
|
8
|
+
|
|
9
|
+
- Description: one-line pitch for the Pi package
|
|
10
|
+
- Website: npm package URL or project docs URL
|
|
11
|
+
- Topics:
|
|
12
|
+
- `pi`
|
|
13
|
+
- `pi-package`
|
|
14
|
+
- `agent-skill`
|
|
15
|
+
- `typescript`
|
|
16
|
+
|
|
17
|
+
## Template mode
|
|
18
|
+
|
|
19
|
+
If this repository itself should be reusable as a template:
|
|
20
|
+
|
|
21
|
+
```txt
|
|
22
|
+
Settings → General → Template repository
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Branch protection
|
|
26
|
+
|
|
27
|
+
Recommended for public packages:
|
|
28
|
+
|
|
29
|
+
- Require pull request before merging
|
|
30
|
+
- Require status checks to pass
|
|
31
|
+
- Require `CI` workflow
|
|
32
|
+
- Block force pushes on the default branch
|
|
33
|
+
|
|
34
|
+
## npm package page
|
|
35
|
+
|
|
36
|
+
After first publish:
|
|
37
|
+
|
|
38
|
+
- Confirm README renders correctly
|
|
39
|
+
- Confirm package provenance appears
|
|
40
|
+
- Confirm package contents are intentional
|
|
41
|
+
- Add npm URL to GitHub About and README
|
|
@@ -0,0 +1,98 @@
|
|
|
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
|
+
## TypeScript
|
|
59
|
+
|
|
60
|
+
- [ ] `extensions/index.ts` を実装に合わせて更新する
|
|
61
|
+
- [ ] `extensions/hello.ts` が不要なら削除する
|
|
62
|
+
- [ ] 共通ロジックを `lib/` に切り出す
|
|
63
|
+
- [ ] `strict: true` を維持する
|
|
64
|
+
- [ ] custom tool parameters は TypeBox schema で定義する
|
|
65
|
+
- [ ] string choices は `StringEnum` helper を使う
|
|
66
|
+
- [ ] runtime dependency は `dependencies`、Pi提供packageは `peerDependencies` に置く
|
|
67
|
+
- [ ] `package.json.files` に公開対象だけを入れる
|
|
68
|
+
|
|
69
|
+
## GitHub Template repo
|
|
70
|
+
|
|
71
|
+
- [ ] `gh repo create --template OWNER/pi-extension-template` で作成できることを確認する
|
|
72
|
+
- [ ] public/privateどちらの作成例もdocsに載せる
|
|
73
|
+
|
|
74
|
+
## CI / Release
|
|
75
|
+
|
|
76
|
+
- [ ] `npm run ci` が通る
|
|
77
|
+
- [ ] `npm pack --dry-run` が通る
|
|
78
|
+
- [ ] npm Trusted Publishing を設定する
|
|
79
|
+
- [ ] npm Trusted Publisher の workflow filename が `publish.yml` になっている
|
|
80
|
+
- [ ] `NPM_TOKEN` を使っていないことを確認する
|
|
81
|
+
- [ ] `auto-release.yml` が `main` の version bump から tag/release を作ることを確認する
|
|
82
|
+
- [ ] `publish.yml` が `workflow_dispatch` と `release.published` に対応していることを確認する
|
|
83
|
+
- [ ] 初回リリースで npm provenance が付いているか確認する
|
|
84
|
+
|
|
85
|
+
## npm page
|
|
86
|
+
|
|
87
|
+
- [ ] npm package URL を README に追加する
|
|
88
|
+
- [ ] npm description が適切に表示されるか確認する
|
|
89
|
+
- [ ] provenance が付いているか確認する
|
|
90
|
+
- [ ] 不要なファイルが package に含まれていないか確認する
|
|
91
|
+
|
|
92
|
+
## Before first release
|
|
93
|
+
|
|
94
|
+
- [ ] サンプルコードを実機 Pi でロードする
|
|
95
|
+
- [ ] `pi install git:github.com/OWNER/REPO` を試す
|
|
96
|
+
- [ ] `pi -e .` を試す
|
|
97
|
+
- [ ] README のコマンドがコピペで動くか確認する
|
|
98
|
+
- [ ] CHANGELOG に `0.1.0` を書く\n
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# TypeScript Guide
|
|
2
|
+
|
|
3
|
+
This is a TypeScript-first Pi package template.
|
|
4
|
+
|
|
5
|
+
## Layout
|
|
6
|
+
|
|
7
|
+
```txt
|
|
8
|
+
extensions/*.ts Pi extension entrypoints
|
|
9
|
+
lib/*.ts Shared TypeScript helpers
|
|
10
|
+
skills/*/SKILL.md Agent Skills
|
|
11
|
+
prompts/*.md Prompt templates
|
|
12
|
+
themes/*.json Themes
|
|
13
|
+
tests/*.test.mjs Smoke tests
|
|
14
|
+
tests/*.test.ts Optional TypeScript tests if you add a TS test runner
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Pi loads TypeScript extensions directly, so no build step is required for normal use.
|
|
18
|
+
|
|
19
|
+
## Strict mode
|
|
20
|
+
|
|
21
|
+
`tsconfig.json` keeps `strict: true`. Prefer fixing types over loosening compiler options.
|
|
22
|
+
|
|
23
|
+
## Extension entrypoints
|
|
24
|
+
|
|
25
|
+
Two entrypoint styles are shown:
|
|
26
|
+
|
|
27
|
+
- `extensions/hello.ts`: single-file extension
|
|
28
|
+
- `extensions/index.ts`: index-style extension that imports shared code from `lib/`
|
|
29
|
+
|
|
30
|
+
For larger packages, keep entrypoints thin and put reusable logic in `lib/`.
|
|
31
|
+
|
|
32
|
+
## TypeBox schemas
|
|
33
|
+
|
|
34
|
+
Use TypeBox schemas for custom tool parameters.
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { Type } from "typebox";
|
|
38
|
+
|
|
39
|
+
const parameters = Type.Object({
|
|
40
|
+
name: Type.String({ description: "Name to greet" }),
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## String enums
|
|
45
|
+
|
|
46
|
+
For string choices, use the local `StringEnum` helper from `lib/schema.ts`.
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { StringEnum } from "../lib/schema.ts";
|
|
50
|
+
|
|
51
|
+
const mode = StringEnum(["short", "friendly"], {
|
|
52
|
+
description: "Greeting style",
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
This emits a JSON Schema `enum`, which is friendlier to model providers than a union of string literals.
|
|
57
|
+
|
|
58
|
+
## Runtime dependencies vs peer dependencies
|
|
59
|
+
|
|
60
|
+
Pi bundles core packages for extension authors. Keep Pi-provided packages as `peerDependencies` and also install them as `devDependencies` for local typechecking.
|
|
61
|
+
|
|
62
|
+
Use `peerDependencies` for:
|
|
63
|
+
|
|
64
|
+
- `@earendil-works/pi-coding-agent`
|
|
65
|
+
- `@earendil-works/pi-ai`
|
|
66
|
+
- `@earendil-works/pi-tui`
|
|
67
|
+
- `typebox`
|
|
68
|
+
|
|
69
|
+
Use `dependencies` for runtime packages your extension imports that Pi does not provide.
|
|
70
|
+
|
|
71
|
+
Use `devDependencies` for local-only tools such as TypeScript, test runners, and linters.
|
|
72
|
+
|
|
73
|
+
## Package contents
|
|
74
|
+
|
|
75
|
+
Control npm package contents with `package.json` `files`. Prefer this over `.npmignore` so the published package stays explicit.
|