Skip to content

Commit 0f79457

Browse files
author
StackMemory Bot (CLI)
committed
feat: auto-init stackmemory on wrapper launch, remove dead feature flags
- Add ensureInitialized() to claude-sm, codex-sm, opencode-sm to auto-run `stackmemory init` if no context.db exists in the repo - Remove greptile and remote feature flags (unused) - Add initialInput support to pty-wrapper with bracketed paste injection - Fix onboard.ts init command (remove unsupported --silent flag) - Add test:smoke-db script
1 parent ed57a64 commit 0f79457

File tree

8 files changed

+268
-211
lines changed

8 files changed

+268
-211
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
"sync:setup": "./scripts/setup-background-sync.sh",
9595
"prepare": "echo 'Prepare step completed'",
9696
"verify:dist": "node scripts/verify-dist.cjs",
97+
"test:smoke-db": "bash scripts/smoke-init-db.sh",
9798
"rebuild:native": "npm rebuild better-sqlite3 || true",
9899
"deps:reset": "rm -rf node_modules package-lock.json && npm ci"
99100
},

scripts/smoke-init-db.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+

0 commit comments

Comments
 (0)