@rfc0/patty 0.0.0-stage → 1.0.2

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 (465) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +214 -2
  3. package/dist/adapters/access-tokens.js +7 -0
  4. package/dist/adapters/accounts.js +37 -0
  5. package/dist/adapters/auth.js +11 -0
  6. package/dist/adapters/bills.js +32 -0
  7. package/dist/adapters/budgets.js +29 -0
  8. package/dist/adapters/categories.js +32 -0
  9. package/dist/adapters/client-grants.js +7 -0
  10. package/dist/adapters/credit-cards.js +33 -0
  11. package/dist/adapters/currencies.js +2 -0
  12. package/dist/adapters/currency-rates.js +18 -0
  13. package/dist/adapters/dashboards.js +43 -0
  14. package/dist/adapters/demo.js +13 -0
  15. package/dist/adapters/instance-settings.js +7 -0
  16. package/dist/adapters/invites.js +7 -0
  17. package/dist/adapters/recurring.js +55 -0
  18. package/dist/adapters/sessions.js +7 -0
  19. package/dist/adapters/settings.js +4 -0
  20. package/dist/adapters/setup-codes.js +7 -0
  21. package/dist/adapters/tags.js +9 -0
  22. package/dist/adapters/transactions.js +95 -0
  23. package/dist/adapters/users.js +7 -0
  24. package/dist/common/build-version.js +5 -0
  25. package/dist/common/errors.js +118 -0
  26. package/dist/common/net.js +71 -0
  27. package/dist/common/result.js +7 -0
  28. package/dist/composition/auth.js +106 -0
  29. package/dist/composition/boot.js +27 -0
  30. package/dist/composition/cli.js +86 -0
  31. package/dist/composition/demo/seed.js +92 -0
  32. package/dist/composition/demo/shell.js +107 -0
  33. package/dist/composition/export.js +89 -0
  34. package/dist/composition/http.js +110 -0
  35. package/dist/composition/import.js +55 -0
  36. package/dist/composition/lazy-modules.js +2 -0
  37. package/dist/composition/runtime.js +115 -0
  38. package/dist/composition/sign-in/interpreter.js +154 -0
  39. package/dist/composition/sign-in/server.js +36 -0
  40. package/dist/composition/sign-in/wiring.js +23 -0
  41. package/dist/composition/stdio.js +69 -0
  42. package/dist/config.js +136 -0
  43. package/dist/controllers/account/account.js +88 -0
  44. package/dist/controllers/account/transaction.js +119 -0
  45. package/dist/controllers/account/transfer.js +34 -0
  46. package/dist/controllers/aggregate.js +40 -0
  47. package/dist/controllers/auth/access-tokens.js +61 -0
  48. package/dist/controllers/auth/grants.js +136 -0
  49. package/dist/controllers/auth/key-export.js +20 -0
  50. package/dist/controllers/auth/owner.js +80 -0
  51. package/dist/controllers/auth/password.js +35 -0
  52. package/dist/controllers/auth/session.js +50 -0
  53. package/dist/controllers/auth/step-up.js +8 -0
  54. package/dist/controllers/auth/users.js +183 -0
  55. package/dist/controllers/budgets.js +87 -0
  56. package/dist/controllers/categories.js +67 -0
  57. package/dist/controllers/correlations.js +112 -0
  58. package/dist/controllers/credit-card/bill.js +105 -0
  59. package/dist/controllers/credit-card/credit-card.js +129 -0
  60. package/dist/controllers/credit-card/transaction.js +181 -0
  61. package/dist/controllers/currencies.js +1 -0
  62. package/dist/controllers/currency-rates.js +40 -0
  63. package/dist/controllers/dashboards.js +68 -0
  64. package/dist/controllers/demo/seed.js +31 -0
  65. package/dist/controllers/demo/tour.js +12 -0
  66. package/dist/controllers/deps.js +6 -0
  67. package/dist/controllers/instance.js +6 -0
  68. package/dist/controllers/merchants.js +12 -0
  69. package/dist/controllers/recurring.js +70 -0
  70. package/dist/controllers/resolve.js +37 -0
  71. package/dist/controllers/settings.js +47 -0
  72. package/dist/controllers/status.js +19 -0
  73. package/dist/controllers/summary.js +21 -0
  74. package/dist/controllers/tags.js +19 -0
  75. package/dist/controllers/transaction/bulk.js +6 -0
  76. package/dist/controllers/transaction/core.js +49 -0
  77. package/dist/controllers/transaction/read.js +28 -0
  78. package/dist/diplomat/auth/credentials.js +58 -0
  79. package/dist/diplomat/auth/sign-in-store.js +18 -0
  80. package/dist/diplomat/cli/commands/auth.js +100 -0
  81. package/dist/diplomat/cli/commands/db.js +72 -0
  82. package/dist/diplomat/cli/commands/demo.js +68 -0
  83. package/dist/diplomat/cli/commands/key.js +119 -0
  84. package/dist/diplomat/cli/commands/login.js +151 -0
  85. package/dist/diplomat/cli/commands/setup.js +132 -0
  86. package/dist/diplomat/cli/commands/users.js +123 -0
  87. package/dist/diplomat/cli/commands.js +61 -0
  88. package/dist/diplomat/cli/export-file.js +37 -0
  89. package/dist/diplomat/cli/import-file.js +44 -0
  90. package/dist/diplomat/cli/io.js +61 -0
  91. package/dist/diplomat/cli/key-export-approval.js +37 -0
  92. package/dist/diplomat/cli/messages.js +96 -0
  93. package/dist/diplomat/cli/prompt.js +74 -0
  94. package/dist/diplomat/cli/terminal.js +81 -0
  95. package/dist/diplomat/client-config/clients.js +150 -0
  96. package/dist/diplomat/client-config/merge.js +41 -0
  97. package/dist/diplomat/db/bootstrap.js +98 -0
  98. package/dist/diplomat/db/database-files.js +147 -0
  99. package/dist/diplomat/db/driver.js +167 -0
  100. package/dist/diplomat/db/effects.js +101 -0
  101. package/dist/diplomat/db/engine.js +9 -0
  102. package/dist/diplomat/db/export.js +22 -0
  103. package/dist/diplomat/db/file-lock.js +82 -0
  104. package/dist/diplomat/db/key-lock.js +14 -0
  105. package/dist/diplomat/db/locale-cache.js +23 -0
  106. package/dist/diplomat/db/migration-barrier.js +57 -0
  107. package/dist/diplomat/db/migration-journal.js +18 -0
  108. package/dist/diplomat/db/migration-lock.js +15 -0
  109. package/dist/diplomat/db/migrations.js +11 -0
  110. package/dist/diplomat/db/present.js +17 -0
  111. package/dist/diplomat/db/queries/aggregate-whitelist.js +35 -0
  112. package/dist/diplomat/db/queries/filters.js +59 -0
  113. package/dist/diplomat/db/queries/fts.js +18 -0
  114. package/dist/diplomat/db/queries/scope.js +8 -0
  115. package/dist/diplomat/db/queries/transaction-select.js +26 -0
  116. package/dist/diplomat/db/queries/tx-predicates.js +13 -0
  117. package/dist/diplomat/db/repos/access-tokens.js +27 -0
  118. package/dist/diplomat/db/repos/accounts.js +91 -0
  119. package/dist/diplomat/db/repos/bills.js +93 -0
  120. package/dist/diplomat/db/repos/budgets.js +72 -0
  121. package/dist/diplomat/db/repos/categories.js +53 -0
  122. package/dist/diplomat/db/repos/client-grants.js +67 -0
  123. package/dist/diplomat/db/repos/correlations.js +66 -0
  124. package/dist/diplomat/db/repos/credit-cards.js +67 -0
  125. package/dist/diplomat/db/repos/currencies.js +8 -0
  126. package/dist/diplomat/db/repos/currency-rates.js +40 -0
  127. package/dist/diplomat/db/repos/dashboards.js +123 -0
  128. package/dist/diplomat/db/repos/health.js +12 -0
  129. package/dist/diplomat/db/repos/instance-settings.js +14 -0
  130. package/dist/diplomat/db/repos/instance.js +58 -0
  131. package/dist/diplomat/db/repos/invites.js +43 -0
  132. package/dist/diplomat/db/repos/merchants.js +121 -0
  133. package/dist/diplomat/db/repos/recurring.js +29 -0
  134. package/dist/diplomat/db/repos/sessions.js +19 -0
  135. package/dist/diplomat/db/repos/settings.js +41 -0
  136. package/dist/diplomat/db/repos/setup-codes.js +28 -0
  137. package/dist/diplomat/db/repos/sub-categories.js +67 -0
  138. package/dist/diplomat/db/repos/tags.js +51 -0
  139. package/dist/diplomat/db/repos/transaction-tags.js +57 -0
  140. package/dist/diplomat/db/repos/transactions.js +163 -0
  141. package/dist/diplomat/db/repos/users.js +47 -0
  142. package/dist/diplomat/db/safety-copy.js +87 -0
  143. package/dist/diplomat/db/schema.js +348 -0
  144. package/dist/diplomat/db/seed/categories.js +112 -0
  145. package/dist/diplomat/db/seed/currencies.js +9 -0
  146. package/dist/diplomat/db/seed/demo/br.js +98 -0
  147. package/dist/diplomat/db/seed/demo/co.js +89 -0
  148. package/dist/diplomat/db/seed/demo/index.js +12 -0
  149. package/dist/diplomat/db/seed/demo/mx.js +90 -0
  150. package/dist/diplomat/db/seed/demo/shared.js +39 -0
  151. package/dist/diplomat/db/seed/demo/us.js +90 -0
  152. package/dist/diplomat/db/seed/merchant-rules.js +188 -0
  153. package/dist/diplomat/db/sqlite-errors.js +40 -0
  154. package/dist/diplomat/db/tenancy-integrity.js +45 -0
  155. package/dist/diplomat/db/version-guard.js +16 -0
  156. package/dist/diplomat/http/auth-pages.js +41 -0
  157. package/dist/diplomat/http/auth-paths.js +46 -0
  158. package/dist/diplomat/http/bearer.js +15 -0
  159. package/dist/diplomat/http/connect-pages.js +51 -0
  160. package/dist/diplomat/http/context.js +17 -0
  161. package/dist/diplomat/http/cookies.js +27 -0
  162. package/dist/diplomat/http/form-pages.js +38 -0
  163. package/dist/diplomat/http/hooks/auth.js +106 -0
  164. package/dist/diplomat/http/hooks/demo-marker.js +59 -0
  165. package/dist/diplomat/http/openapi.js +73 -0
  166. package/dist/diplomat/http/principal.js +1 -0
  167. package/dist/diplomat/http/rate-limiter.js +78 -0
  168. package/dist/diplomat/http/remedy.js +26 -0
  169. package/dist/diplomat/http/respond.js +50 -0
  170. package/dist/diplomat/http/routes/account.js +226 -0
  171. package/dist/diplomat/http/routes/aggregate.js +28 -0
  172. package/dist/diplomat/http/routes/auth.js +105 -0
  173. package/dist/diplomat/http/routes/budget.js +34 -0
  174. package/dist/diplomat/http/routes/category.js +109 -0
  175. package/dist/diplomat/http/routes/connect.js +124 -0
  176. package/dist/diplomat/http/routes/credit-card.js +263 -0
  177. package/dist/diplomat/http/routes/currency-rates.js +60 -0
  178. package/dist/diplomat/http/routes/currency.js +16 -0
  179. package/dist/diplomat/http/routes/dashboard.js +93 -0
  180. package/dist/diplomat/http/routes/invite.js +63 -0
  181. package/dist/diplomat/http/routes/recurring.js +65 -0
  182. package/dist/diplomat/http/routes/settings.js +38 -0
  183. package/dist/diplomat/http/routes/summary.js +23 -0
  184. package/dist/diplomat/http/routes/system.js +29 -0
  185. package/dist/diplomat/http/routes/tag.js +51 -0
  186. package/dist/diplomat/http/routes/tokens.js +72 -0
  187. package/dist/diplomat/http/routes/transaction.js +55 -0
  188. package/dist/diplomat/http/routes/transfer.js +35 -0
  189. package/dist/diplomat/http/routes/ui.js +110 -0
  190. package/dist/diplomat/http/routes/users.js +156 -0
  191. package/dist/diplomat/http/routes/well-known.js +26 -0
  192. package/dist/diplomat/http/routes.js +85 -0
  193. package/dist/diplomat/http/session.js +34 -0
  194. package/dist/diplomat/http/token-pages.js +75 -0
  195. package/dist/diplomat/http/ui-files.js +21 -0
  196. package/dist/diplomat/http/user-pages.js +93 -0
  197. package/dist/diplomat/mcp/annotations.js +8 -0
  198. package/dist/diplomat/mcp/auth-info.js +20 -0
  199. package/dist/diplomat/mcp/context.js +14 -0
  200. package/dist/diplomat/mcp/definition.js +3 -0
  201. package/dist/diplomat/mcp/gate.js +15 -0
  202. package/dist/diplomat/mcp/instructions.js +19 -0
  203. package/dist/diplomat/mcp/prompts.js +125 -0
  204. package/dist/diplomat/mcp/register.js +12 -0
  205. package/dist/diplomat/mcp/remedy.js +17 -0
  206. package/dist/diplomat/mcp/resources.js +93 -0
  207. package/dist/diplomat/mcp/respond.js +20 -0
  208. package/dist/diplomat/mcp/route.js +62 -0
  209. package/dist/diplomat/mcp/scopes.js +53 -0
  210. package/dist/diplomat/mcp/server.js +26 -0
  211. package/dist/diplomat/mcp/shared.js +5 -0
  212. package/dist/diplomat/mcp/stdio-session.js +94 -0
  213. package/dist/diplomat/mcp/stdio.js +23 -0
  214. package/dist/diplomat/mcp/tool-name.js +59 -0
  215. package/dist/diplomat/mcp/tools/account.js +218 -0
  216. package/dist/diplomat/mcp/tools/aggregate.js +32 -0
  217. package/dist/diplomat/mcp/tools/budget.js +99 -0
  218. package/dist/diplomat/mcp/tools/category.js +103 -0
  219. package/dist/diplomat/mcp/tools/correlations.js +70 -0
  220. package/dist/diplomat/mcp/tools/credit-card.js +239 -0
  221. package/dist/diplomat/mcp/tools/currency-rates.js +62 -0
  222. package/dist/diplomat/mcp/tools/dashboard.js +75 -0
  223. package/dist/diplomat/mcp/tools/index.js +31 -0
  224. package/dist/diplomat/mcp/tools/recurring.js +62 -0
  225. package/dist/diplomat/mcp/tools/summary.js +30 -0
  226. package/dist/diplomat/mcp/tools/system.js +83 -0
  227. package/dist/diplomat/mcp/tools/tag.js +48 -0
  228. package/dist/diplomat/mcp/tools/transaction.js +53 -0
  229. package/dist/diplomat/mcp/tools/transfer.js +28 -0
  230. package/dist/diplomat/mcp/tour.js +87 -0
  231. package/dist/logic/account.js +79 -0
  232. package/dist/logic/aggregate.js +37 -0
  233. package/dist/logic/auth/bearer.js +35 -0
  234. package/dist/logic/auth/grant.js +126 -0
  235. package/dist/logic/auth/key-export.js +10 -0
  236. package/dist/logic/auth/keychain.js +3 -0
  237. package/dist/logic/auth/message.js +22 -0
  238. package/dist/logic/auth/origin.js +57 -0
  239. package/dist/logic/auth/owner.js +22 -0
  240. package/dist/logic/auth/password.js +3 -0
  241. package/dist/logic/auth/redact.js +25 -0
  242. package/dist/logic/auth/revoke.js +28 -0
  243. package/dist/logic/auth/scope.js +17 -0
  244. package/dist/logic/auth/session.js +30 -0
  245. package/dist/logic/auth/sign-in-flow.js +305 -0
  246. package/dist/logic/auth/time.js +2 -0
  247. package/dist/logic/auth/token.js +74 -0
  248. package/dist/logic/auth/user-plans.js +84 -0
  249. package/dist/logic/auth/users.js +78 -0
  250. package/dist/logic/balance.js +2 -0
  251. package/dist/logic/bill.js +74 -0
  252. package/dist/logic/budget.js +78 -0
  253. package/dist/logic/category.js +37 -0
  254. package/dist/logic/classify.js +21 -0
  255. package/dist/logic/correlations.js +147 -0
  256. package/dist/logic/credit-card.js +2 -0
  257. package/dist/logic/currency-rate.js +69 -0
  258. package/dist/logic/dashboard.js +40 -0
  259. package/dist/logic/demo/database.js +30 -0
  260. package/dist/logic/demo/plan.js +308 -0
  261. package/dist/logic/demo/tour.js +33 -0
  262. package/dist/logic/export-destination.js +12 -0
  263. package/dist/logic/key-import.js +15 -0
  264. package/dist/logic/locale.js +5 -0
  265. package/dist/logic/localize.js +12 -0
  266. package/dist/logic/merchant.js +31 -0
  267. package/dist/logic/migration.js +1 -0
  268. package/dist/logic/money.js +12 -0
  269. package/dist/logic/period.js +45 -0
  270. package/dist/logic/persistence.js +48 -0
  271. package/dist/logic/recurring.js +51 -0
  272. package/dist/logic/resolve.js +44 -0
  273. package/dist/logic/summary.js +29 -0
  274. package/dist/logic/tag.js +13 -0
  275. package/dist/logic/transaction.js +197 -0
  276. package/dist/main.js +42 -0
  277. package/dist/models/account.js +197 -0
  278. package/dist/models/aggregate.js +61 -0
  279. package/dist/models/auth/bearer.js +11 -0
  280. package/dist/models/auth/entity.js +17 -0
  281. package/dist/models/auth/errors.js +42 -0
  282. package/dist/models/auth/grant.js +58 -0
  283. package/dist/models/auth/key-export.js +11 -0
  284. package/dist/models/auth/message.js +50 -0
  285. package/dist/models/auth/mode.js +7 -0
  286. package/dist/models/auth/origin.js +16 -0
  287. package/dist/models/auth/owner.js +36 -0
  288. package/dist/models/auth/password.js +24 -0
  289. package/dist/models/auth/principal.js +26 -0
  290. package/dist/models/auth/redact.js +4 -0
  291. package/dist/models/auth/scope.js +9 -0
  292. package/dist/models/auth/session.js +19 -0
  293. package/dist/models/auth/sign-in-flow.js +102 -0
  294. package/dist/models/auth/sign-in.js +41 -0
  295. package/dist/models/auth/time.js +5 -0
  296. package/dist/models/auth/token.js +50 -0
  297. package/dist/models/auth/users.js +52 -0
  298. package/dist/models/bill.js +55 -0
  299. package/dist/models/budget.js +106 -0
  300. package/dist/models/category.js +52 -0
  301. package/dist/models/client-config.js +18 -0
  302. package/dist/models/correlations.js +215 -0
  303. package/dist/models/credit-card.js +156 -0
  304. package/dist/models/currency-rate.js +83 -0
  305. package/dist/models/dashboard.js +54 -0
  306. package/dist/models/database.js +16 -0
  307. package/dist/models/date.js +8 -0
  308. package/dist/models/demo/core.js +58 -0
  309. package/dist/models/demo/tour.js +41 -0
  310. package/dist/models/encryption-key.js +2 -0
  311. package/dist/models/error.js +13 -0
  312. package/dist/models/export.js +9 -0
  313. package/dist/models/id.js +2 -0
  314. package/dist/models/instance.js +7 -0
  315. package/dist/models/key-import.js +6 -0
  316. package/dist/models/locale.js +25 -0
  317. package/dist/models/merchant.js +12 -0
  318. package/dist/models/money.js +14 -0
  319. package/dist/models/package.js +12 -0
  320. package/dist/models/page.js +56 -0
  321. package/dist/models/persistence.js +1 -0
  322. package/dist/models/prompts.js +5 -0
  323. package/dist/models/recurring.js +54 -0
  324. package/dist/models/remedy.js +17 -0
  325. package/dist/models/resolution.js +1 -0
  326. package/dist/models/startup.js +7 -0
  327. package/dist/models/summary.js +24 -0
  328. package/dist/models/tag.js +14 -0
  329. package/dist/models/tenancy.js +10 -0
  330. package/dist/models/transaction-tag.js +6 -0
  331. package/dist/models/transaction.js +275 -0
  332. package/dist/wire/db/access-tokens.js +1 -0
  333. package/dist/wire/db/accounts.js +7 -0
  334. package/dist/wire/db/aggregate.js +16 -0
  335. package/dist/wire/db/bills.js +14 -0
  336. package/dist/wire/db/budgets.js +33 -0
  337. package/dist/wire/db/categories.js +14 -0
  338. package/dist/wire/db/client-grants.js +1 -0
  339. package/dist/wire/db/correlations.js +49 -0
  340. package/dist/wire/db/credit-cards.js +1 -0
  341. package/dist/wire/db/currencies.js +1 -0
  342. package/dist/wire/db/currency-rates.js +1 -0
  343. package/dist/wire/db/dashboards.js +1 -0
  344. package/dist/wire/db/instance-settings.js +1 -0
  345. package/dist/wire/db/invites.js +1 -0
  346. package/dist/wire/db/merchants.js +18 -0
  347. package/dist/wire/db/recurring.js +19 -0
  348. package/dist/wire/db/sessions.js +1 -0
  349. package/dist/wire/db/settings.js +1 -0
  350. package/dist/wire/db/setup-codes.js +1 -0
  351. package/dist/wire/db/tags.js +1 -0
  352. package/dist/wire/db/tenancy.js +1 -0
  353. package/dist/wire/db/transactions.js +89 -0
  354. package/dist/wire/db/users.js +1 -0
  355. package/dist/wire/in/accounts.js +26 -0
  356. package/dist/wire/in/aggregate.js +10 -0
  357. package/dist/wire/in/auth.js +107 -0
  358. package/dist/wire/in/bills.js +11 -0
  359. package/dist/wire/in/budgets.js +11 -0
  360. package/dist/wire/in/categories.js +9 -0
  361. package/dist/wire/in/cli.js +106 -0
  362. package/dist/wire/in/coerce.js +6 -0
  363. package/dist/wire/in/common.js +17 -0
  364. package/dist/wire/in/credit-cards.js +16 -0
  365. package/dist/wire/in/currency-rates.js +8 -0
  366. package/dist/wire/in/period.js +7 -0
  367. package/dist/wire/in/recurring.js +6 -0
  368. package/dist/wire/in/settings.js +5 -0
  369. package/dist/wire/in/summary.js +5 -0
  370. package/dist/wire/in/tags.js +2 -0
  371. package/dist/wire/in/transactions.js +31 -0
  372. package/dist/wire/out/bills.js +9 -0
  373. package/dist/wire/out/budgets.js +10 -0
  374. package/dist/wire/out/client-config.js +2 -0
  375. package/dist/wire/out/common.js +4 -0
  376. package/dist/wire/out/credit-cards.js +15 -0
  377. package/dist/wire/out/currency-rates.js +11 -0
  378. package/dist/wire/out/errors.js +58 -0
  379. package/dist/wire/out/recurring.js +6 -0
  380. package/dist/wire/out/status.js +10 -0
  381. package/dist/wire/out/summary.js +9 -0
  382. package/dist/wire/out/transactions.js +52 -0
  383. package/drizzle/0000_futuristic_umar.sql +124 -0
  384. package/drizzle/0001_fts5_search.sql +23 -0
  385. package/drizzle/0002_rename_graph_to_history.sql +7 -0
  386. package/drizzle/0003_lyrical_hairball.sql +2 -0
  387. package/drizzle/0004_misty_ikaris.sql +7 -0
  388. package/drizzle/0005_credit-liability-accounts.sql +14 -0
  389. package/drizzle/0006_smart_aqueduct.sql +1 -0
  390. package/drizzle/0007_add_dashboards.sql +5 -0
  391. package/drizzle/0008_yummy_madripoor.sql +1 -0
  392. package/drizzle/0009_version_groundwork.sql +9 -0
  393. package/drizzle/0010_category_merchant_association_cascade.sql +16 -0
  394. package/drizzle/0011_dashboard_id_normalization.sql +16 -0
  395. package/drizzle/0012_hot_the_spike.sql +12 -0
  396. package/drizzle/0013_recurring_rules_merchant.sql +1 -0
  397. package/drizzle/0014_dashboard_source_discriminator.sql +17 -0
  398. package/drizzle/0015_currencies_decimals.sql +1 -0
  399. package/drizzle/0016_unusual_zaran.sql +13 -0
  400. package/drizzle/0017_premium_blur.sql +1 -0
  401. package/drizzle/0018_auth_identity.sql +39 -0
  402. package/drizzle/0019_access_tokens.sql +16 -0
  403. package/drizzle/0020_stdio_sign_in.sql +27 -0
  404. package/drizzle/0021_tenancy_data.sql +289 -0
  405. package/drizzle/0022_user_management.sql +17 -0
  406. package/drizzle/0023_instance_settings_row.sql +2 -0
  407. package/drizzle/0024_credentials_changed_at.sql +2 -0
  408. package/drizzle/0025_instance_kind.sql +2 -0
  409. package/drizzle/0026_demo_seeded_at.sql +2 -0
  410. package/drizzle/0027_demo_country.sql +2 -0
  411. package/drizzle/0028_reset_sign_ins.sql +2 -0
  412. package/drizzle/meta/0000_snapshot.json +894 -0
  413. package/drizzle/meta/0003_snapshot.json +910 -0
  414. package/drizzle/meta/0004_snapshot.json +951 -0
  415. package/drizzle/meta/0005_snapshot.json +991 -0
  416. package/drizzle/meta/0006_snapshot.json +998 -0
  417. package/drizzle/meta/0007_snapshot.json +1029 -0
  418. package/drizzle/meta/0008_snapshot.json +1049 -0
  419. package/drizzle/meta/0009_snapshot.json +1121 -0
  420. package/drizzle/meta/0010_snapshot.json +1121 -0
  421. package/drizzle/meta/0011_snapshot.json +1136 -0
  422. package/drizzle/meta/0012_snapshot.json +1227 -0
  423. package/drizzle/meta/0013_snapshot.json +1247 -0
  424. package/drizzle/meta/0014_snapshot.json +1267 -0
  425. package/drizzle/meta/0015_snapshot.json +1275 -0
  426. package/drizzle/meta/0016_snapshot.json +1371 -0
  427. package/drizzle/meta/0017_snapshot.json +1392 -0
  428. package/drizzle/meta/0018_snapshot.json +1603 -0
  429. package/drizzle/meta/0019_snapshot.json +1713 -0
  430. package/drizzle/meta/0020_snapshot.json +1904 -0
  431. package/drizzle/meta/0021_snapshot.json +2186 -0
  432. package/drizzle/meta/0022_snapshot.json +2311 -0
  433. package/drizzle/meta/0023_snapshot.json +2311 -0
  434. package/drizzle/meta/0024_snapshot.json +2318 -0
  435. package/drizzle/meta/0025_snapshot.json +2326 -0
  436. package/drizzle/meta/0026_snapshot.json +2333 -0
  437. package/drizzle/meta/0027_snapshot.json +2340 -0
  438. package/drizzle/meta/0028_snapshot.json +2340 -0
  439. package/drizzle/meta/_journal.json +209 -0
  440. package/package.json +106 -4
  441. package/skills/dashboard-building/SKILL.md +201 -0
  442. package/skills/patty-tour/SKILL.md +34 -0
  443. package/ui/app.css +758 -0
  444. package/ui/app.js +543 -0
  445. package/ui/connect-result.html +16 -0
  446. package/ui/connect.html +53 -0
  447. package/ui/dashboards/accounts.html +3189 -0
  448. package/ui/dashboards/budget.html +1734 -0
  449. package/ui/dashboards/cards.html +4032 -0
  450. package/ui/dashboards/categories.html +4694 -0
  451. package/ui/dashboards/comparative.html +2475 -0
  452. package/ui/dashboards/dashboards.html +839 -0
  453. package/ui/dashboards/overview.html +2405 -0
  454. package/ui/dashboards/pending.html +2973 -0
  455. package/ui/dashboards/projections.html +2528 -0
  456. package/ui/dashboards/tags.html +1365 -0
  457. package/ui/invite.html +44 -0
  458. package/ui/login.html +26 -0
  459. package/ui/money.js +175 -0
  460. package/ui/setup.html +29 -0
  461. package/ui/shell.html +96 -0
  462. package/ui/token-created.html +24 -0
  463. package/ui/tokens.html +58 -0
  464. package/ui/user-invited.html +27 -0
  465. package/ui/users.html +60 -0
@@ -0,0 +1,209 @@
1
+ {
2
+ "version": "7",
3
+ "dialect": "sqlite",
4
+ "entries": [
5
+ {
6
+ "idx": 0,
7
+ "version": "6",
8
+ "when": 1781553296963,
9
+ "tag": "0000_futuristic_umar",
10
+ "breakpoints": true
11
+ },
12
+ {
13
+ "idx": 1,
14
+ "version": "6",
15
+ "when": 1781553300000,
16
+ "tag": "0001_fts5_search",
17
+ "breakpoints": true
18
+ },
19
+ {
20
+ "idx": 2,
21
+ "version": "6",
22
+ "when": 1781553400000,
23
+ "tag": "0002_rename_graph_to_history",
24
+ "breakpoints": true
25
+ },
26
+ {
27
+ "idx": 3,
28
+ "version": "6",
29
+ "when": 1781802888663,
30
+ "tag": "0003_lyrical_hairball",
31
+ "breakpoints": true
32
+ },
33
+ {
34
+ "idx": 4,
35
+ "version": "6",
36
+ "when": 1781903562870,
37
+ "tag": "0004_misty_ikaris",
38
+ "breakpoints": true
39
+ },
40
+ {
41
+ "idx": 5,
42
+ "version": "6",
43
+ "when": 1782067834795,
44
+ "tag": "0005_credit-liability-accounts",
45
+ "breakpoints": true
46
+ },
47
+ {
48
+ "idx": 6,
49
+ "version": "6",
50
+ "when": 1782237860598,
51
+ "tag": "0006_smart_aqueduct",
52
+ "breakpoints": true
53
+ },
54
+ {
55
+ "idx": 7,
56
+ "version": "6",
57
+ "when": 1782989725122,
58
+ "tag": "0007_add_dashboards",
59
+ "breakpoints": true
60
+ },
61
+ {
62
+ "idx": 8,
63
+ "version": "6",
64
+ "when": 1783081533318,
65
+ "tag": "0008_yummy_madripoor",
66
+ "breakpoints": true
67
+ },
68
+ {
69
+ "idx": 9,
70
+ "version": "6",
71
+ "when": 1783945739666,
72
+ "tag": "0009_version_groundwork",
73
+ "breakpoints": true
74
+ },
75
+ {
76
+ "idx": 10,
77
+ "version": "6",
78
+ "when": 1784165848746,
79
+ "tag": "0010_category_merchant_association_cascade",
80
+ "breakpoints": true
81
+ },
82
+ {
83
+ "idx": 11,
84
+ "version": "6",
85
+ "when": 1784760614478,
86
+ "tag": "0011_dashboard_id_normalization",
87
+ "breakpoints": true
88
+ },
89
+ {
90
+ "idx": 12,
91
+ "version": "6",
92
+ "when": 1785018004054,
93
+ "tag": "0012_hot_the_spike",
94
+ "breakpoints": true
95
+ },
96
+ {
97
+ "idx": 13,
98
+ "version": "6",
99
+ "when": 1785415113304,
100
+ "tag": "0013_recurring_rules_merchant",
101
+ "breakpoints": true
102
+ },
103
+ {
104
+ "idx": 14,
105
+ "version": "6",
106
+ "when": 1785865715850,
107
+ "tag": "0014_dashboard_source_discriminator",
108
+ "breakpoints": true
109
+ },
110
+ {
111
+ "idx": 15,
112
+ "version": "6",
113
+ "when": 1786325041247,
114
+ "tag": "0015_currencies_decimals",
115
+ "breakpoints": true
116
+ },
117
+ {
118
+ "idx": 16,
119
+ "version": "6",
120
+ "when": 1786370676798,
121
+ "tag": "0016_unusual_zaran",
122
+ "breakpoints": true
123
+ },
124
+ {
125
+ "idx": 17,
126
+ "version": "6",
127
+ "when": 1786370687528,
128
+ "tag": "0017_premium_blur",
129
+ "breakpoints": true
130
+ },
131
+ {
132
+ "idx": 18,
133
+ "version": "6",
134
+ "when": 1791373629090,
135
+ "tag": "0018_auth_identity",
136
+ "breakpoints": true
137
+ },
138
+ {
139
+ "idx": 19,
140
+ "version": "6",
141
+ "when": 1791571168273,
142
+ "tag": "0019_access_tokens",
143
+ "breakpoints": true
144
+ },
145
+ {
146
+ "idx": 20,
147
+ "version": "6",
148
+ "when": 1791761937573,
149
+ "tag": "0020_stdio_sign_in",
150
+ "breakpoints": true
151
+ },
152
+ {
153
+ "idx": 21,
154
+ "version": "6",
155
+ "when": 1791939290275,
156
+ "tag": "0021_tenancy_data",
157
+ "breakpoints": true
158
+ },
159
+ {
160
+ "idx": 22,
161
+ "version": "6",
162
+ "when": 1792195464690,
163
+ "tag": "0022_user_management",
164
+ "breakpoints": true
165
+ },
166
+ {
167
+ "idx": 23,
168
+ "version": "6",
169
+ "when": 1792281864690,
170
+ "tag": "0023_instance_settings_row",
171
+ "breakpoints": true
172
+ },
173
+ {
174
+ "idx": 24,
175
+ "version": "6",
176
+ "when": 1792368264690,
177
+ "tag": "0024_credentials_changed_at",
178
+ "breakpoints": true
179
+ },
180
+ {
181
+ "idx": 25,
182
+ "version": "6",
183
+ "when": 1793019256222,
184
+ "tag": "0025_instance_kind",
185
+ "breakpoints": true
186
+ },
187
+ {
188
+ "idx": 26,
189
+ "version": "6",
190
+ "when": 1793040889072,
191
+ "tag": "0026_demo_seeded_at",
192
+ "breakpoints": true
193
+ },
194
+ {
195
+ "idx": 27,
196
+ "version": "6",
197
+ "when": 1793041889072,
198
+ "tag": "0027_demo_country",
199
+ "breakpoints": true
200
+ },
201
+ {
202
+ "idx": 28,
203
+ "version": "6",
204
+ "when": 1793042889072,
205
+ "tag": "0028_reset_sign_ins",
206
+ "breakpoints": true
207
+ }
208
+ ]
209
+ }
package/package.json CHANGED
@@ -1,6 +1,108 @@
1
1
  {
2
2
  "name": "@rfc0/patty",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.2",
4
+ "description": "AI-first personal finance manager — MCP server (local-first, encrypted libSQL).",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "bin": {
8
+ "patty": "dist/main.js"
9
+ },
10
+ "main": "dist/main.js",
11
+ "files": [
12
+ "dist",
13
+ "drizzle",
14
+ "ui",
15
+ "skills",
16
+ "!skills/**/evals",
17
+ "README.md",
18
+ "LICENSE"
19
+ ],
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/RafaelFCarneiro/patty.git"
23
+ },
24
+ "homepage": "https://github.com/RafaelFCarneiro/patty#readme",
25
+ "bugs": {
26
+ "url": "https://github.com/RafaelFCarneiro/patty/issues"
27
+ },
28
+ "publishConfig": {
29
+ "registry": "https://registry.npmjs.org",
30
+ "access": "public"
31
+ },
32
+ "engines": {
33
+ "node": ">=26 <27",
34
+ "npm": ">=11"
35
+ },
36
+ "scripts": {
37
+ "dev": "cross-env PORT=3001 tsx watch src/main.ts",
38
+ "build": "tsc -p tsconfig.build.json",
39
+ "start": "node dist/main.js",
40
+ "lint": "eslint src test scripts ui",
41
+ "format": "prettier --write .",
42
+ "format:check": "prettier --check .",
43
+ "test": "vitest run --config vitest.unit.config.ts",
44
+ "test:coverage": "vitest run --config vitest.unit.config.ts --coverage",
45
+ "test:coverage:integration": "vitest run --config vitest.integration.config.ts --coverage",
46
+ "test:coverage:all": "npm run test:coverage && npm run test:coverage:integration && node scripts/merge-coverage.mjs",
47
+ "test:integration": "vitest run --config vitest.integration.config.ts",
48
+ "test:all": "npm test && npm run test:integration",
49
+ "test:watch": "vitest --config vitest.unit.config.ts",
50
+ "typecheck": "tsc --noEmit -p tsconfig.test.json",
51
+ "mcp:inspect": "npx @modelcontextprotocol/inspector"
52
+ },
53
+ "ntl": {
54
+ "descriptions": {
55
+ "dev": "Run backend in watch mode (stdio by default; MCP_TRANSPORT=http or PATTY_HTTP=true for REST + MCP on :3001)",
56
+ "build": "Compile TypeScript to dist/",
57
+ "lint": "Lint src/, test/, scripts/ and ui/ with ESLint (style/quality smell rules — part of the gate)",
58
+ "format": "Format the repository with Prettier",
59
+ "format:check": "Check whether files follow Prettier formatting",
60
+ "start": "Run compiled backend",
61
+ "test": "Run only unit tests (Vitest project: unit)",
62
+ "test:integration": "Run MCP integration tests — in-process libSQL DB, no Docker required",
63
+ "test:coverage:integration": "Integration test coverage report (JSON → coverage/.tmp/integration)",
64
+ "test:coverage:all": "Full coverage: unit + integration merged into coverage/index.html",
65
+ "test:all": "Run unit + integration Vitest projects",
66
+ "test:watch": "Run unit tests in watch mode (Vitest project: unit)",
67
+ "typecheck": "Type-check everything, including tests",
68
+ "mcp:inspect": "Open MCP Inspector — connect to http://127.0.0.1:3001/mcp (Streamable HTTP, after `MCP_TRANSPORT=http npm run dev`)"
69
+ }
70
+ },
71
+ "dependencies": {
72
+ "@asteasolutions/zod-to-openapi": "^7.3.4",
73
+ "@libsql/client": "^0.17.4",
74
+ "@modelcontextprotocol/sdk": "^1.12.0",
75
+ "@napi-rs/keyring": "^1.3.0",
76
+ "@node-rs/argon2": "^2.2.2",
77
+ "@rfc0/effect-runner": "^0.5.0",
78
+ "drizzle-orm": "^0.45.2",
79
+ "fastify": "^5.3.0",
80
+ "neverthrow": "^8.2.0",
81
+ "openapi3-ts": "^4.6.0",
82
+ "remeda": "^2.21.0",
83
+ "zod": "^3.25.0"
84
+ },
85
+ "devDependencies": {
86
+ "@eslint/css": "^2.0.1",
87
+ "@eslint/js": "^9.39.5",
88
+ "@html-eslint/eslint-plugin": "^0.67.0",
89
+ "@html-eslint/parser": "^0.67.0",
90
+ "@semantic-release/commit-analyzer": "^13.0.1",
91
+ "@semantic-release/github": "^12.0.8",
92
+ "@semantic-release/npm": "^13.1.5",
93
+ "@semantic-release/release-notes-generator": "^14.1.1",
94
+ "@types/node": "^25.9.4",
95
+ "@vitest/coverage-v8": "^4.1.8",
96
+ "cross-env": "^10.1.0",
97
+ "drizzle-kit": "^0.31.10",
98
+ "eslint": "^9.18.0",
99
+ "eslint-plugin-check-file": "^3.3.2",
100
+ "globals": "^17.13.0",
101
+ "prettier": "^3.9.4",
102
+ "semantic-release": "^25.0.5",
103
+ "tsx": "^4.19.0",
104
+ "typescript": "^5.8.0",
105
+ "typescript-eslint": "^8.21.0",
106
+ "vitest": "^4.1.8"
107
+ }
108
+ }
@@ -0,0 +1,201 @@
1
+ ---
2
+ name: dashboard-building
3
+ description: Use when the user asks to build, change, extend, or "show me" a dashboard/UI for their PATTY finances. Guides generating a data-less HTML fragment that fetches live data from the PATTY API and saving it with save_dashboard.
4
+ ---
5
+
6
+ # Building a PATTY dashboard
7
+
8
+ PATTY dashboards are data-less content **fragments** stored server-side and rendered live inside a shared
9
+ app shell at `GET /ui/:name` (ADR-013, fragment model ADR-027). A fragment is `<section>`s + one inline
10
+ `<script>` — no `<!doctype>`, `<html>`, `<head>`, or `<style>` root: the shell (`ui/shell.html` +
11
+ `ui/app.css` + `ui/app.js`, served by the same PATTY HTTP server) already provides the document, shared
12
+ styling, the menu, and Chart.js. The non-negotiable rule behind everything below: **a dashboard never
13
+ contains data — it fetches it.** The fragment you write is layout, styling, and `fetch()` calls; every
14
+ number, name, or row the user sees comes from a same-origin `/api` response read after the fragment loads,
15
+ every time it loads.
16
+
17
+ `save_dashboard` only rejects content that can't render as a fragment at all (empty content, a full
18
+ `<!doctype>`/`<html>` document root still present, an external `<script src>` reference, or a `<script>`
19
+ syntax error) — it does **not** check for embedded data. Following this checklist is what keeps the
20
+ dashboard data-less; the save endpoint won't catch a violation for you.
21
+
22
+ ## Process
23
+
24
+ 1. **Read the API contract first — never guess a path or field name.**
25
+ - MCP: read the `patty://openapi` resource.
26
+ - REST: `GET /api/openapi.json`.
27
+ This is the source of truth for available routes, query params, and response shapes, including the
28
+ localized labels (`typeLabel`, `categoryName`, `periodLabel`, `accountName`, …) the API already resolves
29
+ for the user's locale.
30
+ - **`search_transactions` / `GET /api/transactions` is paginated**: it returns a page
31
+ `{ items, nextCursor?, total? }`, not a bare array. Read `items` for the rows; if you need every
32
+ matching transaction (not just a preview slice), loop: pass the previous response's `nextCursor` back
33
+ as the next request's `cursor` and stop when `nextCursor` is absent. `sort`/`dir` must stay the same
34
+ across that loop — they're bound to the cursor, and changing them mid-walk is rejected. Only ask for
35
+ `includeTotal: true` on the first call if you need the total count (e.g. for a "N transactions" label);
36
+ it costs an extra query and every other page already omits it. Other list endpoints (`list_accounts`,
37
+ `list_categories`, `list_tags`, `list_credit_cards`, `list_recurring`, a bill's `transactions`) are plain
38
+ arrays — the envelope is specifically the signal that a collection can page.
39
+ - **Month views: pass `month` + `year`, never compute the month's boundaries yourself.** `/api/transactions`
40
+ and `/api/aggregate` take `month`+`year` **or** `from`/`to` — send one or the other (`/api/transactions`
41
+ rejects both). `to` is **exclusive** (`date >= from AND date < to`), so a hand-built `to` set to the
42
+ month's last day silently drops every transaction dated on it. If you genuinely need an arbitrary range, `to` is the day *after* the last day
43
+ you want included (a month is `[YYYY-MM-01, first-of-next-month)`, December → next year's `-01-01`).
44
+ 2. **Discover the user's perspective — ask in personal-finance terms, not layout terms.** Different users
45
+ (and the same user in a different financial moment) care about different views. If it isn't already clear,
46
+ offer the common perspectives below (2–4 targeted questions max, with your recommendation) instead of a
47
+ vague "which sections do you want?":
48
+ - **Expense × income by month** [`expense-income-by-month`] (am I earning more than I spend? trend over
49
+ N months) → `aggregate_spending` with `groupBy: month` per type, or per-month `get_spending_summary`.
50
+ - **Where the money goes** [`where-the-money-goes`] (category breakdown, top categories, month over
51
+ month) → `aggregate_spending` with `groupBy: category` (+ `month` for evolution), `get_spending_summary`.
52
+ - **Cash flow / balances now** [`cash-flow`] (what do I have, per account/type) → `get_account_balances`
53
+ (+ `type` filter), accounts list.
54
+ - **Projection** [`projection`] (where will I land at end of month, counting pending/scheduled) →
55
+ `get_account_balances` with `projectedAsOf`, pending transactions via `search_transactions`
56
+ (`status: "pending"`).
57
+ - **Committed / recurring obligations** [`recurring-obligations`] (subscriptions, fixed bills, what's due
58
+ next) → recurring list; card bills via the bills endpoints (status, due dates).
59
+ - **Credit card view** [`credit-card-view`] (current fatura, per-card spend) → the bills endpoint for
60
+ status/dates/total; for the category breakdown, use the bill's own transaction list, not
61
+ `aggregate_spending` — see the note below.
62
+
63
+ **Why not `aggregate_spending` for a card's category breakdown**: it only counts `effective` transactions
64
+ (never `pending`), so on a still-open cycle with pending installment legs the category total will be
65
+ *lower* than the bill's own total shown right above it on the same page — a visible, confusing
66
+ inconsistency, not just an edge case. The bill's transaction list already reflects everything counted
67
+ toward that bill regardless of status, so group those rows by category client-side instead; the two
68
+ figures then always reconcile.
69
+
70
+ Also ask, when relevant: time range (current month vs last N months), which accounts/cards matter, and
71
+ whether they think per-currency (BRL/USD) or mostly one.
72
+ Map each chosen perspective to one real endpoint from the contract you just read. If nothing in the
73
+ contract covers a perspective, say so — either drop it or add a clearly labeled "coming soon" placeholder
74
+ (see the baseline template's Installment projections section). Never invent an endpoint or fabricate a
75
+ number to fill a gap.
76
+ 3. **Decide the save target.** `save_dashboard(name, html)` is an upsert — reusing an existing name replaces
77
+ it immediately, with no version history to recover the previous content. Ask before overwriting a
78
+ dashboard the user may still want, or default to a new name.
79
+ 4. **Start from the baseline fragment as the structural pattern**, not necessarily its content: the seeded
80
+ `overview` dashboard, viewable at `GET /ui/overview` when the HTTP sidecar is running, is `<section>`s +
81
+ one inline `<script>` (no page chrome of its own — the shell provides that), with one `Api` object mapping
82
+ section → endpoint, a per-section loading/empty/error state machine, and per-currency grouping. Reuse that
83
+ shape; change the sections/layout/endpoints to match what the user actually asked for. The fragment's
84
+ script runs its init immediately at the end of the file (it does **not** wait for `DOMContentLoaded` —
85
+ that only fires once for the shell page itself, never per dashboard navigation) since the shell only
86
+ re-executes it after the fragment's markup is already in the page. If you can't view the seeded fragment
87
+ (sidecar not running, or you're running from the published package with no local source to read), that's
88
+ fine — the hard rules and self-check below fully specify a compliant fragment without it.
89
+
90
+ **Optional: live update (ADR-027 Phase 3).** The shell opens one `EventSource` to `/ui/events` for the
91
+ page's whole lifetime and, on every message, calls `window.onAppDataChanged(entities)` if the
92
+ currently-loaded fragment has defined it — `entities` is an array of changed entity tags (e.g.
93
+ `"transaction"`, `"account"`, `"category"`, `"recurring"`, `"tag"`, `"budget"`). Mirror the baseline
94
+ fragment's pattern: map each section to the loader it already has and the entity tags that feed it, refetch
95
+ only the affected ones, and assign the function to `window.onAppDataChanged` as the very last line of
96
+ the script (after the initial `loadAll()`/equivalent). This is optional — a fragment that never sets it
97
+ simply has no live update, same as before this phase — but skipping it means the user has to manually
98
+ reload to see a write reflected.
99
+ 5. **Record the user's preferences in the dashboard itself** so the next change doesn't re-interrogate them:
100
+ put a design-manifest comment at the top of the HTML. The manifest is **closed-shape only — no freeform
101
+ text fields**, so it structurally cannot carry financial data:
102
+ `<!-- patty:dashboard-manifest {"perspectives":["expense-income-by-month","cash-flow"],"range":"last-6-months","currencies":["BRL"]} -->`
103
+
104
+ For a custom period, `range` takes the object form instead of a token — same key, not an extra one:
105
+ `"range":{"from":"2026-01-01","to":"2026-06-30"}` (`YYYY-MM-DD`, matching PATTY's date convention).
106
+
107
+ - `perspectives`: array of tokens from the fixed list in step 2 — `expense-income-by-month`,
108
+ `where-the-money-goes`, `cash-flow`, `projection`, `recurring-obligations`, `credit-card-view`.
109
+ - `range`: either one token — `current-month`, `last-3-months`, `last-6-months`, `last-12-months`,
110
+ `year-to-date` — or the `{"from", "to"}` object above. Never both on the same manifest.
111
+ - `currencies`: ISO codes (`BRL`, `USD`).
112
+ The manifest has exactly these three keys — `perspectives`, `range`, `currencies` — and no others. Ad-hoc
113
+ context ("user tracks X separately") does not go in the manifest — keep it in conversation instead.
114
+ (`get_preferences` returns only `{ locale, localeSource }` today, no dashboard-view state; the manifest
115
+ is where per-dashboard view choices live.)
116
+ 6. **Save it**: call `save_dashboard(name, html)`. If it's rejected (`validation`, 422), the message names
117
+ the render-ability problem (empty content, a full `<!doctype>`/`<html>` root still present, an external
118
+ `<script src>` reference, or a script syntax error) — fix it and resave; the previously stored dashboard
119
+ is untouched by a rejected save.
120
+ 7. **Hand back the URL**: `/ui/<name>` on whatever host/port the user's PATTY HTTP sidecar is running on
121
+ (see the "Manual config and HTTP mode" section of the project's `README.md` — shipped with this package
122
+ — if unsure which). Tell them to open it in a browser.
123
+
124
+ ## Hard rules (never violate these)
125
+
126
+ 1. **Data-less.** No amount, name, date, or other fact from PATTY's data appears literally in the
127
+ HTML/JS source. Every such value is read from a `fetch('/api/...')` response inside a callback, at
128
+ runtime. Config constants (a row limit, a chart color palette, a static section title) are fine; a
129
+ dollar amount, an account name, or a transaction description baked into the source is not.
130
+ 2. **No secrets or tokens** of any kind in the file.
131
+ 3. **Same-origin `/api` only, for data.** Every data fetch path is relative (`/api/...`) — never an
132
+ absolute host — because the dashboard is served from the same PATTY HTTP server it reads from.
133
+ 4. **No external references of your own at all.** The shell already loads a pinned Chart.js from a CDN once
134
+ (`ui/shell.html`) — a fragment just uses the global `Chart` it provides; do not add your own
135
+ `<script src="...chart.js...">` or any other external host (fonts, icons, analytics, other CDNs). A
136
+ fragment's only "outside" references are same-origin `/api` data fetches.
137
+ 5. **Never mix currencies in one figure.** Group and render per currency exactly as the `/api`
138
+ summary/aggregate responses already do (a `currencies` array); never sum or display BRL and USD
139
+ together.
140
+ 6. **Use the localized labels the API returns** (`typeLabel`, `categoryName`, `periodLabel`,
141
+ `accountName`, …) instead of hardcoding English vocabulary or deriving labels from raw enum values.
142
+ 7. **Every fetch-driven section has its own loading, empty, and error state.** A slow or failing endpoint
143
+ degrades that one section — it never blanks or crashes the whole page. Use `aria-live` regions for
144
+ dynamic containers and `role="alert"` on error messages, as the baseline fragment does.
145
+ 8. **Real-time, not cached.** The fragment is re-fetched (no-cache) every time the shell loads it; freshness
146
+ comes from fetching on every load. Never inline a "data as of <time>" snapshot as if it were live — the
147
+ only "as of" text allowed is a client-side "last updated" label set from `new Date()` at fetch time.
148
+ 9. **Accessible and responsive.** Label form controls, use semantic headings/landmarks, and keep the layout
149
+ usable on narrow viewports (see the baseline fragment's `.dashboard-toolbar`/`.cards-grid` classes and
150
+ `ui/app.css`'s `@media` breakpoint).
151
+ 10. **A fragment, not a full page.** No `<!doctype>`, `<html>`, `<head>`, `<body>`, or `<style>` — just the
152
+ `<section>`s and one inline `<script>`, the same shape `save_dashboard` stores and the shell injects into
153
+ `#content`. Shared styling lives in `ui/app.css`; reuse its existing classes (`card`, `cards-grid`,
154
+ `table-wrap`, `data-table`, `state`, `state-error`, `placeholder-card`, …) instead of inventing new ones.
155
+
156
+ ## Overriding an existing dashboard
157
+
158
+ `save_dashboard` is a name-keyed upsert with no rebuild step and no version history: regenerate the full
159
+ fragment (steps 1–5) and call `save_dashboard` again with the same `name` to replace it. Once that save
160
+ succeeds, the previous content is gone — if the user is changing a dashboard they might still want, offer to
161
+ save under a new name instead of overwriting.
162
+
163
+ **Before regenerating, fetch the current dashboard (`GET /api/dashboards/:name`) and read its
164
+ `patty:dashboard-manifest` comment**: preserve the recorded perspectives/range/currency choices unless
165
+ the user is explicitly changing them, and carry the (updated) manifest into the new fragment. A request like
166
+ "add a projections panel" changes one section — it should not silently lose the perspectives the user
167
+ already chose.
168
+
169
+ **If you can't fetch it** — the HTTP sidecar is on by default, so this should be the exception rather than the
170
+ norm: it happens when the sidecar was explicitly disabled (`PATTY_HTTP=false`) or failed to bind (e.g. the
171
+ port was already taken). `GET /api/dashboards/:name` is REST-only, there is no MCP tool that reads a
172
+ dashboard's HTML back (`save_dashboard` is write-only, `list_dashboards` omits HTML), so when the sidecar
173
+ isn't reachable there's no other way to read it. Do not silently rebuild from scratch and tell the user you
174
+ "kept everything the same"; that claim would be unverifiable. Say plainly that you can't read the dashboard's
175
+ current contents back, name the reason (sidecar disabled or not running), and either ask the user to start it
176
+ (see `README.md`'s HTTP-mode section) so you can fetch it, or ask what sections/manifest they currently have
177
+ so nothing gets silently dropped. This fallback works regardless of how PATTY was installed.
178
+
179
+ If you happen to be working from the PATTY source repository itself (not the published package — you
180
+ have a local `src/`/`ui/` to read) *and* the name is `overview` with no evidence it's been customized since
181
+ the seed, you may additionally treat `ui/dashboards/overview.html` (the file-backed default itself, ADR-027
182
+ Phase 2) as a verified stand-in for "the original" instead of asking: diff your new fragment against that
183
+ source before saving, and confirm the diff is purely additive (existing sections untouched, only the
184
+ requested change applied) — don't just assert it. Treat this as an optional shortcut available only in that
185
+ specific environment, not the general-purpose fallback.
186
+
187
+ ## Self-check before calling save_dashboard
188
+
189
+ - [ ] Every displayed number/name is set inside a `fetch(...).then(...)` callback — not a literal in the
190
+ source.
191
+ - [ ] No `const|let|var <name> = [...]`/`{...}` holding what looks like real spending, transaction,
192
+ balance, or account data.
193
+ - [ ] Every data fetch path starts with `/api/` (relative, same-origin); no other external reference at all
194
+ (no own chart-library `<script src>` — the shell already loads one).
195
+ - [ ] Every currency-bearing section groups/loops by `currency` — nothing sums two currencies together.
196
+ - [ ] Every section has a loading, empty, and error branch.
197
+ - [ ] The content is non-empty, does **NOT** start with `<!doctype html>` or have an `<html>` root (the shell
198
+ owns that), and every inline `<script>` is syntactically valid.
199
+ - [ ] The `patty:dashboard-manifest` comment is present, reflects the user's chosen perspectives, and
200
+ contains ONLY the closed-shape keys (`perspectives` tokens, `range` token or from/to dates,
201
+ `currencies` ISO codes) — no freeform text, no extra keys.
@@ -0,0 +1,34 @@
1
+ ---
2
+ name: patty-tour
3
+ description: Use when the user wants a tour or walkthrough of the PATTY demo, asks "show me what PATTY can do", or is trying the demo (the `patty-demo` MCP server). Runs the six-step tour on the demo's sample data; on a real PATTY it only explains how to start the demo.
4
+ ---
5
+
6
+ # Touring the PATTY demo
7
+
8
+ The same tour is available as the `tour` MCP prompt on the `patty-demo` server (Feature Design 022 §6); this
9
+ skill is for Claude clients that prefer skills. Do the steps in order, one at a time: run the tools, say what you
10
+ found in a few sentences, and wait for the person before the next step. Answer in the demo's language, and group
11
+ every figure by currency — never sum across currencies.
12
+
13
+ ## First, check it is the demo
14
+
15
+ Call `get_status`. If it does not report `demo: true`, **stop**: this server holds real data and the tour would
16
+ write sample rows into it. Tell the person to start the demo with
17
+ `npx @rfc0/patty@latest demo` and add it to their client with
18
+ `npx @rfc0/patty@latest setup <client> --demo`, then use the `patty-demo` server.
19
+
20
+ ## The six steps
21
+
22
+ 1. **"What are my balances?"** — `get_account_balances`: accounts, cards, and the total converted to the base currency.
23
+ 2. **"Where did my money go last month?"** — `get_spending_summary` for last month, by category.
24
+ 3. **"Am I over budget?"** — `get_budget_status` for the current month, counting what is still pending.
25
+ 4. **"Import this statement."** — paste a few recent lines (a known merchant or two, one income and one nobody can
26
+ classify), import them into the checking account with `import_account_statement`, and walk through what was
27
+ classified and the line flagged `needs_review`. The `tour` prompt carries a ready sample per country.
28
+ 5. **"Tag everything from my trip as travel, then build me a travel dashboard."** — the demo has one trip, seeded
29
+ untagged across several categories and accounts over about six days. Find it with `search_transactions` by dates
30
+ and descriptions (the destination the `tour` prompt names), create the tag with
31
+ `create_tag`, tag the purchases, then build the dashboard (see the `dashboard-building` skill) and save it with
32
+ `save_dashboard`.
33
+ 6. **"Ready for your own data?"** — explain how to install PATTY for real, that the demo is sample data, and how
34
+ to remove the demo from the client: `npx @rfc0/patty@latest setup <client> --remove-demo`.