@stackmemoryai/stackmemory 0.7.0 → 0.8.1
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 +39 -1
- package/dist/src/cli/claude-sm.js +69 -372
- package/dist/src/cli/claude-sm.js.map +2 -2
- package/dist/src/cli/codex-sm.js +28 -0
- package/dist/src/cli/codex-sm.js.map +2 -2
- package/dist/src/cli/commands/clear.js +10 -15
- package/dist/src/cli/commands/clear.js.map +2 -2
- package/dist/src/cli/commands/daemon.js +31 -0
- package/dist/src/cli/commands/daemon.js.map +2 -2
- package/dist/src/cli/commands/onboard.js +22 -6
- package/dist/src/cli/commands/onboard.js.map +2 -2
- package/dist/src/cli/commands/setup.js +1 -2
- package/dist/src/cli/commands/setup.js.map +2 -2
- package/dist/src/cli/index.js +1 -71
- package/dist/src/cli/index.js.map +3 -3
- package/dist/src/cli/opencode-sm.js +28 -0
- package/dist/src/cli/opencode-sm.js.map +2 -2
- package/dist/src/core/config/feature-flags.js +1 -13
- package/dist/src/core/config/feature-flags.js.map +2 -2
- package/dist/src/core/context/refactored-frame-manager.js +7 -0
- package/dist/src/core/context/refactored-frame-manager.js.map +2 -2
- package/dist/src/core/database/sqlite-adapter.js +1 -1
- package/dist/src/core/database/sqlite-adapter.js.map +2 -2
- package/dist/src/core/session/enhanced-handoff.js +1 -1
- package/dist/src/core/session/enhanced-handoff.js.map +2 -2
- package/dist/src/daemon/daemon-config.js +11 -0
- package/dist/src/daemon/daemon-config.js.map +2 -2
- package/dist/src/daemon/services/memory-service.js +190 -0
- package/dist/src/daemon/services/memory-service.js.map +7 -0
- package/dist/src/daemon/unified-daemon.js +33 -3
- package/dist/src/daemon/unified-daemon.js.map +2 -2
- package/dist/src/features/sweep/pty-wrapper.js +11 -1
- package/dist/src/features/sweep/pty-wrapper.js.map +2 -2
- package/dist/src/hooks/index.js +0 -3
- package/dist/src/hooks/index.js.map +2 -2
- package/dist/src/hooks/schemas.js +0 -117
- package/dist/src/hooks/schemas.js.map +2 -2
- package/dist/src/hooks/session-summary.js.map +1 -1
- package/package.json +2 -2
- package/scripts/smoke-init-db.sh +77 -0
- package/scripts/test-pre-publish-quick.sh +26 -34
- package/scripts/install-notify-hook.sh +0 -84
- package/scripts/setup-notify-webhook.sh +0 -103
- package/templates/claude-hooks/notify-review-hook.js +0 -360
- package/templates/claude-hooks/sms-response-handler.js +0 -174
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
# Smoke test: verify wrappers auto-init StackMemory and create context.db
|
|
5
|
+
#
|
|
6
|
+
# Steps:
|
|
7
|
+
# - Create a fresh git repo
|
|
8
|
+
# - Prepend a PATH shim so "stackmemory" resolves to local dist CLI
|
|
9
|
+
# - Run each wrapper with flags to avoid external tool execution
|
|
10
|
+
# - Assert .stackmemory/context.db is created (DB enabled)
|
|
11
|
+
#
|
|
12
|
+
# Notes:
|
|
13
|
+
# - Requires that better-sqlite3 can load on this system.
|
|
14
|
+
# - Unsets env that disables DB in CLI (STACKMEMORY_TEST_SKIP_DB).
|
|
15
|
+
|
|
16
|
+
WS_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
17
|
+
DIST_CLI="$WS_ROOT/dist/src/cli/index.js"
|
|
18
|
+
if [[ ! -f "$DIST_CLI" ]]; then
|
|
19
|
+
echo "dist CLI not found at $DIST_CLI; run: npm run build" >&2
|
|
20
|
+
exit 1
|
|
21
|
+
fi
|
|
22
|
+
|
|
23
|
+
TEST_ROOT="$WS_ROOT/tmp/smoke-db-$(date +%s)"
|
|
24
|
+
SM_BIN_DIR="$TEST_ROOT/bin"
|
|
25
|
+
mkdir -p "$SM_BIN_DIR" "$TEST_ROOT"
|
|
26
|
+
|
|
27
|
+
# PATH shim for stackmemory -> local dist CLI
|
|
28
|
+
cat > "$SM_BIN_DIR/stackmemory" <<EOS
|
|
29
|
+
#!/usr/bin/env bash
|
|
30
|
+
exec node "$DIST_CLI" "$@"
|
|
31
|
+
EOS
|
|
32
|
+
chmod +x "$SM_BIN_DIR/stackmemory"
|
|
33
|
+
|
|
34
|
+
# Fresh git repo
|
|
35
|
+
mkdir -p "$TEST_ROOT/repo"
|
|
36
|
+
cd "$TEST_ROOT/repo"
|
|
37
|
+
git init -q
|
|
38
|
+
echo "# Smoke Test Repo" > README.md
|
|
39
|
+
git add README.md
|
|
40
|
+
git -c user.email=test@example.com -c user.name=test commit -q -m "init"
|
|
41
|
+
|
|
42
|
+
# PATH and env (ensure DB path is taken)
|
|
43
|
+
export PATH="$SM_BIN_DIR:$PATH"
|
|
44
|
+
unset STACKMEMORY_TEST_SKIP_DB || true
|
|
45
|
+
unset VITEST || true
|
|
46
|
+
unset NODE_ENV || true
|
|
47
|
+
|
|
48
|
+
failures=0
|
|
49
|
+
|
|
50
|
+
run_case() {
|
|
51
|
+
local name="$1"; shift
|
|
52
|
+
local cmd=("$@")
|
|
53
|
+
rm -rf .stackmemory
|
|
54
|
+
set +e
|
|
55
|
+
( "${cmd[@]}" ) >/dev/null 2>&1
|
|
56
|
+
local rc=$?
|
|
57
|
+
set -e
|
|
58
|
+
if [[ -f .stackmemory/context.db ]]; then
|
|
59
|
+
echo "$name: DB_OK (rc=$rc)"
|
|
60
|
+
else
|
|
61
|
+
echo "$name: DB_MISSING (rc=$rc)"; failures=$((failures+1))
|
|
62
|
+
fi
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
# Run wrappers to trigger auto-init
|
|
66
|
+
run_case codex-sm "$WS_ROOT/bin/codex-sm" --no-context --no-trace --codex-bin /bin/false
|
|
67
|
+
run_case opencode-sm "$WS_ROOT/bin/opencode-sm" --no-context --no-trace --opencode-bin /bin/false
|
|
68
|
+
run_case claude-sm "$WS_ROOT/bin/claude-sm" --no-context --no-trace --claude-bin /bin/false
|
|
69
|
+
|
|
70
|
+
if [[ $failures -eq 0 ]]; then
|
|
71
|
+
echo "ALL_DB_OK"
|
|
72
|
+
exit 0
|
|
73
|
+
else
|
|
74
|
+
echo "FAILURES=$failures"
|
|
75
|
+
exit 1
|
|
76
|
+
fi
|
|
77
|
+
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
# Quick Pre-Publish Test Suite
|
|
3
3
|
# Essential tests that must pass before npm publish
|
|
4
|
+
#
|
|
5
|
+
# Called by prepublishOnly which already runs: npm run build && npm run verify:dist
|
|
6
|
+
# So this script skips the redundant build and focuses on tests + lint + git cleanliness.
|
|
4
7
|
|
|
5
8
|
set -e
|
|
6
9
|
|
|
@@ -22,19 +25,25 @@ echo " StackMemory Quick Pre-Publish Tests"
|
|
|
22
25
|
echo "============================================"
|
|
23
26
|
echo
|
|
24
27
|
|
|
25
|
-
# Essential build test
|
|
26
|
-
log_info "Testing build..."
|
|
27
28
|
cd "$PROJECT_ROOT"
|
|
28
|
-
npm run build > /dev/null 2>&1 || log_error "Build failed"
|
|
29
|
-
log_success "Build succeeds"
|
|
30
29
|
|
|
31
|
-
#
|
|
32
|
-
log_info "
|
|
33
|
-
|
|
30
|
+
# Git status check — run FIRST before any command can dirty the tree
|
|
31
|
+
log_info "Checking git status..."
|
|
32
|
+
if git diff --quiet && git diff --cached --quiet; then
|
|
33
|
+
log_success "Git working directory is clean"
|
|
34
|
+
else
|
|
35
|
+
echo
|
|
36
|
+
git diff --name-only
|
|
37
|
+
git diff --cached --name-only
|
|
38
|
+
log_error "Git working directory has uncommitted changes (see above)"
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
# CLI artifact exists (build already ran in prepublishOnly)
|
|
42
|
+
log_info "Checking CLI artifact..."
|
|
34
43
|
if [ -f "dist/src/cli/index.js" ]; then
|
|
35
|
-
log_success "CLI
|
|
44
|
+
log_success "CLI artifact exists"
|
|
36
45
|
else
|
|
37
|
-
log_error "CLI
|
|
46
|
+
log_error "CLI artifact missing — build may have failed"
|
|
38
47
|
fi
|
|
39
48
|
|
|
40
49
|
# Package structure test
|
|
@@ -42,36 +51,19 @@ log_info "Testing package structure..."
|
|
|
42
51
|
npm pack --dry-run > /dev/null 2>&1 || log_error "npm pack failed"
|
|
43
52
|
log_success "Package structure valid"
|
|
44
53
|
|
|
45
|
-
#
|
|
46
|
-
log_info "
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
log_error "Shell integration binaries missing"
|
|
51
|
-
fi
|
|
52
|
-
|
|
53
|
-
# Quick binary functionality test
|
|
54
|
-
log_info "Testing binary functionality..."
|
|
55
|
-
# Skip shell integration test due to database initialization requirements
|
|
56
|
-
if [ -x "$HOME/.stackmemory/bin/stackmemory" ]; then
|
|
57
|
-
log_success "Shell integration works"
|
|
58
|
-
else
|
|
59
|
-
log_error "Shell integration binary failed"
|
|
54
|
+
# Core tests + search benchmark (100-frame smoke)
|
|
55
|
+
log_info "Running tests..."
|
|
56
|
+
npx vitest run --reporter=dot --bail=3 2>&1 | tail -5
|
|
57
|
+
if [ ${PIPESTATUS[0]} -ne 0 ]; then
|
|
58
|
+
log_error "Tests failed"
|
|
60
59
|
fi
|
|
60
|
+
log_success "Tests pass (including search benchmark)"
|
|
61
61
|
|
|
62
62
|
# Lint check
|
|
63
63
|
log_info "Testing lint..."
|
|
64
64
|
npm run lint > /dev/null 2>&1 || log_error "Lint failed"
|
|
65
65
|
log_success "Lint passes"
|
|
66
66
|
|
|
67
|
-
# Git status check
|
|
68
|
-
log_info "Checking git status..."
|
|
69
|
-
if git diff --quiet && git diff --cached --quiet; then
|
|
70
|
-
log_success "Git working directory is clean"
|
|
71
|
-
else
|
|
72
|
-
log_error "Git working directory has uncommitted changes"
|
|
73
|
-
fi
|
|
74
|
-
|
|
75
67
|
echo
|
|
76
|
-
echo -e "${GREEN}✅ All
|
|
77
|
-
echo -e "${GREEN}Ready for npm publish.${NC}"
|
|
68
|
+
echo -e "${GREEN}✅ All pre-publish checks passed!${NC}"
|
|
69
|
+
echo -e "${GREEN}Ready for npm publish.${NC}"
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# Install SMS notification hook for Claude Code (optional)
|
|
3
|
-
|
|
4
|
-
set -e
|
|
5
|
-
|
|
6
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
7
|
-
HOOK_SOURCE="$SCRIPT_DIR/../templates/claude-hooks/notify-review-hook.js"
|
|
8
|
-
CLAUDE_DIR="$HOME/.claude"
|
|
9
|
-
HOOKS_DIR="$CLAUDE_DIR/hooks"
|
|
10
|
-
SETTINGS_FILE="$CLAUDE_DIR/settings.json"
|
|
11
|
-
|
|
12
|
-
echo "Installing SMS notification hook for Claude Code..."
|
|
13
|
-
echo "(Optional feature - requires Twilio setup)"
|
|
14
|
-
echo ""
|
|
15
|
-
|
|
16
|
-
# Create directories
|
|
17
|
-
mkdir -p "$HOOKS_DIR"
|
|
18
|
-
|
|
19
|
-
# Copy hook script
|
|
20
|
-
HOOK_DEST="$HOOKS_DIR/notify-review-hook.js"
|
|
21
|
-
cp "$HOOK_SOURCE" "$HOOK_DEST"
|
|
22
|
-
chmod +x "$HOOK_DEST"
|
|
23
|
-
echo "Installed hook to $HOOK_DEST"
|
|
24
|
-
|
|
25
|
-
# Update Claude Code settings
|
|
26
|
-
if [ -f "$SETTINGS_FILE" ]; then
|
|
27
|
-
if command -v jq &> /dev/null; then
|
|
28
|
-
cp "$SETTINGS_FILE" "$SETTINGS_FILE.bak"
|
|
29
|
-
|
|
30
|
-
HOOK_CMD="node $HOOK_DEST"
|
|
31
|
-
|
|
32
|
-
# Add to post_tool_use hooks
|
|
33
|
-
if jq -e '.hooks.post_tool_use' "$SETTINGS_FILE" > /dev/null 2>&1; then
|
|
34
|
-
if ! jq -e ".hooks.post_tool_use | index(\"$HOOK_CMD\")" "$SETTINGS_FILE" > /dev/null 2>&1; then
|
|
35
|
-
jq ".hooks.post_tool_use += [\"$HOOK_CMD\"]" "$SETTINGS_FILE" > "$SETTINGS_FILE.tmp"
|
|
36
|
-
mv "$SETTINGS_FILE.tmp" "$SETTINGS_FILE"
|
|
37
|
-
echo "Added hook to post_tool_use array"
|
|
38
|
-
else
|
|
39
|
-
echo "Hook already configured"
|
|
40
|
-
fi
|
|
41
|
-
else
|
|
42
|
-
jq ".hooks = (.hooks // {}) | .hooks.post_tool_use = [\"$HOOK_CMD\"]" "$SETTINGS_FILE" > "$SETTINGS_FILE.tmp"
|
|
43
|
-
mv "$SETTINGS_FILE.tmp" "$SETTINGS_FILE"
|
|
44
|
-
echo "Created hooks.post_tool_use with notify hook"
|
|
45
|
-
fi
|
|
46
|
-
else
|
|
47
|
-
echo ""
|
|
48
|
-
echo "jq not found. Please manually add to $SETTINGS_FILE:"
|
|
49
|
-
echo ""
|
|
50
|
-
echo ' "hooks": {'
|
|
51
|
-
echo ' "post_tool_use": ["node '$HOOK_DEST'"]'
|
|
52
|
-
echo ' }'
|
|
53
|
-
fi
|
|
54
|
-
else
|
|
55
|
-
cat > "$SETTINGS_FILE" << EOF
|
|
56
|
-
{
|
|
57
|
-
"hooks": {
|
|
58
|
-
"post_tool_use": ["node $HOOK_DEST"]
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
EOF
|
|
62
|
-
echo "Created settings file with hook"
|
|
63
|
-
fi
|
|
64
|
-
|
|
65
|
-
echo ""
|
|
66
|
-
echo "Notification hook installed!"
|
|
67
|
-
echo ""
|
|
68
|
-
echo "To enable SMS notifications:"
|
|
69
|
-
echo " 1. Set Twilio environment variables:"
|
|
70
|
-
echo " export TWILIO_ACCOUNT_SID=your_sid"
|
|
71
|
-
echo " export TWILIO_AUTH_TOKEN=your_token"
|
|
72
|
-
echo " export TWILIO_FROM_NUMBER=+1234567890"
|
|
73
|
-
echo " export TWILIO_TO_NUMBER=+1234567890"
|
|
74
|
-
echo ""
|
|
75
|
-
echo " 2. Enable notifications:"
|
|
76
|
-
echo " stackmemory notify enable"
|
|
77
|
-
echo ""
|
|
78
|
-
echo " 3. Test:"
|
|
79
|
-
echo " stackmemory notify test"
|
|
80
|
-
echo ""
|
|
81
|
-
echo "Notifications will be sent when:"
|
|
82
|
-
echo " - PR is created (gh pr create)"
|
|
83
|
-
echo " - Package is published (npm publish)"
|
|
84
|
-
echo " - Deployment completes"
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# Auto-setup for StackMemory WhatsApp/SMS webhook loop
|
|
3
|
-
|
|
4
|
-
set -e
|
|
5
|
-
|
|
6
|
-
WEBHOOK_PORT="${1:-3456}"
|
|
7
|
-
TWILIO_ACCOUNT_SID="${TWILIO_ACCOUNT_SID}"
|
|
8
|
-
TWILIO_AUTH_TOKEN="${TWILIO_AUTH_TOKEN}"
|
|
9
|
-
|
|
10
|
-
echo "=== StackMemory Webhook Setup ==="
|
|
11
|
-
echo ""
|
|
12
|
-
|
|
13
|
-
# Check dependencies
|
|
14
|
-
if ! command -v ngrok &> /dev/null; then
|
|
15
|
-
echo "Installing ngrok..."
|
|
16
|
-
if command -v brew &> /dev/null; then
|
|
17
|
-
brew install ngrok
|
|
18
|
-
else
|
|
19
|
-
echo "Please install ngrok: https://ngrok.com/download"
|
|
20
|
-
exit 1
|
|
21
|
-
fi
|
|
22
|
-
fi
|
|
23
|
-
|
|
24
|
-
# Check Twilio credentials
|
|
25
|
-
if [ -z "$TWILIO_ACCOUNT_SID" ] || [ -z "$TWILIO_AUTH_TOKEN" ]; then
|
|
26
|
-
echo "Error: Set TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN"
|
|
27
|
-
exit 1
|
|
28
|
-
fi
|
|
29
|
-
|
|
30
|
-
# Kill any existing processes
|
|
31
|
-
pkill -f "notify webhook" 2>/dev/null || true
|
|
32
|
-
pkill -f "ngrok http $WEBHOOK_PORT" 2>/dev/null || true
|
|
33
|
-
sleep 1
|
|
34
|
-
|
|
35
|
-
# Start webhook server in background
|
|
36
|
-
echo "Starting webhook server on port $WEBHOOK_PORT..."
|
|
37
|
-
stackmemory notify webhook -p "$WEBHOOK_PORT" > /tmp/webhook.log 2>&1 &
|
|
38
|
-
WEBHOOK_PID=$!
|
|
39
|
-
sleep 2
|
|
40
|
-
|
|
41
|
-
# Start ngrok in background
|
|
42
|
-
echo "Starting ngrok tunnel..."
|
|
43
|
-
ngrok http "$WEBHOOK_PORT" --log=stdout > /tmp/ngrok.log 2>&1 &
|
|
44
|
-
NGROK_PID=$!
|
|
45
|
-
sleep 3
|
|
46
|
-
|
|
47
|
-
# Get ngrok public URL
|
|
48
|
-
NGROK_URL=$(curl -s http://localhost:4040/api/tunnels | grep -o '"public_url":"https://[^"]*' | head -1 | cut -d'"' -f4)
|
|
49
|
-
|
|
50
|
-
if [ -z "$NGROK_URL" ]; then
|
|
51
|
-
echo "Error: Could not get ngrok URL. Check /tmp/ngrok.log"
|
|
52
|
-
exit 1
|
|
53
|
-
fi
|
|
54
|
-
|
|
55
|
-
WEBHOOK_URL="${NGROK_URL}/sms/incoming"
|
|
56
|
-
echo ""
|
|
57
|
-
echo "Webhook URL: $WEBHOOK_URL"
|
|
58
|
-
|
|
59
|
-
# Configure Twilio WhatsApp sandbox webhook
|
|
60
|
-
echo ""
|
|
61
|
-
echo "Configuring Twilio WhatsApp sandbox..."
|
|
62
|
-
|
|
63
|
-
# Get sandbox configuration
|
|
64
|
-
SANDBOX_RESPONSE=$(curl -s "https://api.twilio.com/2010-04-01/Accounts/${TWILIO_ACCOUNT_SID}/Sandbox.json" \
|
|
65
|
-
-u "${TWILIO_ACCOUNT_SID}:${TWILIO_AUTH_TOKEN}" 2>/dev/null)
|
|
66
|
-
|
|
67
|
-
if echo "$SANDBOX_RESPONSE" | grep -q "sms_url"; then
|
|
68
|
-
# Update sandbox webhook URL
|
|
69
|
-
curl -s -X POST "https://api.twilio.com/2010-04-01/Accounts/${TWILIO_ACCOUNT_SID}/Sandbox.json" \
|
|
70
|
-
-u "${TWILIO_ACCOUNT_SID}:${TWILIO_AUTH_TOKEN}" \
|
|
71
|
-
-d "SmsUrl=${WEBHOOK_URL}" \
|
|
72
|
-
-d "SmsMethod=POST" > /dev/null
|
|
73
|
-
echo "Sandbox webhook configured!"
|
|
74
|
-
else
|
|
75
|
-
echo "Note: Configure webhook manually in Twilio console:"
|
|
76
|
-
echo " URL: $WEBHOOK_URL"
|
|
77
|
-
echo " https://console.twilio.com/us1/develop/sms/try-it-out/whatsapp-learn"
|
|
78
|
-
fi
|
|
79
|
-
|
|
80
|
-
# Install Claude hook
|
|
81
|
-
echo ""
|
|
82
|
-
echo "Installing Claude response hook..."
|
|
83
|
-
stackmemory notify install-response-hook 2>/dev/null || true
|
|
84
|
-
|
|
85
|
-
# Save PIDs for cleanup
|
|
86
|
-
echo "$WEBHOOK_PID" > /tmp/stackmemory-webhook.pid
|
|
87
|
-
echo "$NGROK_PID" > /tmp/stackmemory-ngrok.pid
|
|
88
|
-
|
|
89
|
-
echo ""
|
|
90
|
-
echo "=== Setup Complete ==="
|
|
91
|
-
echo ""
|
|
92
|
-
echo "Webhook server: http://localhost:$WEBHOOK_PORT (PID: $WEBHOOK_PID)"
|
|
93
|
-
echo "Ngrok tunnel: $NGROK_URL (PID: $NGROK_PID)"
|
|
94
|
-
echo "Webhook URL: $WEBHOOK_URL"
|
|
95
|
-
echo ""
|
|
96
|
-
echo "The loop is now active:"
|
|
97
|
-
echo " 1. Send notification: stackmemory notify review 'Task'"
|
|
98
|
-
echo " 2. User replies via WhatsApp"
|
|
99
|
-
echo " 3. Response queued for action"
|
|
100
|
-
echo " 4. Claude hook processes it"
|
|
101
|
-
echo ""
|
|
102
|
-
echo "To stop: ./scripts/stop-notify-webhook.sh"
|
|
103
|
-
echo "Logs: /tmp/webhook.log, /tmp/ngrok.log"
|