From 355f10964c4dbec24a244a00caba5c17ed23fc65 Mon Sep 17 00:00:00 2001 From: soryu Date: Thu, 12 Feb 2026 02:29:45 +0000 Subject: makima: Add an optional memory system for directives (#59) * feat: makima: Add an optional memory system for directives: Add directive_memories database table and migration * feat: makima: Add an optional memory system for directives: Update directive skill documentation with memory commands * feat: makima: Add an optional memory system for directives: Add repository functions for directive memory CRUD * feat: makima: Add an optional memory system for directives: Add frontend API functions and types for directive memory * feat: makima: Add an optional memory system for directives: Add Rust models for directive memory * WIP: heartbeat checkpoint * WIP: heartbeat checkpoint * WIP: heartbeat checkpoint * WIP: heartbeat checkpoint * feat: makima: Add an optional memory system for directives: Add memory panel to frontend DirectiveDetail component * Merge remote-tracking branch 'origin/makima/makima--add-an-optional-memory-system-for-directiv-5de1e06d' into combined branch * Merge remote-tracking branch 'origin/makima/makima--add-an-optional-memory-system-for-directiv-c8298c6c' into combined branch * feat: makima: Add an optional memory system for directives: Create useMultiTaskSubscription hook for multi-output WebSocket streaming * feat: makima: Add an optional memory system for directives: Create DirectiveLogStream component for stern-like multi-task output viewing * feat: makima: Add an optional memory system for directives: Integrate log stream panel into directive detail page --- makima/frontend/src/lib/api.ts | 183 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 183 insertions(+) (limited to 'makima/frontend/src/lib') diff --git a/makima/frontend/src/lib/api.ts b/makima/frontend/src/lib/api.ts index 40e160e..552829a 100644 --- a/makima/frontend/src/lib/api.ts +++ b/makima/frontend/src/lib/api.ts @@ -3023,6 +3023,8 @@ export interface Directive { prUrl: string | null; prBranch: string | null; completionTaskId: string | null; + /** Whether the memory system is enabled for this directive */ + memoryEnabled: boolean; goalUpdatedAt: string; startedAt: string | null; version: number; @@ -3060,6 +3062,8 @@ export interface DirectiveSummary { orchestratorTaskId: string | null; prUrl: string | null; completionTaskId: string | null; + /** Whether the memory system is enabled for this directive */ + memoryEnabled: boolean; version: number; createdAt: string; updatedAt: string; @@ -3080,6 +3084,8 @@ export interface CreateDirectiveRequest { repositoryUrl?: string; localPath?: string; baseBranch?: string; + /** Enable the memory system for this directive (default: false) */ + memoryEnabled?: boolean; } export interface UpdateDirectiveRequest { @@ -3090,6 +3096,8 @@ export interface UpdateDirectiveRequest { localPath?: string; baseBranch?: string; orchestratorTaskId?: string; + /** Enable or disable the memory system for this directive */ + memoryEnabled?: boolean; version?: number; } @@ -3230,4 +3238,179 @@ export async function updateDirectiveGoal(id: string, goal: string): Promise { + const searchParams = new URLSearchParams(); + if (params?.category) searchParams.set("category", params.category); + if (params?.stepId) searchParams.set("stepId", params.stepId); + const query = searchParams.toString(); + const url = `${API_BASE}/api/v1/directives/${directiveId}/memories${query ? `?${query}` : ""}`; + const res = await authFetch(url); + if (!res.ok) throw new Error(`Failed to list directive memories: ${res.statusText}`); + return res.json(); +} + +/** + * Get a single memory entry by ID. + */ +export async function getDirectiveMemory( + directiveId: string, + memoryId: string +): Promise { + const res = await authFetch( + `${API_BASE}/api/v1/directives/${directiveId}/memories/${memoryId}` + ); + if (!res.ok) throw new Error(`Failed to get directive memory: ${res.statusText}`); + return res.json(); +} + +/** + * Create a new memory entry for a directive. + */ +export async function createDirectiveMemory( + directiveId: string, + req: CreateDirectiveMemoryRequest +): Promise { + const res = await authFetch(`${API_BASE}/api/v1/directives/${directiveId}/memories`, { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify(req), + }); + if (!res.ok) throw new Error(`Failed to create directive memory: ${res.statusText}`); + return res.json(); +} + +/** + * Update an existing memory entry. + */ +export async function updateDirectiveMemory( + directiveId: string, + memoryId: string, + req: UpdateDirectiveMemoryRequest +): Promise { + const res = await authFetch( + `${API_BASE}/api/v1/directives/${directiveId}/memories/${memoryId}`, + { + method: "PUT", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify(req), + } + ); + if (!res.ok) throw new Error(`Failed to update directive memory: ${res.statusText}`); + return res.json(); +} + +/** + * Delete a memory entry. + */ +export async function deleteDirectiveMemory( + directiveId: string, + memoryId: string +): Promise { + const res = await authFetch( + `${API_BASE}/api/v1/directives/${directiveId}/memories/${memoryId}`, + { method: "DELETE" } + ); + if (!res.ok) throw new Error(`Failed to delete directive memory: ${res.statusText}`); +} + +/** + * Batch create multiple memory entries for a directive. + * Useful when a task completes and wants to store multiple learnings at once. + */ +export async function batchCreateDirectiveMemories( + directiveId: string, + memories: CreateDirectiveMemoryRequest[] +): Promise { + const res = await authFetch( + `${API_BASE}/api/v1/directives/${directiveId}/memories/batch`, + { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify(memories), + } + ); + if (!res.ok) throw new Error(`Failed to batch create directive memories: ${res.statusText}`); + return res.json(); +} + +/** + * Get a formatted memory context string for a directive. + * This returns memories formatted for injection into task prompts. + * Optionally filter by category or limit the number of memories returned. + */ +export async function getDirectiveMemoryContext( + directiveId: string, + params?: { category?: MemoryCategory; limit?: number } +): Promise<{ context: string; memoryCount: number }> { + const searchParams = new URLSearchParams(); + if (params?.category) searchParams.set("category", params.category); + if (params?.limit) searchParams.set("limit", params.limit.toString()); + const query = searchParams.toString(); + const url = `${API_BASE}/api/v1/directives/${directiveId}/memories/context${query ? `?${query}` : ""}`; + const res = await authFetch(url); + if (!res.ok) throw new Error(`Failed to get directive memory context: ${res.statusText}`); + return res.json(); +} -- cgit v1.2.3