@howaboua/pi-subagent-review 0.2.25 → 0.2.27
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 +11 -5
- package/README.md +10 -8
- package/index.ts +0 -2
- package/package.json +68 -70
- package/review.prompt.md +4 -0
- package/src/config.ts +9 -2
- package/src/constants.ts +1 -1
- package/src/conversation-summary.ts +10 -6
- package/src/messages.ts +6 -6
- package/src/review-loop.ts +7 -7
- package/src/summary-session.ts +1 -1
- package/biome.json +0 -31
- package/changelog.ts +0 -337
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @howaboua/pi-subagent-review
|
|
2
2
|
|
|
3
|
+
## 0.2.27
|
|
4
|
+
|
|
5
|
+
- New review configurations use GPT-6.2 Sol.
|
|
6
|
+
- Custom reviewer model IDs now use Pi's CLI instead of falling back when their provider is configured.
|
|
7
|
+
|
|
8
|
+
## 0.2.26
|
|
9
|
+
|
|
10
|
+
- Requires Pi 1.5 or newer.
|
|
11
|
+
- Removed custom changelog suppression. Updates use Pi's native notices and `collapseChangelog`.
|
|
12
|
+
- Conversation summaries now use minute-precision timestamps.
|
|
13
|
+
|
|
3
14
|
## 0.2.25
|
|
4
15
|
|
|
5
16
|
- Reviewer prompts now request evidence-backed findings without issue-count targets.
|
|
@@ -7,7 +18,6 @@
|
|
|
7
18
|
## 0.2.24
|
|
8
19
|
|
|
9
20
|
- GPT-6 Sol and Luna now share Astra's Codex support.
|
|
10
|
-
|
|
11
21
|
- Removed `/terra`; use `/luna` instead.
|
|
12
22
|
- Added Responses Lite, non-destructive reasoning changes and terse context guidance for GPT-6 Sol and Luna.
|
|
13
23
|
- Image descriptions now use GPT-6 Luna directly instead of preferring older mini models.
|
|
@@ -19,7 +29,6 @@
|
|
|
19
29
|
- Adapt Codex, Imagegen, review, and GipPity to Pi 0.87.
|
|
20
30
|
|
|
21
31
|
Codex Conversion, Imagegen, and Subagent Review require Pi 0.87.0 or newer.
|
|
22
|
-
|
|
23
32
|
- Fixed Codex prompt and tool updates rewriting the cached conversation prefix.
|
|
24
33
|
- Context reminders no longer start an extra checkpoint turn if the current run already saved a note in the current window.
|
|
25
34
|
- Fixed Imagegen recent-image selection ignoring context removals and replacements.
|
|
@@ -33,14 +42,12 @@
|
|
|
33
42
|
## 0.2.21
|
|
34
43
|
|
|
35
44
|
- Restore full extension prompt preparation when continuing into a new context window or starting review triage.
|
|
36
|
-
|
|
37
45
|
- Keep tool instructions current through Pi's normal startup hooks without resetting the Notebook.
|
|
38
46
|
- Let active context management own review-loop navigation summaries.
|
|
39
47
|
|
|
40
48
|
## 0.2.20
|
|
41
49
|
|
|
42
50
|
- Preserve extension-owned messages while delivering true developer-role policy through compatible Pi Codex Responses adapters.
|
|
43
|
-
|
|
44
51
|
- Add an optional custom-message API that retains caller rendering and restoration fields.
|
|
45
52
|
- Route Shepherdr's unclaimed worker events and orchestration toggles through it, preserving ordinary Pi delivery when unavailable.
|
|
46
53
|
- Send review preface/triage policy and realtime voice start/end guidance as developer messages without elevating raw reviewer findings, spoken delegations, or transcript tails.
|
|
@@ -63,7 +70,6 @@
|
|
|
63
70
|
### Changes
|
|
64
71
|
|
|
65
72
|
- [#301](https://github.com/IgorWarzocha/howaboua-pi-stuff/pull/301) [`8456135`](https://github.com/IgorWarzocha/howaboua-pi-stuff/commit/8456135c54113c01541c8ee8874baa1bd9eefa59) Thanks [@IgorWarzocha](https://github.com/IgorWarzocha)! - Preserve the review findings UI while restoring the `before_agent_start` lifecycle when `/review` is the first session message.
|
|
66
|
-
|
|
67
73
|
- Keep findings custom-rendered, then use a normal user turn for verification and disposition.
|
|
68
74
|
- Direct the agent to verify findings against the cited code, request user dispositions, and begin agreed work without resummarizing.
|
|
69
75
|
- End cleanly without a disposition turn when the reviewer finds no actionable issues.
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Adds `/review`, which sends the current repository state to an isolated review s
|
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
|
-
Requires Pi 0.
|
|
7
|
+
Requires Pi 1.0.0 or newer.
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
pi install npm:@howaboua/pi-subagent-review
|
|
@@ -48,18 +48,20 @@ On first load, the extension creates `~/.pi/agent/pi-subagent-review.json`, or t
|
|
|
48
48
|
|
|
49
49
|
```json
|
|
50
50
|
{
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
"model": "openai-codex/gpt-6.2-sol",
|
|
52
|
+
"thinking": "medium",
|
|
53
|
+
"summary": {
|
|
54
|
+
"enabled": true,
|
|
55
|
+
"model": "openai-codex/gpt-6-luna",
|
|
56
|
+
"thinking": "low"
|
|
57
|
+
}
|
|
58
58
|
}
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
Models use Pi's `provider/model` format. Thinking levels through `max` are accepted and clamped. If a configured model is unavailable, the command falls back to the current session model.
|
|
62
62
|
|
|
63
|
+
Reviewer IDs absent from Pi's catalogue use its CLI's custom-model support when their provider is configured. Invalid IDs fail in the reviewer rather than selecting another model. Summary models must be registered in Pi.
|
|
64
|
+
|
|
63
65
|
The `summary` model prepares both reviewer conversation context and review-loop increment summaries.
|
|
64
66
|
|
|
65
67
|
Do not load another extension that registers `/review` unless the command collision is intentional.
|
package/index.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import registerPackageChangelog from "./changelog.js";
|
|
3
2
|
import { ensureConfigFile } from "./src/config.js";
|
|
4
3
|
import { CHILD_ENV } from "./src/constants.js";
|
|
5
4
|
import type { ReviewDeveloperMessages } from "./src/messages.js";
|
|
@@ -9,7 +8,6 @@ import { registerTreeSummaryModel } from "./src/tree-summary.js";
|
|
|
9
8
|
export default async function (pi: ExtensionAPI) {
|
|
10
9
|
if (process.env[CHILD_ENV] === "1") return;
|
|
11
10
|
|
|
12
|
-
registerPackageChangelog(pi);
|
|
13
11
|
ensureConfigFile();
|
|
14
12
|
const developerMessages = await loadDeveloperMessages();
|
|
15
13
|
registerReviewCommand(pi, registerTreeSummaryModel(pi), developerMessages);
|
package/package.json
CHANGED
|
@@ -1,72 +1,70 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
"access": "public"
|
|
71
|
-
}
|
|
2
|
+
"name": "@howaboua/pi-subagent-review",
|
|
3
|
+
"version": "0.2.27",
|
|
4
|
+
"description": "Pi extension that adds /review via an isolated review subagent.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.ts",
|
|
7
|
+
"exports": "./index.ts",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"files": [
|
|
10
|
+
"index.ts",
|
|
11
|
+
"src",
|
|
12
|
+
"review.prompt.md",
|
|
13
|
+
"README.md",
|
|
14
|
+
"tsconfig.json",
|
|
15
|
+
"CHANGELOG.md"
|
|
16
|
+
],
|
|
17
|
+
"keywords": [
|
|
18
|
+
"pi-package",
|
|
19
|
+
"pi",
|
|
20
|
+
"pi-extension",
|
|
21
|
+
"review",
|
|
22
|
+
"code-review",
|
|
23
|
+
"subagent",
|
|
24
|
+
"agent"
|
|
25
|
+
],
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/IgorWarzocha/howaboua-pi-stuff.git",
|
|
29
|
+
"directory": "packages/pi-subagent-review"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://github.com/IgorWarzocha/howaboua-pi-stuff/tree/main/packages/pi-subagent-review#readme",
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/IgorWarzocha/howaboua-pi-stuff/issues"
|
|
34
|
+
},
|
|
35
|
+
"pi": {
|
|
36
|
+
"extensions": [
|
|
37
|
+
"./index.ts"
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"@howaboua/pi-codex-conversion": ">=5.0.1",
|
|
42
|
+
"@earendil-works/pi-ai": ">=1.0.0",
|
|
43
|
+
"@earendil-works/pi-coding-agent": ">=1.5.0",
|
|
44
|
+
"@earendil-works/pi-tui": ">=1.0.0"
|
|
45
|
+
},
|
|
46
|
+
"peerDependenciesMeta": {
|
|
47
|
+
"@howaboua/pi-codex-conversion": {
|
|
48
|
+
"optional": true
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"check": "bun run lint && bun run typecheck",
|
|
53
|
+
"prepack": "bun run check",
|
|
54
|
+
"typecheck": "tsrs --noEmit",
|
|
55
|
+
"lint": "bun run format:check && oxlint --type-aware",
|
|
56
|
+
"format": "oxfmt --write '**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx,json,jsonc,json5,css}'",
|
|
57
|
+
"format:check": "oxfmt --check '**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx,json,jsonc,json5,css}'"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@howaboua/pi-codex-conversion": "5.0.1",
|
|
61
|
+
"@earendil-works/pi-ai": "1.5.2",
|
|
62
|
+
"@earendil-works/pi-coding-agent": "1.5.2",
|
|
63
|
+
"@types/node": "^26.6.6",
|
|
64
|
+
"typescript": "^7.0.2",
|
|
65
|
+
"oxfmt": "^0.78.0"
|
|
66
|
+
},
|
|
67
|
+
"publishConfig": {
|
|
68
|
+
"access": "public"
|
|
69
|
+
}
|
|
72
70
|
}
|
package/review.prompt.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
You are the Review Subagent, a code-review specialist.
|
|
2
2
|
|
|
3
3
|
Rules:
|
|
4
|
+
|
|
4
5
|
- Stay strictly in review mode.
|
|
5
6
|
- You do not inherit the parent agent's prior conversation, plan, or hidden context. Treat the provided task as the entire brief.
|
|
6
7
|
- Do not edit files or propose implementation plans beyond concise fixes.
|
|
@@ -12,10 +13,13 @@ Rules:
|
|
|
12
13
|
- Suggest the smallest credible fix when helpful.
|
|
13
14
|
|
|
14
15
|
Output format:
|
|
16
|
+
|
|
15
17
|
# Review Findings
|
|
18
|
+
|
|
16
19
|
- `[high|medium|low] path/to/file:start-end` - issue, why it matters, and the concrete fix
|
|
17
20
|
|
|
18
21
|
If there are no actionable issues, output exactly:
|
|
19
22
|
|
|
20
23
|
# Review Findings
|
|
24
|
+
|
|
21
25
|
No actionable issues found.
|
package/src/config.ts
CHANGED
|
@@ -126,10 +126,17 @@ function splitModelRef(modelRef: string): ParsedModelRef | undefined {
|
|
|
126
126
|
async function canUseModel(
|
|
127
127
|
ctx: ExtensionCommandContext,
|
|
128
128
|
modelRef: string,
|
|
129
|
+
allowCustomId = false,
|
|
129
130
|
): Promise<boolean> {
|
|
130
131
|
const parsed = splitModelRef(modelRef);
|
|
131
132
|
if (!parsed) return false;
|
|
132
|
-
|
|
133
|
+
// The reviewer CLI accepts custom IDs for known providers; summaries do not.
|
|
134
|
+
// Check provider auth with a registered model without replacing the requested ID.
|
|
135
|
+
const model =
|
|
136
|
+
ctx.modelRegistry.find(parsed.provider, parsed.modelId) ??
|
|
137
|
+
(allowCustomId
|
|
138
|
+
? ctx.modelRegistry.getProvider(parsed.provider)?.getModels()[0]
|
|
139
|
+
: undefined);
|
|
133
140
|
if (!model) return false;
|
|
134
141
|
const auth = await ctx.modelRegistry.getApiKeyAndHeaders(model);
|
|
135
142
|
return auth.ok;
|
|
@@ -159,7 +166,7 @@ export async function resolveReviewConfig(
|
|
|
159
166
|
}
|
|
160
167
|
}
|
|
161
168
|
|
|
162
|
-
if (await canUseModel(ctx, configured.model)) {
|
|
169
|
+
if (await canUseModel(ctx, configured.model, true)) {
|
|
163
170
|
return { ...configured, summary, source: "configured" };
|
|
164
171
|
}
|
|
165
172
|
|
package/src/constants.ts
CHANGED
|
@@ -27,30 +27,34 @@ function serializeEntry({
|
|
|
27
27
|
sourceEntry: entry,
|
|
28
28
|
messages,
|
|
29
29
|
}: ProjectedSessionEntry): string | undefined {
|
|
30
|
+
const time = new Date(entry.timestamp);
|
|
31
|
+
const timestamp = Number.isFinite(time.getTime())
|
|
32
|
+
? `${time.toISOString().slice(0, 16)}Z`
|
|
33
|
+
: entry.timestamp;
|
|
30
34
|
switch (entry.type) {
|
|
31
35
|
case "message": {
|
|
32
36
|
const message = messages[0];
|
|
33
37
|
if (!message || !("content" in message)) return undefined;
|
|
34
38
|
const text = textFromContent(message.content).trim();
|
|
35
39
|
if (!text) return undefined;
|
|
36
|
-
return `## ${message.role} (${
|
|
40
|
+
return `## ${message.role} (${timestamp})\n${text}`;
|
|
37
41
|
}
|
|
38
42
|
case "branch_summary":
|
|
39
|
-
return `## branch summary (${
|
|
43
|
+
return `## branch summary (${timestamp})\n${entry.summary}`;
|
|
40
44
|
case "compaction":
|
|
41
45
|
if (messages.length === 0) return undefined;
|
|
42
|
-
return `## compaction summary (${
|
|
46
|
+
return `## compaction summary (${timestamp})\n${entry.summary}`;
|
|
43
47
|
case "custom_message": {
|
|
44
48
|
const message = messages[0];
|
|
45
49
|
if (message?.role !== "custom") return undefined;
|
|
46
50
|
const text = textFromContent(message.content).trim();
|
|
47
51
|
if (!text) return undefined;
|
|
48
|
-
return `## custom message: ${entry.customType} (${
|
|
52
|
+
return `## custom message: ${entry.customType} (${timestamp})\n${text}`;
|
|
49
53
|
}
|
|
50
54
|
case "model_change":
|
|
51
|
-
return `## model change (${
|
|
55
|
+
return `## model change (${timestamp})\n${entry.provider}/${entry.modelId}`;
|
|
52
56
|
case "thinking_level_change":
|
|
53
|
-
return `## thinking level change (${
|
|
57
|
+
return `## thinking level change (${timestamp})\n${entry.thinkingLevel}`;
|
|
54
58
|
default:
|
|
55
59
|
return undefined;
|
|
56
60
|
}
|
package/src/messages.ts
CHANGED
|
@@ -19,19 +19,19 @@ export type ReviewDeveloperMessages = Partial<
|
|
|
19
19
|
const REALTIME_VOICE_PROMPT_CHANNEL =
|
|
20
20
|
"@howaboua/pi-codex-conversion/realtime-voice-prompt/v1";
|
|
21
21
|
const REVIEW_LOOP_PREFACE_MESSAGE = [
|
|
22
|
-
"Review findings are advisory and may be wrong or lack session context. Verify each against the user's request, prior decisions, tradeoffs and current state
|
|
22
|
+
"Review findings are advisory and may be wrong or lack session context. Verify each against the user's request, prior decisions, tradeoffs and current state",
|
|
23
23
|
"Recommend address (necessary and in scope), defer (outside current work), or skip (stylistic, speculative or not useful).",
|
|
24
|
-
"Obtain the user's disposition before making changes
|
|
24
|
+
"Obtain the user's disposition before making changes",
|
|
25
25
|
].join("\n");
|
|
26
26
|
|
|
27
27
|
const REVIEW_SUMMARY_STARTED_PROMPT =
|
|
28
|
-
"The current conversation is being summarised to prepare context for an isolated code review. Please announce this briefly in your natural voice
|
|
28
|
+
"The current conversation is being summarised to prepare context for an isolated code review. Please announce this briefly in your natural voice";
|
|
29
29
|
const REVIEW_FINDINGS_READY_PROMPT =
|
|
30
|
-
"The isolated code review has finished, and its findings have been sent to the main agent for triage. Announce this briefly in your natural voice. When the main agent responds, continue with its substantive triage without repeating this status
|
|
30
|
+
"The isolated code review has finished, and its findings have been sent to the main agent for triage. Announce this briefly in your natural voice. When the main agent responds, continue with its substantive triage without repeating this status";
|
|
31
31
|
const REVIEW_FINDINGS_FOLLOW_UP = [
|
|
32
|
-
"Treat the findings above as advisory and unverified. Read the cited files and trace the relevant paths before deciding whether each finding is true, necessary, and in scope. Compare them against the user’s request, prior decisions, and current state. Do not merely summarize the reviewer output
|
|
32
|
+
"Treat the findings above as advisory and unverified. Read the cited files and trace the relevant paths before deciding whether each finding is true, necessary, and in scope. Compare them against the user’s request, prior decisions, and current state. Do not merely summarize the reviewer output",
|
|
33
33
|
"",
|
|
34
|
-
"Before making changes, get the user’s disposition on the verified findings using an available ask/questions tool, or a normal message if none is available. After dispositions are agreed, do not summarize them again: start the agreed work. If any remain ambiguous, complete the clear, simple, non-blocking agreed fixes first, then return to the ambiguous findings
|
|
34
|
+
"Before making changes, get the user’s disposition on the verified findings using an available ask/questions tool, or a normal message if none is available. After dispositions are agreed, do not summarize them again: start the agreed work. If any remain ambiguous, complete the clear, simple, non-blocking agreed fixes first, then return to the ambiguous findings",
|
|
35
35
|
].join("\n");
|
|
36
36
|
|
|
37
37
|
function announceReviewStatus(
|
package/src/review-loop.ts
CHANGED
|
@@ -15,12 +15,12 @@ const REVIEW_LOOP_BOUNDARY_ENTRY = "subagent-review-loop-boundary";
|
|
|
15
15
|
const REVIEW_LOOP_MARKER_LABEL = "review";
|
|
16
16
|
const REVIEW_LOOP_WIDGET = "subagent-review-loop";
|
|
17
17
|
const REVIEW_LOOP_SUMMARY_PROMPT = [
|
|
18
|
-
"Treat this as a completed review-fix increment that should become durable context before the next isolated review pass
|
|
19
|
-
"Focus on the final accepted outcome, not dead ends or step-by-step implementation noise
|
|
20
|
-
"Capture which review findings were addressed, which were intentionally skipped or deferred, concrete files changed, key decisions, tests/checks run, and any remaining risks that matter for the next review
|
|
21
|
-
"Mention relevant commands, commits, PR outcomes, or review feedback only when they change future work
|
|
22
|
-
"Omit temporary debugging details, abandoned attempts, incidental churn, and repetitive review transcript noise
|
|
23
|
-
"Write the summary so the main agent can continue from this compacted review-loop point and immediately run the next review pass
|
|
18
|
+
"Treat this as a completed review-fix increment that should become durable context before the next isolated review pass",
|
|
19
|
+
"Focus on the final accepted outcome, not dead ends or step-by-step implementation noise",
|
|
20
|
+
"Capture which review findings were addressed, which were intentionally skipped or deferred, concrete files changed, key decisions, tests/checks run, and any remaining risks that matter for the next review",
|
|
21
|
+
"Mention relevant commands, commits, PR outcomes, or review feedback only when they change future work",
|
|
22
|
+
"Omit temporary debugging details, abandoned attempts, incidental churn, and repetitive review transcript noise",
|
|
23
|
+
"Write the summary so the main agent can continue from this compacted review-loop point and immediately run the next review pass",
|
|
24
24
|
].join("\n");
|
|
25
25
|
|
|
26
26
|
interface ReviewLoopState {
|
|
@@ -184,7 +184,7 @@ function isReviewLoopIncrementEntry(entry: SessionEntry): boolean {
|
|
|
184
184
|
);
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
|
|
187
|
+
function hasReviewLoopIncrement(
|
|
188
188
|
ctx: ExtensionCommandContext,
|
|
189
189
|
markerId: string,
|
|
190
190
|
): boolean {
|
package/src/summary-session.ts
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
import type { ResolvedReviewConfig } from "./types.js";
|
|
17
17
|
|
|
18
18
|
const SUMMARY_SYSTEM_PROMPT =
|
|
19
|
-
"Summarize supplied conversation context for a separate code-review agent. Follow the user's summary format exactly and do not use tools
|
|
19
|
+
"Summarize supplied conversation context for a separate code-review agent. Follow the user's summary format exactly and do not use tools";
|
|
20
20
|
|
|
21
21
|
function summaryCredentialStore(
|
|
22
22
|
providerId: string,
|
package/biome.json
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://biomejs.dev/schemas/2.5.10/schema.json",
|
|
3
|
-
"vcs": {
|
|
4
|
-
"enabled": true,
|
|
5
|
-
"clientKind": "git",
|
|
6
|
-
"useIgnoreFile": true
|
|
7
|
-
},
|
|
8
|
-
"files": {
|
|
9
|
-
"includes": [
|
|
10
|
-
"**",
|
|
11
|
-
"!node_modules",
|
|
12
|
-
"!dist",
|
|
13
|
-
"!coverage",
|
|
14
|
-
"!package-lock.json"
|
|
15
|
-
]
|
|
16
|
-
},
|
|
17
|
-
"formatter": {
|
|
18
|
-
"enabled": true,
|
|
19
|
-
"indentStyle": "tab"
|
|
20
|
-
},
|
|
21
|
-
"linter": {
|
|
22
|
-
"enabled": false
|
|
23
|
-
},
|
|
24
|
-
"javascript": {
|
|
25
|
-
"formatter": {
|
|
26
|
-
"quoteStyle": "double",
|
|
27
|
-
"semicolons": "always",
|
|
28
|
-
"trailingCommas": "all"
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
package/changelog.ts
DELETED
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
// Generated extension packages copy this file during changelog:extensions.
|
|
2
|
-
|
|
3
|
-
import { randomUUID } from "node:crypto";
|
|
4
|
-
import { readFileSync } from "node:fs";
|
|
5
|
-
import { mkdir, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
6
|
-
import { dirname, join } from "node:path";
|
|
7
|
-
import { fileURLToPath } from "node:url";
|
|
8
|
-
import {
|
|
9
|
-
DynamicBorder,
|
|
10
|
-
type ExtensionAPI,
|
|
11
|
-
getAgentDir,
|
|
12
|
-
getMarkdownTheme,
|
|
13
|
-
} from "@earendil-works/pi-coding-agent";
|
|
14
|
-
import { Container, Markdown, Spacer, Text } from "@earendil-works/pi-tui";
|
|
15
|
-
|
|
16
|
-
const ENTRY_TYPE = "@howaboua/pi-stuff/changelog";
|
|
17
|
-
const REGISTRATION_CHANNEL = "@howaboua/pi-stuff/changelog/register/v1";
|
|
18
|
-
const STATE_FILENAME = "howaboua-pi-stuff-changelog.json";
|
|
19
|
-
const SUPPRESS_KEY = "suppress";
|
|
20
|
-
const LOCK_STALE_MS = 30_000;
|
|
21
|
-
const LOCK_TIMEOUT_MS = 2_000;
|
|
22
|
-
|
|
23
|
-
interface PackageMetadata {
|
|
24
|
-
name: string;
|
|
25
|
-
version: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
interface PackageRegistration extends PackageMetadata {
|
|
29
|
-
changelogPath: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
interface RegistrationEvent {
|
|
33
|
-
accept: () => void;
|
|
34
|
-
registration: PackageRegistration;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
interface ChangelogEntry {
|
|
38
|
-
content: string;
|
|
39
|
-
version: string;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
interface ChangelogEntryData {
|
|
43
|
-
markdown: string;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
type ChangelogState = Record<string, boolean | string>;
|
|
47
|
-
|
|
48
|
-
function packageRegistration(): PackageRegistration {
|
|
49
|
-
const packageDirectory = fileURLToPath(new URL(".", import.meta.url));
|
|
50
|
-
const metadata = JSON.parse(
|
|
51
|
-
readFileSync(join(packageDirectory, "package.json"), "utf8"),
|
|
52
|
-
) as Partial<PackageMetadata>;
|
|
53
|
-
if (typeof metadata.name !== "string" || typeof metadata.version !== "string")
|
|
54
|
-
throw new Error(`Invalid package metadata in ${packageDirectory}`);
|
|
55
|
-
return {
|
|
56
|
-
name: metadata.name,
|
|
57
|
-
version: metadata.version,
|
|
58
|
-
changelogPath: join(packageDirectory, "CHANGELOG.md"),
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function isRegistrationEvent(value: unknown): value is RegistrationEvent {
|
|
63
|
-
if (!value || typeof value !== "object") return false;
|
|
64
|
-
const event = value as Partial<RegistrationEvent>;
|
|
65
|
-
return (
|
|
66
|
-
typeof event.accept === "function" &&
|
|
67
|
-
typeof event.registration?.name === "string" &&
|
|
68
|
-
typeof event.registration.version === "string" &&
|
|
69
|
-
typeof event.registration.changelogPath === "string"
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function parseChangelog(markdown: string): ChangelogEntry[] {
|
|
74
|
-
const entries: ChangelogEntry[] = [];
|
|
75
|
-
let currentLines: string[] = [];
|
|
76
|
-
let currentVersion: string | undefined;
|
|
77
|
-
|
|
78
|
-
for (const line of markdown.split("\n")) {
|
|
79
|
-
const version = line.match(/^##\s+\[?(\d+\.\d+\.\d+)\]?(?:\s.*)?$/)?.[1];
|
|
80
|
-
if (version) {
|
|
81
|
-
if (currentVersion)
|
|
82
|
-
entries.push({
|
|
83
|
-
content: currentLines.join("\n").trim(),
|
|
84
|
-
version: currentVersion,
|
|
85
|
-
});
|
|
86
|
-
currentVersion = version;
|
|
87
|
-
currentLines = [line];
|
|
88
|
-
} else if (currentVersion) {
|
|
89
|
-
currentLines.push(line);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (currentVersion)
|
|
94
|
-
entries.push({
|
|
95
|
-
content: currentLines.join("\n").trim(),
|
|
96
|
-
version: currentVersion,
|
|
97
|
-
});
|
|
98
|
-
return entries;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function compareVersions(left: string, right: string): number {
|
|
102
|
-
const leftParts = left.split(".").map(Number);
|
|
103
|
-
const rightParts = right.split(".").map(Number);
|
|
104
|
-
for (let index = 0; index < 3; index++) {
|
|
105
|
-
const difference = (leftParts[index] ?? 0) - (rightParts[index] ?? 0);
|
|
106
|
-
if (difference !== 0) return difference;
|
|
107
|
-
}
|
|
108
|
-
return 0;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function isStableVersion(version: string): boolean {
|
|
112
|
-
return /^\d+\.\d+\.\d+$/.test(version);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function statePath(): string {
|
|
116
|
-
return join(getAgentDir(), STATE_FILENAME);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
async function readState(path: string): Promise<ChangelogState> {
|
|
120
|
-
let text: string;
|
|
121
|
-
try {
|
|
122
|
-
text = await readFile(path, "utf8");
|
|
123
|
-
} catch (error) {
|
|
124
|
-
if ((error as NodeJS.ErrnoException).code === "ENOENT") return {};
|
|
125
|
-
throw error;
|
|
126
|
-
}
|
|
127
|
-
const parsed = JSON.parse(text) as unknown;
|
|
128
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
129
|
-
throw new Error(`${path} must contain a JSON object`);
|
|
130
|
-
for (const [name, value] of Object.entries(parsed)) {
|
|
131
|
-
if (name === SUPPRESS_KEY) {
|
|
132
|
-
if (typeof value !== "boolean")
|
|
133
|
-
throw new Error(`${path} ${SUPPRESS_KEY} must be a boolean`);
|
|
134
|
-
} else if (typeof value !== "string") {
|
|
135
|
-
throw new Error(`${path} version for ${name} must be a string`);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return parsed as ChangelogState;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
async function acquireLock(path: string): Promise<() => Promise<void>> {
|
|
142
|
-
const deadline = Date.now() + LOCK_TIMEOUT_MS;
|
|
143
|
-
while (true) {
|
|
144
|
-
try {
|
|
145
|
-
await mkdir(path);
|
|
146
|
-
return () => rm(path, { force: true, recursive: true });
|
|
147
|
-
} catch (error) {
|
|
148
|
-
if ((error as NodeJS.ErrnoException).code !== "EEXIST") throw error;
|
|
149
|
-
const info = await stat(path).catch(() => undefined);
|
|
150
|
-
if (info && Date.now() - info.mtimeMs > LOCK_STALE_MS) {
|
|
151
|
-
await rm(path, { force: true, recursive: true });
|
|
152
|
-
continue;
|
|
153
|
-
}
|
|
154
|
-
if (Date.now() >= deadline)
|
|
155
|
-
throw new Error(`Timed out waiting for ${path}`);
|
|
156
|
-
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
async function writeState(path: string, state: ChangelogState): Promise<void> {
|
|
162
|
-
await mkdir(dirname(path), { mode: 0o700, recursive: true });
|
|
163
|
-
const temporaryPath = `${path}.${process.pid}.${randomUUID()}.tmp`;
|
|
164
|
-
try {
|
|
165
|
-
const ordered = Object.fromEntries(
|
|
166
|
-
Object.entries(state).sort(([left], [right]) =>
|
|
167
|
-
left.localeCompare(right),
|
|
168
|
-
),
|
|
169
|
-
);
|
|
170
|
-
await writeFile(temporaryPath, `${JSON.stringify(ordered, null, 2)}\n`, {
|
|
171
|
-
encoding: "utf8",
|
|
172
|
-
mode: 0o600,
|
|
173
|
-
});
|
|
174
|
-
await rename(temporaryPath, path);
|
|
175
|
-
} catch (error) {
|
|
176
|
-
await rm(temporaryPath, { force: true });
|
|
177
|
-
throw error;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function packageMarkdown(
|
|
182
|
-
registration: PackageRegistration,
|
|
183
|
-
entries: ChangelogEntry[],
|
|
184
|
-
): string {
|
|
185
|
-
const body = (entry: ChangelogEntry) =>
|
|
186
|
-
entry.content
|
|
187
|
-
.replace(/^##[^\n]*\n*/, "")
|
|
188
|
-
.replace(/^###\s+(?:Changes|Minor Changes|Patch Changes)\s*\n*/gim, "")
|
|
189
|
-
.replace(/^###\s+(.+)$/gm, "**$1**");
|
|
190
|
-
if (entries.length === 1) {
|
|
191
|
-
const [entry] = entries;
|
|
192
|
-
if (!entry) return "";
|
|
193
|
-
return `## ${registration.name} ${entry.version}\n\n${body(entry)}`;
|
|
194
|
-
}
|
|
195
|
-
return [
|
|
196
|
-
`## ${registration.name}`,
|
|
197
|
-
...entries.map((entry) => `**${entry.version}**\n\n${body(entry)}`),
|
|
198
|
-
].join("\n\n");
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
async function claimUpdates(
|
|
202
|
-
registrations: Iterable<PackageRegistration>,
|
|
203
|
-
): Promise<{ errors: string[]; markdown?: string }> {
|
|
204
|
-
const stableRegistrations = [...registrations]
|
|
205
|
-
.filter((registration) => isStableVersion(registration.version))
|
|
206
|
-
.sort((left, right) => left.name.localeCompare(right.name));
|
|
207
|
-
if (stableRegistrations.length === 0) return { errors: [] };
|
|
208
|
-
const path = statePath();
|
|
209
|
-
await mkdir(dirname(path), { mode: 0o700, recursive: true });
|
|
210
|
-
const release = await acquireLock(`${path}.lock`);
|
|
211
|
-
try {
|
|
212
|
-
const state = await readState(path);
|
|
213
|
-
const errors: string[] = [];
|
|
214
|
-
const sections: string[] = [];
|
|
215
|
-
let changed = false;
|
|
216
|
-
if (state[SUPPRESS_KEY] === true) {
|
|
217
|
-
for (const registration of stableRegistrations) {
|
|
218
|
-
const seenVersion = state[registration.name];
|
|
219
|
-
if (
|
|
220
|
-
typeof seenVersion !== "string" ||
|
|
221
|
-
compareVersions(registration.version, seenVersion) > 0
|
|
222
|
-
) {
|
|
223
|
-
state[registration.name] = registration.version;
|
|
224
|
-
changed = true;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
if (changed) await writeState(path, state);
|
|
228
|
-
return { errors };
|
|
229
|
-
}
|
|
230
|
-
for (const registration of stableRegistrations) {
|
|
231
|
-
const seenVersion = state[registration.name];
|
|
232
|
-
if (
|
|
233
|
-
typeof seenVersion === "string" &&
|
|
234
|
-
compareVersions(registration.version, seenVersion) <= 0
|
|
235
|
-
)
|
|
236
|
-
continue;
|
|
237
|
-
try {
|
|
238
|
-
const entries = parseChangelog(
|
|
239
|
-
await readFile(registration.changelogPath, "utf8"),
|
|
240
|
-
).filter(
|
|
241
|
-
(entry) =>
|
|
242
|
-
compareVersions(entry.version, registration.version) <= 0 &&
|
|
243
|
-
(typeof seenVersion === "string"
|
|
244
|
-
? compareVersions(entry.version, seenVersion) > 0
|
|
245
|
-
: entry.version === registration.version),
|
|
246
|
-
);
|
|
247
|
-
if (entries.length === 0) {
|
|
248
|
-
errors.push(
|
|
249
|
-
`No ${registration.version} changelog entry found for ${registration.name}`,
|
|
250
|
-
);
|
|
251
|
-
continue;
|
|
252
|
-
}
|
|
253
|
-
sections.push(packageMarkdown(registration, entries));
|
|
254
|
-
state[registration.name] = registration.version;
|
|
255
|
-
changed = true;
|
|
256
|
-
} catch (error) {
|
|
257
|
-
errors.push(
|
|
258
|
-
`Could not read the ${registration.name} changelog: ${error instanceof Error ? error.message : String(error)}`,
|
|
259
|
-
);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
if (changed) await writeState(path, state);
|
|
263
|
-
return {
|
|
264
|
-
errors,
|
|
265
|
-
...(sections.length > 0 ? { markdown: sections.join("\n\n") } : {}),
|
|
266
|
-
};
|
|
267
|
-
} finally {
|
|
268
|
-
await release();
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
function registerCoordinator(
|
|
273
|
-
pi: ExtensionAPI,
|
|
274
|
-
registration: PackageRegistration,
|
|
275
|
-
): void {
|
|
276
|
-
let accepted = false;
|
|
277
|
-
pi.events.emit(REGISTRATION_CHANNEL, {
|
|
278
|
-
registration,
|
|
279
|
-
accept: () => {
|
|
280
|
-
accepted = true;
|
|
281
|
-
},
|
|
282
|
-
} satisfies RegistrationEvent);
|
|
283
|
-
if (accepted) return;
|
|
284
|
-
|
|
285
|
-
const registrations = new Map([[registration.name, registration]]);
|
|
286
|
-
pi.events.on(REGISTRATION_CHANNEL, (value) => {
|
|
287
|
-
if (!isRegistrationEvent(value)) return;
|
|
288
|
-
registrations.set(value.registration.name, value.registration);
|
|
289
|
-
value.accept();
|
|
290
|
-
});
|
|
291
|
-
pi.registerEntryRenderer<ChangelogEntryData>(
|
|
292
|
-
ENTRY_TYPE,
|
|
293
|
-
(entry, _options, theme) => {
|
|
294
|
-
if (!entry.data) return undefined;
|
|
295
|
-
const container = new Container();
|
|
296
|
-
container.addChild(new DynamicBorder());
|
|
297
|
-
container.addChild(
|
|
298
|
-
new Text(theme.bold(theme.fg("accent", "What's New")), 1, 0),
|
|
299
|
-
);
|
|
300
|
-
container.addChild(new Spacer(1));
|
|
301
|
-
container.addChild(
|
|
302
|
-
new Markdown(entry.data.markdown.trim(), 1, 0, getMarkdownTheme()),
|
|
303
|
-
);
|
|
304
|
-
container.addChild(new Spacer(1));
|
|
305
|
-
container.addChild(new DynamicBorder());
|
|
306
|
-
return container;
|
|
307
|
-
},
|
|
308
|
-
);
|
|
309
|
-
pi.on("session_start", async (event, ctx) => {
|
|
310
|
-
if (event.reason === "reload" || ctx.mode !== "tui") return;
|
|
311
|
-
if (
|
|
312
|
-
ctx.sessionManager
|
|
313
|
-
.getEntries()
|
|
314
|
-
.some((entry) =>
|
|
315
|
-
["branch_summary", "compaction", "message"].includes(entry.type),
|
|
316
|
-
)
|
|
317
|
-
)
|
|
318
|
-
return;
|
|
319
|
-
try {
|
|
320
|
-
const update = await claimUpdates(registrations.values());
|
|
321
|
-
if (update.markdown)
|
|
322
|
-
pi.appendEntry<ChangelogEntryData>(ENTRY_TYPE, {
|
|
323
|
-
markdown: update.markdown,
|
|
324
|
-
});
|
|
325
|
-
for (const error of update.errors) ctx.ui.notify(error, "warning");
|
|
326
|
-
} catch (error) {
|
|
327
|
-
ctx.ui.notify(
|
|
328
|
-
`Could not update Howaboua changelog state: ${error instanceof Error ? error.message : String(error)}`,
|
|
329
|
-
"warning",
|
|
330
|
-
);
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
export default function howabouaPackageChangelog(pi: ExtensionAPI): void {
|
|
336
|
-
registerCoordinator(pi, packageRegistration());
|
|
337
|
-
}
|