builderos-cli 2.0.0
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/.builderos +7 -0
- package/.mcp.json +15 -0
- package/PUBLISH.md +182 -0
- package/README.md +333 -0
- package/index.js +390 -0
- package/package.json +30 -0
package/.builderos
ADDED
package/.mcp.json
ADDED
package/PUBLISH.md
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# Publishing @builderos/cli to npm
|
|
2
|
+
|
|
3
|
+
## Prerequisites
|
|
4
|
+
|
|
5
|
+
1. npm account (create at https://www.npmjs.com/signup)
|
|
6
|
+
2. Verified email address
|
|
7
|
+
3. npm login credentials
|
|
8
|
+
|
|
9
|
+
## Publishing Steps
|
|
10
|
+
|
|
11
|
+
### 1. Test Locally
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
cd /Users/audilu/next/builder-os/cli
|
|
15
|
+
|
|
16
|
+
# Test the CLI
|
|
17
|
+
node index.js --help
|
|
18
|
+
node index.js init --api-url=http://builder-os.test
|
|
19
|
+
|
|
20
|
+
# Verify package.json
|
|
21
|
+
cat package.json
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### 2. Login to npm
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm login
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Enter your:
|
|
31
|
+
- Username
|
|
32
|
+
- Password
|
|
33
|
+
- Email (must be verified)
|
|
34
|
+
- OTP (if 2FA enabled)
|
|
35
|
+
|
|
36
|
+
### 3. Publish
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
cd /Users/audilu/next/builder-os/cli
|
|
40
|
+
npm publish --access public
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Important**: Use `--access public` because scoped packages (@builderos/cli) are private by default.
|
|
44
|
+
|
|
45
|
+
### 4. Verify Publication
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# Check on npm
|
|
49
|
+
npm view @builderos/cli
|
|
50
|
+
|
|
51
|
+
# Test installation
|
|
52
|
+
cd /tmp/test-npm
|
|
53
|
+
npx @builderos/cli --help
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Version Updates
|
|
57
|
+
|
|
58
|
+
When making changes:
|
|
59
|
+
|
|
60
|
+
### 1. Update Version
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Patch (2.0.0 → 2.0.1)
|
|
64
|
+
npm version patch
|
|
65
|
+
|
|
66
|
+
# Minor (2.0.0 → 2.1.0)
|
|
67
|
+
npm version minor
|
|
68
|
+
|
|
69
|
+
# Major (2.0.0 → 3.0.0)
|
|
70
|
+
npm version major
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 2. Publish Update
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
npm publish --access public
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Quick Reference
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Full publication workflow
|
|
83
|
+
cd /Users/audilu/next/builder-os/cli
|
|
84
|
+
npm version patch # Update version
|
|
85
|
+
npm publish --access public # Publish to npm
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Troubleshooting
|
|
89
|
+
|
|
90
|
+
### "You must be logged in to publish packages"
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
npm login
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### "You do not have permission to publish"
|
|
97
|
+
|
|
98
|
+
Make sure you're logged in with the correct account:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
npm whoami
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### "Package name already exists"
|
|
105
|
+
|
|
106
|
+
This means @builderos/cli is already taken. Choose a different name in package.json.
|
|
107
|
+
|
|
108
|
+
### "402 Payment Required"
|
|
109
|
+
|
|
110
|
+
Scoped packages need `--access public`:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
npm publish --access public
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Post-Publication
|
|
117
|
+
|
|
118
|
+
### Test Installation
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# In a clean directory
|
|
122
|
+
cd /tmp/test-install
|
|
123
|
+
npx @builderos/cli init --api-url=http://builder-os.test
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Update Documentation
|
|
127
|
+
|
|
128
|
+
Update README.md and other docs to reference the published package.
|
|
129
|
+
|
|
130
|
+
### Announce
|
|
131
|
+
|
|
132
|
+
Let users know the package is available:
|
|
133
|
+
- README.md
|
|
134
|
+
- Documentation
|
|
135
|
+
- Release notes
|
|
136
|
+
|
|
137
|
+
## Package Info
|
|
138
|
+
|
|
139
|
+
After publishing, view package info:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
npm view @builderos/cli
|
|
143
|
+
npm view @builderos/cli versions
|
|
144
|
+
npm view @builderos/cli dist-tags
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Unpublishing (Emergency Only)
|
|
148
|
+
|
|
149
|
+
⚠️ **Warning**: Can only unpublish within 72 hours. After that, version is permanent.
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
# Unpublish specific version
|
|
153
|
+
npm unpublish @builderos/cli@2.0.0
|
|
154
|
+
|
|
155
|
+
# Unpublish entire package (use with extreme caution)
|
|
156
|
+
npm unpublish @builderos/cli --force
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Best Practices
|
|
160
|
+
|
|
161
|
+
1. **Test before publishing** - Always test locally first
|
|
162
|
+
2. **Semantic versioning** - Follow semver (MAJOR.MINOR.PATCH)
|
|
163
|
+
3. **Changelog** - Keep a CHANGELOG.md
|
|
164
|
+
4. **Git tags** - Tag releases in git
|
|
165
|
+
5. **CI/CD** - Consider automated publishing
|
|
166
|
+
6. **Security** - Enable 2FA on npm account
|
|
167
|
+
|
|
168
|
+
## Package Links
|
|
169
|
+
|
|
170
|
+
After publishing:
|
|
171
|
+
|
|
172
|
+
- npm: https://www.npmjs.com/package/@builderos/cli
|
|
173
|
+
- unpkg: https://unpkg.com/@builderos/cli
|
|
174
|
+
- jsdelivr: https://cdn.jsdelivr.net/npm/@builderos/cli
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
Ready to publish? Run:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
cd /Users/audilu/next/builder-os/cli && npm publish --access public
|
|
182
|
+
```
|
package/README.md
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
# @builderos/cli
|
|
2
|
+
|
|
3
|
+
BuilderOS CLI - Initialize BuilderOS in any project without requiring local code.
|
|
4
|
+
|
|
5
|
+
## 🚀 Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Initialize BuilderOS in current project
|
|
9
|
+
npx @builderos/cli init
|
|
10
|
+
|
|
11
|
+
# Initialize with remote BuilderOS
|
|
12
|
+
npx @builderos/cli init --api-url=https://api.builderos.com
|
|
13
|
+
|
|
14
|
+
# Update skills only
|
|
15
|
+
npx @builderos/cli update
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## 📦 What This Does
|
|
19
|
+
|
|
20
|
+
This CLI tool:
|
|
21
|
+
|
|
22
|
+
1. ✅ Creates `.mcp.json` - MCP configuration for Claude Code
|
|
23
|
+
2. ✅ Downloads skills from BuilderOS API to `.claude/skills/`
|
|
24
|
+
3. ✅ Creates `.builderos` marker file
|
|
25
|
+
4. ✅ Updates `.gitignore` with BuilderOS files (commented for easy sharing)
|
|
26
|
+
|
|
27
|
+
## 🌟 Features
|
|
28
|
+
|
|
29
|
+
- **No local BuilderOS code required** - Works purely through API
|
|
30
|
+
- **Supports any API URL** - Local testing or remote production
|
|
31
|
+
- **Smart detection** - Automatically detects project state (new/existing)
|
|
32
|
+
- **Flexible modes** - Install, update, MCP-only, or skills-only
|
|
33
|
+
- **Team-friendly** - Easy to share configuration with team
|
|
34
|
+
|
|
35
|
+
## 📖 Commands
|
|
36
|
+
|
|
37
|
+
### `init`
|
|
38
|
+
|
|
39
|
+
Initialize BuilderOS in current project.
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npx @builderos/cli init [options]
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Options:**
|
|
46
|
+
- `--api-url=<url>` - BuilderOS API URL (default: `http://builder-os.test`)
|
|
47
|
+
- `--force` - Force reinstall even if already configured
|
|
48
|
+
- `--mcp-only` - Only install MCP configuration
|
|
49
|
+
- `--skills-only` - Only download skills
|
|
50
|
+
|
|
51
|
+
**Examples:**
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Local development (default)
|
|
55
|
+
npx @builderos/cli init
|
|
56
|
+
|
|
57
|
+
# Remote BuilderOS
|
|
58
|
+
npx @builderos/cli init --api-url=https://api.builderos.com
|
|
59
|
+
|
|
60
|
+
# Force reinstall
|
|
61
|
+
npx @builderos/cli init --force
|
|
62
|
+
|
|
63
|
+
# Only install MCP, skip skills
|
|
64
|
+
npx @builderos/cli init --mcp-only
|
|
65
|
+
|
|
66
|
+
# Only download skills, skip MCP
|
|
67
|
+
npx @builderos/cli init --skills-only
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### `update`
|
|
71
|
+
|
|
72
|
+
Update skills from BuilderOS API.
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
npx @builderos/cli update [options]
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**Options:**
|
|
79
|
+
- `--api-url=<url>` - BuilderOS API URL (default: `http://builder-os.test`)
|
|
80
|
+
|
|
81
|
+
**Example:**
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# Update skills from default API
|
|
85
|
+
npx @builderos/cli update
|
|
86
|
+
|
|
87
|
+
# Update skills from remote API
|
|
88
|
+
npx @builderos/cli update --api-url=https://api.builderos.com
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## 🔧 How It Works
|
|
92
|
+
|
|
93
|
+
### Architecture
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
npx @builderos/cli init
|
|
97
|
+
↓
|
|
98
|
+
1. Create .mcp.json
|
|
99
|
+
- Uses npx @builderos/mcp-client
|
|
100
|
+
- No local code dependency
|
|
101
|
+
↓
|
|
102
|
+
2. Download skills from API
|
|
103
|
+
- Fetch /api/skills (list)
|
|
104
|
+
- Fetch /api/skills/{slug} (content)
|
|
105
|
+
- Save to .claude/skills/
|
|
106
|
+
↓
|
|
107
|
+
3. Create .builderos marker
|
|
108
|
+
- Track initialization state
|
|
109
|
+
↓
|
|
110
|
+
4. Update .gitignore
|
|
111
|
+
- Add BuilderOS files (commented)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Generated `.mcp.json`
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{
|
|
118
|
+
"mcpServers": {
|
|
119
|
+
"builder-os": {
|
|
120
|
+
"type": "stdio",
|
|
121
|
+
"command": "npx",
|
|
122
|
+
"args": ["-y", "@builderos/mcp-client"],
|
|
123
|
+
"env": {
|
|
124
|
+
"BUILDEROS_API_URL": "https://api.builderos.com"
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Key point: Always uses `npx @builderos/mcp-client`, not local code.
|
|
132
|
+
|
|
133
|
+
## 🌍 Use Cases
|
|
134
|
+
|
|
135
|
+
### Local Development
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# Developer has BuilderOS running locally at builder-os.test
|
|
139
|
+
cd ~/projects/my-app
|
|
140
|
+
npx @builderos/cli init
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Remote Team Collaboration
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
# Team uses shared BuilderOS at api.builderos.com
|
|
147
|
+
cd ~/projects/team-app
|
|
148
|
+
npx @builderos/cli init --api-url=https://api.builderos.com
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### CI/CD Pipeline
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
# Automated setup in CI
|
|
155
|
+
npx @builderos/cli init --api-url=$BUILDEROS_API_URL --force
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Multiple Environments
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
# Development
|
|
162
|
+
npx @builderos/cli init --api-url=https://dev.builderos.com
|
|
163
|
+
|
|
164
|
+
# Staging
|
|
165
|
+
npx @builderos/cli init --api-url=https://staging.builderos.com
|
|
166
|
+
|
|
167
|
+
# Production
|
|
168
|
+
npx @builderos/cli init --api-url=https://api.builderos.com
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## 🎯 Comparison with use-builderos.sh
|
|
172
|
+
|
|
173
|
+
| Feature | @builderos/cli | use-builderos.sh |
|
|
174
|
+
|---------|----------------|------------------|
|
|
175
|
+
| **Requires local BuilderOS code** | ❌ No | ✅ Yes (for script itself) |
|
|
176
|
+
| **Works anywhere** | ✅ Yes | ⚠️ Only if script accessible |
|
|
177
|
+
| **npm installable** | ✅ Yes | ❌ No |
|
|
178
|
+
| **MCP mode** | Remote only | Local + Remote |
|
|
179
|
+
| **Best for** | Remote deployment | Local development |
|
|
180
|
+
|
|
181
|
+
## 📝 After Installation
|
|
182
|
+
|
|
183
|
+
### 1. Restart VSCode
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
# Quit completely (not just reload)
|
|
187
|
+
Cmd+Q (Mac) or Ctrl+Q (Linux/Windows)
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### 2. Reopen Project
|
|
191
|
+
|
|
192
|
+
Open the project directory in VSCode.
|
|
193
|
+
|
|
194
|
+
### 3. Test MCP Connection
|
|
195
|
+
|
|
196
|
+
```
|
|
197
|
+
/mcp
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Should show: `builder-os`
|
|
201
|
+
|
|
202
|
+
### 4. Test Skills
|
|
203
|
+
|
|
204
|
+
Ask Claude:
|
|
205
|
+
```
|
|
206
|
+
What skills do I have?
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Should list available BuilderOS skills.
|
|
210
|
+
|
|
211
|
+
## 🤝 Team Sharing
|
|
212
|
+
|
|
213
|
+
To share BuilderOS with your team:
|
|
214
|
+
|
|
215
|
+
### 1. Edit `.gitignore`
|
|
216
|
+
|
|
217
|
+
Remove `#` from:
|
|
218
|
+
```gitignore
|
|
219
|
+
# .mcp.json
|
|
220
|
+
# .claude/
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### 2. Commit
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
git add .mcp.json .claude/ .gitignore
|
|
227
|
+
git commit -m "Add BuilderOS configuration"
|
|
228
|
+
git push
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### 3. Team Members
|
|
232
|
+
|
|
233
|
+
After cloning:
|
|
234
|
+
```bash
|
|
235
|
+
# No need to run CLI - files already in repo
|
|
236
|
+
# Just restart VSCode
|
|
237
|
+
Cmd+Q
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Done! BuilderOS works automatically.
|
|
241
|
+
|
|
242
|
+
## 🔒 Environment Variables
|
|
243
|
+
|
|
244
|
+
### `BUILDEROS_API_URL`
|
|
245
|
+
|
|
246
|
+
Set default API URL:
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
# Local development
|
|
250
|
+
export BUILDEROS_API_URL=http://builder-os.test
|
|
251
|
+
|
|
252
|
+
# Remote production
|
|
253
|
+
export BUILDEROS_API_URL=https://api.builderos.com
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Then run without `--api-url`:
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
npx @builderos/cli init
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## 🐛 Troubleshooting
|
|
263
|
+
|
|
264
|
+
### CLI not found
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
# Make sure you're online
|
|
268
|
+
# npx will download the package
|
|
269
|
+
|
|
270
|
+
# Or install globally
|
|
271
|
+
npm install -g @builderos/cli
|
|
272
|
+
builderos init
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### API connection failed
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
# Check API URL
|
|
279
|
+
curl http://builder-os.test/api/skills
|
|
280
|
+
|
|
281
|
+
# Try with explicit URL
|
|
282
|
+
npx @builderos/cli init --api-url=http://builder-os.test
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Skills not loading
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
# Verify skills directory
|
|
289
|
+
ls -la .claude/skills/
|
|
290
|
+
|
|
291
|
+
# Re-download skills
|
|
292
|
+
npx @builderos/cli update --api-url=http://builder-os.test
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### MCP not connecting
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
# Verify .mcp.json
|
|
299
|
+
cat .mcp.json
|
|
300
|
+
|
|
301
|
+
# Restart VSCode completely
|
|
302
|
+
# Cmd+Q, not just reload
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## 📦 Publishing to npm
|
|
306
|
+
|
|
307
|
+
When BuilderOS is ready for production:
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
cd /Users/audilu/next/builder-os/cli
|
|
311
|
+
npm login
|
|
312
|
+
npm publish --access public
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
Then users can use:
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
npx @builderos/cli init
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
## 🔗 Related
|
|
322
|
+
|
|
323
|
+
- [@builderos/mcp-client](../mcp-client/) - Lightweight MCP HTTP client
|
|
324
|
+
- [use-builderos.sh](../scripts/use-builderos.sh) - Local development script
|
|
325
|
+
- [REMOTE-USAGE.md](../REMOTE-USAGE.md) - Remote usage guide
|
|
326
|
+
|
|
327
|
+
## 📄 License
|
|
328
|
+
|
|
329
|
+
MIT
|
|
330
|
+
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
**BuilderOS CLI** - Initialize Anywhere, Anytime
|
package/index.js
ADDED
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* BuilderOS CLI
|
|
5
|
+
*
|
|
6
|
+
* Initialize BuilderOS in any project without requiring local code.
|
|
7
|
+
* Works purely through BuilderOS HTTP API.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* npx @builderos/cli init [options]
|
|
11
|
+
* npx @builderos/cli update [options]
|
|
12
|
+
*
|
|
13
|
+
* Options:
|
|
14
|
+
* --api-url=<url> BuilderOS API URL (default: http://builder-os.test)
|
|
15
|
+
* --force Force reinstall even if already configured
|
|
16
|
+
* --mcp-only Only install MCP configuration
|
|
17
|
+
* --skills-only Only download skills
|
|
18
|
+
* --help Show help
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { mkdir, writeFile, readFile, access } from 'fs/promises';
|
|
22
|
+
import { join } from 'path';
|
|
23
|
+
import { constants } from 'fs';
|
|
24
|
+
|
|
25
|
+
// Parse command line arguments
|
|
26
|
+
const args = process.argv.slice(2);
|
|
27
|
+
|
|
28
|
+
// Default options
|
|
29
|
+
const options = {
|
|
30
|
+
apiUrl: process.env.BUILDEROS_API_URL || 'http://builder-os.test',
|
|
31
|
+
force: false,
|
|
32
|
+
mcpOnly: false,
|
|
33
|
+
skillsOnly: false,
|
|
34
|
+
help: false,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// Check if first arg is help or no command
|
|
38
|
+
const command = args[0];
|
|
39
|
+
if (!command || command === '--help' || command === '-h') {
|
|
40
|
+
options.help = true;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Parse options
|
|
44
|
+
for (const arg of args) {
|
|
45
|
+
if (arg.startsWith('--api-url=')) {
|
|
46
|
+
options.apiUrl = arg.split('=')[1];
|
|
47
|
+
} else if (arg === '--force') {
|
|
48
|
+
options.force = true;
|
|
49
|
+
} else if (arg === '--mcp-only') {
|
|
50
|
+
options.mcpOnly = true;
|
|
51
|
+
} else if (arg === '--skills-only') {
|
|
52
|
+
options.skillsOnly = true;
|
|
53
|
+
} else if (arg === '--help' || arg === '-h') {
|
|
54
|
+
options.help = true;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Show help
|
|
59
|
+
if (options.help) {
|
|
60
|
+
console.log(`
|
|
61
|
+
BuilderOS CLI v2.0.0
|
|
62
|
+
|
|
63
|
+
Usage:
|
|
64
|
+
npx @builderos/cli init [options]
|
|
65
|
+
npx @builderos/cli update [options]
|
|
66
|
+
|
|
67
|
+
Commands:
|
|
68
|
+
init Initialize BuilderOS in current project
|
|
69
|
+
update Update skills from BuilderOS API
|
|
70
|
+
|
|
71
|
+
Options:
|
|
72
|
+
--api-url=<url> BuilderOS API URL (default: http://builder-os.test)
|
|
73
|
+
--force Force reinstall even if already configured
|
|
74
|
+
--mcp-only Only install MCP configuration
|
|
75
|
+
--skills-only Only download skills
|
|
76
|
+
--help, -h Show this help
|
|
77
|
+
|
|
78
|
+
Examples:
|
|
79
|
+
# Initialize with local BuilderOS
|
|
80
|
+
npx @builderos/cli init
|
|
81
|
+
|
|
82
|
+
# Initialize with remote BuilderOS
|
|
83
|
+
npx @builderos/cli init --api-url=https://api.builderos.com
|
|
84
|
+
|
|
85
|
+
# Update skills only
|
|
86
|
+
npx @builderos/cli update --skills-only
|
|
87
|
+
|
|
88
|
+
# Force reinstall
|
|
89
|
+
npx @builderos/cli init --force
|
|
90
|
+
`);
|
|
91
|
+
process.exit(0);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Utility: Check if file exists
|
|
95
|
+
async function fileExists(path) {
|
|
96
|
+
try {
|
|
97
|
+
await access(path, constants.F_OK);
|
|
98
|
+
return true;
|
|
99
|
+
} catch {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Utility: Fetch from API
|
|
105
|
+
async function fetchAPI(endpoint) {
|
|
106
|
+
try {
|
|
107
|
+
const url = `${options.apiUrl}${endpoint}`;
|
|
108
|
+
const response = await fetch(url, {
|
|
109
|
+
headers: {
|
|
110
|
+
'Host': 'builder-os.test', // For local nginx-proxy
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
if (!response.ok) {
|
|
115
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return await response.json();
|
|
119
|
+
} catch (error) {
|
|
120
|
+
console.error(`❌ Error fetching ${endpoint}:`, error.message);
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Step 1: Create .mcp.json
|
|
126
|
+
async function installMCP() {
|
|
127
|
+
console.log('1️⃣ Creating .mcp.json (MCP configuration)...');
|
|
128
|
+
|
|
129
|
+
const mcpPath = '.mcp.json';
|
|
130
|
+
|
|
131
|
+
if (await fileExists(mcpPath)) {
|
|
132
|
+
const content = await readFile(mcpPath, 'utf-8');
|
|
133
|
+
if (content.includes('builder-os')) {
|
|
134
|
+
if (!options.force) {
|
|
135
|
+
console.log(' ⚠️ builder-os already configured in .mcp.json');
|
|
136
|
+
console.log(' Use --force to overwrite');
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Always use remote mode (npx @builderos/mcp-client)
|
|
143
|
+
// This CLI is meant to be standalone, not requiring local BuilderOS code
|
|
144
|
+
const mcpConfig = {
|
|
145
|
+
mcpServers: {
|
|
146
|
+
'builder-os': {
|
|
147
|
+
type: 'stdio',
|
|
148
|
+
command: 'npx',
|
|
149
|
+
args: ['-y', '@builderos/mcp-client'],
|
|
150
|
+
env: {
|
|
151
|
+
BUILDEROS_API_URL: options.apiUrl,
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
await writeFile(mcpPath, JSON.stringify(mcpConfig, null, 2) + '\n');
|
|
158
|
+
console.log(' ✅ .mcp.json created');
|
|
159
|
+
console.log(` 🌐 Using remote MCP client with ${options.apiUrl}`);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Step 2: Download skills from API
|
|
163
|
+
async function installSkills() {
|
|
164
|
+
console.log('2️⃣ Downloading BuilderOS skills from API...');
|
|
165
|
+
console.log(` API URL: ${options.apiUrl}`);
|
|
166
|
+
|
|
167
|
+
// Fetch skills list
|
|
168
|
+
const data = await fetchAPI('/api/skills');
|
|
169
|
+
if (!data || !data.skills) {
|
|
170
|
+
console.log(' ❌ Failed to fetch skills list');
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const skills = data.skills;
|
|
175
|
+
console.log(` Found ${skills.length} skills`);
|
|
176
|
+
|
|
177
|
+
// Create .claude/skills directory
|
|
178
|
+
const skillsDir = '.claude/skills';
|
|
179
|
+
await mkdir(skillsDir, { recursive: true });
|
|
180
|
+
|
|
181
|
+
let successCount = 0;
|
|
182
|
+
const failedSkills = [];
|
|
183
|
+
|
|
184
|
+
// Download each skill
|
|
185
|
+
for (const skill of skills) {
|
|
186
|
+
console.log(` 📥 Downloading: ${skill.slug}`);
|
|
187
|
+
|
|
188
|
+
const skillData = await fetchAPI(`/api/skills/${skill.slug}`);
|
|
189
|
+
|
|
190
|
+
if (!skillData || !skillData.content) {
|
|
191
|
+
console.log(` ⚠️ No content available`);
|
|
192
|
+
failedSkills.push(skill.slug);
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Create skill directory
|
|
197
|
+
const skillDir = join(skillsDir, skill.slug);
|
|
198
|
+
await mkdir(skillDir, { recursive: true });
|
|
199
|
+
|
|
200
|
+
// Write skill.md
|
|
201
|
+
const skillPath = join(skillDir, 'skill.md');
|
|
202
|
+
await writeFile(skillPath, skillData.content);
|
|
203
|
+
|
|
204
|
+
console.log(` ✅ Saved to ${skillDir}/skill.md`);
|
|
205
|
+
successCount++;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
console.log('');
|
|
209
|
+
console.log('==========================================');
|
|
210
|
+
console.log(' ✅ Skills Download Complete!');
|
|
211
|
+
console.log('==========================================');
|
|
212
|
+
console.log('');
|
|
213
|
+
console.log(`Downloaded: ${successCount}/${skills.length} skills`);
|
|
214
|
+
|
|
215
|
+
if (failedSkills.length > 0) {
|
|
216
|
+
console.log('');
|
|
217
|
+
console.log('⚠️ Failed to download:');
|
|
218
|
+
failedSkills.forEach(slug => console.log(` - ${slug}`));
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
console.log('');
|
|
222
|
+
console.log(`Skills saved to: ${skillsDir}/`);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Step 3: Create .builderos marker
|
|
226
|
+
async function createMarker() {
|
|
227
|
+
console.log('3️⃣ Creating BuilderOS marker...');
|
|
228
|
+
|
|
229
|
+
const marker = {
|
|
230
|
+
initialized: true,
|
|
231
|
+
version: '2.0.0',
|
|
232
|
+
timestamp: new Date().toISOString(),
|
|
233
|
+
architecture: 'api-based',
|
|
234
|
+
cli_version: '2.0.0',
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
await writeFile('.builderos', JSON.stringify(marker, null, 2) + '\n');
|
|
238
|
+
console.log(' ✅ Marker created');
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Step 4: Update .gitignore
|
|
242
|
+
async function updateGitignore() {
|
|
243
|
+
console.log('4️⃣ Updating .gitignore...');
|
|
244
|
+
|
|
245
|
+
let gitignoreContent = '';
|
|
246
|
+
|
|
247
|
+
if (await fileExists('.gitignore')) {
|
|
248
|
+
gitignoreContent = await readFile('.gitignore', 'utf-8');
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
let updated = false;
|
|
252
|
+
|
|
253
|
+
// Add .mcp.json (commented)
|
|
254
|
+
if (!gitignoreContent.includes('.mcp.json')) {
|
|
255
|
+
gitignoreContent += '\n# BuilderOS MCP - Remove comment to share with team\n';
|
|
256
|
+
gitignoreContent += '# .mcp.json\n';
|
|
257
|
+
console.log(' ✅ Added .mcp.json to .gitignore (commented)');
|
|
258
|
+
updated = true;
|
|
259
|
+
} else {
|
|
260
|
+
console.log(' ℹ️ .mcp.json already in .gitignore');
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// Add .claude/ (commented)
|
|
264
|
+
if (!gitignoreContent.includes('.claude/')) {
|
|
265
|
+
gitignoreContent += '# Claude Skills - Remove comment to share with team\n';
|
|
266
|
+
gitignoreContent += '# .claude/\n';
|
|
267
|
+
console.log(' ✅ Added .claude/ to .gitignore (commented)');
|
|
268
|
+
updated = true;
|
|
269
|
+
} else {
|
|
270
|
+
console.log(' ℹ️ .claude/ already in .gitignore');
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// Add .builderos
|
|
274
|
+
if (!gitignoreContent.includes('.builderos')) {
|
|
275
|
+
gitignoreContent += '.builderos\n';
|
|
276
|
+
console.log(' ✅ Added .builderos to .gitignore');
|
|
277
|
+
updated = true;
|
|
278
|
+
} else {
|
|
279
|
+
console.log(' ℹ️ .builderos already in .gitignore');
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (updated) {
|
|
283
|
+
await writeFile('.gitignore', gitignoreContent);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// Main execution
|
|
288
|
+
async function main() {
|
|
289
|
+
console.log('==========================================');
|
|
290
|
+
console.log(' BuilderOS CLI v2.0.0');
|
|
291
|
+
console.log('==========================================');
|
|
292
|
+
console.log('');
|
|
293
|
+
console.log(`Command: ${command}`);
|
|
294
|
+
console.log(`API URL: ${options.apiUrl}`);
|
|
295
|
+
console.log('');
|
|
296
|
+
|
|
297
|
+
try {
|
|
298
|
+
if (command === 'init') {
|
|
299
|
+
// Detect current state
|
|
300
|
+
const hasMCP = await fileExists('.mcp.json');
|
|
301
|
+
const hasSkills = await fileExists('.claude/skills');
|
|
302
|
+
|
|
303
|
+
let mode = 'install';
|
|
304
|
+
if (options.force) {
|
|
305
|
+
mode = 'install';
|
|
306
|
+
console.log('🔄 Force mode: Reinstalling everything...');
|
|
307
|
+
} else if (options.mcpOnly) {
|
|
308
|
+
mode = 'mcp-only';
|
|
309
|
+
console.log('🔧 MCP only mode');
|
|
310
|
+
} else if (options.skillsOnly) {
|
|
311
|
+
mode = 'skills-only';
|
|
312
|
+
console.log('📥 Skills only mode');
|
|
313
|
+
} else if (!hasMCP && !hasSkills) {
|
|
314
|
+
mode = 'install';
|
|
315
|
+
console.log('🆕 New project detected: Installing BuilderOS...');
|
|
316
|
+
} else if (hasMCP && hasSkills) {
|
|
317
|
+
mode = 'update';
|
|
318
|
+
console.log('🔄 BuilderOS already installed: Updating skills...');
|
|
319
|
+
} else if (hasMCP && !hasSkills) {
|
|
320
|
+
mode = 'skills-only';
|
|
321
|
+
console.log('📥 MCP configured: Installing skills...');
|
|
322
|
+
} else {
|
|
323
|
+
mode = 'install';
|
|
324
|
+
console.log('🔧 Partial installation: Completing setup...');
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
console.log('');
|
|
328
|
+
|
|
329
|
+
// Execute based on mode
|
|
330
|
+
if (mode === 'install') {
|
|
331
|
+
await installMCP();
|
|
332
|
+
console.log('');
|
|
333
|
+
await installSkills();
|
|
334
|
+
console.log('');
|
|
335
|
+
await createMarker();
|
|
336
|
+
console.log('');
|
|
337
|
+
await updateGitignore();
|
|
338
|
+
} else if (mode === 'update') {
|
|
339
|
+
await installSkills();
|
|
340
|
+
} else if (mode === 'mcp-only') {
|
|
341
|
+
await installMCP();
|
|
342
|
+
console.log('');
|
|
343
|
+
await createMarker();
|
|
344
|
+
console.log('');
|
|
345
|
+
await updateGitignore();
|
|
346
|
+
} else if (mode === 'skills-only') {
|
|
347
|
+
await installSkills();
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
console.log('');
|
|
351
|
+
console.log('==========================================');
|
|
352
|
+
console.log(' ✅ BuilderOS Setup Complete!');
|
|
353
|
+
console.log('==========================================');
|
|
354
|
+
console.log('');
|
|
355
|
+
console.log('Next steps:');
|
|
356
|
+
console.log('');
|
|
357
|
+
console.log('1. Restart VSCode completely (Cmd+Q, not Reload Window)');
|
|
358
|
+
console.log('');
|
|
359
|
+
console.log('2. Reopen this project');
|
|
360
|
+
console.log('');
|
|
361
|
+
console.log('3. Test MCP connection:');
|
|
362
|
+
console.log(' /mcp');
|
|
363
|
+
console.log(' # Should show: builder-os');
|
|
364
|
+
console.log('');
|
|
365
|
+
console.log('4. Test Claude Skills:');
|
|
366
|
+
console.log(' "What skills do I have?"');
|
|
367
|
+
console.log(' # Should list available skills');
|
|
368
|
+
console.log('');
|
|
369
|
+
} else if (command === 'update') {
|
|
370
|
+
console.log('🔄 Updating BuilderOS skills...');
|
|
371
|
+
console.log('');
|
|
372
|
+
await installSkills();
|
|
373
|
+
console.log('');
|
|
374
|
+
console.log('✅ Update complete!');
|
|
375
|
+
} else {
|
|
376
|
+
console.log(`❌ Unknown command: ${command}`);
|
|
377
|
+
console.log('Run "npx @builderos/cli --help" for usage');
|
|
378
|
+
process.exit(1);
|
|
379
|
+
}
|
|
380
|
+
} catch (error) {
|
|
381
|
+
console.error('');
|
|
382
|
+
console.error('❌ Error:', error.message);
|
|
383
|
+
console.error('');
|
|
384
|
+
console.error('Stack trace:');
|
|
385
|
+
console.error(error.stack);
|
|
386
|
+
process.exit(1);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "builderos-cli",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "BuilderOS CLI - Initialize BuilderOS in any project without requiring local code",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"builderos": "./index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"test": "node index.js init --help"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"builderos",
|
|
15
|
+
"claude",
|
|
16
|
+
"mcp",
|
|
17
|
+
"ai",
|
|
18
|
+
"cli",
|
|
19
|
+
"developer-tools"
|
|
20
|
+
],
|
|
21
|
+
"author": "BuilderOS",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=18.0.0"
|
|
25
|
+
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "https://github.com/builderos/builderos"
|
|
29
|
+
}
|
|
30
|
+
}
|