diff --git a/src/prompts/maestro-system-prompt.md b/src/prompts/maestro-system-prompt.md index c121f1ac..13447a2c 100644 --- a/src/prompts/maestro-system-prompt.md +++ b/src/prompts/maestro-system-prompt.md @@ -31,8 +31,11 @@ Your session history is stored at `{{AGENT_HISTORY_PATH}}`. When you need contex - `timestamp`: When the task was completed (Unix ms) - `type`: `AUTO` (automated) or `USER` (interactive) - `success`: Whether the task succeeded +- `fullResponse`: Complete AI response text (for detailed context) +- `elapsedTimeMs`: How long the task took +- `contextUsage`: Context window usage percentage at completion -To recall recent work, read the file and scan the most recent entries by timestamp. +To recall recent work, read the file and scan the most recent entries by timestamp. Use `summary` for quick scanning and `fullResponse` when you need detailed context about what was done. ## Auto-run Documents diff --git a/src/prompts/wizard-inline-system.md b/src/prompts/wizard-inline-system.md index 6a9b047a..af9f69f8 100644 --- a/src/prompts/wizard-inline-system.md +++ b/src/prompts/wizard-inline-system.md @@ -8,6 +8,18 @@ You are a planning assistant helping in an existing Maestro session for "{{PROJE You are helping plan work in an active session. The user has an established project context and wants to create or extend a Playbook. +## Task Recall + +Your session history is stored at `{{AGENT_HISTORY_PATH}}`. When you need context about previously completed work in this project, read this JSON file and parse the `entries` array. Each entry contains: +- `summary`: Brief description of the task +- `timestamp`: When the task was completed (Unix ms) +- `type`: `AUTO` (automated) or `USER` (interactive) +- `success`: Whether the task succeeded +- `fullResponse`: Complete AI response text (for detailed context) +- `elapsedTimeMs`: How long the task took + +To recall recent work, read the file and scan the most recent entries by timestamp. Use `summary` for quick scanning and `fullResponse` when you need detailed context about what has already been accomplished. + ## File Access Restrictions **WRITE ACCESS (Limited):** diff --git a/src/prompts/wizard-system.md b/src/prompts/wizard-system.md index cd8d63e5..e8e8c5f5 100644 --- a/src/prompts/wizard-system.md +++ b/src/prompts/wizard-system.md @@ -8,6 +8,18 @@ You are a friendly project discovery assistant helping to set up "{{PROJECT_NAME You are 🎼 Maestro's onboarding assistant, helping the user define their project so we can create an actionable plan. +## Task Recall + +Your session history is stored at `{{AGENT_HISTORY_PATH}}`. When you need context about previously completed work in this project, read this JSON file and parse the `entries` array. Each entry contains: +- `summary`: Brief description of the task +- `timestamp`: When the task was completed (Unix ms) +- `type`: `AUTO` (automated) or `USER` (interactive) +- `success`: Whether the task succeeded +- `fullResponse`: Complete AI response text (for detailed context) +- `elapsedTimeMs`: How long the task took + +To recall recent work, read the file and scan the most recent entries by timestamp. Use `summary` for quick scanning and `fullResponse` when you need detailed context about what has already been accomplished. + ## File Access Restrictions **WRITE ACCESS (Limited):** diff --git a/src/renderer/components/Wizard/services/wizardPrompts.ts b/src/renderer/components/Wizard/services/wizardPrompts.ts index 1fb36c74..309adf10 100644 --- a/src/renderer/components/Wizard/services/wizardPrompts.ts +++ b/src/renderer/components/Wizard/services/wizardPrompts.ts @@ -60,6 +60,10 @@ export interface SystemPromptConfig { existingDocs?: ExistingDocument[]; /** Auto Run folder path (defaults to agentPath/Auto Run Docs if not provided) */ autoRunFolderPath?: string; + /** History file path for task recall (optional, enables AI to recall recent work) */ + historyFilePath?: string; + /** Conductor profile (user's About Me from settings) */ + conductorProfile?: string; } /** @@ -112,7 +116,7 @@ export const READY_CONFIDENCE_THRESHOLD = 80; * @returns The complete system prompt for the agent */ export function generateSystemPrompt(config: SystemPromptConfig): string { - const { agentName, agentPath, existingDocs, autoRunFolderPath } = config; + const { agentName, agentPath, existingDocs, autoRunFolderPath, historyFilePath, conductorProfile } = config; const projectName = agentName || 'this project'; // Default Auto Run folder to standard location under working directory @@ -140,6 +144,7 @@ export function generateSystemPrompt(config: SystemPromptConfig): string { // Build template context for remaining variables (date/time, etc.) // Include autoRunFolderPath so {{AUTORUN_FOLDER}} is properly substituted + // Include historyFilePath for {{AGENT_HISTORY_PATH}} task recall const templateContext: TemplateContext = { session: { id: 'wizard', @@ -150,6 +155,8 @@ export function generateSystemPrompt(config: SystemPromptConfig): string { autoRunFolderPath: effectiveAutoRunFolder, }, autoRunFolder: effectiveAutoRunFolder, + historyFilePath: historyFilePath, + conductorProfile: conductorProfile, }; // Substitute any remaining template variables using the central function diff --git a/src/renderer/hooks/useInlineWizard.ts b/src/renderer/hooks/useInlineWizard.ts index e3922708..913fffa0 100644 --- a/src/renderer/hooks/useInlineWizard.ts +++ b/src/renderer/hooks/useInlineWizard.ts @@ -151,6 +151,8 @@ export interface InlineWizardState { }; /** Conductor profile (user's About Me from settings) */ conductorProfile?: string; + /** History file path for task recall (fetched once during startWizard) */ + historyFilePath?: string; } /** @@ -533,6 +535,19 @@ export function useInlineWizard(): UseInlineWizardReturn { })); try { + // Step 0: Fetch history file path for task recall (if session ID is available) + // This is done early so it's available for both conversation session and state + let historyFilePath: string | undefined; + if (sessionId) { + try { + const fetchedPath = await window.maestro.history.getFilePath(sessionId); + historyFilePath = fetchedPath ?? undefined; // Convert null to undefined + } catch { + // History file path not available - continue without it + logger.debug('Could not fetch history file path', '[InlineWizard]', { sessionId }); + } + } + // Step 1: Check for existing Auto Run documents in the configured folder // Use the effective Auto Run folder path (user-configured or default) let hasExistingDocs = false; @@ -597,6 +612,7 @@ export function useInlineWizard(): UseInlineWizardReturn { supportedWizardAgents.includes(agentType) && effectiveAutoRunFolderPath ) { + // historyFilePath was fetched in Step 0 above const session = startInlineWizardConversation({ mode, agentType, @@ -607,6 +623,7 @@ export function useInlineWizard(): UseInlineWizardReturn { autoRunFolderPath: effectiveAutoRunFolderPath, sessionSshRemoteConfig, conductorProfile, + historyFilePath, }); // Store conversation session per-tab @@ -636,12 +653,14 @@ export function useInlineWizard(): UseInlineWizardReturn { } // Update state with parsed results + // Store historyFilePath so it's available for setMode if user is in 'ask' mode setTabState(effectiveTabId, (prev) => ({ ...prev, isInitializing: false, mode, goal, existingDocuments: existingDocs, + historyFilePath, })); } catch (error) { // Handle any errors during initialization @@ -754,6 +773,7 @@ export function useInlineWizard(): UseInlineWizardReturn { effectiveAutoRunFolderPath ) { console.log('[useInlineWizard] Auto-creating session for direct message in ask mode'); + // Use historyFilePath from state (fetched during startWizard) session = startInlineWizardConversation({ mode: 'new', agentType: currentState.agentType, @@ -764,6 +784,7 @@ export function useInlineWizard(): UseInlineWizardReturn { autoRunFolderPath: effectiveAutoRunFolderPath, sessionSshRemoteConfig: currentState.sessionSshRemoteConfig, conductorProfile: currentState.conductorProfile, + historyFilePath: currentState.historyFilePath, }); conversationSessionsMap.current.set(tabId, session); // Update mode to 'new' since we're proceeding with a new plan @@ -936,6 +957,7 @@ export function useInlineWizard(): UseInlineWizardReturn { (currentState.projectPath ? getAutoRunFolderPath(currentState.projectPath) : null); if (currentState.agentType && effectiveAutoRunFolderPath) { + // Use historyFilePath from state (fetched during startWizard) const session = startInlineWizardConversation({ mode: newMode, agentType: currentState.agentType, @@ -946,6 +968,7 @@ export function useInlineWizard(): UseInlineWizardReturn { autoRunFolderPath: effectiveAutoRunFolderPath, sessionSshRemoteConfig: currentState.sessionSshRemoteConfig, conductorProfile: currentState.conductorProfile, + historyFilePath: currentState.historyFilePath, }); conversationSessionsMap.current.set(tabId, session); diff --git a/src/renderer/services/inlineWizardConversation.ts b/src/renderer/services/inlineWizardConversation.ts index a0e9d5fe..fb799036 100644 --- a/src/renderer/services/inlineWizardConversation.ts +++ b/src/renderer/services/inlineWizardConversation.ts @@ -98,6 +98,8 @@ export interface InlineWizardConversationConfig { }; /** Conductor profile (user's About Me from settings) */ conductorProfile?: string; + /** History file path for task recall (optional, enables AI to recall recent work) */ + historyFilePath?: string; } /** @@ -215,6 +217,7 @@ export function generateInlineWizardPrompt(config: InlineWizardConversationConfi } // Build template context for remaining variables + // Include historyFilePath for {{AGENT_HISTORY_PATH}} task recall const templateContext: TemplateContext = { session: { id: 'inline-wizard', @@ -226,6 +229,7 @@ export function generateInlineWizardPrompt(config: InlineWizardConversationConfi }, autoRunFolder: autoRunFolderPath, conductorProfile: config.conductorProfile, + historyFilePath: config.historyFilePath, }; // Substitute any remaining template variables