@trajectonomics/cli 0.8.0-alpha.8 → 0.8.0-alpha.81
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 +184 -2
- package/package.json +2 -2
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,34 @@ 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
|
+
Pass `--paths` and `--seed` to `traj dashboard` to add the chance of success to the
|
|
227
|
+
Dashboard, as a page of its own: it uses `plan` unless you name a
|
|
228
|
+
`--return-model` file.
|
|
229
|
+
|
|
230
|
+
## Tax allowances
|
|
231
|
+
|
|
232
|
+
> **Ships in 0.8.0.**
|
|
233
|
+
|
|
234
|
+
`traj projection allowances` reads a Scenario that has a tax Levy and says, for each
|
|
235
|
+
whole tax year the Projection holds, how much more of each contribution label (RMF, ThaiESG
|
|
236
|
+
and the others the Levy reads) would still lower the tax, and by how much. You name the
|
|
237
|
+
labels in the order they should fill with `--labels`, and the size of one step with
|
|
238
|
+
`--step`, in major units: the CLI ships no default. `--budget` caps what the extra
|
|
239
|
+
contributions may add up to in a year, and `--min-saving` is the least percent of a step
|
|
240
|
+
a step must save. Each suggestion comes with the contribution Flow that would apply it,
|
|
241
|
+
which you add to the Scenario yourself: the command writes nothing. The figures are one
|
|
242
|
+
plan's own tax rules, an estimate and not tax advice, and each fund's holding rules are
|
|
243
|
+
not checked. A year that ended before the As-of, and a year the horizon cuts short, are left out; the
|
|
244
|
+
current year is included, and when the As-of falls mid-year it needs `--carry-in`, the
|
|
245
|
+
record of what was already contributed in that year earlier. `traj schema projection allowances`
|
|
246
|
+
describes the result.
|
|
189
247
|
|
|
190
248
|
## Money as decimals in a Scenario
|
|
191
249
|
|
|
@@ -197,6 +255,50 @@ Currency's major unit, such as `"1000.00"` for 100000 satang, and
|
|
|
197
255
|
same either way: saving what `show --decimal` printed leaves it unchanged. A value with more places
|
|
198
256
|
than the Currency has is refused, never rounded.
|
|
199
257
|
|
|
258
|
+
## A what-if, applied to the plan it came from
|
|
259
|
+
|
|
260
|
+
> **Ships in 0.8.0.**
|
|
261
|
+
|
|
262
|
+
`traj projection run --set` projects a change without saving it. `traj scenario apply` saves the same
|
|
263
|
+
change to the stored plan, so the plan you keep is the one you projected. It takes the `--set`,
|
|
264
|
+
`--without` and `--decimal` that `projection run` takes, and refuses what they would be refused for:
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
traj scenario apply base --set flows.salary.amount=9000000 --dry-run
|
|
268
|
+
traj scenario apply base --set flows.salary.amount=9000000 --without flows.gym
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
The result names the Overrides it wrote. A change that leaves the plan as it is writes nothing and
|
|
272
|
+
exits 0. `--if-hash <contentHash>` writes only when the stored plan still has that hash, as
|
|
273
|
+
`traj scenario show` printed it, and refuses the write otherwise. Without `--file`, `--set` and
|
|
274
|
+
`--without` never take a document, so the what-if cannot replace a plan you did not read.
|
|
275
|
+
|
|
276
|
+
### Adding an item to a what-if
|
|
277
|
+
|
|
278
|
+
> **Ships in 0.8.0.**
|
|
279
|
+
|
|
280
|
+
`--add <list>=<json>` puts one new item on the end of `accounts`, `flows` or `milestones`, so a new
|
|
281
|
+
loan, an extra payment or a new Flow can be tried before it is saved. The item carries its own `id`,
|
|
282
|
+
and an `id` the list already holds is refused (`--set` is the flag that changes an item that exists).
|
|
283
|
+
Every read that takes `--set` takes `--add` (`projection run`, `projection compare`, `fi`,
|
|
284
|
+
`projection chance` and `projection allowances`), and `scenario fork` and `scenario apply` save it:
|
|
285
|
+
|
|
286
|
+
```bash
|
|
287
|
+
traj projection run --scenario base --as-of 2026-03-31 --horizon 2027-03-30 \
|
|
288
|
+
--add 'flows={"id":"extra","kind":"expense","amount":"1000.00","frequency":"monthly","start":"2026-04-01","growth":{"bps":0}}' --decimal
|
|
289
|
+
traj scenario apply base --add 'flows={...}' --decimal --if-hash <contentHash>
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
The flags apply in a fixed order whatever order they are typed in: every `--without`, then every
|
|
293
|
+
`--add`, then every `--set`. So a `--set` can reach an item the same command adds
|
|
294
|
+
(`--add` then `--set flows.extra.amount=...`). An `--add` never replaces: one whose `list.id` the same
|
|
295
|
+
call's `--without` took out is refused, and `--set <path>.<key>=<value>` changes an item field by field,
|
|
296
|
+
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
|
|
297
|
+
`effectiveContentHash` covers them. The engine checks the document with the item in it, so a refusal names
|
|
298
|
+
`--add` and the item's path (`flows.extra`) with the document path inside it. Under `--decimal` the
|
|
299
|
+
item's money is a decimal string of the Currency's major unit. Nothing is written until
|
|
300
|
+
`scenario apply` or `scenario fork` is run with the same flags.
|
|
301
|
+
|
|
200
302
|
## Milestones: points in the plan that a Flow waits for
|
|
201
303
|
|
|
202
304
|
> **Ships in 0.8.0.**
|
|
@@ -221,6 +323,64 @@ each side.
|
|
|
221
323
|
]
|
|
222
324
|
```
|
|
223
325
|
|
|
326
|
+
## Where each year's money went
|
|
327
|
+
|
|
328
|
+
> **Ships in 0.8.0.**
|
|
329
|
+
|
|
330
|
+
`traj projection run --breakdown` adds each Annual roll-up's cash flow as the engine routed it: each
|
|
331
|
+
Flow's income, the tax taken at source and each Levy's settlement (a refund is negative), each expense
|
|
332
|
+
and its category, each Contribution applied and the part the cash could not fund, each planned
|
|
333
|
+
withdrawal, what `cashflow.withdraw` drew and what `cashflow.surplus` filled. In JSON it is the
|
|
334
|
+
`cashflow` table, one row per line. In the human format it is one block per year, after the body:
|
|
335
|
+
|
|
336
|
+
```
|
|
337
|
+
cash flow 2026-03-31 to 2027-03-30 (13 rows)
|
|
338
|
+
line amount
|
|
339
|
+
money in 124500.00
|
|
340
|
+
income 120000.00
|
|
341
|
+
withdrawals 3000.00
|
|
342
|
+
drawn 1500.00
|
|
343
|
+
tax 4200.00
|
|
344
|
+
spending 50700.00
|
|
345
|
+
housing 30000.00
|
|
346
|
+
food 18000.00
|
|
347
|
+
transport 1500.00
|
|
348
|
+
(uncategorised) 1200.00
|
|
349
|
+
saving 64800.00
|
|
350
|
+
not funded 19200.00
|
|
351
|
+
left over 4800.00
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
Each total is the engine's figure, or an exact sum of the engine's own lines, so the CLI adds no figure of
|
|
355
|
+
its own. In every year, money in plus `unmet` (the cash a Shortfall left unpaid) equals tax, spending,
|
|
356
|
+
saving and left over: the engine routes every unit of cash. `not funded` is the part of the
|
|
357
|
+
Contributions the cash could not fund; it is not in saving.
|
|
358
|
+
|
|
359
|
+
## Loans
|
|
360
|
+
|
|
361
|
+
> **Ships in 0.8.0.**
|
|
362
|
+
|
|
363
|
+
A loan is three parts of a Scenario document: a liability Account with a nominal `rate` and a `compounding`
|
|
364
|
+
period, a `withdrawal` Flow from that liability when the money arrives, and a Contribution into the
|
|
365
|
+
liability whose amount is a `level` payment. `traj schema scenario apply` publishes one as its worked example.
|
|
366
|
+
|
|
367
|
+
`traj projection run --liabilities` adds the engine's statement of each loan: one month row per liability
|
|
368
|
+
(`opening`, `drawn`, `paid`, `interest`, `closing`) and each loan's paid-off date. The rows shown are
|
|
369
|
+
one loan's months, cut from the table; it lists every liability the Scenario holds. In JSON they are the
|
|
370
|
+
`liabilities` and `paidOff` tables. The human format prints one line per loan, then its months:
|
|
371
|
+
|
|
372
|
+
```
|
|
373
|
+
car: paid off on 2026-12-01
|
|
374
|
+
liabilities (26 rows)
|
|
375
|
+
account from to opening drawn paid interest closing partial
|
|
376
|
+
car 2026-06-01 2026-06-30 0.00 12000.00 0.00 58.00 12058.00 false
|
|
377
|
+
car 2026-07-01 2026-07-31 12058.00 0.00 2035.15 50.44 10073.29 false
|
|
378
|
+
car 2026-12-01 2026-12-31 9.66 0.00 9.66 0.00 0.00 false
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
The figures are the engine's: `interest` is the residual of the month, so `opening + drawn − paid + interest`
|
|
382
|
+
equals `closing` exactly. Without `--liabilities` the output is unchanged.
|
|
383
|
+
|
|
224
384
|
## Seeing it in a browser
|
|
225
385
|
|
|
226
386
|
`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 +410,28 @@ traj backup --out ~/traj-backup-2026-11-30
|
|
|
250
410
|
traj data remove --confirm ~/.traj --backup ~/traj-backup-2026-11-30
|
|
251
411
|
```
|
|
252
412
|
|
|
413
|
+
### Going back after an upgrade
|
|
414
|
+
|
|
415
|
+
> **Ships in 0.8.0.**
|
|
416
|
+
|
|
417
|
+
When a newer `traj` has to migrate your database to a newer schema, it first copies it beside the
|
|
418
|
+
original as `traj.db.pre-v<N>.bak`, where `N` is the schema version the copy holds, and says so once
|
|
419
|
+
on stderr. Each copy is about the size of the database, so the upgrade needs that much free space;
|
|
420
|
+
if the copy cannot be written (a full disk, a directory that is not writable) the database is not
|
|
421
|
+
migrated and nothing changes. A new, empty ledger is not copied.
|
|
422
|
+
|
|
423
|
+
An older `traj` refuses a database a newer one has migrated, so to go back: stop every `traj`,
|
|
424
|
+
install the release you used before (the
|
|
425
|
+
[releases page](https://github.com/trajectonomics/trajectonomics/releases) lists them; `traj doctor`
|
|
426
|
+
on it reports the schema version it writes as `head`, which must equal `N`), delete `traj.db`,
|
|
427
|
+
`traj.db-wal` and `traj.db-shm` in the data directory, and copy the `.bak` file to `traj.db`.
|
|
428
|
+
Changes made after the upgrade are lost: the copy is the database as it was.
|
|
429
|
+
|
|
430
|
+
`traj doctor` lists the copies as `database.preMigrationCopies`, and any half-written one a crash
|
|
431
|
+
left as `database.unfinishedCopies`. `traj data remove` leaves the copies, because they are separate
|
|
432
|
+
files you can delete when you no longer need them, and its refusal names them: they hold your
|
|
433
|
+
data in plain text.
|
|
434
|
+
|
|
253
435
|
## Telemetry
|
|
254
436
|
|
|
255
437
|
`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:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trajectonomics/cli",
|
|
3
|
-
"version": "0.8.0-alpha.
|
|
3
|
+
"version": "0.8.0-alpha.81",
|
|
4
4
|
"description": "trajectonomics command line",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -34,6 +34,6 @@
|
|
|
34
34
|
"lint": "biome ci --error-on-warnings .",
|
|
35
35
|
"format": "biome check --write .",
|
|
36
36
|
"build": "bun build src/index.ts --compile --no-compile-autoload-bunfig --no-compile-autoload-dotenv --outfile dist/traj",
|
|
37
|
-
"check": "bun run lint && bun run typecheck && bun test && bun
|
|
37
|
+
"check": "bun run lint && bun run typecheck && bun test && bun ../../tooling/scripts/build-unless-turbo.ts"
|
|
38
38
|
}
|
|
39
39
|
}
|