@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,291 @@
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.loadItemKindsFromSchema = loadItemKindsFromSchema;
37
+ exports.validateCollectionFile = validateCollectionFile;
38
+ exports.validateAllCollections = validateAllCollections;
39
+ exports.generateMarkdown = generateMarkdown;
40
+ exports.listCollectionFiles = listCollectionFiles;
41
+ exports.readCollection = readCollection;
42
+ exports.writeCollection = writeCollection;
43
+ exports.resolveCollectionItemPaths = resolveCollectionItemPaths;
44
+ /**
45
+ * Collection file reading/writing utilities (file-IO dependent).
46
+ * @module app/collection/read-collection
47
+ *
48
+ * File-IO dependent collection reading functions.
49
+ * Pure validation functions are in `@ai-primitives-hub/core`'s
50
+ * `domain/collection/validate.ts`.
51
+ *
52
+ * Ported from the reference branch's `app/src/collection/read-collection.ts`,
53
+ * with one addition: `writeCollection`. The reference branch itself has
54
+ * this function duplicated in a CLI-local `cli/src/collections.ts` (which
55
+ * also re-implements `readCollection`/`listCollectionFiles`/
56
+ * `resolveCollectionItemPaths` verbatim) rather than adding it here —
57
+ * exactly the "two parallel domains" duplication this migration's `app`
58
+ * layer exists to eliminate, so it's added here instead of carried
59
+ * forward as a second copy.
60
+ */
61
+ const fs = __importStar(require("node:fs"));
62
+ const path = __importStar(require("node:path"));
63
+ const core_1 = require("@ai-primitives-hub/core");
64
+ const yaml = __importStar(require("js-yaml"));
65
+ /**
66
+ * Load valid item kinds from the JSON schema (single source of truth).
67
+ * Falls back to a default list if schema cannot be loaded.
68
+ * @param schemaDir - Directory containing the schema file
69
+ * @returns Array of valid item kinds
70
+ */
71
+ function loadItemKindsFromSchema(schemaDir) {
72
+ try {
73
+ const schemaPath = schemaDir
74
+ ? path.join(schemaDir, 'collection.schema.json')
75
+ : path.join(core_1.SCHEMA_DIR, 'collection.schema.json');
76
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- JSON.parse returns any
77
+ const schema = JSON.parse(fs.readFileSync(schemaPath, 'utf8'));
78
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access -- Dynamic schema access
79
+ const kinds = schema?.properties?.items?.items?.properties?.kind?.enum;
80
+ if (Array.isArray(kinds) && kinds.length > 0) {
81
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return -- Schema enum is string[]
82
+ return kinds;
83
+ }
84
+ }
85
+ catch {
86
+ // Schema unavailable or malformed, use fallback
87
+ }
88
+ return ['prompt', 'instruction', 'agent', 'skill'];
89
+ }
90
+ /**
91
+ * Validate a collection file from disk.
92
+ * Checks YAML syntax, required fields, and referenced file existence.
93
+ * @param repoRoot - Repository root path
94
+ * @param collectionFile - Collection file path (absolute or repo-relative)
95
+ * @returns Validation result with parsed collection
96
+ */
97
+ function validateCollectionFile(repoRoot, collectionFile) {
98
+ const rel = collectionFile.replace(/\\/g, '/');
99
+ const abs = path.isAbsolute(collectionFile)
100
+ ? collectionFile
101
+ : path.join(repoRoot, collectionFile);
102
+ const errors = [];
103
+ if (!fs.existsSync(abs)) {
104
+ return { ok: false, errors: [`${rel}: Collection file not found`] };
105
+ }
106
+ let collection;
107
+ try {
108
+ collection = yaml.load(fs.readFileSync(abs, 'utf8'));
109
+ }
110
+ catch (e) {
111
+ const message = e instanceof Error ? e.message : String(e);
112
+ return { ok: false, errors: [`${rel}: YAML parse error: ${message}`] };
113
+ }
114
+ const schema = (0, core_1.validateCollectionObject)(collection, rel);
115
+ errors.push(...schema.errors);
116
+ if (Array.isArray(collection?.items)) {
117
+ collection.items.forEach((item, idx) => {
118
+ if (!item?.path || typeof item.path !== 'string') {
119
+ return;
120
+ }
121
+ let relPath;
122
+ try {
123
+ relPath = (0, core_1.normalizeRepoRelativePath)(item.path);
124
+ }
125
+ catch {
126
+ return;
127
+ }
128
+ const itemAbs = path.join(repoRoot, relPath);
129
+ if (!fs.existsSync(itemAbs)) {
130
+ errors.push(`${rel}: items[${idx}] referenced file not found: ${relPath}`);
131
+ }
132
+ });
133
+ }
134
+ return { ok: errors.length === 0, errors, collection };
135
+ }
136
+ /**
137
+ * Validate all collections in a repository, including duplicate detection.
138
+ * @param repoRoot - Repository root path
139
+ * @param collectionFiles - Array of collection file paths (repo-relative)
140
+ * @returns Validation result
141
+ */
142
+ function validateAllCollections(repoRoot, collectionFiles) {
143
+ const errors = [];
144
+ const fileResults = [];
145
+ const seenIds = new Map(); // id -> file path
146
+ const seenNames = new Map(); // name -> file path
147
+ for (const file of collectionFiles) {
148
+ const result = validateCollectionFile(repoRoot, file);
149
+ fileResults.push({ file, ...result });
150
+ errors.push(...result.errors);
151
+ // Check for duplicate IDs and names
152
+ if (result.collection) {
153
+ const { id, name } = result.collection;
154
+ if (id && seenIds.has(id)) {
155
+ errors.push(`${file}: Duplicate collection ID '${id}' (also in ${seenIds.get(id)})`);
156
+ }
157
+ else if (id) {
158
+ seenIds.set(id, file);
159
+ }
160
+ if (name && seenNames.has(name)) {
161
+ errors.push(`${file}: Duplicate collection name '${name}' (also in ${seenNames.get(name)})`);
162
+ }
163
+ else if (name) {
164
+ seenNames.set(name, file);
165
+ }
166
+ }
167
+ }
168
+ return { ok: errors.length === 0, errors, fileResults };
169
+ }
170
+ /**
171
+ * Generate markdown content for PR comment from validation result.
172
+ * @param result - Result from validateAllCollections
173
+ * @param totalFiles - Total number of collection files
174
+ * @returns Markdown content
175
+ */
176
+ function generateMarkdown(result, totalFiles) {
177
+ let md = '## 📋 Collection Validation Results\n\n';
178
+ if (result.ok) {
179
+ md += `✅ **All ${totalFiles} collection(s) validated successfully!**\n`;
180
+ }
181
+ else {
182
+ md += `❌ **Validation failed with ${result.errors.length} error(s)**\n\n`;
183
+ md += '### Errors\n\n';
184
+ result.errors.forEach((err) => {
185
+ md += `- ${err}\n`;
186
+ });
187
+ }
188
+ return md;
189
+ }
190
+ /**
191
+ * List all collection files in the repository.
192
+ * @param repoRoot - Repository root path
193
+ * @returns Array of collection file paths (repo-relative)
194
+ */
195
+ function listCollectionFiles(repoRoot) {
196
+ const collectionsDir = path.join(repoRoot, 'collections');
197
+ return fs
198
+ .readdirSync(collectionsDir)
199
+ .filter((f) => f.endsWith('.collection.yml'))
200
+ .map((f) => path.join('collections', f));
201
+ }
202
+ /**
203
+ * Read and parse a collection YAML file.
204
+ * @param repoRoot - Repository root path
205
+ * @param collectionFile - Collection file path (absolute or repo-relative)
206
+ * @returns Parsed collection object
207
+ * @throws {Error} if file is invalid YAML or not an object
208
+ */
209
+ function readCollection(repoRoot, collectionFile) {
210
+ const abs = path.isAbsolute(collectionFile)
211
+ ? collectionFile
212
+ : path.join(repoRoot, collectionFile);
213
+ const content = fs.readFileSync(abs, 'utf8');
214
+ const collection = yaml.load(content);
215
+ if (!collection || typeof collection !== 'object') {
216
+ throw new Error(`Invalid collection YAML: ${collectionFile}`);
217
+ }
218
+ // Ensure items array is initialized
219
+ if (!collection.items) {
220
+ collection.items = [];
221
+ }
222
+ return collection;
223
+ }
224
+ /**
225
+ * Write a collection object to a YAML file.
226
+ * @param repoRoot - Repository root path
227
+ * @param collectionFile - Collection file path (absolute or repo-relative)
228
+ * @param collection - Collection object to write
229
+ */
230
+ function writeCollection(repoRoot, collectionFile, collection) {
231
+ const abs = path.isAbsolute(collectionFile)
232
+ ? collectionFile
233
+ : path.join(repoRoot, collectionFile);
234
+ const content = yaml.dump(collection, { indent: 2, lineWidth: -1 });
235
+ fs.writeFileSync(abs, content, 'utf8');
236
+ }
237
+ /**
238
+ * Recursively list all files in a directory.
239
+ * @param dirPath - Absolute path to directory
240
+ * @param basePath - Base path for relative paths
241
+ * @returns Array of repo-relative file paths
242
+ */
243
+ function listFilesRecursively(dirPath, basePath) {
244
+ const results = [];
245
+ const entries = fs.readdirSync(dirPath, { withFileTypes: true });
246
+ for (const entry of entries) {
247
+ const fullPath = path.join(dirPath, entry.name);
248
+ if (entry.isDirectory()) {
249
+ results.push(...listFilesRecursively(fullPath, basePath));
250
+ }
251
+ else {
252
+ const relPath = path.relative(basePath, fullPath).replaceAll('\\', '/');
253
+ results.push(relPath);
254
+ }
255
+ }
256
+ return results;
257
+ }
258
+ /**
259
+ * Resolve all item paths referenced in a collection.
260
+ * For skills, expands the skill directory to include all files.
261
+ * @param repoRoot - Repository root path
262
+ * @param collection - Parsed collection object
263
+ * @returns Array of normalized repo-relative paths
264
+ */
265
+ function resolveCollectionItemPaths(repoRoot, collection) {
266
+ const items = Array.isArray(collection.items) ? collection.items : [];
267
+ const allPaths = [];
268
+ for (const item of items) {
269
+ if (!item?.path) {
270
+ continue;
271
+ }
272
+ const normalizedPath = (0, core_1.normalizeRepoRelativePath)(item.path);
273
+ if (item.kind === 'skill') {
274
+ // For skills, the path points to SKILL.md but we need the entire directory
275
+ const skillDir = path.dirname(path.join(repoRoot, normalizedPath));
276
+ if (fs.existsSync(skillDir) && fs.statSync(skillDir).isDirectory()) {
277
+ const skillFiles = listFilesRecursively(skillDir, repoRoot);
278
+ allPaths.push(...skillFiles);
279
+ }
280
+ else {
281
+ // Fallback: just include the path as-is if directory doesn't exist
282
+ allPaths.push(normalizedPath);
283
+ }
284
+ }
285
+ else {
286
+ allPaths.push(normalizedPath);
287
+ }
288
+ }
289
+ return allPaths;
290
+ }
291
+ //# sourceMappingURL=read-collection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-collection.js","sourceRoot":"","sources":["../../src/collection/read-collection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,0DAiBC;AASD,wDA8CC;AAQD,wDAiCC;AAQD,4CAcC;AAOD,kDAMC;AASD,wCAiBC;AAQD,0CAMC;AA8BD,gEA2BC;AA1RD;;;;;;;;;;;;;;;;GAgBG;AACH,4CAA8B;AA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GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC;YACnE,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;gBACnE,MAAM,UAAU,GAAG,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;gBAC5D,QAAQ,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC;YAC/B,CAAC;iBAAM,CAAC;gBACN,mEAAmE;gBACnE,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Context detection implementation.
3
+ *
4
+ * Analyzes project structure and environment to detect tech stack,
5
+ * domain, and activity information.
6
+ *
7
+ * Ported unchanged from the reference branch's
8
+ * `app/src/context-detection/detector.ts`, including its direct
9
+ * `node:fs/promises` usage (not routed through `core`'s `FileSystem`
10
+ * port) and its three still-stubbed activity signals
11
+ * (`getRecentFiles`/`getGitBranch`/`getLastCommitMessage`, each
12
+ * documented in the reference as "for now" placeholders) — ported
13
+ * as-is per this migration's behavior-parity discipline, not
14
+ * opportunistically completed or re-plumbed through ports here.
15
+ * @module context-detection/detector
16
+ */
17
+ import type { ContextDetectionOptions, DetectedContext } from './types';
18
+ /**
19
+ * Context detector class.
20
+ */
21
+ export declare class ContextDetector {
22
+ private readonly options;
23
+ constructor(options: ContextDetectionOptions);
24
+ /**
25
+ * Detect languages from package dependencies.
26
+ * @param deps Package dependencies.
27
+ * @returns Detected languages.
28
+ */
29
+ private detectLanguages;
30
+ /**
31
+ * Detect frameworks from package dependencies.
32
+ * @param deps Package dependencies.
33
+ * @returns Detected frameworks.
34
+ */
35
+ private detectFrameworks;
36
+ /**
37
+ * Detect build tools from package dependencies.
38
+ * @param deps Package dependencies.
39
+ * @returns Detected build tools.
40
+ */
41
+ private detectBuildTools;
42
+ /**
43
+ * Detect test frameworks from package dependencies.
44
+ * @param deps Package dependencies.
45
+ * @returns Detected test frameworks.
46
+ */
47
+ private detectTestFrameworks;
48
+ /**
49
+ * Detect tech stack from project files.
50
+ * @returns Tech stack information.
51
+ */
52
+ private detectTechStack;
53
+ /**
54
+ * Detect technical domain from directory structure.
55
+ * @param dirs Directory names.
56
+ * @returns Technical domain.
57
+ */
58
+ private detectTechnicalDomain;
59
+ /**
60
+ * Detect category from directory structure.
61
+ * @param dirs Directory names.
62
+ * @returns Category.
63
+ */
64
+ private detectCategory;
65
+ /**
66
+ * Detect business domain from file names.
67
+ * @param files File names.
68
+ * @returns Business domain.
69
+ */
70
+ private detectBusinessDomain;
71
+ /**
72
+ * Detect domain from project structure.
73
+ * @returns Domain information.
74
+ */
75
+ private detectDomain;
76
+ /**
77
+ * Detect activity from recent files and git history.
78
+ * @returns Activity information.
79
+ */
80
+ private detectActivity;
81
+ /**
82
+ * Get recently modified files.
83
+ * @returns List of recent file paths.
84
+ */
85
+ private getRecentFiles;
86
+ /**
87
+ * Get current git branch.
88
+ * @returns Git branch name or undefined.
89
+ */
90
+ private getGitBranch;
91
+ /**
92
+ * Get last commit message.
93
+ * @returns Last commit message or undefined.
94
+ */
95
+ private getLastCommitMessage;
96
+ /**
97
+ * Check if a file exists.
98
+ * @param filePath File path.
99
+ * @returns True if file exists.
100
+ */
101
+ private fileExists;
102
+ /**
103
+ * Read a file.
104
+ * @param filePath File path.
105
+ * @returns File content.
106
+ */
107
+ private readFile;
108
+ /**
109
+ * List directories in a path.
110
+ * @param dirPath Directory path.
111
+ * @returns List of directory names.
112
+ */
113
+ private listDirectories;
114
+ /**
115
+ * List files in a path.
116
+ * @param dirPath Directory path.
117
+ * @returns List of file names.
118
+ */
119
+ private listFiles;
120
+ /**
121
+ * Detect context from working directory.
122
+ * @returns Detected context.
123
+ */
124
+ detect(): Promise<DetectedContext>;
125
+ }
126
+ //# sourceMappingURL=detector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detector.d.ts","sourceRoot":"","sources":["../../src/context-detection/detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAEV,uBAAuB,EACvB,eAAe,EAGhB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA0B;gBAEtC,OAAO,EAAE,uBAAuB;IAQ5C;;;;OAIG;IACH,OAAO,CAAC,eAAe;IAiBvB;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAuBxB;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAiBxB;;;;OAIG;IACH,OAAO,CAAC,oBAAoB;IAc5B;;;OAGG;YACW,eAAe;IAmE7B;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;IAgB7B;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAgBtB;;;;OAIG;IACH,OAAO,CAAC,oBAAoB;IAgB5B;;;OAGG;YACW,YAAY;IAW1B;;;OAGG;YACW,cAAc;IAa5B;;;OAGG;YACW,cAAc;IAO5B;;;OAGG;YACW,YAAY;IAO1B;;;OAGG;YACW,oBAAoB;IAOlC;;;;OAIG;YACW,UAAU;IAYxB;;;;OAIG;YACW,QAAQ;IAKtB;;;;OAIG;YACW,eAAe;IAU7B;;;;OAIG;YACW,SAAS;IAUvB;;;OAGG;IACU,MAAM,IAAI,OAAO,CAAC,eAAe,CAAC;CAYhD"}