@trajectonomics/cli 0.9.0-alpha.79 → 0.9.0-alpha.80
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/README.md +103 -99
- package/bin/launcher.js +1 -1
- package/bin/{traj.js → openretire.js} +5 -3
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
#
|
|
1
|
+
# OpenRetire
|
|
2
2
|
|
|
3
|
-
`
|
|
4
|
-
operates it. The command line never calls a model, so every result is repeatable.
|
|
3
|
+
`openretire` is free, open-source financial simulation software for the AI era, and an AI agent
|
|
4
|
+
operates it. The command line never calls a model, so every result is repeatable. `traj`, its
|
|
5
|
+
earlier name, still runs the same program.
|
|
5
6
|
|
|
6
|
-
The
|
|
7
|
-
[trajectonomics.com/docs/](https://trajectonomics.com/docs/).
|
|
7
|
+
The product page is [trajectonomics.com/openretire/](https://trajectonomics.com/openretire/) and
|
|
8
|
+
the docs are at [trajectonomics.com/docs/](https://trajectonomics.com/docs/).
|
|
8
9
|
|
|
9
10
|
## Install
|
|
10
11
|
|
|
11
|
-
Linux and macOS, one line (verifies the release checksum, installs `traj`
|
|
12
|
-
or `$TRAJ_INSTALL_DIR`, and prints what it installed):
|
|
12
|
+
Linux and macOS, one line (verifies the release checksum, installs `openretire` and a `traj` link
|
|
13
|
+
to `~/.local/bin`, or into `$TRAJ_INSTALL_DIR`, and prints what it installed):
|
|
13
14
|
|
|
14
15
|
```bash
|
|
15
16
|
curl -fsSL https://github.com/trajectonomics/trajectonomics/releases/latest/download/install.sh | sh
|
|
16
17
|
```
|
|
17
18
|
|
|
18
|
-
Windows, one line (installs to `%LOCALAPPDATA%\traj\bin`,
|
|
19
|
-
and needs a new shell afterwards):
|
|
19
|
+
Windows, one line (installs `openretire.exe` and a `traj.exe` copy to `%LOCALAPPDATA%\traj\bin`,
|
|
20
|
+
adds it to the user `PATH` once, and needs a new shell afterwards):
|
|
20
21
|
|
|
21
22
|
```powershell
|
|
22
23
|
irm https://github.com/trajectonomics/trajectonomics/releases/latest/download/install.ps1 | iex
|
|
@@ -50,20 +51,20 @@ use `npx`, so they need Node, which the npm channel already requires; the instal
|
|
|
50
51
|
do not.
|
|
51
52
|
|
|
52
53
|
Which channel: all three end at the same compiled binary and the same version. Use the
|
|
53
|
-
script for a machine that should keep `
|
|
54
|
+
script for a machine that should keep `openretire` on `PATH`, npm when you already have Node or
|
|
54
55
|
Bun and want one command. Pin a release with `TRAJ_VERSION=X.Y.Z` for the script, or
|
|
55
56
|
`@X.Y.Z` for npm.
|
|
56
57
|
|
|
57
|
-
Uninstall by
|
|
58
|
-
|
|
59
|
-
`npx`.
|
|
58
|
+
Uninstall by removing both names: `~/.local/bin/openretire` and the `traj` link beside it, the
|
|
59
|
+
whole `%LOCALAPPDATA%\traj\bin` directory (it holds `openretire.exe` and the `traj.exe` copy),
|
|
60
|
+
`~/.traj/bin` (the download cache only; your ledger is beside it), or nothing at all for `npx`.
|
|
60
61
|
|
|
61
|
-
`
|
|
62
|
+
`openretire` keeps the ledger in `~/.traj/traj.db`, or in `traj.db` inside `TRAJ_HOME` when that is
|
|
62
63
|
set, the same path on Linux, macOS and Windows. Beside it is the disposable `bin/` download
|
|
63
64
|
cache; deleting the data directory deletes the ledger. Take a lossless copy with:
|
|
64
65
|
|
|
65
66
|
```bash
|
|
66
|
-
|
|
67
|
+
openretire export --format jsonl --out backup
|
|
67
68
|
```
|
|
68
69
|
|
|
69
70
|
`--out` names a directory that must not exist yet, and JSONL is the only lossless export
|
|
@@ -74,12 +75,12 @@ format.
|
|
|
74
75
|
The ledger is one record, and the first run builds it in order:
|
|
75
76
|
|
|
76
77
|
```bash
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
openretire init
|
|
79
|
+
openretire account add Cash --type asset --currency THB
|
|
80
|
+
openretire account add Food --type expense --currency THB
|
|
81
|
+
openretire tx add --from Cash --to Food --amount 120.50 --date 2026-03-01
|
|
82
|
+
openretire balance --as-of 2026-03-31
|
|
83
|
+
openretire report networth --as-of 2026-03-31
|
|
83
84
|
```
|
|
84
85
|
|
|
85
86
|
`init` creates the data directory and an empty ledger. An account is a place money sits or
|
|
@@ -90,7 +91,7 @@ To chart net worth over time, state every month-end of a period in one read inst
|
|
|
90
91
|
call per month:
|
|
91
92
|
|
|
92
93
|
```bash
|
|
93
|
-
|
|
94
|
+
openretire report networth --monthly --since 2026-01-01 --until 2026-03-31
|
|
94
95
|
```
|
|
95
96
|
|
|
96
97
|
Each month is exactly what `--as-of` gives for that date.
|
|
@@ -99,22 +100,24 @@ A figure that sums accounts (net worth, the trial balance's debit and credit col
|
|
|
99
100
|
less expenses) can leave the safe integer range though every account is inside it. The read still
|
|
100
101
|
exits 0 and states every account, and states that figure as `null` with an error object beside it
|
|
101
102
|
(`netWorthError`, `totalsError`); the text form prints a sentence in its place. A figure inside the
|
|
102
|
-
range carries no error key. Run `
|
|
103
|
+
range carries no error key. Run `openretire schema balance` or `openretire schema report pnl` for
|
|
104
|
+
the exact shape.
|
|
103
105
|
|
|
104
|
-
`
|
|
105
|
-
that group's core subcommands and `
|
|
106
|
-
lists
|
|
107
|
-
output and error
|
|
106
|
+
`openretire help` lists the core commands and `openretire help --all` lists every command;
|
|
107
|
+
`openretire help <group>` lists that group's core subcommands and `openretire help <group> --all`
|
|
108
|
+
lists all of them; `openretire help <command>` lists one command's flags, and
|
|
109
|
+
`openretire schema --json` prints the whole contract: every command's input, output and error
|
|
110
|
+
codes.
|
|
108
111
|
|
|
109
112
|
## Importing a statement
|
|
110
113
|
|
|
111
114
|
To load a bank statement, fill the one CSV template instead of adding each transaction by
|
|
112
|
-
hand. `
|
|
115
|
+
hand. `openretire tx import` has been in every release since 0.1.0.
|
|
113
116
|
|
|
114
117
|
```bash
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
+
openretire tx import --template # print the template header and nothing else
|
|
119
|
+
openretire tx import statement.csv --dry-run
|
|
120
|
+
openretire tx import statement.csv
|
|
118
121
|
```
|
|
119
122
|
|
|
120
123
|
`--template` prints the header the importer reads, and it opens no data directory:
|
|
@@ -125,7 +128,7 @@ date,from,to,amount,memo,external_ref,project
|
|
|
125
128
|
|
|
126
129
|
Start your file with that header and write one row per transaction. `--dry-run` reports every
|
|
127
130
|
row and rolls every write back, so run it first. A file name of `-` reads the CSV from stdin, as in
|
|
128
|
-
`
|
|
131
|
+
`openretire tx import - --dry-run`. The import is all or nothing, and `external_ref` is the duplicate
|
|
129
132
|
key, so importing the same statement twice adds nothing the second time. Each command's flags and
|
|
130
133
|
the rest of the columns are in
|
|
131
134
|
[the `tx` page of the docs](https://trajectonomics.com/docs/cli/commands/tx/).
|
|
@@ -151,15 +154,15 @@ From a checkout, run the CLI with `bun run dev -- …`. The npm launcher refuses
|
|
|
151
154
|
## Reading the future
|
|
152
155
|
|
|
153
156
|
Three read-only commands run a stored Scenario over the Baseline the ledger
|
|
154
|
-
states at a date: `
|
|
155
|
-
nominal and real (monthly rows with `--monthly`); `
|
|
157
|
+
states at a date: `openretire projection run` rolls net worth up year by year,
|
|
158
|
+
nominal and real (monthly rows with `--monthly`); `openretire projection compare`
|
|
156
159
|
puts two Scenarios side by side, or one against a `--set` what-if, with the
|
|
157
160
|
deltas in FI date, net worth at the ages you name and run-out year; and
|
|
158
|
-
`
|
|
161
|
+
`openretire fi` reports the survival FI date beside the 25× rule of thumb as a
|
|
159
162
|
labelled reference. Every date flag is a Gregorian year between 1900 and
|
|
160
163
|
2100, so a Buddhist year is refused instead of read as 543 years later. Every result states its As-of, the engine version, the
|
|
161
164
|
Scenario's hashes, the Overrides it applied, and its tax status.
|
|
162
|
-
`
|
|
165
|
+
`openretire schema <command>` describes each one.
|
|
163
166
|
|
|
164
167
|
Each result also says what every tax year owes: `taxYears` in JSON, and the
|
|
165
168
|
`taxYears` table in the human format. A row names its Levy, the period and the
|
|
@@ -169,7 +172,7 @@ says whether the settlement date falls inside the Projection, and `partial`
|
|
|
169
172
|
whether the Projection ended before the period did, so a figure that is still
|
|
170
173
|
ahead of you is never mistaken for one already charged.
|
|
171
174
|
|
|
172
|
-
Tax is the Scenario's. `
|
|
175
|
+
Tax is the Scenario's. `openretire scenario tax <name> --tax th-2026` writes Thailand's
|
|
173
176
|
2026 personal income tax into it, and `--label salary=income.section40_1` says
|
|
174
177
|
which Section 40 class each income Flow belongs to, because a Levy tallies
|
|
175
178
|
labels and never guesses them; `--none` takes both out again, with the
|
|
@@ -187,9 +190,9 @@ deduction nobody stated is visible rather than assumed to be zero. It states
|
|
|
187
190
|
what the flags said, never what tax-core applied: a premium the statute does
|
|
188
191
|
not allow for the filing status is still stated, and the Levy zeroes it.
|
|
189
192
|
|
|
190
|
-
The write keeps that profile beside the Scenario, and `
|
|
193
|
+
The write keeps that profile beside the Scenario, and `openretire scenario show` prints
|
|
191
194
|
it back as `tax`. `--merge` then changes only the flags it carries
|
|
192
|
-
(`
|
|
195
|
+
(`openretire scenario tax base --merge --children 2`) and keeps the rest, and
|
|
193
196
|
`--from-stored` writes the Levy again from the profile, for example after a
|
|
194
197
|
tax-year update. Both need a stored profile: a plan taxed before it was kept
|
|
195
198
|
states its profile whole once. `--if-hash` refuses a write over a plan that
|
|
@@ -216,7 +219,7 @@ joint return, which one Levy over a single label could not apply. Salaries of
|
|
|
216
219
|
letters, digits or hyphens, is refused by name. A plan without a partner or without
|
|
217
220
|
`owners` writes the bare labels it always wrote, for every filing status. The result
|
|
218
221
|
lists the `filers` when it has any, and the household's Owners are read each time the
|
|
219
|
-
tax is written, so after changing them run `
|
|
222
|
+
tax is written, so after changing them run `openretire scenario tax <name> --from-stored`.
|
|
220
223
|
|
|
221
224
|
A couple who file separately get one Levy each. `--filing-status married_separate` writes
|
|
222
225
|
`th-2026-pit@me` and `th-2026-pit@partner`, one per person who has a labelled Flow or
|
|
@@ -232,7 +235,7 @@ income that year claims all of it, a person with no income claims nothing of it,
|
|
|
232
235
|
odd satang goes to the holder. The shared total is at most 100,000 baht
|
|
233
236
|
(`MORTGAGE_OVER_CEILING`), and `shared=` is refused under any other filing status. A
|
|
234
237
|
person's own `--mortgage-interest` is for their other loans, and each Return claims at
|
|
235
|
-
most 100,000 baht of its own interest and its share together. `
|
|
238
|
+
most 100,000 baht of its own interest and its share together. `openretire` cannot tell which
|
|
236
239
|
loan interest is on, so when both claim their own, a loan's Owner is `shared` and no
|
|
237
240
|
shared interest is stated, the result's `assumptions` say the loans are taken to be
|
|
238
241
|
separate. `--merge` and `--from-stored` keep the stored `returns` and
|
|
@@ -285,20 +288,20 @@ the other Return's. A missing class is listed by name, and a bare label is refus
|
|
|
285
288
|
|
|
286
289
|
## Chance of success
|
|
287
290
|
|
|
288
|
-
`
|
|
291
|
+
`openretire projection chance` runs one Scenario over seeded Market paths and reports
|
|
289
292
|
the share that never run out before the Horizon, with the net-worth Bands at each
|
|
290
293
|
year. The paths draw from a Return model you state in a JSON file, with
|
|
291
294
|
`--return-model`, and `--paths` and `--seed` are required, so the same model,
|
|
292
295
|
seed and count always give the same answer. The CLI ships no Return model: which
|
|
293
296
|
market history a plan is tested against is your decision, and every figure is
|
|
294
|
-
only as good as that choice. `
|
|
297
|
+
only as good as that choice. `openretire schema projection chance` describes the file.
|
|
295
298
|
Or pass `--return-model plan` to build the model from the plan itself: each asset
|
|
296
299
|
Account's `rate` and its `volatility` (the standard deviation of its yearly
|
|
297
300
|
return, in basis points, which you write into the Scenario), and the Scenario's
|
|
298
301
|
`economy.inflationVolatility` (the standard deviation of one year's inflation)
|
|
299
302
|
as an inflation factor, when you state one. `--buckets` sets its size (a power
|
|
300
303
|
of two from 16 to 1024, 256 by default), the result echoes what it was built
|
|
301
|
-
from as `returnModel`, and `
|
|
304
|
+
from as `returnModel`, and `openretire projection model --scenario NAME` prints the
|
|
302
305
|
model as JSON, a file `--return-model` reads back. A plan with neither an
|
|
303
306
|
Account `volatility` nor an `inflationVolatility` is refused, because every path
|
|
304
307
|
would be the same path.
|
|
@@ -306,7 +309,7 @@ Add `--outcomes` to see what each path came to: its closing and lowest net
|
|
|
306
309
|
worth, the year it was lowest and when it ran out, with the paths at the 10th,
|
|
307
310
|
50th and 90th percentile, the earliest to run out and the lowest named as
|
|
308
311
|
`representative` (the human form prints every path, worst first). Then
|
|
309
|
-
`
|
|
312
|
+
`openretire projection path --index N`, with the same flags, replays path N year by
|
|
310
313
|
year: `projection run`'s result, with the same flags for the cash flow and each
|
|
311
314
|
Account's value, plus the market return each Account drew in each year as
|
|
312
315
|
`returns`. An index is a path's name under the seed, so it is from 0 to
|
|
@@ -314,13 +317,13 @@ Account's value, plus the market return each Account drew in each year as
|
|
|
314
317
|
Add `--milestone-dates` to see when each Milestone of the plan fired: how many
|
|
315
318
|
paths reached it, the median and 10th to 90th percentile months with each
|
|
316
319
|
household person's age, and the paths per year.
|
|
317
|
-
Pass `--paths` and `--seed` to `
|
|
320
|
+
Pass `--paths` and `--seed` to `openretire dashboard` to add the chance of success to the
|
|
318
321
|
Dashboard, as a page of its own: it uses `plan` unless you name a
|
|
319
322
|
`--return-model` file.
|
|
320
323
|
|
|
321
324
|
## Tax allowances
|
|
322
325
|
|
|
323
|
-
`
|
|
326
|
+
`openretire projection allowances` reads a Scenario that has a tax Levy and says, for each
|
|
324
327
|
whole tax year the Projection holds, how much more of each contribution label (RMF, ThaiESG
|
|
325
328
|
and the others the Levy reads) would still lower the tax, and by how much. You name the
|
|
326
329
|
labels in the order they should fill with `--labels`, and the size of one step with
|
|
@@ -331,31 +334,32 @@ which you add to the Scenario yourself: the command writes nothing. The figures
|
|
|
331
334
|
plan's own tax rules, an estimate and not tax advice, and each fund's holding rules are
|
|
332
335
|
not checked. A year that ended before the As-of, and a year the horizon cuts short, are left out; the
|
|
333
336
|
current year is included, and when the As-of falls mid-year it needs `--carry-in`, the
|
|
334
|
-
record of what was already contributed in that year earlier. `
|
|
337
|
+
record of what was already contributed in that year earlier. `openretire schema projection allowances`
|
|
335
338
|
describes the result.
|
|
336
339
|
|
|
337
340
|
## Money as decimals in a Scenario
|
|
338
341
|
|
|
339
|
-
`
|
|
342
|
+
`openretire scenario show base --decimal` prints a Scenario with each amount as a decimal string of the
|
|
340
343
|
Currency's major unit, such as `"1000.00"` for 100000 satang, and
|
|
341
|
-
`
|
|
344
|
+
`openretire scenario apply base --file base.json --decimal` reads that form back. The stored plan is the
|
|
342
345
|
same either way: saving what `show --decimal` printed leaves it unchanged. A value with more places
|
|
343
346
|
than the Currency has is refused, never rounded.
|
|
344
347
|
|
|
345
348
|
## A what-if, applied to the plan it came from
|
|
346
349
|
|
|
347
|
-
`
|
|
348
|
-
change to the stored plan, so the plan you keep is the one you projected. It takes
|
|
349
|
-
`--without` and `--decimal` that `projection run` takes, and refuses what they would be
|
|
350
|
+
`openretire projection run --set` projects a change without saving it. `openretire scenario apply`
|
|
351
|
+
saves the same change to the stored plan, so the plan you keep is the one you projected. It takes
|
|
352
|
+
the `--set`, `--without` and `--decimal` that `projection run` takes, and refuses what they would be
|
|
353
|
+
refused for:
|
|
350
354
|
|
|
351
355
|
```bash
|
|
352
|
-
|
|
353
|
-
|
|
356
|
+
openretire scenario apply base --set flows.salary.amount=9000000 --dry-run
|
|
357
|
+
openretire scenario apply base --set flows.salary.amount=9000000 --without flows.gym
|
|
354
358
|
```
|
|
355
359
|
|
|
356
360
|
The result names the Overrides it wrote. A change that leaves the plan as it is writes nothing and
|
|
357
361
|
exits 0. `--if-hash <contentHash>` writes only when the stored plan still has that hash, as
|
|
358
|
-
`
|
|
362
|
+
`openretire scenario show` printed it, and refuses the write otherwise. Without `--file`, `--set` and
|
|
359
363
|
`--without` never take a document, so the what-if cannot replace a plan you did not read.
|
|
360
364
|
|
|
361
365
|
### Adding an item to a what-if
|
|
@@ -367,9 +371,9 @@ Every read that takes `--set` takes `--add` (`projection run`, `projection compa
|
|
|
367
371
|
`projection chance` and `projection allowances`), and `scenario fork` and `scenario apply` save it:
|
|
368
372
|
|
|
369
373
|
```bash
|
|
370
|
-
|
|
374
|
+
openretire projection run --scenario base --as-of 2026-03-31 --horizon 2027-03-30 \
|
|
371
375
|
--add 'flows={"id":"extra","kind":"expense","amount":"1000.00","frequency":"monthly","start":"2026-04-01","growth":{"bps":0}}' --decimal
|
|
372
|
-
|
|
376
|
+
openretire scenario apply base --add 'flows={...}' --decimal --if-hash <contentHash>
|
|
373
377
|
```
|
|
374
378
|
|
|
375
379
|
The flags apply in a fixed order whatever order they are typed in: every `--without`, then every
|
|
@@ -385,13 +389,13 @@ item's money is a decimal string of the Currency's major unit. Nothing is writte
|
|
|
385
389
|
## Naming plans, keeping notes on them, and marking the main one
|
|
386
390
|
|
|
387
391
|
A person who compares "retire at 55" with "retire at 60 and buy a condo" ends up with several plans.
|
|
388
|
-
`
|
|
389
|
-
`contentHash`. `
|
|
390
|
-
on it (`--file <path>` or `--file -` reads it, `--clear` removes it), and `scenario show`
|
|
391
|
-
back as `notes`. Notes are not part of the plan, so they never change its `contentHash`,
|
|
392
|
-
`scenario fork` copies them unless it is given `--no-notes`.
|
|
392
|
+
`openretire scenario rename early retire-at-55` gives a plan a better name and keeps its id, document
|
|
393
|
+
and `contentHash`. `openretire scenario notes retire-at-55 --text "Sell the condo in 2031."` keeps
|
|
394
|
+
plain text on it (`--file <path>` or `--file -` reads it, `--clear` removes it), and `scenario show`
|
|
395
|
+
prints it back as `notes`. Notes are not part of the plan, so they never change its `contentHash`,
|
|
396
|
+
and a `scenario fork` copies them unless it is given `--no-notes`.
|
|
393
397
|
|
|
394
|
-
`
|
|
398
|
+
`openretire scenario main retire-at-55` marks one plan as your main plan, and `scenario list` and
|
|
395
399
|
`scenario show` print `main`. It is a label and not a default: `projection run` and every other read
|
|
396
400
|
still need `--scenario`. `scenario rm` of the main plan is refused until another is chosen
|
|
397
401
|
(`scenario main --clear` takes the mark off), or removed anyway with `--force`.
|
|
@@ -400,10 +404,10 @@ still need `--scenario`. `scenario rm` of the main plan is refused until another
|
|
|
400
404
|
|
|
401
405
|
A Scenario may name points in the plan a Flow can wait for: a date, a number of months after another
|
|
402
406
|
point, a net-worth or spending figure, or a multiple of spending. They are the `milestones` of the
|
|
403
|
-
Scenario document, and `
|
|
404
|
-
or after a point's date, and its `endAt` before it. `
|
|
405
|
-
or that it was not reached, in a `milestones` table, and `
|
|
406
|
-
each side.
|
|
407
|
+
Scenario document, and `openretire schema scenario apply` lists every key. A Flow's `startAt` lands
|
|
408
|
+
it on or after a point's date, and its `endAt` before it. `openretire projection run` reports each
|
|
409
|
+
point's date, or that it was not reached, in a `milestones` table, and `openretire projection
|
|
410
|
+
compare` reports them under each side.
|
|
407
411
|
|
|
408
412
|
```json
|
|
409
413
|
"milestones": [
|
|
@@ -424,15 +428,15 @@ Every Flow, every Milestone and every person of a household may carry a `display
|
|
|
424
428
|
page reads in place of the id, such as Thai text. It is free text of 1 to 80 code points, with no
|
|
425
429
|
control, invisible or bidirectional characters and no leading or trailing whitespace. It is no key
|
|
426
430
|
and changes no figure: the id still addresses the item, the label may repeat or change, and the
|
|
427
|
-
engine never reads it. `
|
|
428
|
-
with that rule.
|
|
431
|
+
engine never reads it. `openretire schema scenario apply` and `openretire schema scenario household`
|
|
432
|
+
publish it with that rule.
|
|
429
433
|
|
|
430
434
|
A label travels in the document, so `--file` and `--add` carry it, and `--set` writes it:
|
|
431
435
|
|
|
432
436
|
```bash
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
437
|
+
openretire scenario apply base --set 'flows.school-fees.displayLabel="School fees"'
|
|
438
|
+
openretire scenario apply base --set 'milestones.condo.displayLabel="Condo down payment"'
|
|
439
|
+
openretire scenario household base --file household.json # a person's label, in the household
|
|
436
440
|
```
|
|
437
441
|
|
|
438
442
|
A plan written before the field may lack it, and the first `--set` that names it begins it, as
|
|
@@ -443,7 +447,7 @@ cannot remove a key, so `null` and `""` are refused.
|
|
|
443
447
|
|
|
444
448
|
## Where each year's money went
|
|
445
449
|
|
|
446
|
-
`
|
|
450
|
+
`openretire projection run --breakdown` adds each Annual roll-up's cash flow as the engine routed it: each
|
|
447
451
|
Flow's income, the tax taken at source and each Levy's settlement (a refund is negative), each expense
|
|
448
452
|
and its category, each Contribution applied and the part the cash could not fund, each planned
|
|
449
453
|
withdrawal, what `cashflow.withdraw` drew and what `cashflow.surplus` filled. In JSON it is the
|
|
@@ -506,15 +510,15 @@ row of zeros, because the Reporting year states every month it covers.
|
|
|
506
510
|
|
|
507
511
|
## Where the money goes, and moving it between Accounts
|
|
508
512
|
|
|
509
|
-
`cashflow` takes three more forms, every figure in them the caller's own (`
|
|
513
|
+
`cashflow` takes three more forms, every figure in them the caller's own (`openretire` ships none): a surplus step's `share`, which takes that
|
|
510
514
|
many basis points of what is still unrouted instead of everything (a percent string such as `"30.00"` under `--decimal`); a `withdraw` entry that is `{ account, downTo }`, which keeps a Reserve floor
|
|
511
515
|
in the Account while the others are drawn; and an `upTo` or `downTo` that is `{ amount, growth }`, which keeps its value in today's money. A
|
|
512
516
|
Flow of `kind: "transfer"` moves money between two of the plan's own Accounts, outside cashflow: a provident fund rolled into a locked RMF, or
|
|
513
|
-
a monthly amount from savings paying a loan down. `
|
|
517
|
+
a monthly amount from savings paying a loan down. `openretire schema scenario apply` describes each, and `--set` reaches a step or an entry by
|
|
514
518
|
its position, so "what if I kept 100,000.00 in savings before touching the funds" is
|
|
515
|
-
`
|
|
519
|
+
`openretire projection run --scenario plan --set cashflow.withdraw.0.downTo=10000000`.
|
|
516
520
|
|
|
517
|
-
`
|
|
521
|
+
`openretire projection run` states what each did: the annual row's `transfers`, a `routing` echo of every step and entry by position,
|
|
518
522
|
and with `--breakdown` the `entry` each drawn line came from and a `transfers` table (what moved and what could not); with
|
|
519
523
|
`--liabilities`, `transferred` on a loan's months. The amount a target that keeps its value is worth on a later date is the engine's
|
|
520
524
|
and is not stated yet. A plan without these forms prints exactly as before.
|
|
@@ -523,9 +527,9 @@ and is not stated yet. A plan without these forms prints exactly as before.
|
|
|
523
527
|
|
|
524
528
|
A loan is three parts of a Scenario document: a liability Account with a nominal `rate` and a `compounding`
|
|
525
529
|
period, a `withdrawal` Flow from that liability when the money arrives, and a Contribution into the
|
|
526
|
-
liability whose amount is a `level` payment. `
|
|
530
|
+
liability whose amount is a `level` payment. `openretire schema scenario apply` publishes one as its worked example.
|
|
527
531
|
|
|
528
|
-
`
|
|
532
|
+
`openretire projection run --liabilities` adds the engine's statement of each loan: one month row per liability
|
|
529
533
|
(`opening`, `drawn`, `paid`, `interest`, `closing`) and each loan's paid-off date. The rows shown are
|
|
530
534
|
one loan's months, cut from the table; it lists every liability the Scenario holds. In JSON they are the
|
|
531
535
|
`liabilities` and `paidOff` tables. The human format prints one line per loan, then its months:
|
|
@@ -545,7 +549,7 @@ equals `closing` exactly. Without `--liabilities` the output is unchanged.
|
|
|
545
549
|
### What a fee and a payout came to over the plan
|
|
546
550
|
|
|
547
551
|
An asset Account can pay out a share of its value as income (`payout`) and be charged a yearly `fee`.
|
|
548
|
-
`
|
|
552
|
+
`openretire projection run` states each one's total over the whole horizon, so nothing needs adding up: the
|
|
549
553
|
engine sums them in the same run as the roll-ups (it is the sum of the `payouts` and `fees` of every
|
|
550
554
|
roll-up). Two fields appear, and only when the Scenario declares the item above 0 bps (0 bps is none):
|
|
551
555
|
|
|
@@ -570,56 +574,56 @@ Without a fee or a payout the output is unchanged.
|
|
|
570
574
|
|
|
571
575
|
## Seeing it in a browser
|
|
572
576
|
|
|
573
|
-
`
|
|
577
|
+
`openretire dashboard --as-of 2026-11-30 --horizon 2056-11-30` reads your ledger once and serves the Dashboard (net worth, the ledger, projections, the FI date, a Scenario compare, tax and health) on `http://127.0.0.1:4321/` until you press Ctrl-C. It can change your plans (fork, apply or delete a Scenario, each through `openretire` after a dry run), it listens on this machine only and accepts a write only from its own page with a per-run token, and it takes the same Scenario flags as the projection reads (`--scenario`, `--compare` twice, `--monthly`, `--carry-in`); `--port 0` picks a free port. Run it again to see new figures.
|
|
574
578
|
|
|
575
579
|
## Keeping a backup, and removing the data
|
|
576
580
|
|
|
577
|
-
Four commands keep the ledger recoverable. `
|
|
581
|
+
Four commands keep the ledger recoverable. `openretire doctor` checks the data directory, the
|
|
578
582
|
database and every stored transaction and says what is wrong without changing anything;
|
|
579
583
|
`--as-of` adds the trial balance at a date. It exits 0 when its checks ran, with `"ok": false`
|
|
580
584
|
when one found a problem, because the finding is the answer; a non-zero exit is for what the
|
|
581
585
|
command could not do at all.
|
|
582
586
|
|
|
583
|
-
`
|
|
584
|
-
not exist yet, and `
|
|
587
|
+
`openretire backup --out backup` writes `traj.jsonl`, the canonical dump, into a directory that must
|
|
588
|
+
not exist yet, and `openretire restore backup` writes it into an empty data directory byte for byte.
|
|
585
589
|
A restore refuses a database that already holds data: to replace live data, remove it first,
|
|
586
590
|
or restore into a second `TRAJ_HOME`. CSV and Markdown exports are for people; only the JSONL
|
|
587
591
|
restores.
|
|
588
592
|
|
|
589
|
-
`
|
|
593
|
+
`openretire data remove` deletes `traj.db` and nothing else, so the launcher's `bin/` cache beside it
|
|
590
594
|
survives. It prints what would be lost, and it refuses unless `--confirm` names the data
|
|
591
595
|
directory's own path and `--backup` names a backup whose bytes are the data's, so a removal
|
|
592
596
|
cannot outrun the last write:
|
|
593
597
|
|
|
594
598
|
```bash
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
599
|
+
openretire doctor --as-of 2026-11-30
|
|
600
|
+
openretire backup --out ~/traj-backup-2026-11-30
|
|
601
|
+
openretire data remove --confirm ~/.traj --backup ~/traj-backup-2026-11-30
|
|
598
602
|
```
|
|
599
603
|
|
|
600
604
|
### Going back after an upgrade
|
|
601
605
|
|
|
602
|
-
When a newer `
|
|
606
|
+
When a newer `openretire` has to migrate your database to a newer schema, it first copies it beside the
|
|
603
607
|
original as `traj.db.pre-v<N>.bak`, where `N` is the schema version the copy holds, and says so once
|
|
604
608
|
on stderr. Each copy is about the size of the database, so the upgrade needs that much free space;
|
|
605
609
|
if the copy cannot be written (a full disk, a directory that is not writable) the database is not
|
|
606
610
|
migrated and nothing changes. A new, empty ledger is not copied.
|
|
607
611
|
|
|
608
|
-
An older `
|
|
612
|
+
An older `openretire` refuses a database a newer one has migrated, so to go back: stop every `openretire`,
|
|
609
613
|
install the release you used before (the
|
|
610
|
-
[releases page](https://github.com/trajectonomics/trajectonomics/releases) lists them; `
|
|
614
|
+
[releases page](https://github.com/trajectonomics/trajectonomics/releases) lists them; `openretire doctor`
|
|
611
615
|
on it reports the schema version it writes as `head`, which must equal `N`), delete `traj.db`,
|
|
612
616
|
`traj.db-wal` and `traj.db-shm` in the data directory, and copy the `.bak` file to `traj.db`.
|
|
613
617
|
Changes made after the upgrade are lost: the copy is the database as it was.
|
|
614
618
|
|
|
615
|
-
`
|
|
616
|
-
left as `database.unfinishedCopies`. `
|
|
619
|
+
`openretire doctor` lists the copies as `database.preMigrationCopies`, and any half-written one a crash
|
|
620
|
+
left as `database.unfinishedCopies`. `openretire data remove` leaves the copies, because they are separate
|
|
617
621
|
files you can delete when you no longer need them, and its refusal names them: they hold your
|
|
618
622
|
data in plain text.
|
|
619
623
|
|
|
620
624
|
## Telemetry
|
|
621
625
|
|
|
622
|
-
`
|
|
626
|
+
`openretire` counts its own use, so the project can see how many people run it each week. After a command finishes, a detached process sends one anonymous event to PostHog (EU), so the command never waits for the network. The event holds:
|
|
623
627
|
|
|
624
628
|
- `command`: the command name, such as `tx add`, or nothing when the command line named none
|
|
625
629
|
- `exit_code` and `error_code`: how the run ended, such as `invalid_input`
|
|
@@ -628,15 +632,15 @@ data in plain text.
|
|
|
628
632
|
|
|
629
633
|
It never holds your ledger, arguments, flag values, account names, amounts, file paths, the data directory or any environment variable. As with any web request, PostHog sees the IP address the request comes from.
|
|
630
634
|
|
|
631
|
-
The random id that groups one machine's events is in `telemetry.json`, in `$XDG_CONFIG_HOME/traj` (or `~/.config/traj`), or in `%APPDATA%\traj` on Windows. It lives outside the data directory, so `
|
|
635
|
+
The random id that groups one machine's events is in `telemetry.json`, in `$XDG_CONFIG_HOME/traj` (or `~/.config/traj`), or in `%APPDATA%\traj` on Windows. It lives outside the data directory, so `openretire data remove` does not delete it. `openretire telemetry off` deletes it. A machine where that file cannot be written sends nothing.
|
|
632
636
|
|
|
633
637
|
There are three ways to stop it:
|
|
634
638
|
|
|
635
|
-
- `
|
|
639
|
+
- `openretire telemetry off`, which stores the choice for this machine
|
|
636
640
|
- `DO_NOT_TRACK=1` in the environment of the command
|
|
637
641
|
- `TRAJ_TELEMETRY=0` (or `off` or `false`) in the environment of the command
|
|
638
642
|
|
|
639
|
-
CI runners (where `CI` is set) and development builds never send. The first successful command prints one line on stderr that says so, and it prints it once. `
|
|
643
|
+
CI runners (where `CI` is set) and development builds never send. The first successful command prints one line on stderr that says so, and it prints it once. `openretire telemetry status` shows whether counting is on and why, and `openretire telemetry on` turns it back on; a `DO_NOT_TRACK`, `TRAJ_TELEMETRY` or `CI` setting still stops it, and the status says which one.
|
|
640
644
|
|
|
641
645
|
## Docs
|
|
642
646
|
|
|
@@ -657,6 +661,6 @@ registry in `src/registry.ts` with its exit class; add it to `RETRYABLE_CODES` t
|
|
|
657
661
|
retrying the same command can succeed. An input-validation sentence
|
|
658
662
|
comes from the shared table beside it, so a new command needs no wording of its
|
|
659
663
|
own. Commands never format output or
|
|
660
|
-
exit; `
|
|
664
|
+
exit; `openretire help <path>` and `openretire schema <path>` are generated from the same
|
|
661
665
|
schemas that validate them. Test through `run(argv, io, env)`, which needs no
|
|
662
666
|
process. See ADR 0015.
|
package/bin/launcher.js
CHANGED
|
@@ -22,7 +22,7 @@ export function assetName(platform, arch) {
|
|
|
22
22
|
const asset = ASSETS[`${platform}-${arch}`]
|
|
23
23
|
if (asset === undefined) {
|
|
24
24
|
throw new Error(
|
|
25
|
-
`
|
|
25
|
+
`openretire has no build for ${platform}/${arch}. Supported: ${SUPPORTED.join(", ")}.`,
|
|
26
26
|
)
|
|
27
27
|
}
|
|
28
28
|
return asset
|
|
@@ -16,7 +16,7 @@ const { version } = JSON.parse(readFileSync(new URL("../package.json", import.me
|
|
|
16
16
|
|
|
17
17
|
/** A launcher failure is one plain line on stderr and exit 1, never a JSON envelope. */
|
|
18
18
|
function fail(message) {
|
|
19
|
-
process.stderr.write(`
|
|
19
|
+
process.stderr.write(`openretire: ${message}\n`)
|
|
20
20
|
process.exitCode = 1
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -42,7 +42,9 @@ async function download(url) {
|
|
|
42
42
|
}
|
|
43
43
|
if (!said) {
|
|
44
44
|
said = true
|
|
45
|
-
process.stderr.write(
|
|
45
|
+
process.stderr.write(
|
|
46
|
+
`openretire: ${url} is not there yet; retrying for up to five minutes.\n`,
|
|
47
|
+
)
|
|
46
48
|
}
|
|
47
49
|
await sleep(wait)
|
|
48
50
|
}
|
|
@@ -60,7 +62,7 @@ async function main(args) {
|
|
|
60
62
|
const dest = join(home, "bin", `traj-${version}${exe}`)
|
|
61
63
|
if (!existsSync(dest)) {
|
|
62
64
|
const base = process.env["TRAJ_DOWNLOAD_BASE_URL"] || undefined
|
|
63
|
-
process.stderr.write(`
|
|
65
|
+
process.stderr.write(`openretire: downloading ${name} v${version} to ${dest} (about 100 MB).\n`)
|
|
64
66
|
const checksums = new TextDecoder().decode(
|
|
65
67
|
await download(releaseUrl(version, "checksums.txt", base)),
|
|
66
68
|
)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trajectonomics/cli",
|
|
3
|
-
"version": "0.9.0-alpha.
|
|
3
|
+
"version": "0.9.0-alpha.80",
|
|
4
4
|
"description": "A free, open-source money command line that AI agents operate. Deterministic, local-first, Thai tax first.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"personal-finance",
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
"type": "module",
|
|
21
21
|
"packageManager": "bun@1.4.4",
|
|
22
22
|
"bin": {
|
|
23
|
-
"
|
|
23
|
+
"openretire": "./bin/openretire.js",
|
|
24
|
+
"traj": "./bin/openretire.js"
|
|
24
25
|
},
|
|
25
26
|
"files": [
|
|
26
27
|
"bin/"
|