@howaboua/pi-subagent-review 0.2.18 → 0.2.20

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 CHANGED
@@ -1,5 +1,20 @@
1
1
  # @howaboua/pi-subagent-review
2
2
 
3
+ ## 0.2.20
4
+
5
+ - Preserve extension-owned messages while delivering true developer-role policy through compatible Pi Codex Responses adapters.
6
+
7
+ - Add an optional custom-message API that retains caller rendering and restoration fields.
8
+ - Route Shepherdr's unclaimed worker events and orchestration toggles through it, preserving ordinary Pi delivery when unavailable.
9
+ - Send review preface/triage policy and realtime voice start/end guidance as developer messages without elevating raw reviewer findings, spoken delegations, or transcript tails.
10
+ - Keep persisted developer messages in context across model switches, using ordinary Pi conversion on incompatible models.
11
+
12
+ ## 0.2.19
13
+
14
+ ### Changes
15
+
16
+ - [#314](https://github.com/IgorWarzocha/howaboua-pi-stuff/pull/314) [`536910d`](https://github.com/IgorWarzocha/howaboua-pi-stuff/commit/536910d3b0a89f1caaa7a37844bdb80b62c1f844) Thanks [@IgorWarzocha](https://github.com/IgorWarzocha)! - Review a focused JJ revision when its workspace cursor is an empty child commit.
17
+
3
18
  ## 0.2.18
4
19
 
5
20
  ### Changes
package/README.md CHANGED
@@ -24,6 +24,8 @@ Anything after `/review` becomes additional reviewer guidance. A leading `loop`
24
24
 
25
25
  Findings are advisory. The command tells the main agent to verify and categorize them against the current implementation and session context rather than treating them as a TODO list.
26
26
 
27
+ With a compatible optional Pi Codex Responses adapter, the review preface and triage follow-up use developer-role policy. The preface keeps its existing display and deduplication; the follow-up appears as an extension developer message rather than user input. Raw reviewer findings remain lower-authority custom-message content. Without the API or active adapter, ordinary Pi delivery is unchanged.
28
+
27
29
  ## Review scope
28
30
 
29
31
  In a JJ workspace, the extension reviews the active revision before considering an enclosing Git checkout. It pins the active change and commit IDs, reviews against its direct parent by default, and uses `stack=<ancestor revset>` for a cumulative range. The active revision must be conflict-free. The read-only command reviews stored commit content; capture filesystem edits with JJ before invoking `/review`.
package/biome.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://biomejs.dev/schemas/2.4.16/schema.json",
2
+ "$schema": "https://biomejs.dev/schemas/2.5.10/schema.json",
3
3
  "vcs": {
4
4
  "enabled": true,
5
5
  "clientKind": "git",
package/changelog.ts CHANGED
@@ -182,9 +182,19 @@ function packageMarkdown(
182
182
  registration: PackageRegistration,
183
183
  entries: ChangelogEntry[],
184
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
+ }
185
195
  return [
186
196
  `## ${registration.name}`,
187
- ...entries.map((entry) => entry.content.replace(/^##\s+/, "### ")),
197
+ ...entries.map((entry) => `**${entry.version}**\n\n${body(entry)}`),
188
198
  ].join("\n\n");
189
199
  }
190
200
 
package/index.ts CHANGED
@@ -1,12 +1,61 @@
1
1
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
+ import registerPackageChangelog from "./changelog.js";
2
3
  import { ensureConfigFile } from "./src/config.js";
3
4
  import { CHILD_ENV } from "./src/constants.js";
5
+ import type { ReviewDeveloperMessages } from "./src/messages.js";
4
6
  import { registerReviewCommand } from "./src/review-command.js";
5
7
  import { registerTreeSummaryModel } from "./src/tree-summary.js";
6
8
 
7
- export default function (pi: ExtensionAPI) {
9
+ export default async function (pi: ExtensionAPI) {
8
10
  if (process.env[CHILD_ENV] === "1") return;
9
11
 
12
+ registerPackageChangelog(pi);
10
13
  ensureConfigFile();
11
- registerReviewCommand(pi, registerTreeSummaryModel(pi));
14
+ const developerMessages = await loadDeveloperMessages();
15
+ registerReviewCommand(pi, registerTreeSummaryModel(pi), developerMessages);
16
+ }
17
+
18
+ async function loadDeveloperMessages(): Promise<
19
+ ReviewDeveloperMessages | undefined
20
+ > {
21
+ try {
22
+ return await import("@howaboua/pi-codex-conversion/developer-messages");
23
+ } catch (error) {
24
+ if (!isUnavailable(error)) throw error;
25
+ return undefined;
26
+ }
27
+ }
28
+
29
+ function isUnavailable(error: unknown): boolean {
30
+ if (
31
+ !error ||
32
+ typeof error !== "object" ||
33
+ !("code" in error) ||
34
+ !("message" in error) ||
35
+ typeof error.message !== "string"
36
+ )
37
+ return false;
38
+ const packageName = "@howaboua/pi-codex-conversion";
39
+ const moduleName = `${packageName}/developer-messages`;
40
+ if (
41
+ error.code === "ERR_MODULE_NOT_FOUND" ||
42
+ error.code === "MODULE_NOT_FOUND"
43
+ ) {
44
+ const missing = error.message.match(
45
+ /Cannot find (?:package|module) ['"]([^'"]+)['"]/,
46
+ )?.[1];
47
+ const normalized = missing?.replaceAll("\\", "/").replace(/\.js$/, "");
48
+ return (
49
+ missing === packageName ||
50
+ normalized === moduleName ||
51
+ normalized?.endsWith(`/${moduleName}`) === true
52
+ );
53
+ }
54
+ return (
55
+ (error.code === "ERR_PACKAGE_PATH_NOT_EXPORTED" ||
56
+ error.code === "ERR_UNSUPPORTED_DIR_IMPORT") &&
57
+ (error.message.includes(moduleName) ||
58
+ (error.message.includes("Package subpath './developer-messages'") &&
59
+ error.message.includes(packageName)))
60
+ );
12
61
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@howaboua/pi-subagent-review",
3
- "version": "0.2.18",
3
+ "version": "0.2.20",
4
4
  "description": "Pi extension that adds /review via an isolated review subagent.",
5
5
  "type": "module",
6
6
  "main": "index.ts",
@@ -36,14 +36,19 @@
36
36
  },
37
37
  "pi": {
38
38
  "extensions": [
39
- "./changelog.ts",
40
39
  "./index.ts"
41
40
  ]
42
41
  },
43
42
  "peerDependencies": {
44
- "@earendil-works/pi-ai": ">=0.80.8",
45
- "@earendil-works/pi-coding-agent": ">=0.82.0",
46
- "@earendil-works/pi-tui": "*"
43
+ "@howaboua/pi-codex-conversion": ">=3.0.26",
44
+ "@earendil-works/pi-ai": ">=0.84.3",
45
+ "@earendil-works/pi-coding-agent": ">=0.84.3",
46
+ "@earendil-works/pi-tui": ">=0.84.3"
47
+ },
48
+ "peerDependenciesMeta": {
49
+ "@howaboua/pi-codex-conversion": {
50
+ "optional": true
51
+ }
47
52
  },
48
53
  "scripts": {
49
54
  "check": "bun run lint && bun run typecheck && bun run test",
@@ -54,11 +59,12 @@
54
59
  "format": "biome check --write ."
55
60
  },
56
61
  "devDependencies": {
57
- "@earendil-works/pi-ai": "0.84.1",
58
- "@earendil-works/pi-coding-agent": "0.84.1",
59
- "@types/node": "^24.10.0",
60
- "typescript": "^5.9.3",
61
- "@biomejs/biome": "^2.4.16"
62
+ "@howaboua/pi-codex-conversion": "3.0.26",
63
+ "@earendil-works/pi-ai": "0.85.0",
64
+ "@earendil-works/pi-coding-agent": "0.85.0",
65
+ "@types/node": "^26.2.0",
66
+ "typescript": "^7.0.2",
67
+ "@biomejs/biome": "^2.5.10"
62
68
  },
63
69
  "publishConfig": {
64
70
  "access": "public"
package/src/messages.ts CHANGED
@@ -9,6 +9,13 @@ import {
9
9
  } from "./constants.js";
10
10
  import type { ReviewContext } from "./types.js";
11
11
 
12
+ export type ReviewDeveloperMessages = Partial<
13
+ Pick<
14
+ typeof import("@howaboua/pi-codex-conversion/developer-messages"),
15
+ "trySendCodexDeveloperCustomMessage" | "trySendCodexDeveloperMessage"
16
+ >
17
+ >;
18
+
12
19
  const REALTIME_VOICE_PROMPT_CHANNEL =
13
20
  "@howaboua/pi-codex-conversion/realtime-voice-prompt/v1";
14
21
  const REVIEW_LOOP_PREFACE_MESSAGE = [
@@ -83,16 +90,22 @@ export function sendReviewPreface(
83
90
  pi: ExtensionAPI,
84
91
  ctx: ExtensionCommandContext,
85
92
  options: { freshLoop?: boolean } = {},
93
+ developerMessages?: ReviewDeveloperMessages,
86
94
  ): void {
87
95
  if (!options.freshLoop && getReviewPrefaceMessageId(ctx)) return;
88
- pi.sendMessage(
89
- {
90
- customType: REVIEW_PREFACE_MESSAGE_TYPE,
91
- content: REVIEW_LOOP_PREFACE_MESSAGE,
92
- display: true,
93
- },
94
- { triggerTurn: false },
95
- );
96
+ const message = {
97
+ customType: REVIEW_PREFACE_MESSAGE_TYPE,
98
+ content: REVIEW_LOOP_PREFACE_MESSAGE,
99
+ display: true,
100
+ };
101
+ const delivery = { triggerTurn: false };
102
+ if (
103
+ typeof developerMessages?.trySendCodexDeveloperCustomMessage ===
104
+ "function" &&
105
+ developerMessages.trySendCodexDeveloperCustomMessage(pi, message, delivery)
106
+ )
107
+ return;
108
+ pi.sendMessage(message, delivery);
96
109
  }
97
110
 
98
111
  function buildJjReviewScopeText(
@@ -108,8 +121,17 @@ function buildJjReviewScopeText(
108
121
  : "(root revision)";
109
122
  return [
110
123
  "for JJ workspace " + review.repoRoot,
111
- "active change ID: " + review.changeId,
112
- "active commit ID: " + review.commitId,
124
+ ...(review.workspaceChangeId && review.workspaceCommitId
125
+ ? [
126
+ "active empty workspace change ID: " + review.workspaceChangeId,
127
+ "active empty workspace commit ID: " + review.workspaceCommitId,
128
+ "review parent change ID: " + review.changeId,
129
+ "review parent commit ID: " + review.commitId,
130
+ ]
131
+ : [
132
+ "active change ID: " + review.changeId,
133
+ "active commit ID: " + review.commitId,
134
+ ]),
113
135
  "direct parent change ID" +
114
136
  (review.parentChangeIds.length === 1 ? "" : "s") +
115
137
  ": " +
@@ -168,6 +190,7 @@ export function sendReviewFindings(
168
190
  ctx: ExtensionCommandContext,
169
191
  review: ReviewContext,
170
192
  findings: string,
193
+ developerMessages?: ReviewDeveloperMessages,
171
194
  ): void {
172
195
  const normalizedFindings = findings.trim();
173
196
  const idle = ctx.isIdle();
@@ -185,6 +208,17 @@ export function sendReviewFindings(
185
208
  normalizedFindings === "No actionable issues found."
186
209
  )
187
210
  return;
211
+ if (
212
+ typeof developerMessages?.trySendCodexDeveloperMessage === "function" &&
213
+ developerMessages.trySendCodexDeveloperMessage(
214
+ pi,
215
+ REVIEW_FINDINGS_FOLLOW_UP,
216
+ idle
217
+ ? { triggerTurn: true }
218
+ : { triggerTurn: true, deliverAs: "followUp" },
219
+ )
220
+ )
221
+ return;
188
222
  pi.sendUserMessage(
189
223
  REVIEW_FINDINGS_FOLLOW_UP,
190
224
  idle ? undefined : { deliverAs: "followUp" },
@@ -5,6 +5,7 @@ import { buildReviewConversationSummary } from "./conversation-summary.js";
5
5
  import {
6
6
  announceReviewFindingsReady,
7
7
  announceReviewSummaryStarted,
8
+ type ReviewDeveloperMessages,
8
9
  sendReviewFindings,
9
10
  sendReviewPreface,
10
11
  } from "./messages.js";
@@ -29,6 +30,7 @@ import type { NavigateWithSummaryModel } from "./tree-summary.js";
29
30
  export function registerReviewCommand(
30
31
  pi: ExtensionAPI,
31
32
  navigateWithSummaryModel: NavigateWithSummaryModel,
33
+ developerMessages?: ReviewDeveloperMessages,
32
34
  ) {
33
35
  pi.registerCommand(REVIEW_COMMAND, {
34
36
  description:
@@ -100,7 +102,21 @@ export function registerReviewCommand(
100
102
  }
101
103
  }
102
104
 
103
- sendReviewPreface(pi, ctx, { freshLoop: parsedArgs.startLoop });
105
+ if (!review.hasAnyChanges) {
106
+ ctx.ui.notify(
107
+ review.vcs === "jj"
108
+ ? "No changes found in the active JJ revision or its immediate parent."
109
+ : "No changes found relative to the selected base branch.",
110
+ "info",
111
+ );
112
+ return;
113
+ }
114
+ sendReviewPreface(
115
+ pi,
116
+ ctx,
117
+ { freshLoop: parsedArgs.startLoop },
118
+ developerMessages,
119
+ );
104
120
 
105
121
  if (parsedArgs.startLoop) {
106
122
  const targetId =
@@ -116,24 +132,6 @@ export function registerReviewCommand(
116
132
  }
117
133
  }
118
134
 
119
- if (!review.hasAnyChanges) {
120
- sendReviewFindings(
121
- pi,
122
- ctx,
123
- review,
124
- review.vcs === "jj"
125
- ? "No changes found in the active JJ revision."
126
- : "No changes found relative to the selected base branch.",
127
- );
128
- ctx.ui.notify(
129
- review.vcs === "jj"
130
- ? "No changes found in the active JJ revision; sent summary to the agent."
131
- : `No changes found relative to ${review.baseBranch}; sent summary to the agent.`,
132
- "info",
133
- );
134
- return;
135
- }
136
-
137
135
  reviewConfig ??= await resolveReviewConfig(pi, ctx);
138
136
  let conversationSummary: string | undefined;
139
137
  let details = createChildRunDetails("", review.repoRoot, reviewConfig);
@@ -192,7 +190,7 @@ export function registerReviewCommand(
192
190
  details.errorMessage || details.stderr || finalOutput,
193
191
  );
194
192
 
195
- sendReviewFindings(pi, ctx, review, finalOutput);
193
+ sendReviewFindings(pi, ctx, review, finalOutput, developerMessages);
196
194
  announceReviewFindingsReady(pi);
197
195
  ctx.ui.notify(
198
196
  `Review findings sent back to the main agent from /${REVIEW_COMMAND}.`,
@@ -152,74 +152,135 @@ async function resolveSingleJjRevision(
152
152
  return { changeId: lines[0], commitId: lines[1] };
153
153
  }
154
154
 
155
- async function detectJjReviewContext(
155
+ interface JjRevision {
156
+ changeId: string;
157
+ commitId: string;
158
+ parentChangeIds: string[];
159
+ parentCommitIds: string[];
160
+ }
161
+
162
+ async function readJjRevision(
156
163
  pi: ExtensionAPI,
157
- repoRoot: string,
158
- stackBase?: string,
159
- ): Promise<JjReviewContext> {
160
- const active = await jjString(pi, repoRoot, [
164
+ cwd: string,
165
+ revision: string,
166
+ ): Promise<JjRevision> {
167
+ const output = await jjString(pi, cwd, [
161
168
  "log",
162
169
  "-r",
163
- "@",
170
+ revision,
164
171
  "--no-graph",
165
172
  "--template",
166
173
  'change_id ++ "\\n" ++ commit_id ++ "\\n" ++ parents.map(|p| p.change_id()).join(",") ++ "\\n" ++ parents.map(|p| p.commit_id()).join(",") ++ "\\n" ++ if(conflict, "true", "false") ++ "\\n"',
167
174
  ]);
168
175
  const [changeId, commitId, parentChanges = "", parentCommits = "", conflict] =
169
- active.split("\n");
170
- if (!changeId || !commitId || !conflict)
171
- throw new Error("Could not identify the active JJ revision for /review.");
176
+ output.split("\n");
177
+ if (!changeId || !commitId || !conflict) {
178
+ throw new Error("Could not identify the selected JJ revision for /review.");
179
+ }
172
180
  if (conflict === "true") {
173
181
  throw new Error(
174
- `Active JJ revision ${changeId} (${commitId}) has conflicts. Resolve them before running /review.`,
182
+ "JJ revision " +
183
+ changeId +
184
+ " (" +
185
+ commitId +
186
+ ") has conflicts. Resolve them before running /review.",
175
187
  );
176
188
  }
189
+ return {
190
+ changeId,
191
+ commitId,
192
+ parentChangeIds: parentChanges ? parentChanges.split(",") : [],
193
+ parentCommitIds: parentCommits ? parentCommits.split(",") : [],
194
+ };
195
+ }
177
196
 
178
- const parentChangeIds = parentChanges ? parentChanges.split(",") : [];
179
- const parentCommitIds = parentCommits ? parentCommits.split(",") : [];
197
+ async function jjDiffSummary(
198
+ pi: ExtensionAPI,
199
+ cwd: string,
200
+ commitId: string,
201
+ baseCommitId?: string,
202
+ ): Promise<string> {
203
+ return jjString(
204
+ pi,
205
+ cwd,
206
+ baseCommitId
207
+ ? ["diff", "--from", baseCommitId, "--to", commitId, "--summary"]
208
+ : ["diff", "-r", commitId, "--summary"],
209
+ );
210
+ }
211
+
212
+ async function detectJjReviewContext(
213
+ pi: ExtensionAPI,
214
+ repoRoot: string,
215
+ stackBase?: string,
216
+ ): Promise<JjReviewContext> {
217
+ const active = await readJjRevision(pi, repoRoot, "@");
218
+ let target = active;
180
219
  let base:
181
220
  | { revision: string; changeId: string; commitId: string }
182
221
  | undefined;
183
222
  if (stackBase) {
184
223
  const resolved = await resolveSingleJjRevision(pi, repoRoot, stackBase);
185
- if (resolved.commitId === commitId) {
224
+ if (resolved.commitId === active.commitId) {
186
225
  throw new Error(
187
- `JJ review stack base ${JSON.stringify(stackBase)} is the active revision. Choose an ancestor instead.`,
226
+ "JJ review stack base " +
227
+ JSON.stringify(stackBase) +
228
+ " is the active revision. Choose an ancestor instead.",
188
229
  );
189
230
  }
190
231
  const ancestor = await jjString(pi, repoRoot, [
191
232
  "log",
192
233
  "-r",
193
- `ancestors(${commitId}) & ${resolved.commitId}`,
234
+ ["ancestors(", active.commitId, ") & ", resolved.commitId].join(""),
194
235
  "--no-graph",
195
236
  "--template",
196
237
  "commit_id",
197
238
  ]);
198
239
  if (ancestor !== resolved.commitId) {
199
240
  throw new Error(
200
- `JJ review stack base ${JSON.stringify(stackBase)} must be an ancestor of active revision ${changeId}.`,
241
+ "JJ review stack base " +
242
+ JSON.stringify(stackBase) +
243
+ " must be an ancestor of active revision " +
244
+ active.changeId +
245
+ ".",
201
246
  );
202
247
  }
203
248
  base = { revision: stackBase, ...resolved };
204
249
  }
205
250
 
206
- const changedFiles = await jjString(
251
+ let changedFiles = await jjDiffSummary(
207
252
  pi,
208
253
  repoRoot,
209
- base
210
- ? ["diff", "--from", base.commitId, "--to", commitId, "--summary"]
211
- : ["diff", "-r", commitId, "--summary"],
254
+ target.commitId,
255
+ base?.commitId,
212
256
  );
257
+ if (!base && !changedFiles && active.parentCommitIds.length === 1) {
258
+ const parentCommitId = active.parentCommitIds[0];
259
+ if (parentCommitId) {
260
+ const parent = await readJjRevision(pi, repoRoot, parentCommitId);
261
+ const parentChanges = await jjDiffSummary(pi, repoRoot, parent.commitId);
262
+ if (parentChanges) {
263
+ target = parent;
264
+ changedFiles = parentChanges;
265
+ }
266
+ }
267
+ }
213
268
 
214
269
  return {
215
270
  vcs: "jj",
216
271
  repoRoot,
217
- currentRef: changeId,
272
+ currentRef: target.changeId,
218
273
  scope: base ? "jj-base" : "jj-parent",
219
- changeId,
220
- commitId,
221
- parentChangeIds,
222
- parentCommitIds,
274
+ changeId: target.changeId,
275
+ commitId: target.commitId,
276
+ parentChangeIds: target.parentChangeIds,
277
+ parentCommitIds: target.parentCommitIds,
278
+ ...(target.commitId !== active.commitId
279
+ ? {
280
+ workspaceChangeId: active.changeId,
281
+ workspaceCommitId: active.commitId,
282
+ }
283
+ : {}),
223
284
  ...(base
224
285
  ? {
225
286
  baseRevision: base.revision,
@@ -232,7 +293,6 @@ async function detectJjReviewContext(
232
293
  hasAnyChanges: changedFiles.length > 0,
233
294
  };
234
295
  }
235
-
236
296
  async function detectGitReviewContext(
237
297
  pi: ExtensionAPI,
238
298
  cwd: string,
@@ -125,8 +125,17 @@ function buildJjReviewTask(
125
125
  : "(root revision)";
126
126
  const sections = [
127
127
  "JJ workspace root: " + review.repoRoot,
128
- "Active change ID: " + review.changeId,
129
- "Active commit ID: " + review.commitId,
128
+ ...(review.workspaceChangeId && review.workspaceCommitId
129
+ ? [
130
+ "Active empty workspace change ID: " + review.workspaceChangeId,
131
+ "Active empty workspace commit ID: " + review.workspaceCommitId,
132
+ "Review parent change ID: " + review.changeId,
133
+ "Review parent commit ID: " + review.commitId,
134
+ ]
135
+ : [
136
+ "Active change ID: " + review.changeId,
137
+ "Active commit ID: " + review.commitId,
138
+ ]),
130
139
  "Direct parent commit ID" +
131
140
  (review.parentCommitIds.length === 1 ? "" : "s") +
132
141
  ": " +
package/src/types.ts CHANGED
@@ -86,6 +86,8 @@ export interface JjReviewContext {
86
86
  commitId: string;
87
87
  parentChangeIds: string[];
88
88
  parentCommitIds: string[];
89
+ workspaceChangeId?: string;
90
+ workspaceCommitId?: string;
89
91
  baseRevision?: string;
90
92
  baseChangeId?: string;
91
93
  baseCommitId?: string;