agent-plugin-lifecycle 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +94 -2
- package/bin/cli.js +2 -0
- package/config/config.example.json +22 -0
- package/dist/cjs/apm.d.cts +19 -0
- package/dist/cjs/apm.d.ts +19 -0
- package/dist/cjs/apm.js +313 -0
- package/dist/cjs/apm.js.map +1 -0
- package/dist/cjs/cli.d.cts +1 -0
- package/dist/cjs/cli.d.ts +1 -0
- package/dist/cjs/cli.js +366 -0
- package/dist/cjs/cli.js.map +1 -0
- package/dist/cjs/config.d.cts +16 -0
- package/dist/cjs/config.d.ts +16 -0
- package/dist/cjs/config.js +251 -0
- package/dist/cjs/config.js.map +1 -0
- package/dist/cjs/index.d.cts +6 -0
- package/dist/cjs/index.d.ts +6 -0
- package/dist/cjs/index.js +34 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/runner.d.cts +19 -0
- package/dist/cjs/runner.d.ts +19 -0
- package/dist/cjs/runner.js +1157 -0
- package/dist/cjs/runner.js.map +1 -0
- package/dist/esm/apm.d.ts +19 -0
- package/dist/esm/apm.js +121 -0
- package/dist/esm/apm.js.map +1 -0
- package/dist/esm/cli.d.ts +1 -0
- package/dist/esm/cli.js +70 -0
- package/dist/esm/cli.js.map +1 -0
- package/dist/esm/config.d.ts +16 -0
- package/dist/esm/config.js +74 -0
- package/dist/esm/config.js.map +1 -0
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/runner.d.ts +19 -0
- package/dist/esm/runner.js +248 -0
- package/dist/esm/runner.js.map +1 -0
- package/package.json +62 -4
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { mkdir, readFile, realpath, rename, stat, unlink, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { homedir } from 'node:os';
|
|
5
|
+
import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
6
|
+
import spawn from 'cross-spawn-cb';
|
|
7
|
+
import lockfile from 'proper-lockfile';
|
|
8
|
+
import { loadLock, localEventName, matchesSource, samePath, sourceParts } from './apm.js';
|
|
9
|
+
import { loadConfig, recordId } from './config.js';
|
|
10
|
+
function inside(root, child) {
|
|
11
|
+
const subpath = relative(root, child);
|
|
12
|
+
return subpath === '' || subpath !== '..' && !subpath.startsWith(`..${sep}`) && !isAbsolute(subpath);
|
|
13
|
+
}
|
|
14
|
+
async function existingWithin(root, path, label) {
|
|
15
|
+
const rootReal = await realpath(root);
|
|
16
|
+
const candidate = resolve(rootReal, path);
|
|
17
|
+
if (!inside(rootReal, candidate)) throw new Error(`${label} escapes ${root}`);
|
|
18
|
+
const candidateReal = await realpath(candidate);
|
|
19
|
+
if (!inside(rootReal, candidateReal)) throw new Error(`${label} resolves outside ${root}`);
|
|
20
|
+
return candidateReal;
|
|
21
|
+
}
|
|
22
|
+
function pluginRoot(plugin, apmHome) {
|
|
23
|
+
return join(apmHome, 'apm_modules', plugin.repo, plugin.path);
|
|
24
|
+
}
|
|
25
|
+
async function destinations(plugin, policy, home, apmHome) {
|
|
26
|
+
const output = new Set();
|
|
27
|
+
const root = pluginRoot(plugin, apmHome);
|
|
28
|
+
if (!policy.skill) {
|
|
29
|
+
output.add(await existingWithin(join(apmHome, 'apm_modules'), join(plugin.repo, plugin.path), 'kept plugin'));
|
|
30
|
+
if (plugin.nativePluginRoot) {
|
|
31
|
+
const nativeBase = join(home, '.agents', 'plugins');
|
|
32
|
+
if (plugin.nativePluginRoot.startsWith('.agents/plugins/')) output.add(await existingWithin(nativeBase, plugin.nativePluginRoot.slice('.agents/plugins/'.length), 'native plugin'));
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
var _plugin_nativePluginRoot;
|
|
36
|
+
try {
|
|
37
|
+
output.add(await existingWithin(root, `skills/${policy.skill}`, `kept skill ${policy.skill}`));
|
|
38
|
+
} catch (error) {
|
|
39
|
+
if (!(error && typeof error === 'object' && 'code' in error && error.code === 'ENOENT')) throw error;
|
|
40
|
+
}
|
|
41
|
+
if ((_plugin_nativePluginRoot = plugin.nativePluginRoot) === null || _plugin_nativePluginRoot === void 0 ? void 0 : _plugin_nativePluginRoot.startsWith('.agents/plugins/')) {
|
|
42
|
+
const nativeRoot = plugin.nativePluginRoot.slice('.agents/plugins/'.length);
|
|
43
|
+
try {
|
|
44
|
+
output.add(await existingWithin(join(home, '.agents', 'plugins'), `${nativeRoot}/skills/${policy.skill}`, `native skill ${policy.skill}`));
|
|
45
|
+
} catch (error) {
|
|
46
|
+
if (!(error && typeof error === 'object' && 'code' in error && error.code === 'ENOENT')) throw error;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
for (const file of plugin.deployedFiles){
|
|
50
|
+
const parts = file.split('/');
|
|
51
|
+
const index = parts.lastIndexOf('skills');
|
|
52
|
+
if (index < 0 || parts[index + 1] !== policy.skill) continue;
|
|
53
|
+
const deployment = parts.slice(0, index + 2).join('/');
|
|
54
|
+
const prefix = [
|
|
55
|
+
'.agents/skills/',
|
|
56
|
+
'.hermes/skills/',
|
|
57
|
+
'.claude/skills/'
|
|
58
|
+
].find((candidate)=>deployment.startsWith(candidate));
|
|
59
|
+
if (prefix) output.add(await existingWithin(home, deployment, `skill ${policy.skill}`));
|
|
60
|
+
}
|
|
61
|
+
if (output.size === 0) throw new Error(`no deployed copy found for skill ${policy.skill}`);
|
|
62
|
+
}
|
|
63
|
+
return [
|
|
64
|
+
...output
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
async function readState(path) {
|
|
68
|
+
if (!existsSync(path)) return {
|
|
69
|
+
version: 1,
|
|
70
|
+
receipts: {}
|
|
71
|
+
};
|
|
72
|
+
const value = JSON.parse(await readFile(path, 'utf8'));
|
|
73
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) throw new Error('state must be an object');
|
|
74
|
+
const item = value;
|
|
75
|
+
if (item.version !== 1 || !item.receipts || typeof item.receipts !== 'object' || Array.isArray(item.receipts)) throw new Error('unsupported state format');
|
|
76
|
+
if (Object.values(item.receipts).some((receipt)=>typeof receipt !== 'string')) throw new Error('invalid state receipt');
|
|
77
|
+
return item;
|
|
78
|
+
}
|
|
79
|
+
async function saveState(path, state) {
|
|
80
|
+
const temp = join(dirname(path), `.state-${process.pid}-${Date.now()}.tmp`);
|
|
81
|
+
try {
|
|
82
|
+
await writeFile(temp, `${JSON.stringify(state, null, 2)}\n`, {
|
|
83
|
+
mode: 0o600,
|
|
84
|
+
flag: 'wx'
|
|
85
|
+
});
|
|
86
|
+
await rename(temp, path);
|
|
87
|
+
} catch (error) {
|
|
88
|
+
try {
|
|
89
|
+
await unlink(temp);
|
|
90
|
+
} catch {
|
|
91
|
+
/* preserve original error */ }
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function receiptKey(policy, destination) {
|
|
96
|
+
return JSON.stringify([
|
|
97
|
+
recordId(policy),
|
|
98
|
+
destination
|
|
99
|
+
]);
|
|
100
|
+
}
|
|
101
|
+
function digest(policy, command) {
|
|
102
|
+
return createHash('sha256').update(JSON.stringify([
|
|
103
|
+
recordId(policy),
|
|
104
|
+
command
|
|
105
|
+
])).digest('hex');
|
|
106
|
+
}
|
|
107
|
+
// The platform shell runs the configured string as written, as with npm and Node's `shell` option.
|
|
108
|
+
async function execute(command, cwd, environment) {
|
|
109
|
+
await spawn(command, [], {
|
|
110
|
+
cwd,
|
|
111
|
+
env: environment,
|
|
112
|
+
stdio: [
|
|
113
|
+
'ignore',
|
|
114
|
+
'inherit',
|
|
115
|
+
'inherit'
|
|
116
|
+
],
|
|
117
|
+
shell: true
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
function lockLoadError(error) {
|
|
121
|
+
return !!error && typeof error === 'object' && 'code' in error && error.code === 'ENOENT';
|
|
122
|
+
}
|
|
123
|
+
export async function runLifecycle(mode, options = {}) {
|
|
124
|
+
var _options_home, _options_apmHome, _options_configPath, _options_environment, _options_output;
|
|
125
|
+
const home = resolve((_options_home = options.home) !== null && _options_home !== void 0 ? _options_home : homedir());
|
|
126
|
+
const apmHome = resolve((_options_apmHome = options.apmHome) !== null && _options_apmHome !== void 0 ? _options_apmHome : join(home, '.apm'));
|
|
127
|
+
const configPath = (_options_configPath = options.configPath) !== null && _options_configPath !== void 0 ? _options_configPath : join(home, '.config', 'agent-plugin-lifecycle', 'config.json');
|
|
128
|
+
const environment = (_options_environment = options.environment) !== null && _options_environment !== void 0 ? _options_environment : process.env;
|
|
129
|
+
const output = (_options_output = options.output) !== null && _options_output !== void 0 ? _options_output : console.log;
|
|
130
|
+
const config = await loadConfig(configPath);
|
|
131
|
+
let locked;
|
|
132
|
+
try {
|
|
133
|
+
locked = await loadLock(join(apmHome, 'apm.lock.yaml'));
|
|
134
|
+
} catch (error) {
|
|
135
|
+
var _options_event;
|
|
136
|
+
if (mode === 'run' && ((_options_event = options.event) === null || _options_event === void 0 ? void 0 : _options_event.event) === 'post-uninstall' && lockLoadError(error)) {
|
|
137
|
+
const apmDirectory = await stat(apmHome);
|
|
138
|
+
if (!apmDirectory.isDirectory()) throw error;
|
|
139
|
+
locked = [];
|
|
140
|
+
} else throw error;
|
|
141
|
+
}
|
|
142
|
+
const statePath = join(dirname(configPath), 'state.json');
|
|
143
|
+
if (mode === 'run') await mkdir(dirname(statePath), {
|
|
144
|
+
recursive: true,
|
|
145
|
+
mode: 0o700
|
|
146
|
+
});
|
|
147
|
+
const release = mode === 'run' ? await lockfile.lock(dirname(statePath), {
|
|
148
|
+
realpath: false
|
|
149
|
+
}) : undefined;
|
|
150
|
+
try {
|
|
151
|
+
var _ref;
|
|
152
|
+
var _options_event1, _options_event2;
|
|
153
|
+
const state = await readState(statePath);
|
|
154
|
+
let failed = 0;
|
|
155
|
+
if (mode === 'run' && ((_options_event1 = options.event) === null || _options_event1 === void 0 ? void 0 : _options_event1.event) === 'post-uninstall') {
|
|
156
|
+
const eventNames = new Set(options.event.packages.map(({ name })=>name));
|
|
157
|
+
for (const policy of config.plugins){
|
|
158
|
+
var _ref1, _ref2;
|
|
159
|
+
const id = recordId(policy);
|
|
160
|
+
const receiptKeys = Object.keys(state.receipts).filter((key)=>{
|
|
161
|
+
try {
|
|
162
|
+
return JSON.parse(key)[0] === id;
|
|
163
|
+
} catch {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
if (!receiptKeys.length) continue;
|
|
168
|
+
const sourceCandidate = policy.source.startsWith('.') || isAbsolute(policy.source) ? locked.find((plugin)=>plugin.localPath !== undefined && samePath(policy.source, plugin.localPath)) : locked.find((plugin)=>{
|
|
169
|
+
var _policy_path;
|
|
170
|
+
return matchesSource(policy.source, plugin) && (plugin.path === ((_policy_path = policy.path) !== null && _policy_path !== void 0 ? _policy_path : '.') || plugin.localPath !== undefined);
|
|
171
|
+
});
|
|
172
|
+
const sourcePartsValue = sourceParts(policy.source);
|
|
173
|
+
const removedNameMatch = eventNames.has((_ref1 = sourceCandidate === null || sourceCandidate === void 0 ? void 0 : sourceCandidate.repo) !== null && _ref1 !== void 0 ? _ref1 : '') || eventNames.has(sourceCandidate ? `${sourceCandidate.host}/${sourceCandidate.repo}` : '') || eventNames.has((_ref2 = sourcePartsValue === null || sourcePartsValue === void 0 ? void 0 : sourcePartsValue.repo) !== null && _ref2 !== void 0 ? _ref2 : '') || eventNames.has(sourcePartsValue ? `${sourcePartsValue.host}/${sourcePartsValue.repo}` : '') || // APM names a removed subfolder plugin `owner/repo/<folder>` (install and update events name it `owner/repo`); exact match only, so removing one folder never matches another plugin of the repository
|
|
174
|
+
!!sourcePartsValue && !!policy.path && policy.path !== '.' && (eventNames.has(`${sourcePartsValue.repo}/${policy.path}`) || eventNames.has(`${sourcePartsValue.host}/${sourcePartsValue.repo}/${policy.path}`)) || eventNames.has(localEventName(policy.source)) || eventNames.has(policy.source);
|
|
175
|
+
const anyStillInstalled = locked.some((plugin)=>{
|
|
176
|
+
var _policy_path;
|
|
177
|
+
return matchesSource(policy.source, plugin) && plugin.path === ((_policy_path = policy.path) !== null && _policy_path !== void 0 ? _policy_path : '.');
|
|
178
|
+
});
|
|
179
|
+
if (anyStillInstalled || !removedNameMatch) continue;
|
|
180
|
+
const command = policy['post-uninstall'];
|
|
181
|
+
if (!command) {
|
|
182
|
+
for (const key of receiptKeys)delete state.receipts[key];
|
|
183
|
+
await saveState(statePath, state);
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
try {
|
|
187
|
+
await execute(command, home, environment);
|
|
188
|
+
for (const key of receiptKeys)delete state.receipts[key];
|
|
189
|
+
await saveState(statePath, state);
|
|
190
|
+
output(`cleaned ${id}`);
|
|
191
|
+
} catch (error) {
|
|
192
|
+
output(`failed cleanup ${id}: ${error instanceof Error ? error.message : String(error)}`);
|
|
193
|
+
failed++;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return failed ? 1 : 0;
|
|
197
|
+
}
|
|
198
|
+
if (mode === 'run' && !options.event) throw new Error('run requires an APM event');
|
|
199
|
+
const event = (_ref = (_options_event2 = options.event) === null || _options_event2 === void 0 ? void 0 : _options_event2.event) !== null && _ref !== void 0 ? _ref : 'post-install';
|
|
200
|
+
for (const policy of config.plugins){
|
|
201
|
+
var _policy_postupdate;
|
|
202
|
+
const command = event === 'post-update' ? (_policy_postupdate = policy['post-update']) !== null && _policy_postupdate !== void 0 ? _policy_postupdate : policy['post-install'] : policy['post-install'];
|
|
203
|
+
if (!command) continue;
|
|
204
|
+
const matches = locked.filter((plugin)=>{
|
|
205
|
+
var _policy_path;
|
|
206
|
+
return matchesSource(policy.source, plugin) && plugin.path === ((_policy_path = policy.path) !== null && _policy_path !== void 0 ? _policy_path : '.');
|
|
207
|
+
});
|
|
208
|
+
if (matches.length > 1) {
|
|
209
|
+
output(`failed ambiguous source/path record ${recordId(policy)}`);
|
|
210
|
+
failed++;
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
if (!matches.length) {
|
|
214
|
+
output(`skipped source not installed ${recordId(policy)}`);
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
const plugin = matches[0];
|
|
218
|
+
try {
|
|
219
|
+
const found = await destinations(plugin, policy, home, apmHome);
|
|
220
|
+
for (const destination of found){
|
|
221
|
+
const key = receiptKey(policy, destination);
|
|
222
|
+
if (mode === 'check') {
|
|
223
|
+
const validDigests = [
|
|
224
|
+
policy['post-install'],
|
|
225
|
+
policy['post-update']
|
|
226
|
+
].filter((item)=>!!item).map((item)=>digest(policy, item));
|
|
227
|
+
const ready = validDigests.includes(state.receipts[key]);
|
|
228
|
+
output(`${ready ? 'ok' : 'missing'} ${recordId(policy)} ${destination}`);
|
|
229
|
+
if (!ready) failed++;
|
|
230
|
+
} else {
|
|
231
|
+
delete state.receipts[key];
|
|
232
|
+
await saveState(statePath, state);
|
|
233
|
+
await execute(command, destination, environment);
|
|
234
|
+
state.receipts[key] = digest(policy, command);
|
|
235
|
+
await saveState(statePath, state);
|
|
236
|
+
output(`ran ${recordId(policy)} ${destination}`);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
} catch (error) {
|
|
240
|
+
output(`failed ${recordId(policy)}: ${error instanceof Error ? error.message : String(error)}`);
|
|
241
|
+
failed++;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return failed ? 1 : 0;
|
|
245
|
+
} finally{
|
|
246
|
+
await (release === null || release === void 0 ? void 0 : release());
|
|
247
|
+
}
|
|
248
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/ai/agent-plugin-lifecycle/src/runner.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport { existsSync } from 'node:fs';\nimport { mkdir, readFile, realpath, rename, stat, unlink, writeFile } from 'node:fs/promises';\nimport { homedir } from 'node:os';\nimport { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';\nimport spawn from 'cross-spawn-cb';\nimport lockfile from 'proper-lockfile';\nimport { type LockedPlugin, loadLock, localEventName, matchesSource, samePath, sourceParts } from './apm.js';\nimport { loadConfig, type PluginPolicy, recordId } from './config.js';\n\nexport type Mode = 'run' | 'check';\nexport interface LifecycleEvent {\n schema_version: 1;\n event: 'post-install' | 'post-update' | 'post-uninstall';\n scope: 'user';\n packages: { name: string; reference: string | null }[];\n}\ninterface State {\n version: 1;\n receipts: Record<string, string>;\n}\nexport interface RunOptions {\n home?: string;\n apmHome?: string;\n configPath?: string;\n environment?: NodeJS.ProcessEnv;\n output?: (line: string) => void;\n event?: LifecycleEvent;\n}\nfunction inside(root: string, child: string): boolean {\n const subpath = relative(root, child);\n return subpath === '' || (subpath !== '..' && !subpath.startsWith(`..${sep}`) && !isAbsolute(subpath));\n}\nasync function existingWithin(root: string, path: string, label: string): Promise<string> {\n const rootReal = await realpath(root);\n const candidate = resolve(rootReal, path);\n if (!inside(rootReal, candidate)) throw new Error(`${label} escapes ${root}`);\n const candidateReal = await realpath(candidate);\n if (!inside(rootReal, candidateReal)) throw new Error(`${label} resolves outside ${root}`);\n return candidateReal;\n}\nfunction pluginRoot(plugin: LockedPlugin, apmHome: string): string {\n return join(apmHome, 'apm_modules', plugin.repo, plugin.path);\n}\nasync function destinations(plugin: LockedPlugin, policy: PluginPolicy, home: string, apmHome: string): Promise<string[]> {\n const output = new Set<string>();\n const root = pluginRoot(plugin, apmHome);\n if (!policy.skill) {\n output.add(await existingWithin(join(apmHome, 'apm_modules'), join(plugin.repo, plugin.path), 'kept plugin'));\n if (plugin.nativePluginRoot) {\n const nativeBase = join(home, '.agents', 'plugins');\n if (plugin.nativePluginRoot.startsWith('.agents/plugins/')) output.add(await existingWithin(nativeBase, plugin.nativePluginRoot.slice('.agents/plugins/'.length), 'native plugin'));\n }\n } else {\n try {\n output.add(await existingWithin(root, `skills/${policy.skill}`, `kept skill ${policy.skill}`));\n } catch (error) {\n if (!(error && typeof error === 'object' && 'code' in error && error.code === 'ENOENT')) throw error;\n }\n if (plugin.nativePluginRoot?.startsWith('.agents/plugins/')) {\n const nativeRoot = plugin.nativePluginRoot.slice('.agents/plugins/'.length);\n try {\n output.add(await existingWithin(join(home, '.agents', 'plugins'), `${nativeRoot}/skills/${policy.skill}`, `native skill ${policy.skill}`));\n } catch (error) {\n if (!(error && typeof error === 'object' && 'code' in error && error.code === 'ENOENT')) throw error;\n }\n }\n for (const file of plugin.deployedFiles) {\n const parts = file.split('/');\n const index = parts.lastIndexOf('skills');\n if (index < 0 || parts[index + 1] !== policy.skill) continue;\n const deployment = parts.slice(0, index + 2).join('/');\n const prefix = ['.agents/skills/', '.hermes/skills/', '.claude/skills/'].find((candidate) => deployment.startsWith(candidate));\n if (prefix) output.add(await existingWithin(home, deployment, `skill ${policy.skill}`));\n }\n if (output.size === 0) throw new Error(`no deployed copy found for skill ${policy.skill}`);\n }\n return [...output];\n}\nasync function readState(path: string): Promise<State> {\n if (!existsSync(path)) return { version: 1, receipts: {} };\n const value: unknown = JSON.parse(await readFile(path, 'utf8'));\n if (!value || typeof value !== 'object' || Array.isArray(value)) throw new Error('state must be an object');\n const item = value as Record<string, unknown>;\n if (item.version !== 1 || !item.receipts || typeof item.receipts !== 'object' || Array.isArray(item.receipts)) throw new Error('unsupported state format');\n if (Object.values(item.receipts).some((receipt) => typeof receipt !== 'string')) throw new Error('invalid state receipt');\n return item as unknown as State;\n}\nasync function saveState(path: string, state: State): Promise<void> {\n const temp = join(dirname(path), `.state-${process.pid}-${Date.now()}.tmp`);\n try {\n await writeFile(temp, `${JSON.stringify(state, null, 2)}\\n`, { mode: 0o600, flag: 'wx' });\n await rename(temp, path);\n } catch (error) {\n try {\n await unlink(temp);\n } catch {\n /* preserve original error */\n }\n throw error;\n }\n}\nfunction receiptKey(policy: PluginPolicy, destination: string): string {\n return JSON.stringify([recordId(policy), destination]);\n}\nfunction digest(policy: PluginPolicy, command: string): string {\n return createHash('sha256')\n .update(JSON.stringify([recordId(policy), command]))\n .digest('hex');\n}\n// The platform shell runs the configured string as written, as with npm and Node's `shell` option.\nasync function execute(command: string, cwd: string, environment: NodeJS.ProcessEnv): Promise<void> {\n await spawn(command, [], { cwd, env: environment, stdio: ['ignore', 'inherit', 'inherit'], shell: true });\n}\nfunction lockLoadError(error: unknown): boolean {\n return !!error && typeof error === 'object' && 'code' in error && error.code === 'ENOENT';\n}\nexport async function runLifecycle(mode: Mode, options: RunOptions = {}): Promise<number> {\n const home = resolve(options.home ?? homedir());\n const apmHome = resolve(options.apmHome ?? join(home, '.apm'));\n const configPath = options.configPath ?? join(home, '.config', 'agent-plugin-lifecycle', 'config.json');\n const environment = options.environment ?? process.env;\n const output = options.output ?? console.log;\n const config = await loadConfig(configPath);\n let locked: LockedPlugin[];\n try {\n locked = await loadLock(join(apmHome, 'apm.lock.yaml'));\n } catch (error) {\n if (mode === 'run' && options.event?.event === 'post-uninstall' && lockLoadError(error)) {\n const apmDirectory = await stat(apmHome);\n if (!apmDirectory.isDirectory()) throw error;\n locked = [];\n } else throw error;\n }\n const statePath = join(dirname(configPath), 'state.json');\n if (mode === 'run') await mkdir(dirname(statePath), { recursive: true, mode: 0o700 });\n const release = mode === 'run' ? await lockfile.lock(dirname(statePath), { realpath: false }) : undefined;\n try {\n const state = await readState(statePath);\n let failed = 0;\n if (mode === 'run' && options.event?.event === 'post-uninstall') {\n const eventNames = new Set(options.event.packages.map(({ name }) => name));\n for (const policy of config.plugins) {\n const id = recordId(policy);\n const receiptKeys = Object.keys(state.receipts).filter((key) => {\n try {\n return JSON.parse(key)[0] === id;\n } catch {\n return false;\n }\n });\n if (!receiptKeys.length) continue;\n const sourceCandidate =\n policy.source.startsWith('.') || isAbsolute(policy.source) ? locked.find((plugin) => plugin.localPath !== undefined && samePath(policy.source, plugin.localPath)) : locked.find((plugin) => matchesSource(policy.source, plugin) && (plugin.path === (policy.path ?? '.') || plugin.localPath !== undefined));\n const sourcePartsValue = sourceParts(policy.source);\n const removedNameMatch =\n eventNames.has(sourceCandidate?.repo ?? '') ||\n eventNames.has(sourceCandidate ? `${sourceCandidate.host}/${sourceCandidate.repo}` : '') ||\n eventNames.has(sourcePartsValue?.repo ?? '') ||\n eventNames.has(sourcePartsValue ? `${sourcePartsValue.host}/${sourcePartsValue.repo}` : '') ||\n // APM names a removed subfolder plugin `owner/repo/<folder>` (install and update events name it `owner/repo`); exact match only, so removing one folder never matches another plugin of the repository\n (!!sourcePartsValue && !!policy.path && policy.path !== '.' && (eventNames.has(`${sourcePartsValue.repo}/${policy.path}`) || eventNames.has(`${sourcePartsValue.host}/${sourcePartsValue.repo}/${policy.path}`))) ||\n eventNames.has(localEventName(policy.source)) ||\n eventNames.has(policy.source);\n const anyStillInstalled = locked.some((plugin) => matchesSource(policy.source, plugin) && plugin.path === (policy.path ?? '.'));\n if (anyStillInstalled || !removedNameMatch) continue;\n const command = policy['post-uninstall'];\n if (!command) {\n for (const key of receiptKeys) delete state.receipts[key];\n await saveState(statePath, state);\n continue;\n }\n try {\n await execute(command, home, environment);\n for (const key of receiptKeys) delete state.receipts[key];\n await saveState(statePath, state);\n output(`cleaned ${id}`);\n } catch (error) {\n output(`failed cleanup ${id}: ${error instanceof Error ? error.message : String(error)}`);\n failed++;\n }\n }\n return failed ? 1 : 0;\n }\n if (mode === 'run' && !options.event) throw new Error('run requires an APM event');\n const event = options.event?.event ?? 'post-install';\n for (const policy of config.plugins) {\n const command = event === 'post-update' ? (policy['post-update'] ?? policy['post-install']) : policy['post-install'];\n if (!command) continue;\n const matches = locked.filter((plugin) => matchesSource(policy.source, plugin) && plugin.path === (policy.path ?? '.'));\n if (matches.length > 1) {\n output(`failed ambiguous source/path record ${recordId(policy)}`);\n failed++;\n continue;\n }\n if (!matches.length) {\n output(`skipped source not installed ${recordId(policy)}`);\n continue;\n }\n const plugin = matches[0];\n try {\n const found = await destinations(plugin, policy, home, apmHome);\n for (const destination of found) {\n const key = receiptKey(policy, destination);\n if (mode === 'check') {\n const validDigests = [policy['post-install'], policy['post-update']].filter((item): item is string => !!item).map((item) => digest(policy, item));\n const ready = validDigests.includes(state.receipts[key]);\n output(`${ready ? 'ok' : 'missing'} ${recordId(policy)} ${destination}`);\n if (!ready) failed++;\n } else {\n delete state.receipts[key];\n await saveState(statePath, state);\n await execute(command, destination, environment);\n state.receipts[key] = digest(policy, command);\n await saveState(statePath, state);\n output(`ran ${recordId(policy)} ${destination}`);\n }\n }\n } catch (error) {\n output(`failed ${recordId(policy)}: ${error instanceof Error ? error.message : String(error)}`);\n failed++;\n }\n }\n return failed ? 1 : 0;\n } finally {\n await release?.();\n }\n}\n"],"names":["createHash","existsSync","mkdir","readFile","realpath","rename","stat","unlink","writeFile","homedir","dirname","isAbsolute","join","relative","resolve","sep","spawn","lockfile","loadLock","localEventName","matchesSource","samePath","sourceParts","loadConfig","recordId","inside","root","child","subpath","startsWith","existingWithin","path","label","rootReal","candidate","Error","candidateReal","pluginRoot","plugin","apmHome","repo","destinations","policy","home","output","Set","skill","add","nativePluginRoot","nativeBase","slice","length","error","code","nativeRoot","file","deployedFiles","parts","split","index","lastIndexOf","deployment","prefix","find","size","readState","version","receipts","value","JSON","parse","Array","isArray","item","Object","values","some","receipt","saveState","state","temp","process","pid","Date","now","stringify","mode","flag","receiptKey","destination","digest","command","update","execute","cwd","environment","env","stdio","shell","lockLoadError","runLifecycle","options","configPath","console","log","config","locked","event","apmDirectory","isDirectory","statePath","recursive","release","lock","undefined","failed","eventNames","packages","map","name","plugins","id","receiptKeys","keys","filter","key","sourceCandidate","source","localPath","sourcePartsValue","removedNameMatch","has","host","anyStillInstalled","message","String","matches","found","validDigests","ready","includes"],"mappings":"AAAA,SAASA,UAAU,QAAQ,cAAc;AACzC,SAASC,UAAU,QAAQ,UAAU;AACrC,SAASC,KAAK,EAAEC,QAAQ,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,IAAI,E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AAM/C,UAAUgC,WAAW/B;wBAC3B,MAAMc,QAAQF,SAASF,aAAaM;wBACpChB,MAAMZ,QAAQ,CAAC0D,IAAI,GAAGnC,OAAOhD,QAAQiD;wBACrC,MAAMb,UAAUgC,WAAW/B;wBAC3BnC,OAAO,CAAC,IAAI,EAAEpB,SAASkB,QAAQ,CAAC,EAAE+C,aAAa;oBACjD;gBACF;YACF,EAAE,OAAOrC,OAAO;gBACdR,OAAO,CAAC,OAAO,EAAEpB,SAASkB,QAAQ,EAAE,EAAEU,iBAAiBjB,QAAQiB,MAAMkF,OAAO,GAAGC,OAAOnF,QAAQ;gBAC9F+D;YACF;QACF;QACA,OAAOA,SAAS,IAAI;IACtB,SAAU;QACR,OAAMH,oBAAAA,8BAAAA;IACR;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,64 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-plugin-lifecycle",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Run approved lifecycle commands for agent plugins installed by Agent Package Manager (APM)",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"apm",
|
|
7
|
+
"agent",
|
|
8
|
+
"package",
|
|
9
|
+
"manager",
|
|
10
|
+
"plugin",
|
|
11
|
+
"lifecycle"
|
|
12
|
+
],
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+ssh://git@github.com/kmalakoff/agent-plugin-lifecycle.git"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"author": "Kevin Malakoff <kmalakoff@gmail.com> (https://github.com/kmalakoff)",
|
|
19
|
+
"type": "module",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"import": "./dist/esm/index.js",
|
|
23
|
+
"require": "./dist/cjs/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./package.json": "./package.json"
|
|
26
|
+
},
|
|
27
|
+
"main": "dist/cjs/index.js",
|
|
28
|
+
"source": "src/index.ts",
|
|
29
|
+
"types": "dist/cjs/index.d.ts",
|
|
30
|
+
"bin": {
|
|
31
|
+
"agent-plugin-lifecycle": "bin/cli.js"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"config"
|
|
36
|
+
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsds build",
|
|
39
|
+
"format": "tsds format",
|
|
40
|
+
"prepare": "tsds build",
|
|
41
|
+
"prepublishOnly": "tsds validate",
|
|
42
|
+
"test": "tsds test:node --no-timeouts",
|
|
43
|
+
"test:apm": "tsds test:node --no-timeouts test/integration/apm-live.test.ts",
|
|
44
|
+
"test:engines": "nvu engines tsds test:node --no-timeouts",
|
|
45
|
+
"version": "tsds version"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"cross-spawn-cb": "^3.3.1",
|
|
49
|
+
"proper-lockfile": "^4.1.2",
|
|
50
|
+
"yaml": "^2.9.1"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@types/mocha": "*",
|
|
54
|
+
"@types/node": "^22",
|
|
55
|
+
"@types/proper-lockfile": "^4.1.4",
|
|
56
|
+
"fs-remove-compat": "^1.1.1",
|
|
57
|
+
"node-version-use": "*",
|
|
58
|
+
"ts-dev-stack": "*",
|
|
59
|
+
"tsds-config": "*"
|
|
60
|
+
},
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": ">=22.18"
|
|
63
|
+
}
|
|
64
|
+
}
|