From 04c63d4ef601876186e5d7fab980d76575c494ec Mon Sep 17 00:00:00 2001 From: bndw Date: Sat, 28 Feb 2026 21:08:40 -0800 Subject: feat: **1. `src/main/db/schema.ts`** — add `settings` table … (+10 more) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ✅ **1. `src/main/db/schema.ts`** — add `settings` table to `initSchema` - ✅ **2. `src/main/db/settings.ts`** — create file with `getSetting`, `getSettings`, `setSetting`, `deleteSetting` - ✅ **3. `src/main/claude/phases.ts`** — add `customSystemPrompt?` param to `getPhaseConfig`; add `getDefaultSystemPromptTemplate` export - ✅ **4. `src/main/claude/index.ts`** — import `getSetting`; load custom prompt in `sendMessage`; pass to `getPhaseConfig` - ✅ **5. `src/main/ipc/handlers.ts`** — import `settingsDb` + `getDefaultSystemPromptTemplate`; register `settings:get`, `settings:set`, `settings:delete`, `settings:getDefaultPrompts` - ✅ **6. `src/main/preload.ts`** — add `getSettings`, `setSetting`, `deleteSetting`, `getDefaultSystemPrompts` to interface + api object - ✅ **7. `renderer/src/styles/globals.css`** — append all new CSS rules - ✅ **8. `renderer/src/components/settings/SystemPromptsSettings.tsx`** — create file (new directory) - ✅ **9. `renderer/src/components/SettingsPage.tsx`** — create file - ✅ **10. `renderer/src/components/Header.tsx`** — add `onOpenSettings` prop + ⚙ button - ✅ **11. `renderer/src/App.tsx`** — add `showSettings` state; import + render ``; pass `onOpenSettings` to Header --- src/main/claude/index.ts | 7 ++++++- src/main/claude/phases.ts | 22 ++++++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) (limited to 'src/main/claude') diff --git a/src/main/claude/index.ts b/src/main/claude/index.ts index 8971844..30a0f57 100644 --- a/src/main/claude/index.ts +++ b/src/main/claude/index.ts @@ -4,6 +4,7 @@ import { getPhaseConfig, getNextPhase, getArtifactFilename } from "./phases"; import type { Phase, UserPermissionMode } from "./phases"; import { getProject } from "../db/projects"; import { updateSession } from "../db/sessions"; +import { getSetting } from "../db/settings"; import { autoCommitTurn } from "../git"; import fs from "node:fs"; import path from "node:path"; @@ -44,10 +45,14 @@ export async function sendMessage({ const sessionDir = getSessionDir(project.path, session.id); ensureDir(sessionDir); + // Load any custom system prompt for this phase (null → use default) + const customSystemPrompt = getSetting(`systemPrompt.${session.phase}`) ?? undefined; + const phaseConfig = getPhaseConfig( session.phase as Phase, sessionDir, - session.permission_mode as UserPermissionMode + session.permission_mode as UserPermissionMode, + customSystemPrompt ); const q = query({ diff --git a/src/main/claude/phases.ts b/src/main/claude/phases.ts index 89e7c22..a1cbba1 100644 --- a/src/main/claude/phases.ts +++ b/src/main/claude/phases.ts @@ -160,11 +160,20 @@ When complete, summarize what was done and any follow-up tasks.`, export function getPhaseConfig( phase: Phase, artifactDir: string, - userPermissionMode?: UserPermissionMode + userPermissionMode?: UserPermissionMode, + customSystemPrompt?: string ): PhaseConfig { const template = phaseConfigTemplates[phase]; + + // If a custom prompt is provided, substitute the {{artifactDir}} placeholder. + // Otherwise use the default template function (existing behaviour). + const systemPrompt = + customSystemPrompt !== undefined + ? customSystemPrompt.replace(/\{\{artifactDir\}\}/g, artifactDir) + : template.systemPrompt(artifactDir); + const config: PhaseConfig = { - systemPrompt: template.systemPrompt(artifactDir), + systemPrompt, tools: template.tools, permissionMode: template.permissionMode, initialMessage: template.initialMessage, @@ -175,6 +184,15 @@ export function getPhaseConfig( return config; } +/** + * Returns the default system prompt for a phase with "{{artifactDir}}" as a + * literal placeholder — the same format used when storing a custom prompt in + * the settings DB. Used by the Settings UI to display the default text. + */ +export function getDefaultSystemPromptTemplate(phase: Phase): string { + return phaseConfigTemplates[phase].systemPrompt("{{artifactDir}}"); +} + export function getPhaseInitialMessage(phase: Phase): string { return phaseConfigTemplates[phase].initialMessage; } -- cgit v1.2.3