@ai-primitives-hub/core 0.1.0 → 0.2.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 (113) hide show
  1. package/dist/domain/bundle/id.d.ts +58 -7
  2. package/dist/domain/bundle/id.d.ts.map +1 -1
  3. package/dist/domain/bundle/id.js +68 -7
  4. package/dist/domain/bundle/id.js.map +1 -1
  5. package/dist/domain/bundle/types.d.ts +50 -0
  6. package/dist/domain/bundle/types.d.ts.map +1 -1
  7. package/dist/domain/bundle/types.js +110 -0
  8. package/dist/domain/bundle/types.js.map +1 -1
  9. package/dist/domain/bundle/version.d.ts +10 -0
  10. package/dist/domain/bundle/version.d.ts.map +1 -1
  11. package/dist/domain/bundle/version.js +21 -0
  12. package/dist/domain/bundle/version.js.map +1 -1
  13. package/dist/domain/collection/manifest-validator.d.ts +11 -3
  14. package/dist/domain/collection/manifest-validator.d.ts.map +1 -1
  15. package/dist/domain/collection/manifest-validator.js +13 -1
  16. package/dist/domain/collection/manifest-validator.js.map +1 -1
  17. package/dist/domain/collection/release-manifest-plan.d.ts +75 -0
  18. package/dist/domain/collection/release-manifest-plan.d.ts.map +1 -0
  19. package/dist/domain/collection/release-manifest-plan.js +476 -0
  20. package/dist/domain/collection/release-manifest-plan.js.map +1 -0
  21. package/dist/domain/hub/replicate.d.ts +58 -0
  22. package/dist/domain/hub/replicate.d.ts.map +1 -0
  23. package/dist/domain/hub/replicate.js +229 -0
  24. package/dist/domain/hub/replicate.js.map +1 -0
  25. package/dist/domain/hub/types.d.ts +10 -4
  26. package/dist/domain/hub/types.d.ts.map +1 -1
  27. package/dist/domain/hub/validate.d.ts +5 -0
  28. package/dist/domain/hub/validate.d.ts.map +1 -1
  29. package/dist/domain/hub/validate.js +32 -3
  30. package/dist/domain/hub/validate.js.map +1 -1
  31. package/dist/domain/index.d.ts +6 -0
  32. package/dist/domain/index.d.ts.map +1 -1
  33. package/dist/domain/index.js +6 -0
  34. package/dist/domain/index.js.map +1 -1
  35. package/dist/domain/install/installable.d.ts +1 -1
  36. package/dist/domain/install/installable.d.ts.map +1 -1
  37. package/dist/domain/install/integrity.d.ts +12 -18
  38. package/dist/domain/install/integrity.d.ts.map +1 -1
  39. package/dist/domain/install/integrity.js +28 -5
  40. package/dist/domain/install/integrity.js.map +1 -1
  41. package/dist/domain/install/layout.d.ts +15 -0
  42. package/dist/domain/install/layout.d.ts.map +1 -1
  43. package/dist/domain/install/layout.js +18 -7
  44. package/dist/domain/install/layout.js.map +1 -1
  45. package/dist/domain/mcp/env-placeholders.d.ts +29 -0
  46. package/dist/domain/mcp/env-placeholders.d.ts.map +1 -0
  47. package/dist/domain/mcp/env-placeholders.js +32 -0
  48. package/dist/domain/mcp/env-placeholders.js.map +1 -0
  49. package/dist/domain/mcp/index.d.ts +1 -0
  50. package/dist/domain/mcp/index.d.ts.map +1 -1
  51. package/dist/domain/mcp/index.js +1 -0
  52. package/dist/domain/mcp/index.js.map +1 -1
  53. package/dist/domain/plugin/agent-plugin-spec.d.ts +75 -0
  54. package/dist/domain/plugin/agent-plugin-spec.d.ts.map +1 -0
  55. package/dist/domain/plugin/agent-plugin-spec.js +270 -0
  56. package/dist/domain/plugin/agent-plugin-spec.js.map +1 -0
  57. package/dist/domain/registry-error.d.ts +1 -1
  58. package/dist/domain/registry-error.d.ts.map +1 -1
  59. package/dist/domain/registry-error.js +1 -1
  60. package/dist/domain/registry-error.js.map +1 -1
  61. package/dist/domain/source/artifactory-source-index.d.ts +58 -0
  62. package/dist/domain/source/artifactory-source-index.d.ts.map +1 -0
  63. package/dist/domain/source/artifactory-source-index.js +175 -0
  64. package/dist/domain/source/artifactory-source-index.js.map +1 -0
  65. package/dist/domain/source/github-repository-target.d.ts +16 -0
  66. package/dist/domain/source/github-repository-target.d.ts.map +1 -0
  67. package/dist/domain/source/github-repository-target.js +3 -0
  68. package/dist/domain/source/github-repository-target.js.map +1 -0
  69. package/dist/domain/source/github-source-authentication.d.ts +6 -0
  70. package/dist/domain/source/github-source-authentication.d.ts.map +1 -0
  71. package/dist/domain/source/github-source-authentication.js +3 -0
  72. package/dist/domain/source/github-source-authentication.js.map +1 -0
  73. package/dist/domain/source/types.d.ts +9 -2
  74. package/dist/domain/source/types.d.ts.map +1 -1
  75. package/dist/domain/source-id.d.ts +6 -3
  76. package/dist/domain/source-id.d.ts.map +1 -1
  77. package/dist/domain/source-id.js +14 -11
  78. package/dist/domain/source-id.js.map +1 -1
  79. package/dist/index.d.ts +10 -0
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +13 -1
  82. package/dist/index.js.map +1 -1
  83. package/dist/ports/github-api.d.ts +4 -0
  84. package/dist/ports/github-api.d.ts.map +1 -1
  85. package/dist/ports/http-credentials.d.ts +10 -0
  86. package/dist/ports/http-credentials.d.ts.map +1 -0
  87. package/dist/ports/http-credentials.js +3 -0
  88. package/dist/ports/http-credentials.js.map +1 -0
  89. package/dist/ports/http.d.ts +6 -2
  90. package/dist/ports/http.d.ts.map +1 -1
  91. package/dist/ports/http.js +0 -9
  92. package/dist/ports/http.js.map +1 -1
  93. package/dist/ports/index.d.ts +3 -0
  94. package/dist/ports/index.d.ts.map +1 -1
  95. package/dist/ports/index.js +3 -0
  96. package/dist/ports/index.js.map +1 -1
  97. package/dist/ports/process-executor.d.ts +13 -0
  98. package/dist/ports/process-executor.d.ts.map +1 -0
  99. package/dist/ports/process-executor.js +3 -0
  100. package/dist/ports/process-executor.js.map +1 -0
  101. package/dist/ports/registry-operations.d.ts +91 -4
  102. package/dist/ports/registry-operations.d.ts.map +1 -1
  103. package/dist/ports/release-source.d.ts +52 -0
  104. package/dist/ports/release-source.d.ts.map +1 -0
  105. package/dist/ports/release-source.js +3 -0
  106. package/dist/ports/release-source.js.map +1 -0
  107. package/dist/ports/target-writer.d.ts +15 -1
  108. package/dist/ports/target-writer.d.ts.map +1 -1
  109. package/dist/public/schemas/agent-plugins/1.0.0/plugin.schema.json +65 -0
  110. package/dist/public/schemas/artifactory-source-index.schema.json +44 -0
  111. package/dist/public/schemas/hub-config.schema.json +18 -3
  112. package/dist/public/schemas/lockfile.schema.json +37 -2
  113. package/package.json +3 -3
@@ -0,0 +1,75 @@
1
+ import type { ReleaseSourceReader } from '../../ports/release-source';
2
+ import type { ReleaseManifestFileRole } from './types';
3
+ /** Error message used when governed release evidence is incomplete. */
4
+ export declare const NO_SOURCE_LICENSE_MESSAGE = "No source license or notice file was found for the governed release";
5
+ /** Warning shown when a legacy compatibility archive is produced. */
6
+ export declare const LEGACY_RELEASE_WARNING: string;
7
+ /** Exact data written to one archive entry. */
8
+ export interface ReleaseArchiveEntry {
9
+ path: string;
10
+ role: ReleaseManifestFileRole;
11
+ bytes: Uint8Array;
12
+ }
13
+ /** A planned manifest paired with the exact files it inventories. */
14
+ export interface ReleaseManifestPlan {
15
+ manifest: Record<string, unknown>;
16
+ entries: ReleaseArchiveEntry[];
17
+ collectionPath: string;
18
+ readmeSourcePath?: string;
19
+ }
20
+ /** Inputs resolved by a command before planning a release. */
21
+ export interface CreateReleaseManifestPlanOptions {
22
+ /** Absolute repository root. */
23
+ repoRoot: string;
24
+ /** Collection file, repo-relative or absolute under `repoRoot`. */
25
+ collectionFile: string;
26
+ version: string;
27
+ /** Explicit source repository URL; defaults to package metadata, then `origin`. */
28
+ source?: string;
29
+ /** Revision to plan from (default `HEAD`). */
30
+ revision?: string;
31
+ /** Explicit package metadata; defaults to the source tree's `package.json`. */
32
+ packageMetadata?: Record<string, unknown>;
33
+ }
34
+ /**
35
+ * Plan the canonical manifest and all non-manifest ZIP entries for one source
36
+ * collection. The returned inventory is based on exact bytes, so callers must
37
+ * write these bytes unchanged into the final archive.
38
+ * @param options - Planning inputs.
39
+ * @param sources - Source reader for the revisioned tree and `origin` remote.
40
+ * @returns The governed release plan. Rejects with {@link NO_SOURCE_LICENSE_MESSAGE}
41
+ * when the revision has no root license/copying/notice file.
42
+ */
43
+ export declare function createReleaseManifestPlan(options: CreateReleaseManifestPlanOptions, sources: ReleaseSourceReader): Promise<ReleaseManifestPlan>;
44
+ /**
45
+ * Plan the pre-formatVersion archive used for legacy compatibility builds.
46
+ *
47
+ * This deliberately reads the working tree and emits the historical manifest
48
+ * shape. It must only be used after governed planning reports missing license
49
+ * evidence (see {@link isMissingSourceLicenseError}); it is not a relaxed
50
+ * governed-release planner.
51
+ * @param options - Planning inputs (`source` and `revision` are ignored).
52
+ * @param sources - Source reader providing the working tree.
53
+ * @returns The legacy release plan.
54
+ */
55
+ export declare function createLegacyReleaseManifestPlan(options: CreateReleaseManifestPlanOptions, sources: ReleaseSourceReader): Promise<ReleaseManifestPlan>;
56
+ /**
57
+ * Identify the one governed-planning failure that permits legacy fallback.
58
+ * All other planning failures remain blocking.
59
+ * @param error - Rejection reason from {@link createReleaseManifestPlan}.
60
+ * @returns `true` only for the missing source license error.
61
+ */
62
+ export declare const isMissingSourceLicenseError: (error: unknown) => boolean;
63
+ /**
64
+ * Serialize a planned manifest with the repository's stable YAML settings.
65
+ * @param manifest - Planned manifest.
66
+ * @returns YAML text without line wrapping.
67
+ */
68
+ export declare function serializeReleaseManifest(manifest: Record<string, unknown>): string;
69
+ /**
70
+ * Require a full immutable Git object id rather than a mutable ref.
71
+ * @param revision - Candidate revision.
72
+ * @returns The lowercased revision.
73
+ */
74
+ export declare function assertImmutableRevision(revision: string): string;
75
+ //# sourceMappingURL=release-manifest-plan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"release-manifest-plan.d.ts","sourceRoot":"","sources":["../../../src/domain/collection/release-manifest-plan.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EACV,mBAAmB,EAEpB,MAAM,4BAA4B,CAAC;AAIpC,OAAO,KAAK,EAGV,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAKjB,uEAAuE;AACvE,eAAO,MAAM,yBAAyB,wEAAwE,CAAC;AAE/G,qEAAqE;AACrE,eAAO,MAAM,sBAAsB,QAE+B,CAAC;AAEnE,+CAA+C;AAC/C,MAAM,W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@ -0,0 +1,476 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.isMissingSourceLicenseError = exports.LEGACY_RELEASE_WARNING = exports.NO_SOURCE_LICENSE_MESSAGE = void 0;
37
+ exports.createReleaseManifestPlan = createReleaseManifestPlan;
38
+ exports.createLegacyReleaseManifestPlan = createLegacyReleaseManifestPlan;
39
+ exports.serializeReleaseManifest = serializeReleaseManifest;
40
+ exports.assertImmutableRevision = assertImmutableRevision;
41
+ /**
42
+ * Release manifest planning for `bundle build`.
43
+ *
44
+ * Plans the deployment manifest and the exact archive entries of one
45
+ * source collection: the governed (`formatVersion: 1`) release read from an
46
+ * immutable Git revision, and the pre-`formatVersion` legacy compatibility
47
+ * release read from the working tree.
48
+ *
49
+ * This is the packages-side reference implementation, ported from the
50
+ * legacy `lib/` package module `lib/src/release-manifest.ts` (and
51
+ * `lib/src/bundle-id.ts`, superseded by `domain/bundle/id.ts`). `lib/` is legacy and intentionally left
52
+ * unchanged, so the two copies may coexist; behavior here (error messages,
53
+ * manifest key order, YAML format) is kept byte-identical to that source.
54
+ *
55
+ * Pure domain logic over the injected {@link ReleaseSourceReader} port: no
56
+ * `node:fs`, no `node:child_process`.
57
+ * @module domain/collection/release-manifest-plan
58
+ */
59
+ const node_crypto_1 = require("node:crypto");
60
+ const path = __importStar(require("node:path"));
61
+ const yaml = __importStar(require("js-yaml"));
62
+ const types_1 = require("../primitive/types");
63
+ const validate_1 = require("./validate");
64
+ /** Error message used when governed release evidence is incomplete. */
65
+ exports.NO_SOURCE_LICENSE_MESSAGE = 'No source license or notice file was found for the governed release';
66
+ /** Warning shown when a legacy compatibility archive is produced. */
67
+ exports.LEGACY_RELEASE_WARNING = 'No committed LICENSE, COPYING, or NOTICE file was found; '
68
+ + 'building a legacy bundle without governed release evidence. '
69
+ + 'Add license text to enable governed self-contained releases.';
70
+ /**
71
+ * Plan the canonical manifest and all non-manifest ZIP entries for one source
72
+ * collection. The returned inventory is based on exact bytes, so callers must
73
+ * write these bytes unchanged into the final archive.
74
+ * @param options - Planning inputs.
75
+ * @param sources - Source reader for the revisioned tree and `origin` remote.
76
+ * @returns The governed release plan. Rejects with {@link NO_SOURCE_LICENSE_MESSAGE}
77
+ * when the revision has no root license/copying/notice file.
78
+ */
79
+ async function createReleaseManifestPlan(options, sources) {
80
+ const collectionPath = resolveRepoRelativePath(options.repoRoot, options.collectionFile);
81
+ const sourceTree = await sources.openRevision(options.repoRoot, options.revision);
82
+ const collection = yaml.load(decodeUtf8(await sourceTree.readFile(collectionPath)));
83
+ if (!collection || typeof collection !== 'object') {
84
+ throw new Error(`Invalid collection YAML: ${collectionPath}`);
85
+ }
86
+ if (typeof collection.id !== 'string' || collection.id.length === 0) {
87
+ throw new Error(`Collection id is required: ${collectionPath}`);
88
+ }
89
+ if (typeof collection.name !== 'string' || collection.name.length === 0) {
90
+ throw new Error(`Collection name is required: ${collectionPath}`);
91
+ }
92
+ const packageMetadata = (options.packageMetadata ?? await readPackageMetadata(sourceTree));
93
+ const source = await resolveSourceRepository(sources, options.repoRoot, options.source ?? repositoryUrl(packageMetadata.repository));
94
+ const revision = sourceTree.revision;
95
+ const license = collectionLicense(collection, packageMetadata);
96
+ const items = Array.isArray(collection.items) ? collection.items : [];
97
+ const itemEntries = await collectItemEntries(sourceTree, items);
98
+ const canonicalItems = [];
99
+ for (const item of items) {
100
+ canonicalItems.push(await createCanonicalItem(sourceTree, item));
101
+ }
102
+ const legacyItems = canonicalItems.map((item) => createLegacyItem(item));
103
+ const sourceSnapshotPath = `metadata/source/${collectionPath}`;
104
+ const entries = [
105
+ ...itemEntries,
106
+ {
107
+ path: sourceSnapshotPath,
108
+ role: 'metadata',
109
+ bytes: await sourceTree.readFile(collectionPath)
110
+ }
111
+ ];
112
+ const readmeSourcePath = resolveCollectionReadmePath(collection);
113
+ let readmePath;
114
+ if (readmeSourcePath !== null) {
115
+ readmePath = 'README.md';
116
+ entries.push({ path: readmePath, role: 'metadata', bytes: await sourceTree.readFile(readmeSourcePath) });
117
+ }
118
+ const licenseSourcePath = await findLicensePath(sourceTree);
119
+ if (licenseSourcePath === null) {
120
+ throw new Error(exports.NO_SOURCE_LICENSE_MESSAGE);
121
+ }
122
+ const licensePath = 'LICENSE';
123
+ entries.push({
124
+ path: licensePath,
125
+ role: 'metadata',
126
+ bytes: await sourceTree.readFile(licenseSourcePath)
127
+ });
128
+ assertUniqueArchivePaths(entries);
129
+ assertUniqueCanonicalItems(canonicalItems);
130
+ const mcpServers = collection.mcpServers ?? collection.mcp?.items;
131
+ const mcpInputs = collection.mcp?.inputs;
132
+ const manifest = {
133
+ formatVersion: 1,
134
+ id: collection.id,
135
+ version: options.version,
136
+ name: collection.name || packageMetadata.description || '',
137
+ description: collection.description || packageMetadata.description || '',
138
+ author: collection.author || packageMetadata.author || 'Prompt Registry',
139
+ tags: collection.tags || packageMetadata.keywords || [],
140
+ environments: ['vscode', 'windsurf', 'cursor'],
141
+ ...(readmePath === undefined ? {} : { readme: readmePath }),
142
+ license,
143
+ repository: source,
144
+ items: canonicalItems,
145
+ files: sortByPath(entries.map((entry) => ({
146
+ path: entry.path,
147
+ role: entry.role,
148
+ size: entry.bytes.byteLength,
149
+ sha256: sha256(entry.bytes)
150
+ }))),
151
+ provenance: {
152
+ source,
153
+ revision,
154
+ collectionPath,
155
+ sourceSnapshotPath,
156
+ license,
157
+ licensePath
158
+ },
159
+ prompts: legacyItems,
160
+ dependencies: [],
161
+ ...(mcpServers && Object.keys(mcpServers).length > 0 ? { mcpServers } : {}),
162
+ ...(mcpInputs && mcpInputs.length > 0 ? { mcpInputs } : {})
163
+ };
164
+ return {
165
+ manifest,
166
+ entries: sortByPath(entries),
167
+ collectionPath,
168
+ ...(readmeSourcePath === null ? {} : { readmeSourcePath })
169
+ };
170
+ }
171
+ /**
172
+ * Plan the pre-formatVersion archive used for legacy compatibility builds.
173
+ *
174
+ * This deliberately reads the working tree and emits the historical manifest
175
+ * shape. It must only be used after governed planning reports missing license
176
+ * evidence (see {@link isMissingSourceLicenseError}); it is not a relaxed
177
+ * governed-release planner.
178
+ * @param options - Planning inputs (`source` and `revision` are ignored).
179
+ * @param sources - Source reader providing the working tree.
180
+ * @returns The legacy release plan.
181
+ */
182
+ async function createLegacyReleaseManifestPlan(options, sources) {
183
+ const workingTree = sources.openWorkingTree(options.repoRoot);
184
+ const collectionPath = resolveRepoRelativePath(options.repoRoot, options.collectionFile);
185
+ const collectionBytes = await workingTree.readFile(collectionPath);
186
+ const collection = yaml.load(decodeUtf8(collectionBytes));
187
+ if (!collection || typeof collection !== 'object') {
188
+ throw new Error(`Invalid collection YAML: ${collectionPath}`);
189
+ }
190
+ if (typeof collection.id !== 'string' || collection.id.length === 0) {
191
+ throw new Error(`Collection id is required: ${collectionPath}`);
192
+ }
193
+ if (typeof collection.name !== 'string' || collection.name.length === 0) {
194
+ throw new Error(`Collection name is required: ${collectionPath}`);
195
+ }
196
+ const packageMetadata = (options.packageMetadata ?? await readPackageMetadata(workingTree));
197
+ const items = Array.isArray(collection.items) ? collection.items : [];
198
+ const prompts = [];
199
+ const entriesByPath = new Map();
200
+ for (const item of items) {
201
+ const itemPath = (0, validate_1.normalizeRepoRelativePath)(item.path);
202
+ const itemBytes = await workingTree.readFile(itemPath);
203
+ prompts.push(createLegacyManifestItem(item, itemPath, decodeUtf8(itemBytes)));
204
+ const kind = (0, types_1.normalizePrimitiveKind)(item.kind.trim()) ?? item.kind.trim().toLowerCase();
205
+ for (const entryPath of await resolveLegacyItemPaths(workingTree, itemPath, kind)) {
206
+ if (!entriesByPath.has(entryPath)) {
207
+ entriesByPath.set(entryPath, {
208
+ path: entryPath,
209
+ role: 'installable',
210
+ bytes: await workingTree.readFile(entryPath)
211
+ });
212
+ }
213
+ }
214
+ }
215
+ const entries = sortByPath([...entriesByPath.values()]);
216
+ assertUniqueArchivePaths(entries);
217
+ const readmeSourcePath = resolveCollectionReadmePath(collection);
218
+ const mcpServers = collection.mcpServers ?? collection.mcp?.items;
219
+ const mcpInputs = collection.mcp?.inputs;
220
+ const repository = normalizeRepositoryUrl(repositoryUrl(packageMetadata.repository));
221
+ const manifest = {
222
+ id: collection.id,
223
+ version: options.version,
224
+ name: collection.name || packageMetadata.description || '',
225
+ description: collection.description || packageMetadata.description || '',
226
+ author: collection.author || packageMetadata.author || 'Prompt Registry',
227
+ tags: collection.tags || packageMetadata.keywords || [],
228
+ environments: ['vscode', 'windsurf', 'cursor'],
229
+ license: collection.license || packageMetadata.license || 'MIT',
230
+ repository,
231
+ prompts,
232
+ dependencies: [],
233
+ ...(readmeSourcePath === null ? {} : { readme: path.basename(readmeSourcePath) }),
234
+ ...(mcpServers && Object.keys(mcpServers).length > 0 ? { mcpServers } : {}),
235
+ ...(mcpInputs && mcpInputs.length > 0 ? { mcpInputs } : {})
236
+ };
237
+ return {
238
+ manifest,
239
+ entries,
240
+ collectionPath,
241
+ ...(readmeSourcePath === null ? {} : { readmeSourcePath })
242
+ };
243
+ }
244
+ /**
245
+ * Identify the one governed-planning failure that permits legacy fallback.
246
+ * All other planning failures remain blocking.
247
+ * @param error - Rejection reason from {@link createReleaseManifestPlan}.
248
+ * @returns `true` only for the missing source license error.
249
+ */
250
+ const isMissingSourceLicenseError = (error) => error instanceof Error && error.message === exports.NO_SOURCE_LICENSE_MESSAGE;
251
+ exports.isMissingSourceLicenseError = isMissingSourceLicenseError;
252
+ /**
253
+ * Serialize a planned manifest with the repository's stable YAML settings.
254
+ * @param manifest - Planned manifest.
255
+ * @returns YAML text without line wrapping.
256
+ */
257
+ function serializeReleaseManifest(manifest) {
258
+ return yaml.dump(manifest, { lineWidth: -1 });
259
+ }
260
+ /**
261
+ * Require a full immutable Git object id rather than a mutable ref.
262
+ * @param revision - Candidate revision.
263
+ * @returns The lowercased revision.
264
+ */
265
+ function assertImmutableRevision(revision) {
266
+ if (!/^[a-f0-9]{40,64}$/i.test(revision)) {
267
+ throw new Error(`Source revision must be a full immutable Git object ID, got "${revision}"`);
268
+ }
269
+ return revision.toLowerCase();
270
+ }
271
+ /**
272
+ * Decode UTF-8 like Node's `Buffer#toString('utf8')`: a leading BOM is kept
273
+ * (`ignoreBOM: true`; the default `TextDecoder` strips it, which would change
274
+ * heading matches) and invalid sequences become U+FFFD.
275
+ *
276
+ * Read-only use: the decoded string only feeds YAML/JSON parsing and item
277
+ * metadata extraction. Archive entries always carry the original bytes from
278
+ * `ReleaseSourceTree.readFile`, so binary files are never round-tripped
279
+ * through this decoder.
280
+ * @param bytes - Raw bytes.
281
+ */
282
+ const utf8Decoder = new TextDecoder('utf-8', { ignoreBOM: true });
283
+ const decodeUtf8 = (bytes) => utf8Decoder.decode(bytes);
284
+ const resolveSourceRepository = async (sources, repoRoot, preferredSource) => {
285
+ const candidate = preferredSource || await sources.readRemoteUrl(repoRoot);
286
+ const source = normalizeRepositoryUrl(candidate);
287
+ if (!source) {
288
+ throw new Error('Unable to resolve a source repository URL from package metadata or git remote origin');
289
+ }
290
+ return source;
291
+ };
292
+ const collectItemEntries = async (sourceTree, items) => {
293
+ const entries = new Map();
294
+ for (const item of items) {
295
+ const itemPath = (0, validate_1.normalizeRepoRelativePath)(item.path);
296
+ const kind = normalizeKind(item.kind);
297
+ const paths = kind === 'skill' || kind === 'plugin'
298
+ ? await listInstallableSkillFiles(sourceTree, path.posix.dirname(itemPath))
299
+ : [itemPath];
300
+ for (const entryPath of paths) {
301
+ if (!entries.has(entryPath)) {
302
+ entries.set(entryPath, {
303
+ path: entryPath,
304
+ role: 'installable',
305
+ bytes: await sourceTree.readFile(entryPath)
306
+ });
307
+ }
308
+ }
309
+ }
310
+ return [...entries.values()];
311
+ };
312
+ const listInstallableSkillFiles = async (sourceTree, directory) => (await sourceTree.listFiles(directory)).filter((entry) => !isIgnoredPath(entry)).toSorted(comparePaths);
313
+ const isIgnoredPath = (entry) => {
314
+ const segments = entry.split('/');
315
+ const fileName = segments.at(-1) ?? '';
316
+ return segments.includes('__pycache__')
317
+ || segments.includes('.git')
318
+ || segments.includes('node_modules')
319
+ || fileName === '.DS_Store'
320
+ || fileName.endsWith('.pyc')
321
+ || fileName.endsWith('.pyo');
322
+ };
323
+ const itemTags = (item) => Array.isArray(item.tags) && item.tags.length > 0 ? [...item.tags] : undefined;
324
+ const createCanonicalItem = async (sourceTree, item) => {
325
+ const itemPath = (0, validate_1.normalizeRepoRelativePath)(item.path);
326
+ const kind = normalizeKind(item.kind);
327
+ const content = decodeUtf8(await sourceTree.readFile(itemPath));
328
+ const metadata = extractItemMetadata(content, itemPath);
329
+ const id = generateItemId(itemPath, kind);
330
+ const tags = itemTags(item);
331
+ return {
332
+ id,
333
+ path: itemPath,
334
+ kind,
335
+ name: metadata.name || id,
336
+ description: metadata.description,
337
+ ...(tags === undefined ? {} : { tags })
338
+ };
339
+ };
340
+ const createLegacyItem = (canonical) => {
341
+ return {
342
+ id: canonical.id,
343
+ name: canonical.name,
344
+ description: canonical.description,
345
+ file: canonical.path,
346
+ type: legacyType(String(canonical.kind)),
347
+ ...(canonical.tags === undefined ? {} : { tags: canonical.tags })
348
+ };
349
+ };
350
+ const extractItemMetadata = (content, itemPath) => {
351
+ if (itemPath.endsWith('.json')) {
352
+ try {
353
+ const parsed = JSON.parse(content);
354
+ return {
355
+ name: typeof parsed.name === 'string' ? parsed.name : '',
356
+ description: typeof parsed.description === 'string' ? parsed.description : ''
357
+ };
358
+ }
359
+ catch {
360
+ return { name: '', description: '' };
361
+ }
362
+ }
363
+ const nameMatch = /^#\s+(.+)$/m.exec(content);
364
+ const descriptionMatch = /^##?\s*Description[:\s]+(.+)$/im.exec(content)
365
+ ?? /^>\s*(.+)$/m.exec(content);
366
+ return {
367
+ name: nameMatch?.[1] ?? '',
368
+ description: descriptionMatch?.[1] ?? ''
369
+ };
370
+ };
371
+ /**
372
+ * Canonicalize an item kind via the shared primitive alias table.
373
+ * `value.trim()` runs first so a non-string kind fails exactly as before.
374
+ * @param value - Declared item kind.
375
+ */
376
+ const normalizeKind = (value) => {
377
+ const kind = (0, types_1.normalizePrimitiveKind)(value.trim());
378
+ if (kind === null) {
379
+ throw new Error(`Collection item kind is not a canonical primitive kind: ${value}`);
380
+ }
381
+ return kind;
382
+ };
383
+ const legacyType = (kind) => ({
384
+ instruction: 'instructions',
385
+ 'chat-mode': 'chatmode'
386
+ })[kind] ?? kind;
387
+ const generateItemId = (itemPath, kind) => {
388
+ const extension = path.extname(itemPath);
389
+ if (kind === 'skill' || kind === 'plugin') {
390
+ const parts = itemPath.split('/');
391
+ return parts.length >= 2 ? (parts.at(-2) ?? path.basename(itemPath, extension)) : path.basename(itemPath, extension);
392
+ }
393
+ return path.basename(itemPath, extension);
394
+ };
395
+ const resolveCollectionReadmePath = (collection) => collection.readme?.path ? (0, validate_1.normalizeRepoRelativePath)(collection.readme.path) : null;
396
+ const resolveRepoRelativePath = (repoRoot, candidate) => {
397
+ const relative = path.isAbsolute(candidate) ? path.relative(repoRoot, candidate) : candidate;
398
+ return (0, validate_1.normalizeRepoRelativePath)(relative);
399
+ };
400
+ const readPackageMetadata = async (tree) => {
401
+ try {
402
+ return JSON.parse(decodeUtf8(await tree.readFile('package.json')));
403
+ }
404
+ catch {
405
+ return {};
406
+ }
407
+ };
408
+ /**
409
+ * Installable working-tree paths of one legacy item. Skills and plugins ship
410
+ * their whole directory. The item file itself was already read from that
411
+ * directory, so the directory exists; the listing is used as-is (an empty
412
+ * listing means it holds no regular files).
413
+ * @param workingTree - Working tree of the repository.
414
+ * @param itemPath - Normalized item path.
415
+ * @param kind - Declared item kind.
416
+ */
417
+ const resolveLegacyItemPaths = async (workingTree, itemPath, kind) => {
418
+ if (kind !== 'skill' && kind !== 'plugin') {
419
+ return [itemPath];
420
+ }
421
+ return (await workingTree.listFiles(path.posix.dirname(itemPath)))
422
+ .filter((entry) => !isIgnoredPath(entry))
423
+ .toSorted(comparePaths);
424
+ };
425
+ const createLegacyManifestItem = (item, itemPath, content) => {
426
+ const metadata = extractItemMetadata(content, itemPath);
427
+ const kind = item.kind.trim().toLowerCase();
428
+ const id = generateItemId(itemPath, kind);
429
+ const tags = itemTags(item);
430
+ return {
431
+ id,
432
+ name: metadata.name || id,
433
+ description: metadata.description,
434
+ file: itemPath,
435
+ type: legacyType(kind),
436
+ ...(tags === undefined ? {} : { tags })
437
+ };
438
+ };
439
+ const repositoryUrl = (repository) => typeof repository === 'string' ? repository : repository?.url ?? '';
440
+ const normalizeRepositoryUrl = (value) => value.replace(/^git\+/, '').replace(/\.git$/, '');
441
+ const collectionLicense = (_collection, packageMetadata) => packageMetadata.license || 'SEE LICENSE IN LICENSE';
442
+ const findLicensePath = async (sourceTree) => {
443
+ const candidate = (await sourceTree.listFiles('.'))
444
+ .filter((entry) => !entry.includes('/'))
445
+ .find((name) => /^(license|copying|notice)(\.[^.]*)?$/i.test(name));
446
+ return candidate ?? null;
447
+ };
448
+ const sha256 = (content) => `sha256:${(0, node_crypto_1.createHash)('sha256').update(content).digest('hex')}`;
449
+ const sortByPath = (values) => values.toSorted((left, right) => comparePaths(left.path, right.path));
450
+ const comparePaths = (left, right) => left < right ? -1 : (left > right ? 1 : 0);
451
+ const assertUniqueArchivePaths = (entries) => {
452
+ const seen = new Set();
453
+ for (const entry of entries) {
454
+ if (seen.has(entry.path)) {
455
+ throw new Error(`Release archive contains duplicate path: ${entry.path}`);
456
+ }
457
+ seen.add(entry.path);
458
+ }
459
+ };
460
+ const assertUniqueCanonicalItems = (items) => {
461
+ const ids = new Set();
462
+ const paths = new Set();
463
+ for (const item of items) {
464
+ const id = String(item.id);
465
+ const itemPath = String(item.path);
466
+ if (ids.has(id)) {
467
+ throw new Error(`Release manifest contains duplicate item id: ${id}`);
468
+ }
469
+ if (paths.has(itemPath)) {
470
+ throw new Error(`Release manifest contains duplicate item path: ${itemPath}`);
471
+ }
472
+ ids.add(id);
473
+ paths.add(itemPath);
474
+ }
475
+ };
476
+ //# sourceMappingURL=release-manifest-plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"release-manifest-plan.js","sourceRoot":"","sources":["../../../src/domain/collection/release-manifest-plan.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwGA,8DAyGC;AAaD,0EAsEC;AAgBD,4DAEC;AAOD,0DAKC;AAlUD;;;;;;;;;;;;;;;;;GAiBG;AACH,6CAEqB;AACrB,gDAAkC;AAClC,8CAAgC;AAKhC,8CAE4B;AAM5B,yCAEoB;AAEpB,uEAAuE;AAC1D,QAAA,yBAAyB,GAAG,qEAAqE,CAAC;AAE/G,qEAAqE;AACxD,QAAA,sBAAsB,GAAG,2DAA2D;MAC7F,8DAA8D;MAC9D,8DAA8D,CAAC;AAkDnE;;;;;;;;GAQG;AACI,KAAK,U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MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,gDAAgD,EAAE,EAAE,CAAC,CAAC;QACxE,CAAC;QACD,IAAI,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,kDAAkD,QAAQ,EAAE,CAAC,CAAC;QAChF,CAAC;QACD,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACZ,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACtB,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,58 @@
1
+ import type { ArtifactoryBundleIndexEntry, ArtifactorySourceIndex } from '../source/artifactory-source-index';
2
+ import type { HubConfig } from './types';
3
+ export interface ReplicationCandidate {
4
+ sourceId: string;
5
+ sourceIds?: string[];
6
+ repo: string;
7
+ tag: string;
8
+ publishedAt: string;
9
+ releaseName: string;
10
+ manifest: Record<string, unknown>;
11
+ manifestBytes: Uint8Array;
12
+ manifestName: string;
13
+ archiveUrl: string;
14
+ archiveSize: number;
15
+ version: string;
16
+ bundleId: string;
17
+ }
18
+ export interface ReplicationRequest {
19
+ sourceId: string;
20
+ bundleId: string;
21
+ versions: Set<string>;
22
+ }
23
+ export interface ReplicationSelection {
24
+ selected: ReplicationCandidate[];
25
+ unresolved: string[];
26
+ }
27
+ export interface ReplicationCandidateDiscovery {
28
+ candidates: ReplicationCandidate[];
29
+ warnings: string[];
30
+ }
31
+ export interface ReplicationResult {
32
+ index: ArtifactorySourceIndex;
33
+ hubConfig: HubConfig;
34
+ warnings: string[];
35
+ selected: ReplicationCandidate[];
36
+ }
37
+ export interface ReplicationSourcePort {
38
+ getHubConfig(ownerRepo: string, ref: string): Promise<Record<string, unknown>>;
39
+ listReleaseCandidates(owner: string, repo: string, sourceId: string): Promise<ReplicationCandidateDiscovery>;
40
+ downloadArchive(candidate: ReplicationCandidate): Promise<Uint8Array>;
41
+ }
42
+ export interface ReplicationPublishOptions {
43
+ replaceExisting?: boolean;
44
+ }
45
+ export interface ReplicationPublisherPort {
46
+ publish(path: string, data: Uint8Array, mediaType: string, options?: ReplicationPublishOptions): Promise<'uploaded' | 'skipped-existing' | 'skipped-unverified'>;
47
+ }
48
+ export declare const stableReplicatedBundleId: (repo: string, manifest: Record<string, unknown>) => string;
49
+ export declare const normalizedReleaseVersion: (manifest: Record<string, unknown>, tag: string) => string | undefined;
50
+ export declare const selectReplications: (candidates: ReplicationCandidate[], requests: ReplicationRequest[], mode: "latest" | "all") => ReplicationSelection;
51
+ export declare const requestsFromHubConfig: (hub: Record<string, unknown>) => ReplicationRequest[];
52
+ export interface ReplicationProfileResolution {
53
+ profiles: Record<string, unknown>[];
54
+ warnings: string[];
55
+ }
56
+ export declare const resolveReplicatedProfiles: (hub: Record<string, unknown>, candidates: ReplicationCandidate[], selectedCandidates?: ReplicationCandidate[]) => ReplicationProfileResolution;
57
+ export declare const makeReplicatedEntry: (candidate: ReplicationCandidate, manifestPath: string, archivePath: string, archive: Uint8Array, sha256: (data: Uint8Array) => string) => ArtifactoryBundleIndexEntry;
58
+ //# sourceMappingURL=replicate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replicate.d.ts","sourceRoot":"","sources":["../../../src/domain/hub/replicate.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,2BAA2B,EAC3B,sBAAsB,EACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EACV,SAAS,EACV,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,WAA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