@unifan/pi-review-zh 1.0.4 → 1.0.5
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/index.ts +48 -0
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -91,6 +91,54 @@ export default function (pi: ExtensionAPI) {
|
|
|
91
91
|
},
|
|
92
92
|
});
|
|
93
93
|
|
|
94
|
+
pi.registerCommand("review-lite", {
|
|
95
|
+
description: "极速单兵代码审查 (无门禁,3~5秒出结果,极省 Token)",
|
|
96
|
+
handler: async (args, ctx) => {
|
|
97
|
+
const notify = (msg: string, level: "info" | "warning" | "error" = "info") => {
|
|
98
|
+
if (ctx.hasUI) ctx.ui.notify(msg, level);
|
|
99
|
+
else console.log(`pi-review: ${msg}`);
|
|
100
|
+
};
|
|
101
|
+
try {
|
|
102
|
+
const { config, legacyWarnings } = loadConfig();
|
|
103
|
+
for (const w of legacyWarnings) notify(`pi-review 提示: ${w}`, "warning");
|
|
104
|
+
pi.sendMessage({ customType: "pi-review", content: args ? `/review-lite ${args}` : "/review-lite", display: true });
|
|
105
|
+
const prepared = await prepareRun({ cwd: ctx.cwd, input: args, lite: true });
|
|
106
|
+
if (!prepared) {
|
|
107
|
+
notify("没有检测到需要审查的内容 (未找到修改、PR 或非 Git 仓库)。", "info");
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
pi.sendMessage({ customType: "pi-review-directive", content: prepared.directiveText, display: false }, { triggerTurn: true });
|
|
111
|
+
} catch (err) {
|
|
112
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
113
|
+
notify(`极速代码审查启动失败: ${message}`, "error");
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
pi.registerCommand("review-perf", {
|
|
119
|
+
description: "专项性能与基准测试审查 (GC堆分配/算法复杂度/Benchmark探针)",
|
|
120
|
+
handler: async (args, ctx) => {
|
|
121
|
+
const notify = (msg: string, level: "info" | "warning" | "error" = "info") => {
|
|
122
|
+
if (ctx.hasUI) ctx.ui.notify(msg, level);
|
|
123
|
+
else console.log(`pi-review: ${msg}`);
|
|
124
|
+
};
|
|
125
|
+
try {
|
|
126
|
+
const { config, legacyWarnings } = loadConfig();
|
|
127
|
+
for (const w of legacyWarnings) notify(`pi-review 提示: ${w}`, "warning");
|
|
128
|
+
pi.sendMessage({ customType: "pi-review", content: args ? `/review-perf ${args}` : "/review-perf", display: true });
|
|
129
|
+
const prepared = await prepareRun({ cwd: ctx.cwd, input: args, perf: true });
|
|
130
|
+
if (!prepared) {
|
|
131
|
+
notify("没有检测到需要审查的内容 (未找到修改、PR 或非 Git 仓库)。", "info");
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
pi.sendMessage({ customType: "pi-review-directive", content: prepared.directiveText, display: false }, { triggerTurn: true });
|
|
135
|
+
} catch (err) {
|
|
136
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
137
|
+
notify(`性能审查启动失败: ${message}`, "error");
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
|
|
94
142
|
pi.registerCommand("review-config", {
|
|
95
143
|
description: "编辑代码审查配置 (~/.pi/agent/pi-review.json)",
|
|
96
144
|
handler: async (_args, ctx) => {
|