@stackmemoryai/stackmemory 0.3.9 → 0.3.11
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/README.md +54 -0
- package/dist/agents/core/agent-task-manager.js +12 -1
- package/dist/agents/core/agent-task-manager.js.map +3 -3
- package/dist/agents/testing-agent.js +610 -0
- package/dist/agents/testing-agent.js.map +7 -0
- package/dist/cli/browser-test.js +4 -4
- package/dist/cli/browser-test.js.map +2 -2
- package/dist/cli/claude-sm.js +2 -2
- package/dist/cli/claude-sm.js.map +2 -2
- package/dist/cli/codex-sm.js +5 -5
- package/dist/cli/codex-sm.js.map +2 -2
- package/dist/cli/commands/agent.js +3 -3
- package/dist/cli/commands/agent.js.map +2 -2
- package/dist/cli/commands/handoff.js +67 -20
- package/dist/cli/commands/handoff.js.map +3 -3
- package/dist/cli/commands/linear-unified.js +3 -3
- package/dist/cli/commands/linear-unified.js.map +2 -2
- package/dist/cli/commands/linear.js +2 -2
- package/dist/cli/commands/linear.js.map +2 -2
- package/dist/cli/commands/onboard.js +3 -3
- package/dist/cli/commands/onboard.js.map +2 -2
- package/dist/cli/commands/quality.js +2 -2
- package/dist/cli/commands/quality.js.map +2 -2
- package/dist/cli/commands/skills.js +113 -28
- package/dist/cli/commands/skills.js.map +2 -2
- package/dist/cli/commands/tasks.js +3 -3
- package/dist/cli/commands/tasks.js.map +2 -2
- package/dist/cli/commands/test.js +282 -0
- package/dist/cli/commands/test.js.map +7 -0
- package/dist/cli/commands/worktree.js +28 -10
- package/dist/cli/commands/worktree.js.map +2 -2
- package/dist/cli/index.js +5 -3
- package/dist/cli/index.js.map +2 -2
- package/dist/cli/utils/viewer.js +9 -9
- package/dist/cli/utils/viewer.js.map +2 -2
- package/dist/core/config/config-manager.js +26 -0
- package/dist/core/config/config-manager.js.map +3 -3
- package/dist/core/context/frame-handoff-manager.js +4 -4
- package/dist/core/context/frame-handoff-manager.js.map +1 -1
- package/dist/core/context/frame-manager.js +139 -0
- package/dist/core/context/frame-manager.js.map +2 -2
- package/dist/core/context/refactored-frame-manager.js +180 -1
- package/dist/core/context/refactored-frame-manager.js.map +2 -2
- package/dist/core/projects/project-isolation.js +197 -0
- package/dist/core/projects/project-isolation.js.map +7 -0
- package/dist/core/trace/debug-trace.js +1 -1
- package/dist/core/trace/debug-trace.js.map +2 -2
- package/dist/core/trace/index.js +4 -4
- package/dist/core/trace/index.js.map +2 -2
- package/dist/core/trace/trace-demo.js +8 -8
- package/dist/core/trace/trace-demo.js.map +2 -2
- package/dist/core/trace/trace-detector.demo.js +5 -5
- package/dist/core/trace/trace-detector.demo.js.map +2 -2
- package/dist/core/utils/update-checker.js +2 -2
- package/dist/core/utils/update-checker.js.map +2 -2
- package/dist/features/analytics/core/analytics-service.js +2 -2
- package/dist/features/analytics/core/analytics-service.js.map +2 -2
- package/dist/features/tasks/linear-task-manager.js +483 -0
- package/dist/features/tasks/linear-task-manager.js.map +7 -0
- package/dist/integrations/claude-code/subagent-client-stub.js +16 -0
- package/dist/integrations/claude-code/subagent-client-stub.js.map +7 -0
- package/dist/integrations/linear/auto-sync.js +2 -2
- package/dist/integrations/linear/auto-sync.js.map +2 -2
- package/dist/integrations/linear/config.js +12 -1
- package/dist/integrations/linear/config.js.map +2 -2
- package/dist/integrations/linear/sync-manager.js.map +1 -1
- package/dist/integrations/linear/sync.js.map +1 -1
- package/dist/integrations/linear/unified-sync.js.map +1 -1
- package/dist/integrations/linear/webhook-handler.js.map +2 -2
- package/dist/integrations/linear/webhook.js.map +2 -2
- package/dist/integrations/mcp/handlers/linear-handlers.js.map +1 -1
- package/dist/integrations/mcp/handlers/task-handlers.js.map +1 -1
- package/dist/integrations/mcp/refactored-server.js +2 -2
- package/dist/integrations/mcp/refactored-server.js.map +2 -2
- package/dist/integrations/mcp/server.js +3 -3
- package/dist/integrations/mcp/server.js.map +2 -2
- package/dist/mcp/stackmemory-mcp-server.js +3 -3
- package/dist/mcp/stackmemory-mcp-server.js.map +2 -2
- package/dist/skills/claude-skills.js +99 -5
- package/dist/skills/claude-skills.js.map +2 -2
- package/dist/skills/recursive-agent-orchestrator.js.map +1 -1
- package/dist/skills/security-secrets-scanner.js +21 -6
- package/dist/skills/security-secrets-scanner.js.map +2 -2
- package/dist/skills/unified-rlm-orchestrator.js +400 -0
- package/dist/skills/unified-rlm-orchestrator.js.map +7 -0
- package/package.json +4 -5
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/commands/handoff.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Handoff command - Commits work and generates a prompt for the next session\n */\n\nimport { Command } from 'commander';\nimport { execSync } from 'child_process';\nimport { existsSync, readFileSync, writeFileSync } from 'fs';\nimport { join } from 'path';\nimport Database from 'better-sqlite3';\nimport { FrameManager } from '../../core/context/frame-manager.js';\nimport { PebblesTaskStore } from '../../features/tasks/pebbles-task-store.js';\nimport { logger } from '../../core/monitoring/logger.js';\n// Type-safe environment variable access\nfunction getEnv(key: string, defaultValue?: string): string {\n const value = process.env[key];\n if (value === undefined) {\n if (defaultValue !== undefined) return defaultValue;\n throw new Error(`Environment variable ${key} is required`);\n }\n return value;\n}\n\nfunction getOptionalEnv(key: string): string | undefined {\n return process.env[key];\n}\n\nexport function createHandoffCommand(): Command {\n const cmd = new Command('handoff');\n\n cmd.description('Session handoff for continuity between Claude sessions');\n\n // Default action - capture handoff\n cmd\n .command('capture', { isDefault: true })\n .description('Commit current work and generate a handoff prompt')\n .option('-m, --message <message>', 'Custom commit message')\n .option('--no-commit', 'Skip git commit')\n .option('--copy', 'Copy the handoff prompt to clipboard')\n .action(async (options) => {\n try {\n const projectRoot = process.cwd();\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n\n // 1. Check git status\n let gitStatus = '';\n let hasChanges = false;\n\n try {\n gitStatus = execSync('git status --short', {\n encoding: 'utf-8',\n cwd: projectRoot,\n });\n hasChanges = gitStatus.trim().length > 0;\n } catch (err: unknown) {\n console.log('\u26A0\uFE0F Not in a git repository');\n }\n\n // 2. Commit if there are changes and not skipped\n if (hasChanges && options.commit !== false) {\n try {\n // Get current branch\n const currentBranch = execSync('git rev-parse --abbrev-ref HEAD', {\n encoding: 'utf-8',\n cwd: projectRoot,\n }).trim();\n\n // Stage all changes\n execSync('git add -A', { cwd: projectRoot });\n\n // Generate or use custom commit message\n const commitMessage =\n options.message ||\n `chore: handoff checkpoint on ${currentBranch}`;\n\n // Commit\n execSync(`git commit -m \"${commitMessage}\"`, { cwd: projectRoot });\n\n console.log(`\u2705 Committed changes: \"${commitMessage}\"`);\n console.log(` Branch: ${currentBranch}`);\n } catch (err: unknown) {\n console.error(\n '\u274C Failed to commit changes:',\n (err as Error).message\n );\n }\n } else if (!hasChanges) {\n console.log('\u2139\uFE0F No changes to commit');\n }\n\n // 3. Gather context for handoff prompt\n let contextSummary = '';\n let tasksSummary = '';\n let recentWork = '';\n\n if (existsSync(dbPath)) {\n const db = new Database(dbPath);\n\n // Get recent context\n const frameManager = new FrameManager(db, 'cli-project');\n const activeFrames = frameManager.getActiveFramePath();\n\n if (activeFrames.length > 0) {\n contextSummary = 'Active context frames:\\n';\n activeFrames.forEach((frame) => {\n contextSummary += ` - ${frame.name} [${frame.type}]\\n`;\n });\n }\n\n // Get task status\n const taskStore = new PebblesTaskStore(projectRoot, db);\n const activeTasks = taskStore.getActiveTasks();\n\n const inProgress = activeTasks.filter(\n (t: any) => t.status === 'in_progress'\n );\n const todo = activeTasks.filter((t: any) => t.status === 'pending');\n const recentlyCompleted = activeTasks\n .filter((t: any) => t.status === 'completed' && t.completed_at)\n .sort(\n (a: any, b: any) => (b.completed_at || 0) - (a.completed_at || 0)\n )\n .slice(0, 3);\n\n if (inProgress.length > 0 || todo.length > 0) {\n tasksSummary = '\\nTasks:\\n';\n\n if (inProgress.length > 0) {\n tasksSummary += 'In Progress:\\n';\n inProgress.forEach((t: any) => {\n const externalId = t.external_refs?.linear?.id;\n tasksSummary += ` - ${t.title}${externalId ? ` [${externalId}]` : ''}\\n`;\n });\n }\n\n if (todo.length > 0) {\n tasksSummary += 'TODO:\\n';\n todo.slice(0, 5).forEach((t: any) => {\n const externalId = t.external_refs?.linear?.id;\n tasksSummary += ` - ${t.title}${externalId ? ` [${externalId}]` : ''}\\n`;\n });\n if (todo.length > 5) {\n tasksSummary += ` ... and ${todo.length - 5} more\\n`;\n }\n }\n }\n\n if (recentlyCompleted.length > 0) {\n recentWork = '\\nRecently Completed:\\n';\n recentlyCompleted.forEach((t: any) => {\n recentWork += ` \u2713 ${t.title}\\n`;\n });\n }\n\n // Get recent events\n const recentEvents = db\n .prepare(\n `\n SELECT event_type as type, payload as data, datetime(ts, 'unixepoch') as time\n FROM events\n ORDER BY ts DESC\n LIMIT 5\n `\n )\n .all() as any[];\n\n if (recentEvents.length > 0) {\n recentWork += '\\nRecent Activity:\\n';\n recentEvents.forEach((event) => {\n const data = JSON.parse(event.data);\n recentWork += ` - ${event.type}: ${data.message || data.name || 'activity'}\\n`;\n });\n }\n\n db.close();\n }\n\n // 4. Get current git info\n let gitInfo = '';\n try {\n const branch = execSync('git rev-parse --abbrev-ref HEAD', {\n encoding: 'utf-8',\n cwd: projectRoot,\n }).trim();\n\n const lastCommit = execSync('git log -1 --oneline', {\n encoding: 'utf-8',\n cwd: projectRoot,\n }).trim();\n\n gitInfo = `\\nGit Status:\\n Branch: ${branch}\\n Last commit: ${lastCommit}\\n`;\n } catch (err: unknown) {\n // Ignore git errors\n }\n\n // 5. Check for any blockers or notes\n let notes = '';\n const notesPath = join(projectRoot, '.stackmemory', 'handoff.md');\n if (existsSync(notesPath)) {\n const handoffNotes = readFileSync(notesPath, 'utf-8');\n if (handoffNotes.trim()) {\n notes = `\\nNotes from previous handoff:\\n${handoffNotes}\\n`;\n }\n }\n\n // 6. Generate the handoff prompt\n const timestamp = new Date().toISOString();\n const handoffPrompt = `# Session Handoff - ${timestamp}\n\n## Project: ${projectRoot.split('/').pop()}\n\n${gitInfo}\n${contextSummary}\n${tasksSummary}\n${recentWork}\n${notes}\n\n## Continue from here:\n\n1. Run \\`stackmemory status\\` to check the current state\n2. Review any in-progress tasks above\n3. Check for any uncommitted changes with \\`git status\\`\n4. Resume work on the active context\n\n## Quick Commands:\n- \\`stackmemory context load --recent\\` - Load recent context\n- \\`stackmemory task list --state in_progress\\` - Show in-progress tasks\n- \\`stackmemory linear sync\\` - Sync with Linear if configured\n- \\`stackmemory log recent\\` - View recent activity\n\n---\nGenerated by stackmemory handoff at ${timestamp}\n`;\n\n // 7. Save handoff prompt\n const handoffPath = join(\n projectRoot,\n '.stackmemory',\n 'last-handoff.md'\n );\n writeFileSync(handoffPath, handoffPrompt);\n\n // 8. Display the prompt\n console.log('\\n' + '='.repeat(60));\n console.log(handoffPrompt);\n console.log('='.repeat(60));\n\n // 9. Copy to clipboard if requested\n if (options.copy) {\n try {\n const copyCommand =\n process.platform === 'darwin'\n ? 'pbcopy'\n : process.platform === 'win32'\n ? 'clip'\n : 'xclip -selection clipboard';\n\n execSync(copyCommand, {\n input: handoffPrompt,\n cwd: projectRoot,\n });\n\n console.log('\\n\u2705 Handoff prompt copied to clipboard!');\n } catch (err: unknown) {\n console.log('\\n\u26A0\uFE0F Could not copy to clipboard');\n }\n }\n\n console.log(`\\n\uD83D\uDCBE Handoff saved to: ${handoffPath}`);\n console.log('\uD83D\uDCCB Use this prompt when starting your next session');\n } catch (error: unknown) {\n logger.error('Handoff command failed', error as Error);\n console.error('\u274C Handoff failed:', (error as Error).message);\n process.exit(1);\n }\n });\n\n // Restore command\n cmd\n .command('restore')\n .description('Restore context from last handoff')\n .option('--no-copy', 'Do not copy prompt to clipboard')\n .action(async (options) => {\n try {\n const projectRoot = process.cwd();\n const handoffPath = join(\n projectRoot,\n '.stackmemory',\n 'last-handoff.md'\n );\n const metaPath = join(\n process.env['HOME'] || '~',\n '.stackmemory',\n 'handoffs',\n 'last-handoff-meta.json'\n );\n\n if (!existsSync(handoffPath)) {\n console.log('\u274C No handoff found in this project');\n console.log('\uD83D\uDCA1 Run \"stackmemory handoff\" to create one');\n return;\n }\n\n // Read handoff prompt\n const handoffPrompt = readFileSync(handoffPath, 'utf-8');\n\n // Display the prompt\n console.log('\\n' + '='.repeat(60));\n console.log('\uD83D\uDCCB RESTORED HANDOFF');\n console.log('='.repeat(60));\n console.log(handoffPrompt);\n console.log('='.repeat(60));\n\n // Check for metadata\n if (existsSync(metaPath)) {\n const metadata = JSON.parse(readFileSync(metaPath, 'utf-8'));\n console.log('\\n\uD83D\uDCCA Session Metadata:');\n console.log(` Timestamp: ${metadata.timestamp}`);\n console.log(` Reason: ${metadata.reason}`);\n console.log(` Duration: ${metadata.session_duration}s`);\n console.log(` Command: ${metadata.command}`);\n }\n\n // Check current git status\n try {\n const gitStatus = execSync('git status --short', {\n encoding: 'utf-8',\n }).trim();\n if (gitStatus) {\n console.log('\\n\u26A0\uFE0F Current uncommitted changes:');\n console.log(gitStatus);\n }\n } catch (err: unknown) {\n // Not a git repo\n }\n\n // Copy to clipboard unless disabled\n if (options.copy !== false) {\n try {\n const copyCommand =\n process.platform === 'darwin'\n ? 'pbcopy'\n : process.platform === 'win32'\n ? 'clip'\n : 'xclip -selection clipboard';\n\n execSync(copyCommand, {\n input: handoffPrompt,\n cwd: projectRoot,\n });\n\n console.log('\\n\u2705 Handoff prompt copied to clipboard!');\n } catch (err: unknown) {\n console.log('\\n\u26A0\uFE0F Could not copy to clipboard');\n }\n }\n\n console.log('\\n\uD83D\uDE80 Ready to continue where you left off!');\n } catch (error: unknown) {\n logger.error('Handoff restore failed', error as Error);\n console.error('\u274C Restore failed:', (error as Error).message);\n process.exit(1);\n }\n });\n\n // Auto command - enable auto-capture\n cmd\n .command('auto')\n .description('Enable auto-capture on session termination')\n .option('--command <command>', 'Command to wrap with auto-handoff')\n .action(async (options) => {\n const scriptPath = join(\n __dirname,\n '..',\n '..',\n '..',\n 'scripts',\n 'stackmemory-auto-handoff.sh'\n );\n\n if (!existsSync(scriptPath)) {\n console.error('\u274C Auto-handoff script not found');\n console.log('\uD83D\uDCE6 Please ensure StackMemory is properly installed');\n return;\n }\n\n console.log('\uD83D\uDEE1\uFE0F StackMemory Auto-Handoff');\n console.log('\u2500'.repeat(50));\n\n if (options.command) {\n // Wrap specific command\n console.log(`Wrapping command: ${options.command}`);\n execSync(`${scriptPath} ${options.command}`, {\n stdio: 'inherit',\n env: { ...process.env, AUTO_CAPTURE_ON_EXIT: 'true' },\n });\n } else {\n // Interactive mode\n console.log('To enable auto-handoff for your current session:');\n console.log('');\n console.log(' For bash/zsh:');\n console.log(` source <(${scriptPath} --shell)`);\n console.log('');\n console.log(' Or wrap a command:');\n console.log(` ${scriptPath} claude`);\n console.log(` ${scriptPath} npm run dev`);\n console.log('');\n console.log(' Add to your shell profile for permanent setup:');\n console.log(\n ` echo 'alias claude=\"${scriptPath} claude\"' >> ~/.bashrc`\n );\n }\n });\n\n return cmd;\n}\n"],
|
|
5
|
-
"mappings": "AAIA,SAAS,eAAe;AACxB,SAAS,
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["/**\n * Handoff command - Commits work and generates a prompt for the next session\n */\n\nimport { Command } from 'commander';\nimport { execSync, execFileSync } from 'child_process';\nimport { existsSync, readFileSync, writeFileSync } from 'fs';\nimport { join } from 'path';\nimport Database from 'better-sqlite3';\nimport shellEscape from 'shell-escape';\nimport { z } from 'zod';\nimport { FrameManager } from '../../core/context/frame-manager.js';\nimport { LinearTaskManager } from '../../features/tasks/linear-task-manager.js';\nimport { logger } from '../../core/monitoring/logger.js';\n\n// Input validation schemas \nconst CommitMessageSchema = z.string()\n .min(1, 'Commit message cannot be empty')\n .max(200, 'Commit message too long')\n .regex(/^[a-zA-Z0-9\\s\\-_.,:()\\/\\[\\]]+$/, 'Commit message contains invalid characters')\n .refine(msg => !msg.includes('\\n'), 'Commit message cannot contain newlines')\n .refine(msg => !msg.includes('\"'), 'Commit message cannot contain double quotes')\n .refine(msg => !msg.includes('`'), 'Commit message cannot contain backticks');\n// Type-safe environment variable access\nfunction getEnv(key: string, defaultValue?: string): string {\n const value = process.env[key];\n if (value === undefined) {\n if (defaultValue !== undefined) return defaultValue;\n throw new Error(`Environment variable ${key} is required`);\n }\n return value;\n}\n\nfunction getOptionalEnv(key: string): string | undefined {\n return process.env[key];\n}\n\nexport function createHandoffCommand(): Command {\n const cmd = new Command('handoff');\n\n cmd.description('Session handoff for continuity between Claude sessions');\n\n // Default action - capture handoff\n cmd\n .command('capture', { isDefault: true })\n .description('Commit current work and generate a handoff prompt')\n .option('-m, --message <message>', 'Custom commit message')\n .option('--no-commit', 'Skip git commit')\n .option('--copy', 'Copy the handoff prompt to clipboard')\n .action(async (options) => {\n try {\n const projectRoot = process.cwd();\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n\n // 1. Check git status\n let gitStatus = '';\n let hasChanges = false;\n\n try {\n gitStatus = execSync('git status --short', {\n encoding: 'utf-8',\n cwd: projectRoot,\n });\n hasChanges = gitStatus.trim().length > 0;\n } catch (err: unknown) {\n console.log('\u26A0\uFE0F Not in a git repository');\n }\n\n // 2. Commit if there are changes and not skipped\n if (hasChanges && options.commit !== false) {\n try {\n // Get current branch\n const currentBranch = execSync('git rev-parse --abbrev-ref HEAD', {\n encoding: 'utf-8',\n cwd: projectRoot,\n }).trim();\n\n // Stage all changes\n execSync('git add -A', { cwd: projectRoot });\n\n // Generate or use custom commit message\n let commitMessage =\n options.message ||\n `chore: handoff checkpoint on ${currentBranch}`;\n \n // Validate commit message\n try {\n commitMessage = CommitMessageSchema.parse(commitMessage);\n } catch (validationError) {\n console.error('\u274C Invalid commit message:', (validationError as Error).message);\n return;\n }\n\n // Commit using execFileSync for safety\n execFileSync('git', ['commit', '-m', commitMessage], { \n cwd: projectRoot,\n stdio: 'inherit'\n });\n\n console.log(`\u2705 Committed changes: \"${commitMessage}\"`);\n console.log(` Branch: ${currentBranch}`);\n } catch (err: unknown) {\n console.error(\n '\u274C Failed to commit changes:',\n (err as Error).message\n );\n }\n } else if (!hasChanges) {\n console.log('\u2139\uFE0F No changes to commit');\n }\n\n // 3. Gather context for handoff prompt\n let contextSummary = '';\n let tasksSummary = '';\n let recentWork = '';\n\n if (existsSync(dbPath)) {\n const db = new Database(dbPath);\n\n // Get recent context\n const frameManager = new FrameManager(db, 'cli-project');\n const activeFrames = frameManager.getActiveFramePath();\n\n if (activeFrames.length > 0) {\n contextSummary = 'Active context frames:\\n';\n activeFrames.forEach((frame) => {\n contextSummary += ` - ${frame.name} [${frame.type}]\\n`;\n });\n }\n\n // Get task status\n const taskStore = new LinearTaskManager(projectRoot, db);\n const activeTasks = taskStore.getActiveTasks();\n\n const inProgress = activeTasks.filter(\n (t: any) => t.status === 'in_progress'\n );\n const todo = activeTasks.filter((t: any) => t.status === 'pending');\n const recentlyCompleted = activeTasks\n .filter((t: any) => t.status === 'completed' && t.completed_at)\n .sort(\n (a: any, b: any) => (b.completed_at || 0) - (a.completed_at || 0)\n )\n .slice(0, 3);\n\n if (inProgress.length > 0 || todo.length > 0) {\n tasksSummary = '\\nTasks:\\n';\n\n if (inProgress.length > 0) {\n tasksSummary += 'In Progress:\\n';\n inProgress.forEach((t: any) => {\n const externalId = t.external_refs?.linear?.id;\n tasksSummary += ` - ${t.title}${externalId ? ` [${externalId}]` : ''}\\n`;\n });\n }\n\n if (todo.length > 0) {\n tasksSummary += 'TODO:\\n';\n todo.slice(0, 5).forEach((t: any) => {\n const externalId = t.external_refs?.linear?.id;\n tasksSummary += ` - ${t.title}${externalId ? ` [${externalId}]` : ''}\\n`;\n });\n if (todo.length > 5) {\n tasksSummary += ` ... and ${todo.length - 5} more\\n`;\n }\n }\n }\n\n if (recentlyCompleted.length > 0) {\n recentWork = '\\nRecently Completed:\\n';\n recentlyCompleted.forEach((t: any) => {\n recentWork += ` \u2713 ${t.title}\\n`;\n });\n }\n\n // Get recent events\n const recentEvents = db\n .prepare(\n `\n SELECT event_type as type, payload as data, datetime(ts, 'unixepoch') as time\n FROM events\n ORDER BY ts DESC\n LIMIT 5\n `\n )\n .all() as any[];\n\n if (recentEvents.length > 0) {\n recentWork += '\\nRecent Activity:\\n';\n recentEvents.forEach((event) => {\n const data = JSON.parse(event.data);\n recentWork += ` - ${event.type}: ${data.message || data.name || 'activity'}\\n`;\n });\n }\n\n db.close();\n }\n\n // 4. Get current git info\n let gitInfo = '';\n try {\n const branch = execSync('git rev-parse --abbrev-ref HEAD', {\n encoding: 'utf-8',\n cwd: projectRoot,\n }).trim();\n\n const lastCommit = execSync('git log -1 --oneline', {\n encoding: 'utf-8',\n cwd: projectRoot,\n }).trim();\n\n gitInfo = `\\nGit Status:\\n Branch: ${branch}\\n Last commit: ${lastCommit}\\n`;\n } catch (err: unknown) {\n // Ignore git errors\n }\n\n // 5. Check for any blockers or notes\n let notes = '';\n const notesPath = join(projectRoot, '.stackmemory', 'handoff.md');\n if (existsSync(notesPath)) {\n const handoffNotes = readFileSync(notesPath, 'utf-8');\n if (handoffNotes.trim()) {\n notes = `\\nNotes from previous handoff:\\n${handoffNotes}\\n`;\n }\n }\n\n // 6. Generate the handoff prompt\n const timestamp = new Date().toISOString();\n const handoffPrompt = `# Session Handoff - ${timestamp}\n\n## Project: ${projectRoot.split('/').pop()}\n\n${gitInfo}\n${contextSummary}\n${tasksSummary}\n${recentWork}\n${notes}\n\n## Continue from here:\n\n1. Run \\`stackmemory status\\` to check the current state\n2. Review any in-progress tasks above\n3. Check for any uncommitted changes with \\`git status\\`\n4. Resume work on the active context\n\n## Quick Commands:\n- \\`stackmemory context load --recent\\` - Load recent context\n- \\`stackmemory task list --state in_progress\\` - Show in-progress tasks\n- \\`stackmemory linear sync\\` - Sync with Linear if configured\n- \\`stackmemory log recent\\` - View recent activity\n\n---\nGenerated by stackmemory handoff at ${timestamp}\n`;\n\n // 7. Save handoff prompt\n const handoffPath = join(\n projectRoot,\n '.stackmemory',\n 'last-handoff.md'\n );\n writeFileSync(handoffPath, handoffPrompt);\n\n // 8. Display the prompt\n console.log('\\n' + '='.repeat(60));\n console.log(handoffPrompt);\n console.log('='.repeat(60));\n\n // 9. Copy to clipboard if requested\n if (options.copy) {\n try {\n // Use execFileSync with predefined commands for safety\n if (process.platform === 'darwin') {\n execFileSync('pbcopy', [], {\n input: handoffPrompt,\n cwd: projectRoot,\n });\n } else if (process.platform === 'win32') {\n execFileSync('clip', [], {\n input: handoffPrompt,\n cwd: projectRoot,\n });\n } else {\n execFileSync('xclip', ['-selection', 'clipboard'], {\n input: handoffPrompt,\n cwd: projectRoot,\n });\n }\n\n console.log('\\n\u2705 Handoff prompt copied to clipboard!');\n } catch (err: unknown) {\n console.log('\\n\u26A0\uFE0F Could not copy to clipboard');\n }\n }\n\n console.log(`\\n\uD83D\uDCBE Handoff saved to: ${handoffPath}`);\n console.log('\uD83D\uDCCB Use this prompt when starting your next session');\n } catch (error: unknown) {\n logger.error('Handoff command failed', error as Error);\n console.error('\u274C Handoff failed:', (error as Error).message);\n process.exit(1);\n }\n });\n\n // Restore command\n cmd\n .command('restore')\n .description('Restore context from last handoff')\n .option('--no-copy', 'Do not copy prompt to clipboard')\n .action(async (options) => {\n try {\n const projectRoot = process.cwd();\n const handoffPath = join(\n projectRoot,\n '.stackmemory',\n 'last-handoff.md'\n );\n const metaPath = join(\n process.env['HOME'] || '~',\n '.stackmemory',\n 'handoffs',\n 'last-handoff-meta.json'\n );\n\n if (!existsSync(handoffPath)) {\n console.log('\u274C No handoff found in this project');\n console.log('\uD83D\uDCA1 Run \"stackmemory handoff\" to create one');\n return;\n }\n\n // Read handoff prompt\n const handoffPrompt = readFileSync(handoffPath, 'utf-8');\n\n // Display the prompt\n console.log('\\n' + '='.repeat(60));\n console.log('\uD83D\uDCCB RESTORED HANDOFF');\n console.log('='.repeat(60));\n console.log(handoffPrompt);\n console.log('='.repeat(60));\n\n // Check for metadata\n if (existsSync(metaPath)) {\n const metadata = JSON.parse(readFileSync(metaPath, 'utf-8'));\n console.log('\\n\uD83D\uDCCA Session Metadata:');\n console.log(` Timestamp: ${metadata.timestamp}`);\n console.log(` Reason: ${metadata.reason}`);\n console.log(` Duration: ${metadata.session_duration}s`);\n console.log(` Command: ${metadata.command}`);\n }\n\n // Check current git status\n try {\n const gitStatus = execSync('git status --short', {\n encoding: 'utf-8',\n }).trim();\n if (gitStatus) {\n console.log('\\n\u26A0\uFE0F Current uncommitted changes:');\n console.log(gitStatus);\n }\n } catch (err: unknown) {\n // Not a git repo\n }\n\n // Copy to clipboard unless disabled\n if (options.copy !== false) {\n try {\n // Use execFileSync with predefined commands for safety\n if (process.platform === 'darwin') {\n execFileSync('pbcopy', [], {\n input: handoffPrompt,\n cwd: projectRoot,\n });\n } else if (process.platform === 'win32') {\n execFileSync('clip', [], {\n input: handoffPrompt,\n cwd: projectRoot,\n });\n } else {\n execFileSync('xclip', ['-selection', 'clipboard'], {\n input: handoffPrompt,\n cwd: projectRoot,\n });\n }\n\n console.log('\\n\u2705 Handoff prompt copied to clipboard!');\n } catch (err: unknown) {\n console.log('\\n\u26A0\uFE0F Could not copy to clipboard');\n }\n }\n\n console.log('\\n\uD83D\uDE80 Ready to continue where you left off!');\n } catch (error: unknown) {\n logger.error('Handoff restore failed', error as Error);\n console.error('\u274C Restore failed:', (error as Error).message);\n process.exit(1);\n }\n });\n\n // Auto command - enable auto-capture\n cmd\n .command('auto')\n .description('Enable auto-capture on session termination')\n .option('--command <command>', 'Command to wrap with auto-handoff')\n .action(async (options) => {\n const scriptPath = join(\n __dirname,\n '..',\n '..',\n '..',\n 'scripts',\n 'stackmemory-auto-handoff.sh'\n );\n\n if (!existsSync(scriptPath)) {\n console.error('\u274C Auto-handoff script not found');\n console.log('\uD83D\uDCE6 Please ensure StackMemory is properly installed');\n return;\n }\n\n console.log('\uD83D\uDEE1\uFE0F StackMemory Auto-Handoff');\n console.log('\u2500'.repeat(50));\n\n if (options.command) {\n // Validate and wrap specific command \n const commandSchema = z.string()\n .min(1, 'Command cannot be empty')\n .max(200, 'Command too long')\n .regex(/^[a-zA-Z0-9\\s\\-_./:]+$/, 'Command contains invalid characters')\n .refine(cmd => !cmd.includes(';'), 'Command cannot contain \";\"')\n .refine(cmd => !cmd.includes('&'), 'Command cannot contain \"&\"')\n .refine(cmd => !cmd.includes('|'), 'Command cannot contain \"|\"')\n .refine(cmd => !cmd.includes('$'), 'Command cannot contain \"$\"')\n .refine(cmd => !cmd.includes('`'), 'Command cannot contain \"`\"');\n \n try {\n const validatedCommand = commandSchema.parse(options.command);\n console.log(`Wrapping command: ${validatedCommand}`);\n execFileSync(scriptPath, [validatedCommand], {\n stdio: 'inherit',\n env: { ...process.env, AUTO_CAPTURE_ON_EXIT: 'true' },\n });\n } catch (validationError) {\n if (validationError instanceof z.ZodError) {\n console.error('\u274C Invalid command:');\n validationError.errors.forEach(err => {\n console.error(` ${err.message}`);\n });\n } else {\n console.error('\u274C Failed to execute command:', (validationError as Error).message);\n }\n return;\n }\n } else {\n // Interactive mode\n console.log('To enable auto-handoff for your current session:');\n console.log('');\n console.log(' For bash/zsh:');\n console.log(` source <(${scriptPath} --shell)`);\n console.log('');\n console.log(' Or wrap a command:');\n console.log(` ${scriptPath} claude`);\n console.log(` ${scriptPath} npm run dev`);\n console.log('');\n console.log(' Add to your shell profile for permanent setup:');\n console.log(\n ` echo 'alias claude=\"${scriptPath} claude\"' >> ~/.bashrc`\n );\n }\n });\n\n return cmd;\n}\n"],
|
|
5
|
+
"mappings": "AAIA,SAAS,eAAe;AACxB,SAAS,UAAU,oBAAoB;AACvC,SAAS,YAAY,cAAc,qBAAqB;AACxD,SAAS,YAAY;AACrB,OAAO,cAAc;AAErB,SAAS,SAAS;AAClB,SAAS,oBAAoB;AAC7B,SAAS,yBAAyB;AAClC,SAAS,cAAc;AAGvB,MAAM,sBAAsB,EAAE,OAAO,EAClC,IAAI,GAAG,gCAAgC,EACvC,IAAI,KAAK,yBAAyB,EAClC,MAAM,kCAAkC,4CAA4C,EACpF,OAAO,SAAO,CAAC,IAAI,SAAS,IAAI,GAAG,wCAAwC,EAC3E,OAAO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AI,EAAE;AACd,cAAQ,IAAI,iBAAiB;AAC7B,cAAQ,IAAI,gBAAgB,UAAU,WAAW;AACjD,cAAQ,IAAI,EAAE;AACd,cAAQ,IAAI,sBAAsB;AAClC,cAAQ,IAAI,OAAO,UAAU,SAAS;AACtC,cAAQ,IAAI,OAAO,UAAU,cAAc;AAC3C,cAAQ,IAAI,EAAE;AACd,cAAQ,IAAI,kDAAkD;AAC9D,cAAQ;AAAA,QACN,2BAA2B,UAAU;AAAA,MACvC;AAAA,IACF;AAAA,EACF,CAAC;AAEH,SAAO;AACT;",
|
|
6
|
+
"names": ["cmd"]
|
|
7
7
|
}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "../../integrations/linear/unified-sync.js";
|
|
5
5
|
import { LinearAuthManager } from "../../integrations/linear/auth.js";
|
|
6
6
|
import { LinearClient } from "../../integrations/linear/client.js";
|
|
7
|
-
import {
|
|
7
|
+
import { LinearTaskManager } from "../../features/tasks/linear-task-manager.js";
|
|
8
8
|
import Database from "better-sqlite3";
|
|
9
9
|
import { join } from "path";
|
|
10
10
|
import { existsSync, readFileSync } from "fs";
|
|
@@ -39,7 +39,7 @@ function registerUnifiedLinearCommands(parent) {
|
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
const db = new Database(dbPath);
|
|
42
|
-
const taskStore = new
|
|
42
|
+
const taskStore = new LinearTaskManager(projectRoot, db);
|
|
43
43
|
const authManager = new LinearAuthManager(projectRoot);
|
|
44
44
|
const config = {
|
|
45
45
|
direction: options.direction,
|
|
@@ -178,7 +178,7 @@ function registerUnifiedLinearCommands(parent) {
|
|
|
178
178
|
console.log(chalk.yellow("Generating task plan..."));
|
|
179
179
|
const dbPath = join(projectRoot, ".stackmemory", "context.db");
|
|
180
180
|
const db = new Database(dbPath);
|
|
181
|
-
const taskStore = new
|
|
181
|
+
const taskStore = new LinearTaskManager(projectRoot, db);
|
|
182
182
|
const authManager = new LinearAuthManager(projectRoot);
|
|
183
183
|
const unifiedSync = new UnifiedLinearSync(
|
|
184
184
|
taskStore,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/commands/linear-unified.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Unified Linear CLI Commands\n * Consolidates all Linear operations into a single, coherent interface\n */\n\nimport { Command } from 'commander';\nimport chalk from 'chalk';\nimport {\n UnifiedLinearSync,\n UnifiedSyncConfig,\n SyncStats,\n DEFAULT_UNIFIED_CONFIG,\n} from '../../integrations/linear/unified-sync.js';\nimport { LinearAuthManager } from '../../integrations/linear/auth.js';\nimport { LinearClient } from '../../integrations/linear/client.js';\nimport { PebblesTaskStore } from '../../features/tasks/pebbles-task-store.js';\nimport Database from 'better-sqlite3';\nimport { join } from 'path';\nimport { existsSync, readFileSync } from 'fs';\nimport { logger } from '../../core/monitoring/logger.js';\nimport Table from 'cli-table3';\nimport ora from 'ora';\n\nexport function registerUnifiedLinearCommands(parent: Command) {\n const linear = parent\n .command('linear')\n .description(\n 'Unified Linear integration with duplicate detection and task planning'\n );\n\n // Main sync command with all features\n linear\n .command('sync')\n .description(\n 'Intelligent sync with Linear (duplicate detection, bidirectional, task planning)'\n )\n .option(\n '-d, --direction <dir>',\n 'Sync direction: bidirectional, to_linear, from_linear',\n 'bidirectional'\n )\n .option('-t, --team <id>', 'Linear team ID')\n .option('--no-duplicates', 'Disable duplicate detection')\n .option(\n '--merge-strategy <strategy>',\n 'Duplicate handling: merge_content, skip, create_anyway',\n 'merge_content'\n )\n .option(\n '--conflict <resolution>',\n 'Conflict resolution: newest_wins, linear_wins, local_wins',\n 'newest_wins'\n )\n .option('--task-plan', 'Enable task planning integration')\n .option('--dry-run', 'Preview changes without syncing')\n .option('--daemon', 'Run as background daemon')\n .option('-i, --interval <minutes>', 'Auto-sync interval', '15')\n .option('--verbose', 'Show detailed sync progress')\n .action(async (options) => {\n const spinner = ora('Initializing Linear sync...').start();\n\n try {\n const projectRoot = process.cwd();\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n\n if (!existsSync(dbPath)) {\n spinner.fail('StackMemory not initialized');\n console.log(chalk.yellow('Run \"stackmemory init\" first'));\n return;\n }\n\n // Initialize components\n const db = new Database(dbPath);\n const taskStore = new PebblesTaskStore(projectRoot, db);\n const authManager = new LinearAuthManager(projectRoot);\n\n // Build config from options\n const config: Partial<UnifiedSyncConfig> = {\n direction: options.direction,\n defaultTeamId: options.team,\n duplicateDetection: options.duplicates !== false,\n mergeStrategy: options.mergeStrategy,\n conflictResolution: options.conflict,\n taskPlanningEnabled: options.taskPlan || false,\n };\n\n // Create unified sync instance\n const unifiedSync = new UnifiedLinearSync(\n taskStore,\n authManager,\n projectRoot,\n config\n );\n\n // Listen to events for progress\n if (options.verbose) {\n unifiedSync.on('sync:started', ({ config }) => {\n spinner.text = `Syncing (${config.direction})...`;\n });\n }\n\n // Initialize\n spinner.text = 'Authenticating with Linear...';\n await unifiedSync.initialize();\n\n if (options.dryRun) {\n spinner.info('Dry run mode - no changes will be made');\n // TODO: Implement dry run preview\n return;\n }\n\n if (options.daemon) {\n // Daemon mode\n spinner.succeed('Starting sync daemon');\n console.log(chalk.cyan(`Sync interval: ${options.interval} minutes`));\n console.log(chalk.gray('Press Ctrl+C to stop\\n'));\n\n // Initial sync\n const stats = await unifiedSync.sync();\n displaySyncStats(stats);\n\n // Schedule periodic syncs\n const interval = setInterval(\n async () => {\n console.log(\n chalk.yellow(\n `\\n[${new Date().toLocaleTimeString()}] Running scheduled sync...`\n )\n );\n try {\n const stats = await unifiedSync.sync();\n displaySyncStats(stats);\n } catch (error: unknown) {\n console.error(\n chalk.red('Sync failed:'),\n (error as Error).message\n );\n }\n },\n parseInt(options.interval) * 60 * 1000\n );\n\n // Handle graceful shutdown\n process.on('SIGINT', () => {\n console.log(chalk.yellow('\\nStopping sync daemon...'));\n clearInterval(interval);\n db.close();\n process.exit(0);\n });\n\n // Keep process alive\n process.stdin.resume();\n } else {\n // Single sync\n spinner.text = 'Syncing tasks...';\n const stats = await unifiedSync.sync();\n\n spinner.succeed('Sync completed');\n displaySyncStats(stats);\n\n // Show task plan if enabled\n if (options.taskPlan) {\n displayTaskPlan(projectRoot);\n }\n\n db.close();\n }\n } catch (error: unknown) {\n spinner.fail('Sync failed');\n console.error(chalk.red('Error:'), (error as Error).message);\n if (options.verbose) {\n console.error(error);\n }\n process.exit(1);\n }\n });\n\n // Quick status command\n linear\n .command('status')\n .description('Show Linear connection status and sync statistics')\n .action(async () => {\n try {\n const authManager = new LinearAuthManager(process.cwd());\n const hasAuth = authManager.isConfigured();\n\n if (!hasAuth && !process.env.LINEAR_API_KEY) {\n console.log(chalk.yellow('\u26A0 Not connected to Linear'));\n console.log('Run \"stackmemory linear auth\" to connect');\n return;\n }\n\n console.log(chalk.green('\u2713 Linear connection configured'));\n\n // Show last sync stats if available\n const statsFile = join(\n process.cwd(),\n '.stackmemory',\n 'sync-stats.json'\n );\n if (existsSync(statsFile)) {\n const stats = JSON.parse(readFileSync(statsFile, 'utf8'));\n console.log(chalk.cyan('\\nLast sync:'));\n console.log(` Time: ${new Date(stats.timestamp).toLocaleString()}`);\n console.log(` Duration: ${stats.duration}ms`);\n console.log(\n ` To Linear: ${stats.toLinear.created} created, ${stats.toLinear.updated} updated`\n );\n console.log(\n ` From Linear: ${stats.fromLinear.created} created, ${stats.fromLinear.updated} updated`\n );\n\n if (stats.toLinear.duplicatesMerged > 0) {\n console.log(\n chalk.green(\n ` Duplicates prevented: ${stats.toLinear.duplicatesMerged}`\n )\n );\n }\n }\n\n // Show task plan status\n const planFile = join(process.cwd(), '.stackmemory', 'task-plan.md');\n if (existsSync(planFile)) {\n console.log(chalk.cyan('\\n\u2713 Task planning enabled'));\n const reportFile = join(\n process.cwd(),\n '.stackmemory',\n 'task-report.md'\n );\n if (existsSync(reportFile)) {\n console.log(` Report: ${reportFile}`);\n }\n }\n } catch (error: unknown) {\n console.error(\n chalk.red('Status check failed:'),\n (error as Error).message\n );\n }\n });\n\n // Task planning command\n linear\n .command('plan')\n .description('View and manage task planning')\n .option('--generate', 'Generate task plan from current tasks')\n .option('--report', 'Show task report')\n .action(async (options) => {\n try {\n const projectRoot = process.cwd();\n\n if (options.generate) {\n console.log(chalk.yellow('Generating task plan...'));\n // Run sync with task planning enabled\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n const db = new Database(dbPath);\n const taskStore = new PebblesTaskStore(projectRoot, db);\n const authManager = new LinearAuthManager(projectRoot);\n\n const unifiedSync = new UnifiedLinearSync(\n taskStore,\n authManager,\n projectRoot,\n {\n taskPlanningEnabled: true,\n autoCreateTaskPlan: true,\n }\n );\n\n await unifiedSync.initialize();\n await unifiedSync.sync();\n\n console.log(chalk.green('\u2713 Task plan generated'));\n db.close();\n }\n\n displayTaskPlan(projectRoot, options.report);\n } catch (error: unknown) {\n console.error(\n chalk.red('Plan generation failed:'),\n (error as Error).message\n );\n }\n });\n\n // Duplicate detection command\n linear\n .command('duplicates')\n .description('Check for and manage duplicate Linear issues')\n .option('--check <title>', 'Check if a title would create a duplicate')\n .option('--merge', 'Merge detected duplicates')\n .option('--list', 'List potential duplicates')\n .action(async (options) => {\n try {\n const authManager = new LinearAuthManager(process.cwd());\n const token = await authManager.getValidToken();\n\n if (!token) {\n console.log(chalk.red('Not authenticated with Linear'));\n return;\n }\n\n const client = new LinearClient({\n apiKey: token,\n useBearer: authManager.isOAuth(),\n });\n\n if (options.check) {\n // Import dynamically to avoid circular dependency\n const { LinearDuplicateDetector } =\n await import('../../integrations/linear/sync-enhanced.js');\n const detector = new LinearDuplicateDetector(client);\n\n console.log(\n chalk.yellow(`Checking for duplicates of: \"${options.check}\"`)\n );\n const result = await detector.checkForDuplicate(options.check);\n\n if (result.isDuplicate && result.existingIssue) {\n console.log(chalk.red('\u26A0 Duplicate detected!'));\n console.log(\n ` Issue: ${result.existingIssue.identifier} - ${result.existingIssue.title}`\n );\n console.log(\n ` Similarity: ${Math.round((result.similarity || 0) * 100)}%`\n );\n console.log(` URL: ${result.existingIssue.url}`);\n } else {\n console.log(chalk.green('\u2713 No duplicates found'));\n }\n } else if (options.list) {\n console.log(chalk.yellow('Scanning for potential duplicates...'));\n // TODO: Implement duplicate scanning\n console.log('Feature coming soon');\n } else {\n console.log('Specify --check, --merge, or --list');\n }\n } catch (error: unknown) {\n console.error(\n chalk.red('Duplicate check failed:'),\n (error as Error).message\n );\n }\n });\n\n // Auth command (simplified)\n linear\n .command('auth')\n .description('Authenticate with Linear')\n .option('--api-key <key>', 'Use API key')\n .option('--oauth', 'Use OAuth flow')\n .action(async (options) => {\n try {\n const authManager = new LinearAuthManager(process.cwd());\n\n if (options.apiKey) {\n // Simple API key setup\n process.env.LINEAR_API_KEY = options.apiKey;\n console.log(chalk.green('\u2713 API key configured'));\n\n // Test connection\n const client = new LinearClient({ apiKey: options.apiKey });\n const user = await client.getViewer();\n console.log(chalk.cyan(`Connected as: ${user.name} (${user.email})`));\n } else {\n console.log(chalk.cyan('Linear Authentication'));\n console.log('\\nOption 1: API Key (Recommended for automation)');\n console.log(' 1. Go to: https://linear.app/settings/api');\n console.log(' 2. Create a personal API key');\n console.log(' 3. Run: stackmemory linear auth --api-key YOUR_KEY');\n console.log('\\nOption 2: OAuth (For user-facing apps)');\n console.log(' Configure OAuth app and use linear-oauth-server');\n }\n } catch (error: unknown) {\n console.error(\n chalk.red('Authentication failed:'),\n (error as Error).message\n );\n }\n });\n}\n\n/**\n * Display sync statistics\n */\nfunction displaySyncStats(stats: SyncStats): void {\n const table = new Table({\n head: ['Direction', 'Created', 'Updated', 'Merged', 'Skipped'],\n style: { head: ['cyan'] },\n });\n\n table.push(\n [\n '\u2192 Linear',\n stats.toLinear.created,\n stats.toLinear.updated,\n stats.toLinear.duplicatesMerged,\n stats.toLinear.skipped,\n ],\n [\n '\u2190 Linear',\n stats.fromLinear.created,\n stats.fromLinear.updated,\n '-',\n stats.fromLinear.skipped,\n ]\n );\n\n console.log('\\n' + table.toString());\n\n if (stats.conflicts.length > 0) {\n console.log(chalk.yellow(`\\n\u26A0 Conflicts: ${stats.conflicts.length}`));\n stats.conflicts.slice(0, 5).forEach((c) => {\n console.log(` - ${c.reason}`);\n });\n }\n\n if (stats.errors.length > 0) {\n console.log(chalk.red(`\\n\u274C Errors: ${stats.errors.length}`));\n stats.errors.slice(0, 5).forEach((e: string) => {\n console.log(` - ${e.substring(0, 100)}`);\n });\n }\n\n console.log(chalk.gray(`\\nCompleted in ${stats.duration}ms`));\n}\n\n/**\n * Display task plan\n */\nfunction displayTaskPlan(projectRoot: string, showReport = false): void {\n const reportFile = join(projectRoot, '.stackmemory', 'task-report.md');\n const planFile = join(projectRoot, '.stackmemory', 'task-plan.json');\n\n if (showReport && existsSync(reportFile)) {\n const report = readFileSync(reportFile, 'utf8');\n console.log('\\n' + report);\n } else if (existsSync(planFile)) {\n const plan = JSON.parse(readFileSync(planFile, 'utf8'));\n\n console.log(chalk.cyan('\\n\uD83D\uDCCB Task Plan Overview'));\n console.log(\n `Last updated: ${new Date(plan.lastUpdated).toLocaleString()}\\n`\n );\n\n plan.phases.forEach((phase) => {\n console.log(chalk.yellow(`${phase.name} (${phase.tasks.length})`));\n console.log(chalk.gray(` ${phase.description}`));\n\n if (phase.tasks.length > 0) {\n phase.tasks.slice(0, 5).forEach((task) => {\n const status = task.linearId ? '\uD83D\uDD17' : ' ';\n console.log(` ${status} ${task.title}`);\n });\n\n if (phase.tasks.length > 5) {\n console.log(chalk.gray(` ...and ${phase.tasks.length - 5} more`));\n }\n }\n console.log();\n });\n } else {\n console.log(\n chalk.yellow('No task plan found. Run sync with --task-plan to generate.')\n );\n }\n}\n"],
|
|
5
|
-
"mappings": "AAMA,OAAO,WAAW;AAClB;AAAA,EACE;AAAA,OAIK;AACP,SAAS,yBAAyB;AAClC,SAAS,oBAAoB;AAC7B,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * Unified Linear CLI Commands\n * Consolidates all Linear operations into a single, coherent interface\n */\n\nimport { Command } from 'commander';\nimport chalk from 'chalk';\nimport {\n UnifiedLinearSync,\n UnifiedSyncConfig,\n SyncStats,\n DEFAULT_UNIFIED_CONFIG,\n} from '../../integrations/linear/unified-sync.js';\nimport { LinearAuthManager } from '../../integrations/linear/auth.js';\nimport { LinearClient } from '../../integrations/linear/client.js';\nimport { LinearTaskManager } from '../../features/tasks/linear-task-manager.js';\nimport Database from 'better-sqlite3';\nimport { join } from 'path';\nimport { existsSync, readFileSync } from 'fs';\nimport { logger } from '../../core/monitoring/logger.js';\nimport Table from 'cli-table3';\nimport ora from 'ora';\n\nexport function registerUnifiedLinearCommands(parent: Command) {\n const linear = parent\n .command('linear')\n .description(\n 'Unified Linear integration with duplicate detection and task planning'\n );\n\n // Main sync command with all features\n linear\n .command('sync')\n .description(\n 'Intelligent sync with Linear (duplicate detection, bidirectional, task planning)'\n )\n .option(\n '-d, --direction <dir>',\n 'Sync direction: bidirectional, to_linear, from_linear',\n 'bidirectional'\n )\n .option('-t, --team <id>', 'Linear team ID')\n .option('--no-duplicates', 'Disable duplicate detection')\n .option(\n '--merge-strategy <strategy>',\n 'Duplicate handling: merge_content, skip, create_anyway',\n 'merge_content'\n )\n .option(\n '--conflict <resolution>',\n 'Conflict resolution: newest_wins, linear_wins, local_wins',\n 'newest_wins'\n )\n .option('--task-plan', 'Enable task planning integration')\n .option('--dry-run', 'Preview changes without syncing')\n .option('--daemon', 'Run as background daemon')\n .option('-i, --interval <minutes>', 'Auto-sync interval', '15')\n .option('--verbose', 'Show detailed sync progress')\n .action(async (options) => {\n const spinner = ora('Initializing Linear sync...').start();\n\n try {\n const projectRoot = process.cwd();\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n\n if (!existsSync(dbPath)) {\n spinner.fail('StackMemory not initialized');\n console.log(chalk.yellow('Run \"stackmemory init\" first'));\n return;\n }\n\n // Initialize components\n const db = new Database(dbPath);\n const taskStore = new LinearTaskManager(projectRoot, db);\n const authManager = new LinearAuthManager(projectRoot);\n\n // Build config from options\n const config: Partial<UnifiedSyncConfig> = {\n direction: options.direction,\n defaultTeamId: options.team,\n duplicateDetection: options.duplicates !== false,\n mergeStrategy: options.mergeStrategy,\n conflictResolution: options.conflict,\n taskPlanningEnabled: options.taskPlan || false,\n };\n\n // Create unified sync instance\n const unifiedSync = new UnifiedLinearSync(\n taskStore,\n authManager,\n projectRoot,\n config\n );\n\n // Listen to events for progress\n if (options.verbose) {\n unifiedSync.on('sync:started', ({ config }) => {\n spinner.text = `Syncing (${config.direction})...`;\n });\n }\n\n // Initialize\n spinner.text = 'Authenticating with Linear...';\n await unifiedSync.initialize();\n\n if (options.dryRun) {\n spinner.info('Dry run mode - no changes will be made');\n // TODO: Implement dry run preview\n return;\n }\n\n if (options.daemon) {\n // Daemon mode\n spinner.succeed('Starting sync daemon');\n console.log(chalk.cyan(`Sync interval: ${options.interval} minutes`));\n console.log(chalk.gray('Press Ctrl+C to stop\\n'));\n\n // Initial sync\n const stats = await unifiedSync.sync();\n displaySyncStats(stats);\n\n // Schedule periodic syncs\n const interval = setInterval(\n async () => {\n console.log(\n chalk.yellow(\n `\\n[${new Date().toLocaleTimeString()}] Running scheduled sync...`\n )\n );\n try {\n const stats = await unifiedSync.sync();\n displaySyncStats(stats);\n } catch (error: unknown) {\n console.error(\n chalk.red('Sync failed:'),\n (error as Error).message\n );\n }\n },\n parseInt(options.interval) * 60 * 1000\n );\n\n // Handle graceful shutdown\n process.on('SIGINT', () => {\n console.log(chalk.yellow('\\nStopping sync daemon...'));\n clearInterval(interval);\n db.close();\n process.exit(0);\n });\n\n // Keep process alive\n process.stdin.resume();\n } else {\n // Single sync\n spinner.text = 'Syncing tasks...';\n const stats = await unifiedSync.sync();\n\n spinner.succeed('Sync completed');\n displaySyncStats(stats);\n\n // Show task plan if enabled\n if (options.taskPlan) {\n displayTaskPlan(projectRoot);\n }\n\n db.close();\n }\n } catch (error: unknown) {\n spinner.fail('Sync failed');\n console.error(chalk.red('Error:'), (error as Error).message);\n if (options.verbose) {\n console.error(error);\n }\n process.exit(1);\n }\n });\n\n // Quick status command\n linear\n .command('status')\n .description('Show Linear connection status and sync statistics')\n .action(async () => {\n try {\n const authManager = new LinearAuthManager(process.cwd());\n const hasAuth = authManager.isConfigured();\n\n if (!hasAuth && !process.env.LINEAR_API_KEY) {\n console.log(chalk.yellow('\u26A0 Not connected to Linear'));\n console.log('Run \"stackmemory linear auth\" to connect');\n return;\n }\n\n console.log(chalk.green('\u2713 Linear connection configured'));\n\n // Show last sync stats if available\n const statsFile = join(\n process.cwd(),\n '.stackmemory',\n 'sync-stats.json'\n );\n if (existsSync(statsFile)) {\n const stats = JSON.parse(readFileSync(statsFile, 'utf8'));\n console.log(chalk.cyan('\\nLast sync:'));\n console.log(` Time: ${new Date(stats.timestamp).toLocaleString()}`);\n console.log(` Duration: ${stats.duration}ms`);\n console.log(\n ` To Linear: ${stats.toLinear.created} created, ${stats.toLinear.updated} updated`\n );\n console.log(\n ` From Linear: ${stats.fromLinear.created} created, ${stats.fromLinear.updated} updated`\n );\n\n if (stats.toLinear.duplicatesMerged > 0) {\n console.log(\n chalk.green(\n ` Duplicates prevented: ${stats.toLinear.duplicatesMerged}`\n )\n );\n }\n }\n\n // Show task plan status\n const planFile = join(process.cwd(), '.stackmemory', 'task-plan.md');\n if (existsSync(planFile)) {\n console.log(chalk.cyan('\\n\u2713 Task planning enabled'));\n const reportFile = join(\n process.cwd(),\n '.stackmemory',\n 'task-report.md'\n );\n if (existsSync(reportFile)) {\n console.log(` Report: ${reportFile}`);\n }\n }\n } catch (error: unknown) {\n console.error(\n chalk.red('Status check failed:'),\n (error as Error).message\n );\n }\n });\n\n // Task planning command\n linear\n .command('plan')\n .description('View and manage task planning')\n .option('--generate', 'Generate task plan from current tasks')\n .option('--report', 'Show task report')\n .action(async (options) => {\n try {\n const projectRoot = process.cwd();\n\n if (options.generate) {\n console.log(chalk.yellow('Generating task plan...'));\n // Run sync with task planning enabled\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n const db = new Database(dbPath);\n const taskStore = new LinearTaskManager(projectRoot, db);\n const authManager = new LinearAuthManager(projectRoot);\n\n const unifiedSync = new UnifiedLinearSync(\n taskStore,\n authManager,\n projectRoot,\n {\n taskPlanningEnabled: true,\n autoCreateTaskPlan: true,\n }\n );\n\n await unifiedSync.initialize();\n await unifiedSync.sync();\n\n console.log(chalk.green('\u2713 Task plan generated'));\n db.close();\n }\n\n displayTaskPlan(projectRoot, options.report);\n } catch (error: unknown) {\n console.error(\n chalk.red('Plan generation failed:'),\n (error as Error).message\n );\n }\n });\n\n // Duplicate detection command\n linear\n .command('duplicates')\n .description('Check for and manage duplicate Linear issues')\n .option('--check <title>', 'Check if a title would create a duplicate')\n .option('--merge', 'Merge detected duplicates')\n .option('--list', 'List potential duplicates')\n .action(async (options) => {\n try {\n const authManager = new LinearAuthManager(process.cwd());\n const token = await authManager.getValidToken();\n\n if (!token) {\n console.log(chalk.red('Not authenticated with Linear'));\n return;\n }\n\n const client = new LinearClient({\n apiKey: token,\n useBearer: authManager.isOAuth(),\n });\n\n if (options.check) {\n // Import dynamically to avoid circular dependency\n const { LinearDuplicateDetector } =\n await import('../../integrations/linear/sync-enhanced.js');\n const detector = new LinearDuplicateDetector(client);\n\n console.log(\n chalk.yellow(`Checking for duplicates of: \"${options.check}\"`)\n );\n const result = await detector.checkForDuplicate(options.check);\n\n if (result.isDuplicate && result.existingIssue) {\n console.log(chalk.red('\u26A0 Duplicate detected!'));\n console.log(\n ` Issue: ${result.existingIssue.identifier} - ${result.existingIssue.title}`\n );\n console.log(\n ` Similarity: ${Math.round((result.similarity || 0) * 100)}%`\n );\n console.log(` URL: ${result.existingIssue.url}`);\n } else {\n console.log(chalk.green('\u2713 No duplicates found'));\n }\n } else if (options.list) {\n console.log(chalk.yellow('Scanning for potential duplicates...'));\n // TODO: Implement duplicate scanning\n console.log('Feature coming soon');\n } else {\n console.log('Specify --check, --merge, or --list');\n }\n } catch (error: unknown) {\n console.error(\n chalk.red('Duplicate check failed:'),\n (error as Error).message\n );\n }\n });\n\n // Auth command (simplified)\n linear\n .command('auth')\n .description('Authenticate with Linear')\n .option('--api-key <key>', 'Use API key')\n .option('--oauth', 'Use OAuth flow')\n .action(async (options) => {\n try {\n const authManager = new LinearAuthManager(process.cwd());\n\n if (options.apiKey) {\n // Simple API key setup\n process.env.LINEAR_API_KEY = options.apiKey;\n console.log(chalk.green('\u2713 API key configured'));\n\n // Test connection\n const client = new LinearClient({ apiKey: options.apiKey });\n const user = await client.getViewer();\n console.log(chalk.cyan(`Connected as: ${user.name} (${user.email})`));\n } else {\n console.log(chalk.cyan('Linear Authentication'));\n console.log('\\nOption 1: API Key (Recommended for automation)');\n console.log(' 1. Go to: https://linear.app/settings/api');\n console.log(' 2. Create a personal API key');\n console.log(' 3. Run: stackmemory linear auth --api-key YOUR_KEY');\n console.log('\\nOption 2: OAuth (For user-facing apps)');\n console.log(' Configure OAuth app and use linear-oauth-server');\n }\n } catch (error: unknown) {\n console.error(\n chalk.red('Authentication failed:'),\n (error as Error).message\n );\n }\n });\n}\n\n/**\n * Display sync statistics\n */\nfunction displaySyncStats(stats: SyncStats): void {\n const table = new Table({\n head: ['Direction', 'Created', 'Updated', 'Merged', 'Skipped'],\n style: { head: ['cyan'] },\n });\n\n table.push(\n [\n '\u2192 Linear',\n stats.toLinear.created,\n stats.toLinear.updated,\n stats.toLinear.duplicatesMerged,\n stats.toLinear.skipped,\n ],\n [\n '\u2190 Linear',\n stats.fromLinear.created,\n stats.fromLinear.updated,\n '-',\n stats.fromLinear.skipped,\n ]\n );\n\n console.log('\\n' + table.toString());\n\n if (stats.conflicts.length > 0) {\n console.log(chalk.yellow(`\\n\u26A0 Conflicts: ${stats.conflicts.length}`));\n stats.conflicts.slice(0, 5).forEach((c) => {\n console.log(` - ${c.reason}`);\n });\n }\n\n if (stats.errors.length > 0) {\n console.log(chalk.red(`\\n\u274C Errors: ${stats.errors.length}`));\n stats.errors.slice(0, 5).forEach((e: string) => {\n console.log(` - ${e.substring(0, 100)}`);\n });\n }\n\n console.log(chalk.gray(`\\nCompleted in ${stats.duration}ms`));\n}\n\n/**\n * Display task plan\n */\nfunction displayTaskPlan(projectRoot: string, showReport = false): void {\n const reportFile = join(projectRoot, '.stackmemory', 'task-report.md');\n const planFile = join(projectRoot, '.stackmemory', 'task-plan.json');\n\n if (showReport && existsSync(reportFile)) {\n const report = readFileSync(reportFile, 'utf8');\n console.log('\\n' + report);\n } else if (existsSync(planFile)) {\n const plan = JSON.parse(readFileSync(planFile, 'utf8'));\n\n console.log(chalk.cyan('\\n\uD83D\uDCCB Task Plan Overview'));\n console.log(\n `Last updated: ${new Date(plan.lastUpdated).toLocaleString()}\\n`\n );\n\n plan.phases.forEach((phase) => {\n console.log(chalk.yellow(`${phase.name} (${phase.tasks.length})`));\n console.log(chalk.gray(` ${phase.description}`));\n\n if (phase.tasks.length > 0) {\n phase.tasks.slice(0, 5).forEach((task) => {\n const status = task.linearId ? '\uD83D\uDD17' : ' ';\n console.log(` ${status} ${task.title}`);\n });\n\n if (phase.tasks.length > 5) {\n console.log(chalk.gray(` ...and ${phase.tasks.length - 5} more`));\n }\n }\n console.log();\n });\n } else {\n console.log(\n chalk.yellow('No task plan found. Run sync with --task-plan to generate.')\n );\n }\n}\n"],
|
|
5
|
+
"mappings": "AAMA,OAAO,WAAW;AAClB;AAAA,EACE;AAAA,OAIK;AACP,SAAS,yBAAyB;AAClC,SAAS,oBAAoB;AAC7B,SAAS,yBAAyB;AAClC,OAAO,cAAc;AACrB,SAAS,YAAY;AACrB,SAAS,YAAY,oBAAoB;AAEzC,OAAO,WAAW;AAClB,OAAO,SAAS;AAET,SAAS,8BAA8B,QAAiB;AAC7D,QAAM,SAAS,OACZ,QAAQ,QAAQ,EAChB;AAAA,IACC;AAAA,EACF;AAGF,SACG,QAAQ,MAAM,EACd;AAAA,IACC;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,EACF,EACC,OAAO,mBAAmB,gBAAgB,EAC1C,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AAI,KAAK,MAAM,MAAM,MAAM,GAAG,CAAC;AACjE,cAAQ,IAAI,MAAM,KAAK,KAAK,MAAM,WAAW,EAAE,CAAC;AAEhD,UAAI,MAAM,MAAM,SAAS,GAAG;AAC1B,cAAM,MAAM,MAAM,GAAG,CAAC,EAAE,QAAQ,CAAC,SAAS;AACxC,gBAAM,SAAS,KAAK,WAAW,cAAO;AACtC,kBAAQ,IAAI,KAAK,MAAM,IAAI,KAAK,KAAK,EAAE;AAAA,QACzC,CAAC;AAED,YAAI,MAAM,MAAM,SAAS,GAAG;AAC1B,kBAAQ,IAAI,MAAM,KAAK,eAAe,MAAM,MAAM,SAAS,CAAC,OAAO,CAAC;AAAA,QACtE;AAAA,MACF;AACA,cAAQ,IAAI;AAAA,IACd,CAAC;AAAA,EACH,OAAO;AACL,YAAQ;AAAA,MACN,MAAM,OAAO,4DAA4D;AAAA,IAC3E;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["config", "stats"]
|
|
7
7
|
}
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
DEFAULT_SYNC_MANAGER_CONFIG
|
|
13
13
|
} from "../../integrations/linear/sync-manager.js";
|
|
14
14
|
import { LinearConfigManager } from "../../integrations/linear/config.js";
|
|
15
|
-
import {
|
|
15
|
+
import { LinearTaskManager } from "../../features/tasks/linear-task-manager.js";
|
|
16
16
|
import { LinearClient } from "../../integrations/linear/client.js";
|
|
17
17
|
import { LinearRestClient } from "../../integrations/linear/rest-client.js";
|
|
18
18
|
import Database from "better-sqlite3";
|
|
@@ -233,7 +233,7 @@ ${displayTasks.length} shown, ${tasks.length} total tasks`
|
|
|
233
233
|
return;
|
|
234
234
|
}
|
|
235
235
|
const db = new Database(dbPath);
|
|
236
|
-
const taskStore = new
|
|
236
|
+
const taskStore = new LinearTaskManager(projectRoot, db);
|
|
237
237
|
const authManager = new LinearAuthManager(projectRoot);
|
|
238
238
|
const config = {
|
|
239
239
|
...DEFAULT_SYNC_CONFIG,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/commands/linear.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Linear integration commands\n */\n\nimport { Command } from 'commander';\nimport chalk from 'chalk';\nimport {\n LinearAuthManager,\n LinearOAuthSetup,\n} from '../../integrations/linear/auth.js';\nimport { LinearOAuthServer } from '../../integrations/linear/oauth-server.js';\nimport {\n LinearSyncEngine,\n DEFAULT_SYNC_CONFIG,\n} from '../../integrations/linear/sync.js';\nimport {\n LinearSyncManager,\n DEFAULT_SYNC_MANAGER_CONFIG,\n} from '../../integrations/linear/sync-manager.js';\nimport { LinearConfigManager } from '../../integrations/linear/config.js';\nimport { PebblesTaskStore } from '../../features/tasks/pebbles-task-store.js';\nimport { LinearClient } from '../../integrations/linear/client.js';\nimport { LinearRestClient } from '../../integrations/linear/rest-client.js';\nimport Database from 'better-sqlite3';\nimport { join } from 'path';\nimport { existsSync, mkdirSync } from 'fs';\nimport { logger } from '../../core/monitoring/logger.js';\nimport Table from 'cli-table3';\nimport { SyncResult } from '../../integrations/linear/sync.js';\n// Type-safe environment variable access\nfunction getEnv(key: string, defaultValue?: string): string {\n const value = process.env[key];\n if (value === undefined) {\n if (defaultValue !== undefined) return defaultValue;\n throw new Error(`Environment variable ${key} is required`);\n }\n return value;\n}\n\nfunction getOptionalEnv(key: string): string | undefined {\n return process.env[key];\n}\n\n/**\n * Display sync result in a formatted way\n */\nfunction displaySyncResult(result: SyncResult) {\n if (result.success) {\n console.log(chalk.green('\u2713 Sync completed successfully'));\n } else {\n console.log(chalk.yellow('\u26A0 Sync completed with issues'));\n }\n\n if (\n result.synced.toLinear > 0 ||\n result.synced.fromLinear > 0 ||\n result.synced.updated > 0\n ) {\n console.log(chalk.cyan(' \uD83D\uDCCA Summary:'));\n if (result.synced.toLinear > 0) {\n console.log(` \u2192 Linear: ${result.synced.toLinear} tasks`);\n }\n if (result.synced.fromLinear > 0) {\n console.log(` \u2190 Linear: ${result.synced.fromLinear} tasks`);\n }\n if (result.synced.updated > 0) {\n console.log(` \u2194 Updated: ${result.synced.updated} tasks`);\n }\n }\n\n if (result.conflicts.length > 0) {\n console.log(chalk.yellow(` \u26A0 Conflicts: ${result.conflicts.length}`));\n result.conflicts.slice(0, 3).forEach((conflict) => {\n console.log(` - ${conflict.reason}`);\n });\n if (result.conflicts.length > 3) {\n console.log(` ... and ${result.conflicts.length - 3} more`);\n }\n }\n\n if (result.errors.length > 0) {\n console.log(chalk.red(` \u274C Errors: ${result.errors.length}`));\n result.errors.slice(0, 3).forEach((error) => {\n console.log(` - ${error.substring(0, 80)}`);\n });\n if (result.errors.length > 3) {\n console.log(` ... and ${result.errors.length - 3} more`);\n }\n }\n}\n\nexport function registerLinearCommands(parent: Command) {\n const linear = parent\n .command('linear')\n .description('Linear API integration commands');\n\n // Quick tasks command using memory cache\n linear\n .command('list')\n .alias('ls')\n .description('List Linear tasks (memory-cached)')\n .option('--limit <n>', 'Number of tasks to show', '20')\n .option(\n '--status <status>',\n 'Filter by status (backlog, started, completed, etc.)'\n )\n .option('--my', 'Show only tasks assigned to me')\n .option('--cache', 'Show cache stats only')\n .option('--refresh', 'Force refresh cache')\n .option('--count', 'Show count by status only')\n .action(async (options) => {\n try {\n const apiKey = process.env['LINEAR_API_KEY'];\n if (!apiKey) {\n console.log(\n chalk.yellow('\u26A0 Set LINEAR_API_KEY environment variable')\n );\n return;\n }\n\n const restClient = new LinearRestClient(apiKey);\n\n // Show cache stats if requested\n if (options.cache) {\n const stats = restClient.getCacheStats();\n console.log(chalk.cyan('\uD83D\uDCCA Cache Stats:'));\n console.log(` Size: ${stats.size} tasks`);\n console.log(` Age: ${Math.round(stats.age / 1000)}s`);\n console.log(` Fresh: ${stats.fresh ? 'yes' : 'no'}`);\n console.log(\n ` Last sync: ${new Date(stats.lastSync).toLocaleString()}`\n );\n return;\n }\n\n // Show counts only\n if (options.count) {\n const counts = await restClient.getTaskCounts();\n console.log(chalk.cyan('\uD83D\uDCCA Task Counts:'));\n Object.entries(counts)\n .sort(([, a], [, b]) => b - a)\n .forEach(([status, count]) => {\n console.log(` ${status}: ${count}`);\n });\n return;\n }\n\n let tasks;\n if (options.my) {\n tasks = await restClient.getMyTasks();\n } else if (options.status) {\n tasks = await restClient.getTasksByStatus(options.status);\n } else {\n tasks = await restClient.getAllTasks(options.refresh);\n }\n\n if (!tasks || tasks.length === 0) {\n console.log(chalk.gray('No tasks found'));\n return;\n }\n\n // Limit results\n const limit = parseInt(options.limit);\n const displayTasks = tasks.slice(0, limit);\n\n console.log(\n chalk.cyan(\n `\\n\uD83D\uDCCB Linear Tasks (${displayTasks.length}/${tasks.length}):`\n )\n );\n\n displayTasks.forEach((task) => {\n const priority = task.priority ? `P${task.priority}` : '';\n const assignee = task.assignee ? ` @${task.assignee.name}` : '';\n const statusColor =\n task.state.type === 'completed'\n ? chalk.green\n : task.state.type === 'started'\n ? chalk.yellow\n : chalk.gray;\n\n console.log(`${chalk.blue(task.identifier)} ${task.title}`);\n console.log(\n chalk.gray(\n ` ${statusColor(task.state.name)} ${priority}${assignee}`\n )\n );\n });\n\n console.log(\n chalk.gray(\n `\\n${displayTasks.length} shown, ${tasks.length} total tasks`\n )\n );\n } catch (error: unknown) {\n console.error(\n chalk.red('Failed to list tasks:'),\n (error as Error).message\n );\n }\n });\n\n // Auth command\n linear\n .command('auth')\n .description('Authenticate with Linear')\n .option('--api-key <key>', 'Use API key instead of OAuth')\n .option('--no-browser', 'Do not open browser automatically')\n .action(async (options) => {\n try {\n if (options.apiKey) {\n // Set API key as environment variable\n process.env['LINEAR_API_KEY'] = options.apiKey;\n console.log(chalk.green('\u2713 Linear API key set'));\n\n // Test the connection\n const client = new LinearClient({ apiKey: options.apiKey });\n const user = await client.getViewer();\n\n if (user) {\n console.log(\n chalk.cyan(`Connected as: ${user.name} (${user.email})`)\n );\n }\n } else {\n // OAuth flow with callback server\n const authManager = new LinearAuthManager(process.cwd());\n\n // Check if client ID and secret are configured\n const clientId = process.env['LINEAR_CLIENT_ID'];\n const clientSecret = process.env['LINEAR_CLIENT_SECRET'];\n\n if (!clientId || !clientSecret) {\n console.log(chalk.yellow('\\n\u26A0 Linear OAuth app not configured'));\n console.log(chalk.cyan('\\n\uD83D\uDCDD Setup Instructions:'));\n console.log(\n ' 1. Create a Linear OAuth app at: https://linear.app/settings/api'\n );\n console.log(\n ' 2. Set redirect URI to: http://localhost:3456/auth/linear/callback'\n );\n console.log(' 3. Copy your Client ID and Client Secret');\n console.log(' 4. Set environment variables:');\n console.log(\n chalk.gray(' export LINEAR_CLIENT_ID=\"your_client_id\"')\n );\n console.log(\n chalk.gray(\n ' export LINEAR_CLIENT_SECRET=\"your_client_secret\"'\n )\n );\n console.log(' 5. Run this command again');\n return;\n }\n\n // Save OAuth config\n authManager.saveConfig({\n clientId,\n clientSecret,\n redirectUri: 'http://localhost:3456/auth/linear/callback',\n scopes: ['read', 'write', 'admin'],\n });\n\n // Start OAuth server\n const oauthServer = new LinearOAuthServer(process.cwd());\n const { url } = await oauthServer.start();\n\n // Open browser if not disabled\n if (options.browser !== false) {\n const open = (await import('open')).default;\n await open(url);\n console.log(\n chalk.green('\\n\u2713 Browser opened with authorization page')\n );\n } else {\n console.log(chalk.cyan('\\n\uD83D\uDD17 Open this URL in your browser:'));\n console.log(chalk.underline(url));\n }\n\n console.log(chalk.gray('\\nWaiting for authorization...'));\n console.log(\n chalk.gray(\n 'The server will automatically shut down after authorization.'\n )\n );\n }\n } catch (error: unknown) {\n console.error(\n chalk.red('Authentication failed:'),\n (error as Error).message\n );\n process.exit(1);\n }\n });\n\n // Sync command\n linear\n .command('sync')\n .description('Sync tasks with Linear')\n .option(\n '-d, --direction <dir>',\n 'Sync direction: bidirectional, to_linear, from_linear',\n 'bidirectional'\n )\n .option('-t, --team <id>', 'Default Linear team ID')\n .option('--dry-run', 'Preview sync without making changes')\n .option('--daemon', 'Run in daemon mode with periodic sync')\n .option(\n '-i, --interval <minutes>',\n 'Sync interval in minutes (default: 15)'\n )\n .action(async (options) => {\n try {\n const projectRoot = process.cwd();\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n\n if (!existsSync(dbPath)) {\n console.log(chalk.red('\u274C StackMemory not initialized'));\n return;\n }\n\n const db = new Database(dbPath);\n const taskStore = new PebblesTaskStore(projectRoot, db);\n const authManager = new LinearAuthManager(projectRoot);\n\n const config = {\n ...DEFAULT_SYNC_CONFIG,\n direction: options.direction,\n defaultTeamId: options.team,\n enabled: true,\n };\n\n if (options.daemon) {\n // Run in daemon mode with periodic sync\n const managerConfig = {\n ...DEFAULT_SYNC_MANAGER_CONFIG,\n ...config,\n autoSyncInterval: parseInt(options.interval) || 15,\n };\n\n const syncManager = new LinearSyncManager(\n taskStore,\n authManager,\n managerConfig,\n projectRoot\n );\n\n console.log(chalk.green('\uD83D\uDE80 Starting Linear sync daemon'));\n console.log(\n chalk.cyan(\n ` Sync interval: ${managerConfig.autoSyncInterval} minutes`\n )\n );\n console.log(chalk.cyan(` Direction: ${managerConfig.direction}`));\n console.log(chalk.gray(' Press Ctrl+C to stop\\n'));\n\n // Initial sync\n const initialResult = await syncManager.syncOnStart();\n if (initialResult) {\n displaySyncResult(initialResult);\n }\n\n // Listen for sync events\n syncManager.on('sync:started', ({ trigger }) => {\n console.log(\n chalk.yellow(\n `\\n\uD83D\uDD04 ${new Date().toLocaleTimeString()} - Starting ${trigger} sync...`\n )\n );\n });\n\n syncManager.on('sync:completed', ({ result }) => {\n displaySyncResult(result);\n });\n\n syncManager.on('sync:failed', ({ result }) => {\n console.log(chalk.red('\u274C Sync failed'));\n if (result.errors.length > 0) {\n result.errors.forEach((error: string) => {\n console.log(chalk.red(` - ${error}`));\n });\n }\n });\n\n // Handle graceful shutdown\n process.on('SIGINT', async () => {\n console.log(chalk.yellow('\\n\u23F9 Stopping sync daemon...'));\n await syncManager.syncOnEnd();\n syncManager.stop();\n db.close();\n process.exit(0);\n });\n\n // Keep process alive\n process.stdin.resume();\n } else {\n // Single sync\n const syncEngine = new LinearSyncEngine(\n taskStore,\n authManager,\n config\n );\n\n console.log(chalk.yellow('\uD83D\uDD04 Syncing with Linear...'));\n\n if (options.dryRun) {\n console.log(chalk.gray('(Dry run - no changes will be made)'));\n }\n\n const result = await syncEngine.sync();\n displaySyncResult(result);\n db.close();\n }\n } catch (error: unknown) {\n logger.error('Sync failed', error as Error);\n console.error(chalk.red('Sync failed:'), (error as Error).message);\n process.exit(1);\n }\n });\n\n // Status command\n linear\n .command('status')\n .description('Show Linear sync status')\n .action(async () => {\n try {\n const authManager = new LinearAuthManager(process.cwd());\n const tokens = authManager.loadTokens();\n const apiKey = process.env['LINEAR_API_KEY'];\n\n if (!tokens && !apiKey) {\n console.log(chalk.yellow('\u26A0 Not authenticated with Linear'));\n console.log('Run \"stackmemory linear auth\" to connect');\n return;\n }\n\n const client = apiKey\n ? new LinearClient({ apiKey })\n : new LinearClient({\n apiKey: tokens!.accessToken,\n useBearer: true,\n onUnauthorized: async () => {\n const refreshed = await authManager.refreshAccessToken();\n return refreshed.accessToken;\n },\n });\n\n const user = await client.getViewer();\n\n if (user) {\n console.log(chalk.green('\u2713 Connected to Linear'));\n console.log(chalk.cyan(` User: ${user.name} (${user.email})`));\n\n // Show teams\n const teams = await client.getTeams();\n if (teams && teams.length > 0) {\n console.log(chalk.cyan('\\n\uD83D\uDCCB Teams:'));\n teams.forEach((team) => {\n console.log(` - ${team.name} (${team.key})`);\n });\n }\n } else {\n console.log(chalk.red('\u274C Could not connect to Linear'));\n }\n } catch (error: unknown) {\n console.error(\n chalk.red('Status check failed:'),\n (error as Error).message\n );\n }\n });\n\n // List tasks command\n linear\n .command('tasks')\n .description('List Linear tasks')\n .option('--limit <n>', 'Number of tasks to show', '50')\n .option(\n '--status <status>',\n 'Filter by status (backlog, started, completed, etc.)'\n )\n .option('--my', 'Show only tasks assigned to me')\n .option('--cache', 'Show cache stats')\n .option('--refresh', 'Force refresh cache')\n .action(async (options) => {\n try {\n const apiKey = process.env['LINEAR_API_KEY'];\n if (!apiKey) {\n console.log(\n chalk.yellow('\u26A0 Set LINEAR_API_KEY environment variable')\n );\n return;\n }\n\n const restClient = new LinearRestClient(apiKey);\n\n // Show cache stats if requested\n if (options.cache) {\n const stats = restClient.getCacheStats();\n console.log(chalk.cyan('\uD83D\uDCCA Cache Stats:'));\n console.log(` Size: ${stats.size} tasks`);\n console.log(` Age: ${Math.round(stats.age / 1000)}s`);\n console.log(` Fresh: ${stats.fresh ? 'yes' : 'no'}`);\n console.log(\n ` Last sync: ${new Date(stats.lastSync).toLocaleString()}`\n );\n return;\n }\n\n let tasks;\n if (options.my) {\n tasks = await restClient.getMyTasks();\n } else if (options.status) {\n tasks = await restClient.getTasksByStatus(options.status);\n } else {\n tasks = await restClient.getAllTasks(options.refresh);\n }\n\n if (!tasks || tasks.length === 0) {\n console.log(chalk.gray('No tasks found'));\n return;\n }\n\n // Limit results\n const limit = parseInt(options.limit);\n const displayTasks = tasks.slice(0, limit);\n\n const table = new Table({\n head: ['ID', 'Title', 'State', 'Priority', 'Assignee'],\n style: { head: ['cyan'] },\n });\n\n displayTasks.forEach((task) => {\n table.push([\n task.identifier,\n task.title.substring(0, 40) + (task.title.length > 40 ? '...' : ''),\n task.state?.name || '-',\n task.priority ? `P${task.priority}` : '-',\n task.assignee?.name || '-',\n ]);\n });\n\n console.log(table.toString());\n\n // Show counts by status\n const counts = await restClient.getTaskCounts();\n console.log(chalk.cyan('\\n\uD83D\uDCCA Task Summary:'));\n Object.entries(counts).forEach(([status, count]) => {\n console.log(` ${status}: ${count}`);\n });\n\n console.log(\n chalk.gray(\n `\\nShowing ${displayTasks.length} of ${tasks.length} total tasks`\n )\n );\n\n const cacheStats = restClient.getCacheStats();\n console.log(\n chalk.gray(\n `Cache: ${cacheStats.size} tasks, age: ${Math.round(cacheStats.age / 1000)}s`\n )\n );\n } catch (error: unknown) {\n console.error(\n chalk.red('Failed to list tasks:'),\n (error as Error).message\n );\n }\n });\n\n // Update command - update Linear task status\n linear\n .command('update <issueId>')\n .description('Update Linear task status')\n .option(\n '-s, --status <status>',\n 'New status (todo, in-progress, done, canceled)'\n )\n .option('-t, --title <title>', 'Update task title')\n .option('-d, --description <desc>', 'Update task description')\n .option(\n '-p, --priority <priority>',\n 'Set priority (1=urgent, 2=high, 3=medium, 4=low)'\n )\n .action(async (issueId, options) => {\n try {\n const authManager = new LinearAuthManager(process.cwd());\n const tokens = authManager.loadTokens();\n\n if (!tokens) {\n console.error(\n chalk.red('Not authenticated. Run: stackmemory linear auth')\n );\n return;\n }\n\n const client = new LinearClient({\n apiKey: tokens.accessToken,\n });\n\n // Find the issue first\n let issue = await client.getIssue(issueId);\n if (!issue) {\n // Try finding by identifier\n issue = await client.findIssueByIdentifier(issueId);\n }\n\n if (!issue) {\n console.error(chalk.red(`Issue ${issueId} not found`));\n return;\n }\n\n const updates: any = {};\n\n // Handle status update\n if (options.status) {\n const team = await client.getTeam();\n const states = await client.getWorkflowStates(team.id);\n\n const statusMap: Record<string, string> = {\n todo: 'unstarted',\n 'in-progress': 'started',\n done: 'completed',\n canceled: 'cancelled',\n };\n\n const targetType =\n statusMap[options.status.toLowerCase()] || options.status;\n const targetState = states.find((s) => s.type === targetType);\n\n if (!targetState) {\n console.error(chalk.red(`Invalid status: ${options.status}`));\n console.log(chalk.gray('Available states:'));\n states.forEach((s) =>\n console.log(chalk.gray(` - ${s.name} (${s.type})`))\n );\n return;\n }\n\n updates.stateId = targetState.id;\n }\n\n if (options.title) updates.title = options.title;\n if (options.description) updates.description = options.description;\n if (options.priority) updates.priority = parseInt(options.priority);\n\n // Perform update\n const updatedIssue = await client.updateIssue(issue.id, updates);\n\n console.log(\n chalk.green(\n `\u2713 Updated ${updatedIssue.identifier}: ${updatedIssue.title}`\n )\n );\n if (options.status) {\n console.log(chalk.cyan(` Status: ${updatedIssue.state.name}`));\n }\n console.log(chalk.gray(` ${updatedIssue.url}`));\n } catch (error: unknown) {\n console.error(\n chalk.red('Failed to update task:'),\n (error as Error).message\n );\n }\n });\n\n // Config command\n linear\n .command('config')\n .description('Configure Linear sync settings')\n .option('--team <id>', 'Set default team ID')\n .option('--interval <minutes>', 'Auto-sync interval in minutes')\n .option('--direction <dir>', 'Sync direction')\n .option('--conflict <strategy>', 'Conflict resolution strategy')\n .action(async (options) => {\n try {\n const configManager = new LinearConfigManager(process.cwd());\n const config =\n configManager.loadConfig() || configManager.getDefaultConfig();\n\n let updated = false;\n\n if (options.team) {\n // Team ID would need to be stored separately or in a different config\n logger.info('Team ID configuration not yet implemented', {\n teamId: options.team,\n });\n }\n\n if (options.interval) {\n config.interval = parseInt(options.interval);\n updated = true;\n }\n\n if (options.direction) {\n config.direction = options.direction;\n updated = true;\n }\n\n if (options.conflict) {\n config.conflictResolution = options.conflict;\n updated = true;\n }\n\n if (updated) {\n configManager.saveConfig(config);\n console.log(chalk.green('\u2713 Configuration updated'));\n }\n\n // Display current config\n console.log(chalk.cyan('\\n\uD83D\uDCCB Current Configuration:'));\n console.log(` Enabled: ${config.enabled ? 'yes' : 'no'}`);\n console.log(` Interval: ${config.interval} minutes`);\n console.log(` Direction: ${config.direction}`);\n console.log(` Conflicts: ${config.conflictResolution}`);\n } catch (error: unknown) {\n console.error(chalk.red('Config failed:'), (error as Error).message);\n }\n });\n}\n"],
|
|
5
|
-
"mappings": "AAKA,OAAO,WAAW;AAClB;AAAA,EACE;AAAA,OAEK;AACP,SAAS,yBAAyB;AAClC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,2BAA2B;AACpC,SAAS,wBAAwB;AACjC,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AACjC,OAAO,cAAc;AACrB,SAAS,YAAY;AACrB,SAAS,kBAA6B;AACtC,SAAS,cAAc;AACvB,OAAO,WAAW;AAGlB,SAAS,OAAO,KAAa,cAA+B;AAC1D,QAAM,QAAQ,QAAQ,IAAI,GAAG;AAC7B,MAAI,UAAU,QAA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AO,kBAAkB,EAAE;AAAA,IACzD,SAAS,OAAgB;AACvB,cAAQ,MAAM,MAAM,IAAI,gBAAgB,GAAI,MAAgB,OAAO;AAAA,IACrE;AAAA,EACF,CAAC;AACL;",
|
|
4
|
+
"sourcesContent": ["/**\n * Linear integration commands\n */\n\nimport { Command } from 'commander';\nimport chalk from 'chalk';\nimport {\n LinearAuthManager,\n LinearOAuthSetup,\n} from '../../integrations/linear/auth.js';\nimport { LinearOAuthServer } from '../../integrations/linear/oauth-server.js';\nimport {\n LinearSyncEngine,\n DEFAULT_SYNC_CONFIG,\n} from '../../integrations/linear/sync.js';\nimport {\n LinearSyncManager,\n DEFAULT_SYNC_MANAGER_CONFIG,\n} from '../../integrations/linear/sync-manager.js';\nimport { LinearConfigManager } from '../../integrations/linear/config.js';\nimport { LinearTaskManager } from '../../features/tasks/linear-task-manager.js';\nimport { LinearClient } from '../../integrations/linear/client.js';\nimport { LinearRestClient } from '../../integrations/linear/rest-client.js';\nimport Database from 'better-sqlite3';\nimport { join } from 'path';\nimport { existsSync, mkdirSync } from 'fs';\nimport { logger } from '../../core/monitoring/logger.js';\nimport Table from 'cli-table3';\nimport { SyncResult } from '../../integrations/linear/sync.js';\n// Type-safe environment variable access\nfunction getEnv(key: string, defaultValue?: string): string {\n const value = process.env[key];\n if (value === undefined) {\n if (defaultValue !== undefined) return defaultValue;\n throw new Error(`Environment variable ${key} is required`);\n }\n return value;\n}\n\nfunction getOptionalEnv(key: string): string | undefined {\n return process.env[key];\n}\n\n/**\n * Display sync result in a formatted way\n */\nfunction displaySyncResult(result: SyncResult) {\n if (result.success) {\n console.log(chalk.green('\u2713 Sync completed successfully'));\n } else {\n console.log(chalk.yellow('\u26A0 Sync completed with issues'));\n }\n\n if (\n result.synced.toLinear > 0 ||\n result.synced.fromLinear > 0 ||\n result.synced.updated > 0\n ) {\n console.log(chalk.cyan(' \uD83D\uDCCA Summary:'));\n if (result.synced.toLinear > 0) {\n console.log(` \u2192 Linear: ${result.synced.toLinear} tasks`);\n }\n if (result.synced.fromLinear > 0) {\n console.log(` \u2190 Linear: ${result.synced.fromLinear} tasks`);\n }\n if (result.synced.updated > 0) {\n console.log(` \u2194 Updated: ${result.synced.updated} tasks`);\n }\n }\n\n if (result.conflicts.length > 0) {\n console.log(chalk.yellow(` \u26A0 Conflicts: ${result.conflicts.length}`));\n result.conflicts.slice(0, 3).forEach((conflict) => {\n console.log(` - ${conflict.reason}`);\n });\n if (result.conflicts.length > 3) {\n console.log(` ... and ${result.conflicts.length - 3} more`);\n }\n }\n\n if (result.errors.length > 0) {\n console.log(chalk.red(` \u274C Errors: ${result.errors.length}`));\n result.errors.slice(0, 3).forEach((error) => {\n console.log(` - ${error.substring(0, 80)}`);\n });\n if (result.errors.length > 3) {\n console.log(` ... and ${result.errors.length - 3} more`);\n }\n }\n}\n\nexport function registerLinearCommands(parent: Command) {\n const linear = parent\n .command('linear')\n .description('Linear API integration commands');\n\n // Quick tasks command using memory cache\n linear\n .command('list')\n .alias('ls')\n .description('List Linear tasks (memory-cached)')\n .option('--limit <n>', 'Number of tasks to show', '20')\n .option(\n '--status <status>',\n 'Filter by status (backlog, started, completed, etc.)'\n )\n .option('--my', 'Show only tasks assigned to me')\n .option('--cache', 'Show cache stats only')\n .option('--refresh', 'Force refresh cache')\n .option('--count', 'Show count by status only')\n .action(async (options) => {\n try {\n const apiKey = process.env['LINEAR_API_KEY'];\n if (!apiKey) {\n console.log(\n chalk.yellow('\u26A0 Set LINEAR_API_KEY environment variable')\n );\n return;\n }\n\n const restClient = new LinearRestClient(apiKey);\n\n // Show cache stats if requested\n if (options.cache) {\n const stats = restClient.getCacheStats();\n console.log(chalk.cyan('\uD83D\uDCCA Cache Stats:'));\n console.log(` Size: ${stats.size} tasks`);\n console.log(` Age: ${Math.round(stats.age / 1000)}s`);\n console.log(` Fresh: ${stats.fresh ? 'yes' : 'no'}`);\n console.log(\n ` Last sync: ${new Date(stats.lastSync).toLocaleString()}`\n );\n return;\n }\n\n // Show counts only\n if (options.count) {\n const counts = await restClient.getTaskCounts();\n console.log(chalk.cyan('\uD83D\uDCCA Task Counts:'));\n Object.entries(counts)\n .sort(([, a], [, b]) => b - a)\n .forEach(([status, count]) => {\n console.log(` ${status}: ${count}`);\n });\n return;\n }\n\n let tasks;\n if (options.my) {\n tasks = await restClient.getMyTasks();\n } else if (options.status) {\n tasks = await restClient.getTasksByStatus(options.status);\n } else {\n tasks = await restClient.getAllTasks(options.refresh);\n }\n\n if (!tasks || tasks.length === 0) {\n console.log(chalk.gray('No tasks found'));\n return;\n }\n\n // Limit results\n const limit = parseInt(options.limit);\n const displayTasks = tasks.slice(0, limit);\n\n console.log(\n chalk.cyan(\n `\\n\uD83D\uDCCB Linear Tasks (${displayTasks.length}/${tasks.length}):`\n )\n );\n\n displayTasks.forEach((task) => {\n const priority = task.priority ? `P${task.priority}` : '';\n const assignee = task.assignee ? ` @${task.assignee.name}` : '';\n const statusColor =\n task.state.type === 'completed'\n ? chalk.green\n : task.state.type === 'started'\n ? chalk.yellow\n : chalk.gray;\n\n console.log(`${chalk.blue(task.identifier)} ${task.title}`);\n console.log(\n chalk.gray(\n ` ${statusColor(task.state.name)} ${priority}${assignee}`\n )\n );\n });\n\n console.log(\n chalk.gray(\n `\\n${displayTasks.length} shown, ${tasks.length} total tasks`\n )\n );\n } catch (error: unknown) {\n console.error(\n chalk.red('Failed to list tasks:'),\n (error as Error).message\n );\n }\n });\n\n // Auth command\n linear\n .command('auth')\n .description('Authenticate with Linear')\n .option('--api-key <key>', 'Use API key instead of OAuth')\n .option('--no-browser', 'Do not open browser automatically')\n .action(async (options) => {\n try {\n if (options.apiKey) {\n // Set API key as environment variable\n process.env['LINEAR_API_KEY'] = options.apiKey;\n console.log(chalk.green('\u2713 Linear API key set'));\n\n // Test the connection\n const client = new LinearClient({ apiKey: options.apiKey });\n const user = await client.getViewer();\n\n if (user) {\n console.log(\n chalk.cyan(`Connected as: ${user.name} (${user.email})`)\n );\n }\n } else {\n // OAuth flow with callback server\n const authManager = new LinearAuthManager(process.cwd());\n\n // Check if client ID and secret are configured\n const clientId = process.env['LINEAR_CLIENT_ID'];\n const clientSecret = process.env['LINEAR_CLIENT_SECRET'];\n\n if (!clientId || !clientSecret) {\n console.log(chalk.yellow('\\n\u26A0 Linear OAuth app not configured'));\n console.log(chalk.cyan('\\n\uD83D\uDCDD Setup Instructions:'));\n console.log(\n ' 1. Create a Linear OAuth app at: https://linear.app/settings/api'\n );\n console.log(\n ' 2. Set redirect URI to: http://localhost:3456/auth/linear/callback'\n );\n console.log(' 3. Copy your Client ID and Client Secret');\n console.log(' 4. Set environment variables:');\n console.log(\n chalk.gray(' export LINEAR_CLIENT_ID=\"your_client_id\"')\n );\n console.log(\n chalk.gray(\n ' export LINEAR_CLIENT_SECRET=\"your_client_secret\"'\n )\n );\n console.log(' 5. Run this command again');\n return;\n }\n\n // Save OAuth config\n authManager.saveConfig({\n clientId,\n clientSecret,\n redirectUri: 'http://localhost:3456/auth/linear/callback',\n scopes: ['read', 'write', 'admin'],\n });\n\n // Start OAuth server\n const oauthServer = new LinearOAuthServer(process.cwd());\n const { url } = await oauthServer.start();\n\n // Open browser if not disabled\n if (options.browser !== false) {\n const open = (await import('open')).default;\n await open(url);\n console.log(\n chalk.green('\\n\u2713 Browser opened with authorization page')\n );\n } else {\n console.log(chalk.cyan('\\n\uD83D\uDD17 Open this URL in your browser:'));\n console.log(chalk.underline(url));\n }\n\n console.log(chalk.gray('\\nWaiting for authorization...'));\n console.log(\n chalk.gray(\n 'The server will automatically shut down after authorization.'\n )\n );\n }\n } catch (error: unknown) {\n console.error(\n chalk.red('Authentication failed:'),\n (error as Error).message\n );\n process.exit(1);\n }\n });\n\n // Sync command\n linear\n .command('sync')\n .description('Sync tasks with Linear')\n .option(\n '-d, --direction <dir>',\n 'Sync direction: bidirectional, to_linear, from_linear',\n 'bidirectional'\n )\n .option('-t, --team <id>', 'Default Linear team ID')\n .option('--dry-run', 'Preview sync without making changes')\n .option('--daemon', 'Run in daemon mode with periodic sync')\n .option(\n '-i, --interval <minutes>',\n 'Sync interval in minutes (default: 15)'\n )\n .action(async (options) => {\n try {\n const projectRoot = process.cwd();\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n\n if (!existsSync(dbPath)) {\n console.log(chalk.red('\u274C StackMemory not initialized'));\n return;\n }\n\n const db = new Database(dbPath);\n const taskStore = new LinearTaskManager(projectRoot, db);\n const authManager = new LinearAuthManager(projectRoot);\n\n const config = {\n ...DEFAULT_SYNC_CONFIG,\n direction: options.direction,\n defaultTeamId: options.team,\n enabled: true,\n };\n\n if (options.daemon) {\n // Run in daemon mode with periodic sync\n const managerConfig = {\n ...DEFAULT_SYNC_MANAGER_CONFIG,\n ...config,\n autoSyncInterval: parseInt(options.interval) || 15,\n };\n\n const syncManager = new LinearSyncManager(\n taskStore,\n authManager,\n managerConfig,\n projectRoot\n );\n\n console.log(chalk.green('\uD83D\uDE80 Starting Linear sync daemon'));\n console.log(\n chalk.cyan(\n ` Sync interval: ${managerConfig.autoSyncInterval} minutes`\n )\n );\n console.log(chalk.cyan(` Direction: ${managerConfig.direction}`));\n console.log(chalk.gray(' Press Ctrl+C to stop\\n'));\n\n // Initial sync\n const initialResult = await syncManager.syncOnStart();\n if (initialResult) {\n displaySyncResult(initialResult);\n }\n\n // Listen for sync events\n syncManager.on('sync:started', ({ trigger }) => {\n console.log(\n chalk.yellow(\n `\\n\uD83D\uDD04 ${new Date().toLocaleTimeString()} - Starting ${trigger} sync...`\n )\n );\n });\n\n syncManager.on('sync:completed', ({ result }) => {\n displaySyncResult(result);\n });\n\n syncManager.on('sync:failed', ({ result }) => {\n console.log(chalk.red('\u274C Sync failed'));\n if (result.errors.length > 0) {\n result.errors.forEach((error: string) => {\n console.log(chalk.red(` - ${error}`));\n });\n }\n });\n\n // Handle graceful shutdown\n process.on('SIGINT', async () => {\n console.log(chalk.yellow('\\n\u23F9 Stopping sync daemon...'));\n await syncManager.syncOnEnd();\n syncManager.stop();\n db.close();\n process.exit(0);\n });\n\n // Keep process alive\n process.stdin.resume();\n } else {\n // Single sync\n const syncEngine = new LinearSyncEngine(\n taskStore,\n authManager,\n config\n );\n\n console.log(chalk.yellow('\uD83D\uDD04 Syncing with Linear...'));\n\n if (options.dryRun) {\n console.log(chalk.gray('(Dry run - no changes will be made)'));\n }\n\n const result = await syncEngine.sync();\n displaySyncResult(result);\n db.close();\n }\n } catch (error: unknown) {\n logger.error('Sync failed', error as Error);\n console.error(chalk.red('Sync failed:'), (error as Error).message);\n process.exit(1);\n }\n });\n\n // Status command\n linear\n .command('status')\n .description('Show Linear sync status')\n .action(async () => {\n try {\n const authManager = new LinearAuthManager(process.cwd());\n const tokens = authManager.loadTokens();\n const apiKey = process.env['LINEAR_API_KEY'];\n\n if (!tokens && !apiKey) {\n console.log(chalk.yellow('\u26A0 Not authenticated with Linear'));\n console.log('Run \"stackmemory linear auth\" to connect');\n return;\n }\n\n const client = apiKey\n ? new LinearClient({ apiKey })\n : new LinearClient({\n apiKey: tokens!.accessToken,\n useBearer: true,\n onUnauthorized: async () => {\n const refreshed = await authManager.refreshAccessToken();\n return refreshed.accessToken;\n },\n });\n\n const user = await client.getViewer();\n\n if (user) {\n console.log(chalk.green('\u2713 Connected to Linear'));\n console.log(chalk.cyan(` User: ${user.name} (${user.email})`));\n\n // Show teams\n const teams = await client.getTeams();\n if (teams && teams.length > 0) {\n console.log(chalk.cyan('\\n\uD83D\uDCCB Teams:'));\n teams.forEach((team) => {\n console.log(` - ${team.name} (${team.key})`);\n });\n }\n } else {\n console.log(chalk.red('\u274C Could not connect to Linear'));\n }\n } catch (error: unknown) {\n console.error(\n chalk.red('Status check failed:'),\n (error as Error).message\n );\n }\n });\n\n // List tasks command\n linear\n .command('tasks')\n .description('List Linear tasks')\n .option('--limit <n>', 'Number of tasks to show', '50')\n .option(\n '--status <status>',\n 'Filter by status (backlog, started, completed, etc.)'\n )\n .option('--my', 'Show only tasks assigned to me')\n .option('--cache', 'Show cache stats')\n .option('--refresh', 'Force refresh cache')\n .action(async (options) => {\n try {\n const apiKey = process.env['LINEAR_API_KEY'];\n if (!apiKey) {\n console.log(\n chalk.yellow('\u26A0 Set LINEAR_API_KEY environment variable')\n );\n return;\n }\n\n const restClient = new LinearRestClient(apiKey);\n\n // Show cache stats if requested\n if (options.cache) {\n const stats = restClient.getCacheStats();\n console.log(chalk.cyan('\uD83D\uDCCA Cache Stats:'));\n console.log(` Size: ${stats.size} tasks`);\n console.log(` Age: ${Math.round(stats.age / 1000)}s`);\n console.log(` Fresh: ${stats.fresh ? 'yes' : 'no'}`);\n console.log(\n ` Last sync: ${new Date(stats.lastSync).toLocaleString()}`\n );\n return;\n }\n\n let tasks;\n if (options.my) {\n tasks = await restClient.getMyTasks();\n } else if (options.status) {\n tasks = await restClient.getTasksByStatus(options.status);\n } else {\n tasks = await restClient.getAllTasks(options.refresh);\n }\n\n if (!tasks || tasks.length === 0) {\n console.log(chalk.gray('No tasks found'));\n return;\n }\n\n // Limit results\n const limit = parseInt(options.limit);\n const displayTasks = tasks.slice(0, limit);\n\n const table = new Table({\n head: ['ID', 'Title', 'State', 'Priority', 'Assignee'],\n style: { head: ['cyan'] },\n });\n\n displayTasks.forEach((task) => {\n table.push([\n task.identifier,\n task.title.substring(0, 40) + (task.title.length > 40 ? '...' : ''),\n task.state?.name || '-',\n task.priority ? `P${task.priority}` : '-',\n task.assignee?.name || '-',\n ]);\n });\n\n console.log(table.toString());\n\n // Show counts by status\n const counts = await restClient.getTaskCounts();\n console.log(chalk.cyan('\\n\uD83D\uDCCA Task Summary:'));\n Object.entries(counts).forEach(([status, count]) => {\n console.log(` ${status}: ${count}`);\n });\n\n console.log(\n chalk.gray(\n `\\nShowing ${displayTasks.length} of ${tasks.length} total tasks`\n )\n );\n\n const cacheStats = restClient.getCacheStats();\n console.log(\n chalk.gray(\n `Cache: ${cacheStats.size} tasks, age: ${Math.round(cacheStats.age / 1000)}s`\n )\n );\n } catch (error: unknown) {\n console.error(\n chalk.red('Failed to list tasks:'),\n (error as Error).message\n );\n }\n });\n\n // Update command - update Linear task status\n linear\n .command('update <issueId>')\n .description('Update Linear task status')\n .option(\n '-s, --status <status>',\n 'New status (todo, in-progress, done, canceled)'\n )\n .option('-t, --title <title>', 'Update task title')\n .option('-d, --description <desc>', 'Update task description')\n .option(\n '-p, --priority <priority>',\n 'Set priority (1=urgent, 2=high, 3=medium, 4=low)'\n )\n .action(async (issueId, options) => {\n try {\n const authManager = new LinearAuthManager(process.cwd());\n const tokens = authManager.loadTokens();\n\n if (!tokens) {\n console.error(\n chalk.red('Not authenticated. Run: stackmemory linear auth')\n );\n return;\n }\n\n const client = new LinearClient({\n apiKey: tokens.accessToken,\n });\n\n // Find the issue first\n let issue = await client.getIssue(issueId);\n if (!issue) {\n // Try finding by identifier\n issue = await client.findIssueByIdentifier(issueId);\n }\n\n if (!issue) {\n console.error(chalk.red(`Issue ${issueId} not found`));\n return;\n }\n\n const updates: any = {};\n\n // Handle status update\n if (options.status) {\n const team = await client.getTeam();\n const states = await client.getWorkflowStates(team.id);\n\n const statusMap: Record<string, string> = {\n todo: 'unstarted',\n 'in-progress': 'started',\n done: 'completed',\n canceled: 'cancelled',\n };\n\n const targetType =\n statusMap[options.status.toLowerCase()] || options.status;\n const targetState = states.find((s) => s.type === targetType);\n\n if (!targetState) {\n console.error(chalk.red(`Invalid status: ${options.status}`));\n console.log(chalk.gray('Available states:'));\n states.forEach((s) =>\n console.log(chalk.gray(` - ${s.name} (${s.type})`))\n );\n return;\n }\n\n updates.stateId = targetState.id;\n }\n\n if (options.title) updates.title = options.title;\n if (options.description) updates.description = options.description;\n if (options.priority) updates.priority = parseInt(options.priority);\n\n // Perform update\n const updatedIssue = await client.updateIssue(issue.id, updates);\n\n console.log(\n chalk.green(\n `\u2713 Updated ${updatedIssue.identifier}: ${updatedIssue.title}`\n )\n );\n if (options.status) {\n console.log(chalk.cyan(` Status: ${updatedIssue.state.name}`));\n }\n console.log(chalk.gray(` ${updatedIssue.url}`));\n } catch (error: unknown) {\n console.error(\n chalk.red('Failed to update task:'),\n (error as Error).message\n );\n }\n });\n\n // Config command\n linear\n .command('config')\n .description('Configure Linear sync settings')\n .option('--team <id>', 'Set default team ID')\n .option('--interval <minutes>', 'Auto-sync interval in minutes')\n .option('--direction <dir>', 'Sync direction')\n .option('--conflict <strategy>', 'Conflict resolution strategy')\n .action(async (options) => {\n try {\n const configManager = new LinearConfigManager(process.cwd());\n const config =\n configManager.loadConfig() || configManager.getDefaultConfig();\n\n let updated = false;\n\n if (options.team) {\n // Team ID would need to be stored separately or in a different config\n logger.info('Team ID configuration not yet implemented', {\n teamId: options.team,\n });\n }\n\n if (options.interval) {\n config.interval = parseInt(options.interval);\n updated = true;\n }\n\n if (options.direction) {\n config.direction = options.direction;\n updated = true;\n }\n\n if (options.conflict) {\n config.conflictResolution = options.conflict;\n updated = true;\n }\n\n if (updated) {\n configManager.saveConfig(config);\n console.log(chalk.green('\u2713 Configuration updated'));\n }\n\n // Display current config\n console.log(chalk.cyan('\\n\uD83D\uDCCB Current Configuration:'));\n console.log(` Enabled: ${config.enabled ? 'yes' : 'no'}`);\n console.log(` Interval: ${config.interval} minutes`);\n console.log(` Direction: ${config.direction}`);\n console.log(` Conflicts: ${config.conflictResolution}`);\n } catch (error: unknown) {\n console.error(chalk.red('Config failed:'), (error as Error).message);\n }\n });\n}\n"],
|
|
5
|
+
"mappings": "AAKA,OAAO,WAAW;AAClB;AAAA,EACE;AAAA,OAEK;AACP,SAAS,yBAAyB;AAClC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,2BAA2B;AACpC,SAAS,yBAAyB;AAClC,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AACjC,OAAO,cAAc;AACrB,SAAS,YAAY;AACrB,SAAS,kBAA6B;AACtC,SAAS,cAAc;AACvB,OAAO,WAAW;AAGlB,SAAS,OAAO,KAAa,cAA+B;AAC1D,QAAM,QAAQ,QAA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,EAAE;AAC9C,cAAQ,IAAI,gBAAgB,OAAO,kBAAkB,EAAE;AAAA,IACzD,SAAS,OAAgB;AACvB,cAAQ,MAAM,MAAM,IAAI,gBAAgB,GAAI,MAAgB,OAAO;AAAA,IACrE;AAAA,EACF,CAAC;AACL;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -4,7 +4,7 @@ import chalk from "chalk";
|
|
|
4
4
|
import { homedir } from "os";
|
|
5
5
|
import { join } from "path";
|
|
6
6
|
import { existsSync, mkdirSync, writeFileSync } from "fs";
|
|
7
|
-
import {
|
|
7
|
+
import { execFileSync } from "child_process";
|
|
8
8
|
import { WorktreeManager } from "../../core/worktree/worktree-manager.js";
|
|
9
9
|
import { ProjectManager } from "../../core/projects/project-manager.js";
|
|
10
10
|
import { logger } from "../../core/monitoring/logger.js";
|
|
@@ -327,9 +327,9 @@ fi
|
|
|
327
327
|
exec stackmemory "$@"
|
|
328
328
|
`;
|
|
329
329
|
writeFileSync(sourcePath, wrapperScript);
|
|
330
|
-
|
|
330
|
+
execFileSync("chmod", ["+x", sourcePath]);
|
|
331
331
|
if (!existsSync(binPath)) {
|
|
332
|
-
|
|
332
|
+
execFileSync("ln", ["-s", sourcePath, binPath]);
|
|
333
333
|
console.log(chalk.green(" \u2713 Created claude-sm command"));
|
|
334
334
|
}
|
|
335
335
|
} catch (error) {
|