@archlast/cli 0.2.0 → 0.2.1

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.
Files changed (2) hide show
  1. package/README.md +348 -120
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @archlast/cli
2
2
 
3
- The Archlast CLI is a comprehensive command-line tool for development, deployment, and Docker lifecycle management of Archlast applications. It handles code generation, hot deployment, container management, and data operations.
3
+ The Archlast CLI is a comprehensive command-line tool for development, deployment, and Docker lifecycle management of Archlast applications. It handles code analysis, type generation, hot deployment, container management, and data operations.
4
4
 
5
5
  ## Table of Contents
6
6
 
@@ -14,6 +14,7 @@ The Archlast CLI is a comprehensive command-line tool for development, deploymen
14
14
  - [Data Management](#data-management)
15
15
  - [Configuration](#configuration)
16
16
  - [Environment Variables](#environment-variables)
17
+ - [Generated Files](#generated-files)
17
18
  - [Usage Examples](#usage-examples)
18
19
  - [Troubleshooting](#troubleshooting)
19
20
 
@@ -83,7 +84,7 @@ archlast deploy --path ./my-archlast-app --server https://api.myapp.com
83
84
 
84
85
  #### `archlast dev`
85
86
 
86
- Start development mode with file watching. Automatically regenerates types and deploys changes to the server.
87
+ Start development mode with file watching. Automatically regenerates types and deploys changes to the server using delta deployments.
87
88
 
88
89
  ```bash
89
90
  archlast dev [options]
@@ -95,6 +96,15 @@ Options:
95
96
  -p, --port <port> Server port (default: 3001)
96
97
  ```
97
98
 
99
+ **What happens:**
100
+
101
+ 1. Polls server to ensure it's reachable
102
+ 2. Analyzes code for functions, HTTP routes, RPC procedures, and injectables
103
+ 3. Generates types in `_generated/` directory
104
+ 4. Computes delta (added/modified/removed files) against server manifest
105
+ 5. Uploads only changed files (delta deployment)
106
+ 6. Watches `src/**/*.ts` for changes and repeats
107
+
98
108
  **Example:**
99
109
 
100
110
  ```bash
@@ -115,14 +125,17 @@ archlast build --path ./my-archlast-app
115
125
 
116
126
  **What it generates:**
117
127
 
118
- - `_generated/server.ts` - DataModel types, QueryCtx, MutationCtx
128
+ - `_generated/server.ts` - DataModel types, QueryCtx, MutationCtx, ActionCtx
119
129
  - `_generated/api.ts` - Client-side function references
120
- - `_generated/rpc.ts` - tRPC router types (if using RPC)
121
- - `_generated/crud/<collection>.ts` - Auto-generated CRUD handlers
130
+ - `_generated/rpc.ts` - RPC procedure types
131
+ - `_generated/trpc-router.ts` - tRPC router with AppRouter type
132
+ - `_generated/crud/<collection>.ts` - Auto-generated REST CRUD handlers
133
+ - `_generated/di.ts` - Dependency injection provider registrations (if injectables detected)
134
+ - `_generated/index.ts` - Barrel exports
122
135
 
123
136
  #### `archlast deploy`
124
137
 
125
- One-time deployment to the server.
138
+ One-time deployment to the server with delta detection.
126
139
 
127
140
  ```bash
128
141
  archlast deploy [options]
@@ -133,6 +146,21 @@ Options:
133
146
  --max-poll <number> Maximum polling retries (default: 30)
134
147
  ```
135
148
 
149
+ **Deployment Protocol:**
150
+
151
+ The CLI computes a delta by comparing local file hashes against the server's manifest (`GET /_archlast/deploy/manifest`), then sends only changed files to `POST /_archlast/deploy`.
152
+
153
+ ```typescript
154
+ interface DeltaUploadPayload {
155
+ timestamp: number;
156
+ changes: {
157
+ added: Array<{ filePath: string; code: string }>;
158
+ modified: Array<{ filePath: string; code: string }>;
159
+ removed: string[];
160
+ };
161
+ }
162
+ ```
163
+
136
164
  #### `archlast pull`
137
165
 
138
166
  Pull schema or files from the server, or pull Docker images.
@@ -147,9 +175,11 @@ Options:
147
175
  --force Overwrite without prompt
148
176
  --diff Show diff only
149
177
  --merge Attempt merge
178
+ --smart Enable smart pull with change detection
150
179
  --docker Pull Docker image instead of schema
151
180
  --image <image> Docker image name
152
181
  --tag <tag> Docker image tag
182
+ --version <version> Docker image version (alias for --tag)
153
183
  ```
154
184
 
155
185
  **Examples:**
@@ -161,6 +191,9 @@ archlast pull --server http://localhost:4000
161
191
  # Pull and show diff only
162
192
  archlast pull --diff
163
193
 
194
+ # Smart pull with change detection
195
+ archlast pull --smart
196
+
164
197
  # Pull specific Docker image
165
198
  archlast pull --docker --image archlast/server --tag v1.2.0
166
199
  ```
@@ -169,9 +202,11 @@ archlast pull --docker --image archlast/server --tag v1.2.0
169
202
 
170
203
  ### Docker Management
171
204
 
205
+ All Docker commands support configuration via `archlast.config.js` or CLI flags.
206
+
172
207
  #### `archlast start`
173
208
 
174
- Start the Archlast Docker container.
209
+ Start the Archlast Docker container with health checking.
175
210
 
176
211
  ```bash
177
212
  archlast start [options]
@@ -185,6 +220,14 @@ Options:
185
220
  --config <path> Path to archlast.config.js
186
221
  ```
187
222
 
223
+ **What happens:**
224
+
225
+ 1. Loads configuration (CLI flags → config file → .env → defaults)
226
+ 2. Generates Docker Compose file at `.archlast/config/docker-compose.yml`
227
+ 3. Starts the container via Docker Compose
228
+ 4. Waits for health check at `/health` (60 second timeout)
229
+ 5. Displays API and Dashboard URLs
230
+
188
231
  **Example:**
189
232
 
190
233
  ```bash
@@ -198,6 +241,14 @@ archlast start --port 5000
198
241
  archlast start --image archlast/server --tag v1.2.0
199
242
  ```
200
243
 
244
+ **Output:**
245
+
246
+ ```
247
+ API: http://localhost:4000
248
+ Dashboard: http://localhost:4000/_admin
249
+ Compose: .archlast/config/docker-compose.yml
250
+ ```
251
+
201
252
  #### `archlast stop`
202
253
 
203
254
  Stop the running container.
@@ -234,18 +285,14 @@ Options:
234
285
  --config <path> Path to archlast.config.js
235
286
  ```
236
287
 
237
- **Output example:**
238
-
239
- ```
240
- 🐳 Archlast Server Status
288
+ **Output includes:**
241
289
 
242
- Container: archlast-server
243
- Status: running
244
- Health: healthy
245
- Uptime: 2 hours
246
- Port: 4000
247
- Image: archlast/server:latest
248
- ```
290
+ - Container name and state
291
+ - Health status
292
+ - Uptime
293
+ - Port mappings
294
+ - Image version
295
+ - CPU and memory usage
249
296
 
250
297
  #### `archlast logs`
251
298
 
@@ -265,8 +312,8 @@ Options:
265
312
  **Examples:**
266
313
 
267
314
  ```bash
268
- # Follow logs in real-time
269
- archlast logs --follow
315
+ # Follow logs in real-time (default)
316
+ archlast logs
270
317
 
271
318
  # Show last 50 lines and exit
272
319
  archlast logs --tail 50 --no-follow
@@ -283,7 +330,8 @@ Options:
283
330
  --path <path> Path to project root
284
331
  --port <port> Host port to expose
285
332
  --image <image> Docker image name
286
- --tag <tag> Docker image tag (or --version)
333
+ --tag <tag> Docker image tag
334
+ --version <version> Docker image version (alias for --tag)
287
335
  --container <name> Docker container name
288
336
  --config <path> Path to archlast.config.js
289
337
  ```
@@ -317,7 +365,7 @@ Options:
317
365
 
318
366
  #### `archlast generate crud <collection>`
319
367
 
320
- Generate CRUD handlers for a collection defined in your schema.
368
+ Generate REST CRUD handlers for a collection defined in your schema.
321
369
 
322
370
  ```bash
323
371
  archlast generate crud <collection> [options]
@@ -344,42 +392,44 @@ archlast generate crud tasks --ejected
344
392
 
345
393
  **Generated handlers (linked mode):**
346
394
 
395
+ Creates `src/functions/tasks.ts`:
396
+
347
397
  ```ts
348
- // src/tasks.ts - Re-exports from generated code
349
- export {
350
- listTasks,
351
- getTasks,
352
- createTasks,
353
- updateTasks,
354
- deleteTasks,
355
- } from "../_generated/crud/tasks";
398
+ // Auto-generated CRUD re-export for "tasks"
399
+ // This file links to the auto-generated handlers in _generated/crud
400
+ export * from "../_generated/crud/tasks";
356
401
  ```
357
402
 
358
403
  **Generated handlers (ejected mode):**
359
404
 
360
- ```ts
361
- // src/tasks.ts - Full implementation
362
- import { query, mutation } from "../_generated/server";
405
+ Creates standalone handlers with full implementation that you can customize:
363
406
 
364
- export const listTasks = query(async (ctx) => {
365
- return ctx.db.query("tasks").findMany();
366
- });
367
-
368
- export const getTasks = query({
369
- args: { id: v.string().zodSchema },
370
- handler: async (ctx, args) => {
371
- return ctx.db.get("tasks", args.id);
407
+ ```ts
408
+ // Auto-generated CRUD handlers for "tasks"
409
+ import { http } from "../_generated/server";
410
+ import type { DataModel } from "../_generated/server";
411
+
412
+ export const listTasks = http.get({
413
+ path: "/tasks",
414
+ auth: "public",
415
+ handler: async (ctx) => {
416
+ return ctx.db.query("tasks").findMany();
372
417
  },
373
418
  });
374
419
 
375
- // ... create, update, delete handlers
420
+ // ... get, create, update, delete handlers
376
421
  ```
377
422
 
378
423
  ---
379
424
 
380
425
  ### Data Management
381
426
 
382
- Requires `ARCHLAST_API_KEY` environment variable for authentication.
427
+ All data commands require a Better-Auth API key for authentication. API keys use the `arch_` prefix and can be created via the dashboard or Better-Auth API.
428
+
429
+ ```bash
430
+ # Set API key before running data commands
431
+ export ARCHLAST_API_KEY=arch_your_api_key
432
+ ```
383
433
 
384
434
  #### `archlast data snapshot`
385
435
 
@@ -389,69 +439,89 @@ Create a backup snapshot of all data.
389
439
  archlast data snapshot [options]
390
440
 
391
441
  Options:
392
- --server <url> Server URL (default: "http://localhost:4000")
393
- --name <name> Custom snapshot name
442
+ --server <url> Server URL (default: "http://localhost:4000")
443
+ -n, --name <name> Custom snapshot name
444
+ --include-sqlite Include SQLite export (default: false)
394
445
  ```
395
446
 
396
447
  **Example:**
397
448
 
398
449
  ```bash
399
- export ARCHLAST_API_KEY=arch_your_api_key
400
450
  archlast data snapshot --name "pre-migration-backup"
401
451
  ```
402
452
 
403
- #### `archlast data list`
453
+ **Output:**
404
454
 
405
- List available snapshots.
406
-
407
- ```bash
408
- archlast data list --server http://localhost:4000
455
+ ```
456
+ ✅ Snapshot created: snapshot-2024-01-15-123456.zip
457
+ Records: 1234
458
+ Collections: 5
409
459
  ```
410
460
 
411
- #### `archlast data restore`
461
+ #### `archlast data export <outputFile>`
412
462
 
413
- Restore from a snapshot.
463
+ Export all data to a local file.
414
464
 
415
465
  ```bash
416
- archlast data restore <snapshot-name> [options]
466
+ archlast data export <outputFile> [options]
417
467
 
418
468
  Options:
419
- --server <url> Server URL
420
- --force Skip confirmation
469
+ --server <url> Server URL (default: "http://localhost:4000")
470
+ -f, --format <format> Export format: zip or json (default: "zip")
471
+ ```
472
+
473
+ **Example:**
474
+
475
+ ```bash
476
+ archlast data export backup.zip
477
+ archlast data export backup.json --format json
421
478
  ```
422
479
 
423
- #### `archlast data export`
480
+ #### `archlast data import <inputFile>`
424
481
 
425
- Export data to a local JSON file.
482
+ Import data from a local JSON or ZIP file (auto-detects format).
426
483
 
427
484
  ```bash
428
- archlast data export [options]
485
+ archlast data import <inputFile> [options]
429
486
 
430
487
  Options:
431
- --server <url> Server URL
432
- --output <path> Output file path (default: "archlast-export.json")
433
- --collections <...> Specific collections to export
488
+ --server <url> Server URL (default: "http://localhost:4000")
489
+ -s, --strategy <strategy> Import strategy: replace or merge (default: "merge")
490
+ ```
491
+
492
+ **Example:**
493
+
494
+ ```bash
495
+ archlast data import backup.json --strategy merge
496
+ archlast data import backup.zip
434
497
  ```
435
498
 
436
- #### `archlast data import`
499
+ #### `archlast data restore <snapshotFile>`
437
500
 
438
- Import data from a local JSON file.
501
+ Restore database from a server-side snapshot.
439
502
 
440
503
  ```bash
441
- archlast data import <file> [options]
504
+ archlast data restore <snapshotFile> [options]
442
505
 
443
506
  Options:
444
- --server <url> Server URL
445
- --force Skip confirmation
446
- --merge Merge with existing data (default: replace)
507
+ --server <url> Server URL (default: "http://localhost:4000")
447
508
  ```
448
509
 
449
- #### `archlast data delete`
510
+ **Example:**
511
+
512
+ ```bash
513
+ archlast data restore snapshot-2024-01-15-123456
514
+ ```
450
515
 
451
- Delete a snapshot.
516
+ #### `archlast data delete <snapshotFile>`
517
+
518
+ Delete a snapshot file (supports .json and .zip).
452
519
 
453
520
  ```bash
454
- archlast data delete <snapshot-name> --server http://localhost:4000
521
+ archlast data delete <snapshotFile> [options]
522
+
523
+ Options:
524
+ --server <url> Server URL (default: "http://localhost:4000")
455
525
  ```
456
526
 
457
527
  ---
@@ -462,8 +532,9 @@ The CLI reads configuration in this priority order:
462
532
 
463
533
  1. **CLI flags** (highest priority)
464
534
  2. **archlast.config.js** or **archlast.config.ts**
465
- 3. **.env** or **.env.local**
466
- 4. **Defaults** (lowest priority)
535
+ 3. **.env.local** (takes precedence over .env)
536
+ 4. **.env**
537
+ 5. **Defaults** (lowest priority)
467
538
 
468
539
  ### Configuration File
469
540
 
@@ -478,26 +549,22 @@ export default {
478
549
  tag: "latest",
479
550
  containerName: "archlast-server",
480
551
  volumeName: "archlast-data",
481
- network: "archlast-network",
482
552
  },
483
553
 
484
554
  // Server settings
485
555
  server: {
486
556
  port: 4000,
487
- host: "0.0.0.0",
488
557
  },
489
558
 
490
559
  // Paths configuration
491
560
  paths: {
492
561
  config: ".archlast/config",
493
562
  deploy: ".archlast-deploy",
494
- data: "./data",
495
563
  },
496
564
 
497
565
  // CORS settings
498
566
  cors: {
499
567
  origins: ["http://localhost:3000", "https://myapp.com"],
500
- credentials: true,
501
568
  },
502
569
 
503
570
  // Environment variables to forward to container
@@ -509,30 +576,42 @@ export default {
509
576
  };
510
577
  ```
511
578
 
512
- ### TypeScript Configuration
579
+ ### Default Configuration Values
513
580
 
514
- ```ts
515
- // archlast.config.ts
516
- import type { ArchlastConfig } from "@archlast/cli";
517
-
518
- const config: ArchlastConfig = {
581
+ ```js
582
+ {
519
583
  docker: {
520
584
  image: "archlast/server",
521
585
  tag: "latest",
586
+ containerName: "archlast-server",
587
+ volumeName: "archlast-data",
522
588
  },
523
589
  server: {
524
590
  port: 4000,
525
591
  },
526
- };
527
-
528
- export default config;
592
+ paths: {
593
+ config: ".archlast/config",
594
+ deploy: ".archlast-deploy",
595
+ },
596
+ cors: {
597
+ origins: ["http://localhost:3000"],
598
+ },
599
+ env: {
600
+ NODE_ENV: "development",
601
+ ARCHLAST_LOG_LEVEL: "info",
602
+ ARCHLAST_DB_ROOT: "/data",
603
+ STORAGE_ROOT: "/data/storage",
604
+ ARCHLAST_DASHBOARD_PORT: "4001",
605
+ ARCHLAST_STORE_PORT: "7001",
606
+ },
607
+ }
529
608
  ```
530
609
 
531
610
  ---
532
611
 
533
612
  ## Environment Variables
534
613
 
535
- The following environment variables are automatically forwarded to the Docker container:
614
+ The following environment variable prefixes are automatically forwarded to the Docker container:
536
615
 
537
616
  | Prefix | Description |
538
617
  |--------|-------------|
@@ -541,12 +620,21 @@ The following environment variables are automatically forwarded to the Docker co
541
620
  | `AWS_*` | AWS credentials |
542
621
  | `STORAGE_*` | Storage settings |
543
622
 
623
+ Additionally, these specific variables are forwarded:
624
+
625
+ - `NODE_ENV`
626
+ - `BETTER_AUTH_SECRET`
627
+
544
628
  ### Key Variables
545
629
 
546
630
  ```bash
547
- # API Authentication
631
+ # API Authentication (Better-Auth API key with arch_ prefix)
548
632
  ARCHLAST_API_KEY=arch_your_api_key
549
633
 
634
+ # Better-Auth Configuration
635
+ BETTER_AUTH_SECRET=your-32-char-secret-for-production
636
+ APP_URL=http://localhost:4000
637
+
550
638
  # Server Configuration
551
639
  ARCHLAST_PORT=4000
552
640
  ARCHLAST_ALLOWED_ORIGINS=http://localhost:3000,https://myapp.com
@@ -570,6 +658,115 @@ ARCHLAST_STORE_PORT=7001
570
658
 
571
659
  ---
572
660
 
661
+ ## Generated Files
662
+
663
+ When you run `archlast dev` or `archlast build`, the CLI generates the following files:
664
+
665
+ ### `_generated/server.ts`
666
+
667
+ Contains server-side type definitions:
668
+
669
+ ```ts
670
+ // DataModel with all collection types
671
+ export type DataModel = {
672
+ tasks: {
673
+ _id: string;
674
+ _collection: "tasks";
675
+ text: string;
676
+ completed: boolean;
677
+ // ... fields from schema
678
+ };
679
+ // ... other collections
680
+ };
681
+
682
+ // Context types for functions
683
+ export type QueryCtx = { db: DatabaseReader; auth: AuthContext; ... };
684
+ export type MutationCtx = { db: DatabaseWriter; auth: AuthContext; ... };
685
+ export type ActionCtx = { ... };
686
+
687
+ // Function builders
688
+ export const query: QueryBuilder;
689
+ export const mutation: MutationBuilder;
690
+ export const action: ActionBuilder;
691
+ export const http: HttpBuilder;
692
+ ```
693
+
694
+ ### `_generated/api.ts`
695
+
696
+ Contains client-side function references:
697
+
698
+ ```ts
699
+ export const api = {
700
+ tasks: {
701
+ list: createFunctionReference<{}, Task[]>("tasks.list"),
702
+ get: createFunctionReference<{ id: string }, Task>("tasks.get"),
703
+ create: createFunctionReference<CreateTaskArgs, Task>("tasks.create"),
704
+ // ...
705
+ },
706
+ // ... other modules
707
+ };
708
+ ```
709
+
710
+ ### `_generated/rpc.ts`
711
+
712
+ Contains RPC procedure types:
713
+
714
+ ```ts
715
+ export type RpcProcedures = {
716
+ "getUser": { args: { id: string }; result: User };
717
+ // ... procedures defined with rpc.query/rpc.mutation
718
+ };
719
+ ```
720
+
721
+ ### `_generated/trpc-router.ts`
722
+
723
+ Contains tRPC router definition:
724
+
725
+ ```ts
726
+ import { initTRPC } from "@trpc/server";
727
+
728
+ const t = initTRPC.create();
729
+ export const appRouter = t.router({
730
+ getUser: t.procedure.input(...).query(...),
731
+ // ...
732
+ });
733
+
734
+ export type AppRouter = typeof appRouter;
735
+ ```
736
+
737
+ ### `_generated/crud/<collection>.ts`
738
+
739
+ Auto-generated REST CRUD handlers for each collection:
740
+
741
+ ```ts
742
+ export const listTasks = http.get({ path: "/tasks", ... });
743
+ export const getTasks = http.get({ path: "/tasks/:id", ... });
744
+ export const createTasks = http.post({ path: "/tasks", ... });
745
+ export const updateTasks = http.patch({ path: "/tasks/:id", ... });
746
+ export const deleteTasks = http.delete({ path: "/tasks/:id", ... });
747
+ ```
748
+
749
+ ### `_generated/di.ts`
750
+
751
+ Dependency injection registrations (if `@injectable()` decorators detected):
752
+
753
+ ```ts
754
+ import { Container } from "@archlast/server/di/container";
755
+
756
+ export const providers = [
757
+ { provide: "EmailService", useClass: ResendEmailService, scope: "transient" },
758
+ // ...
759
+ ];
760
+
761
+ export function registerProviders(container: Container): void {
762
+ for (const provider of providers) {
763
+ container.register(provider);
764
+ }
765
+ }
766
+ ```
767
+
768
+ ---
769
+
573
770
  ## Usage Examples
574
771
 
575
772
  ### Complete Development Workflow
@@ -585,7 +782,7 @@ archlast dev --path ./my-app
585
782
  archlast generate crud users
586
783
 
587
784
  # 4. Check logs if issues arise
588
- archlast logs --follow
785
+ archlast logs
589
786
 
590
787
  # 5. Create backup before major changes
591
788
  archlast data snapshot --name "before-feature-x"
@@ -655,15 +852,29 @@ docker --version
655
852
  docker ps # Should not error
656
853
  ```
657
854
 
658
- #### "Connection refused"
855
+ #### "Server not reachable after X retries"
659
856
 
660
- The server might not be running:
857
+ The server might not be running or is not healthy:
661
858
 
662
859
  ```bash
663
860
  archlast status
664
861
  archlast start
862
+ archlast logs # Check for errors
863
+ ```
864
+
865
+ #### "Authentication failed" / "API key not found"
866
+
867
+ Set the API key with the correct `arch_` prefix:
868
+
869
+ ```bash
870
+ export ARCHLAST_API_KEY=arch_your_key
871
+
872
+ # Or add to .env.local file
873
+ echo "ARCHLAST_API_KEY=arch_your_key" >> .env.local
665
874
  ```
666
875
 
876
+ API keys can be created via the admin dashboard at `/_archlast/admin/api-keys` or through the Better-Auth API.
877
+
667
878
  #### "Permission denied" (Linux)
668
879
 
669
880
  For Docker socket access:
@@ -675,7 +886,7 @@ newgrp docker
675
886
 
676
887
  #### "Schema file not found"
677
888
 
678
- Ensure your schema is at `src/schema.ts`:
889
+ Ensure your schema is at `src/schema.ts` or `src/schema/index.ts`:
679
890
 
680
891
  ```
681
892
  my-app/
@@ -685,45 +896,59 @@ my-app/
685
896
  └── archlast.config.js
686
897
  ```
687
898
 
688
- #### "API key not found"
899
+ #### "Collection not found in schema"
689
900
 
690
- Set the API key:
901
+ When using `generate crud`, the collection must be defined with `defineTable`:
691
902
 
692
- ```bash
693
- export ARCHLAST_API_KEY=arch_your_key
903
+ ```ts
904
+ // src/schema.ts
905
+ import { defineTable, v } from "@archlast/server/schema";
694
906
 
695
- # Or add to .env file
696
- echo "ARCHLAST_API_KEY=arch_your_key" >> .env
907
+ export const tasks = defineTable({
908
+ _id: v.id().primaryKey(),
909
+ text: v.string(),
910
+ completed: v.boolean().default(false),
911
+ });
697
912
  ```
698
913
 
699
- ### Debug Mode
914
+ ### Podman Support
700
915
 
701
- Enable verbose logging:
916
+ Podman is experimentally supported. If you encounter issues:
702
917
 
703
918
  ```bash
704
- DEBUG=archlast:* archlast dev
919
+ # Ensure DOCKER_HOST is set correctly
920
+ export DOCKER_HOST=unix:///run/user/$(id -u)/podman/podman.sock
705
921
  ```
706
922
 
707
923
  ---
708
924
 
709
- ## Deployment Protocol
925
+ ## Code Analysis
710
926
 
711
- The server receives deployments at `POST /_archlast/deploy` with payload:
927
+ The CLI uses `ts-morph` for sophisticated TypeScript analysis:
712
928
 
713
- ```typescript
714
- interface DeployPayload {
715
- functions: Array<{
716
- name: string;
717
- type: "query" | "mutation" | "action" | "http" | "webhook" | "rpc";
718
- filePath: string;
719
- code: string;
720
- }>;
721
- schema: {
722
- filePath: string;
723
- code: string;
724
- } | null;
725
- timestamp: number;
726
- }
929
+ - **Functions**: Detects `query()`, `mutation()`, `action()` exports
930
+ - **HTTP Routes**: Detects `http.get()`, `http.post()`, `http.put()`, `http.delete()`, `http.patch()`
931
+ - **RPC Procedures**: Detects `rpc.query()`, `rpc.mutation()`
932
+ - **Injectables**: Detects `@injectable()` decorated classes
933
+ - **Schema**: Parses `defineTable()` definitions
934
+
935
+ ### Supported Function Patterns
936
+
937
+ ```ts
938
+ // Arrow function handler
939
+ export const listTasks = query(async (ctx) => { ... });
940
+
941
+ // Object with handler
942
+ export const createTask = mutation({
943
+ args: { text: v.string().zodSchema },
944
+ handler: async (ctx, args) => { ... },
945
+ });
946
+
947
+ // With auth mode
948
+ export const publicQuery = query({
949
+ auth: "public", // "required" | "optional" | "public"
950
+ handler: async (ctx) => { ... },
951
+ });
727
952
  ```
728
953
 
729
954
  ---
@@ -731,16 +956,19 @@ interface DeployPayload {
731
956
  ## Testing
732
957
 
733
958
  ```bash
734
- # Run CLI tests
959
+ # Run all CLI tests
735
960
  bun test
736
961
 
737
962
  # Run specific test
738
963
  bun test tests/cli.test.ts
964
+
965
+ # Run with coverage
966
+ bun test --coverage
739
967
  ```
740
968
 
741
- ## Publishing (Maintainers)
969
+ ## Keywords
742
970
 
743
- See `docs/npm-publishing.md` for the release workflow and manual publish steps.
971
+ archlast, cli, reactive, backend, code-generation, deployment, docker, typescript
744
972
 
745
973
  ## License
746
974
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@archlast/cli",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Archlast CLI for development and deployment",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",