@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,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.uninstallInstalledBundle = uninstallInstalledBundle;
4
+ /**
5
+ * Uninstall a single installed bundle: locate its installation record,
6
+ * remove its files (symlink removal for local-skills, the generic
7
+ * uninstall port otherwise), and clear the installation record (skipped
8
+ * for repository scope, whose lockfile is already updated by the
9
+ * `uninstall`/`uninstallSkillSymlink` port call itself).
10
+ * @param bundleId - The bundle to uninstall.
11
+ * @param scope - Installation scope to uninstall from.
12
+ * @param ports - Injected read/write access to storage, sources, and the installer.
13
+ * @param onLog - Optional sink for diagnostic log events.
14
+ * @returns The installation record that was removed.
15
+ */
16
+ async function uninstallInstalledBundle(bundleId, scope, ports, onLog) {
17
+ const log = (level, message, error) => {
18
+ onLog?.({ level, message, error });
19
+ };
20
+ log('info', `Uninstalling bundle: ${bundleId}`);
21
+ const installed = scope === 'repository'
22
+ ? (await ports.getRepositoryInstalledBundles()).find((b) => b.bundleId === bundleId)
23
+ : await ports.getInstalledBundle(bundleId, scope);
24
+ if (!installed) {
25
+ throw new Error(`Bundle '${bundleId}' is not installed in ${scope} scope`);
26
+ }
27
+ let source;
28
+ if (installed.sourceId) {
29
+ const sources = await ports.listSources();
30
+ source = sources.find((s) => s.id === installed.sourceId);
31
+ }
32
+ if (installed.sourceType === 'local-skills' || source?.type === 'local-skills') {
33
+ log('debug', `Uninstalling local skill symlink: ${bundleId}`);
34
+ await ports.uninstallSkillSymlink(installed);
35
+ }
36
+ else {
37
+ await ports.uninstall(installed);
38
+ }
39
+ if (scope !== 'repository') {
40
+ await ports.removeInstallation(installed.bundleId, scope);
41
+ }
42
+ log('info', `Bundle '${installed.bundleId}' uninstalled successfully`);
43
+ return installed;
44
+ }
45
+ //# sourceMappingURL=uninstall-installed-bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uninstall-installed-bundle.js","sourceRoot":"","sources":["../../src/registry/uninstall-installed-bundle.ts"],"names":[],"mappings":";;AAuDA,4DAuCC;AAnDD;;;;;;;;;;;GAWG;AACI,KAAK,UAAU,wBAAwB,CAC5C,QAAgB,EAChB,KAAwB,EACxB,KAAoC,EACpC,KAAkB;IAElB,MAAM,GAAG,GAAG,CAAC,KAAwB,EAAE,OAAe,EAAE,KAAa,EAAQ,EAAE;QAC7E,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IACrC,CAAC,CAAC;IAEF,GAAG,CAAC,MAAM,EAAE,wBAAwB,QAAQ,EAAE,CAAC,CAAC;IAEhD,MAAM,SAAS,GAAG,KAAK,KAAK,YAAY;QACtC,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,6BAA6B,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC;QACpF,CAAC,CAAC,MAAM,KAAK,CAAC,kBAAkB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAEpD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,WAAW,QAAQ,yBAAyB,KAAK,QAAQ,CAAC,CAAC;IAC7E,CAAC;IAED,IAAI,MAAkC,CAAC;IACvC,IAAI,SAAS,CAAC,QAAQ,EAAE,CAAC;QACvB,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,WAAW,EAAE,CAAC;QAC1C,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,SAAS,CAAC,QAAQ,CAAC,CAAC;IAC5D,CAAC;IAED,IAAI,SAAS,CAAC,UAAU,KAAK,cAAc,IAAI,MAAM,EAAE,IAAI,KAAK,cAAc,EAAE,CAAC;QAC/E,GAAG,CAAC,OAAO,EAAE,qCAAqC,QAAQ,EAAE,CAAC,CAAC;QAC9D,MAAM,KAAK,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAC/C,CAAC;SAAM,CAAC;QACN,MAAM,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IACnC,CAAC;IAED,IAAI,KAAK,KAAK,YAAY,EAAE,CAAC;QAC3B,MAAM,KAAK,CAAC,kBAAkB,CAAC,SAAS,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC5D,CAAC;IAED,GAAG,CAAC,MAAM,EAAE,WAAW,SAAS,CAAC,QAAQ,4BAA4B,CAAC,CAAC;IACvE,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Update an installed bundle — ported from the extension's
3
+ * `src/services/registry-manager.ts` (`RegistryManager.updateBundle`).
4
+ *
5
+ * The interactive "local modifications" warning dialog
6
+ * (`checkLocalModificationsBeforeUpdate` in the original) stays
7
+ * entirely in the extension — it drives VS Code warning dialogs and
8
+ * `LockfileManager`, neither of which are portable — and is injected
9
+ * here as the optional `checkLocalModifications` port, called at the
10
+ * exact point in the sequence the original called it: after resolving
11
+ * the current installation, before resolving the new bundle version.
12
+ * @module registry/update-registry-bundle
13
+ */
14
+ import type { Bundle, InstallationScope, InstalledBundle, RegistrySource, SourceAdapter, SourceType } from '@ai-primitives-hub/core';
15
+ import type { OnLogEvent } from '../update/log-event';
16
+ /** Read/write access `updateRegistryBundle` needs. */
17
+ export interface UpdateRegistryBundlePorts {
18
+ listInstalledBundles(): Promise<InstalledBundle[]>;
19
+ checkLocalModifications?(bundleId: string, current: InstalledBundle): Promise<void>;
20
+ getBundleDetails(bundleId: string): Promise<Bundle>;
21
+ listSources(): Promise<RegistrySource[]>;
22
+ getAdapter(source: RegistrySource): SourceAdapter;
23
+ updateInstalledBundle(current: InstalledBundle, bundle: Bundle, bundleBuffer: Buffer, sourceType: SourceType): Promise<InstalledBundle>;
24
+ recordInstallation(installation: InstalledBundle): Promise<void>;
25
+ removeInstallation(bundleId: string, scope: InstallationScope): Promise<void>;
26
+ }
27
+ /**
28
+ * Update an installed bundle to the latest (or a specific) version.
29
+ * @param bundleId - The currently-installed bundle to update.
30
+ * @param version - Optional specific version to update to; defaults to latest.
31
+ * @param ports - Injected read/write access to installed bundles, sources, adapters, and the installer.
32
+ * @param onLog - Optional sink for diagnostic log events.
33
+ * @returns The resulting installation record.
34
+ */
35
+ export declare function updateRegistryBundle(bundleId: string, version: string | undefined, ports: UpdateRegistryBundlePorts, onLog?: OnLogEvent): Promise<InstalledBundle>;
36
+ //# sourceMappingURL=update-registry-bundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-registry-bundle.d.ts","sourceRoot":"","sources":["../../src/registry/update-registry-bundle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EACV,MAAM,EACN,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,aAAa,EACb,UAAU,EACX,MAAM,yBAAyB,CAAC;AAIjC,OAAO,KAAK,EAEV,UAAU,EACX,MAAM,qBAAqB,CAAC;AAE7B,sDAAsD;AACtD,MAAM,WAAW,yBAAyB;IACxC,oBAAoB,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IACnD,uBAAuB,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpF,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACpD,WAAW,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IACzC,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,aAAa,CAAC;IAClD,qBAAqB,CAAC,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IACxI,kBAAkB,CAAC,YAAY,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/E;AAMD;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,KAAK,EAAE,yBAAyB,EAChC,KAAK,CAAC,EAAE,UAAU,GACjB,OAAO,CAAC,eAAe,CAAC,CAiE1B"}
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateRegistryBundle = updateRegistryBundle;
4
+ const core_1 = require("@ai-primitives-hub/core");
5
+ function log(onLog, level, message, error) {
6
+ onLog?.({ level, message, error });
7
+ }
8
+ /**
9
+ * Update an installed bundle to the latest (or a specific) version.
10
+ * @param bundleId - The currently-installed bundle to update.
11
+ * @param version - Optional specific version to update to; defaults to latest.
12
+ * @param ports - Injected read/write access to installed bundles, sources, adapters, and the installer.
13
+ * @param onLog - Optional sink for diagnostic log events.
14
+ * @returns The resulting installation record.
15
+ */
16
+ async function updateRegistryBundle(bundleId, version, ports, onLog) {
17
+ log(onLog, 'info', `Updating bundle: ${bundleId} to version: ${version || 'latest'}`);
18
+ // Get current installation - use listInstalledBundles to include repository-scoped bundles
19
+ const allInstalled = await ports.listInstalledBundles();
20
+ const current = allInstalled.find((b) => b.bundleId === bundleId);
21
+ if (!current) {
22
+ throw new Error(`Bundle '${bundleId}' is not installed`);
23
+ }
24
+ // For repository-scoped bundles, check for local modifications before updating
25
+ await ports.checkLocalModifications?.(bundleId, current);
26
+ const bundle = await resolveUpdateTargetBundle(bundleId, current, version, ports, onLog);
27
+ // Check if update is needed
28
+ if (current.version === bundle.version) {
29
+ log(onLog, 'info', `Bundle '${bundleId}' is already at version ${bundle.version}, reinstalling...`);
30
+ // Continue with reinstall instead of returning early
31
+ }
32
+ // Get source and adapter
33
+ const sources = await ports.listSources();
34
+ const source = sources.find((s) => s.id === bundle.sourceId);
35
+ if (!source) {
36
+ throw new Error(`Source '${bundle.sourceId}' not found`);
37
+ }
38
+ const adapter = ports.getAdapter(source);
39
+ // Unified download path: use downloadBundle() for all sources
40
+ log(onLog, 'debug', `Downloading bundle update from ${source.type} adapter`);
41
+ const bundleBuffer = await adapter.downloadBundle(bundle);
42
+ log(onLog, 'debug', `Bundle downloaded: ${bundleBuffer.length} bytes`);
43
+ // Update using the installer
44
+ const updated = await ports.updateInstalledBundle(current, bundle, bundleBuffer, source.type);
45
+ // CRITICAL: Write new installation record first, then remove old record.
46
+ // This ordering ensures crash-safety - if removal fails, we have the new
47
+ // record; if the write fails, the old record remains intact.
48
+ // Note: Repository scope bundles are tracked via LockfileManager, not
49
+ // RegistryStorage; the lockfile is already updated by the installer during
50
+ // update.
51
+ log(onLog, 'debug', `Recording new installation for '${updated.bundleId}' v${updated.version}`);
52
+ if (current.scope !== 'repository') {
53
+ await ports.recordInstallation(updated);
54
+ }
55
+ // Only remove old record if bundleId changed (e.g., GitHub bundles with
56
+ // version in ID). For Awesome Copilot bundles, the bundleId doesn't
57
+ // include version, so old and new are the same - in that case,
58
+ // recordInstallation already overwrote the old record.
59
+ if (updated.bundleId !== bundleId && current.scope !== 'repository') {
60
+ log(onLog, 'debug', `Removing old installation record for '${bundleId}' from ${current.scope} scope`);
61
+ await ports.removeInstallation(bundleId, current.scope);
62
+ }
63
+ else {
64
+ log(onLog, 'debug', `BundleId unchanged ('${bundleId}'), old record already overwritten`);
65
+ }
66
+ log(onLog, 'info', `Bundle '${bundleId}' updated from v${current.version} to v${bundle.version}`);
67
+ return updated;
68
+ }
69
+ /**
70
+ * Resolve the bundle to update to: a specific version if requested,
71
+ * otherwise the latest — with a two-tier identity/exact-id fallback
72
+ * at each step, mirroring the original's nested try/catch chain.
73
+ * @param bundleId - The currently-installed bundle id (may itself embed a version suffix).
74
+ * @param current - The current installation record, used to determine the identity-extraction strategy.
75
+ * @param version - Optional specific version to resolve; defaults to latest.
76
+ * @param ports - Injected bundle-lookup access.
77
+ * @param onLog - Optional sink for diagnostic log events.
78
+ */
79
+ async function resolveUpdateTargetBundle(bundleId, current, version, ports, onLog) {
80
+ // Extract identity for GitHub bundles to find the latest version
81
+ const identity = current.sourceType === 'github'
82
+ ? (0, core_1.extractBundleIdentity)(bundleId, 'github')
83
+ : bundleId.replace(/-v?\d+\.\d+\.\d+(-[\w.]+)?$/, '');
84
+ if (version) {
85
+ // Search for the specific version
86
+ const versionedId = `${identity}-${version}`;
87
+ try {
88
+ return await ports.getBundleDetails(versionedId);
89
+ }
90
+ catch {
91
+ // If versioned ID not found, try the identity
92
+ log(onLog, 'warn', `Bundle '${versionedId}' not found, trying identity '${identity}'`);
93
+ const bundle = await ports.getBundleDetails(identity);
94
+ // Verify the version matches
95
+ if (bundle.version !== version) {
96
+ throw new Error(`Requested version ${version} not found for bundle '${identity}'`);
97
+ }
98
+ return bundle;
99
+ }
100
+ }
101
+ // Try to get bundle by identity first (for GitHub bundles with versions)
102
+ try {
103
+ const bundle = await ports.getBundleDetails(identity);
104
+ log(onLog, 'debug', `Found bundle by identity: ${identity} -> ${bundle.id} v${bundle.version}`);
105
+ return bundle;
106
+ }
107
+ catch {
108
+ // Fall back to exact bundleId if identity lookup fails
109
+ log(onLog, 'debug', `Identity lookup failed for '${identity}', trying exact bundleId '${bundleId}'`);
110
+ return await ports.getBundleDetails(bundleId);
111
+ }
112
+ }
113
+ //# sourceMappingURL=update-registry-bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-registry-bundle.js","sourceRoot":"","sources":["../../src/registry/update-registry-bundle.ts"],"names":[],"mappings":";;AAqDA,oDAsEC;AAtGD,kDAEiC;AAkBjC,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;;;;;;;GAOG;AACI,KAAK,UAAU,oBAAoB,CACxC,QAAgB,EAChB,OAA2B,EAC3B,KAAgC,EAChC,KAAkB;IAElB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,oBAAoB,QAAQ,gBAAgB,OAAO,IAAI,QAAQ,EAAE,CAAC,CAAC;IAEtF,2FAA2F;IAC3F,MAAM,YAAY,GAAG,MAAM,KAAK,CAAC,oBAAoB,EAAE,CAAC;IACxD,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC;IAElE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,WAAW,QAAQ,oBAAoB,CAAC,CAAC;IAC3D,CAAC;IAED,+EAA+E;IAC/E,MAAM,KAAK,CAAC,uBAAuB,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAEzD,MAAM,MAAM,GAAG,MAAM,yBAA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AAI,CAAC;YACH,OAAO,MAAM,KAAK,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;QACnD,CAAC;QAAC,MAAM,CAAC;YACP,8CAA8C;YAC9C,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,WAAW,iCAAiC,QAAQ,GAAG,CAAC,CAAC;YACvF,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;YACtD,6BAA6B;YAC7B,IAAI,MAAM,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;gBAC/B,MAAM,IAAI,KAAK,CAAC,qBAAqB,OAAO,0BAA0B,QAAQ,GAAG,CAAC,CAAC;YACrF,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;IACH,CAAC;IAED,yEAAyE;IACzE,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QACtD,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,6BAA6B,QAAQ,OAAO,MAAM,CAAC,EAAE,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;QAChG,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,MAAM,CAAC;QACP,uDAAuD;QACvD,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,+BAA+B,QAAQ,6BAA6B,QAAQ,GAAG,CAAC,CAAC;QACrG,OAAO,MAAM,KAAK,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAChD,CAAC;AACH,CAAC"}
@@ -0,0 +1,24 @@
1
+ /** Resolved user-config path roots. */
2
+ export interface UserConfigPaths {
3
+ /** ${XDG_CONFIG_HOME:-$HOME/.config}/ai-primitives-hub/ */
4
+ root: string;
5
+ /** {root}/hubs/ */
6
+ hubs: string;
7
+ /** {root}/profile-activations/ */
8
+ profileActivations: string;
9
+ /** {root}/active-hub.json */
10
+ activeHub: string;
11
+ /** {root}/targets.yml (optional user targets file) */
12
+ userTargets: string;
13
+ /** {root}/token (token cache) */
14
+ tokenCache: string;
15
+ /** {root}/ai-primitives-hub.lock.json (user-scope lockfile) */
16
+ userLockfile: string;
17
+ }
18
+ /**
19
+ * Resolve the user-config paths from an env bag. Pure; no IO.
20
+ * @param env Environment variables (typically `ctx.env`).
21
+ * @returns Resolved paths.
22
+ */
23
+ export declare const resolveUserConfigPaths: (env: Record<string, string | undefined>) => UserConfigPaths;
24
+ //# sourceMappingURL=user-config-paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-config-paths.d.ts","sourceRoot":"","sources":["../../src/registry/user-config-paths.ts"],"names":[],"mappings":"AA8BA,uCAAuC;AACvC,MAAM,WAAW,eAAe;IAC9B,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,6BAA6B;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,sDAAsD;IACtD,WAAW,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GAAI,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,KAAG,eAWhF,CAAC"}
@@ -0,0 +1,82 @@
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.resolveUserConfigPaths = void 0;
37
+ /**
38
+ * User-level config paths.
39
+ *
40
+ * Resolves the on-disk locations for user-scoped registry state
41
+ * (hubs, profile activations, active-hub pointer, optional user
42
+ * targets, user-scope lockfile) per the XDG Base Directory
43
+ * Specification.
44
+ *
45
+ * Delegates the XDG root resolution to `infra`'s `xdgConfigDir`
46
+ * (ADR-0005 decision 2's shared resolver) rather than re-implementing
47
+ * `XDG_CONFIG_HOME`/`~/.config` fallback logic inline as the reference
48
+ * branch's own version of this file does — avoids reintroducing the
49
+ * exact duplication that resolver was created to consolidate. One
50
+ * behavioral difference from the reference's own inline version: the
51
+ * no-`XDG_CONFIG_HOME` fallback is `os.homedir()` (via `xdgConfigDir`),
52
+ * not `env.HOME`/`env.USERPROFILE` — matching every other XDG-based path
53
+ * in this codebase (e.g. the harvest cache dir) rather than diverging
54
+ * from them; a caller wanting a fully-hermetic override should still set
55
+ * `XDG_CONFIG_HOME` itself, which both approaches honour identically.
56
+ * All artifact names here are the CLI's own, not-yet-released state
57
+ * (rebranded per migration plan §8 decision 3 — `prompt-registry` ->
58
+ * `ai-primitives-hub`); this is unrelated to, and does not rename, the
59
+ * pre-existing, production, git-shared repository-scope lockfile
60
+ * (`prompt-registry.lock.json`, resolved elsewhere via `findLockfile`).
61
+ */
62
+ const path = __importStar(require("node:path"));
63
+ const infra_1 = require("@ai-primitives-hub/infra");
64
+ /**
65
+ * Resolve the user-config paths from an env bag. Pure; no IO.
66
+ * @param env Environment variables (typically `ctx.env`).
67
+ * @returns Resolved paths.
68
+ */
69
+ const resolveUserConfigPaths = (env) => {
70
+ const root = (0, infra_1.xdgConfigDir)(env);
71
+ return {
72
+ root,
73
+ hubs: path.join(root, 'hubs'),
74
+ profileActivations: path.join(root, 'profile-activations'),
75
+ activeHub: path.join(root, 'active-hub.json'),
76
+ userTargets: path.join(root, 'targets.yml'),
77
+ tokenCache: path.join(root, 'token'),
78
+ userLockfile: path.join(root, 'ai-primitives-hub.lock.json')
79
+ };
80
+ };
81
+ exports.resolveUserConfigPaths = resolveUserConfigPaths;
82
+ //# sourceMappingURL=user-config-paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-config-paths.js","sourceRoot":"","sources":["../../src/registry/user-config-paths.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,gDAAkC;AAClC,oDAEkC;AAoBlC;;;;GAIG;AACI,MAAM,sBAAsB,GAAG,CAAC,GAAuC,EAAmB,EAAE;IACjG,MAAM,IAAI,GAAG,IAAA,oBAAY,EAAC,GAAG,CAAC,CAAC;IAC/B,OAAO;QACL,IAAI;QACJ,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC;QAC7B,kBAAkB,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,qBAAqB,CAAC;QAC1D,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,iBAAiB,CAAC;QAC7C,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC;QAC3C,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC;QACpC,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,6BAA6B,CAAC;KAC7D,CAAC;AACJ,CAAC,CAAC;AAXW,QAAA,sBAAsB,0BAWjC"}
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Version consolidation for bundle search results.
3
+ *
4
+ * Ported from the extension's `src/services/version-consolidator.ts`
5
+ * (`VersionConsolidator`) into `app`'s registry/ module (migration plan
6
+ * §7.5, Phase 4 item 3, slice 1) so future search/discovery use-cases can
7
+ * reuse it, not just the extension's Marketplace view. This service groups
8
+ * bundles by their identity (owner/repo for GitHub sources) and selects the
9
+ * latest version based on semantic versioning, maintaining an LRU cache of
10
+ * all available versions for potential future access.
11
+ *
12
+ * Diagnostic debug/warn/error messages from the original are preserved via
13
+ * the optional `onLog` callback (the same `LogEvent` mechanism already used
14
+ * by `update/check-updates.ts`/`update/auto-update.ts`), so the extension's
15
+ * `Logger` output is unchanged.
16
+ * @module registry/version-consolidator
17
+ */
18
+ import type { Bundle, SourceType } from '@ai-primitives-hub/core';
19
+ import type { OnLogEvent } from '../update/log-event';
20
+ /**
21
+ * Version metadata for a bundle.
22
+ */
23
+ export interface BundleVersion {
24
+ version: string;
25
+ bundleId: string;
26
+ publishedAt: string;
27
+ downloadUrl: string;
28
+ manifestUrl: string;
29
+ releaseNotes?: string;
30
+ }
31
+ /**
32
+ * Consolidated bundle with version information.
33
+ */
34
+ export interface ConsolidatedBundle extends Bundle {
35
+ availableVersions: BundleVersion[];
36
+ isConsolidated: boolean;
37
+ }
38
+ /**
39
+ * Service for consolidating multiple bundle versions into single entries.
40
+ */
41
+ export declare class VersionConsolidator {
42
+ private readonly versionCache;
43
+ private readonly accessOrder;
44
+ private readonly maxCacheSize;
45
+ private readonly onLog?;
46
+ private sourceTypeResolver?;
47
+ /**
48
+ * Create a new VersionConsolidator
49
+ * @param maxCacheSize - Maximum number of bundle identities to cache (default: 1000)
50
+ * @param onLog - Optional callback for diagnostic log events (cache eviction, fallback sorting, ...)
51
+ * @throws {Error} if maxCacheSize is not a positive number
52
+ */
53
+ constructor(maxCacheSize?: number, onLog?: OnLogEvent);
54
+ private log;
55
+ /**
56
+ * Add entry to cache with LRU eviction strategy.
57
+ * @param key - Bundle identity key
58
+ * @param versions - Array of bundle versions to cache
59
+ */
60
+ private addToCache;
61
+ /**
62
+ * Update access order for LRU tracking (O(1) operation).
63
+ * @param key
64
+ */
65
+ private updateAccessOrder;
66
+ /**
67
+ * Evict the least recently used entry from cache (O(1) operation).
68
+ */
69
+ private evictLRU;
70
+ /**
71
+ * Get bundle identity based on source type.
72
+ * @param bundle
73
+ */
74
+ private getBundleIdentity;
75
+ /**
76
+ * Infer source type from source ID using heuristics.
77
+ *
78
+ * This is a fallback approach when no resolver is provided.
79
+ * Ideally, the actual source configuration should be used.
80
+ * @param sourceId - Source identifier to analyze
81
+ * @returns Inferred source type (defaults to 'local' for unknown types)
82
+ */
83
+ private inferSourceType;
84
+ /**
85
+ * Sort bundles by version in descending order (latest first).
86
+ * @param bundles
87
+ */
88
+ private sortBundlesByVersion;
89
+ /**
90
+ * Convert Bundle to BundleVersion metadata.
91
+ * @param bundle
92
+ */
93
+ private toBundleVersion;
94
+ /**
95
+ * Set a custom source type resolver function.
96
+ * @param resolver - Function that maps sourceId to SourceType
97
+ */
98
+ setSourceTypeResolver(resolver: (sourceId: string) => SourceType): void;
99
+ /**
100
+ * Consolidate bundles by grouping versions of the same bundle.
101
+ *
102
+ * For GitHub sources, bundles with the same owner/repo are grouped together
103
+ * and only the latest version is returned. For non-GitHub sources, bundles
104
+ * are returned unchanged.
105
+ * @param bundles - Array of bundles from various sources
106
+ * @returns Consolidated bundles with latest version metadata
107
+ */
108
+ consolidateBundles(bundles: Bundle[]): ConsolidatedBundle[];
109
+ /**
110
+ * Get all versions for a bundle identity.
111
+ * @param identity - Unique identifier for the bundle
112
+ * @returns Array of version metadata sorted by version descending
113
+ */
114
+ getAllVersions(identity: string): BundleVersion[];
115
+ /**
116
+ * Get a specific version of a bundle.
117
+ * @param bundleIdentity - Unique identifier for the bundle
118
+ * @param version - Specific version to retrieve
119
+ * @returns Bundle version metadata, or undefined if not found
120
+ */
121
+ getBundleVersion(bundleIdentity: string, version: string): BundleVersion | undefined;
122
+ }
123
+ //# sourceMappingURL=version-consolidator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version-consolidator.d.ts","sourceRoot":"","sources":["../../src/registry/version-consolidator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EACV,MAAM,EACN,UAAU,EACX,MAAM,yBAAyB,CAAC;AAKjC,OAAO,KAAK,EAEV,UAAU,EACX,MAAM,qBAAqB,CAAC;AAE7B;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,MAAM;IAEhD,iBAAiB,EAAE,aAAa,EAAE,CAAC;IACnC,cAAc,EAAE,OAAO,CAAC;CACzB;AAgBD;;GAEG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAsC;IACnE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAgB;IAC5C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAa;IACpC,OAAO,CAAC,kBAAkB,CAAC,CAAmC;IAE9D;;;;;OAKG;gBACgB,YAAY,GAAE,MAA+B,EAAE,KAAK,CAAC,EAAE,U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