@glossic/schema 0.1.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/LICENSE +21 -0
- package/dist/index.d.ts +637 -0
- package/dist/index.js +245 -0
- package/dist/index.js.map +1 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rody Huancas
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,637 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/** Where generate and scan write, relative to the workspace root. */
|
|
4
|
+
declare const OutputConfigSchema: z.ZodObject<{
|
|
5
|
+
dir: z.ZodDefault<z.ZodString>;
|
|
6
|
+
manifest: z.ZodDefault<z.ZodString>;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
type OutputConfig = z.infer<typeof OutputConfigSchema>;
|
|
9
|
+
/** Every option glossic accepts, with the default that applies when nothing sets it. */
|
|
10
|
+
declare const GlossicConfigSchema: z.ZodObject<{
|
|
11
|
+
include: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
12
|
+
exclude: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
13
|
+
adapters: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
14
|
+
ignoreUnits: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
15
|
+
excludeFromContent: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
16
|
+
mergeChildrenInto: z.ZodDefault<z.ZodNumber>;
|
|
17
|
+
minUnitFiles: z.ZodDefault<z.ZodNumber>;
|
|
18
|
+
maxUnitFiles: z.ZodDefault<z.ZodNumber>;
|
|
19
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
20
|
+
model: z.ZodOptional<z.ZodString>;
|
|
21
|
+
lang: z.ZodDefault<z.ZodString>;
|
|
22
|
+
uiLang: z.ZodDefault<z.ZodEnum<{
|
|
23
|
+
en: "en";
|
|
24
|
+
es: "es";
|
|
25
|
+
}>>;
|
|
26
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
27
|
+
output: z.ZodDefault<z.ZodObject<{
|
|
28
|
+
dir: z.ZodDefault<z.ZodString>;
|
|
29
|
+
manifest: z.ZodDefault<z.ZodString>;
|
|
30
|
+
}, z.core.$strip>>;
|
|
31
|
+
concurrency: z.ZodDefault<z.ZodNumber>;
|
|
32
|
+
timeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
/**
|
|
35
|
+
* `GlossicConfig` is the config once the defaults are applied, so every key is
|
|
36
|
+
* present; `GlossicUserConfig` is the same shape as a person writes it.
|
|
37
|
+
*/
|
|
38
|
+
type GlossicConfig = z.infer<typeof GlossicConfigSchema>;
|
|
39
|
+
type GlossicUserConfig = z.input<typeof GlossicConfigSchema>;
|
|
40
|
+
/** Types a glossic.config.ts without making the project import zod. */
|
|
41
|
+
declare const defineConfig: (config: GlossicUserConfig) => GlossicUserConfig;
|
|
42
|
+
|
|
43
|
+
declare const UnitKindSchema: z.ZodEnum<{
|
|
44
|
+
file: "file";
|
|
45
|
+
directory: "directory";
|
|
46
|
+
module: "module";
|
|
47
|
+
}>;
|
|
48
|
+
type UnitKind = z.infer<typeof UnitKindSchema>;
|
|
49
|
+
/** What a directory appears to hold, inferred from its name. */
|
|
50
|
+
declare const RoleHintSchema: z.ZodEnum<{
|
|
51
|
+
components: "components";
|
|
52
|
+
config: "config";
|
|
53
|
+
controllers: "controllers";
|
|
54
|
+
dtos: "dtos";
|
|
55
|
+
entities: "entities";
|
|
56
|
+
hooks: "hooks";
|
|
57
|
+
middleware: "middleware";
|
|
58
|
+
models: "models";
|
|
59
|
+
routes: "routes";
|
|
60
|
+
services: "services";
|
|
61
|
+
tests: "tests";
|
|
62
|
+
utils: "utils";
|
|
63
|
+
}>;
|
|
64
|
+
type RoleHint = z.infer<typeof RoleHintSchema>;
|
|
65
|
+
/** One documentable file: where it lives, its language and its size. */
|
|
66
|
+
declare const FileFactSchema: z.ZodObject<{
|
|
67
|
+
path: z.ZodString;
|
|
68
|
+
language: z.ZodString;
|
|
69
|
+
bytes: z.ZodNumber;
|
|
70
|
+
}, z.core.$strip>;
|
|
71
|
+
type FileFact = z.infer<typeof FileFactSchema>;
|
|
72
|
+
declare const LanguageCountSchema: z.ZodObject<{
|
|
73
|
+
language: z.ZodString;
|
|
74
|
+
count: z.ZodNumber;
|
|
75
|
+
}, z.core.$strip>;
|
|
76
|
+
type LanguageCount = z.infer<typeof LanguageCountSchema>;
|
|
77
|
+
/** What any adapter can state about a unit, whatever the language. */
|
|
78
|
+
declare const BaseFactsSchema: z.ZodObject<{
|
|
79
|
+
files: z.ZodArray<z.ZodObject<{
|
|
80
|
+
path: z.ZodString;
|
|
81
|
+
language: z.ZodString;
|
|
82
|
+
bytes: z.ZodNumber;
|
|
83
|
+
}, z.core.$strip>>;
|
|
84
|
+
testFiles: z.ZodArray<z.ZodObject<{
|
|
85
|
+
path: z.ZodString;
|
|
86
|
+
language: z.ZodString;
|
|
87
|
+
bytes: z.ZodNumber;
|
|
88
|
+
}, z.core.$strip>>;
|
|
89
|
+
ignoredFiles: z.ZodArray<z.ZodObject<{
|
|
90
|
+
path: z.ZodString;
|
|
91
|
+
language: z.ZodString;
|
|
92
|
+
bytes: z.ZodNumber;
|
|
93
|
+
}, z.core.$strip>>;
|
|
94
|
+
languages: z.ZodArray<z.ZodObject<{
|
|
95
|
+
language: z.ZodString;
|
|
96
|
+
count: z.ZodNumber;
|
|
97
|
+
}, z.core.$strip>>;
|
|
98
|
+
roleHint: z.ZodNullable<z.ZodEnum<{
|
|
99
|
+
components: "components";
|
|
100
|
+
config: "config";
|
|
101
|
+
controllers: "controllers";
|
|
102
|
+
dtos: "dtos";
|
|
103
|
+
entities: "entities";
|
|
104
|
+
hooks: "hooks";
|
|
105
|
+
middleware: "middleware";
|
|
106
|
+
models: "models";
|
|
107
|
+
routes: "routes";
|
|
108
|
+
services: "services";
|
|
109
|
+
tests: "tests";
|
|
110
|
+
utils: "utils";
|
|
111
|
+
}>>;
|
|
112
|
+
}, z.core.$strip>;
|
|
113
|
+
type BaseFacts = z.infer<typeof BaseFactsSchema>;
|
|
114
|
+
declare const SymbolKindSchema: z.ZodEnum<{
|
|
115
|
+
function: "function";
|
|
116
|
+
enum: "enum";
|
|
117
|
+
type: "type";
|
|
118
|
+
class: "class";
|
|
119
|
+
const: "const";
|
|
120
|
+
interface: "interface";
|
|
121
|
+
method: "method";
|
|
122
|
+
other: "other";
|
|
123
|
+
}>;
|
|
124
|
+
type SymbolKind = z.infer<typeof SymbolKindSchema>;
|
|
125
|
+
/** One declaration a language-aware adapter recognised. */
|
|
126
|
+
declare const SymbolFactSchema: z.ZodObject<{
|
|
127
|
+
name: z.ZodString;
|
|
128
|
+
kind: z.ZodEnum<{
|
|
129
|
+
function: "function";
|
|
130
|
+
enum: "enum";
|
|
131
|
+
type: "type";
|
|
132
|
+
class: "class";
|
|
133
|
+
const: "const";
|
|
134
|
+
interface: "interface";
|
|
135
|
+
method: "method";
|
|
136
|
+
other: "other";
|
|
137
|
+
}>;
|
|
138
|
+
file: z.ZodString;
|
|
139
|
+
signature: z.ZodOptional<z.ZodString>;
|
|
140
|
+
exported: z.ZodBoolean;
|
|
141
|
+
line: z.ZodOptional<z.ZodNumber>;
|
|
142
|
+
}, z.core.$strip>;
|
|
143
|
+
type SymbolFact = z.infer<typeof SymbolFactSchema>;
|
|
144
|
+
declare const SymbolFactsSchema: z.ZodObject<{
|
|
145
|
+
symbols: z.ZodArray<z.ZodObject<{
|
|
146
|
+
name: z.ZodString;
|
|
147
|
+
kind: z.ZodEnum<{
|
|
148
|
+
function: "function";
|
|
149
|
+
enum: "enum";
|
|
150
|
+
type: "type";
|
|
151
|
+
class: "class";
|
|
152
|
+
const: "const";
|
|
153
|
+
interface: "interface";
|
|
154
|
+
method: "method";
|
|
155
|
+
other: "other";
|
|
156
|
+
}>;
|
|
157
|
+
file: z.ZodString;
|
|
158
|
+
signature: z.ZodOptional<z.ZodString>;
|
|
159
|
+
exported: z.ZodBoolean;
|
|
160
|
+
line: z.ZodOptional<z.ZodNumber>;
|
|
161
|
+
}, z.core.$strip>>;
|
|
162
|
+
}, z.core.$strip>;
|
|
163
|
+
type SymbolFacts = z.infer<typeof SymbolFactsSchema>;
|
|
164
|
+
/** One HTTP route a framework-aware adapter recognised. */
|
|
165
|
+
declare const RouteFactSchema: z.ZodObject<{
|
|
166
|
+
method: z.ZodString;
|
|
167
|
+
path: z.ZodString;
|
|
168
|
+
handler: z.ZodOptional<z.ZodString>;
|
|
169
|
+
}, z.core.$strip>;
|
|
170
|
+
type RouteFact = z.infer<typeof RouteFactSchema>;
|
|
171
|
+
/** What a framework-aware adapter adds on top of the base facts. */
|
|
172
|
+
declare const FrameworkFactsSchema: z.ZodObject<{
|
|
173
|
+
name: z.ZodString;
|
|
174
|
+
role: z.ZodOptional<z.ZodString>;
|
|
175
|
+
routes: z.ZodArray<z.ZodObject<{
|
|
176
|
+
method: z.ZodString;
|
|
177
|
+
path: z.ZodString;
|
|
178
|
+
handler: z.ZodOptional<z.ZodString>;
|
|
179
|
+
}, z.core.$strip>>;
|
|
180
|
+
dependencies: z.ZodArray<z.ZodString>;
|
|
181
|
+
}, z.core.$strip>;
|
|
182
|
+
type FrameworkFacts = z.infer<typeof FrameworkFactsSchema>;
|
|
183
|
+
/** Everything known about a unit; `producedBy` names the adapters that contributed. */
|
|
184
|
+
declare const FactsSchema: z.ZodObject<{
|
|
185
|
+
base: z.ZodObject<{
|
|
186
|
+
files: z.ZodArray<z.ZodObject<{
|
|
187
|
+
path: z.ZodString;
|
|
188
|
+
language: z.ZodString;
|
|
189
|
+
bytes: z.ZodNumber;
|
|
190
|
+
}, z.core.$strip>>;
|
|
191
|
+
testFiles: z.ZodArray<z.ZodObject<{
|
|
192
|
+
path: z.ZodString;
|
|
193
|
+
language: z.ZodString;
|
|
194
|
+
bytes: z.ZodNumber;
|
|
195
|
+
}, z.core.$strip>>;
|
|
196
|
+
ignoredFiles: z.ZodArray<z.ZodObject<{
|
|
197
|
+
path: z.ZodString;
|
|
198
|
+
language: z.ZodString;
|
|
199
|
+
bytes: z.ZodNumber;
|
|
200
|
+
}, z.core.$strip>>;
|
|
201
|
+
languages: z.ZodArray<z.ZodObject<{
|
|
202
|
+
language: z.ZodString;
|
|
203
|
+
count: z.ZodNumber;
|
|
204
|
+
}, z.core.$strip>>;
|
|
205
|
+
roleHint: z.ZodNullable<z.ZodEnum<{
|
|
206
|
+
components: "components";
|
|
207
|
+
config: "config";
|
|
208
|
+
controllers: "controllers";
|
|
209
|
+
dtos: "dtos";
|
|
210
|
+
entities: "entities";
|
|
211
|
+
hooks: "hooks";
|
|
212
|
+
middleware: "middleware";
|
|
213
|
+
models: "models";
|
|
214
|
+
routes: "routes";
|
|
215
|
+
services: "services";
|
|
216
|
+
tests: "tests";
|
|
217
|
+
utils: "utils";
|
|
218
|
+
}>>;
|
|
219
|
+
}, z.core.$strip>;
|
|
220
|
+
symbols: z.ZodOptional<z.ZodObject<{
|
|
221
|
+
symbols: z.ZodArray<z.ZodObject<{
|
|
222
|
+
name: z.ZodString;
|
|
223
|
+
kind: z.ZodEnum<{
|
|
224
|
+
function: "function";
|
|
225
|
+
enum: "enum";
|
|
226
|
+
type: "type";
|
|
227
|
+
class: "class";
|
|
228
|
+
const: "const";
|
|
229
|
+
interface: "interface";
|
|
230
|
+
method: "method";
|
|
231
|
+
other: "other";
|
|
232
|
+
}>;
|
|
233
|
+
file: z.ZodString;
|
|
234
|
+
signature: z.ZodOptional<z.ZodString>;
|
|
235
|
+
exported: z.ZodBoolean;
|
|
236
|
+
line: z.ZodOptional<z.ZodNumber>;
|
|
237
|
+
}, z.core.$strip>>;
|
|
238
|
+
}, z.core.$strip>>;
|
|
239
|
+
framework: z.ZodOptional<z.ZodObject<{
|
|
240
|
+
name: z.ZodString;
|
|
241
|
+
role: z.ZodOptional<z.ZodString>;
|
|
242
|
+
routes: z.ZodArray<z.ZodObject<{
|
|
243
|
+
method: z.ZodString;
|
|
244
|
+
path: z.ZodString;
|
|
245
|
+
handler: z.ZodOptional<z.ZodString>;
|
|
246
|
+
}, z.core.$strip>>;
|
|
247
|
+
dependencies: z.ZodArray<z.ZodString>;
|
|
248
|
+
}, z.core.$strip>>;
|
|
249
|
+
producedBy: z.ZodArray<z.ZodString>;
|
|
250
|
+
}, z.core.$strip>;
|
|
251
|
+
type Facts = z.infer<typeof FactsSchema>;
|
|
252
|
+
/** A documentable chunk of a project: the thing one page of documentation describes. */
|
|
253
|
+
declare const UnitSchema: z.ZodObject<{
|
|
254
|
+
id: z.ZodString;
|
|
255
|
+
projectId: z.ZodString;
|
|
256
|
+
kind: z.ZodEnum<{
|
|
257
|
+
file: "file";
|
|
258
|
+
directory: "directory";
|
|
259
|
+
module: "module";
|
|
260
|
+
}>;
|
|
261
|
+
name: z.ZodString;
|
|
262
|
+
path: z.ZodString;
|
|
263
|
+
facts: z.ZodObject<{
|
|
264
|
+
base: z.ZodObject<{
|
|
265
|
+
files: z.ZodArray<z.ZodObject<{
|
|
266
|
+
path: z.ZodString;
|
|
267
|
+
language: z.ZodString;
|
|
268
|
+
bytes: z.ZodNumber;
|
|
269
|
+
}, z.core.$strip>>;
|
|
270
|
+
testFiles: z.ZodArray<z.ZodObject<{
|
|
271
|
+
path: z.ZodString;
|
|
272
|
+
language: z.ZodString;
|
|
273
|
+
bytes: z.ZodNumber;
|
|
274
|
+
}, z.core.$strip>>;
|
|
275
|
+
ignoredFiles: z.ZodArray<z.ZodObject<{
|
|
276
|
+
path: z.ZodString;
|
|
277
|
+
language: z.ZodString;
|
|
278
|
+
bytes: z.ZodNumber;
|
|
279
|
+
}, z.core.$strip>>;
|
|
280
|
+
languages: z.ZodArray<z.ZodObject<{
|
|
281
|
+
language: z.ZodString;
|
|
282
|
+
count: z.ZodNumber;
|
|
283
|
+
}, z.core.$strip>>;
|
|
284
|
+
roleHint: z.ZodNullable<z.ZodEnum<{
|
|
285
|
+
components: "components";
|
|
286
|
+
config: "config";
|
|
287
|
+
controllers: "controllers";
|
|
288
|
+
dtos: "dtos";
|
|
289
|
+
entities: "entities";
|
|
290
|
+
hooks: "hooks";
|
|
291
|
+
middleware: "middleware";
|
|
292
|
+
models: "models";
|
|
293
|
+
routes: "routes";
|
|
294
|
+
services: "services";
|
|
295
|
+
tests: "tests";
|
|
296
|
+
utils: "utils";
|
|
297
|
+
}>>;
|
|
298
|
+
}, z.core.$strip>;
|
|
299
|
+
symbols: z.ZodOptional<z.ZodObject<{
|
|
300
|
+
symbols: z.ZodArray<z.ZodObject<{
|
|
301
|
+
name: z.ZodString;
|
|
302
|
+
kind: z.ZodEnum<{
|
|
303
|
+
function: "function";
|
|
304
|
+
enum: "enum";
|
|
305
|
+
type: "type";
|
|
306
|
+
class: "class";
|
|
307
|
+
const: "const";
|
|
308
|
+
interface: "interface";
|
|
309
|
+
method: "method";
|
|
310
|
+
other: "other";
|
|
311
|
+
}>;
|
|
312
|
+
file: z.ZodString;
|
|
313
|
+
signature: z.ZodOptional<z.ZodString>;
|
|
314
|
+
exported: z.ZodBoolean;
|
|
315
|
+
line: z.ZodOptional<z.ZodNumber>;
|
|
316
|
+
}, z.core.$strip>>;
|
|
317
|
+
}, z.core.$strip>>;
|
|
318
|
+
framework: z.ZodOptional<z.ZodObject<{
|
|
319
|
+
name: z.ZodString;
|
|
320
|
+
role: z.ZodOptional<z.ZodString>;
|
|
321
|
+
routes: z.ZodArray<z.ZodObject<{
|
|
322
|
+
method: z.ZodString;
|
|
323
|
+
path: z.ZodString;
|
|
324
|
+
handler: z.ZodOptional<z.ZodString>;
|
|
325
|
+
}, z.core.$strip>>;
|
|
326
|
+
dependencies: z.ZodArray<z.ZodString>;
|
|
327
|
+
}, z.core.$strip>>;
|
|
328
|
+
producedBy: z.ZodArray<z.ZodString>;
|
|
329
|
+
}, z.core.$strip>;
|
|
330
|
+
hash: z.ZodString;
|
|
331
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
332
|
+
}, z.core.$strip>;
|
|
333
|
+
type Unit = z.infer<typeof UnitSchema>;
|
|
334
|
+
declare const RelationKindSchema: z.ZodEnum<{
|
|
335
|
+
imports: "imports";
|
|
336
|
+
calls: "calls";
|
|
337
|
+
extends: "extends";
|
|
338
|
+
implements: "implements";
|
|
339
|
+
injects: "injects";
|
|
340
|
+
exposes: "exposes";
|
|
341
|
+
references: "references";
|
|
342
|
+
contains: "contains";
|
|
343
|
+
}>;
|
|
344
|
+
type RelationKind = z.infer<typeof RelationKindSchema>;
|
|
345
|
+
/** A directed edge between two units, by unit id. */
|
|
346
|
+
declare const RelationSchema: z.ZodObject<{
|
|
347
|
+
from: z.ZodString;
|
|
348
|
+
to: z.ZodString;
|
|
349
|
+
kind: z.ZodEnum<{
|
|
350
|
+
imports: "imports";
|
|
351
|
+
calls: "calls";
|
|
352
|
+
extends: "extends";
|
|
353
|
+
implements: "implements";
|
|
354
|
+
injects: "injects";
|
|
355
|
+
exposes: "exposes";
|
|
356
|
+
references: "references";
|
|
357
|
+
contains: "contains";
|
|
358
|
+
}>;
|
|
359
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
360
|
+
}, z.core.$strip>;
|
|
361
|
+
type Relation = z.infer<typeof RelationSchema>;
|
|
362
|
+
|
|
363
|
+
/** The tool that defines the project list, or "none" for a single-project repo. */
|
|
364
|
+
declare const WorkspaceToolSchema: z.ZodEnum<{
|
|
365
|
+
pnpm: "pnpm";
|
|
366
|
+
"npm-workspaces": "npm-workspaces";
|
|
367
|
+
turbo: "turbo";
|
|
368
|
+
nx: "nx";
|
|
369
|
+
lerna: "lerna";
|
|
370
|
+
none: "none";
|
|
371
|
+
}>;
|
|
372
|
+
type WorkspaceTool = z.infer<typeof WorkspaceToolSchema>;
|
|
373
|
+
/** One package inside the workspace. */
|
|
374
|
+
declare const ProjectSchema: z.ZodObject<{
|
|
375
|
+
id: z.ZodString;
|
|
376
|
+
name: z.ZodString;
|
|
377
|
+
rootDir: z.ZodString;
|
|
378
|
+
packageManager: z.ZodOptional<z.ZodString>;
|
|
379
|
+
}, z.core.$strip>;
|
|
380
|
+
type Project = z.infer<typeof ProjectSchema>;
|
|
381
|
+
/** The scanned repository and the projects found inside it. */
|
|
382
|
+
declare const WorkspaceSchema: z.ZodObject<{
|
|
383
|
+
name: z.ZodString;
|
|
384
|
+
root: z.ZodString;
|
|
385
|
+
isMonorepo: z.ZodBoolean;
|
|
386
|
+
tool: z.ZodEnum<{
|
|
387
|
+
pnpm: "pnpm";
|
|
388
|
+
"npm-workspaces": "npm-workspaces";
|
|
389
|
+
turbo: "turbo";
|
|
390
|
+
nx: "nx";
|
|
391
|
+
lerna: "lerna";
|
|
392
|
+
none: "none";
|
|
393
|
+
}>;
|
|
394
|
+
packageManager: z.ZodOptional<z.ZodString>;
|
|
395
|
+
projects: z.ZodArray<z.ZodObject<{
|
|
396
|
+
id: z.ZodString;
|
|
397
|
+
name: z.ZodString;
|
|
398
|
+
rootDir: z.ZodString;
|
|
399
|
+
packageManager: z.ZodOptional<z.ZodString>;
|
|
400
|
+
}, z.core.$strip>>;
|
|
401
|
+
}, z.core.$strip>;
|
|
402
|
+
type Workspace = z.infer<typeof WorkspaceSchema>;
|
|
403
|
+
|
|
404
|
+
/** What every adapter call receives: the workspace being scanned and the resolved config. */
|
|
405
|
+
interface AdapterContext {
|
|
406
|
+
root: string;
|
|
407
|
+
workspace: Workspace;
|
|
408
|
+
config: GlossicConfig;
|
|
409
|
+
}
|
|
410
|
+
interface DiscoverContext extends AdapterContext {
|
|
411
|
+
project: Project;
|
|
412
|
+
}
|
|
413
|
+
/** A unit as discovery found it: paths only, before a single file has been read. */
|
|
414
|
+
interface DiscoveredUnit {
|
|
415
|
+
id: string;
|
|
416
|
+
projectId: string;
|
|
417
|
+
name: string;
|
|
418
|
+
path: string;
|
|
419
|
+
files: string[];
|
|
420
|
+
testFiles: string[];
|
|
421
|
+
ignoredFiles: string[];
|
|
422
|
+
}
|
|
423
|
+
interface ExtractContext extends DiscoverContext {
|
|
424
|
+
units: DiscoveredUnit[];
|
|
425
|
+
}
|
|
426
|
+
interface ExtractResult {
|
|
427
|
+
units: Unit[];
|
|
428
|
+
relations: Relation[];
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Turns a project's files into units. `detect` decides whether this adapter
|
|
432
|
+
* claims the project; the first one that says yes wins.
|
|
433
|
+
*/
|
|
434
|
+
interface Adapter {
|
|
435
|
+
readonly name: string;
|
|
436
|
+
detect(ctx: DiscoverContext): Promise<boolean>;
|
|
437
|
+
discover(ctx: DiscoverContext): Promise<DiscoveredUnit[]>;
|
|
438
|
+
extract(ctx: ExtractContext): Promise<ExtractResult>;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/** Why a completion failed, in the vocabulary every provider maps its own errors onto. */
|
|
442
|
+
type ProviderErrorCode = "not-installed" | "unauthenticated" | "timeout" | "rate-limit" | "server" | "exit-code" | "invalid-output" | "invalid-content" | "refused" | "api";
|
|
443
|
+
interface ProviderErrorOptions {
|
|
444
|
+
provider: string;
|
|
445
|
+
code: ProviderErrorCode;
|
|
446
|
+
message: string;
|
|
447
|
+
detail?: string | undefined;
|
|
448
|
+
cause?: unknown;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* A completion failure carrying a code, so callers can react to the kind of
|
|
452
|
+
* failure without parsing the message.
|
|
453
|
+
*/
|
|
454
|
+
declare class ProviderError extends Error {
|
|
455
|
+
readonly provider: string;
|
|
456
|
+
readonly code: ProviderErrorCode;
|
|
457
|
+
readonly detail: string | undefined;
|
|
458
|
+
constructor(options: ProviderErrorOptions);
|
|
459
|
+
}
|
|
460
|
+
declare const isProviderError: (value: unknown) => value is ProviderError;
|
|
461
|
+
/** True for the codes worth another attempt: timeout, rate limit, server error. */
|
|
462
|
+
declare const isRetryableProviderError: (value: unknown) => boolean;
|
|
463
|
+
|
|
464
|
+
/** Bumped by hand when the manifest shape changes. */
|
|
465
|
+
declare const MANIFEST_VERSION = "1";
|
|
466
|
+
/** A whole scan, serialised. `generatedAt` is its only volatile field. */
|
|
467
|
+
declare const ManifestSchema: z.ZodObject<{
|
|
468
|
+
version: z.ZodString;
|
|
469
|
+
generatedAt: z.ZodString;
|
|
470
|
+
workspace: z.ZodObject<{
|
|
471
|
+
name: z.ZodString;
|
|
472
|
+
root: z.ZodString;
|
|
473
|
+
isMonorepo: z.ZodBoolean;
|
|
474
|
+
tool: z.ZodEnum<{
|
|
475
|
+
pnpm: "pnpm";
|
|
476
|
+
"npm-workspaces": "npm-workspaces";
|
|
477
|
+
turbo: "turbo";
|
|
478
|
+
nx: "nx";
|
|
479
|
+
lerna: "lerna";
|
|
480
|
+
none: "none";
|
|
481
|
+
}>;
|
|
482
|
+
packageManager: z.ZodOptional<z.ZodString>;
|
|
483
|
+
projects: z.ZodArray<z.ZodObject<{
|
|
484
|
+
id: z.ZodString;
|
|
485
|
+
name: z.ZodString;
|
|
486
|
+
rootDir: z.ZodString;
|
|
487
|
+
packageManager: z.ZodOptional<z.ZodString>;
|
|
488
|
+
}, z.core.$strip>>;
|
|
489
|
+
}, z.core.$strip>;
|
|
490
|
+
units: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
491
|
+
id: z.ZodString;
|
|
492
|
+
projectId: z.ZodString;
|
|
493
|
+
kind: z.ZodEnum<{
|
|
494
|
+
file: "file";
|
|
495
|
+
directory: "directory";
|
|
496
|
+
module: "module";
|
|
497
|
+
}>;
|
|
498
|
+
name: z.ZodString;
|
|
499
|
+
path: z.ZodString;
|
|
500
|
+
facts: z.ZodObject<{
|
|
501
|
+
base: z.ZodObject<{
|
|
502
|
+
files: z.ZodArray<z.ZodObject<{
|
|
503
|
+
path: z.ZodString;
|
|
504
|
+
language: z.ZodString;
|
|
505
|
+
bytes: z.ZodNumber;
|
|
506
|
+
}, z.core.$strip>>;
|
|
507
|
+
testFiles: z.ZodArray<z.ZodObject<{
|
|
508
|
+
path: z.ZodString;
|
|
509
|
+
language: z.ZodString;
|
|
510
|
+
bytes: z.ZodNumber;
|
|
511
|
+
}, z.core.$strip>>;
|
|
512
|
+
ignoredFiles: z.ZodArray<z.ZodObject<{
|
|
513
|
+
path: z.ZodString;
|
|
514
|
+
language: z.ZodString;
|
|
515
|
+
bytes: z.ZodNumber;
|
|
516
|
+
}, z.core.$strip>>;
|
|
517
|
+
languages: z.ZodArray<z.ZodObject<{
|
|
518
|
+
language: z.ZodString;
|
|
519
|
+
count: z.ZodNumber;
|
|
520
|
+
}, z.core.$strip>>;
|
|
521
|
+
roleHint: z.ZodNullable<z.ZodEnum<{
|
|
522
|
+
components: "components";
|
|
523
|
+
config: "config";
|
|
524
|
+
controllers: "controllers";
|
|
525
|
+
dtos: "dtos";
|
|
526
|
+
entities: "entities";
|
|
527
|
+
hooks: "hooks";
|
|
528
|
+
middleware: "middleware";
|
|
529
|
+
models: "models";
|
|
530
|
+
routes: "routes";
|
|
531
|
+
services: "services";
|
|
532
|
+
tests: "tests";
|
|
533
|
+
utils: "utils";
|
|
534
|
+
}>>;
|
|
535
|
+
}, z.core.$strip>;
|
|
536
|
+
symbols: z.ZodOptional<z.ZodObject<{
|
|
537
|
+
symbols: z.ZodArray<z.ZodObject<{
|
|
538
|
+
name: z.ZodString;
|
|
539
|
+
kind: z.ZodEnum<{
|
|
540
|
+
function: "function";
|
|
541
|
+
enum: "enum";
|
|
542
|
+
type: "type";
|
|
543
|
+
class: "class";
|
|
544
|
+
const: "const";
|
|
545
|
+
interface: "interface";
|
|
546
|
+
method: "method";
|
|
547
|
+
other: "other";
|
|
548
|
+
}>;
|
|
549
|
+
file: z.ZodString;
|
|
550
|
+
signature: z.ZodOptional<z.ZodString>;
|
|
551
|
+
exported: z.ZodBoolean;
|
|
552
|
+
line: z.ZodOptional<z.ZodNumber>;
|
|
553
|
+
}, z.core.$strip>>;
|
|
554
|
+
}, z.core.$strip>>;
|
|
555
|
+
framework: z.ZodOptional<z.ZodObject<{
|
|
556
|
+
name: z.ZodString;
|
|
557
|
+
role: z.ZodOptional<z.ZodString>;
|
|
558
|
+
routes: z.ZodArray<z.ZodObject<{
|
|
559
|
+
method: z.ZodString;
|
|
560
|
+
path: z.ZodString;
|
|
561
|
+
handler: z.ZodOptional<z.ZodString>;
|
|
562
|
+
}, z.core.$strip>>;
|
|
563
|
+
dependencies: z.ZodArray<z.ZodString>;
|
|
564
|
+
}, z.core.$strip>>;
|
|
565
|
+
producedBy: z.ZodArray<z.ZodString>;
|
|
566
|
+
}, z.core.$strip>;
|
|
567
|
+
hash: z.ZodString;
|
|
568
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
569
|
+
}, z.core.$strip>>>;
|
|
570
|
+
relations: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
571
|
+
from: z.ZodString;
|
|
572
|
+
to: z.ZodString;
|
|
573
|
+
kind: z.ZodEnum<{
|
|
574
|
+
imports: "imports";
|
|
575
|
+
calls: "calls";
|
|
576
|
+
extends: "extends";
|
|
577
|
+
implements: "implements";
|
|
578
|
+
injects: "injects";
|
|
579
|
+
exposes: "exposes";
|
|
580
|
+
references: "references";
|
|
581
|
+
contains: "contains";
|
|
582
|
+
}>;
|
|
583
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
584
|
+
}, z.core.$strip>>>;
|
|
585
|
+
}, z.core.$strip>;
|
|
586
|
+
type Manifest = z.infer<typeof ManifestSchema>;
|
|
587
|
+
|
|
588
|
+
/** One prompt on its way to a provider, in terms no provider owns. */
|
|
589
|
+
declare const CompletionRequestSchema: z.ZodObject<{
|
|
590
|
+
system: z.ZodOptional<z.ZodString>;
|
|
591
|
+
prompt: z.ZodString;
|
|
592
|
+
model: z.ZodOptional<z.ZodString>;
|
|
593
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
594
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
595
|
+
metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
596
|
+
}, z.core.$strip>;
|
|
597
|
+
type CompletionRequest = z.infer<typeof CompletionRequestSchema>;
|
|
598
|
+
/** Token counts a provider reports back, when it reports them at all. */
|
|
599
|
+
declare const CompletionUsageSchema: z.ZodObject<{
|
|
600
|
+
inputTokens: z.ZodNumber;
|
|
601
|
+
outputTokens: z.ZodNumber;
|
|
602
|
+
cacheReadTokens: z.ZodOptional<z.ZodNumber>;
|
|
603
|
+
}, z.core.$strip>;
|
|
604
|
+
type CompletionUsage = z.infer<typeof CompletionUsageSchema>;
|
|
605
|
+
/** The prose a provider wrote, plus whatever it can say about what it cost. */
|
|
606
|
+
declare const CompletionResultSchema: z.ZodObject<{
|
|
607
|
+
text: z.ZodString;
|
|
608
|
+
model: z.ZodString;
|
|
609
|
+
usage: z.ZodOptional<z.ZodObject<{
|
|
610
|
+
inputTokens: z.ZodNumber;
|
|
611
|
+
outputTokens: z.ZodNumber;
|
|
612
|
+
cacheReadTokens: z.ZodOptional<z.ZodNumber>;
|
|
613
|
+
}, z.core.$strip>>;
|
|
614
|
+
costUsd: z.ZodOptional<z.ZodNumber>;
|
|
615
|
+
raw: z.ZodOptional<z.ZodUnknown>;
|
|
616
|
+
}, z.core.$strip>;
|
|
617
|
+
type CompletionResult = z.infer<typeof CompletionResultSchema>;
|
|
618
|
+
/** Writes prose from a prompt. `available` is what provider auto-detection probes. */
|
|
619
|
+
interface Provider {
|
|
620
|
+
readonly name: string;
|
|
621
|
+
available(): Promise<boolean>;
|
|
622
|
+
complete(request: CompletionRequest): Promise<CompletionResult>;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
/** Rewrites a native path with posix separators, so output matches on every OS. */
|
|
626
|
+
declare const toPosix: (value: string) => string;
|
|
627
|
+
/** Posix path from one location to another, "." when they are the same. */
|
|
628
|
+
declare const relativePosix: (from: string, target: string) => string;
|
|
629
|
+
/** Joins two posix fragments, tolerating "." or "" on either side. */
|
|
630
|
+
declare const joinPosix: (base: string, segment: string) => string;
|
|
631
|
+
|
|
632
|
+
/** Total order over strings, so a sort never depends on the machine's locale. */
|
|
633
|
+
declare const compareStrings: (a: string, b: string) => number;
|
|
634
|
+
/** Sorts a copy by a string key, leaving the input untouched. */
|
|
635
|
+
declare const sortBy: <T>(values: readonly T[], key: (value: T) => string) => T[];
|
|
636
|
+
|
|
637
|
+
export { type Adapter, type AdapterContext, type BaseFacts, BaseFactsSchema, type CompletionRequest, CompletionRequestSchema, type CompletionResult, CompletionResultSchema, type CompletionUsage, CompletionUsageSchema, type DiscoverContext, type DiscoveredUnit, type ExtractContext, type ExtractResult, type Facts, FactsSchema, type FileFact, FileFactSchema, type FrameworkFacts, FrameworkFactsSchema, type GlossicConfig, GlossicConfigSchema, type GlossicUserConfig, type LanguageCount, LanguageCountSchema, MANIFEST_VERSION, type Manifest, ManifestSchema, type OutputConfig, OutputConfigSchema, type Project, ProjectSchema, type Provider, ProviderError, type ProviderErrorCode, type ProviderErrorOptions, type Relation, type RelationKind, RelationKindSchema, RelationSchema, type RoleHint, RoleHintSchema, type RouteFact, RouteFactSchema, type SymbolFact, SymbolFactSchema, type SymbolFacts, SymbolFactsSchema, type SymbolKind, SymbolKindSchema, type Unit, type UnitKind, UnitKindSchema, UnitSchema, type Workspace, WorkspaceSchema, type WorkspaceTool, WorkspaceToolSchema, compareStrings, defineConfig, isProviderError, isRetryableProviderError, joinPosix, relativePosix, sortBy, toPosix };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
// src/config.ts
|
|
5
|
+
var OutputConfigSchema = z.object({
|
|
6
|
+
dir: z.string().default("docs"),
|
|
7
|
+
manifest: z.string().default(".glossic/manifest.json")
|
|
8
|
+
});
|
|
9
|
+
var GlossicConfigSchema = z.object({
|
|
10
|
+
include: z.array(z.string()).default(["**/*"]),
|
|
11
|
+
exclude: z.array(z.string()).default(["**/node_modules/**", "**/dist/**", "**/vendor/**"]),
|
|
12
|
+
adapters: z.array(z.string()).default(["nestjs", "treesitter", "generic"]),
|
|
13
|
+
ignoreUnits: z.array(z.string()).default([
|
|
14
|
+
"*.config.ts",
|
|
15
|
+
"*.config.mts",
|
|
16
|
+
"*.config.cts",
|
|
17
|
+
"*.config.js",
|
|
18
|
+
"*.config.mjs",
|
|
19
|
+
"*.config.cjs",
|
|
20
|
+
"*.config.json",
|
|
21
|
+
"tsconfig*.json",
|
|
22
|
+
"package.json",
|
|
23
|
+
".*",
|
|
24
|
+
"**/migrations/**",
|
|
25
|
+
"**/migration/**",
|
|
26
|
+
"**/seeders/**",
|
|
27
|
+
"**/seeds/**",
|
|
28
|
+
"**/__generated__/**",
|
|
29
|
+
"**/generated/**",
|
|
30
|
+
"**/*.generated.*"
|
|
31
|
+
]),
|
|
32
|
+
excludeFromContent: z.array(z.string()).default(["**/*.test.*", "**/*.spec.*", "**/__tests__/**"]),
|
|
33
|
+
mergeChildrenInto: z.number().int().positive().default(25),
|
|
34
|
+
minUnitFiles: z.number().int().positive().default(3),
|
|
35
|
+
maxUnitFiles: z.number().int().positive().default(10),
|
|
36
|
+
provider: z.string().optional(),
|
|
37
|
+
model: z.string().optional(),
|
|
38
|
+
lang: z.string().default("en"),
|
|
39
|
+
uiLang: z.enum(["en", "es"]).default("en"),
|
|
40
|
+
temperature: z.number().min(0).max(2).optional(),
|
|
41
|
+
output: OutputConfigSchema.default({ dir: "docs", manifest: ".glossic/manifest.json" }),
|
|
42
|
+
concurrency: z.number().int().positive().default(3),
|
|
43
|
+
timeoutMs: z.number().int().positive().default(3e5)
|
|
44
|
+
});
|
|
45
|
+
var defineConfig = (config) => config;
|
|
46
|
+
|
|
47
|
+
// src/errors.ts
|
|
48
|
+
var RETRYABLE_CODES = /* @__PURE__ */ new Set([
|
|
49
|
+
"timeout",
|
|
50
|
+
"rate-limit",
|
|
51
|
+
"server"
|
|
52
|
+
]);
|
|
53
|
+
var ProviderError = class extends Error {
|
|
54
|
+
provider;
|
|
55
|
+
code;
|
|
56
|
+
detail;
|
|
57
|
+
constructor(options) {
|
|
58
|
+
super(options.message, options.cause === void 0 ? {} : { cause: options.cause });
|
|
59
|
+
this.name = "ProviderError";
|
|
60
|
+
this.provider = options.provider;
|
|
61
|
+
this.code = options.code;
|
|
62
|
+
this.detail = options.detail;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
var isProviderError = (value) => {
|
|
66
|
+
return value instanceof ProviderError;
|
|
67
|
+
};
|
|
68
|
+
var isRetryableProviderError = (value) => {
|
|
69
|
+
return isProviderError(value) && RETRYABLE_CODES.has(value.code);
|
|
70
|
+
};
|
|
71
|
+
var WorkspaceToolSchema = z.enum([
|
|
72
|
+
"pnpm",
|
|
73
|
+
"npm-workspaces",
|
|
74
|
+
"turbo",
|
|
75
|
+
"nx",
|
|
76
|
+
"lerna",
|
|
77
|
+
"none"
|
|
78
|
+
]);
|
|
79
|
+
var ProjectSchema = z.object({
|
|
80
|
+
id: z.string().min(1),
|
|
81
|
+
name: z.string().min(1),
|
|
82
|
+
rootDir: z.string().min(1),
|
|
83
|
+
packageManager: z.string().optional()
|
|
84
|
+
});
|
|
85
|
+
var WorkspaceSchema = z.object({
|
|
86
|
+
name: z.string().min(1),
|
|
87
|
+
root: z.string().min(1),
|
|
88
|
+
isMonorepo: z.boolean(),
|
|
89
|
+
tool: WorkspaceToolSchema,
|
|
90
|
+
packageManager: z.string().optional(),
|
|
91
|
+
projects: z.array(ProjectSchema)
|
|
92
|
+
});
|
|
93
|
+
var UnitKindSchema = z.enum(["directory", "module", "file"]);
|
|
94
|
+
var RoleHintSchema = z.enum([
|
|
95
|
+
"components",
|
|
96
|
+
"config",
|
|
97
|
+
"controllers",
|
|
98
|
+
"dtos",
|
|
99
|
+
"entities",
|
|
100
|
+
"hooks",
|
|
101
|
+
"middleware",
|
|
102
|
+
"models",
|
|
103
|
+
"routes",
|
|
104
|
+
"services",
|
|
105
|
+
"tests",
|
|
106
|
+
"utils"
|
|
107
|
+
]);
|
|
108
|
+
var FileFactSchema = z.object({
|
|
109
|
+
path: z.string().min(1),
|
|
110
|
+
language: z.string().min(1),
|
|
111
|
+
bytes: z.number().int().nonnegative()
|
|
112
|
+
});
|
|
113
|
+
var LanguageCountSchema = z.object({
|
|
114
|
+
language: z.string().min(1),
|
|
115
|
+
count: z.number().int().positive()
|
|
116
|
+
});
|
|
117
|
+
var BaseFactsSchema = z.object({
|
|
118
|
+
files: z.array(FileFactSchema),
|
|
119
|
+
testFiles: z.array(FileFactSchema),
|
|
120
|
+
ignoredFiles: z.array(FileFactSchema),
|
|
121
|
+
languages: z.array(LanguageCountSchema),
|
|
122
|
+
roleHint: RoleHintSchema.nullable()
|
|
123
|
+
});
|
|
124
|
+
var SymbolKindSchema = z.enum([
|
|
125
|
+
"class",
|
|
126
|
+
"const",
|
|
127
|
+
"enum",
|
|
128
|
+
"function",
|
|
129
|
+
"interface",
|
|
130
|
+
"method",
|
|
131
|
+
"type",
|
|
132
|
+
"other"
|
|
133
|
+
]);
|
|
134
|
+
var SymbolFactSchema = z.object({
|
|
135
|
+
name: z.string().min(1),
|
|
136
|
+
kind: SymbolKindSchema,
|
|
137
|
+
file: z.string().min(1),
|
|
138
|
+
signature: z.string().optional(),
|
|
139
|
+
exported: z.boolean(),
|
|
140
|
+
line: z.number().int().positive().optional()
|
|
141
|
+
});
|
|
142
|
+
var SymbolFactsSchema = z.object({
|
|
143
|
+
symbols: z.array(SymbolFactSchema)
|
|
144
|
+
});
|
|
145
|
+
var RouteFactSchema = z.object({
|
|
146
|
+
method: z.string().min(1),
|
|
147
|
+
path: z.string().min(1),
|
|
148
|
+
handler: z.string().optional()
|
|
149
|
+
});
|
|
150
|
+
var FrameworkFactsSchema = z.object({
|
|
151
|
+
name: z.string().min(1),
|
|
152
|
+
role: z.string().optional(),
|
|
153
|
+
routes: z.array(RouteFactSchema),
|
|
154
|
+
dependencies: z.array(z.string())
|
|
155
|
+
});
|
|
156
|
+
var FactsSchema = z.object({
|
|
157
|
+
base: BaseFactsSchema,
|
|
158
|
+
symbols: SymbolFactsSchema.optional(),
|
|
159
|
+
framework: FrameworkFactsSchema.optional(),
|
|
160
|
+
producedBy: z.array(z.string().min(1)).min(1)
|
|
161
|
+
});
|
|
162
|
+
var UnitSchema = z.object({
|
|
163
|
+
id: z.string().min(1),
|
|
164
|
+
projectId: z.string().min(1),
|
|
165
|
+
kind: UnitKindSchema,
|
|
166
|
+
name: z.string().min(1),
|
|
167
|
+
path: z.string().min(1),
|
|
168
|
+
facts: FactsSchema,
|
|
169
|
+
hash: z.string().min(1),
|
|
170
|
+
summary: z.string().optional()
|
|
171
|
+
});
|
|
172
|
+
var RelationKindSchema = z.enum([
|
|
173
|
+
"imports",
|
|
174
|
+
"calls",
|
|
175
|
+
"extends",
|
|
176
|
+
"implements",
|
|
177
|
+
"injects",
|
|
178
|
+
"exposes",
|
|
179
|
+
"references",
|
|
180
|
+
"contains"
|
|
181
|
+
]);
|
|
182
|
+
var RelationSchema = z.object({
|
|
183
|
+
from: z.string().min(1),
|
|
184
|
+
to: z.string().min(1),
|
|
185
|
+
kind: RelationKindSchema,
|
|
186
|
+
weight: z.number().optional()
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
// src/manifest.ts
|
|
190
|
+
var MANIFEST_VERSION = "1";
|
|
191
|
+
var ManifestSchema = z.object({
|
|
192
|
+
version: z.string().min(1),
|
|
193
|
+
generatedAt: z.string().min(1),
|
|
194
|
+
workspace: WorkspaceSchema,
|
|
195
|
+
units: z.array(UnitSchema).default([]),
|
|
196
|
+
relations: z.array(RelationSchema).default([])
|
|
197
|
+
});
|
|
198
|
+
var CompletionRequestSchema = z.object({
|
|
199
|
+
system: z.string().optional(),
|
|
200
|
+
prompt: z.string().min(1),
|
|
201
|
+
model: z.string().optional(),
|
|
202
|
+
maxTokens: z.number().int().positive().optional(),
|
|
203
|
+
temperature: z.number().min(0).max(2).optional(),
|
|
204
|
+
metadata: z.record(z.string(), z.unknown()).default({})
|
|
205
|
+
});
|
|
206
|
+
var CompletionUsageSchema = z.object({
|
|
207
|
+
inputTokens: z.number().int().nonnegative(),
|
|
208
|
+
outputTokens: z.number().int().nonnegative(),
|
|
209
|
+
cacheReadTokens: z.number().int().nonnegative().optional()
|
|
210
|
+
});
|
|
211
|
+
var CompletionResultSchema = z.object({
|
|
212
|
+
text: z.string(),
|
|
213
|
+
model: z.string(),
|
|
214
|
+
usage: CompletionUsageSchema.optional(),
|
|
215
|
+
costUsd: z.number().nonnegative().optional(),
|
|
216
|
+
raw: z.unknown().optional()
|
|
217
|
+
});
|
|
218
|
+
var toPosix = (value) => value.split(path.sep).join("/");
|
|
219
|
+
var relativePosix = (from, target) => {
|
|
220
|
+
const relative = toPosix(path.relative(from, target));
|
|
221
|
+
return relative === "" ? "." : relative;
|
|
222
|
+
};
|
|
223
|
+
var joinPosix = (base, segment) => {
|
|
224
|
+
if (base === "." || base === "") {
|
|
225
|
+
return segment;
|
|
226
|
+
}
|
|
227
|
+
if (segment === "." || segment === "") {
|
|
228
|
+
return base;
|
|
229
|
+
}
|
|
230
|
+
return `${base}/${segment}`;
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
// src/utils/strings.ts
|
|
234
|
+
var compareStrings = (a, b) => {
|
|
235
|
+
if (a < b) return -1;
|
|
236
|
+
if (a > b) return 1;
|
|
237
|
+
return 0;
|
|
238
|
+
};
|
|
239
|
+
var sortBy = (values, key) => {
|
|
240
|
+
return [...values].sort((a, b) => compareStrings(key(a), key(b)));
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
export { BaseFactsSchema, CompletionRequestSchema, CompletionResultSchema, CompletionUsageSchema, FactsSchema, FileFactSchema, FrameworkFactsSchema, GlossicConfigSchema, LanguageCountSchema, MANIFEST_VERSION, ManifestSchema, OutputConfigSchema, ProjectSchema, ProviderError, RelationKindSchema, RelationSchema, RoleHintSchema, RouteFactSchema, SymbolFactSchema, SymbolFactsSchema, SymbolKindSchema, UnitKindSchema, UnitSchema, WorkspaceSchema, WorkspaceToolSchema, compareStrings, defineConfig, isProviderError, isRetryableProviderError, joinPosix, relativePosix, sortBy, toPosix };
|
|
244
|
+
//# sourceMappingURL=index.js.map
|
|
245
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/config.ts","../src/errors.ts","../src/workspace.ts","../src/unit.ts","../src/manifest.ts","../src/provider.ts","../src/utils/paths.ts","../src/utils/strings.ts"],"names":["z"],"mappings":";;;;AAGO,IAAM,kBAAA,GAAqB,EAAE,MAAA,CAAO;AAAA,EACzC,GAAA,EAAU,CAAA,CAAE,MAAA,EAAO,CAAE,QAAQ,MAA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,OAAA,KAA4B;AAClE,EAAA,IAAI,IAAA,KAAS,GAAA,IAAO,IAAA,KAAS,EAAA,EAAI;AAC/B,IAAA,OAAO,OAAA;AAAA,EACT;AAEA,EAAA,IAAI,OAAA,KAAY,GAAA,IAAO,OAAA,KAAY,EAAA,EAAI;AACrC,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,OAAO,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,OAAO,CAAA,CAAA;AAC3B;;;ACtBO,IAAM,cAAA,GAAiB,CAAC,CAAA,EAAW,CAAA,KAAsB;AAC9D,EAAA,IAAI,CAAA,GAAI,GAAG,OAAO,EAAA;AAClB,EAAA,IAAI,CAAA,GAAI,GAAG,OAAO,CAAA;AAElB,EAAA,OAAO,CAAA;AACT;AAGO,IAAM,MAAA,GAAS,CAAI,MAAA,EAAsB,GAAA,KAAmC;AACjF,EAAA,OAAO,CAAC,GAAG,MAAM,CAAA,CAAE,KAAK,CAAC,CAAA,EAAG,CAAA,KAAM,cAAA,CAAe,IAAI,CAAC,CAAA,EAAG,GAAA,CAAI,CAAC,CAAC,CAAC,CAAA;AAClE","file":"index.js","sourcesContent":["import { z } from \"zod\";\n\n/** Where generate and scan write, relative to the workspace root. */\nexport const OutputConfigSchema = z.object({\n dir : z.string().default(\"docs\"),\n manifest: z.string().default(\".glossic/manifest.json\"),\n});\nexport type OutputConfig = z.infer<typeof OutputConfigSchema>;\n\n\n/** Every option glossic accepts, with the default that applies when nothing sets it. */\nexport const GlossicConfigSchema = z.object({\n include : z.array(z.string()).default([\"**/*\"]),\n exclude : z.array(z.string()).default([\"**/node_modules/**\", \"**/dist/**\", \"**/vendor/**\"]),\n adapters : z.array(z.string()).default([\"nestjs\", \"treesitter\", \"generic\"]),\n ignoreUnits: z\n .array(z.string())\n .default([\n \"*.config.ts\",\n \"*.config.mts\",\n \"*.config.cts\",\n \"*.config.js\",\n \"*.config.mjs\",\n \"*.config.cjs\",\n \"*.config.json\",\n \"tsconfig*.json\",\n \"package.json\",\n \".*\",\n \"**/migrations/**\",\n \"**/migration/**\",\n \"**/seeders/**\",\n \"**/seeds/**\",\n \"**/__generated__/**\",\n \"**/generated/**\",\n \"**/*.generated.*\",\n ]),\n\n excludeFromContent: z\n .array(z.string())\n .default([\"**/*.test.*\", \"**/*.spec.*\", \"**/__tests__/**\"]),\n\n mergeChildrenInto: z.number().int().positive().default(25),\n minUnitFiles : z.number().int().positive().default(3),\n maxUnitFiles : z.number().int().positive().default(10),\n provider : z.string().optional(),\n model : z.string().optional(),\n lang : z.string().default(\"en\"),\n uiLang : z.enum([\"en\", \"es\"]).default(\"en\"),\n temperature : z.number().min(0).max(2).optional(),\n output : OutputConfigSchema.default({ dir: \"docs\", manifest: \".glossic/manifest.json\" }),\n concurrency : z.number().int().positive().default(3),\n timeoutMs : z.number().int().positive().default(300_000),\n});\n\n\n/**\n * `GlossicConfig` is the config once the defaults are applied, so every key is\n * present; `GlossicUserConfig` is the same shape as a person writes it.\n */\nexport type GlossicConfig = z.infer<typeof GlossicConfigSchema>;\nexport type GlossicUserConfig = z.input<typeof GlossicConfigSchema>;\n\n/** Types a glossic.config.ts without making the project import zod. */\nexport const defineConfig = (config: GlossicUserConfig): GlossicUserConfig => config;\n","/** Why a completion failed, in the vocabulary every provider maps its own errors onto. */\nexport type ProviderErrorCode =\n | \"not-installed\"\n | \"unauthenticated\"\n | \"timeout\"\n | \"rate-limit\"\n | \"server\"\n | \"exit-code\"\n | \"invalid-output\"\n | \"invalid-content\"\n | \"refused\"\n | \"api\";\n\n\nconst RETRYABLE_CODES: ReadonlySet<ProviderErrorCode> = new Set([\n \"timeout\",\n \"rate-limit\",\n \"server\",\n]);\n\nexport interface ProviderErrorOptions {\n provider : string;\n code : ProviderErrorCode;\n message : string;\n detail ?: string | undefined;\n cause ?: unknown;\n}\n\n/**\n * A completion failure carrying a code, so callers can react to the kind of\n * failure without parsing the message.\n */\nexport class ProviderError extends Error {\n readonly provider: string;\n readonly code : ProviderErrorCode;\n readonly detail : string | undefined;\n\n constructor(options: ProviderErrorOptions) {\n super(options.message, options.cause === undefined ? {} : { cause: options.cause });\n this.name = \"ProviderError\";\n this.provider = options.provider;\n this.code = options.code;\n this.detail = options.detail;\n }\n}\n\nexport const isProviderError = (value: unknown): value is ProviderError => {\n return value instanceof ProviderError;\n}\n\n/** True for the codes worth another attempt: timeout, rate limit, server error. */\nexport const isRetryableProviderError = (value: unknown): boolean => {\n return isProviderError(value) && RETRYABLE_CODES.has(value.code);\n}\n","import { z } from \"zod\";\n\n/** The tool that defines the project list, or \"none\" for a single-project repo. */\nexport const WorkspaceToolSchema = z.enum([\n \"pnpm\",\n \"npm-workspaces\",\n \"turbo\",\n \"nx\",\n \"lerna\",\n \"none\",\n]);\n\nexport type WorkspaceTool = z.infer<typeof WorkspaceToolSchema>;\n\n\n/** One package inside the workspace. */\nexport const ProjectSchema = z.object({\n id : z.string().min(1),\n name : z.string().min(1),\n rootDir : z.string().min(1),\n packageManager: z.string().optional(),\n});\n\nexport type Project = z.infer<typeof ProjectSchema>;\n\n\n/** The scanned repository and the projects found inside it. */\nexport const WorkspaceSchema = z.object({\n name : z.string().min(1),\n root : z.string().min(1),\n isMonorepo : z.boolean(),\n tool : WorkspaceToolSchema,\n packageManager: z.string().optional(),\n projects : z.array(ProjectSchema),\n});\n\nexport type Workspace = z.infer<typeof WorkspaceSchema>;\n","import { z } from \"zod\";\n\nexport const UnitKindSchema = z.enum([\"directory\", \"module\", \"file\"]);\nexport type UnitKind = z.infer<typeof UnitKindSchema>;\n\n/** What a directory appears to hold, inferred from its name. */\nexport const RoleHintSchema = z.enum([\n \"components\",\n \"config\",\n \"controllers\",\n \"dtos\",\n \"entities\",\n \"hooks\",\n \"middleware\",\n \"models\",\n \"routes\",\n \"services\",\n \"tests\",\n \"utils\",\n]);\nexport type RoleHint = z.infer<typeof RoleHintSchema>;\n\n\n/** One documentable file: where it lives, its language and its size. */\nexport const FileFactSchema = z.object({\n path : z.string().min(1),\n language: z.string().min(1),\n bytes : z.number().int().nonnegative(),\n});\nexport type FileFact = z.infer<typeof FileFactSchema>;\n\n\nexport const LanguageCountSchema = z.object({\n language: z.string().min(1),\n count : z.number().int().positive(),\n});\nexport type LanguageCount = z.infer<typeof LanguageCountSchema>;\n\n\n/** What any adapter can state about a unit, whatever the language. */\nexport const BaseFactsSchema = z.object({\n files : z.array(FileFactSchema),\n testFiles : z.array(FileFactSchema),\n ignoredFiles: z.array(FileFactSchema),\n languages : z.array(LanguageCountSchema),\n roleHint : RoleHintSchema.nullable(),\n});\nexport type BaseFacts = z.infer<typeof BaseFactsSchema>;\n\n\nexport const SymbolKindSchema = z.enum([\n \"class\",\n \"const\",\n \"enum\",\n \"function\",\n \"interface\",\n \"method\",\n \"type\",\n \"other\",\n]);\nexport type SymbolKind = z.infer<typeof SymbolKindSchema>;\n\n\n/** One declaration a language-aware adapter recognised. */\nexport const SymbolFactSchema = z.object({\n name : z.string().min(1),\n kind : SymbolKindSchema,\n file : z.string().min(1),\n signature: z.string().optional(),\n exported : z.boolean(),\n line : z.number().int().positive().optional(),\n});\nexport type SymbolFact = z.infer<typeof SymbolFactSchema>;\n\n\nexport const SymbolFactsSchema = z.object({\n symbols: z.array(SymbolFactSchema),\n});\nexport type SymbolFacts = z.infer<typeof SymbolFactsSchema>;\n\n\n/** One HTTP route a framework-aware adapter recognised. */\nexport const RouteFactSchema = z.object({\n method : z.string().min(1),\n path : z.string().min(1),\n handler: z.string().optional(),\n});\nexport type RouteFact = z.infer<typeof RouteFactSchema>;\n\n\n/** What a framework-aware adapter adds on top of the base facts. */\nexport const FrameworkFactsSchema = z.object({\n name : z.string().min(1),\n role : z.string().optional(),\n routes : z.array(RouteFactSchema),\n dependencies: z.array(z.string()),\n});\nexport type FrameworkFacts = z.infer<typeof FrameworkFactsSchema>;\n\n\n/** Everything known about a unit; `producedBy` names the adapters that contributed. */\nexport const FactsSchema = z.object({\n base : BaseFactsSchema,\n symbols : SymbolFactsSchema.optional(),\n framework : FrameworkFactsSchema.optional(),\n producedBy: z.array(z.string().min(1)).min(1),\n});\nexport type Facts = z.infer<typeof FactsSchema>;\n\n\n/** A documentable chunk of a project: the thing one page of documentation describes. */\nexport const UnitSchema = z.object({\n id : z.string().min(1),\n projectId: z.string().min(1),\n kind : UnitKindSchema,\n name : z.string().min(1),\n path : z.string().min(1),\n facts : FactsSchema,\n hash : z.string().min(1),\n summary : z.string().optional(),\n});\nexport type Unit = z.infer<typeof UnitSchema>;\n\n\nexport const RelationKindSchema = z.enum([\n \"imports\",\n \"calls\",\n \"extends\",\n \"implements\",\n \"injects\",\n \"exposes\",\n \"references\",\n \"contains\",\n]);\nexport type RelationKind = z.infer<typeof RelationKindSchema>;\n\n\n/** A directed edge between two units, by unit id. */\nexport const RelationSchema = z.object({\n from : z.string().min(1),\n to : z.string().min(1),\n kind : RelationKindSchema,\n weight: z.number().optional(),\n});\nexport type Relation = z.infer<typeof RelationSchema>;\n","import { z } from \"zod\";\nimport { WorkspaceSchema } from \"./workspace.js\";\nimport { RelationSchema, UnitSchema } from \"./unit.js\";\n\n/** Bumped by hand when the manifest shape changes. */\nexport const MANIFEST_VERSION = \"1\";\n\n\n/** A whole scan, serialised. `generatedAt` is its only volatile field. */\nexport const ManifestSchema = z.object({\n version : z.string().min(1),\n generatedAt: z.string().min(1),\n workspace : WorkspaceSchema,\n units : z.array(UnitSchema).default([]),\n relations : z.array(RelationSchema).default([]),\n});\nexport type Manifest = z.infer<typeof ManifestSchema>;\n","import { z } from \"zod\";\n\n/** One prompt on its way to a provider, in terms no provider owns. */\nexport const CompletionRequestSchema = z.object({\n system : z.string().optional(),\n prompt : z.string().min(1),\n model : z.string().optional(),\n maxTokens : z.number().int().positive().optional(),\n temperature: z.number().min(0).max(2).optional(),\n metadata : z.record(z.string(), z.unknown()).default({}),\n});\nexport type CompletionRequest = z.infer<typeof CompletionRequestSchema>;\n\n\n/** Token counts a provider reports back, when it reports them at all. */\nexport const CompletionUsageSchema = z.object({\n inputTokens : z.number().int().nonnegative(),\n outputTokens : z.number().int().nonnegative(),\n cacheReadTokens: z.number().int().nonnegative().optional(),\n});\nexport type CompletionUsage = z.infer<typeof CompletionUsageSchema>;\n\n\n/** The prose a provider wrote, plus whatever it can say about what it cost. */\nexport const CompletionResultSchema = z.object({\n text : z.string(),\n model : z.string(),\n usage : CompletionUsageSchema.optional(),\n costUsd: z.number().nonnegative().optional(),\n raw : z.unknown().optional(),\n});\nexport type CompletionResult = z.infer<typeof CompletionResultSchema>;\n\n\n/** Writes prose from a prompt. `available` is what provider auto-detection probes. */\nexport interface Provider {\n readonly name : string;\n available() : Promise<boolean>;\n complete(request: CompletionRequest): Promise<CompletionResult>;\n}\n","import path from \"node:path\";\n\n/** Rewrites a native path with posix separators, so output matches on every OS. */\nexport const toPosix = (value: string): string => value.split(path.sep).join(\"/\");\n\n\n/** Posix path from one location to another, \".\" when they are the same. */\nexport const relativePosix = (from: string, target: string): string => {\n const relative = toPosix(path.relative(from, target));\n return relative === \"\" ? \".\" : relative;\n};\n\n\n/** Joins two posix fragments, tolerating \".\" or \"\" on either side. */\nexport const joinPosix = (base: string, segment: string): string => {\n if (base === \".\" || base === \"\") {\n return segment;\n }\n\n if (segment === \".\" || segment === \"\") {\n return base;\n }\n \n return `${base}/${segment}`;\n};\n","\n/** Total order over strings, so a sort never depends on the machine's locale. */\nexport const compareStrings = (a: string, b: string): number => {\n if (a < b) return -1;\n if (a > b) return 1;\n\n return 0;\n};\n\n/** Sorts a copy by a string key, leaving the input untouched. */\nexport const sortBy = <T>(values: readonly T[], key: (value: T) => string): T[] => {\n return [...values].sort((a, b) => compareStrings(key(a), key(b)));\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@glossic/schema",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Zod schemas and inferred types shared across glossic",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"documentation",
|
|
7
|
+
"docs",
|
|
8
|
+
"docs-as-code",
|
|
9
|
+
"glossic",
|
|
10
|
+
"schema",
|
|
11
|
+
"zod",
|
|
12
|
+
"types"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"author": "Rody Huancas",
|
|
16
|
+
"homepage": "https://github.com/rody-huancas/glosik#readme",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/rody-huancas/glosik.git",
|
|
20
|
+
"directory": "packages/schema"
|
|
21
|
+
},
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/rody-huancas/glosik/issues"
|
|
24
|
+
},
|
|
25
|
+
"type": "module",
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=20"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist"
|
|
31
|
+
],
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"main": "./dist/index.js",
|
|
36
|
+
"module": "./dist/index.js",
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"exports": {
|
|
39
|
+
".": {
|
|
40
|
+
"types": "./dist/index.d.ts",
|
|
41
|
+
"import": "./dist/index.js",
|
|
42
|
+
"default": "./dist/index.js"
|
|
43
|
+
},
|
|
44
|
+
"./package.json": "./package.json"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "tsup",
|
|
48
|
+
"dev": "tsup --watch",
|
|
49
|
+
"test": "vitest run",
|
|
50
|
+
"typecheck": "tsc --noEmit"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"zod": "^4.1.5"
|
|
54
|
+
}
|
|
55
|
+
}
|