@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,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveLayoutFromLayers = resolveLayoutFromLayers;
|
|
4
|
+
/** Workspace-root token resolved from target at install time. */
|
|
5
|
+
const WORKSPACE_ROOT_TOKEN = '${workspaceRoot}';
|
|
6
|
+
/**
|
|
7
|
+
* Merge an ordered array of layout config layers into a single
|
|
8
|
+
* resolved `TargetLayout` for the given target.
|
|
9
|
+
*
|
|
10
|
+
* The `${workspaceRoot}` token in `baseDir` is resolved to
|
|
11
|
+
* `target.rootPath ?? target.path ?? '.'`. Only `scope === 'repository'`
|
|
12
|
+
* uses the `repository` layout branch (falling back to `user`); every
|
|
13
|
+
* other scope value (including this codebase's `workspace` scope,
|
|
14
|
+
* which the reference branch does not have) uses the `user` branch.
|
|
15
|
+
* @param target - Target to resolve.
|
|
16
|
+
* @param layers - Ordered layers from least- to most-specific.
|
|
17
|
+
* @returns Resolved TargetLayout, or null if no definition exists for
|
|
18
|
+
* the target type in any layer.
|
|
19
|
+
*/
|
|
20
|
+
function resolveLayoutFromLayers(target, layers) {
|
|
21
|
+
const scope = target.scope;
|
|
22
|
+
let merged = null;
|
|
23
|
+
for (const layer of layers) {
|
|
24
|
+
const typeDef = layer.layouts[target.type];
|
|
25
|
+
if (typeDef === undefined) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
// Pick the scope-specific def, falling back to 'user' if 'repository' is absent.
|
|
29
|
+
const scopeDef = scope === 'repository'
|
|
30
|
+
? (typeDef.repository ?? typeDef.user)
|
|
31
|
+
: typeDef.user;
|
|
32
|
+
merged = mergeScoped(merged, scopeDef);
|
|
33
|
+
}
|
|
34
|
+
if (merged === null) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
let baseDir;
|
|
38
|
+
if (scope === 'repository') {
|
|
39
|
+
// Repository scope: ${workspaceRoot} resolved from target fields.
|
|
40
|
+
const workspaceRoot = target.rootPath ?? target.path ?? '.';
|
|
41
|
+
baseDir = merged.baseDir === WORKSPACE_ROOT_TOKEN ? workspaceRoot : merged.baseDir;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
// User scope: target.path overrides the config's baseDir if set.
|
|
45
|
+
baseDir = target.path ?? merged.baseDir;
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
baseDir,
|
|
49
|
+
kindRoutes: { ...merged.kindRoutes },
|
|
50
|
+
skipPaths: merged.skipPaths ? [...merged.skipPaths] : undefined
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Deep-merge two ScopedLayoutDef objects.
|
|
55
|
+
* `next` takes precedence for `baseDir` and `skipPaths`;
|
|
56
|
+
* `kindRoutes` are merged entry-by-entry.
|
|
57
|
+
* @param base
|
|
58
|
+
* @param next
|
|
59
|
+
*/
|
|
60
|
+
function mergeScoped(base, next) {
|
|
61
|
+
if (base === null) {
|
|
62
|
+
return next;
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
baseDir: next.baseDir,
|
|
66
|
+
kindRoutes: { ...base.kindRoutes, ...next.kindRoutes },
|
|
67
|
+
skipPaths: next.skipPaths ?? base.skipPaths
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=layout-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout-resolver.js","sourceRoot":"","sources":["../../src/install/layout-resolver.ts"],"names":[],"mappings":";;AAsCA,0DAuCC;AAxDD,iEAAiE;AACjE,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AAEhD;;;;;;;;;;;;;GAaG;AACH,SAAgB,uBAAuB,CACrC,MAAc,EACd,MAA6B;IAE7B,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,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AqB;IAErB,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,UAAU,EAAE,EAAE,GAAG,IAAI,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC,UAAU,EAAE;QACtD,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS;KAC5C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* InstallPipeline orchestrator.
|
|
3
|
+
*
|
|
4
|
+
* Composes the four stages (resolve → download → extract → validate
|
|
5
|
+
* → write) behind a single `run()` entry. Each stage is plug-in
|
|
6
|
+
* via the constructor so unit tests inject deterministic doubles
|
|
7
|
+
* and the production CLI wires real GitHub/HTTP/zip impls.
|
|
8
|
+
*
|
|
9
|
+
* The pipeline emits structured progress events through an optional
|
|
10
|
+
* `onEvent` callback so the install command can render per-step
|
|
11
|
+
* status (verbose mode) or feed the JSON envelope's `meta.events`.
|
|
12
|
+
*
|
|
13
|
+
* Scope-aware routing: callers pass a `writerFactory: (target: Target)
|
|
14
|
+
* => TargetWriter` rather than a single `writer` — routes to
|
|
15
|
+
* `RepositoryScopeWriter` for repository scope, `FileTreeTargetWriter`
|
|
16
|
+
* for user (and workspace) scope.
|
|
17
|
+
* @module install/pipeline
|
|
18
|
+
*/
|
|
19
|
+
import { type BundleDownloader, type BundleExtractor, type BundleResolver, type BundleSpec, type Installable, type Target, type ValidatedManifest } from '@ai-primitives-hub/core';
|
|
20
|
+
import type { TargetWriter, TargetWriteResult } from '../writers/file-tree-writer';
|
|
21
|
+
/**
|
|
22
|
+
* Pipeline events emitted during install.
|
|
23
|
+
* Used for progress tracking and logging.
|
|
24
|
+
*/
|
|
25
|
+
export type PipelineEvent = {
|
|
26
|
+
kind: 'resolve.start';
|
|
27
|
+
spec: BundleSpec;
|
|
28
|
+
} | {
|
|
29
|
+
kind: 'resolve.done';
|
|
30
|
+
installable: Installable;
|
|
31
|
+
} | {
|
|
32
|
+
kind: 'download.start';
|
|
33
|
+
url: string;
|
|
34
|
+
} | {
|
|
35
|
+
kind: 'download.done';
|
|
36
|
+
sha256: string;
|
|
37
|
+
bytes: number;
|
|
38
|
+
} | {
|
|
39
|
+
kind: 'extract.start';
|
|
40
|
+
} | {
|
|
41
|
+
kind: 'extract.done';
|
|
42
|
+
fileCount: number;
|
|
43
|
+
} | {
|
|
44
|
+
kind: 'validate.start';
|
|
45
|
+
} | {
|
|
46
|
+
kind: 'validate.done';
|
|
47
|
+
manifestId: string;
|
|
48
|
+
manifestVersion: string;
|
|
49
|
+
} | {
|
|
50
|
+
kind: 'write.start';
|
|
51
|
+
target: string;
|
|
52
|
+
} | {
|
|
53
|
+
kind: 'write.done';
|
|
54
|
+
target: string;
|
|
55
|
+
written: number;
|
|
56
|
+
skipped: number;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Options for configuring the install pipeline.
|
|
60
|
+
*/
|
|
61
|
+
export interface InstallPipelineOptions {
|
|
62
|
+
resolver: BundleResolver;
|
|
63
|
+
downloader: BundleDownloader;
|
|
64
|
+
extractor: BundleExtractor;
|
|
65
|
+
/** Factory that returns the appropriate writer for a given target. */
|
|
66
|
+
writerFactory: (target: Target) => TargetWriter;
|
|
67
|
+
onEvent?: (event: PipelineEvent) => void;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Outcome of a successful install operation.
|
|
71
|
+
*/
|
|
72
|
+
export interface InstallOutcome {
|
|
73
|
+
installable: Installable;
|
|
74
|
+
manifest: ValidatedManifest;
|
|
75
|
+
write: TargetWriteResult;
|
|
76
|
+
sha256: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Error thrown when the install pipeline fails.
|
|
80
|
+
*/
|
|
81
|
+
export declare class InstallPipelineError extends Error {
|
|
82
|
+
readonly code: string;
|
|
83
|
+
readonly stage: 'resolve' | 'download' | 'extract' | 'validate' | 'write';
|
|
84
|
+
/**
|
|
85
|
+
* Create an InstallPipelineError.
|
|
86
|
+
* @param message Error message.
|
|
87
|
+
* @param code Error code for programmatic handling.
|
|
88
|
+
* @param stage Pipeline stage where the error occurred.
|
|
89
|
+
*/
|
|
90
|
+
constructor(message: string, code: string, stage: 'resolve' | 'download' | 'extract' | 'validate' | 'write');
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* InstallPipeline orchestrates the install process.
|
|
94
|
+
* Composes resolve → download → extract → validate → write stages.
|
|
95
|
+
*/
|
|
96
|
+
export declare class InstallPipeline {
|
|
97
|
+
private readonly opts;
|
|
98
|
+
/**
|
|
99
|
+
* Create an InstallPipeline.
|
|
100
|
+
* @param opts Pipeline options including resolver, downloader, extractor, writer factory, and event callback.
|
|
101
|
+
*/
|
|
102
|
+
constructor(opts: InstallPipelineOptions);
|
|
103
|
+
/**
|
|
104
|
+
* Run the install pipeline end-to-end.
|
|
105
|
+
* @param spec - Parsed BundleSpec.
|
|
106
|
+
* @param target - Target to write into.
|
|
107
|
+
* @returns InstallOutcome.
|
|
108
|
+
*/
|
|
109
|
+
run(spec: BundleSpec, target: Target): Promise<InstallOutcome>;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/install/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,MAAM,EACX,KAAK,iBAAiB,EAEvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EAClB,MAAM,6BAA6B,CAAC;AAErC;;;GAGG;AACH,MAAM,MAAM,aAAa,G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AAM,CAAC;CAChB;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;aAS3B,IAAI,EAAE,MAAM;aACZ,KAAK,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,OAAO;IATlF;;;;;OAKG;gBAED,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,OAAO;CAKnF;AAED;;;GAGG;AACH,qBAAa,eAAe;IAKP,OAAO,CAAC,QAAQ,CAAC,IAAI;IAJxC;;;OAGG;gBACiC,IAAI,EAAE,sBAAsB;IAEhE;;;;;OAKG;IACU,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;CA4F5E"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InstallPipeline = exports.InstallPipelineError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* InstallPipeline orchestrator.
|
|
6
|
+
*
|
|
7
|
+
* Composes the four stages (resolve → download → extract → validate
|
|
8
|
+
* → write) behind a single `run()` entry. Each stage is plug-in
|
|
9
|
+
* via the constructor so unit tests inject deterministic doubles
|
|
10
|
+
* and the production CLI wires real GitHub/HTTP/zip impls.
|
|
11
|
+
*
|
|
12
|
+
* The pipeline emits structured progress events through an optional
|
|
13
|
+
* `onEvent` callback so the install command can render per-step
|
|
14
|
+
* status (verbose mode) or feed the JSON envelope's `meta.events`.
|
|
15
|
+
*
|
|
16
|
+
* Scope-aware routing: callers pass a `writerFactory: (target: Target)
|
|
17
|
+
* => TargetWriter` rather than a single `writer` — routes to
|
|
18
|
+
* `RepositoryScopeWriter` for repository scope, `FileTreeTargetWriter`
|
|
19
|
+
* for user (and workspace) scope.
|
|
20
|
+
* @module install/pipeline
|
|
21
|
+
*/
|
|
22
|
+
const core_1 = require("@ai-primitives-hub/core");
|
|
23
|
+
/**
|
|
24
|
+
* Error thrown when the install pipeline fails.
|
|
25
|
+
*/
|
|
26
|
+
class InstallPipelineError extends Error {
|
|
27
|
+
code;
|
|
28
|
+
stage;
|
|
29
|
+
/**
|
|
30
|
+
* Create an InstallPipelineError.
|
|
31
|
+
* @param message Error message.
|
|
32
|
+
* @param code Error code for programmatic handling.
|
|
33
|
+
* @param stage Pipeline stage where the error occurred.
|
|
34
|
+
*/
|
|
35
|
+
constructor(message, code, stage) {
|
|
36
|
+
super(message);
|
|
37
|
+
this.code = code;
|
|
38
|
+
this.stage = stage;
|
|
39
|
+
this.name = 'InstallPipelineError';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.InstallPipelineError = InstallPipelineError;
|
|
43
|
+
/**
|
|
44
|
+
* InstallPipeline orchestrates the install process.
|
|
45
|
+
* Composes resolve → download → extract → validate → write stages.
|
|
46
|
+
*/
|
|
47
|
+
class InstallPipeline {
|
|
48
|
+
opts;
|
|
49
|
+
/**
|
|
50
|
+
* Create an InstallPipeline.
|
|
51
|
+
* @param opts Pipeline options including resolver, downloader, extractor, writer factory, and event callback.
|
|
52
|
+
*/
|
|
53
|
+
constructor(opts) {
|
|
54
|
+
this.opts = opts;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Run the install pipeline end-to-end.
|
|
58
|
+
* @param spec - Parsed BundleSpec.
|
|
59
|
+
* @param target - Target to write into.
|
|
60
|
+
* @returns InstallOutcome.
|
|
61
|
+
*/
|
|
62
|
+
async run(spec, target) {
|
|
63
|
+
const emit = (e) => {
|
|
64
|
+
if (this.opts.onEvent !== undefined) {
|
|
65
|
+
this.opts.onEvent(e);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
// 1. Resolve.
|
|
69
|
+
emit({ kind: 'resolve.start', spec });
|
|
70
|
+
const installable = await this.opts.resolver.resolve(spec);
|
|
71
|
+
if (installable === null) {
|
|
72
|
+
throw new InstallPipelineError(`bundle "${describeSpec(spec)}" not found`, 'BUNDLE.NOT_FOUND', 'resolve');
|
|
73
|
+
}
|
|
74
|
+
emit({ kind: 'resolve.done', installable });
|
|
75
|
+
// 2. Download.
|
|
76
|
+
emit({ kind: 'download.start', url: installable.downloadUrl });
|
|
77
|
+
let download;
|
|
78
|
+
try {
|
|
79
|
+
download = await this.opts.downloader.download(installable);
|
|
80
|
+
}
|
|
81
|
+
catch (downloadError) {
|
|
82
|
+
throw new InstallPipelineError(`download failed: ${downloadError.message}`, 'NETWORK.DOWNLOAD_FAILED', 'download');
|
|
83
|
+
}
|
|
84
|
+
emit({ kind: 'download.done', sha256: download.sha256, bytes: download.bytes.byteLength });
|
|
85
|
+
// 3. Extract.
|
|
86
|
+
emit({ kind: 'extract.start' });
|
|
87
|
+
let files;
|
|
88
|
+
try {
|
|
89
|
+
files = await this.opts.extractor.extract(download.bytes);
|
|
90
|
+
}
|
|
91
|
+
catch (extractError) {
|
|
92
|
+
throw new InstallPipelineError(`extract failed: ${extractError.message}`, 'BUNDLE.EXTRACT_FAILED', 'extract');
|
|
93
|
+
}
|
|
94
|
+
emit({ kind: 'extract.done', fileCount: files.size });
|
|
95
|
+
// 4. Validate manifest.
|
|
96
|
+
emit({ kind: 'validate.start' });
|
|
97
|
+
let manifest;
|
|
98
|
+
try {
|
|
99
|
+
manifest = (0, core_1.validateManifest)(files, {
|
|
100
|
+
expectedId: spec.bundleId,
|
|
101
|
+
expectedVersion: spec.bundleVersion
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
catch (validateError) {
|
|
105
|
+
const e = validateError;
|
|
106
|
+
throw new InstallPipelineError(e.message, e.code ?? 'BUNDLE.MANIFEST_INVALID', 'validate');
|
|
107
|
+
}
|
|
108
|
+
emit({ kind: 'validate.done', manifestId: manifest.id, manifestVersion: manifest.version });
|
|
109
|
+
// 5. Write to target.
|
|
110
|
+
emit({ kind: 'write.start', target: target.name });
|
|
111
|
+
let writeResult;
|
|
112
|
+
try {
|
|
113
|
+
const writer = this.opts.writerFactory(target);
|
|
114
|
+
writeResult = await writer.write(target, files);
|
|
115
|
+
}
|
|
116
|
+
catch (writeError) {
|
|
117
|
+
throw new InstallPipelineError(`write failed: ${writeError.message}`, 'FS.WRITE_FAILED', 'write');
|
|
118
|
+
}
|
|
119
|
+
emit({
|
|
120
|
+
kind: 'write.done',
|
|
121
|
+
target: target.name,
|
|
122
|
+
written: writeResult.written.length,
|
|
123
|
+
skipped: writeResult.skipped.length
|
|
124
|
+
});
|
|
125
|
+
return {
|
|
126
|
+
installable,
|
|
127
|
+
manifest,
|
|
128
|
+
write: writeResult,
|
|
129
|
+
sha256: download.sha256
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.InstallPipeline = InstallPipeline;
|
|
134
|
+
const describeSpec = (s) => {
|
|
135
|
+
const head = s.sourceId === undefined ? s.bundleId : `${s.sourceId}:${s.bundleId}`;
|
|
136
|
+
return s.bundleVersion === undefined ? head : `${head}@${s.bundleVersion}`;
|
|
137
|
+
};
|
|
138
|
+
//# sourceMappingURL=pipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../src/install/pipeline.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,kDASiC;AA4CjC;;GAEG;AACH,MAAa,oBAAqB,SAAQ,KAAK;IAS3B;IACA;IATlB;;;;;OAKG;IACH,YACE,OAAe,EACC,IAAY,EACZ,KAAgE;QAEhF,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAAQ;QACZ,UAAK,GAAL,KAAK,CAA2D;QAGhF,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAfD,oDAeC;AAED;;;GAGG;AACH,MAAa,eAAe;IAKU;IAJpC;;;OAGG;IACH,YAAoC,IAA4B;QAA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C;QACnD,IAAI,WAAW,CAAC;QAChB,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;YAC/C,WAAW,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAClD,CAAC;QAAC,OAAO,UAAU,EAAE,CAAC;YACpB,MAAM,IAAI,oBAAoB,CAC5B,iBAAkB,UAAoB,CAAC,OAAO,EAAE,EAChD,iBAAiB,EACjB,OAAO,CACR,CAAC;QACJ,CAAC;QACD,IAAI,CAAC;YACH,IAAI,EAAE,YAAY;YAClB,MAAM,EAAE,MAAM,CAAC,IAAI;YACnB,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,MAAM;YACnC,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,MAAM;SACpC,CAAC,CAAC;QAEH,OAAO;YACL,WAAW;YACX,QAAQ;YACR,KAAK,EAAE,WAAW;YAClB,MAAM,EAAE,QAAQ,CAAC,MAAM;SACxB,CAAC;IACJ,CAAC;CACF;AAzGD,0CAyGC;AAED,MAAM,YAAY,GAAG,CAAC,CAAa,EAAU,EAAE;IAC7C,MAAM,IAAI,GAAG,CAAC,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;IACnF,OAAO,CAAC,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;AAC7E,CAAC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UninstallBundleUseCase — application-layer orchestrator for bundle
|
|
3
|
+
* removal. Wraps `UninstallPipeline` and depends only on port interfaces.
|
|
4
|
+
*
|
|
5
|
+
* This module never instantiates concrete classes; it only calls
|
|
6
|
+
* port interface methods.
|
|
7
|
+
* @module install/uninstall-bundle
|
|
8
|
+
*/
|
|
9
|
+
import type { FileSystem, Target } from '@ai-primitives-hub/core';
|
|
10
|
+
import type { TargetWriter } from '../writers/file-tree-writer';
|
|
11
|
+
import { type UninstallPlan, type UninstallResult } from './uninstall-pipeline';
|
|
12
|
+
export interface UninstallBundleInput {
|
|
13
|
+
bundleId?: string;
|
|
14
|
+
target: Target;
|
|
15
|
+
/** Repository root — both lockfile variants are read from here. */
|
|
16
|
+
repositoryPath: string;
|
|
17
|
+
}
|
|
18
|
+
export interface UninstallBundleOptions {
|
|
19
|
+
fs: FileSystem;
|
|
20
|
+
writerFactory: (target: Target) => TargetWriter;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Plan a bundle uninstall (reads the lockfile, produces removal list).
|
|
24
|
+
* @param input Bundle id, target, and repository root.
|
|
25
|
+
* @param opts Injected port implementations.
|
|
26
|
+
* @returns Uninstall plan.
|
|
27
|
+
*/
|
|
28
|
+
export declare const planUninstall: (input: UninstallBundleInput, opts: UninstallBundleOptions) => Promise<UninstallPlan | UninstallPlan[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Execute a bundle uninstall.
|
|
31
|
+
* @param input Bundle id, target, and repository root.
|
|
32
|
+
* @param opts Injected port implementations.
|
|
33
|
+
* @returns Uninstall result.
|
|
34
|
+
*/
|
|
35
|
+
export declare const uninstallBundle: (input: UninstallBundleInput, opts: UninstallBundleOptions) => Promise<UninstallResult | UninstallResult[]>;
|
|
36
|
+
//# sourceMappingURL=uninstall-bundle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uninstall-bundle.d.ts","sourceRoot":"","sources":["../../src/install/uninstall-bundle.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EACV,UAAU,EACV,MAAM,EACP,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,YAAY,EACb,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,eAAe,EACrB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,mEAAmE;IACnE,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,UAAU,CAAC;IACf,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,YAAY,CAAC;CACjD;AAED;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GACxB,OAAO,oBAAoB,EAC3B,MAAM,sBAAsB,KAC3B,OAAO,CAAC,aAAa,GAAG,aAAa,EAAE,CAKzC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,oBAAoB,EAC3B,MAAM,sBAAsB,KAC3B,OAAO,CAAC,eAAe,GAAG,eAAe,EAAE,CAK7C,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uninstallBundle = exports.planUninstall = void 0;
|
|
4
|
+
const uninstall_pipeline_1 = require("./uninstall-pipeline");
|
|
5
|
+
/**
|
|
6
|
+
* Plan a bundle uninstall (reads the lockfile, produces removal list).
|
|
7
|
+
* @param input Bundle id, target, and repository root.
|
|
8
|
+
* @param opts Injected port implementations.
|
|
9
|
+
* @returns Uninstall plan.
|
|
10
|
+
*/
|
|
11
|
+
const planUninstall = (input, opts) => {
|
|
12
|
+
const pipeline = createPipeline(input, opts);
|
|
13
|
+
return input.bundleId === undefined
|
|
14
|
+
? pipeline.planAll()
|
|
15
|
+
: pipeline.plan(input.bundleId);
|
|
16
|
+
};
|
|
17
|
+
exports.planUninstall = planUninstall;
|
|
18
|
+
/**
|
|
19
|
+
* Execute a bundle uninstall.
|
|
20
|
+
* @param input Bundle id, target, and repository root.
|
|
21
|
+
* @param opts Injected port implementations.
|
|
22
|
+
* @returns Uninstall result.
|
|
23
|
+
*/
|
|
24
|
+
const uninstallBundle = (input, opts) => {
|
|
25
|
+
const pipeline = createPipeline(input, opts);
|
|
26
|
+
return input.bundleId === undefined
|
|
27
|
+
? pipeline.runAll()
|
|
28
|
+
: pipeline.run(input.bundleId);
|
|
29
|
+
};
|
|
30
|
+
exports.uninstallBundle = uninstallBundle;
|
|
31
|
+
const createPipeline = (input, opts) => new uninstall_pipeline_1.UninstallPipeline({
|
|
32
|
+
fs: opts.fs,
|
|
33
|
+
target: input.target,
|
|
34
|
+
repositoryPath: input.repositoryPath,
|
|
35
|
+
writerFactory: opts.writerFactory
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=uninstall-bundle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uninstall-bundle.js","sourceRoot":"","sources":["../../src/install/uninstall-bundle.ts"],"names":[],"mappings":";;;AAeA,6DAI8B;AAc9B;;;;;GAKG;AACI,MAAM,aAAa,GAAG,CAC3B,KAA2B,EAC3B,IAA4B,EACc,EAAE;IAC5C,MAAM,QAAQ,GAAG,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC7C,OAAO,KAAK,CAAC,QAAQ,KAAK,SAAS;QACjC,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE;QACpB,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AACpC,CAAC,CAAC;AARW,QAAA,aAAa,iBAQxB;AAEF;;;;;GAKG;AACI,MAAM,eAAe,GAAG,CAC7B,KAA2B,EAC3B,IAA4B,EACkB,EAAE;IAChD,MAAM,QAAQ,GAAG,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC7C,OAAO,KAAK,CAAC,QAAQ,KAAK,SAAS;QACjC,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE;QACnB,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AACnC,CAAC,CAAC;AARW,QAAA,eAAe,mBAQ1B;AAEF,MAAM,cAAc,GAAG,CACrB,KAA2B,EAC3B,IAA4B,EACT,EAAE,CACrB,IAAI,sCAAiB,CAAC;IACpB,EAAE,EAAE,IAAI,CAAC,EAAE;IACX,MAAM,EAAE,KAAK,CAAC,MAAM;IACpB,cAAc,EAAE,KAAK,CAAC,cAAc;IACpC,aAAa,EAAE,IAAI,CAAC,aAAa;CAClC,CAAC,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Uninstall Pipeline.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the install pipeline but for removal operations:
|
|
5
|
+
* - Resolve installed bundle from the lockfile
|
|
6
|
+
* - Plan file removals
|
|
7
|
+
* - Execute removals via target writer
|
|
8
|
+
* - Update the lockfile
|
|
9
|
+
*
|
|
10
|
+
* Repository scope only — see `stores/json-lockfile-store.ts`'s module
|
|
11
|
+
* doc for why. Since the lockfile is split across two physical files
|
|
12
|
+
* (`prompt-registry.lock.json` for `commit` mode,
|
|
13
|
+
* `prompt-registry.local.lock.json` for `local-only`) with no
|
|
14
|
+
* per-entry `target` field, a bundle id is looked up in both files
|
|
15
|
+
* (mirroring the extension's own `LockfileManager.remove()`), and
|
|
16
|
+
* whichever file it's found in is the one updated.
|
|
17
|
+
*
|
|
18
|
+
* Known gap (matches the reference branch's own pipeline, not a
|
|
19
|
+
* regression introduced here): per-file removal goes through the
|
|
20
|
+
* generic `TargetWriter.remove()` method, which does not perform the
|
|
21
|
+
* git-exclude cleanup that `RepositoryScopeWriter`'s own richer
|
|
22
|
+
* `.remove(bundleId, manifest)` method does. Wiring that through the
|
|
23
|
+
* `TargetWriter` interface is deferred.
|
|
24
|
+
* @module install/uninstall-pipeline
|
|
25
|
+
*/
|
|
26
|
+
import type { FileSystem, Target } from '@ai-primitives-hub/core';
|
|
27
|
+
import type { LockfileBundleEntry, RepositoryCommitMode } from '../stores/json-lockfile-store';
|
|
28
|
+
import type { TargetWriter } from '../writers/file-tree-writer';
|
|
29
|
+
/**
|
|
30
|
+
* Options for uninstall pipeline.
|
|
31
|
+
*/
|
|
32
|
+
export interface UninstallPipelineOptions {
|
|
33
|
+
/** Filesystem abstraction. */
|
|
34
|
+
fs: FileSystem;
|
|
35
|
+
/** Target to uninstall from (must be repository scope). */
|
|
36
|
+
target: Target;
|
|
37
|
+
/** Repository root — both lockfile variants are read from here. */
|
|
38
|
+
repositoryPath: string;
|
|
39
|
+
/** Writer factory for scope-aware routing. */
|
|
40
|
+
writerFactory: (target: Target) => TargetWriter;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Uninstall plan result.
|
|
44
|
+
*/
|
|
45
|
+
export interface UninstallPlan {
|
|
46
|
+
/** Bundle ID to uninstall. */
|
|
47
|
+
bundleId: string;
|
|
48
|
+
/** Files to remove (bundle-relative paths from the lockfile entry). */
|
|
49
|
+
filesToRemove: string[];
|
|
50
|
+
/** Lockfile entry to remove (if found). */
|
|
51
|
+
lockfileEntry: LockfileBundleEntry | null;
|
|
52
|
+
/** Which physical lockfile the entry was found in. */
|
|
53
|
+
commitMode?: RepositoryCommitMode;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Uninstall result.
|
|
57
|
+
*/
|
|
58
|
+
export interface UninstallResult {
|
|
59
|
+
/** Bundle ID that was uninstalled. */
|
|
60
|
+
bundleId: string;
|
|
61
|
+
/** Files removed. */
|
|
62
|
+
removed: string[];
|
|
63
|
+
/** Files not found (skipped). */
|
|
64
|
+
skipped: string[];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Uninstall pipeline for bundle removal.
|
|
68
|
+
*/
|
|
69
|
+
export declare class UninstallPipeline {
|
|
70
|
+
private readonly fs;
|
|
71
|
+
private readonly target;
|
|
72
|
+
private readonly repositoryPath;
|
|
73
|
+
private readonly writerFactory;
|
|
74
|
+
constructor(opts: UninstallPipelineOptions);
|
|
75
|
+
/**
|
|
76
|
+
* Remove files via writer.
|
|
77
|
+
* @param writer - Target writer.
|
|
78
|
+
* @param files - Files to remove.
|
|
79
|
+
* @returns Removal result.
|
|
80
|
+
*/
|
|
81
|
+
private removeFiles;
|
|
82
|
+
/**
|
|
83
|
+
* Remove a bundle entry from its lockfile, cleaning up orphaned
|
|
84
|
+
* sources and deleting the physical file when it becomes empty.
|
|
85
|
+
* @param bundleId - Bundle id to remove.
|
|
86
|
+
* @param entry - The entry being removed (for its sourceId).
|
|
87
|
+
* @param commitMode - Which physical lockfile to update.
|
|
88
|
+
*/
|
|
89
|
+
private removeFromLockfile;
|
|
90
|
+
/**
|
|
91
|
+
* Plan uninstall by resolving the bundle in either lockfile.
|
|
92
|
+
* @param id - Bundle ID to uninstall.
|
|
93
|
+
* @returns Uninstall plan.
|
|
94
|
+
*/
|
|
95
|
+
plan(id: string): Promise<UninstallPlan>;
|
|
96
|
+
/**
|
|
97
|
+
* Execute uninstall by removing files and updating the lockfile.
|
|
98
|
+
* @param id - Bundle ID to uninstall.
|
|
99
|
+
* @returns Uninstall result.
|
|
100
|
+
*/
|
|
101
|
+
run(id: string): Promise<UninstallResult>;
|
|
102
|
+
/**
|
|
103
|
+
* Plan uninstall for every bundle across both lockfiles.
|
|
104
|
+
* @returns Array of uninstall plans.
|
|
105
|
+
*/
|
|
106
|
+
planAll(): Promise<UninstallPlan[]>;
|
|
107
|
+
/**
|
|
108
|
+
* Execute uninstall for every bundle across both lockfiles.
|
|
109
|
+
* @returns Array of uninstall results.
|
|
110
|
+
*/
|
|
111
|
+
runAll(): Promise<UninstallResult[]>;
|
|
112
|
+
/**
|
|
113
|
+
* Execute uninstall for every bundle across both lockfiles,
|
|
114
|
+
* tolerating missing/invalid lockfiles by returning an empty result.
|
|
115
|
+
* @returns Array of uninstall results.
|
|
116
|
+
*/
|
|
117
|
+
runFromLockfile(): Promise<UninstallResult[]>;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=uninstall-pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uninstall-pipeline.d.ts","sourceRoot":"","sources":["../../src/install/uninstall-pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,MAAM,EACP,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,+BAA+B,CAAC;AASvC,OAAO,KAAK,EACV,YAAY,EACb,MAAM,6BAA6B,CAAC;AAErC;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,8BAA8B;IAC9B,EAAE,EAAE,UAAU,CAAC;IACf,2DAA2D;IAC3D,MAAM,EAAE,MAAM,CAAC;IACf,mEAAmE;IACnE,cAAc,EAAE,MAAM,CAAC;IACvB,8CAA8C;IAC9C,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,YAAY,CAAC;CACjD;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,2CAA2C;IAC3C,aAAa,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAC1C,sDAAsD;IACtD,UAAU,CAAC,EAAE,oBAAoB,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,sCAAsC;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,qBAAqB;IACrB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,iCAAiC;IACjC,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAID;;GAEG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAa;IAChC,OAAO,CAAC,QAAQ,C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