-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjustfile
More file actions
306 lines (255 loc) Β· 9.3 KB
/
justfile
File metadata and controls
306 lines (255 loc) Β· 9.3 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
# Justfile for Maple Proxy
# Development commands for the OpenAI-compatible proxy server
# Load environment variables from .env file
set dotenv-load
# Set the container runtime (docker or podman)
container := env_var_or_default("CONTAINER_RUNTIME", "podman")
# Default command - show available commands
default:
@just --list
# Set up development environment
setup:
@echo "π§ Setting up development environment..."
@bash setup-hooks.sh
@cargo check --all-features
@echo "β
Development environment ready"
# Format code with rustfmt
format:
@echo "π¨ Formatting code..."
@cargo fmt
@echo "β
Code formatted"
# Alias for format
fmt: format
# Run clippy lints
lint:
@echo "π Running clippy lints..."
@cargo clippy --all-targets --all-features -- -D warnings
@echo "β
Lints passed"
# Alias for lint
clippy: lint
# Run all tests
test:
@echo "π§ͺ Running tests..."
@cargo test --all-features
@echo "β
Tests passed"
# Run all checks (format, lint, test)
check: format lint test
@echo "β
All checks passed"
# Run the development server
run:
@echo "π Starting Maple Proxy server..."
@echo "π Loading configuration from .env"
@cargo run
# Run with custom backend URL (preserves .env variables)
run-with-backend url:
@echo "π Starting Maple Proxy server..."
@echo "π Backend: {{url}}"
@echo "π Loading other configs from .env"
@bash -c 'set -a; source .env 2>/dev/null; set +a; MAPLE_BACKEND_URL={{url}} cargo run'
# Run pointing to local backend
run-local:
@just run-with-backend "http://localhost:3000"
# Run pointing to production backend
run-prod:
@just run-with-backend "https://enclave.trymaple.ai"
# Build debug binary
build:
@echo "π¨ Building debug binary..."
@cargo build
@echo "β
Debug binary built at target/debug/maple-proxy"
# Build release binary
release:
@echo "π¦ Building release binary..."
@cargo build --release
@echo "β
Release binary built at target/release/maple-proxy"
# Build for all targets (used in CI)
build-all:
@echo "π¦ Building for all targets..."
@cargo build --all-targets --all-features
@echo "β
All targets built"
# Clean build artifacts
clean:
@echo "π§Ή Cleaning build artifacts..."
@cargo clean
@echo "β
Build artifacts cleaned"
# Update dependencies
update:
@echo "π¦ Updating dependencies..."
@cargo update
@echo "β
Dependencies updated"
# Install to ~/.cargo/bin
install:
@echo "π₯ Installing maple-proxy..."
@cargo install --path .
@echo "β
Installed to ~/.cargo/bin/maple-proxy"
# Uninstall from ~/.cargo/bin
uninstall:
@echo "π€ Uninstalling maple-proxy..."
@cargo uninstall maple-proxy
@echo "β
Uninstalled"
# Run with verbose logging
debug:
@echo "π Starting with debug logging..."
RUST_LOG=debug MAPLE_DEBUG=true cargo run
# Check for security vulnerabilities
audit:
@echo "π Running security audit..."
@cargo audit
@echo "β
Security audit complete"
# Generate documentation
doc:
@echo "π Generating documentation..."
@cargo doc --no-deps --all-features --open
@echo "β
Documentation generated"
# Show code coverage (requires cargo-tarpaulin)
coverage:
@echo "π Generating code coverage..."
@cargo tarpaulin --verbose --all-features --workspace --timeout 120 --out html
@echo "β
Coverage report generated at tarpaulin-report.html"
# Watch for changes and run tests
watch:
@echo "ποΈ Watching for changes..."
@cargo watch -x test
# Create a new git commit with conventional commit message
commit message:
@git add -A
@git commit -m "{{message}}"
@echo "β
Changes committed"
# Quick test with curl
test-curl:
@echo "π§ͺ Testing with curl..."
@curl -N http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model": "llama3-3-70b", "messages": [{"role": "user", "content": "Say hello"}], "stream": true}'
# Show environment info
env:
@echo "π Environment Info"
@echo "==================="
@echo "Rust version: $(rustc --version)"
@echo "Cargo version: $(cargo --version)"
@echo "Just version: $(just --version)"
@echo "Container runtime: {{container}} $({{container}} --version 2>/dev/null | head -1 || echo 'not installed')"
@echo ""
@echo "π Environment Variables:"
@echo "MAPLE_HOST: ${MAPLE_HOST:-127.0.0.1}"
@echo "MAPLE_PORT: ${MAPLE_PORT:-8080}"
@echo "MAPLE_BACKEND_URL: ${MAPLE_BACKEND_URL:-https://enclave.trymaple.ai}"
@echo "MAPLE_API_KEY: ${MAPLE_API_KEY:-[not set]}"
@echo "MAPLE_DEBUG: ${MAPLE_DEBUG:-false}"
@echo "MAPLE_ENABLE_CORS: ${MAPLE_ENABLE_CORS:-false}"
# Build Docker image
docker-build:
@echo "π³ Building Docker image with {{container}}..."
@{{container}} build -t maple-proxy:latest .
@echo "β
Docker image built: maple-proxy:latest"
# Run Docker container
docker-run:
@echo "π Running Docker container with {{container}}..."
@{{container}} run --rm -it \
-p ${MAPLE_PORT:-8080}:8080 \
-e MAPLE_API_KEY=${MAPLE_API_KEY} \
-e MAPLE_BACKEND_URL=${MAPLE_BACKEND_URL:-https://enclave.trymaple.ai} \
-e MAPLE_DEBUG=${MAPLE_DEBUG:-false} \
-e MAPLE_ENABLE_CORS=${MAPLE_ENABLE_CORS:-true} \
maple-proxy:latest
# Run Docker container in detached mode
docker-run-detached:
@echo "π Running Docker container in background with {{container}}..."
@{{container}} run -d \
--name maple-proxy \
-p ${MAPLE_PORT:-8080}:8080 \
-e MAPLE_API_KEY=${MAPLE_API_KEY} \
-e MAPLE_BACKEND_URL=${MAPLE_BACKEND_URL:-https://enclave.trymaple.ai} \
-e MAPLE_DEBUG=${MAPLE_DEBUG:-false} \
-e MAPLE_ENABLE_CORS=${MAPLE_ENABLE_CORS:-true} \
maple-proxy:latest
@echo "β
Container started. Use 'just docker-stop' to stop it."
# Stop Docker container
docker-stop:
@echo "π Stopping Docker container..."
@{{container}} stop maple-proxy 2>/dev/null || echo "Container not running"
@{{container}} rm maple-proxy 2>/dev/null || true
@echo "β
Container stopped"
# View Docker logs
docker-logs:
@{{container}} logs -f maple-proxy 2>/dev/null || echo "Container not running"
# Run with docker-compose
compose-up:
@echo "π Starting services with docker-compose..."
@{{container}}-compose up -d
@echo "β
Services started. Use 'just compose-down' to stop."
# Stop docker-compose services
compose-down:
@echo "π Stopping services..."
@{{container}}-compose down
@echo "β
Services stopped"
# View docker-compose logs
compose-logs:
@{{container}}-compose logs -f
# Clean Docker images
docker-clean:
@echo "π§Ή Cleaning Docker images..."
@{{container}} rmi maple-proxy:latest 2>/dev/null || true
@echo "β
Docker images cleaned"
# Push to GitHub Container Registry
ghcr-push tag="latest":
@echo "π¦ Pushing to GitHub Container Registry..."
@{{container}} tag maple-proxy:latest ghcr.io/opensecretcloud/maple-proxy:{{tag}}
@{{container}} push ghcr.io/opensecretcloud/maple-proxy:{{tag}}
@echo "β
Pushed to ghcr.io/opensecretcloud/maple-proxy:{{tag}}"
# Build and push to GHCR
ghcr-build-push tag="latest":
@echo "π³ Building and pushing to GHCR..."
@{{container}} build -t ghcr.io/opensecretcloud/maple-proxy:{{tag}} .
@{{container}} push ghcr.io/opensecretcloud/maple-proxy:{{tag}}
@echo "β
Image available at ghcr.io/opensecretcloud/maple-proxy:{{tag}}"
# Login to GitHub Container Registry (requires PAT token)
ghcr-login:
@echo "π Logging in to GitHub Container Registry..."
@echo "Please ensure you have a GitHub Personal Access Token with 'write:packages' scope"
@echo "${GITHUB_TOKEN}" | {{container}} login ghcr.io -u ${GITHUB_USER} --password-stdin
@echo "β
Logged in to ghcr.io"
# Pull from GitHub Container Registry
ghcr-pull tag="latest":
@echo "π₯ Pulling from GitHub Container Registry..."
@{{container}} pull ghcr.io/opensecretcloud/maple-proxy:{{tag}}
@echo "β
Pulled ghcr.io/opensecretcloud/maple-proxy:{{tag}}"
# === OpenClaw Plugin ===
# Install plugin dependencies
plugin-install:
@echo "π¦ Installing plugin dependencies..."
@cd openclaw-plugin && npm install
@echo "β
Plugin dependencies installed"
# Build plugin (TypeScript -> JS)
plugin-build:
@echo "π¨ Building OpenClaw plugin..."
@cd openclaw-plugin && npm run build
@echo "β
Plugin built"
# Lint plugin
plugin-lint:
@echo "π Linting plugin..."
@cd openclaw-plugin && npm run lint
@echo "β
Plugin linted"
# Test plugin
plugin-test:
@echo "π§ͺ Testing plugin..."
@cd openclaw-plugin && npm test
@echo "β
Plugin tests passed"
# Check all (Rust + plugin)
check-all: check plugin-lint plugin-test
@echo "β
All checks passed (Rust + Plugin)"
# Link plugin locally for OpenClaw development
plugin-link:
@echo "π Linking plugin to OpenClaw extensions..."
@openclaw plugins install -l ./openclaw-plugin
@echo "β
Plugin linked"
# Pack plugin for npm publishing
plugin-pack:
@echo "π¦ Packing plugin for npm..."
@cd openclaw-plugin && npm pack
@echo "β
Plugin packed"
# Publish plugin to npm
plugin-publish:
@echo "π Publishing plugin to npm..."
@cd openclaw-plugin && npm publish --access public
@echo "β
Plugin published"