austere-axi 0.2.0 → 0.4.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.
@@ -0,0 +1,82 @@
1
+ // Types for the component catalog (src/shared/catalog.js) and the catalog.json
2
+ // a pack ships. Hand-written. Keep it in step with CATALOG_FORMAT.
3
+
4
+ export declare const CATALOG_FORMAT: 1;
5
+
6
+ export type Tier = "core" | "extended";
7
+
8
+ export interface CatalogEntry {
9
+ name: string;
10
+ group: string;
11
+ signature: string;
12
+ description: string;
13
+ tier: Tier;
14
+ /** "core", or the name of the pack that owns the component. */
15
+ pack: string;
16
+ examples: string[];
17
+ }
18
+
19
+ export interface CatalogGroup {
20
+ name: string;
21
+ notes: string[];
22
+ }
23
+
24
+ export interface Catalog {
25
+ format: typeof CATALOG_FORMAT;
26
+ pack: string;
27
+ version: string;
28
+ groups: CatalogGroup[];
29
+ components: CatalogEntry[];
30
+ }
31
+
32
+ /** What a pack's dist/catalog.json holds: the catalog plus the pack-only fields. */
33
+ export interface PackCatalog extends Omit<Catalog, "components"> {
34
+ /** Pack API version the bundle targets. */
35
+ api: number;
36
+ /** `sha384-<base64>` of dist/pack.js. */
37
+ integrity: string;
38
+ /** Size of dist/pack.js in bytes. */
39
+ size: number;
40
+ /** True when the pack ships CSS. */
41
+ css: boolean;
42
+ components: (CatalogEntry & { slots: string[] | null })[];
43
+ /** JSON schema $defs reachable from the pack's components. */
44
+ defs: Record<string, unknown>;
45
+ }
46
+
47
+ export interface SpecGroup {
48
+ name: string;
49
+ components: string[];
50
+ notes?: string[];
51
+ }
52
+
53
+ /** The part of an OpenUI `library.toSpec()` result that the catalog reads. */
54
+ export interface LibrarySpec {
55
+ components: Record<string, { signature: string; description?: string }>;
56
+ componentGroups?: SpecGroup[];
57
+ }
58
+
59
+ export interface CatalogFromSpecOptions {
60
+ pack?: string;
61
+ version?: string;
62
+ tiers?: Record<string, string>;
63
+ examples?: Record<string, string[]>;
64
+ /** Keep just these components (a pack's own, out of a library that also holds the core). */
65
+ only?: string[] | null;
66
+ }
67
+
68
+ export declare function catalogFromSpec(spec: LibrarySpec, options?: CatalogFromSpecOptions): Catalog;
69
+
70
+ /** The spec the prompt is generated from: extended-tier components leave it. */
71
+ export declare function promptSpec<S extends LibrarySpec>(spec: S, tiers?: Record<string, string>): S;
72
+
73
+ export interface SearchOptions {
74
+ notesOf?: (entry: CatalogEntry) => string[];
75
+ limit?: number;
76
+ }
77
+
78
+ export declare function searchCatalog(
79
+ entries: CatalogEntry[],
80
+ query: string,
81
+ options?: SearchOptions,
82
+ ): { entry: CatalogEntry; score: number }[];
@@ -0,0 +1,46 @@
1
+ // Types for the pack kit (src/pack-kit/index.js, shipped as dist/pack-kit.mjs).
2
+ import type { PackCatalog } from "./catalog.js";
3
+
4
+ export { PACK_API, CONTENT_SLOTS } from "./pack.js";
5
+
6
+ export declare const ENTRY_CANDIDATES: string[];
7
+
8
+ export interface PackageJson {
9
+ name?: string;
10
+ version?: string;
11
+ austere?: { entry?: string };
12
+ [key: string]: unknown;
13
+ }
14
+
15
+ export declare function readPackageJson(dir: string): PackageJson;
16
+
17
+ /** The pack's entry module: package.json "austere.entry", else the first of ENTRY_CANDIDATES. */
18
+ export declare function packEntry(dir: string, pkg?: PackageJson): string;
19
+
20
+ export declare function sri(buffer: Uint8Array): string;
21
+
22
+ export interface BuildPackOptions {
23
+ /** Pack folder (package.json + entry module). */
24
+ dir: string;
25
+ /** The esbuild module to bundle with. */
26
+ esbuild: { build(options: any): Promise<unknown> };
27
+ /** Default <dir>/dist. */
28
+ outDir?: string;
29
+ /** Default package.json name. */
30
+ name?: string;
31
+ /** Default package.json version. */
32
+ version?: string;
33
+ /** Core component names, to warn about collisions. */
34
+ coreNames?: string[];
35
+ /** Default true. */
36
+ minify?: boolean;
37
+ }
38
+
39
+ export interface BuildPackResult {
40
+ catalog: PackCatalog;
41
+ warnings: string[];
42
+ packFile: string;
43
+ catalogFile: string;
44
+ }
45
+
46
+ export declare function buildPack(options: BuildPackOptions): Promise<BuildPackResult>;
@@ -0,0 +1,104 @@
1
+ // Types for "austere-axi/pack": what a component pack imports. Hand-written
2
+ // to match src/runtime/pack-api.js and src/runtime/define.js.
3
+ import type { ZodObject, ZodRawShape, infer as ZodInfer } from "zod";
4
+
5
+ export type { Catalog, CatalogEntry, PackCatalog, Tier } from "./catalog.js";
6
+
7
+ /** Version of the pack API. A pack built for another major version is refused. */
8
+ export declare const PACK_API: 1;
9
+
10
+ /** Slots a content component may fill besides a Stack: "Card.children" and so on. */
11
+ export declare const CONTENT_SLOTS: readonly string[];
12
+
13
+ /** What a renderer receives. `renderNode` renders a child value from the parsed program. */
14
+ export interface RendererArgs<Props> {
15
+ props: Props;
16
+ renderNode: (value: unknown) => unknown;
17
+ statementId?: string;
18
+ }
19
+
20
+ export interface ComponentSpec<Shape extends ZodRawShape = ZodRawShape> {
21
+ /** PascalCase name the agent writes. */
22
+ name: string;
23
+ /** A stock group (Layout, Content, Data, Charts, Forms, Buttons) or a short capitalized category of your own. */
24
+ group: string;
25
+ /** zod props in positional order. Append-only once published. */
26
+ props: ZodObject<Shape>;
27
+ /** One line the agent reads in `spec`. */
28
+ description: string;
29
+ /** React component: ({ props, renderNode, statementId }) => node. */
30
+ renderer: (args: RendererArgs<ZodInfer<ZodObject<Shape>>>) => unknown;
31
+ /** OpenUI statements; the first calls this component. Required unless `slots` is null. */
32
+ example?: string | string[];
33
+ /** Like `example`, with hostile input. Never in the prompt. */
34
+ stress?: string | string[];
35
+ /** Extra prompt lines, each starting with "- ". */
36
+ notes?: string[];
37
+ /** Parent slots it may fill; null for value-only sub-components. */
38
+ slots?: string[] | null;
39
+ /** Wrap the output with its statement name. Default true. */
40
+ tagged?: boolean;
41
+ /** "extended" keeps it out of the prompt. Default "core". */
42
+ tier?: "core" | "extended";
43
+ }
44
+
45
+ /** What austereComponent() returns. Put `definition.ref` in another component's props to nest it. */
46
+ export interface AustereComponent {
47
+ name: string;
48
+ group: string;
49
+ notes: string[];
50
+ slots: string[] | null;
51
+ tagged: boolean;
52
+ tier: "core" | "extended";
53
+ example: string[] | null;
54
+ stress: string[] | null;
55
+ definition: {
56
+ ref: any;
57
+ [key: string]: any;
58
+ };
59
+ }
60
+
61
+ export declare function austereComponent<Shape extends ZodRawShape>(spec: ComponentSpec<Shape>): AustereComponent;
62
+
63
+ /** What a pack's entry module default-exports. */
64
+ export interface PackModule {
65
+ components: AustereComponent | AustereComponent[];
66
+ /** CSS text the runtime adds to the page once. */
67
+ css?: string;
68
+ }
69
+
70
+ export interface PackRegistration {
71
+ name: string;
72
+ version: string;
73
+ /** Defaults to PACK_API. */
74
+ api?: number;
75
+ components: AustereComponent | (AustereComponent | AustereComponent[])[];
76
+ css?: string;
77
+ }
78
+
79
+ export interface RegisteredPack {
80
+ name: string;
81
+ version: string;
82
+ components: AustereComponent[];
83
+ css: string;
84
+ }
85
+
86
+ /** Called once by each pack bundle when it loads. The pack kit adds this call for you. */
87
+ export declare function registerPack(pack: PackRegistration): RegisteredPack;
88
+
89
+ /** Packs registered so far, in load order. */
90
+ export declare function registeredPacks(): RegisteredPack[];
91
+
92
+ export declare function onPackRegistered(fn: (pack: RegisteredPack) => void): () => boolean;
93
+
94
+ /** URL of a runtime asset next to austere.js, or "" when the page is inlined (export). */
95
+ export declare function assetUrl(name: string): string;
96
+
97
+ export interface RuntimeError {
98
+ source: string;
99
+ message: string;
100
+ statementId?: string;
101
+ [key: string]: unknown;
102
+ }
103
+
104
+ export declare function reportRuntimeError(err: RuntimeError): void;