@montytools/cli 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/monty.mjs +591 -255
- package/lib/schemaCodegen.mjs +27 -1
- package/package.json +1 -1
- package/skills/monty-build/SKILL.md +47 -28
- package/skills/monty-design/SKILL.md +123 -0
- package/skills/monty-operate/SKILL.md +7 -9
- package/template/AGENTS.md +50 -19
- package/template/package.json +1 -1
- package/template/src/index.css +35 -31
package/lib/schemaCodegen.mjs
CHANGED
|
@@ -58,6 +58,23 @@ function storedSource(spec, used) {
|
|
|
58
58
|
case "enum":
|
|
59
59
|
src = `z.enum(${JSON.stringify(spec.values)})`;
|
|
60
60
|
break;
|
|
61
|
+
case "multiSelect":
|
|
62
|
+
src = `z.array(z.enum(${JSON.stringify(spec.values)}))`;
|
|
63
|
+
break;
|
|
64
|
+
case "email":
|
|
65
|
+
src = "z.email()";
|
|
66
|
+
break;
|
|
67
|
+
case "url":
|
|
68
|
+
src = "z.url()";
|
|
69
|
+
break;
|
|
70
|
+
case "phone":
|
|
71
|
+
used.add("montyPhone");
|
|
72
|
+
src = "montyPhone()";
|
|
73
|
+
break;
|
|
74
|
+
case "rating":
|
|
75
|
+
used.add("montyRating");
|
|
76
|
+
src = "montyRating()";
|
|
77
|
+
break;
|
|
61
78
|
default:
|
|
62
79
|
// json: the manifest carries no deep shape (schemaJson owns storage
|
|
63
80
|
// validation) — z.any() keeps the field writable; refine by hand.
|
|
@@ -159,7 +176,16 @@ export function manifestToConfig(manifest, { name, icon } = {}) {
|
|
|
159
176
|
}
|
|
160
177
|
|
|
161
178
|
if (manifest.pages !== undefined) {
|
|
162
|
-
|
|
179
|
+
// Emit in declared nav order — the config's declaration order becomes
|
|
180
|
+
// pagesOrder on the next compile, so emission order must match it.
|
|
181
|
+
const orderedPages = {};
|
|
182
|
+
for (const name of manifest.pagesOrder ?? Object.keys(manifest.pages)) {
|
|
183
|
+
if (name in manifest.pages) orderedPages[name] = manifest.pages[name];
|
|
184
|
+
}
|
|
185
|
+
for (const [name, page] of Object.entries(manifest.pages)) {
|
|
186
|
+
if (!(name in orderedPages)) orderedPages[name] = page;
|
|
187
|
+
}
|
|
188
|
+
out.push(` pages: ${JSON.stringify(orderedPages, null, 2).replace(/\n/g, "\n ")},`);
|
|
163
189
|
}
|
|
164
190
|
|
|
165
191
|
if (manifest.datasets !== undefined) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: monty-build
|
|
3
|
-
description: Build, run, and
|
|
3
|
+
description: Build, run, and save Monty workspace apps. Use whenever the task involves a Monty app, monty.config.ts, the monty CLI (create/dev/logs/save/add), the @montytools/sdk, or a prompt mentioning usemonty.dev. Covers folder discipline, the build loop, data/auth rules, and error handling.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Building Monty apps
|
|
@@ -11,10 +11,11 @@ platform's job. The complete contract lives in the app's own `AGENTS.md`
|
|
|
11
11
|
(nearest-file-wins — read it before writing code). This skill is the map, not
|
|
12
12
|
the territory.
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
There is ONE copy of every app: **Live**, the cloud copy the team uses
|
|
15
|
+
(`monty save` updates it). While a dev **session** runs (a dev shell on
|
|
16
|
+
the app's LIVE records, often already started for you by the Monty desktop),
|
|
17
|
+
workspace admins see the session's version automatically — no publish, no
|
|
18
|
+
channel switch. "dev"/"prod" mean platform environments, never app states.
|
|
18
19
|
|
|
19
20
|
## Rules
|
|
20
21
|
|
|
@@ -23,45 +24,61 @@ names for them; "dev"/"prod" mean something else on this platform.
|
|
|
23
24
|
`monty login` first). `monty current` tells you where you are;
|
|
24
25
|
`cd "$(monty select <slug>)"` jumps to an app; `monty apps` lists local
|
|
25
26
|
ones. Never mkdir app folders by hand, and never edit the `id:` line in
|
|
26
|
-
`monty.config.ts`.
|
|
27
|
+
`monty.config.ts`. The folder IS the app's source: every file in it
|
|
28
|
+
rides the source snapshot on `monty save`, so never leave scratch files
|
|
29
|
+
here (manifest edits, notes, one-off scripts). Work in the OS temp dir
|
|
30
|
+
instead, or pipe — `monty schema | <edit> | monty schema set -` needs
|
|
31
|
+
no file at all — and delete anything temporary before saving.
|
|
27
32
|
2. **The loop:** `monty create <slug> --name "Name" --icon <tabler-icon>` →
|
|
28
33
|
(if the prompt includes a `build id`, pass it: `--build <id>` — the
|
|
29
34
|
workspace's New app screen tracks your progress live) →
|
|
30
|
-
`monty install` →
|
|
31
|
-
|
|
35
|
+
`monty install` → shape the schema through `monty schema` /
|
|
36
|
+
`monty schema set` (a brand-new app's very first session lands its
|
|
37
|
+
monty.config.ts once; after that the workspace owns the schema) + edit
|
|
38
|
+
`src/routes/` →
|
|
39
|
+
verify in the session: run `monty dev` once — if the dev shell is already
|
|
32
40
|
running (the Monty desktop usually runs it for you) it prints the status,
|
|
33
|
-
|
|
41
|
+
app URL, and recent log lines, then **exits immediately**; if nothing
|
|
34
42
|
is running it starts the shell (start it in the background and move on).
|
|
35
43
|
Then iterate: edit code → vite hot-reloads → `monty logs -n 50` shows
|
|
36
|
-
whether it compiled and any browser errors.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
whether it compiled and any browser errors. Re-running `monty dev` is
|
|
45
|
+
always safe — it attaches, prints status, and exits. Never try to run a
|
|
46
|
+
second dev *server* for the same app (attach handles this for you) and
|
|
47
|
+
never kill a dev shell you didn't start; `monty dev --takeover` is the
|
|
48
|
+
only sanctioned restart when a session is wedged. **You are not done
|
|
49
|
+
until you've saved: once the work is verified in the session, run
|
|
50
|
+
`monty save "<what changed>"`** — it builds, typechecks, and pushes the
|
|
51
|
+
working copy to the cloud copy, like `git push main`. Save after every
|
|
52
|
+
meaningful change, not just at the end; unsaved work exists only on this
|
|
53
|
+
machine.
|
|
45
54
|
3. **Everything through the CLI.** `monty install`, `monty build`,
|
|
46
|
-
`monty typecheck`, `monty dev`, `monty
|
|
55
|
+
`monty typecheck`, `monty dev`, `monty save` — never run vite, tsc,
|
|
47
56
|
pnpm, or npm scripts directly. `monty dev` auto-picks a free port and
|
|
48
57
|
prints it; `monty typecheck` builds first when needed. `monty logs`
|
|
49
58
|
(add `-f` to follow) is how you read the dev shell's output — vite build
|
|
50
|
-
errors, browser errors, and
|
|
59
|
+
errors, browser errors, and save results all land there.
|
|
51
60
|
4. **One import surface:** `@montytools/sdk` (`defineApp`, zod) and
|
|
52
61
|
`@montytools/sdk/react` (hooks: `useList`, `useInsert`, …). Never import
|
|
53
62
|
Clerk or Convex directly; never fetch external APIs from app code — the
|
|
54
63
|
platform CSP blocks them.
|
|
55
|
-
5. **
|
|
56
|
-
`
|
|
64
|
+
5. **The data schema lives in the WORKSPACE, not in code.** Read it with
|
|
65
|
+
`monty schema` (JSON on stdout); change it by editing that JSON and
|
|
66
|
+
running `monty schema set <file>` — validated server-side, additive by
|
|
67
|
+
default. On workspace-owned apps, `monty.config.ts` edits do NOT change
|
|
68
|
+
the schema. Declare a page in the manifest BEFORE shipping its route —
|
|
69
|
+
a save with an undeclared route refuses with the fix. Field names `_*`,
|
|
70
|
+
`updatedAt`, `createdBy` are reserved.
|
|
57
71
|
6. **UI is stock shadcn** (preset already wired). Add curated components with
|
|
58
72
|
`monty add <name>`; browse with `monty components` / `monty docs <name>`.
|
|
73
|
+
How pages should LOOK — Lyra surfaces, dark-only, the chart language — is
|
|
74
|
+
the `monty-design` skill; read it before styling any page.
|
|
59
75
|
7. **Errors are instructions.** Every failure prints
|
|
60
76
|
`[MontyError CODE] Fix: …` — do exactly what the Fix says; don't guess.
|
|
61
|
-
Typecheck failures block
|
|
62
|
-
8. **
|
|
63
|
-
|
|
64
|
-
real
|
|
77
|
+
Typecheck failures block the save by design.
|
|
78
|
+
8. **Edits are real.** The dev shell reads and writes the app's LIVE
|
|
79
|
+
records — there is one set of data, and every write journals into the
|
|
80
|
+
app's Activity. Exercise the app for real; clean up test rows you
|
|
81
|
+
create; never seed junk into a team's working tables.
|
|
65
82
|
|
|
66
83
|
## CLI reference
|
|
67
84
|
|
|
@@ -71,8 +88,10 @@ names for them; "dev"/"prod" mean something else on this platform.
|
|
|
71
88
|
| `monty create <slug>` | register the app in the workspace + stamp it into `~/.monty/apps/<id>` (needs login) |
|
|
72
89
|
| `monty current` / `select` / `apps` | where am I / jump to app / list local |
|
|
73
90
|
| `monty install` / `build` / `typecheck` | full lifecycle via the CLI — no raw pnpm/vite/tsc |
|
|
74
|
-
| `monty dev` | run the app
|
|
91
|
+
| `monty dev` | run the app's session, or attach to an already-running one (auto-port, live data, auto-auth) |
|
|
75
92
|
| `monty logs [-n N] [-f]` | read/follow the dev shell log — the debugging window after every edit |
|
|
76
93
|
| `monty add <name…>` | install curated shadcn components |
|
|
77
|
-
| `monty
|
|
94
|
+
| `monty schema [slug]` | print the app's stored manifest (tables, pages, metrics) as JSON |
|
|
95
|
+
| `monty schema set <file\|->` | write an edited manifest back (validated, CAS, additive by default) |
|
|
96
|
+
| `monty save ["what changed"]` | push the working copy to the cloud copy, like `git push main` (build + typecheck gate it) |
|
|
78
97
|
| `monty skills` | (re)install this skill for your agent |
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: monty-design
|
|
3
|
+
description: Design Monty app pages — Lyra shadcn styling (borderless, sharp-cornered, stock components only), dark-only theming, and the Monty chart language (square marks on real axes). Use whenever building or restyling UI in a Monty app; pages, dashboards, charts, stat tiles, KPI rows, tables, or any prompt about how a Monty app should look.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Designing Monty pages
|
|
7
|
+
|
|
8
|
+
Monty is a B2B work OS. Apps render inside the platform shell, so a page is
|
|
9
|
+
"designed" when it looks native to Monty: quiet, rectilinear, data-forward.
|
|
10
|
+
The design system is already installed — your job is to NOT fight it.
|
|
11
|
+
|
|
12
|
+
## The one law: stock Lyra, nothing invented
|
|
13
|
+
|
|
14
|
+
Every app ships shadcn preset `radix-lyra` (see `components.json`). Lyra
|
|
15
|
+
surfaces are **borderless and sharp-cornered**: `Card` is `rounded-none`,
|
|
16
|
+
no border, a `bg-card` fill with a hairline `ring-1 ring-foreground/10`.
|
|
17
|
+
|
|
18
|
+
- Use the components as they come: `Card`/`CardHeader`/`CardTitle`/
|
|
19
|
+
`CardDescription`/`CardContent`, `Table`, `Badge`, … Never rebuild a
|
|
20
|
+
surface as a styled `div` — a hand-rolled `rounded-xl border bg-…` card is
|
|
21
|
+
the canonical mistake.
|
|
22
|
+
- Never invent tokens or raw colors. Semantic tokens only (`bg-background`,
|
|
23
|
+
`text-muted-foreground`, `border-border`, `var(--chart-2)`, …).
|
|
24
|
+
- Sanctioned overrides are content-level only: e.g. `text-2xl tabular-nums`
|
|
25
|
+
on a stat value, a width on a label column. If an override styles a
|
|
26
|
+
SURFACE, you are off the system.
|
|
27
|
+
|
|
28
|
+
## Dark-only, in the shell's palette
|
|
29
|
+
|
|
30
|
+
The Monty shell is dark-only; a light page inside it reads as broken. The
|
|
31
|
+
app theme's `.dark` tokens mirror the shell palette (#101112 ground,
|
|
32
|
+
#17181A cards, #266DF0 primary) so embedded pages are seamless — never
|
|
33
|
+
retheme or hand-pick your own dark colors. Until
|
|
34
|
+
the template ships dark by default: `class="dark"` on `<html>` in
|
|
35
|
+
`index.html`, and any boot-splash background set to the dark `--background`
|
|
36
|
+
value. Verify your page against the shell, not in isolation.
|
|
37
|
+
|
|
38
|
+
## Page anatomy
|
|
39
|
+
|
|
40
|
+
Every page opens with the platform chrome from `@montytools/sdk/ui` — the
|
|
41
|
+
SAME components the shell renders system table views with, so a custom page
|
|
42
|
+
is indistinguishable from a record page. Never hand-roll the header bar.
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
import { PageHeader, PageHeaderButton } from "@montytools/sdk/ui";
|
|
46
|
+
|
|
47
|
+
<div className="flex h-full min-h-dvh flex-col bg-background">
|
|
48
|
+
<PageHeader icon={ChartColumn} title="Page title" meta="context (count, filter)">
|
|
49
|
+
<PageHeaderButton onClick={secondary}>Export</PageHeaderButton>
|
|
50
|
+
<PageHeaderButton primary onClick={main}><Plus className="size-3.5" /> New</PageHeaderButton>
|
|
51
|
+
</PageHeader>
|
|
52
|
+
<div className="min-h-0 flex-1 overflow-auto">
|
|
53
|
+
<div className="flex flex-col gap-3 p-6 pt-4">
|
|
54
|
+
{/* KPI row */}
|
|
55
|
+
<div className="grid grid-cols-[repeat(auto-fill,minmax(14rem,1fr))] gap-3">…</div>
|
|
56
|
+
{/* section cards */}
|
|
57
|
+
<div className="grid gap-3 lg:grid-cols-2">…</div>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Also in `@montytools/sdk/ui`: `FloatingBar` + `FloatingBarButton` (the
|
|
64
|
+
bottom-center bar for bulk-selection actions and mode strips) and the Lyra
|
|
65
|
+
table classes `SURFACE`/`THEAD`/`TH`/`ROW`/`CHIP` — record-like tables are
|
|
66
|
+
`<div className={SURFACE}><table>…` with those classes, identical to the
|
|
67
|
+
shell's Configuration surfaces.
|
|
68
|
+
|
|
69
|
+
A stat tile is a stock Card, nothing more:
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
<Card size="sm">
|
|
73
|
+
<CardHeader>
|
|
74
|
+
<CardDescription>Leads added</CardDescription>
|
|
75
|
+
<CardTitle className="text-2xl tabular-nums">{value}</CardTitle>
|
|
76
|
+
<div className="text-xs text-muted-foreground">{delta or context}</div>
|
|
77
|
+
</CardHeader>
|
|
78
|
+
</Card>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Charts: sharp marks on real axes
|
|
82
|
+
|
|
83
|
+
Chart marks are **sharp rectangles — no rounded corners, ever** (matches the
|
|
84
|
+
Lyra rectilinear look). The three failure modes to avoid: pill "track+fill"
|
|
85
|
+
bars (read as progress bars), rounded caps (misstate where a value ends),
|
|
86
|
+
and floating bars with no axis (nothing anchors the eye).
|
|
87
|
+
|
|
88
|
+
- **Horizontal bars**: grow from a left hairline baseline
|
|
89
|
+
(`border-l border-foreground/25`) over quarter gridlines
|
|
90
|
+
(`absolute left-1/4|1/2|3/4 border-l border-foreground/10` —
|
|
91
|
+
foreground-alpha so hairlines read on any surface), bar `h-4`,
|
|
92
|
+
fill `var(--chart-2)`. Label left in `text-muted-foreground`
|
|
93
|
+
(fixed-width, truncate); count right in `font-medium tabular-nums`,
|
|
94
|
+
zero values muted with no fill.
|
|
95
|
+
- **Columns**: a value axis with a baseline (`border-foreground/25`) plus
|
|
96
|
+
hairline gridlines (`border-foreground/10`) and tiny tabular tick labels (10px, muted,
|
|
97
|
+
right-aligned in a left gutter). Round the axis top to a "nice" integer
|
|
98
|
+
(≤4 exact; else the next multiple of 5/10/50) so ticks stay honest.
|
|
99
|
+
Direct value labels above non-zero columns.
|
|
100
|
+
- **Color**: one accent ramp from the Monty palette — `var(--chart-2)` for
|
|
101
|
+
the emphasized series (today, the selection), `var(--chart-5)` for
|
|
102
|
+
context. The values are the platform's (Attio-blue family, matching the
|
|
103
|
+
shell); never restate them as hex, never a hue per category, and text
|
|
104
|
+
never wears the data color.
|
|
105
|
+
- **Numbers**: `tabular-nums` everywhere values align; money via
|
|
106
|
+
`toLocaleString(undefined, { style: "currency", currency: "USD" })`
|
|
107
|
+
(compact notation on tiles, full in tables).
|
|
108
|
+
- **Empty states**: keep the axis and gridlines rendered with an honest
|
|
109
|
+
muted line ("No activity logged on this day.") — structure stays, zeros
|
|
110
|
+
carry meaning.
|
|
111
|
+
|
|
112
|
+
Reference implementations: `ColumnChart` and `BarRow` in
|
|
113
|
+
`demos/crm/src/routes/stats.tsx` (day-selector columns, status bars) and
|
|
114
|
+
`demos/crm-v2/src/routes/stats.tsx` (money detail on bars, top-deals table).
|
|
115
|
+
|
|
116
|
+
## Checklist before you call a page done
|
|
117
|
+
|
|
118
|
+
1. No `border`/`rounded-*` on any surface you authored — surfaces are stock
|
|
119
|
+
Lyra components.
|
|
120
|
+
2. No rounded corners on any chart mark; every bar/column sits on an axis.
|
|
121
|
+
3. Dark: the page blends into the shell with no light seams.
|
|
122
|
+
4. Values in tabular figures; labels in text tokens; one accent hue.
|
|
123
|
+
5. Screenshot it inside the shell (`/apps/<slug>/…`), not just the dev port.
|
|
@@ -11,10 +11,8 @@ and write that data directly from the terminal: no browser session, no dev
|
|
|
11
11
|
server. You do the work (browse, scrape, decide, transform); the app is
|
|
12
12
|
where the results land, and open app tabs update live as you write.
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
seen by the team). Writing to Live is normal operating work; that is what
|
|
17
|
-
this command is for.
|
|
14
|
+
One set of records per app — the team's real data. Writing to it is
|
|
15
|
+
normal operating work; that is what this command is for.
|
|
18
16
|
|
|
19
17
|
## The loop
|
|
20
18
|
|
|
@@ -43,10 +41,10 @@ this command is for.
|
|
|
43
41
|
2. **Schema first, rows second.** Field names come from
|
|
44
42
|
`monty data schema`, exact spelling. The server stores what you send —
|
|
45
43
|
a misspelled field is silently a new field, not an error.
|
|
46
|
-
3. **
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
3. **Every write is real** — operating work targets the team's data, and
|
|
45
|
+
the app's Activity journals it. Destructive verbs (`remove`, bulk
|
|
46
|
+
`update`) deserve a confirmation with the user unless they clearly
|
|
47
|
+
asked for the cleanup.
|
|
50
48
|
4. **Batch with arrays.** `--data` accepts a single object or an array;
|
|
51
49
|
arrays write row by row and return all ids in order.
|
|
52
50
|
5. **Paginate honestly.** `list` returns `"cursor": null` when complete; a
|
|
@@ -72,7 +70,7 @@ this command is for.
|
|
|
72
70
|
| `monty data update <table> <id> --data '<json>' [--unset a,b]` | shallow-merge onto one row; `--unset` deletes fields |
|
|
73
71
|
| `monty data remove <table> <id>` | delete one row |
|
|
74
72
|
|
|
75
|
-
All verbs take `--app <slug
|
|
73
|
+
All verbs take `--app <slug>`. Output is one JSON document on
|
|
76
74
|
stdout.
|
|
77
75
|
|
|
78
76
|
## Example: import scraped leads into a CRM app
|
package/template/AGENTS.md
CHANGED
|
@@ -31,9 +31,16 @@ Folders are managed for you: this app lives in `~/Monty/<slug>`. `monty current`
|
|
|
31
31
|
Icons from `lucide-react`. Don't install other component libraries or
|
|
32
32
|
write raw-color CSS — use semantic tokens (`bg-background`,
|
|
33
33
|
`text-muted-foreground`, …). Don't edit `src/index.css` theme tokens.
|
|
34
|
+
The look is Lyra: surfaces are stock components — borderless,
|
|
35
|
+
sharp-cornered — never hand-styled divs; chart marks are sharp
|
|
36
|
+
rectangles on real axes. The `monty-design` skill is the full spec.
|
|
34
37
|
4. **Schema changes = edit `monty.config.ts` and save.** Types update
|
|
35
38
|
immediately. Prefer additive changes; give new fields `.optional()` or
|
|
36
39
|
`.default(...)` so existing records stay readable.
|
|
40
|
+
5. **You are not done until the work is saved.** After every meaningful
|
|
41
|
+
change verified in dev, run `monty save "<what changed>"` — it builds,
|
|
42
|
+
typechecks, and pushes the working copy to the cloud copy, like
|
|
43
|
+
`git push main`. Unsaved work exists only on this machine.
|
|
37
44
|
|
|
38
45
|
## Data: define, then use
|
|
39
46
|
|
|
@@ -95,7 +102,7 @@ const { url } = useFileUrl(app, row.receipt); // authenticated blob:
|
|
|
95
102
|
## Derived fields, metrics, pages (V2 — the platform renders these)
|
|
96
103
|
|
|
97
104
|
Your config can carry a whole database app the platform shell renders for
|
|
98
|
-
you — system table views, record drawers
|
|
105
|
+
you — system table views, record drawers — no React needed.
|
|
99
106
|
This SPA scaffold exists for the pages that ARE bespoke (`pages` entries
|
|
100
107
|
with `kind: "custom"` mount your routes inside that shell).
|
|
101
108
|
|
|
@@ -127,12 +134,11 @@ export const app = defineApp({
|
|
|
127
134
|
closedAt: montyDate().optional(),
|
|
128
135
|
}),
|
|
129
136
|
},
|
|
130
|
-
metrics: { // app-level named numbers
|
|
137
|
+
metrics: { // app-level named numbers formulas reach as `metrics.wonThisMonth`
|
|
131
138
|
wonThisMonth: rollup(montyMoney(), { from: "sales", where: { status: "won" }, sum: "amount", over: "closedAt", range: "currentMonth" }),
|
|
132
139
|
},
|
|
133
140
|
pages: {
|
|
134
141
|
people: { kind: "view", table: "people", summaries: { monthlySales: "sum" } },
|
|
135
|
-
overview: { kind: "dashboard", metrics: ["wonThisMonth"] },
|
|
136
142
|
reports: { kind: "custom", path: "/reports" }, // ← your src/routes/reports.tsx
|
|
137
143
|
},
|
|
138
144
|
});
|
|
@@ -140,6 +146,32 @@ export const app = defineApp({
|
|
|
140
146
|
|
|
141
147
|
Rules that matter:
|
|
142
148
|
|
|
149
|
+
- **Custom pages wear the platform chrome from `@montytools/sdk/ui`** — the
|
|
150
|
+
SAME components the shell renders its own pages with, so your page is
|
|
151
|
+
indistinguishable from a system table view. Every custom page opens with
|
|
152
|
+
`PageHeader`; without it the page looks foreign beside record pages:
|
|
153
|
+
|
|
154
|
+
```tsx
|
|
155
|
+
import { PageHeader, PageHeaderButton } from "@montytools/sdk/ui";
|
|
156
|
+
|
|
157
|
+
<div className="flex h-full min-h-dvh flex-col">
|
|
158
|
+
<PageHeader icon={ChartColumn} title="Reports" meta="42 rows">
|
|
159
|
+
<PageHeaderButton onClick={exportCsv}>Export</PageHeaderButton>
|
|
160
|
+
<PageHeaderButton primary onClick={openNew}>
|
|
161
|
+
<Plus className="size-3.5" /> New
|
|
162
|
+
</PageHeaderButton>
|
|
163
|
+
</PageHeader>
|
|
164
|
+
<main className="min-h-0 flex-1 overflow-auto p-6">…</main>
|
|
165
|
+
</div>
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
`primary` marks the page's one main action; other actions wear the quiet
|
|
169
|
+
control style; `icon` is any lucide icon (defaults to the custom-page
|
|
170
|
+
puzzle mark the sidebar uses). Also there: `FloatingBar` +
|
|
171
|
+
`FloatingBarButton` (the bottom-center bar for bulk-selection actions and
|
|
172
|
+
mode strips) and the Lyra table classes `SURFACE`/`THEAD`/`TH`/`ROW`/`CHIP`
|
|
173
|
+
for record-like tables (`<div className={SURFACE}><table>…`), identical to
|
|
174
|
+
the app's Configuration surfaces.
|
|
143
175
|
- **Formulas are strings**, not functions — the Monty expression grammar
|
|
144
176
|
(`+ - * / %`, comparisons, `&& || !`, `IF/ROUND/ABS/MIN/MAX`,
|
|
145
177
|
`metrics.<name>`). A formula sees only fields declared ABOVE it. Type
|
|
@@ -183,7 +215,7 @@ When logic must not run in the browser (private tables, third-party APIs with
|
|
|
183
215
|
secret keys, webhooks, clocks), create `server/index.ts` with named async
|
|
184
216
|
exports. Web-standard APIs only (`fetch`, `crypto`, `URL`, …) — no `node:`
|
|
185
217
|
imports; it runs on Cloudflare Workers when Live and inside `monty dev` in
|
|
186
|
-
|
|
218
|
+
a session. Every export gets `ctx`: `ctx.records` (full CRUD on all your
|
|
187
219
|
tables, including ones the UI never exposes), `ctx.secrets` (see below),
|
|
188
220
|
`ctx.viewer` (who called: member session/visitor/schedule/none), and
|
|
189
221
|
`ctx.track()` (emit an event).
|
|
@@ -227,10 +259,10 @@ Public functions are NOT callable through `useServerFn` — only at their
|
|
|
227
259
|
public).
|
|
228
260
|
|
|
229
261
|
**Secrets:** `monty secret set STRIPE_KEY` stores a key for Live (write-only,
|
|
230
|
-
never in code or config). In
|
|
231
|
-
`.monty/secrets.json`. Both arrive as `ctx.secrets.STRIPE_KEY`.
|
|
262
|
+
never in code or config). In a dev session, put the same names in the
|
|
263
|
+
gitignored `.monty/secrets.json`. Both arrive as `ctx.secrets.STRIPE_KEY`.
|
|
232
264
|
|
|
233
|
-
**
|
|
265
|
+
**Session behavior:** `monty dev` runs your schedules for real (a `cron:` line
|
|
234
266
|
prints per firing, UTC) and serves public functions at
|
|
235
267
|
`http://localhost:<port>/__monty/public/<name>` — curl them to test.
|
|
236
268
|
|
|
@@ -247,25 +279,24 @@ monty dev # Vite + HMR, auto-picks a free port and prints it
|
|
|
247
279
|
Headless? Verify with `monty build` then `monty typecheck` (typecheck builds
|
|
248
280
|
first when needed — the build generates `src/routeTree.gen.ts`).
|
|
249
281
|
|
|
250
|
-
**
|
|
251
|
-
|
|
252
|
-
(tunneled
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
`monty deploy` directly if the user explicitly asks.
|
|
282
|
+
**One live app:** there is ONE copy of the app — the one the team uses.
|
|
283
|
+
While `monty dev` runs, workspace admins see your running session's
|
|
284
|
+
version automatically (tunneled); everyone else
|
|
285
|
+
keeps the saved copy. After every meaningful change verified in dev, run
|
|
286
|
+
`monty save "<what changed>"` — it pushes the work to the cloud copy,
|
|
287
|
+
like `git push main` (build + typecheck gate it, so nothing uncompilable
|
|
288
|
+
ever ships). Leave `monty dev` running while you work.
|
|
258
289
|
|
|
259
290
|
**Driving your app in a browser (agents):** while `monty dev` runs, opening
|
|
260
291
|
`http://localhost:5173` is ALREADY AUTHENTICATED — no sign-in screen (the dev
|
|
261
292
|
server mints short-lived workspace tokens from the CLI login). Point
|
|
262
293
|
Playwright or any browser automation at it, click through your app against
|
|
263
|
-
reactive
|
|
294
|
+
reactive live data, and read your errors in the `monty dev` terminal
|
|
264
295
|
(`[browser:error] …` lines). Edit → HMR → look → fix: verify your own work.
|
|
265
296
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
badge
|
|
297
|
+
The session reads and writes the app's REAL records — there is one set
|
|
298
|
+
of data, and every write journals into the app's Activity. Treat edits as
|
|
299
|
+
real edits; the "SESSION · … · live data" badge reminds you.
|
|
269
300
|
|
|
270
301
|
## Modeling tips
|
|
271
302
|
|
package/template/package.json
CHANGED
package/template/src/index.css
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
@import "shadcn/tailwind.css";
|
|
4
4
|
@import "@fontsource-variable/roboto";
|
|
5
5
|
|
|
6
|
+
/* Shared platform chrome (@montytools/sdk/ui) ships Tailwind classes in its
|
|
7
|
+
dist — scan it so they compile. */
|
|
8
|
+
@source "../node_modules/@montytools/sdk/dist/ui.js";
|
|
9
|
+
|
|
6
10
|
|
|
7
11
|
@custom-variant dark (&:is(.dark *));
|
|
8
12
|
|
|
@@ -85,37 +89,37 @@
|
|
|
85
89
|
}
|
|
86
90
|
|
|
87
91
|
.dark {
|
|
88
|
-
--background:
|
|
89
|
-
--foreground:
|
|
90
|
-
--card:
|
|
91
|
-
--card-foreground:
|
|
92
|
-
--popover:
|
|
93
|
-
--popover-foreground:
|
|
94
|
-
--primary:
|
|
95
|
-
--primary-foreground:
|
|
96
|
-
--secondary:
|
|
97
|
-
--secondary-foreground:
|
|
98
|
-
--muted:
|
|
99
|
-
--muted-foreground:
|
|
100
|
-
--accent:
|
|
101
|
-
--accent-foreground:
|
|
102
|
-
--destructive: oklch(0.
|
|
103
|
-
--border:
|
|
104
|
-
--input:
|
|
105
|
-
--ring:
|
|
106
|
-
--chart-1:
|
|
107
|
-
--chart-2:
|
|
108
|
-
--chart-3:
|
|
109
|
-
--chart-4:
|
|
110
|
-
--chart-5:
|
|
111
|
-
--sidebar:
|
|
112
|
-
--sidebar-foreground:
|
|
113
|
-
--sidebar-primary:
|
|
114
|
-
--sidebar-primary-foreground:
|
|
115
|
-
--sidebar-accent:
|
|
116
|
-
--sidebar-accent-foreground:
|
|
117
|
-
--sidebar-border:
|
|
118
|
-
--sidebar-ring:
|
|
92
|
+
--background: #101112;
|
|
93
|
+
--foreground: #F1F2F3;
|
|
94
|
+
--card: #17181A;
|
|
95
|
+
--card-foreground: #F1F2F3;
|
|
96
|
+
--popover: #17181A;
|
|
97
|
+
--popover-foreground: #F1F2F3;
|
|
98
|
+
--primary: #266DF0;
|
|
99
|
+
--primary-foreground: #FFFFFF;
|
|
100
|
+
--secondary: rgb(255 255 255 / 0.05);
|
|
101
|
+
--secondary-foreground: #F1F2F3;
|
|
102
|
+
--muted: rgb(255 255 255 / 0.05);
|
|
103
|
+
--muted-foreground: rgb(255 255 255 / 0.6);
|
|
104
|
+
--accent: rgb(255 255 255 / 0.05);
|
|
105
|
+
--accent-foreground: #F1F2F3;
|
|
106
|
+
--destructive: oklch(0.68 0.19 25);
|
|
107
|
+
--border: #1B1C1F;
|
|
108
|
+
--input: #212224;
|
|
109
|
+
--ring: #266DF0;
|
|
110
|
+
--chart-1: #266DF0;
|
|
111
|
+
--chart-2: #4E8CFC;
|
|
112
|
+
--chart-3: #9B69FF;
|
|
113
|
+
--chart-4: #6EA5F7;
|
|
114
|
+
--chart-5: #2D3A55;
|
|
115
|
+
--sidebar: #101112;
|
|
116
|
+
--sidebar-foreground: #F1F2F3;
|
|
117
|
+
--sidebar-primary: #266DF0;
|
|
118
|
+
--sidebar-primary-foreground: #FFFFFF;
|
|
119
|
+
--sidebar-accent: rgb(255 255 255 / 0.05);
|
|
120
|
+
--sidebar-accent-foreground: #F1F2F3;
|
|
121
|
+
--sidebar-border: #1B1C1F;
|
|
122
|
+
--sidebar-ring: #266DF0;
|
|
119
123
|
}
|
|
120
124
|
|
|
121
125
|
@layer base {
|