@stackmemoryai/stackmemory 0.3.16 → 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/README.md +48 -2
- 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
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Script to fix common TypeScript strict mode issues
|
|
5
|
+
* STA-34: Enable TypeScript Strict Mode
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import fs from 'fs';
|
|
9
|
+
import path from 'path';
|
|
10
|
+
import { fileURLToPath } from 'url';
|
|
11
|
+
|
|
12
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
13
|
+
const projectRoot = path.resolve(__dirname, '..');
|
|
14
|
+
|
|
15
|
+
interface StrictModeIssue {
|
|
16
|
+
file: string;
|
|
17
|
+
line: number;
|
|
18
|
+
column: number;
|
|
19
|
+
type:
|
|
20
|
+
| 'possibly_undefined'
|
|
21
|
+
| 'index_signature'
|
|
22
|
+
| 'implicit_any'
|
|
23
|
+
| 'unknown_type';
|
|
24
|
+
description: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
class StrictModeFixer {
|
|
28
|
+
private issues: StrictModeIssue[] = [];
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Fix process.env access issues (noPropertyAccessFromIndexSignature)
|
|
32
|
+
*/
|
|
33
|
+
async fixProcessEnvAccess(): Promise<void> {
|
|
34
|
+
console.log('🔧 Fixing process.env access issues...');
|
|
35
|
+
|
|
36
|
+
const files = await this.findFilesWithPattern(/process\.env\.\w+/);
|
|
37
|
+
|
|
38
|
+
for (const file of files) {
|
|
39
|
+
const content = fs.readFileSync(file, 'utf-8');
|
|
40
|
+
let updated = content;
|
|
41
|
+
|
|
42
|
+
// Replace process.env['VAR'] with process.env['VAR']
|
|
43
|
+
updated = updated.replace(/process\.env\.(\w+)/g, "process.env['$1']");
|
|
44
|
+
|
|
45
|
+
if (updated !== content) {
|
|
46
|
+
fs.writeFileSync(file, updated);
|
|
47
|
+
console.log(
|
|
48
|
+
`✅ Fixed process.env access in ${path.relative(projectRoot, file)}`
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Fix possibly undefined issues with null assertion or optional chaining
|
|
56
|
+
*/
|
|
57
|
+
async fixPossiblyUndefined(): Promise<void> {
|
|
58
|
+
console.log('🔧 Fixing possibly undefined issues...');
|
|
59
|
+
|
|
60
|
+
// Common patterns that can be safely fixed
|
|
61
|
+
const patterns = [
|
|
62
|
+
{
|
|
63
|
+
// Fix array access that's known to exist
|
|
64
|
+
from: /(\w+)\[(\d+)\](?!\?)/g,
|
|
65
|
+
to: '$1[$2]!',
|
|
66
|
+
condition: (match: string, file: string) => {
|
|
67
|
+
// Only apply if it's an array access in test or known safe contexts
|
|
68
|
+
return file.includes('test') || file.includes('spec');
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
const files = await this.findTypescriptFiles();
|
|
74
|
+
|
|
75
|
+
for (const file of files) {
|
|
76
|
+
const content = fs.readFileSync(file, 'utf-8');
|
|
77
|
+
let updated = content;
|
|
78
|
+
let hasChanges = false;
|
|
79
|
+
|
|
80
|
+
for (const pattern of patterns) {
|
|
81
|
+
const matches = content.match(pattern.from);
|
|
82
|
+
if (matches && pattern.condition(content, file)) {
|
|
83
|
+
updated = updated.replace(pattern.from, pattern.to);
|
|
84
|
+
hasChanges = true;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (hasChanges) {
|
|
89
|
+
fs.writeFileSync(file, updated);
|
|
90
|
+
console.log(
|
|
91
|
+
`✅ Fixed undefined issues in ${path.relative(projectRoot, file)}`
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Fix unknown type issues by adding proper type annotations
|
|
99
|
+
*/
|
|
100
|
+
async fixUnknownTypes(): Promise<void> {
|
|
101
|
+
console.log('🔧 Fixing unknown type issues...');
|
|
102
|
+
|
|
103
|
+
const files = await this.findTypescriptFiles();
|
|
104
|
+
|
|
105
|
+
for (const file of files) {
|
|
106
|
+
const content = fs.readFileSync(file, 'utf-8');
|
|
107
|
+
let updated = content;
|
|
108
|
+
|
|
109
|
+
// Fix catch blocks with unknown error
|
|
110
|
+
updated = updated.replace(
|
|
111
|
+
/catch\s*\(\s*(\w+)\s*\)\s*{/g,
|
|
112
|
+
'catch ($1: unknown) {'
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
// Fix error parameter in catch blocks
|
|
116
|
+
updated = updated.replace(/(\w+) is of type 'unknown'/g, '$1 as Error');
|
|
117
|
+
|
|
118
|
+
if (updated !== content) {
|
|
119
|
+
fs.writeFileSync(file, updated);
|
|
120
|
+
console.log(
|
|
121
|
+
`✅ Fixed unknown types in ${path.relative(projectRoot, file)}`
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Fix implicit any issues by adding type annotations
|
|
129
|
+
*/
|
|
130
|
+
async fixImplicitAny(): Promise<void> {
|
|
131
|
+
console.log('🔧 Fixing implicit any issues...');
|
|
132
|
+
|
|
133
|
+
const files = await this.findTypescriptFiles();
|
|
134
|
+
|
|
135
|
+
for (const file of files) {
|
|
136
|
+
const content = fs.readFileSync(file, 'utf-8');
|
|
137
|
+
let updated = content;
|
|
138
|
+
|
|
139
|
+
// Fix common implicit any patterns
|
|
140
|
+
updated = updated.replace(/\.map\(\s*(\w+)\s*=>/g, '.map(($1: any) =>');
|
|
141
|
+
|
|
142
|
+
updated = updated.replace(
|
|
143
|
+
/\.filter\(\s*(\w+)\s*=>/g,
|
|
144
|
+
'.filter(($1: any) =>'
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
updated = updated.replace(/\.find\(\s*(\w+)\s*=>/g, '.find(($1: any) =>');
|
|
148
|
+
|
|
149
|
+
if (updated !== content) {
|
|
150
|
+
fs.writeFileSync(file, updated);
|
|
151
|
+
console.log(
|
|
152
|
+
`✅ Fixed implicit any in ${path.relative(projectRoot, file)}`
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Add type guards for environment variable access
|
|
160
|
+
*/
|
|
161
|
+
async addEnvironmentTypeGuards(): Promise<void> {
|
|
162
|
+
console.log('🔧 Adding environment variable type guards...');
|
|
163
|
+
|
|
164
|
+
const files = await this.findFilesWithPattern(/process\.env\[/);
|
|
165
|
+
|
|
166
|
+
for (const file of files) {
|
|
167
|
+
const content = fs.readFileSync(file, 'utf-8');
|
|
168
|
+
let updated = content;
|
|
169
|
+
|
|
170
|
+
// Add utility function for safe env access at the top of files that need it
|
|
171
|
+
if (
|
|
172
|
+
content.includes("process.env['") &&
|
|
173
|
+
!content.includes('function getEnv(')
|
|
174
|
+
) {
|
|
175
|
+
const imports = content.match(/^import.*$/gm) || [];
|
|
176
|
+
const lastImportIndex = content.lastIndexOf(
|
|
177
|
+
imports[imports.length - 1] || ''
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
const envUtility = `
|
|
181
|
+
// Type-safe environment variable access
|
|
182
|
+
function getEnv(key: string, defaultValue?: string): string {
|
|
183
|
+
const value = process.env[key];
|
|
184
|
+
if (value === undefined) {
|
|
185
|
+
if (defaultValue !== undefined) return defaultValue;
|
|
186
|
+
throw new Error(\`Environment variable \${key} is required\`);
|
|
187
|
+
}
|
|
188
|
+
return value;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function getOptionalEnv(key: string): string | undefined {
|
|
192
|
+
return process.env[key];
|
|
193
|
+
}
|
|
194
|
+
`;
|
|
195
|
+
|
|
196
|
+
updated =
|
|
197
|
+
content.slice(
|
|
198
|
+
0,
|
|
199
|
+
lastImportIndex + imports[imports.length - 1]?.length || 0
|
|
200
|
+
) +
|
|
201
|
+
envUtility +
|
|
202
|
+
content.slice(
|
|
203
|
+
lastImportIndex + imports[imports.length - 1]?.length || 0
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
fs.writeFileSync(file, updated);
|
|
207
|
+
console.log(
|
|
208
|
+
`✅ Added env utilities to ${path.relative(projectRoot, file)}`
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Find all TypeScript files in the project
|
|
216
|
+
*/
|
|
217
|
+
private async findTypescriptFiles(): Promise<string[]> {
|
|
218
|
+
const files: string[] = [];
|
|
219
|
+
|
|
220
|
+
const walk = (dir: string): void => {
|
|
221
|
+
const items = fs.readdirSync(dir);
|
|
222
|
+
|
|
223
|
+
for (const item of items) {
|
|
224
|
+
const fullPath = path.join(dir, item);
|
|
225
|
+
const stat = fs.statSync(fullPath);
|
|
226
|
+
|
|
227
|
+
if (
|
|
228
|
+
stat.isDirectory() &&
|
|
229
|
+
!item.startsWith('.') &&
|
|
230
|
+
item !== 'node_modules' &&
|
|
231
|
+
item !== 'dist'
|
|
232
|
+
) {
|
|
233
|
+
walk(fullPath);
|
|
234
|
+
} else if (
|
|
235
|
+
stat.isFile() &&
|
|
236
|
+
(item.endsWith('.ts') || item.endsWith('.tsx')) &&
|
|
237
|
+
!item.endsWith('.d.ts')
|
|
238
|
+
) {
|
|
239
|
+
files.push(fullPath);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
walk(path.join(projectRoot, 'src'));
|
|
245
|
+
walk(path.join(projectRoot, 'scripts'));
|
|
246
|
+
|
|
247
|
+
return files;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Find files containing a specific pattern
|
|
252
|
+
*/
|
|
253
|
+
private async findFilesWithPattern(pattern: RegExp): Promise<string[]> {
|
|
254
|
+
const allFiles = await this.findTypescriptFiles();
|
|
255
|
+
const matchingFiles: string[] = [];
|
|
256
|
+
|
|
257
|
+
for (const file of allFiles) {
|
|
258
|
+
const content = fs.readFileSync(file, 'utf-8');
|
|
259
|
+
if (pattern.test(content)) {
|
|
260
|
+
matchingFiles.push(file);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return matchingFiles;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Run all fixes
|
|
269
|
+
*/
|
|
270
|
+
async runAllFixes(): Promise<void> {
|
|
271
|
+
console.log('🚀 Starting TypeScript strict mode fixes...\n');
|
|
272
|
+
|
|
273
|
+
await this.fixProcessEnvAccess();
|
|
274
|
+
await this.addEnvironmentTypeGuards();
|
|
275
|
+
await this.fixUnknownTypes();
|
|
276
|
+
await this.fixImplicitAny();
|
|
277
|
+
// await this.fixPossiblyUndefined(); // Skip this for now as it's more complex
|
|
278
|
+
|
|
279
|
+
console.log('\n✅ All automated fixes completed!');
|
|
280
|
+
console.log('\nRemaining issues will need manual review:');
|
|
281
|
+
console.log('- Complex possibly undefined cases');
|
|
282
|
+
console.log('- Interface property mismatches');
|
|
283
|
+
console.log('- Context-specific type assertions');
|
|
284
|
+
|
|
285
|
+
console.log('\n🔧 Run `npx tsc --noEmit` to check remaining issues');
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// Run the fixer
|
|
290
|
+
const fixer = new StrictModeFixer();
|
|
291
|
+
fixer.runAllFixes().catch(console.error);
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# StackMemory Folder Structure Reorganization Script
|
|
4
|
+
# This script reorganizes the codebase to the new structure
|
|
5
|
+
|
|
6
|
+
set -e
|
|
7
|
+
|
|
8
|
+
echo "🔄 Starting StackMemory folder reorganization..."
|
|
9
|
+
|
|
10
|
+
# Create new directory structure
|
|
11
|
+
echo "📁 Creating new directory structure..."
|
|
12
|
+
|
|
13
|
+
# Core directories
|
|
14
|
+
mkdir -p src/core/{context,projects,storage,monitoring,utils}
|
|
15
|
+
mkdir -p src/core/storage/{migrations,repositories}
|
|
16
|
+
|
|
17
|
+
# Features directories
|
|
18
|
+
mkdir -p src/features/{analytics,tasks,browser}
|
|
19
|
+
|
|
20
|
+
# Integrations directories
|
|
21
|
+
mkdir -p src/integrations/{linear,github,mcp}
|
|
22
|
+
|
|
23
|
+
# CLI directories
|
|
24
|
+
mkdir -p src/cli/commands
|
|
25
|
+
mkdir -p src/cli/utils
|
|
26
|
+
|
|
27
|
+
# Servers directories
|
|
28
|
+
mkdir -p src/servers/{local,railway,production}
|
|
29
|
+
|
|
30
|
+
# Scripts directories
|
|
31
|
+
mkdir -p scripts/{setup,deployment,development,hooks}
|
|
32
|
+
|
|
33
|
+
# Config directories
|
|
34
|
+
mkdir -p config/{docker,environments}
|
|
35
|
+
|
|
36
|
+
# Tests directories
|
|
37
|
+
mkdir -p tests/{unit,integration,e2e}
|
|
38
|
+
|
|
39
|
+
# Docs directories
|
|
40
|
+
mkdir -p docs/{architecture,guides,api,releases}
|
|
41
|
+
|
|
42
|
+
echo "📦 Moving core files..."
|
|
43
|
+
|
|
44
|
+
# Move core context files
|
|
45
|
+
if [ -f "src/core/frame-manager.ts" ]; then
|
|
46
|
+
mv src/core/frame-manager.ts src/core/context/frame-manager.ts
|
|
47
|
+
fi
|
|
48
|
+
|
|
49
|
+
# Move project management files
|
|
50
|
+
if [ -f "src/core/project-manager.ts" ]; then
|
|
51
|
+
mv src/core/project-manager.ts src/core/projects/project-manager.ts
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
# Move monitoring files
|
|
55
|
+
if [ -f "src/core/logger.ts" ]; then
|
|
56
|
+
mv src/core/logger.ts src/core/monitoring/logger.ts
|
|
57
|
+
fi
|
|
58
|
+
if [ -f "src/core/error-handler.ts" ]; then
|
|
59
|
+
mv src/core/error-handler.ts src/core/monitoring/error-handler.ts
|
|
60
|
+
fi
|
|
61
|
+
if [ -f "src/core/progress-tracker.ts" ]; then
|
|
62
|
+
mv src/core/progress-tracker.ts src/core/monitoring/progress-tracker.ts
|
|
63
|
+
fi
|
|
64
|
+
|
|
65
|
+
# Move utils
|
|
66
|
+
if [ -f "src/core/update-checker.ts" ]; then
|
|
67
|
+
mv src/core/update-checker.ts src/core/utils/update-checker.ts
|
|
68
|
+
fi
|
|
69
|
+
|
|
70
|
+
echo "✨ Moving features..."
|
|
71
|
+
|
|
72
|
+
# Move analytics to features
|
|
73
|
+
if [ -d "src/analytics" ]; then
|
|
74
|
+
mv src/analytics/* src/features/analytics/ 2>/dev/null || true
|
|
75
|
+
rmdir src/analytics 2>/dev/null || true
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
# Move pebbles to tasks feature
|
|
79
|
+
if [ -d "src/pebbles" ]; then
|
|
80
|
+
mv src/pebbles/* src/features/tasks/ 2>/dev/null || true
|
|
81
|
+
rmdir src/pebbles 2>/dev/null || true
|
|
82
|
+
fi
|
|
83
|
+
|
|
84
|
+
# Move browser integration
|
|
85
|
+
if [ -f "src/integrations/browser-mcp.ts" ]; then
|
|
86
|
+
mv src/integrations/browser-mcp.ts src/features/browser/browser-mcp.ts
|
|
87
|
+
fi
|
|
88
|
+
|
|
89
|
+
echo "🔌 Moving integrations..."
|
|
90
|
+
|
|
91
|
+
# Move Linear files
|
|
92
|
+
for file in src/integrations/linear-*.ts; do
|
|
93
|
+
if [ -f "$file" ]; then
|
|
94
|
+
basename=$(basename "$file" | sed 's/linear-//')
|
|
95
|
+
mv "$file" "src/integrations/linear/$basename"
|
|
96
|
+
fi
|
|
97
|
+
done
|
|
98
|
+
|
|
99
|
+
# Move MCP files
|
|
100
|
+
if [ -f "src/mcp/mcp-server.ts" ]; then
|
|
101
|
+
mv src/mcp/mcp-server.ts src/integrations/mcp/server.ts
|
|
102
|
+
fi
|
|
103
|
+
if [ -d "src/mcp" ]; then
|
|
104
|
+
rmdir src/mcp 2>/dev/null || true
|
|
105
|
+
fi
|
|
106
|
+
|
|
107
|
+
echo "💻 Moving CLI files..."
|
|
108
|
+
|
|
109
|
+
# Rename main CLI file
|
|
110
|
+
if [ -f "src/cli/cli.ts" ]; then
|
|
111
|
+
mv src/cli/cli.ts src/cli/index.ts
|
|
112
|
+
fi
|
|
113
|
+
|
|
114
|
+
# Move CLI commands
|
|
115
|
+
if [ -f "src/cli/project-commands.ts" ]; then
|
|
116
|
+
mv src/cli/project-commands.ts src/cli/commands/projects.ts
|
|
117
|
+
fi
|
|
118
|
+
if [ -f "src/cli/analytics-viewer.ts" ]; then
|
|
119
|
+
mv src/cli/analytics-viewer.ts src/cli/utils/viewer.ts
|
|
120
|
+
fi
|
|
121
|
+
|
|
122
|
+
echo "🚀 Moving server files..."
|
|
123
|
+
|
|
124
|
+
# Move railway server
|
|
125
|
+
if [ -d "src/railway" ]; then
|
|
126
|
+
mv src/railway/* src/servers/railway/ 2>/dev/null || true
|
|
127
|
+
rmdir src/railway 2>/dev/null || true
|
|
128
|
+
fi
|
|
129
|
+
|
|
130
|
+
# Move production configs from runway.bak
|
|
131
|
+
if [ -d "src/runway.bak" ]; then
|
|
132
|
+
mv src/runway.bak/auth/* src/servers/production/ 2>/dev/null || true
|
|
133
|
+
mv src/runway.bak/database/* src/servers/production/ 2>/dev/null || true
|
|
134
|
+
mv src/runway.bak/monitoring/* src/servers/production/ 2>/dev/null || true
|
|
135
|
+
rm -rf src/runway.bak
|
|
136
|
+
fi
|
|
137
|
+
|
|
138
|
+
echo "📝 Moving scripts..."
|
|
139
|
+
|
|
140
|
+
# Move setup scripts
|
|
141
|
+
if [ -f "scripts/setup-alias.js" ]; then
|
|
142
|
+
mv scripts/setup-alias.js scripts/setup/configure-alias.js
|
|
143
|
+
fi
|
|
144
|
+
if [ -f "scripts/setup-claude-integration.js" ]; then
|
|
145
|
+
mv scripts/setup-claude-integration.js scripts/setup/claude-integration.js
|
|
146
|
+
fi
|
|
147
|
+
|
|
148
|
+
# Move deployment scripts
|
|
149
|
+
if [ -f "scripts/deploy-runway.sh" ]; then
|
|
150
|
+
mv scripts/deploy-runway.sh scripts/deployment/railway.sh
|
|
151
|
+
fi
|
|
152
|
+
if [ -f "scripts/test-railway.js" ]; then
|
|
153
|
+
mv scripts/test-railway.js scripts/deployment/test-deployment.js
|
|
154
|
+
fi
|
|
155
|
+
|
|
156
|
+
# Move development scripts
|
|
157
|
+
if [ -f "scripts/fix-lint-loop.cjs" ]; then
|
|
158
|
+
mv scripts/fix-lint-loop.cjs scripts/development/fix-lint-loop.cjs
|
|
159
|
+
fi
|
|
160
|
+
|
|
161
|
+
# Move hook scripts
|
|
162
|
+
if [ -f "scripts/task-complete-hook.sh" ]; then
|
|
163
|
+
mv scripts/task-complete-hook.sh scripts/hooks/task-complete.sh
|
|
164
|
+
fi
|
|
165
|
+
if [ -f "scripts/cleanup-shell-configs.sh" ]; then
|
|
166
|
+
mv scripts/cleanup-shell-configs.sh scripts/hooks/cleanup-shell.sh
|
|
167
|
+
fi
|
|
168
|
+
|
|
169
|
+
echo "⚙️ Moving configuration files..."
|
|
170
|
+
|
|
171
|
+
# Move Docker files
|
|
172
|
+
if [ -f "Dockerfile.runway" ]; then
|
|
173
|
+
mv Dockerfile.runway config/docker/Dockerfile
|
|
174
|
+
fi
|
|
175
|
+
if [ -f "docker-compose.runway.yml" ]; then
|
|
176
|
+
mv docker-compose.runway.yml config/docker/docker-compose.yml
|
|
177
|
+
fi
|
|
178
|
+
|
|
179
|
+
# Move config files
|
|
180
|
+
if [ -f "railway.json" ]; then
|
|
181
|
+
mv railway.json config/railway.json
|
|
182
|
+
fi
|
|
183
|
+
if [ -f "nixpacks.toml" ]; then
|
|
184
|
+
mv nixpacks.toml config/nixpacks.toml
|
|
185
|
+
fi
|
|
186
|
+
|
|
187
|
+
# Move environment files
|
|
188
|
+
if [ -f ".env.railway.example" ]; then
|
|
189
|
+
mv .env.railway.example config/environments/.env.railway.example
|
|
190
|
+
fi
|
|
191
|
+
|
|
192
|
+
echo "📚 Moving documentation..."
|
|
193
|
+
|
|
194
|
+
# Move architecture docs
|
|
195
|
+
if [ -f "docs/MULTI_PROJECT_ARCHITECTURE.md" ]; then
|
|
196
|
+
mv docs/MULTI_PROJECT_ARCHITECTURE.md docs/architecture/MULTI_PROJECT.md
|
|
197
|
+
fi
|
|
198
|
+
if [ -f "docs/RUNWAY_DEPLOYMENT.md" ]; then
|
|
199
|
+
mv docs/RUNWAY_DEPLOYMENT.md docs/architecture/DEPLOYMENT.md
|
|
200
|
+
fi
|
|
201
|
+
|
|
202
|
+
# Move guides
|
|
203
|
+
if [ -f "DEPLOY_RAILWAY.md" ]; then
|
|
204
|
+
mv DEPLOY_RAILWAY.md docs/guides/RAILWAY_DEPLOY.md
|
|
205
|
+
fi
|
|
206
|
+
|
|
207
|
+
# Move README files
|
|
208
|
+
if [ -f "README.runway.md" ]; then
|
|
209
|
+
mv README.runway.md docs/architecture/RUNWAY_README.md
|
|
210
|
+
fi
|
|
211
|
+
|
|
212
|
+
echo "🧹 Cleaning up empty directories..."
|
|
213
|
+
|
|
214
|
+
# Remove empty directories
|
|
215
|
+
find src -type d -empty -delete 2>/dev/null || true
|
|
216
|
+
find scripts -type d -empty -delete 2>/dev/null || true
|
|
217
|
+
find docs -type d -empty -delete 2>/dev/null || true
|
|
218
|
+
|
|
219
|
+
echo "✅ Folder reorganization complete!"
|
|
220
|
+
echo ""
|
|
221
|
+
echo "⚠️ Important next steps:"
|
|
222
|
+
echo "1. Update all import paths in TypeScript files"
|
|
223
|
+
echo "2. Update package.json scripts paths"
|
|
224
|
+
echo "3. Update build configuration"
|
|
225
|
+
echo "4. Run 'npm run build' to verify everything works"
|
|
226
|
+
echo "5. Commit the changes"
|
|
227
|
+
echo ""
|
|
228
|
+
echo "Run 'npm run update-imports' to automatically update import paths (coming next)"
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { promises as fs } from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
|
|
7
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
|
|
9
|
+
async function testDirectPersistence() {
|
|
10
|
+
console.log('Testing StackMemory Direct Persistence...\n');
|
|
11
|
+
|
|
12
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || '';
|
|
13
|
+
const contextDir = path.join(homeDir, '.stackmemory', 'shared-context', 'projects');
|
|
14
|
+
|
|
15
|
+
// Ensure directory exists
|
|
16
|
+
await fs.mkdir(contextDir, { recursive: true });
|
|
17
|
+
console.log(`✅ Context directory ensured: ${contextDir}`);
|
|
18
|
+
|
|
19
|
+
// Create test context
|
|
20
|
+
const testContext = {
|
|
21
|
+
projectId: 'test-persistence',
|
|
22
|
+
branch: 'main',
|
|
23
|
+
lastUpdated: Date.now(),
|
|
24
|
+
sessions: [
|
|
25
|
+
{
|
|
26
|
+
sessionId: 'test-session-1',
|
|
27
|
+
runId: 'test-run-1',
|
|
28
|
+
summary: 'Test session for persistence verification',
|
|
29
|
+
keyFrames: [
|
|
30
|
+
{
|
|
31
|
+
frameId: 'frame-1',
|
|
32
|
+
title: 'Test Frame 1',
|
|
33
|
+
type: 'observation',
|
|
34
|
+
score: 0.9,
|
|
35
|
+
tags: ['test', 'persistence'],
|
|
36
|
+
summary: 'This is a test frame',
|
|
37
|
+
createdAt: Date.now()
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
frameId: 'frame-2',
|
|
41
|
+
title: 'Error Frame',
|
|
42
|
+
type: 'error',
|
|
43
|
+
score: 0.8,
|
|
44
|
+
tags: ['error', 'test'],
|
|
45
|
+
summary: 'Test error with resolution',
|
|
46
|
+
createdAt: Date.now()
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
createdAt: Date.now() - 3600000, // 1 hour ago
|
|
50
|
+
lastActiveAt: Date.now(),
|
|
51
|
+
metadata: { test: true }
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
globalPatterns: [
|
|
55
|
+
{
|
|
56
|
+
pattern: 'Test error pattern',
|
|
57
|
+
type: 'error',
|
|
58
|
+
frequency: 2,
|
|
59
|
+
lastSeen: Date.now(),
|
|
60
|
+
resolution: 'Test resolution'
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
decisionLog: [
|
|
64
|
+
{
|
|
65
|
+
id: 'decision-1',
|
|
66
|
+
timestamp: Date.now(),
|
|
67
|
+
sessionId: 'test-session-1',
|
|
68
|
+
decision: 'Use persistence layer',
|
|
69
|
+
rationale: 'For context continuity',
|
|
70
|
+
outcome: 'success'
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
referenceIndex: {
|
|
74
|
+
byTag: {},
|
|
75
|
+
byType: {},
|
|
76
|
+
recentlyAccessed: ['frame-1', 'frame-2']
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// Save context
|
|
81
|
+
const contextFile = path.join(contextDir, `${testContext.projectId}_${testContext.branch}.json`);
|
|
82
|
+
await fs.writeFile(contextFile, JSON.stringify(testContext, null, 2));
|
|
83
|
+
console.log(`✅ Test context saved to: ${contextFile}`);
|
|
84
|
+
|
|
85
|
+
// Verify it was saved
|
|
86
|
+
const savedData = await fs.readFile(contextFile, 'utf-8');
|
|
87
|
+
const savedContext = JSON.parse(savedData);
|
|
88
|
+
|
|
89
|
+
console.log('\n📊 Saved Context Summary:');
|
|
90
|
+
console.log(` Sessions: ${savedContext.sessions.length}`);
|
|
91
|
+
console.log(` Key frames: ${savedContext.sessions[0].keyFrames.length}`);
|
|
92
|
+
console.log(` Global patterns: ${savedContext.globalPatterns.length}`);
|
|
93
|
+
console.log(` Decisions: ${savedContext.decisionLog.length}`);
|
|
94
|
+
|
|
95
|
+
// Test that hooks can read this data
|
|
96
|
+
console.log('\n🔍 Testing Hook Integration...');
|
|
97
|
+
|
|
98
|
+
// Simulate what on-clear hook would do
|
|
99
|
+
const clearSurvivalFrame = {
|
|
100
|
+
frameId: 'clear-survival-' + Date.now(),
|
|
101
|
+
title: 'Context preserved from /clear',
|
|
102
|
+
type: 'clear_survival',
|
|
103
|
+
score: 1.0,
|
|
104
|
+
tags: ['preserved', 'clear_survival'],
|
|
105
|
+
summary: 'Important context preserved across clear',
|
|
106
|
+
createdAt: Date.now()
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// Add to existing session
|
|
110
|
+
savedContext.sessions[0].keyFrames.push(clearSurvivalFrame);
|
|
111
|
+
savedContext.lastUpdated = Date.now();
|
|
112
|
+
|
|
113
|
+
// Save updated context
|
|
114
|
+
await fs.writeFile(contextFile, JSON.stringify(savedContext, null, 2));
|
|
115
|
+
console.log('✅ Added clear_survival frame (simulating on-clear hook)');
|
|
116
|
+
|
|
117
|
+
// Verify the update
|
|
118
|
+
const updatedData = await fs.readFile(contextFile, 'utf-8');
|
|
119
|
+
const updatedContext = JSON.parse(updatedData);
|
|
120
|
+
|
|
121
|
+
const hasClearSurvival = updatedContext.sessions[0].keyFrames.some(
|
|
122
|
+
f => f.tags?.includes('clear_survival')
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
if (hasClearSurvival) {
|
|
126
|
+
console.log('✅ Clear survival frame persisted successfully!');
|
|
127
|
+
} else {
|
|
128
|
+
console.log('❌ Clear survival frame not found');
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
console.log('\n🎉 Direct persistence test completed!');
|
|
132
|
+
console.log('\nTo verify manually:');
|
|
133
|
+
console.log(` cat ${contextFile} | jq '.sessions[0].keyFrames | length'`);
|
|
134
|
+
console.log(` cat ${contextFile} | jq '.sessions[0].keyFrames[] | select(.tags | contains(["clear_survival"]))'`);
|
|
135
|
+
console.log(` cat ${contextFile} | jq '.globalPatterns'`);
|
|
136
|
+
|
|
137
|
+
// List all context files
|
|
138
|
+
console.log('\n📁 All context files:');
|
|
139
|
+
const files = await fs.readdir(contextDir);
|
|
140
|
+
for (const file of files) {
|
|
141
|
+
if (file.endsWith('.json')) {
|
|
142
|
+
const stats = await fs.stat(path.join(contextDir, file));
|
|
143
|
+
console.log(` ${file} (${stats.size} bytes, modified: ${new Date(stats.mtime).toLocaleString()})`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
testDirectPersistence().catch(console.error);
|