repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by admin

release: validate all extensions for v0.1.0

047160e48bda03f587f26378a91ce96f04fd91ae

Oliver Jan Krylow <oliver@bugabinga.net> ·

SSH signature · not checked

Browse filesCompare with HEAD

Changed files (10)

.ci/ci.kdl

Modified
3 3 job "ci" {
4 4 image "mcr.microsoft.com/playwright:v1.61.0-noble"
5 5 trigger {
6 6 push {
7 7 branch "trunk"
8 + tag "v*"
10 11 cache "home" {
18 19 run "mise trust"
19 20 run "mise install"
20 21 // Luci's capability-free container replaces Firefox's incompatible content sandbox.
21 - run "CI=true MOZ_DISABLE_CONTENT_SANDBOX=1 mise run ci"
22 + run "CI=true MOZ_DISABLE_CONTENT_SANDBOX=1 mise run //:ci"
23 + artifact "release" {
24 + path ".pi/tmp/release-artifacts/manifest.json"
25 + required true
26 + }
27 + publish "pkg" {
28 + from ".pi/tmp/release-artifacts"
29 + to "pi-ext/${rev}"
30 + }

.gitignore

Modified
7 7 **/test-results/
8 8 **/playwright-report/
9 9 /.pi/tmp/
10 +/.pi/release/
11 +/.home/
10 12 **/.test-home/
11 13 **/.test-state/
12 14 **/.test-config/

.rumdl.toml

Modified
62 62 exclude = [
63 63 "**/node_modules/**",
64 64 "dist/**",
65 + ".home/**",
66 + ".pi/tmp/**",
67 + ".pi/release/**",
65 68 ".research/**",
66 69 "skills/*/references/**",
67 70 "skills/*/_research/**",

CHANGELOG.md

Modified
2 2 # Changelog
4 4 ## Unreleased
6 +## 0.1.0
8 +- Build all 40 extensions as minified, self-contained packages with one repository version
9 +- Validate relocated packages and exact archive bytes; publish release archives with SHA-256 manifests through Luci
10 +- Ship one root installation package containing every extension, plus individual extension archives
11 +- Exclude cached CI toolchains from source linting
6 12 - Raise web fetch and map visible-output limit to 100,000 characters and improve invalid-argument errors
7 13 - Optimize uv spawn-hook command checks and PATH rewriting; add benchmark, profiling, and comparison tasks
8 14 - Add uv blockers for `pip3` and Poetry commands with uv guidance

biome.jsonc

Modified
18 18 "!.rumdl_cache",
19 19 "!.worktrees",
20 20 "!!**/.pi/tmp",
21 + "!!**/.pi/release",
22 + "!!**/.home",
21 23 "!!**/.test-home",
22 24 "!skills/find-skills",
23 25 "!check/fixtures",

mise.toml

Modified
245 245 "node scripts/extensions.mjs check",
248 +[tasks.release-all]
249 +description = "Build and validate all release packages and exact archives"
250 +depends = ["install"]
251 +run = "node --no-warnings scripts/build/release.ts"
248 253 [tasks.ci]
249 254 description = "Release gate"
250 255 run = [
251 256 { tasks = ["check", "lint"] },
252 257 { task = "test" },
253 258 { task = "e2e" },
259 + { task = "release-all" },
256 262 [tasks.list]

package-lock.json

Modified
2 2 "name": "pi-ext",
3 - "version": "0.0.3",
3 + "version": "0.1.0",
4 4 "lockfileVersion": 3,
5 5 "requires": true,
6 6 "packages": {
7 7 "": {
8 8 "name": "pi-ext",
9 - "version": "0.0.3",
9 + "version": "0.1.0",
10 10 "workspaces": [
11 11 "extensions/*"

package.json

Modified
2 2 "name": "pi-ext",
3 - "version": "0.0.3",
3 + "version": "0.1.0",
4 4 "private": true,
5 5 "type": "module",
6 6 "workspaces": [

scripts/build/release.test.ts

Added
new file mode 100644
1 +import {
2 + mkdirSync,
3 + mkdtempSync,
4 + readFileSync,
5 + rmSync,
6 + symlinkSync,
7 + writeFileSync,
8 +} from "node:fs";
9 +import { join } from "node:path";
10 +import { afterEach, describe, expect, it } from "vitest";
11 +import { ROOT } from "./build.ts";
12 +import { archivePackage, collectionManifest, treeDigest } from "./release.ts";
14 +const roots: string[] = [];
15 +afterEach(() => {
16 + for (const root of roots.splice(0))
17 + rmSync(root, { recursive: true, force: true });
18 +});
20 +describe("repository release", () => {
21 + it("exposes every extension and resource from the root installation unit", () => {
22 + expect(
23 + collectionManifest("0.1.0", [
24 + { name: "a", pi: { extensions: ["index.js"], skills: ["skills"] } },
25 + { name: "b", pi: { extensions: ["entry.js"], prompts: ["prompts"] } },
26 + ]),
27 + ).toEqual({
28 + name: "pi-ext",
29 + version: "0.1.0",
30 + private: true,
31 + type: "module",
32 + pi: {
33 + extensions: ["packages/a/index.js", "packages/b/entry.js"],
34 + skills: ["packages/a/skills"],
35 + prompts: ["packages/b/prompts"],
36 + },
37 + });
38 + });
40 + it("archives exact package bytes and records their SHA-256", () => {
41 + const scratch = join(ROOT, ".pi", "tmp");
42 + mkdirSync(scratch, { recursive: true });
43 + const root = mkdtempSync(join(scratch, "release-test-"));
44 + roots.push(root);
45 + const pkg = join(root, "package");
46 + mkdirSync(pkg);
47 + writeFileSync(join(pkg, "index.js"), "export default () => {};\n");
48 + symlinkSync("index.js", join(pkg, "entry.js"));
49 + const digest = treeDigest(pkg);
50 + const archive = join(root, "package.tgz");
51 + expect(archivePackage(pkg, archive, root)).toMatch(/^[a-f0-9]{64}$/u);
52 + expect(readFileSync(archive).length).toBeGreaterThan(0);
53 + expect(treeDigest(pkg)).toBe(digest);
54 + writeFileSync(join(pkg, "index.js"), "changed\n");
55 + expect(treeDigest(pkg)).not.toBe(digest);
56 + writeFileSync(join(root, "outside.js"), "outside\n");
57 + symlinkSync("../outside.js", join(pkg, "escape.js"));
58 + expect(() => treeDigest(pkg)).toThrow(/Symlink escapes package/u);
59 + });
60 +});

scripts/build/release.ts

Added
new file mode 100644
1 +import { spawnSync } from "node:child_process";
2 +import { createHash } from "node:crypto";
3 +import {
4 + cpSync,
5 + lstatSync,
6 + mkdirSync,
7 + mkdtempSync,
8 + readFileSync,
9 + readlinkSync,
10 + realpathSync,
11 + rmSync,
12 + writeFileSync,
13 +} from "node:fs";
14 +import { join, sep } from "node:path";
15 +import {
16 + allExtensionNames,
17 + buildExtension,
18 + ROOT,
19 + rootVersion,
20 +} from "./build.ts";
21 +import { listFiles } from "./publish.ts";
22 +import { readBuildSpec } from "./spec.ts";
23 +import { verifyCollection, verifyPackage } from "./verify.ts";
25 +export function treeDigest(dir: string): string {
26 + const hash = createHash("sha256");
27 + for (const file of listFiles(dir)) {
28 + const path = join(dir, file);
29 + const stat = lstatSync(path);
30 + if (stat.isSymbolicLink()) {
31 + if (!realpathSync(path).startsWith(realpathSync(dir) + sep))
32 + throw new Error(`Symlink escapes package: ${path}`);
33 + hash.update(`${file}\0link:${readlinkSync(path)}\n`);
34 + } else {
35 + if (!stat.isFile()) throw new Error(`Not a regular file: ${path}`);
36 + const digest = createHash("sha256")
37 + .update(readFileSync(path))
38 + .digest("hex");
39 + hash.update(`${file}\0file:${digest}\n`);
40 + }
41 + }
42 + return hash.digest("hex");
45 +export function collectionManifest(
46 + version: string,
47 + packages: Array<{ name: string; pi: Record<string, string[]> }>,
48 +) {
49 + const pi: Record<string, string[]> = {};
50 + for (const pkg of packages) {
51 + for (const [kind, paths] of Object.entries(pkg.pi)) {
52 + pi[kind] ??= [];
53 + pi[kind].push(...paths.map((path) => `packages/${pkg.name}/${path}`));
54 + }
55 + }
56 + return { name: "pi-ext", version, private: true, type: "module", pi };
59 +function tar(args: string[]): void {
60 + const result = spawnSync("tar", args, { encoding: "utf8" });
61 + if (result.status !== 0) throw new Error(`tar failed: ${result.stderr}`);
64 +/** Validate the actual archived bytes, not just the pre-pack directory. */
65 +export function archivePackage(
66 + dir: string,
67 + archive: string,
68 + scratch: string,
69 +): string {
70 + const digest = treeDigest(dir);
71 + tar(["-czf", archive, "-C", dir, "."]);
72 + const extracted = mkdtempSync(join(scratch, "extract-"));
73 + try {
74 + tar(["-xzf", archive, "-C", extracted]);
75 + if (treeDigest(extracted) !== digest)
76 + throw new Error(`Archive differs from package: ${archive}`);
77 + } finally {
78 + rmSync(extracted, { recursive: true, force: true });
79 + }
80 + return createHash("sha256").update(readFileSync(archive)).digest("hex");
83 +export async function releaseAll(): Promise<void> {
84 + const version = rootVersion();
85 + const scratch = join(ROOT, ".pi", "tmp");
86 + mkdirSync(scratch, { recursive: true });
87 + const stage = mkdtempSync(join(scratch, "release-"));
88 + const output = join(scratch, "release-artifacts");
89 + // This task owns only its disposable artifact output, never dist or source.
90 + rmSync(output, { recursive: true, force: true });
91 + mkdirSync(output, { recursive: true });
92 + const packages = [];
93 + const receipts = [];
94 + try {
95 + for (const name of allExtensionNames()) {
96 + const built = await buildExtension(name, {
97 + distRoot: join(stage, "packages"),
98 + release: true,
99 + });
100 + const report = await verifyPackage(built.dir, {
101 + externals: readBuildSpec(join(ROOT, "extensions", name)).externals,
102 + });
103 + if (!report.ok) throw new Error(`${name}: ${JSON.stringify(report)}`);
104 + const pkg = JSON.parse(
105 + readFileSync(join(built.dir, "package.json"), "utf8"),
106 + );
107 + packages.push({ name, pi: pkg.pi });
108 + const file = `${name}-${version}.tgz`;
109 + const digest = treeDigest(built.dir);
110 + const sha256 = archivePackage(built.dir, join(output, file), scratch);
111 + receipts.push({ extension: name, version, file, sha256, digest });
112 + console.log(
113 + `OK release ${name}@${version}: relocated load + archive bytes`,
114 + );
116 + writeFileSync(
117 + join(stage, "package.json"),
118 + `${JSON.stringify(collectionManifest(version, packages), null, "\t")}\n`,
119 + );
120 + cpSync(join(ROOT, "README.md"), join(stage, "README.md"));
121 + const collection = await verifyCollection([stage]);
122 + if (!collection.ok)
123 + throw new Error(`Collection: ${JSON.stringify(collection)}`);
124 + const file = `pi-ext-${version}.tgz`;
125 + const sha256 = archivePackage(stage, join(output, file), scratch);
126 + writeFileSync(
127 + join(output, "manifest.json"),
128 + `${JSON.stringify({ version, collection: { file, sha256, digest: treeDigest(stage) }, extensions: receipts }, null, "\t")}\n`,
129 + );
130 + console.log(
131 + `OK release pi-ext@${version}: ${packages.length} extensions; ${output}`,
132 + );
133 + } catch (error) {
134 + rmSync(output, { recursive: true, force: true });
135 + throw error;
136 + } finally {
137 + rmSync(stage, { recursive: true, force: true });
141 +if (import.meta.main) await releaseAll();