@oneie/cli 0.4.0 → 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 (44) 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 +1 -2
  6. package/dist/src/catalog.js +65 -36
  7. package/dist/src/client.d.ts +0 -1
  8. package/dist/src/client.js +71 -169
  9. package/dist/src/compiler.d.ts +15 -19
  10. package/dist/src/compiler.js +170 -219
  11. package/dist/src/config.d.ts +24 -0
  12. package/dist/src/config.js +70 -0
  13. package/dist/src/coordinate.d.ts +2 -2
  14. package/dist/src/coordinate.js +47 -61
  15. package/dist/src/create.d.ts +2 -0
  16. package/dist/src/create.js +193 -0
  17. package/dist/src/deploy.d.ts +0 -1
  18. package/dist/src/deploy.js +8 -35
  19. package/dist/src/env.d.ts +3 -6
  20. package/dist/src/env.js +31 -24
  21. package/dist/src/fn.d.ts +2 -0
  22. package/dist/src/fn.js +73 -0
  23. package/dist/src/index.js +16 -8
  24. package/dist/src/links.d.ts +5 -0
  25. package/dist/src/links.js +50 -0
  26. package/dist/src/push.d.ts +0 -1
  27. package/dist/src/push.js +44 -99
  28. package/dist/src/render.d.ts +17 -0
  29. package/dist/src/render.js +25 -0
  30. package/dist/src/setup.d.ts +0 -1
  31. package/dist/src/setup.js +43 -134
  32. package/dist/src/ship.d.ts +0 -1
  33. package/dist/src/ship.js +13 -36
  34. package/dist/src/slug.d.ts +2 -5
  35. package/dist/src/slug.js +4 -7
  36. package/dist/src/status.d.ts +0 -1
  37. package/dist/src/status.js +29 -42
  38. package/dist/src/trade.d.ts +1 -2
  39. package/dist/src/trade.js +71 -74
  40. package/dist/src/trail.d.ts +2 -0
  41. package/dist/src/trail.js +47 -0
  42. package/dist/src/validate.d.ts +11 -10
  43. package/dist/src/validate.js +32 -34
  44. package/package.json +2 -2
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function createCmd(): Command;
@@ -0,0 +1,193 @@
1
+ import { Command } from 'commander';
2
+ import { mkdirSync, mkdtempSync, readFileSync, writeFileSync, existsSync } from 'node:fs';
3
+ import { resolve, join } from 'node:path';
4
+ import { spawnSync } from 'node:child_process';
5
+ import { tmpdir } from 'node:os';
6
+ const SAFE_REF = /^[A-Za-z0-9._/-]+$/;
7
+ function downloadTarball(url, targetDir) {
8
+ mkdirSync(targetDir, { recursive: true });
9
+ // No shell — pipe curl stdout directly into tar stdin as a buffer
10
+ const curl = spawnSync('curl', ['-fsSL', '--location', url], {
11
+ maxBuffer: 512 * 1024 * 1024,
12
+ stdio: ['ignore', 'pipe', 'inherit'],
13
+ });
14
+ if (curl.status !== 0 || !curl.stdout)
15
+ throw new Error(`curl failed: ${url}`);
16
+ const tar = spawnSync('tar', ['-xz', '--strip-components=1', '-C', targetDir], {
17
+ input: curl.stdout,
18
+ stdio: ['pipe', 'inherit', 'inherit'],
19
+ });
20
+ if (tar.status !== 0)
21
+ throw new Error(`tar failed extracting to ${targetDir}`);
22
+ }
23
+ function downloadSubdir(url, subdir, targetDir) {
24
+ const tmp = mkdtempSync(join(tmpdir(), 'one-create-'));
25
+ try {
26
+ 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');
31
+ }
32
+ finally {
33
+ spawnSync('rm', ['-rf', tmp]);
34
+ }
35
+ }
36
+ export function createCmd() {
37
+ const cmd = new Command('create').description('Scaffold a new ONE node or site');
38
+ // ── one create agency [name] ──────────────────────────────────────────────
39
+ cmd
40
+ .command('agency [name]')
41
+ .description('Scaffold a new agency node from github.com/one-ie/oo')
42
+ .option('--ref <ref>', 'Git ref to download', 'main')
43
+ .option('--slug <slug>', 'Your agency slug (written into agency.toml)')
44
+ .option('--name <name>', 'Your agency display name (written into agency.toml)')
45
+ .action((dirName, opts) => {
46
+ if (!SAFE_REF.test(opts.ref)) {
47
+ process.stderr.write(`Invalid ref: ${opts.ref}\n`);
48
+ process.exit(1);
49
+ }
50
+ const label = dirName ?? opts.slug ?? 'my-agency';
51
+ const dir = resolve(process.cwd(), label);
52
+ if (existsSync(dir)) {
53
+ process.stderr.write(`Directory already exists: ${dir}\n`);
54
+ process.exit(1);
55
+ }
56
+ process.stdout.write(`Creating agency node at ${dir}...\n`);
57
+ downloadTarball(`https://api.github.com/repos/one-ie/oo/tarball/${opts.ref}`, dir);
58
+ // Patch agency.toml with the user's slug + name so they don't have to
59
+ const tomlPath = join(dir, 'agency.toml');
60
+ if (existsSync(tomlPath) && (opts.slug ?? opts.name)) {
61
+ let toml = readFileSync(tomlPath, 'utf8');
62
+ if (opts.slug)
63
+ toml = toml.replace(/^slug\s*=\s*"[^"]*"/m, `slug = "${opts.slug}"`);
64
+ if (opts.name)
65
+ toml = toml.replace(/^name\s*=\s*"[^"]*"/m, `name = "${opts.name}"`);
66
+ writeFileSync(tomlPath, toml);
67
+ }
68
+ process.stdout.write(`\nAgency node created.\n\n`);
69
+ process.stdout.write(`Next steps:\n`);
70
+ process.stdout.write(` cd ${label}\n`);
71
+ process.stdout.write(` cp .env.example .env.local\n`);
72
+ process.stdout.write(` # Edit .env.local — set ONE_API_KEY and AGENCY_OWNER_EMAIL\n`);
73
+ if (!opts.slug)
74
+ process.stdout.write(` # Edit agency.toml — set slug and name\n`);
75
+ process.stdout.write(` one setup\n`);
76
+ });
77
+ // ── one create client <slug> ──────────────────────────────────────────────
78
+ cmd
79
+ .command('client <slug>')
80
+ .description('Scaffold a client node in clients/<slug>/')
81
+ .option('--name <name>', 'Display name for the client')
82
+ .option('--plan <plan>', 'Plan tier', 'studio')
83
+ .action((slug, opts) => {
84
+ const base = resolve(process.cwd(), 'clients', slug);
85
+ if (existsSync(base)) {
86
+ process.stderr.write(`Client already exists: clients/${slug}\n`);
87
+ process.exit(1);
88
+ }
89
+ const displayName = opts.name ?? slug;
90
+ mkdirSync(join(base, 'ai'), { recursive: true });
91
+ mkdirSync(join(base, 'data', 'lifecycles'), { recursive: true });
92
+ mkdirSync(join(base, 'site'), { recursive: true });
93
+ writeFileSync(join(base, 'ai', 'context.md'), `# ${displayName}\n\nAdd company context here — agents read this on every turn.\n`);
94
+ writeFileSync(join(base, 'site', 'one.config.ts'), [
95
+ `import { defineOne } from '@oneie/frontend'`,
96
+ ``,
97
+ `export default defineOne({`,
98
+ ` backend: { baseUrl: 'https://one.ie' },`,
99
+ ` brand: {`,
100
+ ` tokens: {`,
101
+ ` primary: 'hsl(216 55% 25%)',`,
102
+ ` secondary: 'hsl(219 14% 28%)',`,
103
+ ` tertiary: 'hsl(105 22% 25%)',`,
104
+ ` background: 'hsl(0 0% 93%)',`,
105
+ ` foreground: 'hsl(0 0% 100%)',`,
106
+ ` font: 'hsl(0 0% 13%)',`,
107
+ ` },`,
108
+ ` },`,
109
+ ` plugins: [`,
110
+ ` // auth(),`,
111
+ ` // track({ ws: '${slug}' }),`,
112
+ ` // chat({ agent: 'your-agent' }),`,
113
+ ` ],`,
114
+ `})`,
115
+ ].join('\n') + '\n');
116
+ writeFileSync(join(base, 'client.toml'), [
117
+ `slug = "${slug}"`,
118
+ `name = "${displayName}"`,
119
+ `plan = "${opts.plan}"`,
120
+ ``,
121
+ `# markup_pct = 15 # override agency default`,
122
+ `# monthly_cap = 50000`,
123
+ ].join('\n') + '\n');
124
+ process.stdout.write(`Client node scaffolded: clients/${slug}/\n`);
125
+ process.stdout.write(` ai/context.md — add company context\n`);
126
+ process.stdout.write(` site/one.config.ts — brand tokens (6 tokens rebrand the site)\n`);
127
+ process.stdout.write(` client.toml — plan + economics\n\n`);
128
+ process.stdout.write(`Next: one client add ${slug} [--dry-run]\n`);
129
+ });
130
+ // ── one create partner [name] ────────────────────────────────────────────
131
+ cmd
132
+ .command('partner [name]')
133
+ .description('Scaffold a new partner node from github.com/one-ie/partner')
134
+ .option('--ref <ref>', 'Git ref to download', 'main')
135
+ .option('--slug <slug>', 'Your partner slug (written into partner.toml)')
136
+ .option('--name <name>', 'Your display name (written into partner.toml)')
137
+ .action((dirName, opts) => {
138
+ if (!SAFE_REF.test(opts.ref)) {
139
+ process.stderr.write(`Invalid ref: ${opts.ref}\n`);
140
+ process.exit(1);
141
+ }
142
+ const label = dirName ?? opts.slug ?? 'my-partner';
143
+ const dir = resolve(process.cwd(), label);
144
+ if (existsSync(dir)) {
145
+ process.stderr.write(`Directory already exists: ${dir}\n`);
146
+ process.exit(1);
147
+ }
148
+ process.stdout.write(`Creating partner node at ${dir}...\n`);
149
+ downloadTarball(`https://api.github.com/repos/one-ie/partner/tarball/${opts.ref}`, dir);
150
+ const tomlPath = join(dir, 'partner.toml');
151
+ if (existsSync(tomlPath) && (opts.slug ?? opts.name)) {
152
+ let toml = readFileSync(tomlPath, 'utf8');
153
+ if (opts.slug)
154
+ toml = toml.replace(/^slug\s*=\s*"[^"]*"/m, `slug = "${opts.slug}"`);
155
+ if (opts.name)
156
+ toml = toml.replace(/^name\s*=\s*"[^"]*"/m, `name = "${opts.name}"`);
157
+ writeFileSync(tomlPath, toml);
158
+ }
159
+ process.stdout.write(`\nPartner node created.\n\n`);
160
+ process.stdout.write(`Next steps:\n`);
161
+ process.stdout.write(` cd ${label}\n`);
162
+ process.stdout.write(` cp .env.example .env.local\n`);
163
+ process.stdout.write(` # Edit .env.local — set ONE_API_KEY\n`);
164
+ if (!opts.slug)
165
+ process.stdout.write(` # Edit partner.toml — set slug and name\n`);
166
+ process.stdout.write(` one setup\n`);
167
+ });
168
+ // ── one create site [name] ────────────────────────────────────────────────
169
+ cmd
170
+ .command('site [name]')
171
+ .description('Scaffold a standalone ONE Astro site from github.com/one-ie/one')
172
+ .option('--ref <ref>', 'Git ref to download', 'main')
173
+ .action((name, opts) => {
174
+ if (!SAFE_REF.test(opts.ref)) {
175
+ process.stderr.write(`Invalid ref: ${opts.ref}\n`);
176
+ process.exit(1);
177
+ }
178
+ const dir = resolve(process.cwd(), name ?? 'my-site');
179
+ if (existsSync(dir)) {
180
+ process.stderr.write(`Directory already exists: ${dir}\n`);
181
+ process.exit(1);
182
+ }
183
+ process.stdout.write(`Creating site at ${dir}...\n`);
184
+ downloadSubdir(`https://api.github.com/repos/one-ie/one/tarball/${opts.ref}`, 'apps/web', dir);
185
+ const label = name ?? 'my-site';
186
+ process.stdout.write(`\nSite created.\n\n`);
187
+ process.stdout.write(`Next steps:\n`);
188
+ process.stdout.write(` cd ${label}\n`);
189
+ process.stdout.write(` cp .env.example .env.local\n`);
190
+ process.stdout.write(` bun install && bun run dev\n`);
191
+ });
192
+ return cmd;
193
+ }
@@ -1,3 +1,2 @@
1
- /** `one deploy [path]` — wrangler pages deploy wrapper. */
2
1
  import { Command } from 'commander';
3
2
  export declare function deployCmd(): Command;
@@ -1,46 +1,19 @@
1
- /** `one deploy [path]` — wrangler pages deploy wrapper. */
2
1
  import { Command } from 'commander';
3
2
  import { spawnSync } from 'node:child_process';
4
3
  import { existsSync } from 'node:fs';
5
- import { resolve } from 'node:path';
6
- function out(cmd, data) {
7
- const isJson = cmd.parent?.opts()?.json;
8
- if (isJson)
9
- process.stdout.write(JSON.stringify(data, null, 2) + '\n');
10
- else {
11
- const d = data;
12
- if (d['ok'])
13
- process.stdout.write(`✓ deployed\n`);
14
- else
15
- process.stderr.write(`✗ deploy failed\n`);
16
- }
17
- }
18
4
  export function deployCmd() {
19
- const cmd = new Command('deploy')
20
- .description('Deploy the site/ directory via wrangler pages deploy')
21
- .argument('[path]', 'Path to deploy (defaults to site/ in cwd)', 'site')
5
+ return new Command('deploy')
6
+ .description('Deploy site/ to Cloudflare Pages via wrangler')
7
+ .argument('[path]', 'Path to deploy (default: site/dist)')
22
8
  .option('--project <name>', 'Cloudflare Pages project name')
23
- .option('--branch <branch>', 'Git branch for the deployment')
24
- .option('--dry-run', 'Pass --dry-run to wrangler')
25
9
  .action((path, opts) => {
26
- const dir = resolve(process.cwd(), path);
27
- if (!existsSync(dir)) {
28
- process.stderr.write(`error: directory not found: ${dir}\n`);
29
- process.exit(1);
30
- }
31
- const args = ['wrangler', 'pages', 'deploy', dir];
10
+ const target = path ?? (existsSync('site/dist') ? 'site/dist' : 'dist');
11
+ const args = ['pages', 'deploy', target];
32
12
  if (opts.project)
33
13
  args.push('--project-name', opts.project);
34
- if (opts.branch)
35
- args.push('--branch', opts.branch);
36
- if (opts.dryRun)
37
- args.push('--dry-run');
38
- process.stdout.write(` deploying ${dir}…\n`);
39
- const result = spawnSync('npx', args, { stdio: 'inherit', encoding: 'utf8' });
40
- const ok = result.status === 0;
41
- out(cmd, { ok, path: dir, exit: result.status });
42
- if (!ok)
14
+ process.stdout.write(`Deploying ${target}...\n`);
15
+ const result = spawnSync('wrangler', args, { stdio: 'inherit' });
16
+ if (result.status !== 0)
43
17
  process.exit(result.status ?? 1);
44
18
  });
45
- return cmd;
46
19
  }
package/dist/src/env.d.ts CHANGED
@@ -1,6 +1,3 @@
1
- /** Read existing .env.local (or return empty map). */
2
- export declare function readEnvLocal(cwd?: string): Map<string, string>;
3
- /** Upsert key=value pairs into .env.local, preserving existing entries. */
4
- export declare function mergeEnvLocal(pairs: Record<string, string>, cwd?: string): void;
5
- /** Read a single key from .env.local, then fallback to process.env. */
6
- export declare function readSecret(key: string, cwd?: string): string;
1
+ export declare function readEnvFile(path: string): Record<string, string>;
2
+ export declare function mergeEnv(dir: string): Record<string, string>;
3
+ export declare function writeEnvLocal(dir: string, updates: Record<string, string>): void;
package/dist/src/env.js CHANGED
@@ -1,30 +1,37 @@
1
- /** Helpers for .env.local — merge secrets the compiler resolves from the environment. */
2
- import { readFileSync, writeFileSync, existsSync } from 'node:fs';
3
- import { resolve } from 'node:path';
4
- /** Read existing .env.local (or return empty map). */
5
- export function readEnvLocal(cwd = process.cwd()) {
6
- const path = resolve(cwd, '.env.local');
7
- const map = new Map();
1
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
2
+ const LINE = /^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*?)\s*$/;
3
+ export function readEnvFile(path) {
8
4
  if (!existsSync(path))
9
- return map;
10
- for (const line of readFileSync(path, 'utf8').split('\n')) {
11
- const eq = line.indexOf('=');
12
- if (eq < 1 || line.trim().startsWith('#'))
5
+ return {};
6
+ const out = {};
7
+ for (const raw of readFileSync(path, 'utf8').split('\n')) {
8
+ if (raw.trim().startsWith('#') || !raw.trim())
13
9
  continue;
14
- map.set(line.slice(0, eq).trim(), line.slice(eq + 1).trim());
10
+ const m = raw.match(LINE);
11
+ if (m)
12
+ out[m[1]] = m[2].replace(/^["']|["']$/g, '');
15
13
  }
16
- return map;
14
+ return out;
17
15
  }
18
- /** Upsert key=value pairs into .env.local, preserving existing entries. */
19
- export function mergeEnvLocal(pairs, cwd = process.cwd()) {
20
- const path = resolve(cwd, '.env.local');
21
- const map = readEnvLocal(cwd);
22
- for (const [k, v] of Object.entries(pairs))
23
- map.set(k, v);
24
- const lines = Array.from(map.entries()).map(([k, v]) => `${k}=${v}`);
25
- writeFileSync(path, lines.join('\n') + '\n', 'utf8');
16
+ function fromProcess() {
17
+ const out = {};
18
+ for (const k of ['ONE_API_URL', 'ONE_API_KEY', 'ONEIE_API_KEY', 'AGENCY_SLUG', 'AGENCY_NAME', 'AGENCY_WSID', 'CC_ACTOR_ID']) {
19
+ const v = process.env[k];
20
+ if (v)
21
+ out[k] = v;
22
+ }
23
+ return out;
24
+ }
25
+ export function mergeEnv(dir) {
26
+ return {
27
+ ...readEnvFile(`${dir}/.env`),
28
+ ...readEnvFile(`${dir}/.env.local`),
29
+ ...fromProcess(),
30
+ };
26
31
  }
27
- /** Read a single key from .env.local, then fallback to process.env. */
28
- export function readSecret(key, cwd = process.cwd()) {
29
- return readEnvLocal(cwd).get(key) ?? process.env[key] ?? '';
32
+ export function writeEnvLocal(dir, updates) {
33
+ const path = `${dir}/.env.local`;
34
+ const merged = { ...readEnvFile(path), ...updates };
35
+ const body = Object.entries(merged).map(([k, v]) => `${k}=${v}`).join('\n') + '\n';
36
+ writeFileSync(path, body, 'utf8');
30
37
  }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function fnCmd(): Command;
package/dist/src/fn.js ADDED
@@ -0,0 +1,73 @@
1
+ import { Command } from 'commander';
2
+ import { FN_MAP, FN_MAP_VERSION } from '@oneie/sdk/generated/fn-map';
3
+ const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
4
+ const ALLOWLIST = new Set([
5
+ 'actionable_hypotheses', 'active_frontiers', 'active_objectives',
6
+ 'actor_classification', 'actors_by_kind', 'actors_by_tag', 'actors_for',
7
+ 'attractive_tasks', 'blocked_tasks', 'cheapest_provider', 'exploratory_tasks',
8
+ 'highways', 'optimal_route', 'promising_frontiers', 'suggest_route', 'total_contribution',
9
+ ]);
10
+ function apiKey() {
11
+ return process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
12
+ }
13
+ function base(opts) {
14
+ return (opts.api ?? DEFAULT_API).replace(/\/$/, '');
15
+ }
16
+ async function api(url, body) {
17
+ const h = { 'Content-Type': 'application/json' };
18
+ const k = apiKey();
19
+ if (k)
20
+ h['Authorization'] = `Bearer ${k}`;
21
+ const res = await fetch(url, { method: 'POST', headers: h, body: JSON.stringify(body) });
22
+ if (!res.ok) {
23
+ const text = await res.text().catch(() => '');
24
+ process.stderr.write(`fn:run → ${res.status}\n${text}\n`);
25
+ process.exit(1);
26
+ }
27
+ return res.json();
28
+ }
29
+ export function fnCmd() {
30
+ const cmd = new Command('fn').description(`Execute an allowlisted TypeDB function (FN_MAP v${FN_MAP_VERSION})`);
31
+ cmd
32
+ .command('list')
33
+ .description('List all allowlisted functions')
34
+ .action(() => {
35
+ const rows = Array.from(ALLOWLIST).map((name) => {
36
+ const entry = FN_MAP[name];
37
+ const params = entry?.params.map((p) => p.name).join(', ') ?? '';
38
+ return ` ${name.padEnd(28)}${params ? `(${params})` : '()'} → ${entry?.returnKind ?? '?'}`;
39
+ });
40
+ process.stdout.write(`Allowlisted functions (FN_MAP v${FN_MAP_VERSION}):\n${rows.join('\n')}\n`);
41
+ });
42
+ cmd
43
+ .command('run <name>')
44
+ .description('Execute a function by name')
45
+ .option('--args <json>', 'Function arguments as JSON object (keys without $ prefix)')
46
+ .option('--workspace <slug>', 'Workspace slug')
47
+ .option('--api <url>', 'API base URL', DEFAULT_API)
48
+ .action(async (name, opts) => {
49
+ if (!ALLOWLIST.has(name)) {
50
+ process.stderr.write(`error: '${name}' is not in the allowlist. Run 'one fn list' to see available functions.\n`);
51
+ process.exit(1);
52
+ }
53
+ let args = {};
54
+ if (opts.args) {
55
+ try {
56
+ args = JSON.parse(opts.args);
57
+ }
58
+ catch {
59
+ process.stderr.write('error: --args must be valid JSON\n');
60
+ process.exit(1);
61
+ }
62
+ }
63
+ const prefixed = {};
64
+ for (const [k, v] of Object.entries(args)) {
65
+ prefixed[k.startsWith('$') ? k : `$${k}`] = v;
66
+ }
67
+ const result = await api(`${base(opts)}/api/ask/fn%3Arun`, {
68
+ data: { fn: name, args: prefixed, workspace: opts.workspace },
69
+ });
70
+ process.stdout.write(JSON.stringify(result, null, 2) + '\n');
71
+ });
72
+ return cmd;
73
+ }
package/dist/src/index.js CHANGED
@@ -8,6 +8,7 @@ import { groupCmd } from './group.js';
8
8
  import { socialCmd } from './social.js';
9
9
  import { connectCmd } from './connect.js';
10
10
  import { broadcastCmd, newsletterCmd } from './broadcast.js';
11
+ import { linksCmd } from './links.js';
11
12
  import { staffCmd } from './staff.js';
12
13
  import { substrateCommands } from './substrate.js';
13
14
  import { evalCmd } from './eval.js';
@@ -17,14 +18,17 @@ import { pushCmd } from './push.js';
17
18
  import { deployCmd } from './deploy.js';
18
19
  import { statusCmd } from './status.js';
19
20
  import { shipCmd } from './ship.js';
20
- import { catalogCmd } from './catalog.js';
21
- import { tradeCmd } from './trade.js';
22
- import { coordinateCmd } from './coordinate.js';
21
+ import { catalogCommands } from './catalog.js';
22
+ import { tradeCommands } from './trade.js';
23
+ import { coordinateCommands } from './coordinate.js';
24
+ import { createCmd } from './create.js';
25
+ import { fnCmd } from './fn.js';
26
+ import { trailCmd } from './trail.js';
23
27
  import { readFileSync } from 'node:fs';
24
28
  import { fileURLToPath } from 'node:url';
25
29
  import { resolve, dirname } from 'node:path';
26
30
  const __dirname = dirname(fileURLToPath(import.meta.url));
27
- const pkg = JSON.parse(readFileSync(resolve(__dirname, '../../package.json'), 'utf8'));
31
+ const pkg = JSON.parse(readFileSync(resolve(__dirname, '../package.json'), 'utf8'));
28
32
  const program = new Command()
29
33
  .name('oneie')
30
34
  .description('ONE — agent CLI')
@@ -39,18 +43,22 @@ program.addCommand(socialCmd());
39
43
  program.addCommand(connectCmd());
40
44
  program.addCommand(broadcastCmd());
41
45
  program.addCommand(newsletterCmd());
46
+ program.addCommand(linksCmd());
42
47
  program.addCommand(staffCmd());
43
48
  program.addCommand(evalCmd());
44
- substrateCommands(program);
45
49
  program.addCommand(setupCmd());
46
50
  program.addCommand(clientCmd());
47
51
  program.addCommand(pushCmd());
48
52
  program.addCommand(deployCmd());
49
53
  program.addCommand(statusCmd());
50
54
  program.addCommand(shipCmd());
51
- program.addCommand(catalogCmd());
52
- program.addCommand(tradeCmd());
53
- program.addCommand(coordinateCmd());
55
+ catalogCommands(program);
56
+ tradeCommands(program);
57
+ coordinateCommands(program);
58
+ substrateCommands(program);
59
+ program.addCommand(createCmd());
60
+ program.addCommand(fnCmd());
61
+ program.addCommand(trailCmd());
54
62
  program.parseAsync(process.argv).catch((err) => {
55
63
  const isJson = process.argv.includes('--json');
56
64
  if (isJson)
@@ -0,0 +1,5 @@
1
+ import { Command } from 'commander';
2
+ /** `one links` — mint personalised, actor-bound tracked links from the terminal.
3
+ * Thin wrapper over the `links:create` receiver via ask() (no new route). The
4
+ * receiver walks authority server-side; the API key identifies the caller. */
5
+ export declare function linksCmd(): Command;
@@ -0,0 +1,50 @@
1
+ import { Command } from 'commander';
2
+ const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_BASE_URL ?? 'https://api.one.ie';
3
+ function headers() {
4
+ const h = { 'Content-Type': 'application/json' };
5
+ const k = process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
6
+ if (k)
7
+ h['Authorization'] = `Bearer ${k}`;
8
+ return h;
9
+ }
10
+ async function ask(api, receiver, data) {
11
+ const res = await fetch(`${api.replace(/\/$/, '')}/api/ask/${encodeURIComponent(receiver)}`, {
12
+ method: 'POST',
13
+ headers: headers(),
14
+ body: JSON.stringify({ data }),
15
+ });
16
+ if (!res.ok) {
17
+ process.stderr.write(`POST /api/ask/${receiver} → ${res.status}\n`);
18
+ process.exit(1);
19
+ }
20
+ return res.json();
21
+ }
22
+ function out(data) {
23
+ process.stdout.write(JSON.stringify(data, null, 2) + '\n');
24
+ }
25
+ /** `one links` — mint personalised, actor-bound tracked links from the terminal.
26
+ * Thin wrapper over the `links:create` receiver via ask() (no new route). The
27
+ * receiver walks authority server-side; the API key identifies the caller. */
28
+ export function linksCmd() {
29
+ const cmd = new Command('links').description('Create personalised, actor-bound tracked links');
30
+ cmd
31
+ .command('create <actorId>')
32
+ .description('Create a tracked link bound to a contact (rung-4 identity on click)')
33
+ .option('--to <path>', "Destination path, e.g. '/pricing'", '/')
34
+ .option('--context <text>', "Context injected into the agent's system prompt")
35
+ .option('--greeting <text>', "Override the chat agent's opening line")
36
+ .option('--campaign <id>', 'Group clicks under a campaign')
37
+ .option('--expires <days>', 'Link TTL in days (omit = never)')
38
+ .option('--api <url>', 'API base URL', DEFAULT_API)
39
+ .action(async (actorId, opts) => {
40
+ out(await ask(opts.api, 'links:create', {
41
+ actorId,
42
+ destination: opts.to,
43
+ context: opts.context,
44
+ greeting: opts.greeting,
45
+ campaignId: opts.campaign,
46
+ expiresInDays: opts.expires ? Number(opts.expires) : undefined,
47
+ }));
48
+ });
49
+ return cmd;
50
+ }
@@ -1,3 +1,2 @@
1
- /** `one push [clients/<slug>]` — compile a fractal node to the substrate. */
2
1
  import { Command } from 'commander';
3
2
  export declare function pushCmd(): Command;