earl 0.5.2

AI-safe CLI for AI agents
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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
version = 1
provider = "supabase"
categories = ["database", "backend", "infrastructure"]

command "list_projects" {
  title       = "List projects"
  summary     = "List all Supabase projects"
  description = "List all projects accessible with the current access token."
  categories  = ["projects"]

  annotations {
    mode    = "read"
    secrets = ["supabase.access_token"]
  }

  operation {
    protocol = "http"
    method   = "GET"
    url      = "https://api.supabase.com/v1/projects"

    auth {
      kind   = "bearer"
      secret = "supabase.access_token"
    }
  }

  result {
    decode = "json"
    output = "Found {{ result | length }} projects."
  }
}

command "get_project" {
  title       = "Get project"
  summary     = "Get details of a Supabase project"
  description = "Retrieve detailed information about a specific Supabase project including region, status, and database configuration."
  categories  = ["projects"]

  annotations {
    mode    = "read"
    secrets = ["supabase.access_token"]
  }

  param "project_ref" {
    type        = "string"
    required    = true
    description = "Project reference ID"
  }

  operation {
    protocol = "http"
    method   = "GET"
    url      = "https://api.supabase.com/v1/projects/{{ args.project_ref }}"

    auth {
      kind   = "bearer"
      secret = "supabase.access_token"
    }
  }

  result {
    decode = "json"
    output = "Project: {{ result.name }} ({{ result.ref }}) [{{ result.status }}] — {{ result.region }}"
  }
}

command "create_project" {
  title       = "Create project"
  summary     = "Create a new Supabase project"
  description = "Create a new Supabase project in the specified organization with a database password and region."
  categories  = ["projects"]

  annotations {
    mode    = "write"
    secrets = ["supabase.access_token"]
  }

  param "name" {
    type        = "string"
    required    = true
    description = "Project name"
  }

  param "organization_slug" {
    type        = "string"
    required    = true
    description = "Organization slug"
  }

  param "db_pass" {
    type        = "string"
    required    = true
    description = "Database password"
  }

  param "region" {
    type        = "string"
    required    = false
    default     = "us-east-1"
    description = "AWS region (e.g. us-east-1, eu-west-1, ap-southeast-1)"
  }

  param "plan" {
    type        = "string"
    required    = false
    default     = "free"
    description = "Plan tier: free or pro"
  }

  operation {
    protocol = "http"
    method   = "POST"
    url      = "https://api.supabase.com/v1/projects"

    auth {
      kind   = "bearer"
      secret = "supabase.access_token"
    }

    body {
      kind = "json"
      value = {
        name              = "{{ args.name }}"
        organization_slug = "{{ args.organization_slug }}"
        db_pass           = "{{ args.db_pass }}"
        region            = "{{ args.region }}"
        plan              = "{{ args.plan }}"
      }
    }
  }

  result {
    decode = "json"
    output = "Created project: {{ result.name }} ({{ result.ref }}) [{{ result.region }}]"
  }
}

command "get_project_health" {
  title       = "Get project health"
  summary     = "Check health of project services"
  description = "Check the health status of auth, REST, database, and storage services for a Supabase project."
  categories  = ["projects"]

  annotations {
    mode    = "read"
    secrets = ["supabase.access_token"]
  }

  param "project_ref" {
    type        = "string"
    required    = true
    description = "Project reference ID"
  }

  operation {
    protocol = "http"
    method   = "GET"
    url      = "https://api.supabase.com/v1/projects/{{ args.project_ref }}/health?services=auth&services=rest&services=db&services=storage"

    auth {
      kind   = "bearer"
      secret = "supabase.access_token"
    }
  }

  result {
    decode = "json"
    output = "Health check returned {{ result | length }} service(s) for {{ args.project_ref }}."
  }
}

command "run_sql" {
  title       = "Run SQL query"
  summary     = "Execute a SQL query against a project database"
  description = "Run an arbitrary SQL query against the Postgres database of a Supabase project via the Management API."
  categories  = ["database"]

  annotations {
    mode    = "write"
    secrets = ["supabase.access_token"]
  }

  param "project_ref" {
    type        = "string"
    required    = true
    description = "Project reference ID"
  }

  param "query" {
    type        = "string"
    required    = true
    description = "SQL query to execute"
  }

  operation {
    protocol = "http"
    method   = "POST"
    url      = "https://api.supabase.com/v1/projects/{{ args.project_ref }}/database/query"

    auth {
      kind   = "bearer"
      secret = "supabase.access_token"
    }

    body {
      kind = "json"
      value = {
        query = "{{ args.query }}"
      }
    }
  }

  result {
    decode = "json"
    output = "Query returned {{ result | length }} rows."
  }
}

command "list_secrets" {
  title       = "List secrets"
  summary     = "List all secrets for a project"
  description = "List all environment variable secrets configured for a Supabase project. Values are not returned, only names and metadata."
  categories  = ["secrets"]

  annotations {
    mode    = "read"
    secrets = ["supabase.access_token"]
  }

  param "project_ref" {
    type        = "string"
    required    = true
    description = "Project reference ID"
  }

  operation {
    protocol = "http"
    method   = "GET"
    url      = "https://api.supabase.com/v1/projects/{{ args.project_ref }}/secrets"

    auth {
      kind   = "bearer"
      secret = "supabase.access_token"
    }
  }

  result {
    decode = "json"
    output = "Found {{ result | length }} secret(s) for {{ args.project_ref }}."
  }
}

command "list_edge_functions" {
  title       = "List edge functions"
  summary     = "List all edge functions for a project"
  description = "List all deployed edge functions for a Supabase project including name, slug, status, and version."
  categories  = ["functions"]

  annotations {
    mode    = "read"
    secrets = ["supabase.access_token"]
  }

  param "project_ref" {
    type        = "string"
    required    = true
    description = "Project reference ID"
  }

  operation {
    protocol = "http"
    method   = "GET"
    url      = "https://api.supabase.com/v1/projects/{{ args.project_ref }}/functions"

    auth {
      kind   = "bearer"
      secret = "supabase.access_token"
    }
  }

  result {
    decode = "json"
    output = "Found {{ result | length }} edge function(s) for {{ args.project_ref }}."
  }
}

command "generate_types" {
  title       = "Generate TypeScript types"
  summary     = "Generate TypeScript types from database schema"
  description = "Generate TypeScript type definitions from the database schema of a Supabase project. Useful for type-safe client usage."
  categories  = ["development"]

  annotations {
    mode    = "read"
    secrets = ["supabase.access_token"]
  }

  param "project_ref" {
    type        = "string"
    required    = true
    description = "Project reference ID"
  }

  param "included_schemas" {
    type        = "string"
    required    = false
    default     = "public"
    description = "Comma-separated schema names to include"
  }

  operation {
    protocol = "http"
    method   = "GET"
    url      = "https://api.supabase.com/v1/projects/{{ args.project_ref }}/types/typescript"

    auth {
      kind   = "bearer"
      secret = "supabase.access_token"
    }

    query = {
      included_schemas = "{{ args.included_schemas }}"
    }
  }

  result {
    decode = "json"
    output = "{{ result.types }}"
  }
}

command "list_users" {
  title       = "List users"
  summary     = "List auth users for a project"
  description = "List all authentication users for a Supabase project via the Auth Admin API. Requires the project's service role key."
  categories  = ["auth"]

  annotations {
    mode    = "read"
    secrets = ["supabase.service_role_key"]
  }

  param "project_ref" {
    type        = "string"
    required    = true
    description = "Project reference ID"
  }

  param "page" {
    type        = "integer"
    required    = false
    default     = 1
    description = "Page number"
  }

  param "per_page" {
    type        = "integer"
    required    = false
    default     = 50
    description = "Users per page"
  }

  operation {
    protocol = "http"
    method   = "GET"
    url      = "https://{{ args.project_ref }}.supabase.co/auth/v1/admin/users"

    auth {
      kind   = "bearer"
      secret = "supabase.service_role_key"
    }

    query = {
      page     = "{{ args.page }}"
      per_page = "{{ args.per_page }}"
    }

    headers = {
      apikey = "{{ secrets.supabase_service_role_key }}"
    }
  }

  result {
    decode = "json"
    output = "Found {{ result.users | length }} user(s)."
  }
}

command "create_user" {
  title       = "Create user"
  summary     = "Create a new auth user"
  description = "Create a new authentication user for a Supabase project via the Auth Admin API. The user is auto-confirmed by default."
  categories  = ["auth"]

  annotations {
    mode    = "write"
    secrets = ["supabase.service_role_key"]
  }

  param "project_ref" {
    type        = "string"
    required    = true
    description = "Project reference ID"
  }

  param "email" {
    type        = "string"
    required    = true
    description = "User email address"
  }

  param "email_confirm" {
    type        = "boolean"
    required    = false
    default     = true
    description = "Auto-confirm the email address"
  }

  operation {
    protocol = "http"
    method   = "POST"
    url      = "https://{{ args.project_ref }}.supabase.co/auth/v1/admin/users"

    auth {
      kind   = "bearer"
      secret = "supabase.service_role_key"
    }

    headers = {
      apikey = "{{ secrets.supabase_service_role_key }}"
    }

    body {
      kind = "json"
      value = {
        email         = "{{ args.email }}"
        email_confirm = "{{ args.email_confirm }}"
      }
    }
  }

  result {
    decode = "json"
    output = "Created user: {{ result.email }} ({{ result.id }})"
  }
}

command "delete_user" {
  title       = "Delete user"
  summary     = "Delete an auth user"
  description = "Permanently delete an authentication user from a Supabase project by their UUID."
  categories  = ["auth"]

  annotations {
    mode    = "write"
    secrets = ["supabase.service_role_key"]
  }

  param "project_ref" {
    type        = "string"
    required    = true
    description = "Project reference ID"
  }

  param "user_id" {
    type        = "string"
    required    = true
    description = "User UUID"
  }

  operation {
    protocol = "http"
    method   = "DELETE"
    url      = "https://{{ args.project_ref }}.supabase.co/auth/v1/admin/users/{{ args.user_id }}"

    auth {
      kind   = "bearer"
      secret = "supabase.service_role_key"
    }

    headers = {
      apikey = "{{ secrets.supabase_service_role_key }}"
    }
  }

  result {
    decode = "json"
    output = "Deleted user {{ args.user_id }}."
  }
}

command "query_table" {
  title       = "Query table"
  summary     = "Query rows from a table via PostgREST"
  description = "Query rows from a table or view using the PostgREST API. Supports column selection and row limits. For filtering, append PostgREST operators as query params (e.g. status=eq.active)."
  categories  = ["database"]

  annotations {
    mode    = "read"
    secrets = ["supabase.service_role_key"]
  }

  param "project_ref" {
    type        = "string"
    required    = true
    description = "Project reference ID"
  }

  param "table" {
    type        = "string"
    required    = true
    description = "Table or view name"
  }

  param "select" {
    type        = "string"
    required    = false
    default     = "*"
    description = "Column selection (e.g. id,name,email)"
  }

  param "limit" {
    type        = "integer"
    required    = false
    default     = 100
    description = "Maximum number of rows to return"
  }

  operation {
    protocol = "http"
    method   = "GET"
    url      = "https://{{ args.project_ref }}.supabase.co/rest/v1/{{ args.table }}"

    auth {
      kind   = "bearer"
      secret = "supabase.service_role_key"
    }

    query = {
      select = "{{ args.select }}"
      limit  = "{{ args.limit }}"
    }

    headers = {
      apikey = "{{ secrets.supabase_service_role_key }}"
    }
  }

  result {
    decode = "json"
    output = "Returned {{ result | length }} rows from {{ args.table }}."
  }
}

command "invoke_function" {
  title       = "Invoke edge function"
  summary     = "Invoke a deployed edge function"
  description = "Invoke a deployed Supabase edge function by its slug. Sends an empty JSON body by default — modify the template to pass custom payloads."
  categories  = ["functions"]

  annotations {
    mode    = "write"
    secrets = ["supabase.service_role_key"]
  }

  param "project_ref" {
    type        = "string"
    required    = true
    description = "Project reference ID"
  }

  param "function_name" {
    type        = "string"
    required    = true
    description = "Edge function slug"
  }

  operation {
    protocol = "http"
    method   = "POST"
    url      = "https://{{ args.project_ref }}.supabase.co/functions/v1/{{ args.function_name }}"

    auth {
      kind   = "bearer"
      secret = "supabase.service_role_key"
    }

    body {
      kind = "json"
      value = {}
    }
  }

  result {
    decode = "json"
    output = "Function {{ args.function_name }} invoked successfully."
  }
}