@howaboua/pi-subagent-review 0.2.14 → 0.2.16
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/package.json +3 -3
- package/src/config.ts +1 -1
- package/src/messages.ts +32 -0
- package/src/review-command.ts +8 -1
- package/src/summary-session.ts +30 -7
- package/src/tree-summary.ts +10 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@howaboua/pi-subagent-review",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.16",
|
|
4
4
|
"description": "Pi extension that adds /review via an isolated review subagent.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.ts",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"format": "biome check --write ."
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@earendil-works/pi-ai": "0.
|
|
54
|
-
"@earendil-works/pi-coding-agent": "0.
|
|
53
|
+
"@earendil-works/pi-ai": "0.84.1",
|
|
54
|
+
"@earendil-works/pi-coding-agent": "0.84.1",
|
|
55
55
|
"@types/node": "^24.10.0",
|
|
56
56
|
"typescript": "^5.9.3",
|
|
57
57
|
"@biomejs/biome": "^2.4.16"
|
package/src/config.ts
CHANGED
package/src/messages.ts
CHANGED
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
} from "./constants.js";
|
|
10
10
|
import type { ReviewContext } from "./types.js";
|
|
11
11
|
|
|
12
|
+
const REALTIME_VOICE_PROMPT_CHANNEL =
|
|
13
|
+
"@howaboua/pi-codex-conversion/realtime-voice-prompt/v1";
|
|
12
14
|
const REVIEW_LOOP_PREFACE_MESSAGE = [
|
|
13
15
|
"A review subagent is about to inspect the repository in isolation. Its findings are advisory only and may be wrong, overbroad, or missing session context.",
|
|
14
16
|
"",
|
|
@@ -27,6 +29,36 @@ const REVIEW_LOOP_PREFACE_MESSAGE = [
|
|
|
27
29
|
"Only after triage, explain what you recommend doing next. If a finding is not obviously required for the current implementation, do not change code for it.",
|
|
28
30
|
].join("\n");
|
|
29
31
|
|
|
32
|
+
const REVIEW_SUMMARY_STARTED_PROMPT =
|
|
33
|
+
"The current conversation is being summarised to prepare context for an isolated code review. Please announce this briefly in your natural voice.";
|
|
34
|
+
const REVIEW_FINDINGS_READY_PROMPT =
|
|
35
|
+
"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.";
|
|
36
|
+
|
|
37
|
+
function announceReviewStatus(
|
|
38
|
+
pi: ExtensionAPI,
|
|
39
|
+
id: string,
|
|
40
|
+
prompt: string,
|
|
41
|
+
): void {
|
|
42
|
+
pi.events.emit(REALTIME_VOICE_PROMPT_CHANNEL, { id, active: true, prompt });
|
|
43
|
+
pi.events.emit(REALTIME_VOICE_PROMPT_CHANNEL, { id, active: false, prompt });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function announceReviewSummaryStarted(pi: ExtensionAPI): void {
|
|
47
|
+
announceReviewStatus(
|
|
48
|
+
pi,
|
|
49
|
+
"pi-subagent-review:summary-started",
|
|
50
|
+
REVIEW_SUMMARY_STARTED_PROMPT,
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function announceReviewFindingsReady(pi: ExtensionAPI): void {
|
|
55
|
+
announceReviewStatus(
|
|
56
|
+
pi,
|
|
57
|
+
"pi-subagent-review:findings-ready",
|
|
58
|
+
REVIEW_FINDINGS_READY_PROMPT,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
30
62
|
function getReviewPrefaceMessageId(
|
|
31
63
|
ctx: ExtensionCommandContext,
|
|
32
64
|
): string | undefined {
|
package/src/review-command.ts
CHANGED
|
@@ -2,7 +2,12 @@ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
|
2
2
|
import { resolveReviewConfig } from "./config.js";
|
|
3
3
|
import { REVIEW_COMMAND } from "./constants.js";
|
|
4
4
|
import { buildReviewConversationSummary } from "./conversation-summary.js";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
announceReviewFindingsReady,
|
|
7
|
+
announceReviewSummaryStarted,
|
|
8
|
+
sendReviewFindings,
|
|
9
|
+
sendReviewPreface,
|
|
10
|
+
} from "./messages.js";
|
|
6
11
|
import { detectReviewContext } from "./review-context.js";
|
|
7
12
|
import {
|
|
8
13
|
appendReviewLoopBoundary,
|
|
@@ -135,6 +140,7 @@ export function registerReviewCommand(
|
|
|
135
140
|
"warning",
|
|
136
141
|
);
|
|
137
142
|
setReviewWidget("Preparing review context…");
|
|
143
|
+
announceReviewSummaryStarted(pi);
|
|
138
144
|
conversationSummary = await buildReviewConversationSummary(
|
|
139
145
|
ctx,
|
|
140
146
|
reviewConfig,
|
|
@@ -178,6 +184,7 @@ export function registerReviewCommand(
|
|
|
178
184
|
);
|
|
179
185
|
|
|
180
186
|
sendReviewFindings(pi, ctx, review, finalOutput);
|
|
187
|
+
announceReviewFindingsReady(pi);
|
|
181
188
|
ctx.ui.notify(
|
|
182
189
|
`Review findings sent back to the main agent from /${REVIEW_COMMAND}.`,
|
|
183
190
|
"info",
|
package/src/summary-session.ts
CHANGED
|
@@ -62,6 +62,18 @@ function lastAssistantMessage(
|
|
|
62
62
|
return undefined;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
function mergeRequestHeaders(
|
|
66
|
+
configured: Record<string, string> | undefined,
|
|
67
|
+
resolved: Record<string, string | null> | undefined,
|
|
68
|
+
): Record<string, string> {
|
|
69
|
+
const headers = new Headers(configured);
|
|
70
|
+
for (const [name, value] of Object.entries(resolved ?? {})) {
|
|
71
|
+
if (value === null) headers.delete(name);
|
|
72
|
+
else headers.set(name, value);
|
|
73
|
+
}
|
|
74
|
+
return Object.fromEntries(headers.entries());
|
|
75
|
+
}
|
|
76
|
+
|
|
65
77
|
export async function completeSummary(
|
|
66
78
|
ctx: ExtensionCommandContext,
|
|
67
79
|
config: ResolvedReviewConfig,
|
|
@@ -76,6 +88,9 @@ export async function completeSummary(
|
|
|
76
88
|
throw new Error(`Summary model not found: ${config.summary.model}`);
|
|
77
89
|
const requestAuth = await ctx.modelRegistry.getApiKeyAndHeaders(model);
|
|
78
90
|
if (!requestAuth.ok) throw new Error(requestAuth.error);
|
|
91
|
+
const requestModel = requestAuth.baseUrl
|
|
92
|
+
? { ...model, baseUrl: requestAuth.baseUrl }
|
|
93
|
+
: model;
|
|
79
94
|
const persistedCredential = readStoredCredential(model.provider);
|
|
80
95
|
const storedCredential =
|
|
81
96
|
persistedCredential?.type === "oauth" &&
|
|
@@ -100,17 +115,25 @@ export async function completeSummary(
|
|
|
100
115
|
const registeredProvider = ctx.modelRegistry.getRegisteredProviderConfig(
|
|
101
116
|
model.provider,
|
|
102
117
|
);
|
|
103
|
-
if (
|
|
104
|
-
|
|
118
|
+
if (
|
|
119
|
+
registeredProvider ||
|
|
120
|
+
requestAuth.apiKey ||
|
|
121
|
+
requestAuth.headers ||
|
|
122
|
+
requestAuth.baseUrl
|
|
123
|
+
) {
|
|
124
|
+
const {
|
|
125
|
+
oauth,
|
|
126
|
+
headers: configuredHeaders,
|
|
127
|
+
...providerConfig
|
|
128
|
+
} = registeredProvider ?? {};
|
|
129
|
+
const headers = mergeRequestHeaders(configuredHeaders, requestAuth.headers);
|
|
105
130
|
modelRuntime.registerProvider(model.provider, {
|
|
106
131
|
...providerConfig,
|
|
132
|
+
...(requestAuth.baseUrl ? { baseUrl: requestAuth.baseUrl } : {}),
|
|
107
133
|
...(storedCredential?.type !== "oauth" && requestAuth.apiKey
|
|
108
134
|
? { apiKey: requestAuth.apiKey }
|
|
109
135
|
: {}),
|
|
110
|
-
headers
|
|
111
|
-
...registeredProvider?.headers,
|
|
112
|
-
...requestAuth.headers,
|
|
113
|
-
},
|
|
136
|
+
headers,
|
|
114
137
|
...(storedCredential?.type === "oauth" && oauth ? { oauth } : {}),
|
|
115
138
|
});
|
|
116
139
|
}
|
|
@@ -133,7 +156,7 @@ export async function completeSummary(
|
|
|
133
156
|
|
|
134
157
|
const { session } = await createAgentSession({
|
|
135
158
|
cwd: ctx.cwd,
|
|
136
|
-
model,
|
|
159
|
+
model: requestModel,
|
|
137
160
|
thinkingLevel: config.summary.thinking,
|
|
138
161
|
modelRuntime,
|
|
139
162
|
noTools: "all",
|
package/src/tree-summary.ts
CHANGED
|
@@ -59,26 +59,29 @@ export function registerTreeSummaryModel(
|
|
|
59
59
|
);
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
|
+
const summaryModel = auth.baseUrl
|
|
63
|
+
? { ...model, baseUrl: auth.baseUrl }
|
|
64
|
+
: model;
|
|
62
65
|
|
|
63
66
|
try {
|
|
64
67
|
const result = await generateBranchSummary(
|
|
65
68
|
event.preparation.entriesToSummarize,
|
|
66
69
|
{
|
|
67
|
-
model,
|
|
70
|
+
model: summaryModel,
|
|
68
71
|
signal: event.signal,
|
|
69
|
-
...(auth.apiKey !== undefined ? { apiKey: auth.apiKey } : {}),
|
|
70
|
-
...(auth.headers !== undefined ? { headers: auth.headers } : {}),
|
|
71
|
-
...(auth.env !== undefined ? { env: auth.env } : {}),
|
|
72
72
|
...(event.preparation.customInstructions !== undefined
|
|
73
73
|
? { customInstructions: event.preparation.customInstructions }
|
|
74
74
|
: {}),
|
|
75
75
|
...(event.preparation.replaceInstructions !== undefined
|
|
76
76
|
? { replaceInstructions: event.preparation.replaceInstructions }
|
|
77
77
|
: {}),
|
|
78
|
-
streamFn: (
|
|
79
|
-
provider.streamSimple(
|
|
78
|
+
streamFn: (streamModel, context, options) =>
|
|
79
|
+
provider.streamSimple(streamModel, context, {
|
|
80
80
|
...options,
|
|
81
|
-
...(
|
|
81
|
+
...(auth.apiKey !== undefined ? { apiKey: auth.apiKey } : {}),
|
|
82
|
+
...(auth.headers !== undefined ? { headers: auth.headers } : {}),
|
|
83
|
+
...(auth.env !== undefined ? { env: auth.env } : {}),
|
|
84
|
+
...(streamModel.reasoning && request.config.thinking !== "off"
|
|
82
85
|
? { reasoning: request.config.thinking }
|
|
83
86
|
: {}),
|
|
84
87
|
}),
|