@oneie/cli 4.0.0 → 4.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneie/cli",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "ONE agent CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1 @@
1
+ export declare function displayBanner(): void;
@@ -0,0 +1,16 @@
1
+ // The ONE wordmark — ported from legacy 3.8.3's banner.js, plain stdout
2
+ // (no chalk: the current CLI stays dependency-lean). Shown only on the
3
+ // human-TTY paths (bare invocation, `create`) — never for an agent shell,
4
+ // which wants signal, not decoration.
5
+ export function displayBanner() {
6
+ process.stdout.write(`
7
+ ██████╗ ███╗ ██╗███████╗
8
+ ██╔═══██╗████╗ ██║██╔════╝
9
+ ██║ ██║██╔██╗ ██║█████╗
10
+ ██║ ██║██║╚██╗██║██╔══╝
11
+ ╚██████╔╝██║ ╚████║███████╗
12
+ ╚═════╝ ╚═╝ ╚═══╝╚══════╝
13
+ Turn ideas into reality — https://one.ie
14
+
15
+ `);
16
+ }
@@ -1,8 +1,9 @@
1
1
  import { Command } from 'commander';
2
2
  import { authHeaders, resolveBase } from './lib/client.js';
3
+ import { askPath } from './lib/api-path.js';
3
4
  const DEFAULT_API = resolveBase({}, 'https://api.one.ie');
4
5
  async function ask(api, receiver, data) {
5
- const res = await fetch(`${api.replace(/\/$/, '')}/api/ask/${encodeURIComponent(receiver)}`, {
6
+ const res = await fetch(askPath(api.replace(/\/$/, ''), receiver), {
6
7
  method: 'POST',
7
8
  headers: authHeaders(),
8
9
  body: JSON.stringify({ data }),
@@ -29,7 +29,11 @@ async function ask(base, key, receiver, data) {
29
29
  const body = await res.text().catch(() => '');
30
30
  throw new Error(`${receiver} → ${res.status}\n${body}`);
31
31
  }
32
- return res.json();
32
+ const json = await res.json();
33
+ // Four-outcome envelope: unwrap { outcome, result } (bare shape passes through).
34
+ if (json.outcome === 'failure')
35
+ throw new Error(`${receiver} → failure: ${JSON.stringify(json.result ?? {})}`);
36
+ return (json.result ?? json);
33
37
  }
34
38
  export function clientCmd() {
35
39
  const cmd = new Command('client').description('Manage client nodes');
@@ -62,7 +66,9 @@ export function clientCmd() {
62
66
  process.stderr.write('AGENCY_SLUG missing — run `one setup` first\n');
63
67
  process.exit(1);
64
68
  }
65
- const data = await ask(opts.api.replace(/\/$/, ''), key, 'billing:clients', {});
69
+ // slug required for staff/owner keys — {} resolves the key's personal
70
+ // workspace and returns an empty portfolio.
71
+ const data = await ask(opts.api.replace(/\/$/, ''), key, 'billing:clients', { slug: agencySlug });
66
72
  if (opts.json) {
67
73
  process.stdout.write(JSON.stringify(data, null, 2) + '\n');
68
74
  return;
@@ -2,6 +2,9 @@ import { Command } from 'commander';
2
2
  import { mkdirSync, readFileSync, writeFileSync, existsSync } from 'node:fs';
3
3
  import { resolve, join } from 'node:path';
4
4
  import { spawnSync } from 'node:child_process';
5
+ import { displayBanner } from './banner.js';
6
+ import { maybeLaunchClaude } from './lib/launch-claude.js';
7
+ import { isAgentEnvironment } from './lib/agent-env.js';
5
8
  const SAFE_REF = /^[A-Za-z0-9._/-]+$/;
6
9
  function downloadTarball(url, targetDir) {
7
10
  mkdirSync(targetDir, { recursive: true });
@@ -32,11 +35,14 @@ export function createCmd() {
32
35
  .option('--ref <ref>', 'Git ref to download', 'main')
33
36
  .option('--slug <slug>', 'Workspace slug (written into workspace.toml)')
34
37
  .option('--name <name>', 'Display name (written into workspace.toml)')
35
- .action((dirName, opts) => {
38
+ .action(async (dirName, opts) => {
36
39
  if (!SAFE_REF.test(opts.ref)) {
37
40
  process.stderr.write(`Invalid ref: ${opts.ref}\n`);
38
41
  process.exit(1);
39
42
  }
43
+ const humanTTY = !isAgentEnvironment();
44
+ if (humanTTY)
45
+ displayBanner();
40
46
  const label = dirName ?? opts.slug ?? 'my-business';
41
47
  const dir = resolve(process.cwd(), label);
42
48
  if (existsSync(dir)) {
@@ -63,6 +69,7 @@ export function createCmd() {
63
69
  if (!opts.slug)
64
70
  process.stdout.write(` # Edit workspace.toml — set slug and name\n`);
65
71
  process.stdout.write(` one setup\n`);
72
+ await maybeLaunchClaude(dir);
66
73
  });
67
74
  // ── one create partner [name] ────────────────────────────────────────────
68
75
  cmd
package/dist/src/index.js CHANGED
@@ -5,6 +5,7 @@ import { skillCmd } from './skill.js';
5
5
  import { authCmd, buildLoginCommand } from './auth.js';
6
6
  import { doctorCmd, whoamiCmd } from './doctor.js';
7
7
  import { isAgentEnvironment } from './lib/agent-env.js';
8
+ import { displayBanner } from './banner.js';
8
9
  import { devCmd } from './dev.js';
9
10
  import { groupCmd } from './group.js';
10
11
  import { socialCmd } from './social.js';
@@ -85,8 +86,8 @@ if (process.argv.length === 2) {
85
86
  ' oneie --help # full command reference\n');
86
87
  }
87
88
  else {
88
- process.stdout.write('oneie — ONE, the agent CLI.\n\n' +
89
- ' npx oneie create <name> # scaffold a new workspace\n' +
89
+ displayBanner();
90
+ process.stdout.write(' npx oneie create <name> # scaffold a new workspace\n' +
90
91
  ' oneie --help # full command reference\n');
91
92
  }
92
93
  process.exit(0);
@@ -0,0 +1,5 @@
1
+ /** Offer to launch Claude Code in a freshly scaffolded node — port of legacy
2
+ * 3.8.3's launch-claude.js, zero new deps (no chalk/prompts: readline is a
3
+ * node builtin). Only ever prompts a real human TTY; an agent shell or
4
+ * non-interactive run gets the manual instructions and nothing hangs. */
5
+ export declare function maybeLaunchClaude(dir: string): Promise<void>;
@@ -0,0 +1,45 @@
1
+ import { spawn, spawnSync } from 'node:child_process';
2
+ import { createInterface } from 'node:readline/promises';
3
+ import { isAgentEnvironment } from './agent-env.js';
4
+ function isClaudeInstalled() {
5
+ return spawnSync('which', ['claude'], { stdio: 'ignore' }).status === 0;
6
+ }
7
+ async function confirm(question) {
8
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
9
+ try {
10
+ const answer = (await rl.question(`${question} [Y/n] `)).trim().toLowerCase();
11
+ return answer === '' || answer === 'y' || answer === 'yes';
12
+ }
13
+ finally {
14
+ rl.close();
15
+ }
16
+ }
17
+ /** Offer to launch Claude Code in a freshly scaffolded node — port of legacy
18
+ * 3.8.3's launch-claude.js, zero new deps (no chalk/prompts: readline is a
19
+ * node builtin). Only ever prompts a real human TTY; an agent shell or
20
+ * non-interactive run gets the manual instructions and nothing hangs. */
21
+ export async function maybeLaunchClaude(dir) {
22
+ const claudeInstalled = isClaudeInstalled();
23
+ const canPrompt = claudeInstalled && process.stdin.isTTY === true && !isAgentEnvironment();
24
+ if (canPrompt) {
25
+ const launch = await confirm('\nLaunch Claude Code now?');
26
+ if (launch) {
27
+ process.stdout.write('\nLaunching Claude Code — type /do to start building.\n\n');
28
+ await new Promise((done) => {
29
+ const claude = spawn('claude', [], { stdio: 'inherit', cwd: dir });
30
+ claude.on('exit', () => done());
31
+ claude.on('error', (err) => {
32
+ process.stderr.write(`Failed to launch Claude Code: ${err.message}\n`);
33
+ done();
34
+ });
35
+ });
36
+ return;
37
+ }
38
+ }
39
+ process.stdout.write('\nOpen it:\n');
40
+ process.stdout.write(` cd ${dir}\n`);
41
+ if (!claudeInstalled) {
42
+ process.stdout.write(' # Install Claude Code: https://claude.com/product/claude-code\n');
43
+ }
44
+ process.stdout.write(' claude # then type /do to start building\n');
45
+ }
package/dist/src/links.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import { Command } from 'commander';
2
2
  import { authHeaders, resolveBase } from './lib/client.js';
3
+ import { askPath } from './lib/api-path.js';
3
4
  const DEFAULT_API = resolveBase({}, 'https://api.one.ie');
4
5
  async function ask(api, receiver, data) {
5
- const res = await fetch(`${api.replace(/\/$/, '')}/api/ask/${encodeURIComponent(receiver)}`, {
6
+ const res = await fetch(askPath(api.replace(/\/$/, ''), receiver), {
6
7
  method: 'POST',
7
8
  headers: authHeaders(),
8
9
  body: JSON.stringify({ data }),
@@ -17,6 +17,7 @@ import { writeFileSync, mkdirSync, renameSync, chmodSync } from 'node:fs';
17
17
  import { resolve, join } from 'node:path';
18
18
  import { homedir } from 'node:os';
19
19
  import { mergeEnv, writeEnvLocal } from './env.js';
20
+ import { askPath } from './lib/api-path.js';
20
21
  const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://one.ie';
21
22
  const CONFIG_DIR = resolve(homedir(), '.config', 'oneie');
22
23
  const KEY_FILE = resolve(CONFIG_DIR, 'key');
@@ -28,7 +29,7 @@ function writeKey(value) {
28
29
  renameSync(tmp, KEY_FILE);
29
30
  }
30
31
  async function ask(base, key, receiver, data) {
31
- const res = await fetch(`${base}/api/ask/${encodeURIComponent(receiver)}`, {
32
+ const res = await fetch(askPath(base, receiver), {
32
33
  method: 'POST',
33
34
  headers: { 'Content-Type': 'application/json', ...(key ? { Authorization: `Bearer ${key}` } : {}) },
34
35
  body: JSON.stringify({ data }),
package/dist/src/push.js CHANGED
@@ -1,13 +1,14 @@
1
1
  import { Command } from 'commander';
2
2
  import { compileNode } from './compiler.js';
3
3
  import { mergeEnv } from './env.js';
4
+ import { askPath } from './lib/api-path.js';
4
5
  const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
5
6
  function apiKey(env) {
6
7
  return env.ONEIE_API_KEY ?? env.ONE_API_KEY ?? process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
7
8
  }
8
9
  async function ask(base, headers, receiver, data) {
9
10
  try {
10
- const res = await fetch(`${base}/api/ask/${encodeURIComponent(receiver)}`, {
11
+ const res = await fetch(askPath(base, receiver), {
11
12
  method: 'POST', headers, body: JSON.stringify({ data }),
12
13
  });
13
14
  if (!res.ok)
@@ -66,7 +67,7 @@ export function pushCmd() {
66
67
  // Standard items (agents, skills, context, lifecycles, types …) — explicit-slug receivers
67
68
  // authorize via the ownership walk, so the configured key covers owned child workspaces.
68
69
  for (const item of compiled.filter((i) => !isWorkflow(i))) {
69
- const res = await fetch(`${base}/api/ask/${encodeURIComponent(item.receiver)}`, {
70
+ const res = await fetch(askPath(base, item.receiver), {
70
71
  method: 'POST', headers: authHeaders, body: JSON.stringify({ data: item.payload }),
71
72
  });
72
73
  if (res.ok)
@@ -1,6 +1,7 @@
1
1
  export interface AgencyPL {
2
2
  slug: string;
3
3
  name: string | null;
4
+ plan: string;
4
5
  markup_pct: number;
5
6
  pool: number;
6
7
  }
@@ -25,7 +25,7 @@ export function renderClientTable(clients, markupPct) {
25
25
  }
26
26
  export function renderStatus(agency, clients) {
27
27
  const out = [];
28
- out.push(`Agency: ${agency.name ?? agency.slug} (${agency.slug}) plan=agency markup=${agency.markup_pct}% pool=${fmt(agency.pool)} cr`);
28
+ out.push(`Agency: ${agency.name ?? agency.slug} (${agency.slug}) plan=${agency.plan} markup=${agency.markup_pct}% pool=${fmt(agency.pool)} cr`);
29
29
  out.push('');
30
30
  out.push(renderClientTable(clients, agency.markup_pct));
31
31
  return out.join('\n');
package/dist/src/setup.js CHANGED
@@ -2,10 +2,11 @@ import { Command } from 'commander';
2
2
  import { existsSync, readFileSync, writeFileSync } from 'node:fs';
3
3
  import { mergeEnv, writeEnvLocal } from './env.js';
4
4
  import { readAgency } from './config.js';
5
+ import { askPath } from './lib/api-path.js';
5
6
  const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
6
7
  const DEFAULT_WEB = process.env.ONEIE_BASE_URL ?? 'https://one.ie';
7
8
  async function ask(base, key, receiver, data) {
8
- const res = await fetch(`${base}/api/ask/${encodeURIComponent(receiver)}`, {
9
+ const res = await fetch(askPath(base, receiver), {
9
10
  method: 'POST',
10
11
  headers: { 'Content-Type': 'application/json', ...(key ? { Authorization: `Bearer ${key}` } : {}) },
11
12
  body: JSON.stringify({ data }),
@@ -14,7 +15,15 @@ async function ask(base, key, receiver, data) {
14
15
  const body = await res.text().catch(() => '');
15
16
  throw new Error(`${receiver} → ${res.status}\n${body}`);
16
17
  }
17
- return res.json();
18
+ const json = await res.json();
19
+ if (json.outcome === 'failure') {
20
+ const result = (json.result ?? {});
21
+ const details = Object.entries(result)
22
+ .map(([k, v]) => `${k}=${typeof v === 'string' ? v : JSON.stringify(v)}`)
23
+ .join(' ');
24
+ throw new Error(`${receiver} → forbidden: ${details}`);
25
+ }
26
+ return json;
18
27
  }
19
28
  function findConfigPath(dir) {
20
29
  for (const name of ['_node.toml', 'agency.toml', 'partner.toml', 'workspace.toml']) {
package/dist/src/staff.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Command } from 'commander';
2
2
  import { authHeaders, out, resolveBase, resolveKey } from './lib/client.js';
3
+ import { askPath } from './lib/api-path.js';
3
4
  const DEFAULT_API = resolveBase({}, 'https://one.ie');
4
5
  const VALID_ROLES = ['owner', 'admin', 'member', 'viewer'];
5
6
  export function staffCmd() {
@@ -32,7 +33,7 @@ export function staffCmd() {
32
33
  body.email = email;
33
34
  if (opts.workspace)
34
35
  body.workspace = opts.workspace;
35
- const res = await fetch(`${base}/api/ask/world:invite-member`, {
36
+ const res = await fetch(askPath(base, 'world:invite-member'), {
36
37
  method: 'POST',
37
38
  headers: authHeaders({ key }),
38
39
  body: JSON.stringify({ data: body }),
@@ -71,7 +72,7 @@ export function staffCmd() {
71
72
  const body = { name, role };
72
73
  if (opts.workspace)
73
74
  body.workspace = opts.workspace;
74
- const res = await fetch(`${base}/api/ask/world:invite-agent`, {
75
+ const res = await fetch(askPath(base, 'world:invite-agent'), {
75
76
  method: 'POST',
76
77
  headers: authHeaders({ key }),
77
78
  body: JSON.stringify({ data: body }),
@@ -1,7 +1,8 @@
1
1
  import { Command } from 'commander';
2
2
  import { mergeEnv } from './env.js';
3
3
  import { renderStatus } from './render.js';
4
- const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
4
+ import { askPath } from './lib/api-path.js';
5
+ const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://one.ie';
5
6
  export function statusCmd() {
6
7
  return new Command('status')
7
8
  .description('Agency P&L dashboard (pool, margin, per-client burns)')
@@ -17,22 +18,35 @@ export function statusCmd() {
17
18
  process.exit(1);
18
19
  }
19
20
  const base = opts.api.replace(/\/$/, '');
20
- const res = await fetch(`${base}/api/ask/${encodeURIComponent('billing:clients')}`, {
21
+ // slug is required for staff/owner keys — without it the receiver resolves
22
+ // the key's personal workspace and returns an empty portfolio.
23
+ const res = await fetch(askPath(base, 'billing:clients'), {
21
24
  method: 'POST',
22
25
  headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${key}` },
23
- body: JSON.stringify({ data: {} }),
26
+ body: JSON.stringify({ data: { slug: env.AGENCY_SLUG } }),
24
27
  });
25
28
  if (!res.ok) {
26
29
  process.stderr.write(`billing:clients → ${res.status}\n`);
27
30
  process.exit(1);
28
31
  }
29
- const data = await res.json();
32
+ const json = await res.json();
33
+ if (json.outcome === 'failure') {
34
+ const result = (json.result ?? {});
35
+ const details = Object.entries(result)
36
+ .map(([k, v]) => `${k}=${typeof v === 'string' ? v : JSON.stringify(v)}`)
37
+ .join(' ');
38
+ process.stderr.write(`billing:clients → forbidden: ${details}\n`);
39
+ process.exit(1);
40
+ }
30
41
  if (opts.json) {
31
- process.stdout.write(JSON.stringify(data, null, 2) + '\n');
42
+ process.stdout.write(JSON.stringify(json, null, 2) + '\n');
32
43
  return;
33
44
  }
34
- const agency = (data.agency ?? { slug: env.AGENCY_SLUG, name: env.AGENCY_NAME ?? null, markup_pct: 0, pool: 0 });
35
- const clients = (data.clients ?? []);
45
+ // Receiver replies in the four-outcome envelope: { outcome, result: { agency, clients } }.
46
+ // Unwrap it (keep the bare-shape fallback for older hosts).
47
+ const payload = (json.result ?? json);
48
+ const agency = (payload.agency ?? { slug: env.AGENCY_SLUG, name: env.AGENCY_NAME ?? null, markup_pct: 0, pool: 0, plan: 'free' });
49
+ const clients = (payload.clients ?? []);
36
50
  process.stdout.write(renderStatus(agency, clients) + '\n');
37
51
  });
38
52
  }
@@ -1,4 +1,5 @@
1
1
  import { authHeaders, resolveBase } from './lib/client.js';
2
+ import { askPath } from './lib/api-path.js';
2
3
  const DEFAULT_API = resolveBase({}, 'https://api.one.ie');
3
4
  function base(opts) {
4
5
  return resolveBase(opts, 'https://api.one.ie');
@@ -62,7 +63,7 @@ export function substrateCommands(program) {
62
63
  data = parseJson(await readStdin(), '--data');
63
64
  else if (opts.data)
64
65
  data = parseJson(opts.data, '--data');
65
- out(await api(`${base(opts)}/api/ask/${encodeURIComponent(receiver)}`, {
66
+ out(await api(askPath(base(opts), receiver), {
66
67
  method: 'POST',
67
68
  body: JSON.stringify({ data, timeoutMs: Number(opts.timeout) }),
68
69
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneie/cli",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "ONE agent CLI",
5
5
  "type": "module",
6
6
  "bin": {