pi-arsenal 0.1.4 → 0.2.1
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/startup-splash.ts +11 -9
- package/extensions/task-panel.ts +41 -0
- package/extensions/workspace-drawer.ts +866 -510
- package/package.json +1 -1
|
@@ -142,18 +142,20 @@ function paint(line: string, colors: string, theme: Theme): string {
|
|
|
142
142
|
|
|
143
143
|
function splash(theme: Theme, width: number): string[] {
|
|
144
144
|
const label = `${theme.bold(theme.fg("error", "◆"))}${theme.fg("text", " ID: 沫路")} ${theme.fg("dim", "// PI ARSENAL")}`;
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
const
|
|
151
|
-
return ["", ...PORTRAIT.map((line, index) => center(paint(line, COLOR_MASK[index] || "", theme))), "", ...ARSENAL_LOGO.map(
|
|
145
|
+
// Use a single block width so PORTRAIT, ARSENAL_LOGO, and label all share
|
|
146
|
+
// the same centre point and never drift apart on wide terminals.
|
|
147
|
+
const blockWidth = Math.max(...PORTRAIT.map(visibleWidth), ...ARSENAL_LOGO.map(visibleWidth), visibleWidth(label));
|
|
148
|
+
if (width < blockWidth) return [truncateToWidth(label, width)];
|
|
149
|
+
const pad = " ".repeat(Math.max(0, Math.floor((width - blockWidth) / 2)));
|
|
150
|
+
const center = (line: string) => pad + line;
|
|
151
|
+
return ["", ...PORTRAIT.map((line, index) => center(paint(line, COLOR_MASK[index] || "", theme))), "", ...ARSENAL_LOGO.map((line) => center(theme.fg("error", line))), center(label), ""];
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
export default function startupSplash(pi: ExtensionAPI) {
|
|
155
|
-
|
|
155
|
+
const setHeader = (ctx: { mode: string; ui: { setHeader: (factory: Parameters<typeof ctx.ui.setHeader>[0]) => void } }) => {
|
|
156
156
|
if (ctx.mode !== "tui") return;
|
|
157
157
|
ctx.ui.setHeader((_tui, theme) => ({ invalidate() {}, render(width: number): string[] { return splash(theme, width); } }));
|
|
158
|
-
}
|
|
158
|
+
};
|
|
159
|
+
pi.on("session_start", async (_event, ctx) => setHeader(ctx));
|
|
160
|
+
pi.on("session_tree", async (_event, ctx) => setHeader(ctx));
|
|
159
161
|
}
|
package/extensions/task-panel.ts
CHANGED
|
@@ -87,6 +87,17 @@ function approvalFromChoices(event: { toolName: string; content: Array<{ type: s
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
// Shared mutable state so the /task command can read it.
|
|
91
|
+
let _steps: PlanStep[] = [];
|
|
92
|
+
let _cancelPlan: (() => void) | undefined;
|
|
93
|
+
|
|
94
|
+
export function getActivePlan(): PlanStep[] { return _steps; }
|
|
95
|
+
export function cancelActivePlan(): boolean {
|
|
96
|
+
if (!_steps.some((s) => s.status !== "completed")) return false;
|
|
97
|
+
if (_cancelPlan) _cancelPlan();
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
|
|
90
101
|
export default function taskPanel(pi: ExtensionAPI) {
|
|
91
102
|
let steps: PlanStep[] = [];
|
|
92
103
|
let planChangeAuthorized = false;
|
|
@@ -113,6 +124,7 @@ export default function taskPanel(pi: ExtensionAPI) {
|
|
|
113
124
|
|
|
114
125
|
function restore(ctx: ExtensionContext): void {
|
|
115
126
|
steps = restoreSteps(ctx.sessionManager.getBranch());
|
|
127
|
+
_steps = steps;
|
|
116
128
|
planChangeAuthorized = false;
|
|
117
129
|
planChangeChoiceCallId = undefined;
|
|
118
130
|
render(ctx);
|
|
@@ -146,6 +158,35 @@ export default function taskPanel(pi: ExtensionAPI) {
|
|
|
146
158
|
const next = parseSteps((event.args as { steps?: unknown } | undefined)?.steps);
|
|
147
159
|
if (!next) return;
|
|
148
160
|
steps = next;
|
|
161
|
+
_steps = steps;
|
|
149
162
|
render(ctx);
|
|
150
163
|
});
|
|
164
|
+
|
|
165
|
+
// /task command: show current plan and optionally cancel it.
|
|
166
|
+
_cancelPlan = () => {
|
|
167
|
+
steps = steps.map((s) => s.status === "completed" ? s : { ...s, status: "completed" as const });
|
|
168
|
+
_steps = steps;
|
|
169
|
+
};
|
|
170
|
+
pi.registerCommand("task", {
|
|
171
|
+
description: "Show current plan and cancel if needed",
|
|
172
|
+
handler: async (_args, ctx) => {
|
|
173
|
+
if (ctx.mode !== "tui") return;
|
|
174
|
+
if (!isActivePlan(steps)) { ctx.ui.notify("No active plan.", "info"); return; }
|
|
175
|
+
const statusIcon = (s: PlanStep) => s.status === "completed" ? "✓" : s.status === "in_progress" ? "●" : "○";
|
|
176
|
+
const preview = steps.map((s, i) => `${i + 1}. ${statusIcon(s)} ${s.goal}`).join("\n");
|
|
177
|
+
const choice = await ctx.ui.select(
|
|
178
|
+
`Active plan (${steps.filter((s) => s.status === "completed").length}/${steps.length} done)\n\n${preview}`,
|
|
179
|
+
["Keep current plan", "Cancel this plan"],
|
|
180
|
+
);
|
|
181
|
+
if (choice === "Cancel this plan") {
|
|
182
|
+
const confirmed = await ctx.ui.confirm("Cancel plan?", "Mark all remaining steps completed so the model is free to start a new plan.");
|
|
183
|
+
if (confirmed) {
|
|
184
|
+
steps = steps.map((s) => ({ ...s, status: "completed" as const }));
|
|
185
|
+
_steps = steps;
|
|
186
|
+
render(ctx);
|
|
187
|
+
ctx.ui.notify("Plan cancelled. The model may now start a new plan.", "info");
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
});
|
|
151
192
|
}
|