@oalo-ai/cli 0.2.0 → 0.4.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/man/oalo.1 CHANGED
@@ -1,4 +1,4 @@
1
- .TH OALO 1 "" "oalo 0.1.1" "OALO CLI"
1
+ .TH OALO 1 "" "oalo 0.3.0" "OALO CLI"
2
2
  .SH NAME
3
3
  oalo \- wire a local app into your Oalo workspace
4
4
  .SH SYNOPSIS
@@ -634,6 +634,51 @@ auto on: a dev deploy that finds nothing runnable, or a preview that doesn't run
634
634
  Admins and members with Developer access only.
635
635
  .PP
636
636
  Exit codes: 0 done; 1 refused, or (status) the last setup failed; 2 bad arguments or no CLI token.
637
+ .SS build
638
+ A store build of a Flutter or Expo app: the .ipa for App Store Connect and the .aab for Google Play, with download links.
639
+ .PP
640
+ \fBoalo build [\-\-app <slug>] [\-\-wait] [\-\-download] [\-\-json]\fR
641
+ .br
642
+ \fBoalo build status [\-\-app <slug>] [\-\-build <id>] [\-\-wait] [\-\-download] [\-\-json]\fR
643
+ .br
644
+ \fBoalo build list [\-\-app <slug>] [\-\-json]\fR
645
+ .br
646
+ \fBoalo build upload <file> \-\-target <name> [\-\-app <slug>] [\-\-build <id>]\fR
647
+ .br
648
+ .TP
649
+ \fB\-\-app <slug>\fR
650
+ The app. Default: the one saved with \fBoalo link \-\-app\fR.
651
+ .TP
652
+ \fB\-\-wait\fR
653
+ Follow the build until it's done (15 to 60 minutes), then print the links.
654
+ .TP
655
+ \fB\-\-download\fR
656
+ Save the .ipa and .aab in this folder when the build is done (implies \-\-wait). An existing file is left as it is.
657
+ .TP
658
+ \fB\-\-build <id>\fR
659
+ status, upload: that build instead of the latest one (\fBoalo build list\fR shows the ids).
660
+ .TP
661
+ \fB\-\-target <name>\fR
662
+ upload: the platform the file is for, one the app's .oalo/app.json lists under targets.external (garmin, macos).
663
+ .TP
664
+ \fB\-\-json\fR
665
+ The reply as JSON.
666
+ .IP \(bu 2
667
+ One build makes the file of each platform whose signing is set up (the app's Native Build tab says what's missing). Flutter apps build on Codemagic, Expo apps on EAS with your own Expo token (set it in Integrations, on the Expo tab). The version code goes up by one each build.
668
+ .IP \(bu 2
669
+ A build uses the app's code on Oalo, not this folder: \fBoalo deploy\fR your commits first.
670
+ .IP \(bu 2
671
+ Extra targets are built only when the app's .oalo/app.json declares them. A watch app: add \fB"targets": {"watchos": {"scheme": "<its Xcode scheme>"}}\fR, deploy, then set up its signing in the app's Native Build tab ("Set up the watch app's signing"); it ships inside the .ipa. A Wear OS app: \fB"wearos": {"module": "wear"}\fR (its Gradle module in android/), built as its own \-wear.aab for Play's Wear OS track. Platforms built elsewhere: \fB"external": ["garmin"]\fR, then \fBoalo build upload <file> \-\-target garmin\fR keeps the file with a build.
672
+ .IP \(bu 2
673
+ The files are private on your Base. Their links last an hour; \fBoalo build status\fR gives fresh ones. The app's Native Build tab in the dashboard has the same downloads.
674
+ .IP \(bu 2
675
+ Nothing is sent to the stores. Upload the .ipa with Transporter (or \fBxcrun altool \-\-upload\-app\fR), and the .aab in Google Play Console under a release.
676
+ .IP \(bu 2
677
+ \fBoalo deploy\fR updates the app's web preview; it doesn't make a store build.
678
+ .IP \(bu 2
679
+ One build of an app at a time. Admins and members with Developer access only.
680
+ .PP
681
+ Exit codes: 0 started, or (status, \-\-wait) built; 1 refused, the build failed, or a download failed; 2 bad arguments or no CLI token.
637
682
  .SS sources
638
683
  Feeds that send Oalo rows from outside (another system, a webhook, an export), keeping only the fields you choose.
639
684
  .PP
@@ -649,6 +694,8 @@ Feeds that send Oalo rows from outside (another system, a webhook, an export), k
649
694
  .br
650
695
  \fBoalo sources create <name> \-\-bot <bot> [\-\-auth bearer|hmac|url]\fR
651
696
  .br
697
+ \fBoalo sources create <name> \-\-from\-postgres <postgres url> \-\-relation <schema.view> [\-\-key <column>] [\-\-cursor <column>] [\-\-every <minutes>] [\-\-table <new model>] [\-\-now]\fR
698
+ .br
652
699
  \fBoalo sources push <name> <file.csv|.json|.jsonl> [\-\-json]\fR
653
700
  .br
654
701
  \fBoalo sources push <name> <doc.pdf|.docx|.md|.html|.txt> [more...] [\-\-json]\fR
@@ -670,6 +717,9 @@ Feeds that send Oalo rows from outside (another system, a webhook, an export), k
670
717
  \fBoalo sources delete <name> [\-\-wipe]\fR
671
718
  .br
672
719
  .TP
720
+ \fB\-\-from\-postgres <url>\fR
721
+ create: a view (or table) in your own Postgres, in one step. The Base reads its columns and makes the model from them, then reads the view on a schedule (\-\-every, default 60 minutes; \-\-cursor <column> for only new or changed rows, else the whole view each time as a snapshot). Put the address in a variable: \-\-from\-postgres "$DB_URL". See \fBoalo docs data\-sources\fR.
722
+ .TP
673
723
  \fB\-\-from <file>\fR
674
724
  create: a sample of what the sender sends. Its fields and their types make the source's fields and a new model (\-\-table, default the source's name).
675
725
  .TP
@@ -1359,6 +1409,93 @@ Reads OALO_URL and OALO_CLI_TOKEN, or falls back to what \fBoalo link \-\-cli\-t
1359
1409
  Needs a CLI token.
1360
1410
  .PP
1361
1411
  Exit codes: 0 stopped cleanly; 1 no workspace or CLI token.
1412
+ .SS coord
1413
+ Several agents on one codebase: a shared task board, a worktree per task, a merge queue. First run: \fBoalo coord install\fR.
1414
+ .PP
1415
+ \fBoalo coord install [\-\-force] [\-\-json]\fR
1416
+ .br
1417
+ \fBoalo coord init [\-\-main <branch>] [\-\-test\-cmd <cmd>] [\-\-merge auto|manual] [\-\-signal\-review]\fR
1418
+ .br
1419
+ \fBoalo coord hooks install [\-\-claude] [\-\-opencode]\fR
1420
+ .br
1421
+ \fBoalo coord mcp\fR
1422
+ .br
1423
+ \fBoalo coord board [\-\-json]\fR
1424
+ .br
1425
+ \fBoalo coord events [\-\-follow] [\-\-since <id>] [\-\-json]\fR
1426
+ .br
1427
+ \fBoalo coord files [\-\-json] [\-\-main <branch>]\fR
1428
+ .br
1429
+ \fBoalo coord view [\-\-port <n>] [\-\-main <branch>] [\-\-no\-open]\fR
1430
+ .br
1431
+ \fBoalo coord claim <task>\fR
1432
+ .br
1433
+ \fBoalo coord merge [\-\-all]\fR
1434
+ .br
1435
+ \fBoalo coord approve plan [\-\-yes] | merge <task> | signal <task> <milestone> | proposal <id> [\-\-note <text>]\fR
1436
+ .br
1437
+ \fBoalo coord reject proposal <id> [\-\-note <text>]\fR
1438
+ .br
1439
+ \fBoalo coord hook <pre\-tool|stop|subagent\-stop|check\-write|check\-stop|check\-command>\fR
1440
+ .br
1441
+ .TP
1442
+ \fB\-\-force\fR
1443
+ install: download again even if this version is installed.
1444
+ .TP
1445
+ \fB\-\-main <branch>\fR
1446
+ init: branch the merge queue integrates into. Default: current branch.
1447
+ .TP
1448
+ \fB\-\-test\-cmd <cmd>\fR
1449
+ init: merge\-gate test command. Default: detected (mix test, npm test, ...).
1450
+ .TP
1451
+ \fB\-\-merge auto|manual\fR
1452
+ init: manual holds each merge for \fBapprove merge\fR.
1453
+ .TP
1454
+ \fB\-\-signal\-review\fR
1455
+ init: milestones unblock dependents only after \fBapprove signal\fR.
1456
+ .TP
1457
+ \fB\-\-yes\fR
1458
+ approve plan: skip the confirmation after the plan is shown.
1459
+ .TP
1460
+ \fB\-\-note <text>\fR
1461
+ approve/reject proposal: a note the worker sees with the decision.
1462
+ .TP
1463
+ \fB\-\-json\fR
1464
+ install/board/events/files: machine\-readable output.
1465
+ .TP
1466
+ \fB\-\-follow\fR
1467
+ events: keep streaming.
1468
+ .TP
1469
+ \fB\-\-all\fR
1470
+ merge: keep merging until the queue is idle or blocked.
1471
+ .IP \(bu 2
1472
+ Coord lets several coding agent sessions (Claude Code, OpenCode, Codex, any MCP client) work on one git repo at once. It runs on your machine; the board is .oalo/coord.db in the repo. No Oalo workspace or sign\-in is needed. Full guide: https://oalo.ai/docs/several\-agents\-one\-repo (or \fBoalo docs several\-agents\-one\-repo\fR when signed in).
1473
+ .IP \(bu 2
1474
+ Setup, once per machine: \fBoalo coord install\fR downloads coord for it (about 25 MB on macOS, 37 MB on Linux, checked against this package's checksum). Once per repo: \fBoalo coord init\fR, then \fBoalo coord hooks install\fR, then commit .oalo/coord.json, .gitignore, .claude/settings.json, .mcp.json, opencode.json and .opencode/. .claude/settings.local.json holds this machine's worktree folder and stays out of git.
1475
+ .IP \(bu 2
1476
+ Coord never starts agents. The person opens the sessions, or a manager starts workers as its harness's own subagents. Every session opened in the repo, or in a task's worktree, gets the board's tools through the \fBoalo\-coord\fR MCP server that hooks install registers; the server finds the one board from any worktree. The board also gives each session a short orientation; the person tells it its role. Manager: "You're the oalo coord manager for this repo. Call manager_guide, then plan: <goal>". Worker: "You're an oalo coord worker. Call task_next and follow the brief."
1477
+ .IP \(bu 2
1478
+ Manager: reads manager_guide (the full playbook), then drafts tasks with task_create (title, spec, acceptance criteria, writes: the globs it may change, provides: milestones it will signal, depends_on), then calls plan_submit. Nothing runs until the person approves. Then it handles the inbox (inbox, ack, answer, decide), reviews reports (task_detail, task_reopen) and merges (merge_next). Other tools: task_update, task_cancel, board, wait.
1479
+ .IP \(bu 2
1480
+ Worker: calls task_next, which returns a claim token, its own git worktree and a brief with the spec and how to finish. It works only inside that worktree and its write set, commits, calls signal as soon as a milestone others wait on is committed, and ends with task_done or task_fail and a report. Other tools: release (paths it is finished with), signal_amend, lease_acquire / lease_release (a port, the dev database, migrations), ask, propose_change, report_blocked, notify, wait. Every worker call passes its claim.
1481
+ .IP \(bu 2
1482
+ Messages need no polling: each worker reply carries its notices (answers, decisions, changed dependencies) and who is waiting on it. In Claude Code and OpenCode, a worker that stops while holding a task is sent back to finish it (up to three times) and gets answers to its questions. In Claude Code the manager's stop also waits for its inbox while tasks are running; in other harnesses the manager calls wait.
1483
+ .IP \(bu 2
1484
+ Only a person approves, in their own terminal: \fBapprove plan\fR (shows the design, the tasks and their files, then asks to type yes; it covers only the drafts sent with plan_submit, unchanged since), \fBapprove merge\fR, \fBapprove signal\fR, \fBapprove proposal\fR, \fBreject proposal\fR. They refuse from an agent's shell. An agent tells the person what is waiting and the command to run.
1485
+ .IP \(bu 2
1486
+ Scheduling: a task starts when every milestone it depends on is signalled and no running task's write set overlaps its own. A worker that signals a milestone mid\-task lets its dependents start from that commit right away.
1487
+ .IP \(bu 2
1488
+ Merge queue (merge_next, \fBoalo coord merge\fR): one run at a time. A task merges with a merge commit after every task it builds on has merged, and only if the project's test command passes, then the task's own test_cmd if it has one. A conflict or failing test sends it back to a worker with the output. A branch that changes .oalo/coord.json, .oalo/setup or the hook and MCP config waits for \fBapprove merge\fR.
1489
+ .IP \(bu 2
1490
+ Rework: task_reopen, a merge conflict or a failing merge test sends a task back, and they count together: first held for the same worker for claim_ttl_s, then any worker; the third time it stops as needs_human until the manager sets it back to ready. A worker silent for claim_ttl_s (15 minutes) loses its claim, the manager gets its commits in a report, and the next worker resumes the same worktree.
1491
+ .IP \(bu 2
1492
+ Settings in .oalo/coord.json (a person edits them): main_branch, test_cmd, merge (auto or manual), signal_review, claim_ttl_s, port_base, port_span. Task worktrees live in ~/.oalo/worktrees/<repo>\-<hash>/<task> (OALO_HOME moves them). An executable .oalo/setup runs in each new worktree with OALO_TASK_ID, OALO_WORKTREE, OALO_PROJECT_ROOT, OALO_PORT_BASE, OALO_PORT_SPAN and OALO_DB_NAME set.
1493
+ .IP \(bu 2
1494
+ The hooks block edits outside a worker's worktree and write set, and edits to coord's own files. Shell writes (sed \-i, redirects) aren't intercepted; the merge queue still catches their damage. Harnesses without hooks rely on the merge queue alone.
1495
+ .IP \(bu 2
1496
+ macOS and Linux only.
1497
+ .PP
1498
+ Exit codes: 0 ok; 1 operation refused or failed (message on stderr); 2 bad arguments; 3 no board here; run `oalo coord init`; 4 coord isn't installed on this machine; run `oalo coord install`.
1362
1499
  .SH BOT SETTINGS
1363
1500
  Read with \fBoalo bots settings <bot>\fR, changed with \fBoalo bots settings <bot> set key=value\fR, explained with \fBoalo bots settings \-\-explain <key>\fR. A change to a published bot needs \-\-yes.
1364
1501
  .SS knowledge
@@ -1526,6 +1663,11 @@ Hours after the customer's last WhatsApp message to flag the 24\-hour window as
1526
1663
  .br
1527
1664
  Values: a number from 1 to 23. Default: 20.
1528
1665
  .TP
1666
+ \fBlead_watch.no_reply_hours\fR
1667
+ Hours after our last message with no answer from the customer before the conversation is tagged "no reply" and the No reply from customer trigger fires. 0 turns it off.
1668
+ .br
1669
+ Values: a number from 0 to 168. Default: 24.
1670
+ .TP
1529
1671
  \fBallow_ambient_uploads\fR
1530
1672
  Show an attach button in the web chat, so members can send files with their message.
1531
1673
  .br
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oalo-ai/cli",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Wire a local app into your OALO workspace: link a token, generate typed bindings, and serve the build surface over MCP.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -24,9 +24,11 @@
24
24
  "scripts": {
25
25
  "smoke": "node test/smoke.mjs",
26
26
  "smoke:mcp": "node test/mcp-smoke.mjs",
27
- "test:coord": "bun test test/coord.test.ts",
27
+ "test:coord": "bun test test/coord.test.ts test/coord-files.test.ts test/coord-hooks.test.ts test/coord-fixes.test.ts",
28
28
  "test:unit": "node --test test/*.test.mjs",
29
- "man": "node scripts/man.mjs"
29
+ "man": "node scripts/man.mjs",
30
+ "coord:build": "node scripts/coord_build.mjs",
31
+ "prepublishOnly": "node scripts/coord_check.mjs"
30
32
  },
31
33
  "publishConfig": {
32
34
  "access": "public"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "oalo",
3
3
  "description": "Work on an Oalo workspace from Claude Code: edit chat flows, loops and code tools, lint and push them safely, and run test conversations with a bot.",
4
- "version": "0.1.0",
4
+ "version": "0.3.0",
5
5
  "author": { "name": "Oalo" },
6
6
  "mcpServers": {
7
7
  "oalo": {
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: oalo
3
- description: Build and change an Oalo workspace (the person's Oalo Base) from the terminal with the oalo CLI or its MCP server: chat flows, loops (automations), code tools, bots and what they know, data models and rows, hosting a repo and its environment variables, and what an app gets from Oalo (its own token, events into workflows, workflows as functions, its endpoints as bot tools, a chat widget, member sign-in and sync). Use when editing a flow, loop or tool, testing how a bot answers, moving data in or out of Oalo, bringing or deploying an app, or wiring an app's own code to Oalo.
3
+ description: Build and change an Oalo workspace (the person's Oalo Base) from the terminal with the oalo CLI or its MCP server: chat flows, loops (automations), code tools, bots and what they know, data models and rows, hosting a repo and its environment variables, and what an app gets from Oalo (its own token, events into workflows, workflows as functions, its endpoints as bot tools, a chat widget, member sign-in and sync). Use when editing a flow, loop or tool, testing how a bot answers, moving data in or out of Oalo, bringing or deploying an app, wiring an app's own code to Oalo, or splitting work across several agent sessions on one repo.
4
4
  ---
5
5
 
6
6
  # Working on an Oalo workspace
@@ -222,6 +222,7 @@ oalo deploy --new [<name>] # this repo becomes a new app, its history
222
222
  oalo deploy --new --from <https url> # a repo on a Git host becomes an app, no checkout
223
223
  oalo deploy --app shop # this branch's commits to the preview (dev)
224
224
  oalo deploy --app shop --env prod # build and swap the live release
225
+ oalo build --app shop --download # a Flutter or Expo app's store files (.ipa, .aab), saved here
225
226
  ```
226
227
 
227
228
  0. **A repo that isn't on Oalo yet** (the person wants to host their code):
@@ -286,6 +287,13 @@ oalo deploy --app shop --env prod # build and swap the live release
286
287
  set NAME=value`: for values it can't read (Fly secrets, Primcloud) the
287
288
  person puts them in a .env file and you pass `--env-file`. Then the data
288
289
  (rule 7), and live only when the person says so.
290
+ 9. **App Store and Google Play files** (a Flutter or Expo app): `oalo deploy`
291
+ updates only the web preview. `oalo build --app shop --download` makes a
292
+ store build (15 to 60 minutes, both platforms) and saves the `.ipa` and
293
+ `.aab` where you run it. Oalo doesn't upload them: tell the person to
294
+ deliver the `.ipa` with Transporter and upload the `.aab` in Google Play
295
+ Console. Each build raises the version code, so start one only when asked.
296
+ Don't build them locally with Xcode, Gradle, `flutter build` or `eas build`.
289
297
 
290
298
  ## An app's environment variables
291
299
 
@@ -415,6 +423,21 @@ oalo channels # WhatsApp, Instagram, emai
415
423
  but the bot's data tools leave it out, and it can't be embedded. Don't
416
424
  vectorize it.
417
425
 
426
+ ## Several agents on one repo
427
+
428
+ When the person wants work split across several agent sessions on one repo at
429
+ once, use `oalo coord`: a shared task board, a git worktree per task and a
430
+ merge queue that runs the tests. It needs no Oalo workspace.
431
+
432
+ 1. **Set it up once:** `oalo coord install` (once per machine), then in the
433
+ repo `oalo coord init` and `oalo coord hooks install`, and commit what they
434
+ write. Each session then has the board's tools (MCP server `oalo-coord`).
435
+ 2. **The person approves, never you.** The manager drafts tasks and calls
436
+ `plan_submit`; the person runs `oalo coord approve plan` in their own
437
+ terminal. Never run `oalo coord approve` or `reject` yourself: say what is
438
+ waiting and give them the command.
439
+ 3. `oalo help coord` has every command.
440
+
418
441
  ## Reading the docs
419
442
 
420
443
  Before building on a feature you don't know, read Oalo's own docs. They come
@@ -392,6 +392,19 @@
392
392
  23
393
393
  ]
394
394
  },
395
+ {
396
+ "clear_word": null,
397
+ "default": 24,
398
+ "doc": "Hours after our last message with no answer from the customer before the conversation is tagged \"no reply\" and the No reply from customer trigger fires. 0 turns it off.",
399
+ "effect": null,
400
+ "group": "replies",
401
+ "key": "lead_watch.no_reply_hours",
402
+ "type": "number",
403
+ "values": [
404
+ 0,
405
+ 168
406
+ ]
407
+ },
395
408
  {
396
409
  "clear_word": null,
397
410
  "default": false,
@@ -39,11 +39,16 @@ export async function apps(flags) {
39
39
  if (flags.json) return void console.log(JSON.stringify(rows, null, 2));
40
40
  if (!rows.length) return void console.log(`no apps in ${url}`);
41
41
 
42
+ // A Base stores app hostnames as labels (`dev-shop-acme`); the domain is the
43
+ // workspace's own, less its first label (`acme.oalo.ai` -> `oalo.ai`).
44
+ const apex = new URL(url).hostname.split(".").slice(1).join(".");
45
+ const host = (h) => (h && !h.includes(".") && apex ? `${h}.${apex}` : h);
46
+
42
47
  for (const a of rows.sort((x, y) => String(x.slug).localeCompare(String(y.slug)))) {
43
48
  const runtime = a.app_type === "server" ? `server/${a.config?.server_runtime || "node"}` : a.app_type;
44
49
  console.log(`${a.slug} ${dim(`${runtime}, ${a.status}${a.slug === cfg.appId ? ", linked" : ""}`)}`);
45
- if (a.preview_hostname) console.log(dim(` preview https://${a.preview_hostname}/`));
46
- const live = a.custom_hostname || a.prod_hostname;
50
+ if (a.preview_hostname) console.log(dim(` preview https://${host(a.preview_hostname)}/`));
51
+ const live = host(a.custom_hostname || a.prod_hostname);
47
52
  if (a.release?.commit_hash) {
48
53
  console.log(dim(` live https://${live}/ at ${String(a.release.commit_hash).slice(0, 8)}${a.release.launched_at ? `, ${String(a.release.launched_at).slice(0, 16).replace("T", " ")}` : ""}`));
49
54
  if (a.incident) console.log(` ! ${a.incident.title} (since ${String(a.incident.opened_at).slice(0, 16).replace("T", " ")}): oalo incidents --app ${a.slug}`);
@@ -0,0 +1,219 @@
1
+ import { createReadStream, createWriteStream, existsSync, renameSync, rmSync, statSync } from "node:fs";
2
+ import { basename, join } from "node:path";
3
+ import { Readable } from "node:stream";
4
+ import { pipeline } from "node:stream/promises";
5
+ import { OaloChannel } from "../channel.js";
6
+ import { resolve as resolveConfig, controlPlane, HOW_TO_CONNECT } from "../config.js";
7
+ import { dim } from "../events.js";
8
+
9
+ /**
10
+ * `oalo build`: a store build of a Flutter or Expo app. One build makes both
11
+ * files: the .ipa for App Store Connect (upload it with Transporter) and the
12
+ * .aab for Google Play Console. The files are private on your Base; their
13
+ * download links last an hour, and asking again gives fresh ones.
14
+ *
15
+ * oalo build [--app <slug>] [--wait] [--download] [--json] start one
16
+ * oalo build status [--app <slug>] [--build <id>] [--wait] [--download] [--json]
17
+ * oalo build list [--app <slug>] [--json]
18
+ * oalo build upload <file> --target <name> [--app <slug>] [--build <id>] keep a file built elsewhere with a build
19
+ */
20
+ export async function build(flags, rest, opts = {}) {
21
+ const sub = rest[1] || "start";
22
+ if (!["start", "status", "list", "upload"].includes(sub)) return fail(`unknown build command: ${sub}\n\n${USAGE}`, 2);
23
+ if (sub === "upload" && (!rest[2] || typeof flags.target !== "string")) return fail("usage: oalo build upload <file> --target <name> [--app <slug>] [--build <id>]", 2);
24
+ if (sub === "upload" && !existsSync(rest[2])) return fail(`no file ${rest[2]}`, 2);
25
+
26
+ const cfg = resolveConfig(flags);
27
+ const { url, token } = controlPlane(cfg);
28
+ if (!url || !token) return fail(`oalo build needs a CLI token.\n\n${HOW_TO_CONNECT}`, 2);
29
+ const app = typeof flags.app === "string" ? flags.app : cfg.appId;
30
+ if (!app) return fail("which app? Pass --app <slug> (`oalo apps` lists them), or save it with `oalo link --app <slug>`.", 2);
31
+
32
+ const call = makeCall(opts.channel || ((o) => new OaloChannel(o)), { url, token });
33
+ const sleep = opts.sleep || ((ms) => new Promise((r) => setTimeout(r, ms)));
34
+ const wait = flags.wait === true || flags.download === true;
35
+
36
+ if (sub === "upload") return upload(call, app, rest[2], flags, opts);
37
+
38
+ let r;
39
+ try {
40
+ if (sub === "list") r = await call("native_build:list", { app });
41
+ else if (sub === "start") r = await call("native_build:start", { app });
42
+ else r = await call("native_build:status", { app, ...(typeof flags.build === "string" ? { build: flags.build } : {}) });
43
+ } catch (e) {
44
+ return fail(e.message, 1);
45
+ }
46
+
47
+ if (sub === "list") {
48
+ if (flags.json) return void console.log(JSON.stringify(r, null, 2));
49
+ if (!r.builds.length) return void console.log(`${r.app}: no store builds yet. oalo build --app ${r.app} starts one.`);
50
+ for (const b of r.builds) console.log(`${b.id} ${label(b)} ${state(b)} ${dim(b.created_at || "")}`);
51
+ return;
52
+ }
53
+
54
+ if (sub === "start" && !flags.json) {
55
+ console.log(`${r.app}: building ${label(r)} for ${platformNames(r.targets)} (${r.id}). This takes 15 to 60 minutes.`);
56
+ if (!wait) console.log(dim(`oalo build status --app ${r.app} shows how it's going; --wait follows it, --download also saves the files here.`));
57
+ }
58
+
59
+ // Follow it until it's done.
60
+ let b = r;
61
+ let tries = 0;
62
+ while (wait && b.status === "processing") {
63
+ if (++tries > 720) return fail(`${b.app}: still building after 6 hours; oalo build status --app ${b.app} checks again.`, 1);
64
+ await sleep(opts.pollMs ?? 30000);
65
+ try {
66
+ b = await call("native_build:status", { app, build: r.id });
67
+ } catch (e) {
68
+ // A dropped connection on a long wait isn't the build failing.
69
+ if (tries % 10 === 0) console.error(dim(`still waiting (${e.message})`));
70
+ }
71
+ }
72
+
73
+ if (flags.json && !flags.download) return void console.log(JSON.stringify(b, null, 2));
74
+ if (sub === "start" && !wait) return;
75
+
76
+ report(b, url);
77
+ if (b.status === "processing") return;
78
+ // A build where one platform failed still keeps the others' files (Android
79
+ // built, iOS didn't, say): list and download those, and still exit 1.
80
+ const partial = b.success === false;
81
+ if (partial) process.exitCode = 1;
82
+ if (partial && !files(b).length) return;
83
+
84
+ if (flags.download) {
85
+ const saved = [];
86
+ for (const [platform, link] of files(b)) {
87
+ try {
88
+ saved.push(await download(link, opts.fetch || fetch, opts.cwd || process.cwd()));
89
+ } catch (e) {
90
+ return fail(`couldn't download the ${platform} file: ${e.message}`, 1);
91
+ }
92
+ }
93
+ if (flags.json) return void console.log(JSON.stringify({ ...b, saved }, null, 2));
94
+ for (const s of saved) console.log(s.skipped ? `${s.file} is already here; left as it is` : `saved ${s.file} (${(s.bytes / 1e6).toFixed(1)} MB)`);
95
+ }
96
+ nextSteps(b);
97
+ }
98
+
99
+ const USAGE = [
100
+ "usage: oalo build [--app <slug>] [--wait] [--download] [--json]",
101
+ " oalo build status [--app <slug>] [--build <id>] [--wait] [--download] [--json]",
102
+ " oalo build list [--app <slug>] [--json]",
103
+ " oalo build upload <file> --target <name> [--app <slug>] [--build <id>]",
104
+ ].join("\n");
105
+
106
+ /**
107
+ * A file built elsewhere (a Garmin watch face, a macOS app: a target the
108
+ * app's .oalo/app.json lists under targets.external), kept with a build on
109
+ * the Base: an upload address from the Base, the file straight to private
110
+ * storage, then attached.
111
+ */
112
+ async function upload(call, app, file, flags, opts) {
113
+ const params = { app, target: flags.target, filename: basename(file), ...(typeof flags.build === "string" ? { build: flags.build } : {}) };
114
+ try {
115
+ const up = await call("native_build:upload_url", params);
116
+ const size = statSync(file).size;
117
+ const res = await (opts.fetch || fetch)(up.url, {
118
+ method: "PUT",
119
+ headers: { "content-type": "application/octet-stream", "content-length": String(size) },
120
+ body: Readable.toWeb(createReadStream(file)),
121
+ duplex: "half",
122
+ });
123
+ if (!res.ok) return fail(`upload failed: HTTP ${res.status}`, 1);
124
+ const b = await call("native_build:attach", { app, target: flags.target, key: up.key, build: up.build });
125
+ if (flags.json) return void console.log(JSON.stringify(b, null, 2));
126
+ console.log(`kept ${basename(file)} (${(size / 1e6).toFixed(1)} MB) with ${b.app || app} ${label(b)} (${b.id}) as ${flags.target}.`);
127
+ console.log(dim(`oalo build status --app ${app} --build ${b.id} lists its files with download links.`));
128
+ } catch (e) {
129
+ return fail(e.message, 1);
130
+ }
131
+ }
132
+
133
+ /** One call per request: a build is followed for up to an hour, longer than a channel is worth holding. */
134
+ function makeCall(open, conn) {
135
+ return async (event, params) => {
136
+ const ch = open(conn);
137
+ try {
138
+ await ch.connect();
139
+ return await ch.call(event, params, 120000);
140
+ } finally {
141
+ ch.close();
142
+ }
143
+ };
144
+ }
145
+
146
+ // The platforms a build makes (the ones whose signing was ready), in words.
147
+ const PLATFORM_NAMES = { ios: "iOS", android: "Android", watchos: "its watch app", wearos: "Wear OS" };
148
+ function platformNames(targets) {
149
+ const names = (Array.isArray(targets) && targets.length ? targets : ["ios", "android"]).map((p) => PLATFORM_NAMES[p] || p);
150
+ return names.length > 1 ? `${names.slice(0, -1).join(", ")} and ${names.at(-1)}` : names[0];
151
+ }
152
+
153
+ const label = (b) => `${b.version || "?"} (${b.version_code || "?"})`;
154
+ const state = (b) => (b.status === "processing" ? "building" : b.success ? "built" : `failed: ${b.error_message || "no reason given"}`);
155
+
156
+ function report(b, base) {
157
+ if (b.status === "processing") {
158
+ console.log(`${b.app}: ${label(b)} is building (${b.id}, started ${b.created_at}).`);
159
+ return;
160
+ }
161
+ if (!b.success) {
162
+ console.error(`${b.app}: ${label(b)} failed: ${b.error_message || "no reason given"}`);
163
+ const made = files(b);
164
+ if (made.length) {
165
+ console.log(`These were made anyway (links last ${Math.round((b.links_expire_in_s || 3600) / 60)} minutes):`);
166
+ for (const [platform, link] of made) console.log(` ${platform.padEnd(8)} ${link}`);
167
+ }
168
+ return;
169
+ }
170
+ const mins = Math.round((b.links_expire_in_s || 3600) / 60);
171
+ console.log(`${b.app}: ${label(b)} built.`);
172
+ const all = files(b);
173
+ for (const [platform, link] of all) console.log(` ${platform.padEnd(8)} ${link}`);
174
+ if (!all.length) console.log(" (no files were kept for this build)");
175
+ console.log(dim(`The links last ${mins} minutes; oalo build status gives fresh ones. Also in the dashboard: ${String(base).replace(/^ws/, "http")}, the app's Native Build tab.`));
176
+ }
177
+
178
+ /** [label, link] for each file the build kept: iOS, Android, Wear OS, then any attached with `oalo build upload`. */
179
+ function files(b) {
180
+ const out = [["iOS", b.ios_build_url], ["Android", b.android_build_url], ["Wear OS", b.wear_build_url]];
181
+ for (const [target, link] of Object.entries(b.extra_build_urls || {})) out.push([target, link]);
182
+ return out.filter(([, link]) => link);
183
+ }
184
+
185
+ function nextSteps(b) {
186
+ if (!files(b).length) return;
187
+ console.log(dim("Next:"));
188
+ // The watch line only when this build made a watch app (targets lists it).
189
+ const watch = Array.isArray(b.targets) && b.targets.includes("watchos") ? " The watch app is inside it." : "";
190
+ if (b.ios_build_url) console.log(dim(` iOS: open the .ipa in Transporter and Deliver it to App Store Connect (or: xcrun altool --upload-app -t ios -f <file.ipa> --apiKey <key id> --apiIssuer <issuer id>).${watch}`));
191
+ if (b.android_build_url) console.log(dim(" Android: in Google Play Console, open the app, then a testing track or Production, Create new release, and upload the .aab."));
192
+ if (b.wear_build_url) console.log(dim(" Wear OS: in Play Console, the same app's Wear OS release track (add the Wear OS form factor once), and upload the -wear.aab."));
193
+ }
194
+
195
+ /** Save a download link's file here, named as on the Base (`<slug>-<version>-<code>.ipa`). Never overwrites. */
196
+ async function download(link, fetchFn, cwd) {
197
+ const file = basename(new URL(link).pathname);
198
+ const dest = join(cwd, file);
199
+ if (existsSync(dest)) return { file, skipped: true, bytes: 0 };
200
+ const res = await fetchFn(link);
201
+ if (!res.ok) throw new Error(`HTTP ${res.status}${res.status === 403 ? " (the link may have expired; run oalo build status --download again)" : ""}`);
202
+ const tmp = `${dest}.part`;
203
+ let bytes = 0;
204
+ const counted = Readable.fromWeb(res.body);
205
+ counted.on("data", (c) => (bytes += c.length));
206
+ try {
207
+ await pipeline(counted, createWriteStream(tmp));
208
+ } catch (e) {
209
+ rmSync(tmp, { force: true });
210
+ throw e;
211
+ }
212
+ renameSync(tmp, dest);
213
+ return { file, bytes };
214
+ }
215
+
216
+ function fail(message, code) {
217
+ console.error(message);
218
+ process.exitCode = code;
219
+ }
@@ -93,14 +93,19 @@ function print(sub, channel, ref, r) {
93
93
  }
94
94
  if (sub === "check") {
95
95
  const status = r.channel?.send_status;
96
- console.log(`${r.number}: ${status === "ok" ? "Oalo can send on it." : `Oalo can't send on it yet (${status || "unknown"}).`}`);
97
96
  const d = r.diagnosis || {};
97
+ // A blocker Meta reports (a blocked account, a payment method) means it
98
+ // can't send, whatever our last send status says. Each finding once.
99
+ const seen = new Set();
100
+ const findings = (d.findings || []).filter((f) => f.level !== "ok" && !seen.has(f.text) && seen.add(f.text));
101
+ const blocked = findings.some((f) => f.level === "blocker");
102
+ const can = status === "ok" && !blocked;
103
+ console.log(`${r.number}: ${can ? "Oalo can send on it." : `Oalo can't send on it yet (${status && status !== "ok" ? status : blocked ? "see below" : "unknown"}).`}`);
98
104
  if (d.error) console.log(dim(` ${d.error}`));
99
- for (const f of d.findings || []) {
100
- if (f.level === "ok") continue;
101
- console.log(` ${f.level === "blocker" ? "!" : "-"} ${f.text}${f.side === "meta" ? dim(" (on Meta's side)") : ""}`);
105
+ for (const f of findings) {
106
+ console.log(` ${f.level === "blocker" ? "!" : "-"} ${String(f.text).replace(/\.\.+/g, ".")}${f.side === "meta" ? dim(" (on Meta's side)") : ""}`);
102
107
  }
103
- if (status && status !== "ok") process.exitCode = 1;
108
+ if (!can) process.exitCode = 1;
104
109
  }
105
110
  }
106
111
 
@@ -0,0 +1,103 @@
1
+ /**
2
+ * `oalo coord` from the npm package. Coord itself is a Bun-compiled binary
3
+ * (it needs bun:sqlite); `oalo coord install` downloads the build for this
4
+ * machine, checks it against the SHA-256 shipped in this package, and every
5
+ * other `oalo coord ...` runs it.
6
+ */
7
+ import { spawn, spawnSync } from "node:child_process";
8
+ import { createHash } from "node:crypto";
9
+ import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
10
+ import { homedir } from "node:os";
11
+ import { join } from "node:path";
12
+ import { gunzipSync } from "node:zlib";
13
+
14
+ /** Where the builds are published; OALO_COORD_DOWNLOAD_URL overrides it. */
15
+ const DOWNLOAD_BASE = "https://oalo.ai/dl/coord";
16
+ /** Exit code when the binary isn't installed; `oalo help coord --json` lists it. */
17
+ export const NOT_INSTALLED = 4;
18
+
19
+ function release() {
20
+ try {
21
+ return JSON.parse(readFileSync(new URL("../coord-release.json", import.meta.url), "utf8"));
22
+ } catch {
23
+ return null;
24
+ }
25
+ }
26
+
27
+ function platform() {
28
+ const os = { darwin: "darwin", linux: "linux" }[process.platform];
29
+ const arch = { arm64: "arm64", x64: "x64" }[process.arch];
30
+ return os && arch ? `${os}-${arch}` : null;
31
+ }
32
+
33
+ export function coordBinary(version) {
34
+ return join(process.env.OALO_HOME || homedir(), ".oalo", "bin", `oalo-coord-${version}`);
35
+ }
36
+
37
+ export async function coordInstall(flags) {
38
+ const rel = release();
39
+ const target = platform();
40
+ const say = (obj, text) => (flags.json ? console.log(JSON.stringify(obj)) : console.log(text));
41
+ if (!rel) {
42
+ console.error("oalo coord install: this oalo has no coord build listed; upgrade with `npm install -g @oalo-ai/cli`");
43
+ process.exit(1);
44
+ }
45
+ const entry = target && rel.targets[target];
46
+ if (!entry) {
47
+ console.error(`oalo coord install: no build for ${process.platform}-${process.arch} (macOS and Linux, arm64 and x64, are supported)`);
48
+ process.exit(1);
49
+ }
50
+ const bin = coordBinary(rel.version);
51
+ if (existsSync(bin) && !flags.force) {
52
+ return say({ installed: true, version: rel.version, path: bin, already: true }, `oalo coord ${rel.version} is already installed (${bin})`);
53
+ }
54
+
55
+ const url = `${process.env.OALO_COORD_DOWNLOAD_URL || DOWNLOAD_BASE}/${rel.version}/${entry.file}`;
56
+ if (!flags.json) console.error(`downloading ${url} (${(entry.bytes / 1e6).toFixed(0)} MB)`);
57
+ let res;
58
+ try {
59
+ res = await fetch(url);
60
+ } catch (err) {
61
+ console.error(`oalo coord install: download failed: ${err.message}`);
62
+ process.exit(1);
63
+ }
64
+ if (!res.ok) {
65
+ console.error(`oalo coord install: download failed: HTTP ${res.status} for ${url}`);
66
+ process.exit(1);
67
+ }
68
+ const gz = Buffer.from(await res.arrayBuffer());
69
+ const sha = createHash("sha256").update(gz).digest("hex");
70
+ if (sha !== entry.sha256) {
71
+ console.error(`oalo coord install: the download doesn't match this package's checksum (got ${sha}, want ${entry.sha256}); nothing was installed`);
72
+ process.exit(1);
73
+ }
74
+
75
+ mkdirSync(join(bin, ".."), { recursive: true });
76
+ const tmp = `${bin}.part`;
77
+ writeFileSync(tmp, gunzipSync(gz));
78
+ chmodSync(tmp, 0o755);
79
+ // Apple Silicon runs only signed code; Bun signs its builds ad hoc, and this
80
+ // re-applies that in case a build came from elsewhere.
81
+ if (process.platform === "darwin") spawnSync("codesign", ["--force", "--sign", "-", tmp], { stdio: "ignore" });
82
+ const check = spawnSync(tmp, ["--version"], { encoding: "utf8" });
83
+ if (check.status !== 0 || check.stdout.trim() !== rel.version) {
84
+ rmSync(tmp, { force: true });
85
+ console.error(`oalo coord install: the downloaded build didn't start (${(check.stderr || check.error?.message || "").trim()}); nothing was installed`);
86
+ process.exit(1);
87
+ }
88
+ renameSync(tmp, bin);
89
+ say({ installed: true, version: rel.version, path: bin }, `installed oalo coord ${rel.version} (${bin})\nNext, in your project: oalo coord init`);
90
+ }
91
+
92
+ /** Run an installed coord with these arguments; exits with its exit code. */
93
+ export function coordRun(argv) {
94
+ const rel = release();
95
+ const bin = rel && coordBinary(rel.version);
96
+ if (!bin || !existsSync(bin)) {
97
+ console.error("oalo coord isn't installed on this machine yet. Run `oalo coord install` (a one-time download, 25 to 37 MB), then try again.");
98
+ process.exit(NOT_INSTALLED);
99
+ }
100
+ const child = spawn(bin, argv, { stdio: "inherit" });
101
+ for (const sig of ["SIGINT", "SIGTERM", "SIGHUP"]) process.on(sig, () => child.kill(sig));
102
+ child.on("exit", (code, signal) => process.exit(code ?? (signal ? 1 : 0)));
103
+ }
@@ -1,7 +1,7 @@
1
1
  import { readFileSync } from "node:fs";
2
2
  import { basename } from "node:path";
3
3
  import { OaloChannel } from "../channel.js";
4
- import { resolve as resolveConfig, controlPlane, HOW_TO_CONNECT } from "../config.js";
4
+ import { resolve as resolveConfig, controlPlane, readToken, HOW_TO_CONNECT } from "../config.js";
5
5
  import { requireFeature } from "../server.js";
6
6
  import { ApiError } from "../api.js";
7
7
  import { dim } from "../events.js";
@@ -236,6 +236,13 @@ async function keepFromAi(flags, rest, cfg, opts) {
236
236
 
237
237
  /** The read side: the saved sync token, on the chosen schema. */
238
238
  function readCfg(flags, cfg) {
239
+ // A folder linked with `oalo link` carries its own token; otherwise use the
240
+ // data token `oalo login` saved for the workspace, as whoami does.
241
+ if (!cfg.serverUrl || !cfg.token) {
242
+ const { url } = controlPlane(cfg);
243
+ const saved = url && readToken({ serverUrl: url, appId: cfg.appId }, "sync");
244
+ if (saved) cfg = { ...cfg, serverUrl: url, token: saved };
245
+ }
239
246
  if (!cfg.serverUrl || !cfg.token) {
240
247
  // Exit 2, as the help says for "no token" (audit C2).
241
248
  throw Object.assign(new Error(`no workspace or data token for this project.\n\n${HOW_TO_CONNECT}`), { exitCode: 2 });
@@ -327,7 +334,8 @@ async function list(flags, rest, cfg) {
327
334
  out(flags, page, () => {
328
335
  for (const row of page.rows || []) console.log(JSON.stringify({ id: row.id, ...row.document }));
329
336
  console.error(dim(`${(page.rows || []).length} rows from ${table} in ${c.serverUrl} (${c.env})` +
330
- (page.has_more ? `; more with --since ${page.next_since}` : "")));
337
+ // --since pages forward; newest-first (`--order -seqnum`) can't continue that way.
338
+ (page.has_more ? (String(flags.order || "").startsWith("-") ? "; more with a bigger --limit" : `; more with --since ${page.next_since}`) : "")));
331
339
  });
332
340
  }
333
341
 
@@ -383,12 +391,12 @@ async function push(flags, rest, cfg) {
383
391
  const read = readCfg({ ...flags, env }, cfg);
384
392
  const manifest = await listModels(read);
385
393
  if (!manifest.models?.[table]) {
386
- throw new Error(`there is no model named ${table} in ${cfg.serverUrl}. Create it first: oalo data models create ${table} --field name:type ...`);
394
+ throw new Error(`there is no model named ${table} in ${read.serverUrl}. Create it first: oalo data models create ${table} --field name:type ...`);
387
395
  }
388
396
 
389
397
  if (flags["dry-run"]) {
390
398
  out(flags, { table, env, rows: todo.length, skipped: missing.length, first: todo[0] ?? null }, () => {
391
- console.log(`${todo.length} rows would be upserted into ${table} in ${cfg.serverUrl} (${env}), by ${idField}.`);
399
+ console.log(`${todo.length} rows would be upserted into ${table} in ${read.serverUrl} (${env}), by ${idField}.`);
392
400
  if (todo[0]) console.log(dim(`first: ${JSON.stringify(todo[0])}`));
393
401
  console.log(dim("dry run: nothing was written"));
394
402
  });
@@ -3,7 +3,7 @@ import { mkdtempSync, rmSync, statSync, createReadStream, writeFileSync } from "
3
3
  import { tmpdir } from "node:os";
4
4
  import { join } from "node:path";
5
5
  import { Readable } from "node:stream";
6
- import { resolve as resolveConfig, controlPlane, HOW_TO_CONNECT, readConfig, writeConfig } from "../config.js";
6
+ import { resolve as resolveConfig, controlPlane, HOW_TO_CONNECT, readConfig, writeConfig, ensureGitignored } from "../config.js";
7
7
  import { requireFeature } from "../server.js";
8
8
  import { targetEnv } from "../data.js";
9
9
  import { dim } from "../events.js";
@@ -126,6 +126,8 @@ export async function deploy(flags) {
126
126
  // A new app: this project now deploys to it (as `oalo link --app` saves).
127
127
  if (result.created) {
128
128
  writeConfig({ ...(readConfig(root) || {}), serverUrl: url, appId: result.app, env: "dev" }, root);
129
+ // As `oalo link` does: the link file stays out of the repo's commits.
130
+ ensureGitignored(root);
129
131
  if (result.app_type === "code_only") {
130
132
  // The server's progress line already said what to add.
131
133
  console.log(`created ${result.app} from ${result.commit.slice(0, 8)}, its history kept. Nothing runs yet (see above).`);
@@ -133,6 +135,7 @@ export async function deploy(flags) {
133
135
  } else {
134
136
  console.log(`created ${result.app} (${result.app_type}) from ${result.commit.slice(0, 8)}, its history kept: ${result.url}`);
135
137
  console.log(dim("Its preview is being set up (`oalo logs` shows it). Next deploys: `oalo deploy`; live: `oalo deploy --env prod`."));
138
+ storeBuildHint(result.app_type, result.app);
136
139
  }
137
140
  }
138
141
 
@@ -164,6 +167,12 @@ export async function deploy(flags) {
164
167
  }
165
168
  if (result.install === "failed") console.log(dim("The install failed, so the preview may be missing packages (see above)."));
166
169
  if (env === "dev") console.log(dim(`When the preview looks right: oalo deploy --app ${app} --env prod`));
170
+ storeBuildHint(result.app_type, app);
171
+ }
172
+
173
+ /** A deploy updates a mobile app's web preview; the store files come from `oalo build`. */
174
+ function storeBuildHint(type, app) {
175
+ if (type === "flutter" || type === "expo") console.log(dim(`For the App Store and Google Play (.ipa and .aab): oalo build --app ${app} --download`));
167
176
  }
168
177
 
169
178
  /**
@@ -319,7 +328,13 @@ async function pull(url, token, app, root) {
319
328
  const dir = mkdtempSync(join(tmpdir(), "oalo-pull-"));
320
329
  try {
321
330
  const file = join(dir, "app.bundle");
322
- writeFileSync(file, Buffer.from(await res.arrayBuffer()));
331
+ let bytes;
332
+ try {
333
+ bytes = Buffer.from(await res.arrayBuffer());
334
+ } catch (e) {
335
+ return fail(`could not fetch ${app}: the download stopped part way (${e.message}). Try again.`, 1);
336
+ }
337
+ writeFileSync(file, bytes);
323
338
  const ref = `refs/remotes/oalo/${app}`;
324
339
  git(["fetch", "--quiet", "--no-tags", file, `+HEAD:${ref}`], root);
325
340
  const sha = git(["rev-parse", ref], root);
@@ -137,14 +137,14 @@ async function status(flags) {
137
137
  try {
138
138
  const m = await fetchManifest(cfg);
139
139
  const models = Object.keys(m?.models || {}).length;
140
- console.log(`reachable yes — schema version ${m?.schema_version}, ${models} models`);
140
+ console.log(`reachable yes, schema version ${m?.schema_version}, ${models} models`);
141
141
  if (cfg.schemaVersion != null && m?.schema_version !== cfg.schemaVersion) {
142
142
  console.log(
143
143
  `\nschema moved since link (${cfg.schemaVersion} -> ${m.schema_version}). re-run oalo typegen.`,
144
144
  );
145
145
  }
146
146
  } catch (e) {
147
- console.log(`reachable NO — ${e.message}`);
147
+ console.log(`reachable NO: ${e.message}`);
148
148
  process.exitCode = 1;
149
149
  }
150
150
  }
@@ -67,6 +67,9 @@ export function queryFromFlags(what, flags) {
67
67
  if (!Number.isInteger(d) || d < 1) throw new Error("--days is a whole number of days");
68
68
  q.days = d;
69
69
  }
70
+ // A chart over time needs a window; with none, all of time is refused for a
71
+ // daily chart (over 366 days). Default to a window that fits each step.
72
+ if (q.every && q.days === undefined) q.days = { day: 30, week: 182, month: 366 }[q.every];
70
73
  if (typeof flags.time === "string") q.time = flags.time;
71
74
  if (flags.compare) q.compare = true;
72
75
  if (flags.env === "dev" || flags.env === "prod") q.env = flags.env;
@@ -135,7 +138,7 @@ const DASHBOARDS_USAGE = [
135
138
 
136
139
  function printResult(r) {
137
140
  if (r.steps) {
138
- for (const s of r.steps) console.log(`${s.step} ${s.contacts}${s.rate != null ? dim(` ${Math.round(s.rate * 100)}%`) : ""}`);
141
+ for (const s of r.steps) console.log(`${s.step} ${s.contacts}${s.rate != null ? dim(` ${Math.round(s.rate)}%`) : ""}`);
139
142
  return;
140
143
  }
141
144
  const fmt = (v) => (Number.isInteger(v) ? String(v) : v.toFixed(2));
@@ -48,6 +48,8 @@ export async function migrate(flags, rest, opts = {}) {
48
48
  let plan;
49
49
  try {
50
50
  plan = buildPlan(platform, { files, remote, envFile, fromApp });
51
+ // The same command again, with what it was given, for the "run it again" steps.
52
+ plan.rerun = `oalo migrate ${platform}${fromApp ? ` --from-app ${fromApp}` : ""}${typeof flags["env-file"] === "string" ? ` --env-file ${flags["env-file"]}` : ""}`;
51
53
  } catch (e) {
52
54
  return fail(e.message, 1);
53
55
  }
@@ -112,7 +114,7 @@ export async function migrate(flags, rest, opts = {}) {
112
114
  console.log(`set ${varsResult.saved} variable${varsResult.saved === 1 ? "" : "s"} on ${varsResult.app} (prod)`);
113
115
  if (varsResult.relaunch) console.log(dim("the live app gets them at its next release"));
114
116
  } else if (varsResult?.skipped) {
115
- console.log(`variables not set yet: this folder isn't linked to an Oalo app. After \`oalo deploy --new\`, run \`oalo migrate ${platform} --apply\` again${fromApp ? ` --from-app ${fromApp}` : ""}${flags["env-file"] ? ` --env-file ${flags["env-file"]}` : ""}.`);
117
+ console.log(`variables not set yet: this folder isn't linked to an Oalo app. After \`oalo deploy --new\`, run \`${plan.rerun} --apply\` again.`);
116
118
  }
117
119
  printNeeds(plan);
118
120
  printNext(plan, app, platform, true);
@@ -285,12 +287,16 @@ function printNeeds(plan) {
285
287
  function printNext(plan, app, platform, applied) {
286
288
  console.log("\nNext");
287
289
  const steps = [];
288
- const files = plan.procfile.action === "write" || plan.manifest.action === "write" || plan.manifest.action === "merge";
290
+ const files = [
291
+ ...(plan.procfile.action === "write" ? ["Procfile"] : []),
292
+ ...(["write", "merge"].includes(plan.manifest.action) ? [".oalo/app.json"] : []),
293
+ ];
289
294
  const later = !app && plan.vars.set.length;
290
- if (!applied) steps.push(`oalo migrate ${platform} --apply${later ? " (writes the files; the variables wait until the app exists)" : ""}`);
291
- if (files) steps.push('git add Procfile .oalo/app.json && git commit -m "Move to Oalo"');
295
+ const rerun = plan.rerun || `oalo migrate ${platform}`;
296
+ if (!applied) steps.push(`${rerun} --apply${later ? " (writes the files; the variables wait until the app exists)" : ""}`);
297
+ if (files.length) steps.push(`git add ${files.join(" ")} && git commit -m "Move to Oalo"`);
292
298
  if (!app) steps.push("oalo deploy --new");
293
- if (later) steps.push(`oalo migrate ${platform} --apply (now it sets the variables)`);
299
+ if (later) steps.push(`${rerun} --apply (now it sets the variables)`);
294
300
  if (plan.vars.missing.length) steps.push("oalo env set NAME --secret --env prod (for each one still needed)");
295
301
  steps.push("oalo env set NAME --env dev (test values for the preview)");
296
302
  steps.push("your data: keep the database and set EXTERNAL_DATABASE_URL, or copy it in with oalo db restore");
@@ -22,7 +22,8 @@ export async function secrets(flags, rest, opts = {}) {
22
22
 
23
23
  const app = typeof flags.app === "string" ? flags.app : cfg.appId;
24
24
  if (!app) return fail("which app? Pass --app <slug> (`oalo apps` lists them), or save it with `oalo link --app <slug>`.", 2);
25
- const [action, fingerprint] = rest;
25
+ // rest[0] is the command itself (`secrets`), as for every command.
26
+ const [, action, fingerprint] = rest;
26
27
  if (action && action !== "dismiss") return fail(`unknown: oalo secrets ${action}. Try \`oalo secrets\` or \`oalo secrets dismiss <fingerprint>\`.`, 2);
27
28
  if (action === "dismiss" && !fingerprint) return fail("oalo secrets dismiss needs the finding's fingerprint (from `oalo secrets`).", 2);
28
29
 
@@ -16,6 +16,7 @@ import { dim } from "../events.js";
16
16
  * oalo sources create <name> --table <model or table> [--fields a,b] [--keep-from-ai a,b] [--retention days] ...
17
17
  * oalo sources show <name> its address, fields and recent arrivals
18
18
  * oalo sources create <name> --bot <bot> documents into a bot's knowledge
19
+ * oalo sources create <name> --from-postgres <url> --relation <schema.view> [--key c] [--cursor c] [--every m] [--now]
19
20
  * oalo sources push <name> <file.csv|.json|.jsonl>
20
21
  * oalo sources push <name> <doc.pdf> [more...] into a knowledge source
21
22
  * oalo sources remove <name> <document> a knowledge source's document
@@ -86,6 +87,7 @@ const USAGE = [
86
87
  " oalo sources show <name> | rotate <name> | delete <name> [--wipe]",
87
88
  " oalo sources fields <name> a,b | retention <name> <days|off>",
88
89
  " oalo sources create <name> --bot <bot> [--auth ...] documents into the bot's knowledge",
90
+ " oalo sources create <name> --from-postgres <postgres url> --relation <schema.view> [--key <column>] [--cursor <column>] [--every <minutes>] [--now]",
89
91
  " oalo sources push <name> <file.csv|.json|.jsonl> or, for --bot, <doc.pdf|.docx|.md|.html|.txt> ...",
90
92
  " oalo sources remove <name> <document>",
91
93
  " oalo sources fetch <name> <https url> [--every <minutes>] [--header \"Name: value\"] [--records-at <a.b>] [--document <name>]",
@@ -119,6 +121,34 @@ async function create(ch, name, flags) {
119
121
  if (flags["keep-from-ai"]) params.keep_from_ai = list_(flags["keep-from-ai"]);
120
122
  if (flags.retention) params.retention_days = flags.retention;
121
123
 
124
+ // A view in an outside Postgres: the Base reads its columns, makes the
125
+ // model and sets the fetch in one step (AppBuilder.Sources.create_from_pg).
126
+ if (flags["from-postgres"] !== undefined) {
127
+ if (typeof flags["from-postgres"] !== "string" || !/^postgres(ql)?:\/\//.test(flags["from-postgres"]))
128
+ return fail("--from-postgres takes a postgres:// address (put it in a variable: --from-postgres \"$DB_URL\")", 2);
129
+ for (const f of ["relation", "key", "cursor", "every"]) if (flags[f] === true) return fail(`--${f} needs a value`, 2);
130
+ if (!flags.relation) return fail("--from-postgres needs the view to read: --relation schema.view", 2);
131
+ if (flags.from) return fail("use --from or --from-postgres, not both", 2);
132
+ params.from_postgres = flags["from-postgres"];
133
+ for (const f of ["relation", "key", "cursor", "every"]) if (flags[f]) params[f] = flags[f];
134
+ const s = await ch.call("sources:create", params, 60000);
135
+ if (flags.json && !flags.now) return void console.log(JSON.stringify(s, null, 2));
136
+ const f = s.fetch || {};
137
+ console.log(`made source ${s.name} -> ${s.table} (${s.env}), a new model`);
138
+ console.log(` fields ${Object.entries(s.fields).map(([k, t]) => `${k}:${t}`).join(", ")}`);
139
+ if (s.keep_from_ai?.length) console.log(` kept from AI ${s.keep_from_ai.join(", ")}`);
140
+ console.log(` id ${s.id_field}${s.mode === "snapshot" ? ", snapshot (each run is the whole view; rows it drops are deleted)" : ""}`);
141
+ console.log(` reads ${f.relation} from ${f.url} every ${f.every_minutes} minutes${f.cursor ? `, only rows past the last ${f.cursor} seen` : ""}`);
142
+ if (flags.now) {
143
+ const r = await ch.call("sources:fetch_now", { name: s.name }, 120000);
144
+ if (flags.json) return void console.log(JSON.stringify({ ...s, run: r }, null, 2));
145
+ console.log(` first run ${r.records ?? 0} rows read${r.upserted !== undefined ? `, ${r.upserted} saved` : ""}${r.deleted ? `, ${r.deleted} deleted` : ""}`);
146
+ } else {
147
+ console.log(dim(`The first read is within a minute. \`oalo sources fetch ${s.name} --now\` reads at once.`));
148
+ }
149
+ return;
150
+ }
151
+
122
152
  if (typeof flags.from === "string") {
123
153
  const text = readFileSync(flags.from, "utf8");
124
154
  // A sample is enough to read the fields and their types.
@@ -1,6 +1,6 @@
1
1
  import { readFileSync, writeFileSync, mkdirSync, existsSync } from "node:fs";
2
2
  import { dirname, join } from "node:path";
3
- import { resolve as resolveConfig, HOW_TO_CONNECT } from "../config.js";
3
+ import { resolve as resolveConfig, controlPlane, readToken, HOW_TO_CONNECT } from "../config.js";
4
4
  import { fetchManifest, fetchWorkflows, syncGet } from "../api.js";
5
5
 
6
6
  const DEFAULT_OUT = "oalo.generated.ts";
@@ -59,7 +59,7 @@ function renderModel(table, model) {
59
59
  const fields = model.fields || [];
60
60
  const lines = [];
61
61
 
62
- lines.push(`/** \`${table}\` — primary key \`${model.primary_key || "id"}\`${
62
+ lines.push(`/** \`${table}\`: primary key \`${model.primary_key || "id"}\`${
63
63
  model.shared ? ", shared" : ""
64
64
  }${model.owner_field ? `, owned via \`${model.owner_field}\`` : ""} */`);
65
65
  lines.push(`export interface ${docTypeName(table)} {`);
@@ -394,7 +394,13 @@ function render(manifest, cfg, workflows = []) {
394
394
  export { render as renderTypes };
395
395
 
396
396
  export async function typegen(flags) {
397
- const cfg = resolveConfig(flags);
397
+ let cfg = resolveConfig(flags);
398
+ // Without a linked folder, the data token `oalo login` saved (as in data.js).
399
+ if (!cfg.serverUrl || !cfg.token) {
400
+ const { url } = controlPlane(cfg);
401
+ const saved = url && readToken({ serverUrl: url, appId: cfg.appId }, "sync");
402
+ if (saved) cfg = { ...cfg, serverUrl: url, token: saved };
403
+ }
398
404
 
399
405
  if (!cfg.serverUrl || !cfg.token) {
400
406
  console.error(`no workspace or data token for this project.\n\n${HOW_TO_CONNECT}`);
package/src/config.js CHANGED
@@ -66,13 +66,12 @@ export const TOKEN_KINDS = ["sync", "cli"];
66
66
 
67
67
  export function readToken(config, kind = "sync") {
68
68
  const all = readJson(CRED_PATH, {});
69
- // `oalo login` saves per workspace (no app), so an app-specific link falls
70
- // back to the workspace's own entry.
71
- const entry = all[credKey(config)] || (config.appId ? all[credKey({ ...config, appId: null })] : null);
72
- if (!entry) return null;
73
69
  // Tolerate the earlier flat shape ({token, saved_at}) as a sync token.
74
- if (typeof entry.token === "string") return kind === "sync" ? entry.token : null;
75
- return entry[kind]?.token ?? null;
70
+ const pick = (entry) => (!entry ? null : typeof entry.token === "string" ? (kind === "sync" ? entry.token : null) : entry[kind]?.token ?? null);
71
+ // `oalo login` saves per workspace (no app), so an app-specific link falls
72
+ // back to the workspace's own entry, kind by kind: an app entry holding only
73
+ // a sync token must not hide the workspace's CLI token.
74
+ return pick(all[credKey(config)]) ?? (config.appId ? pick(all[credKey({ ...config, appId: null })]) : null);
76
75
  }
77
76
 
78
77
  export function writeToken(config, token, kind = "sync", extra = {}) {
@@ -140,7 +139,7 @@ export function ensureGitignored(cwd = process.cwd()) {
140
139
  const rule = ".oalo/credentials*";
141
140
  const current = existsSync(gi) ? readFileSync(gi, "utf8") : "";
142
141
  if (current.includes(rule)) return false;
143
- appendFileSync(gi, `${current.endsWith("\n") || !current ? "" : "\n"}\n# Oalo — never commit credentials\n${rule}\n`);
142
+ appendFileSync(gi, `${current.endsWith("\n") || !current ? "" : "\n"}\n# Oalo: never commit credentials\n${rule}\n`);
144
143
  return true;
145
144
  }
146
145
 
@@ -0,0 +1,25 @@
1
+ {
2
+ "version": "0.4.0",
3
+ "targets": {
4
+ "darwin-arm64": {
5
+ "file": "oalo-coord-darwin-arm64.gz",
6
+ "sha256": "da9c1663ffc673924b77fed8ad61b09c16ec61e2f738228e059b5b8fa38cdd29",
7
+ "bytes": 24851871
8
+ },
9
+ "darwin-x64": {
10
+ "file": "oalo-coord-darwin-x64.gz",
11
+ "sha256": "8e3d36775180843d7e333f54321ed0310f7af126b8a2954b8bbf6afd06a09f32",
12
+ "bytes": 26990220
13
+ },
14
+ "linux-x64": {
15
+ "file": "oalo-coord-linux-x64.gz",
16
+ "sha256": "222745d2249b43a0db546bddfcb0118d53cf4040a5e748f76c69834152ac3b05",
17
+ "bytes": 36882875
18
+ },
19
+ "linux-arm64": {
20
+ "file": "oalo-coord-linux-arm64.gz",
21
+ "sha256": "43b5c16359d9a864248798162e78f214ccfea0c5639ce479ab83d8be0c3b4803",
22
+ "bytes": 37123621
23
+ }
24
+ }
25
+ }
package/src/help.js CHANGED
@@ -409,6 +409,34 @@ export const COMMANDS = [
409
409
  ],
410
410
  exits: { 0: "done", 1: "refused, or (status) the last setup failed", 2: "bad arguments or no CLI token" },
411
411
  },
412
+ {
413
+ name: "build",
414
+ summary: "A store build of a Flutter or Expo app: the .ipa for App Store Connect and the .aab for Google Play, with download links.",
415
+ usage: [
416
+ "oalo build [--app <slug>] [--wait] [--download] [--json]",
417
+ "oalo build status [--app <slug>] [--build <id>] [--wait] [--download] [--json]",
418
+ "oalo build list [--app <slug>] [--json]",
419
+ "oalo build upload <file> --target <name> [--app <slug>] [--build <id>]",
420
+ ],
421
+ flags: [
422
+ { flag: "--app <slug>", desc: "The app. Default: the one saved with `oalo link --app`." },
423
+ { flag: "--wait", desc: "Follow the build until it's done (15 to 60 minutes), then print the links." },
424
+ { flag: "--download", desc: "Save the .ipa and .aab in this folder when the build is done (implies --wait). An existing file is left as it is." },
425
+ { flag: "--build <id>", desc: "status, upload: that build instead of the latest one (`oalo build list` shows the ids)." },
426
+ { flag: "--target <name>", desc: "upload: the platform the file is for, one the app's .oalo/app.json lists under targets.external (garmin, macos)." },
427
+ { flag: "--json", desc: "The reply as JSON." },
428
+ ],
429
+ notes: [
430
+ "One build makes the file of each platform whose signing is set up (the app's Native Build tab says what's missing). Flutter apps build on Codemagic, Expo apps on EAS with your own Expo token (set it in Integrations, on the Expo tab). The version code goes up by one each build.",
431
+ "A build uses the app's code on Oalo, not this folder: `oalo deploy` your commits first.",
432
+ "Extra targets are built only when the app's .oalo/app.json declares them. A watch app: add `\"targets\": {\"watchos\": {\"scheme\": \"<its Xcode scheme>\"}}`, deploy, then set up its signing in the app's Native Build tab (\"Set up the watch app's signing\"); it ships inside the .ipa. A Wear OS app: `\"wearos\": {\"module\": \"wear\"}` (its Gradle module in android/), built as its own -wear.aab for Play's Wear OS track. Platforms built elsewhere: `\"external\": [\"garmin\"]`, then `oalo build upload <file> --target garmin` keeps the file with a build.",
433
+ "The files are private on your Base. Their links last an hour; `oalo build status` gives fresh ones. The app's Native Build tab in the dashboard has the same downloads.",
434
+ "Nothing is sent to the stores. Upload the .ipa with Transporter (or `xcrun altool --upload-app`), and the .aab in Google Play Console under a release.",
435
+ "`oalo deploy` updates the app's web preview; it doesn't make a store build.",
436
+ "One build of an app at a time. Admins and members with Developer access only.",
437
+ ],
438
+ exits: { 0: "started, or (status, --wait) built", 1: "refused, the build failed, or a download failed", 2: "bad arguments or no CLI token" },
439
+ },
412
440
  {
413
441
  name: "sources",
414
442
  summary: "Feeds that send Oalo rows from outside (another system, a webhook, an export), keeping only the fields you choose.",
@@ -419,6 +447,7 @@ export const COMMANDS = [
419
447
  " (either form) [--keep-from-ai a,b] [--retention <days>]",
420
448
  "oalo sources show <name> [--json]",
421
449
  "oalo sources create <name> --bot <bot> [--auth bearer|hmac|url]",
450
+ "oalo sources create <name> --from-postgres <postgres url> --relation <schema.view> [--key <column>] [--cursor <column>] [--every <minutes>] [--table <new model>] [--now]",
422
451
  "oalo sources push <name> <file.csv|.json|.jsonl> [--json]",
423
452
  "oalo sources push <name> <doc.pdf|.docx|.md|.html|.txt> [more...] [--json]",
424
453
  "oalo sources remove <name> <document>",
@@ -431,6 +460,7 @@ export const COMMANDS = [
431
460
  "oalo sources delete <name> [--wipe]",
432
461
  ],
433
462
  flags: [
463
+ { flag: "--from-postgres <url>", desc: "create: a view (or table) in your own Postgres, in one step. The Base reads its columns and makes the model from them, then reads the view on a schedule (--every, default 60 minutes; --cursor <column> for only new or changed rows, else the whole view each time as a snapshot). Put the address in a variable: --from-postgres \"$DB_URL\". See `oalo docs data-sources`." },
434
464
  { flag: "--from <file>", desc: "create: a sample of what the sender sends. Its fields and their types make the source's fields and a new model (--table, default the source's name)." },
435
465
  { flag: "--bot <bot>", desc: "create: send documents into this bot's knowledge (its public id, from oalo bots) instead of rows into a table. Each upload is one document by name; the same name replaces it." },
436
466
  { flag: "--table <model>", desc: "create: the model or plain table the rows go to (a table the app made with its own SQL, or an import kept as it is). An existing one keeps all its fields or columns, or the ones in --fields. A plain table's --id-field must be a unique column." },
@@ -858,40 +888,56 @@ export const COMMANDS = [
858
888
  },
859
889
  {
860
890
  name: "coord",
861
- // Not in the npm package yet: it needs Bun (bun:sqlite, TypeScript), so
862
- // it's left out of help, the man page and help --json until it ships as a
863
- // binary. `bun src/index.js coord` still runs it in development.
864
- hidden: true,
865
- summary: "Coordinate several agents on one codebase: task board, worktrees, merge queue.",
891
+ summary: "Several agents on one codebase: a shared task board, a worktree per task, a merge queue. First run: `oalo coord install`.",
866
892
  usage: [
893
+ "oalo coord install [--force] [--json]",
867
894
  "oalo coord init [--main <branch>] [--test-cmd <cmd>] [--merge auto|manual] [--signal-review]",
895
+ "oalo coord hooks install [--claude] [--opencode]",
868
896
  "oalo coord mcp",
869
897
  "oalo coord board [--json]",
870
898
  "oalo coord events [--follow] [--since <id>] [--json]",
899
+ "oalo coord files [--json] [--main <branch>]",
900
+ "oalo coord view [--port <n>] [--main <branch>] [--no-open]",
871
901
  "oalo coord claim <task>",
872
902
  "oalo coord merge [--all]",
873
- "oalo coord approve plan | merge <task> | signal <task> <milestone> | proposal <id>",
874
- "oalo coord reject proposal <id>",
875
- "oalo coord hooks install [--claude] [--opencode]",
876
- "oalo coord hook <pre-tool|stop|subagent-stop|check-write|check-stop>",
903
+ "oalo coord approve plan [--yes] | merge <task> | signal <task> <milestone> | proposal <id> [--note <text>]",
904
+ "oalo coord reject proposal <id> [--note <text>]",
905
+ "oalo coord hook <pre-tool|stop|subagent-stop|check-write|check-stop|check-command>",
877
906
  ],
878
907
  flags: [
908
+ { flag: "--force", desc: "install: download again even if this version is installed." },
879
909
  { flag: "--main <branch>", desc: "init: branch the merge queue integrates into. Default: current branch." },
880
910
  { flag: "--test-cmd <cmd>", desc: "init: merge-gate test command. Default: detected (mix test, npm test, ...)." },
881
911
  { flag: "--merge auto|manual", desc: "init: manual holds each merge for `approve merge`." },
882
912
  { flag: "--signal-review", desc: "init: milestones unblock dependents only after `approve signal`." },
883
- { flag: "--json", desc: "board/events: machine-readable output." },
913
+ { flag: "--yes", desc: "approve plan: skip the confirmation after the plan is shown." },
914
+ { flag: "--note <text>", desc: "approve/reject proposal: a note the worker sees with the decision." },
915
+ { flag: "--json", desc: "install/board/events/files: machine-readable output." },
884
916
  { flag: "--follow", desc: "events: keep streaming." },
885
917
  { flag: "--all", desc: "merge: keep merging until the queue is idle or blocked." },
886
918
  ],
887
919
  notes: [
888
- "Local only: the board is .oalo/coord.db in the project; no server, no account.",
889
- "Every agent session attaches `oalo coord mcp`. The manager plans tasks; workers claim them in their own git worktree.",
890
- "Human gates are CLI-only so no agent can approve its own work: approve plan, merge, signal, scope proposals.",
891
- "`hooks install` adds the guards: edits only inside your task's worktree and write set; no stopping while holding a claim; the manager waits for its inbox instead of polling.",
892
- "Requires the oalo binary (Bun runtime); the other commands also run under Node.",
920
+ "Coord lets several coding agent sessions (Claude Code, OpenCode, Codex, any MCP client) work on one git repo at once. It runs on your machine; the board is .oalo/coord.db in the repo. No Oalo workspace or sign-in is needed. Full guide: https://oalo.ai/docs/several-agents-one-repo (or `oalo docs several-agents-one-repo` when signed in).",
921
+ "Setup, once per machine: `oalo coord install` downloads coord for it (about 25 MB on macOS, 37 MB on Linux, checked against this package's checksum). Once per repo: `oalo coord init`, then `oalo coord hooks install`, then commit .oalo/coord.json, .gitignore, .claude/settings.json, .mcp.json, opencode.json and .opencode/. .claude/settings.local.json holds this machine's worktree folder and stays out of git.",
922
+ "Coord never starts agents. The person opens the sessions, or a manager starts workers as its harness's own subagents. Every session opened in the repo, or in a task's worktree, gets the board's tools through the `oalo-coord` MCP server that hooks install registers; the server finds the one board from any worktree. The board also gives each session a short orientation; the person tells it its role. Manager: \"You're the oalo coord manager for this repo. Call manager_guide, then plan: <goal>\". Worker: \"You're an oalo coord worker. Call task_next and follow the brief.\"",
923
+ "Manager: reads manager_guide (the full playbook), then drafts tasks with task_create (title, spec, acceptance criteria, writes: the globs it may change, provides: milestones it will signal, depends_on), then calls plan_submit. Nothing runs until the person approves. Then it handles the inbox (inbox, ack, answer, decide), reviews reports (task_detail, task_reopen) and merges (merge_next). Other tools: task_update, task_cancel, board, wait.",
924
+ "Worker: calls task_next, which returns a claim token, its own git worktree and a brief with the spec and how to finish. It works only inside that worktree and its write set, commits, calls signal as soon as a milestone others wait on is committed, and ends with task_done or task_fail and a report. Other tools: release (paths it is finished with), signal_amend, lease_acquire / lease_release (a port, the dev database, migrations), ask, propose_change, report_blocked, notify, wait. Every worker call passes its claim.",
925
+ "Messages need no polling: each worker reply carries its notices (answers, decisions, changed dependencies) and who is waiting on it. In Claude Code and OpenCode, a worker that stops while holding a task is sent back to finish it (up to three times) and gets answers to its questions. In Claude Code the manager's stop also waits for its inbox while tasks are running; in other harnesses the manager calls wait.",
926
+ "Only a person approves, in their own terminal: `approve plan` (shows the design, the tasks and their files, then asks to type yes; it covers only the drafts sent with plan_submit, unchanged since), `approve merge`, `approve signal`, `approve proposal`, `reject proposal`. They refuse from an agent's shell. An agent tells the person what is waiting and the command to run.",
927
+ "Scheduling: a task starts when every milestone it depends on is signalled and no running task's write set overlaps its own. A worker that signals a milestone mid-task lets its dependents start from that commit right away.",
928
+ "Merge queue (merge_next, `oalo coord merge`): one run at a time. A task merges with a merge commit after every task it builds on has merged, and only if the project's test command passes, then the task's own test_cmd if it has one. A conflict or failing test sends it back to a worker with the output. A branch that changes .oalo/coord.json, .oalo/setup or the hook and MCP config waits for `approve merge`.",
929
+ "Rework: task_reopen, a merge conflict or a failing merge test sends a task back, and they count together: first held for the same worker for claim_ttl_s, then any worker; the third time it stops as needs_human until the manager sets it back to ready. A worker silent for claim_ttl_s (15 minutes) loses its claim, the manager gets its commits in a report, and the next worker resumes the same worktree.",
930
+ "Settings in .oalo/coord.json (a person edits them): main_branch, test_cmd, merge (auto or manual), signal_review, claim_ttl_s, port_base, port_span. Task worktrees live in ~/.oalo/worktrees/<repo>-<hash>/<task> (OALO_HOME moves them). An executable .oalo/setup runs in each new worktree with OALO_TASK_ID, OALO_WORKTREE, OALO_PROJECT_ROOT, OALO_PORT_BASE, OALO_PORT_SPAN and OALO_DB_NAME set.",
931
+ "The hooks block edits outside a worker's worktree and write set, and edits to coord's own files. Shell writes (sed -i, redirects) aren't intercepted; the merge queue still catches their damage. Harnesses without hooks rely on the merge queue alone.",
932
+ "macOS and Linux only.",
893
933
  ],
894
- exits: { 0: "ok", 1: "operation refused or failed (message on stderr)", 2: "bad arguments", 3: "no board here; run `oalo coord init`" },
934
+ exits: {
935
+ 0: "ok",
936
+ 1: "operation refused or failed (message on stderr)",
937
+ 2: "bad arguments",
938
+ 3: "no board here; run `oalo coord init`",
939
+ 4: "coord isn't installed on this machine; run `oalo coord install`",
940
+ },
895
941
  },
896
942
  ];
897
943
 
package/src/index.js CHANGED
@@ -27,12 +27,15 @@ import { dockerfile } from "./commands/dockerfile.js";
27
27
  import { bots } from "./commands/bots.js";
28
28
  import { sources } from "./commands/sources.js";
29
29
  import { setup } from "./commands/setup.js";
30
+ import { build } from "./commands/build.js";
30
31
  import { incidents } from "./commands/incidents.js";
31
32
  import { channels } from "./commands/channels.js";
32
33
  import { products } from "./commands/products.js";
33
34
  import { metrics, dashboards } from "./commands/metrics.js";
34
35
  import { db } from "./commands/db.js";
35
36
  import { migrate } from "./commands/migrate.js";
37
+ import { coordInstall, coordRun } from "./commands/coord-bin.js";
38
+ import { existsSync } from "node:fs";
36
39
  import { overview, commandHelp, helpJson, COMMANDS } from "./help.js";
37
40
  import { parse } from "./args.js";
38
41
 
@@ -152,6 +155,9 @@ async function dispatch(cmd) {
152
155
  case "setup":
153
156
  await setup(flags, rest);
154
157
  break;
158
+ case "build":
159
+ await build(flags, rest);
160
+ break;
155
161
  case "incidents":
156
162
  await incidents(flags, rest);
157
163
  break;
@@ -207,13 +213,19 @@ async function dispatch(cmd) {
207
213
  await mcp(flags);
208
214
  break;
209
215
  case "coord": {
210
- // coord uses bun:sqlite and is TypeScript; the shipped binary is Bun-compiled.
211
- if (typeof Bun === "undefined") {
212
- console.error("oalo coord needs the oalo binary (Bun runtime). Run it with `bun src/index.js coord ...` in development.");
213
- process.exit(1);
216
+ // Coord needs bun:sqlite, so it ships as its own compiled binary that
217
+ // `oalo coord install` downloads. Under Bun with the sources present
218
+ // (development), it runs from source instead.
219
+ if (rest[1] === "install") {
220
+ await coordInstall(flags);
221
+ break;
222
+ }
223
+ if (typeof Bun !== "undefined" && existsSync(new URL("./commands/coord.ts", import.meta.url))) {
224
+ const { coord } = await import("./commands/coord.ts");
225
+ await coord(flags, rest);
226
+ break;
214
227
  }
215
- const { coord } = await import("./commands/coord.ts");
216
- await coord(flags, rest);
228
+ coordRun(process.argv.slice(process.argv.indexOf("coord")));
217
229
  break;
218
230
  }
219
231
  }
@@ -86,7 +86,7 @@ export function buildPlan(platform, input) {
86
86
  const procfile = procfilePlan(files, read.processes, read.release, warnings);
87
87
  const manifest = manifestPlan(files, procfile, read.sizes || {}, read.health, warnings);
88
88
  const varPlan = filterVars(def, vars, missing, warnings);
89
- commonChecks(files, warnings);
89
+ commonChecks(files, warnings, varPlan);
90
90
 
91
91
  return { platform, label: def.label, procfile, manifest, vars: varPlan, warnings: dedupe(warnings) };
92
92
  }
@@ -205,7 +205,7 @@ function fromRender(files, fromApp, warnings, missing, vars) {
205
205
  if (s.preDeployCommand) release = joinCommands(s.preDeployCommand);
206
206
  if (s.healthCheckPath) health = s.healthCheckPath;
207
207
  } else if (type === "worker" || type === "bworker") {
208
- proc = procName(name);
208
+ proc = uniqueProc(procName(name), processes);
209
209
  } else {
210
210
  warnings.push(`${name} has type ${type}, which oalo migrate doesn't map: add it to the Procfile by hand.`);
211
211
  continue;
@@ -252,11 +252,16 @@ function fromFly(files, warnings, vars, remote, missing) {
252
252
  if (!cfg) return { processes: null, release: null, sizes: {}, health: null };
253
253
 
254
254
  const http = cfg.http_service || null;
255
- const webGroup = (http?.processes && http.processes[0]) || "app";
255
+ // The group behind [http_service]: the one it names, else Fly's default
256
+ // `app`, else one named `web`, else the only group there is.
257
+ const groups = Object.keys(cfg.processes || {});
258
+ const webGroup =
259
+ (http?.processes && http.processes[0]) ||
260
+ (groups.includes("app") ? "app" : groups.includes("web") ? "web" : groups.length === 1 ? groups[0] : "app");
256
261
  const processes = [];
257
262
  const sizes = {};
258
263
  for (const [group, cmd] of Object.entries(cfg.processes || {})) {
259
- processes.push([group === webGroup ? "web" : procName(group), String(cmd)]);
264
+ processes.push([group === webGroup ? "web" : uniqueProc(procName(group), processes), String(cmd)]);
260
265
  }
261
266
  if (!Object.keys(cfg.processes || {}).length && !files.dockerfile && !files.procfile) {
262
267
  warnings.push("fly.toml names no [processes] and there's no Dockerfile or Procfile: add a Procfile with a `web:` line.");
@@ -447,10 +452,14 @@ function privateHost(value) {
447
452
 
448
453
  // ── checks every platform gets ────────────────────────────────────────
449
454
 
450
- function commonChecks(files, warnings) {
455
+ function commonChecks(files, warnings, varPlan) {
451
456
  if (files.packageJson && !files.lockfile && !files.dockerfile) {
452
457
  warnings.push("package.json has no lockfile committed next to it (package-lock.json, yarn.lock, pnpm-lock.yaml or bun.lock): the build needs one.");
453
458
  }
459
+ // Every variable is set as a secret, and a Dockerfile's build only sees public ones.
460
+ if (files.dockerfile && varPlan?.set?.length) {
461
+ warnings.push("The variables are set as secrets, which your app reads when it runs but a Dockerfile's build doesn't see. If the build needs one (an ARG), set it again with `oalo env set NAME=value --public --env prod`.");
462
+ }
454
463
  }
455
464
 
456
465
  // ── helpers ───────────────────────────────────────────────────────────
@@ -459,6 +468,13 @@ function joinCommands(c) {
459
468
  return Array.isArray(c) ? c.map(String).join(" && ") : String(c);
460
469
  }
461
470
 
471
+ /** `worker`, then `worker-2`, ...: two services can reduce to the same Procfile name. */
472
+ function uniqueProc(name, processes) {
473
+ const taken = new Set(processes.map(([n]) => n));
474
+ if (!taken.has(name)) return name;
475
+ for (let i = 2; ; i++) if (!taken.has(`${name}-${i}`)) return `${name}-${i}`;
476
+ }
477
+
462
478
  function procName(name) {
463
479
  const n = String(name).toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "");
464
480
  return n && PROC_RE.test(n) && n !== "web" && n !== "release" ? n : "worker";