mirror of
https://github.com/jlengrand/Maestro.git
synced 2026-03-10 00:21:21 +00:00
Add Task Recall section to wizard prompts for session history access
Add Task Recall documentation to both wizard prompts (wizard-system.md and wizard-inline-system.md), enabling AI to access session history for context about previously completed work. Extended documented fields to include fullResponse, elapsedTimeMs, and contextUsage for detailed context retrieval. Updated wizardPrompts.ts and inlineWizardConversation.ts to pass historyFilePath through template context. Modified useInlineWizard.ts to fetch history file path during wizard initialization and store in state for use across conversation session creation points.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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):**
|
||||
|
||||
@@ -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):**
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user