@oneie/cli 0.5.0 → 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/agent.js CHANGED
@@ -84,6 +84,7 @@ export function agentCmd() {
84
84
  .option('--name <name>', 'Override agent name (defaults to frontmatter name:)')
85
85
  .option('--target <t>', 'Publish target: oneie (default) | agentverse', 'oneie')
86
86
  .option('--agentverse-key <key>', 'Agentverse API key (or set AGENTVERSE_API_KEY)')
87
+ .option('--live', 'Set lifecycle: active before publishing (skip the draft step)')
87
88
  .action(async (path, opts) => {
88
89
  if (!existsSync(path)) {
89
90
  out(cmd, { ok: false, error: `not found: ${path}` });
@@ -94,7 +95,9 @@ export function agentCmd() {
94
95
  out(cmd, { ok: false, errors });
95
96
  return;
96
97
  }
97
- const content = readFileSync(path, 'utf8');
98
+ let content = readFileSync(path, 'utf8');
99
+ if (opts.live)
100
+ content = content.replace(/^lifecycle:\s*draft/m, 'lifecycle: active');
98
101
  const frontmatterName = /^name:\s*(\S+)/m.exec(content)?.[1];
99
102
  const agentName = opts.name ?? frontmatterName ?? basename(path, '.md');
100
103
  // ── Agentverse deploy path ────────────────────────────────────────────
@@ -165,6 +165,44 @@ export function createCmd() {
165
165
  process.stdout.write(` # Edit partner.toml — set slug and name\n`);
166
166
  process.stdout.write(` one setup\n`);
167
167
  });
168
+ // ── one create client-repo [name] ───────────────────────────────────────
169
+ cmd
170
+ .command('client-repo [name]')
171
+ .description('Scaffold a single-business workspace from github.com/one-ie/client')
172
+ .option('--ref <ref>', 'Git ref to download', 'main')
173
+ .option('--slug <slug>', 'Workspace slug (written into workspace.toml)')
174
+ .option('--name <name>', 'Display name (written into workspace.toml)')
175
+ .action((dirName, opts) => {
176
+ if (!SAFE_REF.test(opts.ref)) {
177
+ process.stderr.write(`Invalid ref: ${opts.ref}\n`);
178
+ process.exit(1);
179
+ }
180
+ const label = dirName ?? opts.slug ?? 'my-business';
181
+ const dir = resolve(process.cwd(), label);
182
+ if (existsSync(dir)) {
183
+ process.stderr.write(`Directory already exists: ${dir}\n`);
184
+ process.exit(1);
185
+ }
186
+ process.stdout.write(`Creating client workspace at ${dir}...\n`);
187
+ downloadTarball(`https://api.github.com/repos/one-ie/client/tarball/${opts.ref}`, dir);
188
+ const tomlPath = join(dir, 'workspace.toml');
189
+ if (existsSync(tomlPath) && (opts.slug ?? opts.name)) {
190
+ let toml = readFileSync(tomlPath, 'utf8');
191
+ if (opts.slug)
192
+ toml = toml.replace(/^slug\s*=\s*"[^"]*"/m, `slug = "${opts.slug}"`);
193
+ if (opts.name)
194
+ toml = toml.replace(/^name\s*=\s*"[^"]*"/m, `name = "${opts.name}"`);
195
+ writeFileSync(tomlPath, toml);
196
+ }
197
+ process.stdout.write(`\nWorkspace created.\n\n`);
198
+ process.stdout.write(`Next steps:\n`);
199
+ process.stdout.write(` cd ${label}\n`);
200
+ process.stdout.write(` cp .env.example .env.local\n`);
201
+ process.stdout.write(` # Edit .env.local — set ONE_API_KEY\n`);
202
+ if (!opts.slug)
203
+ process.stdout.write(` # Edit workspace.toml — set slug and name\n`);
204
+ process.stdout.write(` one setup\n`);
205
+ });
168
206
  // ── one create site [name] ────────────────────────────────────────────────
169
207
  cmd
170
208
  .command('site [name]')
package/dist/src/index.js CHANGED
@@ -24,6 +24,8 @@ import { coordinateCommands } from './coordinate.js';
24
24
  import { createCmd } from './create.js';
25
25
  import { fnCmd } from './fn.js';
26
26
  import { trailCmd } from './trail.js';
27
+ import { initCmd } from './init.js';
28
+ import { pluginCmd } from './plugin.js';
27
29
  import { readFileSync } from 'node:fs';
28
30
  import { fileURLToPath } from 'node:url';
29
31
  import { resolve, dirname } from 'node:path';
@@ -59,6 +61,8 @@ substrateCommands(program);
59
61
  program.addCommand(createCmd());
60
62
  program.addCommand(fnCmd());
61
63
  program.addCommand(trailCmd());
64
+ program.addCommand(initCmd());
65
+ program.addCommand(pluginCmd());
62
66
  program.parseAsync(process.argv).catch((err) => {
63
67
  const isJson = process.argv.includes('--json');
64
68
  if (isJson)
@@ -0,0 +1,11 @@
1
+ /**
2
+ * oneie init — provision a workspace in one command.
3
+ *
4
+ * Calls POST /api/provision/agent with the provided options, writes the
5
+ * returned scoped key to ~/.config/oneie/key, and prints the workspace URL
6
+ * + invite link.
7
+ *
8
+ * No prior account or API key required. The server mints everything.
9
+ */
10
+ import { Command } from 'commander';
11
+ export declare function initCmd(): Command;
@@ -0,0 +1,107 @@
1
+ /**
2
+ * oneie init — provision a workspace in one command.
3
+ *
4
+ * Calls POST /api/provision/agent with the provided options, writes the
5
+ * returned scoped key to ~/.config/oneie/key, and prints the workspace URL
6
+ * + invite link.
7
+ *
8
+ * No prior account or API key required. The server mints everything.
9
+ */
10
+ import { Command } from 'commander';
11
+ import { writeFileSync, mkdirSync } from 'node:fs';
12
+ import { resolve } from 'node:path';
13
+ import { homedir } from 'node:os';
14
+ import { renameSync, chmodSync } from 'node:fs';
15
+ import { join } from 'node:path';
16
+ const DEFAULT_API = process.env.ONEIE_BASE_URL ?? 'https://one.ie';
17
+ const CONFIG_DIR = resolve(homedir(), '.config', 'oneie');
18
+ const KEY_FILE = resolve(CONFIG_DIR, 'key');
19
+ function writeKey(value) {
20
+ mkdirSync(CONFIG_DIR, { recursive: true });
21
+ const tmp = join(CONFIG_DIR, '.key.tmp');
22
+ writeFileSync(tmp, value, { mode: 0o600 });
23
+ chmodSync(tmp, 0o600);
24
+ renameSync(tmp, KEY_FILE);
25
+ }
26
+ function out(cmd, data) {
27
+ const isJson = cmd.parent?.opts().json;
28
+ if (isJson) {
29
+ process.stdout.write(JSON.stringify(data) + '\n');
30
+ }
31
+ else if (data.ok) {
32
+ const lines = Object.entries(data)
33
+ .filter(([k]) => k !== 'ok')
34
+ .map(([k, v]) => ` ${k}: ${v}`)
35
+ .join('\n');
36
+ process.stdout.write(`✓ workspace ready\n${lines}\n`);
37
+ }
38
+ else {
39
+ process.stderr.write(`✗ ${data.error ?? 'failed'}\n`);
40
+ }
41
+ }
42
+ function defaultAgentMd(name) {
43
+ const slug = name.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '');
44
+ return `---
45
+ name: ${slug}
46
+ kind: agent
47
+ title: ${name}
48
+ model: claude-sonnet-4-6
49
+ channels: [web, api]
50
+ group: default
51
+ sensitivity: 0.5
52
+ lifecycle: active
53
+ ---
54
+
55
+ You are ${name}. Answer questions clearly and helpfully.
56
+ When you complete a task, summarise what you did in one sentence.
57
+ `;
58
+ }
59
+ export function initCmd() {
60
+ const cmd = new Command('init')
61
+ .description('Provision a new workspace in one command — no account required')
62
+ .option('--name <name>', 'Workspace / agent display name')
63
+ .option('--email <email>', 'Owner email — receives an invite link')
64
+ .option('--skills <refs>', 'Comma-separated skill refs to import (e.g. cold-email,calendar-lookup)')
65
+ .option('--no-content', 'Skip generating a starter agent.md')
66
+ .option('--api <url>', 'API base URL', DEFAULT_API)
67
+ .action(async (opts) => {
68
+ const name = opts.name ?? 'My Agent';
69
+ const skills = opts.skills ? opts.skills.split(',').map(s => s.trim()).filter(Boolean) : [];
70
+ const content = opts.content !== false ? defaultAgentMd(name) : undefined;
71
+ const body = { name, live: true };
72
+ if (content)
73
+ body.content = content;
74
+ if (skills.length)
75
+ body.skills = skills;
76
+ if (opts.email)
77
+ body.invite = { email: opts.email, role: 'owner' };
78
+ let res;
79
+ try {
80
+ res = await fetch(`${opts.api.replace(/\/$/, '')}/api/provision/agent`, {
81
+ method: 'POST',
82
+ headers: { 'Content-Type': 'application/json' },
83
+ body: JSON.stringify(body),
84
+ });
85
+ }
86
+ catch (err) {
87
+ out(cmd, { ok: false, error: `network error: ${err.message}` });
88
+ return;
89
+ }
90
+ const json = await res.json();
91
+ if (!res.ok) {
92
+ out(cmd, { ok: false, ...json });
93
+ return;
94
+ }
95
+ const { workspace, apiKey, inviteUrl } = json;
96
+ writeKey(apiKey);
97
+ out(cmd, {
98
+ ok: true,
99
+ workspace,
100
+ url: `${opts.api.replace(/\/$/, '')}/u/${workspace}`,
101
+ key: `${KEY_FILE} (0600)`,
102
+ ...(inviteUrl ? { invite: inviteUrl } : {}),
103
+ ...(skills.length ? { skills: skills.join(', ') } : {}),
104
+ });
105
+ });
106
+ return cmd;
107
+ }
@@ -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/dist/src/setup.js CHANGED
@@ -32,7 +32,11 @@ export function setupCmd() {
32
32
  ? `${dir}/_node.toml`
33
33
  : existsSync(`${dir}/agency.toml`)
34
34
  ? `${dir}/agency.toml`
35
- : `${dir}/partner.toml`;
35
+ : existsSync(`${dir}/partner.toml`)
36
+ ? `${dir}/partner.toml`
37
+ : existsSync(`${dir}/workspace.toml`)
38
+ ? `${dir}/workspace.toml`
39
+ : `${dir}/agency.toml`;
36
40
  const agency = readAgency(cfgPath);
37
41
  const base = opts.api.replace(/\/$/, '');
38
42
  const ws = await ask(base, key, 'world:create-workspace', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneie/cli",
3
- "version": "0.5.0",
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",