Remove dead code files and update source tree documentation
This commit is contained in:
@@ -1,64 +0,0 @@
|
||||
import { platform, homedir } from 'os';
|
||||
import { execSync } from 'child_process';
|
||||
import { join } from 'path';
|
||||
|
||||
const isWindows = platform() === 'win32';
|
||||
|
||||
/**
|
||||
* Platform-specific utilities for cross-platform compatibility
|
||||
* Handles differences between Windows and Unix-like systems
|
||||
*/
|
||||
export const Platform = {
|
||||
/**
|
||||
* Installs uv package manager using platform-specific method
|
||||
*/
|
||||
installUv: (): void => {
|
||||
if (isWindows) {
|
||||
execSync('powershell -Command "irm https://astral.sh/uv/install.ps1 | iex"', {
|
||||
stdio: 'pipe'
|
||||
});
|
||||
} else {
|
||||
execSync('curl -LsSf https://astral.sh/uv/install.sh | sh', {
|
||||
stdio: 'pipe',
|
||||
shell: '/bin/sh'
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns shell configuration file paths for the current platform
|
||||
* @returns Array of shell config file paths
|
||||
*/
|
||||
getShellConfigPaths: (): string[] => {
|
||||
const home = homedir();
|
||||
|
||||
if (isWindows) {
|
||||
return [
|
||||
join(home, 'Documents', 'PowerShell', 'Microsoft.PowerShell_profile.ps1'),
|
||||
join(home, 'Documents', 'WindowsPowerShell', 'Microsoft.PowerShell_profile.ps1')
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
join(home, '.bashrc'),
|
||||
join(home, '.zshrc'),
|
||||
join(home, '.bash_profile')
|
||||
];
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the appropriate alias syntax for the current platform's shell
|
||||
* @param aliasName - Name of the alias
|
||||
* @param command - Command to alias
|
||||
* @returns Alias definition string
|
||||
*/
|
||||
getAliasDefinition: (aliasName: string, command: string): string => {
|
||||
if (isWindows) {
|
||||
// PowerShell function syntax
|
||||
return `function ${aliasName} { ${command} $args }`;
|
||||
}
|
||||
|
||||
// Bash/Zsh alias syntax
|
||||
return `alias ${aliasName}='${command}'`;
|
||||
}
|
||||
};
|
||||
@@ -1,61 +0,0 @@
|
||||
import { appendFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import { homedir } from 'os';
|
||||
|
||||
/**
|
||||
* Usage data structure from Claude Agent SDK result messages
|
||||
*/
|
||||
export interface UsageData {
|
||||
timestamp: string;
|
||||
sessionDbId: number;
|
||||
claudeSessionId: string;
|
||||
project: string;
|
||||
promptNumber: number;
|
||||
model: string;
|
||||
sessionId: string; // SDK session ID
|
||||
uuid: string; // SDK message UUID
|
||||
durationMs: number;
|
||||
durationApiMs: number;
|
||||
numTurns: number;
|
||||
totalCostUsd: number;
|
||||
usage: {
|
||||
inputTokens: number;
|
||||
outputTokens: number;
|
||||
cacheCreationInputTokens: number;
|
||||
cacheReadInputTokens: number;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Logger for capturing usage metrics to JSONL files
|
||||
*/
|
||||
export class UsageLogger {
|
||||
private logDir: string;
|
||||
private logFile: string;
|
||||
|
||||
constructor() {
|
||||
this.logDir = join(homedir(), '.claude-mem', 'usage-logs');
|
||||
// Create a daily log file
|
||||
const date = new Date().toISOString().split('T')[0]; // YYYY-MM-DD
|
||||
this.logFile = join(this.logDir, `usage-${date}.jsonl`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log usage data from SDK result message
|
||||
*/
|
||||
logUsage(data: UsageData): void {
|
||||
try {
|
||||
const line = JSON.stringify(data) + '\n';
|
||||
appendFileSync(this.logFile, line, 'utf-8');
|
||||
} catch (error) {
|
||||
console.error('Failed to log usage data:', error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current log file path
|
||||
*/
|
||||
getLogFilePath(): string {
|
||||
return this.logFile;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user