@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.
- package/LICENSE +86 -0
- package/dist/src/agent.js +2 -1
- package/dist/src/args.d.ts +9 -0
- package/dist/src/args.js +61 -0
- package/dist/src/catalog.d.ts +1 -2
- package/dist/src/catalog.js +65 -36
- package/dist/src/client.d.ts +0 -1
- package/dist/src/client.js +71 -169
- package/dist/src/compiler.d.ts +15 -19
- package/dist/src/compiler.js +170 -219
- package/dist/src/config.d.ts +24 -0
- package/dist/src/config.js +70 -0
- package/dist/src/coordinate.d.ts +2 -2
- package/dist/src/coordinate.js +47 -61
- package/dist/src/create.d.ts +2 -0
- package/dist/src/create.js +193 -0
- package/dist/src/deploy.d.ts +0 -1
- package/dist/src/deploy.js +8 -35
- package/dist/src/env.d.ts +3 -6
- package/dist/src/env.js +31 -24
- package/dist/src/fn.d.ts +2 -0
- package/dist/src/fn.js +73 -0
- package/dist/src/index.js +16 -8
- package/dist/src/links.d.ts +5 -0
- package/dist/src/links.js +50 -0
- package/dist/src/push.d.ts +0 -1
- package/dist/src/push.js +44 -99
- package/dist/src/render.d.ts +17 -0
- package/dist/src/render.js +25 -0
- package/dist/src/setup.d.ts +0 -1
- package/dist/src/setup.js +43 -134
- package/dist/src/ship.d.ts +0 -1
- package/dist/src/ship.js +13 -36
- package/dist/src/slug.d.ts +2 -5
- package/dist/src/slug.js +4 -7
- package/dist/src/status.d.ts +0 -1
- package/dist/src/status.js +29 -42
- package/dist/src/trade.d.ts +1 -2
- package/dist/src/trade.js +71 -74
- package/dist/src/trail.d.ts +2 -0
- package/dist/src/trail.js +47 -0
- package/dist/src/validate.d.ts +11 -10
- package/dist/src/validate.js +32 -34
- package/package.json +2 -2
package/dist/src/trade.js
CHANGED
|
@@ -1,97 +1,94 @@
|
|
|
1
|
-
|
|
2
|
-
import { Command } from 'commander';
|
|
3
|
-
const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_BASE_URL ?? 'https://api.one.ie';
|
|
1
|
+
const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
|
|
4
2
|
function apiKey() {
|
|
5
3
|
return process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
|
|
6
4
|
}
|
|
7
|
-
|
|
8
|
-
|
|
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)}`, {
|
|
9
17
|
method: 'POST',
|
|
10
|
-
headers:
|
|
18
|
+
headers: authHeaders(),
|
|
11
19
|
body: JSON.stringify({ data }),
|
|
12
20
|
});
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const isJson = cmd.parent?.opts()?.json;
|
|
17
|
-
if (isJson) {
|
|
18
|
-
process.stdout.write(JSON.stringify(data, null, 2) + '\n');
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
const d = data;
|
|
22
|
-
if (d?.kind === 'failure') {
|
|
23
|
-
process.stderr.write(` x ${d?.error ?? 'failed'}\n`);
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
if (d?.kind === 'result') {
|
|
27
|
-
const r = d.result;
|
|
28
|
-
if (typeof r === 'object' && r !== null) {
|
|
29
|
-
for (const [k, v] of Object.entries(r)) {
|
|
30
|
-
if (typeof v !== 'object')
|
|
31
|
-
process.stdout.write(` ${k}: ${v}\n`);
|
|
32
|
-
}
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
21
|
+
if (!res.ok) {
|
|
22
|
+
process.stderr.write(`${receiver} → ${res.status}\n`);
|
|
23
|
+
process.exit(1);
|
|
35
24
|
}
|
|
36
|
-
|
|
25
|
+
return res.json();
|
|
37
26
|
}
|
|
38
|
-
export function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
.description('
|
|
42
|
-
.
|
|
43
|
-
.option('--limit <n>', 'Max results', '20')
|
|
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')
|
|
44
32
|
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
45
|
-
.
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
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');
|
|
49
40
|
});
|
|
50
|
-
|
|
51
|
-
.
|
|
52
|
-
.
|
|
53
|
-
.option('--dry-run', 'Simulate
|
|
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')
|
|
54
45
|
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
46
|
+
.option('--provider <uid>', 'Preferred provider UID')
|
|
47
|
+
.option('--budget <n>', 'Credit budget', '0')
|
|
55
48
|
.action(async (skillId, opts) => {
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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');
|
|
61
60
|
});
|
|
62
|
-
|
|
63
|
-
.
|
|
64
|
-
.
|
|
65
|
-
.option('--dry-run', 'Simulate
|
|
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')
|
|
66
65
|
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
66
|
+
.option('--price <n>', 'Bounty price in credits', '0')
|
|
67
67
|
.action(async (skillId, opts) => {
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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');
|
|
73
75
|
});
|
|
74
|
-
|
|
75
|
-
.
|
|
76
|
-
.
|
|
77
|
-
.option('--dry-run', 'Simulate (passes simulate:true)')
|
|
76
|
+
program
|
|
77
|
+
.command('earn')
|
|
78
|
+
.description('Show credit earned summary (pay:weight)')
|
|
78
79
|
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
80
|
+
.option('--json', 'Output raw JSON')
|
|
79
81
|
.action(async (opts) => {
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
bountyId: opts.bountyId, simulate: opts.dryRun ?? false,
|
|
83
|
-
});
|
|
84
|
-
out(cmd, result);
|
|
82
|
+
const data = await ask(base(opts), 'pay:weight', {});
|
|
83
|
+
process.stdout.write(JSON.stringify(data, null, 2) + '\n');
|
|
85
84
|
});
|
|
86
|
-
|
|
87
|
-
.
|
|
88
|
-
.
|
|
85
|
+
program
|
|
86
|
+
.command('usage')
|
|
87
|
+
.description('Show credit usage dashboard')
|
|
89
88
|
.option('--api <url>', 'API base URL', DEFAULT_API)
|
|
89
|
+
.option('--json', 'Output raw JSON')
|
|
90
90
|
.action(async (opts) => {
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
const result = await ask(base, 'dashboard:usage', { slug });
|
|
94
|
-
out(cmd, result);
|
|
91
|
+
const data = await ask(base(opts), 'dashboard:usage', {});
|
|
92
|
+
process.stdout.write(JSON.stringify(data, null, 2) + '\n');
|
|
95
93
|
});
|
|
96
|
-
return cmd;
|
|
97
94
|
}
|
|
@@ -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
|
+
}
|
package/dist/src/validate.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
export interface
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export interface ClientShape {
|
|
2
|
+
slug?: string;
|
|
3
|
+
name?: string;
|
|
4
|
+
markup_pct?: number | null;
|
|
5
|
+
monthly_cap?: number | null;
|
|
6
|
+
credits?: number | null;
|
|
5
7
|
}
|
|
6
|
-
|
|
7
|
-
export declare function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
body: string;
|
|
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[];
|
|
12
13
|
};
|
package/dist/src/validate.js
CHANGED
|
@@ -1,37 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (!existsSync(resolve(dir, 'ai'))) {
|
|
15
|
-
warnings.push('ai/ directory missing — nothing to push for agents/skills');
|
|
16
|
-
}
|
|
17
|
-
if (!existsSync(resolve(dir, 'data'))) {
|
|
18
|
-
warnings.push('data/ directory missing — nothing to push for types/lifecycles');
|
|
19
|
-
}
|
|
20
|
-
return { ok: errors.length === 0, errors, warnings };
|
|
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;
|
|
21
14
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const col = line.indexOf(':');
|
|
32
|
-
if (col < 0)
|
|
33
|
-
continue;
|
|
34
|
-
fm[line.slice(0, col).trim()] = line.slice(col + 1).trim();
|
|
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();
|
|
35
24
|
}
|
|
36
|
-
return
|
|
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 };
|
|
37
35
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oneie/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "ONE agent CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"tsx": "^4.0.0",
|
|
28
28
|
"typescript": "^5.4.0"
|
|
29
29
|
},
|
|
30
|
-
"license": "SEE LICENSE IN
|
|
30
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
31
31
|
"repository": {
|
|
32
32
|
"type": "git",
|
|
33
33
|
"url": "git+https://github.com/one-ie/packages.git",
|