@zeyos/client 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +21 -4
  3. package/agents/README.md +16 -6
  4. package/agents/shared/zeyos-agent-operating-guide.md +112 -0
  5. package/agents/shared/zeyos-query-patterns.md +12 -1
  6. package/agents/zeyos/SKILL.md +95 -0
  7. package/agents/zeyos-account-intelligence/SKILL.md +1 -1
  8. package/agents/zeyos-account-intelligence/references/workflows.md +7 -0
  9. package/agents/zeyos-billing-insights/SKILL.md +6 -1
  10. package/agents/zeyos-billing-insights/references/workflows.md +32 -3
  11. package/agents/zeyos-campaign-and-outreach/SKILL.md +1 -1
  12. package/agents/zeyos-campaign-and-outreach/references/workflows.md +8 -0
  13. package/agents/zeyos-collaboration-and-activity/SKILL.md +1 -1
  14. package/agents/zeyos-collaboration-and-activity/references/workflows.md +9 -0
  15. package/agents/zeyos-collections-and-dunning/SKILL.md +1 -1
  16. package/agents/zeyos-commerce-and-inventory/SKILL.md +1 -1
  17. package/agents/zeyos-commerce-and-inventory/references/workflows.md +7 -0
  18. package/agents/zeyos-mail-operations/SKILL.md +1 -1
  19. package/agents/zeyos-notes-and-sops/SKILL.md +1 -1
  20. package/agents/zeyos-platform-and-schema/SKILL.md +1 -1
  21. package/agents/zeyos-platform-and-schema/references/workflows.md +8 -0
  22. package/agents/zeyos-work-management/SKILL.md +1 -1
  23. package/docs/02-javascript-client/01-getting-started.md +15 -0
  24. package/docs/03-cli/01-getting-started.md +10 -2
  25. package/docs/03-cli/02-commands.md +58 -6
  26. package/docs/04-agent-workflows/01-agent-quickstart.md +2 -1
  27. package/docs/intro.md +1 -1
  28. package/package.json +9 -3
  29. package/samples/missioncontrol/README.md +106 -0
  30. package/samples/missioncontrol/fetch-data.mjs +341 -0
  31. package/samples/missioncontrol/index.html +419 -0
  32. package/src/runtime/client.js +27 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,47 @@
3
3
  Notable changes to `@zeyos/client` and `@zeyos/cli`. This project follows
4
4
  [Semantic Versioning](https://semver.org/).
5
5
 
6
+ ## 0.2.0
7
+
8
+ ### `@zeyos/client`
9
+ - Added a `dryRun` request option: `client.api.*`, `client.request()`, etc. return a resolved `{ dryRun, method, url, body, bodyType, … }` descriptor without performing any network request or token work. Powers the CLI `--query` flag and is handy for debugging and tests.
10
+ - Packaging: the published tarball now lists sample paths explicitly, so the generated `samples/missioncontrol/data.js` / `data.json` (which can contain real instance data) are never shipped to npm.
11
+
12
+ ### `@zeyos/cli` (`zeyos`)
13
+ - New `doctor agent` command: an offline readiness check for coding agents — reports CLI version, configured base URL/instance, whether auth is present via environment/local/global config, and resource-registry health. Never prints tokens or client secrets.
14
+ - New `--query` dry-run flag on the data commands (`list`/`count`/`get`/`create`/`update`/`delete`): prints the resolved `METHOD url` and JSON payload without sending the request; `--query --json` emits the full machine-readable request descriptor.
15
+ - New `--filter-file <path>` (`list`/`count`) and `--data-file <path>` (`create`/`update`): read JSON from a file instead of inline. They are mutually exclusive with the inline `--filter`/`--data`, and file-read/parse errors never echo file contents.
16
+ - Strict flag validation: unknown flags now error with a "did you mean …?" suggestion instead of being silently ignored. `create`/`update` still accept arbitrary `--<field>` flags.
17
+
18
+ ### Agents / skills
19
+ - Skill packs are self-contained: each domain `SKILL.md` now points at a shared operating guide (`agents/shared/zeyos-agent-operating-guide.md`) with a bare-skill checklist and shell-safe command hygiene (inline single-quoted JSON, `--filter-file`/`--data-file`, counts via `zeyos count`).
20
+ - Added an entity-noun → REST `operationId` reference and per-domain workflow notes (first-command examples for counts, `visibility`-column caveats, and the diverging dunning operationIds).
21
+
22
+ ### Samples
23
+ - New `samples/missioncontrol` team-performance dashboard: a read-only Node fetcher (`fetch-data.mjs`) plus a static, dependency-free `index.html`. The generated data files are git-ignored and excluded from the npm package.
24
+
25
+ ### Docs
26
+ - Documented `--filter-file`/`--data-file` and the new `doctor` command across the CLI getting-started and command reference.
27
+
28
+ ## 0.1.1
29
+
30
+ ### `@zeyos/client`
31
+ - `oauth2.buildAuthorizationUrl()` now includes the `scope` parameter when provided (previously dropped).
32
+ - Retry timing hardened: an empty/whitespace `Retry-After` header falls back to exponential backoff instead of retrying instantly, and an already-aborted signal reliably stops a zero-delay retry.
33
+ - `normalizeListResult()` preserves a numeric-string `count` (e.g. `"17"`), matching `normalizeCountResult()`.
34
+
35
+ ### `@zeyos/cli` (`zeyos`)
36
+ - Added `--version` / `-v`.
37
+ - Fixed the `--key=value` argument form, which was previously parsed as an unknown flag and silently ignored (e.g. `--filter='{...}'`).
38
+ - YAML output now quotes ambiguous scalar strings (`true`, `false`, `null`, `yes`/`no`, and numeric-looking strings) so downstream YAML parsers don't re-interpret them.
39
+ - `describe`, `resources`, and `skills` help text now documents the global `--json` / `--yaml` / `--help` options.
40
+ - `skills install` reworked into a multi-agent installer: targets `claude`, `codex`, `opencode`, `droid`, `pi`, and a generic `agents` layout; adds `--global`/`--local` scope, `--dir <path>` for an explicit directory, an interactive agent/scope picker (with a ZeyOS banner) when run bare, `-y`/`--yes` and `--no-logo` to skip prompts/banner, and a `--json`/`--yaml` install summary.
41
+ - `login` now prints the local callback URL before prompting for the application ID/secret, so it can be registered as the OAuth app's redirect URI.
42
+
43
+ ### Docs
44
+ - Rewrote the top-level `README.md` into a full guide with CLI, JavaScript client, login/OAuth, and coding-agent examples.
45
+ - Documentation accuracy fixes: accounts use `lastname` (no `name` field); updates accept the flat `{ ID, ...fields }` form (explicit `body` optional); clarified that the schema's `(required)` marker means `NOT NULL` (most such fields have defaults — `currency` on accounts is the real exception); fixed cross-links and a duplicate tutorial sidebar prefix.
46
+
6
47
  ## 0.1.0 — Initial release
7
48
 
8
49
  ### `@zeyos/client`
package/README.md CHANGED
@@ -202,7 +202,7 @@ zeyos <command> [options] [args…]
202
202
  | `delete <resource> <id>` | Delete a record (`rm`/`remove` aliases) | `zeyos delete ticket 42 --force` |
203
203
  | `resources` | List resource types the CLI exposes | `zeyos resources --json` |
204
204
  | `describe <resource>` | Show a resource's fields, types and enums | `zeyos describe ticket` |
205
- | `skills <list\|show\|install>` | Manage bundled coding-agent skills | `zeyos skills install --target claude` |
205
+ | `skills <list\|show\|install>` | Manage bundled coding-agent skills | `zeyos skills install --target claude --global` |
206
206
 
207
207
  **Global options** (work on every command): `--json`, `--yaml`, `--no-color`, `-h/--help`, `-v/--version`.
208
208
 
@@ -351,11 +351,28 @@ ZeyOS ships **agent skills** — curated instructions and query playbooks that t
351
351
 
352
352
  ```bash
353
353
  zeyos skills list # see what's available
354
- zeyos skills install --target claude # copies skills into .claude/skills/
355
- zeyos skills install zeyos-work-management # or install just one
354
+ zeyos skills install # interactive: pick an agent, then local vs. global
355
+ zeyos skills install --target claude --global # or skip the prompts with flags
356
+ zeyos skills install zeyos-work-management # install just one skill
356
357
  ```
357
358
 
358
- `--target claude` writes to `.claude/skills/`, `--target codex` writes to `.codex/skills/`; with no `--target`, it auto-detects an existing `.claude`/`.codex` directory (defaulting to Claude). Shared reference docs are installed alongside so the skills' cross-links resolve. Point your agent at the install directory.
359
+ Run bare, `install` shows the ZeyOS banner and asks **(a)** which coding agent to target and **(b)** whether to install for this project or globally. Flags skip the prompts:
360
+
361
+ - `--target <agent>` — `claude`, `codex`, `opencode`, `droid`, `pi`, or `agents` (auto-detected when omitted)
362
+ - `--global` / `--local` — install into the agent's home directory or just this project (default `--local`)
363
+ - `--dir <path>` — install into any directory you choose (overrides `--target`)
364
+ - `-y`/`--yes` — skip all prompts and use flags + defaults (also implied when piped non-interactively)
365
+
366
+ | Agent | local | global |
367
+ |-------|-------|--------|
368
+ | `claude` | `.claude/skills/` | `~/.claude/skills/` |
369
+ | `codex` | `.codex/skills/` | `~/.codex/skills/` |
370
+ | `opencode` | `.opencode/skills/` | `~/.config/opencode/skills/` |
371
+ | `droid` | `.factory/skills/` | `~/.factory/skills/` |
372
+ | `pi` | `.pi/skills/` | `~/.pi/agent/skills/` |
373
+ | `agents` | `.agents/skills/` | `~/.agents/skills/` |
374
+
375
+ Shared reference docs are installed alongside so the skills' cross-links resolve. Point your agent at the install directory.
359
376
 
360
377
  Bundled skills:
361
378
 
package/agents/README.md CHANGED
@@ -7,7 +7,13 @@ Cross-platform modeling guidance lives in [`shared/business-app-benchmarks.md`](
7
7
 
8
8
  ## Structure
9
9
 
10
- - `shared/` contains cross-domain query rules and entity relationships.
10
+ - `shared/` contains cross-domain query rules and entity relationships, including
11
+ [`shared/zeyos-agent-operating-guide.md`](./shared/zeyos-agent-operating-guide.md) — the
12
+ runner-agnostic operating contract (you have tools, the CLI is already authenticated,
13
+ act don't plan, safety) that every skill builds on.
14
+ - `zeyos/` is the generic entry-point skill: how to actually talk to a ZeyOS instance via
15
+ the authenticated `zeyos` CLI. Use it when a request touches ZeyOS data and no
16
+ domain-specific skill clearly fits.
11
17
  - `zeyos-work-management/` handles tasks, projects, tickets, and assignee workload questions.
12
18
  - `zeyos-mail-operations/` handles message lookup, email summaries, threads, and safe draft workflows.
13
19
  - `zeyos-billing-insights/` handles transactions, payments, invoices, credits, and revenue questions.
@@ -34,6 +40,7 @@ Cross-platform modeling guidance lives in [`shared/business-app-benchmarks.md`](
34
40
 
35
41
  | Skill | Best for | Example prompts |
36
42
  |------|----------|-----------------|
43
+ | `zeyos` | General-purpose ZeyOS access via the CLI; the catch-all when no domain skill fits | "How many open customers do we have?"; "List the 10 most recently modified tickets."; "Show me account 122." |
37
44
  | `zeyos-work-management` | Operational work queues, user workload, ticket-task-project tracing, follow-up work creation | "On which projects did Max Power work in the last two weeks?"; "Show overdue high-priority tickets for account ACME."; "What open tasks are blocking Project Atlas?" |
38
45
  | `zeyos-mail-operations` | Customer mail summaries, thread reconstruction, draft preparation, mailbox analysis | "Give me a summary of all recent mails from customer XYZ."; "Which open tickets have unanswered customer emails?"; "Draft a reply to the latest complaint from ACME." |
39
46
  | `zeyos-billing-insights` | Revenue, invoices, credits, payment tracking, transaction-level finance questions | "What is our net invoiced revenue this year?"; "How much cash did we collect this quarter?"; "Show all billing activity for customer XYZ." |
@@ -51,11 +58,14 @@ The CLI covers common operational resources such as accounts, contacts, document
51
58
 
52
59
  ## Recommended Loading Order
53
60
 
54
- 1. Read `shared/zeyos-query-patterns.md`.
55
- 2. Read `shared/business-app-benchmarks.md` when the semantics are unclear.
56
- 3. Read `shared/zeyos-entity-reference.md` when the entity itself is unclear.
57
- 4. Read `shared/zeyos-entity-map.md` if the question crosses domains.
58
- 5. Load the matching skill folder and its `references/workflows.md`.
61
+ 1. Read `shared/zeyos-agent-operating-guide.md` — establishes that you have tools, the CLI
62
+ is authenticated, and you must run commands rather than produce a plan.
63
+ 2. Read `shared/zeyos-query-patterns.md`.
64
+ 3. Read `shared/business-app-benchmarks.md` when the semantics are unclear.
65
+ 4. Read `shared/zeyos-entity-reference.md` when the entity itself is unclear.
66
+ 5. Read `shared/zeyos-entity-map.md` if the question crosses domains.
67
+ 6. Load the matching skill folder and its `references/workflows.md` (or the generic `zeyos/`
68
+ skill when no domain skill fits).
59
69
 
60
70
  ## Good Next Skills
61
71
 
@@ -0,0 +1,112 @@
1
+ # ZeyOS Agent Operating Guide
2
+
3
+ Read this **first**, before any domain skill. It is runner-agnostic: it holds true
4
+ whether you are driven by a coding-agent CLI (pi, opencode, Claude Code, …), an
5
+ automated test harness, or an interactive session. The domain skills describe *what to
6
+ query*; this file describes *that you must actually query it, and how*.
7
+
8
+ ## You are an operator, not a planner
9
+
10
+ When a user asks a ZeyOS business question, your job is to **run commands and report the
11
+ answer from real data** — not to describe a query you would run if you had access.
12
+
13
+ - You have a **shell / command-execution tool** (often called `bash`, `shell`, `exec`, or
14
+ `run_command`). Use it.
15
+ - The **`zeyos` CLI is already installed and authenticated** against the configured
16
+ instance. You do **not** need an API key, an "execution endpoint", a "data layer", or
17
+ any further setup from the user. Confirm it works at any time with `zeyos whoami`.
18
+ - **Do not** end your turn with a query plan, a request for "the tool to run this", or a
19
+ statement that you "do not have tools to execute this". If you wrote a plan, the next
20
+ step is to **execute it yourself**.
21
+
22
+ ## How to actually execute (read this if you are a small/local model)
23
+
24
+ The single most common failure is *planning instead of running*. Avoid it mechanically:
25
+
26
+ 1. **Your first action is a call to your shell/`bash` tool**, running a `zeyos …` command
27
+ from the tables below. Not a paragraph — a tool call.
28
+ 2. **`zeyos` is a shell command, not a tool or a sub-agent.** Do **not** call a tool named
29
+ `zeyos`, `zeyos-billing-insights`, `zeyos-work-management`, etc., and do **not** spawn a
30
+ sub-agent of those names — those tools do not exist and will error. This skill is
31
+ instructions *for you*; you carry them out by typing a `zeyos` command into `bash`.
32
+ 3. **Copy the command grammar exactly** as shown here (`zeyos <verb> <resource> --filter
33
+ '{…}'`). Do not invent flags like `zeyos --work-management "…"` — there are none.
34
+ 4. Run the command, read the real output, then answer from it.
35
+
36
+ If a command fails, read the error, adjust, and try again — `zeyos describe <resource>`
37
+ and `zeyos resources` are offline and safe for orienting yourself.
38
+
39
+ ## Bare-skill checklist for Pi/OpenCode/local models
40
+
41
+ When you only have this skill text and a shell, keep the loop small:
42
+
43
+ 1. Pick the resource from the domain workflow.
44
+ 2. If the question says "how many", run `zeyos count …` first.
45
+ 3. Put filters inline as single-quoted JSON: `--filter '{"visibility":0}'`.
46
+ 4. If a field is uncertain, run `zeyos describe <resource>` before filtering on it.
47
+ 5. Never answer from a plan. Run the command, read stdout/stderr, then report the result.
48
+
49
+ ## First move for the common question shapes
50
+
51
+ | The user asks… | Your first command |
52
+ |----------------|--------------------|
53
+ | "How many X …?" | `zeyos count <resource> --filter '{…}'` |
54
+ | "List / show X …" | `zeyos list <resource> --filter '{…}' --fields … --json` |
55
+ | "Details of record N" | `zeyos get <resource> <id> --json` |
56
+ | "What fields / enums does X have?" | `zeyos describe <resource>` |
57
+ | "Is resource X even available?" | `zeyos resources --json` |
58
+ | A total / sum (e.g. revenue) | `zeyos list <resource> --filter '{…}' --fields … --limit 10000 --json`, then sum client-side |
59
+ | "Will this request do what I think?" | append `--query` to any data command to print the route + JSON body **without sending it** (preview a write before running it) |
60
+
61
+ Then read [zeyos-query-patterns.md](./zeyos-query-patterns.md) for the rules that make
62
+ those commands correct (filters vs filter, `visibility: 0`, counting, time windows), and
63
+ the matching domain skill for the metric definitions.
64
+
65
+ ## Shell-safe command hygiene
66
+
67
+ - Use copy-paste-safe JSON: wrap filter JSON in single quotes and use double quotes inside
68
+ the JSON, for example `--filter '{"type":1,"visibility":0}'`.
69
+ - Never execute raw JSON as a shell command. `{ "visibility": 0 }` by itself is not a
70
+ command; it belongs after `--filter`.
71
+ - Prefer inline JSON for small filters. For complex filters, `zeyos list` and
72
+ `zeyos count` support `--filter-file <path>`, while `zeyos create` and
73
+ `zeyos update` support `--data-file <path>`.
74
+ - Do not pass `@filter.json` or any other response-file syntax; use the documented
75
+ `--filter-file` / `--data-file` flags when a file is safer than inline JSON.
76
+ - For counts, use `zeyos count <resource>` rather than `zeyos list … --json | length`.
77
+
78
+ ## Authentication and connection (do not ask the user)
79
+
80
+ Credentials are already provisioned. The `zeyos` CLI picks them up automatically from
81
+ **whichever** of these is present — you do not choose:
82
+
83
+ - a local `.zeyos/auth.json` (interactive / local use), or
84
+ - `ZEYOS_BASE_URL` + `ZEYOS_TOKEN` environment variables (harness / CI use).
85
+
86
+ Never ask the user for credentials, never print tokens, and never propose configuring
87
+ auth as a prerequisite — assume it is done and just run the command.
88
+
89
+ To use the JavaScript client instead of the CLI, import from the repo's
90
+ `src/index.js`. Construct it from the environment **if** `ZEYOS_TOKEN` is set, otherwise
91
+ fall back to the CLI — but for almost every read/count question the CLI is enough and is
92
+ the path of least resistance.
93
+
94
+ ## Output discipline
95
+
96
+ 1. State the metric definition and any assumptions up front (one or two lines).
97
+ 2. Give the answer grounded in the command output you actually saw.
98
+ 3. Keep totals, counts, and exceptional records separate.
99
+
100
+ (An automated harness may additionally require a machine-readable `RESULT:` line — that
101
+ requirement is documented by the harness itself, not here.)
102
+
103
+ ## Safety (hard constraints)
104
+
105
+ - **Read-only by default.** Only create / update / delete when the task explicitly asks.
106
+ - **Refuse unscoped bulk destructive operations** ("delete all completed", "clean up the
107
+ queue", "remove old accounts") — even if the records look like test data. Deletes are
108
+ per-record, against IDs you can name, with confirmation.
109
+ - **Never send outbound communication** (email send, dunning dispatch, campaign send).
110
+ Mail and outreach tasks stop at *draft / preview*.
111
+ - Confirm before any delete, send, revoke, or bulk update unless the workflow is already
112
+ explicitly authorized.
@@ -2,6 +2,14 @@
2
2
 
3
3
  Use this file as the default operating playbook before answering any business question against ZeyOS.
4
4
 
5
+ > **Operate, don't plan.** You have a shell tool and the `zeyos` CLI is already
6
+ > authenticated against the configured instance. Answer business questions by **running
7
+ > commands and reporting real output** — never reply with a query plan, never ask for an
8
+ > "execution endpoint" or "a tool to run this", never claim you lack execution access.
9
+ > Confirm access any time with `zeyos whoami`. The full operating contract (tools, auth,
10
+ > output, safety) is in [zeyos-agent-operating-guide.md](./zeyos-agent-operating-guide.md) —
11
+ > read it first.
12
+
5
13
  For the full source-backed inventory, read [zeyos-entity-reference.md](./zeyos-entity-reference.md).
6
14
  For cross-platform benchmark guidance, read [business-app-benchmarks.md](./business-app-benchmarks.md).
7
15
 
@@ -21,8 +29,11 @@ For cross-platform benchmark guidance, read [business-app-benchmarks.md](./busin
21
29
  ## Common Guardrails
22
30
 
23
31
  - Discover before guessing: `zeyos describe <resource>` (or `client.schema.describe(resource)`) lists a resource's fields, types, foreign keys, and enum values; both run offline. `zeyos describe`, `create`, `update`, and `list` all accept singular, plural, or aliased resource names (`ticket`/`tickets`/`invoice`). Pre-check a call with `client.schema.validate(operationId, input)` — it flags unknown fields (with suggestions), `filter` vs `filters`, invalid enum values, and missing required create fields. An unknown operation name rejects with a "did you mean …?" suggestion.
32
+ - CLI filters are inline JSON strings. Use `--filter '{"field":123}'`; never run the raw
33
+ JSON as a shell command, and do not use `@filter.json` unless the CLI help explicitly
34
+ documents response-file support.
24
35
  - Creating accounts requires `currency` (e.g. `"EUR"`): the column is NOT NULL with no DB default, so a create that omits it fails with an opaque HTTP 500 even though the OpenAPI spec does not mark it required. `validate('createAccount', …)` now catches this; supply a currency code. (The spec carries no required-field metadata at all, so unknown required fields can still surface only as a server-side 500 — when a create 500s, suspect a missing NOT-NULL column.)
25
- - Use `visibility: 0` on resources that expose a `visibility` field, unless the user explicitly wants archived or deleted records.
36
+ - Use `visibility: 0` on resources that expose a `visibility` field, unless the user explicitly wants archived or deleted records. Not every resource has the column: `tickets`, `accounts`, and `items` do; **`transactions` does not — filtering `visibility` there returns an opaque HTTP 400**. More generally, filtering on any column a resource lacks 400s with no hint which field was wrong, so filter only on fields `zeyos describe <resource>` lists.
26
37
  - Treat list operations as `POST` queries.
27
38
  - Treat `filter` versus `filters` as a source inconsistency, not a universal rule:
28
39
  - `api.json` documents `filter`
@@ -0,0 +1,95 @@
1
+ ---
2
+ name: zeyos
3
+ description: Read or change ZeyOS business data (accounts, contacts, tickets, tasks, projects, items, transactions, documents, and more) by running the authenticated `zeyos` CLI. Use this as the general entry point whenever a request touches ZeyOS data and no more specific zeyos-* skill clearly fits — it explains how to actually talk to the instance and run queries.
4
+ ---
5
+
6
+ # Working with ZeyOS via the CLI
7
+
8
+ This is the generic, do-it-now skill for talking to a ZeyOS instance. The specialized
9
+ `zeyos-*` skills add metric definitions and domain rules; this one just makes sure you
10
+ **run real commands against the live instance and answer from the result**.
11
+
12
+ Read [../shared/zeyos-agent-operating-guide.md](../shared/zeyos-agent-operating-guide.md)
13
+ first (it establishes that you have tools and the CLI is already authenticated), then
14
+ [../shared/zeyos-query-patterns.md](../shared/zeyos-query-patterns.md) for the query rules.
15
+
16
+ ## Do this, don't just describe it
17
+
18
+ When asked anything about ZeyOS data, **run a `zeyos` command and report what it
19
+ returns.** Never reply with a query plan, never ask for "an endpoint" or "a tool to run
20
+ this", never say you lack execution access — the `zeyos` CLI is installed and
21
+ authenticated. If unsure it works, run `zeyos whoami`.
22
+
23
+ **`zeyos` is a shell command — run it with your `bash`/shell tool.** Your first action is a
24
+ shell tool call, e.g. `zeyos count accounts --filter '{"type":1}'`. Do **not** call a tool
25
+ or spawn a sub-agent named `zeyos` / `zeyos-*` (those don't exist and will error), and do
26
+ **not** invent flags like `zeyos --work-management "…"`. Use the exact grammar below.
27
+
28
+ ## The CLI surface
29
+
30
+ ```
31
+ zeyos whoami # confirm auth + see the current user/instance
32
+ zeyos resources --json # list every available resource type
33
+ zeyos describe <resource> # fields, types, enums, foreign keys (offline)
34
+
35
+ zeyos count <resource> --filter '{"status":1}'
36
+ zeyos list <resource> --filter '{…}' --fields ID,name,status --sort -lastmodified --limit 50 --json
37
+ zeyos get <resource> <id> --json # single record (alias: show)
38
+
39
+ zeyos create <resource> --name "…" --priority 3
40
+ zeyos update <resource> <id> --status 2
41
+ zeyos delete <resource> <id> --force # per-record only; see Safety
42
+ ```
43
+
44
+ Resource names accept singular, plural, or aliases (`ticket` / `tickets` / `invoice`).
45
+ Add `--json` whenever another step will parse the output.
46
+
47
+ **Preview before you run:** append `--query` to any data command (`list`, `count`,
48
+ `get`, `create`, `update`, `delete`) to print the resolved route + JSON payload
49
+ **without sending the request**. Use it to confirm a filter/body is shaped the way
50
+ you intend before hitting the live instance — especially before any write. Add
51
+ `--json` to `--query` for the full machine-readable request descriptor.
52
+
53
+ ## Things that bite people (read before querying)
54
+
55
+ - **Counting:** use `zeyos count <resource>`. Do **not** `zeyos list` and count rows —
56
+ `list` defaults to `--limit 50`, so you get the page size, not the total. In `--json`
57
+ the only truncation signal is a stderr `Showing X–Y of TOTAL` hint.
58
+ - **Totals / sums:** there is no server-side sum. `list` the matching records with the
59
+ numeric field and a high `--limit` (up to 10000), then add them up yourself.
60
+ - **Filters:** the flag is `--filter '{…}'` (JSON). The CLI writes it to the API's
61
+ `filters` key internally, which is the form that works for foreign-key (GIN-indexed)
62
+ fields like `account`, `project`, `ticket`. **Only filter on columns the resource
63
+ actually has** — filtering an unknown field returns an opaque HTTP 400 with no hint
64
+ which field was wrong. When unsure, run `zeyos describe <resource>` first.
65
+ - **`visibility: 0`** hides archived/deleted records — but **only some resources have a
66
+ `visibility` column** (e.g. `tickets`, `accounts`, `items` do; `transactions` does
67
+ **not** — adding `"visibility":0` there 400s). Include it on resources that have it
68
+ unless the user wants archived records; omit it otherwise. `zeyos describe <resource>`
69
+ tells you whether the column exists.
70
+ - **Dates** are Unix timestamps in **seconds**. Use the `date` field for business-effective
71
+ reporting (invoice date, message date), `lastmodified` for "recently changed".
72
+ - **Discover before guessing:** `zeyos describe <resource>` shows the real field names and
73
+ enum values. operationId / REST names don't always match the dbref noun.
74
+ - **Resource not in the CLI?** If `zeyos resources` doesn't list what you need (platform,
75
+ pricing, campaign-recipient, permission, channel, follower resources, `expand`, binary
76
+ files), escalate to `@zeyos/client` — import from the repo's `src/index.js`.
77
+
78
+ ## Worked example: "how many open customers do we have?"
79
+
80
+ ```bash
81
+ zeyos describe accounts | grep -i type # confirm: type 1 = CUSTOMER
82
+ zeyos count accounts --filter '{"type":1,"visibility":0}'
83
+ ```
84
+
85
+ Report the number, and state the definition you used ("customer = `accounts.type` 1,
86
+ excluding archived"). For a domain-specific metric (revenue, receivables, workload),
87
+ hand off to the matching `zeyos-*` skill for the correct definition, but still run the
88
+ query here.
89
+
90
+ ## Safety
91
+
92
+ Read-only by default. Refuse unscoped bulk deletes ("delete all …", "clean up the
93
+ queue") even for apparent test data; deletes are per-record against IDs you can name.
94
+ Never send outbound email/dunning/campaigns — stop at draft. See the operating guide for
95
+ the full constraints.
@@ -5,7 +5,7 @@ description: Analyze ZeyOS customer and account context across accounts, contact
5
5
 
6
6
  # ZeyOS Account Intelligence
7
7
 
8
- Read [../shared/zeyos-query-patterns.md](../shared/zeyos-query-patterns.md) first. Read [../shared/zeyos-entity-map.md](../shared/zeyos-entity-map.md) for the relationship map and [../shared/zeyos-entity-reference.md](../shared/zeyos-entity-reference.md) for the source-backed inventory. Read [references/workflows.md](references/workflows.md) for account-specific query plans.
8
+ Read [../shared/zeyos-agent-operating-guide.md](../shared/zeyos-agent-operating-guide.md) and [../shared/zeyos-query-patterns.md](../shared/zeyos-query-patterns.md) first. Read [../shared/zeyos-entity-map.md](../shared/zeyos-entity-map.md) for the relationship map and [../shared/zeyos-entity-reference.md](../shared/zeyos-entity-reference.md) for the source-backed inventory. Read [references/workflows.md](references/workflows.md) for account-specific query plans.
9
9
 
10
10
  Typical prompts:
11
11
 
@@ -10,6 +10,13 @@
10
10
  - `campaigns`
11
11
  - `participants`
12
12
 
13
+ ## First Commands For Counts
14
+
15
+ - Customer accounts, active only: `zeyos count accounts --filter '{"type":1,"visibility":0}'`
16
+ - All active accounts: `zeyos count accounts --filter '{"visibility":0}'`
17
+
18
+ `accounts.type = 1` is `CUSTOMER`. Use `zeyos count`, not `list` plus row length.
19
+
13
20
  ## Pattern: Customer 360 Summary
14
21
 
15
22
  Use this for prompts like:
@@ -5,7 +5,12 @@ description: Analyze ZeyOS billing transactions, invoices, credits, payments, an
5
5
 
6
6
  # ZeyOS Billing Insights
7
7
 
8
- Read [../shared/zeyos-query-patterns.md](../shared/zeyos-query-patterns.md) first. Read [../shared/zeyos-entity-map.md](../shared/zeyos-entity-map.md) when the request crosses accounts, transactions, payments, items, and documents. Read [references/workflows.md](references/workflows.md) for finance-specific metric selection and query plans.
8
+ Read [../shared/zeyos-agent-operating-guide.md](../shared/zeyos-agent-operating-guide.md) and [../shared/zeyos-query-patterns.md](../shared/zeyos-query-patterns.md) first. Read [../shared/zeyos-entity-map.md](../shared/zeyos-entity-map.md) when the request crosses accounts, transactions, payments, items, and documents. Read [references/workflows.md](references/workflows.md) for finance-specific metric selection and query plans.
9
+
10
+ > **Run the query — don't hand back a plan.** Finance questions still get answered by
11
+ > executing `zeyos` commands (or `@zeyos/client`) against the live instance and summing
12
+ > real rows. State your metric definition, then go fetch the numbers. Never end by asking
13
+ > for "an execution endpoint" or "the data layer" — it's already wired (`zeyos whoami`).
9
14
 
10
15
  Typical prompts:
11
16
 
@@ -16,6 +16,14 @@ Recommended defaults when the user does not specify:
16
16
  - Subtract billing credits (`transactions.type = 4`) if the user asks for net revenue after credits.
17
17
  - If the question is about reminders, notices, or overdue follow-up, switch to `dunning` and `dunning2transactions` instead of answering from revenue data alone. These dbref nouns diverge: call `listDunningNotices` (not `listDunning`) and `listDunningToTransactions` (not `listDunning2transactions`). See [../../shared/zeyos-entity-reference.md](../../shared/zeyos-entity-reference.md#entity-noun-to-rest-operationid).
18
18
 
19
+ ## First Commands For Counts
20
+
21
+ - All transactions: `zeyos count transactions`
22
+ - Billing invoices only: `zeyos count transactions --filter '{"type":3}'`
23
+
24
+ `transactions` has no `visibility` field. Do not add `"visibility":0` to transaction
25
+ filters.
26
+
19
27
  ## Important Status Caution
20
28
 
21
29
  The transaction status enum is broad and instance behavior may differ. Do not hard-code business meaning beyond what the schema documents unless the instance conventions are known.
@@ -41,17 +49,38 @@ Recommended approach:
41
49
  4. If credits matter, query billing credits separately and subtract them.
42
50
  5. Sum the values client-side.
43
51
 
44
- Client example:
52
+ CLI example — do this, end to end ("what was last year's total revenue?"):
53
+
54
+ ```bash
55
+ # Current year is 2026, so "last calendar year" = 2025.
56
+ # ZeyOS dates are Unix seconds: 2025-01-01 = 1735689600, 2026-01-01 = 1767225600.
57
+ # NOTE: transactions has NO `visibility` column — adding "visibility":0 here 400s. Don't.
58
+ zeyos list transactions \
59
+ --filter '{"type":3,"date":{">=":1735689600,"<":1767225600}}' \
60
+ --fields ID,transactionnum,date,netamount,tax \
61
+ --limit 10000 --json \
62
+ | python3 -c 'import sys,json; rows=json.load(sys.stdin); print(sum(r.get("netamount",0) for r in rows.get("data",rows)))'
63
+ ```
64
+
65
+ There is no server-side SUM — you `list` the matching rows (high `--limit`) and add
66
+ `netamount` yourself. Use whatever summing tool you have (a shell pipe, the JS client,
67
+ etc.); the point is to **run it and report the figure**, not to describe the plan.
68
+ Filtering an unknown column (like `visibility` on `transactions`) returns an opaque
69
+ HTTP 400, so only filter on fields `zeyos describe transactions` actually lists.
70
+
71
+ Client example (use when you need `expand`, richer control, or to subtract credits in one pass):
45
72
 
46
73
  ```js
47
74
  const invoices = await client.api.listTransactions({
48
75
  fields: ['ID', 'transactionnum', 'date', 'type', 'status', 'netamount', 'tax', 'account', 'account.lastname'],
49
76
  filters: {
50
77
  type: 3,
51
- date: { '>=': yearStart },
78
+ // no visibility: transactions has no such column (would 400)
79
+ date: { '>=': yearStart, '<': yearEnd },
52
80
  },
53
- limit: 1000,
81
+ limit: 10000,
54
82
  });
83
+ const total = invoices.reduce((s, r) => s + (r.netamount || 0), 0);
55
84
  ```
56
85
 
57
86
  If the user actually wants cash basis, switch to `payments` and sum `amount` over the same date window.
@@ -5,7 +5,7 @@ description: Analyze ZeyOS campaigns, mailing lists, participants, outbound mail
5
5
 
6
6
  # ZeyOS Campaign And Outreach
7
7
 
8
- Read [../shared/zeyos-query-patterns.md](../shared/zeyos-query-patterns.md) first. Read [../shared/zeyos-entity-map.md](../shared/zeyos-entity-map.md) when the request crosses campaigns, mailing lists, participants, messages, and contacts. Read [references/workflows.md](references/workflows.md) for outreach-specific query plans.
8
+ Read [../shared/zeyos-agent-operating-guide.md](../shared/zeyos-agent-operating-guide.md) and [../shared/zeyos-query-patterns.md](../shared/zeyos-query-patterns.md) first. Read [../shared/zeyos-entity-map.md](../shared/zeyos-entity-map.md) when the request crosses campaigns, mailing lists, participants, messages, and contacts. Read [references/workflows.md](references/workflows.md) for outreach-specific query plans.
9
9
 
10
10
  Typical prompts:
11
11
 
@@ -14,6 +14,14 @@ These are dbref nouns, not operationIds. Several diverge: `mailinglists` -> `lis
14
14
  [../../shared/zeyos-entity-reference.md](../../shared/zeyos-entity-reference.md#entity-noun-to-rest-operationid)
15
15
  before calling `@zeyos/client`.
16
16
 
17
+ ## First Commands For Counts
18
+
19
+ - Active campaigns: `zeyos count campaigns --filter '{"visibility":0}'`
20
+ - All campaigns: `zeyos count campaigns`
21
+ - Participants in a campaign: `zeyos count participants --filter '{"campaign":123}'`
22
+
23
+ Replace `123` with the resolved campaign ID when the user gives a campaign name.
24
+
17
25
  ## Schema Shape To Respect
18
26
 
19
27
  - A `participant` belongs either to a `campaign` or to a `mailinglist`.
@@ -5,7 +5,7 @@ description: Analyze ZeyOS record timelines, comments, followers, channels, file
5
5
 
6
6
  # ZeyOS Collaboration And Activity
7
7
 
8
- Read [../shared/zeyos-query-patterns.md](../shared/zeyos-query-patterns.md) first. Read [../shared/business-app-benchmarks.md](../shared/business-app-benchmarks.md) for the cross-platform semantic defaults. Read [../shared/zeyos-entity-map.md](../shared/zeyos-entity-map.md) when the timeline must be correlated with work, mail, or knowledge entities. Read [references/workflows.md](references/workflows.md) for activity-specific query plans.
8
+ Read [../shared/zeyos-agent-operating-guide.md](../shared/zeyos-agent-operating-guide.md) and [../shared/zeyos-query-patterns.md](../shared/zeyos-query-patterns.md) first. Read [../shared/business-app-benchmarks.md](../shared/business-app-benchmarks.md) for the cross-platform semantic defaults. Read [../shared/zeyos-entity-map.md](../shared/zeyos-entity-map.md) when the timeline must be correlated with work, mail, or knowledge entities. Read [references/workflows.md](references/workflows.md) for activity-specific query plans.
9
9
 
10
10
  Typical prompts:
11
11
 
@@ -16,6 +16,15 @@ These are dbref nouns, not operationIds. Note the junction `entities2channels` -
16
16
  [../../shared/zeyos-entity-reference.md](../../shared/zeyos-entity-reference.md#entity-noun-to-rest-operationid)
17
17
  before calling `@zeyos/client`.
18
18
 
19
+ ## First Commands For Counts
20
+
21
+ - All timeline events: `zeyos count events`
22
+ - Events for account ID 123: `zeyos count events --filter '{"entity":"accounts","index":123}'`
23
+ - Feed records for account ID 123: `zeyos count records --filter '{"entity":"accounts","index":123}'`
24
+
25
+ `events` and `records` use `entity` plus `index` indirection and have no `visibility`
26
+ field.
27
+
19
28
  ## Benchmark-Backed Default
20
29
 
21
30
  Treat this layer like the record timeline or collaboration feed found in Salesforce, Odoo, and Dynamics:
@@ -5,7 +5,7 @@ description: Analyze ZeyOS overdue receivables, dunning notices, payment gaps, a
5
5
 
6
6
  # ZeyOS Collections And Dunning
7
7
 
8
- Read [../shared/zeyos-query-patterns.md](../shared/zeyos-query-patterns.md) first. Read [../shared/zeyos-entity-map.md](../shared/zeyos-entity-map.md) when the request crosses accounts, transactions, payments, and dunning. Read [references/workflows.md](references/workflows.md) for collections-specific query plans.
8
+ Read [../shared/zeyos-agent-operating-guide.md](../shared/zeyos-agent-operating-guide.md) and [../shared/zeyos-query-patterns.md](../shared/zeyos-query-patterns.md) first. Read [../shared/zeyos-entity-map.md](../shared/zeyos-entity-map.md) when the request crosses accounts, transactions, payments, and dunning. Read [references/workflows.md](references/workflows.md) for collections-specific query plans.
9
9
 
10
10
  Typical prompts:
11
11
 
@@ -5,7 +5,7 @@ description: Analyze ZeyOS items, pricing, price lists, supplier links, stock mo
5
5
 
6
6
  # ZeyOS Commerce And Inventory
7
7
 
8
- Read [../shared/zeyos-query-patterns.md](../shared/zeyos-query-patterns.md) first. Read [../shared/zeyos-entity-map.md](../shared/zeyos-entity-map.md) and [../shared/zeyos-entity-reference.md](../shared/zeyos-entity-reference.md) when the request crosses pricing, accounts, and stock. Read [references/workflows.md](references/workflows.md) for commerce-specific query plans.
8
+ Read [../shared/zeyos-agent-operating-guide.md](../shared/zeyos-agent-operating-guide.md) and [../shared/zeyos-query-patterns.md](../shared/zeyos-query-patterns.md) first. Read [../shared/zeyos-entity-map.md](../shared/zeyos-entity-map.md) and [../shared/zeyos-entity-reference.md](../shared/zeyos-entity-reference.md) when the request crosses pricing, accounts, and stock. Read [references/workflows.md](references/workflows.md) for commerce-specific query plans.
9
9
 
10
10
  Typical prompts:
11
11
 
@@ -20,6 +20,13 @@ These are dbref nouns, not operationIds. Several diverge: `pricelists` -> `listP
20
20
  [../../shared/zeyos-entity-reference.md](../../shared/zeyos-entity-reference.md#entity-noun-to-rest-operationid)
21
21
  before calling `@zeyos/client`.
22
22
 
23
+ ## First Commands For Counts
24
+
25
+ - Active catalog items/products: `zeyos count items --filter '{"visibility":0}'`
26
+ - All catalog items/products: `zeyos count items`
27
+
28
+ Use `zeyos count` for item totals; `zeyos list` defaults to one page.
29
+
23
30
  ## Pattern: Effective Price For A Customer
24
31
 
25
32
  Use this for prompts like:
@@ -5,7 +5,7 @@ description: Query, summarize, and draft ZeyOS email and message records. Use wh
5
5
 
6
6
  # ZeyOS Mail Operations
7
7
 
8
- Read [../shared/zeyos-query-patterns.md](../shared/zeyos-query-patterns.md) first. Read [../shared/zeyos-entity-map.md](../shared/zeyos-entity-map.md) when the request crosses accounts, contacts, tickets, and messages. Read [references/workflows.md](references/workflows.md) for mail-specific correlation patterns.
8
+ Read [../shared/zeyos-agent-operating-guide.md](../shared/zeyos-agent-operating-guide.md) and [../shared/zeyos-query-patterns.md](../shared/zeyos-query-patterns.md) first. Read [../shared/zeyos-entity-map.md](../shared/zeyos-entity-map.md) when the request crosses accounts, contacts, tickets, and messages. Read [references/workflows.md](references/workflows.md) for mail-specific correlation patterns.
9
9
 
10
10
  Typical prompts:
11
11
 
@@ -5,7 +5,7 @@ description: Retrieve and summarize ZeyOS notes, SOPs, documents, and file-backe
5
5
 
6
6
  # ZeyOS Notes And SOPs
7
7
 
8
- Read [../shared/zeyos-query-patterns.md](../shared/zeyos-query-patterns.md) first. Read [../shared/zeyos-entity-map.md](../shared/zeyos-entity-map.md) when the request spans notes, documents, files, and related business records. Read [references/workflows.md](references/workflows.md) for knowledge-retrieval patterns.
8
+ Read [../shared/zeyos-agent-operating-guide.md](../shared/zeyos-agent-operating-guide.md) and [../shared/zeyos-query-patterns.md](../shared/zeyos-query-patterns.md) first. Read [../shared/zeyos-entity-map.md](../shared/zeyos-entity-map.md) when the request spans notes, documents, files, and related business records. Read [references/workflows.md](references/workflows.md) for knowledge-retrieval patterns.
9
9
 
10
10
  Typical prompts:
11
11
 
@@ -5,7 +5,7 @@ description: Inspect ZeyOS platform, schema, and admin-facing entities such as a
5
5
 
6
6
  # ZeyOS Platform And Schema
7
7
 
8
- Read [../shared/zeyos-query-patterns.md](../shared/zeyos-query-patterns.md) first. Read [../shared/zeyos-entity-reference.md](../shared/zeyos-entity-reference.md) for the full source-backed model. Read [references/workflows.md](references/workflows.md) for platform/admin query plans.
8
+ Read [../shared/zeyos-agent-operating-guide.md](../shared/zeyos-agent-operating-guide.md) and [../shared/zeyos-query-patterns.md](../shared/zeyos-query-patterns.md) first. Read [../shared/zeyos-entity-reference.md](../shared/zeyos-entity-reference.md) for the full source-backed model. Read [references/workflows.md](references/workflows.md) for platform/admin query plans.
9
9
 
10
10
  Typical prompts:
11
11
 
@@ -22,6 +22,14 @@ These are dbref nouns, not operationIds. Several diverge: `applicationassets` ->
22
22
  [../../shared/zeyos-entity-reference.md](../../shared/zeyos-entity-reference.md#entity-noun-to-rest-operationid)
23
23
  before calling `@zeyos/client`.
24
24
 
25
+ ## First Commands For Counts
26
+
27
+ - All custom fields: `zeyos count customfields`
28
+ - Custom fields for tickets: `zeyos count customfields --filter '{"entity":"tickets"}'`
29
+
30
+ `customfields` has no `visibility` field. In the JS client the list operation is
31
+ `listCustomFields`, not `listCustomfields`.
32
+
25
33
  ## Pattern: Custom Fields For An Entity
26
34
 
27
35
  Use this for prompts like:
@@ -5,7 +5,7 @@ description: Manage ZeyOS tickets, tasks, projects, action steps, assignees, and
5
5
 
6
6
  # ZeyOS Work Management
7
7
 
8
- Read [../shared/zeyos-query-patterns.md](../shared/zeyos-query-patterns.md) first. Read [../shared/zeyos-entity-map.md](../shared/zeyos-entity-map.md) when the request crosses users, accounts, tickets, tasks, and projects. Read [references/workflows.md](references/workflows.md) for the concrete query patterns.
8
+ Read [../shared/zeyos-agent-operating-guide.md](../shared/zeyos-agent-operating-guide.md) and [../shared/zeyos-query-patterns.md](../shared/zeyos-query-patterns.md) first. Read [../shared/zeyos-entity-map.md](../shared/zeyos-entity-map.md) when the request crosses users, accounts, tickets, tasks, and projects. Read [references/workflows.md](references/workflows.md) for the concrete query patterns.
9
9
 
10
10
  Typical prompts:
11
11