@slothmoney/agent-cli 0.13.0 → 0.14.1
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/CHANGELOG.md +11 -0
- package/README.md +17 -2
- package/dist/account-ref.js +4 -0
- package/dist/args.js +10 -2
- package/dist/cli.js +51 -4
- package/dist/contracts.js +4 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.14.1 - 2026-08-21
|
|
4
|
+
|
|
5
|
+
- Make every parent help page list its nested commands, and give
|
|
6
|
+
`line-items --help` its own group page instead of generic top-level usage.
|
|
7
|
+
|
|
8
|
+
## 0.14.0 - 2026-08-20
|
|
9
|
+
|
|
10
|
+
- Add `transactions --account-ref REF` using the opaque reference returned by
|
|
11
|
+
`sloth-agent accounts`, while retaining `--account-id` for compatibility.
|
|
12
|
+
- Require every transaction result to include its matching `accountRef`.
|
|
13
|
+
|
|
3
14
|
## 0.13.0 - 2026-08-19
|
|
4
15
|
|
|
5
16
|
- Let `assign` share or unshare an owned booked personal transaction, update
|
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ sloth-agent --version
|
|
|
15
15
|
For a one-off pinned run:
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
npm exec --yes --package=@slothmoney/agent-cli@0.
|
|
18
|
+
npm exec --yes --package=@slothmoney/agent-cli@0.14.1 -- sloth-agent --help
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
## Authenticate
|
|
@@ -98,7 +98,7 @@ An assignment can change an owned transaction's sharing, categorisation, or
|
|
|
98
98
|
both.
|
|
99
99
|
|
|
100
100
|
Every command has built-in reference documentation covering its inputs,
|
|
101
|
-
options, output, and examples:
|
|
101
|
+
options, output, and examples. For example:
|
|
102
102
|
|
|
103
103
|
```bash
|
|
104
104
|
sloth-agent auth login --help
|
|
@@ -109,6 +109,7 @@ sloth-agent budget update --help
|
|
|
109
109
|
sloth-agent budget move --help
|
|
110
110
|
sloth-agent categories --help
|
|
111
111
|
sloth-agent categories create --help
|
|
112
|
+
sloth-agent line-items --help
|
|
112
113
|
sloth-agent line-items create --help
|
|
113
114
|
sloth-agent transactions --help
|
|
114
115
|
sloth-agent assign --help
|
|
@@ -471,6 +472,20 @@ Missing values are JSON
|
|
|
471
472
|
are excluded, while enabled shared joint accounts follow Sloth's existing
|
|
472
473
|
visibility rules.
|
|
473
474
|
|
|
475
|
+
Use an account's opaque reference to read only its transactions. Transaction
|
|
476
|
+
rows return the same `accountRef`, so pagination and follow-up reads keep the
|
|
477
|
+
account boundary explicit:
|
|
478
|
+
|
|
479
|
+
```bash
|
|
480
|
+
sloth-agent transactions \
|
|
481
|
+
--account-ref PASTE_THE_EXACT_ACCOUNT_REF_HERE \
|
|
482
|
+
--limit 50
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
Copy the value from `sloth-agent accounts`. The older `--account-id` filter is
|
|
486
|
+
still accepted for compatibility, but new workflows should use
|
|
487
|
+
`--account-ref`. Do not provide both filters in one command.
|
|
488
|
+
|
|
474
489
|
Account changes are previews unless `--apply` is present. Connected accounts
|
|
475
490
|
support only goal-savings membership. Manual current accounts support their
|
|
476
491
|
institution, name, currency, and ownership. Manual balance accounts also
|
package/dist/args.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { UsageError } from './errors.js';
|
|
2
|
+
import { isAccountRef } from './account-ref.js';
|
|
2
3
|
import { CATEGORY_TYPES, ICON_KEYS, } from './category-metadata.js';
|
|
3
4
|
import { isGoalType, } from './goal-metadata.js';
|
|
4
5
|
const PRODUCTION_BASE_URL = 'https://budget.slothmoney.app';
|
|
@@ -175,6 +176,7 @@ function parseTransactions(args) {
|
|
|
175
176
|
'--start-date',
|
|
176
177
|
'--end-date',
|
|
177
178
|
'--q',
|
|
179
|
+
'--account-ref',
|
|
178
180
|
'--account-id',
|
|
179
181
|
'--category-id',
|
|
180
182
|
'--line-item-id',
|
|
@@ -208,6 +210,9 @@ function parseTransactions(args) {
|
|
|
208
210
|
else if (name === '--q') {
|
|
209
211
|
filters.q = setOnce(filters.q, value, name);
|
|
210
212
|
}
|
|
213
|
+
else if (name === '--account-ref') {
|
|
214
|
+
filters.accountRef = setOnce(filters.accountRef, parseAccountRef(value), name);
|
|
215
|
+
}
|
|
211
216
|
else if (name === '--account-id') {
|
|
212
217
|
filters.accountId = setOnce(filters.accountId, value, name);
|
|
213
218
|
}
|
|
@@ -232,6 +237,9 @@ function parseTransactions(args) {
|
|
|
232
237
|
&& filters.endDate < filters.startDate) {
|
|
233
238
|
throw new UsageError('--end-date must not be before --start-date');
|
|
234
239
|
}
|
|
240
|
+
if (filters.accountRef !== undefined && filters.accountId !== undefined) {
|
|
241
|
+
throw new UsageError('Use either --account-ref or --account-id, not both');
|
|
242
|
+
}
|
|
235
243
|
return filters;
|
|
236
244
|
}
|
|
237
245
|
function parseNamedOptions(args, commandLabel, allowed) {
|
|
@@ -267,7 +275,7 @@ function requiredOption(values, option, commandLabel) {
|
|
|
267
275
|
return value;
|
|
268
276
|
}
|
|
269
277
|
function parseAccountRef(value) {
|
|
270
|
-
if (
|
|
278
|
+
if (!isAccountRef(value)) {
|
|
271
279
|
throw new UsageError('--account-ref must be a valid accountRef from sloth-agent accounts');
|
|
272
280
|
}
|
|
273
281
|
return value;
|
|
@@ -795,7 +803,7 @@ function helpTopic(argv) {
|
|
|
795
803
|
return 'line-items-create';
|
|
796
804
|
if (subcommand === 'rename')
|
|
797
805
|
return 'line-items-rename';
|
|
798
|
-
return
|
|
806
|
+
return 'line-items';
|
|
799
807
|
}
|
|
800
808
|
if (command === 'budget') {
|
|
801
809
|
if (subcommand === 'status')
|
package/dist/cli.js
CHANGED
|
@@ -4,7 +4,7 @@ import { ICON_KEYS } from './category-metadata.js';
|
|
|
4
4
|
import { parseApiResponse, validateAssignmentPayload, validateBudgetMovementResponse, validateBudgetUpdatePayload, } from './contracts.js';
|
|
5
5
|
import { createSystemCredentialStore, secureStorageUnavailableError, } from './credential-store.js';
|
|
6
6
|
import { ApiError, CliError, ConfigError, UsageError, } from './errors.js';
|
|
7
|
-
export const CLI_VERSION = '0.
|
|
7
|
+
export const CLI_VERSION = '0.14.1';
|
|
8
8
|
const REQUEST_TIMEOUT_MS = 60_000;
|
|
9
9
|
const API_ORIGIN_HELP_LINES = [
|
|
10
10
|
'',
|
|
@@ -42,7 +42,7 @@ export function usageText() {
|
|
|
42
42
|
' sloth-agent line-items rename --scope personal|joint --category-id ID --line-item-id ID --name NAME [--apply]',
|
|
43
43
|
' sloth-agent transactions [--uncategorized[=true|false]] [--shared[=true|false]] [--limit N]',
|
|
44
44
|
' [--start-date YYYY-MM-DD] [--end-date YYYY-MM-DD] [--q TEXT]',
|
|
45
|
-
' [--account-id ID] [--category-id ID] [--line-item-id ID]',
|
|
45
|
+
' [--account-ref REF] [--account-id ID] [--category-id ID] [--line-item-id ID]',
|
|
46
46
|
' [--cursor CURSOR] [--base-url URL]',
|
|
47
47
|
' sloth-agent assign --input assignments.json [--apply] [--base-url URL]',
|
|
48
48
|
' sloth-agent goals [list] [--base-url URL]',
|
|
@@ -56,7 +56,7 @@ export function usageText() {
|
|
|
56
56
|
'',
|
|
57
57
|
'Help:',
|
|
58
58
|
' Run sloth-agent <command> --help for options, inputs, output, and examples.',
|
|
59
|
-
'
|
|
59
|
+
' Every nested subcommand has its own help, for example:',
|
|
60
60
|
' sloth-agent auth login --help',
|
|
61
61
|
' sloth-agent goals update --help',
|
|
62
62
|
'',
|
|
@@ -176,6 +176,14 @@ export function categoriesHelpText() {
|
|
|
176
176
|
'',
|
|
177
177
|
'Read categories and the personal and joint line items within them.',
|
|
178
178
|
'',
|
|
179
|
+
'Commands:',
|
|
180
|
+
' sloth-agent categories list List categories; "sloth-agent categories" is equivalent.',
|
|
181
|
+
' sloth-agent categories create Preview or create a custom category.',
|
|
182
|
+
' sloth-agent categories rename Preview or rename a custom category.',
|
|
183
|
+
'',
|
|
184
|
+
'Help:',
|
|
185
|
+
' Run sloth-agent categories <command> --help for command-specific details.',
|
|
186
|
+
'',
|
|
179
187
|
'Usage:',
|
|
180
188
|
' sloth-agent categories [list] [--base-url URL]',
|
|
181
189
|
'',
|
|
@@ -286,12 +294,35 @@ export function lineItemsCreateHelpText() {
|
|
|
286
294
|
export function lineItemsRenameHelpText() {
|
|
287
295
|
return lineItemsMutationHelpText('rename');
|
|
288
296
|
}
|
|
297
|
+
export function lineItemsHelpText() {
|
|
298
|
+
return [
|
|
299
|
+
'Sloth Agent CLI — line-items',
|
|
300
|
+
'',
|
|
301
|
+
'Create or rename personal or joint budget line items.',
|
|
302
|
+
'',
|
|
303
|
+
'Commands:',
|
|
304
|
+
' sloth-agent line-items create Preview or create a scoped line item.',
|
|
305
|
+
' sloth-agent line-items rename Preview or rename a scoped line item.',
|
|
306
|
+
'',
|
|
307
|
+
'Help:',
|
|
308
|
+
' Run sloth-agent line-items <command> --help for command-specific details.',
|
|
309
|
+
...API_ORIGIN_HELP_LINES,
|
|
310
|
+
].join('\n');
|
|
311
|
+
}
|
|
289
312
|
export function accountsHelpText() {
|
|
290
313
|
return [
|
|
291
314
|
'Sloth Agent CLI — accounts',
|
|
292
315
|
'',
|
|
293
316
|
'Read the existing Sloth account inventory known to the authenticated user.',
|
|
294
317
|
'',
|
|
318
|
+
'Commands:',
|
|
319
|
+
' sloth-agent accounts list List accounts; "sloth-agent accounts" is equivalent.',
|
|
320
|
+
' sloth-agent accounts update Preview or update an owned account.',
|
|
321
|
+
' sloth-agent accounts remove Preview or archive an owned manual account.',
|
|
322
|
+
'',
|
|
323
|
+
'Help:',
|
|
324
|
+
' Run sloth-agent accounts <command> --help for command-specific details.',
|
|
325
|
+
'',
|
|
295
326
|
'Usage:',
|
|
296
327
|
' sloth-agent accounts [list] [--base-url URL]',
|
|
297
328
|
'',
|
|
@@ -402,6 +433,15 @@ export function budgetHelpText() {
|
|
|
402
433
|
'',
|
|
403
434
|
'Read one personal or joint budget period.',
|
|
404
435
|
'',
|
|
436
|
+
'Commands:',
|
|
437
|
+
' sloth-agent budget Read one budget period.',
|
|
438
|
+
' sloth-agent budget status Read assigned, spent, and available money.',
|
|
439
|
+
' sloth-agent budget update Preview or update planned line-item amounts.',
|
|
440
|
+
' sloth-agent budget move Preview or move assigned money.',
|
|
441
|
+
'',
|
|
442
|
+
'Help:',
|
|
443
|
+
' Run sloth-agent budget <command> --help for command-specific details.',
|
|
444
|
+
'',
|
|
405
445
|
'Usage:',
|
|
406
446
|
' sloth-agent budget --scope personal|joint [--period YYYY-MM] [--base-url URL]',
|
|
407
447
|
'',
|
|
@@ -547,7 +587,9 @@ export function transactionsHelpText() {
|
|
|
547
587
|
' --start-date YYYY-MM-DD Optional. Include transactions on or after this date.',
|
|
548
588
|
' --end-date YYYY-MM-DD Optional. Include transactions on or before this date.',
|
|
549
589
|
' --q TEXT Optional. Search transactions by text.',
|
|
550
|
-
' --account-
|
|
590
|
+
' --account-ref REF Optional. Filter by the opaque accountRef from sloth-agent accounts.',
|
|
591
|
+
' Copy the exact sloth_account_v1_... value.',
|
|
592
|
+
' --account-id ID Optional legacy filter by provider or stored account ID.',
|
|
551
593
|
' --category-id ID Optional. Filter by category ID.',
|
|
552
594
|
' --line-item-id ID Optional. Filter primary or split assignments by line-item ID.',
|
|
553
595
|
' --assignment-scope SCOPE Optional. Filter assignments by personal or joint.',
|
|
@@ -559,6 +601,7 @@ export function transactionsHelpText() {
|
|
|
559
601
|
'',
|
|
560
602
|
'Constraints:',
|
|
561
603
|
' All filters are omitted by default.',
|
|
604
|
+
' Use either --account-ref or --account-id, not both.',
|
|
562
605
|
' --end-date must not be before --start-date.',
|
|
563
606
|
' The first transaction read each UTC day may refresh linked bank data.',
|
|
564
607
|
' Refresh remotely persists booked transactions and account balances.',
|
|
@@ -566,6 +609,7 @@ export function transactionsHelpText() {
|
|
|
566
609
|
'',
|
|
567
610
|
'Output:',
|
|
568
611
|
' JSON containing transactions, nextCursor, and structured refresh status.',
|
|
612
|
+
' Every transaction includes accountRef for its originating account.',
|
|
569
613
|
' Refresh failures do not hide readable cached transactions.',
|
|
570
614
|
' Personal assignments use the top-level categoryId, lineItemId, and categorySplits.',
|
|
571
615
|
' Joint assignments appear under jointBudgetContribution.',
|
|
@@ -909,6 +953,7 @@ export function commandHelpText(topic) {
|
|
|
909
953
|
categories: categoriesHelpText,
|
|
910
954
|
'categories-create': categoriesCreateHelpText,
|
|
911
955
|
'categories-rename': categoriesRenameHelpText,
|
|
956
|
+
'line-items': lineItemsHelpText,
|
|
912
957
|
'line-items-create': lineItemsCreateHelpText,
|
|
913
958
|
'line-items-rename': lineItemsRenameHelpText,
|
|
914
959
|
transactions: transactionsHelpText,
|
|
@@ -1034,6 +1079,8 @@ function buildTransactionsQuery(filters) {
|
|
|
1034
1079
|
params.set('endDate', filters.endDate);
|
|
1035
1080
|
if (filters.q !== undefined)
|
|
1036
1081
|
params.set('q', filters.q);
|
|
1082
|
+
if (filters.accountRef !== undefined)
|
|
1083
|
+
params.set('accountRef', filters.accountRef);
|
|
1037
1084
|
if (filters.accountId !== undefined)
|
|
1038
1085
|
params.set('accountId', filters.accountId);
|
|
1039
1086
|
if (filters.categoryId !== undefined)
|
package/dist/contracts.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ApiError, UsageError, } from './errors.js';
|
|
2
|
+
import { isAccountRef } from './account-ref.js';
|
|
2
3
|
import { CATEGORY_TYPES, ICON_KEYS } from './category-metadata.js';
|
|
3
4
|
import { isGoalType } from './goal-metadata.js';
|
|
4
5
|
function isObject(value) {
|
|
@@ -252,6 +253,7 @@ function isTransaction(value) {
|
|
|
252
253
|
&& typeof value.currency === 'string'
|
|
253
254
|
&& typeof value.date === 'string'
|
|
254
255
|
&& value.status === 'booked'
|
|
256
|
+
&& isAccountRef(value.accountRef)
|
|
255
257
|
&& typeof value.accountId === 'string'
|
|
256
258
|
&& typeof value.accountDocId === 'string'
|
|
257
259
|
&& typeof value.requisitionId === 'string'
|
|
@@ -621,8 +623,7 @@ function isAccount(value) {
|
|
|
621
623
|
'connectionState',
|
|
622
624
|
'isGoalSavingsSource',
|
|
623
625
|
])
|
|
624
|
-
&&
|
|
625
|
-
&& /^sloth_account_v1_[A-Za-z0-9_-]{43}$/.test(value.accountRef)
|
|
626
|
+
&& isAccountRef(value.accountRef)
|
|
626
627
|
&& isNullableNonEmptyString(value.accountName)
|
|
627
628
|
&& isNullableNonEmptyString(value.institutionName)
|
|
628
629
|
&& (value.accountType === 'current'
|
|
@@ -659,8 +660,7 @@ function isAccountRemovalResponse(value) {
|
|
|
659
660
|
&& hasOnlyFields(value, ['removed', 'changed', 'accountRef'])
|
|
660
661
|
&& value.removed === true
|
|
661
662
|
&& typeof value.changed === 'boolean'
|
|
662
|
-
&&
|
|
663
|
-
&& /^sloth_account_v1_[A-Za-z0-9_-]{43}$/.test(value.accountRef));
|
|
663
|
+
&& isAccountRef(value.accountRef));
|
|
664
664
|
}
|
|
665
665
|
function isInvestmentHolding(value) {
|
|
666
666
|
return (isObject(value)
|