@zephyrdeng/pi-review 0.18.2 → 0.18.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/package.json
CHANGED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { buildRvOrchestrationPrompt, parseRvArgs, RV_COMPLETIONS } from "./rv-prompts.js";
|
|
2
|
-
export default function piReviewExtension(pi) {
|
|
3
|
-
pi.registerCommand("rv", {
|
|
4
|
-
description: "Delegate pi-review to the agent (English prompts). Usage: /rv [--mode plan|challenge] [--model id] [--keep-session] @file-or-text | models",
|
|
5
|
-
getArgumentCompletions: (prefix) => {
|
|
6
|
-
const filtered = RV_COMPLETIONS.filter((item) => item.value.startsWith(prefix));
|
|
7
|
-
return filtered.length
|
|
8
|
-
? filtered.map(({ value, hint }) => ({ value, label: value, description: hint }))
|
|
9
|
-
: null;
|
|
10
|
-
},
|
|
11
|
-
handler: async (rawArgs, ctx) => {
|
|
12
|
-
const trimmed = rawArgs.trim();
|
|
13
|
-
const parsed = parseRvArgs(trimmed);
|
|
14
|
-
const prompt = buildRvOrchestrationPrompt(parsed);
|
|
15
|
-
if (!trimmed && !parsed.modelsOnly) {
|
|
16
|
-
ctx.ui.notify("/rv needs a target or `models`. Try: /rv @path or /rv models", "warning");
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
pi.sendUserMessage(prompt);
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* English orchestration prompts for /rv — parent Pi agent runs pi-review per skill.
|
|
3
|
-
* Child review sessions use presets in resources/review-presets.json (also English).
|
|
4
|
-
*/
|
|
5
|
-
export type RvParsed = {
|
|
6
|
-
mode: "code" | "plan" | "challenge";
|
|
7
|
-
model?: string;
|
|
8
|
-
keepSession: boolean;
|
|
9
|
-
continueHandle?: string;
|
|
10
|
-
modelsOnly: boolean;
|
|
11
|
-
target: string;
|
|
12
|
-
};
|
|
13
|
-
export declare function parseRvArgs(raw: string): RvParsed;
|
|
14
|
-
export declare function buildRvOrchestrationPrompt(parsed: RvParsed): string;
|
|
15
|
-
/** Short labels for TUI completions (English). */
|
|
16
|
-
export declare const RV_COMPLETIONS: {
|
|
17
|
-
value: string;
|
|
18
|
-
hint: string;
|
|
19
|
-
}[];
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* English orchestration prompts for /rv — parent Pi agent runs pi-review per skill.
|
|
3
|
-
* Child review sessions use presets in resources/review-presets.json (also English).
|
|
4
|
-
*/
|
|
5
|
-
export function parseRvArgs(raw) {
|
|
6
|
-
const tokens = raw.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g) ?? [];
|
|
7
|
-
const cleaned = tokens.map((t) => t.replace(/^['"]|['"]$/g, ""));
|
|
8
|
-
let mode = "code";
|
|
9
|
-
let model;
|
|
10
|
-
let keepSession = false;
|
|
11
|
-
let continueHandle;
|
|
12
|
-
let modelsOnly = false;
|
|
13
|
-
const rest = [];
|
|
14
|
-
for (let i = 0; i < cleaned.length; i++) {
|
|
15
|
-
const t = cleaned[i];
|
|
16
|
-
if (t === "models" && rest.length === 0 && i === cleaned.length - 1) {
|
|
17
|
-
modelsOnly = true;
|
|
18
|
-
continue;
|
|
19
|
-
}
|
|
20
|
-
if (t === "--keep-session") {
|
|
21
|
-
keepSession = true;
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
if (t === "--mode" && cleaned[i + 1]) {
|
|
25
|
-
const m = cleaned[++i];
|
|
26
|
-
if (m === "plan" || m === "challenge" || m === "code")
|
|
27
|
-
mode = m;
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
if (t === "--model" && cleaned[i + 1]) {
|
|
31
|
-
model = cleaned[++i];
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
if (t === "--continue" && cleaned[i + 1]) {
|
|
35
|
-
continueHandle = cleaned[++i];
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
rest.push(t);
|
|
39
|
-
}
|
|
40
|
-
return {
|
|
41
|
-
mode,
|
|
42
|
-
model,
|
|
43
|
-
keepSession,
|
|
44
|
-
continueHandle,
|
|
45
|
-
modelsOnly,
|
|
46
|
-
target: rest.join(" ").trim(),
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
function baseRules() {
|
|
50
|
-
return [
|
|
51
|
-
"Follow the pi-review skill.",
|
|
52
|
-
"Run pi-review in an isolated child session; return only the review conclusion.",
|
|
53
|
-
"Do not edit, patch, commit, or implement findings unless the user asks separately.",
|
|
54
|
-
"Preserve the final PI_REVIEW_META line from pi-review output.",
|
|
55
|
-
].join(" ");
|
|
56
|
-
}
|
|
57
|
-
export function buildRvOrchestrationPrompt(parsed) {
|
|
58
|
-
if (parsed.modelsOnly) {
|
|
59
|
-
return [
|
|
60
|
-
"Run the pi-review model catalog step.",
|
|
61
|
-
baseRules(),
|
|
62
|
-
"Execute: pi-review models",
|
|
63
|
-
"Present a short English summary: how many providers, suggest 2–3 IDs suited for code review vs plan/challenge.",
|
|
64
|
-
"Do not start a review until the user supplies a target (@path or text).",
|
|
65
|
-
].join("\n\n");
|
|
66
|
-
}
|
|
67
|
-
if (parsed.continueHandle) {
|
|
68
|
-
return [
|
|
69
|
-
"Continue a prior pi-review session.",
|
|
70
|
-
baseRules(),
|
|
71
|
-
`Execute: pi-review --continue ${parsed.continueHandle} -- ${parsed.target || "follow up on the previous review"}`,
|
|
72
|
-
"Answer the follow-up in English; keep the same review-only scope.",
|
|
73
|
-
].join("\n\n");
|
|
74
|
-
}
|
|
75
|
-
if (!parsed.target) {
|
|
76
|
-
return [
|
|
77
|
-
"The /rv command needs a review target.",
|
|
78
|
-
"Tell the user (in English): usage is /rv [--mode code|plan|challenge] [--model provider/model] [--keep-session] -- @files-or-brief",
|
|
79
|
-
"Examples: /rv @src/foo.ts | /rv --mode challenge @docs/design.md | /rv models",
|
|
80
|
-
].join("\n\n");
|
|
81
|
-
}
|
|
82
|
-
const modeBlock = {
|
|
83
|
-
code: [
|
|
84
|
-
"Mode: code (default).",
|
|
85
|
-
"Focus: correctness, regressions, security, concurrency, API contracts, edge cases, tests.",
|
|
86
|
-
"Use read-only inspection via pi-review; no file mutations.",
|
|
87
|
-
].join(" "),
|
|
88
|
-
plan: [
|
|
89
|
-
"Mode: plan.",
|
|
90
|
-
"Review architecture, design, or strategy through engineering, product, security, QA, ops, and DX lenses.",
|
|
91
|
-
"Identify fatal flaws, trade-offs, sequencing risks, and minimal changes to de-risk the plan.",
|
|
92
|
-
].join(" "),
|
|
93
|
-
challenge: [
|
|
94
|
-
"Mode: challenge (adversarial).",
|
|
95
|
-
"Pressure-test assumptions, boundaries, dependencies, failure modes, migration, and missing evidence.",
|
|
96
|
-
"One-shot conclusion; do not run a live Q&A interview.",
|
|
97
|
-
].join(" "),
|
|
98
|
-
};
|
|
99
|
-
const cliParts = ["pi-review"];
|
|
100
|
-
if (parsed.mode !== "code")
|
|
101
|
-
cliParts.push(`--mode ${parsed.mode}`);
|
|
102
|
-
if (parsed.model)
|
|
103
|
-
cliParts.push(`--model ${parsed.model}`);
|
|
104
|
-
if (parsed.keepSession)
|
|
105
|
-
cliParts.push("--keep-session");
|
|
106
|
-
cliParts.push("--", parsed.target);
|
|
107
|
-
const modelStep = parsed.model
|
|
108
|
-
? `Use model exactly as given: ${parsed.model} (must appear in pi-review models output).`
|
|
109
|
-
: "Run pi-review models first if needed; pick a suitable listed ID or omit --model for Pi default.";
|
|
110
|
-
return [
|
|
111
|
-
"Run pi-review for the target below.",
|
|
112
|
-
baseRules(),
|
|
113
|
-
modeBlock[parsed.mode],
|
|
114
|
-
modelStep,
|
|
115
|
-
parsed.keepSession
|
|
116
|
-
? "Use --keep-session so the user can follow up with /rv --continue <handle>."
|
|
117
|
-
: "",
|
|
118
|
-
`Execute:\n${cliParts.join(" ")}`,
|
|
119
|
-
]
|
|
120
|
-
.filter(Boolean)
|
|
121
|
-
.join("\n\n");
|
|
122
|
-
}
|
|
123
|
-
/** Short labels for TUI completions (English). */
|
|
124
|
-
export const RV_COMPLETIONS = [
|
|
125
|
-
{ value: "@", hint: "file path after @ (e.g. @src/foo.ts)" },
|
|
126
|
-
{ value: "models", hint: "list pi-review models only" },
|
|
127
|
-
{ value: "--mode code", hint: "code / diff / MR review" },
|
|
128
|
-
{ value: "--mode plan", hint: "architecture or plan review" },
|
|
129
|
-
{ value: "--mode challenge", hint: "adversarial plan review" },
|
|
130
|
-
{ value: "--model ", hint: "provider/model from pi-review models" },
|
|
131
|
-
{ value: "--keep-session", hint: "persist session for follow-up" },
|
|
132
|
-
];
|