The best way to control Claude Code, Codex and more from any computer or phone

main
ts 74 lines 2.58 KB
Raw
1 import * as Schema from "effect/Schema";
2
3 /**
4 * An npm package name, scoped or unscoped, under the rules npm applies to
5 * new packages: lowercase, URL-safe, at most 214 characters. Names end up
6 * in R2 keys, install URLs, and the markdown of comments and check runs,
7 * so nothing outside this set is ever accepted from a client.
8 */
9 export const PackageName = Schema.String.pipe(
10 Schema.check(
11 Schema.isPattern(/^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/),
12 Schema.isMaxLength(214),
13 ),
14 );
15
16 /** A display group label for the install comment: `Alchemy`, `@alchemy.run`. */
17 export const GroupName = Schema.String.pipe(
18 Schema.check(Schema.isPattern(/^[@A-Za-z0-9][A-Za-z0-9 ._@/-]{0,63}$/)),
19 );
20
21 /**
22 * One packed workspace package inside a `pkg pack` artifact.
23 *
24 * Everything here is data the CLI observed while packing. The registry never
25 * derives a tag from it: every tag comes from the GitHub Actions run that
26 * vouched for the manifest, and R2 verifies uploaded tarball bytes against
27 * the hash they are stored under.
28 */
29 export const ManifestPackage = Schema.Struct({
30 name: PackageName,
31 /** Version from the package manifest at pack time. */
32 version: Schema.String,
33 /** Package directory relative to the workspace root, POSIX separators. */
34 dir: Schema.String,
35 group: GroupName,
36 /** Tarball file name inside the artifact directory. */
37 file: Schema.String,
38 /** Lowercase hex SHA-256 of the tarball bytes. */
39 sha256: Schema.String,
40 /** Tarball size in bytes. */
41 size: Schema.Number,
42 });
43 export type ManifestPackage = typeof ManifestPackage.Type;
44
45 /** A display group in the install comment, in the order `pkg pack` listed it. */
46 export const ManifestGroup = Schema.Struct({
47 name: GroupName,
48 /** Render the group collapsed in the install comment. */
49 collapsed: Schema.Boolean,
50 });
51 export type ManifestGroup = typeof ManifestGroup.Type;
52
53 /**
54 * The `pkg-manifest.json` written next to the tarballs by `pkg pack` and read
55 * back by `pkg publish`.
56 */
57 export const Manifest = Schema.Struct({
58 version: Schema.Literal(1),
59 groups: Schema.Array(ManifestGroup),
60 /** Registry origin the tarball dependencies were rewritten against. */
61 registry: Schema.String,
62 /**
63 * HEAD commit of the root repository at pack time. The registry requires
64 * it to be the head of the run that publishes, since that is the commit
65 * every tag names.
66 */
67 head: Schema.String,
68 packages: Schema.Array(ManifestPackage),
69 });
70 export type Manifest = typeof Manifest.Type;
71
72 export const ManifestJson = Schema.fromJsonString(Manifest);
73
74 export const MANIFEST_FILE = "pkg-manifest.json";