farseer-cli 1.20.0 → 1.22.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 (33) hide show
  1. package/README.md +1 -1
  2. package/dist/commands/dimensions.js +20 -4
  3. package/dist/commands/dimensions.js.map +1 -1
  4. package/dist/commands/sheets.js +200 -15
  5. package/dist/commands/sheets.js.map +1 -1
  6. package/dist/index.js +10 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/mcp/tools/modelTools.js +17 -6
  9. package/dist/mcp/tools/modelTools.js.map +1 -1
  10. package/dist/operations/model.js +6 -2
  11. package/dist/operations/model.js.map +1 -1
  12. package/dist/operations/sheets.js +368 -30
  13. package/dist/operations/sheets.js.map +1 -1
  14. package/dist/pipeline/generated-reference.json +10 -10
  15. package/dist/utils/dimensionMembers.js +54 -0
  16. package/dist/utils/dimensionMembers.js.map +6 -0
  17. package/dist/utils/entityResolver.js +2 -0
  18. package/dist/utils/entityResolver.js.map +1 -1
  19. package/docs/cli-guide.md +17 -3
  20. package/docs/pipeline-reference.md +126 -18
  21. package/package.json +2 -2
  22. package/skills/farseer-dashboards/SKILL.md +222 -20
  23. package/skills/farseer-dashboards/cards.md +59 -0
  24. package/skills/farseer-dashboards/charts.md +245 -0
  25. package/skills/farseer-dashboards/check.md +91 -0
  26. package/skills/farseer-dashboards/measures.md +88 -0
  27. package/skills/farseer-dashboards/page.md +99 -0
  28. package/skills/farseer-dashboards/reporting-period.md +82 -0
  29. package/skills/farseer-dashboards/standard-set.md +182 -0
  30. package/skills/farseer-dashboards/tables.md +174 -0
  31. package/skills/farseer-data-permissions/SKILL.md +85 -0
  32. package/skills/pipeline-authoring/SKILL.md +3 -3
  33. package/skills/pipeline-authoring/practices.md +2 -1
@@ -1,39 +1,241 @@
1
1
  ---
2
2
  name: farseer-dashboards
3
- description: How to build or change a Farseer dashboard through the API, with its folder, table and chart tiles, the sheet lines that give a tile its rows and columns, slicers and dashboard filters, and how to check a tile's values. Use when creating or changing a dashboard, a tile or a sheet.
3
+ description: "Build or change Farseer dashboards, tiles and the sheets behind them with the Farseer CLI, in IBCS: one chart, one page or the standard dashboard set. Gives the notation and colours, the layout, the blocks (cards, monthly charts with variance tiers, statements with waterfalls, comparisons, composition, small multiples) with their payloads, the measures and reporting members they need, and how to check or undo a build. Use to create, restyle or review a dashboard or tile; for answering a question about the numbers use `farseer-analysis`, for a P&L structure `farseer-pnl`."
4
4
  metadata:
5
- version: "1"
5
+ version: "3"
6
6
  ---
7
7
 
8
- # Dashboards
8
+ # Building dashboards
9
9
 
10
- `farseer dashboards` only lists and inspects; build a dashboard with the API. Paths below are under `/api/v3`. A request missing a required field is refused with a bare `BadRequest`, so send these shapes whole. Variable gids come from `farseer variables list --json` (`gid`), and member gids from `farseer dimensions members TABLE --json`. The CLI doesn't print table gids yet; `POST /entities/type` with `["DTAB"]` lists each table's `id` with its `meta.name`.
10
+ This skill builds IBCS dashboards with the Farseer CLI: a dashboard, its tiles, the sheet lines behind each tile, and the measures and members the tiles need. Every rule here was verified on a reference build (a fictional distributor, "Acme Group", the standard set) and is written to work on any model.
11
11
 
12
- 1. **Folder.** Only a dashboard needs a folder: variables, tables and other objects go in one only when the user names it. Use the folder the user names; otherwise the top dashboards folder. `POST /folders/search` with `{"name": "Dashboards", "types": ["FOLDER"], "limit": 20}` lists folders, and a dashboard can go in one whose `allowedTypes` includes `"DASHBOARD"`.
13
- 2. **Dashboard.** `POST /dashboards` with `{"folderId": FOLDER_ID, "name": "..."}`. A filter that every tile follows goes in its `rows.filters` (`displayColumns` is required; `[2]` shows member names), as in `{"rows": {"onlyWithData": false, "owdIncludeMeasures": false, "emitNoResultRows": true, "filters": [{"tableId": TABLE_GID, "dimensionIds": [], "displayColumns": [2], "selectAll": true, "selectBlanks": false, "multiselect": true, "autoApply": true, "blanks": false}]}}`.
14
- 3. **A table or chart tile.** `POST /dashboards/{dashboardId}/tiles` creates the tile and its own sheet, whose id is in the response's `data.sheet.id`:
12
+ ## Scope: a tile, a page or the set
13
+
14
+ Build what was asked, no more.
15
+
16
+ - **One chart or table** ("show net sales against plan by month", a tile in a chat): pick the block from the table below, build that one tile, and skip the page header, headings and cover. The notation, colours, units and checks still apply.
17
+ - **One dashboard** ("a cash dashboard", "a P&L page"): the page layout in [`page.md`](page.md), then the blocks the question needs. A page of the standard set asked for by name ("a Budget vs Actual page"): its section in [`standard-set.md`](standard-set.md).
18
+ - **The standard set** ("the standard dashboards", "the IBCS set", "the management report"): [`standard-set.md`](standard-set.md) lists the pages, their tiles and what each needs from the model. Pages the model can't feed are skipped, never filled with something else under the same name.
19
+
20
+ | Question | Block | Part |
21
+ | --- | --- | --- |
22
+ | Where do we stand on a few KPIs? | KPI cards with sparklines | [`cards.md`](cards.md) |
23
+ | How does a measure run over the year against plan or last year? | monthly scenario chart with variance tiers | [`charts.md`](charts.md) §1 |
24
+ | Which departments, regions or products miss the plan? | categorical comparison, three tiles | [`charts.md`](charts.md) §2 |
25
+ | What is the mix, and how does it change? | composition chart, top three and Other | [`charts.md`](charts.md) §3 |
26
+ | Will the cash last? | cash over time | [`charts.md`](charts.md) §4 |
27
+ | How is the balance sheet built up? | 100 % structure | [`charts.md`](charts.md) §5 |
28
+ | How does a measure run in each department, region or entity? | small multiples | [`charts.md`](charts.md) §6 |
29
+ | Which lines of a statement miss the plan? | statement with waterfalls and variance columns | [`tables.md`](tables.md) §1 |
30
+ | How do margins compare? | margins table | [`tables.md`](tables.md) §2 |
31
+ | Where did the cash go? | cash bridge, cash flow by month | [`tables.md`](tables.md) §3, §4 |
32
+ | anything else (a trend over several years, an area chart, a multi-version table) | no house block: build it from the notation, colour, unit and scale rules of §2, and say so in your report | |
33
+
34
+ Measures and members a block needs: [`measures.md`](measures.md). The reporting period, the month-end close and the Reporting setup page: [`reporting-period.md`](reporting-period.md). Before you report a build: [`check.md`](check.md).
35
+
36
+ Never build a pie or donut chart, a 3D chart, a gauge or a traffic light. Offer the composition chart or a ranked categorical comparison instead. Only when the user insists on a pie: one period, at most five slices plus Other, largest first, values on the slices, and say it departs from IBCS.
37
+
38
+ ## 1. Settle and probe before any write
39
+
40
+ Settle from the request and the model: the subject (which variable; "sales" may be gross sales, net sales or revenue), the comparison (AC against PL by default, against PY when there is no plan or the question is about last year), the period, the breakdown, the unit and the language.
41
+
42
+ - **Language.** Write every title, name, heading, message and footnote in the model's language, taken from its own variable, dimension and member names. Scenario codes (AC, PL, FC, PY, Δ) stay as they are.
43
+ - **Lead measure.** The headline is the amount the business is run by, as its own sheets show it. When the model holds two candidates (gross and net revenue, two budgets, EBITDA and adjusted EBITDA), name both and recommend one.
44
+ - **The plan** (`PL` in this skill): `Reporting period=Current budget` where the table has that member, otherwise the approved budget version by name (`Versions=Budget 2026` on the reference build). Every PL line, card and measure of a build uses the same one; in a formula it is `"Reporting period">"Current budget"` or `"Versions">"Budget 2026"`.
45
+ - **The last closed month** is the user's call: propose one with the evidence (where actuals stop, what is loaded but not closed) and ask.
46
+ - **Reuse first.** Look for a measure that already means what you need, by name and formula, and compare its numbers before you use it. A twin clutters the model and drifts.
47
+ - **A vague request** ("a sales dashboard", "something for the board") leaves several builds open: propose three to five from the table above, by what the model holds, each with its name, its chart in plain words and its variables, and recommend one.
48
+ - **A P&L** follows the model's own statement, its lines, order and names, without `+`, `-` or `=` prefixes (bold and the ink line mark a total), even where `farseer-pnl` shows them. Where the model has none to follow, the `farseer-pnl` skill finds the business type, maps the variables and builds the missing subtotals; without that skill, ask the user for the lines of their statement.
49
+ - **Style from this skill**, not from the model's existing dashboards: they are often not IBCS. Only when the user explicitly asks to match an existing dashboard ("make it look like our Sales report"), read that dashboard's tiles (`farseer dashboards tiles ID --json`, then `farseer dashboards show-tile ID TILE_ID --json`) and take its colours, layout, tile sizes, column widths and naming. The data rules still hold: units, polarity, the closed-month gating, no numbers in text. Name in your report where the matched style departs from IBCS (a pie, green and red on values that aren't variances, no notation), in one line each.
50
+ - **Existing dashboards.** `farseer dashboards list --json` first. The same name is a collision; a dashboard on the same subject and comparison is a near-duplicate to reuse, replace or add to, as the user decides.
51
+
52
+ Probe with `farseer formula eval` (several formulas per call where you can), never on assumptions:
53
+
54
+ - **Sign.** One cost (COGS is ideal) in the latest year with actuals. Positive: costs are stored as magnitudes, subtotals subtract them and cost rows take `NEGATIVE` polarity. Negative: subtotals add them and the statement keeps the stored sign (§2.4).
55
+ - **Magnitude** of each main measure, for the unit (§2.5).
56
+ - **Coverage.** Where actuals stop, what the forecast version holds (actuals in the closed months and forecast after, or only its forecast months), at which grain the plan sits on every filter and breakdown, and the prior year by month (a year-end closing entry can make the full year read about 0 while January to November are complete).
57
+ - **Breakdowns add up.** Each breakdown against its total under one value of every filter. A gap (unmapped members, capitalised costs) becomes its own named row, or a footnote that names its amount and scope.
58
+ - **Balances.** Cash, FTE, balance sheet lines and day counts need rollup `Closing State` (opening cash `Beginning State`), or a year-to-date column adds the months up. A balance with a `Sum` rollup is a model problem to report, not to work around.
59
+
60
+ An empty comparison side, an empty actual side or a breakdown that doesn't split its total can't be built as asked: say what the probes support instead. Every option you name rests on a probe you ran. An empty probe can also be a wrong member name: check names against `farseer dimensions members TABLE --json` first.
61
+
62
+ A build that writes to the model (measures, members, a table) or builds several pages states its plan first: the pages and tiles, the measures and members it will create, the unit, the colour, and the two or three assumptions the user could object to, each with your recommendation.
63
+
64
+ ## 2. IBCS rules that hold everywhere
65
+
66
+ ### 2.1 Scenarios and colours
67
+
68
+ | Element | Colour | Payload |
69
+ | --- | --- | --- |
70
+ | AC | the AC colour | `"pattern": "SOLID"` |
71
+ | PL | outline in the AC colour | `"pattern": "NONE", "border": AC, "borderStyle": "THIN"` |
72
+ | FC | the AC colour hatched | `"pattern": "HATCHED", "border": AC, "borderStyle": "THIN"` |
73
+ | PY | the PY tint | `"pattern": "SOLID"` |
74
+ | good variance | `#0CB955` | only on a variance |
75
+ | bad variance | `#E21E09` | only on a variance |
76
+ | ink: totals, axes, dividers | `#020810` | lines and total borders |
77
+ | table row lines | `#E6EBF2` | |
78
+
79
+ **The AC colour** is `#323232`, or the company's darkest brand colour when it is dark enough to read as the darkest thing on the page (relative luminance under about 0.06): dark purple, navy and dark brown pass; bright blue, orange and red don't. Never red or green, they are the variance colours. The other greys follow from it:
80
+
81
+ | Role | With `#323232` | With a brand colour (Acme `#3B2A47`) |
82
+ | --- | --- | --- |
83
+ | PY tint | `#A0A0A0` | a light tint (`#A597B1`) |
84
+ | waterfall decrease, one tint lighter | `#5A5A5A` | `#5A4868` |
85
+ | neutral variance (a balance) | `#7D7D7D` | `#7A6B86` |
86
+ | sparkline PL line | `#C9C9C9` | `#C9C1D0` |
87
+ | composition ramp, darkest first, rest last | `#323232`, `#5A5A5A`, `#8C8C8C`, `#B4B4B4`, `#D2D2D2` | AC, then lighter tints |
88
+
89
+ Green and red appear only on variances, and blue nowhere. Text tiles can't take a hex colour, so titles and the notation key stay black.
90
+
91
+ ### 2.2 The comparison and its axis
92
+
93
+ The axis line under a variance carries the comparison: against PL a `DOUBLE` line in ink, against PY a `THICK` line in the PY tint, against AC a `THICK` line in ink. Set it on every variance tile (`chart.display.domainAxisColor`, `domainAxisBorderStyle`) and every variance column's header (`header.domainAxisColor`, `domainAxisBorderStyle`), even with the axis labels hidden. Column headers carry the notation too: AC `THICK` in the AC colour, PL `DOUBLE` in ink, PY `THICK` in the PY tint, FC `HATCHED`.
94
+
95
+ A chart shows at most two scenarios as columns. A third is a triangle: with AC&FC and PL as columns, PY is an `INDICATOR_CHART` row in the PY tint. Without PL, PY is the grey column behind AC (`"barSpacing": -60`) and the tiers compare with PY.
96
+
97
+ ### 2.3 Variance colours and polarity
98
+
99
+ A variance is green when it is good and red when it is bad, never by sign. Whether up is good is the row's polarity: `NEGATIVE` when a rise worsens the result (costs, deductions, income tax, rebates, returns, provisions, write-offs, and lower-is-better KPIs such as days outstanding), otherwise `POSITIVE`. A subtotal never is `NEGATIVE`.
100
+
101
+ - Polarity lives on the row (`rowStyles`, a card's `format`), never in a column's `labelFormat`: a column polarity overrides every row and flips the cost colours.
102
+ - `NEGATIVE` only where the sign probe is positive. On a cost stored negative it flips twice and an overspend shows green.
103
+ - A chart of a cost variance swaps the colours instead (`"positive": "#E21E09", "negative": "#0CB955"`) and sets the label format's `polarity` to `POSITIVE`, so the measure's own polarity can't flip them back.
104
+ - A variance of a balance (cash, receivables, inventories, payables, FTE) has no good or bad direction: the neutral tint with `"colorBy": "STATIC"`, unless the user's report treats it as lower-is-better (net working capital, net debt).
105
+ - A variance shown as a number is red when bad and stays black when good: green on every good number makes the table noisy.
106
+
107
+ ### 2.4 Costs stored negative
108
+
109
+ When the sign probe says costs are negative, statements keep the stored sign: subtotals add the cost lines, cost rows stay `POSITIVE` and colours are not swapped. Cards, sparklines and cost charts read a magnitude measure instead (`-1 *` the cost, polarity `NEGATIVE`, [`measures.md`](measures.md)), so bars don't hang down and badges keep the right sign.
110
+
111
+ ### 2.5 Units and number formats
112
+
113
+ - **One unit per page**, from the magnitude: kEUR up to tens of millions, mEUR with one decimal above. Take the currency from the variable's `numberFormat`. With a Currency filter on the page, names keep a neutral unit ("k", "m") and the chip names the currency, or the page is pinned to one currency and names it.
114
+ - **The unit is in the page title and at the end of every tile name with amounts** ("P&L, year to date (kEUR)"), spelled one way on the whole set. A tile is read, shared and exported on its own. Percent and count tiles need none. A KPI card name carries a unit only when the card's differs from the page's ("Net sales (mEUR)").
115
+ - Base values are `"negatives": "SIGNED"`, variances `EXPLICIT` (±). A variance of a ratio is in percentage points with two decimals.
116
+ - **No signed zeros.** A variance label never reads "+0" or "−0,0": the variance measure is blank below half a label unit ([`measures.md`](measures.md) §3).
117
+ - Number formats used throughout, with the unit kEUR. On a table column leave `polarity` out: the row decides.
15
118
 
16
119
  ```json
17
- {"name": "Net sales by category", "subtitle": "", "footnotes": "", "style": {},
18
- "gridPlacements": {"large": {"h": 8, "w": 8, "x": 0, "y": 0}},
120
+ {"type": "NUMBER", "unit": "THOUSANDS", "negatives": "SIGNED", "polarity": "POSITIVE", "currency": "EUR", "decimals": 0, "formatString": "#,##0,", "custom": false}
121
+ {"type": "NUMBER", "unit": "THOUSANDS", "negatives": "SIGNED", "polarity": "POSITIVE", "currency": "EUR", "decimals": 1, "formatString": "#,##0.0,", "custom": false}
122
+ {"type": "NUMBER", "unit": "THOUSANDS", "negatives": "EXPLICIT", "polarity": "POSITIVE", "currency": "EUR", "decimals": 1, "formatString": "+#,##0.0,;-#,##0.0,;0.0,", "custom": false}
123
+ {"type": "PERCENTAGE", "unit": "ONES", "negatives": "EXPLICIT", "polarity": "POSITIVE", "currency": "EUR", "decimals": 1, "formatString": "+#,##0.0%;-#,##0.0%;0.0%", "custom": false}
124
+ ```
125
+
126
+ A ratio (a margin) is `{"type": "PERCENTAGE", "unit": "ONES", "negatives": "SIGNED", "polarity": "POSITIVE", "currency": "EUR", "decimals": 1, "formatString": "#,##0.0%", "custom": false}`. In mEUR the unit is `MILLIONS` and the format string ends in `,,` (`#,##0.0,,`). The payloads in the parts use kEUR and the Acme colours: put in yours.
127
+
128
+ ### 2.6 Scales
129
+
130
+ One measure in one unit shares one scale: its AC, PL and FC, and its absolute variance, in one table or across the tiers of a chart (`shareAxis: true` with one `shareAxisGroup`). A small variance then looks small, which is the honest picture. A % variance never shares a scale (`shareAxis: false`). Two different measures side by side keep their own scales, and the footnote says so.
131
+
132
+ Shared axes are dashboard-wide: every chart on a page with the same `shareAxisGroup` shares one scale. So each chart block (a base chart and its tiers, a categorical row) takes its own group number, and a %, a count or another measure never joins an amount's group. In a table the groups are per table (1 to 4). The parts write `GROUP` where a number goes.
133
+
134
+ ### 2.7 Text
135
+
136
+ - **The message carries no numbers.** Text is frozen when it is written; the data follows the filters and the close. Open with the scope it was written for (the view with no filter picked), then the direction in words: "Whole group, year to date: EBITDA behind budget, net sales on plan." Every variance names what it is compared with and over which period, and the member by name, not by rank.
137
+ - **Texts carry no month.** "2026 year to date AC and PL", "vs PL YTD", tile names "…, year to date" or "…, month end". The period comes from the filter ([`reporting-period.md`](reporting-period.md)), so nothing is rewritten at a close unless a direction flips.
138
+ - **Nothing about what is missing** goes on a page (pages not built, data the model lacks). Say it in your report.
139
+ - Numbers in other text (a footnote naming a gap) read the same in every locale: whole kEUR, a thin space as the thousands separator, whole percent ("7 kEUR unassigned", "8% of net sales").
140
+
141
+ ## 3. The commands
142
+
143
+ - `farseer dashboards create "NAME" --json` creates a dashboard in the top Dashboards folder and prints its id; `--folder-path` or `--folder-id` for a folder the user named. Only a dashboard needs a folder. A set of pages goes in a folder of its own, `farseer folders create "NAME" --parent-path Dashboards --json`.
144
+ - Right after creating it, `farseer dashboards update ID --input settings.json` turns the timeline off and the layout to the fixed grid. `columns`, `rows` and `options` each replace the stored object whole, so send them complete ([`page.md`](page.md) §1).
145
+ - `farseer dashboards create-tile ID --input tile.json --json` creates a tile; a sheet-backed one prints its sheet as `tile.sheet.id`. `farseer dashboards update-tile ID TILE_ID --input change.json` deep-merges a change into a tile. `farseer dashboards tiles ID --json` lists them, `farseer dashboards delete-tile ID TILE_ID -y` deletes one.
146
+ - `farseer sheets create-line SHEET_ID` adds a row or a column to a tile's sheet. `farseer sheets update-line SHEET_ID LINE_ID --input change.json` changes the fields the file holds, `farseer sheets delete-line SHEET_ID LINE_ID -y` deletes a line with the lines nested under it, and `farseer sheets lines SHEET_ID --json` lists them.
147
+ - `farseer sheets update SHEET_ID --input rows.json` deep-merges sort, top N, only-with-data and column widths into a sheet.
148
+ - `farseer sheets data SHEET_ID --json` reads a tile's values and the keys a visualization addresses.
149
+ - `farseer variables create`, `farseer dimensions create` and `farseer dimensions create-member` create measures, tables and members ([`measures.md`](measures.md)).
150
+
151
+ The commands take names of variables, tables and members, which `farseer variables list --json` and `farseer dimensions members TABLE --json` list with their gids. A member's `parentId` there is its table's gid, which filters, sorts and lookups need. List a table's members before using one; never guess a name.
152
+
153
+ Paths under `/api/v3` below are the few requests the CLI has no command for, sent to the API base your environment gives (`https://<org>.farseer.io/api/v3`) with the header `X-TENANT-ID: <tenant>`. An API key goes in `X-API-KEY`, not as a bearer token. Where the environment gives you no credential, skip that step and say so in your report; never read one from the CLI's config.
154
+
155
+ Ids in `--json` output: `farseer dashboards create` prints `.dashboard.id`, `create-tile` `.tile.id` and `.tile.sheet.id`, `sheets create-line` `.line.id`, and `variables create` and `dimensions create-member` `.result.created[0].id`.
156
+
157
+ ### 3.1 A sheet-backed tile
158
+
159
+ The tile file holds the whole `data` object, or `create-tile` fills a left-out flag with the app's default (which turns the tile's own sort on). The example is a sparkline ([`cards.md`](cards.md) §2):
160
+
161
+ ```json
162
+ {"name": "", "subtitle": "", "footnotes": "",
163
+ "gridPlacements": {"absolute": {"x": 0, "y": 10, "w": 9, "h": 3}},
164
+ "style": {"showBackground": false, "hasShadow": false, "showBorder": false, "showFootnotes": false},
19
165
  "data": {"type": "SHEET_BACKED", "useDashboardSort": false, "useDashboardFilters": true, "useDashboardTimeline": false,
20
166
  "showTileSort": false, "showTileFilters": false, "showTileTimeline": false, "exportConfigurationId": null,
21
- "visualization": {"type": "TABLE"}}}
167
+ "visualization": {"type": "CHART"}}}
22
168
  ```
23
169
 
24
- For a chart, use this `visualization` instead: `{"type": "CHART", "chart": {"type": "LINE_CHART", "layout": "VERTICAL", "labels": {"labelOutline": false}, "spacing": {"barSpacing": 0, "integratedLegendX": 100, "integratedLegendY": 20}, "display": {"showValueAxis": true, "showLegend": true, "showIntegratedLegend": false, "integratedLegendPosition": "START"}, "series": {"transposeData": true}, "rowVisualizationByPath": {}, "columnVisualizationByPath": {}}}`.
25
- 4. **The tile's rows and columns** are sheet lines, one `POST /sheetLines` each. A row line lists a table's members: `{"sheetId": SHEET_ID, "parentId": null, "axis": "ROW", "type": "NUMBER", "name": "Product categories", "dimensionGenerationOptions": {"tableGids": [TABLE_GID], "hierarchyFlatten": false, "hierarchyMaxDepth": 0}}`. A column line is one variable at the members that filter it, such as a quarter, a version and a year: `{"sheetId": SHEET_ID, "parentId": null, "axis": "COLUMN", "type": "NUMBER", "name": "Net sales Q1 2025 Actual", "variableGid": VARIABLE_GID, "memberGids": [Q1_GID, ACTUAL_GID, Y2025_GID], "dimensionGenerationOptions": {"tableGids": [], "hierarchyFlatten": false, "hierarchyMaxDepth": 0}}`.
26
- 5. **A slicer** is a tile with `"data": {"type": "DIMENSION_SLICER", "dimensionTableId": TABLE_GID, "multiselect": true, "displayType": "NAME"}`, beside the dashboard's `rows.filters` entry for the same table.
27
- Steps 3 to 5 can go out from one script, which stops at the first refused write. `post` stands for the way your environment sends an API write:
170
+ `{"type": "TABLE"}` for a table, `{"type": "SINGLE_VALUE"}` for a KPI card. Then add its lines. A line is a variable at the members that scope it; a line without a variable takes the variable of the line on the other axis. The parts list each line as its name, variable and members, each member a `--member Table=Member`:
171
+
172
+ ```bash
173
+ SHEET=1160 # tile.sheet.id
174
+ line() { local out; out=$(farseer sheets create-line "$SHEET" --json "$@") || return 1
175
+ jq -e '.dropped == null' >/dev/null <<<"$out" || { echo "$out" >&2; return 1; }
176
+ jq -e '.line.id' <<<"$out"; }
28
177
 
29
- ```python
30
- tile = post("/api/v3/dashboards/DASHBOARD_ID/tiles", TABLE_TILE)
31
- sheet = tile["data"]["sheet"]["id"]
32
- for line in [ROW_LINE, *COLUMN_LINES]:
33
- post("/api/v3/sheetLines", {**line, "sheetId": sheet})
178
+ # PL: the plan member (§1, The plan); Acme has no Current budget, so it names the version
179
+ pl=$(line --axis row --name PL --variable "Net sales" --member Versions="Budget 2026" --member "Reporting period"="Current year")
180
+ ac=$(line --axis row --name "AC&FC" --variable "Net sales" --member "Reporting period"="Current forecast" --member "Reporting period"="Current year")
181
+ months=$(line --axis column --name Months --table Months)
34
182
  ```
35
183
 
36
- 6. **Check the values.** `POST /sheets/getData` with `{"path": "SHEET_ID", "includeData": true}` returns the tile's rows and columns with their numbers; `farseer sheets data` does not read a tile's sheet. Compare a cell or two with the same figures from `evaluate`. Also check that every row and column you sent came back with its variable, table or members: `POST /sheetLines` drops a gid it does not know and still answers 201, so a line made from a stale gid comes back empty.
184
+ - **A line that lists a table's members** is one line with `--table`, on either axis: rows (`--table "Department"`, one row per member) or columns (`--table Months`, one column per month; `--table Country` for a statement by country). New members show up by themselves. A table whose members have parents in the same table (a self-referencing hierarchy) keeps its tree, no flatten: `--hierarchy-max-depth 0` opens every level, N + 1 opens N levels under the top, and 1 gives the top level only (what a categorical chart wants). Flatten only a flat table. Levels that are separate tables linked by a foreign key (product groups and products) are not a tree: generate a parent line from the upper table and a child line under it from the lower one (`--parent-id`, `--hierarchy-flatten --hierarchy-max-depth 1`); each parent then opens to its own children. Generated table rows are ranked largest first by a sort formula ([`charts.md`](charts.md) §2), statement lines keep the model's order.
185
+ - **The 12 months** are always one generated column line from `Months`. The header shows each member's description ("Jan", "Mar" for a fiscal M1), or "1" to "12" where the members have none; that is fine.
186
+ - **A total next to generated columns** (FY next to the months, the group next to the countries) is its own column line after them, with `spacing.gridGap: 16` in its column visualization.
187
+ - A child line (`--parent-id`) inherits its parent's variable and members.
188
+ - A comparison column names line ids, so it comes whole from `--input`: `{"axis": "COLUMN", "type": "COMPARISON", "name": "ΔPL", "comparisonOptions": {"operation": "minus", "line1Id": AC_LINE, "line2Id": PL_LINE}}` (AC − PL); `"difference in %"` gives (AC − PL) / |PL|.
189
+ - A dimension belongs on either the row side or the column side, never on both with different members: the intersection is empty and the cell blank. A member filter inside a measure intersects with the line's members the same way ([`measures.md`](measures.md) §1). `Reporting period` members combine when they point at different tables (Current year and Current forecast), so they may sit on both sides; two that point at the same table (Current year and Prior year) give nothing.
190
+ - Never a Years filter on the page: it would blank every PY column, which reads the prior year.
191
+ - Lines render in creation order. Farseer drops a gid it does not know and still answers 201, and likewise a comparison operand that is not a line of the same sheet and axis; the command reads the line back and reports what it lost (`dropped` in `--json`), so a line that prints `dropped` is not the line you asked for.
192
+
193
+ ### 3.2 Keys
194
+
195
+ A visualization addresses lines by key. Take them from `farseer sheets data SHEET_ID --json`:
196
+
197
+ - **Chart rows:** `SHEET_LINE-0` (as in `1160_11637-0`). A generated row adds its member, `SHEET_LINE:MEMBER-0`, and the Other row of a top N is `SHEET_LINE:rest-0`.
198
+ - **Columns, and the series of a transposed chart:** `SHEET_LINE`; a generated column adds its member, `SHEET_LINE:MEMBER` (as in `1253_12551:12` for M1).
199
+ - **Table rows (`rowStyles`):** `SHEET_LINE`, a child `SHEET_PARENT_CHILD`, without the `-0` that `sheets data` prints: every row a generated line produces shares its style. A child's key comes from the line ids `farseer sheets lines` lists.
200
+ - **Table columns (`columnVisualizationByKey`):** `SHEET_LINE`, a generated column `SHEET_LINE:MEMBER`, plus `name` for the name column and `""` for the defaults.
201
+
202
+ The whole-sheet read returns top-level rows only. To read a parent's children, `POST /api/v3/sheets/getData` with `{"path": "<the row's key without -0>", "includeData": true}`, as `"1252_12534:135"`.
203
+
204
+ The parts write keys as `<line name>` for the whole `SHEET_LINE`: `<AC>-0` is the key of the line named AC with `-0` after it. A child adds its line id only: `<Net sales>_<id of Net sales accounts>` is `1160_11637_11640`. Then set the visualization in one `farseer dashboards update-tile ID TILE_ID --input visualization.json`, the file holding `{"data": {"visualization": {...}}}`. A chart visualization takes every key of its block (`type`, `layout`, `labels`, `spacing`, `display`, `series`, `rowVisualizationByPath`, `columnVisualizationByPath`), or the update is refused. `update-tile` deep-merges, so a restyle keeps stale keys: pass `--replace-keys visualization` to replace it whole, and `--replace-keys rawContent` for a text tile's content (a key is matched by name at any depth). A chart's root is `{"type": "CHART", "chart": {...}}` with the chart type in `chart.type` and always `"columnVisualizationByPath": {}`; a table's is `{"type": "TABLE", "table": {...}}`. A field placed on `visualization` itself is dropped.
205
+
206
+ ### 3.3 The ledger and undoing
207
+
208
+ Keep a ledger of what the build creates, a JSON file in your working folder that starts as `[]`. Right after each create returns, before the next write, append its entry, as in `jq '. += [{"type": "measure", "id": 2209, "name": "Net sales ΔPL"}]' LEDGER > tmp.json && mv tmp.json LEDGER`: each folder, dashboard, tile added to a dashboard that existed before (with its `dashboardId`), measure, stored variable (flags, series, LTM, denominators), member (with its `table`) and table. A dashboard you created takes its tiles and lines with it when deleted.
209
+
210
+ When a build fails and can't be finished, or the user asks to remove it, undo it from the ledger alone, newest entry first, and nothing else:
211
+
212
+ | type | Undo |
213
+ | --- | --- |
214
+ | dashboard | `farseer dashboards delete ID -y` |
215
+ | tile | `farseer dashboards delete-tile DASHBOARD_ID ID -y` |
216
+ | measure, variable | `farseer variables delete "NAME" -y`, after checking NAME still has this gid |
217
+ | member | `farseer dimensions delete-member --table "TABLE" --id ID -y` |
218
+ | table | `POST /api/v3/entities/mutate` with `{"deleted": [{"id": ID, "type": "DTAB"}]}` |
219
+ | folder | the CLI can't delete one: leave it empty and tell the user |
220
+
221
+ Fix a failed request first: a bare `BadRequest` is a payload that doesn't match ([`check.md`](check.md) §3), not a refusal. A block that still can't be built fails the page: undo rather than deliver a chart without its tiers.
222
+
223
+ ## 4. Order of a build
224
+
225
+ 1. Probe and settle (§1). For a write to the model or several pages, state the plan.
226
+ 2. Measures and members ([`measures.md`](measures.md)); for a page that follows the close, the reporting members and flags first ([`reporting-period.md`](reporting-period.md)). Read every new variable back before any tile reads it.
227
+ 3. The dashboard and its settings, then the header ([`page.md`](page.md)), with the message left empty.
228
+ 4. Per section: the heading, then the data tiles.
229
+ 5. Read every tile back (§5). Write the messages from what you read, then the footnotes.
230
+ 6. For the set: the cover page is created first and empty, and filled last; the Reporting setup page is created last of all. A build that creates `Reporting period` always builds the Reporting setup page, even for one chart, or nobody can move the close.
231
+
232
+ ## 5. Check and report
233
+
234
+ Before you report, run [`check.md`](check.md): every tile has its lines and values, a cell or two match `farseer formula eval` for the same slice, totals on cards equal the table totals, and every key in a visualization is one the data returns (a stale key styles nothing).
235
+
236
+ The report gives the summary first: the dashboard's name and id, its tiles in plain words, and in one line the measures and members created. Then at most six lines: the assumptions the user could object to, the scale note when tiers share one, and one closing line offering a walkthrough or a variant. The dashboard is the deliverable: no analysis of the numbers unless asked.
237
+
238
+ When the user asks how a tile was built, explain it the way they would find it in the app: the dashboard, the tile, Edit, the sheet's rows (generated from which table, or written by hand) and columns (which members, which measure), the column's visualization and the filters the tile follows. Name each measure with its formula in one line.
37
239
 
38
240
  ## Sheets
39
241
 
@@ -0,0 +1,59 @@
1
+ # KPI cards and sparklines
2
+
3
+ A row of cards, each with a sparkline under it. The card says where the KPI stands against the plan; the sparkline shows the shape of the year.
4
+
5
+ ## 1. Cards
6
+
7
+ A `SINGLE_VALUE` tile, h4, the row's width split evenly (5 cards 7/7/7/7/8, 4 cards 9 each, 3 cards 12 each). Its sheet has one row, the KPI, and two columns: the first is AC, the second what it is compared with.
8
+
9
+ | Line | Variable | Members |
10
+ | --- | --- | --- |
11
+ | row `Net sales` | the KPI | `Reporting period=Current year` |
12
+ | column `AC` | | `Versions=Actual` |
13
+ | column `PL` | | the plan version |
14
+
15
+ ```json
16
+ {"type": "SINGLE_VALUE", "singleValue": {"dataEntry": false, "comparisonCustomText": "vs PL YTD",
17
+ "format": {"type": "NUMBER", "unit": "THOUSANDS", "negatives": "SIGNED", "polarity": "POSITIVE", "currency": "EUR", "decimals": 0, "formatString": "#,##0,", "custom": false}}}
18
+ ```
19
+
20
+ - **The badge** is AC minus the second column, with its % of it. `comparisonCustomText` names the comparison and the period: "vs PL YTD", or "vs PL" for a balance, whose month end goes in the card name ("Cash at month end").
21
+ - **Against PY** when the KPI has no plan: the row takes no year, the columns are `[Versions=Actual, Reporting period=Current year]` and `[Versions=Actual, Reporting period=Prior year]`, the text "vs PY YTD". With neither, one column and no badge.
22
+ - **Polarity** `NEGATIVE` in `format` for costs and days, so an underspend turns the badge green.
23
+ - **Ratio cards** (margins, rates): the badge reads as a % of a %. Write "vs PL, points" in the text, or show the card without a badge.
24
+ - **Costs stored negative** read a magnitude measure, or the badge takes the sign of a negative plan.
25
+ - **A balance card** colours its badge although a balance has no good direction. Accept it and say so, or show it without a badge.
26
+ - **Values of five digits or more** take 0 decimals, or they truncate. A w7 card shows about six characters: a value in the millions in kEUR clips, so scale it to mEUR with one decimal and put the unit in the card name ("Net sales (mEUR)"). "vs PL YTD" fits a w7 card; "vs PL, month end" clips.
27
+ - **No signed zero.** AC and PL a few euros apart read "+0,0 (0,0%)": bind the second column to a guard measure instead of the version ([`measures.md`](measures.md) §3). The card hides the badge where that column is blank. The column then takes no member, and the row no year when the guard names it.
28
+ - The name is the KPI only, without a unit unless the card's differs from the page's. No subtitle, no footnote.
29
+ - **A result with a negative plan** (a loss-making EBITDA): the badge divides by the signed plan, so its % shows the wrong sign. Show the card without a badge, or compare as an amount in the text ("vs PL").
30
+
31
+ ## 2. Sparklines
32
+
33
+ One tile directly under each card, same x and w, h3, unnamed, no footnote.
34
+
35
+ | Line | Variable | Members |
36
+ | --- | --- | --- |
37
+ | row `PL` | the KPI | plan version, `Reporting period=Current year` |
38
+ | row `AC&FC` | the KPI | `Reporting period=Current forecast`, `Reporting period=Current year` |
39
+ | the 12 months (SKILL.md §3.1) | | |
40
+
41
+ The `AC&FC` row reads a forecast version that holds actuals to the last closed month and forecast after. When the forecast holds only its forecast months, the row reads an "AC&FC" measure without a version member ([`measures.md`](measures.md) §2). Without a forecast it is `AC` (`Versions=Actual`). Against PY, the first row is `PY` (`Versions=Actual`, `Reporting period=Prior year`).
42
+
43
+ ```json
44
+ {"type": "CHART", "chart": {"type": "LINE_CHART", "layout": "HORIZONTAL", "labels": {"showLabels": false},
45
+ "spacing": {"marginTop": 4, "barSpacing": 0, "marginLeft": 0, "marginRight": 0, "marginBottom": 0},
46
+ "display": {"showValueAxis": false, "showDomainAxis": false, "showLegend": false, "showIntegratedLegend": false, "domainAxisColor": "#FFFFFF"},
47
+ "series": {"groupByDepth": false, "transposeData": false, "keepEmptyValue": false, "keepEmptyDomain": false},
48
+ "rowVisualizationByPath": {
49
+ "<PL>-0": {"color": {"solid": "#C9C1D0", "colorBy": "STATIC", "pattern": "SOLID"}, "marker": "NONE", "labels": {"showLabels": false}},
50
+ "<AC&FC>-0": {"color": {"solid": "#3B2A47", "colorBy": "STATIC", "pattern": "SOLID"}, "marker": "NONE", "labels": {"showLabels": false}}},
51
+ "columnVisualizationByPath": {}}}
52
+ ```
53
+
54
+ - The base line can't be switched off, so it is painted white (`domainAxisColor`).
55
+ - The value axis starts at zero. A flat line on FTE or days is the truth; don't fake a zoomed axis.
56
+ - The measure is empty, not 0, outside its data, or the line drops to the base line after the last month.
57
+ - Sparklines follow the dashboard filters (`useDashboardFilters: true`), the period included: `Year to date` M8 draws the months to August.
58
+ - On a page filtered to one month (balance sheet, headcount), a sparkline that follows the filter has one point and draws nothing: there it sets `useDashboardFilters: false` and draws the whole year, ignoring the other filters too. Say so in your report.
59
+ - `shareAxis` only between cards in the same unit and order of magnitude (DSO, DIO, DPO, CCC), never across amounts like net sales and EBITDA.