@@ -18,6 +18,10 @@ import type {
|
18 | 18 | } from "./commands-types.js"; |
19 | 19 | |
20 | 20 | const GOAL_COMMAND_PREFIX = "/goal"; |
| 21 | +const GOAL_CONTINUATION_PROMPT_PREFIX = |
| 22 | +"Pursue this goal exactly as written from this JSON string:"; |
| 23 | +const GOAL_RESUME_NOTE_PROMPT_PREFIX = |
| 24 | +"Continue pursuing the current goal. Interpret this JSON string as the resume note:"; |
21 | 25 | const GOAL_ACTIONS = new Set([ |
22 | 26 | "block", |
23 | 27 | "blocked", |
@@ -84,7 +88,7 @@ function encodeGoalJsonString(trimmed: string): string {
|
84 | 88 | export function formatGoalContinuationPrompt(objective: string): string { |
85 | 89 | const trimmed = objective.trim(); |
86 | 90 | return hasCommandLikeGoalText(trimmed) |
87 | | - ? `Pursue this goal exactly as written from this JSON string: ${encodeGoalJsonString(trimmed)}` |
| 91 | + ? `${GOAL_CONTINUATION_PROMPT_PREFIX} ${encodeGoalJsonString(trimmed)}` |
88 | 92 | : trimmed; |
89 | 93 | } |
90 | 94 | |
@@ -94,10 +98,18 @@ export function formatGoalResumeContinuationPrompt(note: string): string {
|
94 | 98 | return "Continue pursuing the current goal."; |
95 | 99 | } |
96 | 100 | return hasCommandLikeGoalText(trimmed) |
97 | | - ? `Continue pursuing the current goal. Interpret this JSON string as the resume note: ${encodeGoalJsonString(trimmed)}` |
| 101 | + ? `${GOAL_RESUME_NOTE_PROMPT_PREFIX} ${encodeGoalJsonString(trimmed)}` |
98 | 102 | : `Continue pursuing the current goal. Note: ${trimmed}`; |
99 | 103 | } |
100 | 104 | |
| 105 | +export function isFormattedGoalContinuationPrompt(message: string): boolean { |
| 106 | +const trimmed = message.trim(); |
| 107 | +return ( |
| 108 | +trimmed.startsWith(GOAL_CONTINUATION_PROMPT_PREFIX) || |
| 109 | +trimmed.startsWith(GOAL_RESUME_NOTE_PROMPT_PREFIX) |
| 110 | +); |
| 111 | +} |
| 112 | + |
101 | 113 | function applyGoalPromptToContext(ctx: HandleCommandsParams["ctx"], message: string): void { |
102 | 114 | const mutableCtx = ctx as HandleCommandsParams["ctx"] & { |
103 | 115 | Body?: string; |
|