@ai-primitives-hub/app 0.0.1-alpha.1

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 (206) hide show
  1. package/README.md +26 -0
  2. package/dist/collection/generate-skill.d.ts +43 -0
  3. package/dist/collection/generate-skill.d.ts.map +1 -0
  4. package/dist/collection/generate-skill.js +244 -0
  5. package/dist/collection/generate-skill.js.map +1 -0
  6. package/dist/collection/index.d.ts +8 -0
  7. package/dist/collection/index.d.ts.map +1 -0
  8. package/dist/collection/index.js +23 -0
  9. package/dist/collection/index.js.map +1 -0
  10. package/dist/collection/read-collection.d.ts +60 -0
  11. package/dist/collection/read-collection.d.ts.map +1 -0
  12. package/dist/collection/read-collection.js +291 -0
  13. package/dist/collection/read-collection.js.map +1 -0
  14. package/dist/context-detection/detector.d.ts +126 -0
  15. package/dist/context-detection/detector.d.ts.map +1 -0
  16. package/dist/context-detection/detector.js +408 -0
  17. package/dist/context-detection/detector.js.map +1 -0
  18. package/dist/context-detection/index.d.ts +11 -0
  19. package/dist/context-detection/index.d.ts.map +1 -0
  20. package/dist/context-detection/index.js +14 -0
  21. package/dist/context-detection/index.js.map +1 -0
  22. package/dist/context-detection/types.d.ts +74 -0
  23. package/dist/context-detection/types.d.ts.map +1 -0
  24. package/dist/context-detection/types.js +13 -0
  25. package/dist/context-detection/types.js.map +1 -0
  26. package/dist/discovery/index.d.ts +7 -0
  27. package/dist/discovery/index.d.ts.map +1 -0
  28. package/dist/discovery/index.js +23 -0
  29. package/dist/discovery/index.js.map +1 -0
  30. package/dist/discovery/profile-generator.d.ts +31 -0
  31. package/dist/discovery/profile-generator.d.ts.map +1 -0
  32. package/dist/discovery/profile-generator.js +55 -0
  33. package/dist/discovery/profile-generator.js.map +1 -0
  34. package/dist/discovery/recommendation-engine.d.ts +76 -0
  35. package/dist/discovery/recommendation-engine.d.ts.map +1 -0
  36. package/dist/discovery/recommendation-engine.js +210 -0
  37. package/dist/discovery/recommendation-engine.js.map +1 -0
  38. package/dist/index.d.ts +31 -0
  39. package/dist/index.d.ts.map +1 -0
  40. package/dist/index.js +49 -0
  41. package/dist/index.js.map +1 -0
  42. package/dist/install/index.d.ts +14 -0
  43. package/dist/install/index.d.ts.map +1 -0
  44. package/dist/install/index.js +20 -0
  45. package/dist/install/index.js.map +1 -0
  46. package/dist/install/install-bundle.d.ts +31 -0
  47. package/dist/install/install-bundle.d.ts.map +1 -0
  48. package/dist/install/install-bundle.js +23 -0
  49. package/dist/install/install-bundle.js.map +1 -0
  50. package/dist/install/layout-resolver.d.ts +31 -0
  51. package/dist/install/layout-resolver.d.ts.map +1 -0
  52. package/dist/install/layout-resolver.js +70 -0
  53. package/dist/install/layout-resolver.js.map +1 -0
  54. package/dist/install/pipeline.d.ts +111 -0
  55. package/dist/install/pipeline.d.ts.map +1 -0
  56. package/dist/install/pipeline.js +138 -0
  57. package/dist/install/pipeline.js.map +1 -0
  58. package/dist/install/uninstall-bundle.d.ts +36 -0
  59. package/dist/install/uninstall-bundle.d.ts.map +1 -0
  60. package/dist/install/uninstall-bundle.js +37 -0
  61. package/dist/install/uninstall-bundle.js.map +1 -0
  62. package/dist/install/uninstall-pipeline.d.ts +119 -0
  63. package/dist/install/uninstall-pipeline.d.ts.map +1 -0
  64. package/dist/install/uninstall-pipeline.js +187 -0
  65. package/dist/install/uninstall-pipeline.js.map +1 -0
  66. package/dist/registry/activate-registry-profile.d.ts +67 -0
  67. package/dist/registry/activate-registry-profile.d.ts.map +1 -0
  68. package/dist/registry/activate-registry-profile.js +150 -0
  69. package/dist/registry/activate-registry-profile.js.map +1 -0
  70. package/dist/registry/create-source-adapter.d.ts +43 -0
  71. package/dist/registry/create-source-adapter.d.ts.map +1 -0
  72. package/dist/registry/create-source-adapter.js +53 -0
  73. package/dist/registry/create-source-adapter.js.map +1 -0
  74. package/dist/registry/deactivate-registry-profile.d.ts +38 -0
  75. package/dist/registry/deactivate-registry-profile.d.ts.map +1 -0
  76. package/dist/registry/deactivate-registry-profile.js +45 -0
  77. package/dist/registry/deactivate-registry-profile.js.map +1 -0
  78. package/dist/registry/detect-updates.d.ts +12 -0
  79. package/dist/registry/detect-updates.d.ts.map +1 -0
  80. package/dist/registry/detect-updates.js +76 -0
  81. package/dist/registry/detect-updates.js.map +1 -0
  82. package/dist/registry/hub-manager.d.ts +229 -0
  83. package/dist/registry/hub-manager.d.ts.map +1 -0
  84. package/dist/registry/hub-manager.js +473 -0
  85. package/dist/registry/hub-manager.js.map +1 -0
  86. package/dist/registry/index.d.ts +23 -0
  87. package/dist/registry/index.d.ts.map +1 -0
  88. package/dist/registry/index.js +39 -0
  89. package/dist/registry/index.js.map +1 -0
  90. package/dist/registry/install-registry-bundle.d.ts +56 -0
  91. package/dist/registry/install-registry-bundle.d.ts.map +1 -0
  92. package/dist/registry/install-registry-bundle.js +150 -0
  93. package/dist/registry/install-registry-bundle.js.map +1 -0
  94. package/dist/registry/list-all-profiles.d.ts +27 -0
  95. package/dist/registry/list-all-profiles.d.ts.map +1 -0
  96. package/dist/registry/list-all-profiles.js +52 -0
  97. package/dist/registry/list-all-profiles.js.map +1 -0
  98. package/dist/registry/list-installed-bundles.d.ts +37 -0
  99. package/dist/registry/list-installed-bundles.d.ts.map +1 -0
  100. package/dist/registry/list-installed-bundles.js +27 -0
  101. package/dist/registry/list-installed-bundles.js.map +1 -0
  102. package/dist/registry/load-hub-sources.d.ts +56 -0
  103. package/dist/registry/load-hub-sources.d.ts.map +1 -0
  104. package/dist/registry/load-hub-sources.js +123 -0
  105. package/dist/registry/load-hub-sources.js.map +1 -0
  106. package/dist/registry/local-profile-crud.d.ts +58 -0
  107. package/dist/registry/local-profile-crud.d.ts.map +1 -0
  108. package/dist/registry/local-profile-crud.js +85 -0
  109. package/dist/registry/local-profile-crud.js.map +1 -0
  110. package/dist/registry/profile-lifecycle.d.ts +190 -0
  111. package/dist/registry/profile-lifecycle.d.ts.map +1 -0
  112. package/dist/registry/profile-lifecycle.js +400 -0
  113. package/dist/registry/profile-lifecycle.js.map +1 -0
  114. package/dist/registry/registry-settings.d.ts +32 -0
  115. package/dist/registry/registry-settings.d.ts.map +1 -0
  116. package/dist/registry/registry-settings.js +145 -0
  117. package/dist/registry/registry-settings.js.map +1 -0
  118. package/dist/registry/resolve-installation-bundle.d.ts +46 -0
  119. package/dist/registry/resolve-installation-bundle.d.ts.map +1 -0
  120. package/dist/registry/resolve-installation-bundle.js +98 -0
  121. package/dist/registry/resolve-installation-bundle.js.map +1 -0
  122. package/dist/registry/search-registry-bundles.d.ts +47 -0
  123. package/dist/registry/search-registry-bundles.d.ts.map +1 -0
  124. package/dist/registry/search-registry-bundles.js +129 -0
  125. package/dist/registry/search-registry-bundles.js.map +1 -0
  126. package/dist/registry/uninstall-installed-bundle.d.ts +48 -0
  127. package/dist/registry/uninstall-installed-bundle.d.ts.map +1 -0
  128. package/dist/registry/uninstall-installed-bundle.js +45 -0
  129. package/dist/registry/uninstall-installed-bundle.js.map +1 -0
  130. package/dist/registry/update-registry-bundle.d.ts +36 -0
  131. package/dist/registry/update-registry-bundle.d.ts.map +1 -0
  132. package/dist/registry/update-registry-bundle.js +113 -0
  133. package/dist/registry/update-registry-bundle.js.map +1 -0
  134. package/dist/registry/user-config-paths.d.ts +24 -0
  135. package/dist/registry/user-config-paths.d.ts.map +1 -0
  136. package/dist/registry/user-config-paths.js +82 -0
  137. package/dist/registry/user-config-paths.js.map +1 -0
  138. package/dist/registry/version-consolidator.d.ts +123 -0
  139. package/dist/registry/version-consolidator.d.ts.map +1 -0
  140. package/dist/registry/version-consolidator.js +231 -0
  141. package/dist/registry/version-consolidator.js.map +1 -0
  142. package/dist/search/export-profile.d.ts +63 -0
  143. package/dist/search/export-profile.d.ts.map +1 -0
  144. package/dist/search/export-profile.js +138 -0
  145. package/dist/search/export-profile.js.map +1 -0
  146. package/dist/search/index.d.ts +6 -0
  147. package/dist/search/index.d.ts.map +1 -0
  148. package/dist/search/index.js +22 -0
  149. package/dist/search/index.js.map +1 -0
  150. package/dist/stores/index.d.ts +8 -0
  151. package/dist/stores/index.d.ts.map +1 -0
  152. package/dist/stores/index.js +24 -0
  153. package/dist/stores/index.js.map +1 -0
  154. package/dist/stores/json-lockfile-store.d.ts +203 -0
  155. package/dist/stores/json-lockfile-store.d.ts.map +1 -0
  156. package/dist/stores/json-lockfile-store.js +277 -0
  157. package/dist/stores/json-lockfile-store.js.map +1 -0
  158. package/dist/transform/index.d.ts +10 -0
  159. package/dist/transform/index.d.ts.map +1 -0
  160. package/dist/transform/index.js +26 -0
  161. package/dist/transform/index.js.map +1 -0
  162. package/dist/transform/transformer-registry.d.ts +52 -0
  163. package/dist/transform/transformer-registry.d.ts.map +1 -0
  164. package/dist/transform/transformer-registry.js +53 -0
  165. package/dist/transform/transformer-registry.js.map +1 -0
  166. package/dist/transform/transformers/claude-code-transformer.d.ts +67 -0
  167. package/dist/transform/transformers/claude-code-transformer.d.ts.map +1 -0
  168. package/dist/transform/transformers/claude-code-transformer.js +140 -0
  169. package/dist/transform/transformers/claude-code-transformer.js.map +1 -0
  170. package/dist/transform/transformers/kiro-transformer.d.ts +51 -0
  171. package/dist/transform/transformers/kiro-transformer.d.ts.map +1 -0
  172. package/dist/transform/transformers/kiro-transformer.js +128 -0
  173. package/dist/transform/transformers/kiro-transformer.js.map +1 -0
  174. package/dist/transform/transformers/noop-transformer.d.ts +25 -0
  175. package/dist/transform/transformers/noop-transformer.d.ts.map +1 -0
  176. package/dist/transform/transformers/noop-transformer.js +20 -0
  177. package/dist/transform/transformers/noop-transformer.js.map +1 -0
  178. package/dist/transform/transformers/windsurf-transformer.d.ts +63 -0
  179. package/dist/transform/transformers/windsurf-transformer.d.ts.map +1 -0
  180. package/dist/transform/transformers/windsurf-transformer.js +125 -0
  181. package/dist/transform/transformers/windsurf-transformer.js.map +1 -0
  182. package/dist/update/auto-update.d.ts +84 -0
  183. package/dist/update/auto-update.d.ts.map +1 -0
  184. package/dist/update/auto-update.js +217 -0
  185. package/dist/update/auto-update.js.map +1 -0
  186. package/dist/update/check-updates.d.ts +51 -0
  187. package/dist/update/check-updates.d.ts.map +1 -0
  188. package/dist/update/check-updates.js +168 -0
  189. package/dist/update/check-updates.js.map +1 -0
  190. package/dist/update/index.d.ts +8 -0
  191. package/dist/update/index.d.ts.map +1 -0
  192. package/dist/update/index.js +24 -0
  193. package/dist/update/index.js.map +1 -0
  194. package/dist/update/log-event.d.ts +15 -0
  195. package/dist/update/log-event.d.ts.map +1 -0
  196. package/dist/update/log-event.js +11 -0
  197. package/dist/update/log-event.js.map +1 -0
  198. package/dist/writers/file-tree-writer.d.ts +136 -0
  199. package/dist/writers/file-tree-writer.d.ts.map +1 -0
  200. package/dist/writers/file-tree-writer.js +337 -0
  201. package/dist/writers/file-tree-writer.js.map +1 -0
  202. package/dist/writers/index.d.ts +7 -0
  203. package/dist/writers/index.d.ts.map +1 -0
  204. package/dist/writers/index.js +23 -0
  205. package/dist/writers/index.js.map +1 -0
  206. package/package.json +50 -0
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.installRegistryBundle = installRegistryBundle;
4
+ const core_1 = require("@ai-primitives-hub/core");
5
+ const resolve_installation_bundle_1 = require("./resolve-installation-bundle");
6
+ function log(onLog, level, message, error) {
7
+ onLog?.({ level, message, error });
8
+ }
9
+ /**
10
+ * Install a bundle: resolve it, check for an existing installation,
11
+ * resolve its source, download and install (or symlink, for
12
+ * local-skills), record the installation (skipped for repository
13
+ * scope, lockfile-tracked instead), and clean up superseded versions.
14
+ * @param bundleId - The bundle to install.
15
+ * @param options - Install options (scope, version, force, profileId, commitMode).
16
+ * @param ports - Injected read/write access to bundle/source data, adapters, and the installer.
17
+ * @param onLog - Optional sink for diagnostic log events.
18
+ * @returns The resulting installation record.
19
+ */
20
+ async function installRegistryBundle(bundleId, options, ports, onLog) {
21
+ log(onLog, 'info', `Installing bundle: ${bundleId}`);
22
+ const bundle = await (0, resolve_installation_bundle_1.resolveInstallationBundle)(bundleId, options, ports, onLog);
23
+ const installOptions = await checkExistingInstallation(bundleId, bundle, options, ports, onLog);
24
+ const source = await getSourceForBundle(bundle, ports);
25
+ const installation = await downloadAndInstall(bundle, source, installOptions, ports, onLog);
26
+ // Record installation FIRST (before cleanup) to ensure metadata is safe.
27
+ // If anything fails here, old versions remain and can be used as fallback.
28
+ // Note: Repository scope bundles are tracked via LockfileManager, not RegistryStorage;
29
+ // the lockfile is already updated by the installer during installation.
30
+ if (options.scope !== 'repository') {
31
+ await ports.recordInstallation(installation);
32
+ }
33
+ // Clean up old versions AFTER successful recording, so a failed cleanup
34
+ // never loses the newly-recorded installation.
35
+ await cleanupOldVersions(bundle, options.scope, ports, onLog);
36
+ log(onLog, 'info', `Bundle '${bundleId}' installed successfully`);
37
+ return installation;
38
+ }
39
+ /**
40
+ * Check existing installation and determine if installation should proceed.
41
+ * Returns modified options if a version change is detected.
42
+ * @param bundleId
43
+ * @param bundle
44
+ * @param options
45
+ * @param ports
46
+ * @param onLog
47
+ */
48
+ async function checkExistingInstallation(bundleId, bundle, options, ports, onLog) {
49
+ const existing = await ports.getInstalledBundle(bundleId, options.scope);
50
+ if (!existing || options.force) {
51
+ return options;
52
+ }
53
+ if (existing.version !== bundle.version) {
54
+ log(onLog, 'info', `Version change detected: ${existing.version} → ${bundle.version}`);
55
+ return { ...options, force: true };
56
+ }
57
+ throw new Error(`Bundle '${bundleId}' is already installed. Use force=true to reinstall.`);
58
+ }
59
+ async function getSourceForBundle(bundle, ports) {
60
+ const sources = await ports.listSources();
61
+ const source = sources.find((s) => s.id === bundle.sourceId);
62
+ if (!source) {
63
+ throw new Error(`Source '${bundle.sourceId}' not found`);
64
+ }
65
+ return source;
66
+ }
67
+ /**
68
+ * Download and install a bundle (or symlink it, for local-skills).
69
+ * @param bundle
70
+ * @param source
71
+ * @param options
72
+ * @param ports
73
+ * @param onLog
74
+ */
75
+ async function downloadAndInstall(bundle, source, options, ports, onLog) {
76
+ const adapter = ports.getAdapter(source);
77
+ // For local-skills, use symlink installation instead of copying
78
+ if (source.type === 'local-skills') {
79
+ log(onLog, 'debug', `Installing local skill as symlink from ${source.type} adapter`);
80
+ if (typeof adapter.getSkillSourcePath === 'function' && typeof adapter.getSkillName === 'function') {
81
+ const skillSourcePath = adapter.getSkillSourcePath(bundle);
82
+ const skillName = adapter.getSkillName(bundle);
83
+ const localSkillSymlink = await ports.installLocalSkillAsSymlink(bundle, skillName, skillSourcePath, options);
84
+ // Ensure sourceId and sourceType are set
85
+ localSkillSymlink.sourceId = bundle.sourceId;
86
+ localSkillSymlink.sourceType = source.type;
87
+ if (options.profileId) {
88
+ localSkillSymlink.profileId = options.profileId;
89
+ }
90
+ return localSkillSymlink;
91
+ }
92
+ // Fall through to standard installation if methods not available
93
+ log(onLog, 'warn', 'LocalSkillsAdapter missing symlink methods, falling back to standard installation');
94
+ }
95
+ // Unified download path: all adapters use downloadBundle()
96
+ log(onLog, 'debug', `Downloading bundle from ${source.type} adapter`);
97
+ const bundleBuffer = await adapter.downloadBundle(bundle);
98
+ log(onLog, 'debug', `Bundle downloaded: ${bundleBuffer.length} bytes`);
99
+ // Install from buffer
100
+ const installation = await ports.installFromBuffer(bundle, bundleBuffer, options, source.type);
101
+ // Add profileId if provided
102
+ if (options.profileId) {
103
+ installation.profileId = options.profileId;
104
+ }
105
+ // Ensure sourceId and sourceType are set for identity matching
106
+ installation.sourceId = bundle.sourceId;
107
+ installation.sourceType = source.type;
108
+ return installation;
109
+ }
110
+ /**
111
+ * Clean up old versions of a bundle when a new version is installed.
112
+ * Handles downgrades and version changes by removing previous
113
+ * installation records. Failures are logged, not thrown - the new
114
+ * version is already installed by the time this runs.
115
+ * @param bundle
116
+ * @param scope
117
+ * @param ports
118
+ * @param onLog
119
+ */
120
+ async function cleanupOldVersions(bundle, scope, ports, onLog) {
121
+ // Repository scope cleanup is handled by LockfileManager
122
+ if (scope === 'repository') {
123
+ return;
124
+ }
125
+ try {
126
+ const source = await getSourceForBundle(bundle, ports);
127
+ const sourceType = source.type;
128
+ const baseIdentity = (0, core_1.extractBundleIdentity)(bundle.id, sourceType);
129
+ // Get all installed bundles in this scope, filtered early by sourceId
130
+ const allInstalled = await ports.getInstalledBundles(scope);
131
+ const candidateBundles = allInstalled.filter((installed) => installed.sourceId === bundle.sourceId);
132
+ // Find all installations that match this bundle's identity
133
+ const oldInstallations = candidateBundles.filter((installed) => {
134
+ const installedSourceType = installed.sourceType || 'github';
135
+ return (0, core_1.isSameBundleIdentity)(installed.bundleId, installedSourceType, bundle.id, sourceType)
136
+ && installed.version !== bundle.version;
137
+ });
138
+ for (const oldInstall of oldInstallations) {
139
+ log(onLog, 'debug', `Removing old version ${oldInstall.version} of bundle ${baseIdentity}`);
140
+ await ports.removeInstallation(oldInstall.bundleId, scope);
141
+ }
142
+ if (oldInstallations.length > 0) {
143
+ log(onLog, 'info', `Cleaned up ${oldInstallations.length} old version(s) of bundle ${baseIdentity}`);
144
+ }
145
+ }
146
+ catch (error) {
147
+ log(onLog, 'warn', `Failed to cleanup old versions: ${error instanceof Error ? error.message : String(error)}`);
148
+ }
149
+ }
150
+ //# sourceMappingURL=install-registry-bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install-registry-bundle.js","sourceRoot":"","sources":["../../src/registry/install-registry-bundle.ts"],"names":[],"mappings":";;AAiFA,sDA4BC;AArFD,kDAGiC;AAQjC,+EAEuC;AA6BvC,SAAS,GAAG,CAAC,KAA6B,EAAE,KAAwB,EAAE,OAAe,EAAE,KAAa;IAClG,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;AACrC,CAAC;AAED;;;;;;;;;;GAUG;AACI,KAAK,UAAU,qBAAqB,CACzC,QAAgB,EAChB,OAAuB,EACvB,KAAiC,EACjC,KAAkB;IAElB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,sBAAsB,QAAQ,EAAE,CAAC,CAAC;IAErD,MAAM,MAAM,GAAG,MAAM,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CAAC,MAAM,6BAA6B,YAAY,EAAE,CAAC,CAAC;QACvG,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,mCAAmC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAClH,CAAC;AACH,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Merge hub-provided and local profiles into one list — ported from
3
+ * `src/services/registry-manager.ts`'s `listProfiles`/`isHubProfile`.
4
+ * Part of the `RegistryManager` scoping pass's slice 6 (migration plan
5
+ * §7.5 item 3).
6
+ * @module registry/list-all-profiles
7
+ */
8
+ import type { HubProfileReader, Profile, ProfileStore } from '@ai-primitives-hub/core';
9
+ import type { OnLogEvent } from '../update/log-event';
10
+ /**
11
+ * Whether a profile id belongs to the active hub's profiles.
12
+ * @param hub Hub profile reader, or `undefined` when no `HubManager` is wired.
13
+ * @param profileId Profile identifier to check.
14
+ * @returns `true` iff a hub profile with this id is currently active.
15
+ */
16
+ export declare function isHubProfile(hub: HubProfileReader | undefined, profileId: string): Promise<boolean>;
17
+ /**
18
+ * List every profile — hub-provided profiles from the active hub
19
+ * (decorated with `active` re-derived from the activation store, and a
20
+ * default 📦 icon when none is set) followed by local profiles.
21
+ * @param store Local profile storage.
22
+ * @param hub Hub profile reader, or `undefined` when no `HubManager` is wired.
23
+ * @param onLog Optional sink for diagnostic log events.
24
+ * @returns All profiles, hub-provided first.
25
+ */
26
+ export declare function listAllProfiles(store: ProfileStore, hub: HubProfileReader | undefined, onLog?: OnLogEvent): Promise<Profile[]>;
27
+ //# sourceMappingURL=list-all-profiles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-all-profiles.d.ts","sourceRoot":"","sources":["../../src/registry/list-all-profiles.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,gBAAgB,EAChB,OAAO,EACP,YAAY,EACb,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAEV,UAAU,EACX,MAAM,qBAAqB,CAAC;AAM7B;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,gBAAgB,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOzG;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,KAAK,EAAE,YAAY,EACnB,GAAG,EAAE,gBAAgB,GAAG,SAAS,EACjC,KAAK,CAAC,EAAE,UAAU,GACjB,OAAO,CAAC,OAAO,EAAE,CAAC,CAwBpB"}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isHubProfile = isHubProfile;
4
+ exports.listAllProfiles = listAllProfiles;
5
+ function log(onLog, level, message, error) {
6
+ onLog?.({ level, message, error });
7
+ }
8
+ /**
9
+ * Whether a profile id belongs to the active hub's profiles.
10
+ * @param hub Hub profile reader, or `undefined` when no `HubManager` is wired.
11
+ * @param profileId Profile identifier to check.
12
+ * @returns `true` iff a hub profile with this id is currently active.
13
+ */
14
+ async function isHubProfile(hub, profileId) {
15
+ if (!hub) {
16
+ return false;
17
+ }
18
+ const hubProfiles = await hub.listActiveHubProfiles();
19
+ return hubProfiles.some((p) => p.id === profileId);
20
+ }
21
+ /**
22
+ * List every profile — hub-provided profiles from the active hub
23
+ * (decorated with `active` re-derived from the activation store, and a
24
+ * default 📦 icon when none is set) followed by local profiles.
25
+ * @param store Local profile storage.
26
+ * @param hub Hub profile reader, or `undefined` when no `HubManager` is wired.
27
+ * @param onLog Optional sink for diagnostic log events.
28
+ * @returns All profiles, hub-provided first.
29
+ */
30
+ async function listAllProfiles(store, hub, onLog) {
31
+ const allProfiles = [];
32
+ if (hub) {
33
+ try {
34
+ const hubProfiles = await hub.listActiveHubProfiles();
35
+ const activeProfiles = await hub.listAllActiveProfiles();
36
+ const activeProfileIds = new Set(activeProfiles.map((ap) => ap.profileId));
37
+ const convertedHubProfiles = hubProfiles.map((hp) => ({
38
+ ...hp,
39
+ icon: hp.icon || '📦',
40
+ active: activeProfileIds.has(hp.id)
41
+ }));
42
+ allProfiles.push(...convertedHubProfiles);
43
+ }
44
+ catch (error) {
45
+ log(onLog, 'warn', 'Failed to get hub profiles', error instanceof Error ? error : new Error(String(error)));
46
+ }
47
+ }
48
+ const localProfiles = await store.getProfiles();
49
+ allProfiles.push(...localProfiles);
50
+ return allProfiles;
51
+ }
52
+ //# sourceMappingURL=list-all-profiles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-all-profiles.js","sourceRoot":"","sources":["../../src/registry/list-all-profiles.ts"],"names":[],"mappings":";;AA2BA,oCAOC;AAWD,0CA4BC;AAxDD,SAAS,GAAG,CAAC,KAA6B,EAAE,KAAwB,EAAE,OAAe,EAAE,KAAa;IAClG,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;AACrC,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,YAAY,CAAC,GAAiC,EAAE,SAAiB;IACrF,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,qBAAqB,EAAE,CAAC;IACtD,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC;AACrD,CAAC;AAED;;;;;;;;GAQG;AACI,KAAK,UAAU,eAAe,CACnC,KAAmB,EACnB,GAAiC,EACjC,KAAkB;IAElB,MAAM,WAAW,GAAc,EAAE,CAAC;IAElC,IAAI,GAAG,EAAE,CAAC;QACR,IAAI,CAAC;YACH,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,qBAAqB,EAAE,CAAC;YACtD,MAAM,cAAc,GAAG,MAAM,GAAG,CAAC,qBAAqB,EAAE,CAAC;YACzD,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;YAE3E,MAAM,oBAAoB,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;gBACpD,GAAG,EAAE;gBACL,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,IAAI;gBACrB,MAAM,EAAE,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;aACpC,CAAC,CAAC,CAAC;YACJ,WAAW,CAAC,IAAI,CAAC,GAAG,oBAAoB,CAAC,CAAC;QAC5C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,4BAA4B,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC9G,CAAC;IACH,CAAC;IAED,MAAM,aAAa,GAAG,MAAM,KAAK,CAAC,WAAW,EAAE,CAAC;IAChD,WAAW,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC;IAEnC,OAAO,WAAW,CAAC;AACrB,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * List installed bundles across scopes — ported from the extension's
3
+ * `src/services/registry-manager.ts`
4
+ * (`RegistryManager.listInstalledBundles`).
5
+ *
6
+ * Repository-scoped installs are lockfile-backed (via `LockfileManager`,
7
+ * not yet ported — see the migration plan's `RegistryManager` scoping
8
+ * pass) so this module only orchestrates *which* store(s) to query for
9
+ * a given scope; the actual repository-bundle read, including resolving
10
+ * the workspace root and tolerating a missing/unreadable lockfile, is a
11
+ * caller-supplied port kept deliberately opaque here (see
12
+ * `ListInstalledBundlesPorts.getRepositoryInstalledBundles`).
13
+ * @module registry/list-installed-bundles
14
+ */
15
+ import type { InstallationScope, InstalledBundle } from '@ai-primitives-hub/core';
16
+ /**
17
+ * Read access `listInstalledBundles` needs: user/workspace installs
18
+ * (the extension's `RegistryStorage`) and repository installs (the
19
+ * extension's lockfile-backed adapter). Kept as two separate methods
20
+ * rather than a single `getInstalledBundles(scope)` covering all three
21
+ * scopes, since the two backing stores are unrelated today.
22
+ */
23
+ export interface ListInstalledBundlesPorts {
24
+ getInstalledBundles(scope?: InstallationScope): Promise<InstalledBundle[]>;
25
+ getRepositoryInstalledBundles(): Promise<InstalledBundle[]>;
26
+ }
27
+ /**
28
+ * List installed bundles, combining the storage port (user/workspace)
29
+ * and the repository port depending on `scope`:
30
+ * - `'repository'`: repository installs only.
31
+ * - `'user'` | `'workspace'`: that scope's storage installs only.
32
+ * - `undefined`: both storage (all scopes) and repository installs.
33
+ * @param scope - Scope filter, or `undefined` to combine all scopes.
34
+ * @param ports - Read access to both backing stores.
35
+ */
36
+ export declare function listInstalledBundles(scope: InstallationScope | undefined, ports: ListInstalledBundlesPorts): Promise<InstalledBundle[]>;
37
+ //# sourceMappingURL=list-installed-bundles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-installed-bundles.d.ts","sourceRoot":"","sources":["../../src/registry/list-installed-bundles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EAChB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;GAMG;AACH,MAAM,WAAW,yBAAyB;IACxC,mBAAmB,CAAC,KAAK,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAC3E,6BAA6B,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;CAC7D;AAED;;;;;;;;GAQG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,iBAAiB,GAAG,SAAS,EACpC,KAAK,EAAE,yBAAyB,GAC/B,OAAO,CAAC,eAAe,EAAE,CAAC,CAgB5B"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listInstalledBundles = listInstalledBundles;
4
+ /**
5
+ * List installed bundles, combining the storage port (user/workspace)
6
+ * and the repository port depending on `scope`:
7
+ * - `'repository'`: repository installs only.
8
+ * - `'user'` | `'workspace'`: that scope's storage installs only.
9
+ * - `undefined`: both storage (all scopes) and repository installs.
10
+ * @param scope - Scope filter, or `undefined` to combine all scopes.
11
+ * @param ports - Read access to both backing stores.
12
+ */
13
+ async function listInstalledBundles(scope, ports) {
14
+ const bundles = [];
15
+ // Query user/workspace bundles from the storage port
16
+ if (scope !== 'repository') {
17
+ const storageBundles = await ports.getInstalledBundles(scope);
18
+ bundles.push(...storageBundles);
19
+ }
20
+ // Query repository bundles from the repository port
21
+ if (scope === 'repository' || scope === undefined) {
22
+ const repoBundles = await ports.getRepositoryInstalledBundles();
23
+ bundles.push(...repoBundles);
24
+ }
25
+ return bundles;
26
+ }
27
+ //# sourceMappingURL=list-installed-bundles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-installed-bundles.js","sourceRoot":"","sources":["../../src/registry/list-installed-bundles.ts"],"names":[],"mappings":";;AAwCA,oDAmBC;AA5BD;;;;;;;;GAQG;AACI,KAAK,UAAU,oBAAoB,CACxC,KAAoC,EACpC,KAAgC;IAEhC,MAAM,OAAO,GAAsB,EAAE,CAAC;IAEtC,qDAAqD;IACrD,IAAI,KAAK,KAAK,YAAY,EAAE,CAAC;QAC3B,MAAM,cAAc,GAAG,MAAM,KAAK,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAC9D,OAAO,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC;IAClC,CAAC;IAED,oDAAoD;IACpD,IAAI,KAAK,KAAK,YAAY,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAClD,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,6BAA6B,EAAE,CAAC;QAChE,OAAO,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC;IAC/B,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Hub source-loading/dedup — ported from the extension's
3
+ * `src/services/hub-manager.ts` (`HubManager.loadHubSources`/
4
+ * `findDuplicateSource`). Stage 2 of the staged HubManager port
5
+ * (migration plan §7.5, HubManager item; see `hub-manager.ts`'s
6
+ * module doc for the full stage list).
7
+ *
8
+ * Converts a hub's declared `HubSource[]` into `RegistrySource`
9
+ * entries and syncs them into the registry: skips disabled sources,
10
+ * updates sources that already carry the same stable id (re-import/
11
+ * sync of the same hub), skips true duplicates (same url/type/branch/
12
+ * collectionsPath under a different id — e.g. added independently
13
+ * before hub adoption, or shared across two hubs), and adds
14
+ * everything else as new.
15
+ *
16
+ * SourceId format: `generateSourceId(type, url, config)` produces
17
+ * `{type}-{12-char-hash}`, based on source properties rather than the
18
+ * hub id, so lockfiles stay portable across different hub
19
+ * configurations. Legacy hub-prefixed ids (`hub-{hubId}-{sourceId}`)
20
+ * continue to work since duplicate detection matches on url/type/
21
+ * branch/collectionsPath, not id.
22
+ * @module registry/load-hub-sources
23
+ */
24
+ import type { HubSource, HubSourceSync, RegistrySource } from '@ai-primitives-hub/core';
25
+ import type { OnLogEvent } from '../update/log-event';
26
+ export interface LoadHubSourcesResult {
27
+ added: number;
28
+ updated: number;
29
+ skipped: number;
30
+ }
31
+ /**
32
+ * Check if a hub source is a duplicate of an already-registered
33
+ * source, based on type + url + branch + collectionsPath (not id
34
+ * matching, so it tolerates both the new stable-hash id format and
35
+ * legacy hub-prefixed ids).
36
+ * @param source Candidate hub source.
37
+ * @param existingSources Already-registered sources to compare against.
38
+ * @returns The matching existing source, or undefined.
39
+ */
40
+ export declare function findDuplicateSource(source: HubSource, existingSources: RegistrySource[]): RegistrySource | undefined;
41
+ /**
42
+ * Sync a hub's declared sources into the registry.
43
+ *
44
+ * Per-source `addSource` failures (e.g. a private repo returning 404)
45
+ * are caught, logged, and skipped rather than failing the whole
46
+ * operation — a hub with one bad source should still get its other
47
+ * sources loaded. `listSources`/`updateSource` failures are not
48
+ * caught here; they propagate to the caller.
49
+ * @param hubId Hub identifier the sources belong to.
50
+ * @param hubSources Sources declared in the hub's config.
51
+ * @param ports Registry read/write access.
52
+ * @param onLog Optional sink for diagnostic log events.
53
+ * @returns Counts of added/updated/skipped sources.
54
+ */
55
+ export declare function loadHubSources(hubId: string, hubSources: HubSource[], ports: HubSourceSync, onLog?: OnLogEvent): Promise<LoadHubSourcesResult>;
56
+ //# sourceMappingURL=load-hub-sources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-hub-sources.d.ts","sourceRoot":"","sources":["../../src/registry/load-hub-sources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,cAAc,EACf,MAAM,yBAAyB,CAAC;AAIjC,OAAO,KAAK,EAEV,UAAU,EACX,MAAM,qBAAqB,CAAC;AAE7B,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,EACjB,eAAe,EAAE,cAAc,EAAE,GAChC,cAAc,GAAG,SAAS,CAuB5B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,cAAc,CAClC,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,SAAS,EAAE,EACvB,KAAK,EAAE,aAAa,EACpB,KAAK,CAAC,EAAE,UAAU,GACjB,OAAO,CAAC,oBAAoB,CAAC,CA4F/B"}
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findDuplicateSource = findDuplicateSource;
4
+ exports.loadHubSources = loadHubSources;
5
+ const core_1 = require("@ai-primitives-hub/core");
6
+ /**
7
+ * Check if a hub source is a duplicate of an already-registered
8
+ * source, based on type + url + branch + collectionsPath (not id
9
+ * matching, so it tolerates both the new stable-hash id format and
10
+ * legacy hub-prefixed ids).
11
+ * @param source Candidate hub source.
12
+ * @param existingSources Already-registered sources to compare against.
13
+ * @returns The matching existing source, or undefined.
14
+ */
15
+ function findDuplicateSource(source, existingSources) {
16
+ return existingSources.find((existing) => {
17
+ if (existing.type !== source.type || existing.url !== source.url) {
18
+ return false;
19
+ }
20
+ const existingConfig = existing.config ?? {};
21
+ const sourceConfig = source.config ?? {};
22
+ const existingBranch = existingConfig.branch ?? 'main';
23
+ const sourceBranch = sourceConfig.branch ?? 'main';
24
+ if (existingBranch !== sourceBranch) {
25
+ return false;
26
+ }
27
+ const existingPath = existingConfig.collectionsPath ?? 'collections';
28
+ const sourcePath = sourceConfig.collectionsPath ?? 'collections';
29
+ if (existingPath !== sourcePath) {
30
+ return false;
31
+ }
32
+ return true;
33
+ });
34
+ }
35
+ /**
36
+ * Sync a hub's declared sources into the registry.
37
+ *
38
+ * Per-source `addSource` failures (e.g. a private repo returning 404)
39
+ * are caught, logged, and skipped rather than failing the whole
40
+ * operation — a hub with one bad source should still get its other
41
+ * sources loaded. `listSources`/`updateSource` failures are not
42
+ * caught here; they propagate to the caller.
43
+ * @param hubId Hub identifier the sources belong to.
44
+ * @param hubSources Sources declared in the hub's config.
45
+ * @param ports Registry read/write access.
46
+ * @param onLog Optional sink for diagnostic log events.
47
+ * @returns Counts of added/updated/skipped sources.
48
+ */
49
+ async function loadHubSources(hubId, hubSources, ports, onLog) {
50
+ const log = (level, message, error) => {
51
+ onLog?.({ level, message, error });
52
+ };
53
+ log('info', `Found ${hubSources.length} sources in hub ${hubId}`);
54
+ const existingSources = await ports.listSources();
55
+ let added = 0;
56
+ let updated = 0;
57
+ let skipped = 0;
58
+ for (const hubSource of hubSources) {
59
+ if (!hubSource.enabled) {
60
+ log('debug', `Skipping disabled source: ${hubSource.id}`);
61
+ skipped++;
62
+ continue;
63
+ }
64
+ const sourceId = (0, core_1.generateSourceId)(hubSource.type, hubSource.url, {
65
+ branch: hubSource.config?.branch,
66
+ collectionsPath: hubSource.config?.collectionsPath
67
+ });
68
+ const existingSourceById = existingSources.find((s) => s.id === sourceId);
69
+ if (existingSourceById) {
70
+ log('info', `Updating existing hub source: ${sourceId}`);
71
+ await ports.updateSource(sourceId, {
72
+ name: hubSource.name,
73
+ type: hubSource.type,
74
+ url: hubSource.url,
75
+ enabled: hubSource.enabled,
76
+ priority: hubSource.priority,
77
+ private: hubSource.private,
78
+ token: hubSource.token,
79
+ metadata: hubSource.metadata,
80
+ config: hubSource.config,
81
+ hubId
82
+ });
83
+ updated++;
84
+ continue;
85
+ }
86
+ const duplicateSource = findDuplicateSource(hubSource, existingSources);
87
+ if (duplicateSource) {
88
+ log('info', `Skipping duplicate source: ${hubSource.name} `
89
+ + `(already exists as "${duplicateSource.name}" with ID: ${duplicateSource.id})`);
90
+ log('debug', `Duplicate detected - URL: ${hubSource.url}, `
91
+ + `Branch: ${hubSource.config?.branch ?? 'main'}, `
92
+ + `CollectionsPath: ${hubSource.config?.collectionsPath ?? 'collections'}`);
93
+ skipped++;
94
+ continue;
95
+ }
96
+ log('info', `Adding new hub source: ${sourceId} (${hubSource.name})`);
97
+ const registrySource = {
98
+ id: sourceId,
99
+ name: hubSource.name,
100
+ type: hubSource.type,
101
+ url: hubSource.url,
102
+ enabled: hubSource.enabled,
103
+ priority: hubSource.priority,
104
+ private: hubSource.private,
105
+ token: hubSource.token,
106
+ metadata: hubSource.metadata,
107
+ config: hubSource.config,
108
+ hubId
109
+ };
110
+ try {
111
+ await ports.addSource(registrySource);
112
+ added++;
113
+ }
114
+ catch (sourceError) {
115
+ const err = sourceError instanceof Error ? sourceError : new Error(String(sourceError));
116
+ log('warn', `Failed to add hub source ${sourceId} (${hubSource.name}): ${err.message}`, err);
117
+ skipped++;
118
+ }
119
+ }
120
+ log('info', `Hub source loading complete for ${hubId}: ${added} added, ${updated} updated, ${skipped} skipped`);
121
+ return { added, updated, skipped };
122
+ }
123
+ //# sourceMappingURL=load-hub-sources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-hub-sources.js","sourceRoot":"","sources":["../../src/registry/load-hub-sources.ts"],"names":[],"mappings":";;AAmDA,kDA0BC;AAgBD,wCAiGC;AAlKD,kDAEiC;AAYjC;;;;;;;;GAQG;AACH,SAAgB,mBAAmB,CACjC,MAAiB,EACjB,eAAiC;IAEjC,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;QACvC,IAAI,QAAQ,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,IAAI,QAAQ,CAAC,GAAG,KAAK,MAAM,CAAC,GAAG,EAAE,CAAC;YACjE,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,IAAI,EAAE,CAAC;QAC7C,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC;QAEzC,MAAM,cAAc,GAAG,cAAc,CAAC,MAAM,IAAI,MAAM,CAAC;QACvD,MAAM,YAAY,GAAG,YAAY,CAAC,MAAM,IAAI,MAAM,CAAC;QACnD,IAAI,cAAc,KAAK,YAAY,EAAE,CAAC;YACpC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,YAAY,GAAG,cAAc,CAAC,eAAe,IAAI,aAAa,CAAC;QACrE,MAAM,UAAU,GAAG,YAAY,CAAC,eAAe,IAAI,aAAa,CAAC;QACjE,IAAI,YAAY,KAAK,UAAU,EAAE,CAAC;YAChC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;GAaG;AACI,KAAK,UAAU,cAAc,CACl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;YACtB,QAAQ,EAAE,SAAS,CAAC,QAAQ;YAC5B,MAAM,EAAE,SAAS,CAAC,MAAM;YACxB,KAAK;SACN,CAAC;QAEF,IAAI,CAAC;YACH,MAAM,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;YACtC,KAAK,EAAE,CAAC;QACV,CAAC;QAAC,OAAO,WAAW,EAAE,CAAC;YACrB,MAAM,GAAG,GAAG,WAAW,YAAY,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;YACxF,GAAG,CAAC,MAAM,EAAE,4BAA4B,QAAQ,KAAK,SAAS,CAAC,IAAI,MAAM,GAAG,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,CAAC;YAC7F,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;IAED,GAAG,CAAC,MAAM,EAAE,mCAAmC,KAAK,KAAK,KAAK,WAAW,OAAO,aAAa,OAAO,UAAU,CAAC,CAAC;IAEhH,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AACrC,CAAC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * CRUD for the extension's local (non-hub) profiles — ported from
3
+ * `src/services/registry-manager.ts`'s `createProfile`/`updateProfile`/
4
+ * `deleteProfile`/`listLocalProfiles`/`exportProfile`/`importProfile`.
5
+ * Part of the `RegistryManager` scoping pass's slice 6 (profile/hub/
6
+ * settings cluster — migration plan §7.5 item 3).
7
+ *
8
+ * Deliberately excludes event firing (`_onProfileCreated`/`Updated`/
9
+ * `Deleted`): mirrors every other `registry/*` use-case in this
10
+ * package — the extension's thin wrapper fires its own
11
+ * `vscode.EventEmitter`s from these functions' return values.
12
+ * @module registry/local-profile-crud
13
+ */
14
+ import type { Profile, ProfileStore } from '@ai-primitives-hub/core';
15
+ /**
16
+ * Create a new local profile, stamping `createdAt`/`updatedAt`.
17
+ * @param store Local profile storage.
18
+ * @param profile The profile to create (timestamps are set here).
19
+ * @returns The created profile, including its stamped timestamps.
20
+ */
21
+ export declare function createLocalProfile(store: ProfileStore, profile: Omit<Profile, 'createdAt' | 'updatedAt'>): Promise<Profile>;
22
+ /**
23
+ * Update a local profile, stamping a new `updatedAt`.
24
+ * @param store Local profile storage.
25
+ * @param profileId Profile to update.
26
+ * @param updates Partial fields to merge in.
27
+ * @returns The updated profile, or `undefined` if it could not be
28
+ * found afterward (mirrors the original's conditional event-fire).
29
+ */
30
+ export declare function updateLocalProfile(store: ProfileStore, profileId: string, updates: Partial<Profile>): Promise<Profile | undefined>;
31
+ /**
32
+ * Delete a local profile.
33
+ * @param store Local profile storage.
34
+ * @param profileId Profile to delete.
35
+ */
36
+ export declare function deleteLocalProfile(store: ProfileStore, profileId: string): Promise<void>;
37
+ /**
38
+ * List only local profiles (excludes hub-provided ones).
39
+ * @param store Local profile storage.
40
+ * @returns All local profiles.
41
+ */
42
+ export declare function listLocalProfiles(store: ProfileStore): Promise<Profile[]>;
43
+ /**
44
+ * Serialize a single local profile as pretty-printed JSON.
45
+ * @param store Local profile storage.
46
+ * @param profileId Profile to export.
47
+ * @returns The serialized profile.
48
+ */
49
+ export declare function exportLocalProfile(store: ProfileStore, profileId: string): Promise<string>;
50
+ /**
51
+ * Import a single local profile from JSON, resetting its timestamps
52
+ * and forcing it inactive.
53
+ * @param store Local profile storage.
54
+ * @param profileData Serialized profile JSON.
55
+ * @returns The imported profile.
56
+ */
57
+ export declare function importLocalProfile(store: ProfileStore, profileData: string): Promise<Profile>;
58
+ //# sourceMappingURL=local-profile-crud.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-profile-crud.d.ts","sourceRoot":"","sources":["../../src/registry/local-profile-crud.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EACV,OAAO,EACP,YAAY,EACb,MAAM,yBAAyB,CAAC;AAEjC;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,WAAW,CAAC,GAChD,OAAO,CAAC,OAAO,CAAC,CAUlB;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GACxB,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAQ9B;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE9F;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAE/E;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAShG;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAUnG"}