agent-plugin-lifecycle 0.1.1 → 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.
- package/README.md +256 -57
- package/bin/cli.js +8 -1
- package/dist/cjs/apm.d.cts +62 -13
- package/dist/cjs/apm.d.ts +62 -13
- package/dist/cjs/apm.js +534 -115
- package/dist/cjs/apm.js.map +1 -1
- package/dist/cjs/approvals.d.cts +26 -0
- package/dist/cjs/approvals.d.ts +26 -0
- package/dist/cjs/approvals.js +302 -0
- package/dist/cjs/approvals.js.map +1 -0
- package/dist/cjs/cli/index.d.cts +5 -0
- package/dist/cjs/cli/index.d.ts +5 -0
- package/dist/cjs/cli/index.js +53 -0
- package/dist/cjs/cli/index.js.map +1 -0
- package/dist/cjs/cli/install.d.cts +17 -0
- package/dist/cjs/cli/install.d.ts +17 -0
- package/dist/cjs/cli/install.js +308 -0
- package/dist/cjs/cli/install.js.map +1 -0
- package/dist/cjs/cli/report.d.cts +6 -0
- package/dist/cjs/cli/report.d.ts +6 -0
- package/dist/cjs/cli/report.js +47 -0
- package/dist/cjs/cli/report.js.map +1 -0
- package/dist/cjs/cli/status.d.cts +2 -0
- package/dist/cjs/cli/status.d.ts +2 -0
- package/dist/cjs/cli/status.js +222 -0
- package/dist/cjs/cli/status.js.map +1 -0
- package/dist/cjs/cli/types.d.cts +10 -0
- package/dist/cjs/cli/types.d.ts +10 -0
- package/dist/cjs/cli/types.js +6 -0
- package/dist/cjs/cli/types.js.map +1 -0
- package/dist/cjs/cli/usage.d.cts +2 -0
- package/dist/cjs/cli/usage.d.ts +2 -0
- package/dist/cjs/cli/usage.js +21 -0
- package/dist/cjs/cli/usage.js.map +1 -0
- package/dist/cjs/cli.d.cts +2 -1
- package/dist/cjs/cli.d.ts +2 -1
- package/dist/cjs/cli.js +65 -204
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/constants.d.cts +35 -0
- package/dist/cjs/constants.d.ts +35 -0
- package/dist/cjs/constants.js +115 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/copies.d.cts +40 -0
- package/dist/cjs/copies.d.ts +40 -0
- package/dist/cjs/copies.js +937 -0
- package/dist/cjs/copies.js.map +1 -0
- package/dist/cjs/index.d.cts +3 -6
- package/dist/cjs/index.d.ts +3 -6
- package/dist/cjs/index.js +20 -19
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/install.d.cts +6 -0
- package/dist/cjs/install.d.ts +6 -0
- package/dist/cjs/install.js +511 -0
- package/dist/cjs/install.js.map +1 -0
- package/dist/cjs/lib/errors.d.cts +5 -0
- package/dist/cjs/lib/errors.d.ts +5 -0
- package/dist/cjs/lib/errors.js +41 -0
- package/dist/cjs/lib/errors.js.map +1 -0
- package/dist/cjs/lib/object.d.cts +2 -0
- package/dist/cjs/lib/object.d.ts +2 -0
- package/dist/cjs/lib/object.js +18 -0
- package/dist/cjs/lib/object.js.map +1 -0
- package/dist/cjs/lib/options.d.cts +10 -0
- package/dist/cjs/lib/options.d.ts +10 -0
- package/dist/cjs/lib/options.js +26 -0
- package/dist/cjs/lib/options.js.map +1 -0
- package/dist/cjs/lib/run.d.cts +2 -0
- package/dist/cjs/lib/run.d.ts +2 -0
- package/dist/cjs/lib/run.js +40 -0
- package/dist/cjs/lib/run.js.map +1 -0
- package/dist/cjs/lib/store.d.cts +9 -0
- package/dist/cjs/lib/store.d.ts +9 -0
- package/dist/cjs/lib/store.js +418 -0
- package/dist/cjs/lib/store.js.map +1 -0
- package/dist/cjs/lib/visible.d.cts +9 -0
- package/dist/cjs/lib/visible.d.ts +9 -0
- package/dist/cjs/lib/visible.js +26 -0
- package/dist/cjs/lib/visible.js.map +1 -0
- package/dist/cjs/manifest.d.cts +4 -0
- package/dist/cjs/manifest.d.ts +4 -0
- package/dist/cjs/{config.js → manifest.js} +33 -94
- package/dist/cjs/manifest.js.map +1 -0
- package/dist/cjs/state.d.cts +17 -0
- package/dist/cjs/state.d.ts +17 -0
- package/dist/cjs/state.js +143 -0
- package/dist/cjs/state.js.map +1 -0
- package/dist/cjs/status.d.cts +3 -0
- package/dist/cjs/status.d.ts +3 -0
- package/dist/cjs/status.js +273 -0
- package/dist/cjs/status.js.map +1 -0
- package/dist/cjs/types.d.cts +39 -0
- package/dist/cjs/types.d.ts +39 -0
- package/dist/cjs/types.js +5 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/apm.d.ts +62 -13
- package/dist/esm/apm.js +208 -96
- package/dist/esm/apm.js.map +1 -1
- package/dist/esm/approvals.d.ts +26 -0
- package/dist/esm/approvals.js +43 -0
- package/dist/esm/approvals.js.map +1 -0
- package/dist/esm/cli/index.d.ts +5 -0
- package/dist/esm/cli/index.js +5 -0
- package/dist/esm/cli/index.js.map +1 -0
- package/dist/esm/cli/install.d.ts +17 -0
- package/dist/esm/cli/install.js +89 -0
- package/dist/esm/cli/install.js.map +1 -0
- package/dist/esm/cli/report.d.ts +6 -0
- package/dist/esm/cli/report.js +21 -0
- package/dist/esm/cli/report.js.map +1 -0
- package/dist/esm/cli/status.d.ts +2 -0
- package/dist/esm/cli/status.js +41 -0
- package/dist/esm/cli/status.js.map +1 -0
- package/dist/esm/cli/types.d.ts +10 -0
- package/dist/esm/cli/types.js +2 -0
- package/dist/esm/cli/types.js.map +1 -0
- package/dist/esm/cli/usage.d.ts +2 -0
- package/dist/esm/cli/usage.js +2 -0
- package/dist/esm/cli/usage.js.map +1 -0
- package/dist/esm/cli.d.ts +2 -1
- package/dist/esm/cli.js +46 -65
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/constants.d.ts +35 -0
- package/dist/esm/constants.js +37 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/copies.d.ts +40 -0
- package/dist/esm/copies.js +226 -0
- package/dist/esm/copies.js.map +1 -0
- package/dist/esm/index.d.ts +3 -6
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/install.d.ts +6 -0
- package/dist/esm/install.js +116 -0
- package/dist/esm/install.js.map +1 -0
- package/dist/esm/lib/errors.d.ts +5 -0
- package/dist/esm/lib/errors.js +9 -0
- package/dist/esm/lib/errors.js.map +1 -0
- package/dist/esm/lib/object.d.ts +2 -0
- package/dist/esm/lib/object.js +3 -0
- package/dist/esm/lib/object.js.map +1 -0
- package/dist/esm/lib/options.d.ts +10 -0
- package/dist/esm/lib/options.js +15 -0
- package/dist/esm/lib/options.js.map +1 -0
- package/dist/esm/lib/run.d.ts +2 -0
- package/dist/esm/lib/run.js +29 -0
- package/dist/esm/lib/run.js.map +1 -0
- package/dist/esm/lib/store.d.ts +9 -0
- package/dist/esm/lib/store.js +91 -0
- package/dist/esm/lib/store.js.map +1 -0
- package/dist/esm/lib/visible.d.ts +9 -0
- package/dist/esm/lib/visible.js +12 -0
- package/dist/esm/lib/visible.js.map +1 -0
- package/dist/esm/manifest.d.ts +4 -0
- package/dist/esm/manifest.js +25 -0
- package/dist/esm/manifest.js.map +1 -0
- package/dist/esm/state.d.ts +17 -0
- package/dist/esm/state.js +32 -0
- package/dist/esm/state.js.map +1 -0
- package/dist/esm/status.d.ts +3 -0
- package/dist/esm/status.js +44 -0
- package/dist/esm/status.js.map +1 -0
- package/dist/esm/types.d.ts +39 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/types.js.map +1 -0
- package/package.json +25 -9
- package/config/config.example.json +0 -22
- package/dist/cjs/config.d.cts +0 -16
- package/dist/cjs/config.d.ts +0 -16
- package/dist/cjs/config.js.map +0 -1
- package/dist/cjs/runner.d.cts +0 -19
- package/dist/cjs/runner.d.ts +0 -19
- package/dist/cjs/runner.js +0 -1157
- package/dist/cjs/runner.js.map +0 -1
- package/dist/esm/config.d.ts +0 -16
- package/dist/esm/config.js +0 -74
- package/dist/esm/config.js.map +0 -1
- package/dist/esm/runner.d.ts +0 -19
- package/dist/esm/runner.js +0 -248
- package/dist/esm/runner.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/open-source/ai/agent-plugin-lifecycle/src/cli/install.ts"],"sourcesContent":["import { createInterface } from 'node:readline/promises';\nimport { parseArgs } from 'node:util';\nimport { EXIT_INTERRUPTED } from '../constants.ts';\nimport { install } from '../install.ts';\nimport { message } from '../lib/errors.ts';\nimport { visible } from '../lib/visible.ts';\nimport type { ApprovalRequest } from '../types.ts';\nimport { print, summarize } from './report.ts';\nimport type { Ctx } from './types.ts';\nimport { INSTALL_USAGE as USAGE } from './usage.ts';\n\nconst parse = (args: string[]) => parseArgs({ args, allowPositionals: true, options: { global: { type: 'boolean', short: 'g' }, yes: { type: 'boolean', short: 'y' }, help: { type: 'boolean', short: 'h' } } });\n\n/** What the question prints before the prompt. */\nexport function requestText(request: ApprovalRequest): string {\n return `${visible(request.id)} wants to run\\n install: ${visible(request.scripts.install)}\\nin\\n${request.folders.map((folder) => ` ${visible(folder)}\\n`).join('')}`;\n}\nexport const PROMPT = 'Run it? [y/N] ';\n\nexport interface QuestionStreams {\n input: NodeJS.ReadableStream;\n output: NodeJS.WritableStream;\n /** Called on Ctrl+C at the question; the CLI exits 130 there, before any approval is saved or any script runs. */\n interrupt: () => void;\n}\n/**\n * The approval question as an `approve` function, with a readline interface per question so the terminal is normal again while scripts\n * run. `y` or `yes` approves; anything else, or end of input (Ctrl+D), answers no.\n */\nexport function questioner({ input, output, interrupt }: QuestionStreams): (request: ApprovalRequest) => Promise<boolean> {\n return async (request) => {\n output.write(requestText(request));\n const terminal = createInterface({ input, output });\n terminal.on('SIGINT', () => {\n output.write('\\n');\n interrupt();\n });\n try {\n // a pending question does not always settle when input ends, so the interface closing answers it first\n const answer = await new Promise<string | undefined>((resolve, reject) => {\n terminal.on('close', () => resolve(undefined));\n terminal.question(PROMPT).then(resolve, reject);\n });\n if (answer === undefined) output.write('\\n');\n return answer !== undefined && ['y', 'yes'].includes(answer.trim().toLowerCase());\n } finally {\n terminal.close();\n }\n };\n}\n\nexport default async function installCommand(ctx: Ctx): Promise<number> {\n let parsed: ReturnType<typeof parse>;\n try {\n parsed = parse(ctx.rest);\n } catch (error) {\n return ctx.usageError(`${visible(message(error))}\\nusage: ${ctx.name} ${USAGE}`);\n }\n const { values, positionals } = parsed;\n if (values.help) {\n console.log(`usage: ${ctx.name} ${USAGE}\\n\\nRuns the install script in each copy, asking before any that is not approved.\\n -g, --global the user scope (~/.apm) instead of the project here\\n -y, --yes approve every unapproved script without asking`);\n return 0;\n }\n if (values.global && positionals.length) return ctx.usageError(`-g cannot be combined with folders\\nusage: ${ctx.name} ${USAGE}`);\n // the question needs a terminal on both standard input and output; without one, unapproved copies are only reported\n const ask = questioner({ input: process.stdin, output: process.stdout, interrupt: () => process.exit(EXIT_INTERRUPTED) });\n const approve = values.yes ? async () => true : process.stdin.isTTY && process.stdout.isTTY ? ask : undefined;\n // each line is printed as its result is known, so a run killed part-way shows what finished\n return summarize(await install({ global: values.global, folders: positionals, apmHome: process.env.APM_HOME || undefined, approve, onResult: print }));\n}\n"],"names":["createInterface","parseArgs","EXIT_INTERRUPTED","install","message","visible","print","summarize","INSTALL_USAGE","USAGE","parse","args","allowPositionals","options","global","type","short","yes","help","requestText","request","id","scripts","folders","map","folder","join","PROMPT","questioner","input","output","interrupt","write","terminal","on","answer","Promise","resolve","reject","undefined","question","then","includes","trim","toLowerCase","close","installCommand","ctx","parsed","rest","error","usageError","name","values","positionals","console","log","length","ask","process","stdin","stdout","exit","approve","isTTY","apmHome","env","APM_HOME","onResult"],"mappings":"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"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CopyResult } from '../types.js';
|
|
2
|
+
/** One result line, escaped as the question is; the id and folder have no space or are JSON strings, and the reason, last, may hold spaces. */
|
|
3
|
+
export declare function line(result: CopyResult): string;
|
|
4
|
+
export declare function print(result: CopyResult): void;
|
|
5
|
+
/** Prints `nothing installed` when no copy was found, and returns the exit code. */
|
|
6
|
+
export declare function summarize(results: CopyResult[]): number;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { EXIT_NOT_OK, EXIT_OK, NOTHING_INSTALLED, SUCCESS_STATUSES } from '../constants.js';
|
|
2
|
+
import { visible } from '../lib/visible.js';
|
|
3
|
+
/** One result line, escaped as the question is; the id and folder have no space or are JSON strings, and the reason, last, may hold spaces. */ export function line(result) {
|
|
4
|
+
var _result_id, _result_reason;
|
|
5
|
+
const folder = visible(result.folder, {
|
|
6
|
+
field: true
|
|
7
|
+
});
|
|
8
|
+
if (result.status === 'left') return `left ${folder}`;
|
|
9
|
+
const id = visible((_result_id = result.id) !== null && _result_id !== void 0 ? _result_id : '', {
|
|
10
|
+
field: true
|
|
11
|
+
});
|
|
12
|
+
if (result.status === 'failed' || result.status === 'skipped') return `${result.status} ${id} ${folder}: ${visible((_result_reason = result.reason) !== null && _result_reason !== void 0 ? _result_reason : '')}`;
|
|
13
|
+
return `${result.status} ${id} ${folder}`;
|
|
14
|
+
}
|
|
15
|
+
export function print(result) {
|
|
16
|
+
console.log(line(result));
|
|
17
|
+
}
|
|
18
|
+
/** Prints `nothing installed` when no copy was found, and returns the exit code. */ export function summarize(results) {
|
|
19
|
+
if (!results.some((result)=>result.status !== 'left')) console.log(NOTHING_INSTALLED);
|
|
20
|
+
return results.every((result)=>SUCCESS_STATUSES.includes(result.status)) ? EXIT_OK : EXIT_NOT_OK;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/open-source/ai/agent-plugin-lifecycle/src/cli/report.ts"],"sourcesContent":["import { EXIT_NOT_OK, EXIT_OK, NOTHING_INSTALLED, SUCCESS_STATUSES } from '../constants.ts';\nimport { visible } from '../lib/visible.ts';\nimport type { CopyResult } from '../types.ts';\n\n/** One result line, escaped as the question is; the id and folder have no space or are JSON strings, and the reason, last, may hold spaces. */\nexport function line(result: CopyResult): string {\n const folder = visible(result.folder, { field: true });\n if (result.status === 'left') return `left ${folder}`;\n const id = visible(result.id ?? '', { field: true });\n if (result.status === 'failed' || result.status === 'skipped') return `${result.status} ${id} ${folder}: ${visible(result.reason ?? '')}`;\n return `${result.status} ${id} ${folder}`;\n}\n\nexport function print(result: CopyResult): void {\n console.log(line(result));\n}\n\n/** Prints `nothing installed` when no copy was found, and returns the exit code. */\nexport function summarize(results: CopyResult[]): number {\n if (!results.some((result) => result.status !== 'left')) console.log(NOTHING_INSTALLED);\n return results.every((result) => SUCCESS_STATUSES.includes(result.status)) ? EXIT_OK : EXIT_NOT_OK;\n}\n"],"names":["EXIT_NOT_OK","EXIT_OK","NOTHING_INSTALLED","SUCCESS_STATUSES","visible","line","result","folder","field","status","id","reason","print","console","log","summarize","results","some","every","includes"],"mappings":"AAAA,SAASA,WAAW,EAAEC,OAAO,EAAEC,iBAAiB,EAAEC,gBAAgB,QAAQ,kBAAkB;AAC5F,SAASC,OAAO,QAAQ,oBAAoB;AAG5C,6IAA6I,GAC7I,OAAO,SAASC,KAAKC,MAAkB;QAGlBA,YACgGA;IAHnH,MAAMC,SAASH,QAAQE,OAAOC,MAAM,EAAE;QAAEC,OAAO;IAAK;IACpD,IAAIF,OAAOG,MAAM,KAAK,QAAQ,OAAO,CAAC,KAAK,EAAEF,QAAQ;IACrD,MAAMG,KAAKN,SAAQE,aAAAA,OAAOI,EAAE,cAATJ,wBAAAA,aAAa,IAAI;QAAEE,OAAO;IAAK;IAClD,IAAIF,OAAOG,MAAM,KAAK,YAAYH,OAAOG,MAAM,KAAK,WAAW,OAAO,GAAGH,OAAOG,MAAM,CAAC,CAAC,EAAEC,GAAG,CAAC,EAAEH,OAAO,EAAE,EAAEH,SAAQE,iBAAAA,OAAOK,MAAM,cAAbL,4BAAAA,iBAAiB,KAAK;IACzI,OAAO,GAAGA,OAAOG,MAAM,CAAC,CAAC,EAAEC,GAAG,CAAC,EAAEH,QAAQ;AAC3C;AAEA,OAAO,SAASK,MAAMN,MAAkB;IACtCO,QAAQC,GAAG,CAACT,KAAKC;AACnB;AAEA,kFAAkF,GAClF,OAAO,SAASS,UAAUC,OAAqB;IAC7C,IAAI,CAACA,QAAQC,IAAI,CAAC,CAACX,SAAWA,OAAOG,MAAM,KAAK,SAASI,QAAQC,GAAG,CAACZ;IACrE,OAAOc,QAAQE,KAAK,CAAC,CAACZ,SAAWH,iBAAiBgB,QAAQ,CAACb,OAAOG,MAAM,KAAKR,UAAUD;AACzF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { parseArgs } from 'node:util';
|
|
2
|
+
import { message } from '../lib/errors.js';
|
|
3
|
+
import { visible } from '../lib/visible.js';
|
|
4
|
+
import { status } from '../status.js';
|
|
5
|
+
import { print, summarize } from './report.js';
|
|
6
|
+
import { STATUS_USAGE as USAGE } from './usage.js';
|
|
7
|
+
const parse = (args)=>parseArgs({
|
|
8
|
+
args,
|
|
9
|
+
allowPositionals: true,
|
|
10
|
+
options: {
|
|
11
|
+
global: {
|
|
12
|
+
type: 'boolean',
|
|
13
|
+
short: 'g'
|
|
14
|
+
},
|
|
15
|
+
help: {
|
|
16
|
+
type: 'boolean',
|
|
17
|
+
short: 'h'
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
export default async function statusCommand(ctx) {
|
|
22
|
+
let parsed;
|
|
23
|
+
try {
|
|
24
|
+
parsed = parse(ctx.rest);
|
|
25
|
+
} catch (error) {
|
|
26
|
+
return ctx.usageError(`${visible(message(error))}\nusage: ${ctx.name} ${USAGE}`);
|
|
27
|
+
}
|
|
28
|
+
const { values, positionals } = parsed;
|
|
29
|
+
if (values.help) {
|
|
30
|
+
console.log(`usage: ${ctx.name} ${USAGE}\n\nReports each copy and changes nothing; exits 1 unless every copy is ok.\n -g, --global the user scope (~/.apm) instead of the project here`);
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
|
33
|
+
if (values.global && positionals.length) return ctx.usageError(`-g cannot be combined with folders\nusage: ${ctx.name} ${USAGE}`);
|
|
34
|
+
const results = await status({
|
|
35
|
+
global: values.global,
|
|
36
|
+
folders: positionals,
|
|
37
|
+
apmHome: process.env.APM_HOME || undefined
|
|
38
|
+
});
|
|
39
|
+
for (const result of results)print(result);
|
|
40
|
+
return summarize(results);
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/open-source/ai/agent-plugin-lifecycle/src/cli/status.ts"],"sourcesContent":["import { parseArgs } from 'node:util';\nimport { message } from '../lib/errors.ts';\nimport { visible } from '../lib/visible.ts';\nimport { status } from '../status.ts';\nimport { print, summarize } from './report.ts';\nimport type { Ctx } from './types.ts';\nimport { STATUS_USAGE as USAGE } from './usage.ts';\n\nconst parse = (args: string[]) => parseArgs({ args, allowPositionals: true, options: { global: { type: 'boolean', short: 'g' }, help: { type: 'boolean', short: 'h' } } });\n\nexport default async function statusCommand(ctx: Ctx): Promise<number> {\n let parsed: ReturnType<typeof parse>;\n try {\n parsed = parse(ctx.rest);\n } catch (error) {\n return ctx.usageError(`${visible(message(error))}\\nusage: ${ctx.name} ${USAGE}`);\n }\n const { values, positionals } = parsed;\n if (values.help) {\n console.log(`usage: ${ctx.name} ${USAGE}\\n\\nReports each copy and changes nothing; exits 1 unless every copy is ok.\\n -g, --global the user scope (~/.apm) instead of the project here`);\n return 0;\n }\n if (values.global && positionals.length) return ctx.usageError(`-g cannot be combined with folders\\nusage: ${ctx.name} ${USAGE}`);\n const results = await status({ global: values.global, folders: positionals, apmHome: process.env.APM_HOME || undefined });\n for (const result of results) print(result);\n return summarize(results);\n}\n"],"names":["parseArgs","message","visible","status","print","summarize","STATUS_USAGE","USAGE","parse","args","allowPositionals","options","global","type","short","help","statusCommand","ctx","parsed","rest","error","usageError","name","values","positionals","console","log","length","results","folders","apmHome","process","env","APM_HOME","undefined","result"],"mappings":"AAAA,SAASA,SAAS,QAAQ,YAAY;AACtC,SAASC,OAAO,QAAQ,mBAAmB;AAC3C,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,MAAM,QAAQ,eAAe;AACtC,SAASC,KAAK,EAAEC,SAAS,QAAQ,cAAc;AAE/C,SAASC,gBAAgBC,KAAK,QAAQ,aAAa;AAEnD,MAAMC,QAAQ,CAACC,OAAmBT,UAAU;QAAES;QAAMC,kBAAkB;QAAMC,SAAS;YAAEC,QAAQ;gBAAEC,MAAM;gBAAWC,OAAO;YAAI;YAAGC,MAAM;gBAAEF,MAAM;gBAAWC,OAAO;YAAI;QAAE;IAAE;AAExK,eAAe,eAAeE,cAAcC,GAAQ;IAClD,IAAIC;IACJ,IAAI;QACFA,SAASV,MAAMS,IAAIE,IAAI;IACzB,EAAE,OAAOC,OAAO;QACd,OAAOH,IAAII,UAAU,CAAC,GAAGnB,QAAQD,QAAQmB,QAAQ,SAAS,EAAEH,IAAIK,IAAI,CAAC,CAAC,EAAEf,OAAO;IACjF;IACA,MAAM,EAAEgB,MAAM,EAAEC,WAAW,EAAE,GAAGN;IAChC,IAAIK,OAAOR,IAAI,EAAE;QACfU,QAAQC,GAAG,CAAC,CAAC,OAAO,EAAET,IAAIK,IAAI,CAAC,CAAC,EAAEf,MAAM,gJAAgJ,CAAC;QACzL,OAAO;IACT;IACA,IAAIgB,OAAOX,MAAM,IAAIY,YAAYG,MAAM,EAAE,OAAOV,IAAII,UAAU,CAAC,CAAC,2CAA2C,EAAEJ,IAAIK,IAAI,CAAC,CAAC,EAAEf,OAAO;IAChI,MAAMqB,UAAU,MAAMzB,OAAO;QAAES,QAAQW,OAAOX,MAAM;QAAEiB,SAASL;QAAaM,SAASC,QAAQC,GAAG,CAACC,QAAQ,IAAIC;IAAU;IACvH,KAAK,MAAMC,UAAUP,QAASxB,MAAM+B;IACpC,OAAO9B,UAAUuB;AACnB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface Ctx {
|
|
2
|
+
/** binary name, for usage strings */
|
|
3
|
+
name: string;
|
|
4
|
+
/** argv after the command word */
|
|
5
|
+
rest: string[];
|
|
6
|
+
/** Print the message to standard error and exit 2. Readonly property syntax, so TypeScript treats the call as never returning. */
|
|
7
|
+
readonly usageError: (message: string) => never;
|
|
8
|
+
}
|
|
9
|
+
/** Resolves to the exit code. */
|
|
10
|
+
export type Command = (ctx: Ctx) => Promise<number>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/open-source/ai/agent-plugin-lifecycle/src/cli/types.ts"],"sourcesContent":["// Handed to every command; the command word is peeled off in src/cli.ts and each command parses its own flags from `rest`.\nexport interface Ctx {\n /** binary name, for usage strings */\n name: string;\n /** argv after the command word */\n rest: string[];\n /** Print the message to standard error and exit 2. Readonly property syntax, so TypeScript treats the call as never returning. */\n readonly usageError: (message: string) => never;\n}\n\n/** Resolves to the exit code. */\nexport type Command = (ctx: Ctx) => Promise<number>;\n"],"names":[],"mappings":"AAAA,2HAA2H;AAU3H,+BAA+B,GAC/B,WAAoD"}
|
|
@@ -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":"AAAA,OAAO,MAAMA,gBAAgB,gCAAgC;AAC7D,OAAO,MAAMC,eAAe,0BAA0B"}
|
package/dist/esm/cli.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
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/esm/cli.js
CHANGED
|
@@ -1,70 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
// Parsing and dispatch only. Commands live in src/cli/, one file each, lazy-loaded.
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { COMMANDS } from './cli/index.js';
|
|
6
|
+
import { INSTALL_USAGE, STATUS_USAGE } from './cli/usage.js';
|
|
7
|
+
import { EXIT_ERROR } from './constants.js';
|
|
8
|
+
import { message } from './lib/errors.js';
|
|
9
|
+
import { visible } from './lib/visible.js';
|
|
10
|
+
// __dirname (CJS) or its ESM equivalent; dist/<format>/cli.js is two hops below the package root
|
|
11
|
+
const __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : fileURLToPath(import.meta.url));
|
|
12
|
+
function packageVersion() {
|
|
13
|
+
const pkg = JSON.parse(readFileSync(path.resolve(__dirname, '..', '..', 'package.json'), 'utf8'));
|
|
14
|
+
return pkg.version;
|
|
15
|
+
}
|
|
16
|
+
function usage(name) {
|
|
17
|
+
return `usage: ${name} ${INSTALL_USAGE} run install scripts, asking before any that are not approved
|
|
18
|
+
${name} ${STATUS_USAGE} report each copy; exit 1 unless every copy is ok
|
|
19
|
+
${name} --help | -h
|
|
20
|
+
${name} --version | -v
|
|
9
21
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
for await (const chunk of process.stdin){
|
|
17
|
-
payload += chunk.toString();
|
|
18
|
-
if (payload.length > 1024 * 1024) throw new Error('APM event exceeds 1 MiB');
|
|
19
|
-
}
|
|
20
|
-
if (!payload.trim()) throw new Error('run requires an APM event on stdin');
|
|
21
|
-
const event = JSON.parse(payload);
|
|
22
|
-
if (!event || typeof event !== 'object' || Array.isArray(event)) throw new Error('APM event must be an object');
|
|
23
|
-
const value = event;
|
|
24
|
-
if (value.schema_version !== 1 || ![
|
|
25
|
-
'post-install',
|
|
26
|
-
'post-update',
|
|
27
|
-
'post-uninstall'
|
|
28
|
-
].includes(String(value.event)) || ![
|
|
29
|
-
'user',
|
|
30
|
-
'project'
|
|
31
|
-
].includes(String(value.scope)) || !Array.isArray(value.packages) || !value.packages.every((p)=>p && typeof p === 'object' && typeof p.name === 'string' && (p.reference === null || typeof p.reference === 'string'))) {
|
|
32
|
-
throw new Error('unsupported APM lifecycle event');
|
|
33
|
-
}
|
|
34
|
-
return value;
|
|
22
|
+
With 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.
|
|
23
|
+
Approvals and run records: ~/.apl/`;
|
|
24
|
+
}
|
|
25
|
+
/** Prints apl's own text, with any untrusted part already escaped, and exits 2. */ function fail(text) {
|
|
26
|
+
console.error(text);
|
|
27
|
+
process.exit(EXIT_ERROR);
|
|
35
28
|
}
|
|
36
|
-
async function
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
},
|
|
45
|
-
allowPositionals: true
|
|
46
|
-
});
|
|
47
|
-
if (values.help || positionals.length === 0) {
|
|
48
|
-
process.stdout.write(HELP);
|
|
49
|
-
return 0;
|
|
29
|
+
/** Runs the CLI; sets `process.exitCode` to 0, 1 (a copy is not ok) or 2 (apl could not do its work). */ export default async function cli(argv, name) {
|
|
30
|
+
if (argv[0] === '--version' || argv[0] === '-v') {
|
|
31
|
+
console.log(packageVersion());
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (argv[0] === '--help' || argv[0] === '-h') {
|
|
35
|
+
console.log(usage(name));
|
|
36
|
+
return;
|
|
50
37
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
38
|
+
const load = COMMANDS[argv[0]];
|
|
39
|
+
if (!load) fail(`${argv.length ? `unknown command: ${visible(argv[0])}\n` : ''}${usage(name)}`);
|
|
40
|
+
const ctx = {
|
|
41
|
+
name,
|
|
42
|
+
rest: argv.slice(1),
|
|
43
|
+
usageError: fail
|
|
44
|
+
};
|
|
45
|
+
try {
|
|
46
|
+
process.exitCode = await (await load()).default(ctx);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
// 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
|
|
49
|
+
fail(`${name}: ${visible(message(error))}`);
|
|
59
50
|
}
|
|
60
|
-
return runLifecycle(positionals[0], {
|
|
61
|
-
apmHome: process.env.APM_HOME,
|
|
62
|
-
event
|
|
63
|
-
});
|
|
64
51
|
}
|
|
65
|
-
main().then((status)=>{
|
|
66
|
-
process.exitCode = status;
|
|
67
|
-
}).catch((error)=>{
|
|
68
|
-
console.error(`agent-plugin-lifecycle: ${error instanceof Error ? error.message : String(error)}`);
|
|
69
|
-
process.exitCode = 2;
|
|
70
|
-
});
|
package/dist/esm/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/open-source/ai/agent-plugin-lifecycle/src/cli.ts"],"sourcesContent":["
|
|
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":["readFileSync","path","fileURLToPath","COMMANDS","INSTALL_USAGE","STATUS_USAGE","EXIT_ERROR","message","visible","__dirname","dirname","__filename","url","packageVersion","pkg","JSON","parse","resolve","version","usage","name","fail","text","console","error","process","exit","cli","argv","log","load","length","ctx","rest","slice","usageError","exitCode","default"],"mappings":"AAAA,oFAAoF;AACpF,SAASA,YAAY,QAAQ,UAAU;AACvC,OAAOC,UAAU,YAAY;AAC7B,SAASC,aAAa,QAAQ,WAAW;AACzC,SAASC,QAAQ,QAAQ,iBAAiB;AAE1C,SAASC,aAAa,EAAEC,YAAY,QAAQ,iBAAiB;AAC7D,SAASC,UAAU,QAAQ,iBAAiB;AAC5C,SAASC,OAAO,QAAQ,kBAAkB;AAC1C,SAASC,OAAO,QAAQ,mBAAmB;AAE3C,iGAAiG;AACjG,MAAMC,YAAYR,KAAKS,OAAO,CAAC,OAAOC,eAAe,cAAcA,aAAaT,cAAc,YAAYU,GAAG;AAE7G,SAASC;IACP,MAAMC,MAAMC,KAAKC,KAAK,CAAChB,aAAaC,KAAKgB,OAAO,CAACR,WAAW,MAAM,MAAM,iBAAiB;IACzF,OAAOK,IAAII,OAAO;AACpB;AAEA,SAASC,MAAMC,IAAY;IACzB,OAAO,CAAC,OAAO,EAAEA,KAAK,CAAC,EAAEhB,cAAc;OAClC,EAAEgB,KAAK,CAAC,EAAEf,aAAa;OACvB,EAAEe,KAAK;OACP,EAAEA,KAAK;;;kCAGoB,CAAC;AACnC;AAEA,iFAAiF,GACjF,SAASC,KAAKC,IAAY;IACxBC,QAAQC,KAAK,CAACF;IACdG,QAAQC,IAAI,CAACpB;AACf;AAEA,uGAAuG,GACvG,eAAe,eAAeqB,IAAIC,IAAc,EAAER,IAAY;IAC5D,IAAIQ,IAAI,CAAC,EAAE,KAAK,eAAeA,IAAI,CAAC,EAAE,KAAK,MAAM;QAC/CL,QAAQM,GAAG,CAAChB;QACZ;IACF;IACA,IAAIe,IAAI,CAAC,EAAE,KAAK,YAAYA,IAAI,CAAC,EAAE,KAAK,MAAM;QAC5CL,QAAQM,GAAG,CAACV,MAAMC;QAClB;IACF;IACA,MAAMU,OAAO3B,QAAQ,CAACyB,IAAI,CAAC,EAAE,CAAC;IAC9B,IAAI,CAACE,MAAMT,KAAK,GAAGO,KAAKG,MAAM,GAAG,CAAC,iBAAiB,EAAEvB,QAAQoB,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,KAAKT,MAAMC,OAAO;IAC9F,MAAMY,MAAW;QAAEZ;QAAMa,MAAML,KAAKM,KAAK,CAAC;QAAIC,YAAYd;IAAK;IAC/D,IAAI;QACFI,QAAQW,QAAQ,GAAG,MAAM,AAAC,CAAA,MAAMN,MAAK,EAAGO,OAAO,CAACL;IAClD,EAAE,OAAOR,OAAO;QACd,6HAA6H;QAC7HH,KAAK,GAAGD,KAAK,EAAE,EAAEZ,QAAQD,QAAQiB,SAAS;IAC5C;AACF"}
|
|
@@ -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,37 @@
|
|
|
1
|
+
/** The file a plugin or skill ships its scripts in. */ export const MANIFEST = 'apl.json';
|
|
2
|
+
/** The one script name `apl` runs. */ export const INSTALL = 'install';
|
|
3
|
+
/** The per-user folder under the home that holds approvals and run records. */ export const APL_DIR = '.apl';
|
|
4
|
+
export const APPROVALS_FILE = 'approvals.json';
|
|
5
|
+
export const STATE_FILE = 'state.json';
|
|
6
|
+
/** The lock taken on `~/.apl` while either file changes (a folder `proper-lockfile` creates inside it). */ export const LOCK_NAME = 'lock';
|
|
7
|
+
/** Waits for another `apl` holding the lock; each hold is one read-modify-write of a small file. */ export const LOCK_RETRIES = {
|
|
8
|
+
retries: 10,
|
|
9
|
+
minTimeout: 50,
|
|
10
|
+
maxTimeout: 500
|
|
11
|
+
};
|
|
12
|
+
/** The `version` of the files `apl` writes. */ export const FILE_VERSION = 1;
|
|
13
|
+
export const APM_DIR = '.apm';
|
|
14
|
+
export const APM_LOCK = 'apm.lock.yaml';
|
|
15
|
+
export const APM_MODULES = 'apm_modules';
|
|
16
|
+
/** The folder of a plugin's skills, and the part of an id for a skill: `skills/<name>`. */ export const SKILLS = 'skills';
|
|
17
|
+
/** The reason for a package whose `apl.json` reaches only APM's cache, which APM restores on `apm update`, deleting a script's output. */ export const CACHE_ONLY = "APM's cache is the only copy; scripts do not run there";
|
|
18
|
+
// true for the statuses that leave the exit code at 0; typed so the compiler holds it to exactly the Status union
|
|
19
|
+
const STATUS_SUCCESS = {
|
|
20
|
+
ran: true,
|
|
21
|
+
current: true,
|
|
22
|
+
ok: true,
|
|
23
|
+
skipped: true,
|
|
24
|
+
left: true,
|
|
25
|
+
unapproved: false,
|
|
26
|
+
failed: false,
|
|
27
|
+
missing: false,
|
|
28
|
+
stale: false
|
|
29
|
+
};
|
|
30
|
+
export const STATUSES = Object.keys(STATUS_SUCCESS);
|
|
31
|
+
export const SUCCESS_STATUSES = STATUSES.filter((status)=>STATUS_SUCCESS[status]);
|
|
32
|
+
export const EXIT_OK = 0;
|
|
33
|
+
export const EXIT_NOT_OK = 1;
|
|
34
|
+
export const EXIT_ERROR = 2;
|
|
35
|
+
/** Ctrl+C at the approval question: 128 + SIGINT, as shells report it. */ export const EXIT_INTERRUPTED = 130;
|
|
36
|
+
export const NOTHING_INSTALLED = 'nothing installed';
|
|
37
|
+
export const NO_PROJECT_LOCK = 'no apm.lock.yaml here: pass -g or a folder';
|
|
@@ -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":["MANIFEST","INSTALL","APL_DIR","APPROVALS_FILE","STATE_FILE","LOCK_NAME","LOCK_RETRIES","retries","minTimeout","maxTimeout","FILE_VERSION","APM_DIR","APM_LOCK","APM_MODULES","SKILLS","CACHE_ONLY","STATUS_SUCCESS","ran","current","ok","skipped","left","unapproved","failed","missing","stale","STATUSES","Object","keys","SUCCESS_STATUSES","filter","status","EXIT_OK","EXIT_NOT_OK","EXIT_ERROR","EXIT_INTERRUPTED","NOTHING_INSTALLED","NO_PROJECT_LOCK"],"mappings":"AAEA,qDAAqD,GACrD,OAAO,MAAMA,WAAW,WAAW;AACnC,oCAAoC,GACpC,OAAO,MAAMC,UAAU,UAAU;AAEjC,6EAA6E,GAC7E,OAAO,MAAMC,UAAU,OAAO;AAC9B,OAAO,MAAMC,iBAAiB,iBAAiB;AAC/C,OAAO,MAAMC,aAAa,aAAa;AACvC,yGAAyG,GACzG,OAAO,MAAMC,YAAY,OAAO;AAChC,kGAAkG,GAClG,OAAO,MAAMC,eAAe;IAAEC,SAAS;IAAIC,YAAY;IAAIC,YAAY;AAAI,EAAE;AAC7E,6CAA6C,GAC7C,OAAO,MAAMC,eAAe,EAAE;AAE9B,OAAO,MAAMC,UAAU,OAAO;AAC9B,OAAO,MAAMC,WAAW,gBAAgB;AACxC,OAAO,MAAMC,cAAc,cAAc;AACzC,yFAAyF,GACzF,OAAO,MAAMC,SAAS,SAAS;AAC/B,wIAAwI,GACxI,OAAO,MAAMC,aAAa,yDAAyD;AAEnF,kHAAkH;AAClH,MAAMC,iBAA0C;IAAEC,KAAK;IAAMC,SAAS;IAAMC,IAAI;IAAMC,SAAS;IAAMC,MAAM;IAAMC,YAAY;IAAOC,QAAQ;IAAOC,SAAS;IAAOC,OAAO;AAAM;AAChL,OAAO,MAAMC,WAAWC,OAAOC,IAAI,CAACZ,gBAA4B;AAChE,OAAO,MAAMa,mBAAmBH,SAASI,MAAM,CAAC,CAACC,SAAWf,cAAc,CAACe,OAAO,EAAE;AAEpF,OAAO,MAAMC,UAAU,EAAE;AACzB,OAAO,MAAMC,cAAc,EAAE;AAC7B,OAAO,MAAMC,aAAa,EAAE;AAC5B,wEAAwE,GACxE,OAAO,MAAMC,mBAAmB,IAAI;AAEpC,OAAO,MAAMC,oBAAoB,oBAAoB;AACrD,OAAO,MAAMC,kBAAkB,6CAA6C"}
|
|
@@ -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;
|