ad8ac7970d
* fix: distinguish connection errors from collection-not-found in ChromaSync Previously, ensureCollection() caught ALL errors from chroma_get_collection_info and assumed they meant "collection doesn't exist". This caused connection errors like "Not connected" to trigger unnecessary collection creation attempts. Now connection-related errors are re-thrown immediately instead of being misinterpreted as missing collections. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: improve error handling for Chroma connection and collection creation * fix: remove dead last_user_message from summarize flow The last_user_message field was extracted from transcripts but never used. In Claude Code transcripts, "user" type messages are mostly tool_results, not actual user input. The user's original request is already stored in user_prompts table. This removes the false warning "Missing last_user_message when queueing summary" which was complaining about missing data that didn't exist and wasn't needed. Changes: - summary-hook: Only extract last_assistant_message - SessionRoutes: Remove last_user_message from request body handling - SessionManager.queueSummarize: Remove lastUserMessage parameter - PendingMessage interface: Remove last_user_message field - SDKSession interface: Remove last_user_message field - All agents: Remove last_user_message from buildSummaryPrompt calls 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * build artifacts for plugin * Enhance error handling across multiple services - Improved logging in `BranchManager.ts` to capture recovery checkout failures. - Updated `PaginationHelper.ts` to log when file paths are plain strings instead of valid JSON. - Enhanced error logging in `SDKAgent.ts` for Claude executable detection failures. - Added logging for plain string handling in `SearchManager.ts` for files read and edited. - Improved logging in `paths.ts` for git root detection failures. - Enhanced JSON parsing error handling in `timeline-formatting.ts` with previews of failed inputs. - Updated `transcript-parser.ts` to log summary of parse errors after processing transcript lines. - Established a baseline for error handling practices in `error-handling-baseline.txt`. - Documented error handling anti-pattern rules in `CLAUDE.md` to prevent silent failures and improve code quality. * Add error handling anti-pattern detection script and guidelines - Introduced `detect-error-handling-antipatterns.ts` to identify common error handling issues in TypeScript code. - Created comprehensive documentation in `CLAUDE.md` outlining forbidden patterns, allowed patterns, and critical path protection rules. - Implemented checks for empty catch blocks, logging practices, and try-catch block sizes to prevent silent failures and improve debugging. - Established a reporting mechanism to summarize detected anti-patterns with severity levels. * feat: add console filter bar and log line parsing with filtering capabilities - Introduced a console filter bar with options to filter logs by level and component. - Implemented parsing of log lines to extract structured data including timestamp, level, component, and correlation ID. - Added functionality to toggle individual and all levels/components for filtering. - Enhanced log line rendering with color coding based on log level and special message types. - Improved responsiveness of the filter bar for smaller screens. --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
144 lines
3.9 KiB
TypeScript
144 lines
3.9 KiB
TypeScript
import { join, dirname, basename, sep } from 'path';
|
|
import { homedir } from 'os';
|
|
import { existsSync, mkdirSync } from 'fs';
|
|
import { execSync } from 'child_process';
|
|
import { fileURLToPath } from 'url';
|
|
import { SettingsDefaultsManager } from './SettingsDefaultsManager.js';
|
|
import { logger } from '../utils/logger.js';
|
|
|
|
// Get __dirname that works in both ESM (hooks) and CJS (worker) contexts
|
|
function getDirname(): string {
|
|
// CJS context - __dirname exists
|
|
if (typeof __dirname !== 'undefined') {
|
|
return __dirname;
|
|
}
|
|
// ESM context - use import.meta.url
|
|
return dirname(fileURLToPath(import.meta.url));
|
|
}
|
|
|
|
const _dirname = getDirname();
|
|
|
|
/**
|
|
* Simple path configuration for claude-mem
|
|
* Standard paths based on Claude Code conventions
|
|
*/
|
|
|
|
// Base directories
|
|
export const DATA_DIR = SettingsDefaultsManager.get('CLAUDE_MEM_DATA_DIR');
|
|
// Note: CLAUDE_CONFIG_DIR is a Claude Code setting, not claude-mem, so leave as env var
|
|
export const CLAUDE_CONFIG_DIR = process.env.CLAUDE_CONFIG_DIR || join(homedir(), '.claude');
|
|
|
|
// Data subdirectories
|
|
export const ARCHIVES_DIR = join(DATA_DIR, 'archives');
|
|
export const LOGS_DIR = join(DATA_DIR, 'logs');
|
|
export const TRASH_DIR = join(DATA_DIR, 'trash');
|
|
export const BACKUPS_DIR = join(DATA_DIR, 'backups');
|
|
export const MODES_DIR = join(DATA_DIR, 'modes');
|
|
export const USER_SETTINGS_PATH = join(DATA_DIR, 'settings.json');
|
|
export const DB_PATH = join(DATA_DIR, 'claude-mem.db');
|
|
export const VECTOR_DB_DIR = join(DATA_DIR, 'vector-db');
|
|
|
|
// Claude integration paths
|
|
export const CLAUDE_SETTINGS_PATH = join(CLAUDE_CONFIG_DIR, 'settings.json');
|
|
export const CLAUDE_COMMANDS_DIR = join(CLAUDE_CONFIG_DIR, 'commands');
|
|
export const CLAUDE_MD_PATH = join(CLAUDE_CONFIG_DIR, 'CLAUDE.md');
|
|
|
|
/**
|
|
* Get project-specific archive directory
|
|
*/
|
|
export function getProjectArchiveDir(projectName: string): string {
|
|
return join(ARCHIVES_DIR, projectName);
|
|
}
|
|
|
|
/**
|
|
* Get worker socket path for a session
|
|
*/
|
|
export function getWorkerSocketPath(sessionId: number): string {
|
|
return join(DATA_DIR, `worker-${sessionId}.sock`);
|
|
}
|
|
|
|
/**
|
|
* Ensure a directory exists
|
|
*/
|
|
export function ensureDir(dirPath: string): void {
|
|
mkdirSync(dirPath, { recursive: true });
|
|
}
|
|
|
|
/**
|
|
* Ensure all data directories exist
|
|
*/
|
|
export function ensureAllDataDirs(): void {
|
|
ensureDir(DATA_DIR);
|
|
ensureDir(ARCHIVES_DIR);
|
|
ensureDir(LOGS_DIR);
|
|
ensureDir(TRASH_DIR);
|
|
ensureDir(BACKUPS_DIR);
|
|
ensureDir(MODES_DIR);
|
|
}
|
|
|
|
/**
|
|
* Ensure modes directory exists
|
|
*/
|
|
export function ensureModesDir(): void {
|
|
ensureDir(MODES_DIR);
|
|
}
|
|
|
|
/**
|
|
* Ensure all Claude integration directories exist
|
|
*/
|
|
export function ensureAllClaudeDirs(): void {
|
|
ensureDir(CLAUDE_CONFIG_DIR);
|
|
ensureDir(CLAUDE_COMMANDS_DIR);
|
|
}
|
|
|
|
/**
|
|
* Get current project name from git root or cwd
|
|
*/
|
|
export function getCurrentProjectName(): string {
|
|
try {
|
|
const gitRoot = execSync('git rev-parse --show-toplevel', {
|
|
cwd: process.cwd(),
|
|
encoding: 'utf8',
|
|
stdio: ['pipe', 'pipe', 'ignore'],
|
|
windowsHide: true
|
|
}).trim();
|
|
return basename(gitRoot);
|
|
} catch (error) {
|
|
logger.debug('SYSTEM', 'Git root detection failed, using cwd basename', {
|
|
cwd: process.cwd()
|
|
}, error as Error);
|
|
return basename(process.cwd());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Find package root directory
|
|
*
|
|
* Works because bundled hooks are in plugin/scripts/,
|
|
* so package root is always one level up (the plugin directory)
|
|
*/
|
|
export function getPackageRoot(): string {
|
|
return join(_dirname, '..');
|
|
}
|
|
|
|
/**
|
|
* Find commands directory in the installed package
|
|
*/
|
|
export function getPackageCommandsDir(): string {
|
|
const packageRoot = getPackageRoot();
|
|
return join(packageRoot, 'commands');
|
|
}
|
|
|
|
/**
|
|
* Create a timestamped backup filename
|
|
*/
|
|
export function createBackupFilename(originalPath: string): string {
|
|
const timestamp = new Date()
|
|
.toISOString()
|
|
.replace(/[:.]/g, '-')
|
|
.replace('T', '_')
|
|
.slice(0, 19);
|
|
|
|
return `${originalPath}.backup.${timestamp}`;
|
|
}
|