agent-plugin-lifecycle 0.2.0 → 0.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.
Files changed (178) hide show
  1. package/README.md +243 -90
  2. package/bin/cli.js +8 -1
  3. package/dist/cjs/apm.d.cts +62 -13
  4. package/dist/cjs/apm.d.ts +62 -13
  5. package/dist/cjs/apm.js +534 -115
  6. package/dist/cjs/apm.js.map +1 -1
  7. package/dist/cjs/approvals.d.cts +26 -0
  8. package/dist/cjs/approvals.d.ts +26 -0
  9. package/dist/cjs/approvals.js +302 -0
  10. package/dist/cjs/approvals.js.map +1 -0
  11. package/dist/cjs/cli/index.d.cts +5 -0
  12. package/dist/cjs/cli/index.d.ts +5 -0
  13. package/dist/cjs/cli/index.js +53 -0
  14. package/dist/cjs/cli/index.js.map +1 -0
  15. package/dist/cjs/cli/install.d.cts +17 -0
  16. package/dist/cjs/cli/install.d.ts +17 -0
  17. package/dist/cjs/cli/install.js +308 -0
  18. package/dist/cjs/cli/install.js.map +1 -0
  19. package/dist/cjs/cli/report.d.cts +6 -0
  20. package/dist/cjs/cli/report.d.ts +6 -0
  21. package/dist/cjs/cli/report.js +47 -0
  22. package/dist/cjs/cli/report.js.map +1 -0
  23. package/dist/cjs/cli/status.d.cts +2 -0
  24. package/dist/cjs/cli/status.d.ts +2 -0
  25. package/dist/cjs/cli/status.js +222 -0
  26. package/dist/cjs/cli/status.js.map +1 -0
  27. package/dist/cjs/cli/types.d.cts +10 -0
  28. package/dist/cjs/cli/types.d.ts +10 -0
  29. package/dist/cjs/cli/types.js +6 -0
  30. package/dist/cjs/cli/types.js.map +1 -0
  31. package/dist/cjs/cli/usage.d.cts +2 -0
  32. package/dist/cjs/cli/usage.d.ts +2 -0
  33. package/dist/cjs/cli/usage.js +21 -0
  34. package/dist/cjs/cli/usage.js.map +1 -0
  35. package/dist/cjs/cli.d.cts +2 -1
  36. package/dist/cjs/cli.d.ts +2 -1
  37. package/dist/cjs/cli.js +65 -204
  38. package/dist/cjs/cli.js.map +1 -1
  39. package/dist/cjs/constants.d.cts +35 -0
  40. package/dist/cjs/constants.d.ts +35 -0
  41. package/dist/cjs/constants.js +115 -0
  42. package/dist/cjs/constants.js.map +1 -0
  43. package/dist/cjs/copies.d.cts +40 -0
  44. package/dist/cjs/copies.d.ts +40 -0
  45. package/dist/cjs/copies.js +937 -0
  46. package/dist/cjs/copies.js.map +1 -0
  47. package/dist/cjs/index.d.cts +3 -6
  48. package/dist/cjs/index.d.ts +3 -6
  49. package/dist/cjs/index.js +20 -19
  50. package/dist/cjs/index.js.map +1 -1
  51. package/dist/cjs/install.d.cts +6 -0
  52. package/dist/cjs/install.d.ts +6 -0
  53. package/dist/cjs/install.js +511 -0
  54. package/dist/cjs/install.js.map +1 -0
  55. package/dist/cjs/lib/errors.d.cts +5 -0
  56. package/dist/cjs/lib/errors.d.ts +5 -0
  57. package/dist/cjs/lib/errors.js +41 -0
  58. package/dist/cjs/lib/errors.js.map +1 -0
  59. package/dist/cjs/lib/object.d.cts +2 -0
  60. package/dist/cjs/lib/object.d.ts +2 -0
  61. package/dist/cjs/lib/object.js +18 -0
  62. package/dist/cjs/lib/object.js.map +1 -0
  63. package/dist/cjs/lib/options.d.cts +10 -0
  64. package/dist/cjs/lib/options.d.ts +10 -0
  65. package/dist/cjs/lib/options.js +26 -0
  66. package/dist/cjs/lib/options.js.map +1 -0
  67. package/dist/cjs/lib/run.d.cts +2 -0
  68. package/dist/cjs/lib/run.d.ts +2 -0
  69. package/dist/cjs/lib/run.js +40 -0
  70. package/dist/cjs/lib/run.js.map +1 -0
  71. package/dist/cjs/lib/store.d.cts +9 -0
  72. package/dist/cjs/lib/store.d.ts +9 -0
  73. package/dist/cjs/lib/store.js +418 -0
  74. package/dist/cjs/lib/store.js.map +1 -0
  75. package/dist/cjs/lib/visible.d.cts +9 -0
  76. package/dist/cjs/lib/visible.d.ts +9 -0
  77. package/dist/cjs/lib/visible.js +26 -0
  78. package/dist/cjs/lib/visible.js.map +1 -0
  79. package/dist/cjs/manifest.d.cts +4 -0
  80. package/dist/cjs/manifest.d.ts +4 -0
  81. package/dist/cjs/{config.js → manifest.js} +33 -94
  82. package/dist/cjs/manifest.js.map +1 -0
  83. package/dist/cjs/state.d.cts +17 -0
  84. package/dist/cjs/state.d.ts +17 -0
  85. package/dist/cjs/state.js +143 -0
  86. package/dist/cjs/state.js.map +1 -0
  87. package/dist/cjs/status.d.cts +3 -0
  88. package/dist/cjs/status.d.ts +3 -0
  89. package/dist/cjs/status.js +273 -0
  90. package/dist/cjs/status.js.map +1 -0
  91. package/dist/cjs/types.d.cts +39 -0
  92. package/dist/cjs/types.d.ts +39 -0
  93. package/dist/cjs/types.js +5 -0
  94. package/dist/cjs/types.js.map +1 -0
  95. package/dist/esm/apm.d.ts +62 -13
  96. package/dist/esm/apm.js +208 -96
  97. package/dist/esm/apm.js.map +1 -1
  98. package/dist/esm/approvals.d.ts +26 -0
  99. package/dist/esm/approvals.js +43 -0
  100. package/dist/esm/approvals.js.map +1 -0
  101. package/dist/esm/cli/index.d.ts +5 -0
  102. package/dist/esm/cli/index.js +5 -0
  103. package/dist/esm/cli/index.js.map +1 -0
  104. package/dist/esm/cli/install.d.ts +17 -0
  105. package/dist/esm/cli/install.js +89 -0
  106. package/dist/esm/cli/install.js.map +1 -0
  107. package/dist/esm/cli/report.d.ts +6 -0
  108. package/dist/esm/cli/report.js +21 -0
  109. package/dist/esm/cli/report.js.map +1 -0
  110. package/dist/esm/cli/status.d.ts +2 -0
  111. package/dist/esm/cli/status.js +41 -0
  112. package/dist/esm/cli/status.js.map +1 -0
  113. package/dist/esm/cli/types.d.ts +10 -0
  114. package/dist/esm/cli/types.js +2 -0
  115. package/dist/esm/cli/types.js.map +1 -0
  116. package/dist/esm/cli/usage.d.ts +2 -0
  117. package/dist/esm/cli/usage.js +2 -0
  118. package/dist/esm/cli/usage.js.map +1 -0
  119. package/dist/esm/cli.d.ts +2 -1
  120. package/dist/esm/cli.js +46 -65
  121. package/dist/esm/cli.js.map +1 -1
  122. package/dist/esm/constants.d.ts +35 -0
  123. package/dist/esm/constants.js +37 -0
  124. package/dist/esm/constants.js.map +1 -0
  125. package/dist/esm/copies.d.ts +40 -0
  126. package/dist/esm/copies.js +226 -0
  127. package/dist/esm/copies.js.map +1 -0
  128. package/dist/esm/index.d.ts +3 -6
  129. package/dist/esm/index.js +3 -3
  130. package/dist/esm/index.js.map +1 -1
  131. package/dist/esm/install.d.ts +6 -0
  132. package/dist/esm/install.js +116 -0
  133. package/dist/esm/install.js.map +1 -0
  134. package/dist/esm/lib/errors.d.ts +5 -0
  135. package/dist/esm/lib/errors.js +9 -0
  136. package/dist/esm/lib/errors.js.map +1 -0
  137. package/dist/esm/lib/object.d.ts +2 -0
  138. package/dist/esm/lib/object.js +3 -0
  139. package/dist/esm/lib/object.js.map +1 -0
  140. package/dist/esm/lib/options.d.ts +10 -0
  141. package/dist/esm/lib/options.js +15 -0
  142. package/dist/esm/lib/options.js.map +1 -0
  143. package/dist/esm/lib/run.d.ts +2 -0
  144. package/dist/esm/lib/run.js +29 -0
  145. package/dist/esm/lib/run.js.map +1 -0
  146. package/dist/esm/lib/store.d.ts +9 -0
  147. package/dist/esm/lib/store.js +91 -0
  148. package/dist/esm/lib/store.js.map +1 -0
  149. package/dist/esm/lib/visible.d.ts +9 -0
  150. package/dist/esm/lib/visible.js +12 -0
  151. package/dist/esm/lib/visible.js.map +1 -0
  152. package/dist/esm/manifest.d.ts +4 -0
  153. package/dist/esm/manifest.js +25 -0
  154. package/dist/esm/manifest.js.map +1 -0
  155. package/dist/esm/state.d.ts +17 -0
  156. package/dist/esm/state.js +32 -0
  157. package/dist/esm/state.js.map +1 -0
  158. package/dist/esm/status.d.ts +3 -0
  159. package/dist/esm/status.js +44 -0
  160. package/dist/esm/status.js.map +1 -0
  161. package/dist/esm/types.d.ts +39 -0
  162. package/dist/esm/types.js +1 -0
  163. package/dist/esm/types.js.map +1 -0
  164. package/package.json +25 -9
  165. package/config/config.example.json +0 -22
  166. package/dist/cjs/config.d.cts +0 -16
  167. package/dist/cjs/config.d.ts +0 -16
  168. package/dist/cjs/config.js.map +0 -1
  169. package/dist/cjs/runner.d.cts +0 -19
  170. package/dist/cjs/runner.d.ts +0 -19
  171. package/dist/cjs/runner.js +0 -1391
  172. package/dist/cjs/runner.js.map +0 -1
  173. package/dist/esm/config.d.ts +0 -16
  174. package/dist/esm/config.js +0 -74
  175. package/dist/esm/config.js.map +0 -1
  176. package/dist/esm/runner.d.ts +0 -19
  177. package/dist/esm/runner.js +0 -335
  178. package/dist/esm/runner.js.map +0 -1
@@ -0,0 +1,2 @@
1
+ export declare const INSTALL_USAGE = "install [-g] [-y] [folder...]";
2
+ export declare const STATUS_USAGE = "status [-g] [folder...]";
@@ -0,0 +1,2 @@
1
+ export declare const INSTALL_USAGE = "install [-g] [-y] [folder...]";
2
+ export declare const STATUS_USAGE = "status [-g] [folder...]";
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
+ });
10
+ }
11
+ _export(exports, {
12
+ get INSTALL_USAGE () {
13
+ return INSTALL_USAGE;
14
+ },
15
+ get STATUS_USAGE () {
16
+ return STATUS_USAGE;
17
+ }
18
+ });
19
+ var INSTALL_USAGE = 'install [-g] [-y] [folder...]';
20
+ var STATUS_USAGE = 'status [-g] [folder...]';
21
+ /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/open-source/ai/agent-plugin-lifecycle/src/cli/usage.ts"],"sourcesContent":["export const INSTALL_USAGE = 'install [-g] [-y] [folder...]';\nexport const STATUS_USAGE = 'status [-g] [folder...]';\n"],"names":["INSTALL_USAGE","STATUS_USAGE"],"mappings":";;;;;;;;;;;QAAaA;eAAAA;;QACAC;eAAAA;;;AADN,IAAMD,gBAAgB;AACtB,IAAMC,eAAe"}
@@ -1 +1,2 @@
1
- export {};
1
+ /** Runs the CLI; sets `process.exitCode` to 0, 1 (a copy is not ok) or 2 (apl could not do its work). */
2
+ export default function cli(argv: string[], name: string): Promise<void>;
package/dist/cjs/cli.d.ts CHANGED
@@ -1 +1,2 @@
1
- export {};
1
+ /** Runs the CLI; sets `process.exitCode` to 0, 1 (a copy is not ok) or 2 (apl could not do its work). */
2
+ export default function cli(argv: string[], name: string): Promise<void>;
package/dist/cjs/cli.js CHANGED
@@ -1,50 +1,22 @@
1
+ // Parsing and dispatch only. Commands live in src/cli/, one file each, lazy-loaded.
1
2
  "use strict";
2
3
  Object.defineProperty(exports, "__esModule", {
3
4
  value: true
4
5
  });
5
- var _nodeutil = require("node:util");
6
- var _runner = require("./runner.js");
7
- function _async_iterator(iterable) {
8
- var method, async, sync, retry = 2;
9
- for("undefined" != typeof Symbol && (async = Symbol.asyncIterator, sync = Symbol.iterator); retry--;){
10
- if (async && null != (method = iterable[async])) return method.call(iterable);
11
- if (sync && null != (method = iterable[sync])) return new AsyncFromSyncIterator(method.call(iterable));
12
- async = "@@asyncIterator", sync = "@@iterator";
6
+ Object.defineProperty(exports, /** Runs the CLI; sets `process.exitCode` to 0, 1 (a copy is not ok) or 2 (apl could not do its work). */ "default", {
7
+ enumerable: true,
8
+ get: function() {
9
+ return cli;
13
10
  }
14
- throw new TypeError("Object is not async iterable");
15
- }
16
- function AsyncFromSyncIterator(s) {
17
- function AsyncFromSyncIteratorContinuation(r) {
18
- if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object."));
19
- var done = r.done;
20
- return Promise.resolve(r.value).then(function(value) {
21
- return {
22
- value: value,
23
- done: done
24
- };
25
- });
26
- }
27
- return AsyncFromSyncIterator = function(s) {
28
- this.s = s, this.n = s.next;
29
- }, AsyncFromSyncIterator.prototype = {
30
- s: null,
31
- n: null,
32
- next: function() {
33
- return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
34
- },
35
- return: function(value) {
36
- var ret = this.s.return;
37
- return void 0 === ret ? Promise.resolve({
38
- value: value,
39
- done: !0
40
- }) : AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments));
41
- },
42
- throw: function(value) {
43
- var thr = this.s.return;
44
- return void 0 === thr ? Promise.reject(value) : AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments));
45
- }
46
- }, new AsyncFromSyncIterator(s);
47
- }
11
+ });
12
+ var _nodefs = require("node:fs");
13
+ var _nodepath = /*#__PURE__*/ _interop_require_default(require("node:path"));
14
+ var _nodeurl = require("node:url");
15
+ var _indexts = require("./cli/index.js");
16
+ var _usagets = require("./cli/usage.js");
17
+ var _constantsts = require("./constants.js");
18
+ var _errorsts = require("./lib/errors.js");
19
+ var _visiblets = require("./lib/visible.js");
48
20
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
49
21
  try {
50
22
  var info = gen[key](arg);
@@ -71,11 +43,10 @@ function _async_to_generator(fn) {
71
43
  });
72
44
  };
73
45
  }
74
- function _instanceof(left, right) {
75
- "@swc/helpers - instanceof";
76
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
77
- return !!right[Symbol.hasInstance](left);
78
- } else return left instanceof right;
46
+ function _interop_require_default(obj) {
47
+ return obj && obj.__esModule ? obj : {
48
+ default: obj
49
+ };
79
50
  }
80
51
  function _ts_generator(thisArg, body) {
81
52
  var f, y, t, _ = {
@@ -176,191 +147,81 @@ function _ts_generator(thisArg, body) {
176
147
  };
177
148
  }
178
149
  }
179
- function _type_of(obj) {
180
- "@swc/helpers - typeof";
181
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
150
+ // __dirname (CJS) or its ESM equivalent; dist/<format>/cli.js is two hops below the package root
151
+ var __dirname = _nodepath.default.dirname(typeof __filename !== 'undefined' ? __filename : (0, _nodeurl.fileURLToPath)(require("url").pathToFileURL(__filename).toString()));
152
+ function packageVersion() {
153
+ var pkg = JSON.parse((0, _nodefs.readFileSync)(_nodepath.default.resolve(__dirname, '..', '..', 'package.json'), 'utf8'));
154
+ return pkg.version;
155
+ }
156
+ function usage(name) {
157
+ return "usage: ".concat(name, " ").concat(_usagets.INSTALL_USAGE, " run install scripts, asking before any that are not approved\n ").concat(name, " ").concat(_usagets.STATUS_USAGE, " report each copy; exit 1 unless every copy is ok\n ").concat(name, " --help | -h\n ").concat(name, " --version | -v\n\nWith no folder, the copies are the ones APM's lock names: ./apm.lock.yaml, or with -g (or run in the APM home) ~/.apm/apm.lock.yaml.\nApprovals and run records: ~/.apl/");
182
158
  }
183
- var HELP = "agent-plugin-lifecycle\n\nUsage:\n agent-plugin-lifecycle run Dispatch an APM post-install/update/uninstall event from stdin\n agent-plugin-lifecycle check Report missing or failed plugin setup\n agent-plugin-lifecycle --help\n\nPolicy: ~/.config/agent-plugin-lifecycle/config.json\nAPM lock: ~/.apm/apm.lock.yaml (or $APM_HOME/apm.lock.yaml)\n";
184
- function readEvent() {
159
+ /** Prints apl's own text, with any untrusted part already escaped, and exits 2. */ function fail(text) {
160
+ console.error(text);
161
+ process.exit(_constantsts.EXIT_ERROR);
162
+ }
163
+ function cli(argv, name) {
185
164
  return _async_to_generator(function() {
186
- var payload, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, chunk, err, event, value;
165
+ var load, ctx, error;
187
166
  return _ts_generator(this, function(_state) {
188
167
  switch(_state.label){
189
168
  case 0:
190
- if (process.stdin.isTTY) throw new Error('run requires an APM event on stdin');
191
- payload = '';
192
- _iteratorAbruptCompletion = false, _didIteratorError = false;
169
+ if (argv[0] === '--version' || argv[0] === '-v') {
170
+ console.log(packageVersion());
171
+ return [
172
+ 2
173
+ ];
174
+ }
175
+ if (argv[0] === '--help' || argv[0] === '-h') {
176
+ console.log(usage(name));
177
+ return [
178
+ 2
179
+ ];
180
+ }
181
+ load = _indexts.COMMANDS[argv[0]];
182
+ if (!load) fail("".concat(argv.length ? "unknown command: ".concat((0, _visiblets.visible)(argv[0]), "\n") : '').concat(usage(name)));
183
+ ctx = {
184
+ name: name,
185
+ rest: argv.slice(1),
186
+ usageError: fail
187
+ };
193
188
  _state.label = 1;
194
189
  case 1:
195
190
  _state.trys.push([
196
191
  1,
197
- 6,
198
- 7,
199
- 12
192
+ 4,
193
+ ,
194
+ 5
200
195
  ]);
201
- _iterator = _async_iterator(process.stdin);
202
- _state.label = 2;
196
+ return [
197
+ 4,
198
+ load()
199
+ ];
203
200
  case 2:
204
201
  return [
205
202
  4,
206
- _iterator.next()
203
+ _state.sent().default(ctx)
207
204
  ];
208
205
  case 3:
209
- if (!(_iteratorAbruptCompletion = !(_step = _state.sent()).done)) return [
206
+ process.exitCode = _state.sent();
207
+ return [
210
208
  3,
211
209
  5
212
210
  ];
213
- _value = _step.value;
214
- chunk = _value;
215
- payload += chunk.toString();
216
- if (payload.length > 1024 * 1024) throw new Error('APM event exceeds 1 MiB');
217
- _state.label = 4;
218
211
  case 4:
219
- _iteratorAbruptCompletion = false;
212
+ error = _state.sent();
213
+ // the message can carry a hostile lock's text or a folder's name: escaped as a whole, so a newline in it cannot start a line
214
+ fail("".concat(name, ": ").concat((0, _visiblets.visible)((0, _errorsts.message)(error))));
220
215
  return [
221
216
  3,
222
- 2
217
+ 5
223
218
  ];
224
219
  case 5:
225
220
  return [
226
- 3,
227
- 12
228
- ];
229
- case 6:
230
- err = _state.sent();
231
- _didIteratorError = true;
232
- _iteratorError = err;
233
- return [
234
- 3,
235
- 12
236
- ];
237
- case 7:
238
- _state.trys.push([
239
- 7,
240
- ,
241
- 10,
242
- 11
243
- ]);
244
- if (!(_iteratorAbruptCompletion && _iterator.return != null)) return [
245
- 3,
246
- 9
247
- ];
248
- return [
249
- 4,
250
- _iterator.return()
251
- ];
252
- case 8:
253
- _state.sent();
254
- _state.label = 9;
255
- case 9:
256
- return [
257
- 3,
258
- 11
259
- ];
260
- case 10:
261
- if (_didIteratorError) {
262
- throw _iteratorError;
263
- }
264
- return [
265
- 7
266
- ];
267
- case 11:
268
- return [
269
- 7
270
- ];
271
- case 12:
272
- if (!payload.trim()) throw new Error('run requires an APM event on stdin');
273
- event = JSON.parse(payload);
274
- if (!event || (typeof event === "undefined" ? "undefined" : _type_of(event)) !== 'object' || Array.isArray(event)) throw new Error('APM event must be an object');
275
- value = event;
276
- if (value.schema_version !== 1 || ![
277
- 'post-install',
278
- 'post-update',
279
- 'post-uninstall'
280
- ].includes(String(value.event)) || ![
281
- 'user',
282
- 'project'
283
- ].includes(String(value.scope)) || !Array.isArray(value.packages) || !value.packages.every(function(p) {
284
- return p && (typeof p === "undefined" ? "undefined" : _type_of(p)) === 'object' && typeof p.name === 'string' && (p.reference === null || typeof p.reference === 'string');
285
- })) {
286
- throw new Error('unsupported APM lifecycle event');
287
- }
288
- return [
289
- 2,
290
- value
291
- ];
292
- }
293
- });
294
- })();
295
- }
296
- function main() {
297
- return _async_to_generator(function() {
298
- var _parseArgs, values, positionals, event, _tmp;
299
- return _ts_generator(this, function(_state) {
300
- switch(_state.label){
301
- case 0:
302
- _parseArgs = (0, _nodeutil.parseArgs)({
303
- args: process.argv.slice(2),
304
- options: {
305
- help: {
306
- type: 'boolean',
307
- short: 'h'
308
- }
309
- },
310
- allowPositionals: true
311
- }), values = _parseArgs.values, positionals = _parseArgs.positionals;
312
- if (values.help || positionals.length === 0) {
313
- process.stdout.write(HELP);
314
- return [
315
- 2,
316
- 0
317
- ];
318
- }
319
- if (positionals.length !== 1 || ![
320
- 'run',
321
- 'check'
322
- ].includes(positionals[0])) throw new Error('expected run or check; use --help');
323
- if (!(positionals[0] === 'run')) return [
324
- 3,
325
221
  2
326
222
  ];
327
- return [
328
- 4,
329
- readEvent()
330
- ];
331
- case 1:
332
- _tmp = _state.sent();
333
- return [
334
- 3,
335
- 3
336
- ];
337
- case 2:
338
- _tmp = undefined;
339
- _state.label = 3;
340
- case 3:
341
- event = _tmp;
342
- if ((event === null || event === void 0 ? void 0 : event.scope) !== undefined && event.scope !== 'user') {
343
- console.log("skipped APM ".concat(event.scope, " scope event"));
344
- return [
345
- 2,
346
- 0
347
- ];
348
- }
349
- return [
350
- 2,
351
- (0, _runner.runLifecycle)(positionals[0], {
352
- apmHome: process.env.APM_HOME,
353
- event: event
354
- })
355
- ];
356
223
  }
357
224
  });
358
225
  })();
359
226
  }
360
- main().then(function(status) {
361
- process.exitCode = status;
362
- }).catch(function(error) {
363
- console.error("agent-plugin-lifecycle: ".concat(_instanceof(error, Error) ? error.message : String(error)));
364
- process.exitCode = 2;
365
- });
366
227
  /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/open-source/ai/agent-plugin-lifecycle/src/cli.ts"],"sourcesContent":["import { parseArgs } from 'node:util';\n\nimport { runLifecycle } from './runner.js';\n\nconst HELP = `agent-plugin-lifecycle\n\nUsage:\n agent-plugin-lifecycle run Dispatch an APM post-install/update/uninstall event from stdin\n agent-plugin-lifecycle check Report missing or failed plugin setup\n agent-plugin-lifecycle --help\n\nPolicy: ~/.config/agent-plugin-lifecycle/config.json\nAPM lock: ~/.apm/apm.lock.yaml (or $APM_HOME/apm.lock.yaml)\n`;\n\nasync function readEvent(): Promise<import('./runner.js').LifecycleEvent> {\n if (process.stdin.isTTY) throw new Error('run requires an APM event on stdin');\n let payload = '';\n for await (const chunk of process.stdin) {\n payload += chunk.toString();\n if (payload.length > 1024 * 1024) throw new Error('APM event exceeds 1 MiB');\n }\n if (!payload.trim()) throw new Error('run requires an APM event on stdin');\n const event: unknown = JSON.parse(payload);\n if (!event || typeof event !== 'object' || Array.isArray(event)) throw new Error('APM event must be an object');\n const value = event as Record<string, unknown>;\n if (\n value.schema_version !== 1 ||\n !['post-install', 'post-update', 'post-uninstall'].includes(String(value.event)) ||\n !['user', 'project'].includes(String(value.scope)) ||\n !Array.isArray(value.packages) ||\n !value.packages.every((p) => p && typeof p === 'object' && typeof p.name === 'string' && (p.reference === null || typeof p.reference === 'string'))\n ) {\n throw new Error('unsupported APM lifecycle event');\n }\n return value as unknown as import('./runner.js').LifecycleEvent;\n}\n\nasync function main(): Promise<number> {\n const { values, positionals } = parseArgs({\n args: process.argv.slice(2),\n options: { help: { type: 'boolean', short: 'h' } },\n allowPositionals: true,\n });\n if (values.help || positionals.length === 0) {\n process.stdout.write(HELP);\n return 0;\n }\n if (positionals.length !== 1 || !['run', 'check'].includes(positionals[0])) throw new Error('expected run or check; use --help');\n const event = positionals[0] === 'run' ? await readEvent() : undefined;\n if (event?.scope !== undefined && event.scope !== 'user') {\n console.log(`skipped APM ${event.scope} scope event`);\n return 0;\n }\n return runLifecycle(positionals[0] as 'run' | 'check', { apmHome: process.env.APM_HOME, event });\n}\n\nmain()\n .then((status) => {\n process.exitCode = status;\n })\n .catch((error: unknown) => {\n console.error(`agent-plugin-lifecycle: ${error instanceof Error ? error.message : String(error)}`);\n process.exitCode = 2;\n });\n"],"names":["HELP","readEvent","payload","chunk","event","value","process","stdin","isTTY","Error","toString","length","trim","JSON","parse","Array","isArray","schema_version","includes","String","scope","packages","every","p","name","reference","main","parseArgs","values","positionals","args","argv","slice","options","help","type","short","allowPositionals","stdout","write","undefined","console","log","runLifecycle","apmHome","env","APM_HOME","then","status","exitCode","catch","error","message"],"mappings":"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"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/open-source/ai/agent-plugin-lifecycle/src/cli.ts"],"sourcesContent":["// Parsing and dispatch only. Commands live in src/cli/, one file each, lazy-loaded.\nimport { readFileSync } from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { COMMANDS } from './cli/index.ts';\nimport type { Ctx } from './cli/types.ts';\nimport { INSTALL_USAGE, STATUS_USAGE } from './cli/usage.ts';\nimport { EXIT_ERROR } from './constants.ts';\nimport { message } from './lib/errors.ts';\nimport { visible } from './lib/visible.ts';\n\n// __dirname (CJS) or its ESM equivalent; dist/<format>/cli.js is two hops below the package root\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : fileURLToPath(import.meta.url));\n\nfunction packageVersion(): string {\n const pkg = JSON.parse(readFileSync(path.resolve(__dirname, '..', '..', 'package.json'), 'utf8')) as { version: string };\n return pkg.version;\n}\n\nfunction usage(name: string): string {\n return `usage: ${name} ${INSTALL_USAGE} run install scripts, asking before any that are not approved\n ${name} ${STATUS_USAGE} report each copy; exit 1 unless every copy is ok\n ${name} --help | -h\n ${name} --version | -v\n\nWith no folder, the copies are the ones APM's lock names: ./apm.lock.yaml, or with -g (or run in the APM home) ~/.apm/apm.lock.yaml.\nApprovals and run records: ~/.apl/`;\n}\n\n/** Prints apl's own text, with any untrusted part already escaped, and exits 2. */\nfunction fail(text: string): never {\n console.error(text);\n process.exit(EXIT_ERROR);\n}\n\n/** Runs the CLI; sets `process.exitCode` to 0, 1 (a copy is not ok) or 2 (apl could not do its work). */\nexport default async function cli(argv: string[], name: string): Promise<void> {\n if (argv[0] === '--version' || argv[0] === '-v') {\n console.log(packageVersion());\n return;\n }\n if (argv[0] === '--help' || argv[0] === '-h') {\n console.log(usage(name));\n return;\n }\n const load = COMMANDS[argv[0]];\n if (!load) fail(`${argv.length ? `unknown command: ${visible(argv[0])}\\n` : ''}${usage(name)}`);\n const ctx: Ctx = { name, rest: argv.slice(1), usageError: fail };\n try {\n process.exitCode = await (await load()).default(ctx);\n } catch (error) {\n // the message can carry a hostile lock's text or a folder's name: escaped as a whole, so a newline in it cannot start a line\n fail(`${name}: ${visible(message(error))}`);\n }\n}\n"],"names":["cli","__dirname","path","dirname","__filename","fileURLToPath","packageVersion","pkg","JSON","parse","readFileSync","resolve","version","usage","name","INSTALL_USAGE","STATUS_USAGE","fail","text","console","error","process","exit","EXIT_ERROR","argv","load","ctx","log","COMMANDS","length","visible","rest","slice","usageError","default","exitCode","message"],"mappings":"AAAA,oFAAoF;;;;;+BAmCpF,uGAAuG,GACvG;;;eAA8BA;;;sBAnCD;+DACZ;uBACa;uBACL;uBAEmB;2BACjB;wBACH;yBACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAExB,iGAAiG;AACjG,IAAMC,YAAYC,iBAAI,CAACC,OAAO,CAAC,OAAOC,eAAe,cAAcA,aAAaC,IAAAA,sBAAa,EAAC;AAE9F,SAASC;IACP,IAAMC,MAAMC,KAAKC,KAAK,CAACC,IAAAA,oBAAY,EAACR,iBAAI,CAACS,OAAO,CAACV,WAAW,MAAM,MAAM,iBAAiB;IACzF,OAAOM,IAAIK,OAAO;AACpB;AAEA,SAASC,MAAMC,IAAY;IACzB,OAAO,AAAC,UAAiBC,OAARD,MAAK,KACfA,OADkBC,sBAAa,EAAC,4EACxBC,OAARF,MAAK,KACLA,OADQE,qBAAY,EAAC,wEAErBF,OADAA,MAAK,yBACA,OAALA,MAAK;AAId;AAEA,iFAAiF,GACjF,SAASG,KAAKC,IAAY;IACxBC,QAAQC,KAAK,CAACF;IACdG,QAAQC,IAAI,CAACC,uBAAU;AACzB;AAGe,SAAevB,IAAIwB,IAAc,EAAEV,IAAY;;YAStDW,MAEAC,KAGGN;;;;oBAbT,IAAII,IAAI,CAAC,EAAE,KAAK,eAAeA,IAAI,CAAC,EAAE,KAAK,MAAM;wBAC/CL,QAAQQ,GAAG,CAACrB;wBACZ;;;oBACF;oBACA,IAAIkB,IAAI,CAAC,EAAE,KAAK,YAAYA,IAAI,CAAC,EAAE,KAAK,MAAM;wBAC5CL,QAAQQ,GAAG,CAACd,MAAMC;wBAClB;;;oBACF;oBACMW,OAAOG,iBAAQ,CAACJ,IAAI,CAAC,EAAE,CAAC;oBAC9B,IAAI,CAACC,MAAMR,KAAK,AAAC,GAAgEJ,OAA9DW,KAAKK,MAAM,GAAG,AAAC,oBAAoC,OAAjBC,IAAAA,kBAAO,EAACN,IAAI,CAAC,EAAE,GAAE,QAAM,IAAiB,OAAZX,MAAMC;oBACjFY,MAAW;wBAAEZ,MAAAA;wBAAMiB,MAAMP,KAAKQ,KAAK,CAAC;wBAAIC,YAAYhB;oBAAK;;;;;;;;;oBAEnC;;wBAAMQ;;;oBAAb;;wBAAO,cAAcS,OAAO,CAACR;;;oBAAhDL,QAAQc,QAAQ,GAAG;;;;;;oBACZf;oBACP,6HAA6H;oBAC7HH,KAAK,AAAC,GAAWa,OAAThB,MAAK,MAA4B,OAAxBgB,IAAAA,kBAAO,EAACM,IAAAA,iBAAO,EAAChB;;;;;;;;;;;IAErC"}
@@ -0,0 +1,35 @@
1
+ import type { Status } from './types.js';
2
+ /** The file a plugin or skill ships its scripts in. */
3
+ export declare const MANIFEST = "apl.json";
4
+ /** The one script name `apl` runs. */
5
+ export declare const INSTALL = "install";
6
+ /** The per-user folder under the home that holds approvals and run records. */
7
+ export declare const APL_DIR = ".apl";
8
+ export declare const APPROVALS_FILE = "approvals.json";
9
+ export declare const STATE_FILE = "state.json";
10
+ /** The lock taken on `~/.apl` while either file changes (a folder `proper-lockfile` creates inside it). */
11
+ export declare const LOCK_NAME = "lock";
12
+ /** Waits for another `apl` holding the lock; each hold is one read-modify-write of a small file. */
13
+ export declare const LOCK_RETRIES: {
14
+ retries: number;
15
+ minTimeout: number;
16
+ maxTimeout: number;
17
+ };
18
+ /** The `version` of the files `apl` writes. */
19
+ export declare const FILE_VERSION = 1;
20
+ export declare const APM_DIR = ".apm";
21
+ export declare const APM_LOCK = "apm.lock.yaml";
22
+ export declare const APM_MODULES = "apm_modules";
23
+ /** The folder of a plugin's skills, and the part of an id for a skill: `skills/<name>`. */
24
+ export declare const SKILLS = "skills";
25
+ /** The reason for a package whose `apl.json` reaches only APM's cache, which APM restores on `apm update`, deleting a script's output. */
26
+ export declare const CACHE_ONLY = "APM's cache is the only copy; scripts do not run there";
27
+ export declare const STATUSES: Status[];
28
+ export declare const SUCCESS_STATUSES: Status[];
29
+ export declare const EXIT_OK = 0;
30
+ export declare const EXIT_NOT_OK = 1;
31
+ export declare const EXIT_ERROR = 2;
32
+ /** Ctrl+C at the approval question: 128 + SIGINT, as shells report it. */
33
+ export declare const EXIT_INTERRUPTED = 130;
34
+ export declare const NOTHING_INSTALLED = "nothing installed";
35
+ export declare const NO_PROJECT_LOCK = "no apm.lock.yaml here: pass -g or a folder";
@@ -0,0 +1,35 @@
1
+ import type { Status } from './types.js';
2
+ /** The file a plugin or skill ships its scripts in. */
3
+ export declare const MANIFEST = "apl.json";
4
+ /** The one script name `apl` runs. */
5
+ export declare const INSTALL = "install";
6
+ /** The per-user folder under the home that holds approvals and run records. */
7
+ export declare const APL_DIR = ".apl";
8
+ export declare const APPROVALS_FILE = "approvals.json";
9
+ export declare const STATE_FILE = "state.json";
10
+ /** The lock taken on `~/.apl` while either file changes (a folder `proper-lockfile` creates inside it). */
11
+ export declare const LOCK_NAME = "lock";
12
+ /** Waits for another `apl` holding the lock; each hold is one read-modify-write of a small file. */
13
+ export declare const LOCK_RETRIES: {
14
+ retries: number;
15
+ minTimeout: number;
16
+ maxTimeout: number;
17
+ };
18
+ /** The `version` of the files `apl` writes. */
19
+ export declare const FILE_VERSION = 1;
20
+ export declare const APM_DIR = ".apm";
21
+ export declare const APM_LOCK = "apm.lock.yaml";
22
+ export declare const APM_MODULES = "apm_modules";
23
+ /** The folder of a plugin's skills, and the part of an id for a skill: `skills/<name>`. */
24
+ export declare const SKILLS = "skills";
25
+ /** The reason for a package whose `apl.json` reaches only APM's cache, which APM restores on `apm update`, deleting a script's output. */
26
+ export declare const CACHE_ONLY = "APM's cache is the only copy; scripts do not run there";
27
+ export declare const STATUSES: Status[];
28
+ export declare const SUCCESS_STATUSES: Status[];
29
+ export declare const EXIT_OK = 0;
30
+ export declare const EXIT_NOT_OK = 1;
31
+ export declare const EXIT_ERROR = 2;
32
+ /** Ctrl+C at the approval question: 128 + SIGINT, as shells report it. */
33
+ export declare const EXIT_INTERRUPTED = 130;
34
+ export declare const NOTHING_INSTALLED = "nothing installed";
35
+ export declare const NO_PROJECT_LOCK = "no apm.lock.yaml here: pass -g or a folder";
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
+ });
10
+ }
11
+ _export(exports, {
12
+ get APL_DIR () {
13
+ return APL_DIR;
14
+ },
15
+ get APM_DIR () {
16
+ return APM_DIR;
17
+ },
18
+ get APM_LOCK () {
19
+ return APM_LOCK;
20
+ },
21
+ get APM_MODULES () {
22
+ return APM_MODULES;
23
+ },
24
+ get APPROVALS_FILE () {
25
+ return APPROVALS_FILE;
26
+ },
27
+ get CACHE_ONLY () {
28
+ return CACHE_ONLY;
29
+ },
30
+ get EXIT_ERROR () {
31
+ return EXIT_ERROR;
32
+ },
33
+ get EXIT_INTERRUPTED () {
34
+ return EXIT_INTERRUPTED;
35
+ },
36
+ get EXIT_NOT_OK () {
37
+ return EXIT_NOT_OK;
38
+ },
39
+ get EXIT_OK () {
40
+ return EXIT_OK;
41
+ },
42
+ get FILE_VERSION () {
43
+ return FILE_VERSION;
44
+ },
45
+ get INSTALL () {
46
+ return INSTALL;
47
+ },
48
+ get LOCK_NAME () {
49
+ return LOCK_NAME;
50
+ },
51
+ get LOCK_RETRIES () {
52
+ return LOCK_RETRIES;
53
+ },
54
+ get MANIFEST () {
55
+ return MANIFEST;
56
+ },
57
+ get NOTHING_INSTALLED () {
58
+ return NOTHING_INSTALLED;
59
+ },
60
+ get NO_PROJECT_LOCK () {
61
+ return NO_PROJECT_LOCK;
62
+ },
63
+ get SKILLS () {
64
+ return SKILLS;
65
+ },
66
+ get STATE_FILE () {
67
+ return STATE_FILE;
68
+ },
69
+ get STATUSES () {
70
+ return STATUSES;
71
+ },
72
+ get SUCCESS_STATUSES () {
73
+ return SUCCESS_STATUSES;
74
+ }
75
+ });
76
+ var MANIFEST = 'apl.json';
77
+ var INSTALL = 'install';
78
+ var APL_DIR = '.apl';
79
+ var APPROVALS_FILE = 'approvals.json';
80
+ var STATE_FILE = 'state.json';
81
+ var LOCK_NAME = 'lock';
82
+ var LOCK_RETRIES = {
83
+ retries: 10,
84
+ minTimeout: 50,
85
+ maxTimeout: 500
86
+ };
87
+ var FILE_VERSION = 1;
88
+ var APM_DIR = '.apm';
89
+ var APM_LOCK = 'apm.lock.yaml';
90
+ var APM_MODULES = 'apm_modules';
91
+ var SKILLS = 'skills';
92
+ var CACHE_ONLY = "APM's cache is the only copy; scripts do not run there";
93
+ // true for the statuses that leave the exit code at 0; typed so the compiler holds it to exactly the Status union
94
+ var STATUS_SUCCESS = {
95
+ ran: true,
96
+ current: true,
97
+ ok: true,
98
+ skipped: true,
99
+ left: true,
100
+ unapproved: false,
101
+ failed: false,
102
+ missing: false,
103
+ stale: false
104
+ };
105
+ var STATUSES = Object.keys(STATUS_SUCCESS);
106
+ var SUCCESS_STATUSES = STATUSES.filter(function(status) {
107
+ return STATUS_SUCCESS[status];
108
+ });
109
+ var EXIT_OK = 0;
110
+ var EXIT_NOT_OK = 1;
111
+ var EXIT_ERROR = 2;
112
+ var EXIT_INTERRUPTED = 130;
113
+ var NOTHING_INSTALLED = 'nothing installed';
114
+ var NO_PROJECT_LOCK = 'no apm.lock.yaml here: pass -g or a folder';
115
+ /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/open-source/ai/agent-plugin-lifecycle/src/constants.ts"],"sourcesContent":["import type { Status } from './types.ts';\n\n/** The file a plugin or skill ships its scripts in. */\nexport const MANIFEST = 'apl.json';\n/** The one script name `apl` runs. */\nexport const INSTALL = 'install';\n\n/** The per-user folder under the home that holds approvals and run records. */\nexport const APL_DIR = '.apl';\nexport const APPROVALS_FILE = 'approvals.json';\nexport const STATE_FILE = 'state.json';\n/** The lock taken on `~/.apl` while either file changes (a folder `proper-lockfile` creates inside it). */\nexport const LOCK_NAME = 'lock';\n/** Waits for another `apl` holding the lock; each hold is one read-modify-write of a small file. */\nexport const LOCK_RETRIES = { retries: 10, minTimeout: 50, maxTimeout: 500 };\n/** The `version` of the files `apl` writes. */\nexport const FILE_VERSION = 1;\n\nexport const APM_DIR = '.apm';\nexport const APM_LOCK = 'apm.lock.yaml';\nexport const APM_MODULES = 'apm_modules';\n/** The folder of a plugin's skills, and the part of an id for a skill: `skills/<name>`. */\nexport const SKILLS = 'skills';\n/** The reason for a package whose `apl.json` reaches only APM's cache, which APM restores on `apm update`, deleting a script's output. */\nexport const CACHE_ONLY = \"APM's cache is the only copy; scripts do not run there\";\n\n// true for the statuses that leave the exit code at 0; typed so the compiler holds it to exactly the Status union\nconst STATUS_SUCCESS: Record<Status, boolean> = { ran: true, current: true, ok: true, skipped: true, left: true, unapproved: false, failed: false, missing: false, stale: false };\nexport const STATUSES = Object.keys(STATUS_SUCCESS) as Status[];\nexport const SUCCESS_STATUSES = STATUSES.filter((status) => STATUS_SUCCESS[status]);\n\nexport const EXIT_OK = 0;\nexport const EXIT_NOT_OK = 1;\nexport const EXIT_ERROR = 2;\n/** Ctrl+C at the approval question: 128 + SIGINT, as shells report it. */\nexport const EXIT_INTERRUPTED = 130;\n\nexport const NOTHING_INSTALLED = 'nothing installed';\nexport const NO_PROJECT_LOCK = 'no apm.lock.yaml here: pass -g or a folder';\n"],"names":["APL_DIR","APM_DIR","APM_LOCK","APM_MODULES","APPROVALS_FILE","CACHE_ONLY","EXIT_ERROR","EXIT_INTERRUPTED","EXIT_NOT_OK","EXIT_OK","FILE_VERSION","INSTALL","LOCK_NAME","LOCK_RETRIES","MANIFEST","NOTHING_INSTALLED","NO_PROJECT_LOCK","SKILLS","STATE_FILE","STATUSES","SUCCESS_STATUSES","retries","minTimeout","maxTimeout","STATUS_SUCCESS","ran","current","ok","skipped","left","unapproved","failed","missing","stale","Object","keys","filter","status"],"mappings":";;;;;;;;;;;QAQaA;eAAAA;;QAUAC;eAAAA;;QACAC;eAAAA;;QACAC;eAAAA;;QAXAC;eAAAA;;QAeAC;eAAAA;;QASAC;eAAAA;;QAEAC;eAAAA;;QAHAC;eAAAA;;QADAC;eAAAA;;QAfAC;eAAAA;;QAXAC;eAAAA;;QAOAC;eAAAA;;QAEAC;eAAAA;;QAXAC;eAAAA;;QAkCAC;eAAAA;;QACAC;eAAAA;;QAhBAC;eAAAA;;QAZAC;eAAAA;;QAkBAC;eAAAA;;QACAC;eAAAA;;;AA1BN,IAAMN,WAAW;AAEjB,IAAMH,UAAU;AAGhB,IAAMX,UAAU;AAChB,IAAMI,iBAAiB;AACvB,IAAMc,aAAa;AAEnB,IAAMN,YAAY;AAElB,IAAMC,eAAe;IAAEQ,SAAS;IAAIC,YAAY;IAAIC,YAAY;AAAI;AAEpE,IAAMb,eAAe;AAErB,IAAMT,UAAU;AAChB,IAAMC,WAAW;AACjB,IAAMC,cAAc;AAEpB,IAAMc,SAAS;AAEf,IAAMZ,aAAa;AAE1B,kHAAkH;AAClH,IAAMmB,iBAA0C;IAAEC,KAAK;IAAMC,SAAS;IAAMC,IAAI;IAAMC,SAAS;IAAMC,MAAM;IAAMC,YAAY;IAAOC,QAAQ;IAAOC,SAAS;IAAOC,OAAO;AAAM;AACzK,IAAMd,WAAWe,OAAOC,IAAI,CAACX;AAC7B,IAAMJ,mBAAmBD,SAASiB,MAAM,CAAC,SAACC;WAAWb,cAAc,CAACa,OAAO;;AAE3E,IAAM5B,UAAU;AAChB,IAAMD,cAAc;AACpB,IAAMF,aAAa;AAEnB,IAAMC,mBAAmB;AAEzB,IAAMQ,oBAAoB;AAC1B,IAAMC,kBAAkB"}
@@ -0,0 +1,40 @@
1
+ import { type LockedPackage, type Scope } from './apm.js';
2
+ import type { CopyResult } from './types.js';
3
+ /** A folder holding an `apl.json`, the id a person approves, and, when found through APM, the revision APM locked. */
4
+ export interface Copy {
5
+ id: string;
6
+ folder: string;
7
+ /** Where its approval is kept: the real path of the folder holding the lock (project or APM home), or of the named folder. */
8
+ place: string;
9
+ /** The command in `apl.json`; absent when `error` or `skipped` is set. */
10
+ install?: string;
11
+ /** Why the copy's `apl.json` cannot be used. */
12
+ error?: string;
13
+ /** Why the copy is not run and not counted against the exit code: APM's cache is its only copy. */
14
+ skipped?: string;
15
+ revision?: string;
16
+ /** The APM lock file the copy was found through. */
17
+ lock?: string;
18
+ }
19
+ export interface Found {
20
+ copies: Copy[];
21
+ /** Set when the copies came from an APM scope. */
22
+ scope?: Scope;
23
+ /** Every folder the scope's lock names, with or without an `apl.json`. */
24
+ named: Set<string>;
25
+ }
26
+ export interface FindOptions {
27
+ home: string;
28
+ apmHome: string;
29
+ cwd: string;
30
+ global: boolean;
31
+ folders?: string[];
32
+ }
33
+ /** `<host>/<repo>[/<path>]` for a Git package, the absolute source path for a local one. */
34
+ export declare function packageId(item: LockedPackage, manifestRoot: string): string;
35
+ /** The package id, then `:<folder>` when `apl.json` sits below the package root. */
36
+ export declare function copyId(base: string, within: string): string;
37
+ /** The copies of the named folders, or of every package in the scope's APM lock. */
38
+ export declare function findCopies(options: FindOptions): Promise<Found>;
39
+ /** The line for a copy with no command: `skipped` when APM's cache is its only copy, otherwise `failed`. */
40
+ export declare function cannotRun({ id, folder, error, skipped }: Copy): CopyResult;