@gajae-code/coding-agent 0.2.1 → 0.2.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/CHANGELOG.md +31 -1
- package/dist/types/commands/contribution-prep.d.ts +18 -0
- package/dist/types/commands/session.d.ts +24 -0
- package/dist/types/config/model-registry.d.ts +2 -2
- package/dist/types/config/models-config-schema.d.ts +17 -9
- package/dist/types/config/settings-schema.d.ts +1 -24
- package/dist/types/gjc-runtime/deep-interview-runtime.d.ts +15 -0
- package/dist/types/gjc-runtime/goal-mode-request.d.ts +1 -1
- package/dist/types/gjc-runtime/launch-tmux.d.ts +12 -11
- package/dist/types/gjc-runtime/ralplan-runtime.d.ts +25 -0
- package/dist/types/gjc-runtime/state-runtime.d.ts +13 -0
- package/dist/types/gjc-runtime/team-runtime.d.ts +37 -5
- package/dist/types/gjc-runtime/tmux-common.d.ts +41 -0
- package/dist/types/gjc-runtime/tmux-sessions.d.ts +17 -0
- package/dist/types/goals/runtime.d.ts +3 -9
- package/dist/types/goals/state.d.ts +3 -6
- package/dist/types/goals/tools/goal-tool.d.ts +1 -69
- package/dist/types/modes/components/status-line/types.d.ts +0 -3
- package/dist/types/modes/components/status-line.d.ts +0 -3
- package/dist/types/modes/controllers/command-controller.d.ts +1 -0
- package/dist/types/modes/interactive-mode.d.ts +1 -12
- package/dist/types/modes/theme/defaults/index.d.ts +0 -2
- package/dist/types/modes/theme/theme.d.ts +1 -2
- package/dist/types/modes/types.d.ts +1 -7
- package/dist/types/session/agent-session.d.ts +2 -0
- package/dist/types/session/contribution-prep.d.ts +47 -0
- package/dist/types/skill-state/active-state.d.ts +4 -0
- package/dist/types/skill-state/deep-interview-mutation-guard.d.ts +6 -1
- package/dist/types/skill-state/workflow-hud.d.ts +9 -4
- package/dist/types/skill-state/workflow-state-contract.d.ts +34 -0
- package/package.json +7 -7
- package/src/cli/args.ts +3 -2
- package/src/cli.ts +6 -1
- package/src/commands/contribution-prep.ts +41 -0
- package/src/commands/deep-interview.ts +6 -22
- package/src/commands/launch.ts +10 -1
- package/src/commands/ralplan.ts +10 -22
- package/src/commands/session.ts +150 -0
- package/src/commands/state.ts +14 -4
- package/src/commands/team.ts +23 -3
- package/src/config/model-registry.ts +10 -2
- package/src/config/models-config-schema.ts +120 -102
- package/src/config/settings-schema.ts +1 -25
- package/src/config.ts +1 -1
- package/src/defaults/gjc/skills/deep-interview/SKILL.md +14 -13
- package/src/defaults/gjc/skills/ralplan/SKILL.md +14 -2
- package/src/defaults/gjc/skills/team/SKILL.md +29 -7
- package/src/defaults/gjc/skills/ultragoal/SKILL.md +23 -25
- package/src/eval/py/prelude.py +1 -1
- package/src/gjc-runtime/deep-interview-runtime.ts +279 -0
- package/src/gjc-runtime/goal-mode-request.ts +2 -19
- package/src/gjc-runtime/launch-tmux.ts +83 -43
- package/src/gjc-runtime/ralplan-runtime.ts +460 -0
- package/src/gjc-runtime/state-runtime.ts +562 -0
- package/src/gjc-runtime/team-runtime.ts +708 -52
- package/src/gjc-runtime/tmux-common.ts +119 -0
- package/src/gjc-runtime/tmux-sessions.ts +165 -0
- package/src/gjc-runtime/ultragoal-guard.ts +6 -3
- package/src/gjc-runtime/ultragoal-runtime.ts +5 -4
- package/src/goals/runtime.ts +38 -144
- package/src/goals/state.ts +36 -7
- package/src/goals/tools/goal-tool.ts +15 -172
- package/src/hooks/skill-state.ts +31 -12
- package/src/internal-urls/docs-index.generated.ts +4 -3
- package/src/modes/components/skill-hud/render.ts +4 -0
- package/src/modes/components/status-line/segments.ts +5 -16
- package/src/modes/components/status-line/types.ts +0 -3
- package/src/modes/components/status-line.ts +0 -6
- package/src/modes/controllers/command-controller.ts +25 -1
- package/src/modes/controllers/input-controller.ts +0 -15
- package/src/modes/interactive-mode.ts +18 -219
- package/src/modes/theme/defaults/dark-poimandres.json +0 -1
- package/src/modes/theme/defaults/light-poimandres.json +0 -1
- package/src/modes/theme/theme.ts +0 -6
- package/src/modes/types.ts +1 -7
- package/src/prompts/goals/goal-continuation.md +1 -4
- package/src/prompts/goals/goal-mode-active.md +3 -5
- package/src/prompts/system/system-prompt.md +5 -7
- package/src/prompts/tools/goal.md +4 -4
- package/src/sdk.ts +1 -1
- package/src/session/agent-session.ts +18 -0
- package/src/session/contribution-prep.ts +320 -0
- package/src/skill-state/active-state.ts +38 -0
- package/src/skill-state/deep-interview-mutation-guard.ts +88 -24
- package/src/skill-state/workflow-hud.ts +23 -5
- package/src/skill-state/workflow-state-contract.ts +121 -0
- package/src/slash-commands/builtin-registry.ts +24 -12
- package/src/task/commands.ts +1 -5
- package/src/tools/gh.ts +212 -2
- package/src/tools/index.ts +2 -5
- package/dist/types/commands/gjc-runtime-bridge.d.ts +0 -30
- package/dist/types/commands/question.d.ts +0 -7
- package/dist/types/modes/loop-limit.d.ts +0 -22
- package/src/commands/gjc-runtime-bridge.ts +0 -227
- package/src/commands/question.ts +0 -12
- package/src/modes/loop-limit.ts +0 -140
- package/src/prompts/commands/orchestrate.md +0 -49
- package/src/prompts/goals/goal-budget-limit.md +0 -16
- package/src/prompts/tools/create-goal.md +0 -3
- package/src/prompts/tools/get-goal.md +0 -3
- package/src/prompts/tools/update-goal.md +0 -3
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SkillActiveEntry, WorkflowHudChip } from "../../../skill-state/active-state";
|
|
2
|
+
import { workflowReceiptStatus } from "../../../skill-state/workflow-state-contract";
|
|
2
3
|
|
|
3
4
|
const ANSI_RESET_FG = "\x1b[39m";
|
|
4
5
|
const ANSI_RESET_BOLD = "\x1b[22m";
|
|
@@ -60,6 +61,9 @@ function formatEntry(entry: SkillActiveEntry): string {
|
|
|
60
61
|
.map(formatChip)
|
|
61
62
|
.filter((chip): chip is string => Boolean(chip));
|
|
62
63
|
if (entry.stale === true) chips.unshift("warn:stale");
|
|
64
|
+
const receiptStatus = workflowReceiptStatus(entry.receipt);
|
|
65
|
+
if (receiptStatus === "stale") chips.unshift("warn:receipt=stale");
|
|
66
|
+
if (receiptStatus === "fresh") chips.push("receipt=fresh");
|
|
63
67
|
const summary = sanitizeHudPart(entry.hud?.summary);
|
|
64
68
|
return [base, summary, ...chips].filter(Boolean).join(" ");
|
|
65
69
|
}
|
|
@@ -110,10 +110,9 @@ const modelSegment: StatusLineSegment = {
|
|
|
110
110
|
},
|
|
111
111
|
};
|
|
112
112
|
|
|
113
|
-
function
|
|
113
|
+
function formatGoalUsage(current: number): string {
|
|
114
114
|
const used = formatNumber(current);
|
|
115
|
-
|
|
116
|
-
return `${used}/${formatNumber(budget)}`;
|
|
115
|
+
return used;
|
|
117
116
|
}
|
|
118
117
|
|
|
119
118
|
function renderGoalMode(ctx: SegmentContext, mode: { enabled: boolean; paused: boolean }): RenderedSegment {
|
|
@@ -131,10 +130,6 @@ function renderGoalMode(ctx: SegmentContext, mode: { enabled: boolean; paused: b
|
|
|
131
130
|
icon = theme.symbol("status.success");
|
|
132
131
|
color = "success";
|
|
133
132
|
break;
|
|
134
|
-
case "budget-limited":
|
|
135
|
-
icon = theme.symbol("status.warning");
|
|
136
|
-
color = "warning";
|
|
137
|
-
break;
|
|
138
133
|
case "dropped":
|
|
139
134
|
icon = theme.symbol("status.aborted");
|
|
140
135
|
color = "dim";
|
|
@@ -144,9 +139,9 @@ function renderGoalMode(ctx: SegmentContext, mode: { enabled: boolean; paused: b
|
|
|
144
139
|
}
|
|
145
140
|
|
|
146
141
|
const parts: string[] = [withIcon(icon, "Goal")];
|
|
147
|
-
const
|
|
148
|
-
if (
|
|
149
|
-
parts.push(
|
|
142
|
+
const showUsage = ctx.session.settings.get("goal.statusInFooter") === true;
|
|
143
|
+
if (showUsage && goal) {
|
|
144
|
+
parts.push(formatGoalUsage(goal.tokensUsed));
|
|
150
145
|
}
|
|
151
146
|
return { content: theme.fg(color, parts.join(" ")), visible: true };
|
|
152
147
|
}
|
|
@@ -169,12 +164,6 @@ const modeSegment: StatusLineSegment = {
|
|
|
169
164
|
return renderGoalMode(ctx, goal);
|
|
170
165
|
}
|
|
171
166
|
|
|
172
|
-
const loop = ctx.loopMode;
|
|
173
|
-
if (loop?.enabled) {
|
|
174
|
-
const content = withIcon(theme.icon.loop, "Loop");
|
|
175
|
-
return { content: theme.fg("customMessageLabel", content), visible: true };
|
|
176
|
-
}
|
|
177
|
-
|
|
178
167
|
return { content: "", visible: false };
|
|
179
168
|
},
|
|
180
169
|
};
|
|
@@ -155,7 +155,6 @@ export class StatusLineComponent implements Component {
|
|
|
155
155
|
#subagentCount: number = 0;
|
|
156
156
|
#sessionStartTime: number = Date.now();
|
|
157
157
|
#planModeStatus: { enabled: boolean; paused: boolean } | null = null;
|
|
158
|
-
#loopModeStatus: { enabled: boolean } | null = null;
|
|
159
158
|
#goalModeStatus: { enabled: boolean; paused: boolean } | null = null;
|
|
160
159
|
#skillHudEntries: SkillActiveEntry[] = [];
|
|
161
160
|
#skillHudLastFetch = 0;
|
|
@@ -229,10 +228,6 @@ export class StatusLineComponent implements Component {
|
|
|
229
228
|
this.#planModeStatus = status ?? null;
|
|
230
229
|
}
|
|
231
230
|
|
|
232
|
-
setLoopModeStatus(status: { enabled: boolean } | undefined): void {
|
|
233
|
-
this.#loopModeStatus = status ?? null;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
231
|
setGoalModeStatus(status: { enabled: boolean; paused: boolean } | undefined): void {
|
|
237
232
|
this.#goalModeStatus = status ?? null;
|
|
238
233
|
}
|
|
@@ -611,7 +606,6 @@ export class StatusLineComponent implements Component {
|
|
|
611
606
|
width,
|
|
612
607
|
options: this.#resolveSettings().segmentOptions ?? {},
|
|
613
608
|
planMode: this.#planModeStatus,
|
|
614
|
-
loopMode: this.#loopModeStatus,
|
|
615
609
|
goalMode: this.#goalModeStatus,
|
|
616
610
|
usageStats,
|
|
617
611
|
contextPercent,
|
|
@@ -1248,7 +1248,31 @@ export class CommandController {
|
|
|
1248
1248
|
this.ctx.statusContainer.clear();
|
|
1249
1249
|
this.ctx.editor.onEscape = originalOnEscape;
|
|
1250
1250
|
}
|
|
1251
|
-
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
async handleContributionPrepCommand(customInstructions?: string): Promise<void> {
|
|
1254
|
+
this.ctx.editor.setText("");
|
|
1255
|
+
try {
|
|
1256
|
+
const result = await this.ctx.session.prepareContributionPrep({ customInstructions, spawnWorker: true });
|
|
1257
|
+
this.ctx.showStatus(
|
|
1258
|
+
[
|
|
1259
|
+
"Contribution prep artifacts written.",
|
|
1260
|
+
`Manifest: ${result.manifestPath}`,
|
|
1261
|
+
`Worker prompt: ${result.workerPromptPath}`,
|
|
1262
|
+
].join("\n"),
|
|
1263
|
+
);
|
|
1264
|
+
this.ctx.chatContainer.addChild(
|
|
1265
|
+
new Text(
|
|
1266
|
+
`${theme.fg("accent", `${theme.status.success} Contribution prep ready`)}\nManifest: ${result.manifestPath}`,
|
|
1267
|
+
1,
|
|
1268
|
+
1,
|
|
1269
|
+
),
|
|
1270
|
+
);
|
|
1271
|
+
this.ctx.ui.requestRender();
|
|
1272
|
+
} catch (error) {
|
|
1273
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1274
|
+
this.ctx.showError(`Contribution prep failed: ${message}`);
|
|
1275
|
+
}
|
|
1252
1276
|
}
|
|
1253
1277
|
}
|
|
1254
1278
|
|
|
@@ -51,15 +51,6 @@ export class InputController {
|
|
|
51
51
|
this.ctx.retryEscapeHandler,
|
|
52
52
|
);
|
|
53
53
|
this.ctx.editor.onEscape = () => {
|
|
54
|
-
if (this.ctx.loopModeEnabled) {
|
|
55
|
-
this.ctx.pauseLoop();
|
|
56
|
-
if (this.ctx.session.isStreaming) {
|
|
57
|
-
void this.#abortInteractive();
|
|
58
|
-
} else {
|
|
59
|
-
this.ctx.cancelPendingSubmission();
|
|
60
|
-
}
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
54
|
if (this.ctx.hasActiveBtw() && this.ctx.handleBtwEscape()) {
|
|
64
55
|
return;
|
|
65
56
|
}
|
|
@@ -292,12 +283,6 @@ export class InputController {
|
|
|
292
283
|
}
|
|
293
284
|
}
|
|
294
285
|
|
|
295
|
-
// While loop mode is on, every user-typed prompt becomes the new loop
|
|
296
|
-
// prompt that auto-resubmits after each yield.
|
|
297
|
-
if (this.ctx.loopModeEnabled) {
|
|
298
|
-
this.ctx.loopPrompt = text;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
286
|
// Queue input during compaction
|
|
302
287
|
if (this.ctx.session.isCompacting) {
|
|
303
288
|
if (this.ctx.pendingImages.length > 0) {
|
|
@@ -30,6 +30,7 @@ import { APP_NAME, adjustHsv, getProjectDir, hsvToRgb, isEnoent, logger, postmor
|
|
|
30
30
|
import chalk from "chalk";
|
|
31
31
|
import { KeybindingsManager } from "../config/keybindings";
|
|
32
32
|
import { isSettingsInitialized, type Settings, settings } from "../config/settings";
|
|
33
|
+
import { DEFAULT_GJC_DEFINITION_NAMES } from "../defaults/gjc-defaults";
|
|
33
34
|
import type {
|
|
34
35
|
ExtensionUIContext,
|
|
35
36
|
ExtensionUIDialogOptions,
|
|
@@ -40,7 +41,7 @@ import type { CompactOptions } from "../extensibility/extensions/types";
|
|
|
40
41
|
import { resolveSkillSlashCommands, type Skill } from "../extensibility/skills";
|
|
41
42
|
import { BUILTIN_SLASH_COMMANDS, loadSlashCommands } from "../extensibility/slash-commands";
|
|
42
43
|
import { consumePendingGoalModeRequest } from "../gjc-runtime/goal-mode-request";
|
|
43
|
-
import type
|
|
44
|
+
import { type Goal, type GoalModeState, normalizeGoal } from "../goals/state";
|
|
44
45
|
import { resolveLocalUrlToPath } from "../internal-urls";
|
|
45
46
|
import { LSP_STARTUP_EVENT_CHANNEL, type LspStartupEvent } from "../lsp/startup-events";
|
|
46
47
|
import {
|
|
@@ -87,15 +88,6 @@ import { InputController } from "./controllers/input-controller";
|
|
|
87
88
|
import { SelectorController } from "./controllers/selector-controller";
|
|
88
89
|
import { SSHCommandController } from "./controllers/ssh-command-controller";
|
|
89
90
|
import { TodoCommandController } from "./controllers/todo-command-controller";
|
|
90
|
-
import {
|
|
91
|
-
consumeLoopLimitIteration,
|
|
92
|
-
createLoopLimitRuntime,
|
|
93
|
-
describeLoopLimit,
|
|
94
|
-
describeLoopLimitRuntime,
|
|
95
|
-
isLoopDurationExpired,
|
|
96
|
-
type LoopLimitRuntime,
|
|
97
|
-
parseLoopLimitArgs,
|
|
98
|
-
} from "./loop-limit";
|
|
99
91
|
import { OAuthManualInputManager } from "./oauth-manual-input";
|
|
100
92
|
import { SessionObserverRegistry } from "./session-observer-registry";
|
|
101
93
|
import { interruptHint } from "./shared";
|
|
@@ -191,9 +183,9 @@ function formatHudNoteMarker(count: number): string {
|
|
|
191
183
|
return theme.fg("dim", chalk.italic(` \u207a${sub}`));
|
|
192
184
|
}
|
|
193
185
|
|
|
194
|
-
type GoalSubcommand = "set" | "show" | "pause" | "resume" | "drop"
|
|
186
|
+
type GoalSubcommand = "set" | "show" | "pause" | "resume" | "drop";
|
|
195
187
|
|
|
196
|
-
const GOAL_SUBCOMMANDS = new Set<GoalSubcommand>(["set", "show", "pause", "resume", "drop"
|
|
188
|
+
const GOAL_SUBCOMMANDS = new Set<GoalSubcommand>(["set", "show", "pause", "resume", "drop"]);
|
|
197
189
|
|
|
198
190
|
function parseGoalSubcommand(args: string): { sub: GoalSubcommand | undefined; rest: string } {
|
|
199
191
|
const trimmed = args.trim();
|
|
@@ -251,10 +243,6 @@ export class InteractiveMode implements InteractiveModeContext {
|
|
|
251
243
|
goalModeEnabled = false;
|
|
252
244
|
goalModePaused = false;
|
|
253
245
|
planModePlanFilePath: string | undefined = undefined;
|
|
254
|
-
loopModeEnabled = false;
|
|
255
|
-
loopPrompt: string | undefined = undefined;
|
|
256
|
-
loopLimit: LoopLimitRuntime | undefined = undefined;
|
|
257
|
-
#loopAutoSubmitTimer: NodeJS.Timeout | undefined;
|
|
258
246
|
todoPhases: TodoPhase[] = [];
|
|
259
247
|
hideThinkingBlock = false;
|
|
260
248
|
pendingImages: ImageContent[] = [];
|
|
@@ -623,7 +611,13 @@ export class InteractiveMode implements InteractiveModeContext {
|
|
|
623
611
|
for (const command of resolvedCommands) {
|
|
624
612
|
this.skillCommands.set(command.name, command.skill);
|
|
625
613
|
}
|
|
626
|
-
|
|
614
|
+
const defaultGjcNames = new Set<string>(DEFAULT_GJC_DEFINITION_NAMES);
|
|
615
|
+
return resolvedCommands.map(command => ({
|
|
616
|
+
name: command.name,
|
|
617
|
+
description: command.description,
|
|
618
|
+
// Pin the bundled GJC workflow skills above generic commands in autocomplete.
|
|
619
|
+
...(defaultGjcNames.has(command.skill.name) ? { priority: 100 } : {}),
|
|
620
|
+
}));
|
|
627
621
|
}
|
|
628
622
|
|
|
629
623
|
async getUserInput(): Promise<SubmittedUserInput> {
|
|
@@ -635,40 +629,12 @@ export class InteractiveMode implements InteractiveModeContext {
|
|
|
635
629
|
this.onInputCallback = undefined;
|
|
636
630
|
resolve(input);
|
|
637
631
|
};
|
|
638
|
-
this.#scheduleLoopAutoSubmit();
|
|
639
632
|
this.#scheduleGoalContinuation();
|
|
640
633
|
return promise;
|
|
641
634
|
}
|
|
642
635
|
|
|
643
|
-
#scheduleLoopAutoSubmit(): void {
|
|
644
|
-
this.#cancelLoopAutoSubmit();
|
|
645
|
-
if (!this.loopModeEnabled || !this.loopPrompt) return;
|
|
646
|
-
const prompt = this.loopPrompt;
|
|
647
|
-
const loopAction = settings.get("loop.mode");
|
|
648
|
-
this.#deferLoopAutoSubmit(() => {
|
|
649
|
-
void this.#runLoopIteration(loopAction, prompt);
|
|
650
|
-
});
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
#deferLoopAutoSubmit(callback: () => void): void {
|
|
654
|
-
// Brief delay so the user has a chance to press Esc between iterations.
|
|
655
|
-
this.#loopAutoSubmitTimer = setTimeout(() => {
|
|
656
|
-
this.#loopAutoSubmitTimer = undefined;
|
|
657
|
-
if (!this.loopModeEnabled || !this.onInputCallback) return;
|
|
658
|
-
callback();
|
|
659
|
-
}, 800);
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
#cancelLoopAutoSubmit(): void {
|
|
663
|
-
if (this.#loopAutoSubmitTimer) {
|
|
664
|
-
clearTimeout(this.#loopAutoSubmitTimer);
|
|
665
|
-
this.#loopAutoSubmitTimer = undefined;
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
|
|
669
636
|
#scheduleGoalContinuation(): void {
|
|
670
637
|
this.#cancelGoalContinuation();
|
|
671
|
-
if (this.loopModeEnabled) return;
|
|
672
638
|
if (!this.onInputCallback) return;
|
|
673
639
|
if (!this.session.settings.get("goal.continuationModes").includes("interactive")) return;
|
|
674
640
|
if (this.planModeEnabled || this.planModePaused) return;
|
|
@@ -708,92 +674,6 @@ export class InteractiveMode implements InteractiveModeContext {
|
|
|
708
674
|
}
|
|
709
675
|
}
|
|
710
676
|
|
|
711
|
-
#isLoopAutoSubmitBlocked(): boolean {
|
|
712
|
-
return this.session.isStreaming || this.session.isCompacting || this.session.hasPostPromptWork;
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
#submitLoopPromptWhenReady(prompt: string): void {
|
|
716
|
-
if (!this.loopModeEnabled || this.loopPrompt !== prompt || !this.onInputCallback) return;
|
|
717
|
-
if (isLoopDurationExpired(this.loopLimit)) {
|
|
718
|
-
this.disableLoopMode("Loop time limit reached. Loop mode disabled.");
|
|
719
|
-
return;
|
|
720
|
-
}
|
|
721
|
-
if (this.#isLoopAutoSubmitBlocked()) {
|
|
722
|
-
this.#deferLoopAutoSubmit(() => this.#submitLoopPromptWhenReady(prompt));
|
|
723
|
-
return;
|
|
724
|
-
}
|
|
725
|
-
this.onInputCallback(this.startPendingSubmission({ text: prompt }));
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
async #runLoopIteration(action: "prompt" | "compact" | "reset", prompt: string): Promise<void> {
|
|
729
|
-
if (!this.loopModeEnabled || this.loopPrompt !== prompt || !this.onInputCallback) return;
|
|
730
|
-
if (this.#isLoopAutoSubmitBlocked()) {
|
|
731
|
-
this.#deferLoopAutoSubmit(() => {
|
|
732
|
-
void this.#runLoopIteration(action, prompt);
|
|
733
|
-
});
|
|
734
|
-
return;
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
if (!consumeLoopLimitIteration(this.loopLimit)) {
|
|
738
|
-
this.disableLoopMode("Loop limit reached. Loop mode disabled.");
|
|
739
|
-
return;
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
if (action === "compact") {
|
|
743
|
-
await this.handleCompactCommand();
|
|
744
|
-
} else if (action === "reset") {
|
|
745
|
-
await this.handleClearCommand();
|
|
746
|
-
}
|
|
747
|
-
this.#submitLoopPromptWhenReady(prompt);
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
disableLoopMode(message = "Loop mode disabled."): void {
|
|
751
|
-
const wasEnabled = this.loopModeEnabled;
|
|
752
|
-
this.loopModeEnabled = false;
|
|
753
|
-
this.loopPrompt = undefined;
|
|
754
|
-
this.loopLimit = undefined;
|
|
755
|
-
this.#cancelLoopAutoSubmit();
|
|
756
|
-
this.statusLine.setLoopModeStatus(undefined);
|
|
757
|
-
this.updateEditorChrome();
|
|
758
|
-
this.ui.requestRender();
|
|
759
|
-
if (wasEnabled) {
|
|
760
|
-
this.showStatus(message);
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
/**
|
|
765
|
-
* Pause the loop without exiting it: drops the captured prompt and any
|
|
766
|
-
* pending auto-resubmit. Loop mode stays enabled — the next prompt the
|
|
767
|
-
* user submits becomes the new loop prompt and resumes iteration.
|
|
768
|
-
*/
|
|
769
|
-
pauseLoop(): void {
|
|
770
|
-
this.loopPrompt = undefined;
|
|
771
|
-
this.#cancelLoopAutoSubmit();
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
async handleLoopCommand(args = ""): Promise<void> {
|
|
775
|
-
if (this.loopModeEnabled) {
|
|
776
|
-
this.disableLoopMode();
|
|
777
|
-
return;
|
|
778
|
-
}
|
|
779
|
-
const parsedLimit = parseLoopLimitArgs(args);
|
|
780
|
-
if (typeof parsedLimit === "string") {
|
|
781
|
-
this.showError(parsedLimit);
|
|
782
|
-
return;
|
|
783
|
-
}
|
|
784
|
-
this.loopModeEnabled = true;
|
|
785
|
-
this.loopPrompt = undefined;
|
|
786
|
-
this.loopLimit = createLoopLimitRuntime(parsedLimit);
|
|
787
|
-
this.statusLine.setLoopModeStatus({ enabled: true });
|
|
788
|
-
this.updateEditorChrome();
|
|
789
|
-
this.ui.requestRender();
|
|
790
|
-
const limitSuffix = parsedLimit ? ` Limited to ${describeLoopLimit(parsedLimit)}.` : "";
|
|
791
|
-
const remainingSuffix = this.loopLimit ? ` ${describeLoopLimitRuntime(this.loopLimit)}.` : "";
|
|
792
|
-
this.showStatus(
|
|
793
|
-
`Loop mode enabled.${limitSuffix}${remainingSuffix} Your next prompt will repeat after each turn. Esc cancels the current iteration; /loop again to disable.`,
|
|
794
|
-
);
|
|
795
|
-
}
|
|
796
|
-
|
|
797
677
|
recordLocalSubmission(text: string, imageCount = 0): () => void {
|
|
798
678
|
if (this.isKnownSlashCommand(text)) {
|
|
799
679
|
return () => {};
|
|
@@ -1088,30 +968,7 @@ export class InteractiveMode implements InteractiveModeContext {
|
|
|
1088
968
|
}
|
|
1089
969
|
|
|
1090
970
|
#goalFromModeData(modeData: SessionContext["modeData"]): Goal | undefined {
|
|
1091
|
-
|
|
1092
|
-
if (!goal || typeof goal !== "object") return undefined;
|
|
1093
|
-
const value = goal as Record<string, unknown>;
|
|
1094
|
-
if (
|
|
1095
|
-
typeof value.id !== "string" ||
|
|
1096
|
-
typeof value.objective !== "string" ||
|
|
1097
|
-
typeof value.status !== "string" ||
|
|
1098
|
-
typeof value.tokensUsed !== "number" ||
|
|
1099
|
-
typeof value.timeUsedSeconds !== "number" ||
|
|
1100
|
-
typeof value.createdAt !== "number" ||
|
|
1101
|
-
typeof value.updatedAt !== "number"
|
|
1102
|
-
) {
|
|
1103
|
-
return undefined;
|
|
1104
|
-
}
|
|
1105
|
-
return {
|
|
1106
|
-
id: value.id,
|
|
1107
|
-
objective: value.objective,
|
|
1108
|
-
status: value.status as Goal["status"],
|
|
1109
|
-
tokenBudget: typeof value.tokenBudget === "number" ? value.tokenBudget : undefined,
|
|
1110
|
-
tokensUsed: value.tokensUsed,
|
|
1111
|
-
timeUsedSeconds: value.timeUsedSeconds,
|
|
1112
|
-
createdAt: value.createdAt,
|
|
1113
|
-
updatedAt: value.updatedAt,
|
|
1114
|
-
};
|
|
971
|
+
return normalizeGoal(modeData?.goal) ?? undefined;
|
|
1115
972
|
}
|
|
1116
973
|
|
|
1117
974
|
async #handleGoalSessionEvent(event: AgentSessionEvent): Promise<void> {
|
|
@@ -1434,7 +1291,6 @@ export class InteractiveMode implements InteractiveModeContext {
|
|
|
1434
1291
|
this.sessionManager.appendCustomEntry("goal-completed", {
|
|
1435
1292
|
objective: currentState?.goal?.objective,
|
|
1436
1293
|
tokensUsed: currentState?.goal?.tokensUsed,
|
|
1437
|
-
tokenBudget: currentState?.goal?.tokenBudget,
|
|
1438
1294
|
timeUsedSeconds: currentState?.goal?.timeUsedSeconds,
|
|
1439
1295
|
});
|
|
1440
1296
|
}
|
|
@@ -1702,32 +1558,6 @@ export class InteractiveMode implements InteractiveModeContext {
|
|
|
1702
1558
|
}
|
|
1703
1559
|
}
|
|
1704
1560
|
|
|
1705
|
-
async #handleGoalBudgetCommand(rawBudget: string): Promise<void> {
|
|
1706
|
-
const state = this.session.getGoalModeState();
|
|
1707
|
-
if (!this.goalModeEnabled || !state?.enabled) {
|
|
1708
|
-
this.showWarning("No active goal.");
|
|
1709
|
-
return;
|
|
1710
|
-
}
|
|
1711
|
-
if (state.goal.status === "complete") {
|
|
1712
|
-
this.showStatus("Goal is already complete.");
|
|
1713
|
-
return;
|
|
1714
|
-
}
|
|
1715
|
-
const trimmed = rawBudget.trim().toLowerCase();
|
|
1716
|
-
let nextBudget: number | undefined;
|
|
1717
|
-
if (trimmed !== "off") {
|
|
1718
|
-
const parsed = Number.parseInt(trimmed, 10);
|
|
1719
|
-
if (!Number.isInteger(parsed) || parsed <= 0) {
|
|
1720
|
-
this.showError("Goal budget must be a positive integer or `off`.");
|
|
1721
|
-
return;
|
|
1722
|
-
}
|
|
1723
|
-
nextBudget = parsed;
|
|
1724
|
-
}
|
|
1725
|
-
await this.session.goalRuntime.onBudgetMutated(nextBudget);
|
|
1726
|
-
this.#resetGoalContinuationSuppression();
|
|
1727
|
-
this.#scheduleGoalContinuation();
|
|
1728
|
-
this.showStatus(nextBudget === undefined ? "Goal budget cleared." : `Goal budget set to ${nextBudget}.`);
|
|
1729
|
-
}
|
|
1730
|
-
|
|
1731
1561
|
async handleGoalModeCommand(rest?: string): Promise<void> {
|
|
1732
1562
|
try {
|
|
1733
1563
|
if (this.planModeEnabled || this.planModePaused) {
|
|
@@ -1791,19 +1621,6 @@ export class InteractiveMode implements InteractiveModeContext {
|
|
|
1791
1621
|
case "drop":
|
|
1792
1622
|
await this.#confirmAndDropGoal();
|
|
1793
1623
|
return;
|
|
1794
|
-
case "budget":
|
|
1795
|
-
if (!this.goalModeEnabled) {
|
|
1796
|
-
this.showWarning(
|
|
1797
|
-
this.#getPausedGoalState() ? "Resume the goal before adjusting the budget." : "No active goal.",
|
|
1798
|
-
);
|
|
1799
|
-
return;
|
|
1800
|
-
}
|
|
1801
|
-
if (!rest) {
|
|
1802
|
-
await this.#promptGoalBudgetEdit();
|
|
1803
|
-
return;
|
|
1804
|
-
}
|
|
1805
|
-
await this.#handleGoalBudgetCommand(rest);
|
|
1806
|
-
return;
|
|
1807
1624
|
}
|
|
1808
1625
|
}
|
|
1809
1626
|
|
|
@@ -1812,19 +1629,13 @@ export class InteractiveMode implements InteractiveModeContext {
|
|
|
1812
1629
|
if (!goal) return;
|
|
1813
1630
|
const summary = goal.objective.length > 48 ? `${goal.objective.slice(0, 47)}…` : goal.objective;
|
|
1814
1631
|
const title = state === "active" ? `Goal: ${summary} (${goal.status})` : `Goal paused: ${summary}`;
|
|
1815
|
-
const items =
|
|
1816
|
-
state === "active"
|
|
1817
|
-
? ["Show details", "Adjust budget…", "Pause", "Drop"]
|
|
1818
|
-
: ["Resume", "Show details", "Adjust budget…", "Drop"];
|
|
1632
|
+
const items = state === "active" ? ["Show details", "Pause", "Drop"] : ["Resume", "Show details", "Drop"];
|
|
1819
1633
|
const choice = await this.showHookSelector(title, items);
|
|
1820
1634
|
if (!choice) return;
|
|
1821
1635
|
switch (choice) {
|
|
1822
1636
|
case "Show details":
|
|
1823
1637
|
this.#showGoalDetails();
|
|
1824
1638
|
return;
|
|
1825
|
-
case "Adjust budget…":
|
|
1826
|
-
await this.#promptGoalBudgetEdit();
|
|
1827
|
-
return;
|
|
1828
1639
|
case "Pause":
|
|
1829
1640
|
await this.#pauseGoalAction();
|
|
1830
1641
|
return;
|
|
@@ -1845,31 +1656,15 @@ export class InteractiveMode implements InteractiveModeContext {
|
|
|
1845
1656
|
return;
|
|
1846
1657
|
}
|
|
1847
1658
|
const used = goal.tokensUsed.toLocaleString();
|
|
1848
|
-
const budgetLine =
|
|
1849
|
-
goal.tokenBudget !== undefined
|
|
1850
|
-
? `${used} / ${goal.tokenBudget.toLocaleString()} (${Math.max(0, goal.tokenBudget - goal.tokensUsed).toLocaleString()} left)`
|
|
1851
|
-
: `${used} (no budget)`;
|
|
1852
1659
|
const lines = [
|
|
1853
1660
|
`Objective: ${goal.objective}`,
|
|
1854
1661
|
`Status: ${goal.status}${state?.enabled ? "" : " (paused)"}`,
|
|
1855
|
-
`Tokens: ${
|
|
1662
|
+
`Tokens used: ${used}`,
|
|
1856
1663
|
`Time spent: ${formatDuration(goal.timeUsedSeconds * 1000)}`,
|
|
1857
1664
|
];
|
|
1858
1665
|
this.showStatus(lines.join("\n"));
|
|
1859
1666
|
}
|
|
1860
1667
|
|
|
1861
|
-
async #promptGoalBudgetEdit(): Promise<void> {
|
|
1862
|
-
const goal = this.session.getGoalModeState()?.goal;
|
|
1863
|
-
const prefill = goal?.tokenBudget !== undefined ? String(goal.tokenBudget) : "";
|
|
1864
|
-
const input = (
|
|
1865
|
-
await this.showHookEditor("Goal budget (number, `off`, or empty to cancel)", prefill, undefined, {
|
|
1866
|
-
promptStyle: true,
|
|
1867
|
-
})
|
|
1868
|
-
)?.trim();
|
|
1869
|
-
if (!input) return;
|
|
1870
|
-
await this.#handleGoalBudgetCommand(input);
|
|
1871
|
-
}
|
|
1872
|
-
|
|
1873
1668
|
async #pauseGoalAction(): Promise<void> {
|
|
1874
1669
|
if (!this.goalModeEnabled) {
|
|
1875
1670
|
this.showWarning("No active goal to pause.");
|
|
@@ -2524,6 +2319,10 @@ export class InteractiveMode implements InteractiveModeContext {
|
|
|
2524
2319
|
return this.#commandController.handleHandoffCommand(customInstructions);
|
|
2525
2320
|
}
|
|
2526
2321
|
|
|
2322
|
+
handleContributionPrepCommand(customInstructions?: string): Promise<void> {
|
|
2323
|
+
return this.#commandController.handleContributionPrepCommand(customInstructions);
|
|
2324
|
+
}
|
|
2325
|
+
|
|
2527
2326
|
executeCompaction(
|
|
2528
2327
|
customInstructionsOrOptions?: string | CompactOptions,
|
|
2529
2328
|
isAuto?: boolean,
|
package/src/modes/theme/theme.ts
CHANGED
|
@@ -92,7 +92,6 @@ export type SymbolKey =
|
|
|
92
92
|
| "icon.plan"
|
|
93
93
|
| "icon.goal"
|
|
94
94
|
| "icon.pause"
|
|
95
|
-
| "icon.loop"
|
|
96
95
|
| "icon.folder"
|
|
97
96
|
| "icon.scratchFolder"
|
|
98
97
|
| "icon.file"
|
|
@@ -256,7 +255,6 @@ const UNICODE_SYMBOLS: SymbolMap = {
|
|
|
256
255
|
"icon.plan": "🗺",
|
|
257
256
|
"icon.goal": "🎯",
|
|
258
257
|
"icon.pause": "⏸",
|
|
259
|
-
"icon.loop": "↻",
|
|
260
258
|
"icon.folder": "📁",
|
|
261
259
|
"icon.scratchFolder": "🗑",
|
|
262
260
|
"icon.file": "📄",
|
|
@@ -473,8 +471,6 @@ const NERD_SYMBOLS: SymbolMap = {
|
|
|
473
471
|
"icon.goal": "\uf140",
|
|
474
472
|
// pick: (nf-fa-pause) | alt: ⏸ ||
|
|
475
473
|
"icon.pause": "\uf04c",
|
|
476
|
-
// pick: ↻ | alt: ⟳
|
|
477
|
-
"icon.loop": "\uf021",
|
|
478
474
|
// pick: | alt:
|
|
479
475
|
"icon.folder": "\uf115",
|
|
480
476
|
// pick: | alt:
|
|
@@ -679,7 +675,6 @@ const ASCII_SYMBOLS: SymbolMap = {
|
|
|
679
675
|
"icon.plan": "plan",
|
|
680
676
|
"icon.goal": "goal",
|
|
681
677
|
"icon.pause": "||",
|
|
682
|
-
"icon.loop": "loop",
|
|
683
678
|
"icon.folder": "[D]",
|
|
684
679
|
"icon.scratchFolder": "[T]",
|
|
685
680
|
"icon.file": "[F]",
|
|
@@ -1452,7 +1447,6 @@ export class Theme {
|
|
|
1452
1447
|
plan: this.#symbols["icon.plan"],
|
|
1453
1448
|
goal: this.#symbols["icon.goal"],
|
|
1454
1449
|
pause: this.#symbols["icon.pause"],
|
|
1455
|
-
loop: this.#symbols["icon.loop"],
|
|
1456
1450
|
folder: this.#symbols["icon.folder"],
|
|
1457
1451
|
scratchFolder: this.#symbols["icon.scratchFolder"],
|
|
1458
1452
|
file: this.#symbols["icon.file"],
|
package/src/modes/types.ts
CHANGED
|
@@ -27,7 +27,6 @@ import type { HookInputComponent } from "./components/hook-input";
|
|
|
27
27
|
import type { HookSelectorComponent } from "./components/hook-selector";
|
|
28
28
|
import type { StatusLineComponent } from "./components/status-line";
|
|
29
29
|
import type { ToolExecutionHandle } from "./components/tool-execution";
|
|
30
|
-
import type { LoopLimitRuntime } from "./loop-limit";
|
|
31
30
|
import type { OAuthManualInputManager } from "./oauth-manual-input";
|
|
32
31
|
import type { Theme } from "./theme/theme";
|
|
33
32
|
|
|
@@ -92,9 +91,6 @@ export interface InteractiveModeContext {
|
|
|
92
91
|
planModeEnabled: boolean;
|
|
93
92
|
goalModeEnabled: boolean;
|
|
94
93
|
goalModePaused: boolean;
|
|
95
|
-
loopModeEnabled: boolean;
|
|
96
|
-
loopPrompt?: string;
|
|
97
|
-
loopLimit?: LoopLimitRuntime;
|
|
98
94
|
planModePlanFilePath?: string;
|
|
99
95
|
hideThinkingBlock: boolean;
|
|
100
96
|
pendingImages: ImageContent[];
|
|
@@ -221,6 +217,7 @@ export interface InteractiveModeContext {
|
|
|
221
217
|
handleSSHCommand(text: string): Promise<void>;
|
|
222
218
|
handleCompactCommand(customInstructions?: string): Promise<CompactionOutcome>;
|
|
223
219
|
handleHandoffCommand(customInstructions?: string): Promise<void>;
|
|
220
|
+
handleContributionPrepCommand(customInstructions?: string): Promise<void>;
|
|
224
221
|
handleMoveCommand(targetPath: string): Promise<void>;
|
|
225
222
|
handleRenameCommand(title: string): Promise<void>;
|
|
226
223
|
handleMemoryCommand(text: string): Promise<void>;
|
|
@@ -270,9 +267,6 @@ export interface InteractiveModeContext {
|
|
|
270
267
|
registerExtensionShortcuts(): void;
|
|
271
268
|
handlePlanModeCommand(initialPrompt?: string): Promise<void>;
|
|
272
269
|
handleGoalModeCommand(rest?: string): Promise<void>;
|
|
273
|
-
handleLoopCommand(args?: string): Promise<void>;
|
|
274
|
-
disableLoopMode(): void;
|
|
275
|
-
pauseLoop(): void;
|
|
276
270
|
handlePlanApproval(details: PlanApprovalDetails): Promise<void>;
|
|
277
271
|
|
|
278
272
|
// Hook UI methods
|
|
@@ -6,10 +6,8 @@ Continue work on the active goal.
|
|
|
6
6
|
{{objective}}
|
|
7
7
|
</objective>
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Usage:
|
|
10
10
|
- Tokens used: {{tokensUsed}}
|
|
11
|
-
- Token budget: {{tokenBudget}}
|
|
12
|
-
- Tokens remaining: {{remainingTokens}}
|
|
13
11
|
- Time used: {{timeUsedSeconds}} seconds
|
|
14
12
|
|
|
15
13
|
This is an autonomous continuation. The objective persists across turns; do not redefine success around a smaller, easier, or already-completed subset.
|
|
@@ -21,7 +19,6 @@ Before calling `goal({op:"complete"})`, you MUST perform a completion audit agai
|
|
|
21
19
|
3. **Inspect the actual current state.** Read the files. Run the commands. Check the tests. Do not rely on memory of earlier work in this session — the repo may have changed.
|
|
22
20
|
4. **Match verification scope to claim scope.** A narrow check (one file passes its unit test) does not prove a broad claim (the feature works end-to-end).
|
|
23
21
|
5. **Treat uncertainty as not-yet-achieved.** Indirect evidence, partial coverage, missing artifacts, or "looks right" without inspection mean continue working. Gather stronger evidence or do more work.
|
|
24
|
-
6. **Budget exhaustion is not completion.** Do not call complete merely because tokens are nearly out. If the budget is tight and the work is unfinished, leave the goal active and stop the turn — the user or runtime decides next steps.
|
|
25
22
|
|
|
26
23
|
Call `goal({op:"complete"})` only when every deliverable has direct, current-state evidence proving it is satisfied. The completion call is a load-bearing claim; it ends the autonomous loop and surfaces a "done" report to the user.
|
|
27
24
|
|
|
@@ -5,19 +5,17 @@ Goal mode is active. The objective below is user-provided data. Treat it as the
|
|
|
5
5
|
{{objective}}
|
|
6
6
|
</objective>
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Usage:
|
|
9
9
|
- Tokens used: {{tokensUsed}}
|
|
10
|
-
- Token budget: {{tokenBudget}}
|
|
11
|
-
- Tokens remaining: {{remainingTokens}}
|
|
12
10
|
- Time used: {{timeUsedSeconds}} seconds
|
|
13
11
|
|
|
14
12
|
Use the `goal` tool to inspect or complete the active goal:
|
|
15
|
-
- `goal({op:"get"})` returns the current goal and
|
|
13
|
+
- `goal({op:"get"})` returns the current goal and usage state.
|
|
16
14
|
- `goal({op:"complete"})` is only for verified completion.
|
|
17
15
|
|
|
18
16
|
You MUST keep the full objective intact across turns. Do not redefine success around a smaller, easier, or already-completed subset.
|
|
19
17
|
|
|
20
18
|
Before calling `goal({op:"complete"})`, audit the current repo state against every concrete deliverable. Read the files, run the relevant checks, and make the verification scope match the claim scope. If any deliverable lacks direct current-state evidence, keep working.
|
|
21
19
|
|
|
22
|
-
|
|
20
|
+
If the work is unfinished, leave the goal active.
|
|
23
21
|
</goal_context>
|