pi-formatter 1.0.1 → 1.0.2
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/extensions/index.ts +38 -12
- package/package.json +1 -1
package/extensions/index.ts
CHANGED
|
@@ -135,12 +135,27 @@ export default function (pi: ExtensionAPI) {
|
|
|
135
135
|
await next;
|
|
136
136
|
};
|
|
137
137
|
|
|
138
|
+
const emitSummaryMessages = (
|
|
139
|
+
messages: string[],
|
|
140
|
+
ctx: FormatterContext,
|
|
141
|
+
): void => {
|
|
142
|
+
if (
|
|
143
|
+
!ctx.hasUI ||
|
|
144
|
+
formatterConfig.hideCallSummariesInTui ||
|
|
145
|
+
messages.length === 0
|
|
146
|
+
) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
ctx.ui.notify(messages.join("\n"), "info");
|
|
151
|
+
};
|
|
152
|
+
|
|
138
153
|
const formatResolvedPath = async (
|
|
139
154
|
filePath: string,
|
|
140
155
|
ctx: FormatterContext,
|
|
141
|
-
): Promise<
|
|
156
|
+
): Promise<string[]> => {
|
|
142
157
|
if (!(await pathExists(filePath))) {
|
|
143
|
-
return;
|
|
158
|
+
return [];
|
|
144
159
|
}
|
|
145
160
|
|
|
146
161
|
const showSummaries = !formatterConfig.hideCallSummariesInTui && ctx.hasUI;
|
|
@@ -155,6 +170,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
155
170
|
console.warn(normalizedMessage);
|
|
156
171
|
};
|
|
157
172
|
|
|
173
|
+
let summaryMessages: string[] = [];
|
|
174
|
+
|
|
158
175
|
await enqueueFormat(filePath, async () => {
|
|
159
176
|
const summaries: FormatCallSummary[] = [];
|
|
160
177
|
const summaryReporter = showSummaries
|
|
@@ -188,28 +205,37 @@ export default function (pi: ExtensionAPI) {
|
|
|
188
205
|
}
|
|
189
206
|
|
|
190
207
|
const fileLabel = getRelativePathOrAbsolute(filePath, ctx.cwd);
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
208
|
+
summaryMessages = summaries.map((summary) =>
|
|
209
|
+
formatCallSummary(summary, fileLabel),
|
|
210
|
+
);
|
|
195
211
|
});
|
|
212
|
+
|
|
213
|
+
return summaryMessages;
|
|
196
214
|
};
|
|
197
215
|
|
|
198
216
|
const flushPaths = async (
|
|
199
217
|
paths: Set<string>,
|
|
200
218
|
ctx: FormatterContext,
|
|
201
|
-
): Promise<
|
|
219
|
+
): Promise<string[]> => {
|
|
202
220
|
const batch = [...paths];
|
|
203
221
|
paths.clear();
|
|
204
222
|
|
|
223
|
+
const summaryMessages: string[] = [];
|
|
224
|
+
|
|
205
225
|
for (const filePath of batch) {
|
|
206
|
-
await formatResolvedPath(filePath, ctx);
|
|
226
|
+
summaryMessages.push(...(await formatResolvedPath(filePath, ctx)));
|
|
207
227
|
}
|
|
228
|
+
|
|
229
|
+
return summaryMessages;
|
|
208
230
|
};
|
|
209
231
|
|
|
210
232
|
const flushPendingPaths = async (ctx: FormatterContext): Promise<void> => {
|
|
211
|
-
|
|
212
|
-
|
|
233
|
+
const summaryMessages = [
|
|
234
|
+
...(await flushPaths(pendingPromptPaths, ctx)),
|
|
235
|
+
...(await flushPaths(pendingSessionPaths, ctx)),
|
|
236
|
+
];
|
|
237
|
+
|
|
238
|
+
emitSummaryMessages(summaryMessages, ctx);
|
|
213
239
|
};
|
|
214
240
|
|
|
215
241
|
const reloadFormatterConfig = () => {
|
|
@@ -231,7 +257,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
231
257
|
}
|
|
232
258
|
|
|
233
259
|
if (formatterConfig.formatMode === "tool") {
|
|
234
|
-
await formatResolvedPath(filePath, ctx);
|
|
260
|
+
emitSummaryMessages(await formatResolvedPath(filePath, ctx), ctx);
|
|
235
261
|
return;
|
|
236
262
|
}
|
|
237
263
|
|
|
@@ -248,7 +274,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
248
274
|
return;
|
|
249
275
|
}
|
|
250
276
|
|
|
251
|
-
await flushPaths(pendingPromptPaths, ctx);
|
|
277
|
+
emitSummaryMessages(await flushPaths(pendingPromptPaths, ctx), ctx);
|
|
252
278
|
});
|
|
253
279
|
|
|
254
280
|
pi.on("session_switch", async (_event, ctx) => {
|