agentinit 1.3.0 → 1.4.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,3 +1,19 @@
1
+ # [1.4.0](https://github.com/agentinit/agentinit/compare/v1.3.0...v1.4.0) (2025-09-26)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * address comments ([b4a63e7](https://github.com/agentinit/agentinit/commit/b4a63e79b376d059e2403ad396b779912e8ca50e))
7
+ * dirty fix with token calcs ([e7d3ef9](https://github.com/agentinit/agentinit/commit/e7d3ef98ea700937f2ccbd448ff18da02e65d1cd))
8
+ * **mcp:** improve token calculation accuracy for different schema types ([6f85f8b](https://github.com/agentinit/agentinit/commit/6f85f8b8448e8a391029f7bd50f975be5818ff7e))
9
+ * **mcp:** use minified JSON to prevent token inflation ([c5885c2](https://github.com/agentinit/agentinit/commit/c5885c277ac920781919178786386130b04b7633))
10
+
11
+
12
+ ### Features
13
+
14
+ * improve token calc ([107a8d7](https://github.com/agentinit/agentinit/commit/107a8d7b5b849a7dfc4dd776474c7d0bcd11c179))
15
+ * **mcp:** significantly improve token calculation accuracy ([c7c5137](https://github.com/agentinit/agentinit/commit/c7c51377565e2ab110262c859d05a988a39a80ee))
16
+
1
17
  # [1.3.0](https://github.com/agentinit/agentinit/compare/v1.2.1...v1.3.0) (2025-09-24)
2
18
 
3
19
 
Binary file
package/dist/index.js CHANGED
@@ -32285,18 +32285,38 @@ class MCPVerifier {
32285
32285
  return yellow(tokenCount.toString());
32286
32286
  return red(tokenCount.toString());
32287
32287
  }
32288
- calculateToolTokens(tools) {
32288
+ calculateToolTokens(tools, serverName) {
32289
32289
  const toolTokenCounts = new Map;
32290
32290
  let totalToolTokens = 0;
32291
32291
  for (const tool of tools) {
32292
32292
  try {
32293
+ const rawSchema = tool.inputSchema && typeof tool.inputSchema === "object" ? tool.inputSchema : undefined;
32294
+ const schemaType = rawSchema?.type;
32295
+ const parameters = {
32296
+ $schema: "http://json-schema.org/draft-07/schema#",
32297
+ ...rawSchema ?? {}
32298
+ };
32299
+ const hasObjectHints = rawSchema !== undefined && ["properties", "required", "additionalProperties", "patternProperties"].some((key) => (key in rawSchema));
32300
+ const isObjectSchema = rawSchema === undefined || schemaType === "object" || Array.isArray(schemaType) && schemaType.includes("object") || hasObjectHints;
32301
+ if (isObjectSchema) {
32302
+ if (!("type" in parameters))
32303
+ parameters.type = "object";
32304
+ if (!("properties" in parameters))
32305
+ parameters.properties = {};
32306
+ if (!("required" in parameters))
32307
+ parameters.required = [];
32308
+ if (!("additionalProperties" in parameters))
32309
+ parameters.additionalProperties = false;
32310
+ }
32311
+ const prefixedToolName = `mcp__${serverName}__${tool.name}`;
32293
32312
  const toolForCounting = {
32294
- name: tool.name,
32295
- description: tool.description || "",
32296
- inputSchema: tool.inputSchema || {}
32313
+ name: prefixedToolName,
32314
+ ...tool.description !== undefined ? { description: tool.description } : {},
32315
+ parameters
32297
32316
  };
32298
- const toolText = JSON.stringify(toolForCounting, null, 2);
32299
- const tokenCount = countTokens(toolText);
32317
+ const functionDefinition = JSON.stringify(toolForCounting);
32318
+ const claudeToolRepresentation = `<function>${functionDefinition}</function>`;
32319
+ const tokenCount = countTokens(claudeToolRepresentation) * 3;
32300
32320
  toolTokenCounts.set(tool.name, tokenCount);
32301
32321
  totalToolTokens += tokenCount;
32302
32322
  } catch (error) {
@@ -32489,7 +32509,7 @@ class MCPVerifier {
32489
32509
  }));
32490
32510
  } catch (error) {
32491
32511
  }
32492
- const { toolTokenCounts, totalToolTokens } = this.calculateToolTokens(tools);
32512
+ const { toolTokenCounts, totalToolTokens } = this.calculateToolTokens(tools, server.name);
32493
32513
  return {
32494
32514
  tools,
32495
32515
  resources,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentinit",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "A CLI tool for managing and configuring AI coding agents",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
Binary file