@howaboua/pi-subagent-review 0.2.10 → 0.2.11
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 +5 -5
- package/src/conversation-summary.ts +76 -3
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.11",
|
|
4
4
|
"description": "Pi extension that adds /review via an isolated review subagent.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.ts",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
]
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@earendil-works/pi-ai": ">=0.80.
|
|
42
|
-
"@earendil-works/pi-coding-agent": ">=0.80.
|
|
41
|
+
"@earendil-works/pi-ai": ">=0.80.8",
|
|
42
|
+
"@earendil-works/pi-coding-agent": ">=0.80.8"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"check": "bun run lint && bun run typecheck && bun run test",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"format": "biome check --write ."
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@earendil-works/pi-ai": "0.80.
|
|
54
|
-
"@earendil-works/pi-coding-agent": "0.80.
|
|
53
|
+
"@earendil-works/pi-ai": "0.80.8",
|
|
54
|
+
"@earendil-works/pi-coding-agent": "0.80.8",
|
|
55
55
|
"@types/node": "^24.10.0",
|
|
56
56
|
"typescript": "^5.9.3",
|
|
57
57
|
"@biomejs/biome": "^2.4.16"
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
AssistantMessage,
|
|
3
|
+
Credential,
|
|
4
|
+
CredentialStore,
|
|
5
|
+
} from "@earendil-works/pi-ai";
|
|
2
6
|
import {
|
|
3
7
|
createAgentSession,
|
|
4
8
|
DefaultResourceLoader,
|
|
5
9
|
type ExtensionCommandContext,
|
|
6
10
|
getAgentDir,
|
|
11
|
+
ModelRuntime,
|
|
12
|
+
readStoredCredential,
|
|
7
13
|
type SessionEntry,
|
|
8
14
|
SessionManager,
|
|
9
15
|
SettingsManager,
|
|
@@ -13,6 +19,34 @@ import type { ResolvedReviewConfig } from "./types.js";
|
|
|
13
19
|
const SUMMARY_SYSTEM_PROMPT =
|
|
14
20
|
"Summarize supplied conversation context for a separate code-review agent. Follow the user's summary format exactly and do not use tools.";
|
|
15
21
|
|
|
22
|
+
function summaryCredentialStore(
|
|
23
|
+
providerId: string,
|
|
24
|
+
credential: Credential | undefined,
|
|
25
|
+
): CredentialStore {
|
|
26
|
+
const credentials = new Map<string, Credential>();
|
|
27
|
+
if (credential) credentials.set(providerId, credential);
|
|
28
|
+
return {
|
|
29
|
+
async read(id) {
|
|
30
|
+
return credentials.get(id);
|
|
31
|
+
},
|
|
32
|
+
async list() {
|
|
33
|
+
return [...credentials].map(([id, credential]) => ({
|
|
34
|
+
providerId: id,
|
|
35
|
+
type: credential.type,
|
|
36
|
+
}));
|
|
37
|
+
},
|
|
38
|
+
async modify(id, update) {
|
|
39
|
+
const current = credentials.get(id);
|
|
40
|
+
const next = await update(current);
|
|
41
|
+
if (next) credentials.set(id, next);
|
|
42
|
+
return next ?? current;
|
|
43
|
+
},
|
|
44
|
+
async delete(id) {
|
|
45
|
+
credentials.delete(id);
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
16
50
|
function lastAssistantMessage(
|
|
17
51
|
messages: readonly unknown[],
|
|
18
52
|
): AssistantMessage | undefined {
|
|
@@ -41,6 +75,46 @@ async function completeSummary(
|
|
|
41
75
|
const model = ctx.modelRegistry.find(parsed.provider, parsed.modelId);
|
|
42
76
|
if (!model)
|
|
43
77
|
throw new Error(`Summary model not found: ${config.summary.model}`);
|
|
78
|
+
const requestAuth = await ctx.modelRegistry.getApiKeyAndHeaders(model);
|
|
79
|
+
if (!requestAuth.ok) throw new Error(requestAuth.error);
|
|
80
|
+
const persistedCredential = readStoredCredential(model.provider);
|
|
81
|
+
const storedCredential =
|
|
82
|
+
persistedCredential?.type === "oauth" &&
|
|
83
|
+
persistedCredential.access === requestAuth.apiKey
|
|
84
|
+
? persistedCredential
|
|
85
|
+
: undefined;
|
|
86
|
+
const resolvedCredential =
|
|
87
|
+
requestAuth.apiKey || requestAuth.env
|
|
88
|
+
? {
|
|
89
|
+
type: "api_key" as const,
|
|
90
|
+
...(requestAuth.apiKey ? { key: requestAuth.apiKey } : {}),
|
|
91
|
+
...(requestAuth.env ? { env: requestAuth.env } : {}),
|
|
92
|
+
}
|
|
93
|
+
: undefined;
|
|
94
|
+
const modelRuntime = await ModelRuntime.create({
|
|
95
|
+
credentials: summaryCredentialStore(
|
|
96
|
+
model.provider,
|
|
97
|
+
storedCredential ?? resolvedCredential,
|
|
98
|
+
),
|
|
99
|
+
allowModelNetwork: false,
|
|
100
|
+
});
|
|
101
|
+
const registeredProvider = ctx.modelRegistry.getRegisteredProviderConfig(
|
|
102
|
+
model.provider,
|
|
103
|
+
);
|
|
104
|
+
if (registeredProvider || requestAuth.apiKey || requestAuth.headers) {
|
|
105
|
+
const { oauth, ...providerConfig } = registeredProvider ?? {};
|
|
106
|
+
modelRuntime.registerProvider(model.provider, {
|
|
107
|
+
...providerConfig,
|
|
108
|
+
...(storedCredential?.type !== "oauth" && requestAuth.apiKey
|
|
109
|
+
? { apiKey: requestAuth.apiKey }
|
|
110
|
+
: {}),
|
|
111
|
+
headers: {
|
|
112
|
+
...registeredProvider?.headers,
|
|
113
|
+
...requestAuth.headers,
|
|
114
|
+
},
|
|
115
|
+
...(storedCredential?.type === "oauth" && oauth ? { oauth } : {}),
|
|
116
|
+
});
|
|
117
|
+
}
|
|
44
118
|
|
|
45
119
|
const settingsManager = SettingsManager.inMemory({
|
|
46
120
|
compaction: { enabled: false },
|
|
@@ -62,8 +136,7 @@ async function completeSummary(
|
|
|
62
136
|
cwd: ctx.cwd,
|
|
63
137
|
model,
|
|
64
138
|
thinkingLevel: config.summary.thinking,
|
|
65
|
-
|
|
66
|
-
modelRegistry: ctx.modelRegistry,
|
|
139
|
+
modelRuntime,
|
|
67
140
|
noTools: "all",
|
|
68
141
|
resourceLoader,
|
|
69
142
|
sessionManager: SessionManager.inMemory(ctx.cwd),
|