@bonnard/cli 0.2.4 → 0.2.6

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 (29) hide show
  1. package/README.md +85 -0
  2. package/dist/bin/bon.mjs +15 -2
  3. package/dist/bin/{validate-BdqZBH2n.mjs → validate-Bc8zGNw7.mjs} +75 -3
  4. package/dist/docs/_index.md +17 -6
  5. package/dist/docs/topics/catalog.md +36 -0
  6. package/dist/docs/topics/cli.deploy.md +193 -0
  7. package/dist/docs/topics/cli.md +113 -0
  8. package/dist/docs/topics/cli.validate.md +125 -0
  9. package/dist/docs/topics/cubes.data-source.md +1 -1
  10. package/dist/docs/topics/features.governance.md +58 -59
  11. package/dist/docs/topics/features.semantic-layer.md +6 -0
  12. package/dist/docs/topics/getting-started.md +2 -2
  13. package/dist/docs/topics/governance.md +83 -0
  14. package/dist/docs/topics/overview.md +49 -0
  15. package/dist/docs/topics/querying.mcp.md +200 -0
  16. package/dist/docs/topics/querying.md +11 -0
  17. package/dist/docs/topics/querying.rest-api.md +198 -0
  18. package/dist/docs/topics/querying.sdk.md +53 -0
  19. package/dist/docs/topics/slack-teams.md +18 -0
  20. package/dist/docs/topics/views.md +17 -9
  21. package/dist/docs/topics/workflow.md +6 -5
  22. package/dist/templates/claude/skills/bonnard-design-guide/SKILL.md +233 -0
  23. package/dist/templates/claude/skills/bonnard-get-started/SKILL.md +49 -15
  24. package/dist/templates/claude/skills/bonnard-metabase-migrate/SKILL.md +28 -9
  25. package/dist/templates/cursor/rules/bonnard-design-guide.mdc +232 -0
  26. package/dist/templates/cursor/rules/bonnard-get-started.mdc +49 -15
  27. package/dist/templates/cursor/rules/bonnard-metabase-migrate.mdc +28 -9
  28. package/dist/templates/shared/bonnard.md +28 -11
  29. package/package.json +2 -2
@@ -48,9 +48,10 @@ bon datasource add --demo
48
48
  ```
49
49
 
50
50
  This adds a read-only **Contoso** retail database (Postgres) with tables:
51
- - `fact_sales` — transactions with sales_amount, unit_price, sales_quantity, date_key
51
+ - `fact_sales` — transactions with sales_amount, total_cost, sales_quantity, return_quantity, return_amount, discount_amount, date_key, channel_key, store_key, product_key
52
52
  - `dim_product` — product_name, brand_name, manufacturer, unit_cost, unit_price
53
- - `dim_store` — store_name, store_type, employee_count, selling_area_size
53
+ - `dim_store` — store_name, store_type, employee_count, selling_area_size, status
54
+ - `dim_channel` — channel_name (values: Store, Online, Catalog, Reseller)
54
55
  - `dim_customer` — first_name, last_name, gender, yearly_income, education, occupation
55
56
 
56
57
  All tables are in the `contoso` schema. The datasource is named `contoso_demo`.
@@ -69,7 +70,7 @@ All tables are in the `contoso` schema. The datasource is named `contoso_demo`.
69
70
  | `bon deployments` | List recent deployments (add `--all` for full history) |
70
71
  | `bon diff <deployment-id>` | Show changes in a deployment (`--breaking` for breaking only) |
71
72
  | `bon annotate <deployment-id>` | Add reasoning/context to deployment changes |
72
- | `bon query '{...}'` | Execute a semantic layer query (JSON or `--sql` format) |
73
+ | `bon query '{...}'` | Query the deployed semantic layer (requires `bon deploy` first, not for raw DB access) |
73
74
  | `bon mcp` | Show MCP setup instructions for AI agents |
74
75
  | `bon docs` | Browse documentation |
75
76
  | `bon metabase connect` | Connect to a Metabase instance (API key) |
@@ -96,15 +97,19 @@ Topics follow dot notation (e.g., `cubes.dimensions.time`). Use `--recursive` to
96
97
 
97
98
  ## Workflow
98
99
 
99
- 1. **Setup datasource** — `bon datasource add --from-dbt` or manual
100
- 2. **Create cubes** — Define measures/dimensions in `bonnard/cubes/*.yaml`
101
- 3. **Create views** — Compose cubes in `bonnard/views/*.yaml`
102
- 4. **Validate** — `bon validate`
103
- 5. **Deploy** — `bon login` then `bon deploy -m "description of changes"`
104
- 6. **Review** — `bon deployments` to list, `bon diff <id>` to inspect changes
100
+ 1. **Start from questions** — Collect the most common questions your team asks about data. Group them by audience.
101
+ 2. **Setup datasource** — `bon datasource add --from-dbt` or manual
102
+ 3. **Create cubes** — Define measures/dimensions in `bonnard/cubes/*.yaml`. Add filtered measures for any metric with a WHERE clause.
103
+ 4. **Create views** — Compose cubes in `bonnard/views/*.yaml`. Name views by audience/use case, not by table.
104
+ 5. **Write descriptions** — Descriptions are how AI agents choose views and measures. Lead with scope, cross-reference related views, include dimension values.
105
+ 6. **Validate** — `bon validate`
106
+ 7. **Deploy** — `bon login` then `bon deploy -m "description of changes"`
107
+ 8. **Test with questions** — Query via MCP with real user questions. Check the agent picks the right view and measure.
108
+ 9. **Iterate** — Fix agent mistakes by improving descriptions and adding filtered measures. Expect 2-4 iterations.
105
109
 
106
110
  For a guided walkthrough: `/bonnard-get-started`
107
111
  For projects migrating from Metabase: `/bonnard-metabase-migrate`
112
+ For design principles: `/bonnard-design-guide`
108
113
 
109
114
  ## Deployment & Change Tracking
110
115
 
@@ -119,8 +124,20 @@ Every deploy creates a versioned deployment with change detection:
119
124
 
120
125
  For CI/CD pipelines, use `bon deploy --ci -m "message"` (non-interactive, fails on issues). Datasources are always synced automatically during deploy.
121
126
 
122
- ## Best Practices
127
+ ## Design Principles
128
+
129
+ Summary — see `/bonnard-design-guide` for examples and details.
130
+
131
+ 1. **Start from questions, not tables** — collect the 10-20 most common questions, build views that answer them
132
+ 2. **Views are for audiences, not tables** — name by use case (`sales_pipeline`), not by table (`orders_view`)
133
+ 3. **Add filtered measures** — if a dashboard card has a WHERE clause beyond date range, make it a filtered measure
134
+ 4. **Descriptions are the discovery API** — lead with scope, cross-reference related views, include dimension values
135
+ 5. **Build cross-entity views** — combine cubes when users think across tables; don't force one view per cube
136
+ 6. **Test with natural language** — ask an agent real questions via MCP; check it picks the right view and measure
137
+ 7. **Iterate** — expect 2-4 rounds; fix agent mistakes by improving descriptions, not data
138
+
139
+ ## Technical Gotchas
123
140
 
124
141
  - **Always set `data_source`** on cubes — without it, cubes silently use the default warehouse, which breaks when multiple warehouses are added later. `bon validate` warns about this.
125
- - **Add descriptions** to all cubes, views, measures, and dimensions these power AI agent discovery and the schema catalog.
142
+ - **Primary keys must be unique** Cube deduplicates on the primary key. If the column isn't unique (e.g., a date with multiple rows per day), dimension queries silently return empty results. For tables without a natural unique column, use a `sql` query with `ROW_NUMBER()` to generate a synthetic key.
126
143
  - **Use `sql_table` with full schema path** (e.g., `schema.table_name`) for clarity.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonnard/cli",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "bon": "./dist/bin/bon.mjs"
@@ -9,7 +9,7 @@
9
9
  "dist"
10
10
  ],
11
11
  "scripts": {
12
- "build": "tsdown src/bin/bon.ts --format esm --out-dir dist/bin && cp -r src/templates dist/ && mkdir -p dist/docs/topics dist/docs/schemas && cp ../content/index.md dist/docs/_index.md && cp ../content/getting-started.md dist/docs/topics/ && cp ../content/modeling/*.md dist/docs/topics/",
12
+ "build": "tsdown src/bin/bon.ts --format esm --out-dir dist/bin && cp -r src/templates dist/ && mkdir -p dist/docs/topics dist/docs/schemas && cp ../content/index.md dist/docs/_index.md && cp ../content/overview.md ../content/getting-started.md dist/docs/topics/ && cp ../content/modeling/*.md dist/docs/topics/",
13
13
  "dev": "tsdown src/bin/bon.ts --format esm --out-dir dist/bin --watch",
14
14
  "test": "vitest run"
15
15
  },