@oneie/cli 0.5.7 → 0.6.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/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneie/cli",
3
- "version": "0.5.7",
3
+ "version": "0.6.0",
4
4
  "description": "ONE agent CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -21,13 +21,21 @@ function downloadTarball(url, targetDir) {
21
21
  throw new Error(`tar failed extracting to ${targetDir}`);
22
22
  }
23
23
  function downloadSubdir(url, subdir, targetDir) {
24
+ downloadSubdirs(url, [{ subdir, targetDir }]);
25
+ }
26
+ // One tarball fetch, multiple subdirs copied out of it — e.g. a node's own
27
+ // content plus the shared apps/web site composed into <dir>/site/. Avoids a
28
+ // second GitHub API round-trip per extra subdir.
29
+ function downloadSubdirs(url, copies) {
24
30
  const tmp = mkdtempSync(join(tmpdir(), 'one-create-'));
25
31
  try {
26
32
  downloadTarball(url, tmp);
27
- mkdirSync(targetDir, { recursive: true });
28
- const r = spawnSync('cp', ['-r', join(tmp, subdir, '.'), targetDir], { stdio: 'inherit' });
29
- if (r.status !== 0)
30
- throw new Error('cp failed');
33
+ for (const { subdir, targetDir } of copies) {
34
+ mkdirSync(targetDir, { recursive: true });
35
+ const r = spawnSync('cp', ['-r', join(tmp, subdir, '.'), targetDir], { stdio: 'inherit' });
36
+ if (r.status !== 0)
37
+ throw new Error(`cp failed for ${subdir}`);
38
+ }
31
39
  }
32
40
  finally {
33
41
  spawnSync('rm', ['-rf', tmp]);
@@ -38,7 +46,7 @@ export function createCmd() {
38
46
  // ── one create agency [name] ──────────────────────────────────────────────
39
47
  cmd
40
48
  .command('agency [name]')
41
- .description('Scaffold a new agency node from github.com/one-ie/oo')
49
+ .description('Scaffold a new agency node from github.com/one-ie/one (apps/agency)')
42
50
  .option('--ref <ref>', 'Git ref to download', 'main')
43
51
  .option('--slug <slug>', 'Your agency slug (written into agency.toml)')
44
52
  .option('--name <name>', 'Your agency display name (written into agency.toml)')
@@ -54,7 +62,11 @@ export function createCmd() {
54
62
  process.exit(1);
55
63
  }
56
64
  process.stdout.write(`Creating agency node at ${dir}...\n`);
57
- downloadTarball(`https://api.github.com/repos/one-ie/oo/tarball/${opts.ref}`, dir);
65
+ downloadSubdirs(`https://api.github.com/repos/one-ie/one/tarball/${opts.ref}`, [
66
+ { subdir: 'apps/agency', targetDir: dir },
67
+ { subdir: 'apps/_shared', targetDir: dir },
68
+ { subdir: 'apps/web', targetDir: join(dir, 'site') },
69
+ ]);
58
70
  // Patch agency.toml with the user's slug + name so they don't have to
59
71
  const tomlPath = join(dir, 'agency.toml');
60
72
  if (existsSync(tomlPath) && (opts.slug ?? opts.name)) {
@@ -167,8 +179,8 @@ export function createCmd() {
167
179
  });
168
180
  // ── one create client-repo [name] ───────────────────────────────────────
169
181
  cmd
170
- .command('client-repo [name]')
171
- .description('Scaffold a single-business workspace from github.com/one-ie/client')
182
+ .command('client-repo [name]', { isDefault: true })
183
+ .description('Scaffold a single-business workspace from github.com/one-ie/one (apps/client) — the default, free plan')
172
184
  .option('--ref <ref>', 'Git ref to download', 'main')
173
185
  .option('--slug <slug>', 'Workspace slug (written into workspace.toml)')
174
186
  .option('--name <name>', 'Display name (written into workspace.toml)')
@@ -183,8 +195,12 @@ export function createCmd() {
183
195
  process.stderr.write(`Directory already exists: ${dir}\n`);
184
196
  process.exit(1);
185
197
  }
186
- process.stdout.write(`Creating client workspace at ${dir}...\n`);
187
- downloadTarball(`https://api.github.com/repos/one-ie/client/tarball/${opts.ref}`, dir);
198
+ process.stdout.write(`Creating business workspace at ${dir}...\n`);
199
+ downloadSubdirs(`https://api.github.com/repos/one-ie/one/tarball/${opts.ref}`, [
200
+ { subdir: 'apps/client', targetDir: dir },
201
+ { subdir: 'apps/_shared', targetDir: dir },
202
+ { subdir: 'apps/web', targetDir: join(dir, 'site') },
203
+ ]);
188
204
  const tomlPath = join(dir, 'workspace.toml');
189
205
  if (existsSync(tomlPath) && (opts.slug ?? opts.name)) {
190
206
  let toml = readFileSync(tomlPath, 'utf8');
@@ -194,14 +210,16 @@ export function createCmd() {
194
210
  toml = toml.replace(/^name\s*=\s*"[^"]*"/m, `name = "${opts.name}"`);
195
211
  writeFileSync(tomlPath, toml);
196
212
  }
197
- process.stdout.write(`\nWorkspace created.\n\n`);
213
+ process.stdout.write(`\nWorkspace created — free plan, no credit card.\n\n`);
198
214
  process.stdout.write(`Next steps:\n`);
199
215
  process.stdout.write(` cd ${label}\n`);
200
216
  process.stdout.write(` cp .env.example .env.local\n`);
201
- process.stdout.write(` # Edit .env.local — set ONE_API_KEY\n`);
217
+ process.stdout.write(` # Edit .env.local — set WORKSPACE_OWNER_EMAIL\n`);
202
218
  if (!opts.slug)
203
219
  process.stdout.write(` # Edit workspace.toml — set slug and name\n`);
204
- process.stdout.write(` one setup\n`);
220
+ process.stdout.write(` one setup\n\n`);
221
+ process.stdout.write(`Outgrew a single business? \`npx oneie create agency\` unlocks reselling\n`);
222
+ process.stdout.write(`to multiple clients (agency plan) — see README.md.\n`);
205
223
  });
206
224
  // ── one create site [name] ────────────────────────────────────────────────
207
225
  cmd
package/dist/src/init.js CHANGED
@@ -13,6 +13,7 @@ import { resolve } from 'node:path';
13
13
  import { homedir } from 'node:os';
14
14
  import { renameSync, chmodSync } from 'node:fs';
15
15
  import { join } from 'node:path';
16
+ import { mergeEnv, writeEnvLocal } from './env.js';
16
17
  const DEFAULT_API = process.env.ONEIE_BASE_URL ?? 'https://one.ie';
17
18
  const CONFIG_DIR = resolve(homedir(), '.config', 'oneie');
18
19
  const KEY_FILE = resolve(CONFIG_DIR, 'key');
@@ -64,7 +65,16 @@ export function initCmd() {
64
65
  .option('--skills <refs>', 'Comma-separated skill refs to import (e.g. cold-email,calendar-lookup)')
65
66
  .option('--no-content', 'Skip generating a starter agent.md')
66
67
  .option('--api <url>', 'API base URL', DEFAULT_API)
68
+ .option('--write-env', 'Also write ONE_API_KEY to .env.local in the current directory')
67
69
  .action(async (opts) => {
70
+ const dir = process.cwd();
71
+ if (opts.writeEnv) {
72
+ const env = mergeEnv(dir);
73
+ if (env.ONE_API_KEY) {
74
+ out(cmd, { ok: true, note: 'already connected — .env.local has ONE_API_KEY' });
75
+ return;
76
+ }
77
+ }
68
78
  const name = opts.name ?? 'My Agent';
69
79
  const skills = opts.skills ? opts.skills.split(',').map(s => s.trim()).filter(Boolean) : [];
70
80
  const content = opts.content !== false ? defaultAgentMd(name) : undefined;
@@ -94,11 +104,15 @@ export function initCmd() {
94
104
  }
95
105
  const { workspace, apiKey, inviteUrl } = json;
96
106
  writeKey(apiKey);
107
+ if (opts.writeEnv) {
108
+ writeEnvLocal(dir, { ONE_API_KEY: apiKey, ONE_API_URL: opts.api });
109
+ }
97
110
  out(cmd, {
98
111
  ok: true,
99
112
  workspace,
100
113
  url: `${opts.api.replace(/\/$/, '')}/u/${workspace}`,
101
114
  key: `${KEY_FILE} (0600)`,
115
+ ...(opts.writeEnv ? { env: `${dir}/.env.local`, mcp: 'export ONE_API_KEY before launching Claude Code — MCP reads the shell env, not .env.local directly' } : {}),
102
116
  ...(inviteUrl ? { invite: inviteUrl } : {}),
103
117
  ...(skills.length ? { skills: skills.join(', ') } : {}),
104
118
  });
@@ -81,5 +81,75 @@ export function pluginCmd() {
81
81
  }
82
82
  out('plugin:add', { ok: true, plugin: name, source: body.source, install: body.install });
83
83
  });
84
+ cmd
85
+ .command('buy <name>')
86
+ .description('Buy a plugin — card (default) or the workspace credit pool (--credits)')
87
+ .option('--workspace <slug>', 'Workspace slug (default: ONEIE_WORKSPACE env)')
88
+ .option('--credits', 'Pay from the workspace credit pool instead of card')
89
+ .option('--api <url>', 'API base URL')
90
+ .action(async (name, opts) => {
91
+ const workspace = opts.workspace ?? process.env.ONEIE_WORKSPACE;
92
+ if (!workspace) {
93
+ console.error('Error: --workspace or ONEIE_WORKSPACE required');
94
+ process.exit(1);
95
+ }
96
+ const method = opts.credits ? 'credits' : 'stripe';
97
+ let res;
98
+ try {
99
+ res = await fetch(`${apiBase(opts)}/api/ask/plugins:buy`, {
100
+ method: 'POST',
101
+ headers: { ...bearerHeaders(workspace), 'Content-Type': 'application/json' },
102
+ body: JSON.stringify({ data: { name, method } }),
103
+ });
104
+ }
105
+ catch (e) {
106
+ console.error(`Error: ${e instanceof Error ? e.message : e}`);
107
+ process.exit(1);
108
+ }
109
+ const env = (await res.json().catch(() => ({})));
110
+ const r = env.result ?? {};
111
+ if (!res.ok || env.outcome !== 'result' || r.error) {
112
+ out('plugin:buy', { ok: false, plugin: name, error: r.error ?? env.outcome ?? 'failed', status: res.status });
113
+ process.exit(1);
114
+ }
115
+ if (method === 'credits') {
116
+ out('plugin:buy', { ok: true, plugin: name, method, entitled: r.entitled, credits_spent: r.credits_spent, install: `one plugin add ${name}` });
117
+ }
118
+ else {
119
+ out('plugin:buy', { ok: true, plugin: name, method, checkout_url: r.url, note: 'Open checkout_url to pay, then: one plugin add ' + name });
120
+ }
121
+ });
122
+ cmd
123
+ .command('grant <name>')
124
+ .description('Resell a plugin to a client you control — grants the entitlement, no charge')
125
+ .requiredOption('--to <client>', 'Client workspace slug to grant the plugin to')
126
+ .option('--workspace <slug>', 'Your (reseller) workspace slug (default: ONEIE_WORKSPACE env)')
127
+ .option('--api <url>', 'API base URL')
128
+ .action(async (name, opts) => {
129
+ const workspace = opts.workspace ?? process.env.ONEIE_WORKSPACE;
130
+ if (!workspace) {
131
+ console.error('Error: --workspace or ONEIE_WORKSPACE required');
132
+ process.exit(1);
133
+ }
134
+ let res;
135
+ try {
136
+ res = await fetch(`${apiBase(opts)}/api/ask/plugins:grant`, {
137
+ method: 'POST',
138
+ headers: { ...bearerHeaders(workspace), 'Content-Type': 'application/json' },
139
+ body: JSON.stringify({ data: { name, for: opts.to } }),
140
+ });
141
+ }
142
+ catch (e) {
143
+ console.error(`Error: ${e instanceof Error ? e.message : e}`);
144
+ process.exit(1);
145
+ }
146
+ const env = (await res.json().catch(() => ({})));
147
+ const r = env.result ?? {};
148
+ if (!res.ok || env.outcome !== 'result' || r.error) {
149
+ out('plugin:grant', { ok: false, plugin: name, client: opts.to, error: r.error ?? env.outcome ?? 'failed', status: res.status });
150
+ process.exit(1);
151
+ }
152
+ out('plugin:grant', { ok: true, plugin: name, client: opts.to, already: r.already ?? false, note: `Client ${opts.to} is now entitled to ${name}` });
153
+ });
84
154
  return cmd;
85
155
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneie/cli",
3
- "version": "0.5.7",
3
+ "version": "0.6.0",
4
4
  "description": "ONE agent CLI",
5
5
  "type": "module",
6
6
  "bin": {