@oprt/manifest 0.0.0-stage → 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/README.md +59 -2
- package/agent-prompt.md +60 -0
- package/dist/components.json +1 -0
- package/dist/guidance.json +1 -0
- package/dist/index.cjs +172 -0
- package/dist/index.d.cts +1326 -0
- package/dist/index.d.ts +1326 -0
- package/dist/index.js +135 -0
- package/dist/manifest.json +4946 -0
- package/dist/manifest.schema.json +341 -0
- package/package.json +61 -3
package/dist/index.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// src/schema.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var PropSchema = z.discriminatedUnion("type", [
|
|
4
|
+
z.object({
|
|
5
|
+
type: z.literal("enum"),
|
|
6
|
+
values: z.array(z.string()).min(1),
|
|
7
|
+
default: z.string().optional(),
|
|
8
|
+
required: z.boolean().optional(),
|
|
9
|
+
description: z.string().optional()
|
|
10
|
+
}),
|
|
11
|
+
z.object({
|
|
12
|
+
type: z.literal("boolean"),
|
|
13
|
+
default: z.boolean().optional(),
|
|
14
|
+
required: z.boolean().optional(),
|
|
15
|
+
description: z.string().optional()
|
|
16
|
+
}),
|
|
17
|
+
z.object({
|
|
18
|
+
type: z.literal("string"),
|
|
19
|
+
default: z.string().optional(),
|
|
20
|
+
required: z.boolean().optional(),
|
|
21
|
+
description: z.string().optional()
|
|
22
|
+
}),
|
|
23
|
+
z.object({
|
|
24
|
+
type: z.literal("number"),
|
|
25
|
+
default: z.number().optional(),
|
|
26
|
+
required: z.boolean().optional(),
|
|
27
|
+
description: z.string().optional()
|
|
28
|
+
}),
|
|
29
|
+
z.object({
|
|
30
|
+
type: z.literal("function"),
|
|
31
|
+
required: z.boolean().optional(),
|
|
32
|
+
description: z.string().optional()
|
|
33
|
+
}),
|
|
34
|
+
z.object({
|
|
35
|
+
type: z.literal("array"),
|
|
36
|
+
items: z.record(z.unknown()).optional(),
|
|
37
|
+
required: z.boolean().optional(),
|
|
38
|
+
description: z.string().optional()
|
|
39
|
+
}),
|
|
40
|
+
z.object({
|
|
41
|
+
type: z.literal("node"),
|
|
42
|
+
required: z.boolean().optional(),
|
|
43
|
+
description: z.string().optional()
|
|
44
|
+
}),
|
|
45
|
+
z.object({
|
|
46
|
+
type: z.literal("union"),
|
|
47
|
+
types: z.array(z.enum(["boolean", "string", "number", "function", "array", "node"])).min(2).refine((types) => new Set(types).size === types.length, "Union members must be distinct"),
|
|
48
|
+
required: z.boolean().optional(),
|
|
49
|
+
description: z.string().optional()
|
|
50
|
+
})
|
|
51
|
+
]);
|
|
52
|
+
var SlotSchema = z.object({
|
|
53
|
+
type: z.string(),
|
|
54
|
+
required: z.boolean().optional()
|
|
55
|
+
});
|
|
56
|
+
var ComponentSchema = z.object({
|
|
57
|
+
description: z.string().min(1),
|
|
58
|
+
props: z.record(PropSchema),
|
|
59
|
+
slots: z.record(SlotSchema).optional(),
|
|
60
|
+
composable_with: z.array(z.string()).optional(),
|
|
61
|
+
never_inside: z.array(z.string()).optional(),
|
|
62
|
+
example: z.string().min(1)
|
|
63
|
+
});
|
|
64
|
+
var SafeSourcePath = z.string().regex(
|
|
65
|
+
/^(?:[A-Za-z0-9_-]+\/)*[A-Za-z0-9_-]+\.(?:tsx|ts)$/,
|
|
66
|
+
"Expected a safe relative TypeScript source path"
|
|
67
|
+
);
|
|
68
|
+
var PatternSchema = z.object({
|
|
69
|
+
description: z.string().min(1),
|
|
70
|
+
composed_of: z.array(z.string()).min(1),
|
|
71
|
+
layout: z.string().min(1),
|
|
72
|
+
files: z.record(SafeSourcePath, z.string().min(1)).optional(),
|
|
73
|
+
dependencies: z.array(z.string().min(1)).optional()
|
|
74
|
+
});
|
|
75
|
+
var PatternSummarySchema = z.object({
|
|
76
|
+
description: z.string().min(1),
|
|
77
|
+
composed_of: z.array(z.string()).min(1),
|
|
78
|
+
layout: z.string().min(1),
|
|
79
|
+
dependencies: z.array(z.string().min(1)).optional(),
|
|
80
|
+
files: z.record(SafeSourcePath, z.number().int().nonnegative()).optional(),
|
|
81
|
+
install: z.string().min(1)
|
|
82
|
+
});
|
|
83
|
+
var CompositionRuleSchema = z.lazy(
|
|
84
|
+
() => z.object({
|
|
85
|
+
allowed_children: z.array(z.string()),
|
|
86
|
+
children: z.record(CompositionRuleSchema).optional()
|
|
87
|
+
})
|
|
88
|
+
);
|
|
89
|
+
var SEMVER = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
|
|
90
|
+
var Version = z.string().regex(SEMVER, "version must be semver (X.Y.Z)");
|
|
91
|
+
var ManifestSchema = z.object({
|
|
92
|
+
version: Version,
|
|
93
|
+
components: z.record(ComponentSchema),
|
|
94
|
+
composition_rules: z.record(CompositionRuleSchema).optional(),
|
|
95
|
+
patterns: z.record(PatternSchema).optional()
|
|
96
|
+
});
|
|
97
|
+
var ComponentsManifestSchema = z.object({
|
|
98
|
+
version: Version,
|
|
99
|
+
components: z.record(ComponentSchema),
|
|
100
|
+
composition_rules: z.record(CompositionRuleSchema).optional(),
|
|
101
|
+
patterns: z.record(PatternSummarySchema).optional()
|
|
102
|
+
});
|
|
103
|
+
var GuidanceRuleSchema = z.object({
|
|
104
|
+
id: z.string().regex(/^[a-z][a-z0-9-]*$/, "A rule id is lower-case words joined by hyphens"),
|
|
105
|
+
rule: z.string().min(1),
|
|
106
|
+
wrong: z.string().min(1).optional(),
|
|
107
|
+
right: z.string().min(1).optional()
|
|
108
|
+
});
|
|
109
|
+
var ComponentGuidanceSchema = z.object({
|
|
110
|
+
/** Short phrases for the need it answers, the way a person would ask for it. */
|
|
111
|
+
use_for: z.array(z.string().min(1)).min(1).optional(),
|
|
112
|
+
/** For a part that only lives inside another component: that component. */
|
|
113
|
+
part_of: z.string().min(1).optional(),
|
|
114
|
+
/** Needs that look like this component's and belong to another. */
|
|
115
|
+
not_for: z.array(z.object({ need: z.string().min(1), use: z.string().min(1) })).optional(),
|
|
116
|
+
/** Per option prop: a note for each of its values. */
|
|
117
|
+
values: z.record(z.record(z.string().min(1))).optional()
|
|
118
|
+
});
|
|
119
|
+
var GuidanceSchema = z.object({
|
|
120
|
+
rules: z.array(GuidanceRuleSchema),
|
|
121
|
+
components: z.record(ComponentGuidanceSchema)
|
|
122
|
+
});
|
|
123
|
+
export {
|
|
124
|
+
ComponentGuidanceSchema,
|
|
125
|
+
ComponentSchema,
|
|
126
|
+
ComponentsManifestSchema,
|
|
127
|
+
CompositionRuleSchema,
|
|
128
|
+
GuidanceRuleSchema,
|
|
129
|
+
GuidanceSchema,
|
|
130
|
+
ManifestSchema,
|
|
131
|
+
PatternSchema,
|
|
132
|
+
PatternSummarySchema,
|
|
133
|
+
PropSchema,
|
|
134
|
+
SlotSchema
|
|
135
|
+
};
|