@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.
- package/README.md +26 -0
- package/dist/collection/generate-skill.d.ts +43 -0
- package/dist/collection/generate-skill.d.ts.map +1 -0
- package/dist/collection/generate-skill.js +244 -0
- package/dist/collection/generate-skill.js.map +1 -0
- package/dist/collection/index.d.ts +8 -0
- package/dist/collection/index.d.ts.map +1 -0
- package/dist/collection/index.js +23 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/collection/read-collection.d.ts +60 -0
- package/dist/collection/read-collection.d.ts.map +1 -0
- package/dist/collection/read-collection.js +291 -0
- package/dist/collection/read-collection.js.map +1 -0
- package/dist/context-detection/detector.d.ts +126 -0
- package/dist/context-detection/detector.d.ts.map +1 -0
- package/dist/context-detection/detector.js +408 -0
- package/dist/context-detection/detector.js.map +1 -0
- package/dist/context-detection/index.d.ts +11 -0
- package/dist/context-detection/index.d.ts.map +1 -0
- package/dist/context-detection/index.js +14 -0
- package/dist/context-detection/index.js.map +1 -0
- package/dist/context-detection/types.d.ts +74 -0
- package/dist/context-detection/types.d.ts.map +1 -0
- package/dist/context-detection/types.js +13 -0
- package/dist/context-detection/types.js.map +1 -0
- package/dist/discovery/index.d.ts +7 -0
- package/dist/discovery/index.d.ts.map +1 -0
- package/dist/discovery/index.js +23 -0
- package/dist/discovery/index.js.map +1 -0
- package/dist/discovery/profile-generator.d.ts +31 -0
- package/dist/discovery/profile-generator.d.ts.map +1 -0
- package/dist/discovery/profile-generator.js +55 -0
- package/dist/discovery/profile-generator.js.map +1 -0
- package/dist/discovery/recommendation-engine.d.ts +76 -0
- package/dist/discovery/recommendation-engine.d.ts.map +1 -0
- package/dist/discovery/recommendation-engine.js +210 -0
- package/dist/discovery/recommendation-engine.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/install/index.d.ts +14 -0
- package/dist/install/index.d.ts.map +1 -0
- package/dist/install/index.js +20 -0
- package/dist/install/index.js.map +1 -0
- package/dist/install/install-bundle.d.ts +31 -0
- package/dist/install/install-bundle.d.ts.map +1 -0
- package/dist/install/install-bundle.js +23 -0
- package/dist/install/install-bundle.js.map +1 -0
- package/dist/install/layout-resolver.d.ts +31 -0
- package/dist/install/layout-resolver.d.ts.map +1 -0
- package/dist/install/layout-resolver.js +70 -0
- package/dist/install/layout-resolver.js.map +1 -0
- package/dist/install/pipeline.d.ts +111 -0
- package/dist/install/pipeline.d.ts.map +1 -0
- package/dist/install/pipeline.js +138 -0
- package/dist/install/pipeline.js.map +1 -0
- package/dist/install/uninstall-bundle.d.ts +36 -0
- package/dist/install/uninstall-bundle.d.ts.map +1 -0
- package/dist/install/uninstall-bundle.js +37 -0
- package/dist/install/uninstall-bundle.js.map +1 -0
- package/dist/install/uninstall-pipeline.d.ts +119 -0
- package/dist/install/uninstall-pipeline.d.ts.map +1 -0
- package/dist/install/uninstall-pipeline.js +187 -0
- package/dist/install/uninstall-pipeline.js.map +1 -0
- package/dist/registry/activate-registry-profile.d.ts +67 -0
- package/dist/registry/activate-registry-profile.d.ts.map +1 -0
- package/dist/registry/activate-registry-profile.js +150 -0
- package/dist/registry/activate-registry-profile.js.map +1 -0
- package/dist/registry/create-source-adapter.d.ts +43 -0
- package/dist/registry/create-source-adapter.d.ts.map +1 -0
- package/dist/registry/create-source-adapter.js +53 -0
- package/dist/registry/create-source-adapter.js.map +1 -0
- package/dist/registry/deactivate-registry-profile.d.ts +38 -0
- package/dist/registry/deactivate-registry-profile.d.ts.map +1 -0
- package/dist/registry/deactivate-registry-profile.js +45 -0
- package/dist/registry/deactivate-registry-profile.js.map +1 -0
- package/dist/registry/detect-updates.d.ts +12 -0
- package/dist/registry/detect-updates.d.ts.map +1 -0
- package/dist/registry/detect-updates.js +76 -0
- package/dist/registry/detect-updates.js.map +1 -0
- package/dist/registry/hub-manager.d.ts +229 -0
- package/dist/registry/hub-manager.d.ts.map +1 -0
- package/dist/registry/hub-manager.js +473 -0
- package/dist/registry/hub-manager.js.map +1 -0
- package/dist/registry/index.d.ts +23 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +39 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/registry/install-registry-bundle.d.ts +56 -0
- package/dist/registry/install-registry-bundle.d.ts.map +1 -0
- package/dist/registry/install-registry-bundle.js +150 -0
- package/dist/registry/install-registry-bundle.js.map +1 -0
- package/dist/registry/list-all-profiles.d.ts +27 -0
- package/dist/registry/list-all-profiles.d.ts.map +1 -0
- package/dist/registry/list-all-profiles.js +52 -0
- package/dist/registry/list-all-profiles.js.map +1 -0
- package/dist/registry/list-installed-bundles.d.ts +37 -0
- package/dist/registry/list-installed-bundles.d.ts.map +1 -0
- package/dist/registry/list-installed-bundles.js +27 -0
- package/dist/registry/list-installed-bundles.js.map +1 -0
- package/dist/registry/load-hub-sources.d.ts +56 -0
- package/dist/registry/load-hub-sources.d.ts.map +1 -0
- package/dist/registry/load-hub-sources.js +123 -0
- package/dist/registry/load-hub-sources.js.map +1 -0
- package/dist/registry/local-profile-crud.d.ts +58 -0
- package/dist/registry/local-profile-crud.d.ts.map +1 -0
- package/dist/registry/local-profile-crud.js +85 -0
- package/dist/registry/local-profile-crud.js.map +1 -0
- package/dist/registry/profile-lifecycle.d.ts +190 -0
- package/dist/registry/profile-lifecycle.d.ts.map +1 -0
- package/dist/registry/profile-lifecycle.js +400 -0
- package/dist/registry/profile-lifecycle.js.map +1 -0
- package/dist/registry/registry-settings.d.ts +32 -0
- package/dist/registry/registry-settings.d.ts.map +1 -0
- package/dist/registry/registry-settings.js +145 -0
- package/dist/registry/registry-settings.js.map +1 -0
- package/dist/registry/resolve-installation-bundle.d.ts +46 -0
- package/dist/registry/resolve-installation-bundle.d.ts.map +1 -0
- package/dist/registry/resolve-installation-bundle.js +98 -0
- package/dist/registry/resolve-installation-bundle.js.map +1 -0
- package/dist/registry/search-registry-bundles.d.ts +47 -0
- package/dist/registry/search-registry-bundles.d.ts.map +1 -0
- package/dist/registry/search-registry-bundles.js +129 -0
- package/dist/registry/search-registry-bundles.js.map +1 -0
- package/dist/registry/uninstall-installed-bundle.d.ts +48 -0
- package/dist/registry/uninstall-installed-bundle.d.ts.map +1 -0
- package/dist/registry/uninstall-installed-bundle.js +45 -0
- package/dist/registry/uninstall-installed-bundle.js.map +1 -0
- package/dist/registry/update-registry-bundle.d.ts +36 -0
- package/dist/registry/update-registry-bundle.d.ts.map +1 -0
- package/dist/registry/update-registry-bundle.js +113 -0
- package/dist/registry/update-registry-bundle.js.map +1 -0
- package/dist/registry/user-config-paths.d.ts +24 -0
- package/dist/registry/user-config-paths.d.ts.map +1 -0
- package/dist/registry/user-config-paths.js +82 -0
- package/dist/registry/user-config-paths.js.map +1 -0
- package/dist/registry/version-consolidator.d.ts +123 -0
- package/dist/registry/version-consolidator.d.ts.map +1 -0
- package/dist/registry/version-consolidator.js +231 -0
- package/dist/registry/version-consolidator.js.map +1 -0
- package/dist/search/export-profile.d.ts +63 -0
- package/dist/search/export-profile.d.ts.map +1 -0
- package/dist/search/export-profile.js +138 -0
- package/dist/search/export-profile.js.map +1 -0
- package/dist/search/index.d.ts +6 -0
- package/dist/search/index.d.ts.map +1 -0
- package/dist/search/index.js +22 -0
- package/dist/search/index.js.map +1 -0
- package/dist/stores/index.d.ts +8 -0
- package/dist/stores/index.d.ts.map +1 -0
- package/dist/stores/index.js +24 -0
- package/dist/stores/index.js.map +1 -0
- package/dist/stores/json-lockfile-store.d.ts +203 -0
- package/dist/stores/json-lockfile-store.d.ts.map +1 -0
- package/dist/stores/json-lockfile-store.js +277 -0
- package/dist/stores/json-lockfile-store.js.map +1 -0
- package/dist/transform/index.d.ts +10 -0
- package/dist/transform/index.d.ts.map +1 -0
- package/dist/transform/index.js +26 -0
- package/dist/transform/index.js.map +1 -0
- package/dist/transform/transformer-registry.d.ts +52 -0
- package/dist/transform/transformer-registry.d.ts.map +1 -0
- package/dist/transform/transformer-registry.js +53 -0
- package/dist/transform/transformer-registry.js.map +1 -0
- package/dist/transform/transformers/claude-code-transformer.d.ts +67 -0
- package/dist/transform/transformers/claude-code-transformer.d.ts.map +1 -0
- package/dist/transform/transformers/claude-code-transformer.js +140 -0
- package/dist/transform/transformers/claude-code-transformer.js.map +1 -0
- package/dist/transform/transformers/kiro-transformer.d.ts +51 -0
- package/dist/transform/transformers/kiro-transformer.d.ts.map +1 -0
- package/dist/transform/transformers/kiro-transformer.js +128 -0
- package/dist/transform/transformers/kiro-transformer.js.map +1 -0
- package/dist/transform/transformers/noop-transformer.d.ts +25 -0
- package/dist/transform/transformers/noop-transformer.d.ts.map +1 -0
- package/dist/transform/transformers/noop-transformer.js +20 -0
- package/dist/transform/transformers/noop-transformer.js.map +1 -0
- package/dist/transform/transformers/windsurf-transformer.d.ts +63 -0
- package/dist/transform/transformers/windsurf-transformer.d.ts.map +1 -0
- package/dist/transform/transformers/windsurf-transformer.js +125 -0
- package/dist/transform/transformers/windsurf-transformer.js.map +1 -0
- package/dist/update/auto-update.d.ts +84 -0
- package/dist/update/auto-update.d.ts.map +1 -0
- package/dist/update/auto-update.js +217 -0
- package/dist/update/auto-update.js.map +1 -0
- package/dist/update/check-updates.d.ts +51 -0
- package/dist/update/check-updates.d.ts.map +1 -0
- package/dist/update/check-updates.js +168 -0
- package/dist/update/check-updates.js.map +1 -0
- package/dist/update/index.d.ts +8 -0
- package/dist/update/index.d.ts.map +1 -0
- package/dist/update/index.js +24 -0
- package/dist/update/index.js.map +1 -0
- package/dist/update/log-event.d.ts +15 -0
- package/dist/update/log-event.d.ts.map +1 -0
- package/dist/update/log-event.js +11 -0
- package/dist/update/log-event.js.map +1 -0
- package/dist/writers/file-tree-writer.d.ts +136 -0
- package/dist/writers/file-tree-writer.d.ts.map +1 -0
- package/dist/writers/file-tree-writer.js +337 -0
- package/dist/writers/file-tree-writer.js.map +1 -0
- package/dist/writers/index.d.ts +7 -0
- package/dist/writers/index.d.ts.map +1 -0
- package/dist/writers/index.js +23 -0
- package/dist/writers/index.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import type { ExtractedFiles } from '@ai-primitives-hub/core';
|
|
2
|
+
/** Lockfile filename for commit-mode (git-tracked) bundle entries. */
|
|
3
|
+
export declare const LOCKFILE_NAME = "prompt-registry.lock.json";
|
|
4
|
+
/** Lockfile filename for local-only (gitignored) bundle entries. */
|
|
5
|
+
export declare const LOCAL_LOCKFILE_NAME = "prompt-registry.local.lock.json";
|
|
6
|
+
/** Schema version written by this store — matches the extension's. */
|
|
7
|
+
export declare const LOCKFILE_SCHEMA_VERSION = "2.0.0";
|
|
8
|
+
/**
|
|
9
|
+
* Commit mode for repository-scoped installations.
|
|
10
|
+
*/
|
|
11
|
+
export type RepositoryCommitMode = 'commit' | 'local-only';
|
|
12
|
+
/**
|
|
13
|
+
* File entry within a bundle.
|
|
14
|
+
*/
|
|
15
|
+
export interface LockfileFileEntry {
|
|
16
|
+
/** Relative path from repository root. */
|
|
17
|
+
path: string;
|
|
18
|
+
/** SHA256 checksum of the file contents. */
|
|
19
|
+
checksum: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Bundle entry in the lockfile.
|
|
23
|
+
*/
|
|
24
|
+
export interface LockfileBundleEntry {
|
|
25
|
+
/** Semantic version of the installed bundle. */
|
|
26
|
+
version: string;
|
|
27
|
+
/** ID of the source this bundle was installed from. */
|
|
28
|
+
sourceId: string;
|
|
29
|
+
/** Type of the source (github, local, etc.). */
|
|
30
|
+
sourceType: string;
|
|
31
|
+
/** ISO timestamp when the bundle was installed. */
|
|
32
|
+
installedAt: string;
|
|
33
|
+
/**
|
|
34
|
+
* Whether files are committed to Git or excluded. Deprecated: this
|
|
35
|
+
* is implicit based on which lockfile contains the entry. Kept
|
|
36
|
+
* optional for round-tripping entries written by older tooling.
|
|
37
|
+
*/
|
|
38
|
+
commitMode?: RepositoryCommitMode;
|
|
39
|
+
/** Optional checksum of the bundle archive. */
|
|
40
|
+
checksum?: string;
|
|
41
|
+
/** List of installed files with their checksums. */
|
|
42
|
+
files: LockfileFileEntry[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Source configuration entry.
|
|
46
|
+
*/
|
|
47
|
+
export interface LockfileSourceEntry {
|
|
48
|
+
/** Source type (github, local, awesome-copilot, apm, etc.). */
|
|
49
|
+
type: string;
|
|
50
|
+
/** URL of the source. */
|
|
51
|
+
url: string;
|
|
52
|
+
/** Optional Git branch for git-based sources. */
|
|
53
|
+
branch?: string;
|
|
54
|
+
/** Optional collections subdirectory, for `awesome-copilot`-type sources. */
|
|
55
|
+
collectionsPath?: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Hub configuration entry.
|
|
59
|
+
*/
|
|
60
|
+
export interface LockfileHubEntry {
|
|
61
|
+
/** Display name of the hub. */
|
|
62
|
+
name: string;
|
|
63
|
+
/** URL of the hub configuration. */
|
|
64
|
+
url: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Profile entry in the lockfile.
|
|
68
|
+
*/
|
|
69
|
+
export interface LockfileProfileEntry {
|
|
70
|
+
/** Display name of the profile. */
|
|
71
|
+
name: string;
|
|
72
|
+
/** List of bundle IDs included in this profile. */
|
|
73
|
+
bundleIds: string[];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Root lockfile structure — matches the extension's `Lockfile` type
|
|
77
|
+
* (`src/types/lockfile.ts`) field-for-field.
|
|
78
|
+
*/
|
|
79
|
+
export interface Lockfile {
|
|
80
|
+
/** JSON schema reference for validation. */
|
|
81
|
+
$schema: string;
|
|
82
|
+
/** Lockfile schema version (e.g., "2.0.0"). */
|
|
83
|
+
version: string;
|
|
84
|
+
/** ISO timestamp when the lockfile was generated. */
|
|
85
|
+
generatedAt: string;
|
|
86
|
+
/** Extension/CLI name and version that generated the lockfile. */
|
|
87
|
+
generatedBy: string;
|
|
88
|
+
/** Map of bundle IDs to their metadata. */
|
|
89
|
+
bundles: Record<string, LockfileBundleEntry>;
|
|
90
|
+
/** Map of source IDs to their configuration. */
|
|
91
|
+
sources: Record<string, LockfileSourceEntry>;
|
|
92
|
+
/** Optional map of hub IDs to their configuration. */
|
|
93
|
+
hubs?: Record<string, LockfileHubEntry>;
|
|
94
|
+
/** Optional map of profile IDs to their configuration. */
|
|
95
|
+
profiles?: Record<string, LockfileProfileEntry>;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Build an empty lockfile structure with required fields.
|
|
99
|
+
* @param generatedBy - Identifies the tool that generated the lockfile (e.g. `ai-primitives-hub-cli@1.0.0`).
|
|
100
|
+
* @returns Empty Lockfile.
|
|
101
|
+
*/
|
|
102
|
+
export declare const emptyLockfile: (generatedBy: string) => Lockfile;
|
|
103
|
+
export interface LockfileFs {
|
|
104
|
+
readFile(p: string): Promise<string>;
|
|
105
|
+
writeFile(p: string, contents: string): Promise<void>;
|
|
106
|
+
exists(p: string): Promise<boolean>;
|
|
107
|
+
mkdir?(p: string, opts?: {
|
|
108
|
+
recursive?: boolean;
|
|
109
|
+
}): Promise<void>;
|
|
110
|
+
remove?(p: string): Promise<void>;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Get the path to the lockfile for a given commit mode.
|
|
114
|
+
* @param repositoryPath - Repository root.
|
|
115
|
+
* @param commitMode - Commit mode determining which physical file to use.
|
|
116
|
+
* @returns Absolute path to the appropriate lockfile.
|
|
117
|
+
*/
|
|
118
|
+
export declare const getLockfilePathForMode: (repositoryPath: string, commitMode: RepositoryCommitMode) => string;
|
|
119
|
+
/**
|
|
120
|
+
* Read a lockfile from disk; returns `null` when absent.
|
|
121
|
+
* @param file - Absolute lockfile path.
|
|
122
|
+
* @param fs - LockfileFs adapter.
|
|
123
|
+
* @returns Parsed Lockfile, or `null` if the file does not exist.
|
|
124
|
+
* @throws {Error} On invalid JSON.
|
|
125
|
+
*/
|
|
126
|
+
export declare const readLockfile: (file: string, fs: LockfileFs) => Promise<Lockfile | null>;
|
|
127
|
+
/**
|
|
128
|
+
* Write a lockfile to disk (pretty-printed JSON for diff-friendliness).
|
|
129
|
+
* @param file - Absolute lockfile path.
|
|
130
|
+
* @param lock - Lockfile to write.
|
|
131
|
+
* @param fs - LockfileFs adapter.
|
|
132
|
+
*/
|
|
133
|
+
export declare const writeLockfile: (file: string, lock: Lockfile, fs: LockfileFs) => Promise<void>;
|
|
134
|
+
/**
|
|
135
|
+
* Delete a lockfile at the given path if it exists. No-op (does not
|
|
136
|
+
* throw) if the file is already absent or the adapter has no
|
|
137
|
+
* `remove` method.
|
|
138
|
+
* @param file - Absolute lockfile path.
|
|
139
|
+
* @param fs - LockfileFs adapter.
|
|
140
|
+
*/
|
|
141
|
+
export declare const deleteLockfile: (file: string, fs: LockfileFs) => Promise<void>;
|
|
142
|
+
/**
|
|
143
|
+
* Upsert a bundle entry into a lockfile. Pure; doesn't touch disk.
|
|
144
|
+
* @param lock - Existing Lockfile.
|
|
145
|
+
* @param bundleId - Bundle id (the `bundles` map key).
|
|
146
|
+
* @param entry - Entry to add or replace.
|
|
147
|
+
* @returns New Lockfile (input is not mutated).
|
|
148
|
+
*/
|
|
149
|
+
export declare const upsertBundleEntry: (lock: Lockfile, bundleId: string, entry: LockfileBundleEntry) => Lockfile;
|
|
150
|
+
/**
|
|
151
|
+
* Remove a bundle entry from a lockfile. Pure; doesn't touch disk.
|
|
152
|
+
* @param lock - Existing Lockfile.
|
|
153
|
+
* @param bundleId - Bundle id to remove.
|
|
154
|
+
* @returns New Lockfile (input is not mutated).
|
|
155
|
+
*/
|
|
156
|
+
export declare const removeBundleEntry: (lock: Lockfile, bundleId: string) => Lockfile;
|
|
157
|
+
/**
|
|
158
|
+
* Upsert a source descriptor in `lock.sources`. Pure; doesn't touch disk.
|
|
159
|
+
* @param lock - Existing Lockfile.
|
|
160
|
+
* @param sourceId - Stable source id (`generateSourceId` output).
|
|
161
|
+
* @param source - Source descriptor.
|
|
162
|
+
* @returns New Lockfile (input is not mutated).
|
|
163
|
+
*/
|
|
164
|
+
export declare const upsertSource: (lock: Lockfile, sourceId: string, source: LockfileSourceEntry) => Lockfile;
|
|
165
|
+
/**
|
|
166
|
+
* Remove a source descriptor if no remaining bundle references it.
|
|
167
|
+
* Pure; doesn't touch disk.
|
|
168
|
+
* @param lock - Existing Lockfile.
|
|
169
|
+
* @param sourceId - Source id to consider for removal.
|
|
170
|
+
* @returns New Lockfile (input is not mutated).
|
|
171
|
+
*/
|
|
172
|
+
export declare const cleanupOrphanedSource: (lock: Lockfile, sourceId: string) => Lockfile;
|
|
173
|
+
/**
|
|
174
|
+
* Compute SHA256 checksums for every file in an extracted bundle,
|
|
175
|
+
* producing the `{path, checksum}` pairs `LockfileBundleEntry.files`
|
|
176
|
+
* expects. Excludes `deployment-manifest.yml` — it is bundle metadata,
|
|
177
|
+
* not an installed file — matching every writer's own exclusion of it.
|
|
178
|
+
* @param files - Extracted bundle files (path -> raw bytes).
|
|
179
|
+
* @returns Per-file checksum entries, manifest excluded.
|
|
180
|
+
*/
|
|
181
|
+
export declare const checksumFiles: (files: ExtractedFiles) => LockfileFileEntry[];
|
|
182
|
+
/**
|
|
183
|
+
* Find a project-scope lockfile by walking up from `startDir`, then
|
|
184
|
+
* optionally falling back to a user-level path. Checks for either
|
|
185
|
+
* physical lockfile (`LOCKFILE_NAME` or `LOCAL_LOCKFILE_NAME`) at each
|
|
186
|
+
* directory level — unlike the reference branch's `findLockfile`
|
|
187
|
+
* (`infra/src/stores/json-lockfile-store.ts`), which only ever checked
|
|
188
|
+
* a single filename, because this store's schema (adapted to the
|
|
189
|
+
* extension's real on-disk format, see the module doc above) splits
|
|
190
|
+
* commit-mode and local-only entries across two physical files rather
|
|
191
|
+
* than the reference's single-file-with-a-`commitMode`-field shape.
|
|
192
|
+
* Path resolution only — does not read or validate file contents, so
|
|
193
|
+
* the lockfile bundle-entry schema difference from the reference is
|
|
194
|
+
* not a concern here.
|
|
195
|
+
* @param startDir - Directory to start the upward walk from.
|
|
196
|
+
* @param fs - LockfileFs adapter (only `exists` is used).
|
|
197
|
+
* @param userLockfile - Optional user-level lockfile path to try when no
|
|
198
|
+
* project-level lockfile is found (typically
|
|
199
|
+
* `resolveUserConfigPaths(env).userLockfile`).
|
|
200
|
+
* @returns Absolute path to the first lockfile found, or `null`.
|
|
201
|
+
*/
|
|
202
|
+
export declare const findLockfile: (startDir: string, fs: Pick<LockfileFs, "exists">, userLockfile?: string) => Promise<string | null>;
|
|
203
|
+
//# sourceMappingURL=json-lockfile-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-lockfile-store.d.ts","sourceRoot":"","sources":["../../src/stores/json-lockfile-store.ts"],"names":[],"mappings":"AAuCA,OAAO,KAAK,EACV,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC,sEAAsE;AACtE,eAAO,MAAM,aAAa,8BAA8B,CAAC;AACzD,oEAAoE;AACpE,eAAO,MAAM,mBAAmB,oCAAoC,CAAC;AACrE,sEAAsE;AACtE,eAAO,MAAM,uBAAuB,UAAU,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,YAAY,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,uDAAuD;IACvD,QAAQ,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,UAAU,EAAE,MAAM,CAAC;IACnB,mDAAmD;IACnD,WAAW,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAClC,+CAA+C;IAC/C,QAAQ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UAAU,MAAM,EAChB,QAAQ,mBAAmB,KAC1B,QAID,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,GAAI,MAAM,QAAQ,EAAE,UAAU,MAAM,KAAG,QAQxE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,cAAc,KAAG,iBAAiB,EAYtE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,YAAY,GACvB,UAAU,MAAM,EAChB,IAAI,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,EAC9B,eAAe,MAAM,KACpB,OAAO,CAAC,MAAM,GAAG,IAAI,CAmBvB,CAAC"}
|
|
@@ -0,0 +1,277 @@
|
|
|
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.findLockfile = exports.checksumFiles = exports.cleanupOrphanedSource = exports.upsertSource = exports.removeBundleEntry = exports.upsertBundleEntry = exports.deleteLockfile = exports.writeLockfile = exports.readLockfile = exports.getLockfilePathForMode = exports.emptyLockfile = exports.LOCKFILE_SCHEMA_VERSION = exports.LOCAL_LOCKFILE_NAME = exports.LOCKFILE_NAME = void 0;
|
|
37
|
+
/**
|
|
38
|
+
* Install lockfile (repository scope only).
|
|
39
|
+
*
|
|
40
|
+
* Adapted to interoperate byte-for-byte with the VS Code extension's
|
|
41
|
+
* `LockfileManager` (`src/services/lockfile-manager.ts`) schema, NOT
|
|
42
|
+
* the reference branch's schema this module was ported from
|
|
43
|
+
* (schemaVersion `1`, single `entries: LockfileEntry[]` array,
|
|
44
|
+
* `target`-keyed). The two are structurally incompatible:
|
|
45
|
+
*
|
|
46
|
+
* - Extension (this module): `version: '2.0.0'` (string), `bundles:
|
|
47
|
+
* Record<bundleId, LockfileBundleEntry>` (object), `files:
|
|
48
|
+
* LockfileFileEntry[]` (`{path, checksum}`), TWO separate physical
|
|
49
|
+
* files (`prompt-registry.lock.json` for `commit` mode,
|
|
50
|
+
* `prompt-registry.local.lock.json` for `local-only` mode —
|
|
51
|
+
* commitMode is implicit by which file an entry lives in).
|
|
52
|
+
* - Reference branch's original: `schemaVersion: 1` (number),
|
|
53
|
+
* `entries: LockfileEntry[]` (array keyed by target+sourceId+
|
|
54
|
+
* bundleId, to support multi-target lockfiles), `files: string[]`
|
|
55
|
+
* + parallel `fileChecksums`, ONE file with an explicit per-entry
|
|
56
|
+
* `commitMode` field.
|
|
57
|
+
*
|
|
58
|
+
* This module mirrors the extension's actual on-disk shape so a CLI
|
|
59
|
+
* install and an extension install of the same bundle produce
|
|
60
|
+
* byte-compatible lockfile entries. Scope: repository only — the
|
|
61
|
+
* lockfile has never tracked user/workspace-scope installs (no
|
|
62
|
+
* reproducibility/team-sharing use case there), so this store — and
|
|
63
|
+
* the uninstall pipeline that uses it — only applies to
|
|
64
|
+
* `target.scope === 'repository'`. No `target` field exists on
|
|
65
|
+
* `LockfileBundleEntry` for the same reason the extension has none:
|
|
66
|
+
* repository scope always writes to `.github/`, invariant of which
|
|
67
|
+
* IDE type nominally triggered the install (see
|
|
68
|
+
* `writers/repo-scope-writer.ts`'s `RepositoryScopeWriterAdapter`,
|
|
69
|
+
* which ignores its `Target` parameter entirely).
|
|
70
|
+
* @module stores/json-lockfile-store
|
|
71
|
+
*/
|
|
72
|
+
const node_crypto_1 = require("node:crypto");
|
|
73
|
+
const path = __importStar(require("node:path"));
|
|
74
|
+
/** Lockfile filename for commit-mode (git-tracked) bundle entries. */
|
|
75
|
+
exports.LOCKFILE_NAME = 'prompt-registry.lock.json';
|
|
76
|
+
/** Lockfile filename for local-only (gitignored) bundle entries. */
|
|
77
|
+
exports.LOCAL_LOCKFILE_NAME = 'prompt-registry.local.lock.json';
|
|
78
|
+
/** Schema version written by this store — matches the extension's. */
|
|
79
|
+
exports.LOCKFILE_SCHEMA_VERSION = '2.0.0';
|
|
80
|
+
const LOCKFILE_SCHEMA_URL = 'https://github.com/AmadeusITGroup/ai-primitives-hub/schemas/lockfile.schema.json';
|
|
81
|
+
/**
|
|
82
|
+
* Build an empty lockfile structure with required fields.
|
|
83
|
+
* @param generatedBy - Identifies the tool that generated the lockfile (e.g. `ai-primitives-hub-cli@1.0.0`).
|
|
84
|
+
* @returns Empty Lockfile.
|
|
85
|
+
*/
|
|
86
|
+
const emptyLockfile = (generatedBy) => ({
|
|
87
|
+
$schema: LOCKFILE_SCHEMA_URL,
|
|
88
|
+
version: exports.LOCKFILE_SCHEMA_VERSION,
|
|
89
|
+
generatedAt: new Date().toISOString(),
|
|
90
|
+
generatedBy,
|
|
91
|
+
bundles: {},
|
|
92
|
+
sources: {}
|
|
93
|
+
});
|
|
94
|
+
exports.emptyLockfile = emptyLockfile;
|
|
95
|
+
/**
|
|
96
|
+
* Get the path to the lockfile for a given commit mode.
|
|
97
|
+
* @param repositoryPath - Repository root.
|
|
98
|
+
* @param commitMode - Commit mode determining which physical file to use.
|
|
99
|
+
* @returns Absolute path to the appropriate lockfile.
|
|
100
|
+
*/
|
|
101
|
+
const getLockfilePathForMode = (repositoryPath, commitMode) => path.join(repositoryPath, commitMode === 'local-only' ? exports.LOCAL_LOCKFILE_NAME : exports.LOCKFILE_NAME);
|
|
102
|
+
exports.getLockfilePathForMode = getLockfilePathForMode;
|
|
103
|
+
/**
|
|
104
|
+
* Read a lockfile from disk; returns `null` when absent.
|
|
105
|
+
* @param file - Absolute lockfile path.
|
|
106
|
+
* @param fs - LockfileFs adapter.
|
|
107
|
+
* @returns Parsed Lockfile, or `null` if the file does not exist.
|
|
108
|
+
* @throws {Error} On invalid JSON.
|
|
109
|
+
*/
|
|
110
|
+
const readLockfile = async (file, fs) => {
|
|
111
|
+
if (!(await fs.exists(file))) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
const raw = await fs.readFile(file);
|
|
115
|
+
return JSON.parse(raw);
|
|
116
|
+
};
|
|
117
|
+
exports.readLockfile = readLockfile;
|
|
118
|
+
/**
|
|
119
|
+
* Write a lockfile to disk (pretty-printed JSON for diff-friendliness).
|
|
120
|
+
* @param file - Absolute lockfile path.
|
|
121
|
+
* @param lock - Lockfile to write.
|
|
122
|
+
* @param fs - LockfileFs adapter.
|
|
123
|
+
*/
|
|
124
|
+
const writeLockfile = async (file, lock, fs) => {
|
|
125
|
+
if (fs.mkdir !== undefined) {
|
|
126
|
+
const dir = path.dirname(file);
|
|
127
|
+
await fs.mkdir(dir, { recursive: true });
|
|
128
|
+
}
|
|
129
|
+
await fs.writeFile(file, JSON.stringify(lock, null, 2) + '\n');
|
|
130
|
+
};
|
|
131
|
+
exports.writeLockfile = writeLockfile;
|
|
132
|
+
/**
|
|
133
|
+
* Delete a lockfile at the given path if it exists. No-op (does not
|
|
134
|
+
* throw) if the file is already absent or the adapter has no
|
|
135
|
+
* `remove` method.
|
|
136
|
+
* @param file - Absolute lockfile path.
|
|
137
|
+
* @param fs - LockfileFs adapter.
|
|
138
|
+
*/
|
|
139
|
+
const deleteLockfile = async (file, fs) => {
|
|
140
|
+
if (fs.remove === undefined) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
try {
|
|
144
|
+
if (await fs.exists(file)) {
|
|
145
|
+
await fs.remove(file);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
// Ignore errors — deletion is best-effort cleanup.
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
exports.deleteLockfile = deleteLockfile;
|
|
153
|
+
/**
|
|
154
|
+
* Upsert a bundle entry into a lockfile. Pure; doesn't touch disk.
|
|
155
|
+
* @param lock - Existing Lockfile.
|
|
156
|
+
* @param bundleId - Bundle id (the `bundles` map key).
|
|
157
|
+
* @param entry - Entry to add or replace.
|
|
158
|
+
* @returns New Lockfile (input is not mutated).
|
|
159
|
+
*/
|
|
160
|
+
const upsertBundleEntry = (lock, bundleId, entry) => ({
|
|
161
|
+
...lock,
|
|
162
|
+
version: exports.LOCKFILE_SCHEMA_VERSION,
|
|
163
|
+
generatedAt: new Date().toISOString(),
|
|
164
|
+
bundles: { ...lock.bundles, [bundleId]: entry }
|
|
165
|
+
});
|
|
166
|
+
exports.upsertBundleEntry = upsertBundleEntry;
|
|
167
|
+
/**
|
|
168
|
+
* Remove a bundle entry from a lockfile. Pure; doesn't touch disk.
|
|
169
|
+
* @param lock - Existing Lockfile.
|
|
170
|
+
* @param bundleId - Bundle id to remove.
|
|
171
|
+
* @returns New Lockfile (input is not mutated).
|
|
172
|
+
*/
|
|
173
|
+
const removeBundleEntry = (lock, bundleId) => {
|
|
174
|
+
const bundles = { ...lock.bundles };
|
|
175
|
+
delete bundles[bundleId];
|
|
176
|
+
return {
|
|
177
|
+
...lock,
|
|
178
|
+
version: exports.LOCKFILE_SCHEMA_VERSION,
|
|
179
|
+
generatedAt: new Date().toISOString(),
|
|
180
|
+
bundles
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
exports.removeBundleEntry = removeBundleEntry;
|
|
184
|
+
/**
|
|
185
|
+
* Upsert a source descriptor in `lock.sources`. Pure; doesn't touch disk.
|
|
186
|
+
* @param lock - Existing Lockfile.
|
|
187
|
+
* @param sourceId - Stable source id (`generateSourceId` output).
|
|
188
|
+
* @param source - Source descriptor.
|
|
189
|
+
* @returns New Lockfile (input is not mutated).
|
|
190
|
+
*/
|
|
191
|
+
const upsertSource = (lock, sourceId, source) => ({
|
|
192
|
+
...lock,
|
|
193
|
+
version: exports.LOCKFILE_SCHEMA_VERSION,
|
|
194
|
+
sources: { ...lock.sources, [sourceId]: source }
|
|
195
|
+
});
|
|
196
|
+
exports.upsertSource = upsertSource;
|
|
197
|
+
/**
|
|
198
|
+
* Remove a source descriptor if no remaining bundle references it.
|
|
199
|
+
* Pure; doesn't touch disk.
|
|
200
|
+
* @param lock - Existing Lockfile.
|
|
201
|
+
* @param sourceId - Source id to consider for removal.
|
|
202
|
+
* @returns New Lockfile (input is not mutated).
|
|
203
|
+
*/
|
|
204
|
+
const cleanupOrphanedSource = (lock, sourceId) => {
|
|
205
|
+
const stillReferenced = Object.values(lock.bundles).some((b) => b.sourceId === sourceId);
|
|
206
|
+
if (stillReferenced) {
|
|
207
|
+
return lock;
|
|
208
|
+
}
|
|
209
|
+
const sources = { ...lock.sources };
|
|
210
|
+
delete sources[sourceId];
|
|
211
|
+
return { ...lock, sources };
|
|
212
|
+
};
|
|
213
|
+
exports.cleanupOrphanedSource = cleanupOrphanedSource;
|
|
214
|
+
/**
|
|
215
|
+
* Compute SHA256 checksums for every file in an extracted bundle,
|
|
216
|
+
* producing the `{path, checksum}` pairs `LockfileBundleEntry.files`
|
|
217
|
+
* expects. Excludes `deployment-manifest.yml` — it is bundle metadata,
|
|
218
|
+
* not an installed file — matching every writer's own exclusion of it.
|
|
219
|
+
* @param files - Extracted bundle files (path -> raw bytes).
|
|
220
|
+
* @returns Per-file checksum entries, manifest excluded.
|
|
221
|
+
*/
|
|
222
|
+
const checksumFiles = (files) => {
|
|
223
|
+
const entries = [];
|
|
224
|
+
for (const [filePath, bytes] of files) {
|
|
225
|
+
if (filePath === 'deployment-manifest.yml') {
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
entries.push({
|
|
229
|
+
path: filePath,
|
|
230
|
+
checksum: (0, node_crypto_1.createHash)('sha256').update(bytes).digest('hex')
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
return entries;
|
|
234
|
+
};
|
|
235
|
+
exports.checksumFiles = checksumFiles;
|
|
236
|
+
/**
|
|
237
|
+
* Find a project-scope lockfile by walking up from `startDir`, then
|
|
238
|
+
* optionally falling back to a user-level path. Checks for either
|
|
239
|
+
* physical lockfile (`LOCKFILE_NAME` or `LOCAL_LOCKFILE_NAME`) at each
|
|
240
|
+
* directory level — unlike the reference branch's `findLockfile`
|
|
241
|
+
* (`infra/src/stores/json-lockfile-store.ts`), which only ever checked
|
|
242
|
+
* a single filename, because this store's schema (adapted to the
|
|
243
|
+
* extension's real on-disk format, see the module doc above) splits
|
|
244
|
+
* commit-mode and local-only entries across two physical files rather
|
|
245
|
+
* than the reference's single-file-with-a-`commitMode`-field shape.
|
|
246
|
+
* Path resolution only — does not read or validate file contents, so
|
|
247
|
+
* the lockfile bundle-entry schema difference from the reference is
|
|
248
|
+
* not a concern here.
|
|
249
|
+
* @param startDir - Directory to start the upward walk from.
|
|
250
|
+
* @param fs - LockfileFs adapter (only `exists` is used).
|
|
251
|
+
* @param userLockfile - Optional user-level lockfile path to try when no
|
|
252
|
+
* project-level lockfile is found (typically
|
|
253
|
+
* `resolveUserConfigPaths(env).userLockfile`).
|
|
254
|
+
* @returns Absolute path to the first lockfile found, or `null`.
|
|
255
|
+
*/
|
|
256
|
+
const findLockfile = async (startDir, fs, userLockfile) => {
|
|
257
|
+
let dir = startDir;
|
|
258
|
+
while (true) {
|
|
259
|
+
for (const name of [exports.LOCKFILE_NAME, exports.LOCAL_LOCKFILE_NAME]) {
|
|
260
|
+
const candidate = path.join(dir, name);
|
|
261
|
+
if (await fs.exists(candidate)) {
|
|
262
|
+
return candidate;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
const parent = path.dirname(dir);
|
|
266
|
+
if (parent === dir) {
|
|
267
|
+
break;
|
|
268
|
+
}
|
|
269
|
+
dir = parent;
|
|
270
|
+
}
|
|
271
|
+
if (userLockfile !== undefined && await fs.exists(userLockfile)) {
|
|
272
|
+
return userLockfile;
|
|
273
|
+
}
|
|
274
|
+
return null;
|
|
275
|
+
};
|
|
276
|
+
exports.findLockfile = findLockfile;
|
|
277
|
+
//# sourceMappingURL=json-lockfile-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-lockfile-store.js","sourceRoot":"","sources":["../../src/stores/json-lockfile-store.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,6CAEqB;AACrB,gDAAkC;AAKlC,sEAAsE;AACzD,QAAA,aAAa,GAAG,2BAA2B,CAAC;AACzD,oEAAoE;AACvD,QAAA,mBAAmB,GAAG,iCAAiC,CAAC;AACrE,sEAAsE;AACzD,QAAA,uBAAuB,GAAG,OAAO,CAAC;AAkG/C,MAAM,mBAAmB,GAAG,kFAAkF,CAA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AC,MAAM,CAAC,KAAK,CAAC;SAC3D,CAAC,CAAC;IACL,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAZW,QAAA,aAAa,iBAYxB;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACI,MAAM,YAAY,GAAG,KAAK,EAC/B,QAAgB,EAChB,EAA8B,EAC9B,YAAqB,EACG,EAAE;IAC1B,IAAI,GAAG,GAAG,QAAQ,CAAC;IACnB,OAAO,IAAI,EAAE,CAAC;QACZ,KAAK,MAAM,IAAI,IAAI,CAAC,qBAAa,EAAE,2BAAmB,CAAC,EAAE,CAAC;YACxD,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YACvC,IAAI,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;gBAC/B,OAAO,SAAS,CAAC;YACnB,CAAC;QACH,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;YACnB,MAAM;QACR,CAAC;QACD,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;IACD,IAAI,YAAY,KAAK,SAAS,IAAI,MAAM,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;QAChE,OAAO,YAAY,CAAC;IACtB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAvBW,QAAA,YAAY,gBAuBvB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transform subsystem barrel export.
|
|
3
|
+
* @module transform
|
|
4
|
+
*/
|
|
5
|
+
export * from './transformer-registry';
|
|
6
|
+
export * from './transformers/claude-code-transformer';
|
|
7
|
+
export * from './transformers/kiro-transformer';
|
|
8
|
+
export * from './transformers/noop-transformer';
|
|
9
|
+
export * from './transformers/windsurf-transformer';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transform/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,wBAAwB,CAAC;AACvC,cAAc,wCAAwC,CAAC;AACvD,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAChD,cAAc,qCAAqC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/**
|
|
18
|
+
* Transform subsystem barrel export.
|
|
19
|
+
* @module transform
|
|
20
|
+
*/
|
|
21
|
+
__exportStar(require("./transformer-registry"), exports);
|
|
22
|
+
__exportStar(require("./transformers/claude-code-transformer"), exports);
|
|
23
|
+
__exportStar(require("./transformers/kiro-transformer"), exports);
|
|
24
|
+
__exportStar(require("./transformers/noop-transformer"), exports);
|
|
25
|
+
__exportStar(require("./transformers/windsurf-transformer"), exports);
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transform/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;GAGG;AACH,yDAAuC;AACvC,yEAAuD;AACvD,kEAAgD;AAChD,kEAAgD;AAChD,sEAAoD"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TransformerRegistry — maintains target-specific ResourceTransformers.
|
|
3
|
+
*
|
|
4
|
+
* Application layer: pure registry logic, no IO.
|
|
5
|
+
* Concrete transformer implementations live in transformers/ subdirectory.
|
|
6
|
+
*
|
|
7
|
+
* The registry provides a single point to look up transformers by
|
|
8
|
+
* target type. Unknown target types fall back to NoOpTransformer.
|
|
9
|
+
*
|
|
10
|
+
* Ported from the reference branch's
|
|
11
|
+
* `app/src/transform/transformer-registry.ts`; `withBuiltIns()` is
|
|
12
|
+
* extended beyond the reference to also register `WindsurfTransformer`
|
|
13
|
+
* and `ClaudeCodeTransformer` (real implementations — see those
|
|
14
|
+
* modules' own headers — the reference itself only ever registered
|
|
15
|
+
* `kiro`, per migration plan §8 decision 5's "actually implement it,
|
|
16
|
+
* not just model it" scope for these two targets).
|
|
17
|
+
* @module transform/transformer-registry
|
|
18
|
+
*/
|
|
19
|
+
import type { ResourceTransformer, TargetType } from '@ai-primitives-hub/core';
|
|
20
|
+
/**
|
|
21
|
+
* Registry of target-specific transformers.
|
|
22
|
+
* Maps target type identifiers to transformer implementations.
|
|
23
|
+
*/
|
|
24
|
+
export declare class TransformerRegistry {
|
|
25
|
+
private readonly transformers;
|
|
26
|
+
/**
|
|
27
|
+
* Create a TransformerRegistry.
|
|
28
|
+
* @param transformers - Map of target type to transformer implementation.
|
|
29
|
+
*/
|
|
30
|
+
constructor(transformers?: Partial<Record<TargetType, ResourceTransformer>>);
|
|
31
|
+
/**
|
|
32
|
+
* Get a transformer for the given target type.
|
|
33
|
+
* Returns NoOpTransformer for unknown target types (fail-safe).
|
|
34
|
+
* @param targetType - Target type identifier.
|
|
35
|
+
* @returns ResourceTransformer instance.
|
|
36
|
+
*/
|
|
37
|
+
getTransformer(targetType: TargetType): ResourceTransformer;
|
|
38
|
+
/**
|
|
39
|
+
* Register a transformer for a target type.
|
|
40
|
+
* @param targetType - Target type identifier.
|
|
41
|
+
* @param transformer - Transformer implementation.
|
|
42
|
+
*/
|
|
43
|
+
register(targetType: TargetType, transformer: ResourceTransformer): void;
|
|
44
|
+
/**
|
|
45
|
+
* Create a registry with built-in transformers.
|
|
46
|
+
* This factory method initializes the registry with all
|
|
47
|
+
* known target-specific transformers.
|
|
48
|
+
* @returns TransformerRegistry with built-in transformers.
|
|
49
|
+
*/
|
|
50
|
+
static withBuiltIns(): TransformerRegistry;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=transformer-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformer-registry.d.ts","sourceRoot":"","sources":["../../src/transform/transformer-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EACV,mBAAmB,EACnB,UAAU,EACX,MAAM,yBAAyB,CAAC;AAcjC;;;GAGG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAuC;IAEpE;;;OAGG;gBACgB,YAAY,GAAE,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,mBAAmB,CAAC,CAAM;IAItF;;;;;OAKG;IACI,cAAc,CAAC,UAAU,EAAE,UAAU,GAAG,mBAAmB;IAIlE;;;;OAIG;IACI,QAAQ,CAAC,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,mBAAmB,GAAG,IAAI;IAI/E;;;;;OAKG;WACW,YAAY,IAAI,mBAAmB;CAOlD"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransformerRegistry = void 0;
|
|
4
|
+
const claude_code_transformer_1 = require("./transformers/claude-code-transformer");
|
|
5
|
+
const kiro_transformer_1 = require("./transformers/kiro-transformer");
|
|
6
|
+
const noop_transformer_1 = require("./transformers/noop-transformer");
|
|
7
|
+
const windsurf_transformer_1 = require("./transformers/windsurf-transformer");
|
|
8
|
+
/**
|
|
9
|
+
* Registry of target-specific transformers.
|
|
10
|
+
* Maps target type identifiers to transformer implementations.
|
|
11
|
+
*/
|
|
12
|
+
class TransformerRegistry {
|
|
13
|
+
transformers;
|
|
14
|
+
/**
|
|
15
|
+
* Create a TransformerRegistry.
|
|
16
|
+
* @param transformers - Map of target type to transformer implementation.
|
|
17
|
+
*/
|
|
18
|
+
constructor(transformers = {}) {
|
|
19
|
+
this.transformers = new Map(Object.entries(transformers));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get a transformer for the given target type.
|
|
23
|
+
* Returns NoOpTransformer for unknown target types (fail-safe).
|
|
24
|
+
* @param targetType - Target type identifier.
|
|
25
|
+
* @returns ResourceTransformer instance.
|
|
26
|
+
*/
|
|
27
|
+
getTransformer(targetType) {
|
|
28
|
+
return this.transformers.get(targetType) ?? new noop_transformer_1.NoOpTransformer();
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Register a transformer for a target type.
|
|
32
|
+
* @param targetType - Target type identifier.
|
|
33
|
+
* @param transformer - Transformer implementation.
|
|
34
|
+
*/
|
|
35
|
+
register(targetType, transformer) {
|
|
36
|
+
this.transformers.set(targetType, transformer);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Create a registry with built-in transformers.
|
|
40
|
+
* This factory method initializes the registry with all
|
|
41
|
+
* known target-specific transformers.
|
|
42
|
+
* @returns TransformerRegistry with built-in transformers.
|
|
43
|
+
*/
|
|
44
|
+
static withBuiltIns() {
|
|
45
|
+
const registry = new TransformerRegistry();
|
|
46
|
+
registry.register('kiro', new kiro_transformer_1.KiroTransformer());
|
|
47
|
+
registry.register('windsurf', new windsurf_transformer_1.WindsurfTransformer());
|
|
48
|
+
registry.register('claude-code', new claude_code_transformer_1.ClaudeCodeTransformer());
|
|
49
|
+
return registry;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.TransformerRegistry = TransformerRegistry;
|
|
53
|
+
//# sourceMappingURL=transformer-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformer-registry.js","sourceRoot":"","sources":["../../src/transform/transformer-registry.ts"],"names":[],"mappings":";;;AAsBA,oFAEgD;AAChD,sEAEyC;AACzC,sEAEyC;AACzC,8EAE6C;AAE7C;;;GAGG;AACH,MAAa,mBAAmB;IACb,YAAY,CAAuC;IAEpE;;;OAGG;IACH,YAAmB,eAAiE,EAAE;QACpF,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAwC,CAAC,CAAC;IACnG,CAAC;IAED;;;;;OAKG;IACI,cAAc,CAAC,UAAsB;QAC1C,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,IAAI,kCAAe,EAAE,CAAC;IACpE,CAAC;IAED;;;;OAIG;IACI,QAAQ,CAAC,UAAsB,EAAE,WAAgC;QACtE,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;IACjD,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,YAAY;QACxB,MAAM,QAAQ,GAAG,IAAI,mBAAmB,EAAE,CAAC;QAC3C,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,kCAAe,EAAE,CAAC,CAAC;QACjD,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,IAAI,0CAAmB,EAAE,CAAC,CAAC;QACzD,QAAQ,CAAC,QAAQ,CAAC,aAAa,EAAE,IAAI,+CAAqB,EAAE,CAAC,CAAC;QAC9D,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AA3CD,kDA2CC"}
|