@trajectonomics/cli 0.8.0-alpha.12 → 0.8.0-alpha.121

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 (2) hide show
  1. package/README.md +245 -2
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -84,9 +84,42 @@ traj report networth --as-of 2026-03-31
84
84
  comes from, and a transaction moves an amount from one to another. Every read states its own
85
85
  date and never reads the clock, so the same command always answers the same question.
86
86
 
87
+ To chart net worth over time, state every month-end of a period in one read instead of one
88
+ call per month:
89
+
90
+ ```bash
91
+ traj report networth --monthly --since 2026-01-01 --until 2026-03-31
92
+ ```
93
+
94
+ Each month is exactly what `--as-of` gives for that date.
95
+
87
96
  `traj help` lists every command, `traj help <command>` lists one command's flags, and
88
97
  `traj schema --json` prints the whole contract: every command's input, output and error codes.
89
98
 
99
+ ## Importing a statement
100
+
101
+ To load a bank statement, fill the one CSV template instead of adding each transaction by
102
+ hand. `traj tx import` has been in every release since 0.1.0.
103
+
104
+ ```bash
105
+ traj tx import --template # print the template header and nothing else
106
+ traj tx import statement.csv --dry-run
107
+ traj tx import statement.csv
108
+ ```
109
+
110
+ `--template` prints the header the importer reads, and it opens no data directory:
111
+
112
+ ```csv
113
+ date,from,to,amount,memo,external_ref,project
114
+ ```
115
+
116
+ Start your file with that header and write one row per transaction. `--dry-run` reports every
117
+ row and rolls every write back, so run it first. A file name of `-` reads the CSV from stdin, as in
118
+ `traj tx import - --dry-run`. The import is all or nothing, and `external_ref` is the duplicate
119
+ key, so importing the same statement twice adds nothing the second time. Each command's flags and
120
+ the rest of the columns are in
121
+ [the `tx` page of the docs](https://docs.trajectonomics.com/cli/commands/tx/).
122
+
90
123
  ## Development
91
124
 
92
125
  The sources are Bun-only; a released binary needs nothing.
@@ -144,6 +177,14 @@ deduction nobody stated is visible rather than assumed to be zero. It states
144
177
  what the flags said, never what tax-core applied: a premium the statute does
145
178
  not allow for the filing status is still stated, and the Levy zeroes it.
146
179
 
180
+ The write keeps that profile beside the Scenario, and `traj scenario show` prints
181
+ it back as `tax`. `--merge` then changes only the flags it carries
182
+ (`traj scenario tax base --merge --children 2`) and keeps the rest, and
183
+ `--from-stored` writes the Levy again from the profile, for example after a
184
+ tax-year update. Both need a stored profile: a plan taxed before it was kept
185
+ states its profile whole once. `--if-hash` refuses a write over a plan that
186
+ changed since you read it, as on `scenario apply`.
187
+
147
188
  ```json
148
189
  {
149
190
  "status": "updated",
@@ -184,8 +225,43 @@ year. The paths draw from a Return model you state in a JSON file, with
184
225
  seed and count always give the same answer. The CLI ships no Return model: which
185
226
  market history a plan is tested against is your decision, and every figure is
186
227
  only as good as that choice. `traj schema projection chance` describes the file.
187
- Pass the same three flags to `traj dashboard` to add the chance of success to the
188
- Dashboard, as a page of its own.
228
+ Or pass `--return-model plan` to build the model from the plan itself: each asset
229
+ Account's `rate` and its `volatility` (the standard deviation of its yearly
230
+ return, in basis points, which you write into the Scenario). `--buckets` sets its
231
+ size (a power of two from 16 to 1024, 256 by default), the result echoes what it
232
+ was built from as `returnModel`, and `traj projection model --scenario NAME`
233
+ prints the model as JSON, a file `--return-model` reads back. A plan with no
234
+ `volatility` is refused, because every path would be the same path.
235
+ Add `--outcomes` to see what each path came to: its closing and lowest net
236
+ worth, the year it was lowest and when it ran out, with the paths at the 10th,
237
+ 50th and 90th percentile, the earliest to run out and the lowest named as
238
+ `representative` (the human form prints every path, worst first). Then
239
+ `traj projection path --index N`, with the same flags, replays path N year by
240
+ year: `projection run`'s result, with the same flags for the cash flow and each
241
+ Account's value, plus the market return each Account drew in each year as
242
+ `returns`. An index is a path's name under the seed, so it is from 0 to
243
+ `--paths` minus 1.
244
+ Pass `--paths` and `--seed` to `traj dashboard` to add the chance of success to the
245
+ Dashboard, as a page of its own: it uses `plan` unless you name a
246
+ `--return-model` file.
247
+
248
+ ## Tax allowances
249
+
250
+ > **Ships in 0.8.0.**
251
+
252
+ `traj projection allowances` reads a Scenario that has a tax Levy and says, for each
253
+ whole tax year the Projection holds, how much more of each contribution label (RMF, ThaiESG
254
+ and the others the Levy reads) would still lower the tax, and by how much. You name the
255
+ labels in the order they should fill with `--labels`, and the size of one step with
256
+ `--step`, in major units: the CLI ships no default. `--budget` caps what the extra
257
+ contributions may add up to in a year, and `--min-saving` is the least percent of a step
258
+ a step must save. Each suggestion comes with the contribution Flow that would apply it,
259
+ which you add to the Scenario yourself: the command writes nothing. The figures are one
260
+ plan's own tax rules, an estimate and not tax advice, and each fund's holding rules are
261
+ not checked. A year that ended before the As-of, and a year the horizon cuts short, are left out; the
262
+ current year is included, and when the As-of falls mid-year it needs `--carry-in`, the
263
+ record of what was already contributed in that year earlier. `traj schema projection allowances`
264
+ describes the result.
189
265
 
190
266
  ## Money as decimals in a Scenario
191
267
 
@@ -197,6 +273,66 @@ Currency's major unit, such as `"1000.00"` for 100000 satang, and
197
273
  same either way: saving what `show --decimal` printed leaves it unchanged. A value with more places
198
274
  than the Currency has is refused, never rounded.
199
275
 
276
+ ## A what-if, applied to the plan it came from
277
+
278
+ > **Ships in 0.8.0.**
279
+
280
+ `traj projection run --set` projects a change without saving it. `traj scenario apply` saves the same
281
+ change to the stored plan, so the plan you keep is the one you projected. It takes the `--set`,
282
+ `--without` and `--decimal` that `projection run` takes, and refuses what they would be refused for:
283
+
284
+ ```bash
285
+ traj scenario apply base --set flows.salary.amount=9000000 --dry-run
286
+ traj scenario apply base --set flows.salary.amount=9000000 --without flows.gym
287
+ ```
288
+
289
+ The result names the Overrides it wrote. A change that leaves the plan as it is writes nothing and
290
+ exits 0. `--if-hash <contentHash>` writes only when the stored plan still has that hash, as
291
+ `traj scenario show` printed it, and refuses the write otherwise. Without `--file`, `--set` and
292
+ `--without` never take a document, so the what-if cannot replace a plan you did not read.
293
+
294
+ ### Adding an item to a what-if
295
+
296
+ > **Ships in 0.8.0.**
297
+
298
+ `--add <list>=<json>` puts one new item on the end of `accounts`, `flows` or `milestones`, so a new
299
+ loan, an extra payment or a new Flow can be tried before it is saved. The item carries its own `id`,
300
+ and an `id` the list already holds is refused (`--set` is the flag that changes an item that exists).
301
+ Every read that takes `--set` takes `--add` (`projection run`, `projection compare`, `fi`,
302
+ `projection chance` and `projection allowances`), and `scenario fork` and `scenario apply` save it:
303
+
304
+ ```bash
305
+ traj projection run --scenario base --as-of 2026-03-31 --horizon 2027-03-30 \
306
+ --add 'flows={"id":"extra","kind":"expense","amount":"1000.00","frequency":"monthly","start":"2026-04-01","growth":{"bps":0}}' --decimal
307
+ traj scenario apply base --add 'flows={...}' --decimal --if-hash <contentHash>
308
+ ```
309
+
310
+ The flags apply in a fixed order whatever order they are typed in: every `--without`, then every
311
+ `--add`, then every `--set`. So a `--set` can reach an item the same command adds
312
+ (`--add` then `--set flows.extra.amount=...`). An `--add` never replaces: one whose `list.id` the same
313
+ call's `--without` took out is refused, and `--set <path>.<key>=<value>` changes an item field by field,
314
+ 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
315
+ `effectiveContentHash` covers them. The engine checks the document with the item in it, so a refusal names
316
+ `--add` and the item's path (`flows.extra`) with the document path inside it. Under `--decimal` the
317
+ item's money is a decimal string of the Currency's major unit. Nothing is written until
318
+ `scenario apply` or `scenario fork` is run with the same flags.
319
+
320
+ ## Naming plans, keeping notes on them, and marking the main one
321
+
322
+ > **Ships in 0.8.0.**
323
+
324
+ A person who compares "retire at 55" with "retire at 60 and buy a condo" ends up with several plans.
325
+ `traj scenario rename early retire-at-55` gives a plan a better name and keeps its id, document and
326
+ `contentHash`. `traj scenario notes retire-at-55 --text "Sell the condo in 2031."` keeps plain text
327
+ on it (`--file <path>` or `--file -` reads it, `--clear` removes it), and `scenario show` prints it
328
+ back as `notes`. Notes are not part of the plan, so they never change its `contentHash`, and a
329
+ `scenario fork` copies them unless it is given `--no-notes`.
330
+
331
+ `traj scenario main retire-at-55` marks one plan as your main plan, and `scenario list` and
332
+ `scenario show` print `main`. It is a label and not a default: `projection run` and every other read
333
+ still need `--scenario`. `scenario rm` of the main plan is refused until another is chosen
334
+ (`scenario main --clear` takes the mark off), or removed anyway with `--force`.
335
+
200
336
  ## Milestones: points in the plan that a Flow waits for
201
337
 
202
338
  > **Ships in 0.8.0.**
@@ -221,6 +357,113 @@ each side.
221
357
  ]
222
358
  ```
223
359
 
360
+ ## Where each year's money went
361
+
362
+ > **Ships in 0.8.0.**
363
+
364
+ `traj projection run --breakdown` adds each Annual roll-up's cash flow as the engine routed it: each
365
+ Flow's income, the tax taken at source and each Levy's settlement (a refund is negative), each expense
366
+ and its category, each Contribution applied and the part the cash could not fund, each planned
367
+ withdrawal, what `cashflow.withdraw` drew and what `cashflow.surplus` filled. In JSON it is the
368
+ `cashflow` table, one row per line. Its section totals are the `cashflowTotals` table beside it: nine rows per year,
369
+ in the order money in, tax, withdrawals, drawn, spending, saving, not funded, left over and unmet. The `cashflowTotals` table
370
+ and the human block come from one function (`cashflowTotalsOf`), so they cannot disagree. JSON states a zero total as `0.00`; the human block
371
+ leaves out a zero not funded or unmet, and withdrawals, drawn or tax when its roll-up has no line of that group. In the
372
+ human format it is one block per year, after the body:
373
+
374
+ ```
375
+ cash flow 2026-03-31 to 2027-03-30 (13 rows)
376
+ line amount
377
+ money in 124500.00
378
+ income 120000.00
379
+ withdrawals 3000.00
380
+ drawn 1500.00
381
+ tax 4200.00
382
+ spending 50700.00
383
+ housing 30000.00
384
+ food 18000.00
385
+ transport 1500.00
386
+ (uncategorised) 1200.00
387
+ saving 64800.00
388
+ not funded 19200.00
389
+ left over 4800.00
390
+ ```
391
+
392
+ Each total is the engine's figure, or an exact sum of the engine's own lines, so the CLI adds no figure of
393
+ its own. In every year, money in plus `unmet` (the cash a Shortfall left unpaid) equals tax, spending,
394
+ saving and left over: the engine routes every unit of cash. `not funded` is the part of the
395
+ Contributions the cash could not fund; it is not in saving.
396
+
397
+ ## Where the money goes, and moving it between Accounts
398
+
399
+ > **Ships in 0.8.0.**
400
+
401
+ `cashflow` takes three more forms, every figure in them the caller's own (`traj` ships none): a surplus step's `share`, which takes that
402
+ 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
403
+ 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
404
+ 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
405
+ a monthly amount from savings paying a loan down. `traj schema scenario apply` describes each, and `--set` reaches a step or an entry by
406
+ its position, so "what if I kept 100,000.00 in savings before touching the funds" is
407
+ `traj projection run --scenario plan --set cashflow.withdraw.0.downTo=10000000`.
408
+
409
+ `traj projection run` states what each did: the annual row's `transfers`, a `routing` echo of every step and entry by position,
410
+ and with `--breakdown` the `entry` each drawn line came from and a `transfers` table (what moved and what could not); with
411
+ `--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
412
+ and is not stated yet. A plan without these forms prints exactly as before.
413
+
414
+ ## Loans
415
+
416
+ > **Ships in 0.8.0.**
417
+
418
+ A loan is three parts of a Scenario document: a liability Account with a nominal `rate` and a `compounding`
419
+ period, a `withdrawal` Flow from that liability when the money arrives, and a Contribution into the
420
+ liability whose amount is a `level` payment. `traj schema scenario apply` publishes one as its worked example.
421
+
422
+ `traj projection run --liabilities` adds the engine's statement of each loan: one month row per liability
423
+ (`opening`, `drawn`, `paid`, `interest`, `closing`) and each loan's paid-off date. The rows shown are
424
+ one loan's months, cut from the table; it lists every liability the Scenario holds. In JSON they are the
425
+ `liabilities` and `paidOff` tables. The human format prints one line per loan, then its months:
426
+
427
+ ```
428
+ car: paid off on 2026-12-01
429
+ liabilities (26 rows)
430
+ account from to opening drawn paid interest closing partial
431
+ car 2026-06-01 2026-06-30 0.00 12000.00 0.00 58.00 12058.00 false
432
+ car 2026-07-01 2026-07-31 12058.00 0.00 2035.15 50.44 10073.29 false
433
+ car 2026-12-01 2026-12-31 9.66 0.00 9.66 0.00 0.00 false
434
+ ```
435
+
436
+ The figures are the engine's: `interest` is the residual of the month, so `opening + drawn − paid + interest`
437
+ equals `closing` exactly. Without `--liabilities` the output is unchanged.
438
+
439
+ ### What a fee and a payout came to over the plan
440
+
441
+ > **Ships in 0.8.0.**
442
+
443
+ An asset Account can pay out a share of its value as income (`payout`) and be charged a yearly `fee`.
444
+ `traj projection run` states each one's total over the whole horizon, so nothing needs adding up: the
445
+ engine sums them in the same run as the roll-ups (it is the sum of the `payouts` and `fees` of every
446
+ roll-up). Two fields appear, and only when the Scenario declares the item above 0 bps (0 bps is none):
447
+
448
+ - `accountLifetimes`: one `{ account, lifetimeFees?, lifetimePayouts? }` per Account that declares a fee or a payout,
449
+ in Scenario order. `lifetimeFees` is there when the Account carries a fee, `lifetimePayouts` when it carries a
450
+ payout; each is `0.00` if the Account never charged or paid.
451
+ - `lifetimeFees`: the fees of all Accounts together, present only when an Account carries a fee.
452
+
453
+ Both are money as every figure is, a decimal string at the currency's scale (`--decimal` changes what you
454
+ write, not what is read). The human format prints the plan-wide fees on a line of their own, then each
455
+ Account's totals as a table, and `projection path` states the same fields for a Market path:
456
+
457
+ ```
458
+ Fees over the plan, all accounts: 1514.01
459
+
460
+ accountLifetimes (1 row)
461
+ account lifetimeFees lifetimePayouts
462
+ fund 1514.01 4051.89
463
+ ```
464
+
465
+ Without a fee or a payout the output is unchanged.
466
+
224
467
  ## Seeing it in a browser
225
468
 
226
469
  `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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trajectonomics/cli",
3
- "version": "0.8.0-alpha.12",
3
+ "version": "0.8.0-alpha.121",
4
4
  "description": "trajectonomics command line",
5
5
  "license": "MIT",
6
6
  "type": "module",