@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,187 @@
1
+ "use strict";
2
+ /**
3
+ * Uninstall Pipeline.
4
+ *
5
+ * Mirrors the install pipeline but for removal operations:
6
+ * - Resolve installed bundle from the lockfile
7
+ * - Plan file removals
8
+ * - Execute removals via target writer
9
+ * - Update the lockfile
10
+ *
11
+ * Repository scope only — see `stores/json-lockfile-store.ts`'s module
12
+ * doc for why. Since the lockfile is split across two physical files
13
+ * (`prompt-registry.lock.json` for `commit` mode,
14
+ * `prompt-registry.local.lock.json` for `local-only`) with no
15
+ * per-entry `target` field, a bundle id is looked up in both files
16
+ * (mirroring the extension's own `LockfileManager.remove()`), and
17
+ * whichever file it's found in is the one updated.
18
+ *
19
+ * Known gap (matches the reference branch's own pipeline, not a
20
+ * regression introduced here): per-file removal goes through the
21
+ * generic `TargetWriter.remove()` method, which does not perform the
22
+ * git-exclude cleanup that `RepositoryScopeWriter`'s own richer
23
+ * `.remove(bundleId, manifest)` method does. Wiring that through the
24
+ * `TargetWriter` interface is deferred.
25
+ * @module install/uninstall-pipeline
26
+ */
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.UninstallPipeline = void 0;
29
+ const json_lockfile_store_1 = require("../stores/json-lockfile-store");
30
+ const COMMIT_MODES = ['commit', 'local-only'];
31
+ /**
32
+ * Uninstall pipeline for bundle removal.
33
+ */
34
+ class UninstallPipeline {
35
+ fs;
36
+ target;
37
+ repositoryPath;
38
+ writerFactory;
39
+ constructor(opts) {
40
+ this.fs = opts.fs;
41
+ this.target = opts.target;
42
+ this.repositoryPath = opts.repositoryPath;
43
+ this.writerFactory = opts.writerFactory;
44
+ }
45
+ /**
46
+ * Remove files via writer.
47
+ * @param writer - Target writer.
48
+ * @param files - Files to remove.
49
+ * @returns Removal result.
50
+ */
51
+ async removeFiles(writer, files) {
52
+ const removed = [];
53
+ const skipped = [];
54
+ for (const file of files) {
55
+ try {
56
+ await writer.remove(this.target, file);
57
+ removed.push(file);
58
+ }
59
+ catch {
60
+ skipped.push(file);
61
+ }
62
+ }
63
+ return { removed, skipped };
64
+ }
65
+ /**
66
+ * Remove a bundle entry from its lockfile, cleaning up orphaned
67
+ * sources and deleting the physical file when it becomes empty.
68
+ * @param bundleId - Bundle id to remove.
69
+ * @param entry - The entry being removed (for its sourceId).
70
+ * @param commitMode - Which physical lockfile to update.
71
+ */
72
+ async removeFromLockfile(bundleId, entry, commitMode) {
73
+ const lockPath = (0, json_lockfile_store_1.getLockfilePathForMode)(this.repositoryPath, commitMode);
74
+ const lock = await (0, json_lockfile_store_1.readLockfile)(lockPath, this.fs);
75
+ if (lock === null) {
76
+ return;
77
+ }
78
+ let next = (0, json_lockfile_store_1.removeBundleEntry)(lock, bundleId);
79
+ next = (0, json_lockfile_store_1.cleanupOrphanedSource)(next, entry.sourceId);
80
+ if (Object.keys(next.bundles).length === 0) {
81
+ await (0, json_lockfile_store_1.deleteLockfile)(lockPath, this.fs);
82
+ return;
83
+ }
84
+ await (0, json_lockfile_store_1.writeLockfile)(lockPath, next, this.fs);
85
+ }
86
+ /**
87
+ * Plan uninstall by resolving the bundle in either lockfile.
88
+ * @param id - Bundle ID to uninstall.
89
+ * @returns Uninstall plan.
90
+ */
91
+ async plan(id) {
92
+ for (const commitMode of COMMIT_MODES) {
93
+ const lockPath = (0, json_lockfile_store_1.getLockfilePathForMode)(this.repositoryPath, commitMode);
94
+ const lock = await (0, json_lockfile_store_1.readLockfile)(lockPath, this.fs);
95
+ const entry = lock?.bundles[id];
96
+ if (entry !== undefined) {
97
+ return {
98
+ bundleId: id,
99
+ filesToRemove: entry.files.map((f) => f.path),
100
+ lockfileEntry: entry,
101
+ commitMode
102
+ };
103
+ }
104
+ }
105
+ return { bundleId: id, filesToRemove: [], lockfileEntry: null };
106
+ }
107
+ /**
108
+ * Execute uninstall by removing files and updating the lockfile.
109
+ * @param id - Bundle ID to uninstall.
110
+ * @returns Uninstall result.
111
+ */
112
+ async run(id) {
113
+ const plan = await this.plan(id);
114
+ if (plan.lockfileEntry === null || plan.commitMode === undefined) {
115
+ return { bundleId: id, removed: [], skipped: [] };
116
+ }
117
+ const writer = this.writerFactory(this.target);
118
+ const result = await this.removeFiles(writer, plan.filesToRemove);
119
+ await this.removeFromLockfile(id, plan.lockfileEntry, plan.commitMode);
120
+ return {
121
+ bundleId: id,
122
+ removed: result.removed,
123
+ skipped: result.skipped
124
+ };
125
+ }
126
+ /**
127
+ * Plan uninstall for every bundle across both lockfiles.
128
+ * @returns Array of uninstall plans.
129
+ */
130
+ async planAll() {
131
+ const plans = [];
132
+ for (const commitMode of COMMIT_MODES) {
133
+ const lockPath = (0, json_lockfile_store_1.getLockfilePathForMode)(this.repositoryPath, commitMode);
134
+ const lock = await (0, json_lockfile_store_1.readLockfile)(lockPath, this.fs);
135
+ if (lock === null) {
136
+ continue;
137
+ }
138
+ for (const [bundleId, entry] of Object.entries(lock.bundles)) {
139
+ plans.push({
140
+ bundleId,
141
+ filesToRemove: entry.files.map((f) => f.path),
142
+ lockfileEntry: entry,
143
+ commitMode
144
+ });
145
+ }
146
+ }
147
+ return plans;
148
+ }
149
+ /**
150
+ * Execute uninstall for every bundle across both lockfiles.
151
+ * @returns Array of uninstall results.
152
+ */
153
+ async runAll() {
154
+ const plans = await this.planAll();
155
+ const results = [];
156
+ for (const plan of plans) {
157
+ if (plan.lockfileEntry === null || plan.commitMode === undefined) {
158
+ continue;
159
+ }
160
+ const writer = this.writerFactory(this.target);
161
+ const result = await this.removeFiles(writer, plan.filesToRemove);
162
+ await this.removeFromLockfile(plan.bundleId, plan.lockfileEntry, plan.commitMode);
163
+ results.push({
164
+ bundleId: plan.bundleId,
165
+ removed: result.removed,
166
+ skipped: result.skipped
167
+ });
168
+ }
169
+ return results;
170
+ }
171
+ /**
172
+ * Execute uninstall for every bundle across both lockfiles,
173
+ * tolerating missing/invalid lockfiles by returning an empty result.
174
+ * @returns Array of uninstall results.
175
+ */
176
+ async runFromLockfile() {
177
+ try {
178
+ return await this.runAll();
179
+ }
180
+ catch {
181
+ // Lockfile doesn't exist or is invalid
182
+ return [];
183
+ }
184
+ }
185
+ }
186
+ exports.UninstallPipeline = UninstallPipeline;
187
+ //# sourceMappingURL=uninstall-pipeline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uninstall-pipeline.js","sourceRoot":"","sources":["../../src/install/uninstall-pipeline.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;;AAUH,uEAOuC;AA6CvC,MAAM,YAAY,GAAoC,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;AAE/E;;GAEG;AACH,MAAa,iBAAiB;IACX,EAAE,CAAa;IACf,MAAM,CAAS;IACf,cAAc,CAAS;IACvB,aAAa,CAAmC;IAEjE,YAAmB,IAA8B;QAC/C,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;QAC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M,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,IAAI,CAAC,aAAa,KAAK,IAAI,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;gBACjE,SAAS;YACX,CAAC;YAED,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC/C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;YAClE,MAAM,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;YAElF,OAAO,CAAC,IAAI,CAAC;gBACX,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,OAAO,EAAE,MAAM,CAAC,OAAO;aACxB,CAAC,CAAC;QACL,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,eAAe;QAC1B,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC;QAC7B,CAAC;QAAC,MAAM,CAAC;YACP,uCAAuC;YACvC,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;CACF;AA5KD,8CA4KC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Activate a profile (hub-provided or local): deactivate every other
3
+ * active profile, then either delegate to the hub sync port or
4
+ * install the local profile's bundles — ported from
5
+ * `src/services/registry-manager.ts`'s `activateProfile` plus its
6
+ * private `validateProfileId`/`deactivateOtherProfiles`/
7
+ * `getProfileById`/`installProfileBundles`/`installProfileBundle`
8
+ * helpers. Part of the `RegistryManager` scoping pass's slice 6
9
+ * (migration plan §7.5 item 3).
10
+ *
11
+ * The original wraps this whole flow in `vscode.window.withProgress`,
12
+ * reporting a message at each checkpoint. That's presentation-only
13
+ * VS Code glue, so it stays in the extension; every checkpoint message
14
+ * here goes through `onLog` at `'info'` level instead, which the
15
+ * extension's thin wrapper forwards to both its `Logger` and the
16
+ * progress notification — same UX, no `vscode.Progress` dependency
17
+ * here.
18
+ *
19
+ * Also preserves two original quirks verbatim rather than silently
20
+ * tidying them up (flagged inline): the local-profile path runs a
21
+ * second, redundant "deactivate other local profiles" pass after
22
+ * already having done so once up front (harmless — everything else is
23
+ * already inactive by then, but real, original behavior), and fires
24
+ * what would be two `_onProfileActivated` events for the same profile
25
+ * (the extension's thin wrapper reproduces this from this module's
26
+ * return value).
27
+ * @module registry/activate-registry-profile
28
+ */
29
+ import type { Bundle, HubProfileSync, HubProfileWithMetadata, InstalledBundle, InstallOptions, Profile, RegistrySource, SearchQuery, SourceAdapter, SourceType } from '@ai-primitives-hub/core';
30
+ import type { OnLogEvent } from '../update/log-event';
31
+ /**
32
+ * Dependencies needed to activate a profile.
33
+ */
34
+ export interface ActivateRegistryProfilePorts {
35
+ getProfiles(): Promise<Profile[]>;
36
+ updateProfile(profileId: string, updates: Partial<Profile>): Promise<void>;
37
+ getSources(): Promise<RegistrySource[]>;
38
+ getInstalledBundles(): Promise<InstalledBundle[]>;
39
+ searchBundles(query: SearchQuery): Promise<Bundle[]>;
40
+ getAdapter(source: RegistrySource): SourceAdapter;
41
+ installFromBuffer(bundle: Bundle, buffer: Buffer, options: InstallOptions, sourceType: SourceType): Promise<InstalledBundle>;
42
+ recordInstallation(installation: InstalledBundle): Promise<void>;
43
+ /** Deactivate one other profile, hub or local — the caller's own already-event-firing `deactivateProfile`. */
44
+ deactivateOther(profileId: string): Promise<void>;
45
+ /** Present only when a `HubManager` is wired (mirrors the extension's own `if (this.hubManager)` branching). */
46
+ hub?: HubProfileSync;
47
+ }
48
+ export interface ActivateRegistryProfileResult {
49
+ /** Set when the target turned out to be hub-provided (delegated to `hub.activateProfile`). */
50
+ hubActivation?: {
51
+ hubProfile: HubProfileWithMetadata;
52
+ };
53
+ /** Set for the local-profile path. */
54
+ localActivation?: {
55
+ profile: Profile;
56
+ installedBundles: InstalledBundle[];
57
+ };
58
+ }
59
+ /**
60
+ * Activate a profile.
61
+ * @param ports Read/write access to profiles, sources, bundles, and (optionally) the hub.
62
+ * @param profileId Profile to activate (or a legacy `{id}` object — see `validateProfileId`).
63
+ * @param onLog Optional sink for diagnostic log events (also drives the extension's progress UI).
64
+ * @returns Which path was taken, and its outcome — see `ActivateRegistryProfileResult`.
65
+ */
66
+ export declare function activateRegistryProfile(ports: ActivateRegistryProfilePorts, profileId: unknown, onLog?: OnLogEvent): Promise<ActivateRegistryProfileResult>;
67
+ //# sourceMappingURL=activate-registry-profile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activate-registry-profile.d.ts","sourceRoot":"","sources":["../../src/registry/activate-registry-profile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,KAAK,EACV,MAAM,EACN,cAAc,EACd,sBAAsB,EACtB,eAAe,EACf,cAAc,EACd,OAAO,EAEP,cAAc,EACd,WAAW,EACX,aAAa,EACb,UAAU,EACX,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAEV,UAAU,EACX,MAAM,qBAAqB,CAAC;AAK7B;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,WAAW,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAClC,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3E,UAAU,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IACxC,mBAAmB,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAClD,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACrD,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,aAAa,CAAC;IAClD,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC7H,kBAAkB,CAAC,YAAY,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE,8GAA8G;IAC9G,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,gHAAgH;IAChH,GAAG,CAAC,EAAE,cAAc,CAAC;CACtB;AAED,MAAM,WAAW,6BAA6B;IAC5C,8FAA8F;IAC9F,aAAa,CAAC,EAAE;QAAE,UAAU,EAAE,sBAAsB,CAAA;KAAE,CAAC;IACvD,sCAAsC;IACtC,eAAe,CAAC,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,gBAAgB,EAAE,eAAe,EAAE,CAAA;KAAE,CAAC;CAC7E;AA2ID;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,4BAA4B,EACnC,SAAS,EAAE,OAAO,EAClB,KAAK,CAAC,EAAE,UAAU,GACjB,OAAO,CAAC,6BAA6B,CAAC,CA4CxC"}
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.activateRegistryProfile = activateRegistryProfile;
4
+ /** Mirrors the extension's `CONCURRENCY_CONSTANTS.REGISTRY_BATCH_LIMIT` — this module is its only remaining consumer. */
5
+ const PROFILE_BUNDLE_INSTALL_BATCH_LIMIT = 5;
6
+ function log(onLog, level, message, error) {
7
+ onLog?.({ level, message, error });
8
+ }
9
+ function validateProfileId(profileId) {
10
+ if (typeof profileId !== 'string') {
11
+ if (profileId && typeof profileId === 'object' && 'id' in profileId) {
12
+ return profileId.id;
13
+ }
14
+ throw new Error(`Invalid profile identifier: expected string, got ${typeof profileId}`);
15
+ }
16
+ return profileId;
17
+ }
18
+ async function getProfileById(ports, profileId) {
19
+ const profiles = await ports.getProfiles();
20
+ const profile = profiles.find((p) => p.id === profileId);
21
+ if (!profile) {
22
+ throw new Error(`Profile not found: ${profileId}`);
23
+ }
24
+ return profile;
25
+ }
26
+ /**
27
+ * Deactivate every other currently-active local profile. Called
28
+ * twice by `activateRegistryProfile` (see module doc) — kept as a
29
+ * shared helper to avoid duplicating the loop body, not to change
30
+ * how many times it runs.
31
+ * @param ports Read/write access to local profiles and the deactivation callback.
32
+ * @param targetProfileId Profile being activated — never deactivated by this pass.
33
+ * @param onLog Optional sink for diagnostic log events.
34
+ */
35
+ async function deactivateOtherLocalProfiles(ports, targetProfileId, onLog) {
36
+ const profiles = await ports.getProfiles();
37
+ for (const profile of profiles) {
38
+ if (profile.active && profile.id !== targetProfileId) {
39
+ log(onLog, 'info', `Deactivating previous profile: ${profile.id}`);
40
+ try {
41
+ await ports.deactivateOther(profile.id);
42
+ }
43
+ catch (error) {
44
+ log(onLog, 'error', `Failed to deactivate profile ${profile.id}`, error instanceof Error ? error : new Error(String(error)));
45
+ }
46
+ }
47
+ }
48
+ }
49
+ async function installProfileBundle(ports, bundleRef, profileId, allSources) {
50
+ const installedBundles = await ports.getInstalledBundles();
51
+ const alreadyInstalled = installedBundles.find((b) => b.bundleId === bundleRef.id);
52
+ if (alreadyInstalled) {
53
+ return null;
54
+ }
55
+ const searchResults = await ports.searchBundles({ text: bundleRef.id, tags: [], sourceId: bundleRef.sourceId });
56
+ const matchingBundle = searchResults.find((b) => {
57
+ const idMatch = b.id === bundleRef.id || b.name.toLowerCase().includes(bundleRef.id.toLowerCase());
58
+ if (bundleRef.sourceId) {
59
+ return idMatch && b.sourceId === bundleRef.sourceId;
60
+ }
61
+ return idMatch;
62
+ });
63
+ if (!matchingBundle) {
64
+ return null;
65
+ }
66
+ const source = allSources.find((s) => s.id === matchingBundle.sourceId);
67
+ if (!source) {
68
+ return null;
69
+ }
70
+ const adapter = ports.getAdapter(source);
71
+ const bundleBuffer = await adapter.downloadBundle(matchingBundle);
72
+ const options = { scope: 'user', force: false, profileId };
73
+ const installation = await ports.installFromBuffer(matchingBundle, bundleBuffer, options, source.type);
74
+ installation.sourceId = matchingBundle.sourceId;
75
+ installation.sourceType = source.type;
76
+ await ports.recordInstallation(installation);
77
+ return installation;
78
+ }
79
+ async function installProfileBundles(ports, profile, profileId, onLog) {
80
+ if (!profile.bundles || profile.bundles.length === 0) {
81
+ return [];
82
+ }
83
+ log(onLog, 'info', `Installing ${profile.bundles.length} bundle(s)...`);
84
+ const allSources = await ports.getSources();
85
+ const installed = [];
86
+ for (let i = 0; i < profile.bundles.length; i += PROFILE_BUNDLE_INSTALL_BATCH_LIMIT) {
87
+ const chunk = profile.bundles.slice(i, i + PROFILE_BUNDLE_INSTALL_BATCH_LIMIT);
88
+ const results = await Promise.all(chunk.map(async (bundleRef) => {
89
+ log(onLog, 'info', `Installing ${bundleRef.id}...`);
90
+ try {
91
+ return await installProfileBundle(ports, bundleRef, profileId, allSources);
92
+ }
93
+ catch (error) {
94
+ log(onLog, 'error', `Failed to install bundle ${bundleRef.id}`, error instanceof Error ? error : new Error(String(error)));
95
+ return null;
96
+ }
97
+ }));
98
+ for (const result of results) {
99
+ if (result) {
100
+ installed.push(result);
101
+ }
102
+ }
103
+ }
104
+ return installed;
105
+ }
106
+ /**
107
+ * Activate a profile.
108
+ * @param ports Read/write access to profiles, sources, bundles, and (optionally) the hub.
109
+ * @param profileId Profile to activate (or a legacy `{id}` object — see `validateProfileId`).
110
+ * @param onLog Optional sink for diagnostic log events (also drives the extension's progress UI).
111
+ * @returns Which path was taken, and its outcome — see `ActivateRegistryProfileResult`.
112
+ */
113
+ async function activateRegistryProfile(ports, profileId, onLog) {
114
+ const validatedProfileId = validateProfileId(profileId);
115
+ log(onLog, 'info', `Activating profile: ${validatedProfileId}`);
116
+ log(onLog, 'info', 'Deactivating other profiles...');
117
+ if (ports.hub) {
118
+ const activeHubProfiles = await ports.hub.listAllActiveProfiles();
119
+ for (const activeProfile of activeHubProfiles) {
120
+ if (activeProfile.profileId !== validatedProfileId) {
121
+ log(onLog, 'info', `Deactivating hub profile: ${activeProfile.profileId}`);
122
+ try {
123
+ await ports.deactivateOther(activeProfile.profileId);
124
+ }
125
+ catch (error) {
126
+ log(onLog, 'error', `Failed to deactivate hub profile ${activeProfile.profileId}`, error instanceof Error ? error : new Error(String(error)));
127
+ }
128
+ }
129
+ }
130
+ }
131
+ await deactivateOtherLocalProfiles(ports, validatedProfileId, onLog);
132
+ if (ports.hub) {
133
+ const hubProfiles = await ports.hub.listActiveHubProfiles();
134
+ const hubProfile = hubProfiles.find((p) => p.id === validatedProfileId);
135
+ if (hubProfile) {
136
+ log(onLog, 'info', `Profile ${validatedProfileId} is from hub, delegating to HubManager`);
137
+ await ports.hub.activateProfile(hubProfile.hubId, validatedProfileId, { installBundles: true });
138
+ return { hubActivation: { hubProfile } };
139
+ }
140
+ }
141
+ log(onLog, 'info', 'Installing bundles...');
142
+ const profile = await getProfileById(ports, validatedProfileId);
143
+ // Second, redundant local-deactivation pass — see module doc.
144
+ await deactivateOtherLocalProfiles(ports, validatedProfileId, onLog);
145
+ const installedBundles = await installProfileBundles(ports, profile, validatedProfileId, onLog);
146
+ await ports.updateProfile(validatedProfileId, { active: true });
147
+ log(onLog, 'info', `Profile '${validatedProfileId}' activated successfully`);
148
+ return { localActivation: { profile, installedBundles } };
149
+ }
150
+ //# sourceMappingURL=activate-registry-profile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activate-registry-profile.js","sourceRoot":"","sources":["../../src/registry/activate-registry-profile.ts"],"names":[],"mappings":";;AA0NA,0DAgDC;AA5ND,yHAAyH;AACzH,MAAM,kCAAkC,GAAG,CAAC,CAAC;AA2B7C,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;A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AE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC;YAChG,OAAO,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,EAAE,CAAC;QAC3C,CAAC;IACH,CAAC;IAED,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,uBAAuB,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;IAEhE,8DAA8D;IAC9D,MAAM,4BAA4B,CAAC,KAAK,EAAE,kBAAkB,EAAE,KAAK,CAAC,CAAC;IAErE,MAAM,gBAAgB,GAAG,MAAM,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,KAAK,CAAC,CAAC;IAEhG,MAAM,KAAK,CAAC,aAAa,CAAC,kBAAkB,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IAEhE,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,kBAAkB,0BAA0B,CAAC,CAAC;IAE7E,OAAO,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE,EAAE,CAAC;AAC5D,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Maps a `RegistrySource` to its concrete `infra` `SourceAdapter`,
3
+ * building whatever adapter-specific dependencies (a `GitHubApi` for the
4
+ * four GitHub-hosted source types, nothing extra for the four fs-only
5
+ * ones) each constructor needs.
6
+ *
7
+ * This is the "wire it up" half of the migration plan's
8
+ * adapter-unification cutover (§7.5 Phase 4 item 3, decision #10): the
9
+ * eight `infra` adapters already exist and are field-identical to the
10
+ * extension's own `src/adapters/*` (see `core`'s `domain/bundle/types.ts`
11
+ * module doc), but nothing had ever constructed one outside of `infra`'s
12
+ * own tests. Delivery-context-specific pieces - which `TokenProvider`s to
13
+ * fall back to (a VS Code auth session bridge for the extension, none for
14
+ * the CLI today), and the four Node port implementations - are supplied
15
+ * by the caller via `SourceAdapterFactoryDeps`, not hardcoded here, so
16
+ * this stays usable from both `apps/vscode-extension` and `packages/cli`.
17
+ *
18
+ * A source's own explicit `source.token` (if set) always wins over the
19
+ * caller-supplied fallback chain, mirroring every one of the extension's
20
+ * four hand-rolled auth chains today (explicit token checked first).
21
+ * @module registry/create-source-adapter
22
+ */
23
+ import type { Clock, FileSystem, HttpClient, ProcessRunner, RegistrySource, SourceAdapter, TokenProvider } from '@ai-primitives-hub/core';
24
+ export interface SourceAdapterFactoryDeps {
25
+ fs: FileSystem;
26
+ clock: Clock;
27
+ httpClient: HttpClient;
28
+ processRunner: ProcessRunner;
29
+ /**
30
+ * Tried, in order, for any GitHub-hosted source that doesn't have its
31
+ * own explicit `source.token` - e.g. a VS Code auth session bridge
32
+ * followed by the `gh` CLI for the extension, or just the `gh` CLI for
33
+ * the CLI itself.
34
+ */
35
+ fallbackTokenProviders: readonly TokenProvider[];
36
+ }
37
+ /**
38
+ * Build the `infra` `SourceAdapter` for a `RegistrySource`.
39
+ * @param source - The source to build an adapter for.
40
+ * @param deps - Shared, delivery-context-specific dependencies (Node port implementations + auth fallback chain).
41
+ */
42
+ export declare function createSourceAdapter(source: RegistrySource, deps: SourceAdapterFactoryDeps): SourceAdapter;
43
+ //# sourceMappingURL=create-source-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-source-adapter.d.ts","sourceRoot":"","sources":["../../src/registry/create-source-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EACV,KAAK,EACL,UAAU,EAEV,UAAU,EACV,aAAa,EACb,cAAc,EACd,aAAa,EACb,aAAa,EACd,MAAM,yBAAyB,CAAC;AAejC,MAAM,WAAW,wBAAwB;IACvC,EAAE,EAAE,UAAU,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;IACb,UAAU,EAAE,UAAU,CAAC;IACvB,aAAa,EAAE,aAAa,CAAC;IAC7B;;;;;OAKG;IACH,sBAAsB,EAAE,SAAS,aAAa,EAAE,CAAC;CAClD;AAeD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,wBAAwB,GAAG,aAAa,CA+BzG"}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createSourceAdapter = createSourceAdapter;
4
+ const infra_1 = require("@ai-primitives-hub/infra");
5
+ function buildSourceTokenProvider(source, deps) {
6
+ const providers = [];
7
+ if (source.token) {
8
+ providers.push(new infra_1.StaticTokenProvider(source.token));
9
+ }
10
+ providers.push(...deps.fallbackTokenProviders);
11
+ return new infra_1.CompositeTokenProvider(providers);
12
+ }
13
+ function buildGitHubApi(tokenProvider, deps) {
14
+ return new infra_1.GitHubApiClient(deps.httpClient, { tokenProvider });
15
+ }
16
+ /**
17
+ * Build the `infra` `SourceAdapter` for a `RegistrySource`.
18
+ * @param source - The source to build an adapter for.
19
+ * @param deps - Shared, delivery-context-specific dependencies (Node port implementations + auth fallback chain).
20
+ */
21
+ function createSourceAdapter(source, deps) {
22
+ switch (source.type) {
23
+ case 'local': {
24
+ return new infra_1.LocalAdapter(source, deps.fs);
25
+ }
26
+ case 'local-apm': {
27
+ return new infra_1.LocalApmAdapter(source, deps.fs, deps.clock);
28
+ }
29
+ case 'local-awesome-copilot': {
30
+ return new infra_1.LocalAwesomeCopilotAdapter(source, deps.fs);
31
+ }
32
+ case 'local-skills': {
33
+ return new infra_1.LocalSkillsAdapter(source, deps.fs, deps.clock);
34
+ }
35
+ case 'github': {
36
+ return new infra_1.GitHubAdapter(source, buildGitHubApi(buildSourceTokenProvider(source, deps), deps));
37
+ }
38
+ case 'skills': {
39
+ return new infra_1.SkillsAdapter(source, buildGitHubApi(buildSourceTokenProvider(source, deps), deps), deps.clock);
40
+ }
41
+ case 'awesome-copilot': {
42
+ return new infra_1.AwesomeCopilotAdapter(source, buildGitHubApi(buildSourceTokenProvider(source, deps), deps), deps.clock);
43
+ }
44
+ case 'apm': {
45
+ const tokenProvider = buildSourceTokenProvider(source, deps);
46
+ return new infra_1.ApmAdapter(source, buildGitHubApi(tokenProvider, deps), deps.processRunner, deps.fs, deps.clock, tokenProvider);
47
+ }
48
+ default: {
49
+ throw new Error(`No adapter for source type: ${String(source.type)}`);
50
+ }
51
+ }
52
+ }
53
+ //# sourceMappingURL=create-source-adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-source-adapter.js","sourceRoot":"","sources":["../../src/registry/create-source-adapter.ts"],"names":[],"mappings":";;AA8EA,kDA+BC;AA7ED,oDAYkC;AAgBlC,SAAS,wBAAwB,CAAC,MAAsB,EAAE,IAA8B;IACtF,MAAM,SAAS,GAAoB,EAAE,CAAC;IACtC,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,SAAS,CAAC,IAAI,CAAC,IAAI,2BAAmB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACxD,CAAC;IACD,SAAS,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,sBAAsB,CAAC,CAAC;IAC/C,OAAO,IAAI,8BAAsB,CAAC,SAAS,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,cAAc,CAAC,aAA4B,EAAE,IAA8B;IAClF,OAAO,IAAI,uBAAe,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC;AACjE,CAAC;AAED;;;;GAIG;AACH,SAAgB,mBAAmB,CAAC,MAAsB,EAAE,IAA8B;IACxF,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,OAAO,CAAC,CAAC,CAAC;YACb,OAAO,IAAI,oBAAY,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QAC3C,CAAC;QACD,KAAK,WAAW,CAAC,CAAC,CAAC;YACjB,OAAO,IAAI,uBAAe,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1D,CAAC;QACD,K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CAAC,CAAC;QACxE,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Deactivate a profile (hub-provided or local) and uninstall its
3
+ * bundles — ported from `src/services/registry-manager.ts`'s
4
+ * `deactivateProfile`. Part of the `RegistryManager` scoping pass's
5
+ * slice 6 (migration plan §7.5 item 3).
6
+ *
7
+ * Deliberately fires no events itself: the caller already knows the
8
+ * `profileId` it passed in, so its thin wrapper can fire
9
+ * `_onProfileDeactivated` right after this resolves (or skip it, if
10
+ * this throws) with no return value needed — simpler than every other
11
+ * `registry/*` use-case, which return data the caller doesn't already
12
+ * have.
13
+ * @module registry/deactivate-registry-profile
14
+ */
15
+ import type { HubProfileSync, InstalledBundle, Profile } from '@ai-primitives-hub/core';
16
+ import type { OnLogEvent } from '../update/log-event';
17
+ /**
18
+ * Dependencies needed to deactivate a profile.
19
+ */
20
+ export interface DeactivateRegistryProfilePorts {
21
+ getProfiles(): Promise<Profile[]>;
22
+ updateProfile(profileId: string, updates: Partial<Profile>): Promise<void>;
23
+ getInstalledBundles(): Promise<InstalledBundle[]>;
24
+ uninstallBundles(bundleIds: string[]): Promise<void>;
25
+ /** Present only when a `HubManager` is wired (mirrors the extension's own `if (this.hubManager)` branching). */
26
+ hub?: HubProfileSync;
27
+ }
28
+ /**
29
+ * Deactivate a profile: if it's hub-provided, delegate to the hub
30
+ * sync port; otherwise flag it inactive locally. Either way, uninstall
31
+ * every bundle recorded against this `profileId`. Throws when a local
32
+ * profile id doesn't exist (mirrors the original).
33
+ * @param ports Read/write access to profiles, installed bundles, and (optionally) the hub.
34
+ * @param profileId Profile to deactivate.
35
+ * @param onLog Optional sink for diagnostic log events.
36
+ */
37
+ export declare function deactivateRegistryProfile(ports: DeactivateRegistryProfilePorts, profileId: string, onLog?: OnLogEvent): Promise<void>;
38
+ //# sourceMappingURL=deactivate-registry-profile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deactivate-registry-profile.d.ts","sourceRoot":"","sources":["../../src/registry/deactivate-registry-profile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,OAAO,EACR,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAEV,UAAU,EACX,MAAM,qBAAqB,CAAC;AAE7B;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C,WAAW,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAClC,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3E,mBAAmB,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAClD,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,gHAAgH;IAChH,GAAG,CAAC,EAAE,cAAc,CAAC;CACtB;AAMD;;;;;;;;GAQG;AACH,wBAAsB,yBAAyB,CAC7C,KAAK,EAAE,8BAA8B,EACrC,SAAS,EAAE,MAAM,EACjB,KAAK,CAAC,EAAE,UAAU,GACjB,OAAO,CAAC,IAAI,CAAC,CAsCf"}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deactivateRegistryProfile = deactivateRegistryProfile;
4
+ function log(onLog, level, message, error) {
5
+ onLog?.({ level, message, error });
6
+ }
7
+ /**
8
+ * Deactivate a profile: if it's hub-provided, delegate to the hub
9
+ * sync port; otherwise flag it inactive locally. Either way, uninstall
10
+ * every bundle recorded against this `profileId`. Throws when a local
11
+ * profile id doesn't exist (mirrors the original).
12
+ * @param ports Read/write access to profiles, installed bundles, and (optionally) the hub.
13
+ * @param profileId Profile to deactivate.
14
+ * @param onLog Optional sink for diagnostic log events.
15
+ */
16
+ async function deactivateRegistryProfile(ports, profileId, onLog) {
17
+ log(onLog, 'info', `Deactivating profile: ${profileId}`);
18
+ if (ports.hub) {
19
+ const hubProfiles = await ports.hub.listActiveHubProfiles();
20
+ const hubProfile = hubProfiles.find((p) => p.id === profileId);
21
+ if (hubProfile) {
22
+ log(onLog, 'info', `Profile ${profileId} is from hub, delegating to HubManager`);
23
+ await ports.hub.deactivateProfile(hubProfile.hubId, profileId);
24
+ const bundles = (await ports.getInstalledBundles()).filter((b) => b.profileId === profileId);
25
+ if (bundles.length > 0) {
26
+ log(onLog, 'info', `Uninstalling ${bundles.length} bundles from hub profile '${profileId}'`);
27
+ await ports.uninstallBundles(bundles.map((b) => b.bundleId));
28
+ }
29
+ log(onLog, 'info', `Profile deactivated: ${profileId}`);
30
+ return;
31
+ }
32
+ }
33
+ const profiles = await ports.getProfiles();
34
+ const profile = profiles.find((p) => p.id === profileId);
35
+ if (!profile) {
36
+ throw new Error(`Profile not found: ${profileId}`);
37
+ }
38
+ const installedBundles = await ports.getInstalledBundles();
39
+ const profileBundles = installedBundles.filter((b) => b.profileId === profileId);
40
+ log(onLog, 'info', `Uninstalling ${profileBundles.length} bundles from profile '${profileId}'`);
41
+ await ports.uninstallBundles(profileBundles.map((b) => b.bundleId));
42
+ await ports.updateProfile(profileId, { active: false });
43
+ log(onLog, 'info', `Profile '${profileId}' deactivated successfully`);
44
+ }
45
+ //# sourceMappingURL=deactivate-registry-profile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deactivate-registry-profile.js","sourceRoot":"","sources":["../../src/registry/deactivate-registry-profile.ts"],"names":[],"mappings":";;AAiDA,8DA0CC;AAvDD,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;;;;;;;;GAQG;AACI,KAAK,UAAU,yBAAyB,CAC7C,KAAqC,EACrC,SAAiB,EACjB,KAAkB;IAElB,GAAG,CAAC,KA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AAC,CAAC;IAEzD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,sBAAsB,SAAS,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,gBAAgB,GAAG,MAAM,KAAK,CAAC,mBAAmB,EAAE,CAAC;IAC3D,MAAM,cAAc,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC;IAEjF,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,gBAAgB,cAAc,CAAC,MAAM,0BAA0B,SAAS,GAAG,CAAC,CAAC;IAChG,MAAM,KAAK,CAAC,gBAAgB,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEpE,MAAM,KAAK,CAAC,aAAa,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IAExD,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,SAAS,4BAA4B,CAAC,CAAC;AACxE,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { BundleUpdate, UpdateDetectionReader } from '@ai-primitives-hub/core';
2
+ import type { OnLogEvent } from '../update/log-event';
3
+ /**
4
+ * Compare every installed bundle's version against its source's latest
5
+ * known version, returning only the ones that differ. Per-bundle
6
+ * failures (network errors, a bundle no longer resolvable at all) are
7
+ * logged and skipped rather than failing the whole check.
8
+ * @param ports - Read access to bundle details, sources, and installation records.
9
+ * @param onLog - Optional sink for diagnostic log events.
10
+ */
11
+ export declare function detectBundleUpdates(ports: UpdateDetectionReader, onLog?: OnLogEvent): Promise<BundleUpdate[]>;
12
+ //# sourceMappingURL=detect-updates.d.ts.map