ray-finance 0.2.2 → 0.2.4

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 (82) hide show
  1. package/README.md +38 -11
  2. package/dist/ai/agent.js +16 -3
  3. package/dist/ai/context.js +6 -2
  4. package/dist/ai/insights.js +26 -3
  5. package/dist/ai/redactor.js +11 -0
  6. package/dist/ai/system-prompt.js +2 -2
  7. package/dist/ai/tools.js +4 -0
  8. package/dist/cli/backup.js +18 -9
  9. package/dist/cli/chat.js +146 -40
  10. package/dist/cli/format.d.ts +2 -0
  11. package/dist/cli/format.js +25 -0
  12. package/dist/cli/index.js +12 -2
  13. package/dist/cli/setup.js +7 -1
  14. package/dist/daily-sync.js +19 -4
  15. package/dist/db/connection.js +9 -1
  16. package/dist/db/encryption.js +18 -7
  17. package/dist/db/schema.js +6 -1
  18. package/dist/public/link.html +47 -24
  19. package/dist/public/ray-logo-dark.png +0 -0
  20. package/dist/queries/index.js +8 -8
  21. package/dist/server.js +33 -1
  22. package/package.json +7 -2
  23. package/.claude/settings.local.json +0 -16
  24. package/.env.example +0 -13
  25. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -19
  26. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -9
  27. package/.github/PULL_REQUEST_TEMPLATE.md +0 -5
  28. package/.github/workflows/ci.yml +0 -21
  29. package/CHANGELOG.md +0 -16
  30. package/CODE_OF_CONDUCT.md +0 -31
  31. package/CONTRIBUTING.md +0 -41
  32. package/Dockerfile +0 -8
  33. package/SECURITY.md +0 -36
  34. package/SPEC.md +0 -374
  35. package/docker-compose.yml +0 -9
  36. package/site/next-env.d.ts +0 -6
  37. package/site/next.config.ts +0 -7
  38. package/site/package-lock.json +0 -1661
  39. package/site/package.json +0 -24
  40. package/site/postcss.config.mjs +0 -7
  41. package/site/public/ray-og.jpg +0 -0
  42. package/site/public/robots.txt +0 -4
  43. package/site/public/sitemap.xml +0 -8
  44. package/site/src/app/copy-command.tsx +0 -31
  45. package/site/src/app/globals.css +0 -87
  46. package/site/src/app/layout.tsx +0 -64
  47. package/site/src/app/page.tsx +0 -841
  48. package/site/src/app/pii-scramble.tsx +0 -190
  49. package/site/src/app/reveal.tsx +0 -29
  50. package/site/tsconfig.json +0 -21
  51. package/src/ai/agent.ts +0 -106
  52. package/src/ai/audit.ts +0 -11
  53. package/src/ai/context.ts +0 -93
  54. package/src/ai/insights.ts +0 -474
  55. package/src/ai/memory.ts +0 -21
  56. package/src/ai/redactor.ts +0 -102
  57. package/src/ai/system-prompt.ts +0 -90
  58. package/src/ai/tools.ts +0 -716
  59. package/src/alerts/index.ts +0 -123
  60. package/src/cli/backup.ts +0 -113
  61. package/src/cli/chat.ts +0 -105
  62. package/src/cli/commands.ts +0 -240
  63. package/src/cli/format.ts +0 -149
  64. package/src/cli/index.ts +0 -193
  65. package/src/cli/scheduler.ts +0 -116
  66. package/src/cli/setup.ts +0 -189
  67. package/src/config.ts +0 -81
  68. package/src/daily-sync.ts +0 -155
  69. package/src/db/connection.ts +0 -38
  70. package/src/db/encryption.ts +0 -29
  71. package/src/db/helpers.ts +0 -47
  72. package/src/db/schema.ts +0 -196
  73. package/src/index.ts +0 -3
  74. package/src/plaid/client.ts +0 -25
  75. package/src/plaid/link.ts +0 -25
  76. package/src/plaid/sync.ts +0 -219
  77. package/src/public/link.html +0 -161
  78. package/src/queries/index.ts +0 -586
  79. package/src/scoring/index.ts +0 -468
  80. package/src/server.ts +0 -162
  81. package/tsconfig.json +0 -16
  82. /package/{site → dist}/public/favicon.png +0 -0
package/SPEC.md DELETED
@@ -1,374 +0,0 @@
1
- # Ray Finance — Open Source Product Spec
2
-
3
- ## Vision
4
-
5
- An open-source, local-first CLI that turns your bank data into a personal AI financial advisor. Everything runs on your machine. Your data never leaves your computer except for Plaid API calls (to sync bank data), Anthropic API calls (for AI chat), and optionally Resend API calls (for email digests).
6
-
7
- **Target audience:** Engineers who are finance-minded and want to optimize. People who'd rather query a SQLite database than open a budgeting app.
8
-
9
- **Positioning:** "Your finances in a local SQLite database. AI-powered. Private by design."
10
-
11
- ---
12
-
13
- ## What Exists Today
14
-
15
- `ray-finance` is a fully functional personal finance AI agent built for couples. Current architecture:
16
-
17
- | Layer | Status | Files |
18
- |-------|--------|-------|
19
- | Plaid integration (sync, balances, investments, liabilities) | ✅ Complete | `plaid/client.ts`, `sync.ts`, `link.ts` |
20
- | Encrypted SQLite database (multi-tenant capable) | ✅ Complete | `db/connection.ts`, `schema.ts`, `encryption.ts` |
21
- | AI agent (Claude + tool use, agentic loop) | ✅ Complete | `ai/agent.ts`, `tools.ts`, `system-prompt.ts` |
22
- | 13 AI tools (net worth, transactions, budgets, goals, etc.) | ✅ Complete | `ai/tools.ts` |
23
- | Conversation memory + long-term memories | ✅ Complete | `ai/memory.ts` |
24
- | Daily scoring (0-100) + streaks | ✅ Complete | `scoring/index.ts` |
25
- | 14 achievements (gamification) | ✅ Complete | `scoring/index.ts` |
26
- | Alerts (large txns, low balance, budget overruns, price changes) | ✅ Complete | `alerts/index.ts` |
27
- | Daily sync + auto-recategorization (DB-driven rules) | ✅ Complete | `daily-sync.ts` |
28
- | Plaid Link web UI (bank connection flow) | ✅ Complete | `public/link.html`, `server.ts` |
29
- | Telegram bot interface | ✅ Complete | `telegram/bot.ts` |
30
- | Multi-tenant registry (hosted mode) | ✅ Complete | `db/registry.ts` |
31
- | Audit logging | ✅ Complete | `ai/audit.ts` |
32
- | Docker deployment | ✅ Complete | `Dockerfile`, `docker-compose.yml` |
33
- | Debt payoff simulator | ✅ Complete | `db/helpers.ts` |
34
-
35
- ---
36
-
37
- ## What Needs to Change
38
-
39
- ### 1. Remove Telegram, Add CLI
40
-
41
- **Strip:** `telegram/bot.ts`, Telegram references in `index.ts` and `config.ts`.
42
-
43
- **Add:** A CLI interface that replaces Telegram as the primary interaction layer.
44
-
45
- ```
46
- ray # Interactive chat with your AI financial advisor
47
- ray sync # Pull latest from Plaid
48
- ray link # Connect a new bank account (opens browser)
49
- ray status # Quick dashboard: balances, budgets, score
50
- ray transactions # Recent transactions
51
- ray spending [period] # Spending summary
52
- ray budgets # Budget status
53
- ray goals # Goal progress
54
- ray score # Today's score + streaks
55
- ray alerts # Active alerts
56
- ray forecast # Project checking account balance through end of month
57
- ray digest # Send daily digest email now
58
- ray setup # Interactive first-run wizard
59
- ```
60
-
61
- `ray` with no args drops into an interactive chat session — same AI agent, same tools, but in the terminal. Think `claude` CLI but for your finances.
62
-
63
- ### 2. Setup Wizard (`ray setup`)
64
-
65
- ```
66
- $ ray setup
67
-
68
- Welcome to Ray 🐟
69
-
70
- Your AI-powered financial advisor. Everything runs locally.
71
-
72
- Step 1: Plaid API keys
73
- → Get free Development keys at https://dashboard.plaid.com/signup
74
- Client ID: ________
75
- Secret: ________
76
-
77
- Step 2: Connect your bank
78
- → Opening Plaid Link in your browser...
79
- ✓ Connected: Bank of America (3 accounts)
80
- ✓ Synced 847 transactions
81
-
82
- Step 3: Anthropic API key (for AI chat)
83
- → Get one at https://console.anthropic.com
84
- API key: ________
85
-
86
- Step 4: Daily digest email (optional)
87
- → Send daily email summaries via Resend
88
- Resend API key: ________ (skip with Enter)
89
- Email address: ________
90
-
91
- Step 5: Scheduled sync (optional)
92
- → Set up automatic daily sync at 7am?
93
- ✓ Created launchd agent (macOS) / cron job (Linux)
94
-
95
- ✓ Setup complete. Run `ray` to start chatting.
96
- ```
97
-
98
- Stores config in `~/.ray/config.json`, database in `~/.ray/data/finance.db`.
99
-
100
- ### 3. Port Features from Personal Ray (`/Developer/ray`)
101
-
102
- The personal `ray` project has battle-tested features that `ray-finance` doesn't:
103
-
104
- | Feature | Personal `ray` | `ray-finance` | Action |
105
- |---------|---------------|---------------|--------|
106
- | Checking account forecast | ✅ Full | ❌ Missing | Port & generalize `forecast/bills-account.ts` |
107
- | Daily digest email | ✅ Minimal (just rebuilt) | ❌ Missing | Port the new 5-section minimal digest |
108
- | Leakage tracking | ✅ Just built | ❌ Missing | Port, generalize for any account-to-account transfers |
109
- | Auto-recategorization | Hardcoded | DB-driven rules table | `ray-finance` approach is better — keep it |
110
- | Net worth + property tracking | ✅ Redfin integration | ✅ Basic snapshots | Port Redfin scraper as optional plugin |
111
- | Debt payoff simulation | Basic | ✅ `simulatePayoff()` | Already in `ray-finance` |
112
- | Investment holdings sync | Manual | ✅ Plaid native | `ray-finance` is better |
113
-
114
- ### 4. Package & Distribution
115
-
116
- ```bash
117
- # Run directly
118
- npx ray-finance setup
119
-
120
- # Or clone and link
121
- git clone https://github.com/clarkdinnison/ray-finance
122
- cd ray-finance && npm install && npm link
123
- ```
124
-
125
- Global CLI binary via `package.json` `"bin"` field pointing to compiled `dist/cli/index.js`.
126
-
127
- ### 5. Data Structure
128
-
129
- ```
130
- ~/.ray/
131
- config.json # API keys, preferences, email settings
132
- data/
133
- finance.db # All financial data (encrypted SQLite)
134
- ```
135
-
136
- Nothing else. One config file, one database. Portable, backupable, inspectable.
137
-
138
- ---
139
-
140
- ## CLI Commands — Detailed
141
-
142
- ### `ray` (interactive chat)
143
-
144
- Opens an interactive session with the AI financial advisor. Same Claude agent + tool use as the Telegram bot, but in the terminal.
145
-
146
- ```
147
- $ ray
148
-
149
- Ray 🐟 — Your AI financial advisor
150
- Type 'quit' to exit. All data is local.
151
-
152
- You: How much did we spend on food this month?
153
-
154
- Ray: You've spent $310 on food this month — $142 on groceries and $168 on
155
- restaurants/coffee. That's 34% of your $900 budget with 23 days left.
156
- You're on pace to hit about $425, well under budget.
157
-
158
- You: What's our net worth?
159
-
160
- Ray: $508,629 — up $247 from yesterday.
161
- Home equity: $450K | Investments: $83K | Cash: $2,600
162
- Credit card debt: $29,036 (your biggest drag — getting paid down at $535 biweekly)
163
-
164
- You: quit
165
- ```
166
-
167
- ### `ray status`
168
-
169
- Quick dashboard, no AI call needed. Pure DB queries.
170
-
171
- ```
172
- $ ray status
173
-
174
- Free to Spend $26.31 Next paycheck in 5 days
175
- Bills Account $2,955
176
- Savings $760
177
- Credit Card -$29,036
178
-
179
- Net Worth $508,629 +$247 yesterday
180
-
181
- Score 72/100 🍳 3d no restaurants
182
-
183
- Budgets
184
- ● Food $310 / $900 34%
185
- ● Shopping $546 / $500 OVER
186
- ● Entertainment $80 / $565 14%
187
- ```
188
-
189
- ### `ray sync`
190
-
191
- ```
192
- $ ray sync
193
-
194
- Syncing Bank of America...
195
- Accounts: 4 updated
196
- Transactions: +23 new, ~2 modified
197
- Auto-recategorized: 3 transactions
198
-
199
- Net worth: $508,629 (+$247)
200
- Score (yesterday): 72/100
201
- ```
202
-
203
- ### `ray forecast`
204
-
205
- ```
206
- $ ray forecast
207
-
208
- Bills Account Forecast — $2,955 available
209
-
210
- Mar 13 💵 $3,906 Paycheck +$5,016, Mortgage -$2,647, CC auto-pay -$535
211
- Mar 20 $2,536 Honda -$586, Edison -$206, subs
212
- Mar 26 $1,759 ← lowest point (above $1,500 buffer ✅)
213
- Mar 27 💵 $9,740 Paycheck +$5,016, Rent income +$3,500, CC auto-pay -$535
214
- Mar 31 $4,350 Rent -$4,300
215
-
216
- Surplus: $3,850 above $500 buffer
217
- ```
218
-
219
- ### `ray digest`
220
-
221
- Sends the daily email digest immediately. Same minimal format:
222
- 1. Free to Spend balance + paycheck countdown
223
- 2. Yesterday's spending
224
- 3. Leakage warning (if any)
225
- 4. One context line
226
- 5. Net worth
227
-
228
- ---
229
-
230
- ## File Changes
231
-
232
- ### Delete
233
- - `src/telegram/bot.ts`
234
-
235
- ### Rewrite
236
- - `src/index.ts` → CLI entry point with commander
237
- - `src/config.ts` → Read from `~/.ray/config.json` instead of `.env`
238
- - `src/server.ts` → Minimal, only runs temporarily during `ray link`
239
-
240
- ### Add
241
- - `src/cli/index.ts` — Main CLI router (commander)
242
- - `src/cli/chat.ts` — Interactive AI chat session (replaces Telegram)
243
- - `src/cli/setup.ts` — First-run wizard (prompts for API keys, runs Plaid Link)
244
- - `src/cli/status.ts` — Quick dashboard
245
- - `src/cli/commands.ts` — All subcommands (sync, forecast, budgets, etc.)
246
- - `src/emails/daily-digest.ts` — Port minimal digest from personal ray
247
- - `src/forecast/index.ts` — Port & generalize checking account forecast
248
-
249
- ### Keep As-Is
250
- - `src/plaid/*` — Plaid client, sync, link (already clean)
251
- - `src/db/*` — Database connection, schema, encryption, helpers
252
- - `src/ai/*` — Agent, tools, system prompt, memory, audit
253
- - `src/queries/*` — All financial queries
254
- - `src/scoring/*` — Daily scoring + achievements
255
- - `src/alerts/*` — Alert generation
256
- - `src/daily-sync.ts` — Daily sync orchestrator
257
- - `src/public/link.html` — Plaid Link web page
258
-
259
- ---
260
-
261
- ## Daily Digest Email (Minimal)
262
-
263
- Ported from personal ray. Five sections max:
264
-
265
- 1. **Free to Spend balance** — the one number that matters. Paycheck countdown.
266
- 2. **Yesterday's spending** — amount + merchant names. Or "Nothing spent."
267
- 3. **Leakage** — only if transfers detected between accounts. Hidden when clean.
268
- 4. **One context line** — rotating factual reminder (next auto-pay, milestone countdown, etc.)
269
- 5. **Net worth** — one line at the bottom.
270
-
271
- Subject: `Daily Finance Update`
272
-
273
- Users configure digest in setup: Resend API key + recipient emails. Optional — Ray works fine without email.
274
-
275
- ---
276
-
277
- ## Scoring System
278
-
279
- Already built in `scoring/index.ts`. Daily score 0-100:
280
-
281
- - Base: 50
282
- - No restaurants: +15
283
- - No shopping: +15
284
- - Food under daily pace: +10
285
- - Total discretionary under $50: +10
286
- - Zero-spend day: +25
287
-
288
- Streaks tracked: no-restaurant, no-shopping, all-budgets-on-pace.
289
-
290
- 14 achievements: Kitchen Hero, Home Chef, Zero Hero, Monk Mode, Debt Crusher, Half Millionaire, etc.
291
-
292
- ---
293
-
294
- ## Security & Privacy
295
-
296
- - **All financial data stored locally** in `~/.ray/data/finance.db`
297
- - **Database encrypted** with AES-256 via `better-sqlite3-multiple-ciphers`
298
- - **Plaid access tokens encrypted at rest** with separate key
299
- - **Outbound API calls only:**
300
- - Plaid (bank sync) — required
301
- - Anthropic (AI chat) — required for `ray` chat, not for `ray status/sync/forecast`
302
- - Resend (email digest) — optional
303
- - **No telemetry, no analytics, no phoning home**
304
- - **Open source** — inspect every line
305
-
306
- ---
307
-
308
- ## README Structure
309
-
310
- 1. **Hero** — One-liner + demo GIF
311
- 2. **What Ray Does** — Feature list with terminal screenshots
312
- 3. **Quick Start** — `npx ray-finance setup`
313
- 4. **Commands** — Reference for all CLI commands
314
- 5. **Daily Digest** — Screenshot of the email + setup instructions
315
- 6. **How It Works** — Architecture diagram (Plaid → SQLite → CLI/Email)
316
- 7. **Security** — What data goes where, encryption details
317
- 8. **Configuration** — All config options
318
- 9. **Auto-Recategorization** — How to add custom rules
319
- 10. **Contributing** — How to contribute
320
- 11. **Ray Cloud** — "Don't want to set this up? Join the waitlist."
321
-
322
- ---
323
-
324
- ## Landing Page
325
-
326
- Simple page at `rayfinance.dev` (or similar):
327
-
328
- - Demo video (2 min: setup → sync → chat → digest arriving on phone)
329
- - GitHub link with star count
330
- - Feature highlights with terminal screenshots
331
- - "Ray Cloud — coming soon" waitlist (email capture)
332
- - Security section (local-first, encrypted, open source)
333
-
334
- ---
335
-
336
- ## Launch Plan
337
-
338
- ### Week 1: Build
339
- - [ ] CLI scaffold with commander (index, setup, status, chat)
340
- - [ ] Port daily digest + forecast from personal ray
341
- - [ ] `ray setup` wizard (Plaid keys, bank link, Anthropic key, email config)
342
- - [ ] Scheduled sync (launchd on macOS, cron on Linux)
343
- - [ ] Polish `ray status` output
344
-
345
- ### Week 2: Package & Document
346
- - [ ] Clean up README with demo GIF and screenshots
347
- - [ ] `npm publish` as global CLI
348
- - [ ] Landing page with demo video + waitlist
349
- - [ ] Record 2-minute demo video
350
-
351
- ### Week 3: Launch
352
- - [ ] Hacker News — "Show HN: I built an open-source CLI that turns your bank data into a local AI financial advisor"
353
- - [ ] Reddit — r/selfhosted, r/personalfinance, r/commandline, r/node
354
- - [ ] Twitter/X — build-in-public thread showing the real product
355
- - [ ] Product Hunt
356
-
357
- ### Post-Launch
358
- - [ ] Monitor waitlist signups for Ray Cloud demand
359
- - [ ] Community feedback → iterate on CLI
360
- - [ ] If waitlist > 500: build Ray Cloud (hosted version, email-based, no setup required)
361
-
362
- ---
363
-
364
- ## Future: Ray Cloud (if demand exists)
365
-
366
- Hosted version for non-engineers. No CLI, no Plaid keys, no setup.
367
-
368
- - Sign up → connect bank → get daily digest email
369
- - Reply to email to ask Ray questions
370
- - $29-49/mo subscription
371
- - Powered by the same `ray-finance` codebase with a web onboarding layer
372
- - Clark's Plaid production keys handle all bank connections
373
-
374
- **Only build this if the open source launch validates demand via the waitlist.**
@@ -1,9 +0,0 @@
1
- services:
2
- ray:
3
- build: .
4
- env_file: .env
5
- volumes:
6
- - ./data:/app/data
7
- ports:
8
- - "3000:3000"
9
- restart: unless-stopped
@@ -1,6 +0,0 @@
1
- /// <reference types="next" />
2
- /// <reference types="next/image-types/global" />
3
- /// <reference path="./.next/types/routes.d.ts" />
4
-
5
- // NOTE: This file should not be edited
6
- // see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
@@ -1,7 +0,0 @@
1
- import type { NextConfig } from "next";
2
-
3
- const nextConfig: NextConfig = {
4
- output: "export",
5
- };
6
-
7
- export default nextConfig;