zero-debt 0.0.0-stage → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Peyton Cleaver
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,249 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ # zero
2
+
3
+ [![test](https://github.com/aposoloam/zero/actions/workflows/test.yml/badge.svg)](https://github.com/aposoloam/zero/actions/workflows/test.yml)
4
+
5
+ **[try the demo](https://aposoloam.github.io/zero/)**: it runs in your browser with sample numbers, and nothing is sent anywhere.
6
+
7
+ ![zero showing a payoff plan: debt-free by 2027-08, with a line falling to zero](docs/screenshot.png)
8
+
9
+ a local, private debt payoff planner. import your bank and card statements, try
10
+ payoff strategies, and see the month you hit $0.
11
+
12
+ it runs on your own computer. your numbers and your api key stay in a folder you
13
+ can open, read and back up. nothing goes anywhere else unless you ask Claude for
14
+ help.
15
+
16
+ - **am i on track?**: set your plan, check in once a month with your real
17
+ balances, and see whether you're ahead or behind it, on a chart.
18
+ - **the line to zero**: a month-by-month payoff plan. pay the highest rate first,
19
+ the smallest balance first, or your own order. it understands 0% promo deadlines
20
+ and cards you pay in full, and has student mode, extra-shift and one-time
21
+ payment controls.
22
+ - **imports**: OFX/QFX downloads from almost any bank, and csv exports (Capital
23
+ One, Chase and Apple Card are recognized automatically, anything else gets a
24
+ column picker; uk/eu dates and amounts work). Claude reads PDF
25
+ statements and screenshots. importing the same file twice adds nothing.
26
+ - **notes**: plain-language insights worked out on your machine, plus *ask claude*
27
+ for a deeper read using your own Anthropic API key.
28
+ - **yours to change**: four themes, any color, any installed font, one or two
29
+ columns, panes you can reorder or hide, rebindable shortcuts, a command
30
+ palette, and a `settings.json` you can edit by hand.
31
+
32
+ no framework, no build step, no dependencies: Node's standard library on the
33
+ server, plain html, css and javascript modules in the browser.
34
+
35
+ ## run it
36
+
37
+ needs [Node](https://nodejs.org) 22 or newer. one command, nothing to install first:
38
+
39
+ ```sh
40
+ npx github:aposoloam/zero
41
+ ```
42
+
43
+ then open **http://localhost:4321**. your data goes in `~/.zero`. you'll see
44
+ sample numbers first: import a statement, or choose *start empty* from the
45
+ command palette.
46
+
47
+ or work from a clone (data stays in `./data` next to the code):
48
+
49
+ ```sh
50
+ git clone https://github.com/aposoloam/zero.git
51
+ cd zero
52
+ npm start
53
+ ```
54
+
55
+ to use Claude, open settings (<kbd>,</kbd>) → claude → paste your API key from
56
+ [console.anthropic.com](https://console.anthropic.com). zero checks the key with
57
+ Anthropic, then saves it to `data/secrets.json`.
58
+
59
+ | flag / variable | default | |
60
+ |---|---|---|
61
+ | `--port` / `ZERO_PORT` | `4321` | port to listen on (always 127.0.0.1) |
62
+ | `--data` / `ZERO_DATA_DIR` | `./data` in a clone, `~/.zero` with npx | where state, settings and the key are kept |
63
+ | `ANTHROPIC_API_KEY` | none | use this key instead of one saved from the app |
64
+ | `ZERO_MODEL` | from settings | force a model for every Claude call |
65
+
66
+ ## keyboard
67
+
68
+ | key | does |
69
+ |---|---|
70
+ | <kbd>⌘K</kbd> / <kbd>Ctrl K</kbd> | command palette: every action, theme and pane |
71
+ | <kbd>1</kbd>–<kbd>9</kbd> | jump to a pane |
72
+ | <kbd>I</kbd> | import |
73
+ | <kbd>C</kbd> | check in with today's balances |
74
+ | <kbd>A</kbd> | ask claude |
75
+ | <kbd>S</kbd> | student mode on/off |
76
+ | <kbd>/</kbd> | search transactions |
77
+ | <kbd>,</kbd> | settings |
78
+ | <kbd>?</kbd> | all shortcuts |
79
+
80
+ every binding can be changed in settings or in `settings.json`.
81
+
82
+ ![the command palette filtering themes](docs/screenshot-palette.png)
83
+
84
+ ## your data
85
+
86
+ everything lives in one folder: `~/.zero` with npx, or `data/` in a clone (git
87
+ ignores it):
88
+
89
+ ```
90
+ data/
91
+ state.json debts, transactions, plan, category corrections
92
+ settings.json only the settings you changed from the defaults
93
+ secrets.json your api key (owner-only permissions)
94
+ *.bak the previous version of each file, one step of undo
95
+ ```
96
+
97
+ they're plain JSON, so you can back them up, sync them, put them under version
98
+ control in a private repo, or edit them by hand while zero is stopped. *download
99
+ backup* gives you a copy of `state.json`, and importing a backup brings it back.
100
+
101
+ ## staying on track
102
+
103
+ ![the progress pane: plan line, check-ins, ahead or behind](docs/screenshot-progress.png)
104
+
105
+ press <kbd>C</kbd> once a month and type in what each account says you owe. the
106
+ first check-in saves your current forecast as *the plan*. after that, every
107
+ check-in is compared with where the plan said you'd be on that exact day:
108
+
109
+ - **on track**: within $25 or 2% of the plan (payments land a few days either way)
110
+ - **ahead** / **behind**: by how much, with the history in a small table and chart
111
+ - a note reminds you when a month goes by without a check-in
112
+
113
+ check-ins also update your balances, so the forecast above always starts from
114
+ today. *reset plan* starts over from the current forecast.
115
+
116
+ ## customizing
117
+
118
+ ![the phosphor theme](docs/screenshot-phosphor.png)
119
+
120
+ open settings (<kbd>,</kbd>) and scroll to **settings.json**, or edit
121
+ `data/settings.json` directly. anything you leave out uses the default, and any
122
+ invalid value is ignored with a warning in the app.
123
+
124
+ ```json
125
+ {
126
+ "theme": "phosphor",
127
+ "colors": { "accent": "#7aa2f7", "danger": "#ff5f5f" },
128
+ "font": "Berkeley Mono",
129
+ "fontSize": 15,
130
+ "density": "compact",
131
+ "columns": 2,
132
+ "panes": ["payoff", "debts", "plan", "progress", "notes", "flow", "transactions"],
133
+ "wide": ["payoff", "debts", "notes", "flow", "transactions"],
134
+ "dates": "iso",
135
+ "locale": "en-GB",
136
+ "currency": "GBP",
137
+ "chart": { "animate": true, "minimums": true, "promos": true },
138
+ "model": "claude-sonnet-5-5",
139
+ "keys": { "palette": "mod+k", "import": "i", "checkin": "c", "ask": "a", "student": "s", "search": "/", "settings": ",", "help": "?" }
140
+ }
141
+ ```
142
+
143
+ - **themes**: `system` (graph paper by day, ink by night), `graph`, `ink`,
144
+ `phosphor`, `plain`. `colors` overrides any of `bg surface fg muted rule accent
145
+ danger good` on top of the theme.
146
+ - **fonts**: `mono` (JetBrains Mono), `sans` (Hanken Grotesk), or the name of any
147
+ font installed on your computer. both bundled fonts are under the SIL Open
148
+ Font License.
149
+ - **panes**: `payoff progress debts plan notes flow transactions`. the order of `panes`
150
+ is the order on screen. leave one out to hide it. `wide` panes span both
151
+ columns.
152
+
153
+ ## security
154
+
155
+ zero holds financial data and an API key, so the local server is strict:
156
+
157
+ - it only listens on `127.0.0.1`, so nothing else on your network can reach it.
158
+ - every `/api` request must carry this app's own `Host`, a matching `Origin`,
159
+ and an `x-zero` header. that stops websites you visit (including DNS-rebinding
160
+ tricks) from reading your data or spending your key.
161
+ - the API key is written with `0600` permissions, checked with Anthropic before
162
+ it's saved, and never sent back to the browser. the app only ever sees its
163
+ last four characters.
164
+ - Claude's prompts live on the server. the browser can only ask for the two
165
+ fixed jobs (insights, statement reading), so the server can't be used as a
166
+ general Claude relay.
167
+ - *ask claude* sends a summary: totals, your debts, the plan, and your top
168
+ merchants from the last 30 days. it never sends account numbers or full
169
+ transaction lists. statement imports send the file you chose.
170
+ - strict content security policy: only zero's own scripts, styles and fonts. no
171
+ third-party code, no CDNs, no analytics. every imported string is escaped
172
+ before it reaches the page.
173
+ - files are written atomically (write, then rename), so a crash can't leave
174
+ half a file.
175
+
176
+ found a vulnerability? please report it privately. see [SECURITY.md](SECURITY.md).
177
+
178
+ ## troubleshooting
179
+
180
+ - **“port 4321 is already in use”**: zero is probably already running, so open
181
+ http://localhost:4321. or pick another port: `npx github:aposoloam/zero --port 4322`.
182
+ - **the page only says “loading zero…”**: you opened `index.html` straight from
183
+ the folder. start the server with `npm start` and use the localhost address.
184
+ - **“state.json isn’t valid JSON”**: a hand edit broke the file. zero won’t
185
+ touch it until you fix it, or copy `state.json.bak` over it, and reload.
186
+ - **“changed since this tab loaded it”**: zero is open in two tabs. reload the
187
+ tab you're in; the other tab's changes were kept.
188
+ - **a bank's csv imports wrong**: try its OFX/QFX download instead (often
189
+ labelled “Quicken” or “Money”), which is exact. otherwise, in the import preview, pick the right
190
+ columns or tick *flip signs*. day-first dates (UK, EU) and `1.234,56` style
191
+ amounts are detected automatically. if a format still fails, please open an
192
+ issue with the header row and one made-up line.
193
+
194
+ ## demo mode
195
+
196
+ `public/` also works as a plain static site (GitHub Pages, Cloudflare Pages, a
197
+ portfolio). without the server, zero runs in **demo mode**: data stays in that
198
+ browser's localStorage and Claude is off, because API keys are never stored in
199
+ a browser. good for showing it off; run it locally for real use.
200
+
201
+ ## how the math works
202
+
203
+ each month, interest is added to each balance (rate ÷ 12), every minimum is
204
+ paid, and the rest of the monthly budget goes to debts in strategy order. a
205
+ promo rate counts until the month it ends. a card marked *paid in full* never
206
+ accrues interest and is always paid first. money freed by a paid-off debt rolls
207
+ into the next one. `tests/payoff.test.mjs` pins the results to a hand-checked
208
+ spreadsheet.
209
+
210
+ ## project layout
211
+
212
+ ```
213
+ server.js local server: static files, data files, api key, claude
214
+ lib/claude.js the two claude jobs (prompts + structured output)
215
+ public/
216
+ index.html every pane and dialog, top to bottom
217
+ css/zero.css layout and components; colors come from settings
218
+ js/main.js wires the page together (start here)
219
+ js/settings.js themes, defaults, validation for settings.json
220
+ js/api.js server calls, or browser storage in demo mode
221
+ js/payoff.js the payoff simulation (pure, tested)
222
+ js/progress.js plan snapshots and check-ins (pure, tested)
223
+ js/importers.js csv and OFX/QFX parsing, bank presets, column guessing
224
+ js/categorize.js category rules and merchant matching
225
+ js/analysis.js money in/out, categories, merchants
226
+ js/insights.js local notes, and the summary sent to claude
227
+ js/charts.js two hand-drawn svg charts
228
+ js/palette.js command palette
229
+ js/keys.js keyboard shortcuts
230
+ js/state.js data shape, backups, budget math
231
+ js/format.js money/date formatting, html escaping
232
+ js/demo.js made-up sample data
233
+ tests/ node:test, no dependencies — run `npm test`
234
+ ```
235
+
236
+ ## contributing
237
+
238
+ - **another bank's csv**: add an entry to `PRESETS` in `public/js/importers.js`
239
+ (the header columns it must have, and how to read one row), and a test in
240
+ `tests/importers.test.mjs`.
241
+ - **a merchant categorized wrong**: add a pattern to `RULES` in
242
+ `public/js/categorize.js`.
243
+ - **a theme**: add it to `THEMES` in `public/js/settings.js`.
244
+
245
+ keep it dependency-free and readable without a build step. `npm test` must pass.
246
+
247
+ ## license
248
+
249
+ MIT
package/lib/claude.js ADDED
@@ -0,0 +1,148 @@
1
+ // lib/claude.js — the two jobs zero asks Claude to do, and the call that runs them.
2
+ //
3
+ // Prompts live here on the server, never in the browser, so the local API can't be
4
+ // turned into a general-purpose Claude relay. Each job forces a tool call, so the
5
+ // answer always comes back as structured JSON.
6
+
7
+ export const DEFAULT_MODEL = 'claude-sonnet-5-5';
8
+ const API = () => process.env.ZERO_ANTHROPIC_URL || 'https://api.anthropic.com';
9
+
10
+ export const JOBS = {
11
+ insights: {
12
+ system: `You are a blunt, kind money coach for someone who wants out of credit card debt as fast as possible.
13
+ You get a JSON summary: income, spending, a payoff plan already calculated by their app, their debts, and the last 30 days of spending by category and merchant.
14
+ Give 4 to 6 notes they can act on this week. Rules:
15
+ - Use their real numbers and merchant names. Every note names a dollar amount.
16
+ - Prioritize by dollars saved or months shaved off. Interest and promo deadlines first.
17
+ - Do not repeat the plan back to them; add what the plan doesn't already say.
18
+ - Never suggest new credit, loans, gambling, crypto, or skipping minimums. Don't moralize about giving or religion.
19
+ - Write in lowercase, plain and warm, one or two short sentences per note.
20
+ - monthly_impact is the rough dollars per month the note frees up or saves, or null.`,
21
+ tool: {
22
+ name: 'notes',
23
+ description: 'Return the coaching notes.',
24
+ input_schema: {
25
+ type: 'object',
26
+ properties: {
27
+ notes: {
28
+ type: 'array', minItems: 1, maxItems: 6,
29
+ items: {
30
+ type: 'object',
31
+ properties: { title: { type: 'string' }, body: { type: 'string' }, monthly_impact: { type: ['number', 'null'] } },
32
+ required: ['title', 'body', 'monthly_impact'],
33
+ },
34
+ },
35
+ one_thing: { type: 'string', description: 'the single most important thing to do first, one sentence' },
36
+ },
37
+ required: ['notes', 'one_thing'],
38
+ },
39
+ },
40
+ maxTokens: 1500,
41
+ content: (payload) => [{ type: 'text', text: `here's my money summary:\n${JSON.stringify(payload)}` }],
42
+ },
43
+
44
+ extract: {
45
+ system: `You read bank and credit card statements (PDFs or app screenshots) and return every transaction you can see.
46
+ - amount is signed from the account holder's point of view: money in is positive, money out (purchases, fees, interest, withdrawals) is negative. On a credit card a payment or refund is positive, a purchase is negative.
47
+ - dates as YYYY-MM-DD. If a screenshot says "Friday" or "yesterday", work out the date from the newest dated row or the statement period; if you can't, skip that row.
48
+ - skip rows whose amount is hidden or cut off, and list them in skipped.
49
+ - If the statement shows a balance, APR, promo rate, minimum payment or due date, fill in debt; otherwise debt is null.
50
+ - Never return full account or card numbers.`,
51
+ tool: {
52
+ name: 'statement',
53
+ description: 'Return the transactions and account details found.',
54
+ input_schema: {
55
+ type: 'object',
56
+ properties: {
57
+ account_name: { type: 'string', description: 'short name like "Apple Card" or "Capital One checking"' },
58
+ transactions: {
59
+ type: 'array',
60
+ items: {
61
+ type: 'object',
62
+ properties: { date: { type: 'string' }, description: { type: 'string' }, amount: { type: 'number' } },
63
+ required: ['date', 'description', 'amount'],
64
+ },
65
+ },
66
+ skipped: { type: 'array', items: { type: 'string' } },
67
+ debt: {
68
+ type: ['object', 'null'],
69
+ properties: {
70
+ balance: { type: 'number' }, apr: { type: ['number', 'null'] }, promo_apr: { type: ['number', 'null'] },
71
+ promo_end: { type: ['string', 'null'] }, minimum_payment: { type: ['number', 'null'] }, due_date: { type: ['string', 'null'] },
72
+ },
73
+ },
74
+ },
75
+ required: ['account_name', 'transactions', 'skipped', 'debt'],
76
+ },
77
+ },
78
+ maxTokens: 8000,
79
+ content: ({ mediaType, data }) => [
80
+ mediaType === 'application/pdf'
81
+ ? { type: 'document', source: { type: 'base64', media_type: mediaType, data } }
82
+ : { type: 'image', source: { type: 'base64', media_type: mediaType, data } },
83
+ { type: 'text', text: 'pull every transaction from this statement.' },
84
+ ],
85
+ },
86
+ };
87
+
88
+ const FILE_TYPES = ['application/pdf', 'image/png', 'image/jpeg', 'image/webp'];
89
+ const MAX_SUMMARY = 30 * 1024;
90
+
91
+ /** Returns an error message for a bad payload, or null if it's fine. */
92
+ export function checkPayload(task, payload) {
93
+ if (task === 'insights') {
94
+ if (!payload || typeof payload !== 'object' || Array.isArray(payload)) return 'the summary is missing';
95
+ if (JSON.stringify(payload).length > MAX_SUMMARY) return 'the summary is too large';
96
+ return null;
97
+ }
98
+ if (task === 'extract') {
99
+ const { mediaType, data } = payload || {};
100
+ if (!FILE_TYPES.includes(mediaType)) return 'upload a PDF, PNG, JPEG or WebP';
101
+ if (typeof data !== 'string' || !/^[A-Za-z0-9+/=]+$/.test(data)) return 'the file data is not valid base64';
102
+ return null;
103
+ }
104
+ return 'unknown task';
105
+ }
106
+
107
+ const headers = (key) => ({ 'content-type': 'application/json', 'x-api-key': key, 'anthropic-version': '2023-06-01' });
108
+
109
+ /** Runs a job. Resolves to { result } or { error, status }. Never includes the key in errors. */
110
+ export async function runJob(key, model, task, payload) {
111
+ const job = JOBS[task];
112
+ let res;
113
+ try {
114
+ res = await fetch(`${API()}/v1/messages`, {
115
+ method: 'POST',
116
+ headers: headers(key),
117
+ body: JSON.stringify({
118
+ model: model || DEFAULT_MODEL,
119
+ max_tokens: job.maxTokens,
120
+ system: job.system,
121
+ tools: [job.tool],
122
+ tool_choice: { type: 'tool', name: job.tool.name },
123
+ messages: [{ role: 'user', content: job.content(payload) }],
124
+ }),
125
+ });
126
+ } catch {
127
+ return { error: 'couldn’t reach the anthropic api. check your connection.', status: 502 };
128
+ }
129
+ if (res.status === 401) return { error: 'anthropic rejected the api key. replace it in settings.', status: 401 };
130
+ if (res.status === 404) return { error: `the model “${model}” wasn’t found. change it in settings.`, status: 400 };
131
+ if (res.status === 429 || res.status === 529) return { error: 'claude is busy or you hit a rate limit. try again in a minute.', status: 503 };
132
+ if (!res.ok) return { error: `the anthropic api answered ${res.status}.`, status: 502 };
133
+ const data = await res.json();
134
+ const block = (data.content || []).find((b) => b.type === 'tool_use');
135
+ return block ? { result: block.input } : { error: 'claude returned an unexpected answer.', status: 502 };
136
+ }
137
+
138
+ /** Checks a key by listing models. Resolves to 'valid', 'invalid' or 'unverified' (offline). */
139
+ export async function verifyKey(key) {
140
+ try {
141
+ const res = await fetch(`${API()}/v1/models?limit=1`, { headers: headers(key) });
142
+ if (res.ok) return 'valid';
143
+ if (res.status === 401 || res.status === 403) return 'invalid';
144
+ return 'unverified';
145
+ } catch {
146
+ return 'unverified';
147
+ }
148
+ }
package/package.json CHANGED
@@ -1,6 +1,18 @@
1
- {
2
- "name": "zero-debt",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
1
+ {
2
+ "name": "zero-debt",
3
+ "version": "2.2.0",
4
+ "description": "a local, private debt payoff planner. import statements, try payoff strategies, see the month you hit $0.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "bin": { "zero-debt": "server.js" },
8
+ "files": ["server.js", "lib/", "public/", "README.md", "LICENSE"],
9
+ "engines": { "node": ">=22" },
10
+ "repository": { "type": "git", "url": "git+https://github.com/aposoloam/zero.git" },
11
+ "homepage": "https://aposoloam.github.io/zero/",
12
+ "bugs": "https://github.com/aposoloam/zero/issues",
13
+ "keywords": ["debt", "debt-payoff", "personal-finance", "budget", "self-hosted", "local-first", "privacy"],
14
+ "scripts": {
15
+ "start": "node server.js",
16
+ "test": "node --test tests/*.test.mjs"
17
+ }
18
+ }