@agentxm/registry-protocol 0.28.12 → 0.28.13

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 (131) hide show
  1. package/README.md +13 -5
  2. package/dist/src/unstable/publish/index.d.ts +1 -6
  3. package/dist/src/unstable/publish/index.js +1 -6
  4. package/dist/src/unstable/registry/discover-schema.d.ts +4 -4
  5. package/dist/src/unstable/registry/index.d.ts +1 -0
  6. package/dist/src/unstable/registry/index.js +1 -0
  7. package/dist/src/unstable/registry/version-selection.d.ts +22 -0
  8. package/dist/src/unstable/registry/version-selection.js +39 -0
  9. package/package.json +11 -192
  10. package/dist/src/unstable/content/agent-skills-standard.d.ts +0 -17
  11. package/dist/src/unstable/content/agent-skills-standard.js +0 -24
  12. package/dist/src/unstable/content/frontmatter.d.ts +0 -52
  13. package/dist/src/unstable/content/frontmatter.js +0 -115
  14. package/dist/src/unstable/content/index.d.ts +0 -11
  15. package/dist/src/unstable/content/index.js +0 -11
  16. package/dist/src/unstable/content/skill-content.d.ts +0 -43
  17. package/dist/src/unstable/content/skill-content.js +0 -184
  18. package/dist/src/unstable/content/skill-types.d.ts +0 -22
  19. package/dist/src/unstable/content/skill-types.js +0 -9
  20. package/dist/src/unstable/content/subagent-content.d.ts +0 -58
  21. package/dist/src/unstable/content/subagent-content.js +0 -101
  22. package/dist/src/unstable/knowledge/index.d.ts +0 -8
  23. package/dist/src/unstable/knowledge/index.js +0 -8
  24. package/dist/src/unstable/knowledge/knowledge-search.d.ts +0 -32
  25. package/dist/src/unstable/knowledge/knowledge-search.js +0 -147
  26. package/dist/src/unstable/knowledge/okf.d.ts +0 -86
  27. package/dist/src/unstable/knowledge/okf.js +0 -1090
  28. package/dist/src/unstable/lint/catalog/hook/decision-portability.d.ts +0 -4
  29. package/dist/src/unstable/lint/catalog/hook/decision-portability.js +0 -40
  30. package/dist/src/unstable/lint/catalog/hook/entrypoint-exists.d.ts +0 -4
  31. package/dist/src/unstable/lint/catalog/hook/entrypoint-exists.js +0 -39
  32. package/dist/src/unstable/lint/catalog/hook/envelope.d.ts +0 -6
  33. package/dist/src/unstable/lint/catalog/hook/envelope.js +0 -15
  34. package/dist/src/unstable/lint/catalog/hook/matcher-raw-portability.d.ts +0 -4
  35. package/dist/src/unstable/lint/catalog/hook/matcher-raw-portability.js +0 -51
  36. package/dist/src/unstable/lint/catalog/hook.d.ts +0 -4
  37. package/dist/src/unstable/lint/catalog/hook.js +0 -15
  38. package/dist/src/unstable/lint/catalog/knowledge/diagnostics.d.ts +0 -128
  39. package/dist/src/unstable/lint/catalog/knowledge/diagnostics.js +0 -78
  40. package/dist/src/unstable/lint/catalog/knowledge/envelope.d.ts +0 -6
  41. package/dist/src/unstable/lint/catalog/knowledge/envelope.js +0 -15
  42. package/dist/src/unstable/lint/catalog/knowledge.d.ts +0 -5
  43. package/dist/src/unstable/lint/catalog/knowledge.js +0 -9
  44. package/dist/src/unstable/lint/catalog/mcp-server/envelope.d.ts +0 -6
  45. package/dist/src/unstable/lint/catalog/mcp-server/envelope.js +0 -15
  46. package/dist/src/unstable/lint/catalog/mcp-server.d.ts +0 -4
  47. package/dist/src/unstable/lint/catalog/mcp-server.js +0 -4
  48. package/dist/src/unstable/lint/catalog/pack/manifest-keys-recognized.d.ts +0 -28
  49. package/dist/src/unstable/lint/catalog/pack/manifest-keys-recognized.js +0 -38
  50. package/dist/src/unstable/lint/catalog/pack/manifest-present.d.ts +0 -17
  51. package/dist/src/unstable/lint/catalog/pack/manifest-present.js +0 -24
  52. package/dist/src/unstable/lint/catalog/pack/manifest-schema-valid.d.ts +0 -25
  53. package/dist/src/unstable/lint/catalog/pack/manifest-schema-valid.js +0 -33
  54. package/dist/src/unstable/lint/catalog/pack-accessor/contexts.d.ts +0 -51
  55. package/dist/src/unstable/lint/catalog/pack-accessor/contexts.js +0 -45
  56. package/dist/src/unstable/lint/catalog/pack-accessor/vft.d.ts +0 -60
  57. package/dist/src/unstable/lint/catalog/pack-accessor/vft.js +0 -85
  58. package/dist/src/unstable/lint/catalog/pack.d.ts +0 -31
  59. package/dist/src/unstable/lint/catalog/pack.js +0 -36
  60. package/dist/src/unstable/lint/catalog/rule/envelope.d.ts +0 -6
  61. package/dist/src/unstable/lint/catalog/rule/envelope.js +0 -15
  62. package/dist/src/unstable/lint/catalog/rule.d.ts +0 -4
  63. package/dist/src/unstable/lint/catalog/rule.js +0 -4
  64. package/dist/src/unstable/lint/catalog/shared/envelope-rules.d.ts +0 -88
  65. package/dist/src/unstable/lint/catalog/shared/envelope-rules.js +0 -84
  66. package/dist/src/unstable/lint/catalog/shared/manifest-json.d.ts +0 -18
  67. package/dist/src/unstable/lint/catalog/shared/manifest-json.js +0 -28
  68. package/dist/src/unstable/lint/catalog/shared/manifest-present.d.ts +0 -25
  69. package/dist/src/unstable/lint/catalog/shared/manifest-present.js +0 -37
  70. package/dist/src/unstable/lint/catalog/shared/recommended-packs-rules.d.ts +0 -70
  71. package/dist/src/unstable/lint/catalog/shared/recommended-packs-rules.js +0 -139
  72. package/dist/src/unstable/lint/catalog/shared/schema-rule.d.ts +0 -57
  73. package/dist/src/unstable/lint/catalog/shared/schema-rule.js +0 -102
  74. package/dist/src/unstable/lint/catalog/skill/frontmatter-parseable.d.ts +0 -31
  75. package/dist/src/unstable/lint/catalog/skill/frontmatter-parseable.js +0 -148
  76. package/dist/src/unstable/lint/catalog/skill/frontmatter-standard-valid.d.ts +0 -13
  77. package/dist/src/unstable/lint/catalog/skill/frontmatter-standard-valid.js +0 -61
  78. package/dist/src/unstable/lint/catalog/skill/manifest-keys-recognized.d.ts +0 -26
  79. package/dist/src/unstable/lint/catalog/skill/manifest-keys-recognized.js +0 -41
  80. package/dist/src/unstable/lint/catalog/skill/manifest-present.d.ts +0 -23
  81. package/dist/src/unstable/lint/catalog/skill/manifest-present.js +0 -32
  82. package/dist/src/unstable/lint/catalog/skill/manifest-schema-valid.d.ts +0 -21
  83. package/dist/src/unstable/lint/catalog/skill/manifest-schema-valid.js +0 -36
  84. package/dist/src/unstable/lint/catalog/skill/recommended-packs-valid.d.ts +0 -8
  85. package/dist/src/unstable/lint/catalog/skill/recommended-packs-valid.js +0 -12
  86. package/dist/src/unstable/lint/catalog/skill/skill-md-present.d.ts +0 -17
  87. package/dist/src/unstable/lint/catalog/skill/skill-md-present.js +0 -37
  88. package/dist/src/unstable/lint/catalog/skill/standalone-declaration-valid.d.ts +0 -8
  89. package/dist/src/unstable/lint/catalog/skill/standalone-declaration-valid.js +0 -12
  90. package/dist/src/unstable/lint/catalog/skill-accessor/contexts.d.ts +0 -61
  91. package/dist/src/unstable/lint/catalog/skill-accessor/contexts.js +0 -55
  92. package/dist/src/unstable/lint/catalog/skill-accessor/vft.d.ts +0 -77
  93. package/dist/src/unstable/lint/catalog/skill-accessor/vft.js +0 -135
  94. package/dist/src/unstable/lint/catalog/skill.d.ts +0 -38
  95. package/dist/src/unstable/lint/catalog/skill.js +0 -53
  96. package/dist/src/unstable/lint/catalog/subagent/envelope.d.ts +0 -6
  97. package/dist/src/unstable/lint/catalog/subagent/envelope.js +0 -15
  98. package/dist/src/unstable/lint/catalog/subagent.d.ts +0 -4
  99. package/dist/src/unstable/lint/catalog/subagent.js +0 -4
  100. package/dist/src/unstable/lint/catalog-metadata.d.ts +0 -125
  101. package/dist/src/unstable/lint/catalog-metadata.js +0 -642
  102. package/dist/src/unstable/lint/compose-path.d.ts +0 -28
  103. package/dist/src/unstable/lint/compose-path.js +0 -64
  104. package/dist/src/unstable/lint/config.d.ts +0 -77
  105. package/dist/src/unstable/lint/config.js +0 -99
  106. package/dist/src/unstable/lint/context.d.ts +0 -239
  107. package/dist/src/unstable/lint/context.js +0 -17
  108. package/dist/src/unstable/lint/describe-document.d.ts +0 -31
  109. package/dist/src/unstable/lint/describe-document.js +0 -50
  110. package/dist/src/unstable/lint/evaluate.d.ts +0 -47
  111. package/dist/src/unstable/lint/evaluate.js +0 -73
  112. package/dist/src/unstable/lint/issues-to-findings.d.ts +0 -35
  113. package/dist/src/unstable/lint/issues-to-findings.js +0 -149
  114. package/dist/src/unstable/lint/publish.d.ts +0 -49
  115. package/dist/src/unstable/lint/publish.js +0 -86
  116. package/dist/src/unstable/lint/rule.d.ts +0 -97
  117. package/dist/src/unstable/lint/rule.js +0 -17
  118. package/dist/src/unstable/publish/archive-guardrails.d.ts +0 -39
  119. package/dist/src/unstable/publish/archive-guardrails.js +0 -250
  120. package/dist/src/unstable/publish/filtered-package-validation.d.ts +0 -24
  121. package/dist/src/unstable/publish/filtered-package-validation.js +0 -117
  122. package/dist/src/unstable/publish/ingest-limits.d.ts +0 -25
  123. package/dist/src/unstable/publish/ingest-limits.js +0 -41
  124. package/dist/src/unstable/publish/input-normalization.d.ts +0 -40
  125. package/dist/src/unstable/publish/input-normalization.js +0 -125
  126. package/dist/src/unstable/publish/manifest-policy.d.ts +0 -611
  127. package/dist/src/unstable/publish/manifest-policy.js +0 -196
  128. package/dist/src/unstable/publish/test-zip-helpers.d.ts +0 -13
  129. package/dist/src/unstable/publish/test-zip-helpers.js +0 -117
  130. package/dist/src/unstable/registry/release-age-policy.d.ts +0 -57
  131. package/dist/src/unstable/registry/release-age-policy.js +0 -117
package/README.md CHANGED
@@ -1,10 +1,18 @@
1
1
  # @agentxm/registry-protocol
2
2
 
3
- The AgentXM Registry wire contracts and the contract-level publication
4
- validation rules that the AXM client and the Registry implementation must
5
- interpret identically: request and response schemas, publication and
6
- deprecation views, suggested-action error vocabulary, extension content
7
- parsing, and publish lint rules.
3
+ The AgentXM Registry wire contracts that the AXM client and the Registry
4
+ implementation must interpret identically: extension index and version entry
5
+ schemas (`./unstable/registry/schema`), discovery responses
6
+ (`./unstable/registry/discover-schema`), publication-set preview and
7
+ validation (`./unstable/registry/publication-set`), publish visibility
8
+ (`./unstable/publish`), publish authorization
9
+ (`./unstable/publish-authorization`), and the shared suggested-action and
10
+ human-handoff error vocabulary (`./unstable/suggested-action`,
11
+ `./unstable/human-handoff`).
12
+
13
+ Content parsing, Knowledge inspection, the lint catalog, and archive and
14
+ manifest validation live in `@agentxm/extension-content`; version selection
15
+ and release-age policy live in `@agentxm/extension-resolution`.
8
16
 
9
17
  Every export lives under an explicit `./unstable/*` subpath: the surface is
10
18
  unsupported and may change in any release. Ordinary users should use the
@@ -1,12 +1,7 @@
1
1
  /**
2
- * Area barrel for the package public surface.
2
+ * Publish visibility wire contract.
3
3
  *
4
4
  * @experimental This API is unstable and may change without notice.
5
5
  */
6
- export { ArchiveGuardrailError, type ArchiveGuardrailLimits, type ZipEntry, checkForbiddenSourceEntries, validateArchive, } from "./archive-guardrails.js";
7
- export { FilteredPackageError, type ValidateFilteredPackageArgs, validateFilteredPackage, } from "./filtered-package-validation.js";
8
- export { IngestLimitError, IngestUnsupportedContentTypeError, REGISTRY_PUBLISH_MAX_ARCHIVE_BYTES, REGISTRY_PUBLISH_MAX_REQUEST_BYTES, enforceArchiveContentType, enforceArchiveSizeLimit, enforceRequestSizeLimit, } from "./ingest-limits.js";
9
- export { type NormalizePublishInputArgs, type PublishArchiveInput, type PublishInput, normalizePublishInput, } from "./input-normalization.js";
10
- export { type DeclaredPublishIdentity, ManifestError, type ManifestIdentity, ManifestIdentitySchema, type ResolvedManifest, manifestFilenameForType, validateDeclaredManifestAlignment, } from "./manifest-policy.js";
11
6
  export { type PublishVisibility, PublishVisibilitySchema, type ResolveVisibilityIntentArgs, type VisibilityActual, VisibilityActualSchema, type VisibilityComparison, VisibilityComparisonSchema, type VisibilityEvaluation, type VisibilityEvaluationResult, VisibilityEvaluationResultSchema, VisibilityEvaluationSchema, type VisibilityEvaluationUnavailable, VisibilityEvaluationUnavailableSchema, type VisibilityFinding, type VisibilityFindingCode, VisibilityFindingCodeSchema, VisibilityFindingSchema, type VisibilityFingerprint, VisibilityFingerprintSchema, type VisibilityIntent, VisibilityIntentSchema, type VisibilityIntentSource, type VisibilityMutationAuthority, VisibilityMutationAuthoritySchema, type VisibilityMutationRequest, VisibilityMutationRequestSchema, type VisibilityMutationResult, VisibilityMutationResultSchema, type VisibilityRevision, VisibilityRevisionSchema, resolveVisibilityIntent, } from "./visibility.js";
12
7
  //# sourceMappingURL=index.d.ts.map
@@ -1,12 +1,7 @@
1
1
  /**
2
- * Area barrel for the package public surface.
2
+ * Publish visibility wire contract.
3
3
  *
4
4
  * @experimental This API is unstable and may change without notice.
5
5
  */
6
- export { ArchiveGuardrailError, checkForbiddenSourceEntries, validateArchive, } from "./archive-guardrails.js";
7
- export { FilteredPackageError, validateFilteredPackage, } from "./filtered-package-validation.js";
8
- export { IngestLimitError, IngestUnsupportedContentTypeError, REGISTRY_PUBLISH_MAX_ARCHIVE_BYTES, REGISTRY_PUBLISH_MAX_REQUEST_BYTES, enforceArchiveContentType, enforceArchiveSizeLimit, enforceRequestSizeLimit, } from "./ingest-limits.js";
9
- export { normalizePublishInput, } from "./input-normalization.js";
10
- export { ManifestError, ManifestIdentitySchema, manifestFilenameForType, validateDeclaredManifestAlignment, } from "./manifest-policy.js";
11
6
  export { PublishVisibilitySchema, VisibilityActualSchema, VisibilityComparisonSchema, VisibilityEvaluationResultSchema, VisibilityEvaluationSchema, VisibilityEvaluationUnavailableSchema, VisibilityFindingCodeSchema, VisibilityFindingSchema, VisibilityFingerprintSchema, VisibilityIntentSchema, VisibilityMutationAuthoritySchema, VisibilityMutationRequestSchema, VisibilityMutationResultSchema, VisibilityRevisionSchema, resolveVisibilityIntent, } from "./visibility.js";
12
7
  //# sourceMappingURL=index.js.map
@@ -6,7 +6,7 @@
6
6
  import * as Schema from "effect/Schema";
7
7
  export declare const DiscoveryResolvedExtensionSchema: Schema.Struct<{
8
8
  readonly owner: Schema.Union<readonly [Schema.brand<Schema.String, "Handle">, Schema.brand<Schema.String, "Slug">]>;
9
- readonly type: Schema.Literals<readonly ("skill" | "mcp-server" | "subagent" | "rule" | "hook" | "knowledge" | "pack" | "packs" | "rules" | "skills" | "mcps" | "subagents" | "hooks")[]>;
9
+ readonly type: Schema.Literals<readonly ("skill" | "mcp-server" | "subagent" | "rule" | "hook" | "knowledge" | "pack" | "packs" | "skills" | "mcps" | "subagents" | "rules" | "hooks")[]>;
10
10
  readonly name: Schema.brand<Schema.NonEmptyString, "ExtensionName">;
11
11
  readonly installVersion: Schema.brand<Schema.String, "Version">;
12
12
  }>;
@@ -16,7 +16,7 @@ export declare const DiscoveryExtensionResultSchema: Schema.Struct<{
16
16
  readonly resolved: Schema.Boolean;
17
17
  readonly extension: Schema.optional<Schema.Struct<{
18
18
  readonly owner: Schema.Union<readonly [Schema.brand<Schema.String, "Handle">, Schema.brand<Schema.String, "Slug">]>;
19
- readonly type: Schema.Literals<readonly ("skill" | "mcp-server" | "subagent" | "rule" | "hook" | "knowledge" | "pack" | "packs" | "rules" | "skills" | "mcps" | "subagents" | "hooks")[]>;
19
+ readonly type: Schema.Literals<readonly ("skill" | "mcp-server" | "subagent" | "rule" | "hook" | "knowledge" | "pack" | "packs" | "skills" | "mcps" | "subagents" | "rules" | "hooks")[]>;
20
20
  readonly name: Schema.brand<Schema.NonEmptyString, "ExtensionName">;
21
21
  readonly installVersion: Schema.brand<Schema.String, "Version">;
22
22
  }>>;
@@ -34,7 +34,7 @@ export declare const DiscoveryPackageResultSchema: Schema.Struct<{
34
34
  readonly resolved: Schema.Boolean;
35
35
  readonly extension: Schema.optional<Schema.Struct<{
36
36
  readonly owner: Schema.Union<readonly [Schema.brand<Schema.String, "Handle">, Schema.brand<Schema.String, "Slug">]>;
37
- readonly type: Schema.Literals<readonly ("skill" | "mcp-server" | "subagent" | "rule" | "hook" | "knowledge" | "pack" | "packs" | "rules" | "skills" | "mcps" | "subagents" | "hooks")[]>;
37
+ readonly type: Schema.Literals<readonly ("skill" | "mcp-server" | "subagent" | "rule" | "hook" | "knowledge" | "pack" | "packs" | "skills" | "mcps" | "subagents" | "rules" | "hooks")[]>;
38
38
  readonly name: Schema.brand<Schema.NonEmptyString, "ExtensionName">;
39
39
  readonly installVersion: Schema.brand<Schema.String, "Version">;
40
40
  }>>;
@@ -54,7 +54,7 @@ export declare const DiscoverPackagesResponseSchema: Schema.Struct<{
54
54
  readonly resolved: Schema.Boolean;
55
55
  readonly extension: Schema.optional<Schema.Struct<{
56
56
  readonly owner: Schema.Union<readonly [Schema.brand<Schema.String, "Handle">, Schema.brand<Schema.String, "Slug">]>;
57
- readonly type: Schema.Literals<readonly ("skill" | "mcp-server" | "subagent" | "rule" | "hook" | "knowledge" | "pack" | "packs" | "rules" | "skills" | "mcps" | "subagents" | "hooks")[]>;
57
+ readonly type: Schema.Literals<readonly ("skill" | "mcp-server" | "subagent" | "rule" | "hook" | "knowledge" | "pack" | "packs" | "skills" | "mcps" | "subagents" | "rules" | "hooks")[]>;
58
58
  readonly name: Schema.brand<Schema.NonEmptyString, "ExtensionName">;
59
59
  readonly installVersion: Schema.brand<Schema.String, "Version">;
60
60
  }>>;
@@ -6,4 +6,5 @@
6
6
  export { type DiscoverPackagesResponse, DiscoverPackagesResponseSchema, type DiscoveryExtensionResult, DiscoveryExtensionResultSchema, type DiscoveryPackageResult, DiscoveryPackageResultSchema, type DiscoveryResolvedExtension, DiscoveryResolvedExtensionSchema, } from "./discover-schema.js";
7
7
  export { MAX_PUBLICATION_SET_CANDIDATES, PUBLICATION_SET_CONTRACT, type PackDependencyDescriptor, type PackDependencyFinding, PackDependencyFindingSchema, type PreviewPublicationSetRequest, PreviewPublicationSetRequestSchema, type PreviewPublicationSetResponse, PreviewPublicationSetResponseSchema, type ProspectivePackDependencyState, type ProspectivePublicationCandidate, type PublicationCandidateResult, type PublicationDependencySnapshot, type PublicationDependencyVersionSnapshot, type PublicationDescriptor, type PublicationPackResult, type PublicationTarget, type PublicationVisibilityInput, PublicationVisibilityInputSchema, type Sha256Hex, Sha256HexSchema, archiveSha256Hex, comparePublicationTargets, evaluateProspectivePackDependencies, evaluateProspectivePackDependencyState, normalizePublicationDescriptor, normalizePublicationSet, publicationDescriptorDigest, publicationSetDigest, publicationTargetKey, validatePublicationDescriptors, validatePublicationSetResponse, } from "./publication-set.js";
8
8
  export { type DeprecationManagementView, DeprecationManagementViewSchema, type DeprecationReplacementIntent, DeprecationReplacementIntentSchema, DeprecationRevisionSchema, type DeprecationTransition, DeprecationTransitionSchema, type ExtensionIndex, ExtensionIndexSchema, type VersionEntry, VersionEntrySchema, packagesToPackageUrlParts, } from "./schema.js";
9
+ export { resolveVersionEntry, selectVersion } from "./version-selection.js";
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -6,4 +6,5 @@
6
6
  export { DiscoverPackagesResponseSchema, DiscoveryExtensionResultSchema, DiscoveryPackageResultSchema, DiscoveryResolvedExtensionSchema, } from "./discover-schema.js";
7
7
  export { MAX_PUBLICATION_SET_CANDIDATES, PUBLICATION_SET_CONTRACT, PackDependencyFindingSchema, PreviewPublicationSetRequestSchema, PreviewPublicationSetResponseSchema, PublicationVisibilityInputSchema, Sha256HexSchema, archiveSha256Hex, comparePublicationTargets, evaluateProspectivePackDependencies, evaluateProspectivePackDependencyState, normalizePublicationDescriptor, normalizePublicationSet, publicationDescriptorDigest, publicationSetDigest, publicationTargetKey, validatePublicationDescriptors, validatePublicationSetResponse, } from "./publication-set.js";
8
8
  export { DeprecationManagementViewSchema, DeprecationReplacementIntentSchema, DeprecationRevisionSchema, DeprecationTransitionSchema, ExtensionIndexSchema, VersionEntrySchema, packagesToPackageUrlParts, } from "./schema.js";
9
+ export { resolveVersionEntry, selectVersion } from "./version-selection.js";
9
10
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Which entry a Registry index designates for a version request.
3
+ *
4
+ * The rule is part of the Registry contract: a yanked version is selectable
5
+ * only when requested exactly, and a range resolves to the highest non-yanked
6
+ * version it admits.
7
+ *
8
+ * @experimental This API is unstable and may change without notice.
9
+ * @packageDocumentation
10
+ */
11
+ import * as Option from "effect/Option";
12
+ import type { VersionEntry } from "./schema.js";
13
+ /**
14
+ * Select the highest non-yanked version, independent of index order.
15
+ */
16
+ export declare const selectVersion: (versions: ReadonlyArray<VersionEntry>) => Option.Option<VersionEntry>;
17
+ /**
18
+ * Resolve an optional exact version or range against an index: an exact
19
+ * version matches even when yanked; a range excludes yanked versions.
20
+ */
21
+ export declare const resolveVersionEntry: (versions: ReadonlyArray<VersionEntry>, versionRange: Option.Option<string>) => Option.Option<VersionEntry>;
22
+ //# sourceMappingURL=version-selection.d.ts.map
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Which entry a Registry index designates for a version request.
3
+ *
4
+ * The rule is part of the Registry contract: a yanked version is selectable
5
+ * only when requested exactly, and a range resolves to the highest non-yanked
6
+ * version it admits.
7
+ *
8
+ * @experimental This API is unstable and may change without notice.
9
+ * @packageDocumentation
10
+ */
11
+ import * as Option from "effect/Option";
12
+ import * as semver from "semver";
13
+ import { resolveVersionInRange } from "@agentxm/extension-model/unstable/version-constraints";
14
+ /**
15
+ * Select the highest non-yanked version, independent of index order.
16
+ */
17
+ export const selectVersion = (versions) => {
18
+ const availableVersions = versions.filter((entry) => entry.yankedAt === undefined);
19
+ return resolveVersionInRange(availableVersions, Option.none());
20
+ };
21
+ /**
22
+ * Resolve an optional exact version or range against an index: an exact
23
+ * version matches even when yanked; a range excludes yanked versions.
24
+ */
25
+ export const resolveVersionEntry = (versions, versionRange) => {
26
+ if (Option.isNone(versionRange)) {
27
+ return selectVersion(versions);
28
+ }
29
+ if (semver.valid(versionRange.value) === versionRange.value) {
30
+ return Option.fromUndefinedOr(versions.find((candidate) => candidate.version === versionRange.value));
31
+ }
32
+ const availableVersions = versions.filter((entry) => entry.yankedAt === undefined);
33
+ const resolved = resolveVersionInRange(availableVersions, versionRange);
34
+ if (Option.isNone(resolved)) {
35
+ return Option.none();
36
+ }
37
+ return Option.fromUndefinedOr(availableVersions.find((candidate) => candidate.version === resolved.value.version));
38
+ };
39
+ //# sourceMappingURL=version-selection.js.map
package/package.json CHANGED
@@ -4,12 +4,11 @@
4
4
  "url": "https://github.com/agentxm/axm/issues"
5
5
  },
6
6
  "dependencies": {
7
- "@agentxm/extension-model": "^0.28.12",
7
+ "@agentxm/extension-model": "^0.28.13",
8
8
  "effect": "4.0.0-rc.112",
9
- "semver": "^7.8.5",
10
- "yaml": "^2.9.0"
9
+ "semver": "^7.8.5"
11
10
  },
12
- "description": "AgentXM Registry wire contracts and shared publication validation rules. Unstable and unsupported — use the axm.sh CLI.",
11
+ "description": "AgentXM Registry wire contracts: index, discovery, publication-set, visibility, authorization, and suggested-action schemas. Unstable and unsupported — use the axm.sh CLI.",
13
12
  "devDependencies": {
14
13
  "@effect/platform-node": "4.0.0-rc.112",
15
14
  "@effect/vitest": "4.0.0-rc.112",
@@ -22,161 +21,11 @@
22
21
  "node": ">=22.19.0"
23
22
  },
24
23
  "exports": {
25
- "./unstable/content": {
26
- "axm-source": "./src/unstable/content/index.ts",
27
- "default": "./dist/src/unstable/content/index.js",
28
- "types": "./dist/src/unstable/content/index.d.ts"
29
- },
30
- "./unstable/content/agent-skills-standard": {
31
- "axm-source": "./src/unstable/content/agent-skills-standard.ts",
32
- "default": "./dist/src/unstable/content/agent-skills-standard.js",
33
- "types": "./dist/src/unstable/content/agent-skills-standard.d.ts"
34
- },
35
- "./unstable/content/frontmatter": {
36
- "axm-source": "./src/unstable/content/frontmatter.ts",
37
- "default": "./dist/src/unstable/content/frontmatter.js",
38
- "types": "./dist/src/unstable/content/frontmatter.d.ts"
39
- },
40
- "./unstable/content/skill-content": {
41
- "axm-source": "./src/unstable/content/skill-content.ts",
42
- "default": "./dist/src/unstable/content/skill-content.js",
43
- "types": "./dist/src/unstable/content/skill-content.d.ts"
44
- },
45
- "./unstable/content/skill-types": {
46
- "axm-source": "./src/unstable/content/skill-types.ts",
47
- "default": "./dist/src/unstable/content/skill-types.js",
48
- "types": "./dist/src/unstable/content/skill-types.d.ts"
49
- },
50
- "./unstable/content/subagent-content": {
51
- "axm-source": "./src/unstable/content/subagent-content.ts",
52
- "default": "./dist/src/unstable/content/subagent-content.js",
53
- "types": "./dist/src/unstable/content/subagent-content.d.ts"
54
- },
55
24
  "./unstable/human-handoff": {
56
25
  "axm-source": "./src/unstable/human-handoff.ts",
57
26
  "default": "./dist/src/unstable/human-handoff.js",
58
27
  "types": "./dist/src/unstable/human-handoff.d.ts"
59
28
  },
60
- "./unstable/knowledge": {
61
- "axm-source": "./src/unstable/knowledge/index.ts",
62
- "default": "./dist/src/unstable/knowledge/index.js",
63
- "types": "./dist/src/unstable/knowledge/index.d.ts"
64
- },
65
- "./unstable/knowledge/knowledge-search": {
66
- "axm-source": "./src/unstable/knowledge/knowledge-search.ts",
67
- "default": "./dist/src/unstable/knowledge/knowledge-search.js",
68
- "types": "./dist/src/unstable/knowledge/knowledge-search.d.ts"
69
- },
70
- "./unstable/knowledge/okf": {
71
- "axm-source": "./src/unstable/knowledge/okf.ts",
72
- "default": "./dist/src/unstable/knowledge/okf.js",
73
- "types": "./dist/src/unstable/knowledge/okf.d.ts"
74
- },
75
- "./unstable/lint/catalog-metadata": {
76
- "axm-source": "./src/unstable/lint/catalog-metadata.ts",
77
- "default": "./dist/src/unstable/lint/catalog-metadata.js",
78
- "types": "./dist/src/unstable/lint/catalog-metadata.d.ts"
79
- },
80
- "./unstable/lint/catalog/hook": {
81
- "axm-source": "./src/unstable/lint/catalog/hook.ts",
82
- "default": "./dist/src/unstable/lint/catalog/hook.js",
83
- "types": "./dist/src/unstable/lint/catalog/hook.d.ts"
84
- },
85
- "./unstable/lint/catalog/knowledge": {
86
- "axm-source": "./src/unstable/lint/catalog/knowledge.ts",
87
- "default": "./dist/src/unstable/lint/catalog/knowledge.js",
88
- "types": "./dist/src/unstable/lint/catalog/knowledge.d.ts"
89
- },
90
- "./unstable/lint/catalog/knowledge/diagnostics": {
91
- "axm-source": "./src/unstable/lint/catalog/knowledge/diagnostics.ts",
92
- "default": "./dist/src/unstable/lint/catalog/knowledge/diagnostics.js",
93
- "types": "./dist/src/unstable/lint/catalog/knowledge/diagnostics.d.ts"
94
- },
95
- "./unstable/lint/catalog/mcp-server": {
96
- "axm-source": "./src/unstable/lint/catalog/mcp-server.ts",
97
- "default": "./dist/src/unstable/lint/catalog/mcp-server.js",
98
- "types": "./dist/src/unstable/lint/catalog/mcp-server.d.ts"
99
- },
100
- "./unstable/lint/catalog/pack": {
101
- "axm-source": "./src/unstable/lint/catalog/pack.ts",
102
- "default": "./dist/src/unstable/lint/catalog/pack.js",
103
- "types": "./dist/src/unstable/lint/catalog/pack.d.ts"
104
- },
105
- "./unstable/lint/catalog/pack-accessor/contexts": {
106
- "axm-source": "./src/unstable/lint/catalog/pack-accessor/contexts.ts",
107
- "default": "./dist/src/unstable/lint/catalog/pack-accessor/contexts.js",
108
- "types": "./dist/src/unstable/lint/catalog/pack-accessor/contexts.d.ts"
109
- },
110
- "./unstable/lint/catalog/pack-accessor/vft": {
111
- "axm-source": "./src/unstable/lint/catalog/pack-accessor/vft.ts",
112
- "default": "./dist/src/unstable/lint/catalog/pack-accessor/vft.js",
113
- "types": "./dist/src/unstable/lint/catalog/pack-accessor/vft.d.ts"
114
- },
115
- "./unstable/lint/catalog/rule": {
116
- "axm-source": "./src/unstable/lint/catalog/rule.ts",
117
- "default": "./dist/src/unstable/lint/catalog/rule.js",
118
- "types": "./dist/src/unstable/lint/catalog/rule.d.ts"
119
- },
120
- "./unstable/lint/catalog/shared/manifest-json": {
121
- "axm-source": "./src/unstable/lint/catalog/shared/manifest-json.ts",
122
- "default": "./dist/src/unstable/lint/catalog/shared/manifest-json.js",
123
- "types": "./dist/src/unstable/lint/catalog/shared/manifest-json.d.ts"
124
- },
125
- "./unstable/lint/catalog/skill": {
126
- "axm-source": "./src/unstable/lint/catalog/skill.ts",
127
- "default": "./dist/src/unstable/lint/catalog/skill.js",
128
- "types": "./dist/src/unstable/lint/catalog/skill.d.ts"
129
- },
130
- "./unstable/lint/catalog/skill-accessor/contexts": {
131
- "axm-source": "./src/unstable/lint/catalog/skill-accessor/contexts.ts",
132
- "default": "./dist/src/unstable/lint/catalog/skill-accessor/contexts.js",
133
- "types": "./dist/src/unstable/lint/catalog/skill-accessor/contexts.d.ts"
134
- },
135
- "./unstable/lint/catalog/skill-accessor/vft": {
136
- "axm-source": "./src/unstable/lint/catalog/skill-accessor/vft.ts",
137
- "default": "./dist/src/unstable/lint/catalog/skill-accessor/vft.js",
138
- "types": "./dist/src/unstable/lint/catalog/skill-accessor/vft.d.ts"
139
- },
140
- "./unstable/lint/catalog/subagent": {
141
- "axm-source": "./src/unstable/lint/catalog/subagent.ts",
142
- "default": "./dist/src/unstable/lint/catalog/subagent.js",
143
- "types": "./dist/src/unstable/lint/catalog/subagent.d.ts"
144
- },
145
- "./unstable/lint/compose-path": {
146
- "axm-source": "./src/unstable/lint/compose-path.ts",
147
- "default": "./dist/src/unstable/lint/compose-path.js",
148
- "types": "./dist/src/unstable/lint/compose-path.d.ts"
149
- },
150
- "./unstable/lint/config": {
151
- "axm-source": "./src/unstable/lint/config.ts",
152
- "default": "./dist/src/unstable/lint/config.js",
153
- "types": "./dist/src/unstable/lint/config.d.ts"
154
- },
155
- "./unstable/lint/context": {
156
- "axm-source": "./src/unstable/lint/context.ts",
157
- "default": "./dist/src/unstable/lint/context.js",
158
- "types": "./dist/src/unstable/lint/context.d.ts"
159
- },
160
- "./unstable/lint/evaluate": {
161
- "axm-source": "./src/unstable/lint/evaluate.ts",
162
- "default": "./dist/src/unstable/lint/evaluate.js",
163
- "types": "./dist/src/unstable/lint/evaluate.d.ts"
164
- },
165
- "./unstable/lint/issues-to-findings": {
166
- "axm-source": "./src/unstable/lint/issues-to-findings.ts",
167
- "default": "./dist/src/unstable/lint/issues-to-findings.js",
168
- "types": "./dist/src/unstable/lint/issues-to-findings.d.ts"
169
- },
170
- "./unstable/lint/publish": {
171
- "axm-source": "./src/unstable/lint/publish.ts",
172
- "default": "./dist/src/unstable/lint/publish.js",
173
- "types": "./dist/src/unstable/lint/publish.d.ts"
174
- },
175
- "./unstable/lint/rule": {
176
- "axm-source": "./src/unstable/lint/rule.ts",
177
- "default": "./dist/src/unstable/lint/rule.js",
178
- "types": "./dist/src/unstable/lint/rule.d.ts"
179
- },
180
29
  "./unstable/publish": {
181
30
  "axm-source": "./src/unstable/publish/index.ts",
182
31
  "default": "./dist/src/unstable/publish/index.js",
@@ -187,36 +36,6 @@
187
36
  "default": "./dist/src/unstable/publish-authorization.js",
188
37
  "types": "./dist/src/unstable/publish-authorization.d.ts"
189
38
  },
190
- "./unstable/publish/archive-guardrails": {
191
- "axm-source": "./src/unstable/publish/archive-guardrails.ts",
192
- "default": "./dist/src/unstable/publish/archive-guardrails.js",
193
- "types": "./dist/src/unstable/publish/archive-guardrails.d.ts"
194
- },
195
- "./unstable/publish/filtered-package-validation": {
196
- "axm-source": "./src/unstable/publish/filtered-package-validation.ts",
197
- "default": "./dist/src/unstable/publish/filtered-package-validation.js",
198
- "types": "./dist/src/unstable/publish/filtered-package-validation.d.ts"
199
- },
200
- "./unstable/publish/ingest-limits": {
201
- "axm-source": "./src/unstable/publish/ingest-limits.ts",
202
- "default": "./dist/src/unstable/publish/ingest-limits.js",
203
- "types": "./dist/src/unstable/publish/ingest-limits.d.ts"
204
- },
205
- "./unstable/publish/input-normalization": {
206
- "axm-source": "./src/unstable/publish/input-normalization.ts",
207
- "default": "./dist/src/unstable/publish/input-normalization.js",
208
- "types": "./dist/src/unstable/publish/input-normalization.d.ts"
209
- },
210
- "./unstable/publish/manifest-policy": {
211
- "axm-source": "./src/unstable/publish/manifest-policy.ts",
212
- "default": "./dist/src/unstable/publish/manifest-policy.js",
213
- "types": "./dist/src/unstable/publish/manifest-policy.d.ts"
214
- },
215
- "./unstable/publish/visibility": {
216
- "axm-source": "./src/unstable/publish/visibility.ts",
217
- "default": "./dist/src/unstable/publish/visibility.js",
218
- "types": "./dist/src/unstable/publish/visibility.d.ts"
219
- },
220
39
  "./unstable/registry": {
221
40
  "axm-source": "./src/unstable/registry/index.ts",
222
41
  "default": "./dist/src/unstable/registry/index.js",
@@ -232,16 +51,16 @@
232
51
  "default": "./dist/src/unstable/registry/publication-set.js",
233
52
  "types": "./dist/src/unstable/registry/publication-set.d.ts"
234
53
  },
235
- "./unstable/registry/release-age-policy": {
236
- "axm-source": "./src/unstable/registry/release-age-policy.ts",
237
- "default": "./dist/src/unstable/registry/release-age-policy.js",
238
- "types": "./dist/src/unstable/registry/release-age-policy.d.ts"
239
- },
240
54
  "./unstable/registry/schema": {
241
55
  "axm-source": "./src/unstable/registry/schema.ts",
242
56
  "default": "./dist/src/unstable/registry/schema.js",
243
57
  "types": "./dist/src/unstable/registry/schema.d.ts"
244
58
  },
59
+ "./unstable/registry/version-selection": {
60
+ "axm-source": "./src/unstable/registry/version-selection.ts",
61
+ "default": "./dist/src/unstable/registry/version-selection.js",
62
+ "types": "./dist/src/unstable/registry/version-selection.d.ts"
63
+ },
245
64
  "./unstable/suggested-action": {
246
65
  "axm-source": "./src/unstable/suggested-action.ts",
247
66
  "default": "./dist/src/unstable/suggested-action.js",
@@ -262,10 +81,10 @@
262
81
  "access": "public"
263
82
  },
264
83
  "repository": {
265
- "directory": "packages/registry-protocol",
84
+ "directory": "packages/core/registry-protocol",
266
85
  "type": "git",
267
86
  "url": "https://github.com/agentxm/axm.git"
268
87
  },
269
88
  "type": "module",
270
- "version": "0.28.12"
271
- }
89
+ "version": "0.28.13"
90
+ }
@@ -1,17 +0,0 @@
1
- /**
2
- * Agent Skills conformance pin.
3
- *
4
- * AXM validates and materializes agent-facing skill directories against this
5
- * exact upstream revision. Bumping the revision requires reviewing both the
6
- * specification and `skills-ref` behavior, then updating conformance tests.
7
- *
8
- * @experimental This API is unstable and may change without notice.
9
- */
10
- export declare const AGENT_SKILLS_STANDARD_REVISION = "217be548739f21d6008915c29aefe320ea1a90af";
11
- export declare const AGENT_SKILLS_SPECIFICATION_URL = "https://github.com/agentskills/agentskills/blob/217be548739f21d6008915c29aefe320ea1a90af/docs/specification.mdx";
12
- export declare const AGENT_SKILLS_REFERENCE_VALIDATOR_URL = "https://github.com/agentskills/agentskills/tree/217be548739f21d6008915c29aefe320ea1a90af/skills-ref";
13
- export declare const AGENT_SKILLS_FRONTMATTER_FIELDS: readonly ["name", "description", "license", "compatibility", "metadata", "allowed-tools"];
14
- export declare const AGENT_SKILLS_NAME_MAX_LENGTH = 64;
15
- export declare const AGENT_SKILLS_DESCRIPTION_MAX_LENGTH = 1024;
16
- export declare const AGENT_SKILLS_COMPATIBILITY_MAX_LENGTH = 500;
17
- //# sourceMappingURL=agent-skills-standard.d.ts.map
@@ -1,24 +0,0 @@
1
- /**
2
- * Agent Skills conformance pin.
3
- *
4
- * AXM validates and materializes agent-facing skill directories against this
5
- * exact upstream revision. Bumping the revision requires reviewing both the
6
- * specification and `skills-ref` behavior, then updating conformance tests.
7
- *
8
- * @experimental This API is unstable and may change without notice.
9
- */
10
- export const AGENT_SKILLS_STANDARD_REVISION = "217be548739f21d6008915c29aefe320ea1a90af";
11
- export const AGENT_SKILLS_SPECIFICATION_URL = `https://github.com/agentskills/agentskills/blob/${AGENT_SKILLS_STANDARD_REVISION}/docs/specification.mdx`;
12
- export const AGENT_SKILLS_REFERENCE_VALIDATOR_URL = `https://github.com/agentskills/agentskills/tree/${AGENT_SKILLS_STANDARD_REVISION}/skills-ref`;
13
- export const AGENT_SKILLS_FRONTMATTER_FIELDS = [
14
- "name",
15
- "description",
16
- "license",
17
- "compatibility",
18
- "metadata",
19
- "allowed-tools",
20
- ];
21
- export const AGENT_SKILLS_NAME_MAX_LENGTH = 64;
22
- export const AGENT_SKILLS_DESCRIPTION_MAX_LENGTH = 1024;
23
- export const AGENT_SKILLS_COMPATIBILITY_MAX_LENGTH = 500;
24
- //# sourceMappingURL=agent-skills-standard.js.map
@@ -1,52 +0,0 @@
1
- /**
2
- * Generic YAML frontmatter parser.
3
- *
4
- * Parses content that may begin with a YAML frontmatter block delimited
5
- * by `---`. Returns the parsed frontmatter as `unknown` so each consumer
6
- * can apply its own Schema validation.
7
- *
8
- * @experimental This API is unstable and may change without notice.
9
- */
10
- import * as Effect from "effect/Effect";
11
- /**
12
- * Result of parsing frontmatter from content.
13
- *
14
- * @experimental This API is unstable and may change without notice.
15
- */
16
- export interface FrontmatterResult {
17
- /** Parsed YAML frontmatter, or undefined if no frontmatter block was found. */
18
- readonly frontmatter: unknown;
19
- /** Content body after the frontmatter block, or full content if no frontmatter. */
20
- readonly body: string;
21
- }
22
- declare const FrontmatterParseFailure_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
23
- readonly _tag: "FrontmatterParseFailure";
24
- } & Readonly<A>;
25
- /** Bounded, document-relative failure from parsing a YAML frontmatter block. */
26
- export declare class FrontmatterParseFailure extends FrontmatterParseFailure_base<{
27
- readonly reason: string;
28
- readonly line?: number;
29
- readonly column?: number;
30
- }> {
31
- }
32
- export declare const FRONTMATTER_PARSE_FALLBACK_REASON = "YAML frontmatter could not be parsed";
33
- /** Normalize a foreign YAML failure without retaining its raw cause or parser code. */
34
- export declare const normalizeFrontmatterParseFailure: (error: unknown, documentLineOffset: number) => FrontmatterParseFailure;
35
- /**
36
- * Parse frontmatter from content synchronously.
37
- *
38
- * Throws on malformed YAML. Use `parseFrontmatterEffect` for full error channel.
39
- *
40
- * @experimental This API is unstable and may change without notice.
41
- */
42
- export declare const parseFrontmatterSync: (content: string) => FrontmatterResult;
43
- /**
44
- * Parse frontmatter from content as an Effect.
45
- *
46
- * Returns `FrontmatterParseFailure` in the error channel for malformed YAML.
47
- *
48
- * @experimental This API is unstable and may change without notice.
49
- */
50
- export declare const parseFrontmatterEffect: (content: string) => Effect.Effect<FrontmatterResult, FrontmatterParseFailure>;
51
- export {};
52
- //# sourceMappingURL=frontmatter.d.ts.map
@@ -1,115 +0,0 @@
1
- /**
2
- * Generic YAML frontmatter parser.
3
- *
4
- * Parses content that may begin with a YAML frontmatter block delimited
5
- * by `---`. Returns the parsed frontmatter as `unknown` so each consumer
6
- * can apply its own Schema validation.
7
- *
8
- * @experimental This API is unstable and may change without notice.
9
- */
10
- import * as Data from "effect/Data";
11
- import * as Effect from "effect/Effect";
12
- import YAML, { YAMLParseError } from "yaml";
13
- /** Bounded, document-relative failure from parsing a YAML frontmatter block. */
14
- export class FrontmatterParseFailure extends Data.TaggedError("FrontmatterParseFailure") {
15
- }
16
- const FRONTMATTER_DELIMITER = "---";
17
- export const FRONTMATTER_PARSE_FALLBACK_REASON = "YAML frontmatter could not be parsed";
18
- const FRONTMATTER_PARSE_REASON_MAX_CODE_POINTS = 256;
19
- const boundedReason = (reason) => {
20
- const codePoints = Array.from(reason);
21
- if (codePoints.length <= FRONTMATTER_PARSE_REASON_MAX_CODE_POINTS)
22
- return reason;
23
- return `${codePoints.slice(0, FRONTMATTER_PARSE_REASON_MAX_CODE_POINTS - 1).join("")}…`;
24
- };
25
- const parserReason = (error) => {
26
- const firstLine = error.message.split(/\r?\n/, 1)[0]?.trim() ?? "";
27
- const withoutLocation = firstLine
28
- .replace(/\s+at line \d+, column \d+:?$/, "")
29
- .replace(/^Missing closing ["']quote$/, "Missing closing quote")
30
- .trim();
31
- return boundedReason(withoutLocation || FRONTMATTER_PARSE_FALLBACK_REASON);
32
- };
33
- /** Normalize a foreign YAML failure without retaining its raw cause or parser code. */
34
- export const normalizeFrontmatterParseFailure = (error, documentLineOffset) => {
35
- if (!(error instanceof YAMLParseError)) {
36
- return new FrontmatterParseFailure({ reason: FRONTMATTER_PARSE_FALLBACK_REASON });
37
- }
38
- const position = error.linePos?.[0];
39
- if (position === undefined || !Number.isSafeInteger(position.line) || position.line < 1) {
40
- return new FrontmatterParseFailure({ reason: parserReason(error) });
41
- }
42
- const line = position.line + documentLineOffset;
43
- const column = Number.isSafeInteger(position.col) && position.col > 0 ? position.col : undefined;
44
- return new FrontmatterParseFailure({
45
- reason: parserReason(error),
46
- line,
47
- ...(column === undefined ? {} : { column }),
48
- });
49
- };
50
- /**
51
- * Find the frontmatter boundaries in content.
52
- * Returns [endOfOpening, startOfClosing] indices, or undefined if no frontmatter.
53
- */
54
- const findFrontmatterBoundaries = (content) => {
55
- if (!content.startsWith(FRONTMATTER_DELIMITER)) {
56
- return undefined;
57
- }
58
- const afterOpening = content.indexOf("\n");
59
- if (afterOpening === -1) {
60
- return undefined;
61
- }
62
- const closingIndex = content.indexOf(`\n${FRONTMATTER_DELIMITER}`, afterOpening);
63
- if (closingIndex === -1) {
64
- return undefined;
65
- }
66
- const closingEnd = closingIndex + 1 + FRONTMATTER_DELIMITER.length;
67
- const bodyStart = content.startsWith("\r\n", closingEnd)
68
- ? closingEnd + 2
69
- : content[closingEnd] === "\n"
70
- ? closingEnd + 1
71
- : closingEnd;
72
- return {
73
- yamlStart: afterOpening + 1,
74
- bodyStart,
75
- };
76
- };
77
- /**
78
- * Parse frontmatter from content synchronously.
79
- *
80
- * Throws on malformed YAML. Use `parseFrontmatterEffect` for full error channel.
81
- *
82
- * @experimental This API is unstable and may change without notice.
83
- */
84
- export const parseFrontmatterSync = (content) => {
85
- const boundaries = findFrontmatterBoundaries(content);
86
- if (boundaries === undefined) {
87
- return { frontmatter: undefined, body: content };
88
- }
89
- const yamlContent = content.slice(boundaries.yamlStart, boundaries.bodyStart).split("---")[0];
90
- const frontmatter = (() => {
91
- try {
92
- return YAML.parse(yamlContent ?? "");
93
- }
94
- catch (error) {
95
- const documentLineOffset = content.slice(0, boundaries.yamlStart).split("\n").length - 1;
96
- throw normalizeFrontmatterParseFailure(error, documentLineOffset);
97
- }
98
- })();
99
- const body = content.slice(boundaries.bodyStart);
100
- return { frontmatter: frontmatter ?? undefined, body };
101
- };
102
- /**
103
- * Parse frontmatter from content as an Effect.
104
- *
105
- * Returns `FrontmatterParseFailure` in the error channel for malformed YAML.
106
- *
107
- * @experimental This API is unstable and may change without notice.
108
- */
109
- export const parseFrontmatterEffect = (content) => Effect.try({
110
- try: () => parseFrontmatterSync(content),
111
- catch: (error) => error instanceof FrontmatterParseFailure
112
- ? error
113
- : new FrontmatterParseFailure({ reason: FRONTMATTER_PARSE_FALLBACK_REASON }),
114
- });
115
- //# sourceMappingURL=frontmatter.js.map