harnesstap 1.2.0 → 1.3.0
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 +28 -15
- package/dist/apply-QSS4242W.js +67 -0
- package/dist/apply-QSS4242W.js.map +1 -0
- package/dist/approve-CNYQY6DC.js +181 -0
- package/dist/approve-CNYQY6DC.js.map +1 -0
- package/dist/audit-V4SUV7KA.js +434 -0
- package/dist/audit-V4SUV7KA.js.map +1 -0
- package/dist/auth-63FOHIQ3.js +220 -0
- package/dist/auth-63FOHIQ3.js.map +1 -0
- package/dist/bin.js +166 -0
- package/dist/bin.js.map +1 -0
- package/dist/chunk-2H7UOFLK.js +11 -0
- package/dist/chunk-2H7UOFLK.js.map +1 -0
- package/dist/chunk-2NE3QYMP.js +103 -0
- package/dist/chunk-2NE3QYMP.js.map +1 -0
- package/dist/chunk-2P2EOYEW.js +1140 -0
- package/dist/chunk-2P2EOYEW.js.map +1 -0
- package/dist/chunk-37E5M4JX.js +34 -0
- package/dist/chunk-37E5M4JX.js.map +1 -0
- package/dist/chunk-37LQQWMF.js +496 -0
- package/dist/chunk-37LQQWMF.js.map +1 -0
- package/dist/chunk-3FIWOI3H.js +98 -0
- package/dist/chunk-3FIWOI3H.js.map +1 -0
- package/dist/chunk-3PGC6OA3.js +540 -0
- package/dist/chunk-3PGC6OA3.js.map +1 -0
- package/dist/chunk-4IHKBIY3.js +118 -0
- package/dist/chunk-4IHKBIY3.js.map +1 -0
- package/dist/chunk-4ZUBRLSP.js +17 -0
- package/dist/chunk-4ZUBRLSP.js.map +1 -0
- package/dist/chunk-5F3LNDZG.js +9 -0
- package/dist/chunk-5F3LNDZG.js.map +1 -0
- package/dist/chunk-5TXI6BI2.js +1359 -0
- package/dist/chunk-5TXI6BI2.js.map +1 -0
- package/dist/chunk-6P5IO4BX.js +235 -0
- package/dist/chunk-6P5IO4BX.js.map +1 -0
- package/dist/chunk-ABXUKHAU.js +571 -0
- package/dist/chunk-ABXUKHAU.js.map +1 -0
- package/dist/chunk-AOUDSNRK.js +1357 -0
- package/dist/chunk-AOUDSNRK.js.map +1 -0
- package/dist/chunk-BNDJJAEI.js +311 -0
- package/dist/chunk-BNDJJAEI.js.map +1 -0
- package/dist/chunk-C2IWSFF5.js +818 -0
- package/dist/chunk-C2IWSFF5.js.map +1 -0
- package/dist/chunk-CHQGE2HF.js +283 -0
- package/dist/chunk-CHQGE2HF.js.map +1 -0
- package/dist/chunk-DEJLP7QJ.js +681 -0
- package/dist/chunk-DEJLP7QJ.js.map +1 -0
- package/dist/chunk-DJ6FN6EW.js +532 -0
- package/dist/chunk-DJ6FN6EW.js.map +1 -0
- package/dist/chunk-E4WRTRMH.js +1173 -0
- package/dist/chunk-E4WRTRMH.js.map +1 -0
- package/dist/chunk-E5QXNU3K.js +238 -0
- package/dist/chunk-E5QXNU3K.js.map +1 -0
- package/dist/chunk-EMTBGOR3.js +2959 -0
- package/dist/chunk-EMTBGOR3.js.map +1 -0
- package/dist/chunk-FFWYIGQ4.js +18 -0
- package/dist/chunk-FFWYIGQ4.js.map +1 -0
- package/dist/chunk-I6XFZLTJ.js +9 -0
- package/dist/chunk-I6XFZLTJ.js.map +1 -0
- package/dist/chunk-IHWAOIAU.js +172 -0
- package/dist/chunk-IHWAOIAU.js.map +1 -0
- package/dist/chunk-IHZUYG66.js +583 -0
- package/dist/chunk-IHZUYG66.js.map +1 -0
- package/dist/chunk-JQOKQKQT.js +158 -0
- package/dist/chunk-JQOKQKQT.js.map +1 -0
- package/dist/chunk-JRFUTIEH.js +426 -0
- package/dist/chunk-JRFUTIEH.js.map +1 -0
- package/dist/chunk-KCBI6JQC.js +115 -0
- package/dist/chunk-KCBI6JQC.js.map +1 -0
- package/dist/chunk-KDUQMINL.js +60 -0
- package/dist/chunk-KDUQMINL.js.map +1 -0
- package/dist/chunk-KLR2DURP.js +656 -0
- package/dist/chunk-KLR2DURP.js.map +1 -0
- package/dist/chunk-KRI4R7EM.js +25 -0
- package/dist/chunk-KRI4R7EM.js.map +1 -0
- package/dist/chunk-LYQMK6SV.js +87 -0
- package/dist/chunk-LYQMK6SV.js.map +1 -0
- package/dist/chunk-MK3Q37ZN.js +183 -0
- package/dist/chunk-MK3Q37ZN.js.map +1 -0
- package/dist/chunk-MSGAGV7B.js +346 -0
- package/dist/chunk-MSGAGV7B.js.map +1 -0
- package/dist/chunk-MZQRSERO.js +430 -0
- package/dist/chunk-MZQRSERO.js.map +1 -0
- package/dist/chunk-N3WIJXXM.js +691 -0
- package/dist/chunk-N3WIJXXM.js.map +1 -0
- package/dist/chunk-NAGAJ5UM.js +145 -0
- package/dist/chunk-NAGAJ5UM.js.map +1 -0
- package/dist/chunk-NFYPBTKO.js +302 -0
- package/dist/chunk-NFYPBTKO.js.map +1 -0
- package/dist/chunk-NPO2IG6G.js +491 -0
- package/dist/chunk-NPO2IG6G.js.map +1 -0
- package/dist/chunk-OS6NUIBJ.js +38 -0
- package/dist/chunk-OS6NUIBJ.js.map +1 -0
- package/dist/chunk-PFUK3HJ4.js +296 -0
- package/dist/chunk-PFUK3HJ4.js.map +1 -0
- package/dist/chunk-PMQ55GDB.js +115 -0
- package/dist/chunk-PMQ55GDB.js.map +1 -0
- package/dist/chunk-QIVE2YFJ.js +514 -0
- package/dist/chunk-QIVE2YFJ.js.map +1 -0
- package/dist/chunk-QKXD3EUF.js +691 -0
- package/dist/chunk-QKXD3EUF.js.map +1 -0
- package/dist/chunk-RNQYUWF6.js +32 -0
- package/dist/chunk-RNQYUWF6.js.map +1 -0
- package/dist/chunk-S2E4SSQV.js +41 -0
- package/dist/chunk-S2E4SSQV.js.map +1 -0
- package/dist/chunk-SN4BXX3B.js +186 -0
- package/dist/chunk-SN4BXX3B.js.map +1 -0
- package/dist/chunk-SNVAMWB7.js +40 -0
- package/dist/chunk-SNVAMWB7.js.map +1 -0
- package/dist/chunk-T5VRREN4.js +696 -0
- package/dist/chunk-T5VRREN4.js.map +1 -0
- package/dist/chunk-TKBMHZTS.js +10945 -0
- package/dist/chunk-TKBMHZTS.js.map +1 -0
- package/dist/chunk-TNJPTUE4.js +35 -0
- package/dist/chunk-TNJPTUE4.js.map +1 -0
- package/dist/chunk-TQ2NA4Z4.js +24 -0
- package/dist/chunk-TQ2NA4Z4.js.map +1 -0
- package/dist/chunk-TXXDMDPN.js +998 -0
- package/dist/chunk-TXXDMDPN.js.map +1 -0
- package/dist/chunk-UWXUBU7V.js +184 -0
- package/dist/chunk-UWXUBU7V.js.map +1 -0
- package/dist/chunk-UYRK2H24.js +141 -0
- package/dist/chunk-UYRK2H24.js.map +1 -0
- package/dist/chunk-V4IXIM3C.js +806 -0
- package/dist/chunk-V4IXIM3C.js.map +1 -0
- package/dist/chunk-VFHVXXP4.js +6438 -0
- package/dist/chunk-VFHVXXP4.js.map +1 -0
- package/dist/chunk-VQVUJYYY.js +244 -0
- package/dist/chunk-VQVUJYYY.js.map +1 -0
- package/dist/chunk-VZQG2JDV.js +9 -0
- package/dist/chunk-VZQG2JDV.js.map +1 -0
- package/dist/chunk-W7HQ5X3S.js +610 -0
- package/dist/chunk-W7HQ5X3S.js.map +1 -0
- package/dist/chunk-WMSQAFK5.js +65 -0
- package/dist/chunk-WMSQAFK5.js.map +1 -0
- package/dist/chunk-WMYTBJPB.js +364 -0
- package/dist/chunk-WMYTBJPB.js.map +1 -0
- package/dist/chunk-WNLFNCOH.js +7795 -0
- package/dist/chunk-WNLFNCOH.js.map +1 -0
- package/dist/chunk-WRX7CB2M.js +6448 -0
- package/dist/chunk-WRX7CB2M.js.map +1 -0
- package/dist/chunk-XGTTOO4R.js +84 -0
- package/dist/chunk-XGTTOO4R.js.map +1 -0
- package/dist/chunk-YSXRBUR4.js +682 -0
- package/dist/chunk-YSXRBUR4.js.map +1 -0
- package/dist/chunk-YTC2EG64.js +1759 -0
- package/dist/chunk-YTC2EG64.js.map +1 -0
- package/dist/compile-J3UGQSS3.js +161 -0
- package/dist/compile-J3UGQSS3.js.map +1 -0
- package/dist/config-5BPSZND3.js +438 -0
- package/dist/config-5BPSZND3.js.map +1 -0
- package/dist/doctor-BVFKLJVO.js +111 -0
- package/dist/doctor-BVFKLJVO.js.map +1 -0
- package/dist/environment-3RI5H32O.js +2745 -0
- package/dist/environment-3RI5H32O.js.map +1 -0
- package/dist/github-YFJQVH5K.js +114 -0
- package/dist/github-YFJQVH5K.js.map +1 -0
- package/dist/harness-ECGHPEKA.js +746 -0
- package/dist/harness-ECGHPEKA.js.map +1 -0
- package/dist/help-ELPNPPEM.js +2079 -0
- package/dist/help-ELPNPPEM.js.map +1 -0
- package/dist/help-UL5XLY3I.js +1892 -0
- package/dist/help-UL5XLY3I.js.map +1 -0
- package/dist/index.d.ts +164 -1
- package/dist/index.js +50 -59246
- package/dist/index.js.map +1 -1
- package/dist/init-UJQTDHW7.js +873 -0
- package/dist/init-UJQTDHW7.js.map +1 -0
- package/dist/lock-XUMJ63NZ.js +455 -0
- package/dist/lock-XUMJ63NZ.js.map +1 -0
- package/dist/marketplace-ZUMOLVXE.js +495 -0
- package/dist/marketplace-ZUMOLVXE.js.map +1 -0
- package/dist/mcp-RZA5O2ND.js +202 -0
- package/dist/mcp-RZA5O2ND.js.map +1 -0
- package/dist/migrate-CYQI2FH6.js +1043 -0
- package/dist/migrate-CYQI2FH6.js.map +1 -0
- package/dist/open-AWOAWLKO.js +32 -0
- package/dist/open-AWOAWLKO.js.map +1 -0
- package/dist/pack-2QD5ZUIO.js +99 -0
- package/dist/pack-2QD5ZUIO.js.map +1 -0
- package/dist/plugin-GQSSSFX4.js +64 -0
- package/dist/plugin-GQSSSFX4.js.map +1 -0
- package/dist/plugin-from-project-SIQUFYIO.js +16 -0
- package/dist/plugin-from-project-SIQUFYIO.js.map +1 -0
- package/dist/policy-CT4JRCJI.js +105 -0
- package/dist/policy-CT4JRCJI.js.map +1 -0
- package/dist/profile-4JQ6LECP.js +1886 -0
- package/dist/profile-4JQ6LECP.js.map +1 -0
- package/dist/project-JG7QWXRG.js +1392 -0
- package/dist/project-JG7QWXRG.js.map +1 -0
- package/dist/resource-QRMR6CSD.js +555 -0
- package/dist/resource-QRMR6CSD.js.map +1 -0
- package/dist/version-LZ5POOXY.js +17 -0
- package/dist/version-LZ5POOXY.js.map +1 -0
- package/package.json +21 -14
- package/schemas/ap-package.v1.json +36 -0
- package/schemas/fixtures/catalog-missing-schema.ap.json +13 -0
- package/schemas/fixtures/confidence.ap.json +13 -0
- package/schemas/fixtures/context7.ap.json +13 -0
- package/schemas/fixtures/minimal-with-schema.ap.json +13 -0
- package/schemas/fixtures/superpowers.ap.json +13 -0
- package/schemas/fixtures/third-party-skills.ap.json +13 -0
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
import {
|
|
2
|
+
canonicalApmRepoUrl
|
|
3
|
+
} from "./chunk-DEJLP7QJ.js";
|
|
4
|
+
import {
|
|
5
|
+
getPluginById,
|
|
6
|
+
getPluginResources,
|
|
7
|
+
hasParentTraversalSegment,
|
|
8
|
+
recoverOriginLocator,
|
|
9
|
+
resolutionKey,
|
|
10
|
+
resourceFingerprint
|
|
11
|
+
} from "./chunk-TKBMHZTS.js";
|
|
12
|
+
import {
|
|
13
|
+
PACKAGE_VERSION
|
|
14
|
+
} from "./chunk-KLR2DURP.js";
|
|
15
|
+
|
|
16
|
+
// src/services/lockfile.ts
|
|
17
|
+
import { createHash } from "crypto";
|
|
18
|
+
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
19
|
+
import { join } from "path";
|
|
20
|
+
import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
|
|
21
|
+
var APM_LOCKFILE_FILENAME = "apm.lock.yaml";
|
|
22
|
+
var LOCKFILE_VERSION = "1";
|
|
23
|
+
function isRecord(value) {
|
|
24
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
25
|
+
}
|
|
26
|
+
function sha256Envelope(value) {
|
|
27
|
+
const digest = createHash("sha256").update(value).digest("hex");
|
|
28
|
+
return `sha256:${digest}`;
|
|
29
|
+
}
|
|
30
|
+
function canonicalizeText(content) {
|
|
31
|
+
return content.replace(/\r\n/g, "\n");
|
|
32
|
+
}
|
|
33
|
+
function lockfilePath(projectRoot) {
|
|
34
|
+
return join(projectRoot, APM_LOCKFILE_FILENAME);
|
|
35
|
+
}
|
|
36
|
+
function resourceMapHash(resources) {
|
|
37
|
+
const entries = resources.map((resource) => `${resolutionKey(resource)}=${resourceFingerprint(resource)}`).sort();
|
|
38
|
+
return sha256Envelope(entries.join("\n"));
|
|
39
|
+
}
|
|
40
|
+
function pluginIntegrity(pluginId) {
|
|
41
|
+
const entries = getPluginResources(pluginId).map((resource) => `${resolutionKey(resource)}=${resourceFingerprint(resource)}`).sort();
|
|
42
|
+
return sha256Envelope(entries.join("\n"));
|
|
43
|
+
}
|
|
44
|
+
function lockSourceFromSelected(plugin) {
|
|
45
|
+
switch (plugin.source) {
|
|
46
|
+
case "local":
|
|
47
|
+
case "marketplace":
|
|
48
|
+
case "git":
|
|
49
|
+
case "catalog":
|
|
50
|
+
return plugin.source;
|
|
51
|
+
default: {
|
|
52
|
+
const unhandled = plugin.source;
|
|
53
|
+
return unhandled;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function gitFieldsForPlugin(pluginId) {
|
|
58
|
+
const plugin = getPluginById(pluginId);
|
|
59
|
+
if (!plugin) {
|
|
60
|
+
return {};
|
|
61
|
+
}
|
|
62
|
+
const locator = recoverOriginLocator(plugin);
|
|
63
|
+
const repo_url = locator?.kind === "git" ? canonicalApmRepoUrl(locator.url) : plugin.origin_locator || void 0;
|
|
64
|
+
const resolved_commit = plugin.origin_fingerprint_kind === "git_sha" && plugin.origin_fingerprint ? plugin.origin_fingerprint : void 0;
|
|
65
|
+
return {
|
|
66
|
+
...repo_url ? { repo_url } : {},
|
|
67
|
+
...resolved_commit ? { resolved_commit, resolved_ref: resolved_commit } : {}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function mergeGitLockFields(entry, extras) {
|
|
71
|
+
const extra = extras?.find((item) => item.name === entry.name);
|
|
72
|
+
if (!extra) {
|
|
73
|
+
return entry;
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
...entry,
|
|
77
|
+
source: "git",
|
|
78
|
+
repo_url: extra.repo_url,
|
|
79
|
+
resolved_commit: extra.resolved_commit,
|
|
80
|
+
resolved_ref: extra.resolved_ref,
|
|
81
|
+
constraint: extra.constraint,
|
|
82
|
+
resolved_tag: extra.resolved_tag,
|
|
83
|
+
virtual_path: extra.virtual_path,
|
|
84
|
+
...extra.declared_license ? { declared_license: extra.declared_license } : {}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function mcpServersFromResources(resources) {
|
|
88
|
+
return resources.filter((resource) => resource.type === "mcp_server").map((resource) => {
|
|
89
|
+
const metadata = resource.metadata;
|
|
90
|
+
return {
|
|
91
|
+
name: resource.name,
|
|
92
|
+
...metadata.transport ? { transport: metadata.transport } : {},
|
|
93
|
+
...metadata.command ? { command: metadata.command } : {},
|
|
94
|
+
...metadata.url ? { url: metadata.url } : {}
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function deployedFileHashes(files) {
|
|
99
|
+
const hashes = {};
|
|
100
|
+
for (const file of [...files].sort((left, right) => left.path.localeCompare(right.path))) {
|
|
101
|
+
hashes[file.path] = sha256Envelope(canonicalizeText(file.content));
|
|
102
|
+
}
|
|
103
|
+
return hashes;
|
|
104
|
+
}
|
|
105
|
+
function normalizeDigest(value) {
|
|
106
|
+
return value.replace(/^sha256:/i, "").toLowerCase();
|
|
107
|
+
}
|
|
108
|
+
var LockIntegrityError = class extends Error {
|
|
109
|
+
constructor(message) {
|
|
110
|
+
super(message);
|
|
111
|
+
this.name = "LockIntegrityError";
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
function hashFileOnDisk(rootPath, relativePath) {
|
|
115
|
+
const fullPath = join(rootPath, relativePath);
|
|
116
|
+
if (!existsSync(fullPath)) {
|
|
117
|
+
return void 0;
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
return sha256Envelope(canonicalizeText(readFileSync(fullPath, "utf8")));
|
|
121
|
+
} catch {
|
|
122
|
+
return void 0;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function diffDeployedFileHashes(expected, files, options = {}) {
|
|
126
|
+
const issues = [];
|
|
127
|
+
const planned = deployedFileHashes(files);
|
|
128
|
+
for (const relativePath of Object.keys(expected).sort()) {
|
|
129
|
+
if (hasParentTraversalSegment(relativePath) || relativePath.startsWith("/")) {
|
|
130
|
+
issues.push({ kind: "unsafe-path", path: relativePath });
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
for (const relativePath of Object.keys(expected).sort()) {
|
|
134
|
+
const expectedHash = expected[relativePath];
|
|
135
|
+
const plannedHash = planned[relativePath];
|
|
136
|
+
if (plannedHash !== void 0) {
|
|
137
|
+
if (expectedHash && normalizeDigest(expectedHash) !== normalizeDigest(plannedHash)) {
|
|
138
|
+
issues.push({
|
|
139
|
+
kind: "mismatch",
|
|
140
|
+
path: relativePath,
|
|
141
|
+
expected: normalizeDigest(expectedHash),
|
|
142
|
+
actual: normalizeDigest(plannedHash)
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (options.rootPath) {
|
|
148
|
+
const diskHash = hashFileOnDisk(options.rootPath, relativePath);
|
|
149
|
+
if (diskHash === void 0) {
|
|
150
|
+
issues.push({ kind: "missing", path: relativePath, expected: expectedHash });
|
|
151
|
+
}
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
issues.push({ kind: "missing", path: relativePath, expected: expectedHash });
|
|
155
|
+
}
|
|
156
|
+
for (const relativePath of Object.keys(planned).sort()) {
|
|
157
|
+
if (expected[relativePath] === void 0) {
|
|
158
|
+
issues.push({ kind: "extra", path: relativePath, actual: planned[relativePath] });
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return issues;
|
|
162
|
+
}
|
|
163
|
+
function verifyDeployedFileHashes(expected, files, options = {}) {
|
|
164
|
+
const issues = diffDeployedFileHashes(expected, files, options);
|
|
165
|
+
const first = issues[0];
|
|
166
|
+
if (!first) return;
|
|
167
|
+
switch (first.kind) {
|
|
168
|
+
case "unsafe-path":
|
|
169
|
+
throw new LockIntegrityError(
|
|
170
|
+
`Unsafe local_deployed_file_hashes path ${first.path}. Apply aborted closed.`
|
|
171
|
+
);
|
|
172
|
+
case "missing":
|
|
173
|
+
throw new LockIntegrityError(
|
|
174
|
+
`Deployed tree is missing ${first.path} listed in local_deployed_file_hashes`
|
|
175
|
+
);
|
|
176
|
+
case "mismatch":
|
|
177
|
+
throw new LockIntegrityError(
|
|
178
|
+
`Hash mismatch for ${first.path}: lockfile records ${first.expected}, file is ${first.actual}`
|
|
179
|
+
);
|
|
180
|
+
case "extra":
|
|
181
|
+
throw new LockIntegrityError(
|
|
182
|
+
`Deployed tree contains extra file ${first.path} that is not listed in local_deployed_file_hashes`
|
|
183
|
+
);
|
|
184
|
+
default: {
|
|
185
|
+
const unhandled = first.kind;
|
|
186
|
+
throw new LockIntegrityError(`Unknown lock integrity issue: ${String(unhandled)}`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
function lockfileFromResolution(result, extras = {}) {
|
|
191
|
+
const mcp_servers = mcpServersFromResources(result.resources);
|
|
192
|
+
const deployed = extras.deployedFiles ? deployedFileHashes(extras.deployedFiles) : void 0;
|
|
193
|
+
return {
|
|
194
|
+
root: result.root.name,
|
|
195
|
+
resolved_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
196
|
+
resource_map_hash: resourceMapHash(result.resources),
|
|
197
|
+
plugins: result.selected.filter((plugin) => plugin.depth > 0).map((plugin) => {
|
|
198
|
+
const integrity = pluginIntegrity(plugin.pluginId);
|
|
199
|
+
const declared = extras.declaredLicenses?.[plugin.name] ?? extras.gitLocks?.find((item) => item.name === plugin.name)?.declared_license;
|
|
200
|
+
return mergeGitLockFields(
|
|
201
|
+
{
|
|
202
|
+
name: plugin.name,
|
|
203
|
+
version: plugin.version,
|
|
204
|
+
source: lockSourceFromSelected(plugin),
|
|
205
|
+
integrity,
|
|
206
|
+
depth: plugin.depth,
|
|
207
|
+
path: plugin.path,
|
|
208
|
+
content_hash: integrity,
|
|
209
|
+
...gitFieldsForPlugin(plugin.pluginId),
|
|
210
|
+
...extras.execStatuses?.[plugin.name] ? { exec_status: extras.execStatuses[plugin.name] } : {},
|
|
211
|
+
...declared ? { declared_license: declared } : {}
|
|
212
|
+
},
|
|
213
|
+
extras.gitLocks
|
|
214
|
+
);
|
|
215
|
+
}),
|
|
216
|
+
...extras.environment ? { environment: extras.environment } : {},
|
|
217
|
+
...mcp_servers.length > 0 ? { mcp_servers } : {},
|
|
218
|
+
...deployed && Object.keys(deployed).length > 0 ? { deployed_file_hashes: deployed } : {}
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
function apmSourceForEntry(entry) {
|
|
222
|
+
if (entry.source === "local") return "local";
|
|
223
|
+
if (entry.source === "catalog") return "registry";
|
|
224
|
+
return void 0;
|
|
225
|
+
}
|
|
226
|
+
function serializeLockDependency(entry) {
|
|
227
|
+
return {
|
|
228
|
+
name: entry.name,
|
|
229
|
+
version: entry.version,
|
|
230
|
+
depth: entry.depth,
|
|
231
|
+
...apmSourceForEntry(entry) ? { source: apmSourceForEntry(entry) } : {},
|
|
232
|
+
...entry.repo_url ? { repo_url: entry.repo_url } : {},
|
|
233
|
+
...entry.resolved_commit ? { resolved_commit: entry.resolved_commit } : {},
|
|
234
|
+
...entry.resolved_ref ? { resolved_ref: entry.resolved_ref } : {},
|
|
235
|
+
...entry.constraint ? { constraint: entry.constraint } : {},
|
|
236
|
+
...entry.resolved_tag ? { resolved_tag: entry.resolved_tag } : {},
|
|
237
|
+
...entry.virtual_path ? { virtual_path: entry.virtual_path } : {},
|
|
238
|
+
...entry.content_hash ? { content_hash: entry.content_hash } : {},
|
|
239
|
+
...entry.exec_status ? { exec_status: entry.exec_status } : {},
|
|
240
|
+
...entry.declared_license ? { declared_license: entry.declared_license } : {}
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
function writeLockfile(projectRoot, lock) {
|
|
244
|
+
const path = lockfilePath(projectRoot);
|
|
245
|
+
const document = {
|
|
246
|
+
lockfile_version: LOCKFILE_VERSION,
|
|
247
|
+
generated_at: lock.resolved_at,
|
|
248
|
+
apm_version: PACKAGE_VERSION,
|
|
249
|
+
dependencies: [...lock.plugins].sort((left, right) => {
|
|
250
|
+
const byRepo = (left.repo_url ?? left.name).localeCompare(right.repo_url ?? right.name);
|
|
251
|
+
return byRepo;
|
|
252
|
+
}).map(serializeLockDependency),
|
|
253
|
+
...lock.mcp_servers && lock.mcp_servers.length > 0 ? { mcp_servers: lock.mcp_servers } : {},
|
|
254
|
+
...lock.deployed_file_hashes ? { local_deployed_file_hashes: lock.deployed_file_hashes } : {},
|
|
255
|
+
root: lock.root,
|
|
256
|
+
resource_map_hash: lock.resource_map_hash,
|
|
257
|
+
...lock.environment ? { environment: lock.environment } : {},
|
|
258
|
+
plugins: lock.plugins.map((entry) => ({
|
|
259
|
+
name: entry.name,
|
|
260
|
+
version: entry.version,
|
|
261
|
+
source: entry.source,
|
|
262
|
+
integrity: entry.integrity,
|
|
263
|
+
depth: entry.depth,
|
|
264
|
+
path: entry.path,
|
|
265
|
+
...entry.repo_url ? { repo_url: entry.repo_url } : {},
|
|
266
|
+
...entry.resolved_commit ? { resolved_commit: entry.resolved_commit } : {},
|
|
267
|
+
...entry.resolved_ref ? { resolved_ref: entry.resolved_ref } : {},
|
|
268
|
+
...entry.constraint ? { constraint: entry.constraint } : {},
|
|
269
|
+
...entry.resolved_tag ? { resolved_tag: entry.resolved_tag } : {},
|
|
270
|
+
...entry.virtual_path ? { virtual_path: entry.virtual_path } : {},
|
|
271
|
+
...entry.content_hash ? { content_hash: entry.content_hash } : {},
|
|
272
|
+
...entry.exec_status ? { exec_status: entry.exec_status } : {},
|
|
273
|
+
...entry.declared_license ? { declared_license: entry.declared_license } : {}
|
|
274
|
+
}))
|
|
275
|
+
};
|
|
276
|
+
writeFileSync(
|
|
277
|
+
path,
|
|
278
|
+
stringifyYaml(document, {
|
|
279
|
+
indent: 2,
|
|
280
|
+
lineWidth: 0,
|
|
281
|
+
defaultKeyType: "PLAIN"
|
|
282
|
+
}),
|
|
283
|
+
"utf8"
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
function parseLockSource(value) {
|
|
287
|
+
switch (value) {
|
|
288
|
+
case "local":
|
|
289
|
+
case "marketplace":
|
|
290
|
+
case "git":
|
|
291
|
+
case "catalog":
|
|
292
|
+
return value;
|
|
293
|
+
case "registry":
|
|
294
|
+
return "catalog";
|
|
295
|
+
default:
|
|
296
|
+
return "local";
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
function parseHtPluginEntry(entry) {
|
|
300
|
+
return {
|
|
301
|
+
name: String(entry.name ?? ""),
|
|
302
|
+
version: String(entry.version ?? ""),
|
|
303
|
+
source: parseLockSource(entry.source),
|
|
304
|
+
integrity: String(entry.integrity ?? entry.content_hash ?? ""),
|
|
305
|
+
depth: Number(entry.depth ?? 1),
|
|
306
|
+
path: Array.isArray(entry.path) ? entry.path.map(String) : [],
|
|
307
|
+
...typeof entry.repo_url === "string" ? { repo_url: entry.repo_url } : {},
|
|
308
|
+
...typeof entry.resolved_commit === "string" ? { resolved_commit: entry.resolved_commit } : {},
|
|
309
|
+
...typeof entry.resolved_ref === "string" ? { resolved_ref: entry.resolved_ref } : {},
|
|
310
|
+
...typeof entry.constraint === "string" ? { constraint: entry.constraint } : {},
|
|
311
|
+
...typeof entry.resolved_tag === "string" ? { resolved_tag: entry.resolved_tag } : {},
|
|
312
|
+
...typeof entry.virtual_path === "string" ? { virtual_path: entry.virtual_path } : {},
|
|
313
|
+
...typeof entry.content_hash === "string" ? { content_hash: entry.content_hash } : {},
|
|
314
|
+
...parseExecStatus(entry.exec_status) ? { exec_status: parseExecStatus(entry.exec_status) } : {},
|
|
315
|
+
...typeof entry.declared_license === "string" && entry.declared_license.trim() ? { declared_license: entry.declared_license.trim() } : {}
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
function parseExecStatus(value) {
|
|
319
|
+
switch (value) {
|
|
320
|
+
case "deployed":
|
|
321
|
+
case "gated_pending_approval":
|
|
322
|
+
case "denied":
|
|
323
|
+
case "absent":
|
|
324
|
+
return value;
|
|
325
|
+
default:
|
|
326
|
+
return void 0;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
function parseApmDependencyEntry(entry) {
|
|
330
|
+
return parseHtPluginEntry({
|
|
331
|
+
name: entry.name,
|
|
332
|
+
version: entry.version,
|
|
333
|
+
source: entry.source,
|
|
334
|
+
integrity: entry.integrity ?? entry.content_hash,
|
|
335
|
+
depth: entry.depth,
|
|
336
|
+
path: entry.path,
|
|
337
|
+
repo_url: entry.repo_url,
|
|
338
|
+
resolved_commit: entry.resolved_commit,
|
|
339
|
+
resolved_ref: entry.resolved_ref,
|
|
340
|
+
constraint: entry.constraint,
|
|
341
|
+
resolved_tag: entry.resolved_tag,
|
|
342
|
+
virtual_path: entry.virtual_path,
|
|
343
|
+
content_hash: entry.content_hash,
|
|
344
|
+
exec_status: entry.exec_status,
|
|
345
|
+
declared_license: entry.declared_license
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
function readLockfile(projectRoot) {
|
|
349
|
+
const path = lockfilePath(projectRoot);
|
|
350
|
+
if (!existsSync(path)) {
|
|
351
|
+
return void 0;
|
|
352
|
+
}
|
|
353
|
+
const parsed = parseYaml(readFileSync(path, "utf8"));
|
|
354
|
+
if (!isRecord(parsed)) {
|
|
355
|
+
throw new Error(`Invalid lockfile in ${path}: expected a YAML mapping`);
|
|
356
|
+
}
|
|
357
|
+
const version = String(parsed.lockfile_version ?? "");
|
|
358
|
+
if (version !== LOCKFILE_VERSION && version !== "2") {
|
|
359
|
+
throw new Error(
|
|
360
|
+
`Unsupported lockfile_version: ${version || "(missing)"}. Expected "${LOCKFILE_VERSION}". Delete ${APM_LOCKFILE_FILENAME} and re-run apply to regenerate it.`
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
const htPlugins = Array.isArray(parsed.plugins) ? parsed.plugins.filter(isRecord).map(parseHtPluginEntry) : [];
|
|
364
|
+
const apmDeps = Array.isArray(parsed.dependencies) ? parsed.dependencies.filter(isRecord).map(parseApmDependencyEntry) : [];
|
|
365
|
+
const plugins = htPlugins.length > 0 ? htPlugins : apmDeps;
|
|
366
|
+
const mcpRaw = parsed.mcp_servers;
|
|
367
|
+
const mcp_servers = Array.isArray(mcpRaw) ? mcpRaw.filter(isRecord).map((entry) => ({
|
|
368
|
+
name: String(entry.name ?? ""),
|
|
369
|
+
...typeof entry.transport === "string" ? { transport: entry.transport } : {},
|
|
370
|
+
...typeof entry.command === "string" ? { command: entry.command } : {},
|
|
371
|
+
...typeof entry.url === "string" ? { url: entry.url } : {}
|
|
372
|
+
})) : void 0;
|
|
373
|
+
const deployedRaw = parsed.local_deployed_file_hashes;
|
|
374
|
+
const deployed_file_hashes = isRecord(deployedRaw) ? Object.fromEntries(
|
|
375
|
+
Object.entries(deployedRaw).map(([filePath, hash]) => [filePath, String(hash)])
|
|
376
|
+
) : void 0;
|
|
377
|
+
return {
|
|
378
|
+
root: String(parsed.root ?? ""),
|
|
379
|
+
resolved_at: String(parsed.generated_at ?? parsed.resolved_at ?? ""),
|
|
380
|
+
resource_map_hash: String(parsed.resource_map_hash ?? ""),
|
|
381
|
+
plugins,
|
|
382
|
+
...typeof parsed.environment === "string" ? { environment: parsed.environment } : {},
|
|
383
|
+
...mcp_servers && mcp_servers.length > 0 ? { mcp_servers } : {},
|
|
384
|
+
...deployed_file_hashes ? { deployed_file_hashes } : {}
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
function lockedVersionsFrom(lock) {
|
|
388
|
+
return new Map(lock.plugins.map((entry) => [entry.name, entry.version]));
|
|
389
|
+
}
|
|
390
|
+
function lockIsUsable(lock, rootName) {
|
|
391
|
+
return lock.root === rootName && lock.plugins.every((entry) => entry.version !== "");
|
|
392
|
+
}
|
|
393
|
+
function compareLockToResolution(lock, result) {
|
|
394
|
+
const lockedByName = new Map(lock.plugins.map((entry) => [entry.name, entry.version]));
|
|
395
|
+
const resolvedByName = new Map(
|
|
396
|
+
result.selected.filter((p) => p.depth > 0).map((p) => [p.name, p.version])
|
|
397
|
+
);
|
|
398
|
+
const changes = [];
|
|
399
|
+
for (const [name, locked] of lockedByName) {
|
|
400
|
+
const resolved = resolvedByName.get(name);
|
|
401
|
+
if (resolved !== void 0 && resolved !== locked) {
|
|
402
|
+
changes.push({ name, locked, resolved });
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
const added = [...resolvedByName.keys()].filter((name) => !lockedByName.has(name));
|
|
406
|
+
const removed = [...lockedByName.keys()].filter((name) => !lockedByName.has(name));
|
|
407
|
+
const resourceDrift = lock.resource_map_hash !== resourceMapHash(result.resources);
|
|
408
|
+
return {
|
|
409
|
+
drift: changes.length > 0 || added.length > 0 || removed.length > 0 || resourceDrift,
|
|
410
|
+
root: lock.root,
|
|
411
|
+
changes,
|
|
412
|
+
added,
|
|
413
|
+
removed
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
export {
|
|
418
|
+
APM_LOCKFILE_FILENAME,
|
|
419
|
+
lockfilePath,
|
|
420
|
+
LockIntegrityError,
|
|
421
|
+
diffDeployedFileHashes,
|
|
422
|
+
verifyDeployedFileHashes,
|
|
423
|
+
lockfileFromResolution,
|
|
424
|
+
writeLockfile,
|
|
425
|
+
readLockfile,
|
|
426
|
+
lockedVersionsFrom,
|
|
427
|
+
lockIsUsable,
|
|
428
|
+
compareLockToResolution
|
|
429
|
+
};
|
|
430
|
+
//# sourceMappingURL=chunk-MZQRSERO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/services/lockfile.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { parse as parseYaml, stringify as stringifyYaml } from \"yaml\";\nimport { hasParentTraversalSegment } from \"../utils/path-containment.js\";\nimport { getPluginById, getPluginResources } from \"../models/plugin-model.js\";\nimport type { McpServerMetadata, Resource } from \"../types.js\";\nimport { PACKAGE_VERSION } from \"../version.js\";\nimport { recoverOriginLocator } from \"./plugin-origin-locator.js\";\nimport { canonicalApmRepoUrl } from \"./apm-git-resolve.js\";\nimport type { ExecStatus } from \"./executable-trust.js\";\nimport { resourceFingerprint, resolutionKey } from \"./resolve/resource-resolution.js\";\nimport type { ResolutionResult, SelectedPlugin } from \"./resolve/types.js\";\n\nexport const APM_LOCKFILE_FILENAME = \"apm.lock.yaml\";\nexport const LOCKFILE_VERSION = \"1\";\n\nexport type LockSource = \"local\" | \"marketplace\" | \"git\" | \"catalog\";\n\nexport interface LockEntry {\n name: string;\n version: string;\n source: LockSource;\n /** Hash over the plugin's attached resource fingerprints. */\n integrity: string;\n depth: number;\n /** Dependency path from the root that selected this version. */\n path: string[];\n repo_url?: string;\n resolved_commit?: string;\n resolved_ref?: string;\n constraint?: string;\n resolved_tag?: string;\n virtual_path?: string;\n content_hash?: string;\n exec_status?: ExecStatus;\n /** Manifest `license:` recorded at apply/install. Omitted when undeclared. */\n declared_license?: string;\n}\n\nexport interface LockMcpServer {\n name: string;\n transport?: string;\n command?: string;\n url?: string;\n}\n\nexport interface Lockfile {\n root: string;\n resolved_at: string;\n /** Hash over the resolved `type:name` → fingerprint map, for drift detection. */\n resource_map_hash: string;\n plugins: LockEntry[];\n environment?: string;\n mcp_servers?: LockMcpServer[];\n deployed_file_hashes?: Record<string, string>;\n}\n\nexport interface ApmGitLockFields {\n name: string;\n repo_url: string;\n resolved_commit: string;\n resolved_ref?: string;\n constraint?: string;\n resolved_tag?: string;\n virtual_path?: string;\n declared_license?: string;\n}\n\nexport interface LockfileFromResolutionExtras {\n environment?: string;\n deployedFiles?: Array<{ path: string; content: string }>;\n gitLocks?: ApmGitLockFields[];\n execStatuses?: Record<string, ExecStatus>;\n declaredLicenses?: Record<string, string>;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n\nexport function sha256Envelope(value: string): string {\n const digest = createHash(\"sha256\").update(value).digest(\"hex\");\n return `sha256:${digest}`;\n}\n\nfunction canonicalizeText(content: string): string {\n return content.replace(/\\r\\n/g, \"\\n\");\n}\n\nexport function lockfilePath(projectRoot: string): string {\n return join(projectRoot, APM_LOCKFILE_FILENAME);\n}\n\nexport function resourceMapHash(resources: Resource[]): string {\n const entries = resources\n .map((resource) => `${resolutionKey(resource)}=${resourceFingerprint(resource)}`)\n .sort();\n return sha256Envelope(entries.join(\"\\n\"));\n}\n\nexport function pluginIntegrity(pluginId: string): string {\n const entries = getPluginResources(pluginId)\n .map((resource) => `${resolutionKey(resource)}=${resourceFingerprint(resource)}`)\n .sort();\n return sha256Envelope(entries.join(\"\\n\"));\n}\n\nfunction lockSourceFromSelected(plugin: SelectedPlugin): LockSource {\n switch (plugin.source) {\n case \"local\":\n case \"marketplace\":\n case \"git\":\n case \"catalog\":\n return plugin.source;\n default: {\n const unhandled: never = plugin.source;\n return unhandled;\n }\n }\n}\n\nfunction gitFieldsForPlugin(pluginId: string): Pick<\n LockEntry,\n \"repo_url\" | \"resolved_commit\" | \"resolved_ref\"\n> {\n const plugin = getPluginById(pluginId);\n if (!plugin) {\n return {};\n }\n const locator = recoverOriginLocator(plugin);\n const repo_url = locator?.kind === \"git\"\n ? canonicalApmRepoUrl(locator.url)\n : plugin.origin_locator || undefined;\n const resolved_commit =\n plugin.origin_fingerprint_kind === \"git_sha\" && plugin.origin_fingerprint\n ? plugin.origin_fingerprint\n : undefined;\n return {\n ...(repo_url ? { repo_url } : {}),\n ...(resolved_commit ? { resolved_commit, resolved_ref: resolved_commit } : {}),\n };\n}\n\nfunction mergeGitLockFields(\n entry: LockEntry,\n extras: ApmGitLockFields[] | undefined,\n): LockEntry {\n const extra = extras?.find((item) => item.name === entry.name);\n if (!extra) {\n return entry;\n }\n return {\n ...entry,\n source: \"git\",\n repo_url: extra.repo_url,\n resolved_commit: extra.resolved_commit,\n resolved_ref: extra.resolved_ref,\n constraint: extra.constraint,\n resolved_tag: extra.resolved_tag,\n virtual_path: extra.virtual_path,\n ...(extra.declared_license ? { declared_license: extra.declared_license } : {}),\n };\n}\n\nfunction mcpServersFromResources(resources: Resource[]): LockMcpServer[] {\n return resources\n .filter((resource) => resource.type === \"mcp_server\")\n .map((resource) => {\n const metadata = resource.metadata as McpServerMetadata;\n return {\n name: resource.name,\n ...(metadata.transport ? { transport: metadata.transport } : {}),\n ...(metadata.command ? { command: metadata.command } : {}),\n ...(metadata.url ? { url: metadata.url } : {}),\n };\n });\n}\n\nfunction deployedFileHashes(\n files: Array<{ path: string; content: string }>,\n): Record<string, string> {\n const hashes: Record<string, string> = {};\n for (const file of [...files].sort((left, right) => left.path.localeCompare(right.path))) {\n hashes[file.path] = sha256Envelope(canonicalizeText(file.content));\n }\n return hashes;\n}\n\nfunction normalizeDigest(value: string): string {\n return value.replace(/^sha256:/i, \"\").toLowerCase();\n}\n\nexport class LockIntegrityError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"LockIntegrityError\";\n }\n}\n\nexport type DeployedHashIssueKind = \"missing\" | \"extra\" | \"mismatch\" | \"unsafe-path\";\n\nexport interface DeployedHashIssue {\n kind: DeployedHashIssueKind;\n path: string;\n expected?: string;\n actual?: string;\n}\n\nexport interface VerifyDeployedHashesOptions {\n /** When set, \"missing\" means the lock path is absent on disk, not absent from the new plan. */\n rootPath?: string;\n}\n\nfunction hashFileOnDisk(rootPath: string, relativePath: string): string | undefined {\n const fullPath = join(rootPath, relativePath);\n if (!existsSync(fullPath)) {\n return undefined;\n }\n try {\n return sha256Envelope(canonicalizeText(readFileSync(fullPath, \"utf8\")));\n } catch {\n return undefined;\n }\n}\n\nexport function diffDeployedFileHashes(\n expected: Record<string, string>,\n files: Array<{ path: string; content: string }>,\n options: VerifyDeployedHashesOptions = {},\n): DeployedHashIssue[] {\n const issues: DeployedHashIssue[] = [];\n const planned = deployedFileHashes(files);\n\n for (const relativePath of Object.keys(expected).sort()) {\n if (hasParentTraversalSegment(relativePath) || relativePath.startsWith(\"/\")) {\n issues.push({ kind: \"unsafe-path\", path: relativePath });\n }\n }\n\n for (const relativePath of Object.keys(expected).sort()) {\n const expectedHash = expected[relativePath];\n const plannedHash = planned[relativePath];\n if (plannedHash !== undefined) {\n if (expectedHash && normalizeDigest(expectedHash) !== normalizeDigest(plannedHash)) {\n issues.push({\n kind: \"mismatch\",\n path: relativePath,\n expected: normalizeDigest(expectedHash),\n actual: normalizeDigest(plannedHash),\n });\n }\n continue;\n }\n // Path is in the lock but not in the new plan. With rootPath, that is only\n // a lock failure when the file is also gone from disk (W1-1).\n if (options.rootPath) {\n const diskHash = hashFileOnDisk(options.rootPath, relativePath);\n if (diskHash === undefined) {\n issues.push({ kind: \"missing\", path: relativePath, expected: expectedHash });\n }\n continue;\n }\n issues.push({ kind: \"missing\", path: relativePath, expected: expectedHash });\n }\n\n for (const relativePath of Object.keys(planned).sort()) {\n if (expected[relativePath] === undefined) {\n issues.push({ kind: \"extra\", path: relativePath, actual: planned[relativePath] });\n }\n }\n\n return issues;\n}\n\nexport function verifyDeployedFileHashes(\n expected: Record<string, string>,\n files: Array<{ path: string; content: string }>,\n options: VerifyDeployedHashesOptions = {},\n): void {\n const issues = diffDeployedFileHashes(expected, files, options);\n const first = issues[0];\n if (!first) return;\n\n switch (first.kind) {\n case \"unsafe-path\":\n throw new LockIntegrityError(\n `Unsafe local_deployed_file_hashes path ${first.path}. Apply aborted closed.`,\n );\n case \"missing\":\n throw new LockIntegrityError(\n `Deployed tree is missing ${first.path} listed in local_deployed_file_hashes`,\n );\n case \"mismatch\":\n throw new LockIntegrityError(\n `Hash mismatch for ${first.path}: lockfile records ${first.expected}, file is ${first.actual}`,\n );\n case \"extra\":\n throw new LockIntegrityError(\n `Deployed tree contains extra file ${first.path} that is not listed in local_deployed_file_hashes`,\n );\n default: {\n const unhandled: never = first.kind;\n throw new LockIntegrityError(`Unknown lock integrity issue: ${String(unhandled)}`);\n }\n }\n}\n\nexport function lockfileFromResolution(\n result: ResolutionResult,\n extras: LockfileFromResolutionExtras = {},\n): Lockfile {\n const mcp_servers = mcpServersFromResources(result.resources);\n const deployed = extras.deployedFiles ? deployedFileHashes(extras.deployedFiles) : undefined;\n return {\n root: result.root.name,\n resolved_at: new Date().toISOString(),\n resource_map_hash: resourceMapHash(result.resources),\n plugins: result.selected\n .filter((plugin) => plugin.depth > 0)\n .map((plugin) => {\n const integrity = pluginIntegrity(plugin.pluginId);\n const declared =\n extras.declaredLicenses?.[plugin.name]\n ?? extras.gitLocks?.find((item) => item.name === plugin.name)?.declared_license;\n return mergeGitLockFields(\n {\n name: plugin.name,\n version: plugin.version,\n source: lockSourceFromSelected(plugin),\n integrity,\n depth: plugin.depth,\n path: plugin.path,\n content_hash: integrity,\n ...gitFieldsForPlugin(plugin.pluginId),\n ...(extras.execStatuses?.[plugin.name]\n ? { exec_status: extras.execStatuses[plugin.name] }\n : {}),\n ...(declared ? { declared_license: declared } : {}),\n },\n extras.gitLocks,\n );\n }),\n ...(extras.environment ? { environment: extras.environment } : {}),\n ...(mcp_servers.length > 0 ? { mcp_servers } : {}),\n ...(deployed && Object.keys(deployed).length > 0 ? { deployed_file_hashes: deployed } : {}),\n };\n}\n\nfunction apmSourceForEntry(entry: LockEntry): string | undefined {\n if (entry.source === \"local\") return \"local\";\n if (entry.source === \"catalog\") return \"registry\";\n return undefined;\n}\n\nfunction serializeLockDependency(entry: LockEntry): Record<string, unknown> {\n return {\n name: entry.name,\n version: entry.version,\n depth: entry.depth,\n ...(apmSourceForEntry(entry) ? { source: apmSourceForEntry(entry) } : {}),\n ...(entry.repo_url ? { repo_url: entry.repo_url } : {}),\n ...(entry.resolved_commit ? { resolved_commit: entry.resolved_commit } : {}),\n ...(entry.resolved_ref ? { resolved_ref: entry.resolved_ref } : {}),\n ...(entry.constraint ? { constraint: entry.constraint } : {}),\n ...(entry.resolved_tag ? { resolved_tag: entry.resolved_tag } : {}),\n ...(entry.virtual_path ? { virtual_path: entry.virtual_path } : {}),\n ...(entry.content_hash ? { content_hash: entry.content_hash } : {}),\n ...(entry.exec_status ? { exec_status: entry.exec_status } : {}),\n ...(entry.declared_license ? { declared_license: entry.declared_license } : {}),\n };\n}\n\nexport function writeLockfile(projectRoot: string, lock: Lockfile): void {\n const path = lockfilePath(projectRoot);\n const document: Record<string, unknown> = {\n lockfile_version: LOCKFILE_VERSION,\n generated_at: lock.resolved_at,\n apm_version: PACKAGE_VERSION,\n dependencies: [...lock.plugins]\n .sort((left, right) => {\n const byRepo = (left.repo_url ?? left.name).localeCompare(right.repo_url ?? right.name);\n return byRepo;\n })\n .map(serializeLockDependency),\n ...(lock.mcp_servers && lock.mcp_servers.length > 0\n ? { mcp_servers: lock.mcp_servers }\n : {}),\n ...(lock.deployed_file_hashes\n ? { local_deployed_file_hashes: lock.deployed_file_hashes }\n : {}),\n root: lock.root,\n resource_map_hash: lock.resource_map_hash,\n ...(lock.environment ? { environment: lock.environment } : {}),\n plugins: lock.plugins.map((entry) => ({\n name: entry.name,\n version: entry.version,\n source: entry.source,\n integrity: entry.integrity,\n depth: entry.depth,\n path: entry.path,\n ...(entry.repo_url ? { repo_url: entry.repo_url } : {}),\n ...(entry.resolved_commit ? { resolved_commit: entry.resolved_commit } : {}),\n ...(entry.resolved_ref ? { resolved_ref: entry.resolved_ref } : {}),\n ...(entry.constraint ? { constraint: entry.constraint } : {}),\n ...(entry.resolved_tag ? { resolved_tag: entry.resolved_tag } : {}),\n ...(entry.virtual_path ? { virtual_path: entry.virtual_path } : {}),\n ...(entry.content_hash ? { content_hash: entry.content_hash } : {}),\n ...(entry.exec_status ? { exec_status: entry.exec_status } : {}),\n ...(entry.declared_license ? { declared_license: entry.declared_license } : {}),\n })),\n };\n writeFileSync(\n path,\n stringifyYaml(document, {\n indent: 2,\n lineWidth: 0,\n defaultKeyType: \"PLAIN\",\n }),\n \"utf8\",\n );\n}\n\nfunction parseLockSource(value: unknown): LockSource {\n switch (value) {\n case \"local\":\n case \"marketplace\":\n case \"git\":\n case \"catalog\":\n return value;\n case \"registry\":\n return \"catalog\";\n default:\n return \"local\";\n }\n}\n\nfunction parseHtPluginEntry(entry: Record<string, unknown>): LockEntry {\n return {\n name: String(entry.name ?? \"\"),\n version: String(entry.version ?? \"\"),\n source: parseLockSource(entry.source),\n integrity: String(entry.integrity ?? entry.content_hash ?? \"\"),\n depth: Number(entry.depth ?? 1),\n path: Array.isArray(entry.path) ? entry.path.map(String) : [],\n ...(typeof entry.repo_url === \"string\" ? { repo_url: entry.repo_url } : {}),\n ...(typeof entry.resolved_commit === \"string\"\n ? { resolved_commit: entry.resolved_commit }\n : {}),\n ...(typeof entry.resolved_ref === \"string\" ? { resolved_ref: entry.resolved_ref } : {}),\n ...(typeof entry.constraint === \"string\" ? { constraint: entry.constraint } : {}),\n ...(typeof entry.resolved_tag === \"string\" ? { resolved_tag: entry.resolved_tag } : {}),\n ...(typeof entry.virtual_path === \"string\" ? { virtual_path: entry.virtual_path } : {}),\n ...(typeof entry.content_hash === \"string\" ? { content_hash: entry.content_hash } : {}),\n ...(parseExecStatus(entry.exec_status) ? { exec_status: parseExecStatus(entry.exec_status) } : {}),\n ...(typeof entry.declared_license === \"string\" && entry.declared_license.trim()\n ? { declared_license: entry.declared_license.trim() }\n : {}),\n };\n}\n\nfunction parseExecStatus(value: unknown): ExecStatus | undefined {\n switch (value) {\n case \"deployed\":\n case \"gated_pending_approval\":\n case \"denied\":\n case \"absent\":\n return value;\n default:\n return undefined;\n }\n}\n\nfunction parseApmDependencyEntry(entry: Record<string, unknown>): LockEntry {\n return parseHtPluginEntry({\n name: entry.name,\n version: entry.version,\n source: entry.source,\n integrity: entry.integrity ?? entry.content_hash,\n depth: entry.depth,\n path: entry.path,\n repo_url: entry.repo_url,\n resolved_commit: entry.resolved_commit,\n resolved_ref: entry.resolved_ref,\n constraint: entry.constraint,\n resolved_tag: entry.resolved_tag,\n virtual_path: entry.virtual_path,\n content_hash: entry.content_hash,\n exec_status: entry.exec_status,\n declared_license: entry.declared_license,\n });\n}\n\nexport function readLockfile(projectRoot: string): Lockfile | undefined {\n const path = lockfilePath(projectRoot);\n if (!existsSync(path)) {\n return undefined;\n }\n const parsed = parseYaml(readFileSync(path, \"utf8\"));\n if (!isRecord(parsed)) {\n throw new Error(`Invalid lockfile in ${path}: expected a YAML mapping`);\n }\n const version = String(parsed.lockfile_version ?? \"\");\n if (version !== LOCKFILE_VERSION && version !== \"2\") {\n throw new Error(\n `Unsupported lockfile_version: ${version || \"(missing)\"}. Expected \"${LOCKFILE_VERSION}\". ` +\n `Delete ${APM_LOCKFILE_FILENAME} and re-run apply to regenerate it.`,\n );\n }\n\n const htPlugins = Array.isArray(parsed.plugins)\n ? parsed.plugins.filter(isRecord).map(parseHtPluginEntry)\n : [];\n const apmDeps = Array.isArray(parsed.dependencies)\n ? parsed.dependencies.filter(isRecord).map(parseApmDependencyEntry)\n : [];\n const plugins = htPlugins.length > 0 ? htPlugins : apmDeps;\n\n const mcpRaw = parsed.mcp_servers;\n const mcp_servers = Array.isArray(mcpRaw)\n ? mcpRaw.filter(isRecord).map((entry) => ({\n name: String(entry.name ?? \"\"),\n ...(typeof entry.transport === \"string\" ? { transport: entry.transport } : {}),\n ...(typeof entry.command === \"string\" ? { command: entry.command } : {}),\n ...(typeof entry.url === \"string\" ? { url: entry.url } : {}),\n }))\n : undefined;\n\n const deployedRaw = parsed.local_deployed_file_hashes;\n const deployed_file_hashes = isRecord(deployedRaw)\n ? Object.fromEntries(\n Object.entries(deployedRaw).map(([filePath, hash]) => [filePath, String(hash)]),\n )\n : undefined;\n\n return {\n root: String(parsed.root ?? \"\"),\n resolved_at: String(parsed.generated_at ?? parsed.resolved_at ?? \"\"),\n resource_map_hash: String(parsed.resource_map_hash ?? \"\"),\n plugins,\n ...(typeof parsed.environment === \"string\" ? { environment: parsed.environment } : {}),\n ...(mcp_servers && mcp_servers.length > 0 ? { mcp_servers } : {}),\n ...(deployed_file_hashes ? { deployed_file_hashes } : {}),\n };\n}\n\nexport function lockedVersionsFrom(lock: Lockfile): Map<string, string> {\n return new Map(lock.plugins.map((entry) => [entry.name, entry.version]));\n}\n\nexport function lockfileMatchesResolution(\n lock: Lockfile,\n result: ResolutionResult,\n): boolean {\n if (lock.root !== result.root.name) return false;\n if (lock.resource_map_hash !== resourceMapHash(result.resources)) return false;\n const resolved = new Map(\n result.selected.filter((p) => p.depth > 0).map((p) => [p.name, p.version]),\n );\n if (resolved.size !== lock.plugins.length) return false;\n return lock.plugins.every((entry) => resolved.get(entry.name) === entry.version);\n}\n\n/**\n * True when every locked plugin is still available at the locked version.\n * A stale lock falls back to a full re-resolution rather than failing.\n */\nexport function lockIsUsable(lock: Lockfile, rootName: string): boolean {\n return lock.root === rootName && lock.plugins.every((entry) => entry.version !== \"\");\n}\n\nexport interface LockDrift {\n drift: boolean;\n root: string;\n changes: Array<{ name: string; locked: string; resolved: string }>;\n added: string[];\n removed: string[];\n}\n\nexport function compareLockToResolution(\n lock: Lockfile,\n result: ResolutionResult,\n): LockDrift {\n const lockedByName = new Map(lock.plugins.map((entry) => [entry.name, entry.version]));\n const resolvedByName = new Map(\n result.selected.filter((p) => p.depth > 0).map((p) => [p.name, p.version]),\n );\n\n const changes: LockDrift[\"changes\"] = [];\n for (const [name, locked] of lockedByName) {\n const resolved = resolvedByName.get(name);\n if (resolved !== undefined && resolved !== locked) {\n changes.push({ name, locked, resolved });\n }\n }\n const added = [...resolvedByName.keys()].filter((name) => !lockedByName.has(name));\n const removed = [...lockedByName.keys()].filter((name) => !lockedByName.has(name));\n const resourceDrift = lock.resource_map_hash !== resourceMapHash(result.resources);\n\n return {\n drift: changes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