@gadgetinc/ggt 1.7.4 → 2.3.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.
Files changed (149) hide show
  1. package/README.md +167 -31
  2. package/dist/{add-KJLV4API.js → add-7MLI3TCY.js} +10 -9
  3. package/dist/add-7MLI3TCY.js.map +7 -0
  4. package/dist/agent-plugin-543K6WBH.js +11 -0
  5. package/dist/agent-plugin-543K6WBH.js.map +7 -0
  6. package/dist/chunk-2HJS3KFB.js +2 -0
  7. package/dist/{chunk-J2OYMAMD.js.map → chunk-2HJS3KFB.js.map} +2 -2
  8. package/dist/chunk-3WKH3DJL.js +2 -0
  9. package/dist/chunk-3WKH3DJL.js.map +7 -0
  10. package/dist/chunk-577KP32Z.js +8 -0
  11. package/dist/chunk-577KP32Z.js.map +7 -0
  12. package/dist/chunk-6FVHOLT7.js +28 -0
  13. package/dist/chunk-6FVHOLT7.js.map +7 -0
  14. package/dist/chunk-72J7X5LR.js +2 -0
  15. package/dist/chunk-72J7X5LR.js.map +7 -0
  16. package/dist/chunk-ALSXPCRD.js +118 -0
  17. package/dist/chunk-ALSXPCRD.js.map +7 -0
  18. package/dist/chunk-CNNOPE5K.js +69 -0
  19. package/dist/chunk-CNNOPE5K.js.map +7 -0
  20. package/dist/chunk-ETKWDO4V.js +2 -0
  21. package/dist/chunk-ETKWDO4V.js.map +7 -0
  22. package/dist/chunk-F6BGQ4LG.js +11 -0
  23. package/dist/chunk-F6BGQ4LG.js.map +7 -0
  24. package/dist/chunk-FE5O5VX4.js +2 -0
  25. package/dist/chunk-FE5O5VX4.js.map +7 -0
  26. package/dist/chunk-GJGBTM5Y.js +2 -0
  27. package/dist/chunk-GJGBTM5Y.js.map +7 -0
  28. package/dist/chunk-GZTHIOXS.js +2 -0
  29. package/dist/chunk-GZTHIOXS.js.map +7 -0
  30. package/dist/chunk-IQSZEOYY.js +283 -0
  31. package/dist/chunk-IQSZEOYY.js.map +7 -0
  32. package/dist/chunk-J232VCIM.js +2 -0
  33. package/dist/chunk-J232VCIM.js.map +7 -0
  34. package/dist/{chunk-SX5LO3XQ.js → chunk-KKIL22RY.js} +1 -1
  35. package/dist/{chunk-SX5LO3XQ.js.map → chunk-KKIL22RY.js.map} +1 -1
  36. package/dist/chunk-L2XBSR7G.js +2 -0
  37. package/dist/chunk-L2XBSR7G.js.map +7 -0
  38. package/dist/chunk-N5FFICAP.js +9 -0
  39. package/dist/chunk-N5FFICAP.js.map +7 -0
  40. package/dist/chunk-TGCJ6TMW.js +10 -0
  41. package/dist/chunk-TGCJ6TMW.js.map +7 -0
  42. package/dist/chunk-ULJYEUQG.js +113 -0
  43. package/dist/chunk-ULJYEUQG.js.map +7 -0
  44. package/dist/chunk-UVVKKUYG.js +10 -0
  45. package/dist/chunk-UVVKKUYG.js.map +7 -0
  46. package/dist/{chunk-JSGXXXFU.js → chunk-WZ2PO6H2.js} +6 -6
  47. package/dist/{chunk-JSGXXXFU.js.map → chunk-WZ2PO6H2.js.map} +3 -3
  48. package/dist/chunk-X4XSYLCE.js +12 -0
  49. package/dist/chunk-X4XSYLCE.js.map +7 -0
  50. package/dist/chunk-ZYDMXS5R.js +6 -0
  51. package/dist/chunk-ZYDMXS5R.js.map +7 -0
  52. package/dist/{configure-CXY6JQB7.js → configure-PYRXYNGZ.js} +2 -2
  53. package/dist/debugger-VKLUEWIN.js +41 -0
  54. package/dist/debugger-VKLUEWIN.js.map +7 -0
  55. package/dist/deploy-JCREEGBA.js +25 -0
  56. package/dist/deploy-JCREEGBA.js.map +7 -0
  57. package/dist/dev-Y2GLI7EH.js +59 -0
  58. package/dist/dev-Y2GLI7EH.js.map +7 -0
  59. package/dist/env-5OPHX3MC.js +135 -0
  60. package/dist/env-5OPHX3MC.js.map +7 -0
  61. package/dist/esm-3JVXH7DT.js +37 -0
  62. package/dist/esm-3JVXH7DT.js.map +7 -0
  63. package/dist/eval-LZPZ6PBQ.js +54 -0
  64. package/dist/eval-LZPZ6PBQ.js.map +7 -0
  65. package/dist/getMachineId-bsd-QUXN4NKS.js +2 -0
  66. package/dist/getMachineId-bsd-QUXN4NKS.js.map +7 -0
  67. package/dist/getMachineId-darwin-TCXBAX22.js +3 -0
  68. package/dist/getMachineId-darwin-TCXBAX22.js.map +7 -0
  69. package/dist/getMachineId-linux-IJ3LYIOX.js +2 -0
  70. package/dist/getMachineId-linux-IJ3LYIOX.js.map +7 -0
  71. package/dist/getMachineId-unsupported-IKXBUCYY.js +2 -0
  72. package/dist/getMachineId-unsupported-IKXBUCYY.js.map +7 -0
  73. package/dist/getMachineId-win-6CX7VSFF.js +2 -0
  74. package/dist/getMachineId-win-6CX7VSFF.js.map +7 -0
  75. package/dist/ggt-KUAF6WUA.js +45 -0
  76. package/dist/ggt-KUAF6WUA.js.map +7 -0
  77. package/dist/{list-3QZTSHQV.js → list-IANT7SNF.js} +2 -2
  78. package/dist/login-TYRZLN5S.js +2 -0
  79. package/dist/{logout-SWWGI27Q.js → logout-P75XYYZ6.js} +2 -2
  80. package/dist/logs-SBMD6JSR.js +28 -0
  81. package/dist/logs-SBMD6JSR.js.map +7 -0
  82. package/dist/main.js +1 -43
  83. package/dist/main.js.map +4 -4
  84. package/dist/{open-J2ZVNVJ6.js → open-JPAMII4K.js} +11 -11
  85. package/dist/open-JPAMII4K.js.map +7 -0
  86. package/dist/problems-EZRSHLZT.js +14 -0
  87. package/dist/problems-EZRSHLZT.js.map +7 -0
  88. package/dist/pull-R3PMBVOT.js +28 -0
  89. package/dist/pull-R3PMBVOT.js.map +7 -0
  90. package/dist/push-5XEEESQQ.js +2 -0
  91. package/dist/status-RJN5ES6S.js +14 -0
  92. package/dist/status-RJN5ES6S.js.map +7 -0
  93. package/dist/update-X7YS3MNH.js +2 -0
  94. package/dist/update-X7YS3MNH.js.map +7 -0
  95. package/dist/var-PC6KQUPF.js +159 -0
  96. package/dist/var-PC6KQUPF.js.map +7 -0
  97. package/dist/{version-NZHW3VLV.js → version-GZJOU2CV.js} +2 -2
  98. package/dist/{whoami-MIJFO4MW.js → whoami-GKPGPZ3B.js} +2 -2
  99. package/package.json +64 -74
  100. package/dist/add-KJLV4API.js.map +0 -7
  101. package/dist/chunk-24OT7GHO.js +0 -65
  102. package/dist/chunk-24OT7GHO.js.map +0 -7
  103. package/dist/chunk-HN3YKQ3C.js +0 -6
  104. package/dist/chunk-HN3YKQ3C.js.map +0 -7
  105. package/dist/chunk-J2OYMAMD.js +0 -2
  106. package/dist/chunk-JBY5A44K.js +0 -7
  107. package/dist/chunk-JBY5A44K.js.map +0 -7
  108. package/dist/chunk-L5H5T2T6.js +0 -66
  109. package/dist/chunk-L5H5T2T6.js.map +0 -7
  110. package/dist/chunk-M6L2X3GX.js +0 -194
  111. package/dist/chunk-M6L2X3GX.js.map +0 -7
  112. package/dist/chunk-MHTXRD5G.js +0 -2
  113. package/dist/chunk-MHTXRD5G.js.map +0 -7
  114. package/dist/chunk-OIVNACS7.js +0 -12
  115. package/dist/chunk-OIVNACS7.js.map +0 -7
  116. package/dist/chunk-QXWICGG6.js +0 -2
  117. package/dist/chunk-QXWICGG6.js.map +0 -7
  118. package/dist/chunk-WNAYBYSG.js +0 -8
  119. package/dist/chunk-WNAYBYSG.js.map +0 -7
  120. package/dist/chunk-X47UA3VR.js +0 -2
  121. package/dist/chunk-X47UA3VR.js.map +0 -7
  122. package/dist/chunk-XGQQOMPO.js +0 -2
  123. package/dist/chunk-XGQQOMPO.js.map +0 -7
  124. package/dist/chunk-XKYYKHP4.js +0 -28
  125. package/dist/chunk-XKYYKHP4.js.map +0 -7
  126. package/dist/chunk-YU6P3ESA.js +0 -121
  127. package/dist/chunk-YU6P3ESA.js.map +0 -7
  128. package/dist/deploy-XFZBJJWP.js +0 -25
  129. package/dist/deploy-XFZBJJWP.js.map +0 -7
  130. package/dist/dev-GG6TU3DJ.js +0 -59
  131. package/dist/dev-GG6TU3DJ.js.map +0 -7
  132. package/dist/esm-PLVGBDRY.js +0 -38
  133. package/dist/esm-PLVGBDRY.js.map +0 -7
  134. package/dist/login-HKGCVIWO.js +0 -2
  135. package/dist/logs-DW4PH3U6.js +0 -28
  136. package/dist/logs-DW4PH3U6.js.map +0 -7
  137. package/dist/open-J2ZVNVJ6.js.map +0 -7
  138. package/dist/pull-ORNQFSFG.js +0 -28
  139. package/dist/pull-ORNQFSFG.js.map +0 -7
  140. package/dist/push-KMZZ6JJL.js +0 -2
  141. package/dist/status-JAREJZ4X.js +0 -14
  142. package/dist/status-JAREJZ4X.js.map +0 -7
  143. /package/dist/{configure-CXY6JQB7.js.map → configure-PYRXYNGZ.js.map} +0 -0
  144. /package/dist/{list-3QZTSHQV.js.map → list-IANT7SNF.js.map} +0 -0
  145. /package/dist/{login-HKGCVIWO.js.map → login-TYRZLN5S.js.map} +0 -0
  146. /package/dist/{logout-SWWGI27Q.js.map → logout-P75XYYZ6.js.map} +0 -0
  147. /package/dist/{push-KMZZ6JJL.js.map → push-5XEEESQQ.js.map} +0 -0
  148. /package/dist/{version-NZHW3VLV.js.map → version-GZJOU2CV.js.map} +0 -0
  149. /package/dist/{whoami-MIJFO4MW.js.map → whoami-GKPGPZ3B.js.map} +0 -0
package/README.md CHANGED
@@ -5,15 +5,9 @@
5
5
  <br>
6
6
  <br>
7
7
 
8
- <a href="https://github.com/gadget-inc/ggt/actions/workflows/ci.yml?query=branch%3Amain">
9
- <img alt="ci workflow status" src="https://img.shields.io/github/actions/workflow/status/gadget-inc/ggt/ci.yml?branch=main&label=ci">
10
- </a>
11
- <a href="https://www.npmjs.com/package/ggt">
12
- <img alt="npm version" src="https://img.shields.io/npm/v/ggt">
13
- </a>
14
- <a href="https://discord.gg/nAfNKMdwKh">
15
- <img alt="discord chat" src="https://img.shields.io/discord/836317518595096598">
16
- </a>
8
+ [![ci/cd workflow status](https://github.com/gadget-inc/ggt/actions/workflows/cd.yml/badge.svg)](https://github.com/gadget-inc/ggt/actions/workflows/cd.yml)
9
+ [![npm version](https://img.shields.io/npm/v/ggt)](https://www.npmjs.com/package/ggt)
10
+ [![discord server](https://img.shields.io/discord/836317518595096598)](https://discord.gg/9d7wjGBZ6M)
17
11
 
18
12
  <br>
19
13
  <br>
@@ -29,16 +23,22 @@
29
23
  - [`ggt dev`](#ggt-dev)
30
24
  - [`ggt deploy`](#ggt-deploy)
31
25
  - [`ggt status`](#ggt-status)
26
+ - [`ggt problems`](#ggt-problems)
32
27
  - [`ggt push`](#ggt-push)
33
28
  - [`ggt pull`](#ggt-pull)
29
+ - [`ggt var`](#ggt-var)
30
+ - [`ggt env`](#ggt-env)
34
31
  - [`ggt add`](#ggt-add)
35
32
  - [`ggt open`](#ggt-open)
36
33
  - [`ggt list`](#ggt-list)
37
34
  - [`ggt login`](#ggt-login)
38
35
  - [`ggt logout`](#ggt-logout)
39
36
  - [`ggt logs`](#ggt-logs)
37
+ - [`ggt debugger`](#ggt-debugger)
40
38
  - [`ggt whoami`](#ggt-whoami)
41
39
  - [`ggt configure`](#ggt-configure)
40
+ - [`ggt agent-plugin`](#ggt-agent-plugin)
41
+ - [`ggt eval`](#ggt-eval)
42
42
  - [`ggt version`](#ggt-version)
43
43
 
44
44
  ## Intro
@@ -71,14 +71,18 @@ Commands
71
71
  status Show your local and environment's file changes
72
72
  push Push your local files to your environment
73
73
  pull Pull your environment's files to your local computer
74
- add Add models, fields, actions and routes to your app
74
+ var Manage environment variables
75
+ env Manage environments
76
+ add Add models, fields, actions, routes and environments to your app
75
77
  open Open a Gadget location in your browser
76
78
  list List your available applications
77
79
  login Log in to your account
78
80
  logout Log out of your account
79
81
  logs Stream your environment's logs
82
+ debugger Connect to the debugger for your environment
80
83
  whoami Print the currently logged in account
81
84
  configure Configure default execution options
85
+ agent-plugin Install Gadget agent plugins (AGENTS.md + skills)
82
86
  version Print this version of ggt
83
87
 
84
88
  Flags
@@ -86,6 +90,10 @@ Flags
86
90
  -v, --verbose Print more verbose output
87
91
  --telemetry Enable telemetry
88
92
 
93
+ Agent plugins
94
+ Install AGENTS.md and Gadget agent skills for your coding agent:
95
+ ggt agent-plugin install
96
+
89
97
  Run "ggt [COMMAND] -h" for more information about a specific command.
90
98
  ```
91
99
 
@@ -108,11 +116,11 @@ Usage
108
116
  DIRECTORY: The directory to sync files to (default: the current directory)
109
117
 
110
118
  Options
111
- -a, --app <app_name> Selects the app to sync files with. Default set on ".gadget/sync.json"
112
- -e, --env <env_name> Selects the environment to sync files with. Default set on ".gadget/sync.json"
119
+ -a, --app <app_name> Selects the app to sync files with. Defaults to the app synced to the current directory, if there is one.
120
+ -e, --env <env_name> Selects the environment to sync files with. Defaults to the environment synced to the current directory, if there is one.
113
121
  --prefer <source> Auto-select changes from 'local' or 'environment' source on conflict
114
- --allow-unknown-directory Syncs to any local directory with existing files, even if the ".gadget/sync.json" file is missing
115
- --allow-different-app Syncs with a different app using the --app command, instead of the one specified in the .gadget/sync.json file
122
+ --allow-unknown-directory Syncs to any local directory with existing files, even if the directory hasn't been synced before
123
+ --allow-different-app Syncs with a different app using the --app command, instead of the most recently synced one in the current directory
116
124
  --log-level <level> Sets the log level for incoming application logs (default: info)
117
125
  --no-logs Disables outputting application logs to the console
118
126
  --my-logs Only outputs user sourced logs
@@ -157,11 +165,11 @@ Usage
157
165
  $ ggt deploy [options]
158
166
 
159
167
  Options
160
- -a, --app <app_name> Selects a specific app to deploy. Default set on ".gadget/sync.json"
161
- --from, -e, --env <env_name> Selects a specific environment to sync and deploy from. Default set on ".gadget/sync.json"
168
+ -a, --app <app_name> Selects a specific app to deploy. Defaults to the app synced to the current directory, if there is one.
169
+ --from, -e, --env <env_name> Selects a specific environment to sync and deploy from. Defaults to the environment synced to the current directory, if there is one.
162
170
  --force Deploys by discarding any changes made to the environment directory since last sync
163
- --allow-different-directory Deploys from any local directory with existing files, even if the ".gadget/sync.json" file is missing
164
- --allow-different-app Deploys a different app using the --app command, instead of the one specified in the “.gadget/sync.json” file
171
+ --allow-different-directory Deploys from any local directory with existing files, even if the directory hasn't been synced before
172
+ --allow-different-app Deploys a different app using the --app command, instead of the most recently synced one in the current directory
165
173
  --allow-problems Deploys despite any existing issues found in the app (gelly errors, typescript errors etc.)
166
174
  --allow-data-delete Deploys even if it results in the deletion of data in production
167
175
  --allow-charges Deploys even if it results in additional charges to your plan
@@ -181,6 +189,16 @@ Usage
181
189
  ggt status
182
190
  ```
183
191
 
192
+ ### `ggt problems`
193
+
194
+ ```sh-session
195
+ $ ggt problems -h
196
+ Shows any problems (errors, warnings) found in your Gadget application.
197
+
198
+ Usage
199
+ ggt problems
200
+ ```
201
+
184
202
  ### `ggt push`
185
203
 
186
204
  ```sh-session
@@ -194,11 +212,11 @@ Usage
194
212
  ggt push [options]
195
213
 
196
214
  Options
197
- -a, --app <app_name> Selects the app to push local changes to. Default set on ".gadget/sync.json"
198
- -e, --env, --to <env_name> Selects the environment to push local changes to. Default set on ".gadget/sync.json"
215
+ -a, --app <app_name> Selects the app to push local changes to. Defaults to the app synced to the current directory, if there is one.
216
+ -e, --env, --to <env_name> Selects the environment to push local changes to. Defaults to the environment synced to the current directory, if there is one.
199
217
  --force Forces a push by discarding any changes made on your environment directory since last sync
200
- --allow-different-directory Pushes changes from any local directory with existing files, even if the ".gadget/sync.json" file is missing
201
- --allow-different-app Pushes changes to an app using --app command, instead of the one in the “.gadget/sync.json” file
218
+ --allow-different-directory Pushes changes from any local directory with existing files, even if the directory hasn't been synced before
219
+ --allow-different-app Pushes changes to an app using --app command, instead of the most recently synced one in the current directory
202
220
 
203
221
  Examples
204
222
  Push all local changes to the main environment by discarding any changes made on main
@@ -218,17 +236,62 @@ Usage
218
236
  ggt pull [options]
219
237
 
220
238
  Options
221
- -a, --app <app_name> Selects the app to pull your environment changes from. Default set on ".gadget/sync.json"
222
- -e, --env, --from <env_name> Selects the environment to pull changes from. Default set on ".gadget/sync.json"
239
+ -a, --app <app_name> Selects the app to pull your environment changes from. Defaults to the app synced to the current directory, if there is one.
240
+ -e, --env, --from <env_name> Selects the environment to pull changes from. Defaults to the environment synced to the current directory, if there is one.
223
241
  --force Forces a pull by discarding any changes made on your local directory since last sync
224
- --allow-different-directory Pulls changes from any environment directory, even if the ".gadget/sync.json" file is missing
225
- --allow-different-app Pulls changes to a different app using --app command, instead of the one in the “.gadget/sync.json” file
242
+ --allow-different-directory Pulls changes from any environment directory, even if the directory hasn't been synced before
243
+ --allow-different-app Pulls changes to a different app using --app command, instead of the most recently synced one in the current directory
226
244
 
227
245
  Examples
228
246
  Pull all development environment changes by discarding any changes made locally
229
247
  $ ggt pull --env development --force
230
248
  ```
231
249
 
250
+ ### `ggt var`
251
+
252
+ ```sh-session
253
+ $ ggt var -h
254
+ Manage environment variables for your Gadget application.
255
+
256
+ Usage
257
+ ggt var <command> [options]
258
+
259
+ Commands
260
+ list List all environment variables
261
+ get <key> Get the value of an environment variable
262
+ set <key=value> Set one or more environment variables
263
+ delete <key> Delete one or more environment variables
264
+ import Import environment variables from another environment or file
265
+
266
+ Options
267
+ -a, --app <app_name> Selects the application
268
+ -e, --env <env_name> Selects the environment
269
+
270
+ Run "ggt var <command> -h" for more information about a specific command.
271
+ ```
272
+
273
+ ### `ggt env`
274
+
275
+ ```sh-session
276
+ $ ggt env -h
277
+ Manage environments for your Gadget application.
278
+
279
+ Usage
280
+ ggt env <command> [options]
281
+
282
+ Commands
283
+ list List all environments
284
+ create <name> Create a new environment
285
+ delete <name> Delete an environment
286
+ unpause <name> Unpause a paused environment
287
+ use <name> Switch the active environment
288
+
289
+ Options
290
+ -a, --app <app_name> Selects the application
291
+
292
+ Run "ggt env <command> -h" for more information about a specific command.
293
+ ```
294
+
232
295
  ### `ggt add`
233
296
 
234
297
  ```sh-session
@@ -249,7 +312,8 @@ Usage
249
312
  ggt add field <model_path>/<field_name>:<field_type>
250
313
 
251
314
  Options
252
- -e, --env <env_name> Selects the environment to add to. Default set on ".gadget/sync.json"
315
+ -a, --app <app_name> Selects the app to add to. Defaults to the app synced to the current directory, if there is one.
316
+ -e, --env <env_name> Selects the environment to add to. Defaults to the environment synced to the current directory, if there is one.
253
317
 
254
318
  Examples
255
319
  Add a new model 'post' with out fields:
@@ -293,8 +357,8 @@ Usage
293
357
  + schema Opens schema editor for a specific model
294
358
 
295
359
  Options
296
- -a, --app <app_name> Selects the application to open in your browser. Default set on ".gadget/sync.json"
297
- -e, --env <env_name> Selects the environment to open in your browser. Default set on ".gadget/sync.json"
360
+ -a, --app <app_name> Selects the application to open in your browser. Defaults to the app synced to the current directory, if there is one.
361
+ -e, --env <env_name> Selects the environment to open in your browser. Defaults to the environment synced to the current directory, if there is one.
298
362
  --show-all Shows all schema, or data options by listing your available models
299
363
 
300
364
  Examples
@@ -366,8 +430,8 @@ Options
366
430
  -ll, --log-level <level> Sets the log level for incoming application logs (default: info)
367
431
  --my-logs Only outputs user sourced logs and exclude logs from the Gadget framework
368
432
  --json Output logs in JSON format
369
- -a, --app <app_name> Selects the app to pull your environment changes from. Default set on ".gadget/sync.json"
370
- -e, --env, --from <env_name> Selects the environment to pull changes from. Default set on ".gadget/sync.json"
433
+ -a, --app <app_name> Selects the app to pull your environment changes from. Defaults to the app synced to the current directory, if there is one.
434
+ -e, --env, --from <env_name> Selects the environment to pull changes from. Defaults to the environment synced to the current directory, if there is one.
371
435
 
372
436
  Examples
373
437
  Stream all user logs from your development environment
@@ -377,6 +441,39 @@ Examples
377
441
  $ ggt logs --env production --json
378
442
  ```
379
443
 
444
+ ### `ggt debugger`
445
+
446
+ ```sh-session
447
+ $ ggt debugger -h
448
+ Start a Chrome DevTools Protocol proxy server that connects to the Gadget debugger.
449
+ This allows you to debug your Gadget app using VS Code, Chrome DevTools, or any other
450
+ CDP-compatible debugger client.
451
+
452
+ Usage
453
+ $ ggt debugger [DIRECTORY] [options]
454
+
455
+ DIRECTORY: The directory containing your Gadget app (default: current directory)
456
+
457
+ Options
458
+ -a, --app <app_name> Selects the app to debug. Defaults to the app synced to the current directory, if there is one.
459
+ -e, --env <env_name> Selects the environment to debug. Defaults to the environment synced to the current directory, if there is one.
460
+ -p, --port <port> Local port for the inspector proxy (default: 9229)
461
+ --configure <editor> Configure debugger for vscode, cursor
462
+
463
+ Examples
464
+ start debugger proxy for current environment
465
+ $ ggt debugger
466
+
467
+ use a custom port
468
+ $ ggt debugger --port 9230
469
+
470
+ debug a specific app and environment
471
+ $ ggt debugger --app myApp --env development
472
+
473
+ configure VS Code debugger
474
+ $ ggt debugger --configure vscode
475
+ ```
476
+
380
477
  ### `ggt whoami`
381
478
 
382
479
  ```sh-session
@@ -402,6 +499,45 @@ Usage
402
499
  ggt configure clear
403
500
  ```
404
501
 
502
+ ### `ggt agent-plugin`
503
+
504
+ ```sh-session
505
+ $ ggt agent-plugin -h
506
+ Install or update Gadget agent plugins (AGENTS.md + skills).
507
+
508
+ Usage
509
+ ggt agent-plugin install [--force]
510
+ ggt agent-plugin update
511
+
512
+ Flags
513
+ --force Overwrite/reinstall even if already present
514
+ ```
515
+
516
+ ### `ggt eval`
517
+
518
+ ```sh-session
519
+ $ ggt eval -h
520
+ Evaluates a JavaScript snippet against a Gadget app's API client.
521
+
522
+ The snippet receives an api variable (a pre-constructed Gadget API client
523
+ authenticated as the developer). Results are formatted like Node.js REPL output.
524
+ Writes are disallowed by default; use --allow-writes to enable them.
525
+
526
+ Usage
527
+ $ ggt eval [options] <snippet>
528
+
529
+ Options
530
+ -a, --app <app_name> Selects a specific app. Defaults to the app synced to the current directory, if there is one.
531
+ -e, --env <env_name> Selects a specific environment. Defaults to the environment synced to the current directory, if there is one.
532
+ -w, --allow-writes Allow write operations (default is read-only)
533
+ --json Output result as JSON instead of Node.js inspect format (root flag)
534
+
535
+ Examples
536
+ $ ggt eval 'api.user.findMany()'
537
+ $ ggt eval --app my-app --env staging 'api.user.findFirst()'
538
+ $ ggt eval -a my-app -w 'api.user.delete("123")'
539
+ ```
540
+
405
541
  ### `ggt version`
406
542
 
407
543
  ```sh-session
@@ -1,4 +1,4 @@
1
- import{f as O,g as R,h as M,i as j,j as k,k as P,p as b}from"./chunk-M6L2X3GX.js";import{g as N,m as D,n as _,o as E}from"./chunk-YU6P3ESA.js";import"./chunk-JSGXXXFU.js";import"./chunk-WNAYBYSG.js";import{c as f}from"./chunk-J2OYMAMD.js";import{a as J}from"./chunk-JBY5A44K.js";import"./chunk-HN3YKQ3C.js";import{B as U,C as L,a as T,e as C,f as S,l as B,n as y}from"./chunk-L5H5T2T6.js";import"./chunk-X47UA3VR.js";import{b as w}from"./chunk-XGQQOMPO.js";import"./chunk-OIVNACS7.js";import{b as m,ha as d,ja as p,n as F}from"./chunk-24OT7GHO.js";import"./chunk-GFQYFEEH.js";import{a as g,h as $}from"./chunk-7DYQUG5M.js";$();var h=class extends S{static{g(this,"AddClientError")}isBug=C.NO;constructor(o){let i="";if(F(o.cause)){let a=B(o.cause.map(e=>e.message));i=d` • ${a.map(e=>e.split(`
1
+ import{e as j,j as b}from"./chunk-CNNOPE5K.js";import"./chunk-L2XBSR7G.js";import"./chunk-577KP32Z.js";import"./chunk-WZ2PO6H2.js";import{g as M,s as D,t as _,u as E}from"./chunk-ULJYEUQG.js";import{c as f}from"./chunk-2HJS3KFB.js";import{a as P}from"./chunk-F6BGQ4LG.js";import"./chunk-ZYDMXS5R.js";import{A as R,H as y,Y as k,Z as J,a as T,f as C,g as S,m as B,w as N,x as U,y as L,z as O}from"./chunk-IQSZEOYY.js";import"./chunk-GZTHIOXS.js";import{c as w}from"./chunk-72J7X5LR.js";import"./chunk-X4XSYLCE.js";import{b as m,o as F,ra as d,ta as p}from"./chunk-ALSXPCRD.js";import"./chunk-GFQYFEEH.js";import{a as g,h as $}from"./chunk-7DYQUG5M.js";$();var h=class extends S{static{g(this,"AddClientError")}isBug=C.NO;constructor(o){let i="";if(F(o.cause)){let a=B(o.cause.map(e=>e.message));i=d` • ${a.map(e=>e.split(`
2
2
  `).join(`
3
3
  \u200E \u2022 `)).join(`
4
4
  `)}`}else i=d`${o.cause}`;super(i)}render(){return`${m.redBright(w.cross)} Failed to add:
@@ -19,7 +19,8 @@ import{f as O,g as R,h as M,i as j,j as k,k as P,p as b}from"./chunk-M6L2X3GX.js
19
19
  ggt add field <model_path>/<field_name>:<field_type>
20
20
 
21
21
  {gray Options}
22
- -e, --env <env_name> Selects the environment to add to. Default set on ".gadget/sync.json"
22
+ -a, --app <app_name> Selects the app to add to. Defaults to the app synced to the current directory, if there is one.
23
+ -e, --env <env_name> Selects the environment to add to. Defaults to the environment synced to the current directory, if there is one.
23
24
 
24
25
  {gray Examples}
25
26
  Add a new model 'post' with out fields:
@@ -42,7 +43,7 @@ import{f as O,g as R,h as M,i as j,j as k,k as P,p as b}from"./chunk-M6L2X3GX.js
42
43
 
43
44
  Clone the \`development\` environment into a new \`staging\` environment
44
45
  {cyanBright ggt add environment staging --environment development}
45
- `,"usage"),fe=g(async(t,o)=>{let i=await E(process.cwd()),a=await _.load(t,{command:"add",args:o,directory:i});if(!a)throw new N({command:"add",args:o,directory:i});let e=new b(a),r=await e.hashes(t,{silent:!0});switch(r.inSync||await e.merge(t,{hashes:r,printEnvironmentChangesOptions:{limit:5},printLocalChangesOptions:{limit:5},silent:!0}),p({ensureEmptyLineAbove:!0,content:`${m.greenBright(w.tick)} Sync completed ${P()}`}),o._[0]){case"model":await H(t,{args:o,filesync:e});break;case"action":await X(t,{args:o,filesync:e});break;case"route":await z(t,{args:o,filesync:e});break;case"field":await q(t,{args:o,filesync:e});break;case"environment":case"env":await Q(t,{args:o,filesync:e});break;default:p(G(t));return}},"run"),I=g(t=>{let o=[],i=[];return t.forEach(a=>{let e=/^(.*):+(.*)$/.exec(a);!e||e.length!==3||!e[1]||!e[2]?o.push(d`${a} is not a valid field definition`):i.push({name:e[1].replace(/:+/g,""),fieldType:e[2]})}),[i,o]},"parseFieldValues"),H=g(async(t,{args:o,filesync:i})=>{let a=i.syncJson,e=o._[1];if(!e)throw new f(d`Failed to add model, missing model path
46
+ `,"usage"),fe=g(async(t,o)=>{let i=await E(process.cwd()),a=await _.load(t,{command:"add",args:o,directory:i});if(!a)throw new M({command:"add",args:o,directory:i});let e=new b(a),r=await e.hashes(t,{silent:!0});switch(r.inSync||await e.merge(t,{hashes:r,printEnvironmentChangesOptions:{limit:5},printLocalChangesOptions:{limit:5},silent:!0}),p({ensureEmptyLineAbove:!0,content:`${m.greenBright(w.tick)} Sync completed ${j()}`}),o._[0]){case"model":await H(t,{args:o,filesync:e});break;case"action":await X(t,{args:o,filesync:e});break;case"route":await z(t,{args:o,filesync:e});break;case"field":await q(t,{args:o,filesync:e});break;case"environment":case"env":await Q(t,{args:o,filesync:e});break;default:p(G(t));return}},"run"),I=g(t=>{let o=[],i=[];return t.forEach(a=>{let e=/^(.*):+(.*)$/.exec(a);!e||e.length!==3||!e[1]||!e[2]?o.push(d`${a} is not a valid field definition`):i.push({name:e[1].replace(/:+/g,""),fieldType:e[2]})}),[i,o]},"parseFieldValues"),H=g(async(t,{args:o,filesync:i})=>{let a=i.syncJson,e=o._[1];if(!e)throw new f(d`Failed to add model, missing model path
46
47
 
47
48
  {gray Usage}
48
49
  {cyanBright ggt add model <model_name> [field_name:field_type ...]}`);let r=[];if(o._.length>2){let[c,u]=I(o._.slice(2));if(u.length>0)throw new f(d`
@@ -51,21 +52,21 @@ import{f as O,g as R,h as M,i as j,j as k,k as P,p as b}from"./chunk-M6L2X3GX.js
51
52
  \u2022 `)}
52
53
 
53
54
  {gray Usage}
54
- {cyanBright ggt add model ${e} [field_name:field_type ...]}`);r.push(...c)}let n;try{n=(await a.edit.mutate({mutation:O,variables:{path:e,fields:r.map(c=>({name:c.name,fieldType:c.fieldType}))}})).createModel}catch(c){throw c instanceof y?new h(c):c}p({ensureEmptyLineAbove:!0,content:m.gray("New model created in environment.")}),await i.writeToLocalFilesystem(t,{filesVersion:n.remoteFilesVersion,files:n.changed,delete:[]});let s=T.isSupported?T(e,`https://${a.environment.application.primaryDomain}/edit/${a.environment.name}/model/${e}/schema`):e;p({ensureEmptyLineAbove:!0,content:`${m.greenBright(w.tick)} Model ${m.cyanBright(s)} added successfully.`})},"modelSubCommand"),X=g(async(t,{args:o,filesync:i})=>{let a=i.syncJson,e=o._[1];if(!e)throw new f(d`Failed to add action, missing action path
55
+ {cyanBright ggt add model ${e} [field_name:field_type ...]}`);r.push(...c)}let n;try{n=(await a.edit.mutate({mutation:N,variables:{path:e,fields:r.map(c=>({name:c.name,fieldType:c.fieldType}))}})).createModel}catch(c){throw c instanceof y?new h(c):c}p({ensureEmptyLineAbove:!0,content:m.gray("New model created in environment.")}),await i.writeToLocalFilesystem(t,{filesVersion:n.remoteFilesVersion,files:n.changed,delete:[]});let s=T.isSupported?T(e,`https://${a.environment.application.primaryDomain}/edit/${a.environment.name}/model/${e}/schema`):e;p({ensureEmptyLineAbove:!0,content:`${m.greenBright(w.tick)} Model ${m.cyanBright(s)} added successfully.`})},"modelSubCommand"),X=g(async(t,{args:o,filesync:i})=>{let a=i.syncJson,e=o._[1];if(!e)throw new f(d`Failed to add action, missing action path
55
56
 
56
57
  {gray Usage}
57
58
  {cyanBright ggt add action [CONTEXT]/<action_name>
58
- CONTEXT:Specifies the kind of action. Use "model" for model actions otherwise use "action".}`);let r=await U(t,a.environment),n=await L(t,a.environment),s=e.split("/"),c,u=s.length>1?s.slice(0,s.length-1):s,A=s[s.length-1],V=r.find(l=>{let v=u[u.length-1];return l.apiIdentifier.toUpperCase()===v?.toUpperCase()&&l.namespace?.join("/")===u.slice(0,u.length-1).join("/")}),x=n.find(l=>l.namespace?.join("/")===u.join("/"));if(V&&x){let l=u.join("/");c=await J({choices:["models","actions"],content:d`
59
+ CONTEXT:Specifies the kind of action. Use "model" for model actions otherwise use "action".}`);let r=await k(t,a.environment),n=await J(t,a.environment),s=e.split("/"),c,u=s.length>1?s.slice(0,s.length-1):s,A=s[s.length-1],V=r.find(l=>{let v=u[u.length-1];return l.apiIdentifier.toUpperCase()===v.toUpperCase()&&l.namespace?.join("/")===u.slice(0,u.length-1).join("/")}),x=n.find(l=>l.namespace?.join("/")===u.join("/"));if(V&&x){let l=u.join("/");c=await P({choices:["models","actions"],content:d`
59
60
  {bold Namespace Conflict:} The action '${A}.js' cannot be automatically added due to a namespace conflict.
60
61
 
61
62
  How would you like to proceed?:
62
- `,formatChoice:g(v=>{switch(v){case"models":return`As a Model action in ${m.gray(`models/${l}/${A}.js`)}`;case"actions":return`As an Action in ${m.gray(`actions/${l}/${A}.js`)}`}},"formatChoice")}),p({ensureEmptyLineAbove:!0,content:d`${m.yellowBright(w.info)} You can override the context of the action by specifying the context in the path. For example: {gray ggt add action ${c}/${e}}`})}try{let l=(await a.edit.mutate({mutation:R,variables:{path:c?`${c}/`+e:e}})).createAction;await i.writeToLocalFilesystem(t,{filesVersion:l.remoteFilesVersion,files:l.changed,delete:[]})}catch(l){throw l instanceof y?new h(l):l}p({ensureEmptyLineAbove:!0,content:`Action ${m.cyanBright(e)} added successfully.`})},"actionSubCommand"),z=g(async(t,{args:o,filesync:i})=>{let a=i.syncJson,e=o._[1],r=o._[2];if(!e)throw new f(d`Failed to add route, missing route method
63
+ `,formatChoice:g(v=>{switch(v){case"models":return`As a Model action in ${m.gray(`models/${l}/${A}.js`)}`;case"actions":return`As an Action in ${m.gray(`actions/${l}/${A}.js`)}`}},"formatChoice")}),p({ensureEmptyLineAbove:!0,content:d`${m.yellowBright(w.info)} You can override the context of the action by specifying the context in the path. For example: {gray ggt add action ${c}/${e}}`})}try{let l=(await a.edit.mutate({mutation:U,variables:{path:c?`${c}/`+e:e}})).createAction;await i.writeToLocalFilesystem(t,{filesVersion:l.remoteFilesVersion,files:l.changed,delete:[]})}catch(l){throw l instanceof y?new h(l):l}p({ensureEmptyLineAbove:!0,content:`Action ${m.cyanBright(e)} added successfully.`})},"actionSubCommand"),z=g(async(t,{args:o,filesync:i})=>{let a=i.syncJson,e=o._[1],r=o._[2];if(!e)throw new f(d`Failed to add route, missing route method
63
64
 
64
65
  {gray Usage}
65
66
  {cyanBright ggt add route <HTTP_METHOD> <route_path>}`);if(!r)throw new f(d`Failed to add route, missing route path
66
67
 
67
68
  {gray Usage}
68
- {cyanBright ggt add route ${e} <route_path>}`);try{let n=(await a.edit.mutate({mutation:M,variables:{method:e,path:r}})).createRoute;await i.writeToLocalFilesystem(t,{filesVersion:n.remoteFilesVersion,files:n.changed,delete:[]})}catch(n){throw n instanceof y?new h(n):n}p({ensureEmptyLineAbove:!0,content:`Route ${m.cyanBright(r)} added successfully.`})},"routeSubCommand"),q=g(async(t,{args:o,filesync:i})=>{let a=i.syncJson,e=o._[1]?.split("/");if(!e)throw new f(d`Failed to add field, invalid field path definition
69
+ {cyanBright ggt add route ${e} <route_path>}`);try{let n=(await a.edit.mutate({mutation:L,variables:{method:e,path:r}})).createRoute;await i.writeToLocalFilesystem(t,{filesVersion:n.remoteFilesVersion,files:n.changed,delete:[]})}catch(n){throw n instanceof y?new h(n):n}p({ensureEmptyLineAbove:!0,content:`Route ${m.cyanBright(r)} added successfully.`})},"routeSubCommand"),q=g(async(t,{args:o,filesync:i})=>{let a=i.syncJson,e=o._.at(1)?.split("/");if(!e)throw new f(d`Failed to add field, invalid field path definition
69
70
 
70
71
  {gray Usage}
71
72
  {cyanBright ggt add field <model_path>/<field_name>:<field_type>}`);let r=[];if(e[1]){let[n,s]=I([e[1]]);if(s.length>0)throw new f(d`
@@ -77,5 +78,5 @@ import{f as O,g as R,h as M,i as j,j as k,k as P,p as b}from"./chunk-M6L2X3GX.js
77
78
  {cyanBright ggt add field ${e[0]}/<field_name>:<field_type>}`);r.push(...n)}else throw new f(d`Failed to add field, invalid field definition
78
79
 
79
80
  {gray Usage}
80
- {cyanBright ggt add field ${e[0]}/<field_name>:<field_type>}`);try{let n=(await a.edit.mutate({mutation:j,variables:{path:e[0],fields:r.map(s=>({name:s.name,fieldType:s.fieldType}))}})).createModelFields;await i.writeToLocalFilesystem(t,{filesVersion:n.remoteFilesVersion,files:n.changed,delete:[]})}catch(n){throw n instanceof y?new h(n):n}p({ensureEmptyLineAbove:!0,content:`Field ${m.cyanBright(r[0]?.name)} added successfully.`})},"fieldSubCommand"),Q=g(async(t,{args:o,filesync:i})=>{let a=i.syncJson,e=o._[1]??Y();try{await a.edit.mutate({mutation:k,variables:{environment:{slug:e,sourceSlug:a.environment.name}}})}catch(n){throw n instanceof y?new h(n):n}if(p({ensureEmptyLineAbove:!0,content:`Environment ${m.cyanBright(e)} added successfully.`}),await _.load(t,{command:"pull",args:{_:[],"--app":void 0,"--allow-unknown-directory":void 0,"--allow-different-app":void 0,"--env":e},directory:await E(process.cwd())})){let n=new b(a),s=await n.hashes(t);if(s.environmentChangesToPull.size===0){p({ensureEmptyLineAbove:!0,content:"Nothing to pull."});return}s.localChangesToPush.size>0&&await n.print(t,{hashes:s}),await n.pull(t,{hashes:s,force:!0})}},"envSubCommand"),Y=g(()=>{let t=new Date;return`env-${t.toISOString().slice(0,10).replace(/-/g,"")}-${t.toLocaleTimeString("en-US",{hour12:!1}).replace(/:/g,"")}`},"makeDefaultEnvName");export{h as AddClientError,ue as args,fe as run,G as usage};
81
- //# sourceMappingURL=add-KJLV4API.js.map
81
+ {cyanBright ggt add field ${e[0]}/<field_name>:<field_type>}`);try{let n=(await a.edit.mutate({mutation:O,variables:{path:e[0],fields:r.map(s=>({name:s.name,fieldType:s.fieldType}))}})).createModelFields;await i.writeToLocalFilesystem(t,{filesVersion:n.remoteFilesVersion,files:n.changed,delete:[]})}catch(n){throw n instanceof y?new h(n):n}p({ensureEmptyLineAbove:!0,content:`Field ${m.cyanBright(r[0]?.name)} added successfully.`})},"fieldSubCommand"),Q=g(async(t,{args:o,filesync:i})=>{let a=i.syncJson,e=o._[1]??Y();try{await a.edit.mutate({mutation:R,variables:{environment:{slug:e,sourceSlug:a.environment.name}}})}catch(n){throw n instanceof y?new h(n):n}if(p({ensureEmptyLineAbove:!0,content:`Environment ${m.cyanBright(e)} added successfully.`}),await _.load(t,{command:"pull",args:{_:[],"--app":void 0,"--allow-unknown-directory":void 0,"--allow-different-app":void 0,"--env":e},directory:await E(process.cwd())})){let n=new b(a),s=await n.hashes(t);if(s.environmentChangesToPull.size===0){p({ensureEmptyLineAbove:!0,content:"Nothing to pull."});return}s.localChangesToPush.size>0&&await n.print(t,{hashes:s}),await n.pull(t,{hashes:s,force:!0})}},"envSubCommand"),Y=g(()=>{let t=new Date;return`env-${t.toISOString().slice(0,10).replace(/-/g,"")}-${t.toLocaleTimeString("en-US",{hour12:!1}).replace(/:/g,"")}`},"makeDefaultEnvName");export{h as AddClientError,ue as args,fe as run,G as usage};
82
+ //# sourceMappingURL=add-7MLI3TCY.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/commands/add.ts"],
4
+ "sourcesContent": ["import chalk from \"chalk\";\nimport terminalLink from \"terminal-link\";\n\nimport { getGlobalActions, getModels } from \"../services/app/app.js\";\nimport {\n CREATE_ACTION_MUTATION,\n CREATE_ENVIRONMENT_MUTATION,\n CREATE_MODEL_FIELDS_MUTATION,\n CREATE_MODEL_MUTATION,\n CREATE_ROUTE_MUTATION,\n} from \"../services/app/edit/operation.js\";\nimport { ClientError } from \"../services/app/error.js\";\nimport { ArgError, type ArgsDefinitionResult } from \"../services/command/arg.js\";\nimport type { Run, Usage } from \"../services/command/command.js\";\nimport type { Context } from \"../services/command/context.js\";\nimport { UnknownDirectoryError } from \"../services/filesync/error.js\";\nimport { FileSync } from \"../services/filesync/filesync.js\";\nimport { SyncJson, SyncJsonArgs, loadSyncJsonDirectory } from \"../services/filesync/sync-json.js\";\nimport { println } from \"../services/output/print.js\";\nimport { GGTError, IsBug } from \"../services/output/report.js\";\nimport { select } from \"../services/output/select.js\";\nimport { sprint } from \"../services/output/sprint.js\";\nimport { symbol } from \"../services/output/symbols.js\";\nimport { ts } from \"../services/output/timestamp.js\";\nimport { uniq } from \"../services/util/collection.js\";\nimport { isGraphQLErrors } from \"../services/util/is.js\";\n\nexport class AddClientError extends GGTError {\n isBug = IsBug.NO;\n\n constructor(error: ClientError) {\n let template = \"\";\n\n if (isGraphQLErrors(error.cause)) {\n const errors = uniq(error.cause.map((x) => x.message));\n\n template = sprint` \u2022 ${errors.map((e) => e.split(\"\\n\").join(\"\\n\u200E \u2022 \")).join(\"\\n\")}`; // Why in gods name do I have to put an empty character for the tab to work?\n } else {\n template = sprint`${error.cause}`;\n }\n\n super(template);\n }\n\n protected override render(): string {\n return `${chalk.redBright(symbol.cross)} Failed to add:\\n ` + this.message;\n }\n}\n\nexport type AddArgs = typeof args;\nexport type AddArgsResult = ArgsDefinitionResult<AddArgs>;\n\nexport const args = { ...SyncJsonArgs };\n\nexport const usage: Usage = () => {\n return sprint`\n Adds models, fields, actions and routes to your app.\n\n This command first performs a sync to ensure that your local and environment directories match, changes are tracked since last sync.\n If any conflicts are detected, they must be resolved before adding models, fields, actions or routes.\n\n {gray Usage}\n ggt add model <model_name> [field_name:field_type ...]\n\n ggt add action [CONTEXT]/<action_name>\n CONTEXT:Specifies the kind of action. Use \"model\" for model actions otherwise use \"action\".\n\n ggt add route <HTTP_METHOD> <route_path>\n\n ggt add field <model_path>/<field_name>:<field_type>\n\n {gray Options}\n -a, --app <app_name> Selects the app to add to. Defaults to the app synced to the current directory, if there is one.\n -e, --env <env_name> Selects the environment to add to. Defaults to the environment synced to the current directory, if there is one.\n\n {gray Examples}\n Add a new model 'post' with out fields:\n {cyanBright $ ggt add model modelA}\n\n Add a new model 'post' with 2 new 'string' type fields 'title' and 'body':\n {cyanBright $ ggt add model post title:string body:string}\n\n Add a new 'boolean' type field 'published' to an existing model\n {cyanBright ggt add field post/published:boolean}\n\n Add new action 'publish' to the 'post' model:\n {cyanBright ggt add action model/post/publish}\n\n Add a new action 'audit'\n {cyanBright ggt add action action/audit}\n\n Add a new route 'howdy'\n {cyanBright ggt add route GET howdy}\n\n Clone the \\`development\\` environment into a new \\`staging\\` environment\n {cyanBright ggt add environment staging --environment development}\n `;\n};\n\nexport const run: Run<AddArgs> = async (ctx, args) => {\n const directory = await loadSyncJsonDirectory(process.cwd());\n const syncJson = await SyncJson.load(ctx, { command: \"add\", args, directory });\n if (!syncJson) {\n throw new UnknownDirectoryError({ command: \"add\", args, directory });\n }\n\n const filesync = new FileSync(syncJson);\n const hashes = await filesync.hashes(ctx, { silent: true });\n\n if (!hashes.inSync) {\n await filesync.merge(ctx, {\n hashes,\n printEnvironmentChangesOptions: { limit: 5 },\n printLocalChangesOptions: { limit: 5 },\n silent: true,\n });\n }\n\n println({ ensureEmptyLineAbove: true, content: `${chalk.greenBright(symbol.tick)} Sync completed ${ts()}` });\n\n switch (args._[0]) {\n case \"model\":\n await modelSubCommand(ctx, { args, filesync });\n break;\n case \"action\":\n await actionSubCommand(ctx, { args, filesync });\n break;\n case \"route\":\n await routeSubCommand(ctx, { args, filesync });\n break;\n case \"field\":\n await fieldSubCommand(ctx, { args, filesync });\n break;\n case \"environment\":\n case \"env\":\n await envSubCommand(ctx, { args, filesync });\n break;\n default:\n println(usage(ctx));\n return;\n }\n};\n\nconst parseFieldValues = (fields: string[]): [{ name: string; fieldType: string }[], problems: string[]] => {\n const problems: string[] = [];\n const modelFields: { name: string; fieldType: string }[] = [];\n\n fields.forEach((field) => {\n const matches = /^(.*):+(.*)$/.exec(field);\n if (!matches || matches.length !== 3 || !matches[1] || !matches[2]) {\n problems.push(sprint`${field} is not a valid field definition`);\n } else {\n modelFields.push({ name: matches[1].replace(/:+/g, \"\"), fieldType: matches[2] });\n }\n });\n\n return [modelFields, problems];\n};\n\nconst modelSubCommand = async (ctx: Context, { args, filesync }: { args: AddArgsResult; filesync: FileSync }): Promise<void> => {\n const syncJson = filesync.syncJson;\n const modelApiIdentifier = args._[1];\n\n if (!modelApiIdentifier) {\n throw new ArgError(sprint`Failed to add model, missing model path\n\n {gray Usage}\n {cyanBright ggt add model <model_name> [field_name:field_type ...]}`);\n }\n\n const modelFieldsList: { name: string; fieldType: string }[] = [];\n if (args._.length > 2) {\n const [modelFields, problems] = parseFieldValues(args._.slice(2));\n\n if (problems.length > 0) {\n throw new ArgError(sprint`\n Failed to add model:\n \u2022 ${problems.join(\"\\n \u2022 \")}\n\n {gray Usage}\n {cyanBright ggt add model ${modelApiIdentifier} [field_name:field_type ...]}`);\n }\n\n modelFieldsList.push(...modelFields);\n }\n\n let result;\n\n try {\n result = (\n await syncJson.edit.mutate({\n mutation: CREATE_MODEL_MUTATION,\n variables: {\n path: modelApiIdentifier,\n fields: modelFieldsList.map((fields) => ({ name: fields.name, fieldType: fields.fieldType })),\n },\n })\n ).createModel;\n } catch (error) {\n if (error instanceof ClientError) {\n throw new AddClientError(error);\n } else {\n throw error;\n }\n }\n\n println({ ensureEmptyLineAbove: true, content: chalk.gray(\"New model created in environment.\") });\n\n await filesync.writeToLocalFilesystem(ctx, { filesVersion: result.remoteFilesVersion, files: result.changed, delete: [] });\n\n const modelPrintout = terminalLink.isSupported\n ? terminalLink(\n modelApiIdentifier,\n `https://${syncJson.environment.application.primaryDomain}/edit/${syncJson.environment.name}/model/${modelApiIdentifier}/schema`,\n )\n : modelApiIdentifier;\n\n println({\n ensureEmptyLineAbove: true,\n content: `${chalk.greenBright(symbol.tick)} Model ${chalk.cyanBright(modelPrintout)} added successfully.`,\n });\n};\n\nconst actionSubCommand = async (ctx: Context, { args, filesync }: { args: AddArgsResult; filesync: FileSync }): Promise<void> => {\n const syncJson = filesync.syncJson;\n const path = args._[1];\n\n if (!path) {\n throw new ArgError(sprint`Failed to add action, missing action path\n\n {gray Usage}\n {cyanBright ggt add action [CONTEXT]/<action_name>\n CONTEXT:Specifies the kind of action. Use \"model\" for model actions otherwise use \"action\".}`);\n }\n\n const models = await getModels(ctx, syncJson.environment);\n const globalActions = await getGlobalActions(ctx, syncJson.environment);\n const splitPath = path.split(\"/\");\n\n let overrideContextAction: \"models\" | \"actions\" | undefined;\n\n const parsedPaths = splitPath.length > 1 ? splitPath.slice(0, splitPath.length - 1) : splitPath;\n const parsedAction = splitPath[splitPath.length - 1];\n\n const conflictingModel = models.find((model) => {\n const modelName = parsedPaths[parsedPaths.length - 1];\n\n return (\n model.apiIdentifier.toUpperCase() === modelName.toUpperCase() &&\n model.namespace?.join(\"/\") === parsedPaths.slice(0, parsedPaths.length - 1).join(\"/\")\n );\n });\n\n const conflictingActionNamespace = globalActions.find((action) => {\n return action.namespace?.join(\"/\") === parsedPaths.join(\"/\");\n });\n\n if (conflictingModel && conflictingActionNamespace) {\n const joinedParsedPaths = parsedPaths.join(\"/\");\n overrideContextAction = await select({\n choices: [\"models\", \"actions\"] as const,\n content: sprint`\n {bold Namespace Conflict:} The action '${parsedAction}.js' cannot be automatically added due to a namespace conflict.\n\n How would you like to proceed?:\n `,\n formatChoice: (choice) => {\n switch (choice) {\n case \"models\": {\n return `As a Model action in ${chalk.gray(`models/${joinedParsedPaths}/${parsedAction}.js`)}`;\n }\n case \"actions\": {\n return `As an Action in ${chalk.gray(`actions/${joinedParsedPaths}/${parsedAction}.js`)}`;\n }\n }\n },\n });\n\n println({\n ensureEmptyLineAbove: true,\n content: sprint`${chalk.yellowBright(symbol.info)} You can override the context of the action by specifying the context in the path. For example: {gray ggt add action ${overrideContextAction}/${path}}`,\n });\n }\n\n try {\n const result = (\n await syncJson.edit.mutate({\n mutation: CREATE_ACTION_MUTATION,\n variables: { path: overrideContextAction ? `${overrideContextAction}/` + path : path },\n })\n ).createAction;\n\n await filesync.writeToLocalFilesystem(ctx, { filesVersion: result.remoteFilesVersion, files: result.changed, delete: [] });\n } catch (error) {\n if (error instanceof ClientError) {\n throw new AddClientError(error);\n } else {\n throw error;\n }\n }\n\n println({ ensureEmptyLineAbove: true, content: `Action ${chalk.cyanBright(path)} added successfully.` });\n};\n\nconst routeSubCommand = async (ctx: Context, { args, filesync }: { args: AddArgsResult; filesync: FileSync }): Promise<void> => {\n const syncJson = filesync.syncJson;\n const routeMethod = args._[1];\n const routePath = args._[2];\n\n if (!routeMethod) {\n throw new ArgError(sprint`Failed to add route, missing route method\n\n {gray Usage}\n {cyanBright ggt add route <HTTP_METHOD> <route_path>}`);\n }\n\n if (!routePath) {\n throw new ArgError(sprint`Failed to add route, missing route path\n\n {gray Usage}\n {cyanBright ggt add route ${routeMethod} <route_path>}`);\n }\n\n try {\n const result = (await syncJson.edit.mutate({ mutation: CREATE_ROUTE_MUTATION, variables: { method: routeMethod, path: routePath } }))\n .createRoute;\n\n await filesync.writeToLocalFilesystem(ctx, { filesVersion: result.remoteFilesVersion, files: result.changed, delete: [] });\n } catch (error) {\n if (error instanceof ClientError) {\n throw new AddClientError(error);\n } else {\n throw error;\n }\n }\n\n println({ ensureEmptyLineAbove: true, content: `Route ${chalk.cyanBright(routePath)} added successfully.` });\n};\n\nconst fieldSubCommand = async (ctx: Context, { args, filesync }: { args: AddArgsResult; filesync: FileSync }): Promise<void> => {\n const syncJson = filesync.syncJson;\n\n const splitPathAndField = args._.at(1)?.split(\"/\");\n\n if (!splitPathAndField) {\n throw new ArgError(sprint`Failed to add field, invalid field path definition\n\n {gray Usage}\n {cyanBright ggt add field <model_path>/<field_name>:<field_type>}`);\n }\n\n const modelFieldsList: { name: string; fieldType: string }[] = [];\n\n if (splitPathAndField[1]) {\n const [modelFields, problems] = parseFieldValues([splitPathAndField[1]]);\n\n if (problems.length > 0) {\n throw new ArgError(sprint`\n Failed to add field:\n \u2022 ${problems.join(\"\\n \u2022\")}\n\n {gray Usage}\n {cyanBright ggt add field ${splitPathAndField[0]}/<field_name>:<field_type>}`);\n }\n\n modelFieldsList.push(...modelFields);\n } else {\n throw new ArgError(sprint`Failed to add field, invalid field definition\n\n {gray Usage}\n {cyanBright ggt add field ${splitPathAndField[0]}/<field_name>:<field_type>}`);\n }\n\n try {\n const result = (\n await syncJson.edit.mutate({\n mutation: CREATE_MODEL_FIELDS_MUTATION,\n variables: {\n // oxlint-disable-next-line no-non-null-assertion\n path: splitPathAndField[0]!,\n fields: modelFieldsList.map((field) => ({ name: field.name, fieldType: field.fieldType })),\n },\n })\n ).createModelFields;\n\n await filesync.writeToLocalFilesystem(ctx, { filesVersion: result.remoteFilesVersion, files: result.changed, delete: [] });\n } catch (error) {\n if (error instanceof ClientError) {\n throw new AddClientError(error);\n } else {\n throw error;\n }\n }\n\n println({ ensureEmptyLineAbove: true, content: `Field ${chalk.cyanBright(modelFieldsList[0]?.name)} added successfully.` });\n};\n\nconst envSubCommand = async (ctx: Context, { args, filesync }: { args: AddArgsResult; filesync: FileSync }): Promise<void> => {\n const syncJson = filesync.syncJson;\n const newEnvName = args._[1] ?? makeDefaultEnvName();\n\n try {\n await syncJson.edit.mutate({\n mutation: CREATE_ENVIRONMENT_MUTATION,\n variables: { environment: { slug: newEnvName, sourceSlug: syncJson.environment.name } },\n });\n } catch (error) {\n if (error instanceof ClientError) {\n throw new AddClientError(error);\n } else {\n throw error;\n }\n }\n\n println({ ensureEmptyLineAbove: true, content: `Environment ${chalk.cyanBright(newEnvName)} added successfully.` });\n\n // Try to switch to newly made env\n const pullFromNewEnvSyncJson = await SyncJson.load(ctx, {\n command: \"pull\",\n args: { _: [], \"--app\": undefined, \"--allow-unknown-directory\": undefined, \"--allow-different-app\": undefined, \"--env\": newEnvName },\n directory: await loadSyncJsonDirectory(process.cwd()),\n });\n if (pullFromNewEnvSyncJson) {\n const filesync = new FileSync(syncJson);\n const hashes = await filesync.hashes(ctx);\n if (hashes.environmentChangesToPull.size === 0) {\n println({ ensureEmptyLineAbove: true, content: \"Nothing to pull.\" });\n return;\n }\n if (hashes.localChangesToPush.size > 0) {\n // show them the local changes they will discard\n await filesync.print(ctx, { hashes });\n }\n await filesync.pull(ctx, { hashes, force: true });\n }\n};\n\n/**\n * Creates a default environment name based on the current date and time.\n */\nconst makeDefaultEnvName = (): string => {\n const currentDate = new Date();\n return `env-${currentDate.toISOString().slice(0, 10).replace(/-/g, \"\")}-${currentDate.toLocaleTimeString(\"en-US\", { hour12: false }).replace(/:/g, \"\")}`;\n};\n"],
5
+ "mappings": "2oBAAAA,IA2BO,IAAMC,EAAN,cAA6BC,CAAS,CA3B7C,MA2B6C,CAAAC,EAAA,uBAC3C,MAAQC,EAAM,GAEd,YAAYC,EAAoB,CAC9B,IAAIC,EAAW,GAEf,GAAIC,EAAgBF,EAAM,KAAK,EAAG,CAChC,IAAMG,EAASC,EAAKJ,EA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AAE,OAAQ,EAAM,CAAC,EAAE,QAAQ,KAAM,EAAE,CAAC,EACxJ,EAH2B",
6
+ "names": ["init_cjs", "AddClientError", "GGTError", "__name", "IsBug", "error", "template", "isGraphQLErrors", "errors", "uniq", "x", "sprint", "source_default", "symbol", "args", "SyncJsonArgs", "usage", "run", "ctx", "directory", "loadSyncJsonDirectory", "syncJson", "SyncJson", "UnknownDirectoryError", "filesync", "FileSync", "hashes", "println", "ts", "modelSubCommand", "actionSubCommand", "routeSubCommand", "fieldSubCommand", "envSubCommand", "parseFieldValues", "fields", "problems", "modelFields", "field", "matches", "modelApiIdentifier", "ArgError", "modelFieldsList", "result", "CREATE_MODEL_MUTATION", "ClientError", "modelPrintout", "terminalLink", "path", "models", "getModels", "globalActions", "getGlobalActions", "splitPath", "overrideContextAction", "parsedPaths", "parsedAction", "conflictingModel", "model", "modelName", "conflictingActionNamespace", "action", "joinedParsedPaths", "select", "choice", "CREATE_ACTION_MUTATION", "routeMethod", "routePath", "CREATE_ROUTE_MUTATION", "splitPathAndField", "CREATE_MODEL_FIELDS_MUTATION", "newEnvName", "makeDefaultEnvName", "CREATE_ENVIRONMENT_MUTATION", "currentDate"]
7
+ }
@@ -0,0 +1,11 @@
1
+ import{c as s,e as a}from"./chunk-TGCJ6TMW.js";import"./chunk-L2XBSR7G.js";import{R as u}from"./chunk-IQSZEOYY.js";import"./chunk-GZTHIOXS.js";import"./chunk-72J7X5LR.js";import{a as d}from"./chunk-X4XSYLCE.js";import{J as p,K as h,ra as l,ta as g}from"./chunk-ALSXPCRD.js";import"./chunk-GFQYFEEH.js";import{a as r,f as A,h as f}from"./chunk-7DYQUG5M.js";f();import v from"node:path";var w=A(h(),1);var R={"--force":{type:Boolean}},j=r(()=>l`
2
+ Install or update Gadget agent plugins (AGENTS.md + skills).
3
+
4
+ {gray Usage}
5
+ ggt agent-plugin install [--force]
6
+ ggt agent-plugin update
7
+
8
+ {gray Flags}
9
+ --force Overwrite/reinstall even if already present
10
+ `,"usage"),T=r(async(t,i)=>{let e=i._[0];if(e!=="install"&&e!=="update"){g(j(t));return}let n=process.cwd(),m=await p(".gadget/sync.json",{cwd:n}),y=m?v.join(m,"../.."):n,o=await d.init(y);if(e==="install"){let c=i["--force"]??!1;await s({ctx:t,directory:o,force:c}),await a({ctx:t,directory:o,force:c});return}(!await w.default.pathExists(o.absolute("AGENTS.md"))||await u({exitWhenNo:!1,content:"Overwrite AGENTS.md with latest version?"}))&&await s({ctx:t,directory:o,force:!0}),await a({ctx:t,directory:o,force:!0})},"run");export{R as args,T as run,j as usage};
11
+ //# sourceMappingURL=agent-plugin-543K6WBH.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/commands/agent-plugin.ts"],
4
+ "sourcesContent": ["import path from \"node:path\";\n\nimport { findUp } from \"find-up\";\nimport fs from \"fs-extra\";\n\nimport type { ArgsDefinition } from \"../services/command/arg.js\";\nimport type { Run, Usage } from \"../services/command/command.js\";\nimport { Directory } from \"../services/filesync/directory.js\";\nimport { installAgentsMdScaffold, installGadgetSkillsIntoProject } from \"../services/output/agent-plugin.js\";\nimport { confirm } from \"../services/output/confirm.js\";\nimport { println } from \"../services/output/print.js\";\nimport { sprint } from \"../services/output/sprint.js\";\n\nexport const args = {\n \"--force\": { type: Boolean },\n} satisfies ArgsDefinition;\n\nexport const usage: Usage = () => {\n return sprint`\n Install or update Gadget agent plugins (AGENTS.md + skills).\n\n {gray Usage}\n ggt agent-plugin install [--force]\n ggt agent-plugin update\n\n {gray Flags}\n --force Overwrite/reinstall even if already present\n `;\n};\n\nexport const run: Run<typeof args> = async (ctx, args): Promise<void> => {\n const subcommand = args._[0];\n\n if (subcommand !== \"install\" && subcommand !== \"update\") {\n println(usage(ctx));\n return;\n }\n\n const cwd = process.cwd();\n const syncJsonPath = await findUp(\".gadget/sync.json\", { cwd });\n const projectRoot = syncJsonPath ? path.join(syncJsonPath, \"../..\") : cwd;\n const directory = await Directory.init(projectRoot);\n\n if (subcommand === \"install\") {\n const force = args[\"--force\"] ?? false;\n await installAgentsMdScaffold({ ctx, directory, force });\n await installGadgetSkillsIntoProject({ ctx, directory, force });\n return;\n }\n\n // update\n const hasAgentsMd = await fs.pathExists(directory.absolute(\"AGENTS.md\"));\n if (!hasAgentsMd || (await confirm({ exitWhenNo: false, content: \"Overwrite AGENTS.md with latest version?\" }))) {\n await installAgentsMdScaffold({ ctx, directory, force: true });\n }\n await installGadgetSkillsIntoProject({ ctx, directory, force: true });\n};\n"],
5
+ "mappings": "oWAAAA,IAAA,OAAOC,MAAU,YAGjB,IAAAC,EAAe,SAUR,IAAMC,EAAO,CAClB,UAAW,CAAE,KAAM,OAAQ,CAC7B,EAEaC,EAAeC,EAAA,IACnBC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IADmB,SAafC,EAAwBF,EAAA,MAAOG,EAAKL,IAAwB,CACvE,IAAMM,EAAaN,EAAK,EAAE,CAAC,EAE3B,GAAIM,IAAe,WAAaA,IAAe,SAAU,CACvDC,EAAQN,EAAMI,CAAG,CAAC,EAClB,MACF,CAEA,IAAMG,EAAM,QAAQ,IAAI,EAClBC,EAAe,MAAMC,EAAO,oBAAqB,CAAE,IAAAF,CAAI,CAAC,EACxDG,EAAcF,EAAeG,EAAK,KAAKH,EAAc,OAAO,EAAID,EAChEK,EAAY,MAAMC,EAAU,KAAKH,CAAW,EAElD,GAAIL,IAAe,UAAW,CAC5B,IAAMS,EAAQf,EAAK,SAAS,GAAK,GACjC,MAAMgB,EAAwB,CAAE,IAAAX,EAAK,UAAAQ,EAAW,MAAAE,CAAM,CAAC,EACvD,MAAME,EAA+B,CAAE,IAAAZ,EAAK,UAAAQ,EAAW,MAAAE,CAAM,CAAC,EAC9D,MACF,EAII,CADgB,MAAM,EAAAG,QAAG,WAAWL,EAAU,SAAS,WAAW,CAAC,GAClD,MAAMM,EAAQ,CAAE,WAAY,GAAO,QAAS,0CAA2C,CAAC,IAC3G,MAAMH,EAAwB,CAAE,IAAAX,EAAK,UAAAQ,EAAW,MAAO,EAAK,CAAC,EAE/D,MAAMI,EAA+B,CAAE,IAAAZ,EAAK,UAAAQ,EAAW,MAAO,EAAK,CAAC,CACtE,EA1BqC",
6
+ "names": ["init_cjs", "path", "import_fs_extra", "args", "usage", "__name", "sprint", "run", "ctx", "subcommand", "println", "cwd", "syncJsonPath", "findUp", "projectRoot", "path", "directory", "Directory", "force", "installAgentsMdScaffold", "installGadgetSkillsIntoProject", "fs", "confirm"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{f as C,g as b,h as E}from"./chunk-IQSZEOYY.js";import{c as D}from"./chunk-72J7X5LR.js";import{b as N,f as G}from"./chunk-ALSXPCRD.js";import{a as m,d as S,f as T,h as y}from"./chunk-7DYQUG5M.js";var P=S((K,I)=>{y();var k=Symbol("arg flag"),i=class n extends Error{static{m(this,"ArgError")}constructor(e,p){super(e),this.name="ArgError",this.code=p,Object.setPrototypeOf(this,n.prototype)}};function A(n,{argv:e=process.argv.slice(2),permissive:p=!1,stopAtPositional:h=!1}={}){if(!n)throw new i("argument specification object is required","ARG_CONFIG_NO_SPEC");let t={_:[]},s={},f={};for(let r of Object.keys(n)){if(!r)throw new i("argument key cannot be an empty string","ARG_CONFIG_EMPTY_KEY");if(r[0]!=="-")throw new i(`argument key must start with '-' but found: '${r}'`,"ARG_CONFIG_NONOPT_KEY");if(r.length===1)throw new i(`argument key must have a name; singular '-' keys are not allowed: ${r}`,"ARG_CONFIG_NONAME_KEY");if(typeof n[r]=="string"){s[r]=n[r];continue}let l=n[r],a=!1;if(Array.isArray(l)&&l.length===1&&typeof l[0]=="function"){let[u]=l;l=m((c,d,g=[])=>(g.push(u(c,d,g[g.length-1])),g),"type"),a=u===Boolean||u[k]===!0}else if(typeof l=="function")a=l===Boolean||l[k]===!0;else throw new i(`type missing or not a function or valid array type: ${r}`,"ARG_CONFIG_VAD_TYPE");if(r[1]!=="-"&&r.length>2)throw new i(`short argument keys (with a single hyphen) must have only one character: ${r}`,"ARG_CONFIG_SHORTOPT_TOOLONG");f[r]=[l,a]}for(let r=0,l=e.length;r<l;r++){let a=e[r];if(h&&t._.length>0){t._=t._.concat(e.slice(r));break}if(a==="--"){t._=t._.concat(e.slice(r+1));break}if(a.length>1&&a[0]==="-"){let u=a[1]==="-"||a.length===2?[a]:a.slice(1).split("").map(c=>`-${c}`);for(let c=0;c<u.length;c++){let d=u[c],[g,x]=d[1]==="-"?d.split(/=(.*)/,2):[d,void 0],o=g;for(;o in s;)o=s[o];if(!(o in f))if(p){t._.push(d);continue}else throw new i(`unknown or unexpected option: ${g}`,"ARG_UNKNOWN_OPTION");let[w,R]=f[o];if(!R&&c+1<u.length)throw new i(`option requires argument (but was followed by another short argument): ${g}`,"ARG_MISSING_REQUIRED_SHORTARG");if(R)t[o]=w(!0,o,t[o]);else if(x===void 0){if(e.length<r+2||e[r+1].length>1&&e[r+1][0]==="-"&&!(e[r+1].match(/^-?\d*(\.(?=\d))?\d*$/)&&(w===Number||typeof BigInt<"u"&&w===BigInt))){let v=g===o?"":` (alias for ${o})`;throw new i(`option requires argument: ${g}${v}`,"ARG_MISSING_REQUIRED_LONGARG")}t[o]=w(e[r+1],o,t[o]),++r}else t[o]=w(x,o,t[o])}}else t._.push(a)}return t}m(A,"arg");A.flag=n=>(n[k]=!0,n);A.COUNT=A.flag((n,e,p)=>(p||0)+1);A.ArgError=i;I.exports=A});y();var O=T(P(),1);var L=m((n,e)=>{let p={},h={};for(let[t,s]of Object.entries(n)){if(!("type"in s)){p[t]=s;continue}if(p[t]=s.type,h[t]=s.default,s.alias)for(let f of Array.isArray(s.alias)?s.alias:[s.alias])p[f]=t}try{let t=(0,O.default)(p,e);for(let[s,f]of Object.entries(h))G(t[s])&&(t[s]=f);return t}catch(t){throw t instanceof O.default.ArgError&&(t=new _(t.message)),t instanceof b?t:new E(t)}},"parseArgs"),_=class extends b{static{m(this,"ArgError")}isBug=C.NO;render(){return`${N.redBright(D.cross)} `+this.message}};y();import $ from"node:assert";var j=["dev","deploy","status","problems","push","pull","var","env","add","open","list","login","logout","logs","debugger","whoami","configure","agent-plugin","eval","version"],H=m(n=>j.includes(n),"isCommand"),J=m(async n=>{$(H(n),`invalid command: ${n}`);let e;switch(n){case"dev":e=await import("./dev-Y2GLI7EH.js");break;case"deploy":e=await import("./deploy-JCREEGBA.js");break;case"status":e=await import("./status-RJN5ES6S.js");break;case"problems":e=await import("./problems-EZRSHLZT.js");break;case"push":e=await import("./push-5XEEESQQ.js");break;case"pull":e=await import("./pull-R3PMBVOT.js");break;case"var":e=await import("./var-PC6KQUPF.js");break;case"env":e=await import("./env-5OPHX3MC.js");break;case"add":e=await import("./add-7MLI3TCY.js");break;case"open":e=await import("./open-JPAMII4K.js");break;case"list":e=await import("./list-IANT7SNF.js");break;case"login":e=await import("./login-TYRZLN5S.js");break;case"logout":e=await import("./logout-P75XYYZ6.js");break;case"logs":e=await import("./logs-SBMD6JSR.js");break;case"debugger":e=await import("./debugger-VKLUEWIN.js");break;case"whoami":e=await import("./whoami-GKPGPZ3B.js");break;case"configure":e=await import("./configure-PYRXYNGZ.js");break;case"agent-plugin":e=await import("./agent-plugin-543K6WBH.js");break;case"eval":e=await import("./eval-LZPZ6PBQ.js");break;case"version":e=await import("./version-GZJOU2CV.js");break}return e},"importCommand");export{P as a,L as b,_ as c,j as d,H as e,J as f};
2
+ //# sourceMappingURL=chunk-2HJS3KFB.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../node_modules/.pnpm/arg@5.0.2/node_modules/arg/index.js", "../src/services/command/arg.ts", "../src/services/command/command.ts"],
4
- "sourcesContent": ["const flagSymbol = Symbol('arg flag');\n\nclass ArgError extends Error {\n\tconstructor(msg, code) {\n\t\tsuper(msg);\n\t\tthis.name = 'ArgError';\n\t\tthis.code = code;\n\n\t\tObject.setPrototypeOf(this, ArgError.prototype);\n\t}\n}\n\nfunction arg(\n\topts,\n\t{\n\t\targv = process.argv.slice(2),\n\t\tpermissive = false,\n\t\tstopAtPositional = false\n\t} = {}\n) {\n\tif (!opts) {\n\t\tthrow new ArgError(\n\t\t\t'argument specification object is required',\n\t\t\t'ARG_CONFIG_NO_SPEC'\n\t\t);\n\t}\n\n\tconst result = { _: [] };\n\n\tconst aliases = {};\n\tconst handlers = {};\n\n\tfor (const key of Object.keys(opts)) {\n\t\tif (!key) {\n\t\t\tthrow new ArgError(\n\t\t\t\t'argument key cannot be an empty string',\n\t\t\t\t'ARG_CONFIG_EMPTY_KEY'\n\t\t\t);\n\t\t}\n\n\t\tif (key[0] !== '-') {\n\t\t\tthrow new ArgError(\n\t\t\t\t`argument key must start with '-' but found: '${key}'`,\n\t\t\t\t'ARG_CONFIG_NONOPT_KEY'\n\t\t\t);\n\t\t}\n\n\t\tif (key.length === 1) {\n\t\t\tthrow new ArgError(\n\t\t\t\t`argument key must have a name; singular '-' keys are not allowed: ${key}`,\n\t\t\t\t'ARG_CONFIG_NONAME_KEY'\n\t\t\t);\n\t\t}\n\n\t\tif (typeof opts[key] === 'string') {\n\t\t\taliases[key] = opts[key];\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet type = opts[key];\n\t\tlet isFlag = false;\n\n\t\tif (\n\t\t\tArray.isArray(type) &&\n\t\t\ttype.length === 1 &&\n\t\t\ttypeof type[0] === 'function'\n\t\t) {\n\t\t\tconst [fn] = type;\n\t\t\ttype = (value, name, prev = []) => {\n\t\t\t\tprev.push(fn(value, name, prev[prev.length - 1]));\n\t\t\t\treturn prev;\n\t\t\t};\n\t\t\tisFlag = fn === Boolean || fn[flagSymbol] === true;\n\t\t} else if (typeof type === 'function') {\n\t\t\tisFlag = type === Boolean || type[flagSymbol] === true;\n\t\t} else {\n\t\t\tthrow new ArgError(\n\t\t\t\t`type missing or not a function or valid array type: ${key}`,\n\t\t\t\t'ARG_CONFIG_VAD_TYPE'\n\t\t\t);\n\t\t}\n\n\t\tif (key[1] !== '-' && key.length > 2) {\n\t\t\tthrow new ArgError(\n\t\t\t\t`short argument keys (with a single hyphen) must have only one character: ${key}`,\n\t\t\t\t'ARG_CONFIG_SHORTOPT_TOOLONG'\n\t\t\t);\n\t\t}\n\n\t\thandlers[key] = [type, isFlag];\n\t}\n\n\tfor (let i = 0, len = argv.length; i < len; i++) {\n\t\tconst wholeArg = argv[i];\n\n\t\tif (stopAtPositional && result._.length > 0) {\n\t\t\tresult._ = result._.concat(argv.slice(i));\n\t\t\tbreak;\n\t\t}\n\n\t\tif (wholeArg === '--') {\n\t\t\tresult._ = result._.concat(argv.slice(i + 1));\n\t\t\tbreak;\n\t\t}\n\n\t\tif (wholeArg.length > 1 && wholeArg[0] === '-') {\n\t\t\t/* eslint-disable operator-linebreak */\n\t\t\tconst separatedArguments =\n\t\t\t\twholeArg[1] === '-' || wholeArg.length === 2\n\t\t\t\t\t? [wholeArg]\n\t\t\t\t\t: wholeArg\n\t\t\t\t\t\t\t.slice(1)\n\t\t\t\t\t\t\t.split('')\n\t\t\t\t\t\t\t.map((a) => `-${a}`);\n\t\t\t/* eslint-enable operator-linebreak */\n\n\t\t\tfor (let j = 0; j < separatedArguments.length; j++) {\n\t\t\t\tconst arg = separatedArguments[j];\n\t\t\t\tconst [originalArgName, argStr] =\n\t\t\t\t\targ[1] === '-' ? arg.split(/=(.*)/, 2) : [arg, undefined];\n\n\t\t\t\tlet argName = originalArgName;\n\t\t\t\twhile (argName in aliases) {\n\t\t\t\t\targName = aliases[argName];\n\t\t\t\t}\n\n\t\t\t\tif (!(argName in handlers)) {\n\t\t\t\t\tif (permissive) {\n\t\t\t\t\t\tresult._.push(arg);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new ArgError(\n\t\t\t\t\t\t\t`unknown or unexpected option: ${originalArgName}`,\n\t\t\t\t\t\t\t'ARG_UNKNOWN_OPTION'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst [type, isFlag] = handlers[argName];\n\n\t\t\t\tif (!isFlag && j + 1 < separatedArguments.length) {\n\t\t\t\t\tthrow new ArgError(\n\t\t\t\t\t\t`option requires argument (but was followed by another short argument): ${originalArgName}`,\n\t\t\t\t\t\t'ARG_MISSING_REQUIRED_SHORTARG'\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (isFlag) {\n\t\t\t\t\tresult[argName] = type(true, argName, result[argName]);\n\t\t\t\t} else if (argStr === undefined) {\n\t\t\t\t\tif (\n\t\t\t\t\t\targv.length < i + 2 ||\n\t\t\t\t\t\t(argv[i + 1].length > 1 &&\n\t\t\t\t\t\t\targv[i + 1][0] === '-' &&\n\t\t\t\t\t\t\t!(\n\t\t\t\t\t\t\t\targv[i + 1].match(/^-?\\d*(\\.(?=\\d))?\\d*$/) &&\n\t\t\t\t\t\t\t\t(type === Number ||\n\t\t\t\t\t\t\t\t\t// eslint-disable-next-line no-undef\n\t\t\t\t\t\t\t\t\t(typeof BigInt !== 'undefined' && type === BigInt))\n\t\t\t\t\t\t\t))\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst extended =\n\t\t\t\t\t\t\toriginalArgName === argName ? '' : ` (alias for ${argName})`;\n\t\t\t\t\t\tthrow new ArgError(\n\t\t\t\t\t\t\t`option requires argument: ${originalArgName}${extended}`,\n\t\t\t\t\t\t\t'ARG_MISSING_REQUIRED_LONGARG'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tresult[argName] = type(argv[i + 1], argName, result[argName]);\n\t\t\t\t\t++i;\n\t\t\t\t} else {\n\t\t\t\t\tresult[argName] = type(argStr, argName, result[argName]);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tresult._.push(wholeArg);\n\t\t}\n\t}\n\n\treturn result;\n}\n\narg.flag = (fn) => {\n\tfn[flagSymbol] = true;\n\treturn fn;\n};\n\n// Utility types\narg.COUNT = arg.flag((v, name, existingCount) => (existingCount || 0) + 1);\n\n// Expose error class\narg.ArgError = ArgError;\n\nmodule.exports = arg;\n", "import arg from \"arg\";\nimport chalk from \"chalk\";\nimport type { Simplify } from \"type-fest\";\nimport { GGTError, IsBug, UnexpectedError } from \"../output/report.js\";\nimport { symbol } from \"../output/symbols.js\";\nimport { isNil } from \"../util/is.js\";\n\nexport type ArgsDefinition = Record<string, ArgDefinition>;\n\ntype ArgDefinition<Handler extends arg.Handler = arg.Handler> =\n | Handler\n | {\n type: Handler;\n alias?: string | string[];\n default?: ReturnType<Handler>;\n };\n\nexport type ParseArgsOptions = {\n /**\n * A list of arguments to parse.\n */\n argv?: string[];\n\n /**\n * When permissive set to `true`, arg will push any unknown arguments\n * onto the \"extra\" argument array (`ctx.args._`) instead of throwing\n * an error about an unknown flag.\n *\n * @default false\n */\n permissive?: boolean;\n\n /**\n * When stopAtPositional is set to true, context will stop parsing at\n * the first positional argument.\n *\n * @default false\n */\n stopAtPositional?: boolean;\n};\n\nexport const parseArgs = <Args extends ArgsDefinition>(args: Args, options?: arg.Options): ArgsDefinitionResult<Args> => {\n const spec: arg.Spec = {};\n const defaultValues: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(args)) {\n if (!(\"type\" in value)) {\n spec[key] = value;\n continue;\n }\n\n spec[key] = value.type;\n defaultValues[key] = value.default;\n\n if (value.alias) {\n for (const alias of Array.isArray(value.alias) ? value.alias : [value.alias]) {\n spec[alias] = key;\n }\n }\n }\n\n try {\n const parsed = arg(spec, options);\n for (const [key, value] of Object.entries(defaultValues)) {\n if (isNil(parsed[key])) {\n parsed[key] = value as never;\n }\n }\n return parsed as ArgsDefinitionResult<Args>;\n } catch (error: unknown) {\n if (error instanceof arg.ArgError) {\n // convert arg.ArgError to GGTError\n // eslint-disable-next-line no-ex-assign\n error = new ArgError(error.message);\n }\n if (error instanceof GGTError) {\n throw error;\n }\n throw new UnexpectedError(error);\n }\n};\n\nexport class ArgError extends GGTError {\n isBug = IsBug.NO;\n\n protected override render(): string {\n return `${chalk.redBright(symbol.cross)} ` + this.message;\n }\n}\n\n/**\n * Turns this:\n * ```ts\n * type Args = {\n * \"--string\": { type: String; alias: \"s\" };\n * \"--number\": { type: Number; default: 42 };\n * };\n * ```\n *\n * Into this:\n * ```ts\n * type Result = {\n * \"--string\": string | undefined;\n * \"--number\": number;\n * };\n * ```\n */\nexport type ArgsDefinitionResult<Args extends ArgsDefinition, Keys extends keyof Args = keyof Args> = Simplify<{\n [Key in Keys]: Args[Key] extends ArgDefinition<infer Handler>\n ? Args[Key] extends { default: unknown }\n ? NonNullable<ReturnType<Handler>>\n : ReturnType<Handler> | undefined\n : never;\n}> & { _: string[] };\n", "import assert from \"node:assert\";\nimport type { EmptyObject, Promisable } from \"type-fest\";\nimport type { ArgsDefinition, ArgsDefinitionResult } from \"./arg.js\";\nimport type { Context } from \"./context.js\";\n\n/**\n * The list of available commands.\n *\n * 1. Every command corresponds to a file inside of src/commands/\n * 2. The order determines the order of commands in the README\n */\nexport const Commands = [\n \"dev\",\n \"deploy\",\n \"status\",\n \"push\",\n \"pull\",\n \"add\",\n \"open\",\n \"list\",\n \"login\",\n \"logout\",\n \"logs\",\n \"whoami\",\n \"configure\",\n \"version\",\n] as const;\n\n/**\n * One of the commands in {@link Commands}.\n */\nexport type Command = (typeof Commands)[number];\n\n/**\n * Checks if a string is a valid command.\n *\n * @param command - The string to check\n * @returns Whether the string is a valid command\n */\nexport const isCommand = (command: string): command is Command => {\n return Commands.includes(command as Command);\n};\n\n/**\n * A command module is a file in the src/commands/ directory.\n */\nexport type CommandModule<Args extends ArgsDefinition = EmptyObject> = {\n /**\n * The command's {@link ArgsDefinition args}.\n */\n args?: Args;\n\n /**\n * The command's {@link Usage usage}.\n */\n usage: Usage;\n\n /**\n * The command's {@link Run run} function.\n */\n run: Run<Args>;\n};\n\n/**\n * A {@linkcode Command command}'s usage is a function that returns a\n * string describing how to use the command.\n */\nexport type Usage = (ctx: Context) => string;\n\n/**\n * The function that is run when the command is called.\n */\nexport type Run<Args extends ArgsDefinition = EmptyObject> = (ctx: Context, args: ArgsDefinitionResult<Args>) => Promisable<void>;\n\n/**\n * Imports a command module.\n *\n * @param cmd - The command to import\n * @see {@linkcode CommandModule}\n */\nexport const importCommand = async (cmd: Command): Promise<CommandModule> => {\n assert(isCommand(cmd), `invalid command: ${cmd}`);\n\n let module;\n switch (cmd) {\n case \"dev\":\n module = await import(\"../../commands/dev.js\");\n break;\n case \"deploy\":\n module = await import(\"../../commands/deploy.js\");\n break;\n case \"status\":\n module = await import(\"../../commands/status.js\");\n break;\n case \"push\":\n module = await import(\"../../commands/push.js\");\n break;\n case \"pull\":\n module = await import(\"../../commands/pull.js\");\n break;\n case \"add\":\n module = await import(\"../../commands/add.js\");\n break;\n case \"open\":\n module = await import(\"../../commands/open.js\");\n break;\n case \"list\":\n module = await import(\"../../commands/list.js\");\n break;\n case \"login\":\n module = await import(\"../../commands/login.js\");\n break;\n case \"logout\":\n module = await import(\"../../commands/logout.js\");\n break;\n case \"logs\":\n module = await import(\"../../commands/logs.js\");\n break;\n case \"whoami\":\n module = await import(\"../../commands/whoami.js\");\n break;\n case \"configure\":\n module = await import(\"../../commands/configure.js\");\n break;\n case \"version\":\n module = await import(\"../../commands/version.js\");\n break;\n }\n\n return module as CommandModule;\n};\n"],
5
- "mappings": "0MAAA,IAAAA,EAAAC,EAAA,CAAAC,EAAAC,IAAA,CAAAC,IAAA,IAAMC,EAAa,OAAO,UAAU,EAE9BC,EAAN,MAAMC,UAAiB,KAAM,CAF7B,MAE6B,CAAAC,EAAA,iBAC5B,YAAYC,EAAKC,EAAM,CACtB,MAAMD,CAAG,EACT,KAAK,KAAO,WACZ,KAAK,KAAOC,EAEZ,OAAO,eAAe,KAAMH,EAAS,SAAS,CAC/C,CACD,EAEA,SAASI,EACRC,EACA,CACC,KAAAC,EAAO,QAAQ,KAAK,MAAM,CAAC,EAC3B,WAAAC,EAAa,GACb,iBAAAC,EAAmB,EACpB,EAAI,CAAC,EACJ,CACD,GAAI,CAACH,EACJ,MAAM,IAAIN,EACT,4CACA,oBACD,E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K,SACHA,EAAS,KAAM,QAAO,sBAA0B,EAChD,MACF,IAAK,YACHA,EAAS,KAAM,QAAO,yBAA6B,EACnD,MACF,IAAK,UACHA,EAAS,KAAM,QAAO,uBAA2B,EACjD,KACJ,CAEA,OAAOA,CACT,EAlD6B",
4
+ "sourcesContent": ["const flagSymbol = Symbol('arg flag');\n\nclass ArgError extends Error {\n\tconstructor(msg, code) {\n\t\tsuper(msg);\n\t\tthis.name = 'ArgError';\n\t\tthis.code = code;\n\n\t\tObject.setPrototypeOf(this, ArgError.prototype);\n\t}\n}\n\nfunction arg(\n\topts,\n\t{\n\t\targv = process.argv.slice(2),\n\t\tpermissive = false,\n\t\tstopAtPositional = false\n\t} = {}\n) {\n\tif (!opts) {\n\t\tthrow new ArgError(\n\t\t\t'argument specification object is required',\n\t\t\t'ARG_CONFIG_NO_SPEC'\n\t\t);\n\t}\n\n\tconst result = { _: [] };\n\n\tconst aliases = {};\n\tconst handlers = {};\n\n\tfor (const key of Object.keys(opts)) {\n\t\tif (!key) {\n\t\t\tthrow new ArgError(\n\t\t\t\t'argument key cannot be an empty string',\n\t\t\t\t'ARG_CONFIG_EMPTY_KEY'\n\t\t\t);\n\t\t}\n\n\t\tif (key[0] !== '-') {\n\t\t\tthrow new ArgError(\n\t\t\t\t`argument key must start with '-' but found: '${key}'`,\n\t\t\t\t'ARG_CONFIG_NONOPT_KEY'\n\t\t\t);\n\t\t}\n\n\t\tif (key.length === 1) {\n\t\t\tthrow new ArgError(\n\t\t\t\t`argument key must have a name; singular '-' keys are not allowed: ${key}`,\n\t\t\t\t'ARG_CONFIG_NONAME_KEY'\n\t\t\t);\n\t\t}\n\n\t\tif (typeof opts[key] === 'string') {\n\t\t\taliases[key] = opts[key];\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet type = opts[key];\n\t\tlet isFlag = false;\n\n\t\tif (\n\t\t\tArray.isArray(type) &&\n\t\t\ttype.length === 1 &&\n\t\t\ttypeof type[0] === 'function'\n\t\t) {\n\t\t\tconst [fn] = type;\n\t\t\ttype = (value, name, prev = []) => {\n\t\t\t\tprev.push(fn(value, name, prev[prev.length - 1]));\n\t\t\t\treturn prev;\n\t\t\t};\n\t\t\tisFlag = fn === Boolean || fn[flagSymbol] === true;\n\t\t} else if (typeof type === 'function') {\n\t\t\tisFlag = type === Boolean || type[flagSymbol] === true;\n\t\t} else {\n\t\t\tthrow new ArgError(\n\t\t\t\t`type missing or not a function or valid array type: ${key}`,\n\t\t\t\t'ARG_CONFIG_VAD_TYPE'\n\t\t\t);\n\t\t}\n\n\t\tif (key[1] !== '-' && key.length > 2) {\n\t\t\tthrow new ArgError(\n\t\t\t\t`short argument keys (with a single hyphen) must have only one character: ${key}`,\n\t\t\t\t'ARG_CONFIG_SHORTOPT_TOOLONG'\n\t\t\t);\n\t\t}\n\n\t\thandlers[key] = [type, isFlag];\n\t}\n\n\tfor (let i = 0, len = argv.length; i < len; i++) {\n\t\tconst wholeArg = argv[i];\n\n\t\tif (stopAtPositional && result._.length > 0) {\n\t\t\tresult._ = result._.concat(argv.slice(i));\n\t\t\tbreak;\n\t\t}\n\n\t\tif (wholeArg === '--') {\n\t\t\tresult._ = result._.concat(argv.slice(i + 1));\n\t\t\tbreak;\n\t\t}\n\n\t\tif (wholeArg.length > 1 && wholeArg[0] === '-') {\n\t\t\t/* eslint-disable operator-linebreak */\n\t\t\tconst separatedArguments =\n\t\t\t\twholeArg[1] === '-' || wholeArg.length === 2\n\t\t\t\t\t? [wholeArg]\n\t\t\t\t\t: wholeArg\n\t\t\t\t\t\t\t.slice(1)\n\t\t\t\t\t\t\t.split('')\n\t\t\t\t\t\t\t.map((a) => `-${a}`);\n\t\t\t/* eslint-enable operator-linebreak */\n\n\t\t\tfor (let j = 0; j < separatedArguments.length; j++) {\n\t\t\t\tconst arg = separatedArguments[j];\n\t\t\t\tconst [originalArgName, argStr] =\n\t\t\t\t\targ[1] === '-' ? arg.split(/=(.*)/, 2) : [arg, undefined];\n\n\t\t\t\tlet argName = originalArgName;\n\t\t\t\twhile (argName in aliases) {\n\t\t\t\t\targName = aliases[argName];\n\t\t\t\t}\n\n\t\t\t\tif (!(argName in handlers)) {\n\t\t\t\t\tif (permissive) {\n\t\t\t\t\t\tresult._.push(arg);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new ArgError(\n\t\t\t\t\t\t\t`unknown or unexpected option: ${originalArgName}`,\n\t\t\t\t\t\t\t'ARG_UNKNOWN_OPTION'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst [type, isFlag] = handlers[argName];\n\n\t\t\t\tif (!isFlag && j + 1 < separatedArguments.length) {\n\t\t\t\t\tthrow new ArgError(\n\t\t\t\t\t\t`option requires argument (but was followed by another short argument): ${originalArgName}`,\n\t\t\t\t\t\t'ARG_MISSING_REQUIRED_SHORTARG'\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (isFlag) {\n\t\t\t\t\tresult[argName] = type(true, argName, result[argName]);\n\t\t\t\t} else if (argStr === undefined) {\n\t\t\t\t\tif (\n\t\t\t\t\t\targv.length < i + 2 ||\n\t\t\t\t\t\t(argv[i + 1].length > 1 &&\n\t\t\t\t\t\t\targv[i + 1][0] === '-' &&\n\t\t\t\t\t\t\t!(\n\t\t\t\t\t\t\t\targv[i + 1].match(/^-?\\d*(\\.(?=\\d))?\\d*$/) &&\n\t\t\t\t\t\t\t\t(type === Number ||\n\t\t\t\t\t\t\t\t\t// eslint-disable-next-line no-undef\n\t\t\t\t\t\t\t\t\t(typeof BigInt !== 'undefined' && type === BigInt))\n\t\t\t\t\t\t\t))\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst extended =\n\t\t\t\t\t\t\toriginalArgName === argName ? '' : ` (alias for ${argName})`;\n\t\t\t\t\t\tthrow new ArgError(\n\t\t\t\t\t\t\t`option requires argument: ${originalArgName}${extended}`,\n\t\t\t\t\t\t\t'ARG_MISSING_REQUIRED_LONGARG'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tresult[argName] = type(argv[i + 1], argName, result[argName]);\n\t\t\t\t\t++i;\n\t\t\t\t} else {\n\t\t\t\t\tresult[argName] = type(argStr, argName, result[argName]);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tresult._.push(wholeArg);\n\t\t}\n\t}\n\n\treturn result;\n}\n\narg.flag = (fn) => {\n\tfn[flagSymbol] = true;\n\treturn fn;\n};\n\n// Utility types\narg.COUNT = arg.flag((v, name, existingCount) => (existingCount || 0) + 1);\n\n// Expose error class\narg.ArgError = ArgError;\n\nmodule.exports = arg;\n", "import arg from \"arg\";\nimport chalk from \"chalk\";\nimport type { Simplify } from \"type-fest\";\n\nimport { GGTError, IsBug, UnexpectedError } from \"../output/report.js\";\nimport { symbol } from \"../output/symbols.js\";\nimport { isNil } from \"../util/is.js\";\n\nexport type ArgsDefinition = Record<string, ArgDefinition>;\n\ntype ArgDefinition<Handler extends arg.Handler = arg.Handler> =\n | Handler\n | {\n type: Handler;\n alias?: string | string[];\n default?: ReturnType<Handler>;\n };\n\nexport type ParseArgsOptions = {\n /**\n * A list of arguments to parse.\n */\n argv?: string[];\n\n /**\n * When permissive set to `true`, arg will push any unknown arguments\n * onto the \"extra\" argument array (`ctx.args._`) instead of throwing\n * an error about an unknown flag.\n *\n * @default false\n */\n permissive?: boolean;\n\n /**\n * When stopAtPositional is set to true, context will stop parsing at\n * the first positional argument.\n *\n * @default false\n */\n stopAtPositional?: boolean;\n};\n\nexport const parseArgs = <Args extends ArgsDefinition>(args: Args, options?: arg.Options): ArgsDefinitionResult<Args> => {\n const spec: arg.Spec = {};\n const defaultValues: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(args)) {\n if (!(\"type\" in value)) {\n spec[key] = value;\n continue;\n }\n\n spec[key] = value.type;\n defaultValues[key] = value.default;\n\n if (value.alias) {\n for (const alias of Array.isArray(value.alias) ? value.alias : [value.alias]) {\n spec[alias] = key;\n }\n }\n }\n\n try {\n const parsed = arg(spec, options);\n for (const [key, value] of Object.entries(defaultValues)) {\n if (isNil(parsed[key])) {\n parsed[key] = value as never;\n }\n }\n return parsed as ArgsDefinitionResult<Args>;\n } catch (error: unknown) {\n if (error instanceof arg.ArgError) {\n // convert arg.ArgError to GGTError\n // oxlint-disable-next-line no-ex-assign\n error = new ArgError(error.message);\n }\n if (error instanceof GGTError) {\n throw error;\n }\n throw new UnexpectedError(error);\n }\n};\n\nexport class ArgError extends GGTError {\n isBug = IsBug.NO;\n\n protected override render(): string {\n return `${chalk.redBright(symbol.cross)} ` + this.message;\n }\n}\n\n/**\n * Turns this:\n * ```ts\n * type Args = {\n * \"--string\": { type: String; alias: \"s\" };\n * \"--number\": { type: Number; default: 42 };\n * };\n * ```\n *\n * Into this:\n * ```ts\n * type Result = {\n * \"--string\": string | undefined;\n * \"--number\": number;\n * };\n * ```\n */\nexport type ArgsDefinitionResult<Args extends ArgsDefinition, Keys extends keyof Args = keyof Args> = Simplify<{\n [Key in Keys]: Args[Key] extends ArgDefinition<infer Handler>\n ? Args[Key] extends { default: unknown }\n ? NonNullable<ReturnType<Handler>>\n : ReturnType<Handler> | undefined\n : never;\n}> & { _: string[] };\n", "import assert from \"node:assert\";\n\nimport type { EmptyObject, Promisable } from \"type-fest\";\n\nimport type { ArgsDefinition, ArgsDefinitionResult, ParseArgsOptions } from \"./arg.js\";\nimport type { Context } from \"./context.js\";\n\n/**\n * The list of available commands.\n *\n * 1. Every command corresponds to a file inside of src/commands/\n * 2. The order determines the order of commands in the README\n */\nexport const Commands = [\n \"dev\",\n \"deploy\",\n \"status\",\n \"problems\",\n \"push\",\n \"pull\",\n \"var\",\n \"env\",\n \"add\",\n \"open\",\n \"list\",\n \"login\",\n \"logout\",\n \"logs\",\n \"debugger\",\n \"whoami\",\n \"configure\",\n \"agent-plugin\",\n \"eval\",\n \"version\",\n] as const;\n\n/**\n * One of the commands in {@link Commands}.\n */\nexport type Command = (typeof Commands)[number];\n\n/**\n * Checks if a string is a valid command.\n *\n * @param command - The string to check\n * @returns Whether the string is a valid command\n */\nexport const isCommand = (command: string): command is Command => {\n return Commands.includes(command as Command);\n};\n\n/**\n * A command module is a file in the src/commands/ directory.\n */\nexport type CommandModule<Args extends ArgsDefinition = EmptyObject> = {\n /**\n * The command's {@link ArgsDefinition args}.\n */\n args?: Args;\n\n /**\n * Options to pass to {@link parseArgs} when parsing the command's args.\n */\n parseOptions?: ParseArgsOptions;\n\n /**\n * The command's {@link Usage usage}.\n */\n usage: Usage;\n\n /**\n * The command's {@link Run run} function.\n */\n run: Run<Args>;\n};\n\n/**\n * A {@linkcode Command command}'s usage is a function that returns a\n * string describing how to use the command.\n */\nexport type Usage = (ctx: Context) => string;\n\n/**\n * The function that is run when the command is called.\n */\nexport type Run<Args extends ArgsDefinition = EmptyObject> = (ctx: Context, args: ArgsDefinitionResult<Args>) => Promisable<void>;\n\n/**\n * Imports a command module.\n *\n * @param cmd - The command to import\n * @see {@linkcode CommandModule}\n */\nexport const importCommand = async (cmd: Command): Promise<CommandModule> => {\n assert(isCommand(cmd), `invalid command: ${cmd}`);\n\n let module;\n switch (cmd) {\n case \"dev\":\n module = await import(\"../../commands/dev.js\");\n break;\n case \"deploy\":\n module = await import(\"../../commands/deploy.js\");\n break;\n case \"status\":\n module = await import(\"../../commands/status.js\");\n break;\n case \"problems\":\n module = await import(\"../../commands/problems.js\");\n break;\n case \"push\":\n module = await import(\"../../commands/push.js\");\n break;\n case \"pull\":\n module = await import(\"../../commands/pull.js\");\n break;\n case \"var\":\n module = await import(\"../../commands/var.js\");\n break;\n case \"env\":\n module = await import(\"../../commands/env.js\");\n break;\n case \"add\":\n module = await import(\"../../commands/add.js\");\n break;\n case \"open\":\n module = await import(\"../../commands/open.js\");\n break;\n case \"list\":\n module = await import(\"../../commands/list.js\");\n break;\n case \"login\":\n module = await import(\"../../commands/login.js\");\n break;\n case \"logout\":\n module = await import(\"../../commands/logout.js\");\n break;\n case \"logs\":\n module = await import(\"../../commands/logs.js\");\n break;\n case \"debugger\":\n module = await import(\"../../commands/debugger.js\");\n break;\n case \"whoami\":\n module = await import(\"../../commands/whoami.js\");\n break;\n case \"configure\":\n module = await import(\"../../commands/configure.js\");\n break;\n case \"agent-plugin\":\n module = await import(\"../../commands/agent-plugin.js\");\n break;\n case \"eval\":\n module = await import(\"../../commands/eval.js\");\n break;\n case \"version\":\n module = await import(\"../../commands/version.js\");\n break;\n }\n\n return module as CommandModule;\n};\n"],
5
+ "mappings": "0MAAA,IAAAA,EAAAC,EAAA,CAAAC,EAAAC,IAAA,CAAAC,IAAA,IAAMC,EAAa,OAAO,UAAU,EAE9BC,EAAN,MAAMC,UAAiB,KAAM,CAF7B,MAE6B,CAAAC,EAAA,iBAC5B,YAAYC,EAAKC,EAAM,CACtB,MAAMD,CAAG,EACT,KAAK,KAAO,WACZ,KAAK,KAAOC,EAEZ,OAAO,eAAe,KAAMH,EAAS,SAAS,CAC/C,CACD,EAEA,SAASI,EACRC,EACA,CACC,KAAAC,EAAO,QAAQ,KAAK,MAAM,CAAC,EAC3B,WAAAC,EAAa,GACb,iBAAAC,EAAmB,EACpB,EAAI,CAAC,EACJ,CACD,GAAI,CAACH,EACJ,MAAM,IAAIN,EACT,4CACA,oBACD,EAGD,IAAMU,EAAS,CAAE,EAAG,CAAC,CAAE,EAEjBC,EAAU,CAAC,EACXC,EAAW,CAAC,EAElB,QAAWC,KAAO,OAAO,KAAKP,CAAI,EAAG,CACpC,GAAI,CAACO,EACJ,MAAM,IAAIb,EACT,yCACA,sBACD,EAGD,GAAIa,EAAI,CAAC,IAAM,IACd,MAAM,IAAIb,EACT,gDAAgDa,CAAG,IACnD,uBACD,EAGD,GAAIA,EAAI,SAAW,EAClB,MAAM,IAAIb,EACT,qEAAqEa,CAAG,GACxE,uBACD,EAGD,GAAI,OAAOP,EAAKO,CAAG,GAAM,SAAU,CAClCF,EAAQE,CAAG,EAAIP,EAAKO,CAAG,EACvB,QACD,CAEA,IAAI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M,QAAO,uBAA2B,EACjD,KACJ,CAEA,OAAOA,CACT,EApE6B",
6
6
  "names": ["require_arg", "__commonJSMin", "exports", "module", "init_cjs", "flagSymbol", "ArgError", "_ArgError", "__name", "msg", "code", "arg", "opts", "argv", "permissive", "stopAtPositional", "result", "aliases", "handlers", "key", "type", "isFlag", "fn", "value", "name", "prev", "i", "len", "wholeArg", "separatedArguments", "a", "j", "originalArgName", "argStr", "argName", "extended", "v", "existingCount", "init_cjs", "import_arg", "parseArgs", "__name", "args", "options", "spec", "defaultValues", "key", "value", "alias", "parsed", "arg", "isNil", "error", "ArgError", "GGTError", "UnexpectedError", "IsBug", "source_default", "symbol", "init_cjs", "assert", "Commands", "isCommand", "__name", "command", "importCommand", "cmd", "assert", "module"]
7
7
  }