@topy-ai/maggie 0.7.37 → 0.7.40

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 (67) hide show
  1. package/README-zh-TW.md +65 -7
  2. package/README.md +80 -11
  3. package/bin/maggie.js +10 -2
  4. package/bundled-contracts/maggie-design/css-utility-evidence-v1.schema.json +10 -0
  5. package/bundled-contracts/maggie-design/dashboard-surface-v1.schema.json +11 -0
  6. package/bundled-contracts/maggie-design/progressive-enhancement-v1.schema.json +12 -0
  7. package/bundled-contracts/maggie-design/sample-surface-v1.schema.json +13 -0
  8. package/bundled-contracts/maggie-seo/privacy-origin-evidence-v1.schema.json +11 -0
  9. package/bundled-contracts/maggiedash/README.md +1 -1
  10. package/bundled-contracts/maggiedash/booking-access-v1.json +5 -4
  11. package/bundled-contracts/maggiedash/booking-customer-surface-v1.json +12 -1
  12. package/bundled-contracts/maggiedash/booking-email-templates-v1.json +2 -0
  13. package/bundled-contracts/maggiedash/booking-host-adapter-v1.json +16 -2
  14. package/bundled-contracts/maggiedash/booking-runtime.v1.json +41 -0
  15. package/bundled-contracts/maggiedash/execution-board.json +529 -28
  16. package/bundled-contracts/maggiedash/host-capabilities-v1.schema.json +10 -0
  17. package/bundled-contracts/maggiedash/site-structure-v1.schema.json +13 -0
  18. package/bundled-references/maggiedash-booking/ARCHITECTURE.md +218 -0
  19. package/bundled-references/maggiedash-booking/CURRENT-STATE.md +92 -0
  20. package/bundled-references/maggiedash-booking/DATA-FLOW.md +143 -0
  21. package/bundled-references/maggiedash-booking/DATA-MODEL.md +367 -0
  22. package/bundled-references/maggiedash-booking/DECISIONS.md +94 -0
  23. package/bundled-references/maggiedash-booking/EXECUTION-BOARD.json +2387 -0
  24. package/bundled-references/maggiedash-booking/HOST-ADAPTER.md +314 -0
  25. package/bundled-references/maggiedash-booking/ORAWELLNESS-INTEGRATION-AUDIT.md +227 -0
  26. package/bundled-references/maggiedash-booking/PAYMENT-GATEWAY.md +267 -0
  27. package/bundled-references/maggiedash-booking/PRD.md +228 -0
  28. package/bundled-references/maggiedash-booking/PROGRESS.md +2434 -0
  29. package/bundled-references/maggiedash-booking/QA-TEST-PLAN.md +235 -0
  30. package/bundled-references/maggiedash-booking/README.md +271 -0
  31. package/bundled-references/maggiedash-booking/RUNTIME-OPERATIONS.md +152 -0
  32. package/bundled-references/maggiedash-booking/SECURITY-COMPLIANCE.md +158 -0
  33. package/bundled-references/maggiedash-booking/SKILLS-AND-CLI.md +542 -0
  34. package/bundled-references/maggiedash-booking/STRIPE-INTEGRATION.md +129 -0
  35. package/bundled-references/maggiedash-booking/TASK-RUNBOOK.md +107 -0
  36. package/bundled-references/maggiedash-booking/TASKS.md +137 -0
  37. package/bundled-references/maggiedash-booking/USER-JOURNEYS.md +224 -0
  38. package/bundled-references/maggiedash-booking/diagrams/booking-dfd.excalidraw +1 -0
  39. package/bundled-references/maggiedash-booking/diagrams/booking-dfd.mmd +16 -0
  40. package/bundled-references/maggiedash-booking/diagrams/booking-dfd.png +0 -0
  41. package/bundled-references/maggiedash-booking/diagrams/booking-dfd.svg +1 -0
  42. package/bundled-references/maggiedash-booking/diagrams/booking-state-machine.mmd +19 -0
  43. package/bundled-references/maggiedash-booking/diagrams/booking-state-machine.png +0 -0
  44. package/bundled-references/maggiedash-booking/diagrams/booking-state-machine.svg +1 -0
  45. package/bundled-references/maggiedash-booking/diagrams/manager-journey.excalidraw +1 -0
  46. package/bundled-references/maggiedash-booking/diagrams/manager-journey.mmd +11 -0
  47. package/bundled-references/maggiedash-booking/diagrams/manager-journey.png +0 -0
  48. package/bundled-references/maggiedash-booking/diagrams/manager-journey.svg +1 -0
  49. package/bundled-references/maggiedash-booking/diagrams/payment-sequence.mmd +20 -0
  50. package/bundled-references/maggiedash-booking/diagrams/payment-sequence.png +0 -0
  51. package/bundled-references/maggiedash-booking/diagrams/payment-sequence.svg +1 -0
  52. package/bundled-references/maggiedash-booking/diagrams/system-context.excalidraw +1 -0
  53. package/bundled-references/maggiedash-booking/diagrams/system-context.mmd +10 -0
  54. package/bundled-references/maggiedash-booking/diagrams/system-context.png +0 -0
  55. package/bundled-references/maggiedash-booking/diagrams/system-context.svg +1 -0
  56. package/bundled-skills/maggie-blog-bootstrap/SKILL.md +16 -0
  57. package/bundled-skills/maggie-booking/SKILL.md +103 -22
  58. package/bundled-skills/maggie-design/SKILL.md +35 -0
  59. package/bundled-skills/maggie-seo-geo/SKILL.md +12 -0
  60. package/bundled-skills/maggie-service-booking/SKILL.md +14 -0
  61. package/bundled-tools/clis/maggie_booking.py +231 -31
  62. package/bundled-tools/clis/maggie_contracts.py +282 -0
  63. package/bundled-tools/clis/maggie_dash.py +28 -6
  64. package/bundled-tools/clis/maggie_design.py +29 -12
  65. package/bundled-tools/clis/maggie_service_booking.py +50 -1
  66. package/bundled-tools/clis/site_audit.py +49 -0
  67. package/package.json +1 -1
@@ -11,22 +11,30 @@ for importing a provider's service catalogue. The existing
11
11
  right choice for provider-backed services, prices, durations, booking links,
12
12
  and factual provider validation.
13
13
 
14
+ ## Project memory
15
+
16
+ Before changing a host project, follow the shared
17
+ [`memory-hook.md`](../../references/memory-hook.md) instructions for reading
18
+ relevant project preferences and known pitfalls. After a verified fix or a
19
+ durable host decision, record only the generalizable learning; never promote a
20
+ temporary project detail, secret, or unverified guess into active memory.
21
+
14
22
  ## Contract and safety boundary
15
23
 
16
- Read [`../../docs/maggiedash-booking/README.md`](../../docs/maggiedash-booking/README.md),
17
- [`TASKS.md`](../../docs/maggiedash-booking/TASKS.md), and the task's linked
24
+ Read [`../../bundled-references/maggiedash-booking/README.md`](../../bundled-references/maggiedash-booking/README.md),
25
+ [`TASKS.md`](../../bundled-references/maggiedash-booking/TASKS.md), and the task's linked
18
26
  reference before changing code. MaggieDash owns the manager UI and versioned
19
27
  contracts. The host owns routes, traditional email/password sessions,
20
28
  PostgreSQL connection/transaction lifetime, tenant authorization, provider
21
29
  credentials, payment webhooks, notifications, and deployment. MaggieDash also
22
- ships a tenant-scoped PostgreSQL manager repository for catalogue, availability,
30
+ ships a tenant-scoped PostgreSQL manager repository for catalogue, treatment packages, availability,
23
31
  booking, customer, configuration, schedule, health, audit, hold, and lifecycle
24
32
  persistence; it does not replace host connection ownership or payment/public-
25
33
  checkout adapters.
26
34
 
27
35
  For implementation work, use the leaf board and runbook:
28
- [`EXECUTION-BOARD.json`](../../docs/maggiedash-booking/EXECUTION-BOARD.json)
29
- and [`TASK-RUNBOOK.md`](../../docs/maggiedash-booking/TASK-RUNBOOK.md). Do not
36
+ [`EXECUTION-BOARD.json`](../../bundled-references/maggiedash-booking/EXECUTION-BOARD.json)
37
+ and [`TASK-RUNBOOK.md`](../../bundled-references/maggiedash-booking/TASK-RUNBOOK.md). Do not
30
38
  mark a task passed until its implementation gate, docs update, and evidence
31
39
  record are complete.
32
40
 
@@ -69,7 +77,7 @@ It applies the host-only evidence rule; fixture, test, and local environments
69
77
  cannot satisfy a required operational release artifact.
70
78
 
71
79
  For local CLI regression, the sanitized no-customer fixture is
72
- [`fixtures/maggiedash/booking-runtime.v1.json`](../../fixtures/maggiedash/booking-runtime.v1.json).
80
+ [`fixtures/maggiedash/booking-runtime.v1.json`](../../bundled-contracts/maggiedash/booking-runtime.v1.json).
73
81
 
74
82
  Install the first-party workspace and the host integration through the stable
75
83
  Booking installer:
@@ -88,13 +96,29 @@ maggie booking install --project . --confirm --install-dependencies
88
96
 
89
97
  This is an explicit dependency mutation. It preserves existing package
90
98
  versions, updates the matching lockfile, and never installs a second copy of a
91
- package already present in `dependencies` or `devDependencies`.
99
+ package already present in `dependencies` or `devDependencies`. For a blank
100
+ Astro host it also adds the compatible `@astrojs/node` SSR adapter and the
101
+ portable server config; an existing `astro.config.*` and deployment adapter
102
+ remain host-owned.
103
+
104
+ For a new host with an approved database migration, `--ready` combines the two
105
+ explicit setup mutations into one command:
106
+
107
+ ```bash
108
+ maggie booking install --project . --confirm --ready
109
+ ```
110
+
111
+ It installs only missing host packages, generates `BOOKING_TOKEN_SECRET` when
112
+ needed, and applies the installed idempotent Booking schema. It still does not
113
+ create the owner, configure Stripe, send email, enable a scheduler, or deploy.
114
+ Use `--schedule systemd` or `--schedule cron` with `--ready` only to generate a
115
+ reviewable scheduler artifact; enabling it remains an operator action after
116
+ backup, migration, and release evidence checks.
92
117
 
93
- The default installer source is the public MaggieDash distribution. It must
94
- contain the released Astro `hostBootstrap` manifest and 39-route Booking
95
- source. While validating an unreleased local checkout, pass
96
- `--source /home/balalior/Dev/MaggieDash`; do not present a local-source result
97
- as proof that the public npm install path is released.
118
+ The default installer source is the public MaggieDash `0.2.8` distribution. It
119
+ contains the released Astro `hostBootstrap` manifest and 47-route Booking
120
+ source, including the tenant-scoped treatment package catalogue. A fresh public-source install, `maggie booking inspect`, and
121
+ `astro build` are the release evidence; a local-source result alone is not.
98
122
 
99
123
  For a new host with a reviewed `DATABASE_URL`, the explicit one-command
100
124
  bootstrap also applies the idempotent Booking schema:
@@ -112,6 +136,21 @@ characters fails closed. External secret stores must provision the same key
112
136
  separately. Bootstrap still does not create the owner, configure Stripe, send
113
137
  email, or deploy.
114
138
 
139
+ Generate the reviewed worker scheduler artifact as part of the same install,
140
+ or after an existing install:
141
+
142
+ ```bash
143
+ maggie booking install --project . --confirm --bootstrap --schedule systemd
144
+ # or, for a host without systemd:
145
+ maggie booking worker-schedule --project . --scheduler cron --confirm
146
+ ```
147
+
148
+ This writes `deploy/maggie-booking-worker.service` plus `.timer`, or a
149
+ reviewable `deploy/maggie-booking-worker.cron`. It does not edit the crontab,
150
+ enable systemd, start a process, or expose secrets. Review the generated
151
+ artifact, set an unprivileged service user, then enable it only after the
152
+ schema, backup/restore, and release evidence gates pass.
153
+
115
154
  Before changing host configuration, run the safe first-run checklist:
116
155
 
117
156
  ```bash
@@ -147,16 +186,19 @@ Validate the tenant-scoped Resend template boundary independently:
147
186
  maggie booking email-templates-contract
148
187
  ```
149
188
 
150
- This freezes the seven supported Booking events, approved `{{variable}}`
189
+ This freezes the ten supported Booking events, approved `{{variable}}`
151
190
  placeholders, owner/admin/manager access, audit and idempotency requirements,
152
191
  and the server-only provider/recipient privacy boundary. It does not connect to
153
192
  Resend, send a message, or expose customer data.
154
193
 
155
194
  After the first owner signs in, the Booking Overview includes the same
156
195
  secret-safe readiness path: Stripe connection status, test/live mode, and a
157
- copyable `/api/maggie/booking/webhooks/stripe` URL. It gives the operator the
158
- next secret-store action without accepting or storing Stripe credentials in the
159
- browser or Booking database.
196
+ copyable `/api/maggie/booking/webhooks/stripe` URL. The preferred path is still
197
+ the deployment secret store. For a single-business host, an owner or manager
198
+ may submit both Stripe values over HTTPS from this screen; the server verifies
199
+ them first, stores only authenticated AES-256-GCM ciphertext derived from
200
+ `BOOKING_TOKEN_SECRET`, and never returns the raw values. Deployment
201
+ `STRIPE_SECRET_KEY` takes precedence over dashboard-managed credentials.
160
202
 
161
203
  For an Astro host, framework detection installs missing email/password login,
162
204
  first-owner registration, manager/public Booking routes, PostgreSQL/Stripe
@@ -169,9 +211,11 @@ the UI. Use `--host astro` to make detection explicit;
169
211
  use `--host none` when only the source distribution is wanted. The
170
212
  distribution keeps the content admin at `./_maggie/admin` and Booking source at
171
213
  `./_maggie/booking`. Existing files, including an existing `src/middleware.ts`,
172
- are preserved unless `--force` is explicitly supplied. A conventional Astro
173
- middleware receives the rewrite block automatically; unsupported middleware is
174
- preserved and reported by `maggie booking inspect` until integrated manually.
214
+ are preserved unless `--force` is explicitly supplied. Conventional Astro
215
+ middleware using either `defineMiddleware((context, next) => {})` or a
216
+ destructured context such as `defineMiddleware(({ url, request }, next) => {})`
217
+ receives the rewrite block automatically; unsupported middleware is preserved
218
+ and reported by `maggie booking inspect` until integrated manually.
175
219
  Installation does not apply SQL, create an owner, or enable a payment provider.
176
220
  The standard Booking migration must create
177
221
  `maggiedash_booking_user_roles`; do not move that table into a project-only
@@ -231,18 +275,48 @@ allocation by the same time delta, checks each staff/resource interval, and
231
275
  preserves the original total duration. Single-treatment requests and legacy
232
276
  rows remain compatible. Public DTOs expose only safe segment fields.
233
277
 
278
+ When a tenant has multiple online-bookable locations, the public catalogue must
279
+ return a safe `locations` list and the customer page must let the customer pick
280
+ one. Include the selected `locationId` in availability, waitlist, hold,
281
+ checkout, and reschedule requests. Availability must validate that the
282
+ location belongs to the tenant, is active and online-bookable, use its
283
+ timezone, and filter conflicts by that location. Keep the legacy first
284
+ `locationId` field during migration so older hosts remain compatible; never
285
+ fall back to `location-1` or another fixture ID.
286
+
287
+ After a confirmed package purchase, the public page may carry the opaque
288
+ `packageEntitlementId` into the hold and checkout requests. The server resolves
289
+ the customer from the submitted email, validates tenant ownership, active
290
+ status, expiry, currency, and every selected treatment balance, then locks the
291
+ entitlement and item rows while creating the booking and redemption ledger.
292
+ Public package redemption is all-or-nothing for a multi-treatment selection;
293
+ it confirms a fully covered booking at zero price and does not trust the
294
+ browser to decide the balance.
295
+
234
296
  Every `staff` account must also be linked to a Booking staff profile. The host
235
297
  passes that `staff_id` into the server context, and the PostgreSQL repository
236
298
  filters bookings, calendar, availability, customer summaries, staff/resources,
237
299
  schedule, and lifecycle mutations by that assignment. An unlinked staff
238
300
  session fails closed. This is a data-security rule, not a UI convention.
301
+ The administrator access registry must stay identical to the route-handler
302
+ capabilities: calendar, bookings, customers, waitlist, catalogue, packages,
303
+ staff, resources, schedule, locations, payments, refunds, notifications,
304
+ settings, reports, and audit. If `permissions_json` is absent on a legacy role,
305
+ apply the safe role defaults server-side; never treat a missing object as full
306
+ read access. Explicitly granted staff capabilities must be honored by the
307
+ route handler, while staff mutations remain limited to approved lifecycle
308
+ transitions. Keep the access contract, Astro host, reference host, ORA mirror,
309
+ and CLI validator synchronized whenever a route capability changes.
239
310
  The bootstrap now uses the host's server-side Resend configuration to send
240
311
  single-use invitation and password-reset links; raw tokens are never stored.
241
312
  The Resend worker separately delivers booking notifications. The default
242
313
  worker cycle includes `match-waitlist` and `enqueue-reminders`. The waitlist
243
314
  matcher orders eligible entries by priority/FIFO, requires explicit service and
244
315
  location scope, persists the offered slot, and queues one
245
- `booking.waitlist.available` notification. It never auto-creates or reserves a
316
+ `booking.waitlist.available` notification. Package purchase fulfillment and
317
+ provider-confirmed package refunds also queue the allowlisted
318
+ `package.purchase.confirmed`/`package.purchase.refunded` Resend events linked to
319
+ the package purchase, without appointment manage links. It never auto-creates or reserves a
246
320
  booking. The reminder job queues one `booking.reminder`
247
321
  email for each confirmed booking in the next 24 hours; the existing Resend
248
322
  dispatcher resolves the customer address at delivery time. Reminder queueing
@@ -278,7 +352,9 @@ installed host is:
278
352
  node scripts/maggie-booking-schema.mjs --dry-run
279
353
  node scripts/maggie-booking-schema.mjs --apply --confirm
280
354
  # open /_maggie/register and create the first owner
281
- # add Stripe and Resend secrets through the deployment secret store
355
+ # preferred: add Stripe and Resend secrets through the deployment secret store
356
+ # alternative: owner/manager can enter the Stripe key pair in Booking Overview;
357
+ # the host verifies it and stores only encrypted ciphertext
282
358
  node scripts/maggie-booking-worker.mjs --write --confirm
283
359
  ```
284
360
 
@@ -377,7 +453,7 @@ Follow the task board rather than building a disconnected calendar first:
377
453
  signed duplicate/out-of-order webhooks before enabling capture.
378
454
  7. Run the UI source gate, contract gate, host runtime conformance, browser
379
455
  journeys, and release gate. Record each command in
380
- [`PROGRESS.md`](../../docs/maggiedash-booking/PROGRESS.md).
456
+ [`PROGRESS.md`](../../bundled-references/maggiedash-booking/PROGRESS.md).
381
457
 
382
458
  8. Verify the scheduled worker queues and delivers a reminder once for a
383
459
  confirmed booking inside the 24-hour window. Check the notification
@@ -440,6 +516,11 @@ short-lived while customer-manage tokens are 30-day links. A redirect is never
440
516
  payment proof.
441
517
  Run `npm run booking:customer-flow:test` in MaggieDash before wiring the
442
518
  adapter, and retain real host/runtime/browser evidence as a separate gate.
519
+ If the host already has a legacy `/book` request form, keep it as a fallback
520
+ until the Booking schema is ready; expose the new customer route only after a
521
+ schema-aware readiness check, and preserve any existing treatment hint when
522
+ linking into the new flow. Do not replace a working host booking form with a
523
+ route that can only show an unconfigured Booking error.
443
524
  The manager Booking UI also exposes the tenant-scoped waitlist queue. Managers
444
525
  can filter entries, notify/cancel/reprioritize them, or select a concrete slot
445
526
  and staff/resource allocation to create a real booking transaction linked by
@@ -182,6 +182,20 @@ unconfirmed writes. Generated copy and media must be marked authored rather
182
182
  than source-observed. Implementation must still capture responsive screenshots
183
183
  and run accessibility/build validation before publication.
184
184
 
185
+ Author jobs are resumable design jobs even though their plan is stored beside
186
+ the author brief at `.maggie/design/author-<id>.json`. Use the same progress
187
+ commands as an in-place job; `status` and `step` resolve both supported job
188
+ locations:
189
+
190
+ ```bash
191
+ maggie design status author-<id> --project .
192
+ maggie design step author-<id> --project . \
193
+ --step inspect-shell --evidence .maggie/evidence/inspect-shell.json
194
+ ```
195
+
196
+ An author plan is not complete until every `requiredSteps` entry has matching
197
+ evidence and the explicit approval step is recorded.
198
+
185
199
  ## Content UI initialization
186
200
 
187
201
  Use content UI initialization when `maggie-blog` or
@@ -496,3 +510,24 @@ Follow the shared [Maggie Decision Loop](../../references/decision-loop.md) for
496
510
  6. Require explicit final confirmation before any mutation or external write.
497
511
 
498
512
  If a decision is not relevant, record it as `skipped` with a reason. Do not silently assume a missing choice, and do not treat an existing output as permission to skip required work.
513
+
514
+ ## Contract checks for dashboards, samples, and progressive enhancement
515
+
516
+ Run these stable evidence checks after implementation:
517
+
518
+ ```bash
519
+ maggie design progressive-check --evidence .maggie/progressive.json
520
+ maggie design css-check --html dist/index.html --css dist/assets/app.css
521
+ maggie design css-cascade-check --evidence .maggie/css-cascade.json
522
+ maggie design dash-init --project . --route /_maggie/admin --confirm
523
+ maggie design dash-validate --plan .maggie/design/dashboard/*/plan.json --evidence .maggie/dashboard-evidence.json
524
+ maggie design sample-init --project . --route /layout-sample --purpose "layout exploration" --confirm
525
+ maggie design sample-validate --plan .maggie/design/sample/*/plan.json --evidence .maggie/sample-evidence.json
526
+ ```
527
+
528
+ The checks cover smallest-region swaps, stable DOM identities, third-party
529
+ requests, stale responsive Tailwind utilities, and unlayered CSS winning over
530
+ utilities. Dashboard plans require operator journeys and desktop/tablet/mobile,
531
+ collapsed-rail, mobile-drawer, and modal evidence. Sample plans require
532
+ noindex, sitemap exclusion, a visible sample banner, placeholders, and a
533
+ finish checklist.
@@ -381,3 +381,15 @@ backed by a content-change/source-revision event; operational sync, pull,
381
381
  deploy, or `updated_at` timestamps are rejected. The agent-file command emits
382
382
  locale-aware `llms.txt`, `sitemap.md`, and `insights.md` from the same route
383
383
  inventory; non-indexable routes are omitted.
384
+
385
+ For every release, audit third-party privacy origins:
386
+
387
+ ```bash
388
+ maggie seo privacy-check --evidence .maggie/privacy-origin-evidence.json
389
+ ```
390
+
391
+ The site audit also records `primary_navigation_indexability` and flags a
392
+ same-origin page linked from primary navigation when it is `noindex`,
393
+ `nofollow`, or `none`. The privacy check fails in both directions: an embedded
394
+ origin missing from the policy, or a policy origin never observed in rendered
395
+ pages, requires review.
@@ -502,3 +502,17 @@ later sync are marked `archived`, retained for reconciliation, and excluded
502
502
  from active category context and public fact gates. After every sync, run
503
503
  `fact-audit`, `category-context`, the category hash/render/audit sequence, and
504
504
  the aggregate `maggie_release.py` gate.
505
+
506
+ ### Treatment groups
507
+
508
+ Keep one treatment catalogue entry and put length/price choices in its
509
+ `variants` array. Imports emit `treatmentGroup` with variant count, duration
510
+ range, and a from-price summary. Run the gate before rendering service cards:
511
+
512
+ ```bash
513
+ maggie service treatment-group-audit --project .
514
+ ```
515
+
516
+ This prevents a 30/60/90/120-minute treatment from becoming four unrelated
517
+ products and gives catalogue, detail, booking, and pricing surfaces one stable
518
+ identity.