@agentplugins/cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -0
- package/dist/cli.d.ts +14 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +79 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/build.d.ts +14 -0
- package/dist/commands/build.d.ts.map +1 -0
- package/dist/commands/build.js +133 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/init.d.ts +11 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +166 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/validate.d.ts +12 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +58 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/config.d.ts +26 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +77 -0
- package/dist/config.js.map +1 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# @agentplugins/cli
|
|
2
|
+
|
|
3
|
+
> Build, validate, and scaffold [AgentPlugins](https://github.com/espetro/agentplugins) plugins.
|
|
4
|
+
|
|
5
|
+
`@agentplugins/cli` is the `agentplugins` command-line tool. It compiles a universal `PluginManifest` into platform-native outputs for all 7 supported agent harnesses.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Use it directly with npx
|
|
11
|
+
npx @agentplugins/cli init my-plugin
|
|
12
|
+
|
|
13
|
+
# Or install globally
|
|
14
|
+
npm install -g @agentplugins/cli
|
|
15
|
+
agentplugins --help
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Commands
|
|
19
|
+
|
|
20
|
+
| Command | Purpose |
|
|
21
|
+
|---------|---------|
|
|
22
|
+
| `agentplugins init <name>` | Scaffold a new plugin project (creates `agentplugins.config.ts` + skeleton). |
|
|
23
|
+
| `agentplugins validate` | Validate the plugin manifest against the AgentPlugins schema and target constraints. |
|
|
24
|
+
| `agentplugins build` | Compile to **all** target platforms and write to `dist/<platform>/`. |
|
|
25
|
+
| `agentplugins build --target claude,opencode` | Compile to specific platforms only. |
|
|
26
|
+
| `agentplugins build --out-dir build` | Change the output directory (default: `dist`). |
|
|
27
|
+
| `agentplugins build --strict` | Fail the build on warnings, not just errors. |
|
|
28
|
+
|
|
29
|
+
## Quick start
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# 1. Create a plugin
|
|
33
|
+
npx @agentplugins/cli init my-plugin
|
|
34
|
+
cd my-plugin
|
|
35
|
+
|
|
36
|
+
# 2. Edit agentplugins.config.ts
|
|
37
|
+
# (add hooks, tools, commands, skills, MCP servers, etc.)
|
|
38
|
+
|
|
39
|
+
# 3. Validate the manifest
|
|
40
|
+
npx agentplugins validate
|
|
41
|
+
|
|
42
|
+
# 4. Build for all platforms
|
|
43
|
+
npx agentplugins build
|
|
44
|
+
|
|
45
|
+
# 5. Inspect the output
|
|
46
|
+
ls dist/
|
|
47
|
+
# → claude/ codex/ copilot/ gemini/ kimi/ opencode/ pimono/
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Configuration
|
|
51
|
+
|
|
52
|
+
The CLI looks for `agentplugins.config.ts` (or `.js`, `.mjs`, `.json`) in the current working directory. See [@agentplugins/core](https://www.npmjs.com/package/@agentplugins/core) for the manifest schema.
|
|
53
|
+
|
|
54
|
+
## Related packages
|
|
55
|
+
|
|
56
|
+
- [`@agentplugins/core`](https://www.npmjs.com/package/@agentplugins/core) — manifest types, validation, registry.
|
|
57
|
+
- Platform adapters: [`@agentplugins/adapter-claude`](https://www.npmjs.com/package/@agentplugins/adapter-claude), [`@agentplugins/adapter-codex`](https://www.npmjs.com/package/@agentplugins/adapter-codex), [`@agentplugins/adapter-copilot`](https://www.npmjs.com/package/@agentplugins/adapter-copilot), [`@agentplugins/adapter-gemini`](https://www.npmjs.com/package/@agentplugins/adapter-gemini), [`@agentplugins/adapter-kimi`](https://www.npmjs.com/package/@agentplugins/adapter-kimi), [`@agentplugins/adapter-opencode`](https://www.npmjs.com/package/@agentplugins/adapter-opencode), [`@agentplugins/adapter-pimono`](https://www.npmjs.com/package/@agentplugins/adapter-pimono).
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
|
|
61
|
+
MIT
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* AgentPlugins CLI
|
|
4
|
+
*
|
|
5
|
+
* Build AI agent plugins once, ship to any harness.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* npx agentplugins build # Build plugin for all targets
|
|
9
|
+
* npx agentplugins build --target claude,codex # Build for specific targets
|
|
10
|
+
* npx agentplugins validate # Validate plugin without building
|
|
11
|
+
* npx agentplugins init # Scaffold a new plugin
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;GAUG"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* AgentPlugins CLI
|
|
4
|
+
*
|
|
5
|
+
* Build AI agent plugins once, ship to any harness.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* npx agentplugins build # Build plugin for all targets
|
|
9
|
+
* npx agentplugins build --target claude,codex # Build for specific targets
|
|
10
|
+
* npx agentplugins validate # Validate plugin without building
|
|
11
|
+
* npx agentplugins init # Scaffold a new plugin
|
|
12
|
+
*/
|
|
13
|
+
import { cac } from 'cac';
|
|
14
|
+
import chalk from 'chalk';
|
|
15
|
+
import { build } from './commands/build.js';
|
|
16
|
+
import { validate } from './commands/validate.js';
|
|
17
|
+
import { init } from './commands/init.js';
|
|
18
|
+
import { loadConfig } from './config.js';
|
|
19
|
+
const cli = cac('agentplugins');
|
|
20
|
+
cli
|
|
21
|
+
.command('build', 'Build plugin for target platforms')
|
|
22
|
+
.option('-t, --target <targets>', 'Comma-separated target platforms (claude,codex,copilot,gemini,kimi,opencode,pimono)')
|
|
23
|
+
.option('-o, --out-dir <dir>', 'Output directory', { default: 'dist' })
|
|
24
|
+
.option('--strict', 'Fail on warnings', { default: false })
|
|
25
|
+
.option('--config <file>', 'Config file path', { default: 'agentplugins.config.ts' })
|
|
26
|
+
.action(async (options) => {
|
|
27
|
+
try {
|
|
28
|
+
const config = await loadConfig(options.config);
|
|
29
|
+
const targets = options.target
|
|
30
|
+
? options.target.split(',').map((t) => t.trim())
|
|
31
|
+
: config.manifest.targets;
|
|
32
|
+
await build({
|
|
33
|
+
config,
|
|
34
|
+
targets,
|
|
35
|
+
outDir: options.outDir,
|
|
36
|
+
strict: options.strict,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
console.error(chalk.red('Build failed:'), err instanceof Error ? err.message : String(err));
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
cli
|
|
45
|
+
.command('validate', 'Validate plugin configuration')
|
|
46
|
+
.option('--config <file>', 'Config file path', { default: 'agentplugins.config.ts' })
|
|
47
|
+
.option('-t, --target <targets>', 'Validate for specific targets only')
|
|
48
|
+
.action(async (options) => {
|
|
49
|
+
try {
|
|
50
|
+
const config = await loadConfig(options.config);
|
|
51
|
+
const targets = options.target
|
|
52
|
+
? options.target.split(',').map((t) => t.trim())
|
|
53
|
+
: undefined;
|
|
54
|
+
await validate({ config, targets });
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
console.error(chalk.red('Validation failed:'), err instanceof Error ? err.message : String(err));
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
cli
|
|
62
|
+
.command('init [name]', 'Scaffold a new AgentPlugins plugin')
|
|
63
|
+
.option('--target <targets>', 'Initial target platforms', { default: 'claude,codex' })
|
|
64
|
+
.action(async (name, options) => {
|
|
65
|
+
try {
|
|
66
|
+
await init({
|
|
67
|
+
name: name || 'my-agentplugins-plugin',
|
|
68
|
+
targets: options.target.split(',').map((t) => t.trim()),
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
console.error(chalk.red('Init failed:'), err instanceof Error ? err.message : String(err));
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
cli.help();
|
|
77
|
+
cli.version('0.1.0');
|
|
78
|
+
cli.parse();
|
|
79
|
+
//# 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;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,GAAG,GAAG,GAAG,CAAC,cAAc,CAAC,CAAC;AAEhC,GAAG;KACA,OAAO,CAAC,OAAO,EAAE,mCAAmC,CAAC;KACrD,MAAM,CAAC,wBAAwB,EAAE,qFAAqF,CAAC;KACvH,MAAM,CAAC,qBAAqB,EAAE,kBAAkB,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;KACtE,MAAM,CAAC,UAAU,EAAE,kBAAkB,EAAE,EAA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CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QAC3F,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,GAAG,CAAC,IAAI,EAAE,CAAC;AACX,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AAErB,GAAG,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentPlugins Build Command
|
|
3
|
+
*
|
|
4
|
+
* Compiles a universal plugin into platform-specific packages.
|
|
5
|
+
*/
|
|
6
|
+
import type { LoadedConfig } from '../config.js';
|
|
7
|
+
export interface BuildOptions {
|
|
8
|
+
config: LoadedConfig;
|
|
9
|
+
targets?: string[];
|
|
10
|
+
outDir: string;
|
|
11
|
+
strict: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function build(options: BuildOptions): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAIjD,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;CACjB;AAiCD,wBAAsB,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAoFhE"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentPlugins Build Command
|
|
3
|
+
*
|
|
4
|
+
* Compiles a universal plugin into platform-specific packages.
|
|
5
|
+
*/
|
|
6
|
+
import { resolve, join } from 'node:path';
|
|
7
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
import { validateUniversal, validateForPlatform, ALL_TARGETS, } from '@agentplugins/core';
|
|
10
|
+
async function getAdapterFactory(target) {
|
|
11
|
+
switch (target) {
|
|
12
|
+
case 'claude':
|
|
13
|
+
// @ts-ignore - adapter loaded dynamically at runtime
|
|
14
|
+
return (await import('@agentplugins/adapter-claude')).createClaudeAdapter;
|
|
15
|
+
case 'codex':
|
|
16
|
+
// @ts-ignore - adapter loaded dynamically at runtime
|
|
17
|
+
return (await import('@agentplugins/adapter-codex')).createCodexAdapter;
|
|
18
|
+
case 'copilot':
|
|
19
|
+
// @ts-ignore - adapter loaded dynamically at runtime
|
|
20
|
+
return (await import('@agentplugins/adapter-copilot')).createCopilotAdapter;
|
|
21
|
+
case 'gemini':
|
|
22
|
+
// @ts-ignore - adapter loaded dynamically at runtime
|
|
23
|
+
return (await import('@agentplugins/adapter-gemini')).createGeminiAdapter;
|
|
24
|
+
case 'kimi':
|
|
25
|
+
// @ts-ignore - adapter loaded dynamically at runtime
|
|
26
|
+
return (await import('@agentplugins/adapter-kimi')).createKimiAdapter;
|
|
27
|
+
case 'opencode':
|
|
28
|
+
// @ts-ignore - adapter loaded dynamically at runtime
|
|
29
|
+
return (await import('@agentplugins/adapter-opencode')).createOpenCodeAdapter;
|
|
30
|
+
case 'pimono':
|
|
31
|
+
// @ts-ignore - adapter loaded dynamically at runtime
|
|
32
|
+
return (await import('@agentplugins/adapter-pimono')).createPiMonoAdapter;
|
|
33
|
+
default:
|
|
34
|
+
throw new Error(`Unknown target: ${target}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export async function build(options) {
|
|
38
|
+
const { config, outDir } = options;
|
|
39
|
+
const manifest = config.manifest;
|
|
40
|
+
// Determine targets
|
|
41
|
+
const targetList = (options.targets || manifest.targets || ALL_TARGETS);
|
|
42
|
+
console.log(chalk.bold('\n🌉 AgentPlugins Build\n'));
|
|
43
|
+
console.log(chalk.gray(`Plugin: ${manifest.name} v${manifest.version}`));
|
|
44
|
+
console.log(chalk.gray(`Targets: ${targetList.join(', ')}`));
|
|
45
|
+
console.log(chalk.gray(`Output: ${resolve(outDir)}\n`));
|
|
46
|
+
// ─── Universal Validation ─────────────────────────────────────────────────
|
|
47
|
+
console.log(chalk.blue('🔍 Running universal validation...'));
|
|
48
|
+
const universalIssues = validateUniversal(manifest);
|
|
49
|
+
printIssues(universalIssues);
|
|
50
|
+
const hasErrors = universalIssues.some(i => i.severity === 'error');
|
|
51
|
+
if (hasErrors) {
|
|
52
|
+
throw new Error('Universal validation failed. Fix errors before building.');
|
|
53
|
+
}
|
|
54
|
+
// ─── Platform-Specific Compilation ────────────────────────────────────────
|
|
55
|
+
const outRoot = resolve(outDir);
|
|
56
|
+
for (const target of targetList) {
|
|
57
|
+
let factory;
|
|
58
|
+
try {
|
|
59
|
+
factory = await getAdapterFactory(target);
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
console.log(chalk.yellow(`⚠️ No adapter for "${target}" — skipping`));
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
console.log(chalk.blue(`\n📦 Building for ${target}...`));
|
|
66
|
+
// Platform-specific validation
|
|
67
|
+
const platformIssues = validateForPlatform(manifest, target);
|
|
68
|
+
printIssues(platformIssues);
|
|
69
|
+
const platformErrors = platformIssues.filter(i => i.severity === 'error');
|
|
70
|
+
if (platformErrors.length > 0) {
|
|
71
|
+
console.log(chalk.red(` ✗ Build failed for ${target} (${platformErrors.length} error${platformErrors.length > 1 ? 's' : ''})`));
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
// Compile
|
|
75
|
+
try {
|
|
76
|
+
const adapter = factory();
|
|
77
|
+
const output = adapter.compile(manifest);
|
|
78
|
+
// Write files
|
|
79
|
+
const targetDir = join(outRoot, target);
|
|
80
|
+
await mkdir(targetDir, { recursive: true });
|
|
81
|
+
for (const file of output.files) {
|
|
82
|
+
const filePath = join(targetDir, file.path);
|
|
83
|
+
await mkdir(resolve(filePath, '..'), { recursive: true });
|
|
84
|
+
await writeFile(filePath, file.content, 'utf-8');
|
|
85
|
+
}
|
|
86
|
+
// Print results
|
|
87
|
+
console.log(chalk.green(` ✓ Built ${output.files.length} file${output.files.length > 1 ? 's' : ''}`));
|
|
88
|
+
if (output.warnings.length > 0) {
|
|
89
|
+
for (const w of output.warnings) {
|
|
90
|
+
console.log(chalk.yellow(` ⚠ ${w}`));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (output.postInstall) {
|
|
94
|
+
console.log(chalk.cyan(` ⓘ ${output.postInstall.join('\n ⓘ ')}`));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
console.log(chalk.red(` ✗ Build failed for ${target}: ${err instanceof Error ? err.message : String(err)}`));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// ─── Summary ──────────────────────────────────────────────────────────────
|
|
102
|
+
console.log(chalk.bold('\n✅ Build complete!\n'));
|
|
103
|
+
console.log(chalk.gray('Install your plugins:'));
|
|
104
|
+
for (const target of targetList) {
|
|
105
|
+
const installCmd = getInstallCommand(target, manifest.name);
|
|
106
|
+
console.log(chalk.gray(` ${target}: ${installCmd}`));
|
|
107
|
+
}
|
|
108
|
+
console.log();
|
|
109
|
+
}
|
|
110
|
+
function printIssues(issues) {
|
|
111
|
+
for (const issue of issues) {
|
|
112
|
+
const color = issue.severity === 'error' ? chalk.red : issue.severity === 'warning' ? chalk.yellow : chalk.gray;
|
|
113
|
+
const icon = issue.severity === 'error' ? '✗' : issue.severity === 'warning' ? '⚠' : 'ℹ';
|
|
114
|
+
const field = issue.field ? chalk.gray(`[${issue.field}] `) : '';
|
|
115
|
+
console.log(color(` ${icon} ${field}${issue.message}`));
|
|
116
|
+
if (issue.suggestion) {
|
|
117
|
+
console.log(chalk.cyan(` → ${issue.suggestion}`));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function getInstallCommand(target, pluginName) {
|
|
122
|
+
const commands = {
|
|
123
|
+
claude: `cp -r dist/claude ~/.claude/skills/${pluginName}`,
|
|
124
|
+
codex: `cp -r dist/codex ~/.codex/plugins/`,
|
|
125
|
+
copilot: `copilot plugin install ./dist/copilot`,
|
|
126
|
+
gemini: `gemini extensions install ./dist/gemini`,
|
|
127
|
+
kimi: `cp -r dist/kimi ~/.kimi/plugins/`,
|
|
128
|
+
opencode: `cp dist/opencode/*.ts .opencode/plugins/`,
|
|
129
|
+
pimono: `cp -r dist/pimono ~/.pi/agent/extensions/`,
|
|
130
|
+
};
|
|
131
|
+
return commands[target] || `See ${target} documentation`;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,WAAW,GAEZ,MAAM,oBAAoB,CAAC;AAe5B,KAAK,UAAU,iBAAiB,CAAC,MAAsB;IACrD,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,QAAQ;YACX,qDAAqD;YACrD,OAAO,CAAC,MAAM,MAAM,CAAC,8BAA8B,CAAC,CAAC,CAAC,mBAAmB,CAAC;QAC5E,KAAK,OAAO;YACV,qDAAqD;YACrD,OAAO,CAAC,MAAM,MAAM,CAAC,6BAA6B,CAAC,CAAC,CAAC,kBAAkB,CAAC;QAC1E,KAAK,SAAS;YACZ,qDAAqD;YACrD,OAAO,CAAC,MAAM,MAAM,CAAC,+BAA+B,CAAC,CAAC,CA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
|
+
targets: string[];
|
|
9
|
+
}
|
|
10
|
+
export declare function init(options: InitOptions): Promise<void>;
|
|
11
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,wBAAsB,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAiJ9D"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentPlugins Init Command
|
|
3
|
+
*
|
|
4
|
+
* Scaffolds a new AgentPlugins plugin project.
|
|
5
|
+
*/
|
|
6
|
+
import { resolve } from 'node:path';
|
|
7
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
export async function init(options) {
|
|
10
|
+
const { name, targets } = options;
|
|
11
|
+
const cwd = process.cwd();
|
|
12
|
+
const pluginDir = resolve(cwd, name);
|
|
13
|
+
console.log(chalk.bold(`\n🆕 Creating AgentPlugins plugin: ${name}\n`));
|
|
14
|
+
// Create directory
|
|
15
|
+
await mkdir(pluginDir, { recursive: true });
|
|
16
|
+
// ─── agentplugins.config.ts ────────────────────────────────────────────────
|
|
17
|
+
const configContent = `import { definePlugin } from '@agentplugins/core';
|
|
18
|
+
|
|
19
|
+
export default definePlugin({
|
|
20
|
+
name: '${toKebabCase(name)}',
|
|
21
|
+
version: '0.1.0',
|
|
22
|
+
description: 'My AgentPlugins plugin — works across multiple AI agent harnesses',
|
|
23
|
+
|
|
24
|
+
// Target platforms to compile for
|
|
25
|
+
targets: [${targets.map(t => `'${t}'`).join(', ')}] as const,
|
|
26
|
+
|
|
27
|
+
// Plugin hooks
|
|
28
|
+
hooks: {
|
|
29
|
+
sessionStart: {
|
|
30
|
+
handler: {
|
|
31
|
+
type: 'inline',
|
|
32
|
+
handler: async (ctx) => {
|
|
33
|
+
console.log('[AgentPlugins] Session started:', ctx.sessionId);
|
|
34
|
+
return {
|
|
35
|
+
additionalContext: '${name} plugin is active. Log all tool usage for audit.',
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
preToolUse: {
|
|
41
|
+
handler: {
|
|
42
|
+
type: 'inline',
|
|
43
|
+
handler: async (ctx) => {
|
|
44
|
+
console.log('[AgentPlugins] Tool call:', ctx.toolName, JSON.stringify(ctx.toolInput));
|
|
45
|
+
// Return nothing to allow the tool call
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
// Skills the plugin provides
|
|
52
|
+
skills: [
|
|
53
|
+
{
|
|
54
|
+
name: '${toKebabCase(name)}-skill',
|
|
55
|
+
description: 'Default skill for ${name}',
|
|
56
|
+
content: \`---
|
|
57
|
+
name: ${toKebabCase(name)}-skill
|
|
58
|
+
description: Default skill for ${name}
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
When using this plugin, always log your actions for transparency.
|
|
62
|
+
\`,
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
});
|
|
66
|
+
`;
|
|
67
|
+
await writeFile(resolve(pluginDir, 'agentplugins.config.ts'), configContent);
|
|
68
|
+
// ─── package.json ─────────────────────────────────────────────────────────
|
|
69
|
+
const packageJson = {
|
|
70
|
+
name: toKebabCase(name),
|
|
71
|
+
version: '0.1.0',
|
|
72
|
+
description: `AgentPlugins plugin — works across ${targets.join(', ')}`,
|
|
73
|
+
type: 'module',
|
|
74
|
+
private: true,
|
|
75
|
+
scripts: {
|
|
76
|
+
build: 'agentplugins build',
|
|
77
|
+
validate: 'agentplugins validate',
|
|
78
|
+
},
|
|
79
|
+
devDependencies: {
|
|
80
|
+
'@agentplugins/core': '^0.1.0',
|
|
81
|
+
'@agentplugins/cli': '^0.1.0',
|
|
82
|
+
typescript: '^5.5.0',
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
await writeFile(resolve(pluginDir, 'package.json'), JSON.stringify(packageJson, null, 2));
|
|
86
|
+
// ─── tsconfig.json ────────────────────────────────────────────────────────
|
|
87
|
+
const tsconfig = {
|
|
88
|
+
compilerOptions: {
|
|
89
|
+
target: 'ES2022',
|
|
90
|
+
module: 'NodeNext',
|
|
91
|
+
moduleResolution: 'NodeNext',
|
|
92
|
+
strict: true,
|
|
93
|
+
esModuleInterop: true,
|
|
94
|
+
skipLibCheck: true,
|
|
95
|
+
forceConsistentCasingInFileNames: true,
|
|
96
|
+
},
|
|
97
|
+
include: ['agentplugins.config.ts'],
|
|
98
|
+
};
|
|
99
|
+
await writeFile(resolve(pluginDir, 'tsconfig.json'), JSON.stringify(tsconfig, null, 2));
|
|
100
|
+
// ─── .gitignore ───────────────────────────────────────────────────────────
|
|
101
|
+
await writeFile(resolve(pluginDir, '.gitignore'), `dist/
|
|
102
|
+
node_modules/
|
|
103
|
+
*.log
|
|
104
|
+
`);
|
|
105
|
+
// ─── README.md ────────────────────────────────────────────────────────────
|
|
106
|
+
const readme = `# ${name}
|
|
107
|
+
|
|
108
|
+
An [AgentPlugins](https://github.com/espetro/agentplugins) plugin that works across multiple AI agent harnesses.
|
|
109
|
+
|
|
110
|
+
## Supported Platforms
|
|
111
|
+
|
|
112
|
+
${targets.map(t => `- ${t}`).join('\n')}
|
|
113
|
+
|
|
114
|
+
## Development
|
|
115
|
+
|
|
116
|
+
\`\`\`bash
|
|
117
|
+
# Install dependencies
|
|
118
|
+
npm install
|
|
119
|
+
|
|
120
|
+
# Validate plugin configuration
|
|
121
|
+
npm run validate
|
|
122
|
+
|
|
123
|
+
# Build for all targets
|
|
124
|
+
npm run build
|
|
125
|
+
|
|
126
|
+
# Build for specific targets
|
|
127
|
+
npx agentplugins build --target claude,codex
|
|
128
|
+
\`\`\`
|
|
129
|
+
|
|
130
|
+
## Installation
|
|
131
|
+
|
|
132
|
+
After building, install the appropriate output for your agent harness:
|
|
133
|
+
|
|
134
|
+
${targets.map(t => `### ${t}
|
|
135
|
+
\`\`\`bash
|
|
136
|
+
${getInstallCommand(t, name)}
|
|
137
|
+
\`\`\``).join('\n\n')}
|
|
138
|
+
`;
|
|
139
|
+
await writeFile(resolve(pluginDir, 'README.md'), readme);
|
|
140
|
+
console.log(chalk.green('✅ Plugin scaffolded!\n'));
|
|
141
|
+
console.log(chalk.gray('Next steps:'));
|
|
142
|
+
console.log(chalk.gray(` cd ${name}`));
|
|
143
|
+
console.log(chalk.gray(' npm install'));
|
|
144
|
+
console.log(chalk.gray(' npm run validate'));
|
|
145
|
+
console.log(chalk.gray(' npm run build\n'));
|
|
146
|
+
}
|
|
147
|
+
function toKebabCase(str) {
|
|
148
|
+
return str
|
|
149
|
+
.replace(/([a-z])([A-Z])/g, '$1-$2')
|
|
150
|
+
.replace(/[\s_]+/g, '-')
|
|
151
|
+
.replace(/[^a-zA-Z0-9-]/g, '')
|
|
152
|
+
.toLowerCase();
|
|
153
|
+
}
|
|
154
|
+
function getInstallCommand(target, name) {
|
|
155
|
+
const commands = {
|
|
156
|
+
claude: `cp -r dist/claude ~/.claude/skills/${name}`,
|
|
157
|
+
codex: `cp -r dist/codex ~/.codex/plugins/`,
|
|
158
|
+
copilot: `copilot plugin install ./dist/copilot`,
|
|
159
|
+
gemini: `gemini extensions install ./dist/gemini`,
|
|
160
|
+
kimi: `cp -r dist/kimi ~/.kimi/plugins/`,
|
|
161
|
+
opencode: `cp dist/opencode/*.ts .opencode/plugins/`,
|
|
162
|
+
pimono: `cp -r dist/pimono ~/.pi/agent/extensions/`,
|
|
163
|
+
};
|
|
164
|
+
return commands[target] || `# See ${target} documentation`;
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceR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|
1
|
+
/**
|
|
2
|
+
* AgentPlugins Validate Command
|
|
3
|
+
*
|
|
4
|
+
* Validates plugin configuration without building.
|
|
5
|
+
*/
|
|
6
|
+
import type { LoadedConfig } from '../config.js';
|
|
7
|
+
export interface ValidateOptions {
|
|
8
|
+
config: LoadedConfig;
|
|
9
|
+
targets?: string[];
|
|
10
|
+
}
|
|
11
|
+
export declare function validate(options: ValidateOptions): Promise<void>;
|
|
12
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/commands/validate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,wBAAsB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CA0CtE"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentPlugins Validate Command
|
|
3
|
+
*
|
|
4
|
+
* Validates plugin configuration without building.
|
|
5
|
+
*/
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
import { validateUniversal, validateForPlatform, ALL_TARGETS, } from '@agentplugins/core';
|
|
8
|
+
export async function validate(options) {
|
|
9
|
+
const { config } = options;
|
|
10
|
+
const manifest = config.manifest;
|
|
11
|
+
const targets = options.targets || manifest.targets || ALL_TARGETS;
|
|
12
|
+
console.log(chalk.bold('\n🔍 AgentPlugins Validation\n'));
|
|
13
|
+
console.log(chalk.gray(`Plugin: ${manifest.name} v${manifest.version}`));
|
|
14
|
+
console.log(chalk.gray(`Targets: ${targets.join(', ')}\n`));
|
|
15
|
+
// Universal validation
|
|
16
|
+
console.log(chalk.blue('Universal Rules:'));
|
|
17
|
+
const universalIssues = validateUniversal(manifest);
|
|
18
|
+
if (universalIssues.length === 0) {
|
|
19
|
+
console.log(chalk.green(' ✓ No issues found'));
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
for (const issue of universalIssues) {
|
|
23
|
+
printIssue(issue);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// Per-platform validation
|
|
27
|
+
for (const target of targets) {
|
|
28
|
+
console.log(chalk.blue(`\n${target}:`));
|
|
29
|
+
const issues = validateForPlatform(manifest, target);
|
|
30
|
+
if (issues.length === 0) {
|
|
31
|
+
console.log(chalk.green(' ✓ No issues found'));
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
for (const issue of issues) {
|
|
35
|
+
printIssue(issue);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const totalErrors = universalIssues.filter(i => i.severity === 'error').length +
|
|
40
|
+
targets.reduce((sum, t) => sum + validateForPlatform(manifest, t).filter(i => i.severity === 'error').length, 0);
|
|
41
|
+
if (totalErrors === 0) {
|
|
42
|
+
console.log(chalk.bold('\n✅ All checks passed!\n'));
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
console.log(chalk.bold(`\n❌ Found ${totalErrors} error(s)\n`));
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function printIssue(issue) {
|
|
50
|
+
const color = issue.severity === 'error' ? chalk.red : issue.severity === 'warning' ? chalk.yellow : chalk.gray;
|
|
51
|
+
const icon = issue.severity === 'error' ? '✗' : issue.severity === 'warning' ? '⚠' : 'ℹ';
|
|
52
|
+
const field = issue.field ? chalk.gray(`[${issue.field}] `) : '';
|
|
53
|
+
console.log(color(` ${icon} ${field}${issue.message}`));
|
|
54
|
+
if (issue.suggestion) {
|
|
55
|
+
console.log(chalk.cyan(` → ${issue.suggestion}`));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -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,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;IAChH,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IACzF,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACjE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,IAAI,IAAI,KAAK,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IACzD,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;QACrB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IACvD,CAAC;AACH,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentPlugins Config Loader
|
|
3
|
+
*
|
|
4
|
+
* Loads plugin configuration from agentplugins.config.ts/js/mjs/json files.
|
|
5
|
+
* Uses jiti for TypeScript support without pre-compilation.
|
|
6
|
+
*/
|
|
7
|
+
import type { PluginManifest } from '@agentplugins/core';
|
|
8
|
+
export interface LoadedConfig {
|
|
9
|
+
/** Resolved manifest */
|
|
10
|
+
manifest: PluginManifest;
|
|
11
|
+
/** Root directory of the config file */
|
|
12
|
+
root: string;
|
|
13
|
+
/** Path to the config file */
|
|
14
|
+
configPath: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Load configuration from a file path.
|
|
18
|
+
* Supports .ts, .js, .mjs, .cjs, and .json config files.
|
|
19
|
+
*/
|
|
20
|
+
export declare function loadConfig(configPath: string): Promise<LoadedConfig>;
|
|
21
|
+
/**
|
|
22
|
+
* Find config file in the current directory.
|
|
23
|
+
* Searches for: agentplugins.config.ts, .js, .mjs, .json
|
|
24
|
+
*/
|
|
25
|
+
export declare function findConfig(cwd?: string): Promise<string | null>;
|
|
26
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,WAAW,YAAY;IAC3B,wBAAwB;IACxB,QAAQ,EAAE,cAAc,CAAC;IACzB,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,8BAA8B;IAC9B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CA+C1E;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAAC,GAAG,GAAE,MAAsB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAgBpF"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentPlugins Config Loader
|
|
3
|
+
*
|
|
4
|
+
* Loads plugin configuration from agentplugins.config.ts/js/mjs/json files.
|
|
5
|
+
* Uses jiti for TypeScript support without pre-compilation.
|
|
6
|
+
*/
|
|
7
|
+
import { existsSync } from 'node:fs';
|
|
8
|
+
import { resolve, extname } from 'node:path';
|
|
9
|
+
import jiti from 'jiti';
|
|
10
|
+
// jiti's CJS default export is a function - cast to proper type
|
|
11
|
+
const createJITI = jiti;
|
|
12
|
+
/**
|
|
13
|
+
* Load configuration from a file path.
|
|
14
|
+
* Supports .ts, .js, .mjs, .cjs, and .json config files.
|
|
15
|
+
*/
|
|
16
|
+
export async function loadConfig(configPath) {
|
|
17
|
+
const resolvedPath = resolve(configPath);
|
|
18
|
+
if (!existsSync(resolvedPath)) {
|
|
19
|
+
throw new Error(`Config file not found: ${resolvedPath}`);
|
|
20
|
+
}
|
|
21
|
+
const ext = extname(resolvedPath);
|
|
22
|
+
let manifest;
|
|
23
|
+
if (ext === '.json') {
|
|
24
|
+
// JSON config
|
|
25
|
+
const { readFile } = await import('node:fs/promises');
|
|
26
|
+
const content = await readFile(resolvedPath, 'utf-8');
|
|
27
|
+
manifest = JSON.parse(content);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
// TypeScript/JavaScript config — use jiti
|
|
31
|
+
const jiti = createJITI(resolvedPath, {
|
|
32
|
+
interopDefault: true,
|
|
33
|
+
esmResolve: true,
|
|
34
|
+
});
|
|
35
|
+
const mod = await jiti.import(resolvedPath, { default: true });
|
|
36
|
+
const exported = mod?.default ?? mod;
|
|
37
|
+
if (typeof exported === 'function') {
|
|
38
|
+
manifest = await exported();
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
manifest = exported;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// Validate required fields
|
|
45
|
+
if (!manifest.name) {
|
|
46
|
+
throw new Error('Plugin manifest must have a "name" field');
|
|
47
|
+
}
|
|
48
|
+
if (!manifest.version) {
|
|
49
|
+
throw new Error('Plugin manifest must have a "version" field');
|
|
50
|
+
}
|
|
51
|
+
if (!manifest.description) {
|
|
52
|
+
throw new Error('Plugin manifest must have a "description" field');
|
|
53
|
+
}
|
|
54
|
+
// Resolve root directory
|
|
55
|
+
const root = resolve(resolvedPath, '..');
|
|
56
|
+
return { manifest, root, configPath: resolvedPath };
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Find config file in the current directory.
|
|
60
|
+
* Searches for: agentplugins.config.ts, .js, .mjs, .json
|
|
61
|
+
*/
|
|
62
|
+
export async function findConfig(cwd = process.cwd()) {
|
|
63
|
+
const candidates = [
|
|
64
|
+
'agentplugins.config.ts',
|
|
65
|
+
'agentplugins.config.js',
|
|
66
|
+
'agentplugins.config.mjs',
|
|
67
|
+
'agentplugins.config.json',
|
|
68
|
+
];
|
|
69
|
+
for (const name of candidates) {
|
|
70
|
+
const fullPath = resolve(cwd, name);
|
|
71
|
+
if (existsSync(fullPath)) {
|
|
72
|
+
return fullPath;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,gEAAgE;AAChE,MAAM,UAAU,GAAG,IAElB,CAAC;AAYF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,UAAkB;IACjD,MAAM,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAEzC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,0BAA0B,YAAY,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED,MAAM,GAAG,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAClC,IAAI,QAAwB,CAAC;IAE7B,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC;QACpB,cAAc;QACd,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;QACtD,MAAM,OAAO,GAAG,MAAM,QAAQ,CA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B;QACxB,wBAAwB;QACxB,yBAAyB;QACzB,0BAA0B;KAC3B,CAAC;IAEF,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;QAC9B,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACpC,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YACzB,OAAO,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agentplugins/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CLI for building AgentPlugins plugins across multiple AI agent harnesses",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"agentplugins": "./dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "./dist/cli.js",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"dev": "tsc --watch",
|
|
13
|
+
"clean": "rm -rf dist"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@agentplugins/core": "workspace:*",
|
|
24
|
+
"@agentplugins/adapter-claude": "workspace:*",
|
|
25
|
+
"@agentplugins/adapter-codex": "workspace:*",
|
|
26
|
+
"@agentplugins/adapter-copilot": "workspace:*",
|
|
27
|
+
"@agentplugins/adapter-gemini": "workspace:*",
|
|
28
|
+
"@agentplugins/adapter-kimi": "workspace:*",
|
|
29
|
+
"@agentplugins/adapter-opencode": "workspace:*",
|
|
30
|
+
"@agentplugins/adapter-pimono": "workspace:*",
|
|
31
|
+
"cac": "^6.7.14",
|
|
32
|
+
"chalk": "^5.3.0",
|
|
33
|
+
"jiti": "^1.21.6"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"typescript": "^5.5.0",
|
|
37
|
+
"@types/node": "^20.0.0"
|
|
38
|
+
},
|
|
39
|
+
"keywords": [
|
|
40
|
+
"agentplugins",
|
|
41
|
+
"cli",
|
|
42
|
+
"ai",
|
|
43
|
+
"plugin"
|
|
44
|
+
],
|
|
45
|
+
"license": "MIT"
|
|
46
|
+
}
|