@fuzzle/opencode-accountant 0.2.0 → 0.3.0-next.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/README.md +24 -3
- package/agent/accountant.md +28 -7
- package/dist/index.js +6052 -236
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -201,9 +201,10 @@ The `import-pipeline` tool provides an atomic, safe import workflow using git wo
|
|
|
201
201
|
- Creates an isolated git worktree
|
|
202
202
|
- Syncs CSV files from main repo to worktree
|
|
203
203
|
- Classifies CSV files by provider/currency
|
|
204
|
+
- Extracts accounts from rules and creates declarations in year journal
|
|
204
205
|
- Validates all transactions have matching rules
|
|
205
206
|
- Imports transactions to the appropriate year journal
|
|
206
|
-
- Reconciles closing balance (
|
|
207
|
+
- Reconciles closing balance (auto-detected from CSV metadata or data analysis)
|
|
207
208
|
- Merges changes back to main branch with `--no-ff`
|
|
208
209
|
- Deletes processed CSV files from main repo's import/incoming
|
|
209
210
|
- Cleans up the worktree
|
|
@@ -237,13 +238,30 @@ The tool will use that rules file when processing `transactions.csv`.
|
|
|
237
238
|
|
|
238
239
|
See the hledger documentation for details on rules file format and syntax.
|
|
239
240
|
|
|
241
|
+
#### Account Declarations
|
|
242
|
+
|
|
243
|
+
The pipeline automatically manages account declarations:
|
|
244
|
+
|
|
245
|
+
- Scans rules files matched to the CSVs being imported
|
|
246
|
+
- Extracts all accounts (account1 and account2 directives)
|
|
247
|
+
- Creates or updates year journal files with sorted account declarations
|
|
248
|
+
- Ensures `hledger check --strict` validation passes
|
|
249
|
+
|
|
250
|
+
**No manual account setup required.** Account declarations are created proactively before import attempts.
|
|
251
|
+
|
|
240
252
|
#### Unknown Postings
|
|
241
253
|
|
|
242
254
|
When a transaction doesn't match any `if` pattern in the rules file, hledger assigns it to `income:unknown` or `expenses:unknown` depending on the transaction direction. The pipeline will fail at the validation step, reporting the unknown postings so you can add appropriate rules before retrying.
|
|
243
255
|
|
|
244
256
|
#### Closing Balance Reconciliation
|
|
245
257
|
|
|
246
|
-
|
|
258
|
+
The import pipeline automatically detects closing balance using the following fallback chain:
|
|
259
|
+
|
|
260
|
+
1. **CSV Metadata Extraction**: For providers with closing balance in metadata (e.g., UBS)
|
|
261
|
+
2. **CSV Data Analysis**: Extracts balance from the last transaction row if metadata unavailable
|
|
262
|
+
3. **Manual Override**: Use the `closingBalance` parameter when automatic detection fails
|
|
263
|
+
|
|
264
|
+
Configure metadata extraction in `providers.yaml`:
|
|
247
265
|
|
|
248
266
|
```yaml
|
|
249
267
|
metadata:
|
|
@@ -258,7 +276,10 @@ metadata:
|
|
|
258
276
|
column: 1
|
|
259
277
|
```
|
|
260
278
|
|
|
261
|
-
For
|
|
279
|
+
**Note:** For most CSV formats, the closing balance will be detected automatically. Manual override is only needed when:
|
|
280
|
+
|
|
281
|
+
- CSV has no balance information in metadata or data
|
|
282
|
+
- The auto-detected balance has low confidence
|
|
262
283
|
|
|
263
284
|
## Development
|
|
264
285
|
|
package/agent/accountant.md
CHANGED
|
@@ -89,9 +89,10 @@ The `import-pipeline` tool provides an **atomic, safe workflow** using git workt
|
|
|
89
89
|
3. **Automatic Processing**: The tool creates an isolated git worktree and:
|
|
90
90
|
- Syncs CSV files from main repo to worktree
|
|
91
91
|
- Classifies CSV files by provider/currency
|
|
92
|
+
- Extracts required accounts from rules files and updates year journal
|
|
92
93
|
- Validates all transactions have matching rules
|
|
93
94
|
- Imports transactions to the appropriate year journal
|
|
94
|
-
- Reconciles closing balance (
|
|
95
|
+
- Reconciles closing balance (auto-detected from CSV metadata or data, or manual override)
|
|
95
96
|
- Merges changes back to main branch with `--no-ff`
|
|
96
97
|
- Deletes processed CSV files from main repo's import/incoming
|
|
97
98
|
- Cleans up the worktree
|
|
@@ -108,6 +109,25 @@ The `import-pipeline` tool provides an **atomic, safe workflow** using git workt
|
|
|
108
109
|
- Use field names from the `fields` directive for matching
|
|
109
110
|
- Unknown account pattern: `income:unknown` (positive amounts) / `expenses:unknown` (negative amounts)
|
|
110
111
|
|
|
112
|
+
### Automatic Account Declarations
|
|
113
|
+
|
|
114
|
+
The import pipeline automatically:
|
|
115
|
+
|
|
116
|
+
- Scans matched rules files for all account references (account1, account2 directives)
|
|
117
|
+
- Creates/updates year journal files (e.g., ledger/2026.journal) with sorted account declarations
|
|
118
|
+
- Prevents `hledger check --strict` failures due to missing account declarations
|
|
119
|
+
- No manual account setup required
|
|
120
|
+
|
|
121
|
+
### Automatic Balance Detection
|
|
122
|
+
|
|
123
|
+
The reconciliation step attempts to extract closing balance from:
|
|
124
|
+
|
|
125
|
+
1. CSV header metadata (e.g., UBS "Closing balance:" row)
|
|
126
|
+
2. CSV data analysis (balance field in last transaction row)
|
|
127
|
+
3. Manual override via `closingBalance` parameter (fallback)
|
|
128
|
+
|
|
129
|
+
For most providers, manual balance input is no longer required.
|
|
130
|
+
|
|
111
131
|
## Tool Usage Reference
|
|
112
132
|
|
|
113
133
|
The following are MCP tools available to you. Always call these tools directly - do not attempt to replicate their behavior with shell commands.
|
|
@@ -138,12 +158,13 @@ The following are MCP tools available to you. Always call these tools directly -
|
|
|
138
158
|
1. Creates isolated git worktree
|
|
139
159
|
2. Syncs CSV files from main repo to worktree
|
|
140
160
|
3. Classifies CSV files (unless `skipClassify: true`)
|
|
141
|
-
4.
|
|
142
|
-
5.
|
|
143
|
-
6.
|
|
144
|
-
7.
|
|
145
|
-
8.
|
|
146
|
-
9.
|
|
161
|
+
4. Extracts accounts from matched rules and updates year journal with declarations
|
|
162
|
+
5. Validates all transactions have matching rules (dry run)
|
|
163
|
+
6. Imports transactions to year journal
|
|
164
|
+
7. Reconciles closing balance (auto-detected from CSV metadata/data or manual override)
|
|
165
|
+
8. Merges to main with `--no-ff` commit
|
|
166
|
+
9. Deletes processed CSV files from main repo's import/incoming
|
|
167
|
+
10. Cleans up worktree
|
|
147
168
|
|
|
148
169
|
**Output:** Returns step-by-step results with success/failure for each phase
|
|
149
170
|
|