@stackmemoryai/stackmemory 0.3.17 → 0.3.19
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 +51 -5
- package/dist/cli/claude-sm.js.map +2 -2
- package/dist/cli/codex-sm.js +52 -19
- package/dist/cli/codex-sm.js.map +2 -2
- package/dist/cli/commands/db.js +143 -0
- package/dist/cli/commands/db.js.map +7 -0
- package/dist/cli/commands/login.js +50 -0
- package/dist/cli/commands/login.js.map +7 -0
- package/dist/cli/commands/migrate.js +178 -0
- package/dist/cli/commands/migrate.js.map +7 -0
- package/dist/cli/commands/onboard.js +158 -2
- package/dist/cli/commands/onboard.js.map +2 -2
- package/dist/cli/commands/skills.js +15 -2
- package/dist/cli/commands/skills.js.map +2 -2
- package/dist/cli/index.js +118 -834
- package/dist/cli/index.js.map +3 -3
- package/dist/core/context/dual-stack-manager.js +1 -1
- package/dist/core/context/dual-stack-manager.js.map +1 -1
- package/dist/core/context/frame-database.js +1 -0
- package/dist/core/context/frame-database.js.map +2 -2
- package/dist/core/context/frame-manager.js +59 -2
- package/dist/core/context/frame-manager.js.map +2 -2
- package/dist/core/database/database-adapter.js +6 -1
- package/dist/core/database/database-adapter.js.map +2 -2
- package/dist/core/database/sqlite-adapter.js +60 -2
- package/dist/core/database/sqlite-adapter.js.map +2 -2
- package/dist/integrations/claude-code/subagent-client.js +106 -3
- package/dist/integrations/claude-code/subagent-client.js.map +2 -2
- package/dist/servers/railway/config.js +51 -0
- package/dist/servers/railway/config.js.map +7 -0
- package/dist/servers/railway/index-enhanced.js +156 -0
- package/dist/servers/railway/index-enhanced.js.map +7 -0
- package/dist/servers/railway/index.js +843 -82
- package/dist/servers/railway/index.js.map +3 -3
- package/dist/servers/railway/minimal.js +48 -3
- package/dist/servers/railway/minimal.js.map +2 -2
- package/dist/servers/railway/storage-test.js +455 -0
- package/dist/servers/railway/storage-test.js.map +7 -0
- package/dist/skills/claude-skills.js +13 -12
- package/dist/skills/claude-skills.js.map +2 -2
- package/dist/skills/recursive-agent-orchestrator.js +27 -18
- package/dist/skills/recursive-agent-orchestrator.js.map +2 -2
- package/dist/skills/unified-rlm-orchestrator.js.map +2 -2
- package/package.json +13 -21
- package/scripts/README-TESTING.md +186 -0
- package/scripts/analyze-cli-security.js +288 -0
- package/scripts/archive/add-phase-tasks-to-linear.js +163 -0
- package/scripts/archive/analyze-linear-duplicates.js +214 -0
- package/scripts/archive/analyze-remaining-duplicates.js +230 -0
- package/scripts/archive/analyze-sta-duplicates.js +292 -0
- package/scripts/archive/analyze-sta-graphql.js +399 -0
- package/scripts/archive/cancel-duplicate-tasks.ts +246 -0
- package/scripts/archive/check-all-duplicates.ts +419 -0
- package/scripts/archive/clean-duplicate-tasks.js +114 -0
- package/scripts/archive/cleanup-duplicate-tasks.ts +286 -0
- package/scripts/archive/create-phase-tasks.js +387 -0
- package/scripts/archive/delete-linear-duplicates.js +182 -0
- package/scripts/archive/delete-remaining-duplicates.js +158 -0
- package/scripts/archive/delete-sta-duplicates.js +201 -0
- package/scripts/archive/delete-sta-oauth.js +201 -0
- package/scripts/archive/export-sta-tasks.js +62 -0
- package/scripts/archive/install-auto-sync.js +266 -0
- package/scripts/archive/install-chromadb-hooks.sh +133 -0
- package/scripts/archive/install-enhanced-clear-hooks.sh +431 -0
- package/scripts/archive/install-post-task-hooks.sh +289 -0
- package/scripts/archive/install-stackmemory-hooks.sh +420 -0
- package/scripts/archive/merge-linear-duplicates-safe.ts +362 -0
- package/scripts/archive/merge-linear-duplicates.ts +180 -0
- package/scripts/archive/remove-sta-tasks.js +70 -0
- package/scripts/archive/setup-background-sync.sh +168 -0
- package/scripts/archive/setup-claude-auto-triggers.sh +181 -0
- package/scripts/archive/setup-claude-autostart.sh +305 -0
- package/scripts/archive/setup-git-hooks.sh +25 -0
- package/scripts/archive/setup-linear-oauth.sh +46 -0
- package/scripts/archive/setup-mcp.sh +113 -0
- package/scripts/archive/setup-railway-deployment.sh +81 -0
- package/scripts/auto-handoff.sh +262 -0
- package/scripts/background-sync-manager.js +416 -0
- package/scripts/benchmark-performance.ts +57 -0
- package/scripts/check-redis.ts +48 -0
- package/scripts/chromadb-auto-loader.sh +128 -0
- package/scripts/chromadb-context-loader.js +479 -0
- package/scripts/claude-chromadb-hook.js +460 -0
- package/scripts/claude-code-wrapper.sh +66 -0
- package/scripts/claude-linear-skill.js +455 -0
- package/scripts/claude-pre-commit.sh +302 -0
- package/scripts/claude-sm-autostart.js +532 -0
- package/scripts/claude-sm-setup.sh +367 -0
- package/scripts/claude-with-chromadb.sh +69 -0
- package/scripts/claude-worktree-manager.sh +323 -0
- package/scripts/claude-worktree-monitor.sh +371 -0
- package/scripts/claude-worktree-setup.sh +327 -0
- package/scripts/clean-linear-backlog.js +273 -0
- package/scripts/cleanup-old-sessions.sh +57 -0
- package/scripts/codex-wrapper.sh +88 -0
- package/scripts/create-sandbox.sh +269 -0
- package/scripts/debug-linear-update.js +174 -0
- package/scripts/delete-linear-tasks.js +167 -0
- package/scripts/deploy.sh +89 -0
- package/scripts/deployment/railway.sh +352 -0
- package/scripts/deployment/test-deployment.js +194 -0
- package/scripts/detect-and-rehydrate.js +162 -0
- package/scripts/detect-and-rehydrate.mjs +165 -0
- package/scripts/development/create-demo-tasks.js +143 -0
- package/scripts/development/debug-frame-test.js +16 -0
- package/scripts/development/demo-auto-sync.js +128 -0
- package/scripts/development/fix-all-imports.js +213 -0
- package/scripts/development/fix-imports.js +229 -0
- package/scripts/development/fix-lint-loop.cjs +103 -0
- package/scripts/development/fix-project-id.ts +161 -0
- package/scripts/development/fix-strict-mode-issues.ts +291 -0
- package/scripts/development/reorganize-structure.sh +228 -0
- package/scripts/development/test-persistence-direct.js +148 -0
- package/scripts/development/test-persistence.js +114 -0
- package/scripts/development/test-tasks.js +93 -0
- package/scripts/development/update-imports.js +212 -0
- package/scripts/fetch-linear-status.js +125 -0
- package/scripts/git-hooks/README.md +310 -0
- package/scripts/git-hooks/branch-context-manager.sh +342 -0
- package/scripts/git-hooks/post-checkout-stackmemory.sh +63 -0
- package/scripts/git-hooks/post-commit-stackmemory.sh +305 -0
- package/scripts/git-hooks/pre-commit-stackmemory.sh +275 -0
- package/scripts/hooks/cleanup-shell.sh +130 -0
- package/scripts/hooks/task-complete.sh +114 -0
- package/scripts/initialize.ts +129 -0
- package/scripts/install-claude-hooks-auto.js +104 -0
- package/scripts/install-claude-hooks.sh +133 -0
- package/scripts/install-global.sh +296 -0
- package/scripts/install.sh +235 -0
- package/scripts/linear-auto-sync.js +262 -0
- package/scripts/linear-auto-sync.sh +161 -0
- package/scripts/linear-sync-daemon.js +150 -0
- package/scripts/linear-task-review.js +237 -0
- package/scripts/list-linear-tasks.ts +178 -0
- package/scripts/mcp-proxy.js +66 -0
- package/scripts/opencode-wrapper.sh +85 -0
- package/scripts/publish-local.js +74 -0
- package/scripts/query-chromadb.ts +201 -0
- package/scripts/railway-env-setup.sh +39 -0
- package/scripts/reconcile-local-tasks.js +170 -0
- package/scripts/recreate-frames-db.js +89 -0
- package/scripts/setup/claude-integration.js +138 -0
- package/scripts/setup/configure-alias.js +125 -0
- package/scripts/setup/configure-codex-alias.js +161 -0
- package/scripts/setup/configure-opencode-alias.js +175 -0
- package/scripts/setup-claude-integration.js +204 -0
- package/scripts/setup-claude-integration.sh +183 -0
- package/scripts/setup-railway-deployment.sh +37 -0
- package/scripts/setup.sh +31 -0
- package/scripts/show-linear-summary.ts +172 -0
- package/scripts/stackmemory-auto-handoff.sh +231 -0
- package/scripts/stackmemory-daemon.sh +40 -0
- package/scripts/start-linear-sync-daemon.sh +141 -0
- package/scripts/start-temporal-paradox.sh +214 -0
- package/scripts/status.ts +159 -0
- package/scripts/sync-and-clean-tasks.js +258 -0
- package/scripts/sync-frames-from-railway.js +228 -0
- package/scripts/sync-linear-graphql.js +303 -0
- package/scripts/sync-linear-tasks.js +186 -0
- package/scripts/test-auto-triggers.sh +57 -0
- package/scripts/test-browser-mcp.js +74 -0
- package/scripts/test-chromadb-full.js +115 -0
- package/scripts/test-chromadb-hooks.sh +28 -0
- package/scripts/test-chromadb-sync.ts +245 -0
- package/scripts/test-cli-security.js +293 -0
- package/scripts/test-hooks-persistence.sh +220 -0
- package/scripts/test-installation-scenarios.sh +359 -0
- package/scripts/test-installation.sh +224 -0
- package/scripts/test-mcp.js +163 -0
- package/scripts/test-pre-publish-quick.sh +75 -0
- package/scripts/test-quality-gates.sh +263 -0
- package/scripts/test-railway-db.js +222 -0
- package/scripts/test-redis-storage.ts +490 -0
- package/scripts/test-rlm-basic.sh +122 -0
- package/scripts/test-rlm-comprehensive.sh +260 -0
- package/scripts/test-rlm-e2e.sh +268 -0
- package/scripts/test-rlm-simple.js +90 -0
- package/scripts/test-rlm.js +110 -0
- package/scripts/test-session-handoff.sh +165 -0
- package/scripts/test-shell-integration.sh +275 -0
- package/scripts/testing/ab-test-runner.ts +508 -0
- package/scripts/testing/collect-metrics.ts +457 -0
- package/scripts/testing/quick-effectiveness-demo.js +187 -0
- package/scripts/testing/real-performance-test.js +422 -0
- package/scripts/testing/run-effectiveness-tests.sh +176 -0
- package/scripts/testing/scripts/testing/ab-test-runner.js +363 -0
- package/scripts/testing/scripts/testing/collect-metrics.js +292 -0
- package/scripts/testing/simple-effectiveness-test.js +310 -0
- package/scripts/testing/src/core/context/context-bridge.js +253 -0
- package/scripts/testing/src/core/context/frame-manager.js +746 -0
- package/scripts/testing/src/core/context/shared-context-layer.js +437 -0
- package/scripts/testing/src/core/database/database-adapter.js +54 -0
- package/scripts/testing/src/core/errors/index.js +291 -0
- package/scripts/testing/src/core/errors/recovery.js +268 -0
- package/scripts/testing/src/core/monitoring/logger.js +145 -0
- package/scripts/testing/src/core/retrieval/context-retriever.js +516 -0
- package/scripts/testing/src/core/session/index.js +1 -0
- package/scripts/testing/src/core/session/session-manager.js +323 -0
- package/scripts/testing/src/core/trace/cli-trace-wrapper.js +140 -0
- package/scripts/testing/src/core/trace/db-trace-wrapper.js +251 -0
- package/scripts/testing/src/core/trace/debug-trace.js +398 -0
- package/scripts/testing/src/core/trace/index.js +120 -0
- package/scripts/testing/src/core/trace/linear-api-wrapper.js +204 -0
- package/scripts/update-linear-status.js +268 -0
- package/scripts/update-linear-tasks-fixed.js +284 -0
- package/scripts/verify-railway-schema.ts +35 -0
- package/templates/claude-hooks/hooks.json +5 -0
- package/templates/claude-hooks/on-clear.js +56 -0
- package/templates/claude-hooks/on-startup.js +56 -0
- package/templates/claude-hooks/tool-use-trace.js +67 -0
- package/dist/features/tui/components/analytics-panel.js +0 -157
- package/dist/features/tui/components/analytics-panel.js.map +0 -7
- package/dist/features/tui/components/frame-visualizer.js +0 -377
- package/dist/features/tui/components/frame-visualizer.js.map +0 -7
- package/dist/features/tui/components/pr-tracker.js +0 -135
- package/dist/features/tui/components/pr-tracker.js.map +0 -7
- package/dist/features/tui/components/session-monitor.js +0 -299
- package/dist/features/tui/components/session-monitor.js.map +0 -7
- package/dist/features/tui/components/subagent-fleet.js +0 -395
- package/dist/features/tui/components/subagent-fleet.js.map +0 -7
- package/dist/features/tui/components/task-board.js +0 -1139
- package/dist/features/tui/components/task-board.js.map +0 -7
- package/dist/features/tui/index.js +0 -408
- package/dist/features/tui/index.js.map +0 -7
- package/dist/features/tui/services/data-service.js +0 -641
- package/dist/features/tui/services/data-service.js.map +0 -7
- package/dist/features/tui/services/linear-task-reader.js +0 -102
- package/dist/features/tui/services/linear-task-reader.js.map +0 -7
- package/dist/features/tui/services/websocket-client.js +0 -162
- package/dist/features/tui/services/websocket-client.js.map +0 -7
- package/dist/features/tui/terminal-compat.js +0 -220
- package/dist/features/tui/terminal-compat.js.map +0 -7
- package/dist/features/tui/types.js +0 -1
- package/dist/features/tui/types.js.map +0 -7
package/dist/cli/index.js
CHANGED
|
@@ -1,46 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
process.env["STACKMEMORY_CLI"] = "true";
|
|
3
|
+
import "dotenv/config";
|
|
4
|
+
import { initializeTracing, trace } from "../core/trace/index.js";
|
|
5
|
+
initializeTracing();
|
|
3
6
|
import { program } from "commander";
|
|
4
7
|
import { logger } from "../core/monitoring/logger.js";
|
|
5
8
|
import { FrameManager } from "../core/context/frame-manager.js";
|
|
6
9
|
import { sessionManager, FrameQueryMode } from "../core/session/index.js";
|
|
7
10
|
import { sharedContextLayer } from "../core/context/shared-context-layer.js";
|
|
8
|
-
import { LinearTaskManager } from "../features/tasks/linear-task-manager.js";
|
|
9
|
-
import {
|
|
10
|
-
LinearAuthManager,
|
|
11
|
-
LinearOAuthSetup
|
|
12
|
-
} from "../integrations/linear/auth.js";
|
|
13
|
-
import {
|
|
14
|
-
LinearSyncEngine,
|
|
15
|
-
DEFAULT_SYNC_CONFIG
|
|
16
|
-
} from "../integrations/linear/sync.js";
|
|
17
|
-
import {
|
|
18
|
-
initializeAutoSync,
|
|
19
|
-
getAutoSyncService,
|
|
20
|
-
stopAutoSync
|
|
21
|
-
} from "../integrations/linear/auto-sync.js";
|
|
22
|
-
import { LinearConfigManager } from "../integrations/linear/config.js";
|
|
23
11
|
import { UpdateChecker } from "../core/utils/update-checker.js";
|
|
24
12
|
import { ProgressTracker } from "../core/monitoring/progress-tracker.js";
|
|
25
13
|
import { registerProjectCommands } from "./commands/projects.js";
|
|
26
14
|
import { registerLinearCommands } from "./commands/linear.js";
|
|
27
|
-
import { registerLinearTestCommand } from "./commands/linear-test.js";
|
|
28
|
-
import { registerLinearListCommand } from "./commands/linear-list.js";
|
|
29
|
-
import { registerLinearMigrateCommand } from "./commands/linear-migrate.js";
|
|
30
|
-
import { registerLinearCreateCommand } from "./commands/linear-create.js";
|
|
31
|
-
import { createChromaDBCommand } from "./commands/chromadb.js";
|
|
32
|
-
import { createInfiniteStorageCommand } from "./commands/infinite-storage.js";
|
|
33
|
-
import { createGCCommand } from "./commands/gc.js";
|
|
34
15
|
import { createSessionCommands } from "./commands/session.js";
|
|
35
16
|
import { registerWorktreeCommands } from "./commands/worktree.js";
|
|
36
17
|
import { registerOnboardingCommand } from "./commands/onboard.js";
|
|
37
|
-
import { webhookCommand } from "./commands/webhook.js";
|
|
38
18
|
import { createTaskCommands } from "./commands/tasks.js";
|
|
39
19
|
import { createSearchCommand } from "./commands/search.js";
|
|
40
20
|
import { createLogCommand } from "./commands/log.js";
|
|
41
21
|
import { createContextCommands } from "./commands/context.js";
|
|
42
22
|
import { createConfigCommand } from "./commands/config.js";
|
|
43
|
-
import { createAgentCommand } from "./commands/agent.js";
|
|
44
23
|
import { createHandoffCommand } from "./commands/handoff.js";
|
|
45
24
|
import { createStorageCommand } from "./commands/storage.js";
|
|
46
25
|
import { createSkillsCommand } from "./commands/skills.js";
|
|
@@ -49,11 +28,13 @@ import clearCommand from "./commands/clear.js";
|
|
|
49
28
|
import createWorkflowCommand from "./commands/workflow.js";
|
|
50
29
|
import monitorCommand from "./commands/monitor.js";
|
|
51
30
|
import qualityCommand from "./commands/quality.js";
|
|
31
|
+
import { registerLoginCommand } from "./commands/login.js";
|
|
32
|
+
import { registerLogoutCommand, registerDbCommands } from "./commands/db.js";
|
|
52
33
|
import { ProjectManager } from "../core/projects/project-manager.js";
|
|
53
34
|
import Database from "better-sqlite3";
|
|
54
35
|
import { join } from "path";
|
|
55
36
|
import { existsSync, mkdirSync } from "fs";
|
|
56
|
-
const VERSION = "0.3.
|
|
37
|
+
const VERSION = "0.3.17";
|
|
57
38
|
UpdateChecker.checkForUpdates(VERSION, true).catch(() => {
|
|
58
39
|
});
|
|
59
40
|
program.name("stackmemory").description(
|
|
@@ -79,54 +60,55 @@ program.command("init").description("Initialize StackMemory in current project")
|
|
|
79
60
|
}
|
|
80
61
|
});
|
|
81
62
|
program.command("status").description("Show current StackMemory status").option("--all", "Show all active frames across sessions").option("--project", "Show all active frames in current project").option("--session <id>", "Show frames for specific session").action(async (options) => {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
63
|
+
return trace.command("stackmemory-status", options, async () => {
|
|
64
|
+
try {
|
|
65
|
+
const projectRoot = process.cwd();
|
|
66
|
+
const dbPath = join(projectRoot, ".stackmemory", "context.db");
|
|
67
|
+
if (!existsSync(dbPath)) {
|
|
68
|
+
console.log(
|
|
69
|
+
'\u274C StackMemory not initialized. Run "stackmemory init" first.'
|
|
70
|
+
);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
await UpdateChecker.checkForUpdates(VERSION);
|
|
74
|
+
await sessionManager.initialize();
|
|
75
|
+
await sharedContextLayer.initialize();
|
|
76
|
+
const session = await sessionManager.getOrCreateSession({
|
|
77
|
+
projectPath: projectRoot,
|
|
78
|
+
sessionId: options.session
|
|
79
|
+
});
|
|
80
|
+
const contextDiscovery = await sharedContextLayer.autoDiscoverContext();
|
|
81
|
+
if (contextDiscovery.hasSharedContext && contextDiscovery.sessionCount > 1) {
|
|
82
|
+
console.log(`
|
|
101
83
|
\u{1F4A1} Shared Context Available:`);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
84
|
+
console.log(
|
|
85
|
+
` ${contextDiscovery.sessionCount} sessions with shared context`
|
|
86
|
+
);
|
|
87
|
+
if (contextDiscovery.recentPatterns.length > 0) {
|
|
88
|
+
console.log(` Recent patterns:`);
|
|
89
|
+
contextDiscovery.recentPatterns.slice(0, 3).forEach((p) => {
|
|
90
|
+
console.log(
|
|
91
|
+
` \u2022 ${p.type}: ${p.pattern.slice(0, 50)} (${p.frequency}x)`
|
|
92
|
+
);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
if (contextDiscovery.lastDecisions.length > 0) {
|
|
108
96
|
console.log(
|
|
109
|
-
`
|
|
97
|
+
` Last decision: ${contextDiscovery.lastDecisions[0].decision.slice(0, 60)}`
|
|
110
98
|
);
|
|
111
|
-
}
|
|
99
|
+
}
|
|
112
100
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
);
|
|
101
|
+
const db = new Database(dbPath);
|
|
102
|
+
const frameManager = new FrameManager(db, session.projectId);
|
|
103
|
+
if (options.all) {
|
|
104
|
+
frameManager.setQueryMode(FrameQueryMode.ALL_ACTIVE);
|
|
105
|
+
} else if (options.project) {
|
|
106
|
+
frameManager.setQueryMode(FrameQueryMode.PROJECT_ACTIVE);
|
|
117
107
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
frameManager.setQueryMode(FrameQueryMode.ALL_ACTIVE);
|
|
123
|
-
} else if (options.project) {
|
|
124
|
-
frameManager.setQueryMode(FrameQueryMode.PROJECT_ACTIVE);
|
|
125
|
-
}
|
|
126
|
-
const activeFrames = frameManager.getActiveFramePath();
|
|
127
|
-
const stackDepth = frameManager.getStackDepth();
|
|
128
|
-
const totalStats = db.prepare(
|
|
129
|
-
`
|
|
108
|
+
const activeFrames = frameManager.getActiveFramePath();
|
|
109
|
+
const stackDepth = frameManager.getStackDepth();
|
|
110
|
+
const totalStats = db.prepare(
|
|
111
|
+
`
|
|
130
112
|
SELECT
|
|
131
113
|
COUNT(*) as total_frames,
|
|
132
114
|
SUM(CASE WHEN state = 'active' THEN 1 ELSE 0 END) as active_frames,
|
|
@@ -135,577 +117,97 @@ program.command("status").description("Show current StackMemory status").option(
|
|
|
135
117
|
FROM frames
|
|
136
118
|
WHERE project_id = ?
|
|
137
119
|
`
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
120
|
+
).get(session.projectId);
|
|
121
|
+
const contextCount = db.prepare(
|
|
122
|
+
`
|
|
141
123
|
SELECT COUNT(*) as count FROM contexts
|
|
142
124
|
`
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
125
|
+
).get();
|
|
126
|
+
const eventCount = db.prepare(
|
|
127
|
+
`
|
|
146
128
|
SELECT COUNT(*) as count FROM events e
|
|
147
129
|
JOIN frames f ON e.frame_id = f.frame_id
|
|
148
130
|
WHERE f.project_id = ?
|
|
149
131
|
`
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
132
|
+
).get(session.projectId);
|
|
133
|
+
console.log("\u{1F4CA} StackMemory Status:");
|
|
134
|
+
console.log(
|
|
135
|
+
` Session: ${session.sessionId.slice(0, 8)} (${session.state}, ${Math.round((Date.now() - session.startedAt) / 1e3 / 60)}min old)`
|
|
136
|
+
);
|
|
137
|
+
console.log(` Project: ${session.projectId}`);
|
|
138
|
+
if (session.branch) {
|
|
139
|
+
console.log(` Branch: ${session.branch}`);
|
|
140
|
+
}
|
|
141
|
+
console.log(`
|
|
160
142
|
Database Statistics (this project):`);
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
143
|
+
console.log(
|
|
144
|
+
` Frames: ${totalStats.total_frames || 0} (${totalStats.active_frames || 0} active, ${totalStats.closed_frames || 0} closed)`
|
|
145
|
+
);
|
|
146
|
+
console.log(` Events: ${eventCount.count || 0}`);
|
|
147
|
+
console.log(` Sessions: ${totalStats.total_sessions || 0}`);
|
|
148
|
+
console.log(
|
|
149
|
+
` Cached contexts: ${contextCount.count || 0} (global)`
|
|
150
|
+
);
|
|
151
|
+
const recentFrames = db.prepare(
|
|
152
|
+
`
|
|
169
153
|
SELECT name, type, state, datetime(created_at, 'unixepoch') as created
|
|
170
154
|
FROM frames
|
|
171
155
|
WHERE project_id = ?
|
|
172
156
|
ORDER BY created_at DESC
|
|
173
157
|
LIMIT 3
|
|
174
158
|
`
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
console.log(`
|
|
178
|
-
Recent Activity:`);
|
|
179
|
-
recentFrames.forEach((f) => {
|
|
180
|
-
const stateIcon = f.state === "active" ? "\u{1F7E2}" : "\u26AB";
|
|
181
|
-
console.log(` ${stateIcon} ${f.name} [${f.type}] - ${f.created}`);
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
console.log(`
|
|
185
|
-
Current Session:`);
|
|
186
|
-
console.log(` Stack depth: ${stackDepth}`);
|
|
187
|
-
console.log(` Active frames: ${activeFrames.length}`);
|
|
188
|
-
if (activeFrames.length > 0) {
|
|
189
|
-
activeFrames.forEach((frame, i) => {
|
|
190
|
-
const indent = " " + " ".repeat(frame.depth || i);
|
|
191
|
-
const prefix = i === 0 ? "\u2514\u2500" : " \u2514\u2500";
|
|
192
|
-
console.log(`${indent}${prefix} ${frame.name} [${frame.type}]`);
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
if (!options.all && !options.project) {
|
|
196
|
-
const otherSessions = await sessionManager.listSessions({
|
|
197
|
-
projectId: session.projectId,
|
|
198
|
-
state: "active"
|
|
199
|
-
});
|
|
200
|
-
const otherActive = otherSessions.filter(
|
|
201
|
-
(s) => s.sessionId !== session.sessionId
|
|
202
|
-
);
|
|
203
|
-
if (otherActive.length > 0) {
|
|
159
|
+
).all(session.projectId);
|
|
160
|
+
if (recentFrames.length > 0) {
|
|
204
161
|
console.log(`
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
const
|
|
208
|
-
(Date.now() - s.lastActiveAt) / 1e3 / 60 / 60
|
|
209
|
-
);
|
|
162
|
+
Recent Activity:`);
|
|
163
|
+
recentFrames.forEach((f) => {
|
|
164
|
+
const stateIcon = f.state === "active" ? "\u{1F7E2}" : "\u26AB";
|
|
210
165
|
console.log(
|
|
211
|
-
`
|
|
166
|
+
` ${stateIcon} ${f.name} [${f.type}] - ${f.created}`
|
|
212
167
|
);
|
|
213
168
|
});
|
|
214
|
-
console.log(`
|
|
215
|
-
Tip: Use --all to see frames across sessions`);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
db.close();
|
|
219
|
-
} catch (error) {
|
|
220
|
-
logger.error("Failed to get status", error);
|
|
221
|
-
console.error("\u274C Status check failed:", error.message);
|
|
222
|
-
process.exit(1);
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
const linearCommand = program.command("linear").description("Linear API integration commands");
|
|
226
|
-
linearCommand.command("setup").description("Setup Linear OAuth integration").action(async () => {
|
|
227
|
-
try {
|
|
228
|
-
const projectRoot = process.cwd();
|
|
229
|
-
const linearSetup = new LinearOAuthSetup(projectRoot);
|
|
230
|
-
const { authUrl, instructions } = await linearSetup.setupInteractive();
|
|
231
|
-
console.log("\u{1F517} Linear OAuth Setup\n");
|
|
232
|
-
instructions.forEach((instruction) => {
|
|
233
|
-
console.log(instruction);
|
|
234
|
-
});
|
|
235
|
-
if (authUrl) {
|
|
236
|
-
console.log("\n\u{1F4CB} Next step: Complete authorization and run:");
|
|
237
|
-
console.log("stackmemory linear authorize <auth-code>");
|
|
238
|
-
}
|
|
239
|
-
} catch (error) {
|
|
240
|
-
logger.error("Linear setup failed", error);
|
|
241
|
-
console.error("\u274C Setup failed:", error.message);
|
|
242
|
-
process.exit(1);
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
linearCommand.command("authorize").description("Complete Linear OAuth authorization").argument("<code>", "Authorization code from Linear").action(async (authCode) => {
|
|
246
|
-
try {
|
|
247
|
-
const projectRoot = process.cwd();
|
|
248
|
-
const linearSetup = new LinearOAuthSetup(projectRoot);
|
|
249
|
-
const success = await linearSetup.completeAuth(authCode);
|
|
250
|
-
if (success) {
|
|
251
|
-
console.log("\u2705 Linear integration authorized successfully!");
|
|
252
|
-
console.log("\u{1F9EA} Testing connection...");
|
|
253
|
-
const connectionOk = await linearSetup.testConnection();
|
|
254
|
-
if (connectionOk) {
|
|
255
|
-
console.log("\u2705 Linear connection test passed!");
|
|
256
|
-
console.log("\n\u{1F680} You can now use:");
|
|
257
|
-
console.log("- stackmemory linear sync");
|
|
258
|
-
console.log("- stackmemory linear status");
|
|
259
|
-
} else {
|
|
260
|
-
console.log(
|
|
261
|
-
"\u26A0\uFE0F Linear connection test failed. Check your configuration."
|
|
262
|
-
);
|
|
263
169
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
});
|
|
274
|
-
linearCommand.command("status").description("Show Linear integration status").action(async () => {
|
|
275
|
-
try {
|
|
276
|
-
const projectRoot = process.cwd();
|
|
277
|
-
const authManager = new LinearAuthManager(projectRoot);
|
|
278
|
-
const isConfigured = authManager.isConfigured();
|
|
279
|
-
console.log("\u{1F4CA} Linear Integration Status:");
|
|
280
|
-
console.log(` Configured: ${isConfigured ? "\u2705" : "\u274C"}`);
|
|
281
|
-
if (isConfigured) {
|
|
282
|
-
const config = authManager.loadConfig();
|
|
283
|
-
const tokens = authManager.loadTokens();
|
|
284
|
-
console.log(
|
|
285
|
-
` Client ID: ${config?.clientId ? config.clientId.substring(0, 8) + "..." : "Not set"}`
|
|
286
|
-
);
|
|
287
|
-
console.log(` Tokens: ${tokens ? "\u2705 Valid" : "\u274C Missing"}`);
|
|
288
|
-
if (tokens) {
|
|
289
|
-
const expiresIn = Math.floor(
|
|
290
|
-
(tokens.expiresAt - Date.now()) / 1e3 / 60
|
|
291
|
-
);
|
|
292
|
-
console.log(
|
|
293
|
-
` Token expires: ${expiresIn > 0 ? `${expiresIn} minutes` : "Expired"}`
|
|
294
|
-
);
|
|
295
|
-
}
|
|
296
|
-
console.log("\n\u{1F9EA} Testing connection...");
|
|
297
|
-
const linearSetup = new LinearOAuthSetup(projectRoot);
|
|
298
|
-
const connectionOk = await linearSetup.testConnection();
|
|
299
|
-
console.log(` Connection: ${connectionOk ? "\u2705 OK" : "\u274C Failed"}`);
|
|
300
|
-
} else {
|
|
301
|
-
console.log('\n\u{1F4A1} Run "stackmemory linear setup" to get started');
|
|
302
|
-
}
|
|
303
|
-
} catch (error) {
|
|
304
|
-
logger.error("Linear status check failed", error);
|
|
305
|
-
console.error("\u274C Status check failed:", error.message);
|
|
306
|
-
process.exit(1);
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
linearCommand.command("sync").description("Sync tasks with Linear").option(
|
|
310
|
-
"-d, --direction <direction>",
|
|
311
|
-
"Sync direction: bidirectional, to_linear, from_linear",
|
|
312
|
-
"bidirectional"
|
|
313
|
-
).action(async (options) => {
|
|
314
|
-
try {
|
|
315
|
-
const projectRoot = process.cwd();
|
|
316
|
-
const dbPath = join(projectRoot, ".stackmemory", "context.db");
|
|
317
|
-
if (!existsSync(dbPath)) {
|
|
318
|
-
console.log(
|
|
319
|
-
'\u274C StackMemory not initialized. Run "stackmemory init" first.'
|
|
320
|
-
);
|
|
321
|
-
return;
|
|
322
|
-
}
|
|
323
|
-
const authManager = new LinearAuthManager(projectRoot);
|
|
324
|
-
if (!process.env["LINEAR_API_KEY"] && !authManager.isConfigured()) {
|
|
325
|
-
console.log(
|
|
326
|
-
'\u274C Linear not configured. Set LINEAR_API_KEY environment variable or run "stackmemory linear setup" first.'
|
|
327
|
-
);
|
|
328
|
-
return;
|
|
329
|
-
}
|
|
330
|
-
const db = new Database(dbPath);
|
|
331
|
-
const taskStore = new LinearTaskManager(projectRoot, db);
|
|
332
|
-
const syncConfig = {
|
|
333
|
-
...DEFAULT_SYNC_CONFIG,
|
|
334
|
-
enabled: true,
|
|
335
|
-
direction: options.direction
|
|
336
|
-
};
|
|
337
|
-
const linearSync = new LinearSyncEngine(
|
|
338
|
-
taskStore,
|
|
339
|
-
authManager,
|
|
340
|
-
syncConfig
|
|
341
|
-
);
|
|
342
|
-
console.log(`\u{1F504} Starting ${options.direction} sync with Linear...`);
|
|
343
|
-
const result = await linearSync.sync();
|
|
344
|
-
const progress = new ProgressTracker(projectRoot);
|
|
345
|
-
if (result.success) {
|
|
346
|
-
console.log("\u2705 Sync completed successfully!");
|
|
347
|
-
console.log(` To Linear: ${result.synced.toLinear} created`);
|
|
348
|
-
console.log(` From Linear: ${result.synced.fromLinear} created`);
|
|
349
|
-
console.log(` Updated: ${result.synced.updated}`);
|
|
350
|
-
progress.updateLinearStatus({
|
|
351
|
-
lastSync: (/* @__PURE__ */ new Date()).toISOString(),
|
|
352
|
-
tasksSynced: result.synced.toLinear + result.synced.fromLinear + result.synced.updated
|
|
353
|
-
});
|
|
354
|
-
if (result.conflicts.length > 0) {
|
|
355
|
-
console.log(`
|
|
356
|
-
\u26A0\uFE0F Conflicts detected: ${result.conflicts.length}`);
|
|
357
|
-
result.conflicts.forEach((conflict) => {
|
|
358
|
-
console.log(` - ${conflict.taskId}: ${conflict.reason}`);
|
|
170
|
+
console.log(`
|
|
171
|
+
Current Session:`);
|
|
172
|
+
console.log(` Stack depth: ${stackDepth}`);
|
|
173
|
+
console.log(` Active frames: ${activeFrames.length}`);
|
|
174
|
+
if (activeFrames.length > 0) {
|
|
175
|
+
activeFrames.forEach((frame, i) => {
|
|
176
|
+
const indent = " " + " ".repeat(frame.depth || i);
|
|
177
|
+
const prefix = i === 0 ? "\u2514\u2500" : " \u2514\u2500";
|
|
178
|
+
console.log(`${indent}${prefix} ${frame.name} [${frame.type}]`);
|
|
359
179
|
});
|
|
360
180
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
console.log(` Error: ${error}`);
|
|
181
|
+
if (!options.all && !options.project) {
|
|
182
|
+
const otherSessions = await sessionManager.listSessions({
|
|
183
|
+
projectId: session.projectId,
|
|
184
|
+
state: "active"
|
|
366
185
|
});
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
db.close();
|
|
370
|
-
} catch (error) {
|
|
371
|
-
logger.error("Linear sync failed", error);
|
|
372
|
-
console.error("\u274C Sync failed:", error.message);
|
|
373
|
-
process.exit(1);
|
|
374
|
-
}
|
|
375
|
-
});
|
|
376
|
-
linearCommand.command("auto-sync").description("Manage automatic synchronization").option("--start", "Start auto-sync service").option("--stop", "Stop auto-sync service").option("--status", "Show auto-sync status").option("--interval <minutes>", "Set sync interval in minutes", "5").option(
|
|
377
|
-
"--direction <direction>",
|
|
378
|
-
"Set sync direction: bidirectional, to_linear, from_linear",
|
|
379
|
-
"bidirectional"
|
|
380
|
-
).option("--quiet-start <hour>", "Start of quiet hours (0-23)", "22").option("--quiet-end <hour>", "End of quiet hours (0-23)", "7").action(async (options) => {
|
|
381
|
-
try {
|
|
382
|
-
const projectRoot = process.cwd();
|
|
383
|
-
if (options.status) {
|
|
384
|
-
const service = getAutoSyncService();
|
|
385
|
-
if (service) {
|
|
386
|
-
const status = service.getStatus();
|
|
387
|
-
console.log("\u{1F4CA} Linear Auto-Sync Status:");
|
|
388
|
-
console.log(` Running: ${status.running ? "\u2705" : "\u274C"}`);
|
|
389
|
-
console.log(` Direction: ${status.config.direction}`);
|
|
390
|
-
console.log(` Interval: ${status.config.interval} minutes`);
|
|
391
|
-
console.log(
|
|
392
|
-
` Conflict Resolution: ${status.config.conflictResolution}`
|
|
186
|
+
const otherActive = otherSessions.filter(
|
|
187
|
+
(s) => s.sessionId !== session.sessionId
|
|
393
188
|
);
|
|
394
|
-
if (
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
if (status.retryCount > 0) {
|
|
408
|
-
console.log(` \u26A0\uFE0F Retry Count: ${status.retryCount}`);
|
|
409
|
-
}
|
|
410
|
-
} else {
|
|
411
|
-
console.log("\u{1F4CA} Linear Auto-Sync Status: \u274C Not running");
|
|
412
|
-
}
|
|
413
|
-
return;
|
|
414
|
-
}
|
|
415
|
-
if (options.start) {
|
|
416
|
-
const authManager = new LinearAuthManager(projectRoot);
|
|
417
|
-
if (!authManager.isConfigured()) {
|
|
418
|
-
console.log(
|
|
419
|
-
'\u274C Linear not configured. Run "stackmemory linear setup" first.'
|
|
420
|
-
);
|
|
421
|
-
return;
|
|
422
|
-
}
|
|
423
|
-
const config = {
|
|
424
|
-
interval: parseInt(options.interval),
|
|
425
|
-
direction: options.direction,
|
|
426
|
-
quietHours: {
|
|
427
|
-
start: parseInt(options.quietStart),
|
|
428
|
-
end: parseInt(options.quietEnd)
|
|
189
|
+
if (otherActive.length > 0) {
|
|
190
|
+
console.log(`
|
|
191
|
+
Other Active Sessions (same project):`);
|
|
192
|
+
otherActive.forEach((s) => {
|
|
193
|
+
const age = Math.round(
|
|
194
|
+
(Date.now() - s.lastActiveAt) / 1e3 / 60 / 60
|
|
195
|
+
);
|
|
196
|
+
console.log(
|
|
197
|
+
` - ${s.sessionId.slice(0, 8)}: ${s.branch || "main"}, ${age}h old`
|
|
198
|
+
);
|
|
199
|
+
});
|
|
200
|
+
console.log(`
|
|
201
|
+
Tip: Use --all to see frames across sessions`);
|
|
429
202
|
}
|
|
430
|
-
};
|
|
431
|
-
const service = initializeAutoSync(projectRoot, config);
|
|
432
|
-
await service.start();
|
|
433
|
-
console.log("\u2705 Linear auto-sync started");
|
|
434
|
-
console.log(` Interval: ${config.interval} minutes`);
|
|
435
|
-
console.log(` Direction: ${config.direction}`);
|
|
436
|
-
console.log(
|
|
437
|
-
` Quiet Hours: ${config.quietHours.start}:00 - ${config.quietHours.end}:00`
|
|
438
|
-
);
|
|
439
|
-
console.log(
|
|
440
|
-
'\n\u{1F4A1} Use "stackmemory linear auto-sync --status" to check status'
|
|
441
|
-
);
|
|
442
|
-
process.on("SIGINT", () => {
|
|
443
|
-
console.log("\n\u{1F6D1} Stopping auto-sync service...");
|
|
444
|
-
service.stop();
|
|
445
|
-
process.exit(0);
|
|
446
|
-
});
|
|
447
|
-
console.log("\u{1F504} Auto-sync running... Press Ctrl+C to stop");
|
|
448
|
-
await new Promise(() => {
|
|
449
|
-
});
|
|
450
|
-
}
|
|
451
|
-
if (options.stop) {
|
|
452
|
-
stopAutoSync();
|
|
453
|
-
console.log("\u{1F6D1} Linear auto-sync stopped");
|
|
454
|
-
}
|
|
455
|
-
if (!options.start && !options.stop && !options.status) {
|
|
456
|
-
console.log("\u{1F4A1} Usage:");
|
|
457
|
-
console.log(" --start Start auto-sync service");
|
|
458
|
-
console.log(" --stop Stop auto-sync service");
|
|
459
|
-
console.log(" --status Show current status");
|
|
460
|
-
console.log(
|
|
461
|
-
"\nExample: stackmemory linear auto-sync --start --interval 10"
|
|
462
|
-
);
|
|
463
|
-
}
|
|
464
|
-
} catch (error) {
|
|
465
|
-
logger.error("Linear auto-sync command failed", error);
|
|
466
|
-
console.error("\u274C Auto-sync failed:", error.message);
|
|
467
|
-
process.exit(1);
|
|
468
|
-
}
|
|
469
|
-
});
|
|
470
|
-
linearCommand.command("force-sync").description("Force immediate synchronization").action(async () => {
|
|
471
|
-
try {
|
|
472
|
-
const service = getAutoSyncService();
|
|
473
|
-
if (service) {
|
|
474
|
-
console.log("\u{1F504} Forcing immediate sync...");
|
|
475
|
-
await service.forceSync();
|
|
476
|
-
console.log("\u2705 Sync completed");
|
|
477
|
-
} else {
|
|
478
|
-
console.log(
|
|
479
|
-
"\u274C Auto-sync service not running. Use manual sync instead:"
|
|
480
|
-
);
|
|
481
|
-
console.log(" stackmemory linear sync");
|
|
482
|
-
}
|
|
483
|
-
} catch (error) {
|
|
484
|
-
logger.error("Force sync failed", error);
|
|
485
|
-
console.error("\u274C Force sync failed:", error.message);
|
|
486
|
-
process.exit(1);
|
|
487
|
-
}
|
|
488
|
-
});
|
|
489
|
-
linearCommand.command("update <issueId>").description("Update Linear task status").option(
|
|
490
|
-
"-s, --status <status>",
|
|
491
|
-
"New status (todo, in-progress, done, canceled)"
|
|
492
|
-
).option("-t, --title <title>", "Update task title").option("-d, --description <desc>", "Update task description").option(
|
|
493
|
-
"-p, --priority <priority>",
|
|
494
|
-
"Set priority (1=urgent, 2=high, 3=medium, 4=low)"
|
|
495
|
-
).action(async (issueId, options) => {
|
|
496
|
-
try {
|
|
497
|
-
const projectRoot = process.cwd();
|
|
498
|
-
const authManager = new LinearAuthManager(projectRoot);
|
|
499
|
-
const tokens = authManager.loadTokens();
|
|
500
|
-
if (!tokens) {
|
|
501
|
-
console.error("\u274C Not authenticated. Run: stackmemory linear setup");
|
|
502
|
-
process.exit(1);
|
|
503
|
-
}
|
|
504
|
-
const { LinearClient } = await import("../integrations/linear/client.js");
|
|
505
|
-
const client = new LinearClient({
|
|
506
|
-
apiKey: tokens.accessToken,
|
|
507
|
-
useBearer: true,
|
|
508
|
-
onUnauthorized: async () => {
|
|
509
|
-
const refreshed = await authManager.refreshAccessToken();
|
|
510
|
-
return refreshed.accessToken;
|
|
511
|
-
}
|
|
512
|
-
});
|
|
513
|
-
let issue = await client.getIssue(issueId);
|
|
514
|
-
if (!issue) {
|
|
515
|
-
issue = await client.findIssueByIdentifier(issueId);
|
|
516
|
-
}
|
|
517
|
-
if (!issue) {
|
|
518
|
-
console.error(`\u274C Issue ${issueId} not found`);
|
|
519
|
-
process.exit(1);
|
|
520
|
-
}
|
|
521
|
-
const updates = {};
|
|
522
|
-
if (options.status) {
|
|
523
|
-
const team = await client.getTeam();
|
|
524
|
-
const states = await client.getWorkflowStates(team.id);
|
|
525
|
-
const statusMap = {
|
|
526
|
-
todo: "unstarted",
|
|
527
|
-
"in-progress": "started",
|
|
528
|
-
done: "completed",
|
|
529
|
-
canceled: "cancelled"
|
|
530
|
-
};
|
|
531
|
-
const targetType = statusMap[options.status.toLowerCase()] || options.status;
|
|
532
|
-
const targetState = states.find(
|
|
533
|
-
(s) => s.type === targetType
|
|
534
|
-
);
|
|
535
|
-
if (!targetState) {
|
|
536
|
-
console.error(`\u274C Invalid status: ${options.status}`);
|
|
537
|
-
console.log("Available states:");
|
|
538
|
-
states.forEach(
|
|
539
|
-
(s) => console.log(` - ${s.name} (${s.type})`)
|
|
540
|
-
);
|
|
541
|
-
process.exit(1);
|
|
542
|
-
}
|
|
543
|
-
updates.stateId = targetState.id;
|
|
544
|
-
}
|
|
545
|
-
if (options.title) updates.title = options.title;
|
|
546
|
-
if (options.description) updates.description = options.description;
|
|
547
|
-
if (options.priority) updates.priority = parseInt(options.priority);
|
|
548
|
-
const updatedIssue = await client.updateIssue(issue.id, updates);
|
|
549
|
-
console.log(
|
|
550
|
-
`\u2705 Updated ${updatedIssue.identifier}: ${updatedIssue.title}`
|
|
551
|
-
);
|
|
552
|
-
if (options.status) {
|
|
553
|
-
console.log(` Status: ${updatedIssue.state.name}`);
|
|
554
|
-
}
|
|
555
|
-
console.log(` ${updatedIssue.url}`);
|
|
556
|
-
console.log("\n\u{1F504} Syncing to local tasks...");
|
|
557
|
-
const dbPath = join(projectRoot, ".stackmemory", "context.db");
|
|
558
|
-
if (existsSync(dbPath)) {
|
|
559
|
-
const db = new Database(dbPath);
|
|
560
|
-
const taskStore = new LinearTaskManager(projectRoot, db);
|
|
561
|
-
const { LinearSyncEngine: LinearSyncEngine2, DEFAULT_SYNC_CONFIG: DEFAULT_SYNC_CONFIG2 } = await import("../integrations/linear/sync.js");
|
|
562
|
-
const syncEngine = new LinearSyncEngine2(
|
|
563
|
-
taskStore,
|
|
564
|
-
authManager,
|
|
565
|
-
{ ...DEFAULT_SYNC_CONFIG2, enabled: true, direction: "from_linear" },
|
|
566
|
-
projectRoot
|
|
567
|
-
);
|
|
568
|
-
const syncResult = await syncEngine.sync();
|
|
569
|
-
if (syncResult.success) {
|
|
570
|
-
console.log(
|
|
571
|
-
` \u2705 Local tasks synced (${syncResult.synced.fromLinear} new, ${syncResult.synced.updated} updated)`
|
|
572
|
-
);
|
|
573
203
|
}
|
|
574
204
|
db.close();
|
|
205
|
+
} catch (error) {
|
|
206
|
+
logger.error("Failed to get status", error);
|
|
207
|
+
console.error("\u274C Status check failed:", error.message);
|
|
208
|
+
process.exit(1);
|
|
575
209
|
}
|
|
576
|
-
}
|
|
577
|
-
logger.error("Failed to update Linear task", error);
|
|
578
|
-
console.error("\u274C Failed to update task:", error.message);
|
|
579
|
-
process.exit(1);
|
|
580
|
-
}
|
|
581
|
-
});
|
|
582
|
-
linearCommand.command("config").description("Configure auto-sync settings").option("--show", "Show current configuration").option("--set-interval <minutes>", "Set sync interval in minutes").option(
|
|
583
|
-
"--set-direction <direction>",
|
|
584
|
-
"Set sync direction: bidirectional, to_linear, from_linear"
|
|
585
|
-
).option(
|
|
586
|
-
"--set-conflict-resolution <strategy>",
|
|
587
|
-
"Set conflict resolution: newest_wins, linear_wins, stackmemory_wins, manual"
|
|
588
|
-
).option("--set-quiet-start <hour>", "Set start of quiet hours (0-23)").option("--set-quiet-end <hour>", "Set end of quiet hours (0-23)").option("--enable", "Enable auto-sync").option("--disable", "Disable auto-sync").option("--reset", "Reset to default configuration").action(async (options) => {
|
|
589
|
-
try {
|
|
590
|
-
const projectRoot = process.cwd();
|
|
591
|
-
const configManager = new LinearConfigManager(projectRoot);
|
|
592
|
-
if (options.reset) {
|
|
593
|
-
configManager.resetConfig();
|
|
594
|
-
console.log("\u2705 Configuration reset to defaults");
|
|
595
|
-
return;
|
|
596
|
-
}
|
|
597
|
-
if (options.show) {
|
|
598
|
-
const config = configManager.loadConfig();
|
|
599
|
-
if (config) {
|
|
600
|
-
console.log("\u{1F4CA} Linear Auto-Sync Configuration:");
|
|
601
|
-
console.log(` Enabled: ${config.enabled ? "\u2705" : "\u274C"}`);
|
|
602
|
-
console.log(` Interval: ${config.interval} minutes`);
|
|
603
|
-
console.log(` Direction: ${config.direction}`);
|
|
604
|
-
console.log(` Conflict Resolution: ${config.conflictResolution}`);
|
|
605
|
-
console.log(` Retry Attempts: ${config.retryAttempts}`);
|
|
606
|
-
console.log(` Retry Delay: ${config.retryDelay / 1e3}s`);
|
|
607
|
-
if (config.quietHours) {
|
|
608
|
-
console.log(
|
|
609
|
-
` Quiet Hours: ${config.quietHours.start}:00 - ${config.quietHours.end}:00`
|
|
610
|
-
);
|
|
611
|
-
}
|
|
612
|
-
const lastUpdated = new Date(config.lastUpdated);
|
|
613
|
-
console.log(` Last Updated: ${lastUpdated.toLocaleString()}`);
|
|
614
|
-
} else {
|
|
615
|
-
console.log("\u{1F4CA} No configuration found. Using defaults.");
|
|
616
|
-
const defaultConfig = configManager.getDefaultConfig();
|
|
617
|
-
console.log(` Default interval: ${defaultConfig.interval} minutes`);
|
|
618
|
-
console.log(` Default direction: ${defaultConfig.direction}`);
|
|
619
|
-
}
|
|
620
|
-
return;
|
|
621
|
-
}
|
|
622
|
-
const updates = {};
|
|
623
|
-
if (options.setInterval) {
|
|
624
|
-
const interval = parseInt(options.setInterval);
|
|
625
|
-
if (isNaN(interval) || interval < 1) {
|
|
626
|
-
console.error("\u274C Interval must be a positive number");
|
|
627
|
-
process.exit(1);
|
|
628
|
-
}
|
|
629
|
-
updates.interval = interval;
|
|
630
|
-
console.log(`\u2705 Set interval to ${interval} minutes`);
|
|
631
|
-
}
|
|
632
|
-
if (options.setDirection) {
|
|
633
|
-
const validDirections = ["bidirectional", "to_linear", "from_linear"];
|
|
634
|
-
if (!validDirections.includes(options.setDirection)) {
|
|
635
|
-
console.error(
|
|
636
|
-
`\u274C Invalid direction. Must be one of: ${validDirections.join(", ")}`
|
|
637
|
-
);
|
|
638
|
-
process.exit(1);
|
|
639
|
-
}
|
|
640
|
-
updates.direction = options.setDirection;
|
|
641
|
-
console.log(`\u2705 Set direction to ${options.setDirection}`);
|
|
642
|
-
}
|
|
643
|
-
if (options.setConflictResolution) {
|
|
644
|
-
const validStrategies = [
|
|
645
|
-
"newest_wins",
|
|
646
|
-
"linear_wins",
|
|
647
|
-
"stackmemory_wins",
|
|
648
|
-
"manual"
|
|
649
|
-
];
|
|
650
|
-
if (!validStrategies.includes(options.setConflictResolution)) {
|
|
651
|
-
console.error(
|
|
652
|
-
`\u274C Invalid strategy. Must be one of: ${validStrategies.join(", ")}`
|
|
653
|
-
);
|
|
654
|
-
process.exit(1);
|
|
655
|
-
}
|
|
656
|
-
updates.conflictResolution = options.setConflictResolution;
|
|
657
|
-
console.log(
|
|
658
|
-
`\u2705 Set conflict resolution to ${options.setConflictResolution}`
|
|
659
|
-
);
|
|
660
|
-
}
|
|
661
|
-
if (options.setQuietStart) {
|
|
662
|
-
const hour = parseInt(options.setQuietStart);
|
|
663
|
-
if (isNaN(hour) || hour < 0 || hour > 23) {
|
|
664
|
-
console.error("\u274C Quiet start hour must be between 0 and 23");
|
|
665
|
-
process.exit(1);
|
|
666
|
-
}
|
|
667
|
-
const currentConfig = configManager.loadConfig() || configManager.getDefaultConfig();
|
|
668
|
-
updates.quietHours = {
|
|
669
|
-
start: hour,
|
|
670
|
-
end: currentConfig.quietHours?.end || 7
|
|
671
|
-
};
|
|
672
|
-
console.log(`\u2705 Set quiet hours start to ${hour}:00`);
|
|
673
|
-
}
|
|
674
|
-
if (options.setQuietEnd) {
|
|
675
|
-
const hour = parseInt(options.setQuietEnd);
|
|
676
|
-
if (isNaN(hour) || hour < 0 || hour > 23) {
|
|
677
|
-
console.error("\u274C Quiet end hour must be between 0 and 23");
|
|
678
|
-
process.exit(1);
|
|
679
|
-
}
|
|
680
|
-
const currentConfig = configManager.loadConfig() || configManager.getDefaultConfig();
|
|
681
|
-
updates.quietHours = {
|
|
682
|
-
start: currentConfig.quietHours?.start || 22,
|
|
683
|
-
end: hour
|
|
684
|
-
};
|
|
685
|
-
console.log(`\u2705 Set quiet hours end to ${hour}:00`);
|
|
686
|
-
}
|
|
687
|
-
if (options.enable) {
|
|
688
|
-
updates.enabled = true;
|
|
689
|
-
console.log("\u2705 Auto-sync enabled");
|
|
690
|
-
}
|
|
691
|
-
if (options.disable) {
|
|
692
|
-
updates.enabled = false;
|
|
693
|
-
console.log("\u274C Auto-sync disabled");
|
|
694
|
-
}
|
|
695
|
-
if (Object.keys(updates).length > 0) {
|
|
696
|
-
configManager.saveConfig(updates);
|
|
697
|
-
console.log(
|
|
698
|
-
"\n\u{1F4A1} Configuration updated. Restart auto-sync service to apply changes."
|
|
699
|
-
);
|
|
700
|
-
} else if (!options.show) {
|
|
701
|
-
console.log("\u{1F4A1} Use --show to view current configuration");
|
|
702
|
-
console.log("\u{1F4A1} Use --help to see all configuration options");
|
|
703
|
-
}
|
|
704
|
-
} catch (error) {
|
|
705
|
-
logger.error("Linear config command failed", error);
|
|
706
|
-
console.error("\u274C Config failed:", error.message);
|
|
707
|
-
process.exit(1);
|
|
708
|
-
}
|
|
210
|
+
});
|
|
709
211
|
});
|
|
710
212
|
program.command("update-check").description("Check for StackMemory updates").action(async () => {
|
|
711
213
|
try {
|
|
@@ -717,172 +219,6 @@ program.command("update-check").description("Check for StackMemory updates").act
|
|
|
717
219
|
process.exit(1);
|
|
718
220
|
}
|
|
719
221
|
});
|
|
720
|
-
program.command("analytics").description("Launch task analytics dashboard").option("-p, --port <port>", "Port for dashboard server", "3000").option("-o, --open", "Open dashboard in browser").option("--export <format>", "Export metrics (json|csv)").option("--sync", "Sync with Linear before launching").option("--view", "Show analytics in terminal").action(async (options) => {
|
|
721
|
-
try {
|
|
722
|
-
const projectRoot = process.cwd();
|
|
723
|
-
const dbPath = join(projectRoot, ".stackmemory", "context.db");
|
|
724
|
-
if (!existsSync(dbPath)) {
|
|
725
|
-
console.log(
|
|
726
|
-
'\u274C StackMemory not initialized. Run "stackmemory init" first.'
|
|
727
|
-
);
|
|
728
|
-
return;
|
|
729
|
-
}
|
|
730
|
-
if (options.view) {
|
|
731
|
-
const { displayAnalyticsDashboard } = await import("./utils/viewer.js");
|
|
732
|
-
await displayAnalyticsDashboard(projectRoot);
|
|
733
|
-
return;
|
|
734
|
-
}
|
|
735
|
-
if (options.export) {
|
|
736
|
-
const { AnalyticsService } = await import("../features/analytics/index.js");
|
|
737
|
-
const service = new AnalyticsService(projectRoot);
|
|
738
|
-
if (options.sync) {
|
|
739
|
-
console.log("\u{1F504} Syncing with Linear...");
|
|
740
|
-
await service.syncLinearTasks();
|
|
741
|
-
}
|
|
742
|
-
const state = await service.getDashboardState();
|
|
743
|
-
if (options.export === "csv") {
|
|
744
|
-
console.log("\u{1F4CA} Exporting metrics as CSV...");
|
|
745
|
-
const tasks = state.recentTasks;
|
|
746
|
-
const headers = [
|
|
747
|
-
"ID",
|
|
748
|
-
"Title",
|
|
749
|
-
"State",
|
|
750
|
-
"Priority",
|
|
751
|
-
"Created",
|
|
752
|
-
"Completed"
|
|
753
|
-
];
|
|
754
|
-
const rows = tasks.map((t) => [
|
|
755
|
-
t.id,
|
|
756
|
-
t.title,
|
|
757
|
-
t.state,
|
|
758
|
-
t.priority,
|
|
759
|
-
t.createdAt.toISOString(),
|
|
760
|
-
t.completedAt?.toISOString() || ""
|
|
761
|
-
]);
|
|
762
|
-
console.log(headers.join(","));
|
|
763
|
-
rows.forEach((r) => console.log(r.join(",")));
|
|
764
|
-
} else {
|
|
765
|
-
console.log(JSON.stringify(state, null, 2));
|
|
766
|
-
}
|
|
767
|
-
service.close();
|
|
768
|
-
return;
|
|
769
|
-
}
|
|
770
|
-
console.log(
|
|
771
|
-
`\u{1F680} Launching analytics dashboard on port ${options.port}...`
|
|
772
|
-
);
|
|
773
|
-
const express = (await import("express")).default;
|
|
774
|
-
const { AnalyticsAPI } = await import("../features/analytics/index.js");
|
|
775
|
-
const { createServer } = await import("http");
|
|
776
|
-
const app = express();
|
|
777
|
-
app.use(
|
|
778
|
-
(err, _req, res, _next) => {
|
|
779
|
-
console.error("Express error:", err);
|
|
780
|
-
res.status(500).json({ error: err.message });
|
|
781
|
-
}
|
|
782
|
-
);
|
|
783
|
-
const analyticsAPI = new AnalyticsAPI(projectRoot);
|
|
784
|
-
if (options.sync) {
|
|
785
|
-
console.log("\u{1F504} Syncing with Linear...");
|
|
786
|
-
const service = new (await import("../features/analytics/index.js")).AnalyticsService(projectRoot);
|
|
787
|
-
await service.syncLinearTasks();
|
|
788
|
-
service.close();
|
|
789
|
-
}
|
|
790
|
-
app.use("/api/analytics", analyticsAPI.getRouter());
|
|
791
|
-
app.get("/", async (req, res) => {
|
|
792
|
-
const possiblePaths = [
|
|
793
|
-
join(projectRoot, "src/features/analytics/dashboard.html"),
|
|
794
|
-
join(projectRoot, "dist/features/analytics/dashboard.html")
|
|
795
|
-
];
|
|
796
|
-
for (const dashboardPath of possiblePaths) {
|
|
797
|
-
if (existsSync(dashboardPath)) {
|
|
798
|
-
res.sendFile(dashboardPath);
|
|
799
|
-
return;
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
res.send(`<!DOCTYPE html>
|
|
803
|
-
<html lang="en">
|
|
804
|
-
<head>
|
|
805
|
-
<meta charset="UTF-8">
|
|
806
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
807
|
-
<title>StackMemory Analytics</title>
|
|
808
|
-
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
809
|
-
<style>
|
|
810
|
-
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
811
|
-
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #1a1a2e; color: #eee; padding: 20px; }
|
|
812
|
-
.container { max-width: 1200px; margin: 0 auto; }
|
|
813
|
-
h1 { color: #667eea; margin-bottom: 20px; }
|
|
814
|
-
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 30px; }
|
|
815
|
-
.card { background: #16213e; border-radius: 12px; padding: 20px; }
|
|
816
|
-
.metric-value { font-size: 2.5em; font-weight: bold; color: #667eea; }
|
|
817
|
-
.metric-label { color: #888; text-transform: uppercase; font-size: 0.8em; }
|
|
818
|
-
.task-list { max-height: 400px; overflow-y: auto; }
|
|
819
|
-
.task-item { padding: 10px; border-left: 3px solid #667eea; margin-bottom: 8px; background: #1a1a2e; }
|
|
820
|
-
.task-item.completed { border-color: #22c55e; }
|
|
821
|
-
.task-item.in_progress { border-color: #f59e0b; }
|
|
822
|
-
.status { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 0.8em; margin-right: 8px; }
|
|
823
|
-
.status.completed { background: #22c55e30; color: #22c55e; }
|
|
824
|
-
.status.in_progress { background: #f59e0b30; color: #f59e0b; }
|
|
825
|
-
.status.todo { background: #667eea30; color: #667eea; }
|
|
826
|
-
</style>
|
|
827
|
-
</head>
|
|
828
|
-
<body>
|
|
829
|
-
<div class="container">
|
|
830
|
-
<h1>\u{1F4CA} StackMemory Analytics</h1>
|
|
831
|
-
<div class="grid" id="metrics"></div>
|
|
832
|
-
<div class="card"><h3>Recent Tasks</h3><div class="task-list" id="tasks">Loading...</div></div>
|
|
833
|
-
</div>
|
|
834
|
-
<script>
|
|
835
|
-
async function load() {
|
|
836
|
-
const metrics = await fetch('/api/analytics/metrics').then(r => r.json());
|
|
837
|
-
const tasks = await fetch('/api/analytics/tasks').then(r => r.json());
|
|
838
|
-
|
|
839
|
-
document.getElementById('metrics').innerHTML = \`
|
|
840
|
-
<div class="card"><div class="metric-label">Total</div><div class="metric-value">\${metrics.data.metrics.totalTasks}</div></div>
|
|
841
|
-
<div class="card"><div class="metric-label">Completed</div><div class="metric-value">\${metrics.data.metrics.completedTasks}</div></div>
|
|
842
|
-
<div class="card"><div class="metric-label">In Progress</div><div class="metric-value">\${metrics.data.metrics.inProgressTasks}</div></div>
|
|
843
|
-
<div class="card"><div class="metric-label">Completion</div><div class="metric-value">\${metrics.data.metrics.completionRate.toFixed(0)}%</div></div>
|
|
844
|
-
\`;
|
|
845
|
-
|
|
846
|
-
document.getElementById('tasks').innerHTML = tasks.data.tasks.slice(0, 10).map((t: any) => \`
|
|
847
|
-
<div class="task-item \${t.state}">
|
|
848
|
-
<span class="status \${t.state}">\${t.state}</span>
|
|
849
|
-
<strong>\${t.title}</strong>
|
|
850
|
-
</div>
|
|
851
|
-
\`).join('');
|
|
852
|
-
}
|
|
853
|
-
load();
|
|
854
|
-
setInterval(load, 30000);
|
|
855
|
-
</script>
|
|
856
|
-
</body>
|
|
857
|
-
</html>`);
|
|
858
|
-
});
|
|
859
|
-
const server = createServer(app);
|
|
860
|
-
analyticsAPI.setupWebSocket(server);
|
|
861
|
-
server.listen(options.port, async () => {
|
|
862
|
-
console.log(
|
|
863
|
-
`\u2705 Analytics dashboard running at http://localhost:${options.port}`
|
|
864
|
-
);
|
|
865
|
-
if (options.open) {
|
|
866
|
-
const { exec } = await import("child_process");
|
|
867
|
-
const url = `http://localhost:${options.port}`;
|
|
868
|
-
const command = process.platform === "darwin" ? `open ${url}` : process.platform === "win32" ? `start ${url}` : `xdg-open ${url}`;
|
|
869
|
-
exec(command);
|
|
870
|
-
}
|
|
871
|
-
});
|
|
872
|
-
process.on("SIGINT", () => {
|
|
873
|
-
console.log("\n\u{1F44B} Shutting down analytics dashboard...");
|
|
874
|
-
analyticsAPI.close();
|
|
875
|
-
server.close();
|
|
876
|
-
process.exit(0);
|
|
877
|
-
});
|
|
878
|
-
await new Promise(() => {
|
|
879
|
-
});
|
|
880
|
-
} catch (error) {
|
|
881
|
-
logger.error("Analytics command failed", error);
|
|
882
|
-
console.error("\u274C Analytics failed:", error.message);
|
|
883
|
-
process.exit(1);
|
|
884
|
-
}
|
|
885
|
-
});
|
|
886
222
|
program.command("progress").description("Show current progress and recent changes").action(async () => {
|
|
887
223
|
try {
|
|
888
224
|
const projectRoot = process.cwd();
|
|
@@ -971,24 +307,18 @@ program.command("context:test").description("Test context persistence by creatin
|
|
|
971
307
|
}
|
|
972
308
|
});
|
|
973
309
|
registerOnboardingCommand(program);
|
|
310
|
+
registerLoginCommand(program);
|
|
311
|
+
registerLogoutCommand(program);
|
|
312
|
+
registerDbCommands(program);
|
|
974
313
|
registerProjectCommands(program);
|
|
975
314
|
registerWorktreeCommands(program);
|
|
976
315
|
registerLinearCommands(program);
|
|
977
|
-
registerLinearTestCommand(program);
|
|
978
|
-
registerLinearListCommand(program);
|
|
979
|
-
registerLinearMigrateCommand(program);
|
|
980
|
-
registerLinearCreateCommand(program);
|
|
981
|
-
program.addCommand(createChromaDBCommand());
|
|
982
|
-
program.addCommand(createInfiniteStorageCommand());
|
|
983
|
-
program.addCommand(createGCCommand());
|
|
984
316
|
program.addCommand(createSessionCommands());
|
|
985
|
-
program.addCommand(webhookCommand());
|
|
986
317
|
program.addCommand(createTaskCommands());
|
|
987
318
|
program.addCommand(createSearchCommand());
|
|
988
319
|
program.addCommand(createLogCommand());
|
|
989
320
|
program.addCommand(createContextCommands());
|
|
990
321
|
program.addCommand(createConfigCommand());
|
|
991
|
-
program.addCommand(createAgentCommand());
|
|
992
322
|
program.addCommand(createHandoffCommand());
|
|
993
323
|
program.addCommand(createStorageCommand());
|
|
994
324
|
program.addCommand(createSkillsCommand());
|
|
@@ -1001,52 +331,6 @@ program.command("dashboard").description("Display monitoring dashboard in termin
|
|
|
1001
331
|
const { dashboardCommand } = await import("./commands/dashboard.js");
|
|
1002
332
|
await dashboardCommand.handler(options);
|
|
1003
333
|
});
|
|
1004
|
-
program.command("tui").description("Launch interactive TUI monitoring dashboard (requires blessed)").option("-s, --server", "Start WebSocket server for real-time updates").option("-w, --ws-url <url>", "WebSocket server URL", "ws://localhost:8080").option("-r, --refresh <ms>", "Auto-refresh interval in milliseconds", "2000").action(async (options) => {
|
|
1005
|
-
try {
|
|
1006
|
-
try {
|
|
1007
|
-
await import("blessed");
|
|
1008
|
-
} catch {
|
|
1009
|
-
console.log(
|
|
1010
|
-
"\u274C The TUI requires the blessed package. Install it with:"
|
|
1011
|
-
);
|
|
1012
|
-
console.log(" npm install blessed blessed-contrib");
|
|
1013
|
-
console.log(
|
|
1014
|
-
'\n\u{1F4A1} Alternatively, use "stackmemory dashboard" for a simpler view'
|
|
1015
|
-
);
|
|
1016
|
-
process.exit(1);
|
|
1017
|
-
}
|
|
1018
|
-
const { spawn } = await import("child_process");
|
|
1019
|
-
const { fileURLToPath } = await import("url");
|
|
1020
|
-
const { dirname, join: join2 } = await import("path");
|
|
1021
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
1022
|
-
const __dirname = dirname(__filename);
|
|
1023
|
-
console.log("\u{1F680} Launching StackMemory TUI Dashboard...");
|
|
1024
|
-
process.env["STACKMEMORY_WS_URL"] = options.wsUrl;
|
|
1025
|
-
const tuiPath = join2(__dirname, "../features/tui/index.js");
|
|
1026
|
-
const tui = spawn("node", [tuiPath], {
|
|
1027
|
-
stdio: "inherit",
|
|
1028
|
-
env: {
|
|
1029
|
-
...process.env,
|
|
1030
|
-
STACKMEMORY_WS_URL: options.wsUrl
|
|
1031
|
-
}
|
|
1032
|
-
});
|
|
1033
|
-
tui.on("error", (error) => {
|
|
1034
|
-
console.error("Failed to launch TUI:", error);
|
|
1035
|
-
console.log('\n\u{1F4A1} Try "stackmemory dashboard" instead');
|
|
1036
|
-
process.exit(1);
|
|
1037
|
-
});
|
|
1038
|
-
tui.on("exit", (code) => {
|
|
1039
|
-
if (code !== 0) {
|
|
1040
|
-
console.error(`TUI exited with code ${code}`);
|
|
1041
|
-
process.exit(code || 1);
|
|
1042
|
-
}
|
|
1043
|
-
});
|
|
1044
|
-
} catch (error) {
|
|
1045
|
-
console.error("\u274C Failed to launch TUI:", error.message);
|
|
1046
|
-
console.log('\n\u{1F4A1} Try "stackmemory dashboard" for a simpler view');
|
|
1047
|
-
process.exit(1);
|
|
1048
|
-
}
|
|
1049
|
-
});
|
|
1050
334
|
if (process.argv.length > 2) {
|
|
1051
335
|
const manager = ProjectManager.getInstance();
|
|
1052
336
|
manager.detectProject().catch(() => {
|