@narumitw/pi-goal 0.51.0 → 0.52.0
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/README.md +28 -45
- package/package.json +8 -9
- package/src/command-registration.ts +15 -38
- package/src/command.ts +25 -70
- package/src/commands.ts +51 -383
- package/src/goal.ts +1 -1
- package/src/lifecycle.ts +25 -138
- package/src/menu.ts +15 -242
- package/src/persistence.ts +72 -108
- package/src/runtime.ts +22 -64
- package/src/settings-ui.ts +3 -125
- package/src/settings.ts +13 -29
- package/src/tools.ts +0 -65
- package/src/queue.ts +0 -126
package/src/menu.ts
CHANGED
|
@@ -7,8 +7,7 @@ import { notifyTerminal, safeGoalMenuText } from "./errors.js";
|
|
|
7
7
|
|
|
8
8
|
export { safeGoalMenuText } from "./errors.js";
|
|
9
9
|
|
|
10
|
-
import type { ActiveGoal
|
|
11
|
-
import { goalQueueIdentity } from "./queue.js";
|
|
10
|
+
import type { ActiveGoal } from "./persistence.js";
|
|
12
11
|
import { type GoalRuntime, goalSummary } from "./runtime.js";
|
|
13
12
|
|
|
14
13
|
export const GOAL_MENU_ACTIONS = {
|
|
@@ -21,26 +20,14 @@ export const GOAL_MENU_ACTIONS = {
|
|
|
21
20
|
edit: "Edit goal…",
|
|
22
21
|
replace: "Replace goal…",
|
|
23
22
|
status: "View full status",
|
|
24
|
-
queue: "Queue…",
|
|
25
23
|
settings: "Settings…",
|
|
26
24
|
help: "Help",
|
|
27
25
|
clear: "Clear goal…",
|
|
28
26
|
close: "Close",
|
|
29
27
|
} as const;
|
|
30
28
|
|
|
31
|
-
const QUEUE_ACTIONS = {
|
|
32
|
-
add: "Add goal…",
|
|
33
|
-
prioritize: "Prioritize goal…",
|
|
34
|
-
skip: "Skip current goal…",
|
|
35
|
-
dropLast: "Drop last goal…",
|
|
36
|
-
back: "Back",
|
|
37
|
-
} as const;
|
|
38
|
-
|
|
39
29
|
interface GoalMenuRuntimeView {
|
|
40
30
|
activeGoal?: ActiveGoal;
|
|
41
|
-
queuedGoals: ActiveGoal[];
|
|
42
|
-
pendingQueueAction?: PendingQueueAction;
|
|
43
|
-
queueFrozen: boolean;
|
|
44
31
|
settings: GoalRuntime["settings"];
|
|
45
32
|
recordGoalUsage?: GoalRuntime["recordGoalUsage"];
|
|
46
33
|
persistGoal?: GoalRuntime["persistGoal"];
|
|
@@ -59,7 +46,6 @@ type GoalMenuScreen =
|
|
|
59
46
|
| "start-custom-budget"
|
|
60
47
|
| "increase-budget"
|
|
61
48
|
| "safety"
|
|
62
|
-
| "queue"
|
|
63
49
|
| "status"
|
|
64
50
|
| "help";
|
|
65
51
|
type GoalMenuAction =
|
|
@@ -75,27 +61,18 @@ type GoalMenuAction =
|
|
|
75
61
|
| "replace"
|
|
76
62
|
| "settings"
|
|
77
63
|
| "clear"
|
|
78
|
-
| "queue-add"
|
|
79
|
-
| "queue-prioritize"
|
|
80
|
-
| "queue-skip"
|
|
81
|
-
| "queue-drop"
|
|
82
64
|
| "back";
|
|
83
65
|
|
|
84
66
|
export function buildGoalMenuState(runtime: GoalMenuRuntimeView): GoalMenuState {
|
|
85
67
|
const goal = runtime.activeGoal;
|
|
86
|
-
const queueCount = runtime.queuedGoals.length;
|
|
87
68
|
const pausedByAutomaticLimit =
|
|
88
69
|
goal?.status === "paused" && goal.safetyPauseCause === "continuation_limit";
|
|
89
70
|
const waitingReason = goal?.waiting ? safeGoalMenuText(goal.waiting.reason) : undefined;
|
|
90
|
-
const state =
|
|
91
|
-
? "
|
|
92
|
-
:
|
|
93
|
-
?
|
|
94
|
-
:
|
|
95
|
-
? "Paused — automatic-work limit reached"
|
|
96
|
-
: waitingReason
|
|
97
|
-
? `Waiting — ${waitingReason}`
|
|
98
|
-
: displayStatus(goal?.status);
|
|
71
|
+
const state = pausedByAutomaticLimit
|
|
72
|
+
? "Paused — automatic-work limit reached"
|
|
73
|
+
: waitingReason
|
|
74
|
+
? `Waiting — ${waitingReason}`
|
|
75
|
+
: displayStatus(goal?.status);
|
|
99
76
|
const automaticTurnLimit = runtime.settings.continuationLimits.automaticTurns;
|
|
100
77
|
const used = goal?.automaticModelTurns ?? 0;
|
|
101
78
|
const automaticResponses =
|
|
@@ -117,7 +94,6 @@ export function buildGoalMenuState(runtime: GoalMenuRuntimeView): GoalMenuState
|
|
|
117
94
|
...(pausedByAutomaticLimit
|
|
118
95
|
? ["Progress is saved. Review the safety limit before continuing."]
|
|
119
96
|
: []),
|
|
120
|
-
...(queueCount > 0 ? [`Queue: ${queueCount} queued`] : []),
|
|
121
97
|
].join("\n")
|
|
122
98
|
: [
|
|
123
99
|
`Goal · ${state}`,
|
|
@@ -127,19 +103,6 @@ export function buildGoalMenuState(runtime: GoalMenuRuntimeView): GoalMenuState
|
|
|
127
103
|
: `Automatic work is configured to pause after ${automaticTurnLimit} responses.`,
|
|
128
104
|
].join("\n");
|
|
129
105
|
|
|
130
|
-
if (runtime.queueFrozen || runtime.pendingQueueAction) {
|
|
131
|
-
return {
|
|
132
|
-
title,
|
|
133
|
-
actions: [
|
|
134
|
-
GOAL_MENU_ACTIONS.status,
|
|
135
|
-
GOAL_MENU_ACTIONS.settings,
|
|
136
|
-
GOAL_MENU_ACTIONS.help,
|
|
137
|
-
GOAL_MENU_ACTIONS.clear,
|
|
138
|
-
GOAL_MENU_ACTIONS.close,
|
|
139
|
-
],
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
|
|
143
106
|
const actions: string[] = [];
|
|
144
107
|
if (!goal || goal.status === "complete") {
|
|
145
108
|
actions.push(GOAL_MENU_ACTIONS.start, GOAL_MENU_ACTIONS.startBudget);
|
|
@@ -158,9 +121,6 @@ export function buildGoalMenuState(runtime: GoalMenuRuntimeView): GoalMenuState
|
|
|
158
121
|
actions.push(GOAL_MENU_ACTIONS.edit, GOAL_MENU_ACTIONS.replace);
|
|
159
122
|
}
|
|
160
123
|
if (goal) actions.push(GOAL_MENU_ACTIONS.status);
|
|
161
|
-
if (goal && (runtime.settings.experimental.goals || queueCount > 0)) {
|
|
162
|
-
actions.push(GOAL_MENU_ACTIONS.queue);
|
|
163
|
-
}
|
|
164
124
|
actions.push(GOAL_MENU_ACTIONS.settings, GOAL_MENU_ACTIONS.help);
|
|
165
125
|
if (goal) actions.push(GOAL_MENU_ACTIONS.clear);
|
|
166
126
|
actions.push(GOAL_MENU_ACTIONS.close);
|
|
@@ -186,14 +146,10 @@ export async function showGoalManager(
|
|
|
186
146
|
const { defineMenu, runMenu } = await import("@narumitw/pi-tui-kit");
|
|
187
147
|
if (!isMenuCurrent()) return;
|
|
188
148
|
let displayedGoal: ActiveGoal | undefined;
|
|
189
|
-
let startBudgetQueueIdentity = currentGoalQueueIdentity(runtime);
|
|
190
149
|
let displayedBudgetGoal: ActiveGoal | undefined;
|
|
191
150
|
let displayedBudgetValue: number | undefined;
|
|
192
151
|
let displayedBudgetUsage: number | undefined;
|
|
193
152
|
let displayedBudgetStatus: ActiveGoal["status"] | undefined;
|
|
194
|
-
let displayedQueueHead: ActiveGoal | undefined;
|
|
195
|
-
let displayedQueueFirst: ActiveGoal | undefined;
|
|
196
|
-
let displayedQueueLast: ActiveGoal | undefined;
|
|
197
153
|
const menu = defineMenu<undefined, GoalMenuScreen, GoalMenuAction, ExtensionCommandContext>({
|
|
198
154
|
start: "main",
|
|
199
155
|
screens: {
|
|
@@ -201,7 +157,6 @@ export async function showGoalManager(
|
|
|
201
157
|
refreshGoalMenuState(runtime, ctx);
|
|
202
158
|
const state = buildGoalMenuState(runtime);
|
|
203
159
|
displayedGoal = runtime.activeGoal;
|
|
204
|
-
startBudgetQueueIdentity = currentGoalQueueIdentity(runtime);
|
|
205
160
|
return {
|
|
206
161
|
kind: "actions",
|
|
207
162
|
title: "Goal",
|
|
@@ -286,7 +241,6 @@ export async function showGoalManager(
|
|
|
286
241
|
displayedGoal = goal;
|
|
287
242
|
const limit = runtime.settings.continuationLimits.automaticTurns;
|
|
288
243
|
const used = goal?.automaticModelTurns ?? 0;
|
|
289
|
-
const queueCount = runtime.queuedGoals.length;
|
|
290
244
|
return {
|
|
291
245
|
kind: "actions",
|
|
292
246
|
title: "Automatic work paused",
|
|
@@ -295,7 +249,7 @@ export async function showGoalManager(
|
|
|
295
249
|
automaticPauseSummary(used, limit),
|
|
296
250
|
`${safeGoalMenuText(goal.text)} is preserved.`,
|
|
297
251
|
`${formatInteger(goal.tokensUsed)} cumulative tokens and ${formatDuration(goal.timeUsedSeconds)} active time are preserved.`,
|
|
298
|
-
|
|
252
|
+
"The objective and usage are preserved.",
|
|
299
253
|
limit === null
|
|
300
254
|
? "Continuing resets the counter to 0 and resumes with Unlimited automatic work."
|
|
301
255
|
: `Continuing resets the counter to 0 and allows up to ${limit} more automatic model responses.`,
|
|
@@ -322,47 +276,12 @@ export async function showGoalManager(
|
|
|
322
276
|
hint: "back",
|
|
323
277
|
};
|
|
324
278
|
},
|
|
325
|
-
queue: () => {
|
|
326
|
-
displayedQueueHead = runtime.activeGoal;
|
|
327
|
-
displayedQueueFirst = runtime.queuedGoals[0];
|
|
328
|
-
displayedQueueLast = runtime.queuedGoals.at(-1) ?? runtime.activeGoal;
|
|
329
|
-
return {
|
|
330
|
-
kind: "actions",
|
|
331
|
-
title: "Goal queue",
|
|
332
|
-
lines: [
|
|
333
|
-
`${runtime.queuedGoals.length + (runtime.activeGoal ? 1 : 0)} total`,
|
|
334
|
-
...(runtime.activeGoal
|
|
335
|
-
? [`Current: ${safeGoalMenuText(runtime.activeGoal.text)}`]
|
|
336
|
-
: []),
|
|
337
|
-
],
|
|
338
|
-
items: [
|
|
339
|
-
{ id: "add", label: QUEUE_ACTIONS.add, action: "queue-add" },
|
|
340
|
-
{ id: "prioritize", label: QUEUE_ACTIONS.prioritize, action: "queue-prioritize" },
|
|
341
|
-
...(runtime.queuedGoals.length > 0
|
|
342
|
-
? [
|
|
343
|
-
{ id: "skip", label: QUEUE_ACTIONS.skip, action: "queue-skip" as const },
|
|
344
|
-
{
|
|
345
|
-
id: "drop-last",
|
|
346
|
-
label: QUEUE_ACTIONS.dropLast,
|
|
347
|
-
action: "queue-drop" as const,
|
|
348
|
-
},
|
|
349
|
-
]
|
|
350
|
-
: []),
|
|
351
|
-
{ id: "back", label: QUEUE_ACTIONS.back, action: "back" },
|
|
352
|
-
],
|
|
353
|
-
hint: "back",
|
|
354
|
-
};
|
|
355
|
-
},
|
|
356
279
|
status: () => ({
|
|
357
280
|
kind: "detail",
|
|
358
281
|
title: "Goal status",
|
|
359
282
|
lines: runtime.activeGoal
|
|
360
283
|
? goalSummary(
|
|
361
284
|
runtime.activeGoal,
|
|
362
|
-
runtime.queuedGoals,
|
|
363
|
-
runtime.settings.experimental.goals,
|
|
364
|
-
runtime.queueFrozen,
|
|
365
|
-
runtime.pendingQueueAction,
|
|
366
285
|
runtime.settings.continuationLimits.automaticTurns,
|
|
367
286
|
).split("\n")
|
|
368
287
|
: ["No goal is currently set."],
|
|
@@ -384,12 +303,10 @@ export async function showGoalManager(
|
|
|
384
303
|
const budget = parseTokenBudget(itemId);
|
|
385
304
|
if (budget === undefined) return { kind: "rejected" };
|
|
386
305
|
return startBudgetedGoal(
|
|
387
|
-
runtime,
|
|
388
306
|
commands,
|
|
389
307
|
ctx,
|
|
390
308
|
budget,
|
|
391
309
|
runtime.settings.continuationLimits.automaticTurns,
|
|
392
|
-
startBudgetQueueIdentity,
|
|
393
310
|
signal,
|
|
394
311
|
isMenuCurrent,
|
|
395
312
|
"stay",
|
|
@@ -406,12 +323,10 @@ export async function showGoalManager(
|
|
|
406
323
|
return { kind: "rejected" };
|
|
407
324
|
}
|
|
408
325
|
return startBudgetedGoal(
|
|
409
|
-
runtime,
|
|
410
326
|
commands,
|
|
411
327
|
ctx,
|
|
412
328
|
budget,
|
|
413
329
|
runtime.settings.continuationLimits.automaticTurns,
|
|
414
|
-
startBudgetQueueIdentity,
|
|
415
330
|
signal,
|
|
416
331
|
isMenuCurrent,
|
|
417
332
|
"back",
|
|
@@ -517,76 +432,14 @@ export async function showGoalManager(
|
|
|
517
432
|
return { kind: "stay" };
|
|
518
433
|
},
|
|
519
434
|
clear: async () => {
|
|
520
|
-
const
|
|
521
|
-
runtime.activeGoal,
|
|
522
|
-
runtime.queuedGoals,
|
|
523
|
-
runtime.pendingQueueAction,
|
|
524
|
-
);
|
|
435
|
+
const previewedGoal = runtime.activeGoal;
|
|
525
436
|
if (!(await confirmClear(runtime, ctx))) return { kind: "stay" };
|
|
526
|
-
if (
|
|
527
|
-
goalQueueIdentity(runtime.activeGoal, runtime.queuedGoals, runtime.pendingQueueAction) !==
|
|
528
|
-
previewedQueue
|
|
529
|
-
) {
|
|
530
|
-
notifyTerminal(
|
|
531
|
-
ctx.ui,
|
|
532
|
-
"The goal queue changed while the dialog was open. Reopen /goal and try again.",
|
|
533
|
-
"warning",
|
|
534
|
-
);
|
|
437
|
+
if (previewedGoal && !requireCurrentMenuGoal(runtime, previewedGoal, ctx)) {
|
|
535
438
|
return { kind: "stay" };
|
|
536
439
|
}
|
|
537
440
|
commands.clearGoal(ctx);
|
|
538
441
|
return { kind: "close" };
|
|
539
442
|
},
|
|
540
|
-
"queue-add": async () => {
|
|
541
|
-
const objective = (await ctx.ui.editor("Add goal to queue", ""))?.trim();
|
|
542
|
-
if (objective) await commands.addGoal(objective, undefined, ctx);
|
|
543
|
-
return { kind: "close" };
|
|
544
|
-
},
|
|
545
|
-
"queue-prioritize": async () => {
|
|
546
|
-
const goal = displayedQueueHead;
|
|
547
|
-
if (!goal) return { kind: "stay" };
|
|
548
|
-
const objective = (await ctx.ui.editor("Prioritize goal", ""))?.trim();
|
|
549
|
-
if (!objective || !requireCurrentQueueHead(runtime, goal, ctx)) return { kind: "stay" };
|
|
550
|
-
const confirmed = await ctx.ui.confirm(
|
|
551
|
-
"Prioritize goal?",
|
|
552
|
-
`New priority goal:\n${safeGoalMenuText(objective, 4_000)}\n\nCurrent goal moved to the queue:\n${safeGoalMenuText(goal.text, 4_000)}`,
|
|
553
|
-
);
|
|
554
|
-
if (confirmed && requireCurrentQueueHead(runtime, goal, ctx)) {
|
|
555
|
-
await commands.prioritizeGoal(objective, undefined, ctx);
|
|
556
|
-
}
|
|
557
|
-
return { kind: "close" };
|
|
558
|
-
},
|
|
559
|
-
"queue-skip": async () => {
|
|
560
|
-
const goal = displayedQueueHead;
|
|
561
|
-
if (!goal) return { kind: "stay" };
|
|
562
|
-
const next = displayedQueueFirst;
|
|
563
|
-
const nextEffect = !next
|
|
564
|
-
? "No goal remains"
|
|
565
|
-
: next.status === "queued"
|
|
566
|
-
? `Start next goal:\n${safeGoalMenuText(next.text, 4_000)}`
|
|
567
|
-
: `Next goal remains ${displayStatus(next.status).toLowerCase()}:\n${safeGoalMenuText(next.text, 4_000)}`;
|
|
568
|
-
const confirmed = await ctx.ui.confirm(
|
|
569
|
-
"Skip current goal?",
|
|
570
|
-
`Remove current goal:\n${safeGoalMenuText(goal.text, 4_000)}\n\n${nextEffect}`,
|
|
571
|
-
);
|
|
572
|
-
if (confirmed && requireCurrentQueueSelection(runtime, goal, next, "first", ctx)) {
|
|
573
|
-
await commands.skipGoal(ctx);
|
|
574
|
-
}
|
|
575
|
-
return { kind: "close" };
|
|
576
|
-
},
|
|
577
|
-
"queue-drop": async () => {
|
|
578
|
-
const goal = displayedQueueHead;
|
|
579
|
-
const last = displayedQueueLast;
|
|
580
|
-
if (!goal || !last) return { kind: "stay" };
|
|
581
|
-
const confirmed = await ctx.ui.confirm(
|
|
582
|
-
"Drop last goal?",
|
|
583
|
-
`Remove from queue:\n${safeGoalMenuText(last.text, 4_000)}`,
|
|
584
|
-
);
|
|
585
|
-
if (confirmed && requireCurrentQueueSelection(runtime, goal, last, "last", ctx)) {
|
|
586
|
-
commands.dropLastGoal(ctx);
|
|
587
|
-
}
|
|
588
|
-
return { kind: "close" };
|
|
589
|
-
},
|
|
590
443
|
back: async () => ({ kind: "back" }),
|
|
591
444
|
},
|
|
592
445
|
});
|
|
@@ -608,7 +461,6 @@ function goalMainMenuItem(label: string): ActionMenuItem<GoalMenuScreen, GoalMen
|
|
|
608
461
|
if (label === GOAL_MENU_ACTIONS.reviewSafety) {
|
|
609
462
|
return { id: "review-safety", label, to: "safety" as const };
|
|
610
463
|
}
|
|
611
|
-
if (label === GOAL_MENU_ACTIONS.queue) return { id: "queue", label, to: "queue" as const };
|
|
612
464
|
if (label === GOAL_MENU_ACTIONS.help) return { id: "help", label, to: "help" as const };
|
|
613
465
|
if (label === GOAL_MENU_ACTIONS.close) return { id: "close", label, close: true as const };
|
|
614
466
|
const actions = new Map<string, GoalMenuAction>([
|
|
@@ -625,7 +477,7 @@ function goalMainMenuItem(label: string): ActionMenuItem<GoalMenuScreen, GoalMen
|
|
|
625
477
|
|
|
626
478
|
function refreshGoalMenuState(runtime: GoalMenuRuntimeView, ctx: ExtensionCommandContext) {
|
|
627
479
|
const goal = runtime.activeGoal;
|
|
628
|
-
if (!goal
|
|
480
|
+
if (!goal) return;
|
|
629
481
|
runtime.recordGoalUsage?.(goal, ctx);
|
|
630
482
|
runtime.persistGoal?.(goal);
|
|
631
483
|
runtime.updateStatus?.(ctx, goal);
|
|
@@ -638,19 +490,14 @@ async function startFromMenu(commands: GoalCommandController, ctx: ExtensionComm
|
|
|
638
490
|
}
|
|
639
491
|
|
|
640
492
|
async function startBudgetedGoal(
|
|
641
|
-
runtime: GoalMenuRuntimeView,
|
|
642
493
|
commands: GoalCommandController,
|
|
643
494
|
ctx: ExtensionCommandContext,
|
|
644
495
|
budget: number,
|
|
645
496
|
automaticLimit: number | null,
|
|
646
|
-
expectedQueueIdentity: string,
|
|
647
497
|
signal: AbortSignal,
|
|
648
498
|
isMenuCurrent: () => boolean,
|
|
649
499
|
cancelTransition: "stay" | "back",
|
|
650
500
|
) {
|
|
651
|
-
if (!requireCurrentStartBudgetQueue(runtime, expectedQueueIdentity, ctx)) {
|
|
652
|
-
return { kind: "rejected" as const };
|
|
653
|
-
}
|
|
654
501
|
const objective = (
|
|
655
502
|
await ctx.ui.editor(
|
|
656
503
|
`Goal objective · Token budget ${formatCompactTokenCount(budget)} · ${automaticLimit === null ? "Automatic Unlimited" : `Automatic limit ${automaticLimit}`}`,
|
|
@@ -659,9 +506,6 @@ async function startBudgetedGoal(
|
|
|
659
506
|
)?.trim();
|
|
660
507
|
if (signal.aborted || !isMenuCurrent()) return { kind: "close" as const };
|
|
661
508
|
if (!objective) return { kind: cancelTransition } as const;
|
|
662
|
-
if (!requireCurrentStartBudgetQueue(runtime, expectedQueueIdentity, ctx)) {
|
|
663
|
-
return { kind: "rejected" as const };
|
|
664
|
-
}
|
|
665
509
|
await commands.startGoal(
|
|
666
510
|
objective,
|
|
667
511
|
budget,
|
|
@@ -756,46 +600,14 @@ async function editFromMenu(
|
|
|
756
600
|
}
|
|
757
601
|
|
|
758
602
|
async function confirmClear(runtime: GoalMenuRuntimeView, ctx: ExtensionCommandContext) {
|
|
759
|
-
const
|
|
760
|
-
|
|
761
|
-
);
|
|
762
|
-
const pendingPriority =
|
|
763
|
-
runtime.pendingQueueAction?.kind === "prioritize"
|
|
764
|
-
? runtime.pendingQueueAction.objective
|
|
765
|
-
: undefined;
|
|
766
|
-
const summaries = [
|
|
767
|
-
...goals.map((goal) => safeGoalMenuText(goal.text, 4_000)),
|
|
768
|
-
...(pendingPriority ? [`Pending priority: ${safeGoalMenuText(pendingPriority, 4_000)}`] : []),
|
|
769
|
-
];
|
|
770
|
-
if (summaries.length === 0) return false;
|
|
603
|
+
const goal = runtime.activeGoal;
|
|
604
|
+
if (!goal) return false;
|
|
771
605
|
return ctx.ui.confirm(
|
|
772
|
-
|
|
773
|
-
`Remove
|
|
774
|
-
.map((summary, index) => `${index + 1}. ${summary}`)
|
|
775
|
-
.join("\n")}\n\nThis cannot be undone.`,
|
|
606
|
+
"Clear goal?",
|
|
607
|
+
`Remove this goal:\n\n${safeGoalMenuText(goal.text, 4_000)}\n\nThis cannot be undone.`,
|
|
776
608
|
);
|
|
777
609
|
}
|
|
778
610
|
|
|
779
|
-
function currentGoalQueueIdentity(runtime: GoalMenuRuntimeView) {
|
|
780
|
-
return goalQueueIdentity(runtime.activeGoal, runtime.queuedGoals, runtime.pendingQueueAction);
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
function requireCurrentStartBudgetQueue(
|
|
784
|
-
runtime: GoalMenuRuntimeView,
|
|
785
|
-
expectedIdentity: string,
|
|
786
|
-
ctx: ExtensionCommandContext,
|
|
787
|
-
) {
|
|
788
|
-
if (currentGoalQueueIdentity(runtime) === expectedIdentity) {
|
|
789
|
-
return true;
|
|
790
|
-
}
|
|
791
|
-
notifyTerminal(
|
|
792
|
-
ctx.ui,
|
|
793
|
-
"The goal queue changed while the token budget flow was open. Reopen /goal and try again.",
|
|
794
|
-
"warning",
|
|
795
|
-
);
|
|
796
|
-
return false;
|
|
797
|
-
}
|
|
798
|
-
|
|
799
611
|
function requireCurrentBudgetPreview(
|
|
800
612
|
runtime: GoalMenuRuntimeView,
|
|
801
613
|
expectedGoal: ActiveGoal,
|
|
@@ -821,45 +633,6 @@ function requireCurrentBudgetPreview(
|
|
|
821
633
|
return false;
|
|
822
634
|
}
|
|
823
635
|
|
|
824
|
-
function requireCurrentQueueHead(
|
|
825
|
-
runtime: GoalMenuRuntimeView,
|
|
826
|
-
expectedGoal: ActiveGoal,
|
|
827
|
-
ctx: ExtensionCommandContext,
|
|
828
|
-
) {
|
|
829
|
-
if (runtime.activeGoal?.id === expectedGoal.id) return true;
|
|
830
|
-
notifyTerminal(
|
|
831
|
-
ctx.ui,
|
|
832
|
-
"The goal queue changed while the dialog was open. Reopen /goal and try again.",
|
|
833
|
-
"warning",
|
|
834
|
-
);
|
|
835
|
-
return false;
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
function requireCurrentQueueSelection(
|
|
839
|
-
runtime: GoalMenuRuntimeView,
|
|
840
|
-
expectedGoal: ActiveGoal,
|
|
841
|
-
expectedQueuedGoal: ActiveGoal | undefined,
|
|
842
|
-
position: "first" | "last",
|
|
843
|
-
ctx: ExtensionCommandContext,
|
|
844
|
-
) {
|
|
845
|
-
const currentQueuedGoal =
|
|
846
|
-
position === "first"
|
|
847
|
-
? runtime.queuedGoals[0]
|
|
848
|
-
: (runtime.queuedGoals.at(-1) ?? runtime.activeGoal);
|
|
849
|
-
if (
|
|
850
|
-
runtime.activeGoal?.id === expectedGoal.id &&
|
|
851
|
-
currentQueuedGoal?.id === expectedQueuedGoal?.id
|
|
852
|
-
) {
|
|
853
|
-
return true;
|
|
854
|
-
}
|
|
855
|
-
notifyTerminal(
|
|
856
|
-
ctx.ui,
|
|
857
|
-
"The goal queue changed while the dialog was open. Reopen /goal and try again.",
|
|
858
|
-
"warning",
|
|
859
|
-
);
|
|
860
|
-
return false;
|
|
861
|
-
}
|
|
862
|
-
|
|
863
636
|
function requireCurrentMenuGoal(
|
|
864
637
|
runtime: GoalMenuRuntimeView,
|
|
865
638
|
expected: ActiveGoal,
|
|
@@ -902,7 +675,7 @@ function automaticPauseSummary(used: number, limit: number | null) {
|
|
|
902
675
|
function goalHelp() {
|
|
903
676
|
return [
|
|
904
677
|
"Goal menu",
|
|
905
|
-
"Use the menu for guided status, edits,
|
|
678
|
+
"Use the menu for guided status, edits, settings, and confirmations.",
|
|
906
679
|
"Direct routes remain available for deterministic workflows:",
|
|
907
680
|
"/goal <objective>",
|
|
908
681
|
"/goal status | pause | resume | edit | clear",
|