@fuzzle/opencode-accountant 0.0.16-next.1 → 0.0.17

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 -22
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -16981,6 +16981,21 @@ var {$ } = globalThis.Bun;
16981
16981
  import * as path2 from "path";
16982
16982
  import * as fs2 from "fs";
16983
16983
 
16984
+ // src/utils/agentRestriction.ts
16985
+ function checkAccountantAgent(agent, toolPrompt, additionalFields) {
16986
+ if (agent === "accountant") {
16987
+ return null;
16988
+ }
16989
+ const errorResponse = {
16990
+ success: false,
16991
+ error: "This tool is restricted to the accountant agent only.",
16992
+ hint: `Use: Task(subagent_type='accountant', prompt='${toolPrompt}')`,
16993
+ caller: agent || "main assistant",
16994
+ ...additionalFields
16995
+ };
16996
+ return JSON.stringify(errorResponse);
16997
+ }
16998
+
16984
16999
  // src/utils/pricesConfig.ts
16985
17000
  import * as fs from "fs";
16986
17001
  import * as path from "path";
@@ -17090,12 +17105,9 @@ function updateJournalWithPrices(journalPath, newPriceLines) {
17090
17105
  `);
17091
17106
  }
17092
17107
  async function updatePricesCore(directory, agent, backfill, priceFetcher = defaultPriceFetcher, configLoader = loadPricesConfig) {
17093
- if (agent !== "accountant") {
17094
- return JSON.stringify({
17095
- error: "This tool is restricted to the accountant agent only.",
17096
- hint: "Use: Task(subagent_type='accountant', prompt='update prices')",
17097
- caller: agent || "main assistant"
17098
- });
17108
+ const restrictionError = checkAccountantAgent(agent, "update prices");
17109
+ if (restrictionError) {
17110
+ return restrictionError;
17099
17111
  }
17100
17112
  let config2;
17101
17113
  try {
@@ -17461,15 +17473,12 @@ function ensureDirectory(dirPath) {
17461
17473
  }
17462
17474
  }
17463
17475
  async function classifyStatementsCore(directory, agent, configLoader = loadImportConfig) {
17464
- if (agent !== "accountant") {
17465
- return JSON.stringify({
17466
- success: false,
17467
- error: "This tool is restricted to the accountant agent only.",
17468
- hint: "Use: Task(subagent_type='accountant', prompt='classify statements')",
17469
- caller: agent || "main assistant",
17470
- classified: [],
17471
- unrecognized: []
17472
- });
17476
+ const restrictionError = checkAccountantAgent(agent, "classify statements", {
17477
+ classified: [],
17478
+ unrecognized: []
17479
+ });
17480
+ if (restrictionError) {
17481
+ return restrictionError;
17473
17482
  }
17474
17483
  let config2;
17475
17484
  try {
@@ -17989,12 +17998,9 @@ function findPendingCsvFiles(pendingDir, provider, currency) {
17989
17998
  return csvFiles.sort();
17990
17999
  }
17991
18000
  async function importStatementsCore(directory, agent, options, configLoader = loadImportConfig, hledgerExecutor = defaultHledgerExecutor) {
17992
- if (agent !== "accountant") {
17993
- return JSON.stringify({
17994
- success: false,
17995
- error: `This tool is restricted to the accountant agent only. Called by: ${agent || "main assistant"}`,
17996
- hint: "Use: Task(subagent_type='accountant', prompt='import statements')"
17997
- });
18001
+ const restrictionError = checkAccountantAgent(agent, "import statements");
18002
+ if (restrictionError) {
18003
+ return restrictionError;
17998
18004
  }
17999
18005
  let config2;
18000
18006
  try {
@@ -18257,7 +18263,7 @@ async function importStatementsCore(directory, agent, options, configLoader = lo
18257
18263
  });
18258
18264
  }
18259
18265
  var import_statements_default = tool({
18260
- description: `Import classified bank statement CSVs into hledger using rules files.
18266
+ description: `ACCOUNTANT AGENT ONLY: Import classified bank statement CSVs into hledger using rules files.
18261
18267
 
18262
18268
  This tool processes CSV files in the pending import directory and uses hledger's CSV import capabilities with matching rules files.
18263
18269
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fuzzle/opencode-accountant",
3
- "version": "0.0.16-next.1",
3
+ "version": "0.0.17",
4
4
  "description": "An OpenCode accounting agent, specialized in double-entry-bookkepping with hledger",
5
5
  "author": {
6
6
  "name": "ali bengali",