@slothmoney/agent-cli 0.1.0 → 0.3.0

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 CHANGED
@@ -1,5 +1,36 @@
1
1
  # Changelog
2
2
 
3
+ ## Unreleased
4
+
5
+ ## 0.3.0 - 2026-07-30
6
+
7
+ - Add command-specific help for every command and auth subcommand, including
8
+ required inputs, option constraints, output, examples, and write safety.
9
+ - Explain that categories are parents and line items are scoped children, and
10
+ that line-item labels may repeat across categories.
11
+ - Clarify local native credential storage and environment-only authentication
12
+ for containers, CI, and other headless systems.
13
+ - Read and preview or apply the linked joint-budget shared-transaction setting.
14
+ - Filter transactions by personal or joint assignment scope.
15
+ - Categorise shared personal-account contributions against the joint catalogue
16
+ with `assignmentScope: "joint"`.
17
+ - Validate the nested `jointBudgetContribution` response contract.
18
+ - Add goal listing, creation, partial updates, and deletion through the Agent
19
+ API, with goal document ID validation and typed response validation.
20
+ - Keep goal writes in preview mode unless `--apply` is provided, including
21
+ explicit amount and month clearing.
22
+ - Explain that active shared goal target amounts remain app-managed so balance
23
+ allocations can be recalculated safely.
24
+
25
+ ## 0.2.0 - 2026-07-23
26
+
27
+ - Add `auth login`, `auth status`, and `auth logout`.
28
+ - Store PATs in native OS credential storage, separated by API origin.
29
+ - Keep `SLOTH_AGENT_TOKEN` as the highest-precedence option for CI and
30
+ headless systems.
31
+ - Validate imported PATs before saving and report live authentication status
32
+ without exposing credentials.
33
+
3
34
  ## 0.1.0 - 2026-07-18
4
35
 
5
36
  - Publish the first installable Sloth Agent CLI.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Sloth Agent CLI
2
2
 
3
- Use your own agent to read and categorise transactions through the
3
+ Use your own agent to manage goals and categorise transactions through the
4
4
  [Sloth Money Agent API](https://slothmoney.app/developers/).
5
5
 
6
6
  ## Install
@@ -15,78 +15,236 @@ 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.1.0 -- sloth-agent --help
18
+ npm exec --yes --package=@slothmoney/agent-cli@0.3.0 -- sloth-agent --help
19
19
  ```
20
20
 
21
21
  ## Authenticate
22
22
 
23
23
  Create a personal access token in Sloth Money under
24
- **Settings > Developer access**. Load it from your environment or secret
25
- manager:
24
+ **Settings > Developer access**, then choose the authentication method for
25
+ where the CLI runs.
26
+
27
+ ### Local computer
28
+
29
+ On an interactive desktop, save the token in your operating system's secure
30
+ credential store:
31
+
32
+ ```bash
33
+ sloth-agent auth login
34
+ ```
35
+
36
+ The prompt hides the token. The CLI validates it before replacing any
37
+ credential already stored for the selected API origin.
38
+
39
+ ### Containers, CI, and headless systems
40
+
41
+ Native credential storage may be unavailable in a container or other headless
42
+ environment. Inject `SLOTH_AGENT_TOKEN` at runtime through your platform's
43
+ secret manager:
26
44
 
27
45
  ```bash
28
46
  export SLOTH_AGENT_TOKEN="sloth_pat_v1_..."
47
+ sloth-agent auth status
29
48
  ```
30
49
 
31
- Do not paste the token into prompts, chat, source control, shared logs, or
32
- assignment files. The CLI reads the token from the environment, sends it only
33
- as an HTTPS bearer token, and never stores it.
50
+ Keep using the environment variable for later commands. You do not need to run
51
+ `sloth-agent auth login` in this setup. Do not put the token in a command
52
+ argument, source file, or container image.
34
53
 
35
- ## Commands
54
+ `SLOTH_AGENT_TOKEN` always overrides a stored credential.
55
+
56
+ ### Import an existing environment token
36
57
 
37
- Read categories and available budget line items:
58
+ To save an environment token in native credential storage on a local computer:
38
59
 
39
60
  ```bash
40
- sloth-agent categories
61
+ sloth-agent auth login --from-env
62
+ unset SLOTH_AGENT_TOKEN
41
63
  ```
42
64
 
43
- Read uncategorised transactions:
65
+ You can also pass a token to the login command through stdin:
44
66
 
45
67
  ```bash
46
- sloth-agent transactions --uncategorized --limit 50
68
+ printf '%s' "$SLOTH_AGENT_TOKEN" | sloth-agent auth login --token-stdin
47
69
  ```
48
70
 
49
- Search a date range:
71
+ Both commands validate the token before replacing the stored credential.
72
+
73
+ Check the active credential and read your categories:
50
74
 
51
75
  ```bash
52
- sloth-agent transactions \
53
- --q "tesco" \
54
- --start-date 2026-05-01 \
55
- --end-date 2026-05-31
76
+ sloth-agent auth status
77
+ sloth-agent categories
56
78
  ```
57
79
 
58
- Preview an assignment file without writing:
80
+ This updates the PAT's `lastUsedAt` value. To remove the local credential:
59
81
 
60
82
  ```bash
61
- sloth-agent assign --input assignments.json
83
+ sloth-agent auth logout
62
84
  ```
63
85
 
64
- Apply the same file:
86
+ Logout does not unset `SLOTH_AGENT_TOKEN` or revoke the PAT. Revoke a PAT
87
+ remotely in **Sloth Money Settings > Developer access**.
88
+
89
+ ## Commands
90
+
91
+ An assignment categorises an existing transaction e.g. assigning category
92
+ Groceries to a transaction.
93
+
94
+ Every command has built-in reference documentation covering its inputs,
95
+ options, output, and examples:
65
96
 
66
97
  ```bash
67
- sloth-agent assign --input assignments.json --apply
98
+ sloth-agent auth login --help
99
+ sloth-agent categories --help
100
+ sloth-agent transactions --help
101
+ sloth-agent assign --help
102
+ sloth-agent joint-budget-settings --help
103
+ sloth-agent goals create --help
104
+ sloth-agent goals update --help
105
+ sloth-agent ask-partner --help
68
106
  ```
69
107
 
70
- Create a partner clarification link:
108
+ ### Categorise a transaction end to end
109
+
110
+ 1. Read categories and available budget line items:
111
+
112
+ ```bash
113
+ sloth-agent categories
114
+ ```
115
+
116
+ A category is the broader parent. A line item is a child within one category.
117
+ Line-item names such as `Other` may repeat, so preserve the full choice as
118
+ `(scope, categoryId, lineItemId)`. Use the personal or joint line-item map that
119
+ matches the transaction scope. For example, `Bills → Other` and `Subscriptions
120
+ → Other` are different choices.
121
+
122
+ 2. Read uncategorised transactions:
71
123
 
72
124
  ```bash
73
- sloth-agent ask-partner --transaction-ref sloth_txn_...
125
+ sloth-agent transactions --uncategorized --limit 50
74
126
  ```
75
127
 
76
- Assignment files use the Agent API request shape:
128
+ 3. Copy the exact `transactionRef` for the transaction and a `categoryId` from
129
+ the earlier outputs into `assignments.json`:
77
130
 
78
131
  ```json
79
132
  {
80
133
  "assignments": [
81
134
  {
82
- "transactionRef": "sloth_txn_...",
83
- "categoryId": "groceries",
84
- "lineItemId": "weekly"
135
+ "transactionRef": "PASTE_THE_EXACT_TRANSACTION_REF_HERE",
136
+ "categoryId": "PASTE_A_CATEGORY_ID_HERE"
85
137
  }
86
138
  ]
87
139
  }
88
140
  ```
89
141
 
142
+ These are placeholders. Do not submit the example values.
143
+
144
+ 4. Preview the assignment without writing:
145
+
146
+ ```bash
147
+ sloth-agent assign --input assignments.json
148
+ ```
149
+
150
+ Without `--apply`, the CLI checks that the file is valid and returns the
151
+ payload it would send. It does not contact Sloth Money, verify the
152
+ `transactionRef` or category values, or write anything. A successful preview
153
+ does not guarantee that applying it will succeed.
154
+
155
+ 5. Apply the same file:
156
+
157
+ ```bash
158
+ sloth-agent assign --input assignments.json --apply
159
+ ```
160
+
161
+ Inspect every item in the returned `succeeded` and `failed` arrays.
162
+
163
+ 6. Check the result. Successful assignments update the category and optional
164
+ budget line item on the original transaction. See the result in **Sloth
165
+ Money → Transactions**, or re-run the original transaction query without
166
+ `--uncategorized` and inspect its category fields:
167
+
168
+ ```bash
169
+ sloth-agent transactions --limit 50
170
+ ```
171
+
172
+ The transaction should also disappear from the matching `--uncategorized`
173
+ query. Assignments do not create a separate list.
174
+
175
+ ### Other workflows
176
+
177
+ List your goals:
178
+
179
+ ```bash
180
+ sloth-agent goals
181
+ ```
182
+
183
+ Goal writes are previews unless `--apply` is present:
184
+
185
+ ```bash
186
+ sloth-agent goals create \
187
+ --name "Emergency fund" \
188
+ --target-amount 12000 \
189
+ --target-month 2027-06
190
+
191
+ sloth-agent goals create \
192
+ --name "Emergency fund" \
193
+ --target-amount 12000 \
194
+ --target-month 2027-06 \
195
+ --apply
196
+ ```
197
+
198
+ Use the `id` from list or create output to update or delete a goal:
199
+
200
+ ```bash
201
+ sloth-agent goals update \
202
+ --goal-id goal-id \
203
+ --clear-target-amount \
204
+ --target-month 2027-12 \
205
+ --achieved=false \
206
+ --apply
207
+
208
+ sloth-agent goals delete --goal-id goal-id --apply
209
+ ```
210
+
211
+ Updates are partial. Use `--clear-target-amount` or `--clear-target-month` to
212
+ remove an optional value. Marking a goal achieved removes its forecast
213
+ assignment. Deleting a goal also removes its forecast assignments and drift
214
+ history. Goal sharing remains app-managed. Change an active shared goal's
215
+ pot-tracked target amount in the Sloth Budget app, where account balances can
216
+ be reallocated across goals in priority order.
217
+
218
+ Read uncategorised contributions to the joint budget:
219
+
220
+ ```bash
221
+ sloth-agent transactions --assignment-scope joint --uncategorized
222
+ ```
223
+
224
+ Set `"assignmentScope": "joint"` on an assignment to categorise the eligible
225
+ shared portion for the joint budget.
226
+
227
+ Set whether the shared portions of personal-account transactions count in the
228
+ linked joint budget. The first command previews; the second applies:
229
+
230
+ ```bash
231
+ sloth-agent joint-budget-settings \
232
+ --include-shared-personal-transactions=true
233
+ sloth-agent joint-budget-settings \
234
+ --include-shared-personal-transactions=true \
235
+ --apply
236
+ ```
237
+
238
+ Create a partner clarification link:
239
+
240
+ ```bash
241
+ sloth-agent ask-partner \
242
+ --transaction-ref PASTE_THE_EXACT_TRANSACTION_REF_HERE
243
+ ```
244
+
245
+ The value shown is a placeholder. Copy the exact `transactionRef` from
246
+ `sloth-agent transactions` output.
247
+
90
248
  ## Configuration and output
91
249
 
92
250
  The CLI defaults to `https://budget.slothmoney.app`. For local development,
@@ -94,14 +252,18 @@ set `SLOTH_AGENT_API_BASE_URL=http://localhost:4000` or pass
94
252
  `--base-url http://localhost:4000`. Non-local HTTP origins are rejected so a
95
253
  token cannot be sent over an unencrypted connection.
96
254
 
255
+ Stored credentials are separated by normalized API origin. One credential is
256
+ stored per origin; log out and log in again to switch accounts on the same
257
+ origin.
258
+
97
259
  Command results are JSON on stdout. Diagnostics are written to stderr.
98
260
 
99
261
  | Exit code | Meaning |
100
262
  | --- | --- |
101
263
  | `0` | Success |
102
- | `1` | API, network, response-validation, or partial assignment failure |
103
- | `2` | Invalid command, option, URL, date, or assignment input |
104
- | `3` | Missing required configuration |
264
+ | `1` | API, network, credential-store, response-validation, or partial assignment failure |
265
+ | `2` | Invalid command, option, URL, date, auth input, goal input, or assignment input |
266
+ | `3` | No credential or native secure storage is unavailable |
105
267
 
106
268
  Assignment writes are best-effort. A response containing any failed assignment
107
269
  returns exit code `1` while preserving the complete API response on stdout.