@howaboua/pi-subagent-review 0.2.1 → 0.2.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/README.md +1 -1
- package/package.json +5 -5
- package/src/messages.ts +55 -13
- package/src/review-command.ts +13 -14
- package/src/review-loop.ts +11 -0
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ It runs an isolated review subagent against your current repo, optionally prepar
|
|
|
23
23
|
|
|
24
24
|
`/review loop` starts a review loop. It sets a review-specific marker at the current conversation point, strips the `loop` word from the review guidance, and then runs the normal review.
|
|
25
25
|
|
|
26
|
-
The first `/review` in a session branch also adds a visible advisory preface without starting an agent turn. The preface
|
|
26
|
+
The first `/review` in a session branch also adds a visible advisory preface without starting an agent turn. The preface tells the main agent not to treat review findings as a TODO list, and to summarize and triage them against session context and the current implementation before changing code.
|
|
27
27
|
|
|
28
28
|
After that, plain `/review` detects the active review marker, summarizes the work since that marker back into a compact review-fix increment, advances the review marker, and then runs the next isolated review pass from the compacted point. If the stored marker is gone, `/review` simply behaves like a normal review.
|
|
29
29
|
|
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.3",
|
|
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.
|
|
42
|
-
"@earendil-works/pi-coding-agent": "^0.
|
|
41
|
+
"@earendil-works/pi-ai": "^0.79.0",
|
|
42
|
+
"@earendil-works/pi-coding-agent": "^0.79.0"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"check": "bun run lint && bun run typecheck",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"format": "biome check --write ."
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@earendil-works/pi-ai": "^0.
|
|
53
|
-
"@earendil-works/pi-coding-agent": "^0.
|
|
52
|
+
"@earendil-works/pi-ai": "^0.79.0",
|
|
53
|
+
"@earendil-works/pi-coding-agent": "^0.79.0",
|
|
54
54
|
"@types/node": "^24.10.0",
|
|
55
55
|
"typescript": "^5.9.3",
|
|
56
56
|
"@biomejs/biome": "^2.4.16"
|
package/src/messages.ts
CHANGED
|
@@ -6,33 +6,50 @@ import { REVIEW_COMMAND } from "./constants.js";
|
|
|
6
6
|
import type { ReviewContext } from "./types.js";
|
|
7
7
|
|
|
8
8
|
export const REVIEW_LOOP_PREFACE_MESSAGE_TYPE = "subagent-review-preface";
|
|
9
|
+
export const REVIEW_FINDINGS_MESSAGE_TYPE = "subagent-review-findings";
|
|
9
10
|
|
|
10
11
|
export const REVIEW_LOOP_PREFACE_MESSAGE = [
|
|
11
|
-
"
|
|
12
|
+
"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.",
|
|
12
13
|
"",
|
|
13
|
-
"
|
|
14
|
+
"Do not treat review findings as a TODO list. Do not implement review findings automatically.",
|
|
14
15
|
"",
|
|
15
|
-
"When findings
|
|
16
|
+
"When findings return, compare each one against the user’s actual request, prior conversation, accepted decisions, intentional tradeoffs from this session, and the current implementation.",
|
|
16
17
|
"",
|
|
17
|
-
"
|
|
18
|
+
"Default response: summarize and triage, not code.",
|
|
19
|
+
"",
|
|
20
|
+
"For each finding, mark one of:",
|
|
21
|
+
"",
|
|
22
|
+
"- address: concrete, in-scope, necessary for the current implementation",
|
|
23
|
+
"- defer: plausible but outside the current work",
|
|
24
|
+
"- skip: stylistic, speculative, preference-based, overengineered, or not useful",
|
|
25
|
+
"",
|
|
26
|
+
"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.",
|
|
18
27
|
].join("\n");
|
|
19
28
|
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
|
|
29
|
+
function getReviewPrefaceMessageId(
|
|
30
|
+
ctx: ExtensionCommandContext,
|
|
31
|
+
): string | undefined {
|
|
32
|
+
let messageId: string | undefined;
|
|
33
|
+
for (const entry of ctx.sessionManager.getBranch()) {
|
|
34
|
+
if (
|
|
23
35
|
entry.type === "custom_message" &&
|
|
24
36
|
entry.customType === REVIEW_LOOP_PREFACE_MESSAGE_TYPE
|
|
25
|
-
)
|
|
26
|
-
|
|
37
|
+
) {
|
|
38
|
+
messageId = entry.id;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return messageId;
|
|
27
42
|
}
|
|
28
43
|
|
|
29
44
|
export function sendReviewPrefaceOnce(
|
|
30
45
|
pi: ExtensionAPI,
|
|
31
46
|
ctx: ExtensionCommandContext,
|
|
32
47
|
details: { markerId?: string } = {},
|
|
33
|
-
):
|
|
34
|
-
|
|
48
|
+
): { inserted: boolean; entryId?: string } {
|
|
49
|
+
const existingId = getReviewPrefaceMessageId(ctx);
|
|
50
|
+
if (existingId) return { inserted: false, entryId: existingId };
|
|
35
51
|
|
|
52
|
+
const previousLeafId = ctx.sessionManager.getLeafId();
|
|
36
53
|
pi.sendMessage(
|
|
37
54
|
{
|
|
38
55
|
customType: REVIEW_LOOP_PREFACE_MESSAGE_TYPE,
|
|
@@ -42,6 +59,12 @@ export function sendReviewPrefaceOnce(
|
|
|
42
59
|
},
|
|
43
60
|
{ triggerTurn: false },
|
|
44
61
|
);
|
|
62
|
+
|
|
63
|
+
const nextLeafId = ctx.sessionManager.getLeafId();
|
|
64
|
+
if (nextLeafId && nextLeafId !== previousLeafId) {
|
|
65
|
+
return { inserted: true, entryId: nextLeafId };
|
|
66
|
+
}
|
|
67
|
+
return { inserted: true };
|
|
45
68
|
}
|
|
46
69
|
|
|
47
70
|
export function buildReviewScopeText(review: ReviewContext): string {
|
|
@@ -67,8 +90,27 @@ export function buildReviewUserMessage(
|
|
|
67
90
|
"",
|
|
68
91
|
"These findings are advisory output from an isolated review subagent.",
|
|
69
92
|
"",
|
|
70
|
-
"
|
|
93
|
+
"Do not treat review findings as a TODO list. Default response: summarize and triage, not code.",
|
|
94
|
+
"",
|
|
95
|
+
"Compare each finding against the user’s actual request, prior conversation, accepted decisions, intentional tradeoffs from this session, and the current implementation.",
|
|
71
96
|
"",
|
|
72
|
-
"
|
|
97
|
+
"Mark each finding as address, defer, or skip. Only change code for findings that are obviously required for the current implementation.",
|
|
73
98
|
].join("\n");
|
|
74
99
|
}
|
|
100
|
+
|
|
101
|
+
export function sendReviewFindings(
|
|
102
|
+
pi: ExtensionAPI,
|
|
103
|
+
ctx: ExtensionCommandContext,
|
|
104
|
+
review: ReviewContext,
|
|
105
|
+
findings: string,
|
|
106
|
+
): void {
|
|
107
|
+
pi.sendMessage(
|
|
108
|
+
{
|
|
109
|
+
customType: REVIEW_FINDINGS_MESSAGE_TYPE,
|
|
110
|
+
content: buildReviewUserMessage(review, findings),
|
|
111
|
+
display: true,
|
|
112
|
+
details: { repoRoot: review.repoRoot, scope: review.scope },
|
|
113
|
+
},
|
|
114
|
+
ctx.isIdle() ? { triggerTurn: true } : { deliverAs: "followUp" },
|
|
115
|
+
);
|
|
116
|
+
}
|
package/src/review-command.ts
CHANGED
|
@@ -6,9 +6,10 @@ import {
|
|
|
6
6
|
} from "./config.js";
|
|
7
7
|
import { REVIEW_COMMAND } from "./constants.js";
|
|
8
8
|
import { buildReviewConversationSummary } from "./conversation-summary.js";
|
|
9
|
-
import {
|
|
9
|
+
import { sendReviewFindings, sendReviewPrefaceOnce } from "./messages.js";
|
|
10
10
|
import { buildReviewTask, detectReviewContext } from "./review.js";
|
|
11
11
|
import {
|
|
12
|
+
appendReviewLoopBoundary,
|
|
12
13
|
applyReviewLoopMarker,
|
|
13
14
|
getSemanticLeafId,
|
|
14
15
|
parseReviewArgs,
|
|
@@ -20,10 +21,9 @@ import { getFinalOutput, runReviewSubagent } from "./subagent.js";
|
|
|
20
21
|
export function registerReviewCommand(pi: ExtensionAPI) {
|
|
21
22
|
pi.registerCommand(REVIEW_COMMAND, {
|
|
22
23
|
description:
|
|
23
|
-
"Run an isolated code-review subagent against the current repo and send
|
|
24
|
+
"Run an isolated code-review subagent against the current repo and send advisory findings back as custom review output",
|
|
24
25
|
handler: async (args, ctx) => {
|
|
25
26
|
const parsedArgs = parseReviewArgs(args);
|
|
26
|
-
const reviewPrefaceDetails: { markerId?: string } = {};
|
|
27
27
|
const setReviewWidget = (message?: string) => {
|
|
28
28
|
ctx.ui.setWidget(
|
|
29
29
|
REVIEW_COMMAND,
|
|
@@ -72,10 +72,12 @@ export function registerReviewCommand(pi: ExtensionAPI) {
|
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
sendReviewPrefaceOnce(pi, ctx);
|
|
76
|
+
|
|
75
77
|
if (parsedArgs.startLoop) {
|
|
76
|
-
const targetId =
|
|
78
|
+
const targetId =
|
|
79
|
+
appendReviewLoopBoundary(pi, ctx) ?? getSemanticLeafId(ctx);
|
|
77
80
|
if (targetId) {
|
|
78
|
-
reviewPrefaceDetails.markerId = targetId;
|
|
79
81
|
applyReviewLoopMarker(
|
|
80
82
|
pi,
|
|
81
83
|
ctx,
|
|
@@ -85,14 +87,13 @@ export function registerReviewCommand(pi: ExtensionAPI) {
|
|
|
85
87
|
ctx.ui.notify("Review loop marker set", "info");
|
|
86
88
|
}
|
|
87
89
|
}
|
|
88
|
-
sendReviewPrefaceOnce(pi, ctx, reviewPrefaceDetails);
|
|
89
90
|
|
|
90
91
|
if (!review.hasAnyChanges) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
sendReviewFindings(
|
|
93
|
+
pi,
|
|
94
|
+
ctx,
|
|
95
|
+
review,
|
|
96
|
+
"No changes found relative to the selected base branch.",
|
|
96
97
|
);
|
|
97
98
|
ctx.ui.notify(
|
|
98
99
|
`No changes found relative to ${review.baseBranch}; sent summary to the agent.`,
|
|
@@ -155,9 +156,7 @@ export function registerReviewCommand(pi: ExtensionAPI) {
|
|
|
155
156
|
details.errorMessage || details.stderr || finalOutput,
|
|
156
157
|
);
|
|
157
158
|
|
|
158
|
-
|
|
159
|
-
if (ctx.isIdle()) pi.sendUserMessage(message);
|
|
160
|
-
else pi.sendUserMessage(message, { deliverAs: "followUp" });
|
|
159
|
+
sendReviewFindings(pi, ctx, review, finalOutput);
|
|
161
160
|
ctx.ui.notify(
|
|
162
161
|
`Review findings sent back to the main agent from /${REVIEW_COMMAND}.`,
|
|
163
162
|
"info",
|
package/src/review-loop.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
} from "@earendil-works/pi-coding-agent";
|
|
5
5
|
|
|
6
6
|
export const REVIEW_LOOP_STATE_ENTRY = "subagent-review-loop-state";
|
|
7
|
+
export const REVIEW_LOOP_BOUNDARY_ENTRY = "subagent-review-loop-boundary";
|
|
7
8
|
export const REVIEW_LOOP_MARKER_LABEL = "review";
|
|
8
9
|
export const REVIEW_LOOP_WIDGET = "subagent-review-loop";
|
|
9
10
|
export const REVIEW_LOOP_SUMMARY_PROMPT = [
|
|
@@ -106,6 +107,16 @@ export function applyReviewLoopMarker(
|
|
|
106
107
|
} satisfies ReviewLoopState);
|
|
107
108
|
}
|
|
108
109
|
|
|
110
|
+
export function appendReviewLoopBoundary(
|
|
111
|
+
pi: ExtensionAPI,
|
|
112
|
+
ctx: ExtensionCommandContext,
|
|
113
|
+
): string | undefined {
|
|
114
|
+
const previousLeafId = ctx.sessionManager.getLeafId();
|
|
115
|
+
pi.appendEntry(REVIEW_LOOP_BOUNDARY_ENTRY, { version: 1 });
|
|
116
|
+
const nextLeafId = ctx.sessionManager.getLeafId();
|
|
117
|
+
return nextLeafId && nextLeafId !== previousLeafId ? nextLeafId : undefined;
|
|
118
|
+
}
|
|
119
|
+
|
|
109
120
|
export async function summarizeReviewLoopIncrement(
|
|
110
121
|
pi: ExtensionAPI,
|
|
111
122
|
ctx: ExtensionCommandContext,
|