@stackmemoryai/stackmemory 0.3.17 → 0.3.18
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/commands/skills.js +15 -2
- package/dist/cli/commands/skills.js.map +2 -2
- package/dist/cli/index.js +113 -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-manager.js +3 -0
- package/dist/core/context/frame-manager.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/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 +6 -18
- 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.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/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
|
@@ -1,641 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from "events";
|
|
2
|
-
import Database from "better-sqlite3";
|
|
3
|
-
import { SessionManager } from "../../../core/session/session-manager.js";
|
|
4
|
-
import { FrameManager } from "../../../core/context/frame-manager.js";
|
|
5
|
-
import { LinearTaskReader } from "./linear-task-reader.js";
|
|
6
|
-
import { existsSync } from "fs";
|
|
7
|
-
function getEnv(key, defaultValue) {
|
|
8
|
-
const value = process.env[key];
|
|
9
|
-
if (value === void 0) {
|
|
10
|
-
if (defaultValue !== void 0) return defaultValue;
|
|
11
|
-
throw new Error(`Environment variable ${key} is required`);
|
|
12
|
-
}
|
|
13
|
-
return value;
|
|
14
|
-
}
|
|
15
|
-
function getOptionalEnv(key) {
|
|
16
|
-
return process.env[key];
|
|
17
|
-
}
|
|
18
|
-
class DataService extends EventEmitter {
|
|
19
|
-
db = null;
|
|
20
|
-
sessionManager = null;
|
|
21
|
-
frameManager = null;
|
|
22
|
-
taskReader = null;
|
|
23
|
-
linearMappings = /* @__PURE__ */ new Map();
|
|
24
|
-
cache = /* @__PURE__ */ new Map();
|
|
25
|
-
cacheTimeout = 5e3;
|
|
26
|
-
// 5 seconds
|
|
27
|
-
async initialize() {
|
|
28
|
-
try {
|
|
29
|
-
try {
|
|
30
|
-
const dbPath = process.env["PROJECT_ROOT"] ? `${process.env["PROJECT_ROOT"]}/.stackmemory/context.db` : `${process.cwd()}/.stackmemory/context.db`;
|
|
31
|
-
if (existsSync(dbPath)) {
|
|
32
|
-
this.db = new Database(dbPath);
|
|
33
|
-
}
|
|
34
|
-
} catch (dbError) {
|
|
35
|
-
if (process.env["DEBUG"]) {
|
|
36
|
-
console.log("Database not accessible, continuing without it");
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
try {
|
|
40
|
-
this.taskReader = new LinearTaskReader(
|
|
41
|
-
process.env["PROJECT_ROOT"] || process.cwd()
|
|
42
|
-
);
|
|
43
|
-
this.linearMappings = this.taskReader.getMappings();
|
|
44
|
-
if (process.env["DEBUG"]) {
|
|
45
|
-
const tasks = this.taskReader.getTasks();
|
|
46
|
-
console.log(
|
|
47
|
-
`LinearTaskReader initialized with ${tasks.length} tasks`
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
} catch (tsError) {
|
|
51
|
-
if (process.env["DEBUG"]) {
|
|
52
|
-
console.log("Task reader initialization failed:", tsError.message);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
try {
|
|
56
|
-
this.sessionManager = new SessionManager({
|
|
57
|
-
enableMonitoring: true
|
|
58
|
-
});
|
|
59
|
-
} catch (smError) {
|
|
60
|
-
if (process.env["DEBUG"]) {
|
|
61
|
-
console.log("SessionManager initialization failed:", smError.message);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
if (this.db) {
|
|
65
|
-
try {
|
|
66
|
-
this.frameManager = new FrameManager(this.db, "tui");
|
|
67
|
-
} catch (fmError) {
|
|
68
|
-
if (process.env["DEBUG"]) {
|
|
69
|
-
console.log("FrameManager initialization failed:", fmError.message);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
if (process.env["DEBUG"]) {
|
|
74
|
-
console.log(
|
|
75
|
-
"TUI: Using local task store only (no direct Linear API calls)"
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
this.emit("data:ready");
|
|
79
|
-
} catch (error) {
|
|
80
|
-
if (process.env["DEBUG"]) {
|
|
81
|
-
console.error("DataService initialization error:", error);
|
|
82
|
-
}
|
|
83
|
-
this.emit("data:ready");
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
async getSessions() {
|
|
87
|
-
const cached = this.getFromCache("sessions");
|
|
88
|
-
if (cached) return cached;
|
|
89
|
-
try {
|
|
90
|
-
const activeSessions = this.sessionManager?.getActiveSessions() || [];
|
|
91
|
-
let recentSessions = [];
|
|
92
|
-
if (this.db) {
|
|
93
|
-
try {
|
|
94
|
-
const stmt = this.db.prepare(`
|
|
95
|
-
SELECT * FROM sessions
|
|
96
|
-
WHERE created_at > datetime('now', '-24 hours')
|
|
97
|
-
ORDER BY created_at DESC
|
|
98
|
-
LIMIT 20
|
|
99
|
-
`);
|
|
100
|
-
recentSessions = stmt.all() || [];
|
|
101
|
-
} catch (dbError) {
|
|
102
|
-
if (process.env["DEBUG"]) {
|
|
103
|
-
console.log("Sessions table not found, using mock data");
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
if (activeSessions.length === 0 && recentSessions.length === 0) {
|
|
108
|
-
const mockSessions = this.getMockSessions();
|
|
109
|
-
this.setCache("sessions", mockSessions);
|
|
110
|
-
return mockSessions;
|
|
111
|
-
}
|
|
112
|
-
const sessions = [
|
|
113
|
-
...activeSessions.map(this.formatSession),
|
|
114
|
-
...recentSessions.map(this.formatDatabaseSession)
|
|
115
|
-
];
|
|
116
|
-
this.setCache("sessions", sessions);
|
|
117
|
-
return sessions;
|
|
118
|
-
} catch (error) {
|
|
119
|
-
if (process.env["DEBUG"]) {
|
|
120
|
-
console.error("Error getting sessions:", error);
|
|
121
|
-
}
|
|
122
|
-
return this.getMockSessions();
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
async getTasks() {
|
|
126
|
-
const cached = this.getFromCache("tasks");
|
|
127
|
-
if (cached) return cached;
|
|
128
|
-
const tasks = [];
|
|
129
|
-
if (this.taskReader) {
|
|
130
|
-
try {
|
|
131
|
-
const localTasks = this.taskReader.getTasks();
|
|
132
|
-
tasks.push(...localTasks);
|
|
133
|
-
if (process.env["DEBUG"]) {
|
|
134
|
-
console.log(
|
|
135
|
-
`Loaded ${tasks.length} tasks from local store (no Linear API calls)`
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
} catch (error) {
|
|
139
|
-
if (process.env["DEBUG"]) {
|
|
140
|
-
console.log("Failed to get local tasks:", error.message);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
if (tasks.length === 0) {
|
|
145
|
-
console.log(
|
|
146
|
-
'\u2139\uFE0F No local tasks found. Run "npm run linear:sync" to sync tasks from Linear.'
|
|
147
|
-
);
|
|
148
|
-
const mockTasks = this.getMockTasks();
|
|
149
|
-
this.setCache("tasks", mockTasks);
|
|
150
|
-
return mockTasks;
|
|
151
|
-
}
|
|
152
|
-
this.setCache("tasks", tasks);
|
|
153
|
-
return tasks;
|
|
154
|
-
}
|
|
155
|
-
async getFrames() {
|
|
156
|
-
const cached = this.getFromCache("frames");
|
|
157
|
-
if (cached) return cached;
|
|
158
|
-
try {
|
|
159
|
-
const frames = this.frameManager?.getAllFrames() || [];
|
|
160
|
-
if (frames.length === 0) {
|
|
161
|
-
const mockFrames = this.getMockFrames();
|
|
162
|
-
this.setCache("frames", mockFrames);
|
|
163
|
-
return mockFrames;
|
|
164
|
-
}
|
|
165
|
-
const formatted = frames.map(this.formatFrame);
|
|
166
|
-
this.setCache("frames", formatted);
|
|
167
|
-
return formatted;
|
|
168
|
-
} catch (error) {
|
|
169
|
-
if (process.env["DEBUG"]) {
|
|
170
|
-
console.error("Error getting frames:", error);
|
|
171
|
-
}
|
|
172
|
-
const mockFrames = this.getMockFrames();
|
|
173
|
-
this.setCache("frames", mockFrames);
|
|
174
|
-
return mockFrames;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
async getAgents() {
|
|
178
|
-
const cached = this.getFromCache("agents");
|
|
179
|
-
if (cached) return cached;
|
|
180
|
-
try {
|
|
181
|
-
const agents = [
|
|
182
|
-
{
|
|
183
|
-
id: "agent-1",
|
|
184
|
-
type: "analyzer",
|
|
185
|
-
status: "active",
|
|
186
|
-
currentTask: {
|
|
187
|
-
id: "task-1",
|
|
188
|
-
description: "Analyzing codebase for performance issues",
|
|
189
|
-
progress: 0.65,
|
|
190
|
-
startTime: Date.now() - 12e4
|
|
191
|
-
},
|
|
192
|
-
tasksCompleted: 42,
|
|
193
|
-
tasksFailed: 3,
|
|
194
|
-
averageTime: 18e4,
|
|
195
|
-
successRate: 0.93,
|
|
196
|
-
cpuUsage: 45,
|
|
197
|
-
memoryUsage: 62,
|
|
198
|
-
tokenUsage: 125e3
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
id: "agent-2",
|
|
202
|
-
type: "builder",
|
|
203
|
-
status: "idle",
|
|
204
|
-
tasksCompleted: 28,
|
|
205
|
-
tasksFailed: 1,
|
|
206
|
-
averageTime: 24e4,
|
|
207
|
-
successRate: 0.96,
|
|
208
|
-
cpuUsage: 12,
|
|
209
|
-
memoryUsage: 38,
|
|
210
|
-
tokenUsage: 85e3
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
id: "agent-3",
|
|
214
|
-
type: "tester",
|
|
215
|
-
status: "error",
|
|
216
|
-
tasksCompleted: 15,
|
|
217
|
-
tasksFailed: 5,
|
|
218
|
-
averageTime: 9e4,
|
|
219
|
-
successRate: 0.75,
|
|
220
|
-
lastError: {
|
|
221
|
-
message: "Test suite timeout",
|
|
222
|
-
timestamp: Date.now() - 6e4,
|
|
223
|
-
recoverable: true
|
|
224
|
-
},
|
|
225
|
-
cpuUsage: 0,
|
|
226
|
-
memoryUsage: 25,
|
|
227
|
-
tokenUsage: 45e3
|
|
228
|
-
}
|
|
229
|
-
];
|
|
230
|
-
this.setCache("agents", agents);
|
|
231
|
-
return agents;
|
|
232
|
-
} catch (error) {
|
|
233
|
-
this.emit("error", error);
|
|
234
|
-
return [];
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
async getPRs() {
|
|
238
|
-
const cached = this.getFromCache("prs");
|
|
239
|
-
if (cached) return cached;
|
|
240
|
-
try {
|
|
241
|
-
const prs = [
|
|
242
|
-
{
|
|
243
|
-
id: "pr-1",
|
|
244
|
-
number: 142,
|
|
245
|
-
title: "feat: Add TUI monitoring dashboard",
|
|
246
|
-
state: "open",
|
|
247
|
-
draft: false,
|
|
248
|
-
author: { login: "stackmemory-bot" },
|
|
249
|
-
reviews: [{ user: "reviewer1", state: "approved" }],
|
|
250
|
-
checks: {
|
|
251
|
-
total: 5,
|
|
252
|
-
passed: 3,
|
|
253
|
-
failed: 0,
|
|
254
|
-
pending: 2
|
|
255
|
-
},
|
|
256
|
-
createdAt: new Date(Date.now() - 36e5).toISOString(),
|
|
257
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
258
|
-
additions: 1250,
|
|
259
|
-
deletions: 85,
|
|
260
|
-
changedFiles: 12,
|
|
261
|
-
comments: 3,
|
|
262
|
-
labels: ["enhancement", "monitoring"],
|
|
263
|
-
linearTask: "STA-100"
|
|
264
|
-
}
|
|
265
|
-
];
|
|
266
|
-
this.setCache("prs", prs);
|
|
267
|
-
return prs;
|
|
268
|
-
} catch (error) {
|
|
269
|
-
this.emit("error", error);
|
|
270
|
-
return [];
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
async getIssues() {
|
|
274
|
-
const cached = this.getFromCache("issues");
|
|
275
|
-
if (cached) return cached;
|
|
276
|
-
try {
|
|
277
|
-
const issues = [
|
|
278
|
-
{
|
|
279
|
-
id: "issue-1",
|
|
280
|
-
number: 89,
|
|
281
|
-
title: "Session monitoring improvements needed",
|
|
282
|
-
state: "open",
|
|
283
|
-
author: { login: "user1" },
|
|
284
|
-
assignees: ["stackmemory-bot"],
|
|
285
|
-
labels: ["enhancement", "monitoring"],
|
|
286
|
-
createdAt: new Date(Date.now() - 864e5).toISOString(),
|
|
287
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
288
|
-
comments: 5
|
|
289
|
-
}
|
|
290
|
-
];
|
|
291
|
-
this.setCache("issues", issues);
|
|
292
|
-
return issues;
|
|
293
|
-
} catch (error) {
|
|
294
|
-
this.emit("error", error);
|
|
295
|
-
return [];
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
async getAnalytics() {
|
|
299
|
-
const cached = this.getFromCache("analytics");
|
|
300
|
-
if (cached) return cached;
|
|
301
|
-
try {
|
|
302
|
-
const analytics = {
|
|
303
|
-
sessions: {
|
|
304
|
-
labels: ["1h", "2h", "3h", "4h", "5h", "6h"],
|
|
305
|
-
values: [5, 8, 12, 15, 18, 22]
|
|
306
|
-
},
|
|
307
|
-
tokens: {
|
|
308
|
-
labels: ["1h", "2h", "3h", "4h", "5h", "6h"],
|
|
309
|
-
values: [12e3, 25e3, 45e3, 62e3, 78e3, 95e3]
|
|
310
|
-
},
|
|
311
|
-
tasks: {
|
|
312
|
-
completed: 45,
|
|
313
|
-
inProgress: 12,
|
|
314
|
-
todo: 28,
|
|
315
|
-
velocity: [8, 12, 15, 18, 20]
|
|
316
|
-
},
|
|
317
|
-
quality: {
|
|
318
|
-
testsPassed: 142,
|
|
319
|
-
testsFailed: 3,
|
|
320
|
-
coverage: 78,
|
|
321
|
-
lintErrors: 0
|
|
322
|
-
},
|
|
323
|
-
performance: {
|
|
324
|
-
avgResponseTime: [120, 115, 108, 105, 110],
|
|
325
|
-
errorRate: [0.02, 0.015, 0.01, 8e-3, 5e-3],
|
|
326
|
-
throughput: [100, 120, 135, 140, 145]
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
this.setCache("analytics", analytics);
|
|
330
|
-
return analytics;
|
|
331
|
-
} catch (error) {
|
|
332
|
-
this.emit("error", error);
|
|
333
|
-
return {
|
|
334
|
-
sessions: { labels: [], values: [] },
|
|
335
|
-
tokens: { labels: [], values: [] },
|
|
336
|
-
tasks: { completed: 0, inProgress: 0, todo: 0, velocity: [] },
|
|
337
|
-
quality: { testsPassed: 0, testsFailed: 0, coverage: 0, lintErrors: 0 },
|
|
338
|
-
performance: { avgResponseTime: [], errorRate: [], throughput: [] }
|
|
339
|
-
};
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
formatSession(session) {
|
|
343
|
-
return {
|
|
344
|
-
id: session.id,
|
|
345
|
-
startTime: session.startTime,
|
|
346
|
-
lastActivity: session.lastActivity,
|
|
347
|
-
completed: session.completed,
|
|
348
|
-
error: session.error,
|
|
349
|
-
totalTokens: session.totalTokens,
|
|
350
|
-
contextUsage: session.contextUsage || 0,
|
|
351
|
-
filesEdited: session.filesEdited,
|
|
352
|
-
commandsRun: session.commandsRun,
|
|
353
|
-
errors: session.errors,
|
|
354
|
-
primaryFile: session.primaryFile,
|
|
355
|
-
gitBranch: session.gitBranch,
|
|
356
|
-
lastCommit: session.lastCommit,
|
|
357
|
-
linearTask: session.linearTask,
|
|
358
|
-
agentType: session.agentType,
|
|
359
|
-
recentActivities: session.recentActivities
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
formatDatabaseSession(row) {
|
|
363
|
-
return {
|
|
364
|
-
id: row.id,
|
|
365
|
-
startTime: new Date(row.created_at).getTime(),
|
|
366
|
-
lastActivity: row.updated_at ? new Date(row.updated_at).getTime() : void 0,
|
|
367
|
-
completed: row.status === "completed",
|
|
368
|
-
totalTokens: row.token_count,
|
|
369
|
-
contextUsage: row.context_usage || 0,
|
|
370
|
-
filesEdited: row.files_edited ? JSON.parse(row.files_edited) : [],
|
|
371
|
-
commandsRun: row.commands_run || 0
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
formatLinearTask(task) {
|
|
375
|
-
return {
|
|
376
|
-
id: task.id,
|
|
377
|
-
identifier: task.identifier,
|
|
378
|
-
title: task.title,
|
|
379
|
-
description: task.description,
|
|
380
|
-
// Use Linear state.type for stable mapping ('unstarted'|'started'|...)
|
|
381
|
-
state: task.state?.type || task.state?.name,
|
|
382
|
-
priority: task.priority,
|
|
383
|
-
estimate: task.estimate,
|
|
384
|
-
dueDate: task.dueDate,
|
|
385
|
-
assignee: task.assignee ? {
|
|
386
|
-
id: task.assignee.id,
|
|
387
|
-
name: task.assignee.name,
|
|
388
|
-
email: task.assignee.email
|
|
389
|
-
} : void 0,
|
|
390
|
-
labels: task.labels?.nodes.map((l) => l.name),
|
|
391
|
-
project: task.project ? {
|
|
392
|
-
id: task.project.id,
|
|
393
|
-
name: task.project.name,
|
|
394
|
-
key: task.project.key
|
|
395
|
-
} : void 0
|
|
396
|
-
};
|
|
397
|
-
}
|
|
398
|
-
formatRestLinearTask(task) {
|
|
399
|
-
const stateMap = {
|
|
400
|
-
backlog: "Backlog",
|
|
401
|
-
unstarted: "To Do",
|
|
402
|
-
started: "In Progress",
|
|
403
|
-
completed: "Done",
|
|
404
|
-
canceled: "Canceled"
|
|
405
|
-
};
|
|
406
|
-
return {
|
|
407
|
-
id: task.id,
|
|
408
|
-
identifier: task.identifier,
|
|
409
|
-
title: task.title,
|
|
410
|
-
description: task.description,
|
|
411
|
-
state: stateMap[task.state.type] || task.state.name,
|
|
412
|
-
priority: task.priority,
|
|
413
|
-
estimate: task.estimate,
|
|
414
|
-
assignee: task.assignee ? task.assignee.name : void 0,
|
|
415
|
-
createdAt: task.createdAt,
|
|
416
|
-
updatedAt: task.updatedAt
|
|
417
|
-
};
|
|
418
|
-
}
|
|
419
|
-
formatFrame(frame) {
|
|
420
|
-
return {
|
|
421
|
-
id: frame.id,
|
|
422
|
-
sessionId: frame.sessionId,
|
|
423
|
-
parentId: frame.parentId,
|
|
424
|
-
type: frame.type || "leaf",
|
|
425
|
-
inputs: frame.inputs,
|
|
426
|
-
outputs: frame.outputs,
|
|
427
|
-
tools: frame.tools,
|
|
428
|
-
digest: frame.digest,
|
|
429
|
-
timestamp: frame.timestamp,
|
|
430
|
-
tokenCount: frame.tokenCount || 0,
|
|
431
|
-
tier: frame.tier || "hot",
|
|
432
|
-
compressionRatio: frame.compressionRatio,
|
|
433
|
-
score: frame.score,
|
|
434
|
-
children: frame.children,
|
|
435
|
-
references: frame.references
|
|
436
|
-
};
|
|
437
|
-
}
|
|
438
|
-
getFromCache(key) {
|
|
439
|
-
const cached = this.cache.get(key);
|
|
440
|
-
if (cached && Date.now() - cached.timestamp < this.cacheTimeout) {
|
|
441
|
-
return cached.data;
|
|
442
|
-
}
|
|
443
|
-
return null;
|
|
444
|
-
}
|
|
445
|
-
setCache(key, data) {
|
|
446
|
-
this.cache.set(key, { data, timestamp: Date.now() });
|
|
447
|
-
}
|
|
448
|
-
mapLocalStatusToLinearState(status) {
|
|
449
|
-
const statusMap = {
|
|
450
|
-
pending: "To Do",
|
|
451
|
-
in_progress: "In Progress",
|
|
452
|
-
completed: "Done",
|
|
453
|
-
cancelled: "Canceled",
|
|
454
|
-
blocked: "To Do"
|
|
455
|
-
};
|
|
456
|
-
return statusMap[status] || "To Do";
|
|
457
|
-
}
|
|
458
|
-
mapLocalPriorityToLinear(priority) {
|
|
459
|
-
const priorityMap = {
|
|
460
|
-
urgent: 0,
|
|
461
|
-
high: 1,
|
|
462
|
-
medium: 2,
|
|
463
|
-
low: 3
|
|
464
|
-
};
|
|
465
|
-
return priorityMap[priority] || 2;
|
|
466
|
-
}
|
|
467
|
-
cleanup() {
|
|
468
|
-
if (this.db) {
|
|
469
|
-
this.db.close();
|
|
470
|
-
}
|
|
471
|
-
this.cache.clear();
|
|
472
|
-
}
|
|
473
|
-
// Mock data methods for demo/offline mode
|
|
474
|
-
getMockSessions() {
|
|
475
|
-
const now = Date.now();
|
|
476
|
-
return [
|
|
477
|
-
{
|
|
478
|
-
id: "demo-session-1",
|
|
479
|
-
startTime: now - 81e5,
|
|
480
|
-
// 2h 15m ago
|
|
481
|
-
lastActivity: now - 6e4,
|
|
482
|
-
// 1 minute ago
|
|
483
|
-
completed: false,
|
|
484
|
-
totalTokens: 45e3,
|
|
485
|
-
contextUsage: 0.45,
|
|
486
|
-
// 45%
|
|
487
|
-
filesEdited: ["src/components/Dashboard.tsx", "src/hooks/useAuth.ts"],
|
|
488
|
-
commandsRun: 23,
|
|
489
|
-
primaryFile: "src/components/Dashboard.tsx",
|
|
490
|
-
gitBranch: "feature/tui-dashboard",
|
|
491
|
-
agentType: "frontend",
|
|
492
|
-
recentActivities: [
|
|
493
|
-
{
|
|
494
|
-
timestamp: now - 12e4,
|
|
495
|
-
type: "file_edit",
|
|
496
|
-
description: "Modified Dashboard.tsx"
|
|
497
|
-
},
|
|
498
|
-
{
|
|
499
|
-
timestamp: now - 6e4,
|
|
500
|
-
type: "command",
|
|
501
|
-
description: "npm run test"
|
|
502
|
-
}
|
|
503
|
-
]
|
|
504
|
-
},
|
|
505
|
-
{
|
|
506
|
-
id: "demo-session-2",
|
|
507
|
-
startTime: now - 27e5,
|
|
508
|
-
// 45m ago
|
|
509
|
-
lastActivity: now - 3e5,
|
|
510
|
-
// 5 minutes ago
|
|
511
|
-
completed: false,
|
|
512
|
-
totalTokens: 22e3,
|
|
513
|
-
contextUsage: 0.22,
|
|
514
|
-
// 22%
|
|
515
|
-
filesEdited: ["src/api/endpoints.ts", "src/middleware/auth.ts"],
|
|
516
|
-
commandsRun: 15,
|
|
517
|
-
primaryFile: "src/api/endpoints.ts",
|
|
518
|
-
gitBranch: "main",
|
|
519
|
-
agentType: "backend",
|
|
520
|
-
recentActivities: [
|
|
521
|
-
{
|
|
522
|
-
timestamp: now - 6e5,
|
|
523
|
-
type: "file_edit",
|
|
524
|
-
description: "Updated API endpoints"
|
|
525
|
-
}
|
|
526
|
-
]
|
|
527
|
-
}
|
|
528
|
-
];
|
|
529
|
-
}
|
|
530
|
-
getMockFrames() {
|
|
531
|
-
return [
|
|
532
|
-
{
|
|
533
|
-
id: "frame-1",
|
|
534
|
-
sessionId: "demo-session-1",
|
|
535
|
-
type: "root",
|
|
536
|
-
tier: "hot",
|
|
537
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
538
|
-
tokenCount: 2500,
|
|
539
|
-
score: 95,
|
|
540
|
-
compressionRatio: 2.3,
|
|
541
|
-
digest: "Implementing React component with hooks",
|
|
542
|
-
tools: ["Edit", "Read", "MultiEdit"],
|
|
543
|
-
inputs: ["Create user dashboard"],
|
|
544
|
-
outputs: ["Dashboard component created"],
|
|
545
|
-
children: [],
|
|
546
|
-
references: []
|
|
547
|
-
},
|
|
548
|
-
{
|
|
549
|
-
id: "frame-2",
|
|
550
|
-
sessionId: "demo-session-1",
|
|
551
|
-
type: "branch",
|
|
552
|
-
tier: "warm",
|
|
553
|
-
timestamp: new Date(Date.now() - 36e5).toISOString(),
|
|
554
|
-
tokenCount: 1800,
|
|
555
|
-
score: 78,
|
|
556
|
-
compressionRatio: 1.8,
|
|
557
|
-
digest: "Setting up API endpoints",
|
|
558
|
-
tools: ["Write", "Edit"],
|
|
559
|
-
inputs: ["Setup REST API"],
|
|
560
|
-
outputs: ["API routes configured"],
|
|
561
|
-
children: [],
|
|
562
|
-
references: []
|
|
563
|
-
}
|
|
564
|
-
];
|
|
565
|
-
}
|
|
566
|
-
getMockTasks() {
|
|
567
|
-
return [
|
|
568
|
-
{
|
|
569
|
-
id: "task-1",
|
|
570
|
-
identifier: "STA-101",
|
|
571
|
-
title: "Implement TUI dashboard",
|
|
572
|
-
state: "In Progress",
|
|
573
|
-
priority: 2,
|
|
574
|
-
assignee: "demo-user",
|
|
575
|
-
createdAt: new Date(Date.now() - 864e5).toISOString(),
|
|
576
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
577
|
-
},
|
|
578
|
-
{
|
|
579
|
-
id: "task-2",
|
|
580
|
-
identifier: "STA-102",
|
|
581
|
-
title: "Add terminal compatibility",
|
|
582
|
-
state: "Done",
|
|
583
|
-
priority: 1,
|
|
584
|
-
assignee: "demo-user",
|
|
585
|
-
createdAt: new Date(Date.now() - 1728e5).toISOString(),
|
|
586
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
587
|
-
}
|
|
588
|
-
];
|
|
589
|
-
}
|
|
590
|
-
getMockAgents() {
|
|
591
|
-
return [
|
|
592
|
-
{
|
|
593
|
-
id: "agent-1",
|
|
594
|
-
name: "code-reviewer",
|
|
595
|
-
type: "reviewer",
|
|
596
|
-
status: "idle",
|
|
597
|
-
tasksCompleted: 45,
|
|
598
|
-
averageTime: "2.3s",
|
|
599
|
-
successRate: 98.5,
|
|
600
|
-
lastActive: (/* @__PURE__ */ new Date()).toISOString()
|
|
601
|
-
},
|
|
602
|
-
{
|
|
603
|
-
id: "agent-2",
|
|
604
|
-
name: "test-runner",
|
|
605
|
-
type: "qa",
|
|
606
|
-
status: "active",
|
|
607
|
-
tasksCompleted: 156,
|
|
608
|
-
averageTime: "5.6s",
|
|
609
|
-
successRate: 95.2,
|
|
610
|
-
lastActive: (/* @__PURE__ */ new Date()).toISOString()
|
|
611
|
-
}
|
|
612
|
-
];
|
|
613
|
-
}
|
|
614
|
-
getMockPRs() {
|
|
615
|
-
return [
|
|
616
|
-
{
|
|
617
|
-
id: "pr-1",
|
|
618
|
-
number: 123,
|
|
619
|
-
title: "feat: Add terminal compatibility layer",
|
|
620
|
-
state: "open",
|
|
621
|
-
author: { login: "demo-user" },
|
|
622
|
-
assignees: [],
|
|
623
|
-
labels: ["enhancement", "tui"],
|
|
624
|
-
createdAt: new Date(Date.now() - 864e5).toISOString(),
|
|
625
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
626
|
-
comments: 3,
|
|
627
|
-
reviews: 1,
|
|
628
|
-
checks: {
|
|
629
|
-
total: 5,
|
|
630
|
-
passed: 5,
|
|
631
|
-
failed: 0,
|
|
632
|
-
pending: 0
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
];
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
export {
|
|
639
|
-
DataService
|
|
640
|
-
};
|
|
641
|
-
//# sourceMappingURL=data-service.js.map
|