claude-mem 9.0.7 → 10.0.8
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 +33 -5
- package/package.json +19 -3
- package/plugin/.claude-plugin/CLAUDE.md +0 -2
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/CLAUDE.md +1 -3
- package/plugin/hooks/CLAUDE.md +0 -2
- package/plugin/hooks/hooks.json +25 -13
- package/plugin/modes/code--ur.json +25 -0
- package/plugin/package.json +4 -2
- package/plugin/scripts/CLAUDE.md +0 -2
- package/plugin/scripts/bun-runner.js +90 -0
- package/plugin/scripts/context-generator.cjs +153 -47
- package/plugin/scripts/mcp-server.cjs +23 -23
- package/plugin/scripts/setup.sh +228 -0
- package/plugin/scripts/smart-install.js +50 -1
- package/plugin/scripts/statusline-counts.js +61 -0
- package/plugin/scripts/worker-service.cjs +375 -242
- package/plugin/skills/mem-search/SKILL.md +141 -0
- package/plugin/ui/CLAUDE.md +0 -2
- package/plugin/ui/viewer-bundle.js +15 -11
- package/dist/index.d.ts +0 -7
- package/dist/index.js +0 -8
- package/dist/sdk/index.d.ts +0 -109
- package/dist/sdk/index.js +0 -183
- package/plugin/commands/CLAUDE.md +0 -18
- package/plugin/modes/CLAUDE.md +0 -7
- package/plugin/skills/mem-search/CLAUDE.md +0 -17
- package/plugin/ui/assets/fonts/CLAUDE.md +0 -99
package/README.md
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
|
|
23
23
|
<p align="center">
|
|
24
24
|
<a href="docs/i18n/README.zh.md">🇨🇳 中文</a> •
|
|
25
|
+
<a href="docs/i18n/README.zh-tw.md">🇹🇼 繁體中文</a> •
|
|
25
26
|
<a href="docs/i18n/README.ja.md">🇯🇵 日本語</a> •
|
|
26
27
|
<a href="docs/i18n/README.pt-br.md">🇧🇷 Português</a> •
|
|
27
28
|
<a href="docs/i18n/README.ko.md">🇰🇷 한국어</a> •
|
|
@@ -41,6 +42,7 @@
|
|
|
41
42
|
<a href="docs/i18n/README.th.md">🇹🇭 ไทย</a> •
|
|
42
43
|
<a href="docs/i18n/README.hi.md">🇮🇳 हिन्दी</a> •
|
|
43
44
|
<a href="docs/i18n/README.bn.md">🇧🇩 বাংলা</a> •
|
|
45
|
+
<a href="docs/i18n/README.ur.md">🇵🇰 اردو</a> •
|
|
44
46
|
<a href="docs/i18n/README.ro.md">🇷🇴 Română</a> •
|
|
45
47
|
<a href="docs/i18n/README.sv.md">🇸🇪 Svenska</a> •
|
|
46
48
|
<a href="docs/i18n/README.it.md">🇮🇹 Italiano</a> •
|
|
@@ -109,13 +111,23 @@
|
|
|
109
111
|
Start a new Claude Code session in the terminal and enter the following commands:
|
|
110
112
|
|
|
111
113
|
```
|
|
112
|
-
|
|
114
|
+
/plugin marketplace add thedotmack/claude-mem
|
|
113
115
|
|
|
114
|
-
|
|
116
|
+
/plugin install claude-mem
|
|
115
117
|
```
|
|
116
118
|
|
|
117
119
|
Restart Claude Code. Context from previous sessions will automatically appear in new sessions.
|
|
118
120
|
|
|
121
|
+
### 🦞 OpenClaw Gateway
|
|
122
|
+
|
|
123
|
+
Install claude-mem as a persistent memory plugin on [OpenClaw](https://openclaw.ai) gateways with a single command:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
curl -fsSL https://install.cmem.ai/openclaw.sh | bash
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
The installer handles dependencies, plugin setup, AI provider configuration, worker startup, and optional real-time observation feeds to Telegram, Discord, Slack, and more. See the [OpenClaw Integration Guide](https://docs.claude-mem.ai/openclaw-integration) for details.
|
|
130
|
+
|
|
119
131
|
**Key Features:**
|
|
120
132
|
|
|
121
133
|
- 🧠 **Persistent Memory** - Context survives across sessions
|
|
@@ -133,7 +145,7 @@ Restart Claude Code. Context from previous sessions will automatically appear in
|
|
|
133
145
|
|
|
134
146
|
## Documentation
|
|
135
147
|
|
|
136
|
-
📚 **[View Full Documentation](docs/)** - Browse
|
|
148
|
+
📚 **[View Full Documentation](https://docs.claude-mem.ai/)** - Browse on official website
|
|
137
149
|
|
|
138
150
|
### Getting Started
|
|
139
151
|
|
|
@@ -182,7 +194,7 @@ See [Architecture Overview](https://docs.claude-mem.ai/architecture/overview) fo
|
|
|
182
194
|
|
|
183
195
|
## MCP Search Tools
|
|
184
196
|
|
|
185
|
-
Claude-Mem provides intelligent memory search through **
|
|
197
|
+
Claude-Mem provides intelligent memory search through **5 MCP tools** following a token-efficient **3-layer workflow pattern**:
|
|
186
198
|
|
|
187
199
|
**The 3-Layer Workflow:**
|
|
188
200
|
|
|
@@ -195,6 +207,7 @@ Claude-Mem provides intelligent memory search through **4 MCP tools** following
|
|
|
195
207
|
- Start with `search` to get an index of results
|
|
196
208
|
- Use `timeline` to see what was happening around specific observations
|
|
197
209
|
- Use `get_observations` to fetch full details for relevant IDs
|
|
210
|
+
- Use `save_memory` to manually store important information
|
|
198
211
|
- **~10x token savings** by filtering before fetching details
|
|
199
212
|
|
|
200
213
|
**Available MCP Tools:**
|
|
@@ -202,7 +215,8 @@ Claude-Mem provides intelligent memory search through **4 MCP tools** following
|
|
|
202
215
|
1. **`search`** - Search memory index with full-text queries, filters by type/date/project
|
|
203
216
|
2. **`timeline`** - Get chronological context around a specific observation or query
|
|
204
217
|
3. **`get_observations`** - Fetch full observation details by IDs (always batch multiple IDs)
|
|
205
|
-
4. **`
|
|
218
|
+
4. **`save_memory`** - Manually save a memory/observation for semantic search
|
|
219
|
+
5. **`__IMPORTANT`** - Workflow documentation (always visible to Claude)
|
|
206
220
|
|
|
207
221
|
**Example Usage:**
|
|
208
222
|
|
|
@@ -214,6 +228,9 @@ search(query="authentication bug", type="bugfix", limit=10)
|
|
|
214
228
|
|
|
215
229
|
// Step 3: Fetch full details
|
|
216
230
|
get_observations(ids=[123, 456])
|
|
231
|
+
|
|
232
|
+
// Save important information manually
|
|
233
|
+
save_memory(text="API requires auth header X-API-Key", title="API Auth")
|
|
217
234
|
```
|
|
218
235
|
|
|
219
236
|
See [Search Tools Guide](https://docs.claude-mem.ai/usage/search-tools) for detailed examples.
|
|
@@ -236,6 +253,17 @@ See **[Beta Features Documentation](https://docs.claude-mem.ai/beta-features)**
|
|
|
236
253
|
- **uv**: Python package manager for vector search (auto-installed if missing)
|
|
237
254
|
- **SQLite 3**: For persistent storage (bundled)
|
|
238
255
|
|
|
256
|
+
---
|
|
257
|
+
### Windows Setup Notes
|
|
258
|
+
|
|
259
|
+
If you see an error like:
|
|
260
|
+
|
|
261
|
+
```powershell
|
|
262
|
+
npm : The term 'npm' is not recognized as the name of a cmdlet
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
Make sure Node.js and npm are installed and added to your PATH. Download the latest Node.js installer from https://nodejs.org and restart your terminal after installation.
|
|
266
|
+
|
|
239
267
|
---
|
|
240
268
|
|
|
241
269
|
## Configuration
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-mem",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.8",
|
|
4
4
|
"description": "Memory compression system for Claude Code - persist context across sessions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"claude-md:regenerate": "bun scripts/regenerate-claude-md.ts",
|
|
67
67
|
"claude-md:dry-run": "bun scripts/regenerate-claude-md.ts --dry-run",
|
|
68
68
|
"translate-readme": "bun scripts/translate-readme/cli.ts -v -o docs/i18n README.md",
|
|
69
|
-
"translate:tier1": "npm run translate-readme -- zh ja pt-br ko es de fr",
|
|
69
|
+
"translate:tier1": "npm run translate-readme -- zh zh-tw ja pt-br ko es de fr",
|
|
70
70
|
"translate:tier2": "npm run translate-readme -- he ar ru pl cs nl tr uk",
|
|
71
71
|
"translate:tier3": "npm run translate-readme -- vi id th hi bn ro sv",
|
|
72
72
|
"translate:tier4": "npm run translate-readme -- it el hu fi da no",
|
|
@@ -82,12 +82,26 @@
|
|
|
82
82
|
"test:search": "bun test tests/worker/search/",
|
|
83
83
|
"test:context": "bun test tests/context/",
|
|
84
84
|
"test:infra": "bun test tests/infrastructure/",
|
|
85
|
-
"test:server": "bun test tests/server/"
|
|
85
|
+
"test:server": "bun test tests/server/",
|
|
86
|
+
"prepublishOnly": "npm run build",
|
|
87
|
+
"release": "np",
|
|
88
|
+
"release:patch": "np patch --no-cleanup",
|
|
89
|
+
"release:minor": "np minor --no-cleanup",
|
|
90
|
+
"release:major": "np major --no-cleanup"
|
|
91
|
+
},
|
|
92
|
+
"np": {
|
|
93
|
+
"yarn": false,
|
|
94
|
+
"contents": ".",
|
|
95
|
+
"testScript": "test",
|
|
96
|
+
"2fa": false
|
|
86
97
|
},
|
|
87
98
|
"dependencies": {
|
|
88
99
|
"@anthropic-ai/claude-agent-sdk": "^0.1.76",
|
|
89
100
|
"@modelcontextprotocol/sdk": "^1.25.1",
|
|
101
|
+
"@chroma-core/default-embed": "^0.1.9",
|
|
90
102
|
"ansi-to-html": "^0.7.2",
|
|
103
|
+
"chromadb": "^3.2.2",
|
|
104
|
+
"dompurify": "^3.3.1",
|
|
91
105
|
"express": "^4.18.2",
|
|
92
106
|
"glob": "^11.0.3",
|
|
93
107
|
"handlebars": "^4.7.8",
|
|
@@ -98,11 +112,13 @@
|
|
|
98
112
|
},
|
|
99
113
|
"devDependencies": {
|
|
100
114
|
"@types/cors": "^2.8.19",
|
|
115
|
+
"@types/dompurify": "^3.0.5",
|
|
101
116
|
"@types/express": "^4.17.21",
|
|
102
117
|
"@types/node": "^20.0.0",
|
|
103
118
|
"@types/react": "^18.3.5",
|
|
104
119
|
"@types/react-dom": "^18.3.0",
|
|
105
120
|
"esbuild": "^0.27.2",
|
|
121
|
+
"np": "^11.0.2",
|
|
106
122
|
"tsx": "^4.20.6",
|
|
107
123
|
"typescript": "^5.3.0"
|
|
108
124
|
}
|
package/plugin/CLAUDE.md
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
<claude-mem-context>
|
|
2
2
|
# Recent Activity
|
|
3
3
|
|
|
4
|
-
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
|
|
5
|
-
|
|
6
4
|
### Jan 10, 2026
|
|
7
5
|
|
|
8
6
|
| ID | Time | T | Title | Read |
|
|
9
7
|
|----|------|---|-------|------|
|
|
10
|
-
| #
|
|
8
|
+
| #39050 | 3:44 PM | 🔵 | Plugin commands directory is empty | ~255 |
|
|
11
9
|
</claude-mem-context>
|
package/plugin/hooks/CLAUDE.md
CHANGED
package/plugin/hooks/hooks.json
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"description": "Claude-mem memory system hooks",
|
|
3
3
|
"hooks": {
|
|
4
|
+
"Setup": [
|
|
5
|
+
{
|
|
6
|
+
"matcher": "*",
|
|
7
|
+
"hooks": [
|
|
8
|
+
{
|
|
9
|
+
"type": "command",
|
|
10
|
+
"command": "${CLAUDE_PLUGIN_ROOT}/scripts/setup.sh",
|
|
11
|
+
"timeout": 120
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
],
|
|
4
16
|
"SessionStart": [
|
|
5
17
|
{
|
|
6
18
|
"matcher": "startup|clear|compact",
|
|
@@ -12,17 +24,12 @@
|
|
|
12
24
|
},
|
|
13
25
|
{
|
|
14
26
|
"type": "command",
|
|
15
|
-
"command": "bun \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" start",
|
|
16
|
-
"timeout": 60
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"type": "command",
|
|
20
|
-
"command": "bun \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" hook claude-code context",
|
|
27
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/bun-runner.js\" \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" start",
|
|
21
28
|
"timeout": 60
|
|
22
29
|
},
|
|
23
30
|
{
|
|
24
31
|
"type": "command",
|
|
25
|
-
"command": "bun \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" hook claude-code
|
|
32
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/bun-runner.js\" \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" hook claude-code context",
|
|
26
33
|
"timeout": 60
|
|
27
34
|
}
|
|
28
35
|
]
|
|
@@ -33,12 +40,12 @@
|
|
|
33
40
|
"hooks": [
|
|
34
41
|
{
|
|
35
42
|
"type": "command",
|
|
36
|
-
"command": "bun \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" start",
|
|
43
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/bun-runner.js\" \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" start",
|
|
37
44
|
"timeout": 60
|
|
38
45
|
},
|
|
39
46
|
{
|
|
40
47
|
"type": "command",
|
|
41
|
-
"command": "bun \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" hook claude-code session-init",
|
|
48
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/bun-runner.js\" \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" hook claude-code session-init",
|
|
42
49
|
"timeout": 60
|
|
43
50
|
}
|
|
44
51
|
]
|
|
@@ -50,12 +57,12 @@
|
|
|
50
57
|
"hooks": [
|
|
51
58
|
{
|
|
52
59
|
"type": "command",
|
|
53
|
-
"command": "bun \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" start",
|
|
60
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/bun-runner.js\" \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" start",
|
|
54
61
|
"timeout": 60
|
|
55
62
|
},
|
|
56
63
|
{
|
|
57
64
|
"type": "command",
|
|
58
|
-
"command": "bun \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" hook claude-code observation",
|
|
65
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/bun-runner.js\" \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" hook claude-code observation",
|
|
59
66
|
"timeout": 120
|
|
60
67
|
}
|
|
61
68
|
]
|
|
@@ -66,13 +73,18 @@
|
|
|
66
73
|
"hooks": [
|
|
67
74
|
{
|
|
68
75
|
"type": "command",
|
|
69
|
-
"command": "bun \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" start",
|
|
76
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/bun-runner.js\" \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" start",
|
|
70
77
|
"timeout": 60
|
|
71
78
|
},
|
|
72
79
|
{
|
|
73
80
|
"type": "command",
|
|
74
|
-
"command": "bun \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" hook claude-code summarize",
|
|
81
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/bun-runner.js\" \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" hook claude-code summarize",
|
|
75
82
|
"timeout": 120
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"type": "command",
|
|
86
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/bun-runner.js\" \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" hook claude-code session-complete",
|
|
87
|
+
"timeout": 30
|
|
76
88
|
}
|
|
77
89
|
]
|
|
78
90
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Code Development (Urdu)",
|
|
3
|
+
"prompts": {
|
|
4
|
+
"footer": "IMPORTANT! DO NOT do any work right now other than generating this OBSERVATIONS from tool use messages - and remember that you are a memory agent designed to summarize a DIFFERENT claude code session, not this one.\n\nNever reference yourself or your own actions. Do not output anything other than the observation content formatted in the XML structure above. All other output is ignored by the system, and the system has been designed to be smart about token usage. Please spend your tokens wisely on useful observations.\n\nRemember that we record these observations as a way of helping us stay on track with our progress, and to help us keep important decisions and changes at the forefront of our minds! :) Thank you so much for your help!\n\nLANGUAGE REQUIREMENTS: Please write the observation data in اردو",
|
|
5
|
+
|
|
6
|
+
"xml_title_placeholder": "[**title**: بنیادی کام یا موضوع کو بیان کرنے والا مختصر عنوان]",
|
|
7
|
+
"xml_subtitle_placeholder": "[**subtitle**: ایک جملے میں وضاحت (زیادہ سے زیادہ 24 الفاظ)]",
|
|
8
|
+
"xml_fact_placeholder": "[مختصر، خود کفیل بیان]",
|
|
9
|
+
"xml_narrative_placeholder": "[**narrative**: مکمل تناسب: کیا کیا گیا، یہ کیسے کام کرتا ہے، یہ کیوں اہم ہے]",
|
|
10
|
+
"xml_concept_placeholder": "[علم-نوع-قسم]",
|
|
11
|
+
"xml_file_placeholder": "[فائل/کا/راستہ]",
|
|
12
|
+
|
|
13
|
+
"xml_summary_request_placeholder": "[مختصر عنوان جو صارف کے درخواست اور بحث/کیے گئے کام کا خلاصہ بیان کرتا ہے]",
|
|
14
|
+
"xml_summary_investigated_placeholder": "[اب تک کیا دریافت کیا گیا ہے؟ کیا جائزہ لیا گیا ہے؟]",
|
|
15
|
+
"xml_summary_learned_placeholder": "[آپ نے چیزوں کے کام کرنے کے طریقے کے بارے میں کیا سیکھا؟]",
|
|
16
|
+
"xml_summary_completed_placeholder": "[اب تک کون سا کام مکمل ہوا ہے؟ کیا بھیجا گیا یا تبدیل کیا گیا؟]",
|
|
17
|
+
"xml_summary_next_steps_placeholder": "[اس سیشن میں آپ فعال طور پر کس پر کام کر رہے ہیں یا آگے کام کرنے کا منصوبہ بنا رہے ہیں؟]",
|
|
18
|
+
"xml_summary_notes_placeholder": "[موجودہ پیشرفت پر اضافی بصیرت یا نوٹس]",
|
|
19
|
+
|
|
20
|
+
"continuation_instruction": "IMPORTANT: Continue generating observations from tool use messages using the XML structure below.\n\nLANGUAGE REQUIREMENTS: Please write the observation data in اردو",
|
|
21
|
+
|
|
22
|
+
"summary_footer": "IMPORTANT! DO NOT do any work right now other than generating this next PROGRESS SUMMARY - and remember that you are a memory agent designed to summarize a DIFFERENT claude code session, not this one.\n\nNever reference yourself or your own actions. Do not output anything other than the summary content formatted in the XML structure above. All other output is ignored by the system, and the system has been designed to be smart about token usage. Please spend your tokens wisely on useful summary content.\n\nThank you, this summary will be very useful for keeping track of our progress!\n\nLANGUAGE REQUIREMENTS: Please write ALL summary content (request, investigated, learned, completed, next_steps, notes) in اردو"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
package/plugin/package.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-mem-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.8",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Runtime dependencies for claude-mem bundled hooks",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"dependencies": {
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@chroma-core/default-embed": "^0.1.9"
|
|
9
|
+
},
|
|
8
10
|
"engines": {
|
|
9
11
|
"node": ">=18.0.0",
|
|
10
12
|
"bun": ">=1.0.0"
|
package/plugin/scripts/CLAUDE.md
CHANGED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Bun Runner - Finds and executes Bun even when not in PATH
|
|
4
|
+
*
|
|
5
|
+
* This script solves the fresh install problem where:
|
|
6
|
+
* 1. smart-install.js installs Bun to ~/.bun/bin/bun
|
|
7
|
+
* 2. But Bun isn't in PATH until terminal restart
|
|
8
|
+
* 3. Subsequent hooks fail because they can't find `bun`
|
|
9
|
+
*
|
|
10
|
+
* Usage: node bun-runner.js <script> [args...]
|
|
11
|
+
*
|
|
12
|
+
* Fixes #818: Worker fails to start on fresh install
|
|
13
|
+
*/
|
|
14
|
+
import { spawnSync, spawn } from 'child_process';
|
|
15
|
+
import { existsSync } from 'fs';
|
|
16
|
+
import { join } from 'path';
|
|
17
|
+
import { homedir } from 'os';
|
|
18
|
+
|
|
19
|
+
const IS_WINDOWS = process.platform === 'win32';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Find Bun executable - checks PATH first, then common install locations
|
|
23
|
+
*/
|
|
24
|
+
function findBun() {
|
|
25
|
+
// Try PATH first
|
|
26
|
+
const pathCheck = spawnSync(IS_WINDOWS ? 'where' : 'which', ['bun'], {
|
|
27
|
+
encoding: 'utf-8',
|
|
28
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
29
|
+
shell: IS_WINDOWS
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (pathCheck.status === 0 && pathCheck.stdout.trim()) {
|
|
33
|
+
return 'bun'; // Found in PATH
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Check common installation paths (handles fresh installs before PATH reload)
|
|
37
|
+
// Windows: Bun installs to ~/.bun/bin/bun.exe (same as smart-install.js)
|
|
38
|
+
// Unix: Check default location plus common package manager paths
|
|
39
|
+
const bunPaths = IS_WINDOWS
|
|
40
|
+
? [join(homedir(), '.bun', 'bin', 'bun.exe')]
|
|
41
|
+
: [
|
|
42
|
+
join(homedir(), '.bun', 'bin', 'bun'),
|
|
43
|
+
'/usr/local/bin/bun',
|
|
44
|
+
'/opt/homebrew/bin/bun',
|
|
45
|
+
'/home/linuxbrew/.linuxbrew/bin/bun'
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
for (const bunPath of bunPaths) {
|
|
49
|
+
if (existsSync(bunPath)) {
|
|
50
|
+
return bunPath;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Get args: node bun-runner.js <script> [args...]
|
|
58
|
+
const args = process.argv.slice(2);
|
|
59
|
+
|
|
60
|
+
if (args.length === 0) {
|
|
61
|
+
console.error('Usage: node bun-runner.js <script> [args...]');
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const bunPath = findBun();
|
|
66
|
+
|
|
67
|
+
if (!bunPath) {
|
|
68
|
+
console.error('Error: Bun not found. Please install Bun: https://bun.sh');
|
|
69
|
+
console.error('After installation, restart your terminal.');
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Spawn Bun with the provided script and args
|
|
74
|
+
// Use spawn (not spawnSync) to properly handle stdio
|
|
75
|
+
// Note: Don't use shell mode on Windows - it breaks paths with spaces in usernames
|
|
76
|
+
// Use windowsHide to prevent a visible console window from spawning on Windows
|
|
77
|
+
const child = spawn(bunPath, args, {
|
|
78
|
+
stdio: 'inherit',
|
|
79
|
+
windowsHide: true,
|
|
80
|
+
env: process.env
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
child.on('error', (err) => {
|
|
84
|
+
console.error(`Failed to start Bun: ${err.message}`);
|
|
85
|
+
process.exit(1);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
child.on('close', (code) => {
|
|
89
|
+
process.exit(code || 0);
|
|
90
|
+
});
|