Skip to content

Commit bcf3f7a

Browse files
moekatibclaude
andauthored
feat: local data sync + parallel actions execute (#98)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0240dd1 commit bcf3f7a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+6528
-79
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ node_modules/
22
dist/
33
.DS_Store
44
*.log
5-
.idea/
5+
.one
6+
.idea/

README.md

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,30 @@ one actions execute stripe <actionId> <connectionKey> \
246246
| `--form-data` | Send as multipart/form-data |
247247
| `--form-url-encoded` | Send as application/x-www-form-urlencoded |
248248
| `--dry-run` | Show the request without executing it |
249+
| `--mock` | Return example response without making an API call |
250+
| `--skip-validation` | Skip input validation against the action schema |
251+
252+
The CLI validates required parameters (path variables, query params, body fields) against the action schema before executing. Missing params return a clear error with the flag name and description. Pass `--skip-validation` to bypass.
253+
254+
#### Parallel execution
255+
256+
Execute multiple actions concurrently with `--parallel`, separating each action with `--`:
257+
258+
```bash
259+
one --agent actions execute --parallel \
260+
gmail send-email conn123 -d '{"to":"a@b.com","subject":"Hi","body":"Hello"}' \
261+
-- slack post-message conn456 -d '{"channel":"#general","text":"Done"}' \
262+
-- google-sheets append-row conn789 -d '{"values":["x","y"]}'
263+
```
264+
265+
Each segment follows the same format: `<platform> <actionId> <connectionKey> [-d ...] [--path-vars ...] [--query-params ...]`. All segments are validated upfront before any execution starts. Results are collected via `Promise.allSettled` — if one fails, the rest still complete.
266+
267+
| Option | What it does |
268+
|--------|-------------|
269+
| `--parallel` | Enable parallel mode |
270+
| `--max-concurrency <n>` | Max concurrent actions per batch (default: 5) |
271+
272+
Agent-mode output includes `parallel: true`, per-action `status`/`durationMs`/`response`, plus `totalDurationMs`, `succeeded`, and `failed` counts.
249273

250274
### `one cache`
251275

@@ -271,6 +295,48 @@ Default TTL is 1 hour. Configure via `ONE_CACHE_TTL` environment variable or `ca
271295

272296
Note: `actions execute` is never cached — it always hits the API fresh.
273297

298+
### `one sync`
299+
300+
Sync platform data into local SQLite for instant queries, full-text search, scheduled refresh, and change-driven automation. The sync engine (`better-sqlite3`) is an optional dependency — install it once per machine:
301+
302+
```bash
303+
one sync install && one sync doctor
304+
```
305+
306+
```bash
307+
# Discover → init (one command: infer + auto-resolve key + auto-test) → run
308+
one sync models stripe
309+
one sync init stripe balanceTransactions # connectionKey auto-resolved, test auto-run
310+
one sync run stripe --since 90d
311+
312+
# Query, search, SQL
313+
one sync query stripe/balanceTransactions --where "status=available" --limit 20
314+
one sync search "refund"
315+
one sync sql stripe "SELECT count(*) FROM balanceTransactions"
316+
317+
# Schedule unattended syncs + change hooks
318+
one sync schedule add stripe --every 1h
319+
one sync init stripe balanceTransactions --config '{"onInsert":"one flow execute handle-new-txn"}'
320+
321+
# Deletion detection
322+
one sync run stripe --full-refresh
323+
```
324+
325+
| Subcommand | What it does |
326+
|------------|-------------|
327+
| `install` / `doctor` | Install + verify the SQLite engine |
328+
| `models <platform>` | Discover available data models |
329+
| `init <platform> <model>` | Create profile (auto-infers all fields, auto-resolves key, auto-runs test) |
330+
| `test <platform>/<model>` | Validate + auto-fix profile from real API response (also runs inside init) |
331+
| `run <platform>` | Sync data (`--full-refresh`, `--since`, `--dry-run`) |
332+
| `query <platform>/<model>` | Query with `--where`, `--after/before`, `--refresh` |
333+
| `search <query>` | FTS5 across all synced data |
334+
| `sql <platform> <sql>` | Raw SELECT queries |
335+
| `schedule add/list/status/remove/repair` | Cron-backed scheduled syncs with drift detection |
336+
| `remove <platform>` | Delete local data (`--dry-run` to preview) |
337+
338+
Change hooks (`onInsert`, `onUpdate`, `onChange`) fire per-page during sync — pipe to a shell command, a flow, or an event log. Run `one guide sync` for the full reference.
339+
274340
### `one guide [topic]`
275341

276342
Get the full CLI usage guide, designed for AI agents that only have the binary (no MCP, no IDE skills).
@@ -285,7 +351,7 @@ one --agent guide # full guide as structured JSON
285351
one --agent guide flows # single topic as JSON
286352
```
287353

288-
Topics: `overview`, `actions`, `flows`, `relay`, `cache`, `all` (default).
354+
Topics: `overview`, `actions`, `flows`, `relay`, `cache`, `sync`, `all` (default).
289355

290356
In agent mode (`--agent`), the JSON response includes the guide content and an `availableTopics` array so agents can discover what sections exist.
291357

@@ -333,7 +399,8 @@ Press Ctrl+C during execution to pause - the run can be resumed later with `one
333399
|--------|-------------|
334400
| `-i, --input <name=value>` | Input parameter (repeatable) |
335401
| `--dry-run` | Validate and show execution plan without running |
336-
| `--mock` | With `--dry-run`: execute transforms/code with mock API responses |
402+
| `--mock` | With `--dry-run`: execute transforms/code with realistic mock API responses |
403+
| `--skip-validation` | Skip input validation against action schemas |
337404
| `--allow-bash` | Allow bash step execution (disabled by default for security) |
338405
| `-v, --verbose` | Show full request/response for each step |
339406

0 commit comments

Comments
 (0)