install-agent-plugin 0.0.0-stage → 0.4.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 +54 -2
- package/dist/cli.d.ts +61 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +554 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin-loader.d.ts +3 -0
- package/dist/plugin-loader.d.ts.map +1 -0
- package/dist/plugin-loader.js +42 -0
- package/dist/plugin-loader.js.map +1 -0
- package/package.json +51 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OIAP contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,55 @@
|
|
|
1
|
-
#
|
|
1
|
+
# install-agent-plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Executable CLI for discovering OIAP plugin declarations in a repository.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npx install-agent-plugin owner/repo --list
|
|
7
|
+
npx install-agent-plugin owner/repo --plugin review-guard --agent claude-code
|
|
8
|
+
npx install-agent-plugin owner/repo --plugin review-guard --agent claude-code --global
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
The CLI discovers `definePlugin(...)` calls directly from TypeScript and
|
|
12
|
+
JavaScript source files through `@oiap/core`; it does not require a separate JSON
|
|
13
|
+
declaration file.
|
|
14
|
+
|
|
15
|
+
Before loading the selected plugin declaration, the installer installs source
|
|
16
|
+
dependencies when it clones a repository or when a local checkout has a
|
|
17
|
+
`package.json` but no `node_modules`. Lockfiles are used to choose Bun, pnpm,
|
|
18
|
+
Yarn, or npm; lifecycle scripts are ignored unless you pass
|
|
19
|
+
`--allow-install-scripts`. Use `--no-install-deps` to disable dependency
|
|
20
|
+
installation.
|
|
21
|
+
|
|
22
|
+
When the exported bundle contains the generated OIAP hook runtime, the installer
|
|
23
|
+
bundles hook handler modules from the original plugin source. Hook code can use
|
|
24
|
+
normal TypeScript or JavaScript imports, top-level constants, and local helpers;
|
|
25
|
+
the generated `.oiap/runtime/hooks.mjs` is rewritten as a self-contained Node ESM
|
|
26
|
+
module for the selected plugin.
|
|
27
|
+
|
|
28
|
+
This package does not expose a library API. If you want to provide the
|
|
29
|
+
installation of the plugin using your own CLI, import `installPlugin()` from
|
|
30
|
+
`@oiap/core`, shape the CLI however you want, and pass the selected plugin
|
|
31
|
+
declaration and target id to that function:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
#!/usr/bin/env node
|
|
35
|
+
import { installPlugin } from "@oiap/core";
|
|
36
|
+
import plugin from "./oiap.plugin";
|
|
37
|
+
|
|
38
|
+
await installPlugin({
|
|
39
|
+
plugin,
|
|
40
|
+
target: "codex",
|
|
41
|
+
scope: process.argv.includes("--global") ? "global" : "local",
|
|
42
|
+
overwrite: true,
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
If your own CLI only supports a subset of targets, include the exporter packages
|
|
47
|
+
for those targets in that CLI package's runtime dependencies.
|
|
48
|
+
|
|
49
|
+
The default scope is local/project installation. Use `--global` for the target's
|
|
50
|
+
user-level path when the selected target defines one. Install paths are
|
|
51
|
+
inherited from the selected target profile. Pass `--out <dir>` when you want to
|
|
52
|
+
materialize a bundle in an explicit directory for review or debugging, or when
|
|
53
|
+
the selected target only defines a local convention. For example,
|
|
54
|
+
`vscode-copilot-chat` installs locally under `.github/plugins/<pluginId>` but
|
|
55
|
+
does not define a profile-owned global path here.
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { type DiscoveredPluginDeclaration, type InstallPluginResult, type InstallPluginScope } from "@oiap/core";
|
|
3
|
+
export type InstallAgentPluginCommand = InstallCommand | HelpCommand;
|
|
4
|
+
export type DependencyInstallMode = "auto" | "always" | "never";
|
|
5
|
+
export interface InstallCommand {
|
|
6
|
+
kind: "install";
|
|
7
|
+
source: string;
|
|
8
|
+
pluginSelector?: string;
|
|
9
|
+
agent?: string;
|
|
10
|
+
outDir?: string;
|
|
11
|
+
scope: InstallPluginScope;
|
|
12
|
+
ref?: string;
|
|
13
|
+
list: boolean;
|
|
14
|
+
dryRun: boolean;
|
|
15
|
+
json: boolean;
|
|
16
|
+
overwrite: boolean;
|
|
17
|
+
dependencyInstall: DependencyInstallMode;
|
|
18
|
+
allowInstallScripts: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface HelpCommand {
|
|
21
|
+
kind: "help";
|
|
22
|
+
}
|
|
23
|
+
export type InstallAgentPluginResult = ListResult | MaterializeResult | DryRunResult;
|
|
24
|
+
export interface ListResult {
|
|
25
|
+
kind: "list";
|
|
26
|
+
source: ResolvedPluginSourceSummary;
|
|
27
|
+
declarations: DiscoveredPluginDeclaration[];
|
|
28
|
+
}
|
|
29
|
+
export interface DryRunResult {
|
|
30
|
+
kind: "dry-run";
|
|
31
|
+
source: ResolvedPluginSourceSummary;
|
|
32
|
+
declaration: DiscoveredPluginDeclaration;
|
|
33
|
+
target: string;
|
|
34
|
+
scope: InstallPluginScope;
|
|
35
|
+
}
|
|
36
|
+
export interface MaterializeResult {
|
|
37
|
+
kind: "materialize";
|
|
38
|
+
source: ResolvedPluginSourceSummary;
|
|
39
|
+
declaration: DiscoveredPluginDeclaration;
|
|
40
|
+
target: string;
|
|
41
|
+
scope: InstallPluginScope;
|
|
42
|
+
outDir: string;
|
|
43
|
+
explicitOutDir: boolean;
|
|
44
|
+
files: string[];
|
|
45
|
+
report: InstallPluginResult["report"];
|
|
46
|
+
}
|
|
47
|
+
export interface ResolvedPluginSourceSummary {
|
|
48
|
+
input: string;
|
|
49
|
+
directory: string;
|
|
50
|
+
ref?: string;
|
|
51
|
+
temporary: boolean;
|
|
52
|
+
}
|
|
53
|
+
export declare class InstallAgentPluginError extends Error {
|
|
54
|
+
readonly exitCode: number;
|
|
55
|
+
constructor(message: string, exitCode?: number);
|
|
56
|
+
}
|
|
57
|
+
export declare function main(args?: string[]): Promise<void>;
|
|
58
|
+
export declare function parseInstallAgentPluginArgs(args: string[]): InstallAgentPluginCommand;
|
|
59
|
+
export declare function runInstallAgentPlugin(command: InstallCommand): Promise<InstallAgentPluginResult>;
|
|
60
|
+
export declare function selectPluginDeclaration(declarations: readonly DiscoveredPluginDeclaration[], selector: string): DiscoveredPluginDeclaration;
|
|
61
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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,CAAC;IACpB,MAAM,EAAE,2BAA2B,CAAC;IACpC,WAAW,EAAE,2BAA2B,CAAC;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,kBAAkB,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,OAAO,CAAC;IACxB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,2BAA2B;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;CACnB;AAuBD,qBAAa,uBAAwB,SAAQ,KAAK;IACjD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAEd,OAAO,EAAE,MAAM,EAAE,QAAQ,SAAI;CAIzC;AAED,wBAAsB,IAAI,CAAC,IAAI,WAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBtE;AAED,wBAAgB,2BAA2B,CAC1C,IAAI,EAAE,MAAM,EAAE,GACZ,yBAAyB,CA2H3B;AAED,wBAAsB,qBAAqB,CAC1C,OAAO,EAAE,cAAc,GACrB,OAAO,CAAC,wBAAwB,CAAC,CA+EnC;AAED,wBAAgB,uBAAuB,CACtC,YAAY,EAAE,SAAS,2BAA2B,EAAE,EACpD,QAAQ,EAAE,MAAM,GACd,2BAA2B,CAgC7B"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { execFile } from "node:child_process";
|
|
3
|
+
import { constants } from "node:fs";
|
|
4
|
+
import { access, mkdir, mkdtemp, rm, stat } from "node:fs/promises";
|
|
5
|
+
import { homedir, tmpdir } from "node:os";
|
|
6
|
+
import { join, relative, resolve } from "node:path";
|
|
7
|
+
import { pathToFileURL } from "node:url";
|
|
8
|
+
import { promisify } from "node:util";
|
|
9
|
+
import { bundleInstalledHookRuntime } from "@oiap/cli";
|
|
10
|
+
import { builtInInstallTargets, discoverPluginDeclarations, installPlugin, isBuiltInInstallTarget, } from "@oiap/core";
|
|
11
|
+
import { loadPluginFile } from "./plugin-loader";
|
|
12
|
+
const execFileAsync = promisify(execFile);
|
|
13
|
+
export class InstallAgentPluginError extends Error {
|
|
14
|
+
exitCode;
|
|
15
|
+
constructor(message, exitCode = 1) {
|
|
16
|
+
super(message);
|
|
17
|
+
this.exitCode = exitCode;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export async function main(args = process.argv.slice(2)) {
|
|
21
|
+
const command = parseInstallAgentPluginArgs(args);
|
|
22
|
+
if (command.kind === "help") {
|
|
23
|
+
printHelp();
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const result = await runInstallAgentPlugin(command);
|
|
27
|
+
if (command.json) {
|
|
28
|
+
console.log(JSON.stringify(result, null, "\t"));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
printResult(result);
|
|
32
|
+
if (result.kind === "materialize" && result.report.status === "unsupported") {
|
|
33
|
+
process.exitCode = 1;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export function parseInstallAgentPluginArgs(args) {
|
|
37
|
+
if (args.length === 0 || args.some((argument) => isHelpFlag(argument))) {
|
|
38
|
+
return { kind: "help" };
|
|
39
|
+
}
|
|
40
|
+
let source;
|
|
41
|
+
let pluginSelector;
|
|
42
|
+
let agent;
|
|
43
|
+
let outDir;
|
|
44
|
+
let scope = "local";
|
|
45
|
+
let ref;
|
|
46
|
+
let list = false;
|
|
47
|
+
let dryRun = false;
|
|
48
|
+
let json = false;
|
|
49
|
+
let overwrite = false;
|
|
50
|
+
let dependencyInstall = "auto";
|
|
51
|
+
let allowInstallScripts = false;
|
|
52
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
53
|
+
const argument = args[index];
|
|
54
|
+
if (!argument) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const option = splitOption(argument);
|
|
58
|
+
switch (option.name) {
|
|
59
|
+
case "--install-deps":
|
|
60
|
+
dependencyInstall = "always";
|
|
61
|
+
break;
|
|
62
|
+
case "--no-install-deps":
|
|
63
|
+
dependencyInstall = "never";
|
|
64
|
+
break;
|
|
65
|
+
case "--allow-install-scripts":
|
|
66
|
+
allowInstallScripts = true;
|
|
67
|
+
break;
|
|
68
|
+
case "--global":
|
|
69
|
+
case "-g":
|
|
70
|
+
scope = "global";
|
|
71
|
+
break;
|
|
72
|
+
case "--local":
|
|
73
|
+
case "--project":
|
|
74
|
+
scope = "local";
|
|
75
|
+
break;
|
|
76
|
+
case "--plugin":
|
|
77
|
+
case "-p": {
|
|
78
|
+
const parsed = readOptionValue(args, index, option.value, option.name);
|
|
79
|
+
pluginSelector = parsed.value;
|
|
80
|
+
index = parsed.nextIndex;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
case "--agent":
|
|
84
|
+
case "--target":
|
|
85
|
+
case "-a":
|
|
86
|
+
case "-t": {
|
|
87
|
+
const parsed = readOptionValue(args, index, option.value, option.name);
|
|
88
|
+
agent = parsed.value;
|
|
89
|
+
index = parsed.nextIndex;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
case "--out":
|
|
93
|
+
case "-o": {
|
|
94
|
+
const parsed = readOptionValue(args, index, option.value, option.name);
|
|
95
|
+
outDir = parsed.value;
|
|
96
|
+
index = parsed.nextIndex;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
case "--ref": {
|
|
100
|
+
const parsed = readOptionValue(args, index, option.value, option.name);
|
|
101
|
+
ref = parsed.value;
|
|
102
|
+
index = parsed.nextIndex;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
case "--list":
|
|
106
|
+
case "-l":
|
|
107
|
+
list = true;
|
|
108
|
+
break;
|
|
109
|
+
case "--dry-run":
|
|
110
|
+
dryRun = true;
|
|
111
|
+
break;
|
|
112
|
+
case "--json":
|
|
113
|
+
json = true;
|
|
114
|
+
break;
|
|
115
|
+
case "--overwrite":
|
|
116
|
+
overwrite = true;
|
|
117
|
+
break;
|
|
118
|
+
default:
|
|
119
|
+
if (argument.startsWith("-")) {
|
|
120
|
+
throw new InstallAgentPluginError(`Unknown option: ${argument}`);
|
|
121
|
+
}
|
|
122
|
+
if (source) {
|
|
123
|
+
throw new InstallAgentPluginError(`Expected one source, received: ${source}, ${argument}`);
|
|
124
|
+
}
|
|
125
|
+
source = argument;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (!source) {
|
|
129
|
+
throw new InstallAgentPluginError("Missing source. Usage: install-agent-plugin <owner/repo|path>");
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
kind: "install",
|
|
133
|
+
source,
|
|
134
|
+
pluginSelector,
|
|
135
|
+
agent,
|
|
136
|
+
outDir,
|
|
137
|
+
scope,
|
|
138
|
+
ref,
|
|
139
|
+
list,
|
|
140
|
+
dryRun,
|
|
141
|
+
json,
|
|
142
|
+
overwrite,
|
|
143
|
+
dependencyInstall,
|
|
144
|
+
allowInstallScripts,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
export async function runInstallAgentPlugin(command) {
|
|
148
|
+
const source = await resolvePluginSource(command);
|
|
149
|
+
try {
|
|
150
|
+
const declarations = await discoverPluginDeclarations(source.directory);
|
|
151
|
+
if (command.list) {
|
|
152
|
+
return { kind: "list", source: sourceSummary(source), declarations };
|
|
153
|
+
}
|
|
154
|
+
if (!command.pluginSelector) {
|
|
155
|
+
throw new InstallAgentPluginError("Missing --plugin. Use --list to inspect installable plugin declarations.");
|
|
156
|
+
}
|
|
157
|
+
if (!command.agent) {
|
|
158
|
+
throw new InstallAgentPluginError(`Missing --agent. Available agents: ${builtInInstallTargets.join(", ")}`);
|
|
159
|
+
}
|
|
160
|
+
if (!isBuiltInInstallTarget(command.agent)) {
|
|
161
|
+
throw new InstallAgentPluginError(`Unknown agent: ${command.agent}. Available agents: ${builtInInstallTargets.join(", ")}`);
|
|
162
|
+
}
|
|
163
|
+
const declaration = selectPluginDeclaration(declarations, command.pluginSelector);
|
|
164
|
+
if (command.dryRun) {
|
|
165
|
+
return {
|
|
166
|
+
kind: "dry-run",
|
|
167
|
+
source: sourceSummary(source),
|
|
168
|
+
declaration,
|
|
169
|
+
target: command.agent,
|
|
170
|
+
scope: command.scope,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
await installSourceDependencies(source, {
|
|
174
|
+
mode: command.dependencyInstall,
|
|
175
|
+
allowScripts: command.allowInstallScripts,
|
|
176
|
+
});
|
|
177
|
+
const plugin = await loadPluginFile(declaration.filePath, exportNameForLoad(declaration));
|
|
178
|
+
const installResult = await installPlugin({
|
|
179
|
+
plugin,
|
|
180
|
+
target: command.agent,
|
|
181
|
+
outDir: command.outDir,
|
|
182
|
+
scope: command.scope,
|
|
183
|
+
overwrite: command.overwrite,
|
|
184
|
+
});
|
|
185
|
+
const bundledHookFiles = await bundleInstalledHookRuntime({
|
|
186
|
+
pluginFilePath: declaration.filePath,
|
|
187
|
+
declaration,
|
|
188
|
+
outDir: installResult.outDir,
|
|
189
|
+
});
|
|
190
|
+
return {
|
|
191
|
+
kind: "materialize",
|
|
192
|
+
source: sourceSummary(source),
|
|
193
|
+
declaration,
|
|
194
|
+
target: installResult.target,
|
|
195
|
+
scope: installResult.scope,
|
|
196
|
+
outDir: installResult.outDir,
|
|
197
|
+
explicitOutDir: installResult.explicitOutDir,
|
|
198
|
+
files: [...installResult.files, ...bundledHookFiles],
|
|
199
|
+
report: installResult.report,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
finally {
|
|
203
|
+
await source.cleanup();
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
export function selectPluginDeclaration(declarations, selector) {
|
|
207
|
+
const matches = declarations.filter((declaration) => matchesPluginSelector(declaration, selector));
|
|
208
|
+
if (matches.length === 0) {
|
|
209
|
+
throw new InstallAgentPluginError(`No plugin declaration matched "${selector}". Use --list to inspect available plugins.`);
|
|
210
|
+
}
|
|
211
|
+
if (matches.length > 1) {
|
|
212
|
+
throw new InstallAgentPluginError(`Plugin selector "${selector}" is ambiguous: ${matches.map(formatDeclarationSelector).join(", ")}`);
|
|
213
|
+
}
|
|
214
|
+
const declaration = matches[0];
|
|
215
|
+
if (!declaration) {
|
|
216
|
+
throw new InstallAgentPluginError(`No plugin declaration matched "${selector}".`);
|
|
217
|
+
}
|
|
218
|
+
if (declaration.exportKind === "unexported") {
|
|
219
|
+
throw new InstallAgentPluginError(`Plugin declaration "${selector}" is not exported and cannot be installed.`);
|
|
220
|
+
}
|
|
221
|
+
return declaration;
|
|
222
|
+
}
|
|
223
|
+
async function resolvePluginSource(command) {
|
|
224
|
+
const localPath = resolve(expandUserPath(command.source));
|
|
225
|
+
if (await pathExists(localPath)) {
|
|
226
|
+
const localStats = await stat(localPath);
|
|
227
|
+
if (!localStats.isDirectory()) {
|
|
228
|
+
throw new InstallAgentPluginError(`Source must be a repository directory: ${command.source}`);
|
|
229
|
+
}
|
|
230
|
+
return {
|
|
231
|
+
input: command.source,
|
|
232
|
+
directory: localPath,
|
|
233
|
+
ref: command.ref,
|
|
234
|
+
temporary: false,
|
|
235
|
+
cleanup: async () => { },
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
if (!isGitHubShorthand(command.source)) {
|
|
239
|
+
throw new InstallAgentPluginError(`Source must be a local directory or GitHub shorthand owner/repo: ${command.source}`);
|
|
240
|
+
}
|
|
241
|
+
const tempDirectory = await mktempRepositoryDirectory();
|
|
242
|
+
const repositoryDirectory = join(tempDirectory, "repo");
|
|
243
|
+
const repositoryUrl = `https://github.com/${command.source}.git`;
|
|
244
|
+
const cloneArgs = ["clone", "--depth", "1"];
|
|
245
|
+
if (command.ref) {
|
|
246
|
+
cloneArgs.push("--branch", command.ref);
|
|
247
|
+
}
|
|
248
|
+
cloneArgs.push(repositoryUrl, repositoryDirectory);
|
|
249
|
+
try {
|
|
250
|
+
await execFileAsync("git", cloneArgs, { timeout: 120_000 });
|
|
251
|
+
}
|
|
252
|
+
catch (error) {
|
|
253
|
+
await rm(tempDirectory, { recursive: true, force: true });
|
|
254
|
+
throw new InstallAgentPluginError(`Failed to clone ${command.source}: ${error instanceof Error ? error.message : String(error)}`);
|
|
255
|
+
}
|
|
256
|
+
return {
|
|
257
|
+
input: command.source,
|
|
258
|
+
directory: repositoryDirectory,
|
|
259
|
+
ref: command.ref,
|
|
260
|
+
temporary: true,
|
|
261
|
+
cleanup: async () => {
|
|
262
|
+
await rm(tempDirectory, { recursive: true, force: true });
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
async function installSourceDependencies(source, options) {
|
|
267
|
+
const plan = await sourceDependencyInstallPlan(source, options);
|
|
268
|
+
if (!plan) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
await runDependencyInstall(plan);
|
|
272
|
+
}
|
|
273
|
+
async function sourceDependencyInstallPlan(source, options) {
|
|
274
|
+
if (options.mode === "never") {
|
|
275
|
+
return undefined;
|
|
276
|
+
}
|
|
277
|
+
if (!(await pathExists(join(source.directory, "package.json")))) {
|
|
278
|
+
return undefined;
|
|
279
|
+
}
|
|
280
|
+
if (options.mode === "auto" &&
|
|
281
|
+
!source.temporary &&
|
|
282
|
+
(await pathExists(join(source.directory, "node_modules")))) {
|
|
283
|
+
return undefined;
|
|
284
|
+
}
|
|
285
|
+
return await packageManagerInstallPlan(source.directory, options.allowScripts);
|
|
286
|
+
}
|
|
287
|
+
async function packageManagerInstallPlan(directory, allowScripts) {
|
|
288
|
+
if (await pathExists(join(directory, "bun.lock"))) {
|
|
289
|
+
return {
|
|
290
|
+
command: "bun",
|
|
291
|
+
args: [
|
|
292
|
+
"install",
|
|
293
|
+
"--frozen-lockfile",
|
|
294
|
+
...ignoreScriptsArgs("bun", allowScripts),
|
|
295
|
+
],
|
|
296
|
+
cwd: directory,
|
|
297
|
+
label: "bun install",
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
if (await pathExists(join(directory, "bun.lockb"))) {
|
|
301
|
+
return {
|
|
302
|
+
command: "bun",
|
|
303
|
+
args: [
|
|
304
|
+
"install",
|
|
305
|
+
"--frozen-lockfile",
|
|
306
|
+
...ignoreScriptsArgs("bun", allowScripts),
|
|
307
|
+
],
|
|
308
|
+
cwd: directory,
|
|
309
|
+
label: "bun install",
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
if (await pathExists(join(directory, "pnpm-lock.yaml"))) {
|
|
313
|
+
return {
|
|
314
|
+
command: "pnpm",
|
|
315
|
+
args: [
|
|
316
|
+
"install",
|
|
317
|
+
"--frozen-lockfile",
|
|
318
|
+
...ignoreScriptsArgs("pnpm", allowScripts),
|
|
319
|
+
],
|
|
320
|
+
cwd: directory,
|
|
321
|
+
label: "pnpm install",
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
if (await pathExists(join(directory, "yarn.lock"))) {
|
|
325
|
+
return {
|
|
326
|
+
command: "yarn",
|
|
327
|
+
args: [
|
|
328
|
+
"install",
|
|
329
|
+
"--frozen-lockfile",
|
|
330
|
+
...ignoreScriptsArgs("yarn", allowScripts),
|
|
331
|
+
],
|
|
332
|
+
cwd: directory,
|
|
333
|
+
label: "yarn install",
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
if ((await pathExists(join(directory, "package-lock.json"))) ||
|
|
337
|
+
(await pathExists(join(directory, "npm-shrinkwrap.json")))) {
|
|
338
|
+
return {
|
|
339
|
+
command: "npm",
|
|
340
|
+
args: ["ci", ...ignoreScriptsArgs("npm", allowScripts)],
|
|
341
|
+
cwd: directory,
|
|
342
|
+
label: "npm ci",
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
return {
|
|
346
|
+
command: "npm",
|
|
347
|
+
args: ["install", ...ignoreScriptsArgs("npm", allowScripts)],
|
|
348
|
+
cwd: directory,
|
|
349
|
+
label: "npm install",
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
function ignoreScriptsArgs(packageManager, allowScripts) {
|
|
353
|
+
if (allowScripts) {
|
|
354
|
+
return [];
|
|
355
|
+
}
|
|
356
|
+
switch (packageManager) {
|
|
357
|
+
case "bun":
|
|
358
|
+
case "npm":
|
|
359
|
+
case "pnpm":
|
|
360
|
+
case "yarn":
|
|
361
|
+
return ["--ignore-scripts"];
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
async function runDependencyInstall(plan) {
|
|
365
|
+
try {
|
|
366
|
+
await execFileAsync(plan.command, plan.args, {
|
|
367
|
+
cwd: plan.cwd,
|
|
368
|
+
timeout: 300_000,
|
|
369
|
+
maxBuffer: 1024 * 1024 * 10,
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
catch (error) {
|
|
373
|
+
throw new InstallAgentPluginError(`Failed to install dependencies with ${plan.label}: ${formatProcessError(error)}`);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
function formatProcessError(error) {
|
|
377
|
+
if (!error || typeof error !== "object") {
|
|
378
|
+
return String(error);
|
|
379
|
+
}
|
|
380
|
+
const processError = error;
|
|
381
|
+
const stderr = typeof processError.stderr === "string" ? processError.stderr.trim() : "";
|
|
382
|
+
const stdout = typeof processError.stdout === "string" ? processError.stdout.trim() : "";
|
|
383
|
+
return (stderr ||
|
|
384
|
+
stdout ||
|
|
385
|
+
(typeof processError.message === "string"
|
|
386
|
+
? processError.message
|
|
387
|
+
: String(error)));
|
|
388
|
+
}
|
|
389
|
+
function matchesPluginSelector(declaration, selector) {
|
|
390
|
+
const candidates = [
|
|
391
|
+
declaration.manifest?.id,
|
|
392
|
+
declaration.manifest?.name,
|
|
393
|
+
declaration.exportName,
|
|
394
|
+
declaration.localName,
|
|
395
|
+
declaration.relativePath,
|
|
396
|
+
formatDeclarationSelector(declaration),
|
|
397
|
+
];
|
|
398
|
+
return candidates.some((candidate) => candidate === selector);
|
|
399
|
+
}
|
|
400
|
+
function formatDeclarationSelector(declaration) {
|
|
401
|
+
return declaration.exportName
|
|
402
|
+
? `${declaration.relativePath}#${declaration.exportName}`
|
|
403
|
+
: declaration.relativePath;
|
|
404
|
+
}
|
|
405
|
+
function exportNameForLoad(declaration) {
|
|
406
|
+
return declaration.exportName === "default"
|
|
407
|
+
? undefined
|
|
408
|
+
: declaration.exportName;
|
|
409
|
+
}
|
|
410
|
+
function sourceSummary(source) {
|
|
411
|
+
return {
|
|
412
|
+
input: source.input,
|
|
413
|
+
directory: source.directory,
|
|
414
|
+
ref: source.ref,
|
|
415
|
+
temporary: source.temporary,
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
function printResult(result) {
|
|
419
|
+
if (result.kind === "list") {
|
|
420
|
+
printDeclarationList(result);
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
if (result.kind === "dry-run") {
|
|
424
|
+
console.log(`Selected ${displayDeclaration(result.declaration)} for ${result.target} (${result.scope} scope).`);
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
console.log(`${result.explicitOutDir ? "Materialized" : "Installed"} ${displayDeclaration(result.declaration)} for ${result.target} (${result.scope} scope) -> ${displayPath(result.outDir)} (${result.files.length} files, ${result.report.status})`);
|
|
428
|
+
for (const issue of result.report.issues) {
|
|
429
|
+
const message = ` ${issue.severity}: ${issue.code} - ${issue.message}`;
|
|
430
|
+
if (issue.severity === "error") {
|
|
431
|
+
console.error(message);
|
|
432
|
+
}
|
|
433
|
+
else {
|
|
434
|
+
console.warn(message);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
function printDeclarationList(result) {
|
|
439
|
+
if (result.declarations.length === 0) {
|
|
440
|
+
console.log(`No OIAP plugin declarations found in ${result.source.input}.`);
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
console.log(`Installable plugins in ${result.source.input}:`);
|
|
444
|
+
for (const declaration of result.declarations) {
|
|
445
|
+
const targets = declaration.manifest?.supportedTargets?.join(", ") ?? "unknown";
|
|
446
|
+
console.log(`- ${displayDeclaration(declaration)} (${formatDeclarationSelector(declaration)})`);
|
|
447
|
+
console.log(` targets: ${targets}`);
|
|
448
|
+
console.log(` metadata: ${declaration.metadataStatus}`);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
function displayDeclaration(declaration) {
|
|
452
|
+
return (declaration.manifest?.id ??
|
|
453
|
+
declaration.manifest?.name ??
|
|
454
|
+
declaration.exportName ??
|
|
455
|
+
declaration.relativePath);
|
|
456
|
+
}
|
|
457
|
+
function printHelp() {
|
|
458
|
+
console.log(helpText);
|
|
459
|
+
}
|
|
460
|
+
function splitOption(argument) {
|
|
461
|
+
const separatorIndex = argument.indexOf("=");
|
|
462
|
+
if (separatorIndex === -1) {
|
|
463
|
+
return { name: argument };
|
|
464
|
+
}
|
|
465
|
+
return {
|
|
466
|
+
name: argument.slice(0, separatorIndex),
|
|
467
|
+
value: argument.slice(separatorIndex + 1),
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
function readOptionValue(args, index, inlineValue, name) {
|
|
471
|
+
if (inlineValue !== undefined) {
|
|
472
|
+
return { value: inlineValue, nextIndex: index };
|
|
473
|
+
}
|
|
474
|
+
const value = args[index + 1];
|
|
475
|
+
if (!value || value.startsWith("-")) {
|
|
476
|
+
throw new InstallAgentPluginError(`Missing value for ${name}`);
|
|
477
|
+
}
|
|
478
|
+
return { value, nextIndex: index + 1 };
|
|
479
|
+
}
|
|
480
|
+
function isHelpFlag(argument) {
|
|
481
|
+
return argument === "--help" || argument === "-h";
|
|
482
|
+
}
|
|
483
|
+
function isGitHubShorthand(source) {
|
|
484
|
+
return /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(source);
|
|
485
|
+
}
|
|
486
|
+
function expandUserPath(filePath) {
|
|
487
|
+
if (filePath === "~") {
|
|
488
|
+
return homedir();
|
|
489
|
+
}
|
|
490
|
+
if (filePath.startsWith("~/")) {
|
|
491
|
+
return join(homedir(), filePath.slice(2));
|
|
492
|
+
}
|
|
493
|
+
return filePath;
|
|
494
|
+
}
|
|
495
|
+
async function pathExists(filePath) {
|
|
496
|
+
try {
|
|
497
|
+
await access(filePath, constants.F_OK);
|
|
498
|
+
return true;
|
|
499
|
+
}
|
|
500
|
+
catch {
|
|
501
|
+
return false;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
async function mktempRepositoryDirectory() {
|
|
505
|
+
await mkdir(tmpdir(), { recursive: true });
|
|
506
|
+
return await mkdtemp(join(tmpdir(), "oiap-install-"));
|
|
507
|
+
}
|
|
508
|
+
function displayPath(path) {
|
|
509
|
+
const relativePath = relative(process.cwd(), path);
|
|
510
|
+
if (!relativePath || relativePath.startsWith("..")) {
|
|
511
|
+
return path;
|
|
512
|
+
}
|
|
513
|
+
return relativePath;
|
|
514
|
+
}
|
|
515
|
+
function isCliEntrypoint() {
|
|
516
|
+
const entrypoint = process.argv[1];
|
|
517
|
+
if (!entrypoint) {
|
|
518
|
+
return false;
|
|
519
|
+
}
|
|
520
|
+
return pathToFileURL(resolve(entrypoint)).href === import.meta.url;
|
|
521
|
+
}
|
|
522
|
+
const helpText = `Usage:
|
|
523
|
+
install-agent-plugin <owner/repo|path> --list [--ref <ref>] [--json]
|
|
524
|
+
install-agent-plugin <owner/repo|path> --plugin <name> --agent <target> [-g] [--out <dir>] [--ref <ref>] [--overwrite] [--json]
|
|
525
|
+
|
|
526
|
+
Options:
|
|
527
|
+
-l, --list List OIAP definePlugin declarations without loading them.
|
|
528
|
+
-p, --plugin <name> Plugin manifest id/name, export name, or path#export selector.
|
|
529
|
+
-a, --agent <target> Target agent exporter. Alias: --target.
|
|
530
|
+
-g, --global Install to the target's user-level path. Defaults to the local/project path.
|
|
531
|
+
--local, --project Install to the target's local/project path.
|
|
532
|
+
-o, --out <dir> Override the target install path and write the selected bundle to a directory.
|
|
533
|
+
--ref <ref> Git branch or tag for owner/repo sources.
|
|
534
|
+
--dry-run Resolve source, plugin, and agent without loading or writing.
|
|
535
|
+
--install-deps Always install source package dependencies before loading the plugin.
|
|
536
|
+
--no-install-deps Do not install source or runtime dependencies.
|
|
537
|
+
--allow-install-scripts Allow package manager lifecycle scripts while installing dependencies.
|
|
538
|
+
--overwrite Replace an existing install or --out directory.
|
|
539
|
+
--json Print machine-readable output.
|
|
540
|
+
|
|
541
|
+
By default, plugins install to the selected target's local/project directory. The installer installs dependencies for cloned repositories and local checkouts without node_modules, ignoring lifecycle scripts unless --allow-install-scripts is passed. Use --global for user-level installation or --out for a reviewable bundle directory.
|
|
542
|
+
`;
|
|
543
|
+
if (isCliEntrypoint()) {
|
|
544
|
+
main().catch((error) => {
|
|
545
|
+
if (error instanceof InstallAgentPluginError) {
|
|
546
|
+
console.error(error.message);
|
|
547
|
+
process.exitCode = error.exitCode;
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
551
|
+
process.exitCode = 1;
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,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I,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACpD,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO,YAAY,CAAC;AACrB,CAAC;AAED,SAAS,eAAe;IACvB,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAEnC,IAAI,CAAC,UAAU,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC;IACd,CAAC;IAED,OAAO,aAAa,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;AACpE,CAAC;AAED,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;;;;;;CAoBhB,CAAC;AAEF,IAAI,eAAe,EAAE,EAAE,CAAC;IACvB,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;QAC/B,IAAI,KAAK,YAAY,uBAAuB,EAAE,CAAC;YAC9C,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC7B,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;YAClC,OAAO;QACR,CAAC;QAED,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACtE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACtB,CAAC,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-loader.d.ts","sourceRoot":"","sources":["../src/plugin-loader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,wBAAsB,cAAc,CACnC,SAAS,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,kBAAkB,CAAC,CAc7B"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
|
+
export async function loadPluginFile(inputPath, exportName) {
|
|
4
|
+
const absoluteInputPath = resolve(inputPath);
|
|
5
|
+
const moduleUrl = pathToFileURL(absoluteInputPath).href;
|
|
6
|
+
const moduleExports = (await import(moduleUrl));
|
|
7
|
+
const exportedValue = selectPluginExport(moduleExports, exportName);
|
|
8
|
+
const plugin = await resolvePluginExport(exportedValue);
|
|
9
|
+
if (!isPluginObject(plugin)) {
|
|
10
|
+
throw new Error(`Plugin file must export an OIAP plugin object or a function returning one: ${inputPath}`);
|
|
11
|
+
}
|
|
12
|
+
return plugin;
|
|
13
|
+
}
|
|
14
|
+
function selectPluginExport(moduleExports, exportName) {
|
|
15
|
+
if (exportName) {
|
|
16
|
+
if (exportName in moduleExports) {
|
|
17
|
+
return moduleExports[exportName];
|
|
18
|
+
}
|
|
19
|
+
throw new Error(`Plugin file does not export "${exportName}". Available exports: ${formatExportNames(moduleExports)}`);
|
|
20
|
+
}
|
|
21
|
+
if ("default" in moduleExports) {
|
|
22
|
+
return moduleExports.default;
|
|
23
|
+
}
|
|
24
|
+
if ("plugin" in moduleExports) {
|
|
25
|
+
return moduleExports.plugin;
|
|
26
|
+
}
|
|
27
|
+
throw new Error(`Plugin file must export default or plugin. Available exports: ${formatExportNames(moduleExports)}`);
|
|
28
|
+
}
|
|
29
|
+
async function resolvePluginExport(exportedValue) {
|
|
30
|
+
if (typeof exportedValue === "function") {
|
|
31
|
+
return exportedValue();
|
|
32
|
+
}
|
|
33
|
+
return exportedValue;
|
|
34
|
+
}
|
|
35
|
+
function isPluginObject(plugin) {
|
|
36
|
+
return (Boolean(plugin) && typeof plugin === "object" && !Array.isArray(plugin));
|
|
37
|
+
}
|
|
38
|
+
function formatExportNames(moduleExports) {
|
|
39
|
+
const exportNames = Object.keys(moduleExports);
|
|
40
|
+
return exportNames.length > 0 ? exportNames.join(", ") : "none";
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=plugin-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-loader.js","sourceRoot":"","sources":["../src/plugin-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,MAAM,CAAC,KAAK,UAAU,cAAc,CACnC,SAAiB,EACjB,UAAmB;IAEnB,MAAM,iBAAiB,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAC7C,MAAM,SAAS,GAAG,aAAa,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC;IACxD,MAAM,aAAa,GAAG,CAAC,MAAM,MAAM,CAAC,SAAS,CAAC,CAA4B,CAAC;IAC3E,MAAM,aAAa,GAAG,kBAAkB,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;IACpE,MAAM,MAAM,GAAG,MAAM,mBAAmB,CAAC,aAAa,CAAC,CAAC;IAExD,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CACd,8EAA8E,SAAS,EAAE,CACzF,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC;AAED,SAAS,kBAAkB,CAC1B,aAAsC,EACtC,UAAmB;IAEnB,IAAI,UAAU,EAAE,CAAC;QAChB,IAAI,UAAU,IAAI,aAAa,EAAE,CAAC;YACjC,OAAO,aAAa,CAAC,UAAU,CAAC,CAAC;QAClC,CAAC;QAED,MAAM,IAAI,KAAK,CACd,gCAAgC,UAAU,yBAAyB,iBAAiB,CAAC,aAAa,CAAC,EAAE,CACrG,CAAC;IACH,CAAC;IAED,IAAI,SAAS,IAAI,aAAa,EAAE,CAAC;QAChC,OAAO,aAAa,CAAC,OAAO,CAAC;IAC9B,CAAC;IAED,IAAI,QAAQ,IAAI,aAAa,EAAE,CAAC;QAC/B,OAAO,aAAa,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED,MAAM,IAAI,KAAK,CACd,iEAAiE,iBAAiB,CAAC,aAAa,CAAC,EAAE,CACnG,CAAC;AACH,CAAC;AAED,KAAK,UAAU,mBAAmB,CAAC,aAAsB;IACxD,IAAI,OAAO,aAAa,KAAK,UAAU,EAAE,CAAC;QACzC,OAAO,aAAa,EAAE,CAAC;IACxB,CAAC;IAED,OAAO,aAAa,CAAC;AACtB,CAAC;AAED,SAAS,cAAc,CAAC,MAAe;IACtC,OAAO,CACN,OAAO,CAAC,MAAM,CAAC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CACvE,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,aAAsC;IAChE,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAE/C,OAAO,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AACjE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "install-agent-plugin",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Consumer CLI for discovering and installing Open Interoperable Agent Plugins.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/fboldo/oiap.git",
|
|
10
|
+
"directory": "packages/install-agent-plugin"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/fboldo/oiap#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/fboldo/oiap/issues"
|
|
15
|
+
},
|
|
16
|
+
"bin": {
|
|
17
|
+
"install-agent-plugin": "./dist/cli.js"
|
|
18
|
+
},
|
|
19
|
+
"exports": {},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsc -p tsconfig.build.json",
|
|
28
|
+
"check": "bun run typecheck",
|
|
29
|
+
"cli": "bun src/cli.ts",
|
|
30
|
+
"test": "bun test src",
|
|
31
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@oiap/cli": "0.4.0",
|
|
35
|
+
"@oiap/core": "0.4.0",
|
|
36
|
+
"@oiap/exporter-antigravity": "0.4.0",
|
|
37
|
+
"@oiap/exporter-claude-code": "0.4.0",
|
|
38
|
+
"@oiap/exporter-cline": "0.4.0",
|
|
39
|
+
"@oiap/exporter-codex": "0.4.0",
|
|
40
|
+
"@oiap/exporter-cursor": "0.4.0",
|
|
41
|
+
"@oiap/exporter-gemini-cli": "0.4.0",
|
|
42
|
+
"@oiap/exporter-github-copilot-cli": "0.4.0",
|
|
43
|
+
"@oiap/exporter-openclaw": "0.4.0",
|
|
44
|
+
"@oiap/exporter-opencode": "0.4.0",
|
|
45
|
+
"@oiap/exporter-vscode-copilot": "0.4.0",
|
|
46
|
+
"@oiap/exporter-windsurf": "0.4.0"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"typescript": "^5"
|
|
50
|
+
},
|
|
51
|
+
"gitHead": "aa366b6c06bca12310942121a633c2d2a9ea387c"
|
|
52
|
+
}
|