@ai-primitives-hub/core 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.
- package/README.md +18 -0
- package/dist/domain/bundle/id.d.ts +60 -0
- package/dist/domain/bundle/id.d.ts.map +1 -0
- package/dist/domain/bundle/id.js +75 -0
- package/dist/domain/bundle/id.js.map +1 -0
- package/dist/domain/bundle/identity-matcher.d.ts +48 -0
- package/dist/domain/bundle/identity-matcher.d.ts.map +1 -0
- package/dist/domain/bundle/identity-matcher.js +57 -0
- package/dist/domain/bundle/identity-matcher.js.map +1 -0
- package/dist/domain/bundle/types.d.ts +138 -0
- package/dist/domain/bundle/types.d.ts.map +1 -0
- package/dist/domain/bundle/types.js +17 -0
- package/dist/domain/bundle/types.js.map +1 -0
- package/dist/domain/bundle/version.d.ts +51 -0
- package/dist/domain/bundle/version.d.ts.map +1 -0
- package/dist/domain/bundle/version.js +176 -0
- package/dist/domain/bundle/version.js.map +1 -0
- package/dist/domain/collection/manifest-validator.d.ts +47 -0
- package/dist/domain/collection/manifest-validator.d.ts.map +1 -0
- package/dist/domain/collection/manifest-validator.js +83 -0
- package/dist/domain/collection/manifest-validator.js.map +1 -0
- package/dist/domain/collection/types.d.ts +201 -0
- package/dist/domain/collection/types.d.ts.map +1 -0
- package/dist/domain/collection/types.js +17 -0
- package/dist/domain/collection/types.js.map +1 -0
- package/dist/domain/collection/validate.d.ts +51 -0
- package/dist/domain/collection/validate.d.ts.map +1 -0
- package/dist/domain/collection/validate.js +263 -0
- package/dist/domain/collection/validate.js.map +1 -0
- package/dist/domain/discovery/types.d.ts +95 -0
- package/dist/domain/discovery/types.d.ts.map +1 -0
- package/dist/domain/discovery/types.js +13 -0
- package/dist/domain/discovery/types.js.map +1 -0
- package/dist/domain/errors.d.ts +23 -0
- package/dist/domain/errors.d.ts.map +1 -0
- package/dist/domain/errors.js +41 -0
- package/dist/domain/errors.js.map +1 -0
- package/dist/domain/hub/types.d.ts +254 -0
- package/dist/domain/hub/types.d.ts.map +1 -0
- package/dist/domain/hub/types.js +11 -0
- package/dist/domain/hub/types.js.map +1 -0
- package/dist/domain/hub/validate.d.ts +40 -0
- package/dist/domain/hub/validate.d.ts.map +1 -0
- package/dist/domain/hub/validate.js +89 -0
- package/dist/domain/hub/validate.js.map +1 -0
- package/dist/domain/index.d.ts +31 -0
- package/dist/domain/index.d.ts.map +1 -0
- package/dist/domain/index.js +47 -0
- package/dist/domain/index.js.map +1 -0
- package/dist/domain/install/copilot-file-type.d.ts +84 -0
- package/dist/domain/install/copilot-file-type.d.ts.map +1 -0
- package/dist/domain/install/copilot-file-type.js +190 -0
- package/dist/domain/install/copilot-file-type.js.map +1 -0
- package/dist/domain/install/installable.d.ts +58 -0
- package/dist/domain/install/installable.d.ts.map +1 -0
- package/dist/domain/install/installable.js +36 -0
- package/dist/domain/install/installable.js.map +1 -0
- package/dist/domain/install/layout.d.ts +84 -0
- package/dist/domain/install/layout.d.ts.map +1 -0
- package/dist/domain/install/layout.js +70 -0
- package/dist/domain/install/layout.js.map +1 -0
- package/dist/domain/install/target.d.ts +70 -0
- package/dist/domain/install/target.d.ts.map +1 -0
- package/dist/domain/install/target.js +43 -0
- package/dist/domain/install/target.js.map +1 -0
- package/dist/domain/install/transform.d.ts +47 -0
- package/dist/domain/install/transform.d.ts.map +1 -0
- package/dist/domain/install/transform.js +24 -0
- package/dist/domain/install/transform.js.map +1 -0
- package/dist/domain/install/types.d.ts +51 -0
- package/dist/domain/install/types.d.ts.map +1 -0
- package/dist/domain/install/types.js +3 -0
- package/dist/domain/install/types.js.map +1 -0
- package/dist/domain/primitive/types.d.ts +59 -0
- package/dist/domain/primitive/types.d.ts.map +1 -0
- package/dist/domain/primitive/types.js +22 -0
- package/dist/domain/primitive/types.js.map +1 -0
- package/dist/domain/registry/guards.d.ts +28 -0
- package/dist/domain/registry/guards.d.ts.map +1 -0
- package/dist/domain/registry/guards.js +33 -0
- package/dist/domain/registry/guards.js.map +1 -0
- package/dist/domain/registry/settings.d.ts +49 -0
- package/dist/domain/registry/settings.d.ts.map +1 -0
- package/dist/domain/registry/settings.js +3 -0
- package/dist/domain/registry/settings.js.map +1 -0
- package/dist/domain/registry/types.d.ts +91 -0
- package/dist/domain/registry/types.d.ts.map +1 -0
- package/dist/domain/registry/types.js +3 -0
- package/dist/domain/registry/types.js.map +1 -0
- package/dist/domain/registry-error.d.ts +69 -0
- package/dist/domain/registry-error.d.ts.map +1 -0
- package/dist/domain/registry-error.js +87 -0
- package/dist/domain/registry-error.js.map +1 -0
- package/dist/domain/scaffold/index.d.ts +9 -0
- package/dist/domain/scaffold/index.d.ts.map +1 -0
- package/dist/domain/scaffold/index.js +13 -0
- package/dist/domain/scaffold/index.js.map +1 -0
- package/dist/domain/scaffold/types.d.ts +135 -0
- package/dist/domain/scaffold/types.d.ts.map +1 -0
- package/dist/domain/scaffold/types.js +44 -0
- package/dist/domain/scaffold/types.js.map +1 -0
- package/dist/domain/skill/validate.d.ts +52 -0
- package/dist/domain/skill/validate.d.ts.map +1 -0
- package/dist/domain/skill/validate.js +108 -0
- package/dist/domain/skill/validate.js.map +1 -0
- package/dist/domain/source/types.d.ts +72 -0
- package/dist/domain/source/types.d.ts.map +1 -0
- package/dist/domain/source/types.js +14 -0
- package/dist/domain/source/types.js.map +1 -0
- package/dist/domain/source-id.d.ts +41 -0
- package/dist/domain/source-id.d.ts.map +1 -0
- package/dist/domain/source-id.js +90 -0
- package/dist/domain/source-id.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +74 -0
- package/dist/index.js.map +1 -0
- package/dist/ports/app-storage.d.ts +65 -0
- package/dist/ports/app-storage.d.ts.map +1 -0
- package/dist/ports/app-storage.js +22 -0
- package/dist/ports/app-storage.js.map +1 -0
- package/dist/ports/bundle-downloader.d.ts +28 -0
- package/dist/ports/bundle-downloader.d.ts.map +1 -0
- package/dist/ports/bundle-downloader.js +3 -0
- package/dist/ports/bundle-downloader.js.map +1 -0
- package/dist/ports/bundle-extractor.d.ts +21 -0
- package/dist/ports/bundle-extractor.d.ts.map +1 -0
- package/dist/ports/bundle-extractor.js +8 -0
- package/dist/ports/bundle-extractor.js.map +1 -0
- package/dist/ports/clock.d.ts +29 -0
- package/dist/ports/clock.d.ts.map +1 -0
- package/dist/ports/clock.js +13 -0
- package/dist/ports/clock.js.map +1 -0
- package/dist/ports/copilot-sdk.d.ts +80 -0
- package/dist/ports/copilot-sdk.d.ts.map +1 -0
- package/dist/ports/copilot-sdk.js +16 -0
- package/dist/ports/copilot-sdk.js.map +1 -0
- package/dist/ports/filesystem.d.ts +53 -0
- package/dist/ports/filesystem.d.ts.map +1 -0
- package/dist/ports/filesystem.js +14 -0
- package/dist/ports/filesystem.js.map +1 -0
- package/dist/ports/github-api.d.ts +62 -0
- package/dist/ports/github-api.d.ts.map +1 -0
- package/dist/ports/github-api.js +19 -0
- package/dist/ports/github-api.js.map +1 -0
- package/dist/ports/http.d.ts +58 -0
- package/dist/ports/http.d.ts.map +1 -0
- package/dist/ports/http.js +12 -0
- package/dist/ports/http.js.map +1 -0
- package/dist/ports/index.d.ts +23 -0
- package/dist/ports/index.d.ts.map +1 -0
- package/dist/ports/index.js +39 -0
- package/dist/ports/index.js.map +1 -0
- package/dist/ports/layout-config-loader.d.ts +27 -0
- package/dist/ports/layout-config-loader.d.ts.map +1 -0
- package/dist/ports/layout-config-loader.js +3 -0
- package/dist/ports/layout-config-loader.js.map +1 -0
- package/dist/ports/process-runner.d.ts +31 -0
- package/dist/ports/process-runner.d.ts.map +1 -0
- package/dist/ports/process-runner.js +14 -0
- package/dist/ports/process-runner.js.map +1 -0
- package/dist/ports/registry-operations.d.ts +157 -0
- package/dist/ports/registry-operations.d.ts.map +1 -0
- package/dist/ports/registry-operations.js +3 -0
- package/dist/ports/registry-operations.js.map +1 -0
- package/dist/ports/resource-transformer.d.ts +28 -0
- package/dist/ports/resource-transformer.d.ts.map +1 -0
- package/dist/ports/resource-transformer.js +3 -0
- package/dist/ports/resource-transformer.js.map +1 -0
- package/dist/ports/source-adapter.d.ts +43 -0
- package/dist/ports/source-adapter.d.ts.map +1 -0
- package/dist/ports/source-adapter.js +3 -0
- package/dist/ports/source-adapter.js.map +1 -0
- package/dist/ports/source-resolver.d.ts +19 -0
- package/dist/ports/source-resolver.d.ts.map +1 -0
- package/dist/ports/source-resolver.js +3 -0
- package/dist/ports/source-resolver.js.map +1 -0
- package/dist/ports/target-writer.d.ts +37 -0
- package/dist/ports/target-writer.d.ts.map +1 -0
- package/dist/ports/target-writer.js +3 -0
- package/dist/ports/target-writer.js.map +1 -0
- package/dist/ports/telemetry.d.ts +22 -0
- package/dist/ports/telemetry.d.ts.map +1 -0
- package/dist/ports/telemetry.js +11 -0
- package/dist/ports/telemetry.js.map +1 -0
- package/dist/ports/update-notifier.d.ts +22 -0
- package/dist/ports/update-notifier.d.ts.map +1 -0
- package/dist/ports/update-notifier.js +12 -0
- package/dist/ports/update-notifier.js.map +1 -0
- package/dist/ports/update-store.d.ts +25 -0
- package/dist/ports/update-store.d.ts.map +1 -0
- package/dist/ports/update-store.js +12 -0
- package/dist/ports/update-store.js.map +1 -0
- package/dist/public/schemas/apm.schema.json +59 -0
- package/dist/public/schemas/collection.schema.json +345 -0
- package/dist/public/schemas/default-hubs-config.schema.json +68 -0
- package/dist/public/schemas/hub-config.schema.json +389 -0
- package/dist/public/schemas/lockfile.schema.json +243 -0
- package/package.json +50 -0
|
@@ -0,0 +1,263 @@
|
|
|
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.DEFAULT_VALIDATION_RULES = void 0;
|
|
37
|
+
exports.validateCollectionId = validateCollectionId;
|
|
38
|
+
exports.validateVersion = validateVersion;
|
|
39
|
+
exports.validateItemKind = validateItemKind;
|
|
40
|
+
exports.normalizeRepoRelativePath = normalizeRepoRelativePath;
|
|
41
|
+
exports.isSafeRepoRelativePath = isSafeRepoRelativePath;
|
|
42
|
+
exports.validateCollectionObject = validateCollectionObject;
|
|
43
|
+
/**
|
|
44
|
+
* Collection validation utilities (pure functions).
|
|
45
|
+
* @module domain/collection/validate
|
|
46
|
+
*
|
|
47
|
+
* Pure validation logic for collection files.
|
|
48
|
+
* File-IO dependent functions are in `app/collection/read-collection.ts`.
|
|
49
|
+
*
|
|
50
|
+
* Ported unchanged from the reference branch's
|
|
51
|
+
* `core/src/domain/collection/validate.ts`, save for dropping its trailing
|
|
52
|
+
* `export { type ValidationResult, type ObjectValidationResult } from
|
|
53
|
+
* './types'` — this barrel already re-exports every `./collection/types`
|
|
54
|
+
* name via `domain/index.ts`'s own `export * from './collection/types'`,
|
|
55
|
+
* so repeating it here would create an ambiguous star-export binding.
|
|
56
|
+
*/
|
|
57
|
+
const path = __importStar(require("node:path"));
|
|
58
|
+
/**
|
|
59
|
+
* Default validation rules for collections.
|
|
60
|
+
* Item kinds are loaded from the JSON schema for single source of truth.
|
|
61
|
+
*/
|
|
62
|
+
exports.DEFAULT_VALIDATION_RULES = {
|
|
63
|
+
collectionId: {
|
|
64
|
+
maxLength: 100,
|
|
65
|
+
pattern: /^[a-z0-9-]+$/,
|
|
66
|
+
description: 'lowercase letters, numbers, and hyphens only'
|
|
67
|
+
},
|
|
68
|
+
version: {
|
|
69
|
+
pattern: /^\d+\.\d+\.\d+$/,
|
|
70
|
+
default: '1.0.0',
|
|
71
|
+
description: 'semantic versioning format (X.Y.Z)'
|
|
72
|
+
},
|
|
73
|
+
itemKinds: ['prompt', 'instruction', 'chat-mode', 'agent', 'skill', 'plugin', 'hook'],
|
|
74
|
+
deprecatedKinds: {
|
|
75
|
+
chatmode: 'agent'
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Validate a collection ID.
|
|
80
|
+
* @param id - Collection ID to validate
|
|
81
|
+
* @param rules - Validation rules (uses DEFAULT_VALIDATION_RULES if not provided)
|
|
82
|
+
* @returns Validation result
|
|
83
|
+
*/
|
|
84
|
+
function validateCollectionId(id, rules = exports.DEFAULT_VALIDATION_RULES) {
|
|
85
|
+
if (!id || typeof id !== 'string') {
|
|
86
|
+
return { valid: false, error: 'Collection ID is required and must be a string' };
|
|
87
|
+
}
|
|
88
|
+
if (id.length > rules.collectionId.maxLength) {
|
|
89
|
+
return {
|
|
90
|
+
valid: false,
|
|
91
|
+
error: `Collection ID must be at most ${rules.collectionId.maxLength} characters (got ${id.length})`
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
if (!rules.collectionId.pattern.test(id)) {
|
|
95
|
+
return {
|
|
96
|
+
valid: false,
|
|
97
|
+
error: `Collection ID must contain only ${rules.collectionId.description}`
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return { valid: true };
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Validate a version string.
|
|
104
|
+
* @param version - Version string to validate
|
|
105
|
+
* @param rules - Validation rules (uses DEFAULT_VALIDATION_RULES if not provided)
|
|
106
|
+
* @returns Validation result with normalized version
|
|
107
|
+
*/
|
|
108
|
+
function validateVersion(version, rules = exports.DEFAULT_VALIDATION_RULES) {
|
|
109
|
+
// If no version provided, use default
|
|
110
|
+
if (version === undefined || version === null) {
|
|
111
|
+
return { valid: true, normalized: rules.version.default };
|
|
112
|
+
}
|
|
113
|
+
if (typeof version !== 'string') {
|
|
114
|
+
return { valid: false, error: 'Version must be a string' };
|
|
115
|
+
}
|
|
116
|
+
if (!rules.version.pattern.test(version)) {
|
|
117
|
+
return {
|
|
118
|
+
valid: false,
|
|
119
|
+
error: `Version must follow ${rules.version.description} (got "${version}")`
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
return { valid: true, normalized: version };
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Validate an item kind.
|
|
126
|
+
* @param kind - Item kind to validate
|
|
127
|
+
* @param rules - Validation rules (uses DEFAULT_VALIDATION_RULES if not provided)
|
|
128
|
+
* @returns Validation result
|
|
129
|
+
*/
|
|
130
|
+
function validateItemKind(kind, rules = exports.DEFAULT_VALIDATION_RULES) {
|
|
131
|
+
if (!kind || typeof kind !== 'string') {
|
|
132
|
+
return { valid: false, error: 'Item kind is required and must be a string' };
|
|
133
|
+
}
|
|
134
|
+
const normalizedKind = kind.toLowerCase();
|
|
135
|
+
// Check for deprecated kinds (chatmode)
|
|
136
|
+
if (rules.deprecatedKinds[normalizedKind]) {
|
|
137
|
+
const replacement = rules.deprecatedKinds[normalizedKind];
|
|
138
|
+
return {
|
|
139
|
+
valid: false,
|
|
140
|
+
error: `Item kind '${kind}' is deprecated. Use '${replacement}' instead`,
|
|
141
|
+
deprecated: true,
|
|
142
|
+
replacement
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
// Check for valid kinds
|
|
146
|
+
if (!rules.itemKinds.includes(normalizedKind)) {
|
|
147
|
+
return {
|
|
148
|
+
valid: false,
|
|
149
|
+
error: `Invalid item kind '${kind}'. Must be one of: ${rules.itemKinds.join(', ')}`
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
return { valid: true };
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Normalize a path to be repo-root relative.
|
|
156
|
+
* Uses POSIX normalization since collection paths are repo-root relative
|
|
157
|
+
* and should work consistently across platforms.
|
|
158
|
+
* @param p - Path to normalize
|
|
159
|
+
* @returns Normalized repo-relative path
|
|
160
|
+
* @throws {Error} if path is empty, traverses outside repo, or is absolute
|
|
161
|
+
*/
|
|
162
|
+
function normalizeRepoRelativePath(p) {
|
|
163
|
+
if (!p || typeof p !== 'string') {
|
|
164
|
+
throw new Error('path must be a non-empty string');
|
|
165
|
+
}
|
|
166
|
+
const s = String(p).trim().replaceAll('\\', '/').replace(/^\//, '');
|
|
167
|
+
if (!s) {
|
|
168
|
+
throw new Error('path must be a non-empty string');
|
|
169
|
+
}
|
|
170
|
+
// Use posix normalization since collection paths are repo-root relative.
|
|
171
|
+
const normalized = path.posix.normalize(s);
|
|
172
|
+
if (normalized.startsWith('../') || normalized === '..') {
|
|
173
|
+
throw new Error('path must not traverse outside repo');
|
|
174
|
+
}
|
|
175
|
+
if (normalized.startsWith('/')) {
|
|
176
|
+
throw new Error('path must be repo-root relative');
|
|
177
|
+
}
|
|
178
|
+
return normalized;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Check if a path is a safe repo-relative path.
|
|
182
|
+
* @param p - Path to check
|
|
183
|
+
* @returns True if path is valid and safe
|
|
184
|
+
*/
|
|
185
|
+
function isSafeRepoRelativePath(p) {
|
|
186
|
+
try {
|
|
187
|
+
normalizeRepoRelativePath(p);
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Validate a collection object structure.
|
|
196
|
+
* @param collection - Parsed collection object
|
|
197
|
+
* @param sourceLabel - Label for error messages
|
|
198
|
+
* @param rules - Validation rules (uses DEFAULT_VALIDATION_RULES if not provided)
|
|
199
|
+
* @returns Validation result
|
|
200
|
+
*/
|
|
201
|
+
function validateCollectionObject(collection, sourceLabel, rules = exports.DEFAULT_VALIDATION_RULES) {
|
|
202
|
+
const errors = [];
|
|
203
|
+
if (!collection || typeof collection !== 'object') {
|
|
204
|
+
return { ok: false, errors: [`${sourceLabel}: YAML did not parse to an object`] };
|
|
205
|
+
}
|
|
206
|
+
const col = collection;
|
|
207
|
+
// Validate collection ID
|
|
208
|
+
if (!col.id || typeof col.id !== 'string') {
|
|
209
|
+
errors.push(`${sourceLabel}: Missing required field: id`);
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
const idResult = validateCollectionId(col.id, rules);
|
|
213
|
+
if (!idResult.valid) {
|
|
214
|
+
errors.push(`${sourceLabel}: ${idResult.error}`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (!col.name || typeof col.name !== 'string') {
|
|
218
|
+
errors.push(`${sourceLabel}: Missing required field: name`);
|
|
219
|
+
}
|
|
220
|
+
// Validate version if present
|
|
221
|
+
if (col.version !== undefined) {
|
|
222
|
+
const versionResult = validateVersion(col.version, rules);
|
|
223
|
+
if (!versionResult.valid) {
|
|
224
|
+
errors.push(`${sourceLabel}: ${versionResult.error}`);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if (!Array.isArray(col.items)) {
|
|
228
|
+
errors.push(`${sourceLabel}: Missing required field: items (array)`);
|
|
229
|
+
}
|
|
230
|
+
if (Array.isArray(col.items)) {
|
|
231
|
+
col.items.forEach((item, idx) => {
|
|
232
|
+
const prefix = `${sourceLabel}: items[${idx}]`;
|
|
233
|
+
if (!item || typeof item !== 'object') {
|
|
234
|
+
errors.push(`${prefix}: must be an object`);
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
const it = item;
|
|
238
|
+
if (!it.path || typeof it.path !== 'string') {
|
|
239
|
+
errors.push(`${prefix}: Missing required field: path`);
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
try {
|
|
243
|
+
normalizeRepoRelativePath(it.path);
|
|
244
|
+
}
|
|
245
|
+
catch {
|
|
246
|
+
errors.push(`${prefix}: Invalid path (must be repo-root relative): ${it.path}`);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
if (!it.kind || typeof it.kind !== 'string') {
|
|
250
|
+
errors.push(`${prefix}: Missing required field: kind`);
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
// Validate item kind (including chatmode rejection)
|
|
254
|
+
const kindResult = validateItemKind(it.kind, rules);
|
|
255
|
+
if (!kindResult.valid) {
|
|
256
|
+
errors.push(`${prefix}: ${kindResult.error}`);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
return { ok: errors.length === 0, errors };
|
|
262
|
+
}
|
|
263
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/domain/collection/validate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,oDAoBC;AAQD,0CAkBC;AAQD,4CA2BC;AAUD,8DAmBC;A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YACzD,CAAC;iBAAM,CAAC;gBACN,oDAAoD;gBACpD,MAAM,UAAU,GAAG,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;gBACpD,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;oBACtB,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,KAAK,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC;gBAChD,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discovery domain types.
|
|
3
|
+
*
|
|
4
|
+
* Core type definitions for AI-powered resource discovery. These types
|
|
5
|
+
* are pure and have no dependencies on feature layers.
|
|
6
|
+
*
|
|
7
|
+
* Ported unchanged from the reference branch's
|
|
8
|
+
* `core/src/domain/discovery/types.ts`.
|
|
9
|
+
* @module domain/discovery/types
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Resource type discriminator.
|
|
13
|
+
*/
|
|
14
|
+
export type ResourceType = 'profile' | 'bundle' | 'primitive';
|
|
15
|
+
/**
|
|
16
|
+
* Branded type for recommendation ID to prevent confusion.
|
|
17
|
+
*/
|
|
18
|
+
export type RecommendationId = string & {
|
|
19
|
+
readonly _BRAND: 'RecommendationId';
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Branded type for profile draft ID to prevent confusion.
|
|
23
|
+
*/
|
|
24
|
+
export type ProfileDraftId = string & {
|
|
25
|
+
readonly _BRAND: 'ProfileDraftId';
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Resource recommendation with AI reasoning.
|
|
29
|
+
*/
|
|
30
|
+
export interface ResourceRecommendation {
|
|
31
|
+
/** Resource type: profile, bundle, or primitive */
|
|
32
|
+
readonly type: ResourceType;
|
|
33
|
+
/** Unique resource identifier */
|
|
34
|
+
readonly id: string;
|
|
35
|
+
/** Display name */
|
|
36
|
+
readonly name: string;
|
|
37
|
+
/** Brief description */
|
|
38
|
+
readonly description: string;
|
|
39
|
+
/** Relevance score (0-1) */
|
|
40
|
+
readonly relevanceScore: number;
|
|
41
|
+
/** AI-generated reasoning for recommendation */
|
|
42
|
+
readonly reasoning: string;
|
|
43
|
+
/** Source hub or repository */
|
|
44
|
+
readonly source: string;
|
|
45
|
+
/** Primitive kind (if applicable) */
|
|
46
|
+
readonly kind?: string;
|
|
47
|
+
/** Whether this is recommended by AI */
|
|
48
|
+
readonly aiRecommended: boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* User selection from recommendations.
|
|
52
|
+
*/
|
|
53
|
+
export interface ResourceSelection {
|
|
54
|
+
/** Resource identifier */
|
|
55
|
+
readonly id: string;
|
|
56
|
+
/** Whether selected */
|
|
57
|
+
readonly selected: boolean;
|
|
58
|
+
/** Selection timestamp */
|
|
59
|
+
readonly selectedAt?: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Profile draft for generation.
|
|
63
|
+
*/
|
|
64
|
+
export interface ProfileDraft {
|
|
65
|
+
/** Profile ID */
|
|
66
|
+
readonly id: string;
|
|
67
|
+
/** Profile name */
|
|
68
|
+
readonly name: string;
|
|
69
|
+
/** Profile description */
|
|
70
|
+
readonly description: string;
|
|
71
|
+
/** Profile icon */
|
|
72
|
+
readonly icon?: string;
|
|
73
|
+
/** Selected resources */
|
|
74
|
+
readonly selections: readonly ResourceSelection[];
|
|
75
|
+
/** Draft creation timestamp */
|
|
76
|
+
readonly createdAt: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Discovery options.
|
|
80
|
+
*/
|
|
81
|
+
export interface DiscoveryOptions {
|
|
82
|
+
/** Enable AI-powered recommendations */
|
|
83
|
+
readonly enableAI: boolean;
|
|
84
|
+
/** Enable interactive mode */
|
|
85
|
+
readonly interactive: boolean;
|
|
86
|
+
/** Working directory */
|
|
87
|
+
readonly cwd: string;
|
|
88
|
+
/** Index file path */
|
|
89
|
+
readonly indexFile?: string;
|
|
90
|
+
/** Maximum recommendations */
|
|
91
|
+
readonly limit?: number;
|
|
92
|
+
/** Filter by primitive kinds */
|
|
93
|
+
readonly kinds?: readonly string[];
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/domain/discovery/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAC;AAE9D;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAEhF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAE5E;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,mDAAmD;IACnD,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,iCAAiC;IACjC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,mBAAmB;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,wBAAwB;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,4BAA4B;IAC5B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,gDAAgD;IAChD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,+BAA+B;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,qCAAqC;IACrC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;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+
*
|
|
5
|
+
* Core type definitions for AI-powered resource discovery. These types
|
|
6
|
+
* are pure and have no dependencies on feature layers.
|
|
7
|
+
*
|
|
8
|
+
* Ported unchanged from the reference branch's
|
|
9
|
+
* `core/src/domain/discovery/types.ts`.
|
|
10
|
+
* @module domain/discovery/types
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/domain/discovery/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure error categorization.
|
|
3
|
+
*
|
|
4
|
+
* Ported from the extension's `src/utils/error-handler.ts`
|
|
5
|
+
* (`ErrorHandler.categorize` + its four private keyword-matching
|
|
6
|
+
* predicates) — that file also pulls in `vscode` (for its `handle()`
|
|
7
|
+
* method's user-facing notifications), so only this pure, side-effect-free
|
|
8
|
+
* slice moves to `core`. The extension's `ErrorHandler.categorize`
|
|
9
|
+
* delegates here; `app` use-cases that need the same classification
|
|
10
|
+
* (e.g. deciding whether an update-enrichment failure is worth retrying)
|
|
11
|
+
* call it directly.
|
|
12
|
+
* @module domain/errors
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Error categories for consistent error handling.
|
|
16
|
+
*/
|
|
17
|
+
export type ErrorCategory = 'network' | 'notfound' | 'validation' | 'authentication' | 'unexpected';
|
|
18
|
+
/**
|
|
19
|
+
* Categorize an error based on keyword-matching its message.
|
|
20
|
+
* @param error - The error to categorize.
|
|
21
|
+
*/
|
|
22
|
+
export declare function categorizeError(error: Error): ErrorCategory;
|
|
23
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/domain/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,UAAU,GAAG,YAAY,GAAG,gBAAgB,GAAG,YAAY,CAAC;AAOpG;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,GAAG,aAAa,CAgB3D"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Pure error categorization.
|
|
4
|
+
*
|
|
5
|
+
* Ported from the extension's `src/utils/error-handler.ts`
|
|
6
|
+
* (`ErrorHandler.categorize` + its four private keyword-matching
|
|
7
|
+
* predicates) — that file also pulls in `vscode` (for its `handle()`
|
|
8
|
+
* method's user-facing notifications), so only this pure, side-effect-free
|
|
9
|
+
* slice moves to `core`. The extension's `ErrorHandler.categorize`
|
|
10
|
+
* delegates here; `app` use-cases that need the same classification
|
|
11
|
+
* (e.g. deciding whether an update-enrichment failure is worth retrying)
|
|
12
|
+
* call it directly.
|
|
13
|
+
* @module domain/errors
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.categorizeError = categorizeError;
|
|
17
|
+
const NETWORK_KEYWORDS = ['network', 'timeout', 'econnrefused', 'enotfound', 'econnreset', 'etimedout', 'connection', 'dns', 'socket'];
|
|
18
|
+
const NOT_FOUND_KEYWORDS = ['not found', '404', 'does not exist', 'missing', 'unavailable'];
|
|
19
|
+
const VALIDATION_KEYWORDS = ['invalid', 'validation', 'schema', 'format', 'required', 'malformed'];
|
|
20
|
+
const AUTHENTICATION_KEYWORDS = ['unauthorized', 'forbidden', 'authentication', 'token', 'credentials', '401', '403'];
|
|
21
|
+
/**
|
|
22
|
+
* Categorize an error based on keyword-matching its message.
|
|
23
|
+
* @param error - The error to categorize.
|
|
24
|
+
*/
|
|
25
|
+
function categorizeError(error) {
|
|
26
|
+
const message = error.message.toLowerCase();
|
|
27
|
+
if (NETWORK_KEYWORDS.some((keyword) => message.includes(keyword))) {
|
|
28
|
+
return 'network';
|
|
29
|
+
}
|
|
30
|
+
if (NOT_FOUND_KEYWORDS.some((keyword) => message.includes(keyword))) {
|
|
31
|
+
return 'notfound';
|
|
32
|
+
}
|
|
33
|
+
if (VALIDATION_KEYWORDS.some((keyword) => message.includes(keyword))) {
|
|
34
|
+
return 'validation';
|
|
35
|
+
}
|
|
36
|
+
if (AUTHENTICATION_KEYWORDS.some((keyword) => message.includes(keyword))) {
|
|
37
|
+
return 'authentication';
|
|
38
|
+
}
|
|
39
|
+
return 'unexpected';
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/domain/errors.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;AAgBH,0CAgBC;AAzBD,MAAM,gBAAgB,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;AACvI,MAAM,kBAAkB,GAAG,CAAC,WAAW,EAAE,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;AAC5F,MAAM,mBAAmB,GAAG,CAAC,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;AACnG,MAAM,uBAAuB,GAAG,CAAC,cAAc,EAAE,WAAW,EAAE,gBAAgB,EAAE,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAEtH;;;GAGG;AACH,SAAgB,eAAe,CAAC,KAAY;IAC1C,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;IAE5C,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,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