From 3ac34530578b9a6f59bcea6b5aeefd97eb03d588 Mon Sep 17 00:00:00 2001 From: Clawd Date: Sat, 28 Feb 2026 18:46:11 -0800 Subject: Move artifacts to ~/.claude-flow/ (outside repo) - Store session artifacts in ~/.claude-flow/projects/{projectId}/sessions/{sessionId}/ - Artifacts no longer live in project directory - can't be accidentally committed - Remove .claude-flow/ from .gitignore (not needed anymore) - Update all IPC handlers and renderer to use projectId instead of projectPath - Update prompts to remove worktree references - Update README with new storage location --- src/main/claude/index.ts | 65 +++++++++++++++++++----------------------------- 1 file changed, 25 insertions(+), 40 deletions(-) (limited to 'src/main/claude/index.ts') diff --git a/src/main/claude/index.ts b/src/main/claude/index.ts index 4d8909b..b8c9c07 100644 --- a/src/main/claude/index.ts +++ b/src/main/claude/index.ts @@ -6,16 +6,28 @@ import { getProject } from "../db/projects"; import { updateSession } from "../db/sessions"; import fs from "node:fs"; import path from "node:path"; +import os from "node:os"; // Track active queries by session ID const activeQueries = new Map(); +// Global storage in home directory +const GLOBAL_CLAUDE_FLOW_DIR = path.join(os.homedir(), ".claude-flow"); + function ensureDir(dirPath: string): void { if (!fs.existsSync(dirPath)) { fs.mkdirSync(dirPath, { recursive: true }); } } +function getProjectDir(projectId: string): string { + return path.join(GLOBAL_CLAUDE_FLOW_DIR, "projects", projectId); +} + +function getSessionDir(projectId: string, sessionId: string): string { + return path.join(getProjectDir(projectId), "sessions", sessionId); +} + export interface SendMessageOptions { session: Session; message: string; @@ -30,8 +42,8 @@ export async function sendMessage({ const project = getProject(session.project_id); if (!project) throw new Error("Project not found"); - // Ensure session artifact directory exists - const sessionDir = path.join(project.path, getSessionArtifactDir(session.id)); + // Ensure session artifact directory exists in global storage + const sessionDir = getSessionDir(session.project_id, session.id); ensureDir(sessionDir); const phaseConfig = getPhaseConfig( @@ -100,22 +112,22 @@ export function advancePhase(session: Session): Phase | null { } /** - * Get the artifact path for a session and phase + * Get the artifact path for a session and phase (in global storage) */ export function getArtifactPath(session: Session): string { const filename = getArtifactFilename(session.phase as Phase); - return path.join(getSessionArtifactDir(session.id), filename); + return path.join(getSessionDir(session.project_id, session.id), filename); } /** - * Read an artifact file for a session + * Read an artifact file for a session (from global storage) */ export function readSessionArtifact( - projectPath: string, + projectId: string, sessionId: string, filename: string ): string | null { - const filePath = path.join(projectPath, getSessionArtifactDir(sessionId), filename); + const filePath = path.join(getSessionDir(projectId, sessionId), filename); if (fs.existsSync(filePath)) { return fs.readFileSync(filePath, "utf-8"); } @@ -123,15 +135,15 @@ export function readSessionArtifact( } /** - * Write an artifact file for a session + * Write an artifact file for a session (to global storage) */ export function writeSessionArtifact( - projectPath: string, + projectId: string, sessionId: string, filename: string, content: string ): void { - const dir = path.join(projectPath, getSessionArtifactDir(sessionId)); + const dir = getSessionDir(projectId, sessionId); ensureDir(dir); fs.writeFileSync(path.join(dir, filename), content, "utf-8"); } @@ -156,37 +168,10 @@ export function writeClaudeMd(projectPath: string, content: string): void { } /** - * Read an artifact file from the project's .claude-flow directory (legacy path) - */ -export function readArtifact( - projectPath: string, - filename: string -): string | null { - const filePath = path.join(projectPath, ".claude-flow", filename); - if (fs.existsSync(filePath)) { - return fs.readFileSync(filePath, "utf-8"); - } - return null; -} - -/** - * Write an artifact file to the project's .claude-flow directory (legacy path) - */ -export function writeArtifact( - projectPath: string, - filename: string, - content: string -): void { - const dir = path.join(projectPath, ".claude-flow"); - ensureDir(dir); - fs.writeFileSync(path.join(dir, filename), content, "utf-8"); -} - -/** - * Clear session artifacts + * Clear session artifacts from global storage */ -export function clearSessionArtifacts(projectPath: string, sessionId: string): void { - const dir = path.join(projectPath, getSessionArtifactDir(sessionId)); +export function clearSessionArtifacts(projectId: string, sessionId: string): void { + const dir = getSessionDir(projectId, sessionId); if (fs.existsSync(dir)) { fs.rmSync(dir, { recursive: true, force: true }); } -- cgit v1.2.3