diff --git a/docs/developers/share-source.mdx b/docs/developers/share-source.mdx index 664aa1fdab..3a7082703b 100644 --- a/docs/developers/share-source.mdx +++ b/docs/developers/share-source.mdx @@ -31,7 +31,8 @@ through `hyperframes share --manage`. Source uses the same portable project policy as Desktop: authored HTML, scripts, styles, assets, and supported Studio edit metadata. Known credential filenames (such as `.env`, `.npmrc`, and `*.pem`), dependency directories, chat -history, local sharing state, and recorded render outputs stay out. +history, local sharing state, and recorded render outputs stay out. Files ending in `.key` stay local, +including Keynote decks. These are filename rules, not a secret scanner. `.gitignore` does not control source capture. Other regular files can be included even if Git ignores them. For example, diff --git a/packages/parsers/src/privatePath.ts b/packages/parsers/src/privatePath.ts index 3c45cb3913..253c8886d4 100644 --- a/packages/parsers/src/privatePath.ts +++ b/packages/parsers/src/privatePath.ts @@ -32,26 +32,10 @@ function withoutTrailingDotsOrSpaces(segment: string): string { return segment.slice(0, end); } -// Git metadata and env files hold commands other tools run and secrets: nothing serves or inlines them. -export function isVcsOrSecretPath(relPath: string): boolean { - return projectPathSegments(relPath).some( - (segment) => segment === ".git" || segment.startsWith(".env"), - ); -} - -// `.hyperframes/` holds the desktop app's and the CLI's own records (a hand-off, chat history, read marks): no file -// server serves any of it, the folder itself included, but Studio's own files and the assets compositions load. Studio -// reads and writes those only in the project's own `.hyperframes/`, so one in a subfolder holds records only. -const STUDIO_FILES = new Set([ - ".hyperframes/studio-motion.json", - ".hyperframes/studio-manual-edits.json", -]); -const STUDIO_FOLDERS = [".hyperframes/prepared-assets", ".hyperframes/requests"]; -const UNCONVERTED_PREVIEW_DOWNLOADS = ".hyperframes/prepared-assets/downloads"; - -// Credentials and coding-tool state that projects often sit next to: registry tokens, MCP and agent settings, cloud and -// SSH keys. No composition loads one, so no file server serves one and no upload ships one. -const CREDENTIAL_FILES = new Set([ +// Shared with the editable-source contract. Each expression matches whole normalized paths. +const anyDepth = String.raw`(?:[^/]*/)*`; +const vcsOrEnv = String.raw`(?:\.git|\.env[^/]*)(?:/.*)?`; +const credentialNames = [ ".npmrc", ".yarnrc", ".yarnrc.yml", @@ -67,8 +51,8 @@ const CREDENTIAL_FILES = new Set([ "serviceaccountkey.json", "service-account.json", "service_account.json", -]); -const CREDENTIAL_FOLDERS = new Set([ +]; +const toolFolders = [ ".ssh", ".aws", ".gnupg", @@ -82,26 +66,33 @@ const CREDENTIAL_FOLDERS = new Set([ ".gemini", ".vscode", ".idea", +]; +const alternatives = (names: string[]) => + names.map((name) => name.replaceAll(".", "\\.")).join("|"); +const keyOrStore = String.raw`id_(?:rsa|dsa|ecdsa|ed25519)[^/]*|[^/]*\.(?:pem|key|p12|pfx|p8|ppk|jks|keystore|kdbx|tfstate(?:\.backup)?|tfvars(?:\.json)?)`; +const folders = String.raw`(?:${alternatives(toolFolders)}|\.config/(?:gcloud|gh))(?:/.*)?`; +const credentials = [alternatives(credentialNames), keyOrStore, folders].join("|"); + +export const portablePrivatePattern = `${anyDepth}(?:${vcsOrEnv}|${credentials})`; +const vcsOrSecret = new RegExp(`^${anyDepth}(?:${vcsOrEnv})$`, "su"); +const credentialOrToolState = new RegExp(`^${anyDepth}(?:${credentials})$`, "su"); + +// Git metadata and env files hold commands other tools run and secrets: nothing serves or inlines them. +export function isVcsOrSecretPath(relPath: string): boolean { + return vcsOrSecret.test(projectPathSegments(relPath).join("/")); +} + +// Only known project files in the root .hyperframes directory can be served as assets. +const STUDIO_FILES = new Set([ + ".hyperframes/studio-motion.json", + ".hyperframes/studio-manual-edits.json", ]); -const CREDENTIAL_CONFIG_FOLDERS = new Set(["gcloud", "gh"]); -const KEY_FILE = - /^(?:id_(?:rsa|dsa|ecdsa|ed25519).*|.*\.(?:pem|key|p12|pfx|p8|ppk|jks|keystore|kdbx))$/; -const SECRET_STORE_FILE = /\.(?:tfstate(?:\.backup)?|tfvars(?:\.json)?)$/; +const STUDIO_FOLDERS = [".hyperframes/prepared-assets", ".hyperframes/requests"]; +const UNCONVERTED_PREVIEW_DOWNLOADS = ".hyperframes/prepared-assets/downloads"; /** Credential files and tool or agent state, for a project-relative path in any spelling Windows opens. */ export function isCredentialOrToolStatePath(relPath: string): boolean { - const segments = projectPathSegments(relPath); - const name = segments.at(-1) ?? ""; - return ( - CREDENTIAL_FILES.has(name) || - KEY_FILE.test(name) || - SECRET_STORE_FILE.test(name) || - segments.some( - (segment, at) => - CREDENTIAL_FOLDERS.has(segment) || - (segment === ".config" && CREDENTIAL_CONFIG_FOLDERS.has(segments[at + 1] ?? "")), - ) - ); + return credentialOrToolState.test(projectPathSegments(relPath).join("/")); } /** Files no composition loads, in any spelling Windows opens: git, env, credentials, tool state, app records. */ diff --git a/packages/share/README.md b/packages/share/README.md index ee2bd916c7..3271b2c18c 100644 --- a/packages/share/README.md +++ b/packages/share/README.md @@ -78,7 +78,7 @@ can use video-only; changed source, conflicts and unexpected upload failures nee an explicit choice to omit source. The CLI exposes `--video-only` for that choice. `filesForExport` only validates already-prepared source; it does not upload. -The adapter uses the portable-source-v11 capture/manifest rules and +The adapter uses the portable-source-v12 capture/manifest rules and multipart transport. The pinned policy, Unicode 15.1 registry (with its license), and manifest test vectors are checked into this repository. Source is captured through verified file handles; upload bytes are streamed and checked against their hash. diff --git a/packages/share/src/projectSnapshot.mjs b/packages/share/src/projectSnapshot.mjs index 8a9d898e45..a64d85d2ae 100644 --- a/packages/share/src/projectSnapshot.mjs +++ b/packages/share/src/projectSnapshot.mjs @@ -8,6 +8,9 @@ import path from "node:path"; import { createHash } from "node:crypto"; import { isOutsideFilm } from "./appOwnedPaths.mjs"; +export { readSourceIgnore }; +export { isPrivateSourcePath, privateSourceSpelling } from "./sources/privateSource.mjs"; + export const HF_ID_ATTRIBUTE = /\sdata-hf-id\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/g; const sha256 = (/** @type {import("node:crypto").BinaryLike} */ data) => diff --git a/packages/share/src/sources/contract/path-policy.json b/packages/share/src/sources/contract/path-policy.json index c363ddef1c..e145f73aa3 100644 --- a/packages/share/src/sources/contract/path-policy.json +++ b/packages/share/src/sources/contract/path-policy.json @@ -1,5 +1,5 @@ { - "policy_version": "portable-source-v11", + "policy_version": "portable-source-v12", "manifest": { "format_version": 1, "entrypoint": "index.html", @@ -57,7 +57,7 @@ "max_segment_bytes": 240, "separator": "/", "forbidden_characters": "<>:\"|?*\\", - "reserved_segment_regex": "(?:con|prn|aux|nul|com[1-9\u00b9\u00b2\u00b3]|lpt[1-9\u00b9\u00b2\u00b3])(?:\\..*)?", + "reserved_segment_regex": "(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³])(?:\\..*)?", "reserved_segment_match": "full match against each segment's comparison key, so CON, Con.txt and nul.tar.gz are all reserved", "canonical_spelling_roots": [ ".media", @@ -71,11 +71,13 @@ ".amazonq", ".augment", ".aws", + ".azure", ".cache", ".claude", ".cline", ".clinerules", ".codex", + ".config", ".continue", ".continuerc.json", ".crush", @@ -83,6 +85,7 @@ ".cursor", ".devcontainer", ".devcontainer.json", + ".docker", ".ds_store", ".env", ".envrc", @@ -92,9 +95,11 @@ ".git", ".git-credentials", ".gitattributes", + ".gitconfig", ".github", ".gitmodules", ".gitpod.yml", + ".gnupg", ".grok", ".hg", ".hyperframes", @@ -103,6 +108,7 @@ ".junie", ".kilocode", ".kiro", + ".kube", ".lock", ".mcp.json", ".media", @@ -293,10 +299,10 @@ }, { "id": "credential-files", - "regex": "(?:[^/]+/)*(?:\\.netrc|\\.pypirc|\\.git-credentials|[^/]*\\.(?:pem|p12|pfx)|id_rsa[^/]*|id_ed25519[^/]*|(?:\\.ssh|\\.aws)(?:/.*)?)", + "regex": "(?:[^/]+/)*(?:\\.netrc|_netrc|\\.pypirc|\\.git-credentials|\\.gitconfig|pip\\.ini|[^/]*\\.(?:pem|p12|pfx)|id_(?:rsa|dsa|ecdsa|ed25519)[^/]*|(?:\\.ssh|\\.aws|\\.gnupg|\\.docker|\\.kube|\\.azure|\\.config/(?:gcloud|gh))(?:/.*)?)", "client_action": "exclude", "server_action": "reject", - "basis": "Credential files by name at any depth. *.key is deliberately absent: Keynote decks are plausible project sources" + "basis": "Credential files and stores by name at any depth." }, { "id": "os-metadata", @@ -312,6 +318,13 @@ "server_action": "reject", "basis": "A .hyperframes folder below the project root, such as one inside a project copied into compositions/, holds that copy's client records; only the root folder's named portable files below travel" }, + { + "id": "private-source", + "regex": "(?:[^/]*/)*(?:(?:\\.git|\\.env[^/]*)(?:/.*)?|\\.npmrc|\\.yarnrc|\\.yarnrc\\.yml|\\.pypirc|pip\\.conf|pip\\.ini|\\.netrc|_netrc|\\.git-credentials|\\.gitconfig|\\.mcp\\.json|credentials\\.json|serviceaccountkey\\.json|service-account\\.json|service_account\\.json|id_(?:rsa|dsa|ecdsa|ed25519)[^/]*|[^/]*\\.(?:pem|key|p12|pfx|p8|ppk|jks|keystore|kdbx|tfstate(?:\\.backup)?|tfvars(?:\\.json)?)|(?:\\.ssh|\\.aws|\\.gnupg|\\.docker|\\.kube|\\.azure|\\.claude|\\.codex|\\.cursor|\\.agents|\\.gemini|\\.vscode|\\.idea|\\.config/(?:gcloud|gh))(?:/.*)?)", + "client_action": "exclude", + "server_action": "reject", + "basis": "The private-path rule for credentials, tool state, Git and environment files. Also match the parser spelling after NFKC, upper then lower case, removal of default-ignorable code points and Windows segment cleanup." + }, { "id": "portable-transcripts", "regex": "\\.hyperframes/transcripts/(?:[^/]+/)*[^/]+\\.json", @@ -440,7 +453,9 @@ "agent-client-state": "(?:[^/]+/)*(?:\\.claude|\\.agents|\\.cursor|\\.vscode|\\.idea)(?:/.*)?", "work-tree-config": "(?!)", "git-directory-head": "(?!)", - "nested-hyperframes-state": "(?!)" + "nested-hyperframes-state": "(?!)", + "credential-files": "(?:[^/]+/)*(?:\\.netrc|\\.pypirc|\\.git-credentials|[^/]*\\.(?:pem|p12|pfx)|id_rsa[^/]*|id_ed25519[^/]*|(?:\\.ssh|\\.aws)(?:/.*)?)", + "private-source": "(?!)" }, "legacy_short_name_alias_names": [ ".agent", @@ -483,6 +498,6 @@ ".yarnrc", ".yarnrc.yml" ], - "rule": "Only stored snapshot reads use each listed rule's regex in place of its current one, and the v10 short_name_alias_names in place of the current ones, to retain immutable manifest digests: agent-client-state its v3 regex, and work-tree-config, added in v7, git-directory-head, added in v9, and nested-hyperframes-state, added in v10, none. New captures and uploads use the current rules and short names. Clients never install, and the server never signs a download URL for, a path a current rule excludes or a segment that is a current short name." + "rule": "Only stored snapshot reads use each listed rule's regex in place of its current one, and the v10 short_name_alias_names in place of the current ones, to retain immutable manifest digests: agent-client-state its v3 regex, and work-tree-config, added in v7, git-directory-head, added in v9, and nested-hyperframes-state, added in v10, none. The credential-files rule keeps its v11 regex. New captures and uploads use the current rules and short names. Clients never install, and the server never signs a download URL for, a path a current rule excludes or a segment that is a current short name. The private-source rule applies only to current validation and delivery." } } diff --git a/packages/share/src/sources/pathPolicy.mjs b/packages/share/src/sources/pathPolicy.mjs index 31a5c6c6da..9c6b65c201 100644 --- a/packages/share/src/sources/pathPolicy.mjs +++ b/packages/share/src/sources/pathPolicy.mjs @@ -1,6 +1,7 @@ // @ts-check // Validate source manifests against the bundled sync contract. -import { isCredentialOrToolStatePath, isVcsOrSecretPath } from "@hyperframes/parsers/private-path"; +import { isPrivateSourcePath, privateSourceSpelling } from "./privateSource.mjs"; +export { isPrivateSourcePath }; import { readContract } from "./contract.mjs"; import { UNICODE_VERSION, @@ -11,7 +12,7 @@ import { withoutIgnorable, } from "./unicode.mjs"; -const PATH_POLICY_VERSION = "portable-source-v11"; +const PATH_POLICY_VERSION = "portable-source-v12"; /** @typedef {import("./types.js").PathRule} PathRule @typedef {import("./types.js").PolicyDocument} PolicyDocument */ @@ -109,10 +110,15 @@ const policy = () => (compiled ??= compile(readContract("path-policy.json"))); /** Every segment replaced by its comparison key. @param {string} path */ const foldedPath = (path) => path.split("/").map(comparisonKey).join("/"); +/** @param {{ pattern: RegExp, rule: PathRule }} entry @param {string} folded @param {string} path */ +const matches = ({ pattern, rule }, folded, path) => + pattern.test(folded) || + (rule.id === "private-source" && pattern.test(privateSourceSpelling(path))); + /** The first rule matching a path's folded spelling. @param {string} path @returns {PathRule} */ export function classifyPath(path) { const folded = foldedPath(path); - const found = policy().rules.find(({ pattern }) => pattern.test(folded)); + const found = policy().rules.find((entry) => matches(entry, folded, path)); if (!found) throw new Error("the path policy's catch-all rule did not match"); return found.rule; } @@ -169,7 +175,7 @@ export function validatePath(path, mode = "current") { if (root !== undefined && segments[0] !== root) throw new PathViolation("reserved_path_alias", path); const folded = keys.join("/"); - const found = rules.find(({ pattern }) => pattern.test(folded)); + const found = rules.find((entry) => matches(entry, folded, path)); if (!found) throw new Error("the path policy's catch-all rule did not match"); if (found.rule.server_action === "reject") throw new PathViolation("excluded_path", path, found.rule.id); @@ -246,10 +252,6 @@ export function excludedFolder(dir) { }); } -/** Private names omitted locally even when the wire contract accepts them. @param {string} path */ -export const isPrivateSourcePath = (path) => - isVcsOrSecretPath(path) || isCredentialOrToolStatePath(path); - /** A stored manifest may contain paths that are no longer eligible for upload. @param {string} path */ export function canUploadStoredPath(path) { if (isPrivateSourcePath(path)) return false; diff --git a/packages/share/src/sources/privateSource.mjs b/packages/share/src/sources/privateSource.mjs new file mode 100644 index 0000000000..719eeed23a --- /dev/null +++ b/packages/share/src/sources/privateSource.mjs @@ -0,0 +1,13 @@ +// @ts-check +import { + isCredentialOrToolStatePath, + isVcsOrSecretPath, + projectPathSegments, +} from "@hyperframes/parsers/private-path"; + +/** @param {string} path */ +export const isPrivateSourcePath = (path) => + isVcsOrSecretPath(path) || isCredentialOrToolStatePath(path); + +/** @param {string} path */ +export const privateSourceSpelling = (path) => projectPathSegments(path).join("/"); diff --git a/packages/share/tests/fixtures/compositionSync/manifest-vectors.json b/packages/share/tests/fixtures/compositionSync/manifest-vectors.json index 84530a7a6e..1844316787 100644 --- a/packages/share/tests/fixtures/compositionSync/manifest-vectors.json +++ b/packages/share/tests/fixtures/compositionSync/manifest-vectors.json @@ -1,5 +1,5 @@ { - "policy_version": "portable-source-v11", + "policy_version": "portable-source-v12", "about": "Golden vectors for the composition sync manifest. valid: build the canonical bytes from `manifest`; UTF-8 encoding `canonical` gives those bytes and `manifest_sha256` is their SHA-256. invalid: validating `manifest` fails with `error.code` (and `error.rule` for path-policy rules). limits: with `limits`, the first exceeded limit in the order file_count, file_size, project_size, manifest_size is `limit` (null: admitted). stored: base64 `body` is stored manifest bytes; reading them requires they are already canonical.", "valid": [ { @@ -306,7 +306,7 @@ "size": 9 }, { - "path": "deck.key", + "path": "deck.pdf", "sha256": "8e11a86cf1052f458f6766baba49f519b80b3eee7c35433debd93483515626d4", "size": 8 }, @@ -327,8 +327,8 @@ } ] }, - "canonical": "{\"entrypoint\":\"index.html\",\"files\":[{\"path\":\".gitignore\",\"sha256\":\"bc37d034bad564583790a46f19d807abfe519c5671395fd494d8cce506c42947\",\"size\":10},{\"path\":\".hyperframes/brand-kit.json\",\"sha256\":\"dda44abb548e99aad3ec261c6b87c5f545eb09f8fb1b261d3c75a7cfc21bfa94\",\"size\":27},{\"path\":\".hyperframes/caption-skin.html\",\"sha256\":\"a2e2d9315c6a9e3437f752e69a8514d8c662f53a9ade33db2686fa9affaa97b2\",\"size\":30},{\"path\":\".hyperframes/studio-manual-edits.json\",\"sha256\":\"450ba94d0f2fbb1ac30cc5e1dcae043e2f7f970357984a6bdfaf2f2087904fe0\",\"size\":37},{\"path\":\".hyperframes/studio-motion.json\",\"sha256\":\"205f890f2a576608d6f009ef4738fc2b81df387329f2e20bdf67356c5365b55d\",\"size\":31},{\"path\":\".hyperframes/transcription.json\",\"sha256\":\"bc0b9ef4215d81d0ae7adabc471993f63ac70a24a693f4f91b4c18a103dd9ba1\",\"size\":31},{\"path\":\".hyperframes/transcripts/a.json\",\"sha256\":\"7ffb8ceda0a4b872cc4a9ba63bdd040a70631e3343157454a95206f2fc9f27cf\",\"size\":31},{\"path\":\".hyperframes/transcripts/nested/b.json\",\"sha256\":\"a5222ca2063d161da3e06294d2ab5c6c32d7692a1177bb0f79ddde4001deb47b\",\"size\":38},{\"path\":\".hyperframesignore\",\"sha256\":\"4f7382fe2d1d64d27e88900b9997a85f9d9fa42062f04aab7426b03cabba7497\",\"size\":18},{\"path\":\".media/CREDITS.md\",\"sha256\":\"4056dedc9ad51868f89af43f34035af851bb566f6d30f804e57551da7ec0dd9c\",\"size\":17},{\"path\":\".media/images/image_001.png\",\"sha256\":\"35037cf8cd8a2d3e2b20a04563ecba015e6404678af5631c0e9e3a50fec200de\",\"size\":27},{\"path\":\".media/index.md\",\"sha256\":\"8a925d0e3cc08cd0ed4601d0f94e8a781881d1b3034d07fe11cc02d296a2ad43\",\"size\":15},{\"path\":\".media/preferences.json\",\"sha256\":\"888316c0c00d9d6929423a311f302500134d74315226a6a78a7a73bf66b4ef58\",\"size\":23},{\"path\":\".media/video/unused-take.mp4\",\"sha256\":\"a3e29b7ba3f66207df6182ec09ed749df364378cf2cfb8cf589163a6cdac93e2\",\"size\":28},{\"path\":\"CLAUDE.md\",\"sha256\":\"6ebdb617a8104a7756d0cf36578ab01103dc9f07e4dc6feb751296b9c402faf7\",\"size\":9},{\"path\":\"deck.key\",\"sha256\":\"8e11a86cf1052f458f6766baba49f519b80b3eee7c35433debd93483515626d4\",\"size\":8},{\"path\":\"docs/node_modules.md\",\"sha256\":\"ef0612da92e8204f7277982d4d3ce82b4589d200192fcfa74371a5b80365d5ba\",\"size\":20},{\"path\":\"index.html\",\"sha256\":\"0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051\",\"size\":10},{\"path\":\"notes/TRANSCRIPTS/file.bin\",\"sha256\":\"0392523321b470965a29a3ec513f460128fe11513b1dc2e2396fe510d5e67b15\",\"size\":26},{\"path\":\"templates/env.example.md\",\"sha256\":\"bf8e2a33ac126e948ed744ea606beb8f150409bbfcea9fbdf3184a710d0d3bff\",\"size\":24}],\"format_version\":1}", - "manifest_sha256": "376dac8985415bfe84d9fbc3fb8086cc6a2cfa2a8b2d8c180a8a8a2c3fef8360", + "canonical": "{\"entrypoint\":\"index.html\",\"files\":[{\"path\":\".gitignore\",\"sha256\":\"bc37d034bad564583790a46f19d807abfe519c5671395fd494d8cce506c42947\",\"size\":10},{\"path\":\".hyperframes/brand-kit.json\",\"sha256\":\"dda44abb548e99aad3ec261c6b87c5f545eb09f8fb1b261d3c75a7cfc21bfa94\",\"size\":27},{\"path\":\".hyperframes/caption-skin.html\",\"sha256\":\"a2e2d9315c6a9e3437f752e69a8514d8c662f53a9ade33db2686fa9affaa97b2\",\"size\":30},{\"path\":\".hyperframes/studio-manual-edits.json\",\"sha256\":\"450ba94d0f2fbb1ac30cc5e1dcae043e2f7f970357984a6bdfaf2f2087904fe0\",\"size\":37},{\"path\":\".hyperframes/studio-motion.json\",\"sha256\":\"205f890f2a576608d6f009ef4738fc2b81df387329f2e20bdf67356c5365b55d\",\"size\":31},{\"path\":\".hyperframes/transcription.json\",\"sha256\":\"bc0b9ef4215d81d0ae7adabc471993f63ac70a24a693f4f91b4c18a103dd9ba1\",\"size\":31},{\"path\":\".hyperframes/transcripts/a.json\",\"sha256\":\"7ffb8ceda0a4b872cc4a9ba63bdd040a70631e3343157454a95206f2fc9f27cf\",\"size\":31},{\"path\":\".hyperframes/transcripts/nested/b.json\",\"sha256\":\"a5222ca2063d161da3e06294d2ab5c6c32d7692a1177bb0f79ddde4001deb47b\",\"size\":38},{\"path\":\".hyperframesignore\",\"sha256\":\"4f7382fe2d1d64d27e88900b9997a85f9d9fa42062f04aab7426b03cabba7497\",\"size\":18},{\"path\":\".media/CREDITS.md\",\"sha256\":\"4056dedc9ad51868f89af43f34035af851bb566f6d30f804e57551da7ec0dd9c\",\"size\":17},{\"path\":\".media/images/image_001.png\",\"sha256\":\"35037cf8cd8a2d3e2b20a04563ecba015e6404678af5631c0e9e3a50fec200de\",\"size\":27},{\"path\":\".media/index.md\",\"sha256\":\"8a925d0e3cc08cd0ed4601d0f94e8a781881d1b3034d07fe11cc02d296a2ad43\",\"size\":15},{\"path\":\".media/preferences.json\",\"sha256\":\"888316c0c00d9d6929423a311f302500134d74315226a6a78a7a73bf66b4ef58\",\"size\":23},{\"path\":\".media/video/unused-take.mp4\",\"sha256\":\"a3e29b7ba3f66207df6182ec09ed749df364378cf2cfb8cf589163a6cdac93e2\",\"size\":28},{\"path\":\"CLAUDE.md\",\"sha256\":\"6ebdb617a8104a7756d0cf36578ab01103dc9f07e4dc6feb751296b9c402faf7\",\"size\":9},{\"path\":\"deck.pdf\",\"sha256\":\"8e11a86cf1052f458f6766baba49f519b80b3eee7c35433debd93483515626d4\",\"size\":8},{\"path\":\"docs/node_modules.md\",\"sha256\":\"ef0612da92e8204f7277982d4d3ce82b4589d200192fcfa74371a5b80365d5ba\",\"size\":20},{\"path\":\"index.html\",\"sha256\":\"0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051\",\"size\":10},{\"path\":\"notes/TRANSCRIPTS/file.bin\",\"sha256\":\"0392523321b470965a29a3ec513f460128fe11513b1dc2e2396fe510d5e67b15\",\"size\":26},{\"path\":\"templates/env.example.md\",\"sha256\":\"bf8e2a33ac126e948ed744ea606beb8f150409bbfcea9fbdf3184a710d0d3bff\",\"size\":24}],\"format_version\":1}", + "manifest_sha256": "d520abd030a7461b5565047aaf492b697be1e35badf6a23b6772a98ce6237792", "file_count": 20, "project_bytes": 460 }, @@ -5657,6 +5657,419 @@ "code": "excluded_path", "rule": "work-tree-config" } + }, + { + "name": "credential-docker", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "size": 1 + }, + { + "path": "nested/.DoCker/config.json", + "sha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "size": 2 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "credential-files" + } + }, + { + "name": "credential-gh", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "size": 1 + }, + { + "path": "boards/.config/gh/hosts.yml", + "sha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "size": 2 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "credential-files" + } + }, + { + "name": "credential-gcloud", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "size": 1 + }, + { + "path": ".config/gcloud/credentials.db", + "sha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "size": 2 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "credential-files" + } + }, + { + "name": "credential-gnupg", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "size": 1 + }, + { + "path": ".gnupg/data", + "sha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "size": 2 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "credential-files" + } + }, + { + "name": "credential-kube", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "size": 1 + }, + { + "path": ".kube/config", + "sha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "size": 2 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "credential-files" + } + }, + { + "name": "credential-azure", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "size": 1 + }, + { + "path": ".azure/cache.json", + "sha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "size": 2 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "credential-files" + } + }, + { + "name": "credential-pip", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "size": 1 + }, + { + "path": "pip.ini", + "sha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "size": 2 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "credential-files" + } + }, + { + "name": "credential-gitconfig", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "size": 1 + }, + { + "path": ".gitconfig", + "sha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "size": 2 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "credential-files" + } + }, + { + "name": "credential-netrc", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "size": 1 + }, + { + "path": "_netrc", + "sha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "size": 2 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "credential-files" + } + }, + { + "name": "credential-ecdsa", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "size": 1 + }, + { + "path": "id_ecdsa.pub", + "sha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "size": 2 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "credential-files" + } + }, + { + "name": "credential-dsa", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "size": 1 + }, + { + "path": "id_dsa", + "sha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "size": 2 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "credential-files" + } + }, + { + "name": "credential-short-name", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "size": 1 + }, + { + "path": "DOCKER~1/config", + "sha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "size": 2 + } + ] + }, + "error": { + "code": "segment_short_name" + } + }, + { + "name": "private-source-1", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "size": 1 + }, + { + "path": "nested/service-account.json", + "sha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "size": 2 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "private-source" + } + }, + { + "name": "private-source-2", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "size": 1 + }, + { + "path": "nested/.env-production/token", + "sha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "size": 2 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "private-source" + } + }, + { + "name": "private-source-3", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "size": 1 + }, + { + "path": "config/terraform.tfstate.backup", + "sha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "size": 2 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "private-source" + } + }, + { + "name": "private-source-4", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "size": 1 + }, + { + "path": "nested/SERVICE_ACCOUNT.JSON", + "sha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "size": 2 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "private-source" + } + }, + { + "name": "private-source-5", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "size": 1 + }, + { + "path": "assets/deck.key", + "sha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "size": 2 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "private-source" + } + }, + { + "name": "private-source-6", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "size": 1 + }, + { + "path": "nested/service-account.json", + "sha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "size": 2 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "private-source" + } } ], "limits": [ diff --git a/packages/share/tests/sourceCapture.test.mjs b/packages/share/tests/sourceCapture.test.mjs index 10d8810f80..e695e13744 100644 --- a/packages/share/tests/sourceCapture.test.mjs +++ b/packages/share/tests/sourceCapture.test.mjs @@ -355,3 +355,50 @@ test("scratch files and wildcard exclusions do not change the snapshot", async ( await writeFile(join(root, "data.json"), "{}"); assert.notEqual(await projectFingerprint(root), before); }); + +test("editable source omits credential stores while preserving authored assets", async (t) => { + const root = await project({ + "index.html": "page", + ".config/gh/hosts.yml": "fixture", + ".config/gcloud/state.db": "fixture", + "assets/.DOCKER/config.json": "{}", + ".gnupg/keys/data": "fixture", + ".kube/config": "fixture", + ".azure/settings": "fixture", + ".fonts/Inter.woff2": "font", + ".Gitignore": "output/", + ".GitHub/workflows/ci.yml": "workflow", + "assets/deck.key": "slides", + ".media/video/clip.mp4": "clip", + }); + t.after(() => rm(root, { recursive: true, force: true })); + assert.deepEqual( + captured(await captureProject(root)).manifest.document.files.map(({ path }) => path), + [ + ".GitHub/workflows/ci.yml", + ".Gitignore", + ".fonts/Inter.woff2", + ".media/video/clip.mp4", + "index.html", + ], + ); + await symlink(".config/gh/hosts.yml", join(root, "notes.txt")); + assert.deepEqual(await captureProject(root), { + at: "problems", + problems: [{ path: "notes.txt", problem: "symlink" }], + }); +}); + +test("a host can use the package snapshot entry point for private names and strict ignore rules", async (t) => { + const { isPrivateSourcePath, privateSourceSpelling, readSourceIgnore } = + await import("@hyperframes/share/projectSnapshot.mjs"); + const root = await project({ ".hyperframesignore": "scratch/\n" }); + t.after(() => rm(root, { recursive: true, force: true })); + const spelled = "Assets/Service-Account.json"; + assert.equal(privateSourceSpelling(spelled), "assets/service-account.json"); + assert.equal(isPrivateSourcePath(spelled), true); + assert.equal(isPrivateSourcePath("assets/voice.wav"), false); + const ignored = await readSourceIgnore(root); + assert.equal(ignored("scratch/draft.txt"), true); + assert.equal(ignored("assets/voice.wav"), false); +}); diff --git a/packages/share/tests/sourceManifest.test.mjs b/packages/share/tests/sourceManifest.test.mjs index ba5697d00d..d6ada420fd 100644 --- a/packages/share/tests/sourceManifest.test.mjs +++ b/packages/share/tests/sourceManifest.test.mjs @@ -1,3 +1,4 @@ +import { portablePrivatePattern } from "@hyperframes/parsers/private-path"; import { test } from "node:test"; import assert from "node:assert/strict"; import { createHash } from "node:crypto"; @@ -31,11 +32,11 @@ function refusal(run) { return null; } -test("the vectors are portable-source-v11's, and there are vectors of every kind", () => { - assert.equal(vectors.policy_version, "portable-source-v11"); +test("the vectors are portable-source-v12's, and there are vectors of every kind", () => { + assert.equal(vectors.policy_version, "portable-source-v12"); assert.deepEqual( [vectors.valid.length, vectors.invalid.length, vectors.limits.length, vectors.stored.length], - [13, 219, 5, 8], + [13, 237, 5, 8], ); }); @@ -174,3 +175,13 @@ test("only links under assets/podcast/, in any spelling, are skipped", () => { assert.equal(skippedSymlink("assets/cam-a.mov"), false); assert.equal(skippedSymlink("other/assets/podcast/cam-a.mov"), false); }); + +test("the portable contract tracks the complete parser private-path expression", () => { + const policy = JSON.parse( + readFileSync(new URL("../src/sources/contract/path-policy.json", import.meta.url), "utf8"), + ); + assert.equal( + policy.rules.find(({ id }) => id === "private-source").regex, + portablePrivatePattern, + ); +}); diff --git a/skills-manifest.json b/skills-manifest.json index 7415fff620..13ee3ec94a 100644 --- a/skills-manifest.json +++ b/skills-manifest.json @@ -18,7 +18,7 @@ "files": 13 }, "media-use": { - "hash": "89f0d2fddb8bb9b1", + "hash": "88f6a145ed56da5f", "files": 137 }, "remotion-to-hyperframes": { diff --git a/skills/media-use/audio/scripts/lib/audio-carve.mjs b/skills/media-use/audio/scripts/lib/audio-carve.mjs index a618d72b83..39ea5fcce3 100644 --- a/skills/media-use/audio/scripts/lib/audio-carve.mjs +++ b/skills/media-use/audio/scripts/lib/audio-carve.mjs @@ -2,4 +2,4 @@ // packages/parsers/src/privatePath.ts, bundled by scripts/generate-media-use-audio-carve.mjs so carve.mjs // runs the same analysis and private-path rule as Studio without loading @hyperframes/core from the project. // Regenerate: node scripts/generate-media-use-audio-carve.mjs -var de="data-fx-chain",et=de.slice(5),P=1,E=(e="frequency",n="Frequency",t=1e3,r=20,a=2e4)=>({kind:"number",key:e,label:n,unit:"Hz",min:r,max:a,step:1,default:t,scale:"log",automatable:!0}),H=(e=.707,n="Bandwidth: higher is narrower.")=>({kind:"number",key:"q",label:"Q",unit:"",min:.1,max:20,step:.01,default:e,scale:"log",automatable:!0,hint:n}),O=(e=-40,n=40,t=0)=>({kind:"number",key:"gain",label:"Gain",unit:"dB",min:e,max:n,step:.1,default:t,automatable:!0}),W={kind:"enum",key:"poles",label:"Slope",options:[{value:"1",label:"6 dB/oct"},{value:"2",label:"12 dB/oct"}],default:"2",hint:"Two poles is the usual biquad; one pole is gentler."},Y=[{id:"gain",label:"Gain",group:"dynamics",description:"Raise or lower the whole signal. Automate it to duck under something else.",params:[O(-60,12,0)],web:"gain-node"},{id:"peaking",label:"Peaking EQ",group:"filter",description:"Boost or cut a band, leaving everything either side alone.",params:[E("frequency","Frequency",1e3),O(-40,40,0),H(1)],web:"biquad-peaking"},{id:"lowshelf",label:"Low Shelf",group:"filter",description:"Lift or drop everything below the corner frequency.",params:[E("frequency","Frequency",200,20,2e3),O(-40,40,0)],web:"biquad-lowshelf"},{id:"highshelf",label:"High Shelf",group:"filter",description:"Lift or drop everything above the corner frequency.",params:[E("frequency","Frequency",4e3,500,2e4),O(-40,40,0)],web:"biquad-highshelf"},{id:"highpass",label:"High-pass",group:"filter",description:"Remove low frequencies: the usual fix for rumble on a voice.",params:[E("frequency","Cutoff",300,20,2e4),H(.707),W],web:"biquad-highpass"},{id:"lowpass",label:"Low-pass",group:"filter",description:"Remove high frequencies, which darkens or muffles a track.",params:[E("frequency","Cutoff",8e3,100,2e4),H(.707),W],web:"biquad-lowpass"},{id:"compressor",label:"Compressor",group:"dynamics",description:"Pull loud parts down so the quiet ones can come up.",params:[{kind:"number",key:"threshold",label:"Threshold",unit:"dB",min:-60,max:0,step:.5,default:-24,hint:"Level above which the compressor starts working."},{kind:"number",key:"ratio",label:"Ratio",unit:":1",min:1,max:20,step:.1,default:4},{kind:"number",key:"attack",label:"Attack",unit:"ms",min:.01,max:2e3,step:.1,default:20,scale:"log"},{kind:"number",key:"release",label:"Release",unit:"ms",min:.01,max:9e3,step:1,default:250,scale:"log"},{kind:"number",key:"knee",label:"Knee",unit:"",min:1,max:8,step:.01,default:2.83,hint:"1 is a hard corner; higher eases into it."},{kind:"number",key:"makeup",label:"Makeup",unit:"dB",min:0,max:36,step:.1,default:0},{kind:"number",key:"mix",label:"Mix",unit:"",min:0,max:1,step:.01,default:1,hint:"Below 1 blends the dry signal back in."}],web:"worklet-compressor"},{id:"limiter",label:"Limiter",group:"dynamics",description:"Peak limiter that follows the signal's level. It has no lookahead, so a fast peak or an inter-sample peak can pass the ceiling; use the true-peak limiter for a delivery limit.",params:[{kind:"number",key:"limit",label:"Ceiling",unit:"dB",min:-24,max:0,step:.1,default:-1},{kind:"number",key:"attack",label:"Attack",unit:"ms",min:.1,max:80,step:.1,default:5},{kind:"number",key:"release",label:"Release",unit:"ms",min:1,max:8e3,step:1,default:50,scale:"log"},{kind:"number",key:"level_out",label:"Output",unit:"dB",min:-24,max:24,step:.1,default:0}],web:"worklet-limiter"},{id:"truepeak",label:"True-peak limiter",group:"dynamics",description:"Lookahead limiter that holds a 4x estimate of the inter-sample peak at a dBTP ceiling; full-band noise can land up to about 1.7 dB above it. Adds lookahead plus about 0.3 ms of latency.",params:[{kind:"number",key:"ceiling",label:"Ceiling",unit:"dBTP",min:-24,max:0,step:.1,default:-1,hint:"Target true peak, measured on a 4x oversampled signal. Dense full-band sound can end up to about 1.7 dB above it."},{kind:"number",key:"lookahead",label:"Lookahead",unit:"ms",min:.5,max:10,step:.1,default:3,hint:"How far ahead the gain starts falling. Longer is smoother and adds the same latency."},{kind:"number",key:"release",label:"Release",unit:"ms",min:10,max:2e3,step:1,default:80,scale:"log"}],web:"worklet-truepeak"},{id:"gate",label:"Noise Gate",group:"dynamics",description:"Silence the track when it drops below the threshold.",params:[{kind:"number",key:"threshold",label:"Threshold",unit:"dB",min:-80,max:0,step:.5,default:-35},{kind:"number",key:"range",label:"Range",unit:"dB",min:-80,max:0,step:.5,default:-24,hint:"How far down the gate pulls when closed."},{kind:"number",key:"ratio",label:"Ratio",unit:":1",min:1,max:20,step:.1,default:10},{kind:"number",key:"attack",label:"Attack",unit:"ms",min:.01,max:9e3,step:.1,default:1,scale:"log"},{kind:"number",key:"release",label:"Release",unit:"ms",min:.01,max:9e3,step:1,default:100,scale:"log"},{kind:"number",key:"knee",label:"Knee",unit:"",min:1,max:8,step:.01,default:2.83}],web:"worklet-gate"},{id:"saturate",label:"Saturation",group:"nonlinear",description:"Soft-clip the waveform for warmth or outright distortion.",params:[{kind:"enum",key:"type",label:"Curve",options:[{value:"tanh",label:"Tanh"},{value:"atan",label:"Arctan"},{value:"cubic",label:"Cubic"},{value:"exp",label:"Exponential"},{value:"alg",label:"Algebraic"},{value:"quintic",label:"Quintic"},{value:"sin",label:"Sine"},{value:"erf",label:"Error function"},{value:"hard",label:"Hard clip"}],default:"tanh"},{kind:"number",key:"threshold",label:"Threshold",unit:"dB",min:-40,max:0,step:.1,default:-6},{kind:"number",key:"output",automatable:!0,label:"Output",unit:"dB",min:-24,max:24,step:.1,default:0},{kind:"number",key:"oversample",label:"Oversample",unit:"x",min:1,max:8,step:1,default:4,hint:"Higher costs more but keeps aliasing down."}],web:"waveshaper"},{id:"bitcrush",label:"Bitcrush",group:"nonlinear",description:"Drop bit depth and sample rate for a lo-fi, digital sound.",params:[{kind:"number",key:"bits",label:"Bit depth",unit:"bit",min:1,max:32,step:.1,default:8},{kind:"number",key:"samples",label:"Sample hold",unit:"x",min:1,max:250,step:1,default:1,hint:"Repeats each sample N times, a crude downsample."},{kind:"number",key:"mix",label:"Mix",unit:"",min:0,max:1,step:.01,default:1}],web:"worklet-bitcrush"},{id:"pitchshift",label:"Pitch shift",group:"time",description:"Shifts pitch up or down without changing playback speed. Adds ~50 ms of latency.",params:[{kind:"number",key:"semitones",label:"Semitones",unit:"st",min:-12,max:12,step:1,default:0},{kind:"number",key:"mix",label:"Mix",unit:"",min:0,max:1,step:.01,default:1}],web:"worklet-pitchshift"},{id:"delay",label:"Delay",group:"time",description:"Repeating echoes behind the dry signal.",params:[{kind:"number",key:"time",automatable:!0,label:"Time",unit:"ms",min:1,max:5e3,step:1,default:250,scale:"log"},{kind:"number",key:"feedback",automatable:!0,label:"Feedback",unit:"",min:.01,max:.95,step:.01,default:.35},{kind:"number",key:"mix",automatable:!0,label:"Mix",unit:"",min:0,max:1,step:.01,default:.4}],web:"delay-feedback"},{id:"chorus",label:"Chorus",group:"time",description:"Detuned copies of the signal for width and thickness.",params:[{kind:"number",key:"delay",automatable:!0,label:"Delay",unit:"ms",min:1,max:100,step:.1,default:7},{kind:"number",key:"depth",automatable:!0,label:"Depth",unit:"ms",min:0,max:10,step:.01,default:2},{kind:"number",key:"speed",automatable:!0,label:"Rate",unit:"Hz",min:.01,max:10,step:.01,default:1},{kind:"number",key:"mix",automatable:!0,label:"Mix",unit:"",min:0,max:1,step:.01,default:.5}],web:"chorus-lfo"},{id:"phaser",label:"Phaser",group:"time",description:"Sweeping notches moving through the spectrum.",params:[{kind:"number",key:"in_gain",automatable:!0,label:"Input",unit:"",min:0,max:1,step:.01,default:.4},{kind:"number",key:"out_gain",automatable:!0,label:"Output",unit:"",min:0,max:2,step:.01,default:.74},{kind:"number",key:"delay",label:"Delay",unit:"ms",min:.1,max:5,step:.1,default:3},{kind:"number",key:"decay",label:"Decay",unit:"",min:0,max:.99,step:.01,default:.4},{kind:"number",key:"speed",automatable:!0,label:"Rate",unit:"Hz",min:.1,max:2,step:.01,default:.5},{kind:"enum",key:"type",label:"Waveform",options:[{value:"0",label:"Triangular"},{value:"1",label:"Sinusoidal"}],default:"0"}],web:"allpass-phaser"},{id:"reverb",label:"Reverb",group:"time",description:"Room tail. Both ends convolve the same generated impulse, so preview matches render.",params:[{kind:"number",key:"size",label:"Room size",unit:"",min:.05,max:1,step:.01,default:.7},{kind:"number",key:"damping",label:"Damping",unit:"",min:0,max:1,step:.01,default:.5,hint:"Higher rolls the top off the tail faster."},{kind:"number",key:"wet",automatable:!0,label:"Wet",unit:"",min:0,max:1,step:.01,default:.35},{kind:"number",key:"dry",automatable:!0,label:"Dry",unit:"",min:0,max:1,step:.01,default:.7}],web:"convolver"}],B=new Map(Y.map(e=>[e.id,e]));var tt=Y.map(e=>e.id);function L(e){let n=B.get(e);if(!n)return{};let t={};for(let r of n.params)t[r.key]=r.default;return t}function X(e,n){let t=B.get(e);if(!t)return{};let r={};for(let a of t.params){let o=n?.[a.key];if(a.kind==="enum"){let i=a.options.some(l=>l.value===o);r[a.key]=i?o:a.default;continue}let s=typeof o=="number"?o:typeof o=="string"&&o.trim()!==""?Number(o):Number.NaN;r[a.key]=Number.isFinite(s)?Math.min(a.max,Math.max(a.min,s)):a.default}return r}var A=class extends Error{constructor(n){super(n),this.name="AudioFxChainError"}};function fe(e){let n;try{n=JSON.parse(e)}catch(a){throw new A(`Chain file is not valid JSON: ${a.message}`)}if(typeof n!="object"||n===null)throw new A("Chain file must be a JSON object.");let t=n;if(t.version!==P)throw new A(`Unsupported chain version: ${String(t.version)}`);if(!Array.isArray(t.nodes))throw new A("Chain file is missing a `nodes` array.");let r=t.nodes.map(be);return{version:P,nodes:r}}function pe(e){return JSON.stringify({version:P,nodes:e.nodes.map(ge)})}function he(e){let n=new Set(e.nodes.map(t=>t.id).filter(Boolean));for(let t=1;;t+=1){let r=`n${t}`;if(!n.has(r))return r}}function be(e,n){if(typeof e!="object"||e===null)throw new A(`Node ${n} is not an object.`);let t=e;if(typeof t.type!="string"||!B.has(t.type))throw new A(`Node ${n} has unknown effect type: ${String(t.type)}`);return Q({type:t.type,id:M(t.id),fromCarve:D(t.fromCarve),fromPreset:M(t.fromPreset),label:M(t.label),fromEq:M(t.fromEq),fromLeveller:D(t.fromLeveller),presetAmount:Z(t.presetAmount),enabled:t.enabled!==!1,params:X(t.type,t.params??void 0)})}function ge(e){return Q({type:e.type,id:M(e.id),fromCarve:D(e.fromCarve),fromPreset:M(e.fromPreset),label:M(e.label),fromEq:M(e.fromEq),fromLeveller:D(e.fromLeveller),presetAmount:e.presetAmount===1?void 0:Z(e.presetAmount),enabled:e.enabled===!1?!1:void 0,params:X(e.type,e.params)})}function M(e){return typeof e=="string"&&e?e:void 0}function D(e){return e===!0?!0:void 0}function Z(e){if(!(typeof e!="number"||!Number.isFinite(e)))return Math.min(1,Math.max(0,e))}function Q(e){for(let n of Object.keys(e))e[n]===void 0&&delete e[n];return e}function _(e,n){let t=e.length;for(let r=1,a=0;r>1;for(;a&o;o>>=1)a^=o;a^=o,r{let t=n/J;return t>=q?0:(t===0?1:Math.sin(Math.PI*t)/(Math.PI*t))*(.5+.5*Math.cos(Math.PI*t/q))});var te=22050;var $=4096;var ht=Array.from({length:$/2},(e,n)=>{let t=n*te/$;return t<55||t>2e3?-1:((Math.round(12*Math.log2(t/440))+9)%12+12)%12});var bt=$/2/te;var z=16;var wt=(()=>{let e=Array.from({length:2*z},(t,r)=>r-z),n=t=>Math.exp(-.5*(((t<0?-t-1:t)+.5)/(z/2))**2);return e.map(t=>e.map(r=>(t<0==r<0?1:-1)*n(t)*n(r)))})();var N=(e,n)=>2**Math.round(Math.log2(e*n));function U(e,n,t){let r=0,a=0;for(let s=n;s0?20*Math.log10(o):Number.NEGATIVE_INFINITY}var ne=4,V=12,Nt=Array.from({length:ne-1},(e,n)=>{let t=(n+1)/ne;return Float64Array.from({length:2*V},(r,a)=>{let o=a-V+1-t;return(o===0?1:Math.sin(Math.PI*o)/(Math.PI*o))*(.5+.5*Math.cos(Math.PI*o/V))})});function re(e){let n=new Float32Array(e);for(let t=0;t`${Me}${e}${Fe}`,ke=new RegExp(`music|bgm|${C("bed")}|soundtrack|score|${C("song")}|theme|instrumental|track\\d`,"i"),we=new RegExp(`voice|${C("vo")}|${C("vox")}|narrat|speech|dialog|monolog|announce|${C("tts")}|talk|interview|podcast|recap|script`,"i");function Se(...e){let n=e.filter(Boolean).join(" ");return we.test(n)?"voice":Ae.test(n)?"sfx":ke.test(n)?"music":"unknown"}function ve(e,n){let t=r=>typeof r.duration=="number"&&Number.isFinite(r.duration)?r.start+Math.max(0,r.duration):Number.POSITIVE_INFINITY;return e.start({samples:o.samples,at:Math.round(o.offsetSeconds*n)})),r=t.reduce((o,s)=>Math.max(o,s.at+s.samples.length),0);if(r<=0)return new Float32Array(0);let a=new Float32Array(r);for(let{samples:o,at:s}of t){let i=s<0?-s:0;for(let l=i;l=r||(a[c]=(a[c]??0)+(o[l]??0))}}return a}function _e(e,n){let t=N(n,G),r=t/2,a=Math.max(e.length,t),o=e.length>=t?e:(()=>{let d=new Float32Array(t);return d.set(e),d})(),s=re(t),i=t/2+1,l=new Float64Array(i),c=new Float64Array(t),m=new Float64Array(t),p=0;for(let d=0;d+t<=a;d+=r){m.fill(0);for(let u=0;u=r&&e[i]0?o/s:0}var Ce=30;function Ie(e,n){let t=Math.log2(e/2e3),r=Math.exp(-(t*t)/2);return n*Ce*(1-r)}function Oe(e,n,t){if(e.length===0)return[];let{freqs:r,power:a}=_e(e,n),s=xe.map(l=>{let c=oe(r,a,l);return{center:l,hasEnergy:c>0,scoreDb:c>0?10*Math.log10(c)-Ie(l,t.intelligibilityBias):Number.NEGATIVE_INFINITY}}).sort((l,c)=>c.scoreDb-l.scoreDb).slice(0,Math.max(1,t.bands)).filter(l=>l.hasEnergy);if(s.length===0)return[];let i=s[0].scoreDb;return s.map(({center:l,scoreDb:c})=>{let m=Math.pow(10,(c-i)/10),p=Math.min(t.maxCutDb,Math.max(t.maxCutDb/2,t.maxCutDb*m));return{freq:l,gainDb:-Number(p.toFixed(2)),q:t.q}}).sort((l,c)=>l.freq-c.freq)}var ae=30,se=.05,De=.25,Ne=2.4,ie=400,R=.2,ue=.5;function le(e,n){let t=[{t:0,v:0}],r=0,a=-1;return e.forEach((o,s)=>{s!==e.length-1&&Math.abs(o.v-r)0&&a!==s-1&&t.push(e[s-1]),t.push(o),r=o.v,a=s)}),t}function Re(e,n,t){if(e.length===0||t.length===0)return[];let r=N(n,G),a=re(r),o=Math.max(r,Math.ceil(e.length/ie)),s=r/2+1,i=[];for(let u=0;u[]),m=new Float64Array(r),p=new Float64Array(r);for(let u=0;uc[F].push(oe(i,y,f.freq)))}let b=e.length/n,g=1-Math.exp(-(o/n)/se),d=1-Math.exp(-(o/n)/De);return t.map((u,y)=>{let f=c[y],F=Math.max(...f),x=0,I=[];f.forEach((w,h)=>{let S=w>0&&F>0?Math.max(0,1+10*Math.log10(w/F)/ae):0;x+=(S>x?g:d)*(S-x);let v=u.gainDb*x,T=Math.abs(v){let v=c[S]??Number.NEGATIVE_INFINITY,T=h>b&&Number.isFinite(v)?v-(h-r.headroomDb):0,j=Math.min(r.duckDb,Math.max(0,T));u+=(j>u?g:d)*(j-u);let me=u=R;)u+=d*-u,F+=f,y.push({t:Number(F.toFixed(3)),v:u=w||x.push({t:w,v:0}),x}function He(e){let n=e.map(t=>({type:"peaking",enabled:!0,params:{...L("peaking"),frequency:t.freq,gain:t.gainDb,q:t.q}}));return{version:P,nodes:n}}import{isAbsolute as Be,relative as Kt,resolve as jt,sep as Wt}from"node:path";function K(e){return e.normalize("NFKC").toUpperCase().toLowerCase().replace(/\p{Default_Ignorable_Code_Point}/gu,"").split(/[\\/]/).map(n=>Le(n.split(":",1)[0]??""))}function Le(e){let n=e.length;for(;n>0&&(e[n-1]==="."||e[n-1]===" ");)n--;return e.slice(0,n)}function qe(e){return K(e).some(n=>n===".git"||n.startsWith(".env"))}var $e=new Set([".hyperframes/studio-motion.json",".hyperframes/studio-manual-edits.json"]),ze=[".hyperframes/prepared-assets",".hyperframes/requests"],ce=".hyperframes/prepared-assets/downloads",Ve=new Set([".npmrc",".yarnrc",".yarnrc.yml",".pypirc","pip.conf","pip.ini",".netrc","_netrc",".git-credentials",".gitconfig",".mcp.json","credentials.json","serviceaccountkey.json","service-account.json","service_account.json"]),Ue=new Set([".ssh",".aws",".gnupg",".docker",".kube",".azure",".claude",".codex",".cursor",".agents",".gemini",".vscode",".idea"]),Ge=new Set(["gcloud","gh"]),Ke=/^(?:id_(?:rsa|dsa|ecdsa|ed25519).*|.*\.(?:pem|key|p12|pfx|p8|ppk|jks|keystore|kdbx))$/,je=/\.(?:tfstate(?:\.backup)?|tfvars(?:\.json)?)$/;function We(e){let n=K(e),t=n.at(-1)??"";return Ve.has(t)||Ke.test(t)||je.test(t)||n.some((r,a)=>Ue.has(r)||r===".config"&&Ge.has(n[a+1]??""))}function Ye(e){if(qe(e)||We(e))return!0;let n=K(e),t=!Be(e)&&!/^\.\.[. ]*$/.test(e.split(/[\\/]/,1)[0]??""),r=n.at(-1)??"",a=!r.startsWith(".")&&Qe.test(r),o=n.findIndex(s=>s!=="");return n.some((s,i)=>{let l=o===-1||i<=o;if(s===".hyperframes")return!l||!Je(n.slice(i).join("/"));if(Ze.has(s))return t;let c=l&&s===Xe;return t&&s.startsWith(".")&&!c&&!a})}var Xe=".media",Ze=new Set([".next",".nuxt",".output",".svelte-kit",".vercel",".netlify",".wrangler",".astro",".turbo"]),Qe=/.\.(?:png|jpe?g|gif|webp|avif|svg|ico|bmp|tiff?|heic|heif|mp4|m4v|mov|webm|mkv|mxf|avi|mp3|wav|m4a|aac|ogg|oga|opus|flac|woff2?|ttf|otf|css|m?js|cjs)$/;function Je(e){return e===ce||e.startsWith(`${ce}/`)?!1:$e.has(e)||ze.some(n=>e===n||e.startsWith(`${n}/`))}export{Oe as analyseCarveBands,Te as analyseCarveDuck,Re as analyseCarveDynamics,He as carveBandsToChain,Ee as carveProfile,Se as classifyAudioName,ve as clipsOverlap,L as defaultAudioFxParams,Ye as isStudioPrivatePath,he as mintAudioFxNodeId,Pe as mixCarveSources,fe as parseAudioFxChain,pe as serializeAudioFxChain}; +var be="data-fx-chain",at=be.slice(5),P=1,E=(e="frequency",n="Frequency",t=1e3,r=20,a=2e4)=>({kind:"number",key:e,label:n,unit:"Hz",min:r,max:a,step:1,default:t,scale:"log",automatable:!0}),T=(e=.707,n="Bandwidth: higher is narrower.")=>({kind:"number",key:"q",label:"Q",unit:"",min:.1,max:20,step:.01,default:e,scale:"log",automatable:!0,hint:n}),I=(e=-40,n=40,t=0)=>({kind:"number",key:"gain",label:"Gain",unit:"dB",min:e,max:n,step:.1,default:t,automatable:!0}),Y={kind:"enum",key:"poles",label:"Slope",options:[{value:"1",label:"6 dB/oct"},{value:"2",label:"12 dB/oct"}],default:"2",hint:"Two poles is the usual biquad; one pole is gentler."},X=[{id:"gain",label:"Gain",group:"dynamics",description:"Raise or lower the whole signal. Automate it to duck under something else.",params:[I(-60,12,0)],web:"gain-node"},{id:"peaking",label:"Peaking EQ",group:"filter",description:"Boost or cut a band, leaving everything either side alone.",params:[E("frequency","Frequency",1e3),I(-40,40,0),T(1)],web:"biquad-peaking"},{id:"lowshelf",label:"Low Shelf",group:"filter",description:"Lift or drop everything below the corner frequency.",params:[E("frequency","Frequency",200,20,2e3),I(-40,40,0)],web:"biquad-lowshelf"},{id:"highshelf",label:"High Shelf",group:"filter",description:"Lift or drop everything above the corner frequency.",params:[E("frequency","Frequency",4e3,500,2e4),I(-40,40,0)],web:"biquad-highshelf"},{id:"highpass",label:"High-pass",group:"filter",description:"Remove low frequencies: the usual fix for rumble on a voice.",params:[E("frequency","Cutoff",300,20,2e4),T(.707),Y],web:"biquad-highpass"},{id:"lowpass",label:"Low-pass",group:"filter",description:"Remove high frequencies, which darkens or muffles a track.",params:[E("frequency","Cutoff",8e3,100,2e4),T(.707),Y],web:"biquad-lowpass"},{id:"compressor",label:"Compressor",group:"dynamics",description:"Pull loud parts down so the quiet ones can come up.",params:[{kind:"number",key:"threshold",label:"Threshold",unit:"dB",min:-60,max:0,step:.5,default:-24,hint:"Level above which the compressor starts working."},{kind:"number",key:"ratio",label:"Ratio",unit:":1",min:1,max:20,step:.1,default:4},{kind:"number",key:"attack",label:"Attack",unit:"ms",min:.01,max:2e3,step:.1,default:20,scale:"log"},{kind:"number",key:"release",label:"Release",unit:"ms",min:.01,max:9e3,step:1,default:250,scale:"log"},{kind:"number",key:"knee",label:"Knee",unit:"",min:1,max:8,step:.01,default:2.83,hint:"1 is a hard corner; higher eases into it."},{kind:"number",key:"makeup",label:"Makeup",unit:"dB",min:0,max:36,step:.1,default:0},{kind:"number",key:"mix",label:"Mix",unit:"",min:0,max:1,step:.01,default:1,hint:"Below 1 blends the dry signal back in."}],web:"worklet-compressor"},{id:"limiter",label:"Limiter",group:"dynamics",description:"Peak limiter that follows the signal's level. It has no lookahead, so a fast peak or an inter-sample peak can pass the ceiling; use the true-peak limiter for a delivery limit.",params:[{kind:"number",key:"limit",label:"Ceiling",unit:"dB",min:-24,max:0,step:.1,default:-1},{kind:"number",key:"attack",label:"Attack",unit:"ms",min:.1,max:80,step:.1,default:5},{kind:"number",key:"release",label:"Release",unit:"ms",min:1,max:8e3,step:1,default:50,scale:"log"},{kind:"number",key:"level_out",label:"Output",unit:"dB",min:-24,max:24,step:.1,default:0}],web:"worklet-limiter"},{id:"truepeak",label:"True-peak limiter",group:"dynamics",description:"Lookahead limiter that holds a 4x estimate of the inter-sample peak at a dBTP ceiling; full-band noise can land up to about 1.7 dB above it. Adds lookahead plus about 0.3 ms of latency.",params:[{kind:"number",key:"ceiling",label:"Ceiling",unit:"dBTP",min:-24,max:0,step:.1,default:-1,hint:"Target true peak, measured on a 4x oversampled signal. Dense full-band sound can end up to about 1.7 dB above it."},{kind:"number",key:"lookahead",label:"Lookahead",unit:"ms",min:.5,max:10,step:.1,default:3,hint:"How far ahead the gain starts falling. Longer is smoother and adds the same latency."},{kind:"number",key:"release",label:"Release",unit:"ms",min:10,max:2e3,step:1,default:80,scale:"log"}],web:"worklet-truepeak"},{id:"gate",label:"Noise Gate",group:"dynamics",description:"Silence the track when it drops below the threshold.",params:[{kind:"number",key:"threshold",label:"Threshold",unit:"dB",min:-80,max:0,step:.5,default:-35},{kind:"number",key:"range",label:"Range",unit:"dB",min:-80,max:0,step:.5,default:-24,hint:"How far down the gate pulls when closed."},{kind:"number",key:"ratio",label:"Ratio",unit:":1",min:1,max:20,step:.1,default:10},{kind:"number",key:"attack",label:"Attack",unit:"ms",min:.01,max:9e3,step:.1,default:1,scale:"log"},{kind:"number",key:"release",label:"Release",unit:"ms",min:.01,max:9e3,step:1,default:100,scale:"log"},{kind:"number",key:"knee",label:"Knee",unit:"",min:1,max:8,step:.01,default:2.83}],web:"worklet-gate"},{id:"saturate",label:"Saturation",group:"nonlinear",description:"Soft-clip the waveform for warmth or outright distortion.",params:[{kind:"enum",key:"type",label:"Curve",options:[{value:"tanh",label:"Tanh"},{value:"atan",label:"Arctan"},{value:"cubic",label:"Cubic"},{value:"exp",label:"Exponential"},{value:"alg",label:"Algebraic"},{value:"quintic",label:"Quintic"},{value:"sin",label:"Sine"},{value:"erf",label:"Error function"},{value:"hard",label:"Hard clip"}],default:"tanh"},{kind:"number",key:"threshold",label:"Threshold",unit:"dB",min:-40,max:0,step:.1,default:-6},{kind:"number",key:"output",automatable:!0,label:"Output",unit:"dB",min:-24,max:24,step:.1,default:0},{kind:"number",key:"oversample",label:"Oversample",unit:"x",min:1,max:8,step:1,default:4,hint:"Higher costs more but keeps aliasing down."}],web:"waveshaper"},{id:"bitcrush",label:"Bitcrush",group:"nonlinear",description:"Drop bit depth and sample rate for a lo-fi, digital sound.",params:[{kind:"number",key:"bits",label:"Bit depth",unit:"bit",min:1,max:32,step:.1,default:8},{kind:"number",key:"samples",label:"Sample hold",unit:"x",min:1,max:250,step:1,default:1,hint:"Repeats each sample N times, a crude downsample."},{kind:"number",key:"mix",label:"Mix",unit:"",min:0,max:1,step:.01,default:1}],web:"worklet-bitcrush"},{id:"pitchshift",label:"Pitch shift",group:"time",description:"Shifts pitch up or down without changing playback speed. Adds ~50 ms of latency.",params:[{kind:"number",key:"semitones",label:"Semitones",unit:"st",min:-12,max:12,step:1,default:0},{kind:"number",key:"mix",label:"Mix",unit:"",min:0,max:1,step:.01,default:1}],web:"worklet-pitchshift"},{id:"delay",label:"Delay",group:"time",description:"Repeating echoes behind the dry signal.",params:[{kind:"number",key:"time",automatable:!0,label:"Time",unit:"ms",min:1,max:5e3,step:1,default:250,scale:"log"},{kind:"number",key:"feedback",automatable:!0,label:"Feedback",unit:"",min:.01,max:.95,step:.01,default:.35},{kind:"number",key:"mix",automatable:!0,label:"Mix",unit:"",min:0,max:1,step:.01,default:.4}],web:"delay-feedback"},{id:"chorus",label:"Chorus",group:"time",description:"Detuned copies of the signal for width and thickness.",params:[{kind:"number",key:"delay",automatable:!0,label:"Delay",unit:"ms",min:1,max:100,step:.1,default:7},{kind:"number",key:"depth",automatable:!0,label:"Depth",unit:"ms",min:0,max:10,step:.01,default:2},{kind:"number",key:"speed",automatable:!0,label:"Rate",unit:"Hz",min:.01,max:10,step:.01,default:1},{kind:"number",key:"mix",automatable:!0,label:"Mix",unit:"",min:0,max:1,step:.01,default:.5}],web:"chorus-lfo"},{id:"phaser",label:"Phaser",group:"time",description:"Sweeping notches moving through the spectrum.",params:[{kind:"number",key:"in_gain",automatable:!0,label:"Input",unit:"",min:0,max:1,step:.01,default:.4},{kind:"number",key:"out_gain",automatable:!0,label:"Output",unit:"",min:0,max:2,step:.01,default:.74},{kind:"number",key:"delay",label:"Delay",unit:"ms",min:.1,max:5,step:.1,default:3},{kind:"number",key:"decay",label:"Decay",unit:"",min:0,max:.99,step:.01,default:.4},{kind:"number",key:"speed",automatable:!0,label:"Rate",unit:"Hz",min:.1,max:2,step:.01,default:.5},{kind:"enum",key:"type",label:"Waveform",options:[{value:"0",label:"Triangular"},{value:"1",label:"Sinusoidal"}],default:"0"}],web:"allpass-phaser"},{id:"reverb",label:"Reverb",group:"time",description:"Room tail. Both ends convolve the same generated impulse, so preview matches render.",params:[{kind:"number",key:"size",label:"Room size",unit:"",min:.05,max:1,step:.01,default:.7},{kind:"number",key:"damping",label:"Damping",unit:"",min:0,max:1,step:.01,default:.5,hint:"Higher rolls the top off the tail faster."},{kind:"number",key:"wet",automatable:!0,label:"Wet",unit:"",min:0,max:1,step:.01,default:.35},{kind:"number",key:"dry",automatable:!0,label:"Dry",unit:"",min:0,max:1,step:.01,default:.7}],web:"convolver"}],B=new Map(X.map(e=>[e.id,e]));var st=X.map(e=>e.id);function q(e){let n=B.get(e);if(!n)return{};let t={};for(let r of n.params)t[r.key]=r.default;return t}function Z(e,n){let t=B.get(e);if(!t)return{};let r={};for(let a of t.params){let o=n?.[a.key];if(a.kind==="enum"){let i=a.options.some(l=>l.value===o);r[a.key]=i?o:a.default;continue}let s=typeof o=="number"?o:typeof o=="string"&&o.trim()!==""?Number(o):Number.NaN;r[a.key]=Number.isFinite(s)?Math.min(a.max,Math.max(a.min,s)):a.default}return r}var A=class extends Error{constructor(n){super(n),this.name="AudioFxChainError"}};function ge(e){let n;try{n=JSON.parse(e)}catch(a){throw new A(`Chain file is not valid JSON: ${a.message}`)}if(typeof n!="object"||n===null)throw new A("Chain file must be a JSON object.");let t=n;if(t.version!==P)throw new A(`Unsupported chain version: ${String(t.version)}`);if(!Array.isArray(t.nodes))throw new A("Chain file is missing a `nodes` array.");let r=t.nodes.map(Ae);return{version:P,nodes:r}}function ye(e){return JSON.stringify({version:P,nodes:e.nodes.map(Me)})}function xe(e){let n=new Set(e.nodes.map(t=>t.id).filter(Boolean));for(let t=1;;t+=1){let r=`n${t}`;if(!n.has(r))return r}}function Ae(e,n){if(typeof e!="object"||e===null)throw new A(`Node ${n} is not an object.`);let t=e;if(typeof t.type!="string"||!B.has(t.type))throw new A(`Node ${n} has unknown effect type: ${String(t.type)}`);return J({type:t.type,id:M(t.id),fromCarve:N(t.fromCarve),fromPreset:M(t.fromPreset),label:M(t.label),fromEq:M(t.fromEq),fromLeveller:N(t.fromLeveller),presetAmount:Q(t.presetAmount),enabled:t.enabled!==!1,params:Z(t.type,t.params??void 0)})}function Me(e){return J({type:e.type,id:M(e.id),fromCarve:N(e.fromCarve),fromPreset:M(e.fromPreset),label:M(e.label),fromEq:M(e.fromEq),fromLeveller:N(e.fromLeveller),presetAmount:e.presetAmount===1?void 0:Q(e.presetAmount),enabled:e.enabled===!1?!1:void 0,params:Z(e.type,e.params)})}function M(e){return typeof e=="string"&&e?e:void 0}function N(e){return e===!0?!0:void 0}function Q(e){if(!(typeof e!="number"||!Number.isFinite(e)))return Math.min(1,Math.max(0,e))}function J(e){for(let n of Object.keys(e))e[n]===void 0&&delete e[n];return e}function _(e,n){let t=e.length;for(let r=1,a=0;r>1;for(;a&o;o>>=1)a^=o;a^=o,r{let t=n/ee;return t>=L?0:(t===0?1:Math.sin(Math.PI*t)/(Math.PI*t))*(.5+.5*Math.cos(Math.PI*t/L))});var ne=22050;var $=4096;var At=Array.from({length:$/2},(e,n)=>{let t=n*ne/$;return t<55||t>2e3?-1:((Math.round(12*Math.log2(t/440))+9)%12+12)%12});var Mt=$/2/ne;var z=16;var _t=(()=>{let e=Array.from({length:2*z},(t,r)=>r-z),n=t=>Math.exp(-.5*(((t<0?-t-1:t)+.5)/(z/2))**2);return e.map(t=>e.map(r=>(t<0==r<0?1:-1)*n(t)*n(r)))})();var D=(e,n)=>2**Math.round(Math.log2(e*n));function j(e,n,t){let r=0,a=0;for(let s=n;s0?20*Math.log10(o):Number.NEGATIVE_INFINITY}var re=4,V=12,qt=Array.from({length:re-1},(e,n)=>{let t=(n+1)/re;return Float64Array.from({length:2*V},(r,a)=>{let o=a-V+1-t;return(o===0?1:Math.sin(Math.PI*o)/(Math.PI*o))*(.5+.5*Math.cos(Math.PI*o/V))})});function oe(e){let n=new Float32Array(e);for(let t=0;t`${Se}${e}${ve}`,Ee=new RegExp(`music|bgm|${C("bed")}|soundtrack|score|${C("song")}|theme|instrumental|track\\d`,"i"),Pe=new RegExp(`voice|${C("vo")}|${C("vox")}|narrat|speech|dialog|monolog|announce|${C("tts")}|talk|interview|podcast|recap|script`,"i");function _e(...e){let n=e.filter(Boolean).join(" ");return Pe.test(n)?"voice":we.test(n)?"sfx":Ee.test(n)?"music":"unknown"}function Ce(e,n){let t=r=>typeof r.duration=="number"&&Number.isFinite(r.duration)?r.start+Math.max(0,r.duration):Number.POSITIVE_INFINITY;return e.start({samples:o.samples,at:Math.round(o.offsetSeconds*n)})),r=t.reduce((o,s)=>Math.max(o,s.at+s.samples.length),0);if(r<=0)return new Float32Array(0);let a=new Float32Array(r);for(let{samples:o,at:s}of t){let i=s<0?-s:0;for(let l=i;l=r||(a[c]=(a[c]??0)+(o[l]??0))}}return a}function Ne(e,n){let t=D(n,U),r=t/2,a=Math.max(e.length,t),o=e.length>=t?e:(()=>{let d=new Float32Array(t);return d.set(e),d})(),s=oe(t),i=t/2+1,l=new Float64Array(i),c=new Float64Array(t),m=new Float64Array(t),p=0;for(let d=0;d+t<=a;d+=r){m.fill(0);for(let u=0;u=r&&e[i]0?o/s:0}var De=30;function Re(e,n){let t=Math.log2(e/2e3),r=Math.exp(-(t*t)/2);return n*De*(1-r)}function He(e,n,t){if(e.length===0)return[];let{freqs:r,power:a}=Ne(e,n),s=Fe.map(l=>{let c=ae(r,a,l);return{center:l,hasEnergy:c>0,scoreDb:c>0?10*Math.log10(c)-Re(l,t.intelligibilityBias):Number.NEGATIVE_INFINITY}}).sort((l,c)=>c.scoreDb-l.scoreDb).slice(0,Math.max(1,t.bands)).filter(l=>l.hasEnergy);if(s.length===0)return[];let i=s[0].scoreDb;return s.map(({center:l,scoreDb:c})=>{let m=Math.pow(10,(c-i)/10),p=Math.min(t.maxCutDb,Math.max(t.maxCutDb/2,t.maxCutDb*m));return{freq:l,gainDb:-Number(p.toFixed(2)),q:t.q}}).sort((l,c)=>l.freq-c.freq)}var se=30,ie=.05,Te=.25,Be=2.4,ue=400,R=.2,le=.5;function ce(e,n){let t=[{t:0,v:0}],r=0,a=-1;return e.forEach((o,s)=>{s!==e.length-1&&Math.abs(o.v-r)0&&a!==s-1&&t.push(e[s-1]),t.push(o),r=o.v,a=s)}),t}function qe(e,n,t){if(e.length===0||t.length===0)return[];let r=D(n,U),a=oe(r),o=Math.max(r,Math.ceil(e.length/ue)),s=r/2+1,i=[];for(let u=0;u[]),m=new Float64Array(r),p=new Float64Array(r);for(let u=0;uc[k].push(ae(i,y,f.freq)))}let b=e.length/n,g=1-Math.exp(-(o/n)/ie),d=1-Math.exp(-(o/n)/Te);return t.map((u,y)=>{let f=c[y],k=Math.max(...f),x=0,O=[];f.forEach((w,h)=>{let S=w>0&&k>0?Math.max(0,1+10*Math.log10(w/k)/se):0;x+=(S>x?g:d)*(S-x);let v=u.gainDb*x,H=Math.abs(v){let v=c[S]??Number.NEGATIVE_INFINITY,H=h>b&&Number.isFinite(v)?v-(h-r.headroomDb):0,W=Math.min(r.duckDb,Math.max(0,H));u+=(W>u?g:d)*(W-u);let he=u=R;)u+=d*-u,k+=f,y.push({t:Number(k.toFixed(3)),v:u=w||x.push({t:w,v:0}),x}function $e(e){let n=e.map(t=>({type:"peaking",enabled:!0,params:{...q("peaking"),frequency:t.freq,gain:t.gainDb,q:t.q}}));return{version:P,nodes:n}}import{isAbsolute as ze,relative as Zt,resolve as Qt,sep as Jt}from"node:path";function G(e){return e.normalize("NFKC").toUpperCase().toLowerCase().replace(/\p{Default_Ignorable_Code_Point}/gu,"").split(/[\\/]/).map(n=>Ve(n.split(":",1)[0]??""))}function Ve(e){let n=e.length;for(;n>0&&(e[n-1]==="."||e[n-1]===" ");)n--;return e.slice(0,n)}var K=String.raw`(?:[^/]*/)*`,de=String.raw`(?:\.git|\.env[^/]*)(?:/.*)?`,je=[".npmrc",".yarnrc",".yarnrc.yml",".pypirc","pip.conf","pip.ini",".netrc","_netrc",".git-credentials",".gitconfig",".mcp.json","credentials.json","serviceaccountkey.json","service-account.json","service_account.json"],Ue=[".ssh",".aws",".gnupg",".docker",".kube",".azure",".claude",".codex",".cursor",".agents",".gemini",".vscode",".idea"],fe=e=>e.map(n=>n.replaceAll(".","\\.")).join("|"),Ge=String.raw`id_(?:rsa|dsa|ecdsa|ed25519)[^/]*|[^/]*\.(?:pem|key|p12|pfx|p8|ppk|jks|keystore|kdbx|tfstate(?:\.backup)?|tfvars(?:\.json)?)`,Ke=String.raw`(?:${fe(Ue)}|\.config/(?:gcloud|gh))(?:/.*)?`,pe=[fe(je),Ge,Ke].join("|"),en=`${K}(?:${de}|${pe})`,We=new RegExp(`^${K}(?:${de})$`,"su"),Ye=new RegExp(`^${K}(?:${pe})$`,"su");function Xe(e){return We.test(G(e).join("/"))}var Ze=new Set([".hyperframes/studio-motion.json",".hyperframes/studio-manual-edits.json"]),Qe=[".hyperframes/prepared-assets",".hyperframes/requests"],me=".hyperframes/prepared-assets/downloads";function Je(e){return Ye.test(G(e).join("/"))}function et(e){if(Xe(e)||Je(e))return!0;let n=G(e),t=!ze(e)&&!/^\.\.[. ]*$/.test(e.split(/[\\/]/,1)[0]??""),r=n.at(-1)??"",a=!r.startsWith(".")&&rt.test(r),o=n.findIndex(s=>s!=="");return n.some((s,i)=>{let l=o===-1||i<=o;if(s===".hyperframes")return!l||!ot(n.slice(i).join("/"));if(nt.has(s))return t;let c=l&&s===tt;return t&&s.startsWith(".")&&!c&&!a})}var tt=".media",nt=new Set([".next",".nuxt",".output",".svelte-kit",".vercel",".netlify",".wrangler",".astro",".turbo"]),rt=/.\.(?:png|jpe?g|gif|webp|avif|svg|ico|bmp|tiff?|heic|heif|mp4|m4v|mov|webm|mkv|mxf|avi|mp3|wav|m4a|aac|ogg|oga|opus|flac|woff2?|ttf|otf|css|m?js|cjs)$/;function ot(e){return e===me||e.startsWith(`${me}/`)?!1:Ze.has(e)||Qe.some(n=>e===n||e.startsWith(`${n}/`))}export{He as analyseCarveBands,Le as analyseCarveDuck,qe as analyseCarveDynamics,$e as carveBandsToChain,Oe as carveProfile,_e as classifyAudioName,Ce as clipsOverlap,q as defaultAudioFxParams,et as isStudioPrivatePath,xe as mintAudioFxNodeId,Ie as mixCarveSources,ge as parseAudioFxChain,ye as serializeAudioFxChain};