@mostra/protocol 0.14.0 → 0.15.0

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.
Files changed (125) hide show
  1. package/dist/artifact-path.d.ts +22 -0
  2. package/dist/artifact-path.d.ts.map +1 -0
  3. package/dist/artifact-path.js +39 -0
  4. package/dist/artifact-path.js.map +1 -0
  5. package/dist/diagnostics/codes/index.d.ts +5 -2
  6. package/dist/diagnostics/codes/index.d.ts.map +1 -1
  7. package/dist/diagnostics/codes/index.js +7 -1
  8. package/dist/diagnostics/codes/index.js.map +1 -1
  9. package/dist/diagnostics/codes/license.d.ts +8 -0
  10. package/dist/diagnostics/codes/license.d.ts.map +1 -0
  11. package/dist/diagnostics/codes/license.js +55 -0
  12. package/dist/diagnostics/codes/license.js.map +1 -0
  13. package/dist/diagnostics/codes/pack.d.ts +8 -0
  14. package/dist/diagnostics/codes/pack.d.ts.map +1 -0
  15. package/dist/diagnostics/codes/pack.js +110 -0
  16. package/dist/diagnostics/codes/pack.js.map +1 -0
  17. package/dist/diagnostics/codes/plugin.d.ts +8 -0
  18. package/dist/diagnostics/codes/plugin.d.ts.map +1 -0
  19. package/dist/diagnostics/codes/plugin.js +154 -0
  20. package/dist/diagnostics/codes/plugin.js.map +1 -0
  21. package/dist/diagnostics/diagnostic.d.ts +1 -1
  22. package/dist/diagnostics/diagnostic.d.ts.map +1 -1
  23. package/dist/diagnostics/diagnostic.js +4 -1
  24. package/dist/diagnostics/diagnostic.js.map +1 -1
  25. package/dist/index.d.ts +13 -1
  26. package/dist/index.js +13 -1
  27. package/dist/methods/deps/add.d.ts +6 -0
  28. package/dist/methods/deps/add.d.ts.map +1 -1
  29. package/dist/methods/deps/add.js +1 -0
  30. package/dist/methods/deps/add.js.map +1 -1
  31. package/dist/methods/index.d.ts.map +1 -1
  32. package/dist/methods/index.js +15 -1
  33. package/dist/methods/index.js.map +1 -1
  34. package/dist/methods/mostra/initialize.d.ts +7 -0
  35. package/dist/methods/mostra/initialize.d.ts.map +1 -1
  36. package/dist/methods/mostra/initialize.js +4 -2
  37. package/dist/methods/mostra/initialize.js.map +1 -1
  38. package/dist/methods/pack/add.d.ts +80 -0
  39. package/dist/methods/pack/add.d.ts.map +1 -0
  40. package/dist/methods/pack/add.js +59 -0
  41. package/dist/methods/pack/add.js.map +1 -0
  42. package/dist/methods/plugin/add.d.ts +43 -0
  43. package/dist/methods/plugin/add.d.ts.map +1 -0
  44. package/dist/methods/plugin/add.js +39 -0
  45. package/dist/methods/plugin/add.js.map +1 -0
  46. package/dist/methods/plugin/commands.d.ts +38 -0
  47. package/dist/methods/plugin/commands.d.ts.map +1 -0
  48. package/dist/methods/plugin/commands.js +33 -0
  49. package/dist/methods/plugin/commands.js.map +1 -0
  50. package/dist/methods/plugin/export.d.ts +58 -0
  51. package/dist/methods/plugin/export.d.ts.map +1 -0
  52. package/dist/methods/plugin/export.js +57 -0
  53. package/dist/methods/plugin/export.js.map +1 -0
  54. package/dist/methods/plugin/list.d.ts +26 -0
  55. package/dist/methods/plugin/list.d.ts.map +1 -0
  56. package/dist/methods/plugin/list.js +30 -0
  57. package/dist/methods/plugin/list.js.map +1 -0
  58. package/dist/methods/plugin/remove.d.ts +32 -0
  59. package/dist/methods/plugin/remove.d.ts.map +1 -0
  60. package/dist/methods/plugin/remove.js +33 -0
  61. package/dist/methods/plugin/remove.js.map +1 -0
  62. package/dist/methods/plugin/validate.d.ts +35 -0
  63. package/dist/methods/plugin/validate.d.ts.map +1 -0
  64. package/dist/methods/plugin/validate.js +33 -0
  65. package/dist/methods/plugin/validate.js.map +1 -0
  66. package/dist/plugin/contract-versions.generated.js +14 -0
  67. package/dist/plugin/contract-versions.generated.js.map +1 -0
  68. package/dist/plugin/contracts.d.ts +51 -0
  69. package/dist/plugin/contracts.d.ts.map +1 -0
  70. package/dist/plugin/contracts.js +129 -0
  71. package/dist/plugin/contracts.js.map +1 -0
  72. package/dist/plugin/license.d.ts +87 -0
  73. package/dist/plugin/license.d.ts.map +1 -0
  74. package/dist/plugin/license.js +243 -0
  75. package/dist/plugin/license.js.map +1 -0
  76. package/dist/plugin/manifest.d.ts +141 -0
  77. package/dist/plugin/manifest.d.ts.map +1 -0
  78. package/dist/plugin/manifest.js +281 -0
  79. package/dist/plugin/manifest.js.map +1 -0
  80. package/dist/plugin/registry-item.d.ts +171 -0
  81. package/dist/plugin/registry-item.d.ts.map +1 -0
  82. package/dist/plugin/registry-item.js +162 -0
  83. package/dist/plugin/registry-item.js.map +1 -0
  84. package/dist/plugin/spdx.generated.d.ts +9 -0
  85. package/dist/plugin/spdx.generated.d.ts.map +1 -0
  86. package/dist/plugin/spdx.generated.js +846 -0
  87. package/dist/plugin/spdx.generated.js.map +1 -0
  88. package/dist/plugin.d.ts +7 -0
  89. package/dist/plugin.js +6 -0
  90. package/dist/plugins.d.ts +118 -0
  91. package/dist/plugins.d.ts.map +1 -0
  92. package/dist/plugins.js +109 -0
  93. package/dist/plugins.js.map +1 -0
  94. package/package.json +19 -4
  95. package/schemas/plugin-manifest.draft-07.json +611 -0
  96. package/schemas/plugin-manifest.schema.json +607 -0
  97. package/schemas/protocol.draft-07.json +899 -1
  98. package/schemas/protocol.schema.json +875 -1
  99. package/src/artifact-path.ts +46 -0
  100. package/src/diagnostics/codes/index.ts +14 -2
  101. package/src/diagnostics/codes/license.ts +65 -0
  102. package/src/diagnostics/codes/pack.ts +125 -0
  103. package/src/diagnostics/codes/plugin.ts +173 -0
  104. package/src/diagnostics/diagnostic.ts +7 -1
  105. package/src/index.ts +57 -0
  106. package/src/methods/deps/add.ts +7 -0
  107. package/src/methods/index.ts +14 -0
  108. package/src/methods/mostra/initialize.ts +9 -1
  109. package/src/methods/pack/add.ts +133 -0
  110. package/src/methods/plugin/add.ts +70 -0
  111. package/src/methods/plugin/commands.ts +67 -0
  112. package/src/methods/plugin/export.ts +100 -0
  113. package/src/methods/plugin/list.ts +45 -0
  114. package/src/methods/plugin/remove.ts +58 -0
  115. package/src/methods/plugin/validate.ts +60 -0
  116. package/src/plugin/contract-versions.generated.ts +15 -0
  117. package/src/plugin/contracts.ts +171 -0
  118. package/src/plugin/license.ts +320 -0
  119. package/src/plugin/manifest.ts +546 -0
  120. package/src/plugin/registry-item.ts +330 -0
  121. package/src/plugin/spdx-tables.ts +74 -0
  122. package/src/plugin/spdx.generated.ts +844 -0
  123. package/src/plugin.ts +77 -0
  124. package/src/plugins.ts +239 -0
  125. package/LICENSE +0 -202
@@ -0,0 +1 @@
1
+ {"version":3,"file":"license.js","names":[],"sources":["../../src/plugin/license.ts"],"sourcesContent":["/**\n * License expressions and classes (D31, EX-04): what Mostra shows about a plugin's or a pack's\n * licenses at install, and which of them need a one-time acknowledgment. An SPDX expression is\n * parsed (SPDX 3.0 Annex B: `AND`, `OR`, `WITH`, `+`, parentheses, `LicenseRef-` and\n * `DocumentRef-`), each license in it is classed from the SPDX License List's own flags, and an\n * `OR` takes the branch that needs the fewest acknowledgments, as the person installing may choose.\n */\nimport type { LicenseClass } from \"../plugins.ts\";\nimport { SPDX_EXCEPTIONS, SPDX_LICENSES } from \"./spdx.generated.ts\";\n\nexport { SPDX_LICENSE_LIST_VERSION } from \"./spdx.generated.ts\";\n\n/** The classes whose licenses need `--accept-license` (or a host's pre-acceptance) at install. */\nexport const ACKNOWLEDGED_CLASSES: ReadonlySet<LicenseClass> = new Set([\n \"source-available\",\n \"proprietary\",\n \"unknown\",\n]);\n\n/**\n * OSI-approved licenses that ask derivative or combined works to stay under them (copyleft,\n * strong or weak), by family: everything else OSI-approved is `osi-permissive`. Either class\n * needs no acknowledgment; the difference is shown.\n */\nconst COPYLEFT =\n /^(?:A?GPL|LGPL|MPL|EPL|EUPL|CDDL|CPL|OSL|RPL|SPL|Sleepycat|MS-RL|CECILL|CPAL|APSL|QPL|RPSL|NPOSL|SimPL|Watcom|IPL|OSET-PL|Motosoto|Nokia|LPL|CUA-OPL|ErlPL|SISSL|eCos|Interbase|NGPL|EFL|OCLC|LiLiQ-R|AFL)(?:[-.]|$)/;\n\n/**\n * Dedications to the public domain, and licenses that ask nothing at all: none needs an\n * acknowledgment, OSI-approved or not (CC0 never was).\n */\nconst PUBLIC_DOMAIN: ReadonlySet<string> = new Set([\n \"CC0-1.0\",\n \"PDDL-1.0\",\n \"CC-PDDC\",\n \"CC-PDM-1.0\",\n \"Unlicense\",\n \"0BSD\",\n \"WTFPL\",\n \"MIT-0\",\n]);\n\n/** A license of the SPDX License List, as {@link spdxLicense} finds it. */\nexport interface SpdxEntry {\n /** Its SPDX ID, in the List's own case. */\n readonly id: string;\n /** OSI-approved, as the List flags it. */\n readonly osi: boolean;\n /** Free (libre) by the FSF, as the List flags it. */\n readonly free: boolean;\n}\n\nlet byLowerCase: Map<string, SpdxEntry> | undefined;\nlet exceptionsByLowerCase: Map<string, string> | undefined;\n\n/** An SPDX license ID in its canonical case with its flags, or `undefined` for one the list lacks. */\nexport function spdxLicense(id: string): SpdxEntry | undefined {\n if (byLowerCase === undefined) {\n byLowerCase = new Map();\n for (const entry of SPDX_LICENSES) {\n const at = entry.lastIndexOf(\":\");\n const licenseId = entry.slice(0, at);\n const flags = entry.slice(at + 1);\n byLowerCase.set(licenseId.toLowerCase(), {\n id: licenseId,\n osi: flags.includes(\"o\"),\n free: flags.includes(\"f\"),\n });\n }\n }\n return byLowerCase.get(id.toLowerCase());\n}\n\n/** An SPDX exception ID in its canonical case, or `undefined`. */\nfunction spdxException(id: string): string | undefined {\n exceptionsByLowerCase ??= new Map(SPDX_EXCEPTIONS.map((entry) => [entry.toLowerCase(), entry]));\n return exceptionsByLowerCase.get(id.toLowerCase());\n}\n\n/** The pattern of a license reference: `LicenseRef-<idstring>`, optionally `DocumentRef-<idstring>:` first. */\nconst LICENSE_REF = /^(?:DocumentRef-[A-Za-z0-9.-]+:)?LicenseRef-[A-Za-z0-9.-]+$/;\n\n/** Whether `id` is a license reference (never OSI-approved: it names a license only its author knows). */\nexport function isLicenseRef(id: string): boolean {\n return LICENSE_REF.test(id);\n}\n\n/** A parsed SPDX license expression. */\nexport type LicenseExpression =\n | { readonly kind: \"license\"; readonly id: string; readonly orLater: boolean }\n | { readonly kind: \"ref\"; readonly id: string }\n | { readonly kind: \"with\"; readonly license: LicenseExpression; readonly exception: string }\n | {\n readonly kind: \"and\" | \"or\";\n readonly left: LicenseExpression;\n readonly right: LicenseExpression;\n };\n\n/** Why an expression didn't parse. */\nexport class LicenseExpressionError extends Error {\n /** `LicenseExpressionError`. */\n override readonly name = \"LicenseExpressionError\";\n}\n\n/**\n * Parses an SPDX license expression. License and exception IDs take their canonical case;\n * operators are read in either case, as npm's ecosystem writes them.\n *\n * @throws LicenseExpressionError naming what isn't valid.\n */\nexport function parseLicenseExpression(text: string): LicenseExpression {\n const tokens = text.match(/\\(|\\)|[^\\s()]+/g) ?? [];\n if (tokens.length === 0) throw new LicenseExpressionError(\"The license expression is empty.\");\n let at = 0;\n const peek = (): string | undefined => tokens[at];\n const operator = (word: string | undefined): string | undefined => {\n const upper = word?.toUpperCase();\n return upper === \"AND\" || upper === \"OR\" || upper === \"WITH\" ? upper : undefined;\n };\n const simple = (): LicenseExpression => {\n const token = tokens[at++];\n if (token === undefined) throw new LicenseExpressionError(\"The expression ends too early.\");\n if (token === \"(\") {\n const inner = or();\n if (tokens[at++] !== \")\") throw new LicenseExpressionError(\"A parenthesis isn't closed.\");\n return inner;\n }\n if (token === \")\" || operator(token) !== undefined) {\n throw new LicenseExpressionError(`\"${token}\" can't start a license.`);\n }\n if (isLicenseRef(token)) return { kind: \"ref\", id: token };\n const orLater = token.endsWith(\"+\");\n const bare = orLater ? token.slice(0, -1) : token;\n const known = spdxLicense(bare);\n if (known === undefined) {\n throw new LicenseExpressionError(\n `\"${token}\" isn't an SPDX license ID or a LicenseRef- reference.`,\n );\n }\n return { kind: \"license\", id: known.id, orLater };\n };\n const withExpression = (): LicenseExpression => {\n const license = simple();\n if (operator(peek()) !== \"WITH\") return license;\n at += 1;\n const token = tokens[at++];\n const exception =\n token === undefined\n ? undefined\n : (spdxException(token) ??\n (/^(?:DocumentRef-[A-Za-z0-9.-]+:)?AdditionRef-[A-Za-z0-9.-]+$/.test(token)\n ? token\n : undefined));\n if (exception === undefined) {\n throw new LicenseExpressionError(`\"${token ?? \"\"}\" isn't an SPDX license exception.`);\n }\n if (license.kind !== \"license\" && license.kind !== \"ref\") {\n throw new LicenseExpressionError(\"WITH applies to one license.\");\n }\n return { kind: \"with\", license, exception };\n };\n const and = (): LicenseExpression => {\n let left = withExpression();\n while (operator(peek()) === \"AND\") {\n at += 1;\n left = { kind: \"and\", left, right: withExpression() };\n }\n return left;\n };\n const or = (): LicenseExpression => {\n let left = and();\n while (operator(peek()) === \"OR\") {\n at += 1;\n left = { kind: \"or\", left, right: and() };\n }\n return left;\n };\n const expression = or();\n if (at < tokens.length) {\n throw new LicenseExpressionError(`\"${tokens[at]}\" doesn't belong where it is.`);\n }\n return expression;\n}\n\n/** The canonical text of an expression. */\nexport function formatLicenseExpression(expression: LicenseExpression, nested = false): string {\n switch (expression.kind) {\n case \"license\":\n return `${expression.id}${expression.orLater ? \"+\" : \"\"}`;\n case \"ref\":\n return expression.id;\n case \"with\":\n return `${formatLicenseExpression(expression.license)} WITH ${expression.exception}`;\n default: {\n const text = `${formatLicenseExpression(expression.left, expression.kind === \"and\")} ${expression.kind.toUpperCase()} ${formatLicenseExpression(expression.right, expression.kind === \"and\")}`;\n return nested && expression.kind === \"or\" ? `(${text})` : text;\n }\n }\n}\n\n/** One license an expression comes down to, with its class. */\nexport interface LicenseTerm {\n /** The license's ID: an SPDX ID or a `LicenseRef-` reference, which `--accept-license` names. */\n readonly id: string;\n /** Its class (D31). */\n readonly class: LicenseClass;\n}\n\n/** The class of one SPDX license ID (canonical case). */\nexport function spdxClass(id: string): LicenseClass {\n const known = spdxLicense(id);\n if (known === undefined) return \"unknown\";\n if (PUBLIC_DOMAIN.has(known.id)) return \"public-domain\";\n if (known.osi) return COPYLEFT.test(known.id) ? \"osi-copyleft\" : \"osi-permissive\";\n if (known.free) return \"free\";\n return \"source-available\";\n}\n\n/**\n * What an expression comes down to: every license that applies, each with its class. A\n * reference's class is `declared(id)` (what the plugin's manifest says of it, never an OSI class)\n * or `unknown`. An `OR` keeps the branch that needs the fewest acknowledgments, then the first.\n */\nexport function licenseTerms(\n expression: LicenseExpression,\n declared: (id: string) => LicenseClass | undefined = () => undefined,\n): readonly LicenseTerm[] {\n const needs = (terms: readonly LicenseTerm[]): number =>\n terms.filter((term) => ACKNOWLEDGED_CLASSES.has(term.class)).length;\n const walk = (node: LicenseExpression): LicenseTerm[] => {\n switch (node.kind) {\n case \"license\":\n return [{ id: node.id, class: spdxClass(node.id) }];\n case \"ref\": {\n const declaredClass = declared(node.id);\n return [\n {\n id: node.id,\n class:\n declaredClass !== undefined && ACKNOWLEDGED_CLASSES.has(declaredClass)\n ? declaredClass\n : \"unknown\",\n },\n ];\n }\n case \"with\":\n return walk(node.license);\n case \"and\": {\n const terms = [...walk(node.left)];\n for (const term of walk(node.right)) {\n if (!terms.some((other) => other.id === term.id)) terms.push(term);\n }\n return terms;\n }\n case \"or\": {\n const left = walk(node.left);\n const right = walk(node.right);\n return needs(right) < needs(left) ? right : left;\n }\n }\n };\n return walk(expression);\n}\n\n/**\n * The license reference Mostra gives a package whose license it can't read (no `license` field,\n * `SEE LICENSE IN …`, a string that isn't an expression), so `--accept-license` can still name\n * it: `LicenseRef-npm-<name>` with the name's `@` and `/` as `-`.\n */\nexport function unreadableLicenseRef(packageName: string): string {\n return `LicenseRef-npm-${packageName.replace(/^@/, \"\").replace(/[^A-Za-z0-9.-]/g, \"-\")}`;\n}\n\n/**\n * The license expression a package's `package.json` declares: `license` (a string, or the old\n * `{ type }` form) or the old `licenses` array (each an alternative), or `undefined`.\n */\nexport function packageLicense(manifest: {\n readonly license?: unknown;\n readonly licenses?: unknown;\n}): string | undefined {\n const text = (value: unknown): string | undefined =>\n typeof value === \"string\"\n ? value\n : typeof value === \"object\" &&\n value !== null &&\n typeof (value as { type?: unknown }).type === \"string\"\n ? (value as { type: string }).type\n : undefined;\n const single = text(manifest.license);\n if (single !== undefined) return single.trim();\n if (Array.isArray(manifest.licenses)) {\n const all = manifest.licenses.map(text).filter((value) => value !== undefined);\n if (all.length > 0) return all.length === 1 ? all[0] : `(${all.join(\" OR \")})`;\n }\n return undefined;\n}\n\n/**\n * The terms of a package's license field: its expression's, or, for a field Mostra can't read,\n * one `unknown` term under {@link unreadableLicenseRef} (`UNLICENSED`, npm's word for \"no license\n * granted\", is `proprietary`).\n */\nexport function packageLicenseTerms(\n packageName: string,\n license: string | undefined,\n declared?: (id: string) => LicenseClass | undefined,\n): readonly LicenseTerm[] {\n if (license === \"UNLICENSED\") {\n return [{ id: unreadableLicenseRef(packageName), class: \"proprietary\" }];\n }\n if (license !== undefined) {\n try {\n return licenseTerms(parseLicenseExpression(license), declared);\n } catch (error) {\n if (!(error instanceof LicenseExpressionError)) throw error;\n }\n }\n return [{ id: unreadableLicenseRef(packageName), class: \"unknown\" }];\n}\n"],"mappings":";;;AAaA,MAAa,uCAAkD,IAAI,IAAI;CACrE;CACA;CACA;AACF,CAAC;;;;;;AAOD,MAAM,WACJ;;;;;AAMF,MAAM,gCAAqC,IAAI,IAAI;CACjD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAYD,IAAI;AACJ,IAAI;;AAGJ,SAAgB,YAAY,IAAmC;CAC7D,IAAI,gBAAgB,KAAA,GAAW;EAC7B,8BAAc,IAAI,IAAI;EACtB,KAAK,MAAM,SAAS,eAAe;GACjC,MAAM,KAAK,MAAM,YAAY,GAAG;GAChC,MAAM,YAAY,MAAM,MAAM,GAAG,EAAE;GACnC,MAAM,QAAQ,MAAM,MAAM,KAAK,CAAC;GAChC,YAAY,IAAI,UAAU,YAAY,GAAG;IACvC,IAAI;IACJ,KAAK,MAAM,SAAS,GAAG;IACvB,MAAM,MAAM,SAAS,GAAG;GAC1B,CAAC;EACH;CACF;CACA,OAAO,YAAY,IAAI,GAAG,YAAY,CA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AAI,IAAI,QAAQ;GAC9C;EACF;CACF;CACA,OAAO,KAAK,UAAU;AACxB;;;;;;AAOA,SAAgB,qBAAqB,aAA6B;CAChE,OAAO,kBAAkB,YAAY,QAAQ,MAAM,EAAE,CAAC,CAAC,QAAQ,mBAAmB,GAAG;AACvF;;;;;AAMA,SAAgB,eAAe,UAGR;CACrB,MAAM,QAAQ,UACZ,OAAO,UAAU,WACb,QACA,OAAO,UAAU,YACf,UAAU,QACV,OAAQ,MAA6B,SAAS,WAC7C,MAA2B,OAC5B,KAAA;CACR,MAAM,SAAS,KAAK,SAAS,OAAO;CACpC,IAAI,WAAW,KAAA,GAAW,OAAO,OAAO,KAAK;CAC7C,IAAI,MAAM,QAAQ,SAAS,QAAQ,GAAG;EACpC,MAAM,MAAM,SAAS,SAAS,IAAI,IAAI,CAAC,CAAC,QAAQ,UAAU,UAAU,KAAA,CAAS;EAC7E,IAAI,IAAI,SAAS,GAAG,OAAO,IAAI,WAAW,IAAI,IAAI,KAAK,IAAI,IAAI,KAAK,MAAM,EAAE;CAC9E;AAEF;;;;;;AAOA,SAAgB,oBACd,aACA,SACA,UACwB;CACxB,IAAI,YAAY,cACd,OAAO,CAAC;EAAE,IAAI,qBAAqB,WAAW;EAAG,OAAO;CAAc,CAAC;CAEzE,IAAI,YAAY,KAAA,GACd,IAAI;EACF,OAAO,aAAa,uBAAuB,OAAO,GAAG,QAAQ;CAC/D,SAAS,OAAO;EACd,IAAI,EAAE,iBAAiB,yBAAyB,MAAM;CACxD;CAEF,OAAO,CAAC;EAAE,IAAI,qBAAqB,WAAW;EAAG,OAAO;CAAU,CAAC;AACrE"}
@@ -0,0 +1,141 @@
1
+ import { ContractName, LicenseClass } from "../plugins.js";
2
+ import { ContributesKey } from "./contracts.js";
3
+ import * as z from "zod";
4
+ //#region src/plugin/manifest.d.ts
5
+ /**
6
+ * The dated revision of the manifest's schema (and of pack items'), published with it; within it
7
+ * the schema only grows, as the host protocol's does (D32).
8
+ */
9
+ export declare const PLUGIN_MANIFEST_REVISION = "2026-11-14";
10
+ /** The registry of the manifest's schemas: its own JSON Schema bundle, apart from the protocol's. */
11
+ export declare const pluginManifestRegistry: z.core.$ZodRegistry<{
12
+ id?: string;
13
+ description?: string;
14
+ }>;
15
+ /** The pattern of a manifest's `name`: `<namespace>/<name>`, the namespace in reverse-DNS form. */
16
+ export declare const PLUGIN_NAME: RegExp;
17
+ /** The pattern of a contribution's ID (each contract package's `CONTRIBUTION_ID`). */
18
+ export declare const CONTRIBUTION_ID: RegExp;
19
+ /** A path inside the plugin's package: `./`-relative, `/`-separated, never leaving it. */
20
+ export declare const PACKAGE_PATH: RegExp;
21
+ /** The effects a plugin may declare (D30): disclosure, never enforced. */
22
+ export declare const PLUGIN_EFFECTS: readonly string[];
23
+ /** The systems a plugin may name, as Node.js names them. */
24
+ export declare const PLUGIN_PLATFORMS: readonly string[];
25
+ /** One contribution that loads from a module of the package. */
26
+ export interface PluginEntry {
27
+ /** Its ID: what `--as`, a component or a review anchor names. */
28
+ readonly id: string;
29
+ /** The module that exports it: `./dist/pdf.js`. */
30
+ readonly entry: string;
31
+ /** The export that holds it; `default` when absent. */
32
+ readonly export?: string;
33
+ }
34
+ /** A CLI command contribution. */
35
+ export interface PluginCommandEntry {
36
+ /** Its words after `mostra`, joined by spaces: `term record`. */
37
+ readonly command: string;
38
+ /** The module that exports it: `./dist/index.js`. */
39
+ readonly entry: string;
40
+ /** The export that holds the definition; `default` when absent. */
41
+ readonly export?: string;
42
+ }
43
+ /** A source pack the plugin carries: a registry item file in its package. */
44
+ export interface PluginPackEntry {
45
+ /** The item: `./registry/terminal-demo.json`. */
46
+ readonly item: string;
47
+ }
48
+ /** What a plugin contributes, by kind. */
49
+ export interface PluginContributes {
50
+ /** Embed engines (`@mostra/contract-embed-engine`). */
51
+ readonly embedEngines?: readonly PluginEntry[];
52
+ /** Exporters (`@mostra/contract-exporter`). */
53
+ readonly exporters?: readonly PluginEntry[];
54
+ /** Verify checks (`@mostra/contract-verify-check`). */
55
+ readonly verifyChecks?: readonly PluginEntry[];
56
+ /** Anchor providers (`@mostra/contract-anchor-provider`). */
57
+ readonly anchorProviders?: readonly PluginEntry[];
58
+ /** Connectors (`@mostra/contract-connector`). */
59
+ readonly connectors?: readonly PluginEntry[];
60
+ /** CLI commands (`@mostra/contract-cli-command`). */
61
+ readonly cliCommands?: readonly PluginCommandEntry[];
62
+ /** Source packs it carries: registry items in the package. */
63
+ readonly packs?: readonly PluginPackEntry[];
64
+ }
65
+ /** A license the plugin brings with it, declared so Mostra can disclose it before install. */
66
+ export interface BundledLicense {
67
+ /** The npm package (or bundled engine) under it. */
68
+ readonly package: string;
69
+ /** Its SPDX expression: `MIT`, `LicenseRef-Remotion`. */
70
+ readonly license: string;
71
+ /** For a `LicenseRef-`: `source-available` or `proprietary`. */
72
+ readonly class?: LicenseClass;
73
+ /** One line on its terms, shown at install. */
74
+ readonly summary?: string;
75
+ /** Where its full text is. */
76
+ readonly url?: string;
77
+ }
78
+ /** A plugin's example and the baselines it verifies against. */
79
+ export interface PluginExample {
80
+ /** Its ID: lower-case letters, digits, `.`, `_` and `-`. */
81
+ readonly id: string;
82
+ /** The example artifact: `./examples/htop`. */
83
+ readonly path: string;
84
+ /** Its committed baselines: `./baselines/htop`. */
85
+ readonly baselines?: string;
86
+ }
87
+ /** The `"mostra"` key of a plugin's `package.json`. */
88
+ export interface PluginManifest {
89
+ /** `<namespace>/<name>`, the namespace in reverse-DNS form: `dev.acme/pdf`. */
90
+ readonly name: string;
91
+ /** A short name for people. */
92
+ readonly title?: string;
93
+ /** One sentence on what it does, for people and agents. */
94
+ readonly description?: string;
95
+ /** A semver range per contract it implements: `{ "exporter": "^0.1.0" }`. */
96
+ readonly contracts: Partial<Record<ContractName, string>>;
97
+ /** What it contributes, by kind. */
98
+ readonly contributes: PluginContributes;
99
+ /** What it does beyond computing (`network`, `filesystem` …): declared, never enforced. */
100
+ readonly effects?: readonly string[];
101
+ /** The plugin's own license, as an SPDX expression. */
102
+ readonly license: string;
103
+ /** Licenses of what it brings along: engines, assets, dependencies. */
104
+ readonly bundledLicenses?: readonly BundledLicense[];
105
+ /** Agent Skills that teach agents to use it: `./skills/pdf`. */
106
+ readonly skills?: readonly string[];
107
+ /** Example artifacts, each verified against its baselines. */
108
+ readonly examples?: readonly PluginExample[];
109
+ /** The systems it runs on; absent means all of Mostra's. */
110
+ readonly platforms?: readonly string[];
111
+ }
112
+ /** The Zod schema of the `PluginManifest` type, open to keys a later release adds. */
113
+ export declare const PluginManifestSchema: z.ZodType<PluginManifest>;
114
+ /** One problem with a manifest, at a path under `package.json` (`["mostra", "contracts"]`). */
115
+ export interface ManifestIssue {
116
+ /** Its path, relative to the package or registry. */
117
+ readonly path: readonly (string | number)[];
118
+ /** How serious it is: `error` fails the check, `warning` and `hint` inform. */
119
+ readonly severity: "error" | "warning";
120
+ /** What it found, in plain words. */
121
+ readonly message: string;
122
+ }
123
+ /** What {@link checkPluginManifest} found. */
124
+ export interface ManifestCheck {
125
+ /** The manifest, when it has no error. */
126
+ readonly manifest?: PluginManifest;
127
+ /** Every problem, errors and warnings, in the order of the manifest. */
128
+ readonly issues: readonly ManifestIssue[];
129
+ }
130
+ /** The contract each `contributes` key's contributions implement. */
131
+ export declare const CONTRACT_OF_KEY: Readonly<Record<ContributesKey, ContractName>>;
132
+ /**
133
+ * Checks the `"mostra"` key of a `package.json` (`value`), reporting every problem with its path.
134
+ * Unknown keys are warnings, so manifests grow additively; everything Mostra can't load is an
135
+ * error.
136
+ */
137
+ export declare function checkPluginManifest(value: unknown): ManifestCheck;
138
+ /** Where a plugin with this manifest may be installed: every scope its contracts allow. */
139
+ export declare function manifestScopes(manifest: PluginManifest): readonly ("artifact" | "home")[];
140
+ //#endregion
141
+ //# sourceMappingURL=manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.d.ts","names":["LicenseClassType","ContractNameType"],"sources":["../../src/plugin/manifest.ts"],"mappings":";;;;;;;;qBA+Ba;;qBAGA,wBAAwB,EAAE,KAAK;EAAe;EAAa;;;qBAI3D,aAAa;;qBAIb,iBAAiB;;qBAGjB,cAAc;;qBAGd;;qBASA;;iBAGI;;WAEN;;WAEA;;WAEA;;;iBAIM;;WAEN;;WAEA;;WAEA;;;iBAIM;;WAEN;;;iBAIM;;WAEN,wBAAwB;;WAExB,qBAAqB;;WAErB,wBAAwB;;WAExB,2BAA2B;;WAE3B,sBAAsB;;WAEtB,uBAAuB;;WAEvB,iBAAiB;;;iBAIX;;WAEN;;WAEA;;WAEA,QAAQA;;WAER;;WAEA;;;iBAIM;;WAEN;;WAEA;;WAEA;;;iBAIM;;WAEN;;WAEA;;WAEA;;WAEA,WAAW,QAAQ,OAAOC;;WAE1B,aAAa;;WAEb;;WAEA;;WAEA,2BAA2B;;WAE3B;;WAEA,oBAAoB;;WAEpB;;;qBAgEE,sBAAsB,EAAE,QAAQ;;iBAqB5B;;WAEN;;WAEA;;WAEA;;;iBAIM;;WAEN,WAAW;;WAEX,iBAAiB;;;qBA2Bf,iBAAiB,SAAS,OAAO,gBAAgBA;;;;;;wBAW9C,oBAAoB,iBAAiB;;wBA2PrC,eAAe,UAAU"}
@@ -0,0 +1,281 @@
1
+ import { ContractName, LicenseClass } from "../plugins.js";
2
+ import { CONTRACT_NAMES, PLUGIN_CONTRACTS, coreCommandTaken } from "./contracts.js";
3
+ import { ACKNOWLEDGED_CLASSES, LicenseExpressionError, isLicenseRef, parseLicenseExpression } from "./license.js";
4
+ import * as z from "zod";
5
+ //#region src/plugin/manifest.ts
6
+ /**
7
+ * The plugin manifest (D30, ROUND-3 §6.2, EX-02): the `"mostra"` key of a plugin's
8
+ * `package.json`. Its Zod schema is the source of the published JSON Schema
9
+ * (`schemas/plugin-manifest.schema.json`); {@link checkPluginManifest} adds what a schema can't
10
+ * say (a contract each contribution kind needs, unique IDs, license expressions) and reports every
11
+ * problem it finds, each with the path of the field, so `mostra plugin validate` names them all.
12
+ */
13
+ /**
14
+ * The dated revision of the manifest's schema (and of pack items'), published with it; within it
15
+ * the schema only grows, as the host protocol's does (D32).
16
+ */
17
+ const PLUGIN_MANIFEST_REVISION = "2026-11-14";
18
+ /** The registry of the manifest's schemas: its own JSON Schema bundle, apart from the protocol's. */
19
+ const pluginManifestRegistry = z.registry();
20
+ /** The pattern of a manifest's `name`: `<namespace>/<name>`, the namespace in reverse-DNS form. */
21
+ const PLUGIN_NAME = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+\/[a-z0-9][a-z0-9._-]{0,63}$/;
22
+ /** The pattern of a contribution's ID (each contract package's `CONTRIBUTION_ID`). */
23
+ const CONTRIBUTION_ID = /^[a-z0-9][a-z0-9._-]{0,63}$/;
24
+ /** A path inside the plugin's package: `./`-relative, `/`-separated, never leaving it. */
25
+ const PACKAGE_PATH = /^\.\/(?!.*(?:^|\/)\.\.?(?:\/|$))[^\\:*?"<>|\0]+$/;
26
+ /** The effects a plugin may declare (D30): disclosure, never enforced. */
27
+ const PLUGIN_EFFECTS = [
28
+ "network",
29
+ "filesystem",
30
+ "process",
31
+ "credentials",
32
+ "sends-data"
33
+ ];
34
+ /** The systems a plugin may name, as Node.js names them. */
35
+ const PLUGIN_PLATFORMS = [
36
+ "darwin",
37
+ "linux",
38
+ "win32"
39
+ ];
40
+ const packagePath = z.string().regex(PACKAGE_PATH, "a ./-relative path inside the package");
41
+ const exportName = z.string().regex(/^[A-Za-z_$][\w$]*$/, "a JavaScript export name");
42
+ const PluginEntrySchema = z.looseObject({
43
+ id: z.string().regex(CONTRIBUTION_ID, "lower-case letters, digits, '.', '_' and '-' (1 to 64)"),
44
+ entry: packagePath,
45
+ export: exportName.exactOptional()
46
+ }).register(pluginManifestRegistry, { id: "PluginEntry" });
47
+ const PluginCommandEntrySchema = z.looseObject({
48
+ command: z.string().regex(/^[a-z][a-z0-9-]{0,31}(?: [a-z][a-z0-9-]{0,31}){0,3}$/, "one to four lower-case words separated by single spaces"),
49
+ entry: packagePath,
50
+ export: exportName.exactOptional()
51
+ }).register(pluginManifestRegistry, { id: "PluginCommandEntry" });
52
+ const PluginPackEntrySchema = z.looseObject({ item: packagePath }).register(pluginManifestRegistry, { id: "PluginPackEntry" });
53
+ const entries = PluginEntrySchema.array().readonly().exactOptional();
54
+ const PluginContributesSchema = z.looseObject({
55
+ embedEngines: entries,
56
+ exporters: entries,
57
+ verifyChecks: entries,
58
+ anchorProviders: entries,
59
+ connectors: entries,
60
+ cliCommands: PluginCommandEntrySchema.array().readonly().exactOptional(),
61
+ packs: PluginPackEntrySchema.array().readonly().exactOptional()
62
+ }).register(pluginManifestRegistry, { id: "PluginContributes" });
63
+ const BundledLicenseSchema = z.looseObject({
64
+ package: z.string().min(1).max(214),
65
+ license: z.string().min(1).max(512),
66
+ class: LicenseClass.exactOptional(),
67
+ summary: z.string().max(400).exactOptional(),
68
+ url: z.url().exactOptional()
69
+ }).register(pluginManifestRegistry, { id: "BundledLicense" });
70
+ const PluginExampleSchema = z.looseObject({
71
+ id: z.string().regex(CONTRIBUTION_ID),
72
+ path: packagePath,
73
+ baselines: packagePath.exactOptional()
74
+ }).register(pluginManifestRegistry, { id: "PluginExample" });
75
+ /** The Zod schema of the `PluginManifest` type, open to keys a later release adds. */
76
+ const PluginManifestSchema = z.looseObject({
77
+ name: z.string().regex(PLUGIN_NAME, "<namespace>/<name>, the namespace in reverse-DNS form"),
78
+ title: z.string().min(1).max(80).exactOptional(),
79
+ description: z.string().max(400).exactOptional(),
80
+ contracts: z.partialRecord(ContractName, z.string().min(1).max(128)),
81
+ contributes: PluginContributesSchema,
82
+ effects: z.array(z.string()).readonly().exactOptional(),
83
+ license: z.string().min(1).max(512),
84
+ bundledLicenses: BundledLicenseSchema.array().readonly().exactOptional(),
85
+ skills: packagePath.array().readonly().exactOptional(),
86
+ examples: PluginExampleSchema.array().readonly().exactOptional(),
87
+ platforms: z.array(z.string()).readonly().exactOptional()
88
+ }).register(pluginManifestRegistry, {
89
+ id: "PluginManifest",
90
+ description: "The \"mostra\" key of a Mostra plugin's package.json (D30): its name, contract ranges, contributions, declared effects and licenses."
91
+ });
92
+ const KNOWN_KEYS = {
93
+ manifest: [
94
+ "$schema",
95
+ "name",
96
+ "title",
97
+ "description",
98
+ "contracts",
99
+ "contributes",
100
+ "effects",
101
+ "license",
102
+ "bundledLicenses",
103
+ "skills",
104
+ "examples",
105
+ "platforms"
106
+ ],
107
+ contributes: [...CONTRACT_NAMES.map((name) => PLUGIN_CONTRACTS[name].key), "packs"],
108
+ entry: [
109
+ "id",
110
+ "entry",
111
+ "export",
112
+ "title"
113
+ ],
114
+ command: [
115
+ "command",
116
+ "entry",
117
+ "export"
118
+ ],
119
+ pack: ["item"],
120
+ license: [
121
+ "package",
122
+ "license",
123
+ "class",
124
+ "summary",
125
+ "url"
126
+ ],
127
+ example: [
128
+ "id",
129
+ "path",
130
+ "baselines"
131
+ ]
132
+ };
133
+ /** The contract each `contributes` key's contributions implement. */
134
+ const CONTRACT_OF_KEY = Object.fromEntries(CONTRACT_NAMES.map((name) => [PLUGIN_CONTRACTS[name].key, name]));
135
+ /**
136
+ * Checks the `"mostra"` key of a `package.json` (`value`), reporting every problem with its path.
137
+ * Unknown keys are warnings, so manifests grow additively; everything Mostra can't load is an
138
+ * error.
139
+ */
140
+ function checkPluginManifest(value) {
141
+ const issues = [];
142
+ const at = (...path) => ["mostra", ...path];
143
+ const error = (message, ...path) => {
144
+ issues.push({
145
+ path: at(...path),
146
+ severity: "error",
147
+ message
148
+ });
149
+ };
150
+ const warn = (message, ...path) => {
151
+ issues.push({
152
+ path: at(...path),
153
+ severity: "warning",
154
+ message
155
+ });
156
+ };
157
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
158
+ error("The mostra key must be an object: the plugin's manifest.");
159
+ return { issues };
160
+ }
161
+ const parsed = PluginManifestSchema.safeParse(value);
162
+ if (!parsed.success) for (const issue of parsed.error.issues) {
163
+ const path = issue.path.filter((part) => typeof part === "string" || typeof part === "number");
164
+ if (issue.code === "unrecognized_keys") for (const key of issue.keys) error(`Mostra implements no contract "${key}"; it implements ${CONTRACT_NAMES.join(", ")}.`, ...path, key);
165
+ else error(issueMessage(issue), ...path);
166
+ }
167
+ const raw = value;
168
+ const unknownKeys = (object, known, ...path) => {
169
+ if (typeof object !== "object" || object === null || Array.isArray(object)) return;
170
+ for (const key of Object.keys(object)) if (!known.includes(key)) warn(`This Mostra release doesn't know the key "${key}"; it is ignored.`, ...path, key);
171
+ };
172
+ unknownKeys(raw, KNOWN_KEYS["manifest"] ?? []);
173
+ unknownKeys(raw["contributes"], KNOWN_KEYS["contributes"] ?? [], "contributes");
174
+ const contributes = raw["contributes"] ?? {};
175
+ for (const [key, list] of Object.entries(contributes)) {
176
+ if (!Array.isArray(list)) continue;
177
+ list.forEach((item, index) => {
178
+ const known = key === "cliCommands" ? KNOWN_KEYS["command"] : key === "packs" ? KNOWN_KEYS["pack"] : KNOWN_KEYS["entry"];
179
+ unknownKeys(item, known ?? [], "contributes", key, index);
180
+ });
181
+ }
182
+ if (Array.isArray(raw["bundledLicenses"])) raw["bundledLicenses"].forEach((item, index) => {
183
+ unknownKeys(item, KNOWN_KEYS["license"] ?? [], "bundledLicenses", index);
184
+ });
185
+ if (Array.isArray(raw["examples"])) raw["examples"].forEach((item, index) => {
186
+ unknownKeys(item, KNOWN_KEYS["example"] ?? [], "examples", index);
187
+ });
188
+ const view = lenientView(raw);
189
+ let contributions = 0;
190
+ for (const name of CONTRACT_NAMES) {
191
+ const key = PLUGIN_CONTRACTS[name].key;
192
+ const list = view.contributes[key];
193
+ if (list === void 0) continue;
194
+ contributions += list.length;
195
+ if (list.length > 0 && !view.contracts.has(name)) error(`contributes.${key} needs the contract it implements: add "${name}" with a range to contracts.`, "contributes", key);
196
+ const seen = /* @__PURE__ */ new Map();
197
+ list.forEach((item, index) => {
198
+ const id = key === "cliCommands" ? item["command"] : item["id"];
199
+ if (typeof id !== "string") return;
200
+ const first = seen.get(id);
201
+ if (first !== void 0) error(`"${id}" is contributed twice (also at contributes.${key}[${first}]).`, "contributes", key, index);
202
+ else seen.set(id, index);
203
+ if (key === "cliCommands") {
204
+ const taken = coreCommandTaken(id.split(" "));
205
+ if (taken !== void 0) error(`"mostra ${id}" would collide with Mostra's own "mostra ${taken.join(" ")}".`, "contributes", key, index, "command");
206
+ }
207
+ });
208
+ }
209
+ for (const name of view.contracts) {
210
+ const key = PLUGIN_CONTRACTS[name].key;
211
+ if ((view.contributes[key]?.length ?? 0) === 0) warn(`The manifest declares the ${name} contract but contributes nothing to it.`, "contracts", name);
212
+ }
213
+ if (view.contributesObject && contributions === 0 && (view.contributes["packs"]?.length ?? 0) === 0) error("The plugin contributes nothing: add an entry to contributes.", "contributes");
214
+ if (typeof raw["license"] === "string") try {
215
+ parseLicenseExpression(raw["license"]);
216
+ } catch (problem) {
217
+ if (!(problem instanceof LicenseExpressionError)) throw problem;
218
+ error(`${problem.message} Use an SPDX expression, or LicenseRef-<name> for another license.`, "license");
219
+ }
220
+ view.bundledLicenses.forEach((bundled, index) => {
221
+ const license = bundled["license"];
222
+ if (typeof license === "string") try {
223
+ parseLicenseExpression(license);
224
+ } catch (problem) {
225
+ if (!(problem instanceof LicenseExpressionError)) throw problem;
226
+ error(problem.message, "bundledLicenses", index, "license");
227
+ }
228
+ const licenseClass = bundled["class"];
229
+ if (typeof licenseClass === "string" && typeof license === "string") {
230
+ if (!isLicenseRef(license)) error("class applies only to a LicenseRef-: Mostra classes SPDX licenses from the SPDX License List itself.", "bundledLicenses", index, "class");
231
+ else if (!ACKNOWLEDGED_CLASSES.has(licenseClass) || licenseClass === "unknown") error("A LicenseRef- is never OSI-approved: its class is \"source-available\" or \"proprietary\".", "bundledLicenses", index, "class");
232
+ }
233
+ });
234
+ view.effects.forEach((effect, index) => {
235
+ if (typeof effect === "string" && !PLUGIN_EFFECTS.includes(effect)) warn(`This Mostra release doesn't know the effect "${effect}" (it knows ${PLUGIN_EFFECTS.join(", ")}); it is shown as declared.`, "effects", index);
236
+ });
237
+ view.platforms.forEach((platform, index) => {
238
+ if (typeof platform === "string" && !PLUGIN_PLATFORMS.includes(platform)) warn(`"${platform}" isn't a system Mostra runs on (${PLUGIN_PLATFORMS.join(", ")}).`, "platforms", index);
239
+ });
240
+ if (!parsed.success) return { issues };
241
+ const manifest = parsed.data;
242
+ return issues.some((issue) => issue.severity === "error") ? { issues } : {
243
+ manifest,
244
+ issues
245
+ };
246
+ }
247
+ const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
248
+ function lenientView(raw) {
249
+ const contracts = /* @__PURE__ */ new Set();
250
+ if (isObject(raw["contracts"])) {
251
+ for (const key of Object.keys(raw["contracts"])) if (CONTRACT_NAMES.includes(key)) contracts.add(key);
252
+ }
253
+ const contributes = {};
254
+ if (isObject(raw["contributes"])) {
255
+ for (const [key, list] of Object.entries(raw["contributes"])) if (Array.isArray(list)) contributes[key] = list.filter(isObject);
256
+ }
257
+ return {
258
+ contracts,
259
+ contributesObject: isObject(raw["contributes"]),
260
+ contributes,
261
+ bundledLicenses: Array.isArray(raw["bundledLicenses"]) ? raw["bundledLicenses"].filter(isObject) : [],
262
+ effects: Array.isArray(raw["effects"]) ? raw["effects"] : [],
263
+ platforms: Array.isArray(raw["platforms"]) ? raw["platforms"] : []
264
+ };
265
+ }
266
+ /** A Zod issue in the manifest's words. */
267
+ function issueMessage(issue) {
268
+ if (issue.code === "invalid_type") return issue.input === void 0 ? `This field is required (${issue.expected}).` : `Expected ${issue.expected}.`;
269
+ if (issue.code === "invalid_value") return `Expected one of ${issue.values.map((value) => JSON.stringify(value)).join(", ")}.`;
270
+ if (issue.code === "invalid_format" && issue.format === "regex") return `Expected ${issue.message.replace(/^Invalid string: must match pattern .*$/, "the documented form")}.`;
271
+ return issue.message;
272
+ }
273
+ /** Where a plugin with this manifest may be installed: every scope its contracts allow. */
274
+ function manifestScopes(manifest) {
275
+ const kinds = CONTRACT_NAMES.filter((name) => (manifest.contributes[PLUGIN_CONTRACTS[name].key]?.length ?? 0) > 0);
276
+ return !((manifest.contributes.packs?.length ?? 0) > 0) && kinds.every((name) => PLUGIN_CONTRACTS[name].scopes.includes("home")) ? ["artifact", "home"] : ["artifact"];
277
+ }
278
+ //#endregion
279
+ export { CONTRACT_OF_KEY, CONTRIBUTION_ID, PACKAGE_PATH, PLUGIN_EFFECTS, PLUGIN_MANIFEST_REVISION, PLUGIN_NAME, PLUGIN_PLATFORMS, PluginManifestSchema, checkPluginManifest, manifestScopes, pluginManifestRegistry };
280
+
281
+ //# sourceMappingURL=manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.js","names":[],"sources":["../../src/plugin/manifest.ts"],"sourcesContent":["/**\n * The plugin manifest (D30, ROUND-3 §6.2, EX-02): the `\"mostra\"` key of a plugin's\n * `package.json`. Its Zod schema is the source of the published JSON Schema\n * (`schemas/plugin-manifest.schema.json`); {@link checkPluginManifest} adds what a schema can't\n * say (a contract each contribution kind needs, unique IDs, license expressions) and reports every\n * problem it finds, each with the path of the field, so `mostra plugin validate` names them all.\n */\nimport * as z from \"zod\";\nimport {\n ContractName,\n type ContractName as ContractNameType,\n LicenseClass,\n type LicenseClass as LicenseClassType,\n} from \"../plugins.ts\";\nimport {\n CONTRACT_NAMES,\n type ContributesKey,\n coreCommandTaken,\n PLUGIN_CONTRACTS,\n} from \"./contracts.ts\";\nimport {\n ACKNOWLEDGED_CLASSES,\n isLicenseRef,\n LicenseExpressionError,\n parseLicenseExpression,\n} from \"./license.ts\";\n\n/**\n * The dated revision of the manifest's schema (and of pack items'), published with it; within it\n * the schema only grows, as the host protocol's does (D32).\n */\nexport const PLUGIN_MANIFEST_REVISION = \"2026-11-14\";\n\n/** The registry of the manifest's schemas: its own JSON Schema bundle, apart from the protocol's. */\nexport const pluginManifestRegistry: z.core.$ZodRegistry<{ id?: string; description?: string }> =\n z.registry<{ id?: string; description?: string }>();\n\n/** The pattern of a manifest's `name`: `<namespace>/<name>`, the namespace in reverse-DNS form. */\nexport const PLUGIN_NAME: RegExp =\n /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+\\/[a-z0-9][a-z0-9._-]{0,63}$/;\n\n/** The pattern of a contribution's ID (each contract package's `CONTRIBUTION_ID`). */\nexport const CONTRIBUTION_ID: RegExp = /^[a-z0-9][a-z0-9._-]{0,63}$/;\n\n/** A path inside the plugin's package: `./`-relative, `/`-separated, never leaving it. */\nexport const PACKAGE_PATH: RegExp = /^\\.\\/(?!.*(?:^|\\/)\\.\\.?(?:\\/|$))[^\\\\:*?\"<>|\\0]+$/;\n\n/** The effects a plugin may declare (D30): disclosure, never enforced. */\nexport const PLUGIN_EFFECTS: readonly string[] = [\n \"network\",\n \"filesystem\",\n \"process\",\n \"credentials\",\n \"sends-data\",\n];\n\n/** The systems a plugin may name, as Node.js names them. */\nexport const PLUGIN_PLATFORMS: readonly string[] = [\"darwin\", \"linux\", \"win32\"];\n\n/** One contribution that loads from a module of the package. */\nexport interface PluginEntry {\n /** Its ID: what `--as`, a component or a review anchor names. */\n readonly id: string;\n /** The module that exports it: `./dist/pdf.js`. */\n readonly entry: string;\n /** The export that holds it; `default` when absent. */\n readonly export?: string;\n}\n\n/** A CLI command contribution. */\nexport interface PluginCommandEntry {\n /** Its words after `mostra`, joined by spaces: `term record`. */\n readonly command: string;\n /** The module that exports it: `./dist/index.js`. */\n readonly entry: string;\n /** The export that holds the definition; `default` when absent. */\n readonly export?: string;\n}\n\n/** A source pack the plugin carries: a registry item file in its package. */\nexport interface PluginPackEntry {\n /** The item: `./registry/terminal-demo.json`. */\n readonly item: string;\n}\n\n/** What a plugin contributes, by kind. */\nexport interface PluginContributes {\n /** Embed engines (`@mostra/contract-embed-engine`). */\n readonly embedEngines?: readonly PluginEntry[];\n /** Exporters (`@mostra/contract-exporter`). */\n readonly exporters?: readonly PluginEntry[];\n /** Verify checks (`@mostra/contract-verify-check`). */\n readonly verifyChecks?: readonly PluginEntry[];\n /** Anchor providers (`@mostra/contract-anchor-provider`). */\n readonly anchorProviders?: readonly PluginEntry[];\n /** Connectors (`@mostra/contract-connector`). */\n readonly connectors?: readonly PluginEntry[];\n /** CLI commands (`@mostra/contract-cli-command`). */\n readonly cliCommands?: readonly PluginCommandEntry[];\n /** Source packs it carries: registry items in the package. */\n readonly packs?: readonly PluginPackEntry[];\n}\n\n/** A license the plugin brings with it, declared so Mostra can disclose it before install. */\nexport interface BundledLicense {\n /** The npm package (or bundled engine) under it. */\n readonly package: string;\n /** Its SPDX expression: `MIT`, `LicenseRef-Remotion`. */\n readonly license: string;\n /** For a `LicenseRef-`: `source-available` or `proprietary`. */\n readonly class?: LicenseClassType;\n /** One line on its terms, shown at install. */\n readonly summary?: string;\n /** Where its full text is. */\n readonly url?: string;\n}\n\n/** A plugin's example and the baselines it verifies against. */\nexport interface PluginExample {\n /** Its ID: lower-case letters, digits, `.`, `_` and `-`. */\n readonly id: string;\n /** The example artifact: `./examples/htop`. */\n readonly path: string;\n /** Its committed baselines: `./baselines/htop`. */\n readonly baselines?: string;\n}\n\n/** The `\"mostra\"` key of a plugin's `package.json`. */\nexport interface PluginManifest {\n /** `<namespace>/<name>`, the namespace in reverse-DNS form: `dev.acme/pdf`. */\n readonly name: string;\n /** A short name for people. */\n readonly title?: string;\n /** One sentence on what it does, for people and agents. */\n readonly description?: string;\n /** A semver range per contract it implements: `{ \"exporter\": \"^0.1.0\" }`. */\n readonly contracts: Partial<Record<ContractNameType, string>>;\n /** What it contributes, by kind. */\n readonly contributes: PluginContributes;\n /** What it does beyond computing (`network`, `filesystem` …): declared, never enforced. */\n readonly effects?: readonly string[];\n /** The plugin's own license, as an SPDX expression. */\n readonly license: string;\n /** Licenses of what it brings along: engines, assets, dependencies. */\n readonly bundledLicenses?: readonly BundledLicense[];\n /** Agent Skills that teach agents to use it: `./skills/pdf`. */\n readonly skills?: readonly string[];\n /** Example artifacts, each verified against its baselines. */\n readonly examples?: readonly PluginExample[];\n /** The systems it runs on; absent means all of Mostra's. */\n readonly platforms?: readonly string[];\n}\n\nconst packagePath = z.string().regex(PACKAGE_PATH, \"a ./-relative path inside the package\");\nconst exportName = z.string().regex(/^[A-Za-z_$][\\w$]*$/, \"a JavaScript export name\");\n\nconst PluginEntrySchema: z.ZodType<PluginEntry> = z\n .looseObject({\n id: z.string().regex(CONTRIBUTION_ID, \"lower-case letters, digits, '.', '_' and '-' (1 to 64)\"),\n entry: packagePath,\n export: exportName.exactOptional(),\n })\n .register(pluginManifestRegistry, { id: \"PluginEntry\" });\n\nconst PluginCommandEntrySchema: z.ZodType<PluginCommandEntry> = z\n .looseObject({\n command: z\n .string()\n .regex(\n /^[a-z][a-z0-9-]{0,31}(?: [a-z][a-z0-9-]{0,31}){0,3}$/,\n \"one to four lower-case words separated by single spaces\",\n ),\n entry: packagePath,\n export: exportName.exactOptional(),\n })\n .register(pluginManifestRegistry, { id: \"PluginCommandEntry\" });\n\nconst PluginPackEntrySchema: z.ZodType<PluginPackEntry> = z\n .looseObject({ item: packagePath })\n .register(pluginManifestRegistry, { id: \"PluginPackEntry\" });\n\nconst entries = PluginEntrySchema.array().readonly().exactOptional();\n\nconst PluginContributesSchema: z.ZodType<PluginContributes> = z\n .looseObject({\n embedEngines: entries,\n exporters: entries,\n verifyChecks: entries,\n anchorProviders: entries,\n connectors: entries,\n cliCommands: PluginCommandEntrySchema.array().readonly().exactOptional(),\n packs: PluginPackEntrySchema.array().readonly().exactOptional(),\n })\n .register(pluginManifestRegistry, { id: \"PluginContributes\" });\n\nconst BundledLicenseSchema: z.ZodType<BundledLicense> = z\n .looseObject({\n package: z.string().min(1).max(214),\n license: z.string().min(1).max(512),\n class: LicenseClass.exactOptional(),\n summary: z.string().max(400).exactOptional(),\n url: z.url().exactOptional(),\n })\n .register(pluginManifestRegistry, { id: \"BundledLicense\" });\n\nconst PluginExampleSchema: z.ZodType<PluginExample> = z\n .looseObject({\n id: z.string().regex(CONTRIBUTION_ID),\n path: packagePath,\n baselines: packagePath.exactOptional(),\n })\n .register(pluginManifestRegistry, { id: \"PluginExample\" });\n\n/** The Zod schema of the `PluginManifest` type, open to keys a later release adds. */\nexport const PluginManifestSchema: z.ZodType<PluginManifest> = z\n .looseObject({\n name: z.string().regex(PLUGIN_NAME, \"<namespace>/<name>, the namespace in reverse-DNS form\"),\n title: z.string().min(1).max(80).exactOptional(),\n description: z.string().max(400).exactOptional(),\n contracts: z.partialRecord(ContractName, z.string().min(1).max(128)),\n contributes: PluginContributesSchema,\n effects: z.array(z.string()).readonly().exactOptional(),\n license: z.string().min(1).max(512),\n bundledLicenses: BundledLicenseSchema.array().readonly().exactOptional(),\n skills: packagePath.array().readonly().exactOptional(),\n examples: PluginExampleSchema.array().readonly().exactOptional(),\n platforms: z.array(z.string()).readonly().exactOptional(),\n })\n .register(pluginManifestRegistry, {\n id: \"PluginManifest\",\n description:\n 'The \"mostra\" key of a Mostra plugin\\'s package.json (D30): its name, contract ranges, contributions, declared effects and licenses.',\n });\n\n/** One problem with a manifest, at a path under `package.json` (`[\"mostra\", \"contracts\"]`). */\nexport interface ManifestIssue {\n /** Its path, relative to the package or registry. */\n readonly path: readonly (string | number)[];\n /** How serious it is: `error` fails the check, `warning` and `hint` inform. */\n readonly severity: \"error\" | \"warning\";\n /** What it found, in plain words. */\n readonly message: string;\n}\n\n/** What {@link checkPluginManifest} found. */\nexport interface ManifestCheck {\n /** The manifest, when it has no error. */\n readonly manifest?: PluginManifest;\n /** Every problem, errors and warnings, in the order of the manifest. */\n readonly issues: readonly ManifestIssue[];\n}\n\nconst KNOWN_KEYS: Readonly<Record<string, readonly string[]>> = {\n manifest: [\n \"$schema\",\n \"name\",\n \"title\",\n \"description\",\n \"contracts\",\n \"contributes\",\n \"effects\",\n \"license\",\n \"bundledLicenses\",\n \"skills\",\n \"examples\",\n \"platforms\",\n ],\n contributes: [...CONTRACT_NAMES.map((name) => PLUGIN_CONTRACTS[name].key), \"packs\"],\n entry: [\"id\", \"entry\", \"export\", \"title\"],\n command: [\"command\", \"entry\", \"export\"],\n pack: [\"item\"],\n license: [\"package\", \"license\", \"class\", \"summary\", \"url\"],\n example: [\"id\", \"path\", \"baselines\"],\n};\n\n/** The contract each `contributes` key's contributions implement. */\nexport const CONTRACT_OF_KEY: Readonly<Record<ContributesKey, ContractNameType>> =\n Object.fromEntries(CONTRACT_NAMES.map((name) => [PLUGIN_CONTRACTS[name].key, name])) as Record<\n ContributesKey,\n ContractNameType\n >;\n\n/**\n * Checks the `\"mostra\"` key of a `package.json` (`value`), reporting every problem with its path.\n * Unknown keys are warnings, so manifests grow additively; everything Mostra can't load is an\n * error.\n */\nexport function checkPluginManifest(value: unknown): ManifestCheck {\n const issues: ManifestIssue[] = [];\n const at = (...path: (string | number)[]): (string | number)[] => [\"mostra\", ...path];\n const error = (message: string, ...path: (string | number)[]): void => {\n issues.push({ path: at(...path), severity: \"error\", message });\n };\n const warn = (message: string, ...path: (string | number)[]): void => {\n issues.push({ path: at(...path), severity: \"warning\", message });\n };\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n error(\"The mostra key must be an object: the plugin's manifest.\");\n return { issues };\n }\n const parsed = PluginManifestSchema.safeParse(value);\n if (!parsed.success) {\n for (const issue of parsed.error.issues) {\n const path = issue.path.filter(\n (part): part is string | number => typeof part === \"string\" || typeof part === \"number\",\n );\n if (issue.code === \"unrecognized_keys\") {\n // Only `contracts` is closed: a contract this release doesn't implement can't load.\n for (const key of issue.keys) {\n error(\n `Mostra implements no contract \"${key}\"; it implements ${CONTRACT_NAMES.join(\", \")}.`,\n ...path,\n key,\n );\n }\n } else error(issueMessage(issue), ...path);\n }\n }\n const raw = value as Record<string, unknown>;\n const unknownKeys = (object: unknown, known: readonly string[], ...path: (string | number)[]) => {\n if (typeof object !== \"object\" || object === null || Array.isArray(object)) return;\n for (const key of Object.keys(object)) {\n if (!known.includes(key)) {\n warn(`This Mostra release doesn't know the key \"${key}\"; it is ignored.`, ...path, key);\n }\n }\n };\n unknownKeys(raw, KNOWN_KEYS[\"manifest\"] ?? []);\n unknownKeys(raw[\"contributes\"], KNOWN_KEYS[\"contributes\"] ?? [], \"contributes\");\n const contributes = (raw[\"contributes\"] ?? {}) as Record<string, unknown>;\n for (const [key, list] of Object.entries(contributes)) {\n if (!Array.isArray(list)) continue;\n list.forEach((item, index) => {\n const known =\n key === \"cliCommands\"\n ? KNOWN_KEYS[\"command\"]\n : key === \"packs\"\n ? KNOWN_KEYS[\"pack\"]\n : KNOWN_KEYS[\"entry\"];\n unknownKeys(item, known ?? [], \"contributes\", key, index);\n });\n }\n if (Array.isArray(raw[\"bundledLicenses\"])) {\n raw[\"bundledLicenses\"].forEach((item, index) => {\n unknownKeys(item, KNOWN_KEYS[\"license\"] ?? [], \"bundledLicenses\", index);\n });\n }\n if (Array.isArray(raw[\"examples\"])) {\n raw[\"examples\"].forEach((item, index) => {\n unknownKeys(item, KNOWN_KEYS[\"example\"] ?? [], \"examples\", index);\n });\n }\n // The rules beyond the schema run on what the manifest holds even when part of it is wrong, so\n // one run reports every invalid field (EX-02); each looks only at values of the right type.\n const view = lenientView(raw);\n // Each kind of contribution needs its contract, and IDs are unique per contract.\n let contributions = 0;\n for (const name of CONTRACT_NAMES) {\n const key = PLUGIN_CONTRACTS[name].key;\n const list = view.contributes[key];\n if (list === undefined) continue;\n contributions += list.length;\n if (list.length > 0 && !view.contracts.has(name)) {\n error(\n `contributes.${key} needs the contract it implements: add \"${name}\" with a range to contracts.`,\n \"contributes\",\n key,\n );\n }\n const seen = new Map<string, number>();\n list.forEach((item, index) => {\n const id = key === \"cliCommands\" ? item[\"command\"] : item[\"id\"];\n if (typeof id !== \"string\") return;\n const first = seen.get(id);\n if (first !== undefined) {\n error(\n `\"${id}\" is contributed twice (also at contributes.${key}[${first}]).`,\n \"contributes\",\n key,\n index,\n );\n } else seen.set(id, index);\n if (key === \"cliCommands\") {\n const taken = coreCommandTaken(id.split(\" \"));\n if (taken !== undefined) {\n error(\n `\"mostra ${id}\" would collide with Mostra's own \"mostra ${taken.join(\" \")}\".`,\n \"contributes\",\n key,\n index,\n \"command\",\n );\n }\n }\n });\n }\n for (const name of view.contracts) {\n const key = PLUGIN_CONTRACTS[name].key;\n if ((view.contributes[key]?.length ?? 0) === 0) {\n warn(\n `The manifest declares the ${name} contract but contributes nothing to it.`,\n \"contracts\",\n name,\n );\n }\n }\n if (\n view.contributesObject &&\n contributions === 0 &&\n (view.contributes[\"packs\"]?.length ?? 0) === 0\n ) {\n error(\"The plugin contributes nothing: add an entry to contributes.\", \"contributes\");\n }\n // Licenses: the plugin's own, and each bundled one, must be expressions Mostra can read.\n if (typeof raw[\"license\"] === \"string\") {\n try {\n parseLicenseExpression(raw[\"license\"]);\n } catch (problem) {\n if (!(problem instanceof LicenseExpressionError)) throw problem;\n error(\n `${problem.message} Use an SPDX expression, or LicenseRef-<name> for another license.`,\n \"license\",\n );\n }\n }\n view.bundledLicenses.forEach((bundled, index) => {\n const license = bundled[\"license\"];\n if (typeof license === \"string\") {\n try {\n parseLicenseExpression(license);\n } catch (problem) {\n if (!(problem instanceof LicenseExpressionError)) throw problem;\n error(problem.message, \"bundledLicenses\", index, \"license\");\n }\n }\n const licenseClass = bundled[\"class\"];\n if (typeof licenseClass === \"string\" && typeof license === \"string\") {\n if (!isLicenseRef(license)) {\n error(\n \"class applies only to a LicenseRef-: Mostra classes SPDX licenses from the SPDX License List itself.\",\n \"bundledLicenses\",\n index,\n \"class\",\n );\n } else if (\n !ACKNOWLEDGED_CLASSES.has(licenseClass as LicenseClass) ||\n licenseClass === \"unknown\"\n ) {\n error(\n 'A LicenseRef- is never OSI-approved: its class is \"source-available\" or \"proprietary\".',\n \"bundledLicenses\",\n index,\n \"class\",\n );\n }\n }\n });\n view.effects.forEach((effect, index) => {\n if (typeof effect === \"string\" && !PLUGIN_EFFECTS.includes(effect)) {\n warn(\n `This Mostra release doesn't know the effect \"${effect}\" (it knows ${PLUGIN_EFFECTS.join(\", \")}); it is shown as declared.`,\n \"effects\",\n index,\n );\n }\n });\n view.platforms.forEach((platform, index) => {\n if (typeof platform === \"string\" && !PLUGIN_PLATFORMS.includes(platform)) {\n warn(\n `\"${platform}\" isn't a system Mostra runs on (${PLUGIN_PLATFORMS.join(\", \")}).`,\n \"platforms\",\n index,\n );\n }\n });\n if (!parsed.success) return { issues };\n const manifest = parsed.data;\n return issues.some((issue) => issue.severity === \"error\") ? { issues } : { manifest, issues };\n}\n\n/** What the rules beyond the schema read of a manifest, whatever its shape. */\ninterface LenientView {\n /** The contracts it declares, by a name Mostra implements (any range). */\n readonly contracts: ReadonlySet<ContractNameType>;\n readonly contributesObject: boolean;\n /** Each kind's list of objects. */\n readonly contributes: Readonly<Record<string, readonly Record<string, unknown>[]>>;\n readonly bundledLicenses: readonly Record<string, unknown>[];\n readonly effects: readonly unknown[];\n readonly platforms: readonly unknown[];\n}\n\nconst isObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nfunction lenientView(raw: Record<string, unknown>): LenientView {\n const contracts = new Set<ContractNameType>();\n if (isObject(raw[\"contracts\"])) {\n for (const key of Object.keys(raw[\"contracts\"])) {\n if ((CONTRACT_NAMES as readonly string[]).includes(key))\n contracts.add(key as ContractNameType);\n }\n }\n const contributes: Record<string, Record<string, unknown>[]> = {};\n if (isObject(raw[\"contributes\"])) {\n for (const [key, list] of Object.entries(raw[\"contributes\"])) {\n if (Array.isArray(list)) contributes[key] = list.filter(isObject);\n }\n }\n return {\n contracts,\n contributesObject: isObject(raw[\"contributes\"]),\n contributes,\n bundledLicenses: Array.isArray(raw[\"bundledLicenses\"])\n ? raw[\"bundledLicenses\"].filter(isObject)\n : [],\n effects: Array.isArray(raw[\"effects\"]) ? raw[\"effects\"] : [],\n platforms: Array.isArray(raw[\"platforms\"]) ? raw[\"platforms\"] : [],\n };\n}\n\n/** A Zod issue in the manifest's words. */\nfunction issueMessage(issue: z.core.$ZodIssue): string {\n if (issue.code === \"invalid_type\") {\n return issue.input === undefined\n ? `This field is required (${issue.expected}).`\n : `Expected ${issue.expected}.`;\n }\n if (issue.code === \"invalid_value\") {\n return `Expected one of ${issue.values.map((value) => JSON.stringify(value)).join(\", \")}.`;\n }\n if (issue.code === \"invalid_format\" && issue.format === \"regex\") {\n return `Expected ${issue.message.replace(/^Invalid string: must match pattern .*$/, \"the documented form\")}.`;\n }\n return issue.message;\n}\n\n/** Where a plugin with this manifest may be installed: every scope its contracts allow. */\nexport function manifestScopes(manifest: PluginManifest): readonly (\"artifact\" | \"home\")[] {\n const kinds = CONTRACT_NAMES.filter(\n (name) => (manifest.contributes[PLUGIN_CONTRACTS[name].key]?.length ?? 0) > 0,\n );\n const packs = (manifest.contributes.packs?.length ?? 0) > 0;\n const home = !packs && kinds.every((name) => PLUGIN_CONTRACTS[name].scopes.includes(\"home\"));\n return home ? [\"artifact\", \"home\"] : [\"artifact\"];\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA+BA,MAAa,2BAA2B;;AAGxC,MAAa,yBACX,EAAE,SAAgD;;AAGpD,MAAa,cACX;;AAGF,MAAa,kBAA0B;;AAGvC,MAAa,eAAuB;;AAGpC,MAAa,iBAAoC;CAC/C;CACA;CACA;CACA;CACA;AACF;;AAGA,MAAa,mBAAsC;CAAC;CAAU;CAAS;AAAO;AAgG9E,MAAM,cAAc,EAAE,OAAO,CAAC,CAAC,MAAM,cAAc,uCAAuC;AAC1F,MAAM,aAAa,EAAE,OAAO,CAAC,CAAC,MAAM,sBAAsB,0BAA0B;AAEpF,MAAM,oBAA4C,EAC/C,YAAY;CACX,IAAI,EAAE,OAAO,CAAC,CAAC,MAAM,iBAAiB,wDAAwD;CAC9F,OAAO;CACP,QAAQ,WAAW,cAAc;AACnC,CAAC,CAAC,CACD,SAAS,wBAAwB,EAAE,IAAI,cAAc,CAAC;AAEzD,MAAM,2BAA0D,EAC7D,YAAY;CACX,SAAS,EACN,OAAO,CAAC,CACR,MACC,wDACA,yDACF;CACF,OAAO;CACP,QAAQ,WAAW,cAAc;AAC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