pi-doc-injector 0.1.2 → 0.1.3
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/docs/publish.md +49 -42
- package/index.ts +3 -3
- package/package.json +1 -1
- package/registry.ts +4 -1
package/docs/publish.md
CHANGED
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "Publishing Workflow"
|
|
3
|
-
keywords: [publish, release, npm, version, tag,
|
|
3
|
+
keywords: [publish, release, npm, version, tag, bun, oidc, trusted publisher]
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Publishing Workflow
|
|
7
7
|
|
|
8
|
+
## Trusted Publisher (OIDC)
|
|
9
|
+
|
|
10
|
+
This package uses **npm trusted publishing** — no tokens needed. The GitHub Actions workflow authenticates via OIDC, which is configured at:
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
https://www.npmjs.com/package/pi-doc-injector → Settings → Trusted Publisher
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The trusted publisher entry authorizes `lmn451/pi-docs` with workflow `publish.yml`.
|
|
17
|
+
|
|
18
|
+
## How It Works
|
|
19
|
+
|
|
20
|
+
1. Push a `v*` tag → triggers the publish workflow
|
|
21
|
+
2. GitHub Actions generates a short-lived OIDC token (`id-token: write`)
|
|
22
|
+
3. npm verifies the OIDC claims match the trusted publisher config
|
|
23
|
+
4. Package is published with provenance attestation
|
|
24
|
+
|
|
25
|
+
No `NPM_TOKEN` secret, no token rotation, nothing to leak.
|
|
26
|
+
|
|
8
27
|
## Versioning
|
|
9
28
|
|
|
10
29
|
We follow [Semantic Versioning](https://semver.org/):
|
|
@@ -12,69 +31,57 @@ We follow [Semantic Versioning](https://semver.org/):
|
|
|
12
31
|
- **MINOR** — backwards-compatible functionality additions
|
|
13
32
|
- **PATCH** — backwards-compatible bug fixes
|
|
14
33
|
|
|
15
|
-
##
|
|
16
|
-
|
|
17
|
-
### 1. Bump the version
|
|
34
|
+
## Release Process
|
|
18
35
|
|
|
19
36
|
```bash
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
37
|
+
# 1. Edit version in package.json (e.g., 0.1.1 → 0.1.2)
|
|
38
|
+
|
|
39
|
+
# 2. Commit, tag, and push
|
|
40
|
+
git add package.json
|
|
41
|
+
git commit -m "chore: bump version to X.Y.Z"
|
|
42
|
+
git tag vX.Y.Z
|
|
43
|
+
git push origin master
|
|
44
|
+
git push origin vX.Y.Z
|
|
23
45
|
```
|
|
24
46
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
### 2. Push the tag to trigger the workflow
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
git push origin v0.1.1
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
Or push all tags:
|
|
47
|
+
Or use `npm version`:
|
|
34
48
|
|
|
35
49
|
```bash
|
|
36
|
-
|
|
50
|
+
npm version patch # bumps version, commits, tags
|
|
51
|
+
git push origin master --follow-tags
|
|
37
52
|
```
|
|
38
53
|
|
|
39
|
-
|
|
54
|
+
## CI/CD
|
|
40
55
|
|
|
41
|
-
|
|
56
|
+
The `Publish` workflow triggers on `v*` tags and:
|
|
57
|
+
- Runs `bun install --frozen-lockfile`
|
|
58
|
+
- Verifies tag matches `package.json` version
|
|
59
|
+
- Runs `bun test`
|
|
60
|
+
- Publishes to npm with provenance via OIDC
|
|
42
61
|
|
|
43
|
-
|
|
44
|
-
- Runs tests
|
|
45
|
-
- Publishes to npm registry
|
|
46
|
-
|
|
47
|
-
Monitor the workflow at: `https://github.com/lmn451/pi-docs/actions`
|
|
62
|
+
Monitor: https://github.com/lmn451/pi-docs/actions
|
|
48
63
|
|
|
49
64
|
## Verify the Publish
|
|
50
65
|
|
|
51
|
-
Check if the package was published:
|
|
52
|
-
|
|
53
66
|
```bash
|
|
54
67
|
npm view pi-doc-injector
|
|
55
68
|
```
|
|
56
69
|
|
|
57
|
-
## Manual Publish
|
|
70
|
+
## Manual Publish (first time only)
|
|
58
71
|
|
|
59
|
-
|
|
72
|
+
OIDC only works after the package exists on npm. For the initial publish:
|
|
60
73
|
|
|
61
74
|
```bash
|
|
62
|
-
npm
|
|
75
|
+
npm login
|
|
76
|
+
npm publish --access public
|
|
63
77
|
```
|
|
64
78
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
Ensure your npm token is configured as a GitHub secret:
|
|
68
|
-
- Go to repository Settings → Secrets and variables → Actions
|
|
69
|
-
- Add a new secret named `NPM_TOKEN` with your npm access token
|
|
79
|
+
After that, configure the trusted publisher and all future releases go through CI.
|
|
70
80
|
|
|
71
81
|
## Troubleshooting
|
|
72
82
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
**npm publish failed?**
|
|
79
|
-
- Ensure `NPM_TOKEN` secret is set
|
|
80
|
-
- Verify the version hasn't already been published
|
|
83
|
+
| Issue | Solution |
|
|
84
|
+
|-------|----------|
|
|
85
|
+
| Workflow didn't run | Verify tag exists: `git ls-remote origin refs/tags/vX.Y.Z` |
|
|
86
|
+
| 404 on publish | Verify trusted publisher config on npmjs.com matches exactly |
|
|
87
|
+
| Version already published | Bump to a new version |
|
package/index.ts
CHANGED
|
@@ -143,7 +143,7 @@ export default async function docInjectorExtension(pi: ExtensionAPI) {
|
|
|
143
143
|
});
|
|
144
144
|
|
|
145
145
|
// ---- Event: before_agent_start (inject into system prompt) ----
|
|
146
|
-
pi.on("before_agent_start", async (
|
|
146
|
+
pi.on("before_agent_start", async (event, ctx) => {
|
|
147
147
|
if (!enabled || !registry || pendingMatches.size === 0) return;
|
|
148
148
|
|
|
149
149
|
const matchedEntries: DocEntry[] = [];
|
|
@@ -160,7 +160,7 @@ export default async function docInjectorExtension(pi: ExtensionAPI) {
|
|
|
160
160
|
// Skip injection if context usage exceeds the configured threshold
|
|
161
161
|
// (default: 80%). This prevents doc injection from pushing the context
|
|
162
162
|
// past the model's limit.
|
|
163
|
-
const usage =
|
|
163
|
+
const usage = ctx.getContextUsage();
|
|
164
164
|
if (usage && usage.tokens && usage.tokens > 0 && usage.percent && usage.percent > config.contextThreshold) {
|
|
165
165
|
console.warn(`[doc-injector] Skipping injection: context usage > ${config.contextThreshold}%`);
|
|
166
166
|
pendingMatches.clear();
|
|
@@ -174,7 +174,7 @@ export default async function docInjectorExtension(pi: ExtensionAPI) {
|
|
|
174
174
|
pendingMatches.clear();
|
|
175
175
|
|
|
176
176
|
return {
|
|
177
|
-
systemPrompt: (
|
|
177
|
+
systemPrompt: (event.systemPrompt || "") + "\n\n" + append,
|
|
178
178
|
};
|
|
179
179
|
});
|
|
180
180
|
|
package/package.json
CHANGED
package/registry.ts
CHANGED
|
@@ -111,7 +111,10 @@ export class DocRegistry {
|
|
|
111
111
|
injected: preserved.get(filePath) ?? false,
|
|
112
112
|
});
|
|
113
113
|
} catch (err) {
|
|
114
|
-
|
|
114
|
+
// Only warn for unexpected errors, not ENOENT (file deleted/moved after scan)
|
|
115
|
+
if ((err as NodeJS.ErrnoException).code !== "ENOENT") {
|
|
116
|
+
console.warn(`[doc-injector] Error reading ${relativePath}:`, err);
|
|
117
|
+
}
|
|
115
118
|
}
|
|
116
119
|
}
|
|
117
120
|
|