@stackmemoryai/stackmemory 0.3.20 → 0.3.22
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/dist/cli/claude-sm.js +1 -3
- package/dist/cli/claude-sm.js.map +2 -2
- package/dist/cli/codex-sm.js.map +1 -1
- package/dist/cli/commands/linear-unified.js +2 -3
- package/dist/cli/commands/linear-unified.js.map +2 -2
- package/dist/cli/commands/signup.js +46 -0
- package/dist/cli/commands/signup.js.map +7 -0
- package/dist/cli/commands/tasks.js +1 -1
- package/dist/cli/commands/tasks.js.map +2 -2
- package/dist/cli/index.js +3 -1
- package/dist/cli/index.js.map +2 -2
- package/dist/integrations/mcp/handlers/code-execution-handlers.js +262 -0
- package/dist/integrations/mcp/handlers/code-execution-handlers.js.map +7 -0
- package/dist/integrations/mcp/tool-definitions-code.js +121 -0
- package/dist/integrations/mcp/tool-definitions-code.js.map +7 -0
- package/dist/servers/railway/index.js +283 -93
- package/dist/servers/railway/index.js.map +3 -3
- package/package.json +2 -3
- package/scripts/claude-sm-autostart.js +1 -1
- package/scripts/clean-linear-backlog.js +2 -2
- package/scripts/debug-linear-update.js +1 -1
- package/scripts/debug-railway-build.js +87 -0
- package/scripts/delete-linear-tasks.js +2 -2
- package/scripts/install-code-execution-hooks.sh +96 -0
- package/scripts/linear-task-review.js +1 -1
- package/scripts/sync-and-clean-tasks.js +1 -1
- package/scripts/sync-linear-graphql.js +3 -3
- package/scripts/sync-linear-tasks.js +1 -1
- package/scripts/test-code-execution.js +143 -0
- package/scripts/update-linear-tasks-fixed.js +1 -1
- package/scripts/validate-railway-deployment.js +137 -0
- package/templates/claude-hooks/hook-config.json +59 -0
- package/templates/claude-hooks/pre-tool-use +189 -0
- package/dist/servers/railway/minimal.js +0 -91
- package/dist/servers/railway/minimal.js.map +0 -7
package/dist/cli/claude-sm.js
CHANGED
|
@@ -354,9 +354,7 @@ class ClaudeSM {
|
|
|
354
354
|
console.error(chalk.red("\u274C Failed to launch Claude CLI."));
|
|
355
355
|
if (err.code === "ENOENT") {
|
|
356
356
|
console.error(
|
|
357
|
-
chalk.gray(
|
|
358
|
-
" Not found. Set CLAUDE_BIN or install claude on PATH."
|
|
359
|
-
)
|
|
357
|
+
chalk.gray(" Not found. Set CLAUDE_BIN or install claude on PATH.")
|
|
360
358
|
);
|
|
361
359
|
} else if (err.code === "EPERM" || err.code === "EACCES") {
|
|
362
360
|
console.error(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/cli/claude-sm.ts"],
|
|
4
|
-
"sourcesContent": ["#!/usr/bin/env node\n\n/**\n * claude-sm: Claude wrapper with StackMemory and worktree integration\n * Automatically manages context persistence and instance isolation\n */\n\nimport { spawn, execSync, execFileSync } from 'child_process';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as os from 'os';\nimport { program } from 'commander';\nimport { v4 as uuidv4 } from 'uuid';\nimport chalk from 'chalk';\nimport { initializeTracing, trace } from '../core/trace/index.js';\n\ninterface ClaudeConfig {\n instanceId: string;\n worktreePath?: string;\n useSandbox: boolean;\n useChrome: boolean;\n useWorktree: boolean;\n contextEnabled: boolean;\n branch?: string;\n task?: string;\n tracingEnabled: boolean;\n verboseTracing: boolean;\n claudeBin?: string;\n}\n\nclass ClaudeSM {\n private config: ClaudeConfig;\n private stackmemoryPath: string;\n private worktreeScriptPath: string;\n private claudeConfigDir: string;\n\n constructor() {\n this.config = {\n instanceId: this.generateInstanceId(),\n useSandbox: false,\n useChrome: false,\n useWorktree: false,\n contextEnabled: true,\n tracingEnabled: true, // Enable tracing by default for claude-sm\n verboseTracing: false,\n };\n\n this.stackmemoryPath = this.findStackMemory();\n this.worktreeScriptPath = path.join(\n __dirname,\n '../../scripts/claude-worktree-manager.sh'\n );\n this.claudeConfigDir = path.join(os.homedir(), '.claude');\n\n // Ensure config directory exists\n if (!fs.existsSync(this.claudeConfigDir)) {\n fs.mkdirSync(this.claudeConfigDir, { recursive: true });\n }\n }\n\n private generateInstanceId(): string {\n return uuidv4().substring(0, 8);\n }\n\n private findStackMemory(): string {\n // Check multiple possible locations\n const possiblePaths = [\n path.join(os.homedir(), '.stackmemory', 'bin', 'stackmemory'),\n '/usr/local/bin/stackmemory',\n '/opt/homebrew/bin/stackmemory',\n 'stackmemory', // Rely on PATH\n ];\n\n for (const smPath of possiblePaths) {\n try {\n execFileSync('which', [smPath], { stdio: 'ignore' });\n return smPath;\n } catch {\n // Continue searching\n }\n }\n\n return 'stackmemory'; // Fallback to PATH\n }\n\n private isGitRepo(): boolean {\n try {\n execSync('git rev-parse --git-dir', { stdio: 'ignore' });\n return true;\n } catch {\n return false;\n }\n }\n\n private getCurrentBranch(): string {\n try {\n return execSync('git rev-parse --abbrev-ref HEAD', {\n encoding: 'utf8',\n }).trim();\n } catch {\n return 'main';\n }\n }\n\n private hasUncommittedChanges(): boolean {\n try {\n const status = execSync('git status --porcelain', { encoding: 'utf8' });\n return status.length > 0;\n } catch {\n return false;\n }\n }\n\n private resolveClaudeBin(): string | null {\n // 1) CLI-specified\n if (this.config.claudeBin && this.config.claudeBin.trim()) {\n return this.config.claudeBin.trim();\n }\n // 2) Env override\n const envBin = process.env['CLAUDE_BIN'];\n if (envBin && envBin.trim()) return envBin.trim();\n // 3) PATH detection\n try {\n execSync('which claude', { stdio: 'ignore' });\n return 'claude';\n } catch {}\n return null;\n }\n\n private setupWorktree(): string | null {\n if (!this.config.useWorktree || !this.isGitRepo()) {\n return null;\n }\n\n console.log(chalk.blue('\uD83C\uDF33 Setting up isolated worktree...'));\n\n const timestamp = new Date()\n .toISOString()\n .replace(/[:.]/g, '-')\n .substring(0, 19);\n const branch =\n this.config.branch ||\n `claude-${this.config.task || 'work'}-${timestamp}-${this.config.instanceId}`;\n const repoName = path.basename(process.cwd());\n const worktreePath = path.join(\n path.dirname(process.cwd()),\n `${repoName}--${branch}`\n );\n\n try {\n // Create worktree\n const flags = [];\n if (this.config.useSandbox) flags.push('--sandbox');\n if (this.config.useChrome) flags.push('--chrome');\n\n const cmd = `git worktree add -b \"${branch}\" \"${worktreePath}\"`;\n execSync(cmd, { stdio: 'inherit' });\n\n console.log(chalk.green(`\u2705 Worktree created: ${worktreePath}`));\n console.log(chalk.gray(` Branch: ${branch}`));\n\n // Save worktree config\n const configPath = path.join(worktreePath, '.claude-instance.json');\n const configData = {\n instanceId: this.config.instanceId,\n worktreePath,\n branch,\n task: this.config.task,\n sandboxEnabled: this.config.useSandbox,\n chromeEnabled: this.config.useChrome,\n created: new Date().toISOString(),\n parentRepo: process.cwd(),\n };\n fs.writeFileSync(configPath, JSON.stringify(configData, null, 2));\n\n // Copy environment files\n const envFiles = ['.env', '.env.local', '.mise.toml', '.tool-versions'];\n for (const file of envFiles) {\n const srcPath = path.join(process.cwd(), file);\n if (fs.existsSync(srcPath)) {\n fs.copyFileSync(srcPath, path.join(worktreePath, file));\n }\n }\n\n return worktreePath;\n } catch (err: unknown) {\n console.error(chalk.red('\u274C Failed to create worktree:'), err);\n return null;\n }\n }\n\n private saveContext(\n message: string,\n metadata: Record<string, unknown> = {}\n ): void {\n if (!this.config.contextEnabled) return;\n\n try {\n const contextData = {\n message,\n metadata: {\n ...metadata,\n instanceId: this.config.instanceId,\n worktree: this.config.worktreePath,\n timestamp: new Date().toISOString(),\n },\n };\n\n const cmd = `${this.stackmemoryPath} context save --json '${JSON.stringify(contextData)}'`;\n execSync(cmd, { stdio: 'ignore' });\n } catch {\n // Silently fail - don't interrupt Claude\n }\n }\n\n private loadContext(): void {\n if (!this.config.contextEnabled) return;\n\n try {\n console.log(chalk.blue('\uD83D\uDCDA Loading previous context...'));\n\n const cmd = `${this.stackmemoryPath} context list --limit 5 --format json`;\n const output = execSync(cmd, { encoding: 'utf8' });\n const contexts = JSON.parse(output);\n\n if (contexts.length > 0) {\n console.log(chalk.gray('Recent context loaded:'));\n contexts.forEach(\n (ctx: { message: string; metadata?: { timestamp?: string } }) => {\n console.log(\n chalk.gray(` - ${ctx.message} (${ctx.metadata?.timestamp})`)\n );\n }\n );\n }\n } catch {\n // Silently continue\n }\n }\n\n private detectMultipleInstances(): boolean {\n try {\n const lockDir = path.join(process.cwd(), '.claude-worktree-locks');\n if (!fs.existsSync(lockDir)) return false;\n\n const locks = fs.readdirSync(lockDir).filter((f) => f.endsWith('.lock'));\n const activeLocks = locks.filter((lockFile) => {\n const lockPath = path.join(lockDir, lockFile);\n const lockData = JSON.parse(fs.readFileSync(lockPath, 'utf8'));\n const lockAge = Date.now() - new Date(lockData.created).getTime();\n return lockAge < 24 * 60 * 60 * 1000; // Less than 24 hours old\n });\n\n return activeLocks.length > 0;\n } catch {\n return false;\n }\n }\n\n private suggestWorktreeMode(): void {\n if (this.hasUncommittedChanges()) {\n console.log(chalk.yellow('\u26A0\uFE0F Uncommitted changes detected'));\n console.log(\n chalk.gray(' Consider using --worktree to work in isolation')\n );\n }\n\n if (this.detectMultipleInstances()) {\n console.log(chalk.yellow('\u26A0\uFE0F Other Claude instances detected'));\n console.log(\n chalk.gray(' Using --worktree is recommended to avoid conflicts')\n );\n }\n }\n\n public async run(args: string[]): Promise<void> {\n // Parse arguments\n const claudeArgs: string[] = [];\n let i = 0;\n\n while (i < args.length) {\n const arg = args[i];\n\n switch (arg) {\n case '--worktree':\n case '-w':\n this.config.useWorktree = true;\n break;\n case '--sandbox':\n case '-s':\n this.config.useSandbox = true;\n claudeArgs.push('--sandbox');\n break;\n case '--chrome':\n case '-c':\n this.config.useChrome = true;\n claudeArgs.push('--chrome');\n break;\n case '--no-context':\n this.config.contextEnabled = false;\n break;\n case '--no-trace':\n this.config.tracingEnabled = false;\n break;\n case '--verbose-trace':\n this.config.verboseTracing = true;\n break;\n case '--branch':\n case '-b':\n i++;\n this.config.branch = args[i];\n break;\n case '--task':\n case '-t':\n i++;\n this.config.task = args[i];\n break;\n case '--claude-bin':\n i++;\n this.config.claudeBin = args[i];\n process.env['CLAUDE_BIN'] = this.config.claudeBin;\n break;\n case '--auto':\n case '-a':\n // Auto mode: detect and apply best settings\n if (this.isGitRepo()) {\n this.config.useWorktree =\n this.hasUncommittedChanges() || this.detectMultipleInstances();\n }\n break;\n default:\n claudeArgs.push(arg);\n }\n i++;\n }\n\n // Initialize tracing system if enabled\n if (this.config.tracingEnabled) {\n // Set up environment for tracing\n process.env['DEBUG_TRACE'] = 'true';\n process.env['STACKMEMORY_DEBUG'] = 'true';\n process.env['TRACE_OUTPUT'] = 'file'; // Write to file to not clutter Claude output\n process.env['TRACE_MASK_SENSITIVE'] = 'true'; // Always mask sensitive data\n\n if (this.config.verboseTracing) {\n process.env['TRACE_VERBOSITY'] = 'full';\n process.env['TRACE_PARAMS'] = 'true';\n process.env['TRACE_RESULTS'] = 'true';\n process.env['TRACE_MEMORY'] = 'true';\n } else {\n process.env['TRACE_VERBOSITY'] = 'summary';\n process.env['TRACE_PARAMS'] = 'true';\n process.env['TRACE_RESULTS'] = 'false';\n }\n\n // Initialize the tracing system\n initializeTracing();\n\n // Start tracing this Claude session\n trace.command(\n 'claude-sm',\n {\n instanceId: this.config.instanceId,\n worktree: this.config.useWorktree,\n sandbox: this.config.useSandbox,\n task: this.config.task,\n },\n async () => {\n // Session tracing will wrap the entire Claude execution\n }\n );\n }\n\n // Show header\n console.log(chalk.blue('\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557'));\n console.log(chalk.blue('\u2551 Claude + StackMemory + Worktree \u2551'));\n console.log(chalk.blue('\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D'));\n console.log();\n\n // Check Git repo status\n if (this.isGitRepo()) {\n const branch = this.getCurrentBranch();\n console.log(chalk.gray(`\uD83D\uDCCD Current branch: ${branch}`));\n\n if (!this.config.useWorktree) {\n this.suggestWorktreeMode();\n }\n }\n\n // Setup worktree if requested\n if (this.config.useWorktree) {\n const worktreePath = this.setupWorktree();\n if (worktreePath) {\n this.config.worktreePath = worktreePath;\n process.chdir(worktreePath);\n\n // Save context about worktree creation\n this.saveContext('Created worktree for Claude instance', {\n action: 'worktree_created',\n path: worktreePath,\n branch: this.config.branch,\n });\n }\n }\n\n // Load previous context\n this.loadContext();\n\n // Setup environment\n process.env['CLAUDE_INSTANCE_ID'] = this.config.instanceId;\n if (this.config.worktreePath) {\n process.env['CLAUDE_WORKTREE_PATH'] = this.config.worktreePath;\n }\n\n console.log(chalk.gray(`\uD83E\uDD16 Instance ID: ${this.config.instanceId}`));\n console.log(chalk.gray(`\uD83D\uDCC1 Working in: ${process.cwd()}`));\n\n if (this.config.useSandbox) {\n console.log(chalk.yellow('\uD83D\uDD12 Sandbox mode enabled'));\n }\n if (this.config.useChrome) {\n console.log(chalk.yellow('\uD83C\uDF10 Chrome automation enabled'));\n }\n if (this.config.tracingEnabled) {\n console.log(\n chalk.gray(`\uD83D\uDD0D Debug tracing enabled (logs to ~/.stackmemory/traces/)`)\n );\n if (this.config.verboseTracing) {\n console.log(\n chalk.gray(` Verbose mode: capturing all execution details`)\n );\n }\n }\n\n console.log();\n console.log(chalk.gray('Starting Claude...'));\n console.log(chalk.gray('\u2500'.repeat(42)));\n\n const claudeBin = this.resolveClaudeBin();\n if (!claudeBin) {\n console.error(chalk.red('\u274C Claude CLI not found.'));\n console.log(\n chalk.gray(\n ' Install Claude CLI or set an override:\\n' +\n ' export CLAUDE_BIN=/path/to/claude\\n' +\n ' claude-sm --help\\n\\n' +\n ' Ensure PATH includes npm global bin (npm bin -g).'\n )\n );\n process.exit(1);\n return;\n }\n\n // Launch Claude\n const claude = spawn(claudeBin, claudeArgs, {\n stdio: 'inherit',\n env: process.env,\n });\n\n claude.on('error', (err: NodeJS.ErrnoException) => {\n console.error(chalk.red('\u274C Failed to launch Claude CLI.'));\n if (err.code === 'ENOENT') {\n console.error(\n chalk.gray(\n ' Not found. Set CLAUDE_BIN or install claude on PATH.'\n )\n );\n } else if (err.code === 'EPERM' || err.code === 'EACCES') {\n console.error(\n chalk.gray(\n ' Permission/sandbox issue. Try outside a sandbox or set CLAUDE_BIN.'\n )\n );\n } else {\n console.error(chalk.gray(` ${err.message}`));\n }\n process.exit(1);\n });\n\n // Handle exit\n claude.on('exit', (code) => {\n // Save final context\n this.saveContext('Claude session ended', {\n action: 'session_end',\n exitCode: code,\n });\n\n // End tracing and show summary if enabled\n if (this.config.tracingEnabled) {\n const summary = trace.getExecutionSummary();\n console.log();\n console.log(chalk.gray('\u2500'.repeat(42)));\n console.log(chalk.blue('Debug Trace Summary:'));\n console.log(chalk.gray(summary));\n }\n\n // Offer to clean up worktree\n if (this.config.worktreePath) {\n console.log();\n console.log(chalk.gray('\u2500'.repeat(42)));\n console.log(chalk.blue('Session ended in worktree:'));\n console.log(chalk.gray(` ${this.config.worktreePath}`));\n console.log();\n console.log(chalk.gray('To remove worktree: gd_claude'));\n console.log(chalk.gray('To merge to main: cwm'));\n }\n\n process.exit(code || 0);\n });\n\n // Handle signals\n process.on('SIGINT', () => {\n this.saveContext('Claude session interrupted', {\n action: 'session_interrupt',\n });\n claude.kill('SIGINT');\n });\n\n process.on('SIGTERM', () => {\n this.saveContext('Claude session terminated', {\n action: 'session_terminate',\n });\n claude.kill('SIGTERM');\n });\n }\n}\n\n// CLI interface\nprogram\n .name('claude-sm')\n .description('Claude with StackMemory context and worktree isolation')\n .version('1.0.0')\n .option('-w, --worktree', 'Create isolated worktree for this instance')\n .option('-s, --sandbox', 'Enable sandbox mode (file/network restrictions)')\n .option('-c, --chrome', 'Enable Chrome automation')\n .option('-a, --auto', 'Automatically detect and apply best settings')\n .option('-b, --branch <name>', 'Specify branch name for worktree')\n .option('-t, --task <desc>', 'Task description for context')\n .option('--claude-bin <path>', 'Path to claude CLI (or use CLAUDE_BIN)')\n .option('--no-context', 'Disable StackMemory context integration')\n .option('--no-trace', 'Disable debug tracing (enabled by default)')\n .option('--verbose-trace', 'Enable verbose debug tracing with full details')\n .helpOption('-h, --help', 'Display help')\n .allowUnknownOption(true)\n .action(async (_options) => {\n const claudeSM = new ClaudeSM();\n const args = process.argv.slice(2);\n await claudeSM.run(args);\n });\n\n// Handle direct execution\n// ESM-safe CLI entry\nprogram.parse(process.argv);\n"],
|
|
5
|
-
"mappings": ";AAOA,SAAS,OAAO,UAAU,oBAAoB;AAC9C,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,YAAY,QAAQ;AACpB,SAAS,eAAe;AACxB,SAAS,MAAM,cAAc;AAC7B,OAAO,WAAW;AAClB,SAAS,mBAAmB,aAAa;AAgBzC,MAAM,SAAS;AAAA,EACL;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAER,cAAc;AACZ,SAAK,SAAS;AAAA,MACZ,YAAY,KAAK,mBAAmB;AAAA,MACpC,YAAY;AAAA,MACZ,WAAW;AAAA,MACX,aAAa;AAAA,MACb,gBAAgB;AAAA,MAChB,gBAAgB;AAAA;AAAA,MAChB,gBAAgB;AAAA,IAClB;AAEA,SAAK,kBAAkB,KAAK,gBAAgB;AAC5C,SAAK,qBAAqB,KAAK;AAAA,MAC7B;AAAA,MACA;AAAA,IACF;AACA,SAAK,kBAAkB,KAAK,KAAK,GAAG,QAAQ,GAAG,SAAS;AAGxD,QAAI,CAAC,GAAG,WAAW,KAAK,eAAe,GAAG;AACxC,SAAG,UAAU,KAAK,iBAAiB,EAAE,WAAW,KAAK,CAAC;AAAA,IACxD;AAAA,EACF;AAAA,EAEQ,qBAA6B;AACnC,WAAO,OAAO,EAAE,UAAU,GAAG,CAAC;AAAA,EAChC;AAAA,EAEQ,kBAA0B;AA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AAO,gBAAgB;AAC9B,cAAQ;AAAA,QACN,MAAM,KAAK,kEAA2D;AAAA,MACxE;AACA,UAAI,KAAK,OAAO,gBAAgB;AAC9B,gBAAQ;AAAA,UACN,MAAM,KAAK,kDAAkD;AAAA,QAC/D;AAAA,MACF;AAAA,IACF;AAEA,YAAQ,IAAI;AACZ,YAAQ,IAAI,MAAM,KAAK,oBAAoB,CAAC;AAC5C,YAAQ,IAAI,MAAM,KAAK,SAAI,OAAO,EAAE,CAAC,CAAC;AAEtC,UAAM,YAAY,KAAK,iBAAiB;AACxC,QAAI,CAAC,WAAW;AACd,cAAQ,MAAM,MAAM,IAAI,8BAAyB,CAAC;AAClD,cAAQ;AAAA,QACN,MAAM;AAAA,UACJ;AAAA,QAIF;AAAA,MACF;AACA,cAAQ,KAAK,CAAC;AACd;AAAA,IACF;AAGA,UAAM,SAAS,MAAM,WAAW,YAAY;AAAA,MAC1C,OAAO;AAAA,MACP,KAAK,QAAQ;AAAA,IACf,CAAC;AAED,WAAO,GAAG,SAAS,CAAC,QAA+B;AACjD,cAAQ,MAAM,MAAM,IAAI,qCAAgC,CAAC;AACzD,UAAI,IAAI,SAAS,UAAU;AACzB,gBAAQ;AAAA,UACN,MAAM
|
|
4
|
+
"sourcesContent": ["#!/usr/bin/env node\n\n/**\n * claude-sm: Claude wrapper with StackMemory and worktree integration\n * Automatically manages context persistence and instance isolation\n */\n\nimport { spawn, execSync, execFileSync } from 'child_process';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as os from 'os';\nimport { program } from 'commander';\nimport { v4 as uuidv4 } from 'uuid';\nimport chalk from 'chalk';\nimport { initializeTracing, trace } from '../core/trace/index.js';\n\ninterface ClaudeConfig {\n instanceId: string;\n worktreePath?: string;\n useSandbox: boolean;\n useChrome: boolean;\n useWorktree: boolean;\n contextEnabled: boolean;\n branch?: string;\n task?: string;\n tracingEnabled: boolean;\n verboseTracing: boolean;\n claudeBin?: string;\n}\n\nclass ClaudeSM {\n private config: ClaudeConfig;\n private stackmemoryPath: string;\n private worktreeScriptPath: string;\n private claudeConfigDir: string;\n\n constructor() {\n this.config = {\n instanceId: this.generateInstanceId(),\n useSandbox: false,\n useChrome: false,\n useWorktree: false,\n contextEnabled: true,\n tracingEnabled: true, // Enable tracing by default for claude-sm\n verboseTracing: false,\n };\n\n this.stackmemoryPath = this.findStackMemory();\n this.worktreeScriptPath = path.join(\n __dirname,\n '../../scripts/claude-worktree-manager.sh'\n );\n this.claudeConfigDir = path.join(os.homedir(), '.claude');\n\n // Ensure config directory exists\n if (!fs.existsSync(this.claudeConfigDir)) {\n fs.mkdirSync(this.claudeConfigDir, { recursive: true });\n }\n }\n\n private generateInstanceId(): string {\n return uuidv4().substring(0, 8);\n }\n\n private findStackMemory(): string {\n // Check multiple possible locations\n const possiblePaths = [\n path.join(os.homedir(), '.stackmemory', 'bin', 'stackmemory'),\n '/usr/local/bin/stackmemory',\n '/opt/homebrew/bin/stackmemory',\n 'stackmemory', // Rely on PATH\n ];\n\n for (const smPath of possiblePaths) {\n try {\n execFileSync('which', [smPath], { stdio: 'ignore' });\n return smPath;\n } catch {\n // Continue searching\n }\n }\n\n return 'stackmemory'; // Fallback to PATH\n }\n\n private isGitRepo(): boolean {\n try {\n execSync('git rev-parse --git-dir', { stdio: 'ignore' });\n return true;\n } catch {\n return false;\n }\n }\n\n private getCurrentBranch(): string {\n try {\n return execSync('git rev-parse --abbrev-ref HEAD', {\n encoding: 'utf8',\n }).trim();\n } catch {\n return 'main';\n }\n }\n\n private hasUncommittedChanges(): boolean {\n try {\n const status = execSync('git status --porcelain', { encoding: 'utf8' });\n return status.length > 0;\n } catch {\n return false;\n }\n }\n\n private resolveClaudeBin(): string | null {\n // 1) CLI-specified\n if (this.config.claudeBin && this.config.claudeBin.trim()) {\n return this.config.claudeBin.trim();\n }\n // 2) Env override\n const envBin = process.env['CLAUDE_BIN'];\n if (envBin && envBin.trim()) return envBin.trim();\n // 3) PATH detection\n try {\n execSync('which claude', { stdio: 'ignore' });\n return 'claude';\n } catch {}\n return null;\n }\n\n private setupWorktree(): string | null {\n if (!this.config.useWorktree || !this.isGitRepo()) {\n return null;\n }\n\n console.log(chalk.blue('\uD83C\uDF33 Setting up isolated worktree...'));\n\n const timestamp = new Date()\n .toISOString()\n .replace(/[:.]/g, '-')\n .substring(0, 19);\n const branch =\n this.config.branch ||\n `claude-${this.config.task || 'work'}-${timestamp}-${this.config.instanceId}`;\n const repoName = path.basename(process.cwd());\n const worktreePath = path.join(\n path.dirname(process.cwd()),\n `${repoName}--${branch}`\n );\n\n try {\n // Create worktree\n const flags = [];\n if (this.config.useSandbox) flags.push('--sandbox');\n if (this.config.useChrome) flags.push('--chrome');\n\n const cmd = `git worktree add -b \"${branch}\" \"${worktreePath}\"`;\n execSync(cmd, { stdio: 'inherit' });\n\n console.log(chalk.green(`\u2705 Worktree created: ${worktreePath}`));\n console.log(chalk.gray(` Branch: ${branch}`));\n\n // Save worktree config\n const configPath = path.join(worktreePath, '.claude-instance.json');\n const configData = {\n instanceId: this.config.instanceId,\n worktreePath,\n branch,\n task: this.config.task,\n sandboxEnabled: this.config.useSandbox,\n chromeEnabled: this.config.useChrome,\n created: new Date().toISOString(),\n parentRepo: process.cwd(),\n };\n fs.writeFileSync(configPath, JSON.stringify(configData, null, 2));\n\n // Copy environment files\n const envFiles = ['.env', '.env.local', '.mise.toml', '.tool-versions'];\n for (const file of envFiles) {\n const srcPath = path.join(process.cwd(), file);\n if (fs.existsSync(srcPath)) {\n fs.copyFileSync(srcPath, path.join(worktreePath, file));\n }\n }\n\n return worktreePath;\n } catch (err: unknown) {\n console.error(chalk.red('\u274C Failed to create worktree:'), err);\n return null;\n }\n }\n\n private saveContext(\n message: string,\n metadata: Record<string, unknown> = {}\n ): void {\n if (!this.config.contextEnabled) return;\n\n try {\n const contextData = {\n message,\n metadata: {\n ...metadata,\n instanceId: this.config.instanceId,\n worktree: this.config.worktreePath,\n timestamp: new Date().toISOString(),\n },\n };\n\n const cmd = `${this.stackmemoryPath} context save --json '${JSON.stringify(contextData)}'`;\n execSync(cmd, { stdio: 'ignore' });\n } catch {\n // Silently fail - don't interrupt Claude\n }\n }\n\n private loadContext(): void {\n if (!this.config.contextEnabled) return;\n\n try {\n console.log(chalk.blue('\uD83D\uDCDA Loading previous context...'));\n\n const cmd = `${this.stackmemoryPath} context list --limit 5 --format json`;\n const output = execSync(cmd, { encoding: 'utf8' });\n const contexts = JSON.parse(output);\n\n if (contexts.length > 0) {\n console.log(chalk.gray('Recent context loaded:'));\n contexts.forEach(\n (ctx: { message: string; metadata?: { timestamp?: string } }) => {\n console.log(\n chalk.gray(` - ${ctx.message} (${ctx.metadata?.timestamp})`)\n );\n }\n );\n }\n } catch {\n // Silently continue\n }\n }\n\n private detectMultipleInstances(): boolean {\n try {\n const lockDir = path.join(process.cwd(), '.claude-worktree-locks');\n if (!fs.existsSync(lockDir)) return false;\n\n const locks = fs.readdirSync(lockDir).filter((f) => f.endsWith('.lock'));\n const activeLocks = locks.filter((lockFile) => {\n const lockPath = path.join(lockDir, lockFile);\n const lockData = JSON.parse(fs.readFileSync(lockPath, 'utf8'));\n const lockAge = Date.now() - new Date(lockData.created).getTime();\n return lockAge < 24 * 60 * 60 * 1000; // Less than 24 hours old\n });\n\n return activeLocks.length > 0;\n } catch {\n return false;\n }\n }\n\n private suggestWorktreeMode(): void {\n if (this.hasUncommittedChanges()) {\n console.log(chalk.yellow('\u26A0\uFE0F Uncommitted changes detected'));\n console.log(\n chalk.gray(' Consider using --worktree to work in isolation')\n );\n }\n\n if (this.detectMultipleInstances()) {\n console.log(chalk.yellow('\u26A0\uFE0F Other Claude instances detected'));\n console.log(\n chalk.gray(' Using --worktree is recommended to avoid conflicts')\n );\n }\n }\n\n public async run(args: string[]): Promise<void> {\n // Parse arguments\n const claudeArgs: string[] = [];\n let i = 0;\n\n while (i < args.length) {\n const arg = args[i];\n\n switch (arg) {\n case '--worktree':\n case '-w':\n this.config.useWorktree = true;\n break;\n case '--sandbox':\n case '-s':\n this.config.useSandbox = true;\n claudeArgs.push('--sandbox');\n break;\n case '--chrome':\n case '-c':\n this.config.useChrome = true;\n claudeArgs.push('--chrome');\n break;\n case '--no-context':\n this.config.contextEnabled = false;\n break;\n case '--no-trace':\n this.config.tracingEnabled = false;\n break;\n case '--verbose-trace':\n this.config.verboseTracing = true;\n break;\n case '--branch':\n case '-b':\n i++;\n this.config.branch = args[i];\n break;\n case '--task':\n case '-t':\n i++;\n this.config.task = args[i];\n break;\n case '--claude-bin':\n i++;\n this.config.claudeBin = args[i];\n process.env['CLAUDE_BIN'] = this.config.claudeBin;\n break;\n case '--auto':\n case '-a':\n // Auto mode: detect and apply best settings\n if (this.isGitRepo()) {\n this.config.useWorktree =\n this.hasUncommittedChanges() || this.detectMultipleInstances();\n }\n break;\n default:\n claudeArgs.push(arg);\n }\n i++;\n }\n\n // Initialize tracing system if enabled\n if (this.config.tracingEnabled) {\n // Set up environment for tracing\n process.env['DEBUG_TRACE'] = 'true';\n process.env['STACKMEMORY_DEBUG'] = 'true';\n process.env['TRACE_OUTPUT'] = 'file'; // Write to file to not clutter Claude output\n process.env['TRACE_MASK_SENSITIVE'] = 'true'; // Always mask sensitive data\n\n if (this.config.verboseTracing) {\n process.env['TRACE_VERBOSITY'] = 'full';\n process.env['TRACE_PARAMS'] = 'true';\n process.env['TRACE_RESULTS'] = 'true';\n process.env['TRACE_MEMORY'] = 'true';\n } else {\n process.env['TRACE_VERBOSITY'] = 'summary';\n process.env['TRACE_PARAMS'] = 'true';\n process.env['TRACE_RESULTS'] = 'false';\n }\n\n // Initialize the tracing system\n initializeTracing();\n\n // Start tracing this Claude session\n trace.command(\n 'claude-sm',\n {\n instanceId: this.config.instanceId,\n worktree: this.config.useWorktree,\n sandbox: this.config.useSandbox,\n task: this.config.task,\n },\n async () => {\n // Session tracing will wrap the entire Claude execution\n }\n );\n }\n\n // Show header\n console.log(chalk.blue('\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557'));\n console.log(chalk.blue('\u2551 Claude + StackMemory + Worktree \u2551'));\n console.log(chalk.blue('\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D'));\n console.log();\n\n // Check Git repo status\n if (this.isGitRepo()) {\n const branch = this.getCurrentBranch();\n console.log(chalk.gray(`\uD83D\uDCCD Current branch: ${branch}`));\n\n if (!this.config.useWorktree) {\n this.suggestWorktreeMode();\n }\n }\n\n // Setup worktree if requested\n if (this.config.useWorktree) {\n const worktreePath = this.setupWorktree();\n if (worktreePath) {\n this.config.worktreePath = worktreePath;\n process.chdir(worktreePath);\n\n // Save context about worktree creation\n this.saveContext('Created worktree for Claude instance', {\n action: 'worktree_created',\n path: worktreePath,\n branch: this.config.branch,\n });\n }\n }\n\n // Load previous context\n this.loadContext();\n\n // Setup environment\n process.env['CLAUDE_INSTANCE_ID'] = this.config.instanceId;\n if (this.config.worktreePath) {\n process.env['CLAUDE_WORKTREE_PATH'] = this.config.worktreePath;\n }\n\n console.log(chalk.gray(`\uD83E\uDD16 Instance ID: ${this.config.instanceId}`));\n console.log(chalk.gray(`\uD83D\uDCC1 Working in: ${process.cwd()}`));\n\n if (this.config.useSandbox) {\n console.log(chalk.yellow('\uD83D\uDD12 Sandbox mode enabled'));\n }\n if (this.config.useChrome) {\n console.log(chalk.yellow('\uD83C\uDF10 Chrome automation enabled'));\n }\n if (this.config.tracingEnabled) {\n console.log(\n chalk.gray(`\uD83D\uDD0D Debug tracing enabled (logs to ~/.stackmemory/traces/)`)\n );\n if (this.config.verboseTracing) {\n console.log(\n chalk.gray(` Verbose mode: capturing all execution details`)\n );\n }\n }\n\n console.log();\n console.log(chalk.gray('Starting Claude...'));\n console.log(chalk.gray('\u2500'.repeat(42)));\n\n const claudeBin = this.resolveClaudeBin();\n if (!claudeBin) {\n console.error(chalk.red('\u274C Claude CLI not found.'));\n console.log(\n chalk.gray(\n ' Install Claude CLI or set an override:\\n' +\n ' export CLAUDE_BIN=/path/to/claude\\n' +\n ' claude-sm --help\\n\\n' +\n ' Ensure PATH includes npm global bin (npm bin -g).'\n )\n );\n process.exit(1);\n return;\n }\n\n // Launch Claude\n const claude = spawn(claudeBin, claudeArgs, {\n stdio: 'inherit',\n env: process.env,\n });\n\n claude.on('error', (err: NodeJS.ErrnoException) => {\n console.error(chalk.red('\u274C Failed to launch Claude CLI.'));\n if (err.code === 'ENOENT') {\n console.error(\n chalk.gray(' Not found. Set CLAUDE_BIN or install claude on PATH.')\n );\n } else if (err.code === 'EPERM' || err.code === 'EACCES') {\n console.error(\n chalk.gray(\n ' Permission/sandbox issue. Try outside a sandbox or set CLAUDE_BIN.'\n )\n );\n } else {\n console.error(chalk.gray(` ${err.message}`));\n }\n process.exit(1);\n });\n\n // Handle exit\n claude.on('exit', (code) => {\n // Save final context\n this.saveContext('Claude session ended', {\n action: 'session_end',\n exitCode: code,\n });\n\n // End tracing and show summary if enabled\n if (this.config.tracingEnabled) {\n const summary = trace.getExecutionSummary();\n console.log();\n console.log(chalk.gray('\u2500'.repeat(42)));\n console.log(chalk.blue('Debug Trace Summary:'));\n console.log(chalk.gray(summary));\n }\n\n // Offer to clean up worktree\n if (this.config.worktreePath) {\n console.log();\n console.log(chalk.gray('\u2500'.repeat(42)));\n console.log(chalk.blue('Session ended in worktree:'));\n console.log(chalk.gray(` ${this.config.worktreePath}`));\n console.log();\n console.log(chalk.gray('To remove worktree: gd_claude'));\n console.log(chalk.gray('To merge to main: cwm'));\n }\n\n process.exit(code || 0);\n });\n\n // Handle signals\n process.on('SIGINT', () => {\n this.saveContext('Claude session interrupted', {\n action: 'session_interrupt',\n });\n claude.kill('SIGINT');\n });\n\n process.on('SIGTERM', () => {\n this.saveContext('Claude session terminated', {\n action: 'session_terminate',\n });\n claude.kill('SIGTERM');\n });\n }\n}\n\n// CLI interface\nprogram\n .name('claude-sm')\n .description('Claude with StackMemory context and worktree isolation')\n .version('1.0.0')\n .option('-w, --worktree', 'Create isolated worktree for this instance')\n .option('-s, --sandbox', 'Enable sandbox mode (file/network restrictions)')\n .option('-c, --chrome', 'Enable Chrome automation')\n .option('-a, --auto', 'Automatically detect and apply best settings')\n .option('-b, --branch <name>', 'Specify branch name for worktree')\n .option('-t, --task <desc>', 'Task description for context')\n .option('--claude-bin <path>', 'Path to claude CLI (or use CLAUDE_BIN)')\n .option('--no-context', 'Disable StackMemory context integration')\n .option('--no-trace', 'Disable debug tracing (enabled by default)')\n .option('--verbose-trace', 'Enable verbose debug tracing with full details')\n .helpOption('-h, --help', 'Display help')\n .allowUnknownOption(true)\n .action(async (_options) => {\n const claudeSM = new ClaudeSM();\n const args = process.argv.slice(2);\n await claudeSM.run(args);\n });\n\n// Handle direct execution\n// ESM-safe CLI entry\nprogram.parse(process.argv);\n"],
|
|
5
|
+
"mappings": ";AAOA,SAAS,OAAO,UAAU,oBAAoB;AAC9C,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,YAAY,QAAQ;AACpB,SAAS,eAAe;AACxB,SAAS,MAAM,cAAc;AAC7B,OAAO,WAAW;AAClB,SAAS,mBAAmB,aAAa;AAgBzC,MAAM,SAAS;AAAA,EACL;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAER,cAAc;AACZ,SAAK,SAAS;AAAA,MACZ,YAAY,KAAK,mBAAmB;AAAA,MACpC,YAAY;AAAA,MACZ,WAAW;AAAA,MACX,aAAa;AAAA,MACb,gBAAgB;AAAA,MAChB,gBAAgB;AAAA;AAAA,MAChB,gBAAgB;AAAA,IAClB;AAEA,SAAK,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A,EACH;AACF;AAGA,QACG,KAAK,WAAW,EAChB,YAAY,wDAAwD,EACpE,QAAQ,OAAO,EACf,OAAO,kBAAkB,4CAA4C,EACrE,OAAO,iBAAiB,iDAAiD,EACzE,OAAO,gBAAgB,0BAA0B,EACjD,OAAO,cAAc,8CAA8C,EACnE,OAAO,uBAAuB,kCAAkC,EAChE,OAAO,qBAAqB,8BAA8B,EAC1D,OAAO,uBAAuB,wCAAwC,EACtE,OAAO,gBAAgB,yCAAyC,EAChE,OAAO,cAAc,4CAA4C,EACjE,OAAO,mBAAmB,gDAAgD,EAC1E,WAAW,cAAc,cAAc,EACvC,mBAAmB,IAAI,EACvB,OAAO,OAAO,aAAa;AAC1B,QAAM,WAAW,IAAI,SAAS;AAC9B,QAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,QAAM,SAAS,IAAI,IAAI;AACzB,CAAC;AAIH,QAAQ,MAAM,QAAQ,IAAI;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cli/codex-sm.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/cli/codex-sm.ts"],
|
|
4
|
-
"sourcesContent": ["#!/usr/bin/env node\n\n/**\n * codex-sm: Codex wrapper with StackMemory and worktree integration\n * Automatically manages context persistence, optional worktree isolation, and tracing\n */\n\nimport { spawn, execSync, execFileSync } from 'child_process';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as os from 'os';\nimport { program } from 'commander';\nimport { v4 as uuidv4 } from 'uuid';\nimport chalk from 'chalk';\nimport { initializeTracing, trace } from '../core/trace/index.js';\n\ninterface CodexConfig {\n instanceId: string;\n worktreePath?: string;\n useWorktree: boolean;\n contextEnabled: boolean;\n branch?: string;\n task?: string;\n tracingEnabled: boolean;\n verboseTracing: boolean;\n codexBin?: string;\n}\n\nclass CodexSM {\n private config: CodexConfig;\n private stackmemoryPath: string;\n\n constructor() {\n this.config = {\n instanceId: this.generateInstanceId(),\n useWorktree: false,\n contextEnabled: true,\n tracingEnabled: true,\n verboseTracing: false,\n };\n\n this.stackmemoryPath = this.findStackMemory();\n }\n\n private generateInstanceId(): string {\n return uuidv4().substring(0, 8);\n }\n\n private findStackMemory(): string {\n const possiblePaths = [\n path.join(os.homedir(), '.stackmemory', 'bin', 'stackmemory'),\n '/usr/local/bin/stackmemory',\n '/opt/homebrew/bin/stackmemory',\n 'stackmemory',\n ];\n for (const smPath of possiblePaths) {\n try {\n execFileSync('which', [smPath], { stdio: 'ignore' });\n return smPath;\n } catch {\n // continue\n }\n }\n return 'stackmemory';\n }\n\n private isGitRepo(): boolean {\n try {\n execSync('git rev-parse --git-dir', { stdio: 'ignore' });\n return true;\n } catch {\n return false;\n }\n }\n\n private getCurrentBranch(): string {\n try {\n return execSync('git rev-parse --abbrev-ref HEAD', {\n encoding: 'utf8',\n }).trim();\n } catch {\n return 'main';\n }\n }\n\n private hasUncommittedChanges(): boolean {\n try {\n const status = execSync('git status --porcelain', { encoding: 'utf8' });\n return status.length > 0;\n } catch {\n return false;\n }\n }\n\n private resolveCodexBin(): string | null {\n // 1) CLI option\n if (this.config.codexBin && this.config.codexBin.trim()) {\n return this.config.codexBin.trim();\n }\n // 2) Environment override\n const envBin = process.env['CODEX_BIN'];\n if (envBin && envBin.trim()) {\n return envBin.trim();\n }\n // 3) Detect on PATH\n try {\n execSync('which codex', { stdio: 'ignore' });\n return 'codex';\n } catch {}\n try {\n execSync('which codex-cli', { stdio: 'ignore' });\n return 'codex-cli';\n } catch {}\n return null;\n }\n\n private setupWorktree(): string | null {\n if (!this.config.useWorktree || !this.isGitRepo()) return null;\n\n console.log(chalk.blue('\uD83C\uDF33 Setting up isolated worktree...'));\n\n const timestamp = new Date()\n .toISOString()\n .replace(/[:.]/g, '-')\n .substring(0, 19);\n const branch =\n this.config.branch ||\n `codex-${this.config.task || 'work'}-${timestamp}-${this.config.instanceId}`;\n const repoName = path.basename(process.cwd());\n const worktreePath = path.join(\n path.dirname(process.cwd()),\n `${repoName}--${branch}`\n );\n\n try {\n const cmd = `git worktree add -b \"${branch}\" \"${worktreePath}\"`;\n execSync(cmd, { stdio: 'inherit' });\n\n console.log(chalk.green(`Worktree created: ${worktreePath}`));\n console.log(chalk.gray(` Branch: ${branch}`));\n\n const configPath = path.join(worktreePath, '.codex-instance.json');\n const configData = {\n instanceId: this.config.instanceId,\n worktreePath,\n branch,\n task: this.config.task,\n created: new Date().toISOString(),\n parentRepo: process.cwd(),\n };\n fs.writeFileSync(configPath, JSON.stringify(configData, null, 2));\n\n const envFiles = ['.env', '.env.local', '.mise.toml', '.tool-versions'];\n for (const file of envFiles) {\n const srcPath = path.join(process.cwd(), file);\n if (fs.existsSync(srcPath))\n fs.copyFileSync(srcPath, path.join(worktreePath, file));\n }\n\n return worktreePath;\n } catch (err: unknown) {\n console.error(chalk.red('Failed to create worktree:'), err);\n return null;\n }\n }\n\n private saveContext(\n message: string,\n metadata: Record<string, unknown> = {}\n ): void {\n if (!this.config.contextEnabled) return;\n try {\n const contextData = {\n message,\n metadata: {\n ...metadata,\n instanceId: this.config.instanceId,\n worktree: this.config.worktreePath,\n timestamp: new Date().toISOString(),\n },\n };\n const cmd = `${this.stackmemoryPath} context save --json '${JSON.stringify(contextData)}'`;\n execSync(cmd, { stdio: 'ignore' });\n } catch {\n // ignore\n }\n }\n\n private loadContext(): void {\n if (!this.config.contextEnabled) return;\n try {\n console.log(chalk.blue('\uD83D\uDCDA Loading previous context...'));\n const cmd = `${this.stackmemoryPath} context list --limit 5 --format json`;\n const output = execSync(cmd, { encoding: 'utf8' });\n const contexts = JSON.parse(output);\n if (Array.isArray(contexts) && contexts.length > 0) {\n console.log(chalk.gray('Recent context loaded:'));\n contexts.forEach(\n (ctx: { message: string; metadata?: { timestamp?: string } }) => {\n console.log(\n chalk.gray(` - ${ctx.message} (${ctx.metadata?.timestamp})`)\n );\n }\n );\n }\n } catch {\n // ignore\n }\n }\n\n private suggestWorktreeMode(): void {\n if (this.hasUncommittedChanges()) {\n console.log(chalk.yellow('WARNING: Uncommitted changes detected'));\n console.log(\n chalk.gray(' Consider using --worktree to work in isolation')\n );\n }\n }\n\n public async run(args: string[]): Promise<void> {\n const codexArgs: string[] = [];\n let i = 0;\n while (i < args.length) {\n const arg = args[i];\n switch (arg) {\n case '--worktree':\n case '-w':\n this.config.useWorktree = true;\n break;\n case '--no-context':\n this.config.contextEnabled = false;\n break;\n case '--no-trace':\n this.config.tracingEnabled = false;\n break;\n case '--verbose-trace':\n this.config.verboseTracing = true;\n break;\n case '--branch':\n case '-b':\n i++;\n this.config.branch = args[i];\n break;\n case '--task':\n case '-t':\n i++;\n this.config.task = args[i];\n break;\n case '--codex-bin':\n i++;\n this.config.codexBin = args[i];\n process.env['CODEX_BIN'] = this.config.codexBin;\n break;\n case '--auto':\n case '-a':\n if (this.isGitRepo()) {\n this.config.useWorktree = this.hasUncommittedChanges();\n }\n break;\n default:\n codexArgs.push(arg);\n }\n i++;\n }\n\n if (this.config.tracingEnabled) {\n process.env['DEBUG_TRACE'] = 'true';\n process.env['STACKMEMORY_DEBUG'] = 'true';\n process.env['TRACE_OUTPUT'] = 'file';\n process.env['TRACE_MASK_SENSITIVE'] = 'true';\n if (this.config.verboseTracing) {\n process.env['TRACE_VERBOSITY'] = 'full';\n process.env['TRACE_PARAMS'] = 'true';\n process.env['TRACE_RESULTS'] = 'true';\n process.env['TRACE_MEMORY'] = 'true';\n } else {\n process.env['TRACE_VERBOSITY'] = 'summary';\n process.env['TRACE_PARAMS'] = 'true';\n process.env['TRACE_RESULTS'] = 'false';\n }\n initializeTracing();\n trace.command(\n 'codex-sm',\n {\n instanceId: this.config.instanceId,\n worktree: this.config.useWorktree,\n task: this.config.task,\n },\n async () => {}\n );\n }\n\n console.log(chalk.blue('\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557'));\n console.log(chalk.blue('\u2551 Codex + StackMemory + Worktree \u2551'));\n console.log(chalk.blue('\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D'));\n console.log();\n\n if (this.isGitRepo()) {\n const branch = this.getCurrentBranch();\n console.log(chalk.gray(`\uD83D\uDCCD Current branch: ${branch}`));\n if (!this.config.useWorktree) this.suggestWorktreeMode();\n }\n\n if (this.config.useWorktree) {\n const worktreePath = this.setupWorktree();\n if (worktreePath) {\n this.config.worktreePath = worktreePath;\n process.chdir(worktreePath);\n this.saveContext('Created worktree for Codex instance', {\n action: 'worktree_created',\n path: worktreePath,\n branch: this.config.branch,\n });\n }\n }\n\n this.loadContext();\n\n process.env['CODEX_INSTANCE_ID'] = this.config.instanceId;\n if (this.config.worktreePath)\n process.env['CODEX_WORKTREE_PATH'] = this.config.worktreePath;\n\n console.log(chalk.gray(`\uD83E\uDD16 Instance ID: ${this.config.instanceId}`));\n console.log(chalk.gray(`\uD83D\uDCC1 Working in: ${process.cwd()}`));\n\n console.log();\n console.log(chalk.gray('Starting Codex...'));\n console.log(chalk.gray('\u2500'.repeat(42)));\n\n const codexBin = this.resolveCodexBin();\n \n if (!codexBin) {\n console.error(chalk.red('\u274C Codex CLI not found.'));\n console.log(\n chalk.gray(\n ' Install codex/codex-cli or set an override:\\n' +\n ' export CODEX_BIN=/path/to/codex\\n' +\n ' codex-sm --help\\n\\n' +\n ' Ensure PATH includes npm global bin (npm bin -g).'\n )\n );\n process.exit(1);\n return;\n }\n\n const child = spawn(codexBin, codexArgs, {\n stdio: 'inherit',\n env: process.env,\n });\n\n child.on('error', (err: NodeJS.ErrnoException) => {\n console.error(chalk.red('\u274C Failed to launch Codex CLI.'));\n if (err.code === 'ENOENT') {\n console.error(\n chalk.gray(\n ' Not found. Set CODEX_BIN or install codex/codex-cli on PATH.'\n )\n );\n } else if (err.code === 'EPERM' || err.code === 'EACCES') {\n console.error(\n chalk.gray(\n ' Permission/sandbox issue. Try running outside a sandbox or set CODEX_BIN.'\n )\n );\n } else {\n console.error(chalk.gray(` ${err.message}`));\n }\n process.exit(1);\n });\n\n child.on('exit', (code) => {\n this.saveContext('Codex session ended', {\n action: 'session_end',\n exitCode: code,\n });\n if (this.config.tracingEnabled) {\n const summary = trace.getExecutionSummary();\n console.log();\n console.log(chalk.gray('\u2500'.repeat(42)));\n console.log(chalk.blue('Debug Trace Summary:'));\n console.log(chalk.gray(summary));\n }\n if (this.config.worktreePath) {\n console.log();\n console.log(chalk.gray('\u2500'.repeat(42)));\n console.log(chalk.blue('Session ended in worktree:'));\n console.log(chalk.gray(` ${this.config.worktreePath}`));\n }\n process.exit(code || 0);\n });\n\n process.on('SIGINT', () => {\n this.saveContext('Codex session interrupted', {\n action: 'session_interrupt',\n });\n child.kill('SIGINT');\n });\n\n process.on('SIGTERM', () => {\n this.saveContext('Codex session terminated', {\n action: 'session_terminate',\n });\n child.kill('SIGTERM');\n });\n }\n}\n\nprogram\n .name('codex-sm')\n .description('Codex with StackMemory context and optional worktree isolation')\n .version('1.0.0')\n .option('-w, --worktree', 'Create isolated worktree for this instance')\n .option('-a, --auto', 'Automatically detect and apply best settings')\n .option('-b, --branch <name>', 'Specify branch name for worktree')\n .option('-t, --task <desc>', 'Task description for context')\n .option('--codex-bin <path>', 'Path to codex/codex-cli (or use CODEX_BIN)')\n .option('--no-context', 'Disable StackMemory context integration')\n .option('--no-trace', 'Disable debug tracing (enabled by default)')\n .option('--verbose-trace', 'Enable verbose debug tracing with full details')\n .helpOption('-h, --help', 'Display help')\n .allowUnknownOption(true)\n .action(async (_options) => {\n const codexSM = new CodexSM();\n const args = process.argv.slice(2);\n await codexSM.run(args);\n });\n\n// ESM-safe CLI entry\nprogram.parse(process.argv);\n"],
|
|
4
|
+
"sourcesContent": ["#!/usr/bin/env node\n\n/**\n * codex-sm: Codex wrapper with StackMemory and worktree integration\n * Automatically manages context persistence, optional worktree isolation, and tracing\n */\n\nimport { spawn, execSync, execFileSync } from 'child_process';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as os from 'os';\nimport { program } from 'commander';\nimport { v4 as uuidv4 } from 'uuid';\nimport chalk from 'chalk';\nimport { initializeTracing, trace } from '../core/trace/index.js';\n\ninterface CodexConfig {\n instanceId: string;\n worktreePath?: string;\n useWorktree: boolean;\n contextEnabled: boolean;\n branch?: string;\n task?: string;\n tracingEnabled: boolean;\n verboseTracing: boolean;\n codexBin?: string;\n}\n\nclass CodexSM {\n private config: CodexConfig;\n private stackmemoryPath: string;\n\n constructor() {\n this.config = {\n instanceId: this.generateInstanceId(),\n useWorktree: false,\n contextEnabled: true,\n tracingEnabled: true,\n verboseTracing: false,\n };\n\n this.stackmemoryPath = this.findStackMemory();\n }\n\n private generateInstanceId(): string {\n return uuidv4().substring(0, 8);\n }\n\n private findStackMemory(): string {\n const possiblePaths = [\n path.join(os.homedir(), '.stackmemory', 'bin', 'stackmemory'),\n '/usr/local/bin/stackmemory',\n '/opt/homebrew/bin/stackmemory',\n 'stackmemory',\n ];\n for (const smPath of possiblePaths) {\n try {\n execFileSync('which', [smPath], { stdio: 'ignore' });\n return smPath;\n } catch {\n // continue\n }\n }\n return 'stackmemory';\n }\n\n private isGitRepo(): boolean {\n try {\n execSync('git rev-parse --git-dir', { stdio: 'ignore' });\n return true;\n } catch {\n return false;\n }\n }\n\n private getCurrentBranch(): string {\n try {\n return execSync('git rev-parse --abbrev-ref HEAD', {\n encoding: 'utf8',\n }).trim();\n } catch {\n return 'main';\n }\n }\n\n private hasUncommittedChanges(): boolean {\n try {\n const status = execSync('git status --porcelain', { encoding: 'utf8' });\n return status.length > 0;\n } catch {\n return false;\n }\n }\n\n private resolveCodexBin(): string | null {\n // 1) CLI option\n if (this.config.codexBin && this.config.codexBin.trim()) {\n return this.config.codexBin.trim();\n }\n // 2) Environment override\n const envBin = process.env['CODEX_BIN'];\n if (envBin && envBin.trim()) {\n return envBin.trim();\n }\n // 3) Detect on PATH\n try {\n execSync('which codex', { stdio: 'ignore' });\n return 'codex';\n } catch {}\n try {\n execSync('which codex-cli', { stdio: 'ignore' });\n return 'codex-cli';\n } catch {}\n return null;\n }\n\n private setupWorktree(): string | null {\n if (!this.config.useWorktree || !this.isGitRepo()) return null;\n\n console.log(chalk.blue('\uD83C\uDF33 Setting up isolated worktree...'));\n\n const timestamp = new Date()\n .toISOString()\n .replace(/[:.]/g, '-')\n .substring(0, 19);\n const branch =\n this.config.branch ||\n `codex-${this.config.task || 'work'}-${timestamp}-${this.config.instanceId}`;\n const repoName = path.basename(process.cwd());\n const worktreePath = path.join(\n path.dirname(process.cwd()),\n `${repoName}--${branch}`\n );\n\n try {\n const cmd = `git worktree add -b \"${branch}\" \"${worktreePath}\"`;\n execSync(cmd, { stdio: 'inherit' });\n\n console.log(chalk.green(`Worktree created: ${worktreePath}`));\n console.log(chalk.gray(` Branch: ${branch}`));\n\n const configPath = path.join(worktreePath, '.codex-instance.json');\n const configData = {\n instanceId: this.config.instanceId,\n worktreePath,\n branch,\n task: this.config.task,\n created: new Date().toISOString(),\n parentRepo: process.cwd(),\n };\n fs.writeFileSync(configPath, JSON.stringify(configData, null, 2));\n\n const envFiles = ['.env', '.env.local', '.mise.toml', '.tool-versions'];\n for (const file of envFiles) {\n const srcPath = path.join(process.cwd(), file);\n if (fs.existsSync(srcPath))\n fs.copyFileSync(srcPath, path.join(worktreePath, file));\n }\n\n return worktreePath;\n } catch (err: unknown) {\n console.error(chalk.red('Failed to create worktree:'), err);\n return null;\n }\n }\n\n private saveContext(\n message: string,\n metadata: Record<string, unknown> = {}\n ): void {\n if (!this.config.contextEnabled) return;\n try {\n const contextData = {\n message,\n metadata: {\n ...metadata,\n instanceId: this.config.instanceId,\n worktree: this.config.worktreePath,\n timestamp: new Date().toISOString(),\n },\n };\n const cmd = `${this.stackmemoryPath} context save --json '${JSON.stringify(contextData)}'`;\n execSync(cmd, { stdio: 'ignore' });\n } catch {\n // ignore\n }\n }\n\n private loadContext(): void {\n if (!this.config.contextEnabled) return;\n try {\n console.log(chalk.blue('\uD83D\uDCDA Loading previous context...'));\n const cmd = `${this.stackmemoryPath} context list --limit 5 --format json`;\n const output = execSync(cmd, { encoding: 'utf8' });\n const contexts = JSON.parse(output);\n if (Array.isArray(contexts) && contexts.length > 0) {\n console.log(chalk.gray('Recent context loaded:'));\n contexts.forEach(\n (ctx: { message: string; metadata?: { timestamp?: string } }) => {\n console.log(\n chalk.gray(` - ${ctx.message} (${ctx.metadata?.timestamp})`)\n );\n }\n );\n }\n } catch {\n // ignore\n }\n }\n\n private suggestWorktreeMode(): void {\n if (this.hasUncommittedChanges()) {\n console.log(chalk.yellow('WARNING: Uncommitted changes detected'));\n console.log(\n chalk.gray(' Consider using --worktree to work in isolation')\n );\n }\n }\n\n public async run(args: string[]): Promise<void> {\n const codexArgs: string[] = [];\n let i = 0;\n while (i < args.length) {\n const arg = args[i];\n switch (arg) {\n case '--worktree':\n case '-w':\n this.config.useWorktree = true;\n break;\n case '--no-context':\n this.config.contextEnabled = false;\n break;\n case '--no-trace':\n this.config.tracingEnabled = false;\n break;\n case '--verbose-trace':\n this.config.verboseTracing = true;\n break;\n case '--branch':\n case '-b':\n i++;\n this.config.branch = args[i];\n break;\n case '--task':\n case '-t':\n i++;\n this.config.task = args[i];\n break;\n case '--codex-bin':\n i++;\n this.config.codexBin = args[i];\n process.env['CODEX_BIN'] = this.config.codexBin;\n break;\n case '--auto':\n case '-a':\n if (this.isGitRepo()) {\n this.config.useWorktree = this.hasUncommittedChanges();\n }\n break;\n default:\n codexArgs.push(arg);\n }\n i++;\n }\n\n if (this.config.tracingEnabled) {\n process.env['DEBUG_TRACE'] = 'true';\n process.env['STACKMEMORY_DEBUG'] = 'true';\n process.env['TRACE_OUTPUT'] = 'file';\n process.env['TRACE_MASK_SENSITIVE'] = 'true';\n if (this.config.verboseTracing) {\n process.env['TRACE_VERBOSITY'] = 'full';\n process.env['TRACE_PARAMS'] = 'true';\n process.env['TRACE_RESULTS'] = 'true';\n process.env['TRACE_MEMORY'] = 'true';\n } else {\n process.env['TRACE_VERBOSITY'] = 'summary';\n process.env['TRACE_PARAMS'] = 'true';\n process.env['TRACE_RESULTS'] = 'false';\n }\n initializeTracing();\n trace.command(\n 'codex-sm',\n {\n instanceId: this.config.instanceId,\n worktree: this.config.useWorktree,\n task: this.config.task,\n },\n async () => {}\n );\n }\n\n console.log(chalk.blue('\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557'));\n console.log(chalk.blue('\u2551 Codex + StackMemory + Worktree \u2551'));\n console.log(chalk.blue('\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D'));\n console.log();\n\n if (this.isGitRepo()) {\n const branch = this.getCurrentBranch();\n console.log(chalk.gray(`\uD83D\uDCCD Current branch: ${branch}`));\n if (!this.config.useWorktree) this.suggestWorktreeMode();\n }\n\n if (this.config.useWorktree) {\n const worktreePath = this.setupWorktree();\n if (worktreePath) {\n this.config.worktreePath = worktreePath;\n process.chdir(worktreePath);\n this.saveContext('Created worktree for Codex instance', {\n action: 'worktree_created',\n path: worktreePath,\n branch: this.config.branch,\n });\n }\n }\n\n this.loadContext();\n\n process.env['CODEX_INSTANCE_ID'] = this.config.instanceId;\n if (this.config.worktreePath)\n process.env['CODEX_WORKTREE_PATH'] = this.config.worktreePath;\n\n console.log(chalk.gray(`\uD83E\uDD16 Instance ID: ${this.config.instanceId}`));\n console.log(chalk.gray(`\uD83D\uDCC1 Working in: ${process.cwd()}`));\n\n console.log();\n console.log(chalk.gray('Starting Codex...'));\n console.log(chalk.gray('\u2500'.repeat(42)));\n\n const codexBin = this.resolveCodexBin();\n\n if (!codexBin) {\n console.error(chalk.red('\u274C Codex CLI not found.'));\n console.log(\n chalk.gray(\n ' Install codex/codex-cli or set an override:\\n' +\n ' export CODEX_BIN=/path/to/codex\\n' +\n ' codex-sm --help\\n\\n' +\n ' Ensure PATH includes npm global bin (npm bin -g).'\n )\n );\n process.exit(1);\n return;\n }\n\n const child = spawn(codexBin, codexArgs, {\n stdio: 'inherit',\n env: process.env,\n });\n\n child.on('error', (err: NodeJS.ErrnoException) => {\n console.error(chalk.red('\u274C Failed to launch Codex CLI.'));\n if (err.code === 'ENOENT') {\n console.error(\n chalk.gray(\n ' Not found. Set CODEX_BIN or install codex/codex-cli on PATH.'\n )\n );\n } else if (err.code === 'EPERM' || err.code === 'EACCES') {\n console.error(\n chalk.gray(\n ' Permission/sandbox issue. Try running outside a sandbox or set CODEX_BIN.'\n )\n );\n } else {\n console.error(chalk.gray(` ${err.message}`));\n }\n process.exit(1);\n });\n\n child.on('exit', (code) => {\n this.saveContext('Codex session ended', {\n action: 'session_end',\n exitCode: code,\n });\n if (this.config.tracingEnabled) {\n const summary = trace.getExecutionSummary();\n console.log();\n console.log(chalk.gray('\u2500'.repeat(42)));\n console.log(chalk.blue('Debug Trace Summary:'));\n console.log(chalk.gray(summary));\n }\n if (this.config.worktreePath) {\n console.log();\n console.log(chalk.gray('\u2500'.repeat(42)));\n console.log(chalk.blue('Session ended in worktree:'));\n console.log(chalk.gray(` ${this.config.worktreePath}`));\n }\n process.exit(code || 0);\n });\n\n process.on('SIGINT', () => {\n this.saveContext('Codex session interrupted', {\n action: 'session_interrupt',\n });\n child.kill('SIGINT');\n });\n\n process.on('SIGTERM', () => {\n this.saveContext('Codex session terminated', {\n action: 'session_terminate',\n });\n child.kill('SIGTERM');\n });\n }\n}\n\nprogram\n .name('codex-sm')\n .description('Codex with StackMemory context and optional worktree isolation')\n .version('1.0.0')\n .option('-w, --worktree', 'Create isolated worktree for this instance')\n .option('-a, --auto', 'Automatically detect and apply best settings')\n .option('-b, --branch <name>', 'Specify branch name for worktree')\n .option('-t, --task <desc>', 'Task description for context')\n .option('--codex-bin <path>', 'Path to codex/codex-cli (or use CODEX_BIN)')\n .option('--no-context', 'Disable StackMemory context integration')\n .option('--no-trace', 'Disable debug tracing (enabled by default)')\n .option('--verbose-trace', 'Enable verbose debug tracing with full details')\n .helpOption('-h, --help', 'Display help')\n .allowUnknownOption(true)\n .action(async (_options) => {\n const codexSM = new CodexSM();\n const args = process.argv.slice(2);\n await codexSM.run(args);\n });\n\n// ESM-safe CLI entry\nprogram.parse(process.argv);\n"],
|
|
5
5
|
"mappings": ";AAOA,SAAS,OAAO,UAAU,oBAAoB;AAC9C,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,YAAY,QAAQ;AACpB,SAAS,eAAe;AACxB,SAAS,MAAM,cAAc;AAC7B,OAAO,WAAW;AAClB,SAAS,mBAAmB,aAAa;AAczC,MAAM,QAAQ;AAAA,EACJ;AAAA,EACA;AAAA,EAER,cAAc;AACZ,SAAK,SAAS;AAAA,MACZ,YAAY,KAAK,mBAAmB;AAAA,MACpC,aAAa;AAAA,MACb,gBAAgB;AAAA,MAChB,gBAAgB;AAAA,MAChB,gBAAgB;AAAA,IAClB;AAEA,SAAK,kBAAkB,KAAK,gBAAgB;AAAA,EAC9C;AAAA,EAEQ,qBAA6B;AACnC,WAAO,OAAO,EAAE,UAAU,GAAG,CAAC;AAAA,EAChC;AAAA,EAEQ,kBAA0B;AAChC,UAAM,gBAAgB;AAAA,M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AK,SAAI,OAAO,EAAE,CAAC,CAAC;AACtC,gBAAQ,IAAI,MAAM,KAAK,4BAA4B,CAAC;AACpD,gBAAQ,IAAI,MAAM,KAAK,KAAK,KAAK,OAAO,YAAY,EAAE,CAAC;AAAA,MACzD;AACA,cAAQ,KAAK,QAAQ,CAAC;AAAA,IACxB,CAAC;AAED,YAAQ,GAAG,UAAU,MAAM;AACzB,WAAK,YAAY,6BAA6B;AAAA,QAC5C,QAAQ;AAAA,MACV,CAAC;AACD,YAAM,KAAK,QAAQ;AAAA,IACrB,CAAC;AAED,YAAQ,GAAG,WAAW,MAAM;AAC1B,WAAK,YAAY,4BAA4B;AAAA,QAC3C,QAAQ;AAAA,MACV,CAAC;AACD,YAAM,KAAK,SAAS;AAAA,IACtB,CAAC;AAAA,EACH;AACF;AAEA,QACG,KAAK,UAAU,EACf,YAAY,gEAAgE,EAC5E,QAAQ,OAAO,EACf,OAAO,kBAAkB,4CAA4C,EACrE,OAAO,cAAc,8CAA8C,EACnE,OAAO,uBAAuB,kCAAkC,EAChE,OAAO,qBAAqB,8BAA8B,EAC1D,OAAO,sBAAsB,4CAA4C,EACzE,OAAO,gBAAgB,yCAAyC,EAChE,OAAO,cAAc,4CAA4C,EACjE,OAAO,mBAAmB,gDAAgD,EAC1E,WAAW,cAAc,cAAc,EACvC,mBAAmB,IAAI,EACvB,OAAO,OAAO,aAAa;AAC1B,QAAM,UAAU,IAAI,QAAQ;AAC5B,QAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,QAAM,QAAQ,IAAI,IAAI;AACxB,CAAC;AAGH,QAAQ,MAAM,QAAQ,IAAI;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -122,7 +122,7 @@ function registerUnifiedLinearCommands(parent) {
|
|
|
122
122
|
try {
|
|
123
123
|
const authManager = new LinearAuthManager(process.cwd());
|
|
124
124
|
const hasAuth = authManager.isConfigured();
|
|
125
|
-
if (!hasAuth && !process.env.LINEAR_API_KEY) {
|
|
125
|
+
if (!hasAuth && !process.env.STACKMEMORY_LINEAR_API_KEY && !process.env.LINEAR_API_KEY) {
|
|
126
126
|
console.log(chalk.yellow("\u26A0 Not connected to Linear"));
|
|
127
127
|
console.log('Run "stackmemory linear auth" to connect');
|
|
128
128
|
return;
|
|
@@ -248,9 +248,8 @@ function registerUnifiedLinearCommands(parent) {
|
|
|
248
248
|
});
|
|
249
249
|
linear.command("auth").description("Authenticate with Linear").option("--api-key <key>", "Use API key").option("--oauth", "Use OAuth flow").action(async (options) => {
|
|
250
250
|
try {
|
|
251
|
-
const authManager = new LinearAuthManager(process.cwd());
|
|
252
251
|
if (options.apiKey) {
|
|
253
|
-
process.env.
|
|
252
|
+
process.env.STACKMEMORY_LINEAR_API_KEY = options.apiKey;
|
|
254
253
|
console.log(chalk.green("\u2713 API key configured"));
|
|
255
254
|
const client = new LinearClient({ apiKey: options.apiKey });
|
|
256
255
|
const user = await client.getViewer();
|
|
@@ -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 { 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,
|
|
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} 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';\n// import { 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.STACKMEMORY_LINEAR_API_KEY && !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.STACKMEMORY_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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E,QAAM,WAAW,KAAK,aAAa,gBAAgB,gBAAgB;AAEnE,MAAI,cAAc,WAAW,UAAU,GAAG;AACxC,UAAM,SAAS,aAAa,YAAY,MAAM;AAC9C,YAAQ,IAAI,OAAO,MAAM;AAAA,EAC3B,WAAW,WAAW,QAAQ,GAAG;AAC/B,UAAM,OAAO,KAAK,MAAM,aAAa,UAAU,MAAM,CAAC;AAEtD,YAAQ,IAAI,MAAM,KAAK,gCAAyB,CAAC;AACjD,YAAQ;AAAA,MACN,iBAAiB,IAAI,KAAK,KAAK,WAAW,EAAE,eAAe,CAAC;AAAA;AAAA,IAC9D;AAEA,SAAK,OAAO,QAAQ,CAAC,UAAU;AAC7B,cAAQ,IAAI,MAAM,OAAO,GAAG,MAAM,IAAI,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
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import open from "open";
|
|
4
|
+
import inquirer from "inquirer";
|
|
5
|
+
function registerSignupCommand(program) {
|
|
6
|
+
program.command("signup").alias("register").description("Sign up for StackMemory hosted service").option("--no-open", "Do not automatically open browser").action(async (options) => {
|
|
7
|
+
console.log(chalk.cyan("\u{1F680} StackMemory Hosted Service Signup\n"));
|
|
8
|
+
const signupUrl = "https://stackmemory.ai/signup";
|
|
9
|
+
if (options.open !== false) {
|
|
10
|
+
console.log(chalk.gray("Opening signup page in your browser..."));
|
|
11
|
+
try {
|
|
12
|
+
await open(signupUrl);
|
|
13
|
+
console.log(chalk.green("\u2713 Opened: ") + chalk.cyan(signupUrl));
|
|
14
|
+
} catch (error) {
|
|
15
|
+
console.log(chalk.yellow("Could not open browser automatically."));
|
|
16
|
+
console.log(chalk.gray("Please visit: ") + chalk.cyan(signupUrl));
|
|
17
|
+
}
|
|
18
|
+
} else {
|
|
19
|
+
console.log(chalk.gray("Visit this URL to sign up:"));
|
|
20
|
+
console.log(chalk.cyan(signupUrl));
|
|
21
|
+
}
|
|
22
|
+
console.log(chalk.gray("\nAfter signing up, you can login with:"));
|
|
23
|
+
console.log(chalk.cyan(" stackmemory login"));
|
|
24
|
+
const { proceed } = await inquirer.prompt([
|
|
25
|
+
{
|
|
26
|
+
type: "confirm",
|
|
27
|
+
name: "proceed",
|
|
28
|
+
message: "Have you completed signup and want to login now?",
|
|
29
|
+
default: false
|
|
30
|
+
}
|
|
31
|
+
]);
|
|
32
|
+
if (proceed) {
|
|
33
|
+
const { registerLoginCommand } = await import("./login.js");
|
|
34
|
+
const loginCmd = new Command();
|
|
35
|
+
registerLoginCommand(loginCmd);
|
|
36
|
+
console.log(chalk.cyan("\n\u{1F510} Proceeding to login...\n"));
|
|
37
|
+
await loginCmd.parseAsync(["node", "stackmemory", "login"]);
|
|
38
|
+
} else {
|
|
39
|
+
console.log(chalk.gray("\nWhen ready, run: ") + chalk.cyan("stackmemory login"));
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
registerSignupCommand
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=signup.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/cli/commands/signup.ts"],
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport chalk from 'chalk';\nimport open from 'open';\nimport inquirer from 'inquirer';\n\nexport function registerSignupCommand(program: Command): void {\n program\n .command('signup')\n .alias('register')\n .description('Sign up for StackMemory hosted service')\n .option('--no-open', 'Do not automatically open browser')\n .action(async (options) => {\n console.log(chalk.cyan('\uD83D\uDE80 StackMemory Hosted Service Signup\\n'));\n\n const signupUrl = 'https://stackmemory.ai/signup';\n \n if (options.open !== false) {\n console.log(chalk.gray('Opening signup page in your browser...'));\n try {\n await open(signupUrl);\n console.log(chalk.green('\u2713 Opened: ') + chalk.cyan(signupUrl));\n } catch (error) {\n console.log(chalk.yellow('Could not open browser automatically.'));\n console.log(chalk.gray('Please visit: ') + chalk.cyan(signupUrl));\n }\n } else {\n console.log(chalk.gray('Visit this URL to sign up:'));\n console.log(chalk.cyan(signupUrl));\n }\n\n console.log(chalk.gray('\\nAfter signing up, you can login with:'));\n console.log(chalk.cyan(' stackmemory login'));\n\n // Optional: Ask if they want to login now\n const { proceed } = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'proceed',\n message: 'Have you completed signup and want to login now?',\n default: false,\n },\n ]);\n\n if (proceed) {\n // Import and run login command\n const { registerLoginCommand } = await import('./login.js');\n const loginCmd = new Command();\n registerLoginCommand(loginCmd);\n \n // Execute login\n console.log(chalk.cyan('\\n\uD83D\uDD10 Proceeding to login...\\n'));\n await loginCmd.parseAsync(['node', 'stackmemory', 'login']);\n } else {\n console.log(chalk.gray('\\nWhen ready, run: ') + chalk.cyan('stackmemory login'));\n }\n });\n}"],
|
|
5
|
+
"mappings": "AAAA,SAAS,eAAe;AACxB,OAAO,WAAW;AAClB,OAAO,UAAU;AACjB,OAAO,cAAc;AAEd,SAAS,sBAAsB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AC;AACL;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/commands/tasks.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Enhanced Task Commands for StackMemory CLI\n * Provides task management directly from command line\n */\n\nimport { Command } from 'commander';\nimport Database from 'better-sqlite3';\nimport { join } from 'path';\nimport { existsSync } from 'fs';\nimport {\n LinearTaskManager,\n TaskPriority,\n} from '../../features/tasks/linear-task-manager.js';\n\nfunction getTaskStore(projectRoot: string): LinearTaskManager | null {\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n if (!existsSync(dbPath)) {\n console.log(\n '\u274C StackMemory not initialized. Run \"stackmemory init\" first.'\n );\n return null;\n }\n \n // Use project isolation for proper task management\n const config = {\n linearApiKey: process.env.LINEAR_API_KEY,\n autoSync: true,\n syncInterval: 15,\n };\n return new LinearTaskManager(config, undefined, projectRoot);\n}\n\nexport function createTaskCommands(): Command {\n const tasks = new Command('tasks')\n .alias('task')\n .description('Manage tasks from command line');\n\n // List tasks\n tasks\n .command('list')\n .alias('ls')\n .description('List tasks')\n .option(\n '-s, --status <status>',\n 'Filter by status (pending, in_progress, completed, blocked)'\n )\n .option(\n '-p, --priority <priority>',\n 'Filter by priority (urgent, high, medium, low)'\n )\n .option('-q, --query <text>', 'Search in title/description')\n .option('-l, --limit <n>', 'Limit results', '20')\n .option('-a, --all', 'Include completed tasks')\n .action(async (options) => {\n const projectRoot = process.cwd();\n const taskStore = getTaskStore(projectRoot);\n if (!taskStore) return;\n\n try {\n // Get all tasks from DB\n const db = new Database(\n join(projectRoot, '.stackmemory', 'context.db')\n );\n let query = 'SELECT * FROM task_cache WHERE 1=1';\n const params: any[] = [];\n\n if (!options.all && !options.status) {\n query += \" AND status NOT IN ('completed', 'cancelled')\";\n }\n\n if (options.status) {\n query += ' AND status = ?';\n params.push(options.status);\n }\n\n if (options.priority) {\n query += ' AND priority = ?';\n params.push(options.priority);\n }\n\n if (options.query) {\n query += ' AND (title LIKE ? OR description LIKE ?)';\n params.push(`%${options.query}%`, `%${options.query}%`);\n }\n\n query += ' ORDER BY priority ASC, created_at DESC LIMIT ?';\n params.push(parseInt(options.limit));\n\n const rows = db.prepare(query).all(...params) as any[];\n db.close();\n\n if (rows.length === 0) {\n console.log('\uD83D\uDCDD No tasks found');\n return;\n }\n\n console.log(`\\n\uD83D\uDCCB Tasks (${rows.length})\\n`);\n\n const priorityIcon: Record<string, string> = {\n urgent: '\uD83D\uDD34',\n high: '\uD83D\uDFE0',\n medium: '\uD83D\uDFE1',\n low: '\uD83D\uDFE2',\n };\n const statusIcon: Record<string, string> = {\n pending: '\u23F3',\n in_progress: '\uD83D\uDD04',\n completed: '\u2705',\n blocked: '\uD83D\uDEAB',\n cancelled: '\u274C',\n };\n\n rows.forEach((row) => {\n const pIcon = priorityIcon[row.priority] || '\u26AA';\n const sIcon = statusIcon[row.status] || '\u26AA';\n const id = row.id.slice(0, 10);\n console.log(`${sIcon} ${pIcon} [${id}] ${row.title}`);\n if (row.description) {\n const desc = row.description.split('\\n')[0].slice(0, 60);\n console.log(\n ` ${desc}${row.description.length > 60 ? '...' : ''}`\n );\n }\n });\n console.log('');\n } catch (error: unknown) {\n console.error('\u274C Failed to list tasks:', (error as Error).message);\n }\n });\n\n // Add task\n tasks\n .command('add <title>')\n .description('Add a new task')\n .option('-d, --description <text>', 'Task description')\n .option(\n '-p, --priority <priority>',\n 'Priority (urgent, high, medium, low)',\n 'medium'\n )\n .option('-t, --tags <tags>', 'Comma-separated tags')\n .action(async (title, options) => {\n const projectRoot = process.cwd();\n const taskStore = getTaskStore(projectRoot);\n if (!taskStore) return;\n\n try {\n const taskId = taskStore.createTask({\n title,\n description: options.description,\n priority: options.priority as TaskPriority,\n frameId: 'cli',\n tags: options.tags\n ? options.tags.split(',').map((t: string) => t.trim())\n : [],\n });\n\n console.log(`\u2705 Created task: ${taskId.slice(0, 10)}`);\n console.log(` Title: ${title}`);\n console.log(` Priority: ${options.priority}`);\n } catch (error: unknown) {\n console.error('\u274C Failed to add task:', (error as Error).message);\n }\n });\n\n // Start task (set to in_progress)\n tasks\n .command('start <taskId>')\n .description('Start working on a task')\n .action(async (taskId) => {\n const projectRoot = process.cwd();\n const taskStore = getTaskStore(projectRoot);\n if (!taskStore) return;\n\n try {\n // Find task by partial ID\n const task = findTaskByPartialId(projectRoot, taskId);\n if (!task) {\n console.log(`\u274C Task not found: ${taskId}`);\n return;\n }\n\n taskStore.updateTaskStatus(task.id, 'in_progress', 'Started from CLI');\n console.log(`\uD83D\uDD04 Started: ${task.title}`);\n } catch (error: unknown) {\n console.error('\u274C Failed to start task:', (error as Error).message);\n }\n });\n\n // Complete task\n tasks\n .command('done <taskId>')\n .alias('complete')\n .description('Mark task as completed')\n .action(async (taskId) => {\n const projectRoot = process.cwd();\n const taskStore = getTaskStore(projectRoot);\n if (!taskStore) return;\n\n try {\n const task = findTaskByPartialId(projectRoot, taskId);\n if (!task) {\n console.log(`\u274C Task not found: ${taskId}`);\n return;\n }\n\n taskStore.updateTaskStatus(task.id, 'completed', 'Completed from CLI');\n console.log(`\u2705 Completed: ${task.title}`);\n } catch (error: unknown) {\n console.error('\u274C Failed to complete task:', (error as Error).message);\n }\n });\n\n // Show task details\n tasks\n .command('show <taskId>')\n .description('Show task details')\n .action(async (taskId) => {\n const projectRoot = process.cwd();\n\n try {\n const task = findTaskByPartialId(projectRoot, taskId);\n if (!task) {\n console.log(`\u274C Task not found: ${taskId}`);\n return;\n }\n\n console.log(`\\n\uD83D\uDCCB Task Details\\n`);\n console.log(`ID: ${task.id}`);\n console.log(`Title: ${task.title}`);\n console.log(`Status: ${task.status}`);\n console.log(`Priority: ${task.priority}`);\n console.log(\n `Created: ${new Date(task.created_at * 1000).toLocaleString()}`\n );\n if (task.completed_at) {\n console.log(\n `Completed: ${new Date(task.completed_at * 1000).toLocaleString()}`\n );\n }\n if (task.description) {\n console.log(`\\nDescription:\\n${task.description}`);\n }\n const tags = JSON.parse(task.tags || '[]');\n if (tags.length > 0) {\n console.log(`\\nTags: ${tags.join(', ')}`);\n }\n console.log('');\n } catch (error: unknown) {\n console.error('\u274C Failed to show task:', (error as Error).message);\n }\n });\n\n return tasks;\n}\n\nfunction findTaskByPartialId(\n projectRoot: string,\n partialId: string\n): any | null {\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n if (!existsSync(dbPath)) return null;\n\n const db = new Database(dbPath);\n\n // Try exact match first, then partial\n let row = db.prepare('SELECT * FROM task_cache WHERE id = ?').get(partialId);\n\n if (!row) {\n row = db\n .prepare('SELECT * FROM task_cache WHERE id LIKE ?')\n .get(`${partialId}%`);\n }\n\n // Also try matching Linear identifier in title\n if (!row && partialId.match(/^ENG-\\d+$/i)) {\n row = db\n .prepare('SELECT * FROM task_cache WHERE title LIKE ?')\n .get(`%[${partialId.toUpperCase()}]%`);\n }\n\n db.close();\n return row || null;\n}\n"],
|
|
5
|
-
"mappings": "AAKA,SAAS,eAAe;AACxB,OAAO,cAAc;AACrB,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAC3B;AAAA,EACE;AAAA,OAEK;AAEP,SAAS,aAAa,aAA+C;AACnE,QAAM,SAAS,KAAK,aAAa,gBAAgB,YAAY;AAC7D,MAAI,CAAC,WAAW,MAAM,GAAG;AACvB,YAAQ;AAAA,MACN;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAGA,QAAM,SAAS;AAAA,IACb,cAAc,QAAQ,IAAI;AAAA,
|
|
4
|
+
"sourcesContent": ["/**\n * Enhanced Task Commands for StackMemory CLI\n * Provides task management directly from command line\n */\n\nimport { Command } from 'commander';\nimport Database from 'better-sqlite3';\nimport { join } from 'path';\nimport { existsSync } from 'fs';\nimport {\n LinearTaskManager,\n TaskPriority,\n} from '../../features/tasks/linear-task-manager.js';\n\nfunction getTaskStore(projectRoot: string): LinearTaskManager | null {\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n if (!existsSync(dbPath)) {\n console.log(\n '\u274C StackMemory not initialized. Run \"stackmemory init\" first.'\n );\n return null;\n }\n \n // Use project isolation for proper task management\n const config = {\n linearApiKey: process.env.STACKMEMORY_LINEAR_API_KEY || process.env.LINEAR_API_KEY,\n autoSync: true,\n syncInterval: 15,\n };\n return new LinearTaskManager(config, undefined, projectRoot);\n}\n\nexport function createTaskCommands(): Command {\n const tasks = new Command('tasks')\n .alias('task')\n .description('Manage tasks from command line');\n\n // List tasks\n tasks\n .command('list')\n .alias('ls')\n .description('List tasks')\n .option(\n '-s, --status <status>',\n 'Filter by status (pending, in_progress, completed, blocked)'\n )\n .option(\n '-p, --priority <priority>',\n 'Filter by priority (urgent, high, medium, low)'\n )\n .option('-q, --query <text>', 'Search in title/description')\n .option('-l, --limit <n>', 'Limit results', '20')\n .option('-a, --all', 'Include completed tasks')\n .action(async (options) => {\n const projectRoot = process.cwd();\n const taskStore = getTaskStore(projectRoot);\n if (!taskStore) return;\n\n try {\n // Get all tasks from DB\n const db = new Database(\n join(projectRoot, '.stackmemory', 'context.db')\n );\n let query = 'SELECT * FROM task_cache WHERE 1=1';\n const params: any[] = [];\n\n if (!options.all && !options.status) {\n query += \" AND status NOT IN ('completed', 'cancelled')\";\n }\n\n if (options.status) {\n query += ' AND status = ?';\n params.push(options.status);\n }\n\n if (options.priority) {\n query += ' AND priority = ?';\n params.push(options.priority);\n }\n\n if (options.query) {\n query += ' AND (title LIKE ? OR description LIKE ?)';\n params.push(`%${options.query}%`, `%${options.query}%`);\n }\n\n query += ' ORDER BY priority ASC, created_at DESC LIMIT ?';\n params.push(parseInt(options.limit));\n\n const rows = db.prepare(query).all(...params) as any[];\n db.close();\n\n if (rows.length === 0) {\n console.log('\uD83D\uDCDD No tasks found');\n return;\n }\n\n console.log(`\\n\uD83D\uDCCB Tasks (${rows.length})\\n`);\n\n const priorityIcon: Record<string, string> = {\n urgent: '\uD83D\uDD34',\n high: '\uD83D\uDFE0',\n medium: '\uD83D\uDFE1',\n low: '\uD83D\uDFE2',\n };\n const statusIcon: Record<string, string> = {\n pending: '\u23F3',\n in_progress: '\uD83D\uDD04',\n completed: '\u2705',\n blocked: '\uD83D\uDEAB',\n cancelled: '\u274C',\n };\n\n rows.forEach((row) => {\n const pIcon = priorityIcon[row.priority] || '\u26AA';\n const sIcon = statusIcon[row.status] || '\u26AA';\n const id = row.id.slice(0, 10);\n console.log(`${sIcon} ${pIcon} [${id}] ${row.title}`);\n if (row.description) {\n const desc = row.description.split('\\n')[0].slice(0, 60);\n console.log(\n ` ${desc}${row.description.length > 60 ? '...' : ''}`\n );\n }\n });\n console.log('');\n } catch (error: unknown) {\n console.error('\u274C Failed to list tasks:', (error as Error).message);\n }\n });\n\n // Add task\n tasks\n .command('add <title>')\n .description('Add a new task')\n .option('-d, --description <text>', 'Task description')\n .option(\n '-p, --priority <priority>',\n 'Priority (urgent, high, medium, low)',\n 'medium'\n )\n .option('-t, --tags <tags>', 'Comma-separated tags')\n .action(async (title, options) => {\n const projectRoot = process.cwd();\n const taskStore = getTaskStore(projectRoot);\n if (!taskStore) return;\n\n try {\n const taskId = taskStore.createTask({\n title,\n description: options.description,\n priority: options.priority as TaskPriority,\n frameId: 'cli',\n tags: options.tags\n ? options.tags.split(',').map((t: string) => t.trim())\n : [],\n });\n\n console.log(`\u2705 Created task: ${taskId.slice(0, 10)}`);\n console.log(` Title: ${title}`);\n console.log(` Priority: ${options.priority}`);\n } catch (error: unknown) {\n console.error('\u274C Failed to add task:', (error as Error).message);\n }\n });\n\n // Start task (set to in_progress)\n tasks\n .command('start <taskId>')\n .description('Start working on a task')\n .action(async (taskId) => {\n const projectRoot = process.cwd();\n const taskStore = getTaskStore(projectRoot);\n if (!taskStore) return;\n\n try {\n // Find task by partial ID\n const task = findTaskByPartialId(projectRoot, taskId);\n if (!task) {\n console.log(`\u274C Task not found: ${taskId}`);\n return;\n }\n\n taskStore.updateTaskStatus(task.id, 'in_progress', 'Started from CLI');\n console.log(`\uD83D\uDD04 Started: ${task.title}`);\n } catch (error: unknown) {\n console.error('\u274C Failed to start task:', (error as Error).message);\n }\n });\n\n // Complete task\n tasks\n .command('done <taskId>')\n .alias('complete')\n .description('Mark task as completed')\n .action(async (taskId) => {\n const projectRoot = process.cwd();\n const taskStore = getTaskStore(projectRoot);\n if (!taskStore) return;\n\n try {\n const task = findTaskByPartialId(projectRoot, taskId);\n if (!task) {\n console.log(`\u274C Task not found: ${taskId}`);\n return;\n }\n\n taskStore.updateTaskStatus(task.id, 'completed', 'Completed from CLI');\n console.log(`\u2705 Completed: ${task.title}`);\n } catch (error: unknown) {\n console.error('\u274C Failed to complete task:', (error as Error).message);\n }\n });\n\n // Show task details\n tasks\n .command('show <taskId>')\n .description('Show task details')\n .action(async (taskId) => {\n const projectRoot = process.cwd();\n\n try {\n const task = findTaskByPartialId(projectRoot, taskId);\n if (!task) {\n console.log(`\u274C Task not found: ${taskId}`);\n return;\n }\n\n console.log(`\\n\uD83D\uDCCB Task Details\\n`);\n console.log(`ID: ${task.id}`);\n console.log(`Title: ${task.title}`);\n console.log(`Status: ${task.status}`);\n console.log(`Priority: ${task.priority}`);\n console.log(\n `Created: ${new Date(task.created_at * 1000).toLocaleString()}`\n );\n if (task.completed_at) {\n console.log(\n `Completed: ${new Date(task.completed_at * 1000).toLocaleString()}`\n );\n }\n if (task.description) {\n console.log(`\\nDescription:\\n${task.description}`);\n }\n const tags = JSON.parse(task.tags || '[]');\n if (tags.length > 0) {\n console.log(`\\nTags: ${tags.join(', ')}`);\n }\n console.log('');\n } catch (error: unknown) {\n console.error('\u274C Failed to show task:', (error as Error).message);\n }\n });\n\n return tasks;\n}\n\nfunction findTaskByPartialId(\n projectRoot: string,\n partialId: string\n): any | null {\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n if (!existsSync(dbPath)) return null;\n\n const db = new Database(dbPath);\n\n // Try exact match first, then partial\n let row = db.prepare('SELECT * FROM task_cache WHERE id = ?').get(partialId);\n\n if (!row) {\n row = db\n .prepare('SELECT * FROM task_cache WHERE id LIKE ?')\n .get(`${partialId}%`);\n }\n\n // Also try matching Linear identifier in title\n if (!row && partialId.match(/^ENG-\\d+$/i)) {\n row = db\n .prepare('SELECT * FROM task_cache WHERE title LIKE ?')\n .get(`%[${partialId.toUpperCase()}]%`);\n }\n\n db.close();\n return row || null;\n}\n"],
|
|
5
|
+
"mappings": "AAKA,SAAS,eAAe;AACxB,OAAO,cAAc;AACrB,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAC3B;AAAA,EACE;AAAA,OAEK;AAEP,SAAS,aAAa,aAA+C;AACnE,QAAM,SAAS,KAAK,aAAa,gBAAgB,YAAY;AAC7D,MAAI,CAAC,WAAW,MAAM,GAAG;AACvB,YAAQ;AAAA,MACN;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAGA,QAAM,SAAS;AAAA,IACb,cAAc,QAAQ,IAAI,8BAA8B,QAAQ,IAAI;AAAA,IACpE,UAAU;AAAA,IACV,cAAc;AAAA,EAChB;AACA,SAAO,IAAI,kBAAkB,QAAQ,QAAW,WAAW;AAC7D;AAEO,SAAS,qBAA8B;AAC5C,QAAM,QAAQ,IAAI,QAAQ,OAAO,EAC9B,MAAM,MAAM,EACZ,YAAY,gCAAgC;AAG/C,QACG,QAAQ,MAAM,EACd,MAAM,IAAI,EACV,YAAY,YAAY,EACxB;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,OAAO,sBAAsB,6BAA6B,EAC1D,OAAO,mBAAmB,iBAAiB,IAAI,EAC/C,OAAO,aAAa,yBAAyB,EAC7C,OAAO,OAAO,YAAY;AACzB,UAAM,cAAc,QAAQ,IAAI;AAChC,UAAM,YAAY,aAAa,WAAW;AAC1C,QAAI,CAAC,UAAW;AAEhB,QAAI;AAEF,YAAM,KAAK,IAAI;AAAA,QACb,KAAK,aAAa,gBAAgB,YAAY;AAAA,MAChD;AACA,UAAI,QAAQ;AACZ,YAAM,SAAgB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I,EAAE,eAAe,CAAC;AAAA,MACnE;AACA,UAAI,KAAK,cAAc;AACrB,gBAAQ;AAAA,UACN,gBAAgB,IAAI,KAAK,KAAK,eAAe,GAAI,EAAE,eAAe,CAAC;AAAA,QACrE;AAAA,MACF;AACA,UAAI,KAAK,aAAa;AACpB,gBAAQ,IAAI;AAAA;AAAA,EAAmB,KAAK,WAAW,EAAE;AAAA,MACnD;AACA,YAAM,OAAO,KAAK,MAAM,KAAK,QAAQ,IAAI;AACzC,UAAI,KAAK,SAAS,GAAG;AACnB,gBAAQ,IAAI;AAAA,QAAW,KAAK,KAAK,IAAI,CAAC,EAAE;AAAA,MAC1C;AACA,cAAQ,IAAI,EAAE;AAAA,IAChB,SAAS,OAAgB;AACvB,cAAQ,MAAM,+BAA2B,MAAgB,OAAO;AAAA,IAClE;AAAA,EACF,CAAC;AAEH,SAAO;AACT;AAEA,SAAS,oBACP,aACA,WACY;AACZ,QAAM,SAAS,KAAK,aAAa,gBAAgB,YAAY;AAC7D,MAAI,CAAC,WAAW,MAAM,EAAG,QAAO;AAEhC,QAAM,KAAK,IAAI,SAAS,MAAM;AAG9B,MAAI,MAAM,GAAG,QAAQ,uCAAuC,EAAE,IAAI,SAAS;AAE3E,MAAI,CAAC,KAAK;AACR,UAAM,GACH,QAAQ,0CAA0C,EAClD,IAAI,GAAG,SAAS,GAAG;AAAA,EACxB;AAGA,MAAI,CAAC,OAAO,UAAU,MAAM,YAAY,GAAG;AACzC,UAAM,GACH,QAAQ,6CAA6C,EACrD,IAAI,KAAK,UAAU,YAAY,CAAC,IAAI;AAAA,EACzC;AAEA,KAAG,MAAM;AACT,SAAO,OAAO;AAChB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cli/index.js
CHANGED
|
@@ -29,12 +29,13 @@ import createWorkflowCommand from "./commands/workflow.js";
|
|
|
29
29
|
import monitorCommand from "./commands/monitor.js";
|
|
30
30
|
import qualityCommand from "./commands/quality.js";
|
|
31
31
|
import { registerLoginCommand } from "./commands/login.js";
|
|
32
|
+
import { registerSignupCommand } from "./commands/signup.js";
|
|
32
33
|
import { registerLogoutCommand, registerDbCommands } from "./commands/db.js";
|
|
33
34
|
import { ProjectManager } from "../core/projects/project-manager.js";
|
|
34
35
|
import Database from "better-sqlite3";
|
|
35
36
|
import { join } from "path";
|
|
36
37
|
import { existsSync, mkdirSync } from "fs";
|
|
37
|
-
const VERSION = "0.3.
|
|
38
|
+
const VERSION = "0.3.21";
|
|
38
39
|
UpdateChecker.checkForUpdates(VERSION, true).catch(() => {
|
|
39
40
|
});
|
|
40
41
|
program.name("stackmemory").description(
|
|
@@ -307,6 +308,7 @@ program.command("context:test").description("Test context persistence by creatin
|
|
|
307
308
|
}
|
|
308
309
|
});
|
|
309
310
|
registerOnboardingCommand(program);
|
|
311
|
+
registerSignupCommand(program);
|
|
310
312
|
registerLoginCommand(program);
|
|
311
313
|
registerLogoutCommand(program);
|
|
312
314
|
registerDbCommands(program);
|