@ikenga/contract 0.4.0 → 0.5.1
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/browser.d.ts +624 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +264 -0
- package/dist/browser.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/registry.d.ts +2258 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +92 -0
- package/dist/registry.js.map +1 -0
- package/package.json +9 -1
- package/schemas/registry/index-v1.json +54 -0
- package/schemas/registry/pkg-detail-v1.json +655 -0
- package/src/browser.test.ts +350 -0
- package/src/browser.ts +364 -0
- package/src/index.ts +3 -1
- package/src/registry.ts +108 -0
package/src/index.ts
CHANGED
|
@@ -4,6 +4,8 @@ export * from './engine.js';
|
|
|
4
4
|
export * from './scopes.js';
|
|
5
5
|
export * from './iyke.js';
|
|
6
6
|
export * from './artifact.js';
|
|
7
|
+
export * from './registry.js';
|
|
8
|
+
export * from './browser.js';
|
|
7
9
|
|
|
8
10
|
/** This package's own version. */
|
|
9
|
-
export const CONTRACT_PACKAGE_VERSION = '0.
|
|
11
|
+
export const CONTRACT_PACKAGE_VERSION = '0.5.0' as const;
|
package/src/registry.ts
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// Ikenga registry schema — the static JSON catalog served by
|
|
2
|
+
// `Royalti-io/ikenga-registry` over GitHub Pages.
|
|
3
|
+
//
|
|
4
|
+
// Shape: a small root `index.json` lists every pkg with its latest version
|
|
5
|
+
// and a pointer to a per-pkg detail file (`pkgs/<short-name>.json`).
|
|
6
|
+
// The detail file holds the full per-version metadata (manifest, tarball
|
|
7
|
+
// URL, integrity, dep tree). Consumers (the shell, the `ikenga` CLI)
|
|
8
|
+
// fetch the root index on boot/refresh, then lazy-load detail files on
|
|
9
|
+
// demand.
|
|
10
|
+
//
|
|
11
|
+
// Source of truth for `manifest` inside a `PkgVersion` is `ManifestSchema`
|
|
12
|
+
// in this same package. Registry consumers can trust manifests because the
|
|
13
|
+
// publisher (the `ikenga-pkgs` release workflow) reads the pkg's own
|
|
14
|
+
// `manifest.json` at publish time.
|
|
15
|
+
|
|
16
|
+
import { z } from 'zod';
|
|
17
|
+
import { ManifestSchema } from './manifest.js';
|
|
18
|
+
|
|
19
|
+
export const REGISTRY_SCHEMA_VERSION = 1 as const;
|
|
20
|
+
|
|
21
|
+
// ---------- Per-pkg detail (pkgs/<short-name>.json) ----------
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Dependency on another @ikenga/pkg-* in the registry. External npm deps
|
|
25
|
+
* (non-`@ikenga/pkg-*`) are bundled into the published tarball and resolved
|
|
26
|
+
* at publish time, so they don't appear here.
|
|
27
|
+
*/
|
|
28
|
+
export const PkgDepSchema = z.object({
|
|
29
|
+
/** Full npm name, e.g. `@ikenga/pkg-engine-claude-code`. */
|
|
30
|
+
name: z.string(),
|
|
31
|
+
/** Semver range as declared in the pkg's package.json. */
|
|
32
|
+
range: z.string(),
|
|
33
|
+
});
|
|
34
|
+
export type PkgDep = z.infer<typeof PkgDepSchema>;
|
|
35
|
+
|
|
36
|
+
export const PkgVersionSchema = z.object({
|
|
37
|
+
/** Semver, e.g. `0.1.0`. */
|
|
38
|
+
version: z.string(),
|
|
39
|
+
/** ISO-8601 publish time, as reported by npm. */
|
|
40
|
+
publishedAt: z.string(),
|
|
41
|
+
/** npm tarball URL — what the shell/CLI downloads to install the pkg. */
|
|
42
|
+
tarball: z.string().url(),
|
|
43
|
+
/** SRI-style integrity (sha512-...) as returned by npm. */
|
|
44
|
+
integrity: z.string(),
|
|
45
|
+
/** Tarball size in bytes (npm `dist.unpackedSize` is unpacked; this is packed). */
|
|
46
|
+
size: z.number().int().nonnegative().optional(),
|
|
47
|
+
/** The pkg's own manifest.json contents at this version. */
|
|
48
|
+
manifest: ManifestSchema,
|
|
49
|
+
/** Cross-pkg deps within `@ikenga/pkg-*`. External deps ride in the tarball. */
|
|
50
|
+
deps: z.array(PkgDepSchema).default([]),
|
|
51
|
+
});
|
|
52
|
+
export type PkgVersion = z.infer<typeof PkgVersionSchema>;
|
|
53
|
+
|
|
54
|
+
export const PkgDetailSchema = z.object({
|
|
55
|
+
$schemaVersion: z.literal(REGISTRY_SCHEMA_VERSION),
|
|
56
|
+
/** Full npm name, e.g. `@ikenga/pkg-engine-claude-code`. */
|
|
57
|
+
name: z.string(),
|
|
58
|
+
/** ISO-8601 — last time any version was published. */
|
|
59
|
+
updatedAt: z.string(),
|
|
60
|
+
/** Newest-first. The first element is `latest`. */
|
|
61
|
+
versions: z.array(PkgVersionSchema).min(1),
|
|
62
|
+
});
|
|
63
|
+
export type PkgDetail = z.infer<typeof PkgDetailSchema>;
|
|
64
|
+
|
|
65
|
+
// ---------- Root index (index.json) ----------
|
|
66
|
+
|
|
67
|
+
export const RegistryEntrySchema = z.object({
|
|
68
|
+
/** Full npm name. */
|
|
69
|
+
name: z.string(),
|
|
70
|
+
/** Latest semver. */
|
|
71
|
+
latest: z.string(),
|
|
72
|
+
/**
|
|
73
|
+
* Relative path from `index.json` to the per-pkg detail file.
|
|
74
|
+
* Convention: `pkgs/<short-name>.json` where short-name is the npm name
|
|
75
|
+
* minus the `@ikenga/` scope and `pkg-` prefix (e.g.
|
|
76
|
+
* `@ikenga/pkg-engine-claude-code` → `engine-claude-code`).
|
|
77
|
+
*/
|
|
78
|
+
detail: z.string(),
|
|
79
|
+
/** Short description, mirrored from the manifest's `name`/`description`. */
|
|
80
|
+
description: z.string().optional(),
|
|
81
|
+
/** Manifest `kind` hint ("engine" | "skill" | "embedded" | "windowed"). */
|
|
82
|
+
kind: z.string().optional(),
|
|
83
|
+
});
|
|
84
|
+
export type RegistryEntry = z.infer<typeof RegistryEntrySchema>;
|
|
85
|
+
|
|
86
|
+
export const RegistryIndexSchema = z.object({
|
|
87
|
+
$schemaVersion: z.literal(REGISTRY_SCHEMA_VERSION),
|
|
88
|
+
/** ISO-8601 — last time any entry was added/updated. */
|
|
89
|
+
updatedAt: z.string(),
|
|
90
|
+
pkgs: z.array(RegistryEntrySchema),
|
|
91
|
+
});
|
|
92
|
+
export type RegistryIndex = z.infer<typeof RegistryIndexSchema>;
|
|
93
|
+
|
|
94
|
+
// ---------- Helpers ----------
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Canonical short-name used in detail-file paths.
|
|
98
|
+
* `@ikenga/pkg-engine-claude-code` → `engine-claude-code`
|
|
99
|
+
* `@ikenga/mcp-iyke` → `mcp-iyke`
|
|
100
|
+
*/
|
|
101
|
+
export function pkgShortName(npmName: string): string {
|
|
102
|
+
return npmName.replace(/^@ikenga\//, '').replace(/^pkg-/, '');
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Default detail-file path for a pkg name, relative to the registry root. */
|
|
106
|
+
export function pkgDetailPath(npmName: string): string {
|
|
107
|
+
return `pkgs/${pkgShortName(npmName)}.json`;
|
|
108
|
+
}
|