@deathbeam/pi-delegate 0.0.36 → 0.0.38
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/format.ts +7 -12
- package/index.ts +12 -6
- package/package.json +1 -1
package/format.ts
CHANGED
|
@@ -47,12 +47,8 @@ export const STATUS_COLORS = {
|
|
|
47
47
|
cancelled: "muted",
|
|
48
48
|
interrupted: "warning",
|
|
49
49
|
} as const satisfies Record<JobStatus, string>;
|
|
50
|
-
/**
|
|
51
|
-
const
|
|
52
|
-
/** Only a few jobs still fit with their tool-call and tool-result lines: 1 tally + 3 lines per job. */
|
|
53
|
-
const WIDGET_MAX_DETAIL_JOBS = Math.floor((WIDGET_MAX_LINES - 1) / 3);
|
|
54
|
-
/** In bulk, one row per job: 1 tally + N rows + 1 "more running" footer. */
|
|
55
|
-
const WIDGET_MAX_JOBS = WIDGET_MAX_LINES - 2;
|
|
50
|
+
/** Each job takes up to 3 rows (job, tool call, tool result); older ones collapse into a footer. */
|
|
51
|
+
const WIDGET_MAX_JOBS = 5;
|
|
56
52
|
export const COLLAPSED_OUTPUT_LINES = 10;
|
|
57
53
|
const MAX_OUTPUT_BYTES = 50 * 1024;
|
|
58
54
|
const EXPANDED_PAD = " ";
|
|
@@ -280,7 +276,7 @@ export function reportText(report: DelegateReport): string {
|
|
|
280
276
|
// The apply hint is for the model only: the transcript renders `output`, so users never see it.
|
|
281
277
|
const hint =
|
|
282
278
|
report.isolation && !report.cloneClosed
|
|
283
|
-
? `\n\nCall delegate_apply with job ${report.id} to land its changes, or delegate_discard to drop them.`
|
|
279
|
+
? `\n\nCall delegate_apply with job ${report.id} to land its changes, or delegate_discard to drop them. Call one, not both: a successful apply removes the clone.`
|
|
284
280
|
: "";
|
|
285
281
|
return `${head} finished.${output ? `\n\n${output}` : ""}${hint}`;
|
|
286
282
|
}
|
|
@@ -289,11 +285,10 @@ export function jobLine(info: { description?: string } & UsageInfo, elapsedMs: n
|
|
|
289
285
|
return [info.description?.trim(), usageStats(info, elapsedMs)].filter(Boolean).join(" · ");
|
|
290
286
|
}
|
|
291
287
|
|
|
292
|
-
/**
|
|
293
|
-
export function widgetJobs<T>(jobs: T[]): { shown: T[]; hidden: number
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
return { shown, hidden: jobs.length - shown.length, detail };
|
|
288
|
+
/** Shows the newest jobs; the rest are counted in a "more running" footer. */
|
|
289
|
+
export function widgetJobs<T>(jobs: T[]): { shown: T[]; hidden: number } {
|
|
290
|
+
const shown = jobs.slice(-WIDGET_MAX_JOBS);
|
|
291
|
+
return { shown, hidden: jobs.length - shown.length };
|
|
297
292
|
}
|
|
298
293
|
|
|
299
294
|
export type DelegateDetails = Pick<
|
package/index.ts
CHANGED
|
@@ -152,7 +152,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
152
152
|
}
|
|
153
153
|
const theme = ctx.ui.theme;
|
|
154
154
|
const now = Date.now();
|
|
155
|
-
const { shown, hidden
|
|
155
|
+
const { shown, hidden } = widgetJobs(jobs);
|
|
156
156
|
const lines: string[] = [];
|
|
157
157
|
const all = store.all();
|
|
158
158
|
const counts = tally(jobs.length, all, now);
|
|
@@ -161,7 +161,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
161
161
|
lines.push(
|
|
162
162
|
`${statusText(theme, "running", now)} ${jobIdentity(theme, job)} ${theme.fg("muted", jobLine(job, elapsedMs(job, now)))}`,
|
|
163
163
|
);
|
|
164
|
-
if (!detail) continue;
|
|
165
164
|
const { tool, result } = lastToolCall(job);
|
|
166
165
|
if (tool)
|
|
167
166
|
lines.push(
|
|
@@ -172,8 +171,14 @@ export default function (pi: ExtensionAPI) {
|
|
|
172
171
|
` ${theme.fg("muted", "↳")} ${theme.fg(result.isError ? "error" : "toolOutput", result.text)}`,
|
|
173
172
|
);
|
|
174
173
|
}
|
|
175
|
-
if (hidden) lines.push(` ${theme.fg("muted", `… ${hidden} more running`)}`);
|
|
176
|
-
|
|
174
|
+
if (hidden) lines.push(` ${theme.fg("muted", `… ${hidden} more running · /delegate to view all`)}`);
|
|
175
|
+
|
|
176
|
+
// A component factory, because Pi cuts string-array widgets at ten lines.
|
|
177
|
+
ctx.ui.setWidget(WIDGET_KEY, () => {
|
|
178
|
+
const container = new Container();
|
|
179
|
+
for (const line of lines) container.addChild(new Text(line, 1, 0));
|
|
180
|
+
return container;
|
|
181
|
+
});
|
|
177
182
|
};
|
|
178
183
|
|
|
179
184
|
// The ticker animates spinners exactly while live jobs exist.
|
|
@@ -666,7 +671,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
666
671
|
name: "delegate_apply",
|
|
667
672
|
label: "Apply delegate",
|
|
668
673
|
description:
|
|
669
|
-
"Apply an isolated delegate's changes to the main working tree by job id. The delegate's commits and uncommitted changes are 3-way merged onto a fresh snapshot of the main tree, so nearby but non-overlapping edits apply cleanly; only a true conflict fails. On conflict the clone is kept and the error explains the recovery. No delegate may be running in its clone.",
|
|
674
|
+
"Apply an isolated delegate's changes to the main working tree by job id. The delegate's commits and uncommitted changes are 3-way merged onto a fresh snapshot of the main tree, so nearby but non-overlapping edits apply cleanly; only a true conflict fails. A successful apply removes the clone itself, so never call delegate_discard for the same clone, in the same turn or after. On conflict the clone is kept and the error explains the recovery. No delegate may be running in its clone.",
|
|
670
675
|
promptSnippet: "Apply an isolated delegate's clone to the main tree by job id",
|
|
671
676
|
parameters: Type.Object({
|
|
672
677
|
id: Type.String({ description: "Job id of an isolated delegate; any job id that ran in the clone works." }),
|
|
@@ -728,7 +733,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
728
733
|
pi.registerTool({
|
|
729
734
|
name: "delegate_discard",
|
|
730
735
|
label: "Discard delegate clone",
|
|
731
|
-
description:
|
|
736
|
+
description:
|
|
737
|
+
"Remove an isolated delegate's clone without applying its changes. Use it instead of delegate_apply, never alongside it: a successful apply already removes the clone, and a discard in the same turn deletes the clone that apply needs.",
|
|
732
738
|
promptSnippet: "Discard an isolated delegate's clone by job id",
|
|
733
739
|
parameters: Type.Object({
|
|
734
740
|
id: Type.String({ description: "Job id of an isolated delegate; any job id that ran in the clone works." }),
|