pi-model-fallback 0.1.0 → 0.3.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 +56 -33
- package/README.md +164 -163
- package/extensions/index.ts +199 -27
- package/lib/config.ts +144 -136
- package/lib/state.ts +118 -0
- package/lib/storage.ts +37 -36
- package/package.json +59 -59
package/CHANGELOG.md
CHANGED
|
@@ -1,38 +1,61 @@
|
|
|
1
|
-
# Changelog
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## Unreleased
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
- Add Buy Me a Coffee sponsor button to README and native GitHub funding link via `.github/FUNDING.yml`.
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## [0.1.3] - 2026-06-19
|
|
8
|
-
|
|
9
|
-
### Changed
|
|
10
|
-
|
|
11
|
-
- CONTRIBUTING now reminds maintainers to run `npm pack --dry-run` after changing which `docs/` files ship in the package.
|
|
7
|
+
## [0.3.2] - 2026-07-04
|
|
12
8
|
|
|
13
9
|
### Fixed
|
|
14
10
|
|
|
15
|
-
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
-
|
|
38
|
-
|
|
11
|
+
- Publish only from release refs, print Node/npm versions, and publish with `--provenance --access public` so npm Trusted Publishing uses the same known-good path as `pi-spotify-widget`.
|
|
12
|
+
- Release instructions now use `npm version patch --no-git-tag-version` so local tags do not race the auto-release workflow.
|
|
13
|
+
|
|
14
|
+
## 0.3.0
|
|
15
|
+
|
|
16
|
+
- Use `agent_start` for persistent preselect; `session_start` was not a Pi extension event.
|
|
17
|
+
- Persist fallback state from assistant error messages on `turn_end`, covering provider SDK errors that do not emit `after_provider_response`.
|
|
18
|
+
|
|
19
|
+
## 0.2.0
|
|
20
|
+
|
|
21
|
+
- Add persistent failover state. A matching provider failure now writes `model-fallback/state.json`, and future sessions preselect the fallback model before the first provider call until the cooldown expires.
|
|
22
|
+
- Parse retry/reset headers when available; otherwise default 429 cooldown to 72h and 5xx cooldown to 10m.
|
|
23
|
+
- `/model-fallback:reset` now clears persistent state.
|
|
24
|
+
|
|
25
|
+
All notable changes to this project will be documented in this file.
|
|
26
|
+
|
|
27
|
+
This project follows semantic versioning.
|
|
28
|
+
|
|
29
|
+
## [0.1.3] - 2026-06-19
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
|
|
33
|
+
- CONTRIBUTING now reminds maintainers to run `npm pack --dry-run` after changing which `docs/` files ship in the package.
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
|
|
37
|
+
- README License section no longer ends with a literal `\n` placeholder.
|
|
38
|
+
|
|
39
|
+
## [0.1.2] - 2026-06-04
|
|
40
|
+
|
|
41
|
+
### Changed
|
|
42
|
+
|
|
43
|
+
- 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.
|
|
44
|
+
- Template bootstrap docs (`github-template.md`, `repository-settings.md`, `typescript.md`) are labeled for delete-or-merge after setup.
|
|
45
|
+
|
|
46
|
+
## [0.1.1] - 2026-06-01
|
|
47
|
+
|
|
48
|
+
### Changed
|
|
49
|
+
|
|
50
|
+
- Publish workflow now supports npm publishing on merged package version bumps in addition to tags, releases, and manual dispatch.
|
|
51
|
+
- Publish workflow now installs a current npm CLI so npm Trusted Publishing OIDC is supported.
|
|
52
|
+
- CI and publish workflow commands no longer include literal trailing `\\n` text.
|
|
53
|
+
|
|
54
|
+
## [0.1.0] - YYYY-MM-DD
|
|
55
|
+
|
|
56
|
+
### Added
|
|
57
|
+
|
|
58
|
+
- Initial Pi package template.
|
|
59
|
+
- Example extension, Agent Skill, prompt, and theme.
|
|
60
|
+
- CI and npm Trusted Publishing workflow.
|
|
61
|
+
|
package/README.md
CHANGED
|
@@ -1,163 +1,164 @@
|
|
|
1
|
-
# PACKAGE_DISPLAY_NAME
|
|
2
|
-
|
|
3
|
-
[](https://github.com/OWNER/REPO/actions/workflows/ci.yml)
|
|
4
|
-
[](https://github.com/OWNER/REPO/actions/workflows/publish.yml)
|
|
5
|
-
[](https://www.npmjs.com/package/PACKAGE_NAME)
|
|
6
|
-
[](https://www.npmjs.com/package/PACKAGE_NAME)
|
|
7
|
-
[](LICENSE)
|
|
8
|
-
[](https://pi.dev/packages)
|
|
9
|
-
[](docs/release.md)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
- Feature
|
|
21
|
-
- Feature
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
| `
|
|
82
|
-
| `
|
|
83
|
-
| `
|
|
84
|
-
| `
|
|
85
|
-
| `
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
npm
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
- [`docs/
|
|
137
|
-
- `docs/
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
- `docs/
|
|
147
|
-
- `docs/
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
-
|
|
159
|
-
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
1
|
+
# PACKAGE_DISPLAY_NAME
|
|
2
|
+
|
|
3
|
+
[](https://github.com/OWNER/REPO/actions/workflows/ci.yml)
|
|
4
|
+
[](https://github.com/OWNER/REPO/actions/workflows/publish.yml)
|
|
5
|
+
[](https://www.npmjs.com/package/PACKAGE_NAME)
|
|
6
|
+
[](https://www.npmjs.com/package/PACKAGE_NAME)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
[](https://pi.dev/packages)
|
|
9
|
+
[](docs/release.md)
|
|
10
|
+
<a href="https://buymeacoffee.com/ekawano114m"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" width="217" height="60"></a>
|
|
11
|
+
|
|
12
|
+
> One-line pitch for this TypeScript-first Pi package.
|
|
13
|
+
|
|
14
|
+
## What this is
|
|
15
|
+
|
|
16
|
+
Briefly explain what this TypeScript-first package adds to Pi and who should use it.
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- Feature 1
|
|
21
|
+
- Feature 2
|
|
22
|
+
- Feature 3
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
Install the published npm package with Pi:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pi install npm:PACKAGE_NAME
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Replace `PACKAGE_NAME` with the exact `name` from `package.json`.
|
|
33
|
+
For a scoped npm package, keep the `npm:` prefix:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pi install npm:@your-scope/your-pi-package
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Pin a specific version when you want reproducible installs:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pi install npm:PACKAGE_NAME@0.1.0
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Install into the current project instead of your user Pi settings:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pi install npm:PACKAGE_NAME -l
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Or install from GitHub:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pi install git:github.com/OWNER/REPO
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Try it without permanently installing:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pi -e npm:PACKAGE_NAME
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Quick start
|
|
64
|
+
|
|
65
|
+
Try this package locally:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pi -e .
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Then run:
|
|
72
|
+
|
|
73
|
+
```txt
|
|
74
|
+
/your-command
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Package contents
|
|
78
|
+
|
|
79
|
+
| Path | Purpose |
|
|
80
|
+
|---|---|
|
|
81
|
+
| `extensions/` | Pi TypeScript extension entrypoints (`*.ts` and `index.ts`) |
|
|
82
|
+
| `lib/` | Shared TypeScript helpers |
|
|
83
|
+
| `skills/` | Agent Skills |
|
|
84
|
+
| `prompts/` | Prompt templates |
|
|
85
|
+
| `themes/` | Pi themes |
|
|
86
|
+
| `docs/` | Optional supporting docs (usage, examples, release, ADRs) |
|
|
87
|
+
|
|
88
|
+
## Development
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
npm install
|
|
92
|
+
npm run ci
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Development flow
|
|
96
|
+
|
|
97
|
+
Use this default flow when building a new Pi extension OSS project from this template:
|
|
98
|
+
|
|
99
|
+
1. Create the Vault project notes under `4_Project/<ProjectName>/`.
|
|
100
|
+
2. Add `CONTEXT.md`, `README.md`, `ROADMAP.md`, `Docs/`, `Issues/`, and `Progress/`.
|
|
101
|
+
3. Write the PRD in `4_Project/<ProjectName>/Docs/`.
|
|
102
|
+
4. Split approved tracer-bullet issues into `4_Project/<ProjectName>/Issues/`.
|
|
103
|
+
5. Implement in the OSS repo.
|
|
104
|
+
6. Run `npm run ci`, `npm test`, and `npm pack --dry-run`.
|
|
105
|
+
7. Release with Trusted Publishing.
|
|
106
|
+
8. Save release notes and follow-up decisions back to the Vault project.
|
|
107
|
+
|
|
108
|
+
Short version:
|
|
109
|
+
|
|
110
|
+
```txt
|
|
111
|
+
Vault notes -> PRD -> Issues -> implement -> ci/check -> release -> save learnings
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Release
|
|
115
|
+
|
|
116
|
+
This package is set up for npm Trusted Publishing, so no `NPM_TOKEN` is required.
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
npm version patch
|
|
120
|
+
git push
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
See [`docs/release.md`](docs/release.md) for setup details.
|
|
124
|
+
|
|
125
|
+
## Docs
|
|
126
|
+
|
|
127
|
+
`docs/` is optional supporting documentation, not a fixed six-file set. README stays the GitHub/npm entrypoint; add `docs/*.md` only when they help users or maintainers.
|
|
128
|
+
|
|
129
|
+
After creating a repository from this template:
|
|
130
|
+
|
|
131
|
+
1. Follow [`docs/template-checklist.md`](docs/template-checklist.md) for setup.
|
|
132
|
+
2. Run the **post-generation docs cleanup** in that checklist: delete or merge template bootstrap docs that no longer add project value.
|
|
133
|
+
|
|
134
|
+
Useful docs to keep when they add value:
|
|
135
|
+
|
|
136
|
+
- [`docs/examples.md`](docs/examples.md) — examples for extensions, skills, prompts, and themes
|
|
137
|
+
- [`docs/release.md`](docs/release.md) — Trusted Publishing details (README Release summarizes the flow)
|
|
138
|
+
- `docs/usage.md` — create when usage does not fit in README
|
|
139
|
+
|
|
140
|
+
Optional maintainer guidance (not a public-user navigation target in mature repos):
|
|
141
|
+
|
|
142
|
+
- [`docs/template-checklist.md`](docs/template-checklist.md)
|
|
143
|
+
|
|
144
|
+
Template bootstrap docs to delete or merge after setup unless they still teach something project-specific:
|
|
145
|
+
|
|
146
|
+
- `docs/github-template.md`
|
|
147
|
+
- `docs/repository-settings.md`
|
|
148
|
+
- `docs/typescript.md`
|
|
149
|
+
|
|
150
|
+
## Security
|
|
151
|
+
|
|
152
|
+
Pi packages can execute code with your local permissions. Review extensions before installing third-party packages.
|
|
153
|
+
|
|
154
|
+
For vulnerability reporting, see [`SECURITY.md`](SECURITY.md).
|
|
155
|
+
|
|
156
|
+
## Links
|
|
157
|
+
|
|
158
|
+
- npm: https://www.npmjs.com/package/PACKAGE_NAME
|
|
159
|
+
- GitHub: https://github.com/OWNER/REPO
|
|
160
|
+
- Issues: https://github.com/OWNER/REPO/issues
|
|
161
|
+
|
|
162
|
+
## License
|
|
163
|
+
|
|
164
|
+
MIT
|