@wrongstack/plugins 0.89.1 → 0.89.3

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.
@@ -1,10 +1,6 @@
1
+ import { expectDefined } from '@wrongstack/core';
2
+
1
3
  // src/cost-tracker/index.ts
2
- function expectDefined(value) {
3
- if (value === null || value === void 0) {
4
- throw new Error("Expected value to be defined");
5
- }
6
- return value;
7
- }
8
4
  var API_VERSION = "^0.1.10";
9
5
  var PRICING = {
10
6
  "gpt-4o": { input: 5, output: 15 },
@@ -18,6 +14,12 @@ var PRICING = {
18
14
  "default": { input: 5, output: 15 }
19
15
  };
20
16
  var DEFAULT_PRICING = { input: 5, output: 15 };
17
+ function readCostTrackerConfig(raw) {
18
+ return {
19
+ budgetLimit: typeof raw?.["budgetLimit"] === "number" ? raw["budgetLimit"] : 0,
20
+ warningThreshold: typeof raw?.["warningThreshold"] === "number" ? raw["warningThreshold"] : 80
21
+ };
22
+ }
21
23
  function estimateCost(model, promptTokens, completionTokens) {
22
24
  const pricing = PRICING[model.toLowerCase()] ?? DEFAULT_PRICING;
23
25
  const inputCost = promptTokens / 1e6 * pricing.input;
@@ -91,8 +93,9 @@ var plugin = {
91
93
  permission: "auto",
92
94
  mutating: false,
93
95
  async execute() {
94
- const budgetLimit = api.config.extensions?.["cost-tracker"]?.["budgetLimit"] ?? 0;
95
- const warningThreshold = api.config.extensions?.["cost-tracker"]?.["warningThreshold"] ?? 80;
96
+ const { budgetLimit, warningThreshold } = readCostTrackerConfig(
97
+ api.config.extensions?.["cost-tracker"]
98
+ );
96
99
  const usage = {
97
100
  totalRequests: sessionCost.requests.length,
98
101
  totalPromptTokens: sessionCost.totalPromptTokens,
@@ -125,7 +128,7 @@ var plugin = {
125
128
  description: "Resets all token usage and cost counters for the current session.",
126
129
  inputSchema: { type: "object", properties: {} },
127
130
  permission: "auto",
128
- mutating: false,
131
+ mutating: true,
129
132
  async execute() {
130
133
  const prev = {
131
134
  totalTokens: sessionCost.totalTokens,
@@ -198,7 +201,7 @@ var plugin = {
198
201
  };
199
202
  }
200
203
  });
201
- api.onEvent("session.close", async () => {
204
+ api.onEvent("session.ended", async () => {
202
205
  if (sessionCost.requests.length > 0) {
203
206
  await api.session.append({
204
207
  type: "cost-tracker:session_summary",
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@ import { execFileSync, execSync } from 'child_process';
2
2
  import { watch, existsSync, readdirSync, readFileSync } from 'fs';
3
3
  import * as path from 'path';
4
4
  import { isAbsolute, join } from 'path';
5
+ import { expectDefined } from '@wrongstack/core';
5
6
  import { lookup } from 'dns/promises';
6
7
  import { isIPv4, isIPv6 } from 'net';
7
8
 
@@ -888,14 +889,6 @@ var plugin3 = {
888
889
  }
889
890
  };
890
891
  var shell_check_default = plugin3;
891
-
892
- // src/cost-tracker/index.ts
893
- function expectDefined(value) {
894
- if (value === null || value === void 0) {
895
- throw new Error("Expected value to be defined");
896
- }
897
- return value;
898
- }
899
892
  var API_VERSION3 = "^0.1.10";
900
893
  var PRICING = {
901
894
  "gpt-4o": { input: 5, output: 15 },
@@ -909,6 +902,12 @@ var PRICING = {
909
902
  "default": { input: 5, output: 15 }
910
903
  };
911
904
  var DEFAULT_PRICING = { input: 5, output: 15 };
905
+ function readCostTrackerConfig(raw) {
906
+ return {
907
+ budgetLimit: typeof raw?.["budgetLimit"] === "number" ? raw["budgetLimit"] : 0,
908
+ warningThreshold: typeof raw?.["warningThreshold"] === "number" ? raw["warningThreshold"] : 80
909
+ };
910
+ }
912
911
  function estimateCost(model, promptTokens, completionTokens) {
913
912
  const pricing = PRICING[model.toLowerCase()] ?? DEFAULT_PRICING;
914
913
  const inputCost = promptTokens / 1e6 * pricing.input;
@@ -982,8 +981,9 @@ var plugin4 = {
982
981
  permission: "auto",
983
982
  mutating: false,
984
983
  async execute() {
985
- const budgetLimit = api.config.extensions?.["cost-tracker"]?.["budgetLimit"] ?? 0;
986
- const warningThreshold = api.config.extensions?.["cost-tracker"]?.["warningThreshold"] ?? 80;
984
+ const { budgetLimit, warningThreshold } = readCostTrackerConfig(
985
+ api.config.extensions?.["cost-tracker"]
986
+ );
987
987
  const usage = {
988
988
  totalRequests: sessionCost.requests.length,
989
989
  totalPromptTokens: sessionCost.totalPromptTokens,
@@ -1016,7 +1016,7 @@ var plugin4 = {
1016
1016
  description: "Resets all token usage and cost counters for the current session.",
1017
1017
  inputSchema: { type: "object", properties: {} },
1018
1018
  permission: "auto",
1019
- mutating: false,
1019
+ mutating: true,
1020
1020
  async execute() {
1021
1021
  const prev = {
1022
1022
  totalTokens: sessionCost.totalTokens,
@@ -1089,7 +1089,7 @@ var plugin4 = {
1089
1089
  };
1090
1090
  }
1091
1091
  });
1092
- api.onEvent("session.close", async () => {
1092
+ api.onEvent("session.ended", async () => {
1093
1093
  if (sessionCost.requests.length > 0) {
1094
1094
  await api.session.append({
1095
1095
  type: "cost-tracker:session_summary",
@@ -1632,21 +1632,13 @@ var plugin6 = {
1632
1632
  }
1633
1633
  };
1634
1634
  var web_search_default = plugin6;
1635
-
1636
- // src/json-path/index.ts
1637
- function expectDefined2(value) {
1638
- if (value === null || value === void 0) {
1639
- throw new Error("Expected value to be defined");
1640
- }
1641
- return value;
1642
- }
1643
1635
  var API_VERSION6 = "^0.1.10";
1644
1636
  function jmespathSearch(data, query) {
1645
1637
  if (!query || query === "@") return data;
1646
1638
  if (query === "$") return data;
1647
1639
  const dotMatch = query.match(/^([a-zA-Z_][a-zA-Z0-9_]*)(?:\.(.+))?$/);
1648
1640
  if (dotMatch) {
1649
- const key = expectDefined2(dotMatch[1]);
1641
+ const key = expectDefined(dotMatch[1]);
1650
1642
  const rest = dotMatch[2];
1651
1643
  const val = data?.[key];
1652
1644
  if (rest === void 0) return val;
@@ -1654,7 +1646,7 @@ function jmespathSearch(data, query) {
1654
1646
  }
1655
1647
  const arrMatch = query.match(/^\[(\d+)\](?:\.(.+))?$/);
1656
1648
  if (arrMatch) {
1657
- const idx = Number.parseInt(expectDefined2(arrMatch[1]), 10);
1649
+ const idx = Number.parseInt(expectDefined(arrMatch[1]), 10);
1658
1650
  const rest = arrMatch[2];
1659
1651
  const arr = data;
1660
1652
  const val = arr?.[idx];
@@ -1669,7 +1661,7 @@ function jmespathSearch(data, query) {
1669
1661
  }
1670
1662
  const multiMatch = query.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[\*\](?:\.(.+))?$/);
1671
1663
  if (multiMatch) {
1672
- const key = expectDefined2(multiMatch[1]);
1664
+ const key = expectDefined(multiMatch[1]);
1673
1665
  const rest = multiMatch[2];
1674
1666
  const arr = data?.[key];
1675
1667
  if (!Array.isArray(arr)) return [];
@@ -1678,9 +1670,9 @@ function jmespathSearch(data, query) {
1678
1670
  }
1679
1671
  const filterMatch = query.match(/^\[\\?([a-zA-Z_][a-zA-Z0-9_]*)(==|!=|<|>|<=|>=)(`[^`]+`|'[^']*')\](?:\.(.+))?$/);
1680
1672
  if (filterMatch) {
1681
- const field = expectDefined2(filterMatch[1]);
1682
- const op = expectDefined2(filterMatch[2]);
1683
- const rawVal = expectDefined2(filterMatch[3]);
1673
+ const field = expectDefined(filterMatch[1]);
1674
+ const op = expectDefined(filterMatch[2]);
1675
+ const rawVal = expectDefined(filterMatch[3]);
1684
1676
  const rest = filterMatch[4];
1685
1677
  const cmpVal = JSON.parse(rawVal.slice(1, -1));
1686
1678
  const arr = data;
@@ -1709,7 +1701,7 @@ function jmespathSearch(data, query) {
1709
1701
  }
1710
1702
  const fnMatch = query.match(/^(length|keys|values|type)\(@\)$/);
1711
1703
  if (fnMatch) {
1712
- const fn = expectDefined2(fnMatch[1]);
1704
+ const fn = expectDefined(fnMatch[1]);
1713
1705
  switch (fn) {
1714
1706
  case "length":
1715
1707
  if (Array.isArray(data)) return data.length;
@@ -2441,12 +2433,6 @@ var plugin9 = {
2441
2433
  }
2442
2434
  };
2443
2435
  var template_engine_default = plugin9;
2444
- function expectDefined3(value) {
2445
- if (value === null || value === void 0) {
2446
- throw new Error("Expected value to be defined");
2447
- }
2448
- return value;
2449
- }
2450
2436
  var API_VERSION9 = "^0.1.10";
2451
2437
  function runGit2(args, cwd) {
2452
2438
  try {
@@ -2474,7 +2460,7 @@ function getPackageJson(cwd) {
2474
2460
  function parseVersion(v) {
2475
2461
  const m = v.match(/^v?(\d+)\.(\d+)\.(\d+)/);
2476
2462
  if (!m) return [0, 0, 0];
2477
- return [Number.parseInt(expectDefined3(m[1])), Number.parseInt(expectDefined3(m[2])), Number.parseInt(expectDefined3(m[3]))];
2463
+ return [Number.parseInt(expectDefined(m[1])), Number.parseInt(expectDefined(m[2])), Number.parseInt(expectDefined(m[3]))];
2478
2464
  }
2479
2465
  function bumpVersion(version, part) {
2480
2466
  let [major, minor, patch] = parseVersion(version);
package/dist/json-path.js CHANGED
@@ -1,10 +1,6 @@
1
+ import { expectDefined } from '@wrongstack/core';
2
+
1
3
  // src/json-path/index.ts
2
- function expectDefined(value) {
3
- if (value === null || value === void 0) {
4
- throw new Error("Expected value to be defined");
5
- }
6
- return value;
7
- }
8
4
  var API_VERSION = "^0.1.10";
9
5
  function jmespathSearch(data, query) {
10
6
  if (!query || query === "@") return data;
@@ -1,13 +1,8 @@
1
+ import { expectDefined } from '@wrongstack/core';
1
2
  import { execFileSync } from 'child_process';
2
3
  import { existsSync, readFileSync } from 'fs';
3
4
 
4
5
  // src/semver-bump/index.ts
5
- function expectDefined(value) {
6
- if (value === null || value === void 0) {
7
- throw new Error("Expected value to be defined");
8
- }
9
- return value;
10
- }
11
6
  var API_VERSION = "^0.1.10";
12
7
  function runGit(args, cwd) {
13
8
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrongstack/plugins",
3
- "version": "0.89.1",
3
+ "version": "0.89.3",
4
4
  "description": "Official WrongStack plugin collection — auto-doc, git-autocommit, shell-check, cost-tracker, file-watcher, web-search, json-path, cron, template-engine, semver-bump",
5
5
  "license": "MIT",
6
6
  "author": "ECOSTACK TECHNOLOGY OÜ",
@@ -63,7 +63,7 @@
63
63
  "vitest": "^4.1.7"
64
64
  },
65
65
  "dependencies": {
66
- "@wrongstack/core": "0.89.1"
66
+ "@wrongstack/core": "0.89.3"
67
67
  },
68
68
  "scripts": {
69
69
  "build": "tsup",