-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathstart-memstack.bat
More file actions
139 lines (121 loc) · 3.96 KB
/
start-memstack.bat
File metadata and controls
139 lines (121 loc) · 3.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
@echo off
REM ============================================================
REM MemStack v3.3.4 - Session Launcher
REM
REM Usage: start-memstack.bat (launch session)
REM start-memstack.bat link <path> (link project)
REM
REM Shortcut: Right-click this file, Send to, Desktop
REM (create shortcut). Then double-click to launch.
REM ============================================================
REM --- Dynamic path detection ---
set "MEMSTACK_DIR=%~dp0"
if "%MEMSTACK_DIR:~-1%"=="\" set "MEMSTACK_DIR=%MEMSTACK_DIR:~0,-1%"
REM --- Subcommand routing ---
if /i "%~1"=="link" goto link_project
title MemStack Launcher
echo.
echo MemStack v3.2.1 - Starting session...
echo =========================================
echo.
REM 1. Check if Headroom is already running
echo [1/4] Checking Headroom proxy on port 8787...
curl -s -o nul -w "" http://127.0.0.1:8787/health >nul 2>&1
if %errorlevel% equ 0 (
echo.
echo Headroom: ALREADY RUNNING
goto headroom_done
)
REM 2. Start Headroom proxy in a minimized window
echo Starting Headroom proxy...
start /min "Headroom Proxy" cmd /c "headroom proxy --port 8787 --llmlingua-device cpu"
REM 3. Wait for initialization
echo [2/4] Waiting for Headroom to initialize...
timeout /t 2 /nobreak >nul
REM 4. Health check
echo [3/4] Checking Headroom health...
curl -s -o nul -w "" http://127.0.0.1:8787/health >nul 2>&1
if %errorlevel% equ 0 (
echo.
echo Headroom: RUNNING
) else (
echo.
echo Headroom: FAILED - proxy may not be installed
echo Install with: pip install headroom-ai[code]
)
:headroom_done
REM 4. Count skills
set /a SKILL_COUNT=0
for /r "%MEMSTACK_DIR%\skills" %%f in (SKILL.md) do set /a SKILL_COUNT+=1
REM 5. Open VS Code (if available)
echo.
where code >nul 2>nul
if %errorlevel% neq 0 (
echo [5/5] VS Code not found, skipping...
) else (
echo [5/5] Opening VS Code...
code "%MEMSTACK_DIR%"
)
echo.
echo =========================================
echo MemStack v3.3.4 ready - %SKILL_COUNT% skills
echo =========================================
echo.
pause
goto :eof
REM ============================================================
REM link <project-path> — Create .claude junction to MemStack
REM ============================================================
:link_project
set "TARGET=%~2"
if "%TARGET%"=="" (
echo.
echo ERROR: No project path provided.
echo Usage: start-memstack.bat link C:\Projects\MyProject
echo.
goto :eof
)
if not exist "%TARGET%" (
echo.
echo ERROR: Directory not found: %TARGET%
echo.
goto :eof
)
REM Check if .claude already exists
if exist "%TARGET%\.claude" (
REM Check if it's already a junction (reparse point)
dir "%TARGET%" /AL 2>nul | findstr /C:".claude" >nul 2>&1
if %errorlevel% equ 0 (
REM It's a junction — remove it so we can recreate with current path
echo.
echo Updating existing junction...
rmdir "%TARGET%\.claude"
goto :create_junction
)
REM It's a real directory — merge MemStack rules into it without destroying user files
echo.
echo MERGE: %TARGET%\.claude exists as a real folder.
echo Copying MemStack rules into existing .claude directory...
if not exist "%TARGET%\.claude\rules" mkdir "%TARGET%\.claude\rules"
if not exist "%TARGET%\.claude\hooks" mkdir "%TARGET%\.claude\hooks"
xcopy "%MEMSTACK_DIR%\.claude\rules\*" "%TARGET%\.claude\rules\" /Y /Q >nul 2>&1
xcopy "%MEMSTACK_DIR%\.claude\hooks\*" "%TARGET%\.claude\hooks\" /Y /Q >nul 2>&1
echo.
echo SUCCESS: MemStack rules merged into %TARGET%\.claude
echo Note: Your existing settings, commands, and other files were preserved.
echo.
goto :eof
)
:create_junction
mklink /J "%TARGET%\.claude" "%MEMSTACK_DIR%\.claude"
if %errorlevel% equ 0 (
echo.
echo SUCCESS: Linked %TARGET%\.claude
echo -^> %MEMSTACK_DIR%\.claude
echo.
) else (
echo.
echo ERROR: Failed to create junction.
echo.
)
goto :eof