@trajectonomics/cli 0.8.0-alpha.9 → 0.8.0-alpha.90
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 +238 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -87,6 +87,30 @@ date and never reads the clock, so the same command always answers the same ques
|
|
|
87
87
|
`traj help` lists every command, `traj help <command>` lists one command's flags, and
|
|
88
88
|
`traj schema --json` prints the whole contract: every command's input, output and error codes.
|
|
89
89
|
|
|
90
|
+
## Importing a statement
|
|
91
|
+
|
|
92
|
+
To load a bank statement, fill the one CSV template instead of adding each transaction by
|
|
93
|
+
hand. `traj tx import` has been in every release since 0.1.0.
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
traj tx import --template # print the template header and nothing else
|
|
97
|
+
traj tx import statement.csv --dry-run
|
|
98
|
+
traj tx import statement.csv
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
`--template` prints the header the importer reads, and it opens no data directory:
|
|
102
|
+
|
|
103
|
+
```csv
|
|
104
|
+
date,from,to,amount,memo,external_ref,project
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Start your file with that header and write one row per transaction. `--dry-run` reports every
|
|
108
|
+
row and rolls every write back, so run it first. A file name of `-` reads the CSV from stdin, as in
|
|
109
|
+
`traj tx import - --dry-run`. The import is all or nothing, and `external_ref` is the duplicate
|
|
110
|
+
key, so importing the same statement twice adds nothing the second time. Each command's flags and
|
|
111
|
+
the rest of the columns are in
|
|
112
|
+
[the `tx` page of the docs](https://docs.trajectonomics.com/cli/commands/tx/).
|
|
113
|
+
|
|
90
114
|
## Development
|
|
91
115
|
|
|
92
116
|
The sources are Bun-only; a released binary needs nothing.
|
|
@@ -144,6 +168,14 @@ deduction nobody stated is visible rather than assumed to be zero. It states
|
|
|
144
168
|
what the flags said, never what tax-core applied: a premium the statute does
|
|
145
169
|
not allow for the filing status is still stated, and the Levy zeroes it.
|
|
146
170
|
|
|
171
|
+
The write keeps that profile beside the Scenario, and `traj scenario show` prints
|
|
172
|
+
it back as `tax`. `--merge` then changes only the flags it carries
|
|
173
|
+
(`traj scenario tax base --merge --children 2`) and keeps the rest, and
|
|
174
|
+
`--from-stored` writes the Levy again from the profile, for example after a
|
|
175
|
+
tax-year update. Both need a stored profile: a plan taxed before it was kept
|
|
176
|
+
states its profile whole once. `--if-hash` refuses a write over a plan that
|
|
177
|
+
changed since you read it, as on `scenario apply`.
|
|
178
|
+
|
|
147
179
|
```json
|
|
148
180
|
{
|
|
149
181
|
"status": "updated",
|
|
@@ -184,8 +216,43 @@ year. The paths draw from a Return model you state in a JSON file, with
|
|
|
184
216
|
seed and count always give the same answer. The CLI ships no Return model: which
|
|
185
217
|
market history a plan is tested against is your decision, and every figure is
|
|
186
218
|
only as good as that choice. `traj schema projection chance` describes the file.
|
|
187
|
-
|
|
188
|
-
|
|
219
|
+
Or pass `--return-model plan` to build the model from the plan itself: each asset
|
|
220
|
+
Account's `rate` and its `volatility` (the standard deviation of its yearly
|
|
221
|
+
return, in basis points, which you write into the Scenario). `--buckets` sets its
|
|
222
|
+
size (a power of two from 16 to 1024, 256 by default), the result echoes what it
|
|
223
|
+
was built from as `returnModel`, and `traj projection model --scenario NAME`
|
|
224
|
+
prints the model as JSON, a file `--return-model` reads back. A plan with no
|
|
225
|
+
`volatility` is refused, because every path would be the same path.
|
|
226
|
+
Add `--outcomes` to see what each path came to: its closing and lowest net
|
|
227
|
+
worth, the year it was lowest and when it ran out, with the paths at the 10th,
|
|
228
|
+
50th and 90th percentile, the earliest to run out and the lowest named as
|
|
229
|
+
`representative` (the human form prints every path, worst first). Then
|
|
230
|
+
`traj projection path --index N`, with the same flags, replays path N year by
|
|
231
|
+
year: `projection run`'s result, with the same flags for the cash flow and each
|
|
232
|
+
Account's value, plus the market return each Account drew in each year as
|
|
233
|
+
`returns`. An index is a path's name under the seed, so it is from 0 to
|
|
234
|
+
`--paths` minus 1.
|
|
235
|
+
Pass `--paths` and `--seed` to `traj dashboard` to add the chance of success to the
|
|
236
|
+
Dashboard, as a page of its own: it uses `plan` unless you name a
|
|
237
|
+
`--return-model` file.
|
|
238
|
+
|
|
239
|
+
## Tax allowances
|
|
240
|
+
|
|
241
|
+
> **Ships in 0.8.0.**
|
|
242
|
+
|
|
243
|
+
`traj projection allowances` reads a Scenario that has a tax Levy and says, for each
|
|
244
|
+
whole tax year the Projection holds, how much more of each contribution label (RMF, ThaiESG
|
|
245
|
+
and the others the Levy reads) would still lower the tax, and by how much. You name the
|
|
246
|
+
labels in the order they should fill with `--labels`, and the size of one step with
|
|
247
|
+
`--step`, in major units: the CLI ships no default. `--budget` caps what the extra
|
|
248
|
+
contributions may add up to in a year, and `--min-saving` is the least percent of a step
|
|
249
|
+
a step must save. Each suggestion comes with the contribution Flow that would apply it,
|
|
250
|
+
which you add to the Scenario yourself: the command writes nothing. The figures are one
|
|
251
|
+
plan's own tax rules, an estimate and not tax advice, and each fund's holding rules are
|
|
252
|
+
not checked. A year that ended before the As-of, and a year the horizon cuts short, are left out; the
|
|
253
|
+
current year is included, and when the As-of falls mid-year it needs `--carry-in`, the
|
|
254
|
+
record of what was already contributed in that year earlier. `traj schema projection allowances`
|
|
255
|
+
describes the result.
|
|
189
256
|
|
|
190
257
|
## Money as decimals in a Scenario
|
|
191
258
|
|
|
@@ -197,6 +264,50 @@ Currency's major unit, such as `"1000.00"` for 100000 satang, and
|
|
|
197
264
|
same either way: saving what `show --decimal` printed leaves it unchanged. A value with more places
|
|
198
265
|
than the Currency has is refused, never rounded.
|
|
199
266
|
|
|
267
|
+
## A what-if, applied to the plan it came from
|
|
268
|
+
|
|
269
|
+
> **Ships in 0.8.0.**
|
|
270
|
+
|
|
271
|
+
`traj projection run --set` projects a change without saving it. `traj scenario apply` saves the same
|
|
272
|
+
change to the stored plan, so the plan you keep is the one you projected. It takes the `--set`,
|
|
273
|
+
`--without` and `--decimal` that `projection run` takes, and refuses what they would be refused for:
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
traj scenario apply base --set flows.salary.amount=9000000 --dry-run
|
|
277
|
+
traj scenario apply base --set flows.salary.amount=9000000 --without flows.gym
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
The result names the Overrides it wrote. A change that leaves the plan as it is writes nothing and
|
|
281
|
+
exits 0. `--if-hash <contentHash>` writes only when the stored plan still has that hash, as
|
|
282
|
+
`traj scenario show` printed it, and refuses the write otherwise. Without `--file`, `--set` and
|
|
283
|
+
`--without` never take a document, so the what-if cannot replace a plan you did not read.
|
|
284
|
+
|
|
285
|
+
### Adding an item to a what-if
|
|
286
|
+
|
|
287
|
+
> **Ships in 0.8.0.**
|
|
288
|
+
|
|
289
|
+
`--add <list>=<json>` puts one new item on the end of `accounts`, `flows` or `milestones`, so a new
|
|
290
|
+
loan, an extra payment or a new Flow can be tried before it is saved. The item carries its own `id`,
|
|
291
|
+
and an `id` the list already holds is refused (`--set` is the flag that changes an item that exists).
|
|
292
|
+
Every read that takes `--set` takes `--add` (`projection run`, `projection compare`, `fi`,
|
|
293
|
+
`projection chance` and `projection allowances`), and `scenario fork` and `scenario apply` save it:
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
traj projection run --scenario base --as-of 2026-03-31 --horizon 2027-03-30 \
|
|
297
|
+
--add 'flows={"id":"extra","kind":"expense","amount":"1000.00","frequency":"monthly","start":"2026-04-01","growth":{"bps":0}}' --decimal
|
|
298
|
+
traj scenario apply base --add 'flows={...}' --decimal --if-hash <contentHash>
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
The flags apply in a fixed order whatever order they are typed in: every `--without`, then every
|
|
302
|
+
`--add`, then every `--set`. So a `--set` can reach an item the same command adds
|
|
303
|
+
(`--add` then `--set flows.extra.amount=...`). An `--add` never replaces: one whose `list.id` the same
|
|
304
|
+
call's `--without` took out is refused, and `--set <path>.<key>=<value>` changes an item field by field,
|
|
305
|
+
so no field is dropped by accident and the plan saved is the plan projected. The result lists the items it added under `additions` (absent when none were), and
|
|
306
|
+
`effectiveContentHash` covers them. The engine checks the document with the item in it, so a refusal names
|
|
307
|
+
`--add` and the item's path (`flows.extra`) with the document path inside it. Under `--decimal` the
|
|
308
|
+
item's money is a decimal string of the Currency's major unit. Nothing is written until
|
|
309
|
+
`scenario apply` or `scenario fork` is run with the same flags.
|
|
310
|
+
|
|
200
311
|
## Milestones: points in the plan that a Flow waits for
|
|
201
312
|
|
|
202
313
|
> **Ships in 0.8.0.**
|
|
@@ -221,6 +332,109 @@ each side.
|
|
|
221
332
|
]
|
|
222
333
|
```
|
|
223
334
|
|
|
335
|
+
## Where each year's money went
|
|
336
|
+
|
|
337
|
+
> **Ships in 0.8.0.**
|
|
338
|
+
|
|
339
|
+
`traj projection run --breakdown` adds each Annual roll-up's cash flow as the engine routed it: each
|
|
340
|
+
Flow's income, the tax taken at source and each Levy's settlement (a refund is negative), each expense
|
|
341
|
+
and its category, each Contribution applied and the part the cash could not fund, each planned
|
|
342
|
+
withdrawal, what `cashflow.withdraw` drew and what `cashflow.surplus` filled. In JSON it is the
|
|
343
|
+
`cashflow` table, one row per line. In the human format it is one block per year, after the body:
|
|
344
|
+
|
|
345
|
+
```
|
|
346
|
+
cash flow 2026-03-31 to 2027-03-30 (13 rows)
|
|
347
|
+
line amount
|
|
348
|
+
money in 124500.00
|
|
349
|
+
income 120000.00
|
|
350
|
+
withdrawals 3000.00
|
|
351
|
+
drawn 1500.00
|
|
352
|
+
tax 4200.00
|
|
353
|
+
spending 50700.00
|
|
354
|
+
housing 30000.00
|
|
355
|
+
food 18000.00
|
|
356
|
+
transport 1500.00
|
|
357
|
+
(uncategorised) 1200.00
|
|
358
|
+
saving 64800.00
|
|
359
|
+
not funded 19200.00
|
|
360
|
+
left over 4800.00
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
Each total is the engine's figure, or an exact sum of the engine's own lines, so the CLI adds no figure of
|
|
364
|
+
its own. In every year, money in plus `unmet` (the cash a Shortfall left unpaid) equals tax, spending,
|
|
365
|
+
saving and left over: the engine routes every unit of cash. `not funded` is the part of the
|
|
366
|
+
Contributions the cash could not fund; it is not in saving.
|
|
367
|
+
|
|
368
|
+
## Where the money goes, and moving it between Accounts
|
|
369
|
+
|
|
370
|
+
> **Ships in 0.8.0.**
|
|
371
|
+
|
|
372
|
+
`cashflow` takes three more forms, every figure in them the caller's own (`traj` ships none): a surplus step's `share`, which takes that
|
|
373
|
+
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
|
|
374
|
+
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
|
|
375
|
+
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
|
|
376
|
+
a monthly amount from savings paying a loan down. `traj schema scenario apply` describes each, and `--set` reaches a step or an entry by
|
|
377
|
+
its position, so "what if I kept 100,000.00 in savings before touching the funds" is
|
|
378
|
+
`traj projection run --scenario plan --set cashflow.withdraw.0.downTo=10000000`.
|
|
379
|
+
|
|
380
|
+
`traj projection run` states what each did: the annual row's `transfers`, a `routing` echo of every step and entry by position,
|
|
381
|
+
and with `--breakdown` the `entry` each drawn line came from and a `transfers` table (what moved and what could not); with
|
|
382
|
+
`--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
|
|
383
|
+
and is not stated yet. A plan without these forms prints exactly as before.
|
|
384
|
+
|
|
385
|
+
## Loans
|
|
386
|
+
|
|
387
|
+
> **Ships in 0.8.0.**
|
|
388
|
+
|
|
389
|
+
A loan is three parts of a Scenario document: a liability Account with a nominal `rate` and a `compounding`
|
|
390
|
+
period, a `withdrawal` Flow from that liability when the money arrives, and a Contribution into the
|
|
391
|
+
liability whose amount is a `level` payment. `traj schema scenario apply` publishes one as its worked example.
|
|
392
|
+
|
|
393
|
+
`traj projection run --liabilities` adds the engine's statement of each loan: one month row per liability
|
|
394
|
+
(`opening`, `drawn`, `paid`, `interest`, `closing`) and each loan's paid-off date. The rows shown are
|
|
395
|
+
one loan's months, cut from the table; it lists every liability the Scenario holds. In JSON they are the
|
|
396
|
+
`liabilities` and `paidOff` tables. The human format prints one line per loan, then its months:
|
|
397
|
+
|
|
398
|
+
```
|
|
399
|
+
car: paid off on 2026-12-01
|
|
400
|
+
liabilities (26 rows)
|
|
401
|
+
account from to opening drawn paid interest closing partial
|
|
402
|
+
car 2026-06-01 2026-06-30 0.00 12000.00 0.00 58.00 12058.00 false
|
|
403
|
+
car 2026-07-01 2026-07-31 12058.00 0.00 2035.15 50.44 10073.29 false
|
|
404
|
+
car 2026-12-01 2026-12-31 9.66 0.00 9.66 0.00 0.00 false
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
The figures are the engine's: `interest` is the residual of the month, so `opening + drawn − paid + interest`
|
|
408
|
+
equals `closing` exactly. Without `--liabilities` the output is unchanged.
|
|
409
|
+
|
|
410
|
+
### What a fee and a payout came to over the plan
|
|
411
|
+
|
|
412
|
+
> **Ships in 0.8.0.**
|
|
413
|
+
|
|
414
|
+
An asset Account can pay out a share of its value as income (`payout`) and be charged a yearly `fee`.
|
|
415
|
+
`traj projection run` states each one's total over the whole horizon, so nothing needs adding up: the
|
|
416
|
+
engine sums them in the same run as the roll-ups (it is the sum of the `payouts` and `fees` of every
|
|
417
|
+
roll-up). Two fields appear, and only when the Scenario declares the item above 0 bps (0 bps is none):
|
|
418
|
+
|
|
419
|
+
- `accountLifetimes`: one `{ account, lifetimeFees?, lifetimePayouts? }` per Account that declares a fee or a payout,
|
|
420
|
+
in Scenario order. `lifetimeFees` is there when the Account carries a fee, `lifetimePayouts` when it carries a
|
|
421
|
+
payout; each is `0.00` if the Account never charged or paid.
|
|
422
|
+
- `lifetimeFees`: the fees of all Accounts together, present only when an Account carries a fee.
|
|
423
|
+
|
|
424
|
+
Both are money as every figure is, a decimal string at the currency's scale (`--decimal` changes what you
|
|
425
|
+
write, not what is read). The human format prints the plan-wide fees on a line of their own, then each
|
|
426
|
+
Account's totals as a table, and `projection path` states the same fields for a Market path:
|
|
427
|
+
|
|
428
|
+
```
|
|
429
|
+
Fees over the plan, all accounts: 1514.01
|
|
430
|
+
|
|
431
|
+
accountLifetimes (1 row)
|
|
432
|
+
account lifetimeFees lifetimePayouts
|
|
433
|
+
fund 1514.01 4051.89
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
Without a fee or a payout the output is unchanged.
|
|
437
|
+
|
|
224
438
|
## Seeing it in a browser
|
|
225
439
|
|
|
226
440
|
`traj 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 only reads, it listens on this machine only, 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.
|
|
@@ -250,6 +464,28 @@ traj backup --out ~/traj-backup-2026-11-30
|
|
|
250
464
|
traj data remove --confirm ~/.traj --backup ~/traj-backup-2026-11-30
|
|
251
465
|
```
|
|
252
466
|
|
|
467
|
+
### Going back after an upgrade
|
|
468
|
+
|
|
469
|
+
> **Ships in 0.8.0.**
|
|
470
|
+
|
|
471
|
+
When a newer `traj` has to migrate your database to a newer schema, it first copies it beside the
|
|
472
|
+
original as `traj.db.pre-v<N>.bak`, where `N` is the schema version the copy holds, and says so once
|
|
473
|
+
on stderr. Each copy is about the size of the database, so the upgrade needs that much free space;
|
|
474
|
+
if the copy cannot be written (a full disk, a directory that is not writable) the database is not
|
|
475
|
+
migrated and nothing changes. A new, empty ledger is not copied.
|
|
476
|
+
|
|
477
|
+
An older `traj` refuses a database a newer one has migrated, so to go back: stop every `traj`,
|
|
478
|
+
install the release you used before (the
|
|
479
|
+
[releases page](https://github.com/trajectonomics/trajectonomics/releases) lists them; `traj doctor`
|
|
480
|
+
on it reports the schema version it writes as `head`, which must equal `N`), delete `traj.db`,
|
|
481
|
+
`traj.db-wal` and `traj.db-shm` in the data directory, and copy the `.bak` file to `traj.db`.
|
|
482
|
+
Changes made after the upgrade are lost: the copy is the database as it was.
|
|
483
|
+
|
|
484
|
+
`traj doctor` lists the copies as `database.preMigrationCopies`, and any half-written one a crash
|
|
485
|
+
left as `database.unfinishedCopies`. `traj data remove` leaves the copies, because they are separate
|
|
486
|
+
files you can delete when you no longer need them, and its refusal names them: they hold your
|
|
487
|
+
data in plain text.
|
|
488
|
+
|
|
253
489
|
## Telemetry
|
|
254
490
|
|
|
255
491
|
`traj` 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:
|