@mercurjs/cli 2.3.5-canary.0 → 2.3.6-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,89 +1,44 @@
1
1
  #!/usr/bin/env node
2
2
  import { z } from 'zod';
3
3
 
4
- declare const registryItemTypeSchema: z.ZodEnum<["registry:api", "registry:vendor", "registry:admin"]>;
4
+ declare const registryItemTypeSchema: z.ZodEnum<{
5
+ "registry:api": "registry:api";
6
+ "registry:vendor": "registry:vendor";
7
+ "registry:admin": "registry:admin";
8
+ }>;
5
9
  declare const registryItemFileSchema: z.ZodObject<{
6
10
  path: z.ZodString;
7
11
  content: z.ZodOptional<z.ZodString>;
8
- type: z.ZodEnum<["registry:api", "registry:vendor", "registry:admin"]>;
12
+ type: z.ZodEnum<{
13
+ "registry:api": "registry:api";
14
+ "registry:vendor": "registry:vendor";
15
+ "registry:admin": "registry:admin";
16
+ }>;
9
17
  target: z.ZodOptional<z.ZodString>;
10
- }, "strip", z.ZodTypeAny, {
11
- path: string;
12
- type: "registry:api" | "registry:vendor" | "registry:admin";
13
- content?: string | undefined;
14
- target?: string | undefined;
15
- }, {
16
- path: string;
17
- type: "registry:api" | "registry:vendor" | "registry:admin";
18
- content?: string | undefined;
19
- target?: string | undefined;
20
- }>;
18
+ }, z.core.$strip>;
21
19
  declare const registryItemSchema: z.ZodObject<{
22
20
  $schema: z.ZodOptional<z.ZodString>;
23
21
  name: z.ZodString;
24
22
  title: z.ZodOptional<z.ZodString>;
25
23
  author: z.ZodOptional<z.ZodString>;
26
24
  description: z.ZodOptional<z.ZodString>;
27
- dependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
28
- devDependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
29
- registryDependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
25
+ dependencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
26
+ devDependencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
27
+ registryDependencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
30
28
  meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
31
29
  docs: z.ZodOptional<z.ZodString>;
32
- categories: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
33
- } & {
30
+ categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
34
31
  files: z.ZodArray<z.ZodObject<{
35
32
  path: z.ZodString;
36
33
  content: z.ZodOptional<z.ZodString>;
37
- type: z.ZodEnum<["registry:api", "registry:vendor", "registry:admin"]>;
34
+ type: z.ZodEnum<{
35
+ "registry:api": "registry:api";
36
+ "registry:vendor": "registry:vendor";
37
+ "registry:admin": "registry:admin";
38
+ }>;
38
39
  target: z.ZodOptional<z.ZodString>;
39
- }, "strip", z.ZodTypeAny, {
40
- path: string;
41
- type: "registry:api" | "registry:vendor" | "registry:admin";
42
- content?: string | undefined;
43
- target?: string | undefined;
44
- }, {
45
- path: string;
46
- type: "registry:api" | "registry:vendor" | "registry:admin";
47
- content?: string | undefined;
48
- target?: string | undefined;
49
- }>, "many">;
50
- }, "strip", z.ZodTypeAny, {
51
- name: string;
52
- files: {
53
- path: string;
54
- type: "registry:api" | "registry:vendor" | "registry:admin";
55
- content?: string | undefined;
56
- target?: string | undefined;
57
- }[];
58
- $schema?: string | undefined;
59
- title?: string | undefined;
60
- author?: string | undefined;
61
- description?: string | undefined;
62
- dependencies?: string[] | undefined;
63
- devDependencies?: string[] | undefined;
64
- registryDependencies?: string[] | undefined;
65
- meta?: Record<string, any> | undefined;
66
- docs?: string | undefined;
67
- categories?: string[] | undefined;
68
- }, {
69
- name: string;
70
- files: {
71
- path: string;
72
- type: "registry:api" | "registry:vendor" | "registry:admin";
73
- content?: string | undefined;
74
- target?: string | undefined;
75
- }[];
76
- $schema?: string | undefined;
77
- title?: string | undefined;
78
- author?: string | undefined;
79
- description?: string | undefined;
80
- dependencies?: string[] | undefined;
81
- devDependencies?: string[] | undefined;
82
- registryDependencies?: string[] | undefined;
83
- meta?: Record<string, any> | undefined;
84
- docs?: string | undefined;
85
- categories?: string[] | undefined;
86
- }>;
40
+ }, z.core.$strip>>;
41
+ }, z.core.$strip>;
87
42
  type RegistryItem = z.infer<typeof registryItemSchema>;
88
43
  declare const registrySchema: z.ZodObject<{
89
44
  name: z.ZodString;
@@ -94,111 +49,24 @@ declare const registrySchema: z.ZodObject<{
94
49
  title: z.ZodOptional<z.ZodString>;
95
50
  author: z.ZodOptional<z.ZodString>;
96
51
  description: z.ZodOptional<z.ZodString>;
97
- dependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
98
- devDependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
99
- registryDependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
52
+ dependencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
53
+ devDependencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
54
+ registryDependencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
100
55
  meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
101
56
  docs: z.ZodOptional<z.ZodString>;
102
- categories: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
103
- } & {
57
+ categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
104
58
  files: z.ZodArray<z.ZodObject<{
105
59
  path: z.ZodString;
106
60
  content: z.ZodOptional<z.ZodString>;
107
- type: z.ZodEnum<["registry:api", "registry:vendor", "registry:admin"]>;
61
+ type: z.ZodEnum<{
62
+ "registry:api": "registry:api";
63
+ "registry:vendor": "registry:vendor";
64
+ "registry:admin": "registry:admin";
65
+ }>;
108
66
  target: z.ZodOptional<z.ZodString>;
109
- }, "strip", z.ZodTypeAny, {
110
- path: string;
111
- type: "registry:api" | "registry:vendor" | "registry:admin";
112
- content?: string | undefined;
113
- target?: string | undefined;
114
- }, {
115
- path: string;
116
- type: "registry:api" | "registry:vendor" | "registry:admin";
117
- content?: string | undefined;
118
- target?: string | undefined;
119
- }>, "many">;
120
- }, "strip", z.ZodTypeAny, {
121
- name: string;
122
- files: {
123
- path: string;
124
- type: "registry:api" | "registry:vendor" | "registry:admin";
125
- content?: string | undefined;
126
- target?: string | undefined;
127
- }[];
128
- $schema?: string | undefined;
129
- title?: string | undefined;
130
- author?: string | undefined;
131
- description?: string | undefined;
132
- dependencies?: string[] | undefined;
133
- devDependencies?: string[] | undefined;
134
- registryDependencies?: string[] | undefined;
135
- meta?: Record<string, any> | undefined;
136
- docs?: string | undefined;
137
- categories?: string[] | undefined;
138
- }, {
139
- name: string;
140
- files: {
141
- path: string;
142
- type: "registry:api" | "registry:vendor" | "registry:admin";
143
- content?: string | undefined;
144
- target?: string | undefined;
145
- }[];
146
- $schema?: string | undefined;
147
- title?: string | undefined;
148
- author?: string | undefined;
149
- description?: string | undefined;
150
- dependencies?: string[] | undefined;
151
- devDependencies?: string[] | undefined;
152
- registryDependencies?: string[] | undefined;
153
- meta?: Record<string, any> | undefined;
154
- docs?: string | undefined;
155
- categories?: string[] | undefined;
156
- }>, "many">;
157
- }, "strip", z.ZodTypeAny, {
158
- name: string;
159
- homepage: string;
160
- items: {
161
- name: string;
162
- files: {
163
- path: string;
164
- type: "registry:api" | "registry:vendor" | "registry:admin";
165
- content?: string | undefined;
166
- target?: string | undefined;
167
- }[];
168
- $schema?: string | undefined;
169
- title?: string | undefined;
170
- author?: string | undefined;
171
- description?: string | undefined;
172
- dependencies?: string[] | undefined;
173
- devDependencies?: string[] | undefined;
174
- registryDependencies?: string[] | undefined;
175
- meta?: Record<string, any> | undefined;
176
- docs?: string | undefined;
177
- categories?: string[] | undefined;
178
- }[];
179
- }, {
180
- name: string;
181
- homepage: string;
182
- items: {
183
- name: string;
184
- files: {
185
- path: string;
186
- type: "registry:api" | "registry:vendor" | "registry:admin";
187
- content?: string | undefined;
188
- target?: string | undefined;
189
- }[];
190
- $schema?: string | undefined;
191
- title?: string | undefined;
192
- author?: string | undefined;
193
- description?: string | undefined;
194
- dependencies?: string[] | undefined;
195
- devDependencies?: string[] | undefined;
196
- registryDependencies?: string[] | undefined;
197
- meta?: Record<string, any> | undefined;
198
- docs?: string | undefined;
199
- categories?: string[] | undefined;
200
- }[];
201
- }>;
67
+ }, z.core.$strip>>;
68
+ }, z.core.$strip>>;
69
+ }, z.core.$strip>;
202
70
  type Registry = z.infer<typeof registrySchema>;
203
71
  declare const registryIndexSchema: z.ZodArray<z.ZodObject<{
204
72
  $schema: z.ZodOptional<z.ZodString>;
@@ -206,112 +74,37 @@ declare const registryIndexSchema: z.ZodArray<z.ZodObject<{
206
74
  title: z.ZodOptional<z.ZodString>;
207
75
  author: z.ZodOptional<z.ZodString>;
208
76
  description: z.ZodOptional<z.ZodString>;
209
- dependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
210
- devDependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
211
- registryDependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
77
+ dependencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
78
+ devDependencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
79
+ registryDependencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
212
80
  meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
213
81
  docs: z.ZodOptional<z.ZodString>;
214
- categories: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
215
- }, "strip", z.ZodTypeAny, {
216
- name: string;
217
- $schema?: string | undefined;
218
- title?: string | undefined;
219
- author?: string | undefined;
220
- description?: string | undefined;
221
- dependencies?: string[] | undefined;
222
- devDependencies?: string[] | undefined;
223
- registryDependencies?: string[] | undefined;
224
- meta?: Record<string, any> | undefined;
225
- docs?: string | undefined;
226
- categories?: string[] | undefined;
227
- }, {
228
- name: string;
229
- $schema?: string | undefined;
230
- title?: string | undefined;
231
- author?: string | undefined;
232
- description?: string | undefined;
233
- dependencies?: string[] | undefined;
234
- devDependencies?: string[] | undefined;
235
- registryDependencies?: string[] | undefined;
236
- meta?: Record<string, any> | undefined;
237
- docs?: string | undefined;
238
- categories?: string[] | undefined;
239
- }>, "many">;
240
- declare const registryResolvedItemsTreeSchema: z.ZodObject<Pick<{
241
- $schema: z.ZodOptional<z.ZodString>;
242
- name: z.ZodString;
243
- title: z.ZodOptional<z.ZodString>;
244
- author: z.ZodOptional<z.ZodString>;
245
- description: z.ZodOptional<z.ZodString>;
246
- dependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
247
- devDependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
248
- registryDependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
249
- meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
82
+ categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
83
+ }, z.core.$strip>>;
84
+ declare const registryResolvedItemsTreeSchema: z.ZodObject<{
85
+ dependencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
86
+ devDependencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
250
87
  docs: z.ZodOptional<z.ZodString>;
251
- categories: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
252
- } & {
253
88
  files: z.ZodArray<z.ZodObject<{
254
89
  path: z.ZodString;
255
90
  content: z.ZodOptional<z.ZodString>;
256
- type: z.ZodEnum<["registry:api", "registry:vendor", "registry:admin"]>;
91
+ type: z.ZodEnum<{
92
+ "registry:api": "registry:api";
93
+ "registry:vendor": "registry:vendor";
94
+ "registry:admin": "registry:admin";
95
+ }>;
257
96
  target: z.ZodOptional<z.ZodString>;
258
- }, "strip", z.ZodTypeAny, {
259
- path: string;
260
- type: "registry:api" | "registry:vendor" | "registry:admin";
261
- content?: string | undefined;
262
- target?: string | undefined;
263
- }, {
264
- path: string;
265
- type: "registry:api" | "registry:vendor" | "registry:admin";
266
- content?: string | undefined;
267
- target?: string | undefined;
268
- }>, "many">;
269
- }, "dependencies" | "devDependencies" | "docs" | "files">, "strip", z.ZodTypeAny, {
270
- files: {
271
- path: string;
272
- type: "registry:api" | "registry:vendor" | "registry:admin";
273
- content?: string | undefined;
274
- target?: string | undefined;
275
- }[];
276
- dependencies?: string[] | undefined;
277
- devDependencies?: string[] | undefined;
278
- docs?: string | undefined;
279
- }, {
280
- files: {
281
- path: string;
282
- type: "registry:api" | "registry:vendor" | "registry:admin";
283
- content?: string | undefined;
284
- target?: string | undefined;
285
- }[];
286
- dependencies?: string[] | undefined;
287
- devDependencies?: string[] | undefined;
288
- docs?: string | undefined;
289
- }>;
290
- declare const registryConfigItemSchema: z.ZodUnion<[z.ZodString, z.ZodObject<{
97
+ }, z.core.$strip>>;
98
+ }, z.core.$strip>;
99
+ declare const registryConfigItemSchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
291
100
  url: z.ZodString;
292
101
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
293
102
  headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
294
- }, "strip", z.ZodTypeAny, {
295
- url: string;
296
- params?: Record<string, string> | undefined;
297
- headers?: Record<string, string> | undefined;
298
- }, {
299
- url: string;
300
- params?: Record<string, string> | undefined;
301
- headers?: Record<string, string> | undefined;
302
- }>]>;
303
- declare const registryConfigSchema: z.ZodRecord<z.ZodEffects<z.ZodString, string, string>, z.ZodUnion<[z.ZodString, z.ZodObject<{
103
+ }, z.core.$strip>]>;
104
+ declare const registryConfigSchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
304
105
  url: z.ZodString;
305
106
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
306
107
  headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
307
- }, "strip", z.ZodTypeAny, {
308
- url: string;
309
- params?: Record<string, string> | undefined;
310
- headers?: Record<string, string> | undefined;
311
- }, {
312
- url: string;
313
- params?: Record<string, string> | undefined;
314
- headers?: Record<string, string> | undefined;
315
- }>]>>;
108
+ }, z.core.$strip>]>>;
316
109
 
317
110
  export { type Registry, type RegistryItem, registryConfigItemSchema, registryConfigSchema, registryIndexSchema, registryItemFileSchema, registryItemSchema, registryItemTypeSchema, registryResolvedItemsTreeSchema, registrySchema };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import {Command}from'commander';import*as b from'path';import b__default,{join,basename}from'path';import pt from'prompts';import {z}from'zod';import Xe,{promises,existsSync,readFileSync,mkdirSync,writeFileSync,statSync}from'fs';import {cosmiconfig}from'cosmiconfig';import {loadConfig,createMatchPath}from'tsconfig-paths';import gt from'fs-extra';import tt from'fast-glob';import Ms,{createHash}from'crypto';import Jt from'deepmerge';import*as A from'fs/promises';import A__default,{writeFile,rm}from'fs/promises';import Ls,{homedir,tmpdir}from'os';import {Project,ScriptKind}from'ts-morph';import xe from'kleur';import No from'ora';import {execa}from'execa';import {detect}from'@antfu/ni';import {diffLines}from'diff';import {execSync}from'child_process';import {builtinModules}from'module';import {generatePluginEntryModule}from'@mercurjs/dashboard-sdk/vite';var It={version:"2.3.5-canary.0"};var St="MISSING_DIR_OR_EMPTY_PROJECT",P="MISSING_CONFIG",M="BUILD_MISSING_REGISTRY_FILE";var Yr=z.enum(["registry:api","registry:vendor","registry:admin"]),kt=z.object({path:z.string(),content:z.string().optional(),type:Yr,target:z.string().optional()}),Ct=z.object({$schema:z.string().optional(),name:z.string(),title:z.string().optional(),author:z.string().min(2).optional(),description:z.string().optional(),dependencies:z.array(z.string()).optional(),devDependencies:z.array(z.string()).optional(),registryDependencies:z.array(z.string()).optional(),meta:z.record(z.string(),z.any()).optional(),docs:z.string().optional(),categories:z.array(z.string()).optional()}),j=Ct.extend({files:z.array(kt)}),J=z.object({name:z.string(),homepage:z.string(),items:z.array(j)}),Fn=z.array(Ct),Pt=j.pick({dependencies:true,devDependencies:true,files:true,docs:true}),Jr=z.union([z.string(),z.object({url:z.string(),params:z.record(z.string(),z.string()).optional(),headers:z.record(z.string(),z.string()).optional()})]),_t=z.record(z.string().refine(e=>e.startsWith("@"),{message:"Registry names must start with @ (e.g., @mercurjs)"}),Jr);var _e="https://registry.mercurjs.com/registry.json",Tt="https://registry.mercurjs.com/registry-item.json",de=process.env.REGISTRY_URL??"https://raw.githubusercontent.com/mercurjs/mercur/main/packages/registry/r",_={"@mercurjs":`${de}/{name}.json`};var F={NOT_FOUND:"NOT_FOUND",UNAUTHORIZED:"UNAUTHORIZED",FORBIDDEN:"FORBIDDEN",FETCH_ERROR:"FETCH_ERROR",NOT_CONFIGURED:"NOT_CONFIGURED",INVALID_CONFIG:"INVALID_CONFIG",MISSING_ENV_VARS:"MISSING_ENV_VARS",LOCAL_FILE_ERROR:"LOCAL_FILE_ERROR",PARSE_ERROR:"PARSE_ERROR",VALIDATION_ERROR:"VALIDATION_ERROR",UNKNOWN_ERROR:"UNKNOWN_ERROR"},S=class extends Error{code;statusCode;context;suggestion;timestamp;cause;constructor(t,r={}){super(t),this.name="RegistryError",this.code=r.code||F.UNKNOWN_ERROR,this.statusCode=r.statusCode,this.cause=r.cause,this.context=r.context,this.suggestion=r.suggestion,this.timestamp=new Date,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor);}},se=class extends S{constructor(r,o){let s=`The item at ${r} was not found. It may not exist at the registry.`;super(s,{code:F.NOT_FOUND,statusCode:404,cause:o,context:{url:r},suggestion:"Check if the item name is correct and the registry URL is accessible."});this.url=r;this.name="RegistryNotFoundError";}url},Te=class extends S{constructor(r,o){let s=`You are not authorized to access the item at ${r}. If this is a remote registry, you may need to authenticate.`;super(s,{code:F.UNAUTHORIZED,statusCode:401,cause:o,context:{url:r},suggestion:"Check your authentication credentials and environment variables."});this.url=r;this.name="RegistryUnauthorizedError";}url},je=class extends S{constructor(r,o){let s=`You are not authorized to access the item at ${r}. If this is a remote registry, you may need to authenticate.`;super(s,{code:F.FORBIDDEN,statusCode:403,cause:o,context:{url:r},suggestion:"Check your authentication credentials and environment variables."});this.url=r;this.name="RegistryForbiddenError";}url},Fe=class extends S{constructor(r,o,s,n){let i=o?`Failed to fetch from registry (${o}): ${r}`:`Failed to fetch from registry: ${r}`,f=typeof n=="string"&&n?`${i} - ${n}`:i,c="Check your network connection and try again.";o===404?c="The requested resource was not found. Check the URL or item name.":o===500?c="The registry server encountered an error. Try again later.":o&&o>=400&&o<500&&(c="There was a client error. Check your request parameters.");super(f,{code:F.FETCH_ERROR,statusCode:o,cause:n,context:{url:r,responseBody:s},suggestion:c});this.url=r;this.responseBody=s;this.name="RegistryFetchError";}url;responseBody},H=class extends S{constructor(r){let o=r?`Unknown registry "${r}". Make sure it is defined in agents.json as follows:
2
+ import {Command}from'commander';import*as b from'path';import b__default,{join,basename}from'path';import pt from'prompts';import {z}from'zod';import Xe,{promises,existsSync,readFileSync,mkdirSync,writeFileSync,statSync}from'fs';import {cosmiconfig}from'cosmiconfig';import {loadConfig,createMatchPath}from'tsconfig-paths';import gt from'fs-extra';import tt from'fast-glob';import Ms,{createHash}from'crypto';import Jt from'deepmerge';import*as A from'fs/promises';import A__default,{writeFile,rm}from'fs/promises';import Ls,{homedir,tmpdir}from'os';import {Project,ScriptKind}from'ts-morph';import xe from'kleur';import No from'ora';import {execa}from'execa';import {detect}from'@antfu/ni';import {diffLines}from'diff';import {execSync}from'child_process';import {builtinModules}from'module';import {generatePluginEntryModule}from'@mercurjs/dashboard-sdk/vite';var It={version:"2.3.6-canary.0"};var St="MISSING_DIR_OR_EMPTY_PROJECT",P="MISSING_CONFIG",M="BUILD_MISSING_REGISTRY_FILE";var Yr=z.enum(["registry:api","registry:vendor","registry:admin"]),kt=z.object({path:z.string(),content:z.string().optional(),type:Yr,target:z.string().optional()}),Ct=z.object({$schema:z.string().optional(),name:z.string(),title:z.string().optional(),author:z.string().min(2).optional(),description:z.string().optional(),dependencies:z.array(z.string()).optional(),devDependencies:z.array(z.string()).optional(),registryDependencies:z.array(z.string()).optional(),meta:z.record(z.string(),z.any()).optional(),docs:z.string().optional(),categories:z.array(z.string()).optional()}),j=Ct.extend({files:z.array(kt)}),J=z.object({name:z.string(),homepage:z.string(),items:z.array(j)}),Fn=z.array(Ct),Pt=j.pick({dependencies:true,devDependencies:true,files:true,docs:true}),Jr=z.union([z.string(),z.object({url:z.string(),params:z.record(z.string(),z.string()).optional(),headers:z.record(z.string(),z.string()).optional()})]),_t=z.record(z.string().refine(e=>e.startsWith("@"),{message:"Registry names must start with @ (e.g., @mercurjs)"}),Jr);var _e="https://registry.mercurjs.com/registry.json",Tt="https://registry.mercurjs.com/registry-item.json",de=process.env.REGISTRY_URL??"https://raw.githubusercontent.com/mercurjs/mercur/main/packages/registry/r",_={"@mercurjs":`${de}/{name}.json`};var F={NOT_FOUND:"NOT_FOUND",UNAUTHORIZED:"UNAUTHORIZED",FORBIDDEN:"FORBIDDEN",FETCH_ERROR:"FETCH_ERROR",NOT_CONFIGURED:"NOT_CONFIGURED",INVALID_CONFIG:"INVALID_CONFIG",MISSING_ENV_VARS:"MISSING_ENV_VARS",LOCAL_FILE_ERROR:"LOCAL_FILE_ERROR",PARSE_ERROR:"PARSE_ERROR",VALIDATION_ERROR:"VALIDATION_ERROR",UNKNOWN_ERROR:"UNKNOWN_ERROR"},S=class extends Error{code;statusCode;context;suggestion;timestamp;cause;constructor(t,r={}){super(t),this.name="RegistryError",this.code=r.code||F.UNKNOWN_ERROR,this.statusCode=r.statusCode,this.cause=r.cause,this.context=r.context,this.suggestion=r.suggestion,this.timestamp=new Date,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor);}},se=class extends S{constructor(r,o){let s=`The item at ${r} was not found. It may not exist at the registry.`;super(s,{code:F.NOT_FOUND,statusCode:404,cause:o,context:{url:r},suggestion:"Check if the item name is correct and the registry URL is accessible."});this.url=r;this.name="RegistryNotFoundError";}url},Te=class extends S{constructor(r,o){let s=`You are not authorized to access the item at ${r}. If this is a remote registry, you may need to authenticate.`;super(s,{code:F.UNAUTHORIZED,statusCode:401,cause:o,context:{url:r},suggestion:"Check your authentication credentials and environment variables."});this.url=r;this.name="RegistryUnauthorizedError";}url},je=class extends S{constructor(r,o){let s=`You are not authorized to access the item at ${r}. If this is a remote registry, you may need to authenticate.`;super(s,{code:F.FORBIDDEN,statusCode:403,cause:o,context:{url:r},suggestion:"Check your authentication credentials and environment variables."});this.url=r;this.name="RegistryForbiddenError";}url},Fe=class extends S{constructor(r,o,s,n){let i=o?`Failed to fetch from registry (${o}): ${r}`:`Failed to fetch from registry: ${r}`,f=typeof n=="string"&&n?`${i} - ${n}`:i,c="Check your network connection and try again.";o===404?c="The requested resource was not found. Check the URL or item name.":o===500?c="The registry server encountered an error. Try again later.":o&&o>=400&&o<500&&(c="There was a client error. Check your request parameters.");super(f,{code:F.FETCH_ERROR,statusCode:o,cause:n,context:{url:r,responseBody:s},suggestion:c});this.url=r;this.responseBody=s;this.name="RegistryFetchError";}url;responseBody},H=class extends S{constructor(r){let o=r?`Unknown registry "${r}". Make sure it is defined in agents.json as follows:
3
3
  {
4
4
  "registries": {
5
5
  "${r}": "[URL_TO_REGISTRY]"