Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/frontend/src/main/claude-profile-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import { app } from 'electron';
import { join } from 'path';
import { mkdir } from 'fs/promises';
import os from 'os';
import type {
ClaudeProfile,
ClaudeProfileSettings,
Expand Down Expand Up @@ -381,7 +382,7 @@ export class ClaudeProfileManager {
if (profile?.configDir && !profile.isDefault) {
// Expand ~ to home directory for the environment variable
const expandedConfigDir = profile.configDir.startsWith('~')
? profile.configDir.replace(/^~/, require('os').homedir())
? profile.configDir.replace(/^~/, os.homedir())
: profile.configDir;
env.CLAUDE_CONFIG_DIR = expandedConfigDir;
console.warn('[ClaudeProfileManager] Using configDir for profile:', profile.name, expandedConfigDir);
Expand Down
3 changes: 2 additions & 1 deletion apps/frontend/src/main/ipc-handlers/context/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { app } from 'electron';
import path from 'path';
import os from 'os';
import { existsSync, readFileSync } from 'fs';

export interface EnvironmentVars {
Expand Down Expand Up @@ -215,7 +216,7 @@ export interface GraphitiDatabaseDetails {
export function getGraphitiDatabaseDetails(projectEnvVars: EnvironmentVars): GraphitiDatabaseDetails {
const dbPath = projectEnvVars['GRAPHITI_DB_PATH'] ||
process.env.GRAPHITI_DB_PATH ||
require('path').join(require('os').homedir(), '.auto-claude', 'memories');
path.join(os.homedir(), '.auto-claude', 'memories');

const database = projectEnvVars['GRAPHITI_DATABASE'] ||
process.env.GRAPHITI_DATABASE ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { promisify } from 'util';
import path from 'path';
import { fileURLToPath } from 'url';
import fs from 'fs';
import { app } from 'electron';

// ESM-compatible __dirname
const __filename = fileURLToPath(import.meta.url);
Expand Down Expand Up @@ -335,14 +336,6 @@ export function getRunnerPath(backendPath: string): string {
* 3. Current working directory
*/
export function getBackendPath(project: Project): string | null {
// Import app module for production path detection
let app: any;
try {
app = require('electron').app;
} catch {
// Electron not available in tests
}

// Check if this is a development repo (has apps/backend structure)
const appsBackendPath = path.join(project.path, 'apps', 'backend');
if (fs.existsSync(path.join(appsBackendPath, 'runners', 'github', 'runner.py'))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { IPC_CHANNELS, AUTO_BUILD_PATHS, DEFAULT_APP_SETTINGS, DEFAULT_FEATURE_M
import type { IPCResult, WorktreeStatus, WorktreeDiff, WorktreeDiffFile, WorktreeMergeResult, WorktreeDiscardResult, WorktreeListResult, WorktreeListItem, WorktreeCreatePROptions, WorktreeCreatePRResult, SupportedIDE, SupportedTerminal, AppSettings } from '../../../shared/types';
import path from 'path';
import { minimatch } from 'minimatch';
import { existsSync, readdirSync, statSync, readFileSync } from 'fs';
import { existsSync, readdirSync, statSync, readFileSync, promises as fsPromises } from 'fs';
import { execSync, execFileSync, spawn, spawnSync, exec, execFile } from 'child_process';
import { projectStore } from '../../project-store';
import { getConfiguredPythonPath, PythonEnvManager, pythonEnvManager as pythonEnvManagerSingleton } from '../../python-env-manager';
Expand Down Expand Up @@ -2196,7 +2196,6 @@ export function registerWorktreeHandlers(
const commitMsgPath = path.join(specDir, 'suggested_commit_message.txt');
try {
if (existsSync(commitMsgPath)) {
const { promises: fsPromises } = require('fs');
suggestedCommitMessage = (await fsPromises.readFile(commitMsgPath, 'utf-8')).trim();
debug('Read suggested commit message:', suggestedCommitMessage?.substring(0, 100));
}
Expand All @@ -2219,8 +2218,6 @@ export function registerWorktreeHandlers(
planPaths.push({ path: path.join(worktreeSpecDir, AUTO_BUILD_PATHS.IMPLEMENTATION_PLAN), isMain: false });
}

const { promises: fsPromises } = require('fs');

// Update plan file with retry logic for transient failures
// Uses EAFP pattern (try/catch) instead of LBYL (existsSync check) to avoid TOCTOU race conditions
const updatePlanWithRetry = async (planPath: string, isMain: boolean): Promise<boolean> => {
Expand Down Expand Up @@ -2838,7 +2835,6 @@ export function registerWorktreeHandlers(
const planPath = path.join(specDir, AUTO_BUILD_PATHS.IMPLEMENTATION_PLAN);

// Use EAFP pattern (try/catch) instead of LBYL (existsSync check) to avoid TOCTOU race conditions
const { promises: fsPromises } = require('fs');
const isFileNotFound = (err: unknown): boolean =>
!!(err && typeof err === 'object' && 'code' in err && err.code === 'ENOENT');

Expand Down
4 changes: 2 additions & 2 deletions apps/frontend/src/main/log-service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'path';
import { existsSync, mkdirSync, appendFileSync, readdirSync, readFileSync, writeFileSync, statSync } from 'fs';
import { existsSync, mkdirSync, appendFileSync, readdirSync, readFileSync, writeFileSync, statSync, unlinkSync } from 'fs';

export interface LogSession {
sessionId: string;
Expand Down Expand Up @@ -293,7 +293,7 @@ export class LogService {
for (const file of toDelete) {
const filePath = path.join(logsDir, file);
try {
require('fs').unlinkSync(filePath);
unlinkSync(filePath);
console.warn(`[LogService] Deleted old log session: ${file}`);
} catch (_e) {
// Ignore deletion errors
Expand Down
Loading