@howaboua/pi-subagent-review 0.2.18 → 0.2.19
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 +6 -0
- package/package.json +1 -1
- package/src/messages.ts +11 -2
- package/src/review-command.ts +9 -18
- package/src/review-context.ts +86 -26
- package/src/review-task.ts +11 -2
- package/src/types.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @howaboua/pi-subagent-review
|
|
2
2
|
|
|
3
|
+
## 0.2.19
|
|
4
|
+
|
|
5
|
+
### Changes
|
|
6
|
+
|
|
7
|
+
- [#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.
|
|
8
|
+
|
|
3
9
|
## 0.2.18
|
|
4
10
|
|
|
5
11
|
### Changes
|
package/package.json
CHANGED
package/src/messages.ts
CHANGED
|
@@ -108,8 +108,17 @@ function buildJjReviewScopeText(
|
|
|
108
108
|
: "(root revision)";
|
|
109
109
|
return [
|
|
110
110
|
"for JJ workspace " + review.repoRoot,
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
...(review.workspaceChangeId && review.workspaceCommitId
|
|
112
|
+
? [
|
|
113
|
+
"active empty workspace change ID: " + review.workspaceChangeId,
|
|
114
|
+
"active empty workspace commit ID: " + review.workspaceCommitId,
|
|
115
|
+
"review parent change ID: " + review.changeId,
|
|
116
|
+
"review parent commit ID: " + review.commitId,
|
|
117
|
+
]
|
|
118
|
+
: [
|
|
119
|
+
"active change ID: " + review.changeId,
|
|
120
|
+
"active commit ID: " + review.commitId,
|
|
121
|
+
]),
|
|
113
122
|
"direct parent change ID" +
|
|
114
123
|
(review.parentChangeIds.length === 1 ? "" : "s") +
|
|
115
124
|
": " +
|
package/src/review-command.ts
CHANGED
|
@@ -100,6 +100,15 @@ export function registerReviewCommand(
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
if (!review.hasAnyChanges) {
|
|
104
|
+
ctx.ui.notify(
|
|
105
|
+
review.vcs === "jj"
|
|
106
|
+
? "No changes found in the active JJ revision or its immediate parent."
|
|
107
|
+
: "No changes found relative to the selected base branch.",
|
|
108
|
+
"info",
|
|
109
|
+
);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
103
112
|
sendReviewPreface(pi, ctx, { freshLoop: parsedArgs.startLoop });
|
|
104
113
|
|
|
105
114
|
if (parsedArgs.startLoop) {
|
|
@@ -116,24 +125,6 @@ export function registerReviewCommand(
|
|
|
116
125
|
}
|
|
117
126
|
}
|
|
118
127
|
|
|
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
128
|
reviewConfig ??= await resolveReviewConfig(pi, ctx);
|
|
138
129
|
let conversationSummary: string | undefined;
|
|
139
130
|
let details = createChildRunDetails("", review.repoRoot, reviewConfig);
|
package/src/review-context.ts
CHANGED
|
@@ -152,74 +152,135 @@ async function resolveSingleJjRevision(
|
|
|
152
152
|
return { changeId: lines[0], commitId: lines[1] };
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
|
|
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
|
-
|
|
158
|
-
|
|
159
|
-
): Promise<
|
|
160
|
-
const
|
|
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
|
-
|
|
170
|
-
if (!changeId || !commitId || !conflict)
|
|
171
|
-
throw new Error("Could not identify the
|
|
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
|
-
|
|
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
|
-
|
|
179
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
251
|
+
let changedFiles = await jjDiffSummary(
|
|
207
252
|
pi,
|
|
208
253
|
repoRoot,
|
|
209
|
-
|
|
210
|
-
|
|
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,
|
package/src/review-task.ts
CHANGED
|
@@ -125,8 +125,17 @@ function buildJjReviewTask(
|
|
|
125
125
|
: "(root revision)";
|
|
126
126
|
const sections = [
|
|
127
127
|
"JJ workspace root: " + review.repoRoot,
|
|
128
|
-
|
|
129
|
-
|
|
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