@stackmemoryai/stackmemory 0.5.57 → 0.5.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/codex-smd +6 -0
- package/dist/cli/codex-sm-danger.js +21 -0
- package/dist/cli/codex-sm-danger.js.map +7 -0
- package/dist/cli/commands/handoff.js +33 -3
- package/dist/cli/commands/handoff.js.map +2 -2
- package/dist/core/session/enhanced-handoff.js +136 -2
- package/dist/core/session/enhanced-handoff.js.map +3 -3
- package/package.json +2 -1
- package/scripts/create-cleanup-issues.js +302 -0
- package/scripts/demos/browser-test.ts +39 -0
- package/scripts/demos/ralph-integration-demo.ts +244 -0
- package/scripts/demos/trace-demo.ts +214 -0
- package/scripts/demos/trace-detector.demo.ts +171 -0
- package/scripts/demos/trace-test.ts +67 -0
- package/scripts/test-claude-config.sh +123 -0
- package/scripts/validate-claude-config.sh +155 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/core/session/enhanced-handoff.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Enhanced Handoff Generator\n * Produces high-efficacy handoffs (70-85% context preservation)\n * Target: 2,000-3,000 tokens for rich context\n */\n\nimport { execSync } from 'child_process';\nimport {\n existsSync,\n readFileSync,\n readdirSync,\n statSync,\n writeFileSync,\n mkdirSync,\n} from 'fs';\nimport { join, basename } from 'path';\nimport { homedir, tmpdir } from 'os';\nimport { globSync } from 'glob';\n\n// Token counting - use Anthropic's tokenizer for accurate counts\nlet countTokens: (text: string) => number;\ntry {\n // Dynamic import for CommonJS compatibility\n const tokenizer = await import('@anthropic-ai/tokenizer');\n countTokens = tokenizer.countTokens;\n} catch {\n // Fallback to estimation if tokenizer not available\n countTokens = (text: string) => Math.ceil(text.length / 3.5);\n}\n\n// Load session decisions if available\ninterface SessionDecision {\n id: string;\n what: string;\n why: string;\n alternatives?: string[];\n timestamp: string;\n category?: string;\n}\n\n// Review feedback persistence\ninterface StoredReviewFeedback {\n timestamp: string;\n source: string;\n keyPoints: string[];\n actionItems: string[];\n sourceFile?: string;\n}\n\ninterface ReviewFeedbackStore {\n feedbacks: StoredReviewFeedback[];\n lastUpdated: string;\n}\n\nfunction loadSessionDecisions(projectRoot: string): SessionDecision[] {\n const storePath = join(projectRoot, '.stackmemory', 'session-decisions.json');\n if (existsSync(storePath)) {\n try {\n const store = JSON.parse(readFileSync(storePath, 'utf-8'));\n return store.decisions || [];\n } catch {\n return [];\n }\n }\n return [];\n}\n\nfunction loadReviewFeedback(projectRoot: string): StoredReviewFeedback[] {\n const storePath = join(projectRoot, '.stackmemory', 'review-feedback.json');\n if (existsSync(storePath)) {\n try {\n const store: ReviewFeedbackStore = JSON.parse(\n readFileSync(storePath, 'utf-8')\n );\n // Return feedbacks from last 24 hours\n const cutoff = Date.now() - 24 * 60 * 60 * 1000;\n return store.feedbacks.filter(\n (f) => new Date(f.timestamp).getTime() > cutoff\n );\n } catch {\n return [];\n }\n }\n return [];\n}\n\nfunction saveReviewFeedback(\n projectRoot: string,\n feedbacks: StoredReviewFeedback[]\n): void {\n const dir = join(projectRoot, '.stackmemory');\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true });\n }\n\n const storePath = join(dir, 'review-feedback.json');\n\n // Load existing and merge\n let existing: StoredReviewFeedback[] = [];\n if (existsSync(storePath)) {\n try {\n const store: ReviewFeedbackStore = JSON.parse(\n readFileSync(storePath, 'utf-8')\n );\n existing = store.feedbacks || [];\n } catch {\n // Ignore parse errors\n }\n }\n\n // Deduplicate by source + first key point\n const seen = new Set<string>();\n const merged: StoredReviewFeedback[] = [];\n\n for (const f of [...feedbacks, ...existing]) {\n const key = `${f.source}:${f.keyPoints[0] || ''}`;\n if (!seen.has(key)) {\n seen.add(key);\n merged.push(f);\n }\n }\n\n // Keep only last 20 feedbacks\n const store: ReviewFeedbackStore = {\n feedbacks: merged.slice(0, 20),\n lastUpdated: new Date().toISOString(),\n };\n\n writeFileSync(storePath, JSON.stringify(store, null, 2));\n}\n\n/**\n * Find Claude agent output directories dynamically\n */\nfunction findAgentOutputDirs(projectRoot: string): string[] {\n const dirs: string[] = [];\n\n // Try multiple locations where agent outputs might be stored\n const tmpBase = process.env['TMPDIR'] || tmpdir() || '/tmp';\n\n // Pattern 1: /tmp/claude/-path-to-project/tasks\n const projectPathEncoded = projectRoot.replace(/\\//g, '-').replace(/^-/, '');\n const pattern1 = join(tmpBase, 'claude', `*${projectPathEncoded}*`, 'tasks');\n try {\n const matches = globSync(pattern1);\n dirs.push(...matches);\n } catch {\n // Glob failed\n }\n\n // Pattern 2: /private/tmp/claude/... (macOS specific)\n if (tmpBase !== '/private/tmp') {\n const pattern2 = join(\n '/private/tmp',\n 'claude',\n `*${projectPathEncoded}*`,\n 'tasks'\n );\n try {\n const matches = globSync(pattern2);\n dirs.push(...matches);\n } catch {\n // Glob failed\n }\n }\n\n // Pattern 3: ~/.claude/projects/*/tasks (if exists)\n const homeClaudeDir = join(homedir(), '.claude', 'projects');\n if (existsSync(homeClaudeDir)) {\n try {\n const projectDirs = readdirSync(homeClaudeDir);\n for (const d of projectDirs) {\n const tasksDir = join(homeClaudeDir, d, 'tasks');\n if (existsSync(tasksDir)) {\n dirs.push(tasksDir);\n }\n }\n } catch {\n // Failed to read\n }\n }\n\n return [...new Set(dirs)]; // Deduplicate\n}\n\nexport interface EnhancedHandoff {\n // Metadata\n timestamp: string;\n project: string;\n branch: string;\n sessionDuration?: string;\n\n // What we're building (HIGH VALUE)\n activeWork: {\n description: string;\n status: 'in_progress' | 'blocked' | 'review' | 'done';\n keyFiles: string[];\n progress?: string;\n };\n\n // Decisions made (HIGH VALUE)\n decisions: Array<{\n what: string;\n why: string;\n alternatives?: string[];\n }>;\n\n // Architecture context (MEDIUM VALUE)\n architecture: {\n keyComponents: Array<{\n file: string;\n purpose: string;\n }>;\n patterns: string[];\n };\n\n // Blockers and issues (HIGH VALUE)\n blockers: Array<{\n issue: string;\n attempted: string[];\n status: 'resolved' | 'open';\n }>;\n\n // Review feedback (HIGH VALUE if present)\n reviewFeedback?: {\n source: string;\n keyPoints: string[];\n actionItems: string[];\n }[];\n\n // Next actions (MEDIUM VALUE)\n nextActions: string[];\n\n // Patterns established (LOW-MEDIUM VALUE)\n codePatterns?: string[];\n\n // Token metrics\n estimatedTokens: number;\n}\n\nexport class EnhancedHandoffGenerator {\n private projectRoot: string;\n private claudeProjectsDir: string;\n\n constructor(projectRoot: string) {\n this.projectRoot = projectRoot;\n this.claudeProjectsDir = join(homedir(), '.claude', 'projects');\n }\n\n /**\n * Generate a high-efficacy handoff\n */\n async generate(): Promise<EnhancedHandoff> {\n const handoff: EnhancedHandoff = {\n timestamp: new Date().toISOString(),\n project: basename(this.projectRoot),\n branch: this.getCurrentBranch(),\n activeWork: await this.extractActiveWork(),\n decisions: await this.extractDecisions(),\n architecture: await this.extractArchitecture(),\n blockers: await this.extractBlockers(),\n reviewFeedback: await this.extractReviewFeedback(),\n nextActions: await this.extractNextActions(),\n codePatterns: await this.extractCodePatterns(),\n estimatedTokens: 0,\n };\n\n // Calculate estimated tokens\n const markdown = this.toMarkdown(handoff);\n handoff.estimatedTokens = countTokens(markdown);\n\n return handoff;\n }\n\n /**\n * Extract what we're currently building from git and recent files\n */\n private async extractActiveWork(): Promise<EnhancedHandoff['activeWork']> {\n // Get recent commits to understand current work\n const recentCommits = this.getRecentCommits(5);\n const recentFiles = this.getRecentlyModifiedFiles(10);\n\n // Try to infer the active work from commit messages\n let description = 'Unknown - check git log for context';\n let status: EnhancedHandoff['activeWork']['status'] = 'in_progress';\n\n if (recentCommits.length > 0) {\n // Use most recent commit as indicator\n const lastCommit = recentCommits[0];\n if (lastCommit.includes('feat:') || lastCommit.includes('implement')) {\n description = lastCommit.replace(/^[a-f0-9]+\\s+/, '');\n } else if (lastCommit.includes('fix:')) {\n description = 'Bug fix: ' + lastCommit.replace(/^[a-f0-9]+\\s+/, '');\n } else if (\n lastCommit.includes('chore:') ||\n lastCommit.includes('refactor:')\n ) {\n description = lastCommit.replace(/^[a-f0-9]+\\s+/, '');\n } else {\n description = lastCommit.replace(/^[a-f0-9]+\\s+/, '');\n }\n }\n\n // Check for blocking indicators\n const gitStatus = this.getGitStatus();\n if (gitStatus.includes('conflict')) {\n status = 'blocked';\n }\n\n return {\n description,\n status,\n keyFiles: recentFiles.slice(0, 5),\n progress:\n recentCommits.length > 0\n ? `${recentCommits.length} commits in current session`\n : undefined,\n };\n }\n\n /**\n * Extract decisions from session store, git commits, and decision logs\n */\n private async extractDecisions(): Promise<EnhancedHandoff['decisions']> {\n const decisions: EnhancedHandoff['decisions'] = [];\n\n // First, load session decisions (highest priority - explicitly recorded)\n const sessionDecisions = loadSessionDecisions(this.projectRoot);\n for (const d of sessionDecisions) {\n decisions.push({\n what: d.what,\n why: d.why,\n alternatives: d.alternatives,\n });\n }\n\n // Then look for decision markers in recent commits\n const commits = this.getRecentCommits(20);\n for (const commit of commits) {\n // Look for decision-like patterns\n if (\n commit.toLowerCase().includes('use ') ||\n commit.toLowerCase().includes('switch to ') ||\n commit.toLowerCase().includes('default to ') ||\n (commit.toLowerCase().includes('make ') &&\n commit.toLowerCase().includes('optional'))\n ) {\n // Avoid duplicates\n const commitText = commit.replace(/^[a-f0-9]+\\s+/, '');\n if (!decisions.some((d) => d.what.includes(commitText.slice(0, 30)))) {\n decisions.push({\n what: commitText,\n why: 'See commit for details',\n });\n }\n }\n }\n\n // Check for a decisions file\n const decisionsFile = join(\n this.projectRoot,\n '.stackmemory',\n 'decisions.md'\n );\n if (existsSync(decisionsFile)) {\n const content = readFileSync(decisionsFile, 'utf-8');\n const parsed = this.parseDecisionsFile(content);\n decisions.push(...parsed);\n }\n\n return decisions.slice(0, 10); // Limit to prevent bloat\n }\n\n /**\n * Parse a decisions.md file\n */\n private parseDecisionsFile(content: string): EnhancedHandoff['decisions'] {\n const decisions: EnhancedHandoff['decisions'] = [];\n const lines = content.split('\\n');\n\n let currentDecision: {\n what: string;\n why: string;\n alternatives?: string[];\n } | null = null;\n\n for (const line of lines) {\n if (line.startsWith('## ') || line.startsWith('### ')) {\n if (currentDecision) {\n decisions.push(currentDecision);\n }\n currentDecision = { what: line.replace(/^#+\\s+/, ''), why: '' };\n } else if (currentDecision && line.toLowerCase().includes('rationale:')) {\n currentDecision.why = line.replace(/rationale:\\s*/i, '').trim();\n } else if (currentDecision && line.toLowerCase().includes('why:')) {\n currentDecision.why = line.replace(/why:\\s*/i, '').trim();\n } else if (\n currentDecision &&\n line.toLowerCase().includes('alternatives:')\n ) {\n currentDecision.alternatives = [];\n } else if (currentDecision?.alternatives && line.trim().startsWith('-')) {\n currentDecision.alternatives.push(line.replace(/^\\s*-\\s*/, '').trim());\n }\n }\n\n if (currentDecision) {\n decisions.push(currentDecision);\n }\n\n return decisions;\n }\n\n /**\n * Extract architecture context from key files\n */\n private async extractArchitecture(): Promise<\n EnhancedHandoff['architecture']\n > {\n const keyComponents: EnhancedHandoff['architecture']['keyComponents'] = [];\n const patterns: string[] = [];\n\n // Find recently modified TypeScript/JavaScript files\n const recentFiles = this.getRecentlyModifiedFiles(20);\n const codeFiles = recentFiles.filter(\n (f) => f.endsWith('.ts') || f.endsWith('.js') || f.endsWith('.tsx')\n );\n\n for (const file of codeFiles.slice(0, 8)) {\n const purpose = this.inferFilePurpose(file);\n if (purpose) {\n keyComponents.push({ file, purpose });\n }\n }\n\n // Detect patterns from file structure\n if (codeFiles.some((f) => f.includes('/daemon/'))) {\n patterns.push('Daemon/background process pattern');\n }\n if (codeFiles.some((f) => f.includes('/cli/'))) {\n patterns.push('CLI command pattern');\n }\n if (\n codeFiles.some((f) => f.includes('.test.') || f.includes('__tests__'))\n ) {\n patterns.push('Test files present');\n }\n if (codeFiles.some((f) => f.includes('/core/'))) {\n patterns.push('Core/domain separation');\n }\n\n return { keyComponents, patterns };\n }\n\n /**\n * Infer purpose from file name and path\n */\n private inferFilePurpose(filePath: string): string | null {\n const name = basename(filePath).replace(/\\.(ts|js|tsx)$/, '');\n const path = filePath.toLowerCase();\n\n if (path.includes('daemon')) return 'Background daemon/service';\n if (path.includes('cli/command')) return 'CLI command handler';\n if (path.includes('config')) return 'Configuration management';\n if (path.includes('storage')) return 'Data storage layer';\n if (path.includes('handoff')) return 'Session handoff logic';\n if (path.includes('service')) return 'Service orchestration';\n if (path.includes('manager')) return 'Resource/state management';\n if (path.includes('handler')) return 'Event/request handler';\n if (path.includes('util') || path.includes('helper'))\n return 'Utility functions';\n if (path.includes('types') || path.includes('interface'))\n return 'Type definitions';\n if (path.includes('test')) return null; // Skip test files\n if (name.includes('-')) {\n return name\n .split('-')\n .map((w) => w.charAt(0).toUpperCase() + w.slice(1))\n .join(' ');\n }\n return null;\n }\n\n /**\n * Extract blockers from git status and recent errors\n */\n private async extractBlockers(): Promise<EnhancedHandoff['blockers']> {\n const blockers: EnhancedHandoff['blockers'] = [];\n\n // Check for merge conflicts\n const gitStatus = this.getGitStatus();\n if (gitStatus.includes('UU ') || gitStatus.includes('both modified')) {\n blockers.push({\n issue: 'Merge conflict detected',\n attempted: ['Check git status for affected files'],\n status: 'open',\n });\n }\n\n // Check for failing tests\n try {\n const testResult = execSync('npm test 2>&1 || true', {\n encoding: 'utf-8',\n cwd: this.projectRoot,\n timeout: 30000,\n });\n if (testResult.includes('FAIL') || testResult.includes('failed')) {\n const failCount = (testResult.match(/(\\d+) failed/i) || ['', '?'])[1];\n blockers.push({\n issue: `Test failures: ${failCount} tests failing`,\n attempted: ['Run npm test for details'],\n status: 'open',\n });\n }\n } catch {\n // Test command failed - might indicate issues\n }\n\n // Check for lint errors\n try {\n const lintResult = execSync('npm run lint 2>&1 || true', {\n encoding: 'utf-8',\n cwd: this.projectRoot,\n timeout: 30000,\n });\n if (lintResult.includes('error') && !lintResult.includes('0 errors')) {\n blockers.push({\n issue: 'Lint errors present',\n attempted: ['Run npm run lint for details'],\n status: 'open',\n });\n }\n } catch {\n // Lint command failed\n }\n\n return blockers;\n }\n\n /**\n * Extract review feedback from agent output files and persisted storage\n */\n private async extractReviewFeedback(): Promise<\n EnhancedHandoff['reviewFeedback']\n > {\n const feedback: EnhancedHandoff['reviewFeedback'] = [];\n const newFeedbacks: StoredReviewFeedback[] = [];\n\n // Find agent output directories dynamically\n const outputDirs = findAgentOutputDirs(this.projectRoot);\n\n for (const tmpDir of outputDirs) {\n if (!existsSync(tmpDir)) continue;\n\n try {\n const files = readdirSync(tmpDir).filter((f) => f.endsWith('.output'));\n const recentFiles = files\n .map((f) => ({\n name: f,\n path: join(tmpDir, f),\n stat: statSync(join(tmpDir, f)),\n }))\n .filter((f) => Date.now() - f.stat.mtimeMs < 3600000) // Last hour\n .sort((a, b) => b.stat.mtimeMs - a.stat.mtimeMs)\n .slice(0, 3);\n\n for (const file of recentFiles) {\n const content = readFileSync(file.path, 'utf-8');\n const extracted = this.extractKeyPointsFromReview(content);\n if (extracted.keyPoints.length > 0) {\n feedback.push(extracted);\n\n // Also store for persistence\n newFeedbacks.push({\n timestamp: new Date().toISOString(),\n source: extracted.source,\n keyPoints: extracted.keyPoints,\n actionItems: extracted.actionItems,\n sourceFile: file.name,\n });\n }\n }\n } catch {\n // Failed to read agent outputs from this directory\n }\n }\n\n // Save new feedback to persistent storage\n if (newFeedbacks.length > 0) {\n saveReviewFeedback(this.projectRoot, newFeedbacks);\n }\n\n // Load persisted feedback if no new feedback found\n if (feedback.length === 0) {\n const stored = loadReviewFeedback(this.projectRoot);\n for (const s of stored.slice(0, 3)) {\n feedback.push({\n source: s.source,\n keyPoints: s.keyPoints,\n actionItems: s.actionItems,\n });\n }\n }\n\n return feedback.length > 0 ? feedback : undefined;\n }\n\n /**\n * Extract key points from a review output\n */\n private extractKeyPointsFromReview(content: string): {\n source: string;\n keyPoints: string[];\n actionItems: string[];\n } {\n const keyPoints: string[] = [];\n const actionItems: string[] = [];\n let source = 'Agent Review';\n\n // Detect review type\n if (\n content.includes('Product Manager') ||\n content.includes('product-manager')\n ) {\n source = 'Product Manager';\n } else if (\n content.includes('Staff Architect') ||\n content.includes('staff-architect')\n ) {\n source = 'Staff Architect';\n }\n\n // Extract key recommendations (look for common patterns)\n const lines = content.split('\\n');\n let inRecommendations = false;\n let inActionItems = false;\n\n for (const line of lines) {\n const trimmed = line.trim();\n\n // Detect section headers\n if (\n trimmed.toLowerCase().includes('recommendation') ||\n trimmed.toLowerCase().includes('key finding')\n ) {\n inRecommendations = true;\n inActionItems = false;\n continue;\n }\n if (\n trimmed.toLowerCase().includes('action') ||\n trimmed.toLowerCase().includes('next step') ||\n trimmed.toLowerCase().includes('priority')\n ) {\n inActionItems = true;\n inRecommendations = false;\n continue;\n }\n\n // Extract bullet points\n if (\n trimmed.startsWith('- ') ||\n trimmed.startsWith('* ') ||\n /^\\d+\\.\\s/.test(trimmed)\n ) {\n const point = trimmed.replace(/^[-*]\\s+/, '').replace(/^\\d+\\.\\s+/, '');\n if (point.length > 10 && point.length < 200) {\n if (inActionItems) {\n actionItems.push(point);\n } else if (inRecommendations) {\n keyPoints.push(point);\n }\n }\n }\n }\n\n // Limit to prevent bloat\n return {\n source,\n keyPoints: keyPoints.slice(0, 5),\n actionItems: actionItems.slice(0, 5),\n };\n }\n\n /**\n * Extract next actions from todo state and git\n */\n private async extractNextActions(): Promise<string[]> {\n const actions: string[] = [];\n\n // Check for uncommitted changes\n const gitStatus = this.getGitStatus();\n if (gitStatus.trim()) {\n actions.push('Commit pending changes');\n }\n\n // Look for TODO comments in recent files\n const recentFiles = this.getRecentlyModifiedFiles(5);\n for (const file of recentFiles) {\n try {\n const fullPath = join(this.projectRoot, file);\n if (existsSync(fullPath)) {\n const content = readFileSync(fullPath, 'utf-8');\n const todos = content.match(/\\/\\/\\s*TODO:?\\s*.+/gi) || [];\n for (const todo of todos.slice(0, 2)) {\n actions.push(todo.replace(/\\/\\/\\s*TODO:?\\s*/i, 'TODO: '));\n }\n }\n } catch {\n // Skip unreadable files\n }\n }\n\n // Check for pending tasks in .stackmemory\n const tasksFile = join(this.projectRoot, '.stackmemory', 'tasks.json');\n if (existsSync(tasksFile)) {\n try {\n const tasks = JSON.parse(readFileSync(tasksFile, 'utf-8'));\n const pending = tasks.filter(\n (t: any) => t.status === 'pending' || t.status === 'in_progress'\n );\n for (const task of pending.slice(0, 3)) {\n actions.push(task.title || task.description);\n }\n } catch {\n // Invalid tasks file\n }\n }\n\n return actions.slice(0, 8);\n }\n\n /**\n * Extract established code patterns\n */\n private async extractCodePatterns(): Promise<string[]> {\n const patterns: string[] = [];\n\n // Check ESLint config for patterns\n const eslintConfig = join(this.projectRoot, 'eslint.config.js');\n if (existsSync(eslintConfig)) {\n const content = readFileSync(eslintConfig, 'utf-8');\n if (content.includes('argsIgnorePattern')) {\n patterns.push('Underscore prefix for unused vars (_var)');\n }\n if (content.includes('ignores') && content.includes('test')) {\n patterns.push('Test files excluded from lint');\n }\n }\n\n // Check tsconfig for patterns\n const tsconfig = join(this.projectRoot, 'tsconfig.json');\n if (existsSync(tsconfig)) {\n const content = readFileSync(tsconfig, 'utf-8');\n if (content.includes('\"strict\": true')) {\n patterns.push('TypeScript strict mode enabled');\n }\n if (content.includes('ES2022') || content.includes('ESNext')) {\n patterns.push('ESM module system');\n }\n }\n\n return patterns;\n }\n\n /**\n * Get recent git commits\n */\n private getRecentCommits(count: number): string[] {\n try {\n const result = execSync(`git log --oneline -${count}`, {\n encoding: 'utf-8',\n cwd: this.projectRoot,\n });\n return result.trim().split('\\n').filter(Boolean);\n } catch {\n return [];\n }\n }\n\n /**\n * Get current git branch\n */\n private getCurrentBranch(): string {\n try {\n return execSync('git rev-parse --abbrev-ref HEAD', {\n encoding: 'utf-8',\n cwd: this.projectRoot,\n }).trim();\n } catch {\n return 'unknown';\n }\n }\n\n /**\n * Get git status\n */\n private getGitStatus(): string {\n try {\n return execSync('git status --short', {\n encoding: 'utf-8',\n cwd: this.projectRoot,\n });\n } catch {\n return '';\n }\n }\n\n /**\n * Get recently modified files\n */\n private getRecentlyModifiedFiles(count: number): string[] {\n try {\n const result = execSync(\n `git diff --name-only HEAD~10 HEAD 2>/dev/null || git diff --name-only`,\n {\n encoding: 'utf-8',\n cwd: this.projectRoot,\n }\n );\n return result.trim().split('\\n').filter(Boolean).slice(0, count);\n } catch {\n return [];\n }\n }\n\n /**\n * Convert handoff to markdown\n */\n toMarkdown(handoff: EnhancedHandoff): string {\n const lines: string[] = [];\n\n lines.push(`# Session Handoff - ${handoff.timestamp.split('T')[0]}`);\n lines.push('');\n lines.push(`**Project**: ${handoff.project}`);\n lines.push(`**Branch**: ${handoff.branch}`);\n lines.push('');\n\n // Active Work (HIGH VALUE)\n lines.push('## Active Work');\n lines.push(`- **Building**: ${handoff.activeWork.description}`);\n lines.push(`- **Status**: ${handoff.activeWork.status}`);\n if (handoff.activeWork.keyFiles.length > 0) {\n lines.push(`- **Key files**: ${handoff.activeWork.keyFiles.join(', ')}`);\n }\n if (handoff.activeWork.progress) {\n lines.push(`- **Progress**: ${handoff.activeWork.progress}`);\n }\n lines.push('');\n\n // Decisions (HIGH VALUE)\n if (handoff.decisions.length > 0) {\n lines.push('## Key Decisions');\n for (const d of handoff.decisions) {\n lines.push(`1. **${d.what}**`);\n if (d.why) {\n lines.push(` - Rationale: ${d.why}`);\n }\n if (d.alternatives && d.alternatives.length > 0) {\n lines.push(\n ` - Alternatives considered: ${d.alternatives.join(', ')}`\n );\n }\n }\n lines.push('');\n }\n\n // Architecture (MEDIUM VALUE)\n if (handoff.architecture.keyComponents.length > 0) {\n lines.push('## Architecture Context');\n for (const c of handoff.architecture.keyComponents) {\n lines.push(`- \\`${c.file}\\`: ${c.purpose}`);\n }\n if (handoff.architecture.patterns.length > 0) {\n lines.push('');\n lines.push('**Patterns**: ' + handoff.architecture.patterns.join(', '));\n }\n lines.push('');\n }\n\n // Blockers (HIGH VALUE)\n if (handoff.blockers.length > 0) {\n lines.push('## Blockers');\n for (const b of handoff.blockers) {\n lines.push(`- **${b.issue}** [${b.status}]`);\n if (b.attempted.length > 0) {\n lines.push(` - Tried: ${b.attempted.join(', ')}`);\n }\n }\n lines.push('');\n }\n\n // Review Feedback (HIGH VALUE)\n if (handoff.reviewFeedback && handoff.reviewFeedback.length > 0) {\n lines.push('## Review Feedback');\n for (const r of handoff.reviewFeedback) {\n lines.push(`### ${r.source}`);\n if (r.keyPoints.length > 0) {\n lines.push('**Key Points**:');\n for (const p of r.keyPoints) {\n lines.push(`- ${p}`);\n }\n }\n if (r.actionItems.length > 0) {\n lines.push('**Action Items**:');\n for (const a of r.actionItems) {\n lines.push(`- ${a}`);\n }\n }\n lines.push('');\n }\n }\n\n // Next Actions (MEDIUM VALUE)\n if (handoff.nextActions.length > 0) {\n lines.push('## Next Actions');\n for (const a of handoff.nextActions) {\n lines.push(`1. ${a}`);\n }\n lines.push('');\n }\n\n // Code Patterns (LOW VALUE)\n if (handoff.codePatterns && handoff.codePatterns.length > 0) {\n lines.push('## Established Patterns');\n for (const p of handoff.codePatterns) {\n lines.push(`- ${p}`);\n }\n lines.push('');\n }\n\n lines.push('---');\n lines.push(`*Estimated tokens: ~${handoff.estimatedTokens}*`);\n lines.push(`*Generated at ${handoff.timestamp}*`);\n\n return lines.join('\\n');\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;AAMA,SAAS,gBAAgB;AACzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,MAAM,gBAAgB;AAC/B,SAAS,SAAS,cAAc;AAChC,SAAS,gBAAgB;AAGzB,IAAI;AACJ,IAAI;AAEF,QAAM,YAAY,MAAM,OAAO,yBAAyB;AACxD,gBAAc,UAAU;AAC1B,QAAQ;AAEN,gBAAc,CAAC,SAAiB,KAAK,KAAK,KAAK,SAAS,GAAG;AAC7D;AA0BA,SAAS,qBAAqB,aAAwC;AACpE,QAAM,YAAY,KAAK,aAAa,gBAAgB,wBAAwB;AAC5E,MAAI,WAAW,SAAS,GAAG;AACzB,QAAI;AACF,YAAM,QAAQ,KAAK,MAAM,aAAa,WAAW,OA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KAAK,CAAC,EAAE;AAAA,UACrB;AAAA,QACF;AACA,YAAI,EAAE,YAAY,SAAS,GAAG;AAC5B,gBAAM,KAAK,mBAAmB;AAC9B,qBAAW,KAAK,EAAE,aAAa;AAC7B,kBAAM,KAAK,KAAK,CAAC,EAAE;AAAA,UACrB;AAAA,QACF;AACA,cAAM,KAAK,EAAE;AAAA,MACf;AAAA,IACF;AAGA,QAAI,QAAQ,YAAY,SAAS,GAAG;AAClC,YAAM,KAAK,iBAAiB;AAC5B,iBAAW,KAAK,QAAQ,aAAa;AACnC,cAAM,KAAK,MAAM,CAAC,EAAE;AAAA,MACtB;AACA,YAAM,KAAK,EAAE;AAAA,IACf;AAGA,QAAI,QAAQ,gBAAgB,QAAQ,aAAa,SAAS,GAAG;AAC3D,YAAM,KAAK,yBAAyB;AACpC,iBAAW,KAAK,QAAQ,cAAc;AACpC,cAAM,KAAK,KAAK,CAAC,EAAE;AAAA,MACrB;AACA,YAAM,KAAK,EAAE;AAAA,IACf;AAEA,UAAM,KAAK,KAAK;AAChB,UAAM,KAAK,uBAAuB,QAAQ,eAAe,GAAG;AAC5D,UAAM,KAAK,iBAAiB,QAAQ,SAAS,GAAG;AAEhD,WAAO,MAAM,KAAK,IAAI;AAAA,EACxB;AACF;",
|
|
6
|
-
"names": ["store"]
|
|
4
|
+
"sourcesContent": ["/**\n * Enhanced Handoff Generator\n * Produces high-efficacy handoffs (70-85% context preservation)\n * Target: 2,000-3,000 tokens for rich context\n */\n\nimport { execSync } from 'child_process';\nimport {\n existsSync,\n readFileSync,\n readdirSync,\n statSync,\n writeFileSync,\n mkdirSync,\n} from 'fs';\nimport { basename, join } from 'path';\nimport { homedir, tmpdir } from 'os';\nimport { globSync } from 'glob';\n\n// Token counting - use Anthropic's tokenizer for accurate counts\nlet countTokens: (text: string) => number;\ntry {\n // Dynamic import for CommonJS compatibility\n const tokenizer = await import('@anthropic-ai/tokenizer');\n countTokens = tokenizer.countTokens;\n} catch {\n // Fallback to estimation if tokenizer not available\n countTokens = (text: string) => Math.ceil(text.length / 3.5);\n}\n\n// Load session decisions if available\ninterface SessionDecision {\n id: string;\n what: string;\n why: string;\n alternatives?: string[];\n timestamp: string;\n category?: string;\n}\n\n// Review feedback persistence\ninterface StoredReviewFeedback {\n timestamp: string;\n source: string;\n keyPoints: string[];\n actionItems: string[];\n sourceFile?: string;\n}\n\ninterface ReviewFeedbackStore {\n feedbacks: StoredReviewFeedback[];\n lastUpdated: string;\n}\n\nfunction loadSessionDecisions(projectRoot: string): SessionDecision[] {\n const storePath = join(projectRoot, '.stackmemory', 'session-decisions.json');\n if (existsSync(storePath)) {\n try {\n const store = JSON.parse(readFileSync(storePath, 'utf-8'));\n return store.decisions || [];\n } catch {\n return [];\n }\n }\n return [];\n}\n\nfunction loadReviewFeedback(projectRoot: string): StoredReviewFeedback[] {\n const storePath = join(projectRoot, '.stackmemory', 'review-feedback.json');\n if (existsSync(storePath)) {\n try {\n const store: ReviewFeedbackStore = JSON.parse(\n readFileSync(storePath, 'utf-8')\n );\n // Return feedbacks from last 24 hours\n const cutoff = Date.now() - 24 * 60 * 60 * 1000;\n return store.feedbacks.filter(\n (f) => new Date(f.timestamp).getTime() > cutoff\n );\n } catch {\n return [];\n }\n }\n return [];\n}\n\nfunction saveReviewFeedback(\n projectRoot: string,\n feedbacks: StoredReviewFeedback[]\n): void {\n const dir = join(projectRoot, '.stackmemory');\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true });\n }\n\n const storePath = join(dir, 'review-feedback.json');\n\n // Load existing and merge\n let existing: StoredReviewFeedback[] = [];\n if (existsSync(storePath)) {\n try {\n const store: ReviewFeedbackStore = JSON.parse(\n readFileSync(storePath, 'utf-8')\n );\n existing = store.feedbacks || [];\n } catch {\n // Ignore parse errors\n }\n }\n\n // Deduplicate by source + first key point\n const seen = new Set<string>();\n const merged: StoredReviewFeedback[] = [];\n\n for (const f of [...feedbacks, ...existing]) {\n const key = `${f.source}:${f.keyPoints[0] || ''}`;\n if (!seen.has(key)) {\n seen.add(key);\n merged.push(f);\n }\n }\n\n // Keep only last 20 feedbacks\n const store: ReviewFeedbackStore = {\n feedbacks: merged.slice(0, 20),\n lastUpdated: new Date().toISOString(),\n };\n\n writeFileSync(storePath, JSON.stringify(store, null, 2));\n}\n\n/**\n * Find Claude agent output directories dynamically\n */\nfunction findAgentOutputDirs(projectRoot: string): string[] {\n const dirs: string[] = [];\n\n // Try multiple locations where agent outputs might be stored\n const tmpBase = process.env['TMPDIR'] || tmpdir() || '/tmp';\n\n // Pattern 1: /tmp/claude/-path-to-project/tasks\n const projectPathEncoded = projectRoot.replace(/\\//g, '-').replace(/^-/, '');\n const pattern1 = join(tmpBase, 'claude', `*${projectPathEncoded}*`, 'tasks');\n try {\n const matches = globSync(pattern1);\n dirs.push(...matches);\n } catch {\n // Glob failed\n }\n\n // Pattern 2: /private/tmp/claude/... (macOS specific)\n if (tmpBase !== '/private/tmp') {\n const pattern2 = join(\n '/private/tmp',\n 'claude',\n `*${projectPathEncoded}*`,\n 'tasks'\n );\n try {\n const matches = globSync(pattern2);\n dirs.push(...matches);\n } catch {\n // Glob failed\n }\n }\n\n // Pattern 3: ~/.claude/projects/*/tasks (if exists)\n const homeClaudeDir = join(homedir(), '.claude', 'projects');\n if (existsSync(homeClaudeDir)) {\n try {\n const projectDirs = readdirSync(homeClaudeDir);\n for (const d of projectDirs) {\n const tasksDir = join(homeClaudeDir, d, 'tasks');\n if (existsSync(tasksDir)) {\n dirs.push(tasksDir);\n }\n }\n } catch {\n // Failed to read\n }\n }\n\n return [...new Set(dirs)]; // Deduplicate\n}\n\nexport interface EnhancedHandoff {\n // Metadata\n timestamp: string;\n project: string;\n branch: string;\n sessionDuration?: string;\n\n // What we're building (HIGH VALUE)\n activeWork: {\n description: string;\n status: 'in_progress' | 'blocked' | 'review' | 'done';\n keyFiles: string[];\n progress?: string;\n };\n\n // Decisions made (HIGH VALUE)\n decisions: Array<{\n what: string;\n why: string;\n alternatives?: string[];\n }>;\n\n // Architecture context (MEDIUM VALUE)\n architecture: {\n keyComponents: Array<{\n file: string;\n purpose: string;\n }>;\n patterns: string[];\n };\n\n // Blockers and issues (HIGH VALUE)\n blockers: Array<{\n issue: string;\n attempted: string[];\n status: 'resolved' | 'open';\n }>;\n\n // Review feedback (HIGH VALUE if present)\n reviewFeedback?: {\n source: string;\n keyPoints: string[];\n actionItems: string[];\n }[];\n\n // Next actions (MEDIUM VALUE)\n nextActions: string[];\n\n // Patterns established (LOW-MEDIUM VALUE)\n codePatterns?: string[];\n\n // Token metrics\n estimatedTokens: number;\n}\n\nexport class EnhancedHandoffGenerator {\n private projectRoot: string;\n private claudeProjectsDir: string;\n\n constructor(projectRoot: string) {\n this.projectRoot = projectRoot;\n this.claudeProjectsDir = join(homedir(), '.claude', 'projects');\n }\n\n /**\n * Generate a high-efficacy handoff\n */\n async generate(): Promise<EnhancedHandoff> {\n const handoff: EnhancedHandoff = {\n timestamp: new Date().toISOString(),\n project: basename(this.projectRoot),\n branch: this.getCurrentBranch(),\n activeWork: await this.extractActiveWork(),\n decisions: await this.extractDecisions(),\n architecture: await this.extractArchitecture(),\n blockers: await this.extractBlockers(),\n reviewFeedback: await this.extractReviewFeedback(),\n nextActions: await this.extractNextActions(),\n codePatterns: await this.extractCodePatterns(),\n estimatedTokens: 0,\n };\n\n // Calculate estimated tokens\n const markdown = this.toMarkdown(handoff);\n handoff.estimatedTokens = countTokens(markdown);\n\n return handoff;\n }\n\n /**\n * Extract what we're currently building from git and recent files\n */\n private async extractActiveWork(): Promise<EnhancedHandoff['activeWork']> {\n // Get recent commits to understand current work\n const recentCommits = this.getRecentCommits(5);\n const recentFiles = this.getRecentlyModifiedFiles(10);\n\n // Try to infer the active work from commit messages\n let description = 'Unknown - check git log for context';\n let status: EnhancedHandoff['activeWork']['status'] = 'in_progress';\n\n if (recentCommits.length > 0) {\n // Use most recent commit as indicator\n const lastCommit = recentCommits[0];\n if (lastCommit.includes('feat:') || lastCommit.includes('implement')) {\n description = lastCommit.replace(/^[a-f0-9]+\\s+/, '');\n } else if (lastCommit.includes('fix:')) {\n description = 'Bug fix: ' + lastCommit.replace(/^[a-f0-9]+\\s+/, '');\n } else if (\n lastCommit.includes('chore:') ||\n lastCommit.includes('refactor:')\n ) {\n description = lastCommit.replace(/^[a-f0-9]+\\s+/, '');\n } else {\n description = lastCommit.replace(/^[a-f0-9]+\\s+/, '');\n }\n }\n\n // Check for blocking indicators\n const gitStatus = this.getGitStatus();\n if (gitStatus.includes('conflict')) {\n status = 'blocked';\n }\n\n return {\n description,\n status,\n keyFiles: recentFiles.slice(0, 5),\n progress:\n recentCommits.length > 0\n ? `${recentCommits.length} commits in current session`\n : undefined,\n };\n }\n\n /**\n * Extract decisions from session store, git commits, and decision logs\n */\n private async extractDecisions(): Promise<EnhancedHandoff['decisions']> {\n const decisions: EnhancedHandoff['decisions'] = [];\n\n // First, load session decisions (highest priority - explicitly recorded)\n const sessionDecisions = loadSessionDecisions(this.projectRoot);\n for (const d of sessionDecisions) {\n decisions.push({\n what: d.what,\n why: d.why,\n alternatives: d.alternatives,\n });\n }\n\n // Then look for decision markers in recent commits\n const commits = this.getRecentCommits(20);\n for (const commit of commits) {\n // Look for decision-like patterns\n if (\n commit.toLowerCase().includes('use ') ||\n commit.toLowerCase().includes('switch to ') ||\n commit.toLowerCase().includes('default to ') ||\n (commit.toLowerCase().includes('make ') &&\n commit.toLowerCase().includes('optional'))\n ) {\n // Avoid duplicates\n const commitText = commit.replace(/^[a-f0-9]+\\s+/, '');\n if (!decisions.some((d) => d.what.includes(commitText.slice(0, 30)))) {\n decisions.push({\n what: commitText,\n why: 'See commit for details',\n });\n }\n }\n }\n\n // Check for a decisions file\n const decisionsFile = join(\n this.projectRoot,\n '.stackmemory',\n 'decisions.md'\n );\n if (existsSync(decisionsFile)) {\n const content = readFileSync(decisionsFile, 'utf-8');\n const parsed = this.parseDecisionsFile(content);\n decisions.push(...parsed);\n }\n\n return decisions.slice(0, 10); // Limit to prevent bloat\n }\n\n /**\n * Parse a decisions.md file\n */\n private parseDecisionsFile(content: string): EnhancedHandoff['decisions'] {\n const decisions: EnhancedHandoff['decisions'] = [];\n const lines = content.split('\\n');\n\n let currentDecision: {\n what: string;\n why: string;\n alternatives?: string[];\n } | null = null;\n\n for (const line of lines) {\n if (line.startsWith('## ') || line.startsWith('### ')) {\n if (currentDecision) {\n decisions.push(currentDecision);\n }\n currentDecision = { what: line.replace(/^#+\\s+/, ''), why: '' };\n } else if (currentDecision && line.toLowerCase().includes('rationale:')) {\n currentDecision.why = line.replace(/rationale:\\s*/i, '').trim();\n } else if (currentDecision && line.toLowerCase().includes('why:')) {\n currentDecision.why = line.replace(/why:\\s*/i, '').trim();\n } else if (\n currentDecision &&\n line.toLowerCase().includes('alternatives:')\n ) {\n currentDecision.alternatives = [];\n } else if (currentDecision?.alternatives && line.trim().startsWith('-')) {\n currentDecision.alternatives.push(line.replace(/^\\s*-\\s*/, '').trim());\n }\n }\n\n if (currentDecision) {\n decisions.push(currentDecision);\n }\n\n return decisions;\n }\n\n /**\n * Extract architecture context from key files\n */\n private async extractArchitecture(): Promise<\n EnhancedHandoff['architecture']\n > {\n const keyComponents: EnhancedHandoff['architecture']['keyComponents'] = [];\n const patterns: string[] = [];\n\n // Find recently modified TypeScript/JavaScript files\n const recentFiles = this.getRecentlyModifiedFiles(20);\n const codeFiles = recentFiles.filter(\n (f) => f.endsWith('.ts') || f.endsWith('.js') || f.endsWith('.tsx')\n );\n\n for (const file of codeFiles.slice(0, 8)) {\n const purpose = this.inferFilePurpose(file);\n if (purpose) {\n keyComponents.push({ file, purpose });\n }\n }\n\n // Detect patterns from file structure\n if (codeFiles.some((f) => f.includes('/daemon/'))) {\n patterns.push('Daemon/background process pattern');\n }\n if (codeFiles.some((f) => f.includes('/cli/'))) {\n patterns.push('CLI command pattern');\n }\n if (\n codeFiles.some((f) => f.includes('.test.') || f.includes('__tests__'))\n ) {\n patterns.push('Test files present');\n }\n if (codeFiles.some((f) => f.includes('/core/'))) {\n patterns.push('Core/domain separation');\n }\n\n return { keyComponents, patterns };\n }\n\n /**\n * Infer purpose from file name and path\n */\n private inferFilePurpose(filePath: string): string | null {\n const name = basename(filePath).replace(/\\.(ts|js|tsx)$/, '');\n const path = filePath.toLowerCase();\n\n if (path.includes('daemon')) return 'Background daemon/service';\n if (path.includes('cli/command')) return 'CLI command handler';\n if (path.includes('config')) return 'Configuration management';\n if (path.includes('storage')) return 'Data storage layer';\n if (path.includes('handoff')) return 'Session handoff logic';\n if (path.includes('service')) return 'Service orchestration';\n if (path.includes('manager')) return 'Resource/state management';\n if (path.includes('handler')) return 'Event/request handler';\n if (path.includes('util') || path.includes('helper'))\n return 'Utility functions';\n if (path.includes('types') || path.includes('interface'))\n return 'Type definitions';\n if (path.includes('test')) return null; // Skip test files\n if (name.includes('-')) {\n return name\n .split('-')\n .map((w) => w.charAt(0).toUpperCase() + w.slice(1))\n .join(' ');\n }\n return null;\n }\n\n /**\n * Extract blockers from git status and recent errors\n */\n private async extractBlockers(): Promise<EnhancedHandoff['blockers']> {\n const blockers: EnhancedHandoff['blockers'] = [];\n\n // Check for merge conflicts\n const gitStatus = this.getGitStatus();\n if (gitStatus.includes('UU ') || gitStatus.includes('both modified')) {\n blockers.push({\n issue: 'Merge conflict detected',\n attempted: ['Check git status for affected files'],\n status: 'open',\n });\n }\n\n // Check for failing tests\n try {\n const testResult = execSync('npm test 2>&1 || true', {\n encoding: 'utf-8',\n cwd: this.projectRoot,\n timeout: 30000,\n });\n if (testResult.includes('FAIL') || testResult.includes('failed')) {\n const failCount = (testResult.match(/(\\d+) failed/i) || ['', '?'])[1];\n blockers.push({\n issue: `Test failures: ${failCount} tests failing`,\n attempted: ['Run npm test for details'],\n status: 'open',\n });\n }\n } catch {\n // Test command failed - might indicate issues\n }\n\n // Check for lint errors\n try {\n const lintResult = execSync('npm run lint 2>&1 || true', {\n encoding: 'utf-8',\n cwd: this.projectRoot,\n timeout: 30000,\n });\n if (lintResult.includes('error') && !lintResult.includes('0 errors')) {\n blockers.push({\n issue: 'Lint errors present',\n attempted: ['Run npm run lint for details'],\n status: 'open',\n });\n }\n } catch {\n // Lint command failed\n }\n\n return blockers;\n }\n\n /**\n * Extract review feedback from agent output files and persisted storage\n */\n private async extractReviewFeedback(): Promise<\n EnhancedHandoff['reviewFeedback']\n > {\n const feedback: EnhancedHandoff['reviewFeedback'] = [];\n const newFeedbacks: StoredReviewFeedback[] = [];\n\n // Find agent output directories dynamically\n const outputDirs = findAgentOutputDirs(this.projectRoot);\n\n for (const tmpDir of outputDirs) {\n if (!existsSync(tmpDir)) continue;\n\n try {\n const files = readdirSync(tmpDir).filter((f) => f.endsWith('.output'));\n const recentFiles = files\n .map((f) => ({\n name: f,\n path: join(tmpDir, f),\n stat: statSync(join(tmpDir, f)),\n }))\n .filter((f) => Date.now() - f.stat.mtimeMs < 3600000) // Last hour\n .sort((a, b) => b.stat.mtimeMs - a.stat.mtimeMs)\n .slice(0, 3);\n\n for (const file of recentFiles) {\n const content = readFileSync(file.path, 'utf-8');\n const extracted = this.extractKeyPointsFromReview(content);\n if (extracted.keyPoints.length > 0) {\n feedback.push(extracted);\n\n // Also store for persistence\n newFeedbacks.push({\n timestamp: new Date().toISOString(),\n source: extracted.source,\n keyPoints: extracted.keyPoints,\n actionItems: extracted.actionItems,\n sourceFile: file.name,\n });\n }\n }\n } catch {\n // Failed to read agent outputs from this directory\n }\n }\n\n // Save new feedback to persistent storage\n if (newFeedbacks.length > 0) {\n saveReviewFeedback(this.projectRoot, newFeedbacks);\n }\n\n // Load persisted feedback if no new feedback found\n if (feedback.length === 0) {\n const stored = loadReviewFeedback(this.projectRoot);\n for (const s of stored.slice(0, 3)) {\n feedback.push({\n source: s.source,\n keyPoints: s.keyPoints,\n actionItems: s.actionItems,\n });\n }\n }\n\n return feedback.length > 0 ? feedback : undefined;\n }\n\n /**\n * Extract key points from a review output\n */\n private extractKeyPointsFromReview(content: string): {\n source: string;\n keyPoints: string[];\n actionItems: string[];\n } {\n const keyPoints: string[] = [];\n const actionItems: string[] = [];\n let source = 'Agent Review';\n\n // Detect review type\n if (\n content.includes('Product Manager') ||\n content.includes('product-manager')\n ) {\n source = 'Product Manager';\n } else if (\n content.includes('Staff Architect') ||\n content.includes('staff-architect')\n ) {\n source = 'Staff Architect';\n }\n\n // Extract key recommendations (look for common patterns)\n const lines = content.split('\\n');\n let inRecommendations = false;\n let inActionItems = false;\n\n for (const line of lines) {\n const trimmed = line.trim();\n\n // Detect section headers\n if (\n trimmed.toLowerCase().includes('recommendation') ||\n trimmed.toLowerCase().includes('key finding')\n ) {\n inRecommendations = true;\n inActionItems = false;\n continue;\n }\n if (\n trimmed.toLowerCase().includes('action') ||\n trimmed.toLowerCase().includes('next step') ||\n trimmed.toLowerCase().includes('priority')\n ) {\n inActionItems = true;\n inRecommendations = false;\n continue;\n }\n\n // Extract bullet points\n if (\n trimmed.startsWith('- ') ||\n trimmed.startsWith('* ') ||\n /^\\d+\\.\\s/.test(trimmed)\n ) {\n const point = trimmed.replace(/^[-*]\\s+/, '').replace(/^\\d+\\.\\s+/, '');\n if (point.length > 10 && point.length < 200) {\n if (inActionItems) {\n actionItems.push(point);\n } else if (inRecommendations) {\n keyPoints.push(point);\n }\n }\n }\n }\n\n // Limit to prevent bloat\n return {\n source,\n keyPoints: keyPoints.slice(0, 5),\n actionItems: actionItems.slice(0, 5),\n };\n }\n\n /**\n * Extract next actions from todo state and git\n */\n private async extractNextActions(): Promise<string[]> {\n const actions: string[] = [];\n\n // Check for uncommitted changes\n const gitStatus = this.getGitStatus();\n if (gitStatus.trim()) {\n actions.push('Commit pending changes');\n }\n\n // Look for TODO comments in recent files\n const recentFiles = this.getRecentlyModifiedFiles(5);\n for (const file of recentFiles) {\n try {\n const fullPath = join(this.projectRoot, file);\n if (existsSync(fullPath)) {\n const content = readFileSync(fullPath, 'utf-8');\n const todos = content.match(/\\/\\/\\s*TODO:?\\s*.+/gi) || [];\n for (const todo of todos.slice(0, 2)) {\n actions.push(todo.replace(/\\/\\/\\s*TODO:?\\s*/i, 'TODO: '));\n }\n }\n } catch {\n // Skip unreadable files\n }\n }\n\n // Check for pending tasks in .stackmemory\n const tasksFile = join(this.projectRoot, '.stackmemory', 'tasks.json');\n if (existsSync(tasksFile)) {\n try {\n const tasks = JSON.parse(readFileSync(tasksFile, 'utf-8'));\n const pending = tasks.filter(\n (t: any) => t.status === 'pending' || t.status === 'in_progress'\n );\n for (const task of pending.slice(0, 3)) {\n actions.push(task.title || task.description);\n }\n } catch {\n // Invalid tasks file\n }\n }\n\n return actions.slice(0, 8);\n }\n\n /**\n * Extract established code patterns\n */\n private async extractCodePatterns(): Promise<string[]> {\n const patterns: string[] = [];\n\n // Check ESLint config for patterns\n const eslintConfig = join(this.projectRoot, 'eslint.config.js');\n if (existsSync(eslintConfig)) {\n const content = readFileSync(eslintConfig, 'utf-8');\n if (content.includes('argsIgnorePattern')) {\n patterns.push('Underscore prefix for unused vars (_var)');\n }\n if (content.includes('ignores') && content.includes('test')) {\n patterns.push('Test files excluded from lint');\n }\n }\n\n // Check tsconfig for patterns\n const tsconfig = join(this.projectRoot, 'tsconfig.json');\n if (existsSync(tsconfig)) {\n const content = readFileSync(tsconfig, 'utf-8');\n if (content.includes('\"strict\": true')) {\n patterns.push('TypeScript strict mode enabled');\n }\n if (content.includes('ES2022') || content.includes('ESNext')) {\n patterns.push('ESM module system');\n }\n }\n\n return patterns;\n }\n\n /**\n * Get recent git commits\n */\n private getRecentCommits(count: number): string[] {\n try {\n const result = execSync(`git log --oneline -${count}`, {\n encoding: 'utf-8',\n cwd: this.projectRoot,\n });\n return result.trim().split('\\n').filter(Boolean);\n } catch {\n return [];\n }\n }\n\n /**\n * Get current git branch\n */\n private getCurrentBranch(): string {\n try {\n return execSync('git rev-parse --abbrev-ref HEAD', {\n encoding: 'utf-8',\n cwd: this.projectRoot,\n }).trim();\n } catch {\n return 'unknown';\n }\n }\n\n /**\n * Get git status\n */\n private getGitStatus(): string {\n try {\n return execSync('git status --short', {\n encoding: 'utf-8',\n cwd: this.projectRoot,\n });\n } catch {\n return '';\n }\n }\n\n /**\n * Get recently modified files\n */\n private getRecentlyModifiedFiles(count: number): string[] {\n try {\n const result = execSync(\n `git diff --name-only HEAD~10 HEAD 2>/dev/null || git diff --name-only`,\n {\n encoding: 'utf-8',\n cwd: this.projectRoot,\n }\n );\n return result.trim().split('\\n').filter(Boolean).slice(0, count);\n } catch {\n return [];\n }\n }\n\n /**\n * Convert handoff to markdown (verbose format)\n */\n toMarkdown(handoff: EnhancedHandoff): string {\n const lines: string[] = [];\n\n lines.push(`# Session Handoff - ${handoff.timestamp.split('T')[0]}`);\n lines.push('');\n lines.push(`**Project**: ${handoff.project}`);\n lines.push(`**Branch**: ${handoff.branch}`);\n lines.push('');\n\n // Active Work (HIGH VALUE)\n lines.push('## Active Work');\n lines.push(`- **Building**: ${handoff.activeWork.description}`);\n lines.push(`- **Status**: ${handoff.activeWork.status}`);\n if (handoff.activeWork.keyFiles.length > 0) {\n lines.push(`- **Key files**: ${handoff.activeWork.keyFiles.join(', ')}`);\n }\n if (handoff.activeWork.progress) {\n lines.push(`- **Progress**: ${handoff.activeWork.progress}`);\n }\n lines.push('');\n\n // Decisions (HIGH VALUE)\n if (handoff.decisions.length > 0) {\n lines.push('## Key Decisions');\n for (const d of handoff.decisions) {\n lines.push(`1. **${d.what}**`);\n if (d.why) {\n lines.push(` - Rationale: ${d.why}`);\n }\n if (d.alternatives && d.alternatives.length > 0) {\n lines.push(\n ` - Alternatives considered: ${d.alternatives.join(', ')}`\n );\n }\n }\n lines.push('');\n }\n\n // Architecture (MEDIUM VALUE)\n if (handoff.architecture.keyComponents.length > 0) {\n lines.push('## Architecture Context');\n for (const c of handoff.architecture.keyComponents) {\n lines.push(`- \\`${c.file}\\`: ${c.purpose}`);\n }\n if (handoff.architecture.patterns.length > 0) {\n lines.push('');\n lines.push('**Patterns**: ' + handoff.architecture.patterns.join(', '));\n }\n lines.push('');\n }\n\n // Blockers (HIGH VALUE)\n if (handoff.blockers.length > 0) {\n lines.push('## Blockers');\n for (const b of handoff.blockers) {\n lines.push(`- **${b.issue}** [${b.status}]`);\n if (b.attempted.length > 0) {\n lines.push(` - Tried: ${b.attempted.join(', ')}`);\n }\n }\n lines.push('');\n }\n\n // Review Feedback (HIGH VALUE)\n if (handoff.reviewFeedback && handoff.reviewFeedback.length > 0) {\n lines.push('## Review Feedback');\n for (const r of handoff.reviewFeedback) {\n lines.push(`### ${r.source}`);\n if (r.keyPoints.length > 0) {\n lines.push('**Key Points**:');\n for (const p of r.keyPoints) {\n lines.push(`- ${p}`);\n }\n }\n if (r.actionItems.length > 0) {\n lines.push('**Action Items**:');\n for (const a of r.actionItems) {\n lines.push(`- ${a}`);\n }\n }\n lines.push('');\n }\n }\n\n // Next Actions (MEDIUM VALUE)\n if (handoff.nextActions.length > 0) {\n lines.push('## Next Actions');\n for (const a of handoff.nextActions) {\n lines.push(`1. ${a}`);\n }\n lines.push('');\n }\n\n // Code Patterns (LOW VALUE)\n if (handoff.codePatterns && handoff.codePatterns.length > 0) {\n lines.push('## Established Patterns');\n for (const p of handoff.codePatterns) {\n lines.push(`- ${p}`);\n }\n lines.push('');\n }\n\n lines.push('---');\n lines.push(`*Estimated tokens: ~${handoff.estimatedTokens}*`);\n lines.push(`*Generated at ${handoff.timestamp}*`);\n\n return lines.join('\\n');\n }\n\n /**\n * Convert handoff to compact format (~50% smaller)\n * Optimized for minimal context window usage\n */\n toCompact(handoff: EnhancedHandoff): string {\n const lines: string[] = [];\n\n // Header: single line\n lines.push(`# Handoff: ${handoff.project}@${handoff.branch}`);\n\n // Active Work: condensed\n const status =\n handoff.activeWork.status === 'in_progress'\n ? 'WIP'\n : handoff.activeWork.status;\n lines.push(`## Work: ${handoff.activeWork.description} [${status}]`);\n if (handoff.activeWork.keyFiles.length > 0) {\n // Use basenames only, limit to 5\n const files = handoff.activeWork.keyFiles\n .slice(0, 5)\n .map((f) => basename(f))\n .join(', ');\n const progress = handoff.activeWork.progress\n ? ` (${handoff.activeWork.progress.replace(' in current session', '')})`\n : '';\n lines.push(`Files: ${files}${progress}`);\n }\n\n // Decisions: single line each with arrow notation\n if (handoff.decisions.length > 0) {\n lines.push('');\n lines.push('## Decisions');\n for (const d of handoff.decisions.slice(0, 7)) {\n // Truncate long decisions\n const what = d.what.length > 40 ? d.what.slice(0, 37) + '...' : d.what;\n const why = d.why ? ` \u2192 ${d.why.slice(0, 50)}` : '';\n lines.push(`- ${what}${why}`);\n }\n }\n\n // Blockers: terse format\n if (handoff.blockers.length > 0) {\n lines.push('');\n lines.push('## Blockers');\n for (const b of handoff.blockers) {\n const status = b.status === 'open' ? '!' : '\u2713';\n const tried = b.attempted.length > 0 ? ` \u2192 ${b.attempted[0]}` : '';\n lines.push(`${status} ${b.issue}${tried}`);\n }\n }\n\n // Review Feedback: only if present, condensed\n if (handoff.reviewFeedback && handoff.reviewFeedback.length > 0) {\n lines.push('');\n lines.push('## Feedback');\n for (const r of handoff.reviewFeedback.slice(0, 2)) {\n lines.push(`[${r.source}]`);\n for (const p of r.keyPoints.slice(0, 3)) {\n lines.push(`- ${p.slice(0, 60)}`);\n }\n for (const a of r.actionItems.slice(0, 2)) {\n lines.push(`\u2192 ${a.slice(0, 60)}`);\n }\n }\n }\n\n // Next Actions: only top 3\n if (handoff.nextActions.length > 0) {\n lines.push('');\n lines.push('## Next');\n for (const a of handoff.nextActions.slice(0, 3)) {\n lines.push(`- ${a.slice(0, 60)}`);\n }\n }\n\n // Skip: Architecture, Patterns (can be inferred from codebase)\n\n // Compact footer\n lines.push('');\n lines.push(`---`);\n lines.push(\n `~${handoff.estimatedTokens} tokens | ${handoff.timestamp.split('T')[0]}`\n );\n\n return lines.join('\\n');\n }\n\n /**\n * Convert handoff to ultra-compact pipe-delimited format (~90% smaller)\n * Optimized for minimal token usage while preserving critical context\n * Target: ~100-150 tokens\n */\n toUltraCompact(handoff: EnhancedHandoff): string {\n const lines: string[] = [];\n\n // Header: [H]project@branch|status|commits\n const status =\n handoff.activeWork.status === 'in_progress'\n ? 'WIP'\n : handoff.activeWork.status;\n const commitCount = handoff.activeWork.progress?.match(/(\\d+)/)?.[1] || '0';\n lines.push(\n `[H]${handoff.project}@${handoff.branch}|${status}|${commitCount}c`\n );\n\n // Files: [F]file1,file2,file3 (basenames only, max 5)\n if (handoff.activeWork.keyFiles.length > 0) {\n const files = handoff.activeWork.keyFiles\n .slice(0, 5)\n .map((f) => basename(f).replace(/\\.(ts|js|tsx|jsx)$/, ''))\n .join(',');\n lines.push(`[F]${files}`);\n }\n\n // Decisions: [D]decision1\u2192why|decision2\u2192why (max 5, truncated)\n if (handoff.decisions.length > 0) {\n const decisions = handoff.decisions\n .slice(0, 5)\n .map((d) => {\n const what = d.what.slice(0, 25).replace(/\\|/g, '/');\n const why = d.why ? `\u2192${d.why.slice(0, 20)}` : '';\n return `${what}${why}`;\n })\n .join('|');\n lines.push(`[D]${decisions}`);\n }\n\n // Blockers: [B]!issue1\u2192tried|!issue2 (! = open, \u2713 = resolved)\n if (handoff.blockers.length > 0) {\n const blockers = handoff.blockers\n .slice(0, 3)\n .map((b) => {\n const marker = b.status === 'open' ? '!' : '\u2713';\n const issue = b.issue.slice(0, 20).replace(/\\|/g, '/');\n const tried =\n b.attempted.length > 0 ? `\u2192${b.attempted[0].slice(0, 15)}` : '';\n return `${marker}${issue}${tried}`;\n })\n .join('|');\n lines.push(`[B]${blockers}`);\n }\n\n // Next actions: [N]action1|action2 (max 3)\n if (handoff.nextActions.length > 0) {\n const actions = handoff.nextActions\n .slice(0, 3)\n .map((a) => a.slice(0, 25).replace(/\\|/g, '/'))\n .join('|');\n lines.push(`[N]${actions}`);\n }\n\n // Footer: ~tokens|date\n const ultraCompactContent = lines.join('\\n');\n const tokens = countTokens(ultraCompactContent);\n lines.push(`~${tokens}t|${handoff.timestamp.split('T')[0]}`);\n\n return lines.join('\\n');\n }\n\n /**\n * Auto-select format based on context budget and content complexity\n * Returns: 'ultra' | 'compact' | 'verbose'\n */\n selectFormat(\n handoff: EnhancedHandoff,\n contextBudget?: number\n ): 'ultra' | 'compact' | 'verbose' {\n // If explicit budget provided, use thresholds\n if (contextBudget !== undefined) {\n if (contextBudget < 500) return 'ultra';\n if (contextBudget < 2000) return 'compact';\n return 'verbose';\n }\n\n // Auto-select based on content complexity\n const complexity =\n handoff.decisions.length +\n handoff.blockers.length +\n (handoff.reviewFeedback?.length || 0) * 2 +\n handoff.nextActions.length;\n\n // Simple sessions: ultra-compact is sufficient\n if (complexity <= 3 && handoff.activeWork.keyFiles.length <= 3) {\n return 'ultra';\n }\n\n // Complex sessions: need more detail\n if (\n complexity > 8 ||\n (handoff.reviewFeedback && handoff.reviewFeedback.length > 1)\n ) {\n return 'verbose';\n }\n\n // Default: compact\n return 'compact';\n }\n\n /**\n * Generate handoff in auto-selected format\n */\n toAutoFormat(handoff: EnhancedHandoff, contextBudget?: number): string {\n const format = this.selectFormat(handoff, contextBudget);\n switch (format) {\n case 'ultra':\n return this.toUltraCompact(handoff);\n case 'verbose':\n return this.toMarkdown(handoff);\n default:\n return this.toCompact(handoff);\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;AAMA,SAAS,gBAAgB;AACzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,UAAU,YAAY;AAC/B,SAAS,SAAS,cAAc;AAChC,SAAS,gBAAgB;AAGzB,IAAI;AACJ,IAAI;AAEF,QAAM,YAAY,MAAM,OAAO,yBAAyB;AACxD,gBAAc,UAAU;AAC1B,QAAQ;AAEN,gBAAc,CAAC,SAAiB,KAAK,KAAK,KAAK,SAAS,GAAG;AAC7D;AA0BA,SAAS,qBAAqB,aAAwC;AACpE,QAAM,YAAY,KAAK,aAAa,gBAAgB,wBAAwB;AAC5E,MAAI,WAAW,SAAS,GAAG;AACzB,QAAI;AACF,YAAM,QAAQ,KAAK,MAAM,aAAa,WAAW,OAAO,CAAC;AACzD,aAAO,MAAM,a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AAO;AAAA,IACT;AAGA,UAAM,aACJ,QAAQ,UAAU,SAClB,QAAQ,SAAS,UAChB,QAAQ,gBAAgB,UAAU,KAAK,IACxC,QAAQ,YAAY;AAGtB,QAAI,cAAc,KAAK,QAAQ,WAAW,SAAS,UAAU,GAAG;AAC9D,aAAO;AAAA,IACT;AAGA,QACE,aAAa,KACZ,QAAQ,kBAAkB,QAAQ,eAAe,SAAS,GAC3D;AACA,aAAO;AAAA,IACT;AAGA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,aAAa,SAA0B,eAAgC;AACrE,UAAM,SAAS,KAAK,aAAa,SAAS,aAAa;AACvD,YAAQ,QAAQ;AAAA,MACd,KAAK;AACH,eAAO,KAAK,eAAe,OAAO;AAAA,MACpC,KAAK;AACH,eAAO,KAAK,WAAW,OAAO;AAAA,MAChC;AACE,eAAO,KAAK,UAAU,OAAO;AAAA,IACjC;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["store", "status"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackmemoryai/stackmemory",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.58",
|
|
4
4
|
"description": "Lossless memory runtime for AI coding tools - organizes context as a call stack instead of linear chat logs, with team collaboration and infinite retention",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=20.0.0",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"bin": {
|
|
12
12
|
"stackmemory": "dist/cli/index.js",
|
|
13
13
|
"codex-sm": "dist/cli/codex-sm.js",
|
|
14
|
+
"codex-smd": "bin/codex-smd",
|
|
14
15
|
"claude-sm": "bin/claude-sm",
|
|
15
16
|
"claude-smd": "bin/claude-smd",
|
|
16
17
|
"opencode-sm": "bin/opencode-sm"
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Create cleanup issues in Linear
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import dotenv from 'dotenv';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import { fileURLToPath } from 'url';
|
|
9
|
+
|
|
10
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
dotenv.config({ path: path.join(__dirname, '..', '.env') });
|
|
12
|
+
|
|
13
|
+
const TEAM_ID = 'STA'; // Stackmemoryai team
|
|
14
|
+
|
|
15
|
+
const cleanupTasks = [
|
|
16
|
+
{
|
|
17
|
+
title: 'Add tests for monitoring module (0% coverage)',
|
|
18
|
+
description: `## Problem
|
|
19
|
+
The \`/src/core/monitoring/\` module has 0% test coverage.
|
|
20
|
+
|
|
21
|
+
## Files affected
|
|
22
|
+
- src/core/monitoring/logger.ts
|
|
23
|
+
- src/core/monitoring/health-check.ts
|
|
24
|
+
- src/core/monitoring/metrics-collector.ts
|
|
25
|
+
- src/core/monitoring/performance-tracker.ts
|
|
26
|
+
- src/core/monitoring/index.ts
|
|
27
|
+
|
|
28
|
+
## Acceptance criteria
|
|
29
|
+
- [ ] Add unit tests for all public functions
|
|
30
|
+
- [ ] Test error handling paths
|
|
31
|
+
- [ ] Achieve >80% coverage`,
|
|
32
|
+
priority: 2, // High
|
|
33
|
+
labels: ['tech-debt', 'testing'],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
title: 'Add tests for performance module (0% coverage)',
|
|
37
|
+
description: `## Problem
|
|
38
|
+
The \`/src/core/performance/\` module has 0% test coverage.
|
|
39
|
+
|
|
40
|
+
## Files affected
|
|
41
|
+
- src/core/performance/profiler.ts
|
|
42
|
+
- src/core/performance/metrics.ts
|
|
43
|
+
- src/core/performance/index.ts
|
|
44
|
+
|
|
45
|
+
## Acceptance criteria
|
|
46
|
+
- [ ] Add unit tests for profiler
|
|
47
|
+
- [ ] Add unit tests for metrics collection
|
|
48
|
+
- [ ] Achieve >80% coverage`,
|
|
49
|
+
priority: 2, // High
|
|
50
|
+
labels: ['tech-debt', 'testing'],
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
title: 'Add tests for session module (0% coverage)',
|
|
54
|
+
description: `## Problem
|
|
55
|
+
The \`/src/core/session/\` module has 0% test coverage.
|
|
56
|
+
|
|
57
|
+
## Files affected
|
|
58
|
+
- src/core/session/session-manager.ts
|
|
59
|
+
- src/core/session/enhanced-handoff.ts
|
|
60
|
+
- src/core/session/index.ts
|
|
61
|
+
|
|
62
|
+
## Acceptance criteria
|
|
63
|
+
- [ ] Add unit tests for session lifecycle
|
|
64
|
+
- [ ] Add unit tests for handoff
|
|
65
|
+
- [ ] Achieve >80% coverage`,
|
|
66
|
+
priority: 2, // High
|
|
67
|
+
labels: ['tech-debt', 'testing'],
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
title: 'Add tests for claude-code integration (7 files, 0% coverage)',
|
|
71
|
+
description: `## Problem
|
|
72
|
+
The \`/src/integrations/claude-code/\` module has no tests.
|
|
73
|
+
|
|
74
|
+
## Files affected
|
|
75
|
+
- src/integrations/claude-code/agent-bridge.ts
|
|
76
|
+
- src/integrations/claude-code/context-injector.ts
|
|
77
|
+
- src/integrations/claude-code/hook-manager.ts
|
|
78
|
+
- src/integrations/claude-code/index.ts
|
|
79
|
+
- src/integrations/claude-code/mcp-client.ts
|
|
80
|
+
- src/integrations/claude-code/session-detector.ts
|
|
81
|
+
- src/integrations/claude-code/types.ts
|
|
82
|
+
|
|
83
|
+
## Acceptance criteria
|
|
84
|
+
- [ ] Add unit tests for all modules
|
|
85
|
+
- [ ] Mock external dependencies
|
|
86
|
+
- [ ] Achieve >80% coverage`,
|
|
87
|
+
priority: 2, // High
|
|
88
|
+
labels: ['tech-debt', 'testing'],
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
title: 'Improve trace module test coverage (9%)',
|
|
92
|
+
description: `## Problem
|
|
93
|
+
The \`/src/core/trace/\` module has only ~9% test coverage.
|
|
94
|
+
|
|
95
|
+
## Files affected (11 files)
|
|
96
|
+
- src/core/trace/trace-detector.ts
|
|
97
|
+
- src/core/trace/trace-bundler.ts
|
|
98
|
+
- src/core/trace/pattern-matcher.ts
|
|
99
|
+
- And 8 more...
|
|
100
|
+
|
|
101
|
+
## Acceptance criteria
|
|
102
|
+
- [ ] Add tests for trace detection
|
|
103
|
+
- [ ] Add tests for pattern matching
|
|
104
|
+
- [ ] Add tests for trace bundling
|
|
105
|
+
- [ ] Achieve >80% coverage`,
|
|
106
|
+
priority: 3, // Medium
|
|
107
|
+
labels: ['tech-debt', 'testing'],
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
title: 'Reorganize scripts directory (112 files)',
|
|
111
|
+
description: `## Problem
|
|
112
|
+
The \`/scripts/\` directory has 112 files with no clear organization.
|
|
113
|
+
|
|
114
|
+
## Proposed structure
|
|
115
|
+
\`\`\`
|
|
116
|
+
scripts/
|
|
117
|
+
setup/ # Installation & configuration
|
|
118
|
+
test/ # Test runners
|
|
119
|
+
cli/ # CLI wrappers
|
|
120
|
+
maintenance/ # Cleanup & sync tasks
|
|
121
|
+
demos/ # Demo & example scripts (DONE)
|
|
122
|
+
archive/ # Archived scripts
|
|
123
|
+
\`\`\`
|
|
124
|
+
|
|
125
|
+
## Acceptance criteria
|
|
126
|
+
- [ ] Create subdirectories
|
|
127
|
+
- [ ] Move scripts to appropriate directories
|
|
128
|
+
- [ ] Update any references in package.json
|
|
129
|
+
- [ ] Update documentation`,
|
|
130
|
+
priority: 4, // Low
|
|
131
|
+
labels: ['tech-debt', 'organization'],
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
title: 'Remove ESLint blanket exclusion of /src/integrations/',
|
|
135
|
+
description: `## Problem
|
|
136
|
+
ESLint config (line 55) excludes entire \`/src/integrations/\` directory from linting.
|
|
137
|
+
|
|
138
|
+
## Impact
|
|
139
|
+
- Potential code quality issues not caught
|
|
140
|
+
- Inconsistent code style
|
|
141
|
+
- 33 warnings not shown
|
|
142
|
+
|
|
143
|
+
## Acceptance criteria
|
|
144
|
+
- [ ] Remove blanket exclusion from eslint.config.js
|
|
145
|
+
- [ ] Fix any lint errors that appear
|
|
146
|
+
- [ ] Keep specific exclusions only if truly needed`,
|
|
147
|
+
priority: 3, // Medium
|
|
148
|
+
labels: ['tech-debt', 'code-quality'],
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
title: 'Resolve service duplication (context-service.ts)',
|
|
152
|
+
description: `## Problem
|
|
153
|
+
\`context-service.ts\` exists in two locations with different implementations:
|
|
154
|
+
- /src/services/context-service.ts
|
|
155
|
+
- /src/daemon/services/context-service.ts
|
|
156
|
+
|
|
157
|
+
## Acceptance criteria
|
|
158
|
+
- [ ] Analyze both implementations
|
|
159
|
+
- [ ] Rename daemon version to DaemonContextService or consolidate
|
|
160
|
+
- [ ] Update all imports
|
|
161
|
+
- [ ] Document the difference if both needed`,
|
|
162
|
+
priority: 3, // Medium
|
|
163
|
+
labels: ['tech-debt', 'organization'],
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
title: 'Rename temporary-named files (refactored-*, enhanced-*)',
|
|
167
|
+
description: `## Problem
|
|
168
|
+
Several files have temporary-sounding names:
|
|
169
|
+
- refactored-frame-manager.ts
|
|
170
|
+
- enhanced-hybrid-digest.ts
|
|
171
|
+
- enhanced-rehydration.ts
|
|
172
|
+
- enhanced-handoff.ts
|
|
173
|
+
|
|
174
|
+
## Acceptance criteria
|
|
175
|
+
- [ ] Rename to final names (remove prefix)
|
|
176
|
+
- [ ] Update all imports
|
|
177
|
+
- [ ] Verify tests pass`,
|
|
178
|
+
priority: 4, // Low
|
|
179
|
+
labels: ['tech-debt', 'naming'],
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
title: 'Add documentation for monitoring, trace, and performance modules',
|
|
183
|
+
description: `## Problem
|
|
184
|
+
Critical modules lack documentation:
|
|
185
|
+
- /src/core/monitoring/ - no docs
|
|
186
|
+
- /src/core/trace/ - demos but no guide
|
|
187
|
+
- /src/core/performance/ - no docs
|
|
188
|
+
|
|
189
|
+
## Acceptance criteria
|
|
190
|
+
- [ ] Add README.md or docs for each module
|
|
191
|
+
- [ ] Document public APIs
|
|
192
|
+
- [ ] Add usage examples`,
|
|
193
|
+
priority: 4, // Low
|
|
194
|
+
labels: ['documentation'],
|
|
195
|
+
},
|
|
196
|
+
];
|
|
197
|
+
|
|
198
|
+
async function queryLinear(query, variables = {}) {
|
|
199
|
+
const apiKey =
|
|
200
|
+
process.env.STACKMEMORY_LINEAR_API_KEY || process.env.LINEAR_API_KEY;
|
|
201
|
+
const response = await fetch('https://api.linear.app/graphql', {
|
|
202
|
+
method: 'POST',
|
|
203
|
+
headers: {
|
|
204
|
+
'Content-Type': 'application/json',
|
|
205
|
+
Authorization: apiKey,
|
|
206
|
+
},
|
|
207
|
+
body: JSON.stringify({ query, variables }),
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
const data = await response.json();
|
|
211
|
+
if (data.errors) {
|
|
212
|
+
throw new Error(data.errors[0].message);
|
|
213
|
+
}
|
|
214
|
+
return data.data;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
async function getTeamId() {
|
|
218
|
+
const teams = await queryLinear(`
|
|
219
|
+
query {
|
|
220
|
+
teams {
|
|
221
|
+
nodes {
|
|
222
|
+
id
|
|
223
|
+
key
|
|
224
|
+
name
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
`);
|
|
229
|
+
|
|
230
|
+
const team = teams.teams.nodes.find((t) => t.key === TEAM_ID);
|
|
231
|
+
if (!team) {
|
|
232
|
+
throw new Error(`Team ${TEAM_ID} not found`);
|
|
233
|
+
}
|
|
234
|
+
return team.id;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
async function createIssue(teamId, task) {
|
|
238
|
+
const mutation = `
|
|
239
|
+
mutation CreateIssue($input: IssueCreateInput!) {
|
|
240
|
+
issueCreate(input: $input) {
|
|
241
|
+
success
|
|
242
|
+
issue {
|
|
243
|
+
id
|
|
244
|
+
identifier
|
|
245
|
+
title
|
|
246
|
+
url
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
`;
|
|
251
|
+
|
|
252
|
+
const result = await queryLinear(mutation, {
|
|
253
|
+
input: {
|
|
254
|
+
teamId,
|
|
255
|
+
title: task.title,
|
|
256
|
+
description: task.description,
|
|
257
|
+
priority: task.priority,
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
return result.issueCreate;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
async function main() {
|
|
265
|
+
const apiKey =
|
|
266
|
+
process.env.STACKMEMORY_LINEAR_API_KEY || process.env.LINEAR_API_KEY;
|
|
267
|
+
if (!apiKey) {
|
|
268
|
+
console.error('❌ LINEAR_API_KEY not set');
|
|
269
|
+
process.exit(1);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
console.log('🔄 Connecting to Linear...');
|
|
273
|
+
|
|
274
|
+
// Verify connection
|
|
275
|
+
const viewer = await queryLinear('{ viewer { name email } }');
|
|
276
|
+
console.log(`✅ Connected as: ${viewer.viewer.name}`);
|
|
277
|
+
|
|
278
|
+
// Get team ID
|
|
279
|
+
const teamId = await getTeamId();
|
|
280
|
+
console.log(`📋 Team: ${TEAM_ID} (${teamId})\n`);
|
|
281
|
+
|
|
282
|
+
// Create issues
|
|
283
|
+
console.log(`Creating ${cleanupTasks.length} cleanup issues...\n`);
|
|
284
|
+
|
|
285
|
+
for (const task of cleanupTasks) {
|
|
286
|
+
try {
|
|
287
|
+
const result = await createIssue(teamId, task);
|
|
288
|
+
if (result.success) {
|
|
289
|
+
console.log(`✅ ${result.issue.identifier}: ${task.title}`);
|
|
290
|
+
console.log(` ${result.issue.url}\n`);
|
|
291
|
+
} else {
|
|
292
|
+
console.log(`❌ Failed: ${task.title}`);
|
|
293
|
+
}
|
|
294
|
+
} catch (error) {
|
|
295
|
+
console.log(`❌ Error creating "${task.title}": ${error.message}`);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
console.log('✅ Done!');
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
main().catch(console.error);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Test Browser MCP integration locally
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { BrowserMCPIntegration } from '../features/browser/browser-mcp.js';
|
|
7
|
+
|
|
8
|
+
async function testBrowserMCP() {
|
|
9
|
+
console.log('Testing Browser MCP Integration...\n');
|
|
10
|
+
|
|
11
|
+
const browser = new BrowserMCPIntegration({
|
|
12
|
+
headless: false, // Show browser for testing
|
|
13
|
+
defaultViewport: { width: 1280, height: 720 },
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
await browser.initialize();
|
|
17
|
+
|
|
18
|
+
console.log('Browser MCP initialized successfully!');
|
|
19
|
+
console.log('\nAvailable tools:');
|
|
20
|
+
console.log(' - browser_navigate');
|
|
21
|
+
console.log(' - browser_screenshot');
|
|
22
|
+
console.log(' - browser_click');
|
|
23
|
+
console.log(' - browser_type');
|
|
24
|
+
console.log(' - browser_evaluate');
|
|
25
|
+
console.log(' - browser_wait');
|
|
26
|
+
console.log(' - browser_get_content');
|
|
27
|
+
console.log(' - browser_close');
|
|
28
|
+
|
|
29
|
+
console.log('\nBrowser MCP is ready to use with StackMemory!');
|
|
30
|
+
|
|
31
|
+
// Clean up
|
|
32
|
+
await browser.cleanup();
|
|
33
|
+
process.exit(0);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
testBrowserMCP().catch((error) => {
|
|
37
|
+
console.error('Browser MCP test failed:', error);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
});
|