mirror of
https://github.com/rohitg00/skillkit.git
synced 2026-11-20 12:23:29 +00:00
* feat(memory): add lifecycle hooks, progressive disclosure, and auto-CLAUDE.md updates
- Add Claude Code lifecycle hooks (SessionStart, PostToolUse, SessionEnd)
for automatic memory capture and injection
- Implement 3-layer progressive disclosure for token-optimized retrieval
(Index ~50 tokens, Timeline ~200 tokens, Details ~600 tokens)
- Add CLAUDE.md auto-updater to populate LEARNED section with learnings
- Add auto-compression threshold trigger in observation store
- Add new CLI commands: `memory sync-claude` and `memory index`
- Update documentation with new memory features
- Remove 139 lines of unnecessary inline comments (code cleanup)
* fix(memory): address Devin review comments
- Fix double execution bug in MemoryHookManager by adding
generateHookOutputFromResult methods to avoid calling execute() twice
- Add setConfig method to PostToolUseHook for runtime config updates
- Update manager.setConfig() to propagate config to all hooks
* fix(memory): address CodeRabbit review comments
- Fix cross-platform path handling using path.basename() instead of split('/')
in claude-md-updater.ts, session-start.ts, and session-end.ts
- Fix onSessionEnd to call execute() before generateHookOutput to run
compression/cleanup side effects
- Add generateHookOutputFromResult() to SessionEndHook to avoid double execution
- Call clearOldPendingErrors() in PostToolUseHook.execute() to prevent
unbounded pendingErrors map growth
- Handle async checkAutoCompression() errors in observation-store.ts
- Add validation for compression threshold (must be positive integer)
- Fix docs/commands.mdx to use correct CLI flags (--limit, --tags)
- Clarify token accounting in progressive-disclosure smartRetrieve() JSDoc
- Use config.minRelevanceForCapture in session-start.ts instead of hardcoded value
* fix(memory): address additional CodeRabbit review comments
- Use nullish coalescing (??) for maxResults defaults in progressive-disclosure
- Guard against non-positive tokenBudget in smartRetrieve()
- Thread minRelevance option through to findRelevantIds()
- Fix memory index CLI to validate --limit and pass maxResults to getIndex()
77 lines
2.3 KiB
TypeScript
77 lines
2.3 KiB
TypeScript
import { existsSync, mkdirSync } from 'node:fs';
|
|
import { join } from 'node:path';
|
|
import { homedir } from 'node:os';
|
|
|
|
export interface MemoryPaths {
|
|
projectMemoryDir: string;
|
|
globalMemoryDir: string;
|
|
observationsFile: string;
|
|
learningsFile: string;
|
|
indexFile: string;
|
|
globalLearningsFile: string;
|
|
globalIndexFile: string;
|
|
}
|
|
|
|
export function getMemoryPaths(projectPath: string): MemoryPaths {
|
|
const projectMemoryDir = join(projectPath, '.skillkit', 'memory');
|
|
const globalMemoryDir = join(homedir(), '.skillkit', 'memory');
|
|
|
|
return {
|
|
projectMemoryDir,
|
|
globalMemoryDir,
|
|
observationsFile: join(projectMemoryDir, 'observations.yaml'),
|
|
learningsFile: join(projectMemoryDir, 'learnings.yaml'),
|
|
indexFile: join(projectMemoryDir, 'index.yaml'),
|
|
globalLearningsFile: join(globalMemoryDir, 'global.yaml'),
|
|
globalIndexFile: join(globalMemoryDir, 'index.yaml'),
|
|
};
|
|
}
|
|
|
|
export function initializeMemoryDirectory(projectPath: string): MemoryPaths {
|
|
const paths = getMemoryPaths(projectPath);
|
|
|
|
if (!existsSync(paths.projectMemoryDir)) {
|
|
mkdirSync(paths.projectMemoryDir, { recursive: true });
|
|
}
|
|
|
|
if (!existsSync(paths.globalMemoryDir)) {
|
|
mkdirSync(paths.globalMemoryDir, { recursive: true });
|
|
}
|
|
|
|
return paths;
|
|
}
|
|
|
|
export function memoryDirectoryExists(projectPath: string): boolean {
|
|
const paths = getMemoryPaths(projectPath);
|
|
return existsSync(paths.projectMemoryDir);
|
|
}
|
|
|
|
export function globalMemoryDirectoryExists(): boolean {
|
|
const globalMemoryDir = join(homedir(), '.skillkit', 'memory');
|
|
return existsSync(globalMemoryDir);
|
|
}
|
|
|
|
export interface MemoryStatus {
|
|
projectMemoryExists: boolean;
|
|
globalMemoryExists: boolean;
|
|
hasObservations: boolean;
|
|
hasLearnings: boolean;
|
|
hasGlobalLearnings: boolean;
|
|
hasIndex: boolean;
|
|
hasGlobalIndex: boolean;
|
|
}
|
|
|
|
export function getMemoryStatus(projectPath: string): MemoryStatus {
|
|
const paths = getMemoryPaths(projectPath);
|
|
|
|
return {
|
|
projectMemoryExists: existsSync(paths.projectMemoryDir),
|
|
globalMemoryExists: existsSync(paths.globalMemoryDir),
|
|
hasObservations: existsSync(paths.observationsFile),
|
|
hasLearnings: existsSync(paths.learningsFile),
|
|
hasGlobalLearnings: existsSync(paths.globalLearningsFile),
|
|
hasIndex: existsSync(paths.indexFile),
|
|
hasGlobalIndex: existsSync(paths.globalIndexFile),
|
|
};
|
|
}
|