@oneie/cli 0.5.1 → 0.5.2

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/dist/src/index.js CHANGED
@@ -25,6 +25,7 @@ import { createCmd } from './create.js';
25
25
  import { fnCmd } from './fn.js';
26
26
  import { trailCmd } from './trail.js';
27
27
  import { initCmd } from './init.js';
28
+ import { pluginCmd } from './plugin.js';
28
29
  import { readFileSync } from 'node:fs';
29
30
  import { fileURLToPath } from 'node:url';
30
31
  import { resolve, dirname } from 'node:path';
@@ -61,6 +62,7 @@ program.addCommand(createCmd());
61
62
  program.addCommand(fnCmd());
62
63
  program.addCommand(trailCmd());
63
64
  program.addCommand(initCmd());
65
+ program.addCommand(pluginCmd());
64
66
  program.parseAsync(process.argv).catch((err) => {
65
67
  const isJson = process.argv.includes('--json');
66
68
  if (isJson)
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function pluginCmd(): Command;
@@ -0,0 +1,85 @@
1
+ import { Command } from 'commander';
2
+ function out(cmd, data) {
3
+ if (process.env.ONEIE_JSON) {
4
+ process.stdout.write(JSON.stringify({ cmd, ...data }) + '\n');
5
+ }
6
+ else {
7
+ const ok = data.ok !== false;
8
+ const pairs = Object.entries(data)
9
+ .filter(([k]) => k !== 'ok')
10
+ .map(([k, v]) => `${k}=${JSON.stringify(v)}`)
11
+ .join(' ');
12
+ console.log(`${ok ? '✓' : '✗'} ${cmd} ${pairs}`);
13
+ }
14
+ }
15
+ function apiBase(opts) {
16
+ return opts.api ?? process.env.ONEIE_BASE_URL ?? 'https://one.ie';
17
+ }
18
+ function bearerHeaders(workspace) {
19
+ const key = process.env.ONEIE_API_KEY;
20
+ return key && workspace ? { Authorization: `Bearer ${workspace}:${key}` } : {};
21
+ }
22
+ export function pluginCmd() {
23
+ const cmd = new Command('plugin').description('Manage ONE plugins');
24
+ cmd
25
+ .command('list')
26
+ .description('List available plugins and their pricing')
27
+ .option('--api <url>', 'API base URL')
28
+ .action(async (opts) => {
29
+ let res;
30
+ try {
31
+ res = await fetch(`${apiBase(opts)}/api/plugins`);
32
+ }
33
+ catch (e) {
34
+ console.error(`Error: ${e instanceof Error ? e.message : e}`);
35
+ process.exit(1);
36
+ }
37
+ const body = (await res.json());
38
+ if (!res.ok || !body.plugins) {
39
+ out('plugin:list', { ok: false, error: 'fetch_failed', status: res.status });
40
+ process.exit(1);
41
+ }
42
+ for (const p of body.plugins) {
43
+ console.log(` ${p.name.padEnd(12)} ${p.title.padEnd(16)} $${p.price_usd}/mo ${p.description}`);
44
+ }
45
+ out('plugin:list', { ok: true, count: body.plugins.length });
46
+ });
47
+ cmd
48
+ .command('add <name>')
49
+ .description('Install a plugin — pulls source when workspace is entitled')
50
+ .option('--workspace <slug>', 'Workspace slug (default: ONEIE_WORKSPACE env)')
51
+ .option('--api <url>', 'API base URL')
52
+ .action(async (name, opts) => {
53
+ const workspace = opts.workspace ?? process.env.ONEIE_WORKSPACE;
54
+ if (!workspace) {
55
+ console.error('Error: --workspace or ONEIE_WORKSPACE required');
56
+ process.exit(1);
57
+ }
58
+ let res;
59
+ try {
60
+ res = await fetch(`${apiBase(opts)}/api/plugins/${name}/source`, {
61
+ headers: bearerHeaders(workspace),
62
+ });
63
+ }
64
+ catch (e) {
65
+ console.error(`Error: ${e instanceof Error ? e.message : e}`);
66
+ process.exit(1);
67
+ }
68
+ const body = (await res.json());
69
+ if (res.status === 402) {
70
+ out('plugin:add', {
71
+ ok: false,
72
+ error: 'not_entitled',
73
+ plugin: name,
74
+ hint: body.hint ?? `Purchase the ${name} plugin at https://one.ie/marketplace`,
75
+ });
76
+ process.exit(1);
77
+ }
78
+ if (!res.ok) {
79
+ out('plugin:add', { ok: false, error: body.error ?? 'unknown', plugin: name, status: res.status });
80
+ process.exit(1);
81
+ }
82
+ out('plugin:add', { ok: true, plugin: name, source: body.source, install: body.install });
83
+ });
84
+ return cmd;
85
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneie/cli",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "ONE agent CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -19,8 +19,8 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "commander": "^12.0.0",
22
- "@oneie/sdk": "^0.14.0",
23
- "@oneie/evals": "^0.1.0"
22
+ "@oneie/sdk": "^0.14.2",
23
+ "@oneie/evals": "workspace:*"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/node": "^25.6.0",