diff options
| author | soryu <soryu@soryu.co> | 2026-02-12 02:29:45 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-12 02:29:45 +0000 |
| commit | 355f10964c4dbec24a244a00caba5c17ed23fc65 (patch) | |
| tree | 6fdc998e6b95948e80a87a962acd58acf79d5b98 /makima/frontend/src/lib/api.ts | |
| parent | 9bd6eacaa9ebe860842b5d5cfbf2b7d2d0293ab1 (diff) | |
| download | soryu-355f10964c4dbec24a244a00caba5c17ed23fc65.tar.gz soryu-355f10964c4dbec24a244a00caba5c17ed23fc65.zip | |
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
Diffstat (limited to 'makima/frontend/src/lib/api.ts')
| -rw-r--r-- | makima/frontend/src/lib/api.ts | 183 |
1 files changed, 183 insertions, 0 deletions
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<Dir return res.json(); } +// ============================================================================= +// Directive Memory Types & API +// ============================================================================= + +/** Category of a directive memory entry */ +export type MemoryCategory = + | "decision" + | "learning" + | "context" + | "preference" + | "issue" + | "progress" + | "other"; + +/** A single memory entry associated with a directive */ +export interface DirectiveMemory { + id: string; + directiveId: string; + /** The memory content text */ + content: string; + /** Category for organizing memories */ + category: MemoryCategory; + /** Which step created this memory (null if directive-level) */ + stepId: string | null; + /** Which task created this memory (null if manually added) */ + taskId: string | null; + /** Importance score (1-10, higher = more important) */ + importance: number; + createdAt: string; + updatedAt: string; +} + +/** Response from listing directive memories */ +export interface DirectiveMemoryListResponse { + memories: DirectiveMemory[]; + total: number; +} + +/** Request to create a new directive memory */ +export interface CreateDirectiveMemoryRequest { + content: string; + category?: MemoryCategory; + stepId?: string; + taskId?: string; + importance?: number; +} + +/** Request to update a directive memory */ +export interface UpdateDirectiveMemoryRequest { + content?: string; + category?: MemoryCategory; + importance?: number; +} +// Directive Memory API functions + +/** + * List all memories for a directive. + * Optionally filter by category or step. + */ +export async function listDirectiveMemories( + directiveId: string, + params?: { category?: MemoryCategory; stepId?: string } +): Promise<DirectiveMemoryListResponse> { + 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<DirectiveMemory> { + 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<DirectiveMemory> { + 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<DirectiveMemory> { + 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<void> { + 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<DirectiveMemory[]> { + 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(); +} |
