@oneie/cli 0.5.2 → 0.5.4

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/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # @oneie/cli
2
+
3
+ The command line for [ONE](https://one.ie) — scaffold, validate, publish, and operate AI agents, skills, and whole agency workspaces from your terminal.
4
+
5
+ Ships two bins: **`one`** and **`oneie`** (aliases — same entry).
6
+
7
+ ```bash
8
+ npm install -g @oneie/cli
9
+ # or run without installing:
10
+ npx @oneie/cli --help
11
+ ```
12
+
13
+ ## Quick start — operate an agency on ONE
14
+
15
+ A ONE node (agency or client) is three folders the CLI compiles to the substrate:
16
+
17
+ ```
18
+ <node>/
19
+ ├── ai/ agents · skills · tools · workflows · context.md
20
+ ├── data/ types · lifecycles · content
21
+ └── _node.toml who it is
22
+ ```
23
+
24
+ ```bash
25
+ one setup # stand up your agency workspace (idempotent)
26
+ one client add <slug> # provision a managed client (workspace + credits + brand + agents)
27
+ one push [clients/<slug>] # compile ai/ + data/ → agents, skills, context, lifecycles, types, workflows
28
+ one status # P&L — funded · burned · margin · balance
29
+ one deploy # wrangler deploy the node's site/
30
+ ```
31
+
32
+ `one push` understands TOML array-of-tables (`[[stages]]`, `[[fields]]`), compiles
33
+ `data/lifecycles/*.toml` and `data/types/*.toml` into the shapes the substrate expects, and
34
+ deploys `ai/workflows/*.md` as runnable workflows — the step graph rides in a fenced
35
+ ` ```graph ` block (`{ "steps": [...], "edges": [...] }`), prose above it is human docs.
36
+
37
+ ## Reach the whole surface
38
+
39
+ The receiver namespace *is* the API — discover it, then call anything:
40
+
41
+ ```bash
42
+ one catalog [--goal G] # browse receivers grouped by recipe
43
+ one ask <receiver> '{json}' # typed, validated pass-through to any receiver
44
+ one signal <receiver> '{json}' # fire-and-forget variant
45
+ one groups | actors | things | paths | events | learning # dimension reads
46
+ one mark | warn | fade | follow | select # the verbs
47
+ ```
48
+
49
+ ## Build agents & skills
50
+
51
+ ```bash
52
+ one agent new <name> --profile core|commerce|asi
53
+ one agent validate | lint | compile --target mcp|a2a|web|skillmd
54
+ one agent publish # sync to your ONE workspace
55
+ one skill new | import <ref> | publish
56
+ one init --name N --email E # zero-to-live: register + workspace + agent + skills
57
+ ```
58
+
59
+ ## Auth
60
+
61
+ ```bash
62
+ one login --key <key> # stored at ~/.config/oneie/key (0600)
63
+ # or set ONEIE_API_KEY in the environment
64
+ ```
65
+
66
+ Workspace operations use a Bearer token `<slug>:<key>`. Override the API base per command with `--api` (default `https://one.ie`).
67
+
68
+ ## Links
69
+
70
+ - Platform: **https://one.ie**
71
+ - Developers + SDK + MCP: **https://github.com/one-ie/one**
72
+
73
+ MIT © ONE
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@oneie/cli",
3
+ "version": "0.5.4",
4
+ "description": "ONE agent CLI",
5
+ "type": "module",
6
+ "bin": {
7
+ "oneie": "dist/src/index.js",
8
+ "one": "dist/src/index.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "README.md"
13
+ ],
14
+ "scripts": {
15
+ "build": "tsc && cp package.json dist/ && chmod +x dist/src/index.js",
16
+ "dev": "tsx src/index.ts",
17
+ "typecheck": "tsc --noEmit",
18
+ "test": "vitest run",
19
+ "prepublishOnly": "bun run build"
20
+ },
21
+ "dependencies": {
22
+ "commander": "^12.0.0",
23
+ "@oneie/sdk": "^0.14.4",
24
+ "@oneie/evals": "^0.1.0"
25
+ },
26
+ "devDependencies": {
27
+ "@types/node": "^25.6.0",
28
+ "tsx": "^4.0.0",
29
+ "typescript": "^5.4.0",
30
+ "vitest": "^4.1.6"
31
+ },
32
+ "license": "SEE LICENSE IN LICENSE",
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git+https://github.com/one-ie/packages.git",
36
+ "directory": "cli"
37
+ }
38
+ }
@@ -2,7 +2,25 @@ export interface CompileItem {
2
2
  path: string;
3
3
  receiver: string;
4
4
  payload: Record<string, unknown>;
5
+ /** Workflow two-phase: after `workflow:create` returns an id, push applies this diff. */
6
+ applyDiff?: {
7
+ add: Record<string, unknown>[];
8
+ connect: Record<string, unknown>[];
9
+ };
5
10
  }
11
+ /**
12
+ * Parse a workflow `.md` into a WorkflowDiff (`{add, connect}` per @oneie/sdk/schemas).
13
+ * The deterministic step graph rides in a fenced ```graph JSON block:
14
+ * { "steps": [{ "id", "kind", "name", "config": {…} }],
15
+ * "edges": [ ["a","b"], { "from":"a", "to":"b", "condition":"…" } ] }
16
+ * Prose above the block is human docs. `config` objects are JSON-stringified (the receiver
17
+ * wants a string). Frontmatter `trigger:` seeds a trigger step when the graph omits one.
18
+ * No graph block → null (the workflow is created as a shell). Unknown kind → throws.
19
+ */
20
+ export declare function parseWorkflowGraph(md: string, fm: Record<string, string>): {
21
+ add: Record<string, unknown>[];
22
+ connect: Record<string, unknown>[];
23
+ } | null;
6
24
  export interface CompileResult {
7
25
  compiled: CompileItem[];
8
26
  errors: {
@@ -1,5 +1,50 @@
1
1
  import { readdirSync, readFileSync, statSync, existsSync } from 'node:fs';
2
2
  import { join, basename } from 'node:path';
3
+ // The 8 LOCKED workflow step kinds (one-ie/CLAUDE.md · @oneie/sdk/schemas StepKind).
4
+ const WORKFLOW_STEP_KINDS = new Set(['trigger', 'tool', 'skill', 'agent', 'condition', 'human', 'delay', 'sell']);
5
+ /**
6
+ * Parse a workflow `.md` into a WorkflowDiff (`{add, connect}` per @oneie/sdk/schemas).
7
+ * The deterministic step graph rides in a fenced ```graph JSON block:
8
+ * { "steps": [{ "id", "kind", "name", "config": {…} }],
9
+ * "edges": [ ["a","b"], { "from":"a", "to":"b", "condition":"…" } ] }
10
+ * Prose above the block is human docs. `config` objects are JSON-stringified (the receiver
11
+ * wants a string). Frontmatter `trigger:` seeds a trigger step when the graph omits one.
12
+ * No graph block → null (the workflow is created as a shell). Unknown kind → throws.
13
+ */
14
+ export function parseWorkflowGraph(md, fm) {
15
+ const m = md.match(/```graph\s*\n([\s\S]*?)```/);
16
+ if (!m)
17
+ return null;
18
+ let graph;
19
+ try {
20
+ graph = JSON.parse(m[1]);
21
+ }
22
+ catch (e) {
23
+ throw new Error(`invalid \`\`\`graph JSON: ${String(e)}`);
24
+ }
25
+ const steps = Array.isArray(graph.steps) ? graph.steps : [];
26
+ const add = steps.map((s) => {
27
+ const kind = String(s.kind ?? '');
28
+ if (!WORKFLOW_STEP_KINDS.has(kind))
29
+ throw new Error(`unknown workflow step kind "${kind}"`);
30
+ const config = typeof s.config === 'string' ? s.config : JSON.stringify(s.config ?? {});
31
+ return { tempId: String(s.id ?? ''), kind, name: String(s.name ?? s.id ?? ''), config };
32
+ });
33
+ const edges = Array.isArray(graph.edges) ? graph.edges : [];
34
+ const connect = edges.map((e) => {
35
+ if (Array.isArray(e))
36
+ return { source: String(e[0]), target: String(e[1]) };
37
+ const o = e;
38
+ return { source: String(o.from), target: String(o.to), ...(o.condition ? { condition: String(o.condition) } : {}) };
39
+ });
40
+ // Seed a trigger from frontmatter when the graph has none, wiring it to the first step.
41
+ if (fm.trigger && !add.some((s) => s.kind === 'trigger')) {
42
+ add.unshift({ tempId: 'trigger', kind: 'trigger', name: String(fm.label ?? 'Trigger'), config: JSON.stringify({ source: fm.trigger }) });
43
+ if (add.length > 1)
44
+ connect.unshift({ source: 'trigger', target: String(add[1].tempId) });
45
+ }
46
+ return { add, connect };
47
+ }
3
48
  /** Minimal TOML parser: key="v", key=123, key=true, [section], key=["a","b"] */
4
49
  export function parseToml(src) {
5
50
  const root = {};
@@ -8,6 +53,16 @@ export function parseToml(src) {
8
53
  const line = rawLine.trim();
9
54
  if (!line || line.startsWith('#'))
10
55
  continue;
56
+ if (line.startsWith('[[') && line.endsWith(']]')) {
57
+ // Array-of-tables: [[stages]] / [[fields]] — append a fresh item, point at it.
58
+ const key = line.slice(2, -2).trim();
59
+ if (!Array.isArray(root[key]))
60
+ root[key] = [];
61
+ const item = {};
62
+ root[key].push(item);
63
+ current = item;
64
+ continue;
65
+ }
11
66
  if (line.startsWith('[') && line.endsWith(']')) {
12
67
  const key = line.slice(1, -1).trim();
13
68
  if (!root[key])
@@ -157,22 +212,80 @@ export async function compileNode(dir, agencySlug, opts) {
157
212
  }
158
213
  }
159
214
  // data/types/*.toml → world:declare-types
215
+ // The receiver wants { group, types: [{ key, label, dimension, type, columns[], fields[] }] }
216
+ // with each column/field { field, label, kind(enum) }. The TOML authors { id, label,
217
+ // dimension?, [[fields]]{ name, type, label } }; map field.type → a render `kind`.
218
+ const TYPE_KIND = {
219
+ string: 'text', url: 'text', number: 'number', currency: 'currency', date: 'date',
220
+ tags: 'tags', select: 'select', image: 'image', markdown: 'markdown', relation: 'relation', bool: 'select',
221
+ };
160
222
  for (const f of walk(join(dir, 'data', 'types'), '.toml')) {
161
223
  try {
162
224
  const toml = parseToml(readFileSync(f, 'utf8'));
163
- compiled.push({ path: f, receiver: 'world:declare-types', payload: { slug: agencySlug, types: toml } });
225
+ const rawFields = Array.isArray(toml.fields) ? toml.fields : [];
226
+ const cols = rawFields.map((fl) => {
227
+ const field = String(fl.name ?? fl.field ?? '');
228
+ return {
229
+ field,
230
+ label: String(fl.label ?? field),
231
+ kind: String(fl.kind ?? TYPE_KIND[String(fl.type ?? 'string')] ?? 'text'),
232
+ };
233
+ });
234
+ const key = String(toml.id ?? basename(f, '.toml'));
235
+ const type = {
236
+ key,
237
+ label: String(toml.label ?? key),
238
+ dimension: String(toml.dimension ?? 'things'),
239
+ type: key,
240
+ columns: cols,
241
+ fields: cols,
242
+ };
243
+ compiled.push({ path: f, receiver: 'world:declare-types', payload: { group: agencySlug, types: [type] } });
164
244
  }
165
245
  catch (e) {
166
246
  errors.push({ path: f, message: String(e) });
167
247
  }
168
248
  }
169
249
  // data/lifecycles/*.toml → lifecycle:save
250
+ // Build the LifecycleDef that the receiver's saveDef() persists. The TOML authors the
251
+ // human bits {id,label,tags,description,[[stages]]}; the rest is derived deterministically:
252
+ // stage.slot numeric order (the wall loads ORDER BY slot) → the stage index
253
+ // stage.tag full namespaced tag lifecycle:<id>:<stageId> (LifecycleStage.tag)
254
+ // stage.subSteps / enter_when empty / null (no sub-steps or auto-enter rule by default)
170
255
  for (const f of walk(join(dir, 'data', 'lifecycles'), '.toml')) {
171
256
  try {
172
- const src = readFileSync(f, 'utf8');
173
- const toml = parseToml(src);
174
- const lifecycle = String(toml.lifecycle ?? basename(f, '.toml'));
175
- compiled.push({ path: f, receiver: 'lifecycle:save', payload: { slug: agencySlug, lifecycle, def: src } });
257
+ const toml = parseToml(readFileSync(f, 'utf8'));
258
+ const id = String(toml.id ?? toml.lifecycle ?? basename(f, '.toml'));
259
+ const rawStages = Array.isArray(toml.stages) ? toml.stages : [];
260
+ const stages = rawStages.map((s, i) => {
261
+ const stageId = String(s.id ?? '');
262
+ return {
263
+ id: stageId,
264
+ label: String(s.label ?? stageId),
265
+ tag: `lifecycle:${id}:${stageId}`,
266
+ slot: i,
267
+ subSteps: [],
268
+ enter_when: null,
269
+ };
270
+ });
271
+ const def = { id, name: String(toml.label ?? id), version: 1, stages, transitions: [], arcs: [], monotonic: true };
272
+ compiled.push({ path: f, receiver: 'lifecycle:save', payload: { slug: agencySlug, lifecycle: id, def } });
273
+ }
274
+ catch (e) {
275
+ errors.push({ path: f, message: String(e) });
276
+ }
277
+ }
278
+ // ai/workflows/*.md → workflow:create (+ workflow:apply-diff via item.applyDiff, two-phase in push)
279
+ for (const f of walk(join(dir, 'ai', 'workflows'), '.md')) {
280
+ try {
281
+ const md = readFileSync(f, 'utf8');
282
+ const fm = frontmatter(md);
283
+ const name = String(fm.label ?? fm.id ?? basename(f, '.md'));
284
+ const item = { path: f, receiver: 'workflow:create', payload: { name, description: String(fm.description ?? '') } };
285
+ const graph = parseWorkflowGraph(md, fm);
286
+ if (graph && graph.add.length)
287
+ item.applyDiff = graph;
288
+ compiled.push(item);
176
289
  }
177
290
  catch (e) {
178
291
  errors.push({ path: f, message: String(e) });
package/dist/src/push.js CHANGED
@@ -5,6 +5,27 @@ const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'ht
5
5
  function apiKey(env) {
6
6
  return env.ONEIE_API_KEY ?? env.ONE_API_KEY ?? process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
7
7
  }
8
+ async function ask(base, headers, receiver, data) {
9
+ try {
10
+ const res = await fetch(`${base}/api/ask/${encodeURIComponent(receiver)}`, {
11
+ method: 'POST', headers, body: JSON.stringify({ data }),
12
+ });
13
+ if (!res.ok)
14
+ return { ok: false, result: {} };
15
+ const json = (await res.json().catch(() => ({})));
16
+ return { ok: true, result: json.result ?? {} };
17
+ }
18
+ catch {
19
+ return { ok: false, result: {} };
20
+ }
21
+ }
22
+ /** workflow:create resolves the target from requireSlug(ctx), so child workflows need that
23
+ * workspace's own owner key. The configured (possibly parent) key can mint it via the walk. */
24
+ async function mintOwnerKey(base, headers, slug) {
25
+ const r = await ask(base, headers, 'world:mint-owner-key', { slug, label: 'push' });
26
+ const k = r.result.key ?? r.result.ownerKey ?? r.result.scopedKey;
27
+ return typeof k === 'string' && k ? k : null;
28
+ }
8
29
  export function pushCmd() {
9
30
  return new Command('push')
10
31
  .description('Compile ai/ + data/ folders and push to substrate')
@@ -29,8 +50,10 @@ export function pushCmd() {
29
50
  }
30
51
  if (opts.dryRun) {
31
52
  process.stdout.write(`[dry-run] ${compiled.length} item(s) would push:\n`);
32
- for (const item of compiled)
33
- process.stdout.write(` ${item.receiver} ${item.path}\n`);
53
+ for (const item of compiled) {
54
+ const steps = item.applyDiff ? ` (+${item.applyDiff.add.length} steps)` : '';
55
+ process.stdout.write(` ${item.receiver} ${item.path}${steps}\n`);
56
+ }
34
57
  return;
35
58
  }
36
59
  const base = (opts.api ?? DEFAULT_API).replace(/\/$/, '');
@@ -38,17 +61,51 @@ export function pushCmd() {
38
61
  const authHeaders = { 'Content-Type': 'application/json' };
39
62
  if (key)
40
63
  authHeaders['Authorization'] = `Bearer ${key}`;
64
+ const isWorkflow = (i) => i.receiver === 'workflow:create';
41
65
  let ok = 0;
42
- for (const item of compiled) {
66
+ // Standard items (agents, skills, context, lifecycles, types …) — explicit-slug receivers
67
+ // authorize via the ownership walk, so the configured key covers owned child workspaces.
68
+ for (const item of compiled.filter((i) => !isWorkflow(i))) {
43
69
  const res = await fetch(`${base}/api/ask/${encodeURIComponent(item.receiver)}`, {
44
- method: 'POST',
45
- headers: authHeaders,
46
- body: JSON.stringify({ data: item.payload }),
70
+ method: 'POST', headers: authHeaders, body: JSON.stringify({ data: item.payload }),
47
71
  });
48
- if (!res.ok) {
72
+ if (res.ok)
73
+ ok++;
74
+ else
49
75
  process.stderr.write(` failed: ${item.receiver} ${res.status}\n`);
76
+ }
77
+ // Workflows — two-phase (create → apply-diff) under a workspace-owner key, idempotent by name.
78
+ const wfItems = compiled.filter(isWorkflow);
79
+ if (wfItems.length) {
80
+ const wfKey = (await mintOwnerKey(base, authHeaders, agencySlug)) ?? key;
81
+ const wfHeaders = { 'Content-Type': 'application/json', Authorization: `Bearer ${wfKey}` };
82
+ // Existing workflows by name → delete a same-name match before recreating (clean re-push).
83
+ const list = await ask(base, wfHeaders, 'workflow:list', {});
84
+ const rows = (Array.isArray(list.result) ? list.result : (list.result.workflows ?? list.result.items ?? []));
85
+ const byName = new Map();
86
+ for (const w of rows) {
87
+ const n = String(w.name ?? '');
88
+ const id = String(w.id ?? w.workflowId ?? '');
89
+ if (n && id)
90
+ byName.set(n, [...(byName.get(n) ?? []), id]);
50
91
  }
51
- else {
92
+ for (const item of wfItems) {
93
+ const name = String(item.payload.name ?? '');
94
+ for (const id of byName.get(name) ?? [])
95
+ await ask(base, wfHeaders, 'workflow:delete', { workflowId: id });
96
+ const created = await ask(base, wfHeaders, 'workflow:create', item.payload);
97
+ const wid = created.result.workflowId ?? created.result.id;
98
+ if (!created.ok || typeof wid !== 'string') {
99
+ process.stderr.write(` failed: workflow:create ${name}\n`);
100
+ continue;
101
+ }
102
+ if (item.applyDiff) {
103
+ const applied = await ask(base, wfHeaders, 'workflow:apply-diff', { workflowId: wid, diff: item.applyDiff });
104
+ if (!applied.ok || applied.result.ok === false) {
105
+ process.stderr.write(` failed: workflow:apply-diff ${name}\n`);
106
+ continue;
107
+ }
108
+ }
52
109
  ok++;
53
110
  }
54
111
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneie/cli",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "ONE agent CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -12,20 +12,22 @@
12
12
  "README.md"
13
13
  ],
14
14
  "scripts": {
15
- "build": "tsc && chmod +x dist/src/index.js",
15
+ "build": "tsc && cp package.json dist/ && chmod +x dist/src/index.js",
16
16
  "dev": "tsx src/index.ts",
17
17
  "typecheck": "tsc --noEmit",
18
+ "test": "vitest run",
18
19
  "prepublishOnly": "bun run build"
19
20
  },
20
21
  "dependencies": {
21
22
  "commander": "^12.0.0",
22
- "@oneie/sdk": "^0.14.2",
23
- "@oneie/evals": "workspace:*"
23
+ "@oneie/sdk": "^0.14.4",
24
+ "@oneie/evals": "^0.1.0"
24
25
  },
25
26
  "devDependencies": {
26
27
  "@types/node": "^25.6.0",
27
28
  "tsx": "^4.0.0",
28
- "typescript": "^5.4.0"
29
+ "typescript": "^5.4.0",
30
+ "vitest": "^4.1.6"
29
31
  },
30
32
  "license": "SEE LICENSE IN LICENSE",
31
33
  "repository": {