fix(plugin): avoid high compression silence fixture (#1717)

This commit is contained in:
Miguel Ángel
2026-06-25 11:20:11 -04:00
committed by GitHub
parent 0558b8761e
commit 96ab4b18a4
3 changed files with 33 additions and 1 deletions
+1 -1
View File
@@ -32,7 +32,7 @@
"player:perf": "bun run --filter @hyperframes/player perf",
"format:check": "oxfmt --check .",
"knip": "knip",
"test:scripts": "node --import tsx --test scripts/validate-release-channel.test.mjs scripts/draft-changelog.test.ts scripts/set-version.test.ts scripts/release-prepare.test.ts scripts/cli-options.test.ts scripts/changelog-weekly.test.ts",
"test:scripts": "node --import tsx --test scripts/validate-release-channel.test.mjs scripts/draft-changelog.test.ts scripts/set-version.test.ts scripts/release-prepare.test.ts scripts/cli-options.test.ts scripts/changelog-weekly.test.ts scripts/claude-plugin-compression.test.ts",
"generate:previews": "tsx scripts/generate-template-previews.ts",
"generate:catalog-previews": "tsx scripts/generate-catalog-previews.ts",
"upload:docs-images": "bash scripts/upload-docs-images.sh",
+32
View File
@@ -0,0 +1,32 @@
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { dirname, resolve } from "node:path";
import { describe, it } from "node:test";
import { fileURLToPath } from "node:url";
import { deflateRawSync } from "node:zlib";
const REPO_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");
const MAX_INSTALL_COMPRESSION_RATIO = 50;
const CLAUDE_PLUGIN_PAYLOAD_FILES = [
"packages/producer/tests/missing-host-comp-id/src/silence.wav",
] as const;
function compressionRatio(bytes: Buffer): number {
const compressedBytes = deflateRawSync(bytes).byteLength;
return bytes.byteLength / compressedBytes;
}
describe("Claude plugin install payload", () => {
it("keeps bundled files below the suspicious compression-ratio guard", () => {
for (const relativePath of CLAUDE_PLUGIN_PAYLOAD_FILES) {
const bytes = readFileSync(resolve(REPO_ROOT, relativePath));
const ratio = compressionRatio(bytes);
assert.ok(
ratio <= MAX_INSTALL_COMPRESSION_RATIO,
`${relativePath} compresses at ${ratio.toFixed(1)}:1, above the ${MAX_INSTALL_COMPRESSION_RATIO}:1 install guard`,
);
}
});
});