@oneie/cli 0.3.5 → 0.5.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.
Files changed (49) hide show
  1. package/LICENSE +86 -0
  2. package/dist/src/agent.js +2 -1
  3. package/dist/src/args.d.ts +9 -0
  4. package/dist/src/args.js +61 -0
  5. package/dist/src/catalog.d.ts +2 -0
  6. package/dist/src/catalog.js +77 -0
  7. package/dist/src/client.d.ts +2 -0
  8. package/dist/src/client.js +98 -0
  9. package/dist/src/compiler.d.ts +18 -0
  10. package/dist/src/compiler.js +201 -0
  11. package/dist/src/config.d.ts +24 -0
  12. package/dist/src/config.js +70 -0
  13. package/dist/src/coordinate.d.ts +3 -0
  14. package/dist/src/coordinate.js +57 -0
  15. package/dist/src/create.d.ts +2 -0
  16. package/dist/src/create.js +193 -0
  17. package/dist/src/deploy.d.ts +2 -0
  18. package/dist/src/deploy.js +19 -0
  19. package/dist/src/env.d.ts +3 -0
  20. package/dist/src/env.js +37 -0
  21. package/dist/src/eval.d.ts +2 -0
  22. package/dist/src/eval.js +32 -0
  23. package/dist/src/fn.d.ts +2 -0
  24. package/dist/src/fn.js +73 -0
  25. package/dist/src/index.js +29 -1
  26. package/dist/src/links.d.ts +5 -0
  27. package/dist/src/links.js +50 -0
  28. package/dist/src/push.d.ts +2 -0
  29. package/dist/src/push.js +57 -0
  30. package/dist/src/render.d.ts +17 -0
  31. package/dist/src/render.js +25 -0
  32. package/dist/src/setup.d.ts +2 -0
  33. package/dist/src/setup.js +56 -0
  34. package/dist/src/ship.d.ts +2 -0
  35. package/dist/src/ship.js +18 -0
  36. package/dist/src/skill.js +39 -0
  37. package/dist/src/slug.d.ts +2 -0
  38. package/dist/src/slug.js +6 -0
  39. package/dist/src/status.d.ts +2 -0
  40. package/dist/src/status.js +38 -0
  41. package/dist/src/templates/_node/site/one.config.d.ts +2 -0
  42. package/dist/src/templates/_node/site/one.config.js +22 -0
  43. package/dist/src/trade.d.ts +2 -0
  44. package/dist/src/trade.js +94 -0
  45. package/dist/src/trail.d.ts +2 -0
  46. package/dist/src/trail.js +47 -0
  47. package/dist/src/validate.d.ts +13 -0
  48. package/dist/src/validate.js +35 -0
  49. package/package.json +4 -3
@@ -0,0 +1,56 @@
1
+ import { Command } from 'commander';
2
+ import { existsSync } from 'node:fs';
3
+ import { mergeEnv, writeEnvLocal } from './env.js';
4
+ import { readAgency } from './config.js';
5
+ const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
6
+ async function ask(base, key, receiver, data) {
7
+ const res = await fetch(`${base}/api/ask/${encodeURIComponent(receiver)}`, {
8
+ method: 'POST',
9
+ headers: { 'Content-Type': 'application/json', ...(key ? { Authorization: `Bearer ${key}` } : {}) },
10
+ body: JSON.stringify({ data }),
11
+ });
12
+ if (!res.ok) {
13
+ const body = await res.text().catch(() => '');
14
+ throw new Error(`${receiver} → ${res.status}\n${body}`);
15
+ }
16
+ return res.json();
17
+ }
18
+ export function setupCmd() {
19
+ return new Command('setup')
20
+ .description('Bootstrap agency workspace (idempotent)')
21
+ .option('--api <url>', 'API base URL', DEFAULT_API)
22
+ .option('--key <key>', 'API key (overrides ONEIE_API_KEY env)')
23
+ .action(async (opts) => {
24
+ const dir = process.cwd();
25
+ const env = mergeEnv(dir);
26
+ const key = opts.key ?? env.ONEIE_API_KEY ?? env.ONE_API_KEY ?? '';
27
+ if (env.AGENCY_WSID && env.CC_ACTOR_ID) {
28
+ process.stdout.write(`Agency already set up (${env.AGENCY_WSID}). No-op.\n`);
29
+ return;
30
+ }
31
+ const cfgPath = existsSync(`${dir}/_node.toml`)
32
+ ? `${dir}/_node.toml`
33
+ : existsSync(`${dir}/agency.toml`)
34
+ ? `${dir}/agency.toml`
35
+ : `${dir}/partner.toml`;
36
+ const agency = readAgency(cfgPath);
37
+ const base = opts.api.replace(/\/$/, '');
38
+ const ws = await ask(base, key, 'world:create-workspace', {
39
+ name: agency.name,
40
+ slug: agency.slug,
41
+ plan: agency.plan,
42
+ markup: agency.markup_pct,
43
+ brand: agency.brand ?? false,
44
+ credit: agency.pool ?? 0,
45
+ });
46
+ const wsid = String(ws.wsid ?? agency.slug);
47
+ const actor = await ask(base, key, 'world:create-actor', {
48
+ name: 'claude-code',
49
+ type: 'claude-code',
50
+ group: wsid,
51
+ });
52
+ const aid = String(actor.aid ?? '');
53
+ writeEnvLocal(dir, { AGENCY_WSID: wsid, CC_ACTOR_ID: aid, AGENCY_SLUG: agency.slug });
54
+ process.stdout.write(`Agency: ${wsid} plan=${agency.plan} markup=${agency.markup_pct}% pool=${agency.pool ?? 0} cr\nClaude Code actor: ${aid}\n`);
55
+ });
56
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function shipCmd(): Command;
@@ -0,0 +1,18 @@
1
+ import { Command } from 'commander';
2
+ import { spawnSync } from 'node:child_process';
3
+ export function shipCmd() {
4
+ return new Command('ship')
5
+ .description('git add -A, commit, and push (close the loop)')
6
+ .argument('[message]', 'Commit message', 'ship: update agency workspace')
7
+ .action((message) => {
8
+ const add = spawnSync('git', ['add', '-A'], { stdio: 'inherit' });
9
+ if (add.status !== 0)
10
+ process.exit(add.status ?? 1);
11
+ const commit = spawnSync('git', ['commit', '-m', message], { stdio: 'inherit' });
12
+ if (commit.status !== 0 && commit.status !== 1)
13
+ process.exit(commit.status ?? 1);
14
+ const push = spawnSync('git', ['push'], { stdio: 'inherit' });
15
+ if (push.status !== 0)
16
+ process.exit(push.status ?? 1);
17
+ });
18
+ }
package/dist/src/skill.js CHANGED
@@ -95,12 +95,15 @@ export function skillCmd() {
95
95
  out(cmd, { ok: false, status: res.status, ...data });
96
96
  return;
97
97
  }
98
+ const sealed = data?.skill?.sealed === true;
98
99
  out(cmd, {
99
100
  ok: true,
100
101
  ref,
101
102
  slug: opts.slug,
102
103
  name: data?.skill?.name,
103
104
  price: data?.skill?.price,
105
+ tier: sealed ? 'sealed (run-only)' : 'open',
106
+ sealed,
104
107
  key: data?.key,
105
108
  diagnostics: data?.diagnostics ?? [],
106
109
  });
@@ -109,6 +112,42 @@ export function skillCmd() {
109
112
  out(cmd, { ok: false, error: err.message, hint: 'try `oneie skill validate <path>` for offline validation' });
110
113
  }
111
114
  });
115
+ cmd.command('fork <name>')
116
+ .description('Copy an open skill into a workspace (refuses sealed — invoke-only)')
117
+ .requiredOption('--slug <slug>', 'Workspace slug')
118
+ .option('--api <url>', 'API base URL', 'https://one.ie')
119
+ .action(async (name, opts) => {
120
+ const keyFile = resolve(homedir(), '.config', 'oneie', 'key');
121
+ const key = process.env.ONEIE_API_KEY ?? (existsSync(keyFile) ? readFileSync(keyFile, 'utf8').trim() : '');
122
+ if (!key) {
123
+ out(cmd, { ok: false, error: 'no API key — run `oneie auth login`' });
124
+ return;
125
+ }
126
+ const token = `${opts.slug}:${key}`;
127
+ try {
128
+ const res = await fetch(`${opts.api.replace(/\/$/, '')}/api/skills/workspace?slug=${encodeURIComponent(opts.slug)}`, {
129
+ headers: { Authorization: `Bearer ${token}` },
130
+ });
131
+ const data = await res.json();
132
+ if (!res.ok) {
133
+ out(cmd, { ok: false, status: res.status, error: data.error ?? 'fork failed' });
134
+ return;
135
+ }
136
+ const skill = (data.skills ?? []).find((s) => s.name === name);
137
+ if (!skill) {
138
+ out(cmd, { ok: false, error: `not found: ${name}` });
139
+ return;
140
+ }
141
+ if (skill.sealed) {
142
+ out(cmd, { ok: false, error: 'sealed skills are invoke-only' });
143
+ return;
144
+ }
145
+ out(cmd, { ok: true, forked: name, slug: opts.slug, tier: 'open' });
146
+ }
147
+ catch (err) {
148
+ out(cmd, { ok: false, error: err.message });
149
+ }
150
+ });
112
151
  cmd.command('list')
113
152
  .description('List skills imported into a workspace')
114
153
  .requiredOption('--slug <slug>', 'Workspace slug')
@@ -0,0 +1,2 @@
1
+ export declare function safeSlug(s: string): string;
2
+ export declare function namespaced(agency: string, name: string): string;
@@ -0,0 +1,6 @@
1
+ export function safeSlug(s) {
2
+ return s.toLowerCase().replace(/[^a-z0-9-]/g, '-').replace(/-+/g, '-').replace(/^-|-$/g, '');
3
+ }
4
+ export function namespaced(agency, name) {
5
+ return `${safeSlug(agency)}--${safeSlug(name)}`;
6
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function statusCmd(): Command;
@@ -0,0 +1,38 @@
1
+ import { Command } from 'commander';
2
+ import { mergeEnv } from './env.js';
3
+ import { renderStatus } from './render.js';
4
+ const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
5
+ export function statusCmd() {
6
+ return new Command('status')
7
+ .description('Agency P&L dashboard (pool, margin, per-client burns)')
8
+ .option('--api <url>', 'API base URL', DEFAULT_API)
9
+ .option('--key <key>', 'API key (overrides ONEIE_API_KEY env)')
10
+ .option('--json', 'Output raw JSON')
11
+ .action(async (opts) => {
12
+ const dir = process.cwd();
13
+ const env = mergeEnv(dir);
14
+ const key = opts.key ?? env.ONEIE_API_KEY ?? env.ONE_API_KEY ?? '';
15
+ if (!key || !env.AGENCY_SLUG) {
16
+ process.stderr.write('not set up — run `one setup` first\n');
17
+ process.exit(1);
18
+ }
19
+ const base = opts.api.replace(/\/$/, '');
20
+ const res = await fetch(`${base}/api/ask/${encodeURIComponent('billing:clients')}`, {
21
+ method: 'POST',
22
+ headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${key}` },
23
+ body: JSON.stringify({ data: {} }),
24
+ });
25
+ if (!res.ok) {
26
+ process.stderr.write(`billing:clients → ${res.status}\n`);
27
+ process.exit(1);
28
+ }
29
+ const data = await res.json();
30
+ if (opts.json) {
31
+ process.stdout.write(JSON.stringify(data, null, 2) + '\n');
32
+ return;
33
+ }
34
+ const agency = (data.agency ?? { slug: env.AGENCY_SLUG, name: env.AGENCY_NAME ?? null, markup_pct: 0, pool: 0 });
35
+ const clients = (data.clients ?? []);
36
+ process.stdout.write(renderStatus(agency, clients) + '\n');
37
+ });
38
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,22 @@
1
+ // @ts-nocheck — template file; typechecked in the target Astro project, not the CLI
2
+ // Install: bun add @oneie/frontend
3
+ // After setup: copy ONE_API_KEY from .env.local into backend.apiKey
4
+ import { defineOne } from '@oneie/frontend';
5
+ // The only per-node configuration:
6
+ // - backend.apiKey: your workspace's scoped API key (from one setup)
7
+ // - brand.tokens: 6 color tokens to match your brand
8
+ export default defineOne({
9
+ backend: {
10
+ apiKey: process.env.ONE_API_KEY ?? '',
11
+ },
12
+ brand: {
13
+ tokens: {
14
+ primary: 'hsl(216 55% 25%)', // your brand primary
15
+ secondary: 'hsl(160 40% 45%)', // secondary / accent
16
+ tertiary: 'hsl(38 90% 55%)', // highlight / CTA
17
+ background: 'hsl(0 0% 100%)', // page background
18
+ foreground: 'hsl(220 20% 15%)', // body text
19
+ font: 'Inter, system-ui, sans-serif',
20
+ },
21
+ },
22
+ });
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function tradeCommands(program: Command): void;
@@ -0,0 +1,94 @@
1
+ const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
2
+ function apiKey() {
3
+ return process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
4
+ }
5
+ function base(opts) {
6
+ return (opts.api ?? DEFAULT_API).replace(/\/$/, '');
7
+ }
8
+ function authHeaders() {
9
+ const h = { 'Content-Type': 'application/json' };
10
+ const k = apiKey();
11
+ if (k)
12
+ h['Authorization'] = `Bearer ${k}`;
13
+ return h;
14
+ }
15
+ async function ask(b, receiver, data) {
16
+ const res = await fetch(`${b}/api/ask/${encodeURIComponent(receiver)}`, {
17
+ method: 'POST',
18
+ headers: authHeaders(),
19
+ body: JSON.stringify({ data }),
20
+ });
21
+ if (!res.ok) {
22
+ process.stderr.write(`${receiver} → ${res.status}\n`);
23
+ process.exit(1);
24
+ }
25
+ return res.json();
26
+ }
27
+ export function tradeCommands(program) {
28
+ program
29
+ .command('market')
30
+ .description('Discover agents and skills on the market')
31
+ .option('--query <text>', 'Search for agents or skills by keyword')
32
+ .option('--api <url>', 'API base URL', DEFAULT_API)
33
+ .option('--json', 'Output raw JSON')
34
+ .action(async (opts) => {
35
+ const b = base(opts);
36
+ const data = opts.query
37
+ ? await ask(b, 'actors:find', { search: opts.query, type: 'agent' })
38
+ : await ask(b, 'market:list', {});
39
+ process.stdout.write(JSON.stringify(data, null, 2) + '\n');
40
+ });
41
+ program
42
+ .command('hire <skillId>')
43
+ .description('Hire an agent for a skill (use --dry-run to simulate)')
44
+ .option('--dry-run', 'Simulate — no settlement, no cost')
45
+ .option('--api <url>', 'API base URL', DEFAULT_API)
46
+ .option('--provider <uid>', 'Preferred provider UID')
47
+ .option('--budget <n>', 'Credit budget', '0')
48
+ .action(async (skillId, opts) => {
49
+ const payload = { skillId };
50
+ if (opts.provider)
51
+ payload.provider = opts.provider;
52
+ if (opts.budget)
53
+ payload.budget = Number(opts.budget);
54
+ if (opts.dryRun)
55
+ payload.simulate = true;
56
+ const data = await ask(base(opts), 'market:hire', payload);
57
+ if (opts.dryRun)
58
+ process.stdout.write('[dry-run] market:hire simulated — nothing settled\n');
59
+ process.stdout.write(JSON.stringify(data, null, 2) + '\n');
60
+ });
61
+ program
62
+ .command('bounty <skillId>')
63
+ .description('Post a bounty for a skill (use --dry-run to simulate)')
64
+ .option('--dry-run', 'Simulate — no settlement, no cost')
65
+ .option('--api <url>', 'API base URL', DEFAULT_API)
66
+ .option('--price <n>', 'Bounty price in credits', '0')
67
+ .action(async (skillId, opts) => {
68
+ const payload = { skillId, price: Number(opts.price) };
69
+ if (opts.dryRun)
70
+ payload.simulate = true;
71
+ const data = await ask(base(opts), 'market:bounty', payload);
72
+ if (opts.dryRun)
73
+ process.stdout.write('[dry-run] market:bounty simulated — nothing settled\n');
74
+ process.stdout.write(JSON.stringify(data, null, 2) + '\n');
75
+ });
76
+ program
77
+ .command('earn')
78
+ .description('Show credit earned summary (pay:weight)')
79
+ .option('--api <url>', 'API base URL', DEFAULT_API)
80
+ .option('--json', 'Output raw JSON')
81
+ .action(async (opts) => {
82
+ const data = await ask(base(opts), 'pay:weight', {});
83
+ process.stdout.write(JSON.stringify(data, null, 2) + '\n');
84
+ });
85
+ program
86
+ .command('usage')
87
+ .description('Show credit usage dashboard')
88
+ .option('--api <url>', 'API base URL', DEFAULT_API)
89
+ .option('--json', 'Output raw JSON')
90
+ .action(async (opts) => {
91
+ const data = await ask(base(opts), 'dashboard:usage', {});
92
+ process.stdout.write(JSON.stringify(data, null, 2) + '\n');
93
+ });
94
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function trailCmd(): Command;
@@ -0,0 +1,47 @@
1
+ import { Command } from 'commander';
2
+ const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_BASE_URL ?? 'https://one.ie';
3
+ function apiKey() {
4
+ return process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
5
+ }
6
+ export function trailCmd() {
7
+ return new Command('trail')
8
+ .description('read trail confidence for a tag combination — ranked next tasks from KV')
9
+ .argument('<tags>', 'comma-separated tags, e.g. fn:engineering,builds,deploy')
10
+ .option('--workspace <ws>', 'workspace slug', 'global')
11
+ .option('--limit <n>', 'max results', '10')
12
+ .option('--api <url>', 'api base url', DEFAULT_API)
13
+ .action(async (tags, opts) => {
14
+ const base = opts.api.replace(/\/$/, '');
15
+ const key = apiKey();
16
+ const sorted = tags.split(',').map((t) => t.trim()).filter(Boolean).sort().join(',');
17
+ const params = new URLSearchParams({ tags: sorted, workspace: opts.workspace, limit: opts.limit });
18
+ const res = await fetch(`${base}/api/export/trail?${params}`, {
19
+ headers: {
20
+ 'Content-Type': 'application/json',
21
+ ...(key ? { Authorization: `Bearer ${key}` } : {}),
22
+ },
23
+ });
24
+ if (!res.ok) {
25
+ const body = await res.text().catch(() => '');
26
+ process.stderr.write(`trail: ${res.status}\n${body}\n`);
27
+ process.exit(1);
28
+ }
29
+ const data = (await res.json());
30
+ const isJson = process.argv.includes('--json');
31
+ if (isJson) {
32
+ process.stdout.write(JSON.stringify(data, null, 2) + '\n');
33
+ return;
34
+ }
35
+ process.stdout.write(`fingerprint: ${data.fingerprint}\n`);
36
+ process.stdout.write(`confidence: ${(data.confidence * 100).toFixed(1)}%\n\n`);
37
+ if (!data.tasks.length) {
38
+ process.stdout.write('no trail data for these tags — run some /do cycles with matching tags\n');
39
+ return;
40
+ }
41
+ for (const t of data.tasks) {
42
+ const pct = (t.confidence * 100).toFixed(0).padStart(3);
43
+ const score = t.score.toFixed(2).padStart(6);
44
+ process.stdout.write(` ${pct}% score=${score} ${t.slug}\n`);
45
+ }
46
+ });
47
+ }
@@ -0,0 +1,13 @@
1
+ export interface ClientShape {
2
+ slug?: string;
3
+ name?: string;
4
+ markup_pct?: number | null;
5
+ monthly_cap?: number | null;
6
+ credits?: number | null;
7
+ }
8
+ export declare function validateClient(c: ClientShape): string[];
9
+ export declare function frontmatter(md: string): Record<string, string>;
10
+ export declare function validateAgent(md: string): {
11
+ name: string;
12
+ errors: string[];
13
+ };
@@ -0,0 +1,35 @@
1
+ export function validateClient(c) {
2
+ const errs = [];
3
+ if (!c.slug)
4
+ errs.push('client: slug required');
5
+ if (!c.name)
6
+ errs.push('client: name required');
7
+ if (c.markup_pct != null && (c.markup_pct < 0 || c.markup_pct > 100))
8
+ errs.push('client: markup_pct must be 0–100');
9
+ if (c.monthly_cap != null && c.monthly_cap < 0)
10
+ errs.push('client: monthly_cap must be ≥ 0');
11
+ if (c.credits != null && c.credits < 0)
12
+ errs.push('client: credits must be ≥ 0');
13
+ return errs;
14
+ }
15
+ export function frontmatter(md) {
16
+ const m = md.match(/^---\n([\s\S]*?)\n---/);
17
+ if (!m)
18
+ return {};
19
+ const out = {};
20
+ for (const line of m[1].split('\n')) {
21
+ const kv = line.match(/^([A-Za-z_][\w-]*)\s*:\s*(.*)$/);
22
+ if (kv)
23
+ out[kv[1]] = kv[2].trim();
24
+ }
25
+ return out;
26
+ }
27
+ export function validateAgent(md) {
28
+ const fm = frontmatter(md);
29
+ const errors = [];
30
+ if (!fm.name)
31
+ errors.push('agent: frontmatter `name` required');
32
+ if (!fm.description)
33
+ errors.push('agent: frontmatter `description` required');
34
+ return { name: fm.name ?? '', errors };
35
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneie/cli",
3
- "version": "0.3.5",
3
+ "version": "0.5.0",
4
4
  "description": "ONE agent CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -19,14 +19,15 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "commander": "^12.0.0",
22
- "@oneie/sdk": "workspace:*"
22
+ "@oneie/sdk": "^0.14.0",
23
+ "@oneie/evals": "^0.1.0"
23
24
  },
24
25
  "devDependencies": {
25
26
  "@types/node": "^25.6.0",
26
27
  "tsx": "^4.0.0",
27
28
  "typescript": "^5.4.0"
28
29
  },
29
- "license": "SEE LICENSE IN https://one.ie/free-license",
30
+ "license": "SEE LICENSE IN LICENSE",
30
31
  "repository": {
31
32
  "type": "git",
32
33
  "url": "git+https://github.com/one-ie/packages.git",