@fuzzle/opencode-accountant 0.10.6-next.1 → 0.10.7-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.
Files changed (2) hide show
  1. package/dist/index.js +28 -13
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -4258,6 +4258,19 @@ var require_brace_expansion = __commonJS((exports, module) => {
4258
4258
  }
4259
4259
  });
4260
4260
 
4261
+ // src/utils/journalMatchers.ts
4262
+ function extractAccount(line, pattern) {
4263
+ const match2 = line.match(pattern);
4264
+ return match2 ? match2[1].trim() : null;
4265
+ }
4266
+ var JOURNAL_ACCOUNT_DECL, RULES_ACCOUNT_DIRECTIVE, RULES_ACCOUNT2_DIRECTIVE, TX_HEADER_PATTERN;
4267
+ var init_journalMatchers = __esm(() => {
4268
+ JOURNAL_ACCOUNT_DECL = /^account\s+(.+)$/;
4269
+ RULES_ACCOUNT_DIRECTIVE = /^account\d+\s+(.+)$/;
4270
+ RULES_ACCOUNT2_DIRECTIVE = /^\s*account2\s+(.+)$/;
4271
+ TX_HEADER_PATTERN = /^(\d{4})-(\d{2}-\d{2})(\s+(.+))?$/;
4272
+ });
4273
+
4261
4274
  // src/utils/accountSuggester.ts
4262
4275
  var exports_accountSuggester = {};
4263
4276
  __export(exports_accountSuggester, {
@@ -4287,9 +4300,9 @@ function loadExistingAccounts(yearJournalPath) {
4287
4300
  for (const line of lines) {
4288
4301
  const trimmed = line.trim();
4289
4302
  if (trimmed.startsWith("account ")) {
4290
- const match2 = trimmed.match(/^account\s+(.+?)(?:\s+|$)/);
4291
- if (match2) {
4292
- accounts.push(match2[1].trim());
4303
+ const accountName = extractAccount(trimmed, JOURNAL_ACCOUNT_DECL);
4304
+ if (accountName) {
4305
+ accounts.push(accountName);
4293
4306
  }
4294
4307
  }
4295
4308
  }
@@ -4314,11 +4327,11 @@ function extractRulePatternsFromFile(rulesPath) {
4314
4327
  currentCondition = ifMatch[1].trim();
4315
4328
  continue;
4316
4329
  }
4317
- const account2Match = trimmed.match(/^\s*account2\s+(.+?)(?:\s+|$)/);
4318
- if (account2Match && currentCondition) {
4330
+ const account2Name = extractAccount(trimmed, RULES_ACCOUNT2_DIRECTIVE);
4331
+ if (account2Name && currentCondition) {
4319
4332
  patterns.push({
4320
4333
  condition: currentCondition,
4321
- account: account2Match[1].trim()
4334
+ account: account2Name
4322
4335
  });
4323
4336
  currentCondition = null;
4324
4337
  continue;
@@ -4504,6 +4517,7 @@ function generateMockSuggestions(postings) {
4504
4517
  var EXAMPLE_PATTERN_SAMPLE_SIZE = 10, suggestionCache, RESPONSE_FORMAT_SECTION;
4505
4518
  var init_accountSuggester = __esm(() => {
4506
4519
  init_agentLoader();
4520
+ init_journalMatchers();
4507
4521
  suggestionCache = {};
4508
4522
  RESPONSE_FORMAT_SECTION = [
4509
4523
  `## Task
@@ -23123,7 +23137,7 @@ function findRulesForCsv(csvPath, mapping) {
23123
23137
 
23124
23138
  // src/utils/hledgerExecutor.ts
23125
23139
  var {$: $2 } = globalThis.Bun;
23126
- var TX_HEADER_PATTERN = /^(\d{4})-(\d{2}-\d{2})(\s+(.+))?$/;
23140
+ init_journalMatchers();
23127
23141
  async function defaultHledgerExecutor(cmdArgs) {
23128
23142
  try {
23129
23143
  const result = await $2`hledger ${cmdArgs}`.quiet().nothrow();
@@ -24150,6 +24164,7 @@ import * as fs20 from "fs";
24150
24164
  import * as path14 from "path";
24151
24165
 
24152
24166
  // src/utils/accountDeclarations.ts
24167
+ init_journalMatchers();
24153
24168
  import * as fs12 from "fs";
24154
24169
  function extractAccountsFromRulesFile(rulesPath) {
24155
24170
  const accounts = new Set;
@@ -24164,9 +24179,9 @@ function extractAccountsFromRulesFile(rulesPath) {
24164
24179
  if (trimmed.startsWith("#") || trimmed.startsWith(";") || trimmed === "") {
24165
24180
  continue;
24166
24181
  }
24167
- const accountMatch = trimmed.match(/^account\d+\s+(.+?)(?:\s+|$)/);
24168
- if (accountMatch) {
24169
- accounts.add(accountMatch[1].trim());
24182
+ const accountName = extractAccount(trimmed, RULES_ACCOUNT_DIRECTIVE);
24183
+ if (accountName) {
24184
+ accounts.add(accountName);
24170
24185
  continue;
24171
24186
  }
24172
24187
  }
@@ -24201,9 +24216,9 @@ function parseJournalSections(content) {
24201
24216
  }
24202
24217
  if (trimmed.startsWith("account ")) {
24203
24218
  inAccountSection = true;
24204
- const accountMatch = trimmed.match(/^account\s+(.+?)(?:\s+|$)/);
24205
- if (accountMatch) {
24206
- existingAccounts.add(accountMatch[1].trim());
24219
+ const accountName = extractAccount(trimmed, JOURNAL_ACCOUNT_DECL);
24220
+ if (accountName) {
24221
+ existingAccounts.add(accountName);
24207
24222
  }
24208
24223
  continue;
24209
24224
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fuzzle/opencode-accountant",
3
- "version": "0.10.6-next.1",
3
+ "version": "0.10.7-next.1",
4
4
  "description": "An OpenCode accounting agent, specialized in double-entry-bookkepping with hledger",
5
5
  "author": {
6
6
  "name": "ali bengali",