@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
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import 'dotenv/config';
|
|
4
|
+
import { RecursiveAgentOrchestrator } from '../dist/skills/recursive-agent-orchestrator.js';
|
|
5
|
+
import { FrameManager } from '../dist/core/context/frame-manager.js';
|
|
6
|
+
import { DualStackManager } from '../dist/core/context/dual-stack-manager.js';
|
|
7
|
+
import { ContextRetriever } from '../dist/core/retrieval/context-retriever.js';
|
|
8
|
+
import { PebblesTaskStore } from '../dist/features/tasks/pebbles-task-store.js';
|
|
9
|
+
import { SQLiteAdapter } from '../dist/core/database/sqlite-adapter.js';
|
|
10
|
+
import { ClaudeCodeSubagentClient } from '../dist/integrations/claude-code/subagent-client.js';
|
|
11
|
+
import * as path from 'path';
|
|
12
|
+
import * as os from 'os';
|
|
13
|
+
|
|
14
|
+
async function testRLM() {
|
|
15
|
+
console.log('🚀 Testing RLM Orchestrator...\n');
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
// Initialize dependencies
|
|
19
|
+
const projectId = 'test-project';
|
|
20
|
+
const userId = 'test-user';
|
|
21
|
+
const dbPath = path.join(os.tmpdir(), 'test-rlm.db');
|
|
22
|
+
|
|
23
|
+
console.log('📦 Initializing components...');
|
|
24
|
+
const database = new SQLiteAdapter(projectId, { dbPath });
|
|
25
|
+
await database.connect();
|
|
26
|
+
|
|
27
|
+
const dualStackManager = new DualStackManager(database, projectId, userId);
|
|
28
|
+
const frameManager = dualStackManager.getActiveStack();
|
|
29
|
+
const contextRetriever = new ContextRetriever(database);
|
|
30
|
+
|
|
31
|
+
// Initialize task store with projectId
|
|
32
|
+
const taskStorePath = path.join(os.tmpdir(), 'test-tasks');
|
|
33
|
+
const taskStore = new PebblesTaskStore(projectId, taskStorePath);
|
|
34
|
+
|
|
35
|
+
// Initialize RLM Orchestrator
|
|
36
|
+
console.log('🤖 Creating RLM Orchestrator...');
|
|
37
|
+
const rlm = new RecursiveAgentOrchestrator(
|
|
38
|
+
frameManager,
|
|
39
|
+
dualStackManager,
|
|
40
|
+
contextRetriever,
|
|
41
|
+
taskStore
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
// Test with a simple task
|
|
45
|
+
const task = 'Create a simple hello world function in JavaScript';
|
|
46
|
+
console.log(`\n📝 Task: "${task}"\n`);
|
|
47
|
+
|
|
48
|
+
const options = {
|
|
49
|
+
maxParallel: 2,
|
|
50
|
+
maxRecursionDepth: 2,
|
|
51
|
+
reviewStages: 1,
|
|
52
|
+
qualityThreshold: 0.7,
|
|
53
|
+
testGenerationMode: 'unit',
|
|
54
|
+
verboseLogging: true,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
console.log('⚙️ Options:', JSON.stringify(options, null, 2));
|
|
58
|
+
console.log('\n🔄 Executing RLM...\n');
|
|
59
|
+
|
|
60
|
+
const result = await rlm.execute(task, options);
|
|
61
|
+
|
|
62
|
+
if (result.success) {
|
|
63
|
+
console.log('✅ RLM Execution Successful!\n');
|
|
64
|
+
console.log('📊 Results:');
|
|
65
|
+
console.log(` - Total tokens: ${result.data.totalTokens}`);
|
|
66
|
+
console.log(` - Estimated cost: $${result.data.totalCost.toFixed(4)}`);
|
|
67
|
+
console.log(` - Duration: ${result.data.duration}ms`);
|
|
68
|
+
console.log(` - Tests generated: ${result.data.testsGenerated}`);
|
|
69
|
+
console.log(` - Issues found: ${result.data.issuesFound}`);
|
|
70
|
+
console.log(` - Issues fixed: ${result.data.issuesFixed}`);
|
|
71
|
+
|
|
72
|
+
if (result.data.improvements?.length > 0) {
|
|
73
|
+
console.log('\n🔧 Improvements:');
|
|
74
|
+
result.data.improvements.forEach(imp => {
|
|
75
|
+
console.log(` • ${imp}`);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
console.log('\n🌳 Execution Tree:');
|
|
80
|
+
printTaskTree(result.data.rootNode, 0);
|
|
81
|
+
} else {
|
|
82
|
+
console.log('❌ RLM Execution Failed');
|
|
83
|
+
console.log('Error:', result.message);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Cleanup
|
|
87
|
+
await database.disconnect();
|
|
88
|
+
console.log('\n✨ Test complete!');
|
|
89
|
+
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.error('💥 Test failed:', error);
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function printTaskTree(node, depth = 0) {
|
|
97
|
+
const indent = ' '.repeat(depth);
|
|
98
|
+
const status = node.status === 'completed' ? '✓' :
|
|
99
|
+
node.status === 'failed' ? '✗' :
|
|
100
|
+
node.status === 'running' ? '⟳' : '○';
|
|
101
|
+
|
|
102
|
+
console.log(`${indent}${status} ${node.description} [${node.agent}]`);
|
|
103
|
+
|
|
104
|
+
if (node.children) {
|
|
105
|
+
node.children.forEach(child => printTaskTree(child, depth + 1));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Run the test
|
|
110
|
+
testRLM().catch(console.error);
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Test session handoff and memory persistence between Claude sessions
|
|
4
|
+
# This script validates the full lifecycle of context preservation
|
|
5
|
+
|
|
6
|
+
set -e
|
|
7
|
+
|
|
8
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
9
|
+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
10
|
+
|
|
11
|
+
# Colors
|
|
12
|
+
GREEN='\033[0;32m'
|
|
13
|
+
YELLOW='\033[1;33m'
|
|
14
|
+
BLUE='\033[0;34m'
|
|
15
|
+
NC='\033[0m'
|
|
16
|
+
|
|
17
|
+
echo -e "${BLUE}=== Session Handoff & Memory Test ===${NC}"
|
|
18
|
+
echo
|
|
19
|
+
|
|
20
|
+
# 1. Create context in current session
|
|
21
|
+
echo -e "${BLUE}1. Creating session context...${NC}"
|
|
22
|
+
stackmemory context add observation "Session starting - testing handoff"
|
|
23
|
+
stackmemory context add decision "Using shared context for persistence"
|
|
24
|
+
stackmemory context add observation "Progress checkpoint 1"
|
|
25
|
+
echo -e "${GREEN}✓ Context created${NC}"
|
|
26
|
+
echo
|
|
27
|
+
|
|
28
|
+
# 2. Save progress to shared context
|
|
29
|
+
echo -e "${BLUE}2. Saving progress to shared context...${NC}"
|
|
30
|
+
cat << 'EOF' | node -
|
|
31
|
+
const fs = require('fs');
|
|
32
|
+
const path = require('path');
|
|
33
|
+
|
|
34
|
+
const progressData = {
|
|
35
|
+
sessionId: 'test-' + Date.now(),
|
|
36
|
+
timestamp: new Date().toISOString(),
|
|
37
|
+
project: 'stackmemory',
|
|
38
|
+
branch: 'main',
|
|
39
|
+
progress: {
|
|
40
|
+
tasksCompleted: [
|
|
41
|
+
'Setup session context',
|
|
42
|
+
'Test persistence mechanism'
|
|
43
|
+
],
|
|
44
|
+
currentTask: 'Validate handoff process',
|
|
45
|
+
pendingTasks: [
|
|
46
|
+
'Verify retrieval in new session',
|
|
47
|
+
'Test hook integration'
|
|
48
|
+
],
|
|
49
|
+
decisions: [
|
|
50
|
+
'Use shared context for inter-session persistence',
|
|
51
|
+
'Implement checkpoint-based recovery'
|
|
52
|
+
],
|
|
53
|
+
blockers: [],
|
|
54
|
+
lastCheckpoint: new Date().toISOString(),
|
|
55
|
+
contextFrames: 3,
|
|
56
|
+
sessionDuration: '15 minutes'
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const sharedDir = path.join(process.env.HOME, '.stackmemory/shared-context/projects');
|
|
61
|
+
if (!fs.existsSync(sharedDir)) {
|
|
62
|
+
fs.mkdirSync(sharedDir, { recursive: true });
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const filePath = path.join(sharedDir, 'stackmemory_main.json');
|
|
66
|
+
fs.writeFileSync(filePath, JSON.stringify(progressData, null, 2));
|
|
67
|
+
console.log('✓ Progress saved to shared context');
|
|
68
|
+
console.log(' Path:', filePath);
|
|
69
|
+
console.log(' Session:', progressData.sessionId);
|
|
70
|
+
console.log(' Tasks completed:', progressData.progress.tasksCompleted.length);
|
|
71
|
+
EOF
|
|
72
|
+
echo
|
|
73
|
+
|
|
74
|
+
# 3. Generate handoff
|
|
75
|
+
echo -e "${BLUE}3. Generating handoff summary...${NC}"
|
|
76
|
+
stackmemory handoff > /tmp/handoff-test.md
|
|
77
|
+
echo -e "${GREEN}✓ Handoff generated${NC}"
|
|
78
|
+
echo " Saved to: /tmp/handoff-test.md"
|
|
79
|
+
echo
|
|
80
|
+
|
|
81
|
+
# 4. Save with clear command
|
|
82
|
+
echo -e "${BLUE}4. Testing clear --save...${NC}"
|
|
83
|
+
stackmemory clear --save
|
|
84
|
+
echo -e "${GREEN}✓ Context saved for clear survival${NC}"
|
|
85
|
+
echo
|
|
86
|
+
|
|
87
|
+
# 5. Simulate new session retrieval
|
|
88
|
+
echo -e "${BLUE}5. Simulating new session context load...${NC}"
|
|
89
|
+
cat << 'EOF' | node -
|
|
90
|
+
const fs = require('fs');
|
|
91
|
+
const path = require('path');
|
|
92
|
+
|
|
93
|
+
console.log('\n--- NEW SESSION START ---\n');
|
|
94
|
+
|
|
95
|
+
// Load saved context
|
|
96
|
+
const filePath = path.join(process.env.HOME, '.stackmemory/shared-context/projects/stackmemory_main.json');
|
|
97
|
+
|
|
98
|
+
if (fs.existsSync(filePath)) {
|
|
99
|
+
const data = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
100
|
+
|
|
101
|
+
console.log('📚 Restored Context from Previous Session:');
|
|
102
|
+
console.log('━'.repeat(50));
|
|
103
|
+
console.log('Previous session:', data.sessionId);
|
|
104
|
+
console.log('Last active:', data.timestamp);
|
|
105
|
+
console.log('');
|
|
106
|
+
console.log('✅ Completed Tasks:');
|
|
107
|
+
data.progress.tasksCompleted.forEach(task => {
|
|
108
|
+
console.log(' •', task);
|
|
109
|
+
});
|
|
110
|
+
console.log('');
|
|
111
|
+
console.log('🔄 Current Task:');
|
|
112
|
+
console.log(' •', data.progress.currentTask);
|
|
113
|
+
console.log('');
|
|
114
|
+
console.log('📋 Pending Tasks:');
|
|
115
|
+
data.progress.pendingTasks.forEach(task => {
|
|
116
|
+
console.log(' •', task);
|
|
117
|
+
});
|
|
118
|
+
console.log('');
|
|
119
|
+
console.log('💡 Key Decisions:');
|
|
120
|
+
data.progress.decisions.forEach(decision => {
|
|
121
|
+
console.log(' •', decision);
|
|
122
|
+
});
|
|
123
|
+
console.log('━'.repeat(50));
|
|
124
|
+
|
|
125
|
+
// Calculate session gap
|
|
126
|
+
const lastTime = new Date(data.progress.lastCheckpoint);
|
|
127
|
+
const gap = Math.round((Date.now() - lastTime.getTime()) / 1000);
|
|
128
|
+
console.log(`\nSession gap: ${gap} seconds`);
|
|
129
|
+
console.log('Ready to continue from checkpoint ✨');
|
|
130
|
+
} else {
|
|
131
|
+
console.log('❌ No previous session context found');
|
|
132
|
+
}
|
|
133
|
+
EOF
|
|
134
|
+
echo
|
|
135
|
+
|
|
136
|
+
# 6. Restore from clear
|
|
137
|
+
echo -e "${BLUE}6. Testing clear --restore...${NC}"
|
|
138
|
+
stackmemory clear --restore
|
|
139
|
+
echo -e "${GREEN}✓ Context restored${NC}"
|
|
140
|
+
echo
|
|
141
|
+
|
|
142
|
+
# 7. Verify restoration
|
|
143
|
+
echo -e "${BLUE}7. Verifying restored context...${NC}"
|
|
144
|
+
stackmemory context show
|
|
145
|
+
echo
|
|
146
|
+
|
|
147
|
+
# Summary
|
|
148
|
+
echo -e "${BLUE}=== Test Summary ===${NC}"
|
|
149
|
+
echo -e "${GREEN}✓ Session context created and saved${NC}"
|
|
150
|
+
echo -e "${GREEN}✓ Progress persisted to shared context${NC}"
|
|
151
|
+
echo -e "${GREEN}✓ Handoff generated successfully${NC}"
|
|
152
|
+
echo -e "${GREEN}✓ Clear/restore cycle working${NC}"
|
|
153
|
+
echo -e "${GREEN}✓ New session can retrieve context${NC}"
|
|
154
|
+
echo
|
|
155
|
+
echo "Key locations:"
|
|
156
|
+
echo " • Shared context: ~/.stackmemory/shared-context/projects/"
|
|
157
|
+
echo " • Continuity ledger: ./.stackmemory/continuity.json"
|
|
158
|
+
echo " • Last handoff: ./.stackmemory/last-handoff.md"
|
|
159
|
+
echo " • Session data: ~/.stackmemory/sessions/"
|
|
160
|
+
echo
|
|
161
|
+
echo -e "${YELLOW}💡 To use in new Claude session:${NC}"
|
|
162
|
+
echo " 1. Run: stackmemory handoff"
|
|
163
|
+
echo " 2. Copy the handoff summary"
|
|
164
|
+
echo " 3. Paste at start of new session"
|
|
165
|
+
echo " 4. Context will be automatically loaded"
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# StackMemory Shell Integration Test Suite
|
|
3
|
+
# Tests shell integration components in isolation
|
|
4
|
+
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
8
|
+
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
|
9
|
+
|
|
10
|
+
# Colors
|
|
11
|
+
GREEN='\033[0;32m'
|
|
12
|
+
RED='\033[0;31m'
|
|
13
|
+
YELLOW='\033[1;33m'
|
|
14
|
+
BLUE='\033[0;34m'
|
|
15
|
+
NC='\033[0m'
|
|
16
|
+
|
|
17
|
+
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
|
18
|
+
log_success() { echo -e "${GREEN}[PASS]${NC} $1"; }
|
|
19
|
+
log_error() { echo -e "${RED}[FAIL]${NC} $1"; }
|
|
20
|
+
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
|
|
21
|
+
|
|
22
|
+
TEST_COUNT=0
|
|
23
|
+
PASS_COUNT=0
|
|
24
|
+
|
|
25
|
+
run_shell_test() {
|
|
26
|
+
local test_name="$1"
|
|
27
|
+
local test_function="$2"
|
|
28
|
+
|
|
29
|
+
((TEST_COUNT++))
|
|
30
|
+
log_info "Test $TEST_COUNT: $test_name"
|
|
31
|
+
|
|
32
|
+
if $test_function; then
|
|
33
|
+
log_success "$test_name"
|
|
34
|
+
((PASS_COUNT++))
|
|
35
|
+
return 0
|
|
36
|
+
else
|
|
37
|
+
log_error "$test_name"
|
|
38
|
+
return 1
|
|
39
|
+
fi
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
# Test functions
|
|
43
|
+
test_binaries_directory_exists() {
|
|
44
|
+
[ -d "$HOME/.stackmemory/bin" ]
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
test_all_binaries_exist() {
|
|
48
|
+
local binaries=("stackmemory" "stackmemory-daemon" "stackmemory-monitor" "sm-review")
|
|
49
|
+
for binary in "${binaries[@]}"; do
|
|
50
|
+
if [ ! -f "$HOME/.stackmemory/bin/$binary" ]; then
|
|
51
|
+
echo "Missing binary: $binary"
|
|
52
|
+
return 1
|
|
53
|
+
fi
|
|
54
|
+
if [ ! -x "$HOME/.stackmemory/bin/$binary" ]; then
|
|
55
|
+
echo "Binary not executable: $binary"
|
|
56
|
+
return 1
|
|
57
|
+
fi
|
|
58
|
+
done
|
|
59
|
+
return 0
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
test_stackmemory_daemon() {
|
|
63
|
+
local output
|
|
64
|
+
|
|
65
|
+
# Test help/usage (should fail and show usage for invalid args)
|
|
66
|
+
if output=$("$HOME/.stackmemory/bin/stackmemory-daemon" invalid 2>&1); then
|
|
67
|
+
if ! echo "$output" | grep -q "Usage:"; then
|
|
68
|
+
echo "Should show usage for invalid args"
|
|
69
|
+
return 1
|
|
70
|
+
fi
|
|
71
|
+
fi
|
|
72
|
+
|
|
73
|
+
# Test status command (should succeed)
|
|
74
|
+
if ! output=$("$HOME/.stackmemory/bin/stackmemory-daemon" status 2>&1); then
|
|
75
|
+
echo "Status command failed: $output"
|
|
76
|
+
return 1
|
|
77
|
+
fi
|
|
78
|
+
|
|
79
|
+
return 0
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
test_stackmemory_monitor() {
|
|
83
|
+
local output
|
|
84
|
+
|
|
85
|
+
# Test config command
|
|
86
|
+
if ! output=$("$HOME/.stackmemory/bin/stackmemory-monitor" config 2>&1); then
|
|
87
|
+
echo "Config command failed: $output"
|
|
88
|
+
return 1
|
|
89
|
+
fi
|
|
90
|
+
|
|
91
|
+
# Should show current configuration
|
|
92
|
+
if ! echo "$output" | grep -qi "monitor\|configuration\|interval"; then
|
|
93
|
+
echo "Config output doesn't contain expected text: $output"
|
|
94
|
+
return 1
|
|
95
|
+
fi
|
|
96
|
+
|
|
97
|
+
return 0
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
test_sm_review() {
|
|
101
|
+
local output
|
|
102
|
+
|
|
103
|
+
# Test recent command (should not fail even if no context)
|
|
104
|
+
if ! output=$(timeout 10s "$HOME/.stackmemory/bin/sm-review" recent 1 2>&1); then
|
|
105
|
+
echo "Recent command failed: $output"
|
|
106
|
+
return 1
|
|
107
|
+
fi
|
|
108
|
+
|
|
109
|
+
# Test default command
|
|
110
|
+
if ! output=$(timeout 10s "$HOME/.stackmemory/bin/sm-review" 2>&1); then
|
|
111
|
+
echo "Default command failed: $output"
|
|
112
|
+
return 1
|
|
113
|
+
fi
|
|
114
|
+
|
|
115
|
+
return 0
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
test_stackmemory_wrapper() {
|
|
119
|
+
local output
|
|
120
|
+
|
|
121
|
+
# Test version command
|
|
122
|
+
if ! output=$(timeout 10s "$HOME/.stackmemory/bin/stackmemory" --version 2>&1); then
|
|
123
|
+
echo "Version command failed: $output"
|
|
124
|
+
return 1
|
|
125
|
+
fi
|
|
126
|
+
|
|
127
|
+
# Should return version number
|
|
128
|
+
if ! echo "$output" | grep -E "^[0-9]+\.[0-9]+\.[0-9]+"; then
|
|
129
|
+
echo "Version output doesn't match expected pattern: $output"
|
|
130
|
+
return 1
|
|
131
|
+
fi
|
|
132
|
+
|
|
133
|
+
return 0
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
test_shell_integration_files_exist() {
|
|
137
|
+
[ -f "$HOME/.stackmemory/shell-integration.sh" ] &&
|
|
138
|
+
[ -f "$HOME/.stackmemory/shell-integration-consolidated.sh" ]
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
test_shell_integration_syntax() {
|
|
142
|
+
# Test basic shell integration syntax
|
|
143
|
+
if ! bash -n "$HOME/.stackmemory/shell-integration.sh"; then
|
|
144
|
+
echo "Basic shell integration has syntax errors"
|
|
145
|
+
return 1
|
|
146
|
+
fi
|
|
147
|
+
|
|
148
|
+
# Test consolidated integration syntax
|
|
149
|
+
if ! bash -n "$HOME/.stackmemory/shell-integration-consolidated.sh"; then
|
|
150
|
+
echo "Consolidated shell integration has syntax errors"
|
|
151
|
+
return 1
|
|
152
|
+
fi
|
|
153
|
+
|
|
154
|
+
return 0
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
test_shell_integration_loading() {
|
|
158
|
+
# Test that shell integration can be sourced without errors
|
|
159
|
+
local temp_script=$(mktemp)
|
|
160
|
+
cat > "$temp_script" << 'EOF'
|
|
161
|
+
#!/bin/bash
|
|
162
|
+
set -e
|
|
163
|
+
# Temporarily disable the problematic parts and test basic loading
|
|
164
|
+
export STACKMEMORY_HOME="$HOME/.stackmemory"
|
|
165
|
+
source "$HOME/.stackmemory/shell-integration.sh" || exit 1
|
|
166
|
+
echo "Basic integration loaded successfully"
|
|
167
|
+
EOF
|
|
168
|
+
|
|
169
|
+
if bash "$temp_script"; then
|
|
170
|
+
rm -f "$temp_script"
|
|
171
|
+
return 0
|
|
172
|
+
else
|
|
173
|
+
rm -f "$temp_script"
|
|
174
|
+
echo "Shell integration loading failed"
|
|
175
|
+
return 1
|
|
176
|
+
fi
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
test_path_configuration() {
|
|
180
|
+
# Test that PATH includes stackmemory bin directory
|
|
181
|
+
if ! echo "$PATH" | grep -q "$HOME/.stackmemory/bin"; then
|
|
182
|
+
echo "PATH doesn't include ~/.stackmemory/bin"
|
|
183
|
+
return 1
|
|
184
|
+
fi
|
|
185
|
+
|
|
186
|
+
# Test that stackmemory command is found in PATH
|
|
187
|
+
if ! command -v stackmemory > /dev/null; then
|
|
188
|
+
echo "stackmemory command not found in PATH"
|
|
189
|
+
return 1
|
|
190
|
+
fi
|
|
191
|
+
|
|
192
|
+
return 0
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
test_no_startup_errors() {
|
|
196
|
+
# Test that sourcing shell integration doesn't produce errors
|
|
197
|
+
local temp_script=$(mktemp)
|
|
198
|
+
cat > "$temp_script" << 'EOF'
|
|
199
|
+
#!/bin/bash
|
|
200
|
+
# Capture any error output when sourcing
|
|
201
|
+
exec 2> /tmp/shell_integration_errors.log
|
|
202
|
+
set -e
|
|
203
|
+
source ~/.stackmemory/shell-integration-consolidated.sh
|
|
204
|
+
EOF
|
|
205
|
+
|
|
206
|
+
# Run in a timeout to prevent hanging
|
|
207
|
+
if timeout 30s bash "$temp_script" > /dev/null 2>&1; then
|
|
208
|
+
# Check if any errors were logged
|
|
209
|
+
if [ -f /tmp/shell_integration_errors.log ] && [ -s /tmp/shell_integration_errors.log ]; then
|
|
210
|
+
echo "Shell integration produced errors:"
|
|
211
|
+
cat /tmp/shell_integration_errors.log
|
|
212
|
+
rm -f /tmp/shell_integration_errors.log "$temp_script"
|
|
213
|
+
return 1
|
|
214
|
+
fi
|
|
215
|
+
rm -f /tmp/shell_integration_errors.log "$temp_script"
|
|
216
|
+
return 0
|
|
217
|
+
else
|
|
218
|
+
rm -f /tmp/shell_integration_errors.log "$temp_script"
|
|
219
|
+
echo "Shell integration timed out or failed"
|
|
220
|
+
return 1
|
|
221
|
+
fi
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
# Main test execution
|
|
225
|
+
main() {
|
|
226
|
+
echo "============================================"
|
|
227
|
+
echo " StackMemory Shell Integration Test Suite"
|
|
228
|
+
echo "============================================"
|
|
229
|
+
echo
|
|
230
|
+
|
|
231
|
+
log_info "Testing shell integration components..."
|
|
232
|
+
echo
|
|
233
|
+
|
|
234
|
+
# Directory and file tests
|
|
235
|
+
run_shell_test "Binaries directory exists" "test_binaries_directory_exists"
|
|
236
|
+
run_shell_test "All required binaries exist and are executable" "test_all_binaries_exist"
|
|
237
|
+
run_shell_test "Shell integration files exist" "test_shell_integration_files_exist"
|
|
238
|
+
echo
|
|
239
|
+
|
|
240
|
+
# Syntax tests
|
|
241
|
+
run_shell_test "Shell integration syntax is valid" "test_shell_integration_syntax"
|
|
242
|
+
echo
|
|
243
|
+
|
|
244
|
+
# Functionality tests
|
|
245
|
+
run_shell_test "stackmemory-daemon functionality" "test_stackmemory_daemon"
|
|
246
|
+
run_shell_test "stackmemory-monitor functionality" "test_stackmemory_monitor"
|
|
247
|
+
run_shell_test "sm-review functionality" "test_sm_review"
|
|
248
|
+
run_shell_test "stackmemory wrapper functionality" "test_stackmemory_wrapper"
|
|
249
|
+
echo
|
|
250
|
+
|
|
251
|
+
# Integration tests
|
|
252
|
+
run_shell_test "Shell integration can be loaded" "test_shell_integration_loading"
|
|
253
|
+
run_shell_test "PATH configuration is correct" "test_path_configuration"
|
|
254
|
+
run_shell_test "No startup errors in shell integration" "test_no_startup_errors"
|
|
255
|
+
echo
|
|
256
|
+
|
|
257
|
+
# Results
|
|
258
|
+
echo "============================================"
|
|
259
|
+
echo " Shell Integration Test Results"
|
|
260
|
+
echo "============================================"
|
|
261
|
+
echo "Total tests: $TEST_COUNT"
|
|
262
|
+
echo -e "${GREEN}Passed: $PASS_COUNT${NC}"
|
|
263
|
+
echo -e "${RED}Failed: $((TEST_COUNT - PASS_COUNT))${NC}"
|
|
264
|
+
echo
|
|
265
|
+
|
|
266
|
+
if [ $PASS_COUNT -eq $TEST_COUNT ]; then
|
|
267
|
+
echo -e "${GREEN}✅ All shell integration tests passed!${NC}"
|
|
268
|
+
return 0
|
|
269
|
+
else
|
|
270
|
+
echo -e "${RED}❌ Some shell integration tests failed.${NC}"
|
|
271
|
+
return 1
|
|
272
|
+
fi
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
main "$@"
|