@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,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copilot file type domain logic.
|
|
4
|
+
*
|
|
5
|
+
* Pure classification/naming rules for GitHub Copilot customization files
|
|
6
|
+
* (prompts, instructions, chatmodes, agents, skills): given a manifest
|
|
7
|
+
* item's file name/tags, decide its `CopilotFileType`, and given an id +
|
|
8
|
+
* type, compute the canonical on-disk file name.
|
|
9
|
+
*
|
|
10
|
+
* Ported verbatim from the extension's `src/utils/copilot-file-type-utils.ts`
|
|
11
|
+
* (migration plan §7.5 item 2) — that module becomes a thin re-export of
|
|
12
|
+
* this one. No IO, no framework imports: safe for both the extension and
|
|
13
|
+
* the CLI to depend on directly.
|
|
14
|
+
* @module domain/install/copilot-file-type
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.normalizePromptId = normalizePromptId;
|
|
18
|
+
exports.isSkillDirectory = isSkillDirectory;
|
|
19
|
+
exports.getSkillName = getSkillName;
|
|
20
|
+
exports.determineFileType = determineFileType;
|
|
21
|
+
exports.getTargetFileName = getTargetFileName;
|
|
22
|
+
exports.getRepositoryTargetDirectory = getRepositoryTargetDirectory;
|
|
23
|
+
exports.getFileExtension = getFileExtension;
|
|
24
|
+
/**
|
|
25
|
+
* Normalize a prompt ID to a safe string for use in file names.
|
|
26
|
+
*
|
|
27
|
+
* Replaces any characters that are not alphanumeric, hyphens, or underscores
|
|
28
|
+
* with hyphens. Also handles YAML parsing numeric-looking IDs as numbers.
|
|
29
|
+
* @param id - The prompt ID to normalize (can be string or number from YAML parsing)
|
|
30
|
+
* @returns A normalized string safe for use in file names
|
|
31
|
+
*/
|
|
32
|
+
function normalizePromptId(id) {
|
|
33
|
+
return String(id).replace(/[^a-zA-Z0-9-_]/g, '-');
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* File extension mappings for each Copilot file type
|
|
37
|
+
*/
|
|
38
|
+
const FILE_EXTENSIONS = {
|
|
39
|
+
prompt: '.prompt.md',
|
|
40
|
+
instructions: '.instructions.md',
|
|
41
|
+
chatmode: '.chatmode.md',
|
|
42
|
+
agent: '.agent.md',
|
|
43
|
+
skill: '' // Skills are directories, not single files
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Repository directory mappings for each Copilot file type
|
|
47
|
+
* These follow VS Code Copilot conventions for repository-level customizations
|
|
48
|
+
*/
|
|
49
|
+
const REPOSITORY_DIRECTORIES = {
|
|
50
|
+
prompt: '.github/prompts/',
|
|
51
|
+
instructions: '.github/instructions/',
|
|
52
|
+
chatmode: '.github/agents/', // Chatmodes are associated with agents
|
|
53
|
+
agent: '.github/agents/',
|
|
54
|
+
skill: '.github/skills/'
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Common skill directory patterns
|
|
58
|
+
*/
|
|
59
|
+
const SKILL_DIRECTORY_PATTERNS = [
|
|
60
|
+
/^skills[/\\]/i, // skills/skill-name
|
|
61
|
+
/[/\\]skills[/\\]/i // path/to/skills/skill-name
|
|
62
|
+
];
|
|
63
|
+
/**
|
|
64
|
+
* Check if a path represents a skill directory.
|
|
65
|
+
*
|
|
66
|
+
* Skill directories are identified by:
|
|
67
|
+
* 1. Being under a 'skills/' parent directory
|
|
68
|
+
* 2. Containing a SKILL.md file (when checking contents)
|
|
69
|
+
* @param filePath - The path to check
|
|
70
|
+
* @returns True if the path represents a skill directory
|
|
71
|
+
*/
|
|
72
|
+
function isSkillDirectory(filePath) {
|
|
73
|
+
const normalizedPath = filePath.replace(/\\/g, '/');
|
|
74
|
+
// Check if path is under a skills directory
|
|
75
|
+
return SKILL_DIRECTORY_PATTERNS.some((pattern) => pattern.test(normalizedPath));
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Extract the skill name from a skill directory path.
|
|
79
|
+
*
|
|
80
|
+
* Given a path like 'skills/my-skill' or 'path/to/skills/my-skill',
|
|
81
|
+
* returns 'my-skill'.
|
|
82
|
+
* @param skillPath - The path to the skill directory
|
|
83
|
+
* @returns The skill name, or null if not a valid skill path
|
|
84
|
+
*/
|
|
85
|
+
function getSkillName(skillPath) {
|
|
86
|
+
const normalizedPath = skillPath.replace(/\\/g, '/');
|
|
87
|
+
// Match patterns like 'skills/skill-name' or 'path/skills/skill-name'
|
|
88
|
+
const match = normalizedPath.match(/(?:^|[/\\])skills[/\\]([^/\\]+)(?:[/\\]|$)/i);
|
|
89
|
+
if (match && match[1]) {
|
|
90
|
+
return match[1];
|
|
91
|
+
}
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Determine the Copilot file type from a file name and optional tags.
|
|
96
|
+
*
|
|
97
|
+
* Detection priority:
|
|
98
|
+
* 1. File extension patterns (e.g., .prompt.md, .agent.md)
|
|
99
|
+
* 2. Directory-based detection (e.g., any .md file in an agents/ directory)
|
|
100
|
+
* 3. Special file names (e.g., SKILL.md)
|
|
101
|
+
* 4. Tags from manifest
|
|
102
|
+
* 5. Filename patterns (e.g., contains "instructions")
|
|
103
|
+
* 6. Default to 'prompt'
|
|
104
|
+
* @param fileName - The file name or path to analyze
|
|
105
|
+
* @param tags - Optional tags from the manifest
|
|
106
|
+
* @returns The detected CopilotFileType
|
|
107
|
+
*/
|
|
108
|
+
function determineFileType(fileName, tags) {
|
|
109
|
+
// Get just the file name without directory path
|
|
110
|
+
const baseName = fileName.replace(/^.*[/\\]/, '');
|
|
111
|
+
const lowerBaseName = baseName.toLowerCase();
|
|
112
|
+
// 1. Check for specific file extension patterns (highest priority)
|
|
113
|
+
if (lowerBaseName.endsWith('.prompt.md')) {
|
|
114
|
+
return 'prompt';
|
|
115
|
+
}
|
|
116
|
+
if (lowerBaseName.endsWith('.instructions.md')) {
|
|
117
|
+
return 'instructions';
|
|
118
|
+
}
|
|
119
|
+
if (lowerBaseName.endsWith('.chatmode.md')) {
|
|
120
|
+
return 'chatmode';
|
|
121
|
+
}
|
|
122
|
+
if (lowerBaseName.endsWith('.agent.md')) {
|
|
123
|
+
return 'agent';
|
|
124
|
+
}
|
|
125
|
+
// 2. Check if file is in an agents/ directory
|
|
126
|
+
// VS Code no longer requires .agent.md suffix — any .md in agents/ is an agent
|
|
127
|
+
const normalizedPath = fileName.replace(/\\/g, '/');
|
|
128
|
+
if (lowerBaseName.endsWith('.md') && /(?:^|[/])agents[/]/i.test(normalizedPath)) {
|
|
129
|
+
return 'agent';
|
|
130
|
+
}
|
|
131
|
+
// 3. Check for special file names
|
|
132
|
+
if (lowerBaseName === 'skill.md') {
|
|
133
|
+
return 'skill';
|
|
134
|
+
}
|
|
135
|
+
// 4. Check tags if provided
|
|
136
|
+
if (tags && tags.length > 0) {
|
|
137
|
+
const lowerTags = tags.map((t) => t.toLowerCase());
|
|
138
|
+
if (lowerTags.includes('instructions')) {
|
|
139
|
+
return 'instructions';
|
|
140
|
+
}
|
|
141
|
+
if (lowerTags.includes('chatmode') || lowerTags.includes('mode')) {
|
|
142
|
+
return 'chatmode';
|
|
143
|
+
}
|
|
144
|
+
if (lowerTags.includes('agent')) {
|
|
145
|
+
return 'agent';
|
|
146
|
+
}
|
|
147
|
+
if (lowerTags.includes('skill')) {
|
|
148
|
+
return 'skill';
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
// 5. Check filename patterns
|
|
152
|
+
if (lowerBaseName.includes('instructions')) {
|
|
153
|
+
return 'instructions';
|
|
154
|
+
}
|
|
155
|
+
// 6. Default to prompt
|
|
156
|
+
return 'prompt';
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Generate the target file name for a given ID and file type.
|
|
160
|
+
* @param id - The prompt/agent/etc. identifier
|
|
161
|
+
* @param type - The Copilot file type
|
|
162
|
+
* @returns The target file name with appropriate extension
|
|
163
|
+
*/
|
|
164
|
+
function getTargetFileName(id, type) {
|
|
165
|
+
// Skills use SKILL.md as the main file
|
|
166
|
+
if (type === 'skill') {
|
|
167
|
+
return 'SKILL.md';
|
|
168
|
+
}
|
|
169
|
+
return `${id}${FILE_EXTENSIONS[type]}`;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Get the repository target directory for a given file type.
|
|
173
|
+
*
|
|
174
|
+
* Returns the appropriate .github/ subdirectory where files of this type
|
|
175
|
+
* should be placed for repository-level installation.
|
|
176
|
+
* @param type - The Copilot file type
|
|
177
|
+
* @returns The repository directory path (e.g., '.github/prompts/')
|
|
178
|
+
*/
|
|
179
|
+
function getRepositoryTargetDirectory(type) {
|
|
180
|
+
return REPOSITORY_DIRECTORIES[type];
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Get the file extension for a given Copilot file type.
|
|
184
|
+
* @param type - The Copilot file type
|
|
185
|
+
* @returns The file extension (e.g., '.prompt.md') or empty string for skills
|
|
186
|
+
*/
|
|
187
|
+
function getFileExtension(type) {
|
|
188
|
+
return FILE_EXTENSIONS[type];
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=copilot-file-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copilot-file-type.js","sourceRoot":"","sources":["../../../src/domain/install/copilot-file-type.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;AAUH,8CAEC;AA+CD,4CAKC;AAUD,oCAWC;AAgBD,8CAwDC;AAQD,8CAOC;AAUD,oEAEC;AAOD,4CAEC;AA/LD;;;;;;;GAOG;AACH,SAAgB,iBAAiB,CAAC,EAAmB;IACnD,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;AACpD,CAAC;AAOD;;GAEG;AACH,MAAM,eAAe,GAAoC;IACvD,MAAM,EAAE,YAAY;IACpB,YAAY,EAAE,kBAAkB;IAChC,QAAQ,EAAE,cAAc;IACxB,KAAK,EAAE,WAAW;IAClB,KAAK,EAAE,EAAE,CAAC,2CAA2C;CACtD,CAAC;AAEF;;;GAGG;AACH,MAAM,sBAAsB,GAAoC;IAC9D,MAAM,EAAE,kBAAkB;IAC1B,YAAY,EAAE,uBAAuB;IACrC,QAAQ,EAAE,iBAAiB,EAAE,uCAAuC;IACpE,KAAK,EAAE,iBAAiB;IACxB,KAAK,EAAE,iBAAiB;CACzB,CAAC;AAEF;;GAEG;AACH,MAAM,wBAAwB,GAAG;IAC/B,eAAe,EAAE,oBAAoB;IACrC,mBAAmB,CAAC,4BAA4B;CACjD,CAAC;AAEF;;;;;;;;GAQG;AACH,SAAgB,gBAAgB,CAAC,QAAg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AO,EAAE,CAAC;QACrB,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,OAAO,GAAG,EAAE,GAAG,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;AACzC,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,4BAA4B,CAAC,IAAqB;IAChE,OAAO,sBAAsB,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC;AAED;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,IAAqB;IACpD,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Installable + BundleSpec types.
|
|
3
|
+
*
|
|
4
|
+
* `BundleSpec` is the parsed form of an install positional argument:
|
|
5
|
+
* ai-primitives-hub install foo → bundleId only
|
|
6
|
+
* ai-primitives-hub install owner/repo:foo → source-scoped
|
|
7
|
+
* ai-primitives-hub install owner/repo:foo@1.2.3 → fully qualified
|
|
8
|
+
*
|
|
9
|
+
* `Installable` is the resolved form: a BundleRef plus the optional
|
|
10
|
+
* runtime fields the install pipeline needs (download URL, integrity
|
|
11
|
+
* digest, manifest pre-fetched). The pipeline produces it in the
|
|
12
|
+
* resolve stage and consumes it in the download/extract/write stages.
|
|
13
|
+
* @module domain/install/installable
|
|
14
|
+
*/
|
|
15
|
+
import type { BundleRef } from '../bundle/types';
|
|
16
|
+
/**
|
|
17
|
+
* Parsed `install <spec>` positional.
|
|
18
|
+
*/
|
|
19
|
+
export interface BundleSpec {
|
|
20
|
+
/** Source identifier (e.g., `owner/repo`); undefined when omitted. */
|
|
21
|
+
sourceId?: string;
|
|
22
|
+
/** Bundle id within the source (always required). */
|
|
23
|
+
bundleId: string;
|
|
24
|
+
/** Semver-ish version; `latest` or undefined when omitted. */
|
|
25
|
+
bundleVersion?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Parse an `install <spec>` positional argument into a `BundleSpec`.
|
|
29
|
+
* Accepted forms (see module doc):
|
|
30
|
+
* `foo` -> `{ bundleId: 'foo' }`
|
|
31
|
+
* `owner/repo:foo` -> `{ sourceId: 'owner/repo', bundleId: 'foo' }`
|
|
32
|
+
* `owner/repo:foo@1.2.3` -> `{ sourceId: 'owner/repo', bundleId: 'foo', bundleVersion: '1.2.3' }`
|
|
33
|
+
* `foo@1.2.3` -> `{ bundleId: 'foo', bundleVersion: '1.2.3' }`
|
|
34
|
+
* @param raw - Raw positional argument.
|
|
35
|
+
* @returns Parsed bundle spec.
|
|
36
|
+
* @throws {Error} When `raw` is empty or has no bundle id segment.
|
|
37
|
+
*/
|
|
38
|
+
export declare const parseBundleSpec: (raw: string) => BundleSpec;
|
|
39
|
+
/**
|
|
40
|
+
* Resolved + ready-to-download bundle.
|
|
41
|
+
*/
|
|
42
|
+
export interface Installable {
|
|
43
|
+
ref: BundleRef;
|
|
44
|
+
/** Direct-download URL (zip). Empty string when `inlineBytes` carries the bundle. */
|
|
45
|
+
downloadUrl: string;
|
|
46
|
+
/**
|
|
47
|
+
* Optional pre-built bundle bytes. When set, the downloader skips
|
|
48
|
+
* the network call and uses these bytes directly. Used by source
|
|
49
|
+
* types that synthesize bundles (awesome-copilot, skills) rather
|
|
50
|
+
* than serving pre-packaged zips.
|
|
51
|
+
*/
|
|
52
|
+
inlineBytes?: Uint8Array;
|
|
53
|
+
/** Optional integrity hash (e.g., `sha256-base64`). */
|
|
54
|
+
integrity?: string;
|
|
55
|
+
/** Optional pre-fetched manifest. */
|
|
56
|
+
manifest?: Record<string, unknown>;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=installable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installable.d.ts","sourceRoot":"","sources":["../../../src/domain/install/installable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EACV,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qDAAqD;IACrD,QAAQ,EAAE,MAAM,CAAC;IACjB,8DAA8D;IAC9D,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,MAAM,KAAG,UAmB7C,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,SAAS,CAAC;IACf,qFAAqF;IACrF,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,UAAU,CAAC;IACzB,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qCAAqC;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseBundleSpec = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Parse an `install <spec>` positional argument into a `BundleSpec`.
|
|
6
|
+
* Accepted forms (see module doc):
|
|
7
|
+
* `foo` -> `{ bundleId: 'foo' }`
|
|
8
|
+
* `owner/repo:foo` -> `{ sourceId: 'owner/repo', bundleId: 'foo' }`
|
|
9
|
+
* `owner/repo:foo@1.2.3` -> `{ sourceId: 'owner/repo', bundleId: 'foo', bundleVersion: '1.2.3' }`
|
|
10
|
+
* `foo@1.2.3` -> `{ bundleId: 'foo', bundleVersion: '1.2.3' }`
|
|
11
|
+
* @param raw - Raw positional argument.
|
|
12
|
+
* @returns Parsed bundle spec.
|
|
13
|
+
* @throws {Error} When `raw` is empty or has no bundle id segment.
|
|
14
|
+
*/
|
|
15
|
+
const parseBundleSpec = (raw) => {
|
|
16
|
+
const trimmed = raw.trim();
|
|
17
|
+
if (trimmed.length === 0) {
|
|
18
|
+
throw new Error('bundle spec must be a non-empty string');
|
|
19
|
+
}
|
|
20
|
+
const colonIndex = trimmed.lastIndexOf(':');
|
|
21
|
+
const sourceId = colonIndex === -1 ? undefined : trimmed.slice(0, colonIndex);
|
|
22
|
+
const rest = colonIndex === -1 ? trimmed : trimmed.slice(colonIndex + 1);
|
|
23
|
+
const atIndex = rest.lastIndexOf('@');
|
|
24
|
+
const bundleId = atIndex === -1 ? rest : rest.slice(0, atIndex);
|
|
25
|
+
const bundleVersion = atIndex === -1 ? undefined : rest.slice(atIndex + 1);
|
|
26
|
+
if (bundleId.length === 0) {
|
|
27
|
+
throw new Error(`bundle spec "${raw}" has no bundle id`);
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
sourceId: sourceId !== undefined && sourceId.length > 0 ? sourceId : undefined,
|
|
31
|
+
bundleId,
|
|
32
|
+
bundleVersion: bundleVersion !== undefined && bundleVersion.length > 0 ? bundleVersion : undefined
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
exports.parseBundleSpec = parseBundleSpec;
|
|
36
|
+
//# sourceMappingURL=installable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installable.js","sourceRoot":"","sources":["../../../src/domain/install/installable.ts"],"names":[],"mappings":";;;AA8BA;;;;;;;;;;GAUG;AACI,MAAM,eAAe,GAAG,CAAC,GAAW,EAAc,EAAE;IACzD,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IAC3B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IACD,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC5C,MAAM,QAAQ,GAAG,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;IAC9E,MAAM,IAAI,GAAG,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;IACzE,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,QAAQ,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IAChE,MAAM,aAAa,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC;IAC3E,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,gBAAgB,GAAG,oBAAoB,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO;QACL,QAAQ,EAAE,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;QAC9E,QAAQ;QACR,aAAa,EAAE,aAAa,KAAK,SAAS,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS;KACnG,CAAC;AACJ,CAAC,CAAC;AAnBW,QAAA,eAAe,mBAmB1B"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain types for target layout configuration.
|
|
3
|
+
*
|
|
4
|
+
* A layout config describes where each primitive kind should be placed
|
|
5
|
+
* for a given target type and scope (user vs repository). These types
|
|
6
|
+
* represent the on-disk configuration format (YAML/JSON) as well as
|
|
7
|
+
* the resolved shape consumed by writers.
|
|
8
|
+
*
|
|
9
|
+
* Pure domain: no IO, no framework imports.
|
|
10
|
+
* @module domain/install/layout
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Per-scope layout definition as stored in a layout config file.
|
|
14
|
+
* Both user and repository scopes use this same shape.
|
|
15
|
+
*/
|
|
16
|
+
export interface ScopedLayoutDef {
|
|
17
|
+
/**
|
|
18
|
+
* Base directory for the target. May contain env var tokens like
|
|
19
|
+
* `${HOME}` or the special `${workspaceRoot}` token which is resolved
|
|
20
|
+
* from `target.rootPath ?? target.path ?? '.'` at install time.
|
|
21
|
+
*/
|
|
22
|
+
readonly baseDir: string;
|
|
23
|
+
/**
|
|
24
|
+
* Map from bundle sub-path prefix (e.g. `"prompts/"`) to output
|
|
25
|
+
* sub-path relative to `baseDir` (e.g. `".github/prompts/"`).
|
|
26
|
+
*/
|
|
27
|
+
readonly kindRoutes: Readonly<Record<string, string>>;
|
|
28
|
+
/**
|
|
29
|
+
* Bundle-relative paths to skip entirely (manifests, READMEs, etc.).
|
|
30
|
+
* Defaults to `["deployment-manifest.yml", "README.md"]` if absent.
|
|
31
|
+
*/
|
|
32
|
+
readonly skipPaths?: readonly string[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Per-target-type layout definition. Holds one entry per scope.
|
|
36
|
+
* `repository` is optional: if absent, `user` layout is used regardless
|
|
37
|
+
* of the target's scope field.
|
|
38
|
+
*/
|
|
39
|
+
export interface TargetLayoutDef {
|
|
40
|
+
/** Layout for user-scoped targets. */
|
|
41
|
+
readonly user: ScopedLayoutDef;
|
|
42
|
+
/** Layout for repository-scoped targets. Falls back to `user` if absent. */
|
|
43
|
+
readonly repository?: ScopedLayoutDef;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Root shape of an `ai-primitives-hub-layouts.yml` (or `.json`) config file.
|
|
47
|
+
* Keyed by target type identifier (e.g. `"vscode"`, `"kiro"`).
|
|
48
|
+
*
|
|
49
|
+
* A partial config (only overriding some targets, or some kindRoutes
|
|
50
|
+
* within a target) is valid — the layout resolver deep-merges multiple
|
|
51
|
+
* layers before resolving.
|
|
52
|
+
*/
|
|
53
|
+
export interface TargetLayoutsConfig {
|
|
54
|
+
readonly layouts: Readonly<Record<string, TargetLayoutDef>>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Mapping from a primitive kind to a relative subdirectory.
|
|
58
|
+
* Keys are bundle sub-path prefixes (e.g. `"prompts/"`),
|
|
59
|
+
* values are output sub-paths relative to baseDir.
|
|
60
|
+
*/
|
|
61
|
+
export type KindRoutes = Record<string, string>;
|
|
62
|
+
/**
|
|
63
|
+
* Resolved target layout consumed by writers.
|
|
64
|
+
* The `baseDir` is already resolved (no `${workspaceRoot}` token);
|
|
65
|
+
* `${HOME}` and other env tokens are still present and expanded by
|
|
66
|
+
* `expandPath` at write time.
|
|
67
|
+
*/
|
|
68
|
+
export interface TargetLayout {
|
|
69
|
+
/** Base directory the writer writes into (post-${VAR} expansion). */
|
|
70
|
+
baseDir: string;
|
|
71
|
+
/** Map: bundle subpath prefix → output subpath under baseDir. */
|
|
72
|
+
kindRoutes: KindRoutes;
|
|
73
|
+
/** Bundle-relative paths to skip (manifests, READMEs, etc.). */
|
|
74
|
+
skipPaths?: string[];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Validate an unknown value as a `TargetLayoutsConfig`.
|
|
78
|
+
* Returns the typed config or throws with a descriptive message.
|
|
79
|
+
* Pure; no IO.
|
|
80
|
+
* @param raw - Parsed YAML/JSON to validate.
|
|
81
|
+
* @returns Typed `TargetLayoutsConfig`.
|
|
82
|
+
*/
|
|
83
|
+
export declare function validateTargetLayoutsConfig(raw: unknown): TargetLayoutsConfig;
|
|
84
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/domain/install/layout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACtD;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,sCAAsC;IACtC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,4EAA4E;IAC5E,QAAQ,CAAC,UAAU,CAAC,EAAE,eAAe,CAAC;CACvC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC;CAC7D;AAED;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,qEAAqE;IACrE,OAAO,EAAE,MAAM,CAAC;IAChB,iEAAiE;IACjE,UAAU,EAAE,UAAU,CAAC;IACvB,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,OAAO,GAAG,mBAAmB,CAoB7E"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Domain types for target layout configuration.
|
|
4
|
+
*
|
|
5
|
+
* A layout config describes where each primitive kind should be placed
|
|
6
|
+
* for a given target type and scope (user vs repository). These types
|
|
7
|
+
* represent the on-disk configuration format (YAML/JSON) as well as
|
|
8
|
+
* the resolved shape consumed by writers.
|
|
9
|
+
*
|
|
10
|
+
* Pure domain: no IO, no framework imports.
|
|
11
|
+
* @module domain/install/layout
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.validateTargetLayoutsConfig = validateTargetLayoutsConfig;
|
|
15
|
+
/**
|
|
16
|
+
* Validate an unknown value as a `TargetLayoutsConfig`.
|
|
17
|
+
* Returns the typed config or throws with a descriptive message.
|
|
18
|
+
* Pure; no IO.
|
|
19
|
+
* @param raw - Parsed YAML/JSON to validate.
|
|
20
|
+
* @returns Typed `TargetLayoutsConfig`.
|
|
21
|
+
*/
|
|
22
|
+
function validateTargetLayoutsConfig(raw) {
|
|
23
|
+
if (raw === null || typeof raw !== 'object') {
|
|
24
|
+
throw new Error('layout config must be an object');
|
|
25
|
+
}
|
|
26
|
+
const obj = raw;
|
|
27
|
+
if (obj.layouts === null || typeof obj.layouts !== 'object') {
|
|
28
|
+
throw new Error('layout config must have a "layouts" object');
|
|
29
|
+
}
|
|
30
|
+
const layouts = obj.layouts;
|
|
31
|
+
for (const [type, def] of Object.entries(layouts)) {
|
|
32
|
+
if (def === null || typeof def !== 'object') {
|
|
33
|
+
throw new Error(`layout config: "${type}" must be an object`);
|
|
34
|
+
}
|
|
35
|
+
const typedDef = def;
|
|
36
|
+
validateScopedLayoutDef(typedDef.user, `${type}.user`);
|
|
37
|
+
if (typedDef.repository !== undefined) {
|
|
38
|
+
validateScopedLayoutDef(typedDef.repository, `${type}.repository`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return raw;
|
|
42
|
+
}
|
|
43
|
+
function validateScopedLayoutDef(raw, path) {
|
|
44
|
+
if (raw === null || typeof raw !== 'object') {
|
|
45
|
+
throw new TypeError(`layout config: "${path}" must be an object`);
|
|
46
|
+
}
|
|
47
|
+
const obj = raw;
|
|
48
|
+
if (typeof obj.baseDir !== 'string') {
|
|
49
|
+
throw new TypeError(`layout config: "${path}.baseDir" must be a string`);
|
|
50
|
+
}
|
|
51
|
+
if (obj.kindRoutes === null || typeof obj.kindRoutes !== 'object') {
|
|
52
|
+
throw new TypeError(`layout config: "${path}.kindRoutes" must be an object`);
|
|
53
|
+
}
|
|
54
|
+
for (const [k, v] of Object.entries(obj.kindRoutes)) {
|
|
55
|
+
if (typeof v !== 'string') {
|
|
56
|
+
throw new TypeError(`layout config: "${path}.kindRoutes.${k}" must be a string`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (obj.skipPaths !== undefined) {
|
|
60
|
+
if (!Array.isArray(obj.skipPaths)) {
|
|
61
|
+
throw new TypeError(`layout config: "${path}.skipPaths" must be an array`);
|
|
62
|
+
}
|
|
63
|
+
for (const p of obj.skipPaths) {
|
|
64
|
+
if (typeof p !== 'string') {
|
|
65
|
+
throw new TypeError(`layout config: "${path}.skipPaths" entries must be strings`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.js","sourceRoot":"","sources":["../../../src/domain/install/layout.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;AA8EH,kEAoBC;AA3BD;;;;;;GAMG;AACH,SAAgB,2BAA2B,CAAC,GAAY;IACtD,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IACD,MAAM,GAAG,GAAG,GAA8B,CAAC;IAC3C,IAAI,GAAG,CAAC,OAAO,KAAK,IAAI,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC5D,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IACD,MAAM,OAAO,GAAG,GAAG,CAAC,OAAkC,CAAC;IACvD,KAAK,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,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mB,IAAI,eAAe,CAAC,oBAAoB,CAAC,CAAC;QACnF,CAAC;IACH,CAAC;IACD,IAAI,GAAG,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QAChC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,SAAS,CAAC,mBAAmB,IAAI,8BAA8B,CAAC,CAAC;QAC7E,CAAC;QACD,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,SAAsB,EAAE,CAAC;YAC3C,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;gBAC1B,MAAM,IAAI,SAAS,CAAC,mBAAmB,IAAI,qCAAqC,CAAC,CAAC;YACpF,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain layer — multi-target install destinations.
|
|
3
|
+
*
|
|
4
|
+
* New in `ai-primitives-hub-next` (no equivalent exists on `main` today):
|
|
5
|
+
* a `Target` is a typed, named install destination, generalizing beyond
|
|
6
|
+
* VS Code so `cli install` can write to Kiro/Windsurf/Claude Code/GitHub
|
|
7
|
+
* Copilot CLI too. In scope per migration plan §8 decision 5 — ported
|
|
8
|
+
* from the reference branch's `Target` union
|
|
9
|
+
* (`docs/library-centric-architecture` design), with `scope` unified to
|
|
10
|
+
* this package's own `InstallationScope` (`./types.ts`) instead of the
|
|
11
|
+
* reference branch's narrower `user | repository`, so a `Target` behaves
|
|
12
|
+
* exactly like every other install destination in `core` — no separate
|
|
13
|
+
* scope model to reconcile later. Whether a given target type actually
|
|
14
|
+
* supports every scope value is a validation concern for whatever
|
|
15
|
+
* consumes this type (`app`, Phase 4), not a type-system constraint here.
|
|
16
|
+
* @module domain/install/target
|
|
17
|
+
*/
|
|
18
|
+
import type { InstallationScope, RepositoryCommitMode } from './types';
|
|
19
|
+
/**
|
|
20
|
+
* All target types known to `ai-primitives-hub-next`.
|
|
21
|
+
*/
|
|
22
|
+
export declare const TARGET_TYPES: readonly ["vscode", "vscode-insiders", "copilot-cli", "kiro", "windsurf", "claude-code"];
|
|
23
|
+
/**
|
|
24
|
+
* Target type discriminant.
|
|
25
|
+
*/
|
|
26
|
+
export type TargetType = typeof TARGET_TYPES[number];
|
|
27
|
+
/**
|
|
28
|
+
* Fields common to every target, regardless of type.
|
|
29
|
+
*/
|
|
30
|
+
export interface TargetBase {
|
|
31
|
+
/** Unique identifier, looked up by `install --target <name>`. */
|
|
32
|
+
name: string;
|
|
33
|
+
type: TargetType;
|
|
34
|
+
scope: InstallationScope;
|
|
35
|
+
/** Required when `scope` is `'repository'`. */
|
|
36
|
+
commitMode?: RepositoryCommitMode;
|
|
37
|
+
/** Workspace/repository root path; required when `scope` is not `'user'`. */
|
|
38
|
+
rootPath?: string;
|
|
39
|
+
/** Override the platform-default config path for this target. */
|
|
40
|
+
path?: string;
|
|
41
|
+
/** Restrict which primitive kinds this target accepts, e.g. `['prompt', 'agent']`. */
|
|
42
|
+
allowedKinds?: string[];
|
|
43
|
+
}
|
|
44
|
+
export interface VsCodeTarget extends TargetBase {
|
|
45
|
+
type: 'vscode' | 'vscode-insiders';
|
|
46
|
+
}
|
|
47
|
+
export interface CopilotCliTarget extends TargetBase {
|
|
48
|
+
type: 'copilot-cli';
|
|
49
|
+
}
|
|
50
|
+
export interface KiroTarget extends TargetBase {
|
|
51
|
+
type: 'kiro';
|
|
52
|
+
}
|
|
53
|
+
export interface WindsurfTarget extends TargetBase {
|
|
54
|
+
type: 'windsurf';
|
|
55
|
+
}
|
|
56
|
+
export interface ClaudeCodeTarget extends TargetBase {
|
|
57
|
+
type: 'claude-code';
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Tagged union of every target type.
|
|
61
|
+
*/
|
|
62
|
+
export type Target = VsCodeTarget | CopilotCliTarget | KiroTarget | WindsurfTarget | ClaudeCodeTarget;
|
|
63
|
+
/**
|
|
64
|
+
* Type guard for `Target`. Pure; no IO — safe to use directly against
|
|
65
|
+
* parsed YAML/JSON config nodes.
|
|
66
|
+
* @param value - Candidate value, typically a parsed config node.
|
|
67
|
+
* @returns true iff `value` matches the `Target` shape.
|
|
68
|
+
*/
|
|
69
|
+
export declare function isTarget(value: unknown): value is Target;
|
|
70
|
+
//# sourceMappingURL=target.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"target.d.ts","sourceRoot":"","sources":["../../../src/domain/install/target.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,eAAO,MAAM,YAAY,0FAOf,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,iEAAiE;IACjE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,iBAAiB,CAAC;IACzB,+CAA+C;IAC/C,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAClC,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iEAAiE;IACjE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sFAAsF;IACtF,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,YAAa,SAAQ,UAAU;IAC9C,IAAI,EAAE,QAAQ,GAAG,iBAAiB,CAAC;CACpC;AAED,MAAM,WAAW,gBAAiB,SAAQ,UAAU;IAClD,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,WAAW,UAAW,SAAQ,UAAU;IAC5C,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,cAAe,SAAQ,UAAU;IAChD,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,MAAM,WAAW,gBAAiB,SAAQ,UAAU;IAClD,IAAI,EAAE,aAAa,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,MAAM,MAAM,GACd,YAAY,GACZ,gBAAgB,GAChB,UAAU,GACV,cAAc,GACd,gBAAgB,CAAC;AAKrB;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAmBxD"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TARGET_TYPES = void 0;
|
|
4
|
+
exports.isTarget = isTarget;
|
|
5
|
+
/**
|
|
6
|
+
* All target types known to `ai-primitives-hub-next`.
|
|
7
|
+
*/
|
|
8
|
+
exports.TARGET_TYPES = [
|
|
9
|
+
'vscode',
|
|
10
|
+
'vscode-insiders',
|
|
11
|
+
'copilot-cli',
|
|
12
|
+
'kiro',
|
|
13
|
+
'windsurf',
|
|
14
|
+
'claude-code'
|
|
15
|
+
];
|
|
16
|
+
const INSTALLATION_SCOPES = ['user', 'workspace', 'repository'];
|
|
17
|
+
const COMMIT_MODES = ['commit', 'local-only'];
|
|
18
|
+
/**
|
|
19
|
+
* Type guard for `Target`. Pure; no IO — safe to use directly against
|
|
20
|
+
* parsed YAML/JSON config nodes.
|
|
21
|
+
* @param value - Candidate value, typically a parsed config node.
|
|
22
|
+
* @returns true iff `value` matches the `Target` shape.
|
|
23
|
+
*/
|
|
24
|
+
function isTarget(value) {
|
|
25
|
+
if (value === null || typeof value !== 'object') {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
const candidate = value;
|
|
29
|
+
if (typeof candidate.name !== 'string' || candidate.name.length === 0) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
if (typeof candidate.type !== 'string' || !exports.TARGET_TYPES.includes(candidate.type)) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
if (candidate.scope !== undefined && !INSTALLATION_SCOPES.includes(candidate.scope)) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
if (candidate.commitMode !== undefined && !COMMIT_MODES.includes(candidate.commitMode)) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=target.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"target.js","sourceRoot":"","sources":["../../../src/domain/install/target.ts"],"names":[],"mappings":";;;AAgGA,4BAmBC;AA7FD;;GAEG;AACU,QAAA,YAAY,GAAG;IAC1B,QAAQ;IACR,iBAAiB;IACjB,aAAa;IACb,MAAM;IACN,UAAU;IACV,aAAa;CACL,CAAC;AAuDX,MAAM,mBAAmB,GAAsB,CAAC,MAAM,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;AACnF,MAAM,YAAY,GAAsB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;AAEjE;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,KAAc;IACrC,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,SAAS,GAAG,KAAgC,CAAC;IAEnD,IAAI,OAAO,SAAS,CAAC,IAAI,KAAK,QAAQ,IAAI,SAAS,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtE,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,OAAO,SAAS,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAE,oBAAkC,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;QACxG,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,SAAS,CAAC,KAAK,KAAK,SAAS,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAe,CAAC,EAAE,CAAC;QAC9F,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,SAAS,CAAC,UAAU,KAAK,SAAS,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAoB,CAAC,EAAE,CAAC;QACjG,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain types for resource transformation.
|
|
3
|
+
*
|
|
4
|
+
* Transformations adapt runtime-agnostic bundle content to meet
|
|
5
|
+
* specific requirements of different target runtimes (e.g., Kiro
|
|
6
|
+
* requiring mandatory agent name in frontmatter, VS Code considering
|
|
7
|
+
* it optional).
|
|
8
|
+
*
|
|
9
|
+
* Pure domain: no IO, no framework imports, no feature layer imports.
|
|
10
|
+
* @module domain/install/transform
|
|
11
|
+
*/
|
|
12
|
+
import type { Target } from './target';
|
|
13
|
+
/**
|
|
14
|
+
* Context provided to transformers.
|
|
15
|
+
* Contains all information needed to decide whether and how to transform
|
|
16
|
+
* a file's content.
|
|
17
|
+
*/
|
|
18
|
+
export interface TransformContext {
|
|
19
|
+
/** Target being written to. */
|
|
20
|
+
readonly target: Target;
|
|
21
|
+
/** Bundle-relative file path (e.g., "agents/my-agent.md"). */
|
|
22
|
+
readonly filePath: string;
|
|
23
|
+
/** Original file content as string. */
|
|
24
|
+
readonly content: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Result of a transformation operation.
|
|
28
|
+
*/
|
|
29
|
+
export interface TransformResult {
|
|
30
|
+
/** Transformed content. May be identical to original if no change needed. */
|
|
31
|
+
readonly content: string;
|
|
32
|
+
/** Whether the content was actually modified. */
|
|
33
|
+
readonly modified: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Create a TransformResult indicating no change.
|
|
37
|
+
* @param content - The (unchanged) content.
|
|
38
|
+
* @returns TransformResult with modified=false.
|
|
39
|
+
*/
|
|
40
|
+
export declare const noChange: (content: string) => TransformResult;
|
|
41
|
+
/**
|
|
42
|
+
* Create a TransformResult indicating a change.
|
|
43
|
+
* @param content - The transformed content.
|
|
44
|
+
* @returns TransformResult with modified=true.
|
|
45
|
+
*/
|
|
46
|
+
export declare const changed: (content: string) => TransformResult;
|
|
47
|
+
//# sourceMappingURL=transform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/domain/install/transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EACV,MAAM,EACP,MAAM,UAAU,CAAC;AAElB;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,+BAA+B;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,8DAA8D;IAC9D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,uCAAuC;IACvC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,6EAA6E;IAC7E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,iDAAiD;IACjD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAI,SAAS,MAAM,KAAG,eAGzC,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,SAAS,MAAM,KAAG,eAGxC,CAAC"}
|