refactor: streamline claude-mem integration and remove unused code
- Updated CODEMAP to reflect changes in fallback methods for package root discovery. - Removed the `detectClaudePath` function and replaced its usage with direct references to `PACKAGE_NAME`. - Eliminated the `claudePath` property from Settings interface and user settings configuration. - Cleaned up path discovery logic by removing the npm list command method. - Removed the `findExecutable` method from the Platform utility as it was no longer needed.
This commit is contained in:
Vendored
+82
-82
File diff suppressed because one or more lines are too long
+1
-6
@@ -749,7 +749,7 @@ export type { ParsedObservation, ParsedSummary } from './parser.js';
|
|||||||
- `getProjectMcpConfigPath()`: `./.mcp.json`
|
- `getProjectMcpConfigPath()`: `./.mcp.json`
|
||||||
|
|
||||||
**Package Discovery**:
|
**Package Discovery**:
|
||||||
- `getPackageRoot()`: Find claude-mem package root (3 fallback methods)
|
- `getPackageRoot()`: Find claude-mem package root (2 fallback methods)
|
||||||
- `findPackageCommandsDirectory()`: Find commands directory in package
|
- `findPackageCommandsDirectory()`: Find commands directory in package
|
||||||
|
|
||||||
**Utility Methods**:
|
**Utility Methods**:
|
||||||
@@ -1108,7 +1108,6 @@ export interface Settings {
|
|||||||
backend?: string; // 'chroma'
|
backend?: string; // 'chroma'
|
||||||
embedded?: boolean;
|
embedded?: boolean;
|
||||||
saveMemoriesOnClear?: boolean;
|
saveMemoriesOnClear?: boolean;
|
||||||
claudePath?: string;
|
|
||||||
rollingCaptureEnabled?: boolean;
|
rollingCaptureEnabled?: boolean;
|
||||||
rollingSummaryEnabled?: boolean;
|
rollingSummaryEnabled?: boolean;
|
||||||
rollingSessionStartEnabled?: boolean;
|
rollingSessionStartEnabled?: boolean;
|
||||||
@@ -1181,10 +1180,6 @@ export async function getStorageProvider(): Promise<IStorageProvider>
|
|||||||
|
|
||||||
**Key Functions**:
|
**Key Functions**:
|
||||||
|
|
||||||
- **`Platform.findExecutable(name)`**: Find path to executable
|
|
||||||
- Windows: `where {name}`
|
|
||||||
- Unix: `which {name}`
|
|
||||||
|
|
||||||
- **`Platform.installUv()`**: Install uv package manager
|
- **`Platform.installUv()`**: Install uv package manager
|
||||||
- Windows: PowerShell script
|
- Windows: PowerShell script
|
||||||
- Unix: curl + sh script
|
- Unix: curl + sh script
|
||||||
|
|||||||
+6
-13
@@ -58,9 +58,6 @@ function installUv(): void {
|
|||||||
process.env.PATH = `${homedir()}/.cargo/bin:${process.env.PATH}`;
|
process.env.PATH = `${homedir()}/.cargo/bin:${process.env.PATH}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function detectClaudePath(): string {
|
|
||||||
return Platform.findExecutable('claude');
|
|
||||||
}
|
|
||||||
|
|
||||||
function hasExistingInstallation(): boolean {
|
function hasExistingInstallation(): boolean {
|
||||||
const pathDiscovery = PathDiscovery.getInstance();
|
const pathDiscovery = PathDiscovery.getInstance();
|
||||||
@@ -343,12 +340,11 @@ function configureHooks(settingsPath: string): void {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Configure hooks to use CLI commands directly
|
// Configure hooks to use CLI commands directly
|
||||||
const cliPath = detectClaudePath() || PACKAGE_NAME;
|
// claude-mem should be in PATH after npm installation
|
||||||
|
settings.hooks.SessionStart = [createHookConfig(`${PACKAGE_NAME} context`, 180)];
|
||||||
settings.hooks.SessionStart = [createHookConfig(`${cliPath} context`, 180)];
|
settings.hooks.Stop = [createHookConfig(`${PACKAGE_NAME} summary`, 60)];
|
||||||
settings.hooks.Stop = [createHookConfig(`${cliPath} summary`, 60)];
|
settings.hooks.UserPromptSubmit = [createHookConfig(`${PACKAGE_NAME} new`, 60)];
|
||||||
settings.hooks.UserPromptSubmit = [createHookConfig(`${cliPath} new`, 60)];
|
settings.hooks.PostToolUse = [createHookConfig(`${PACKAGE_NAME} save`, 180, "*")];
|
||||||
settings.hooks.PostToolUse = [createHookConfig(`${cliPath} save`, 180, "*")];
|
|
||||||
|
|
||||||
writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
|
writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
|
||||||
}
|
}
|
||||||
@@ -375,7 +371,6 @@ function configureUserSettings(config: InstallConfig): void {
|
|||||||
userSettings.installed = true;
|
userSettings.installed = true;
|
||||||
userSettings.embedded = true;
|
userSettings.embedded = true;
|
||||||
userSettings.saveMemoriesOnClear = config.saveMemoriesOnClear || false;
|
userSettings.saveMemoriesOnClear = config.saveMemoriesOnClear || false;
|
||||||
userSettings.claudePath = detectClaudePath();
|
|
||||||
|
|
||||||
writeFileSync(userSettingsPath, JSON.stringify(userSettings, null, 2));
|
writeFileSync(userSettingsPath, JSON.stringify(userSettings, null, 2));
|
||||||
}
|
}
|
||||||
@@ -383,9 +378,7 @@ function configureUserSettings(config: InstallConfig): void {
|
|||||||
function configureSmartTrashAlias(): void {
|
function configureSmartTrashAlias(): void {
|
||||||
const shellConfigs = Platform.getShellConfigPaths();
|
const shellConfigs = Platform.getShellConfigPaths();
|
||||||
const aliasDefinition = Platform.getAliasDefinition('rm', 'claude-mem trash');
|
const aliasDefinition = Platform.getAliasDefinition('rm', 'claude-mem trash');
|
||||||
const commentLine = Platform.isWindows()
|
const commentLine = '# claude-mem smart trash alias';
|
||||||
? '# claude-mem smart trash alias'
|
|
||||||
: '# claude-mem smart trash alias';
|
|
||||||
|
|
||||||
for (const configPath of shellConfigs) {
|
for (const configPath of shellConfigs) {
|
||||||
if (!existsSync(configPath)) {
|
if (!existsSync(configPath)) {
|
||||||
|
|||||||
@@ -198,21 +198,6 @@ export class PathDiscovery {
|
|||||||
currentDir = parentDir;
|
currentDir = parentDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method 3: Try npm list command
|
|
||||||
try {
|
|
||||||
const npmOutput = execSync('npm list -g claude-mem --json 2>/dev/null || npm list claude-mem --json 2>/dev/null', {
|
|
||||||
encoding: 'utf8'
|
|
||||||
});
|
|
||||||
const npmData = JSON.parse(npmOutput);
|
|
||||||
|
|
||||||
if (npmData.dependencies?.['claude-mem']?.resolved) {
|
|
||||||
this._packageRoot = dirname(npmData.dependencies['claude-mem'].resolved);
|
|
||||||
return this._packageRoot;
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
// Continue to error
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Error('Cannot locate claude-mem package root. Ensure claude-mem is properly installed.');
|
throw new Error('Cannot locate claude-mem package root. Ensure claude-mem is properly installed.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ export interface Settings {
|
|||||||
backend?: string;
|
backend?: string;
|
||||||
embedded?: boolean;
|
embedded?: boolean;
|
||||||
saveMemoriesOnClear?: boolean;
|
saveMemoriesOnClear?: boolean;
|
||||||
claudePath?: string;
|
|
||||||
rollingCaptureEnabled?: boolean;
|
rollingCaptureEnabled?: boolean;
|
||||||
rollingSummaryEnabled?: boolean;
|
rollingSummaryEnabled?: boolean;
|
||||||
rollingSessionStartEnabled?: boolean;
|
rollingSessionStartEnabled?: boolean;
|
||||||
|
|||||||
@@ -9,19 +9,6 @@ const isWindows = platform() === 'win32';
|
|||||||
* Handles differences between Windows and Unix-like systems
|
* Handles differences between Windows and Unix-like systems
|
||||||
*/
|
*/
|
||||||
export const Platform = {
|
export const Platform = {
|
||||||
/**
|
|
||||||
* Finds the path to an executable command
|
|
||||||
* @param name - Name of the executable to find
|
|
||||||
* @returns Full path to the executable
|
|
||||||
*/
|
|
||||||
findExecutable: (name: string): string => {
|
|
||||||
const cmd = isWindows ? `where ${name}` : `which ${name}`;
|
|
||||||
return execSync(cmd, {
|
|
||||||
encoding: 'utf8',
|
|
||||||
stdio: ['ignore', 'pipe', 'ignore']
|
|
||||||
}).trim();
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Installs uv package manager using platform-specific method
|
* Installs uv package manager using platform-specific method
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user