agentinit 1.2.1 → 1.3.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,16 @@
1
+ # [1.3.0](https://github.com/agentinit/agentinit/compare/v1.2.1...v1.3.0) (2025-09-24)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * address review comments ([e337f07](https://github.com/agentinit/agentinit/commit/e337f072bd41794756c72a3cdba96ebaff033e5f))
7
+ * address review comments ([6be5b93](https://github.com/agentinit/agentinit/commit/6be5b937ec6fcbf924ea93f378156ba44a46b9d5))
8
+
9
+
10
+ ### Features
11
+
12
+ * centralize constants and add timeout support to apply command ([d35a6fc](https://github.com/agentinit/agentinit/commit/d35a6fc2dd76923c82ca7f26b4503260f25e944f))
13
+
1
14
  ## [1.2.1](https://github.com/agentinit/agentinit/compare/v1.2.0...v1.2.1) (2025-09-20)
2
15
 
3
16
 
package/README.md CHANGED
@@ -94,25 +94,16 @@ agentinit mcp --install <name> # Install specific MCP
94
94
 
95
95
  ### `agentinit verify_mcp`
96
96
 
97
- Verify MCP server installations and list their capabilities.
98
-
99
- ```bash
100
- agentinit verify_mcp --all # Verify all configured MCP servers
101
- agentinit verify_mcp --mcp-name <name> # Verify specific MCP server
102
- ```
97
+ Verify MCP server installations and get their tools with token usage.
103
98
 
104
99
  **Examples:**
105
100
  ```bash
106
101
  # Verify all MCPs in project
107
102
  agentinit verify_mcp --all
108
-
109
- # Verify specific server
110
- agentinit verify_mcp --mcp-name everything
111
-
112
- # Test MCP configuration directly
103
+ # Verify STDIO server
113
104
  agentinit verify_mcp --mcp-stdio everything "npx -y @modelcontextprotocol/server-everything"
114
-
115
- agentinit verify_mcp --mcp-http
105
+ # Verify HTTP server
106
+ agentinit verify_mcp --mcp-http notion_api "https://mcp.notion.com/mcp" --timeout 30000
116
107
  ```
117
108
 
118
109
  Shows connection status, response time, and available tools/resources/prompts for each MCP server.
@@ -181,7 +172,13 @@ This generates `.agentinit/agentinit.toml` with your MCP configurations.
181
172
  - `--header "KEY:VALUE"` - Adds custom headers in KEY:VALUE format (can be used multiple times)
182
173
  - Both flags can be combined for APIs requiring multiple authentication methods
183
174
 
184
- **MCP Verification**: Use the `--verify-mcp` flag to test MCP servers immediately after configuration. This ensures servers are reachable and shows their available tools, resources, and prompts.
175
+ **MCP Verification**: Use the `--verify-mcp` flag to test MCP servers immediately after configuration. This ensures servers are reachable and shows their available tools, resources, and prompts. Use `--timeout <ms>` to set a custom connection timeout (default: 30000ms).
176
+
177
+ ```bash
178
+ # Verify with custom timeout
179
+ npx agentinit apply --verify-mcp --timeout 30000 \
180
+ --mcp-stdio chrome-mcp "bunx -y chrome-devtools-mcp@latest"
181
+ ```
185
182
 
186
183
  #### Rules Configuration
187
184
 
package/dist/index.js CHANGED
@@ -22985,16 +22985,48 @@ class MCPParser {
22985
22985
  }
22986
22986
  }
22987
22987
 
22988
+ // src/constants/mcp.ts
22989
+ import {readFileSync} from "fs";
22990
+ import {fileURLToPath} from "url";
22991
+ import {dirname as dirname3, join as join2} from "path";
22992
+ var getPackageVersion = function() {
22993
+ try {
22994
+ const __filename2 = fileURLToPath(import.meta.url);
22995
+ const __dirname2 = dirname3(__filename2);
22996
+ const packageJsonPath = join2(__dirname2, "../../package.json");
22997
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
22998
+ return packageJson.version || "1.0.0";
22999
+ } catch {
23000
+ return "1.0.0";
23001
+ }
23002
+ };
23003
+ var DEFAULT_CONNECTION_TIMEOUT_MS = 30000;
23004
+ var MCP_VERIFIER_CONFIG = {
23005
+ name: "agentinit-verifier",
23006
+ version: getPackageVersion()
23007
+ };
23008
+
23009
+ class TimeoutError extends Error {
23010
+ constructor(message) {
23011
+ super(message);
23012
+ this.name = "TimeoutError";
23013
+ }
23014
+ }
23015
+ // src/constants/tokens.ts
23016
+ var TOKEN_COUNT_THRESHOLDS = {
23017
+ LOW: 5000,
23018
+ MEDIUM: 15000
23019
+ };
22988
23020
  // src/core/rulesParser.ts
22989
- import {readFileSync as readFileSync2} from "fs";
23021
+ import {readFileSync as readFileSync3} from "fs";
22990
23022
 
22991
23023
  // src/core/rulesTemplateLoader.ts
22992
23024
  var toml = __toESM(require_toml(), 1);
22993
- import {resolve as resolve5, dirname as dirname3} from "path";
22994
- import {fileURLToPath} from "url";
22995
- import {readFileSync, readdirSync, existsSync} from "fs";
22996
- var __filename2 = fileURLToPath(import.meta.url);
22997
- var __dirname2 = dirname3(__filename2);
23025
+ import {resolve as resolve5, dirname as dirname4} from "path";
23026
+ import {fileURLToPath as fileURLToPath2} from "url";
23027
+ import {readFileSync as readFileSync2, readdirSync, existsSync} from "fs";
23028
+ var __filename2 = fileURLToPath2(import.meta.url);
23029
+ var __dirname2 = dirname4(__filename2);
22998
23030
 
22999
23031
  class RulesTemplateLoader {
23000
23032
  templatesPath;
@@ -23011,7 +23043,7 @@ class RulesTemplateLoader {
23011
23043
  for (const file of files) {
23012
23044
  try {
23013
23045
  const filePath = resolve5(this.templatesPath, file);
23014
- const content = readFileSync(filePath, "utf-8");
23046
+ const content = readFileSync2(filePath, "utf-8");
23015
23047
  const parsed = toml.default.parse(content);
23016
23048
  const template = {
23017
23049
  id: parsed.template.id,
@@ -23159,7 +23191,7 @@ class RulesParser {
23159
23191
  throw new RulesParseError(`Rules file not found: ${filePath}`);
23160
23192
  }
23161
23193
  try {
23162
- const content = readFileSync2(filePath, "utf-8");
23194
+ const content = readFileSync3(filePath, "utf-8");
23163
23195
  if (filePath.endsWith(".json")) {
23164
23196
  const parsed = JSON.parse(content);
23165
23197
  return this.extractRulesFromObject(parsed);
@@ -23185,12 +23217,17 @@ class RulesParser {
23185
23217
  }
23186
23218
  }
23187
23219
  const controller = new AbortController;
23188
- const timeoutId = setTimeout(() => controller.abort(), options2.timeout || 1e4);
23189
- const response = await fetch(options2.url, {
23190
- headers,
23191
- signal: controller.signal
23192
- });
23193
- clearTimeout(timeoutId);
23220
+ const timeoutMs = options2.timeout ?? DEFAULT_CONNECTION_TIMEOUT_MS;
23221
+ const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
23222
+ let response;
23223
+ try {
23224
+ response = await fetch(options2.url, {
23225
+ headers,
23226
+ signal: controller.signal
23227
+ });
23228
+ } finally {
23229
+ clearTimeout(timeoutId);
23230
+ }
23194
23231
  if (!response.ok) {
23195
23232
  throw new Error(`HTTP ${response.status}: ${response.statusText}`);
23196
23233
  }
@@ -23395,7 +23432,7 @@ class TOMLGenerator {
23395
23432
  import {resolve as resolve8} from "path";
23396
23433
 
23397
23434
  // src/utils/paths.ts
23398
- import {resolve as resolve6, join as join2} from "path";
23435
+ import {resolve as resolve6, join as join3} from "path";
23399
23436
  import {homedir} from "os";
23400
23437
  function getHomeDirectory() {
23401
23438
  return homedir();
@@ -23414,7 +23451,7 @@ function getPlatform() {
23414
23451
  }
23415
23452
  function expandTilde(path) {
23416
23453
  if (path.startsWith("~/")) {
23417
- return join2(getHomeDirectory(), path.slice(2));
23454
+ return join3(getHomeDirectory(), path.slice(2));
23418
23455
  }
23419
23456
  if (path === "~") {
23420
23457
  return getHomeDirectory();
@@ -32236,22 +32273,15 @@ class MCPVerificationError extends Error {
32236
32273
  }
32237
32274
  }
32238
32275
 
32239
- class TimeoutError extends Error {
32240
- constructor(message) {
32241
- super(message);
32242
- this.name = "TimeoutError";
32243
- }
32244
- }
32245
-
32246
32276
  class MCPVerifier {
32247
32277
  defaultTimeout;
32248
- constructor(defaultTimeout = 1e4) {
32278
+ constructor(defaultTimeout = DEFAULT_CONNECTION_TIMEOUT_MS) {
32249
32279
  this.defaultTimeout = defaultTimeout;
32250
32280
  }
32251
32281
  colorizeTokenCount(tokenCount) {
32252
- if (tokenCount <= 5000)
32282
+ if (tokenCount <= TOKEN_COUNT_THRESHOLDS.LOW)
32253
32283
  return green(tokenCount.toString());
32254
- if (tokenCount <= 15000)
32284
+ if (tokenCount <= TOKEN_COUNT_THRESHOLDS.MEDIUM)
32255
32285
  return yellow(tokenCount.toString());
32256
32286
  return red(tokenCount.toString());
32257
32287
  }
@@ -32285,8 +32315,8 @@ class MCPVerifier {
32285
32315
  try {
32286
32316
  transport = await this.createTransport(server);
32287
32317
  client2 = new Client({
32288
- name: "agentinit-verifier",
32289
- version: "1.0.0"
32318
+ name: MCP_VERIFIER_CONFIG.name,
32319
+ version: MCP_VERIFIER_CONFIG.version
32290
32320
  });
32291
32321
  const timeoutPromise = new Promise((_, reject) => {
32292
32322
  const timeoutId = setTimeout(async () => {
@@ -32542,12 +32572,10 @@ class MCPVerifier {
32542
32572
 
32543
32573
  // src/commands/apply.ts
32544
32574
  var colorizeTokenCount = function(tokenCount) {
32545
- if (tokenCount <= 5000)
32575
+ if (tokenCount <= TOKEN_COUNT_THRESHOLDS.LOW)
32546
32576
  return green(tokenCount.toString());
32547
- if (tokenCount <= 15000)
32577
+ if (tokenCount <= TOKEN_COUNT_THRESHOLDS.MEDIUM)
32548
32578
  return yellow(tokenCount.toString());
32549
- if (tokenCount <= 30000)
32550
- return red(tokenCount.toString());
32551
32579
  return red(tokenCount.toString());
32552
32580
  };
32553
32581
  var colorizeTokenDiff = function(diff) {
@@ -32566,6 +32594,10 @@ async function applyCommand(args) {
32566
32594
  const specifiedClient = clientArgIndex >= 0 && clientArgIndex + 1 < args.length ? args[clientArgIndex + 1] : null;
32567
32595
  const isGlobal = args.includes("--global");
32568
32596
  const verifyMcp = args.includes("--verify-mcp");
32597
+ const timeoutIndex = args.findIndex((arg) => arg === "--timeout");
32598
+ const timeoutArg = timeoutIndex >= 0 && timeoutIndex + 1 < args.length ? args[timeoutIndex + 1] : null;
32599
+ const parsedTimeout = timeoutArg ? parseInt(timeoutArg, 10) : NaN;
32600
+ const timeout = timeoutArg && Number.isFinite(parsedTimeout) && parsedTimeout > 0 ? parsedTimeout : undefined;
32569
32601
  if (!hasMcpArgs && !hasRulesArgs) {
32570
32602
  logger.info("Usage: agentinit apply [options]");
32571
32603
  logger.info("");
@@ -32575,6 +32607,7 @@ async function applyCommand(args) {
32575
32607
  logger.info(" --global Apply configuration globally (requires --agent)");
32576
32608
  logger.info(" If not specified, auto-detects agents in the project");
32577
32609
  logger.info(" --verify-mcp Verify MCP servers after configuration");
32610
+ logger.info(` --timeout <ms> Connection timeout in milliseconds for MCP verification (default: ${DEFAULT_CONNECTION_TIMEOUT_MS})`);
32578
32611
  logger.info("");
32579
32612
  logger.info("Rules Configuration Options:");
32580
32613
  logger.info(" --rules <templates> Apply rule templates (comma-separated)");
@@ -32631,11 +32664,11 @@ async function applyCommand(args) {
32631
32664
  const spinner = ora("Parsing configurations...").start();
32632
32665
  try {
32633
32666
  const mcpArgs = args.filter((arg, index) => {
32634
- if (arg === "--client" || arg === "--agent" || arg === "--global" || arg === "--verify-mcp")
32667
+ if (arg === "--client" || arg === "--agent" || arg === "--global" || arg === "--verify-mcp" || arg === "--timeout")
32635
32668
  return false;
32636
32669
  if (arg === "--rules" || arg === "--rule-raw" || arg === "--rules-file" || arg === "--rules-remote")
32637
32670
  return false;
32638
- if (index > 0 && (args[index - 1] === "--client" || args[index - 1] === "--agent"))
32671
+ if (index > 0 && (args[index - 1] === "--client" || args[index - 1] === "--agent" || args[index - 1] === "--timeout"))
32639
32672
  return false;
32640
32673
  if (index > 0 && (args[index - 1] === "--rules" || args[index - 1] === "--rule-raw" || args[index - 1] === "--rules-file" || args[index - 1] === "--rules-remote"))
32641
32674
  return false;
@@ -32786,8 +32819,8 @@ async function applyCommand(args) {
32786
32819
  logger.info("");
32787
32820
  const verifySpinner = ora(`Verifying ${mcpParsed.servers.length} MCP server(s)...`).start();
32788
32821
  try {
32789
- const verifier = new MCPVerifier;
32790
- const verificationResults = await verifier.verifyServers(mcpParsed.servers);
32822
+ const verifier = new MCPVerifier(timeout);
32823
+ const verificationResults = await verifier.verifyServers(mcpParsed.servers, timeout);
32791
32824
  const successCount = verificationResults.filter((r) => r.status === "success").length;
32792
32825
  const errorCount = verificationResults.filter((r) => r.status === "error").length;
32793
32826
  const timeoutCount = verificationResults.filter((r) => r.status === "timeout").length;
@@ -32821,7 +32854,17 @@ async function applyCommand(args) {
32821
32854
  if (server.type === "stdio" && server.command) {
32822
32855
  logger.info(` Command: ${server.command} ${server.args?.join(" ") || ""}`);
32823
32856
  } else if (server.url) {
32824
- logger.info(` URL: ${server.url}`);
32857
+ let sanitizedUrl;
32858
+ try {
32859
+ const parsedUrl = new URL(server.url);
32860
+ parsedUrl.username = "";
32861
+ parsedUrl.password = "";
32862
+ parsedUrl.search = "";
32863
+ sanitizedUrl = parsedUrl.toString();
32864
+ } catch {
32865
+ sanitizedUrl = server.url.split("?")[0] || "invalid-url";
32866
+ }
32867
+ logger.info(` URL: ${sanitizedUrl}`);
32825
32868
  }
32826
32869
  });
32827
32870
  }
@@ -32937,7 +32980,7 @@ async function verifyMcpCommand(args) {
32937
32980
  const timeoutIndex = args.findIndex((arg) => arg === "--timeout");
32938
32981
  const timeoutArg = timeoutIndex >= 0 && timeoutIndex + 1 < args.length ? args[timeoutIndex + 1] : null;
32939
32982
  const parsedTimeout = timeoutArg ? parseInt(timeoutArg, 10) : NaN;
32940
- const timeout = timeoutArg && !Number.isNaN(parsedTimeout) && Number.isFinite(parsedTimeout) ? parsedTimeout : undefined;
32983
+ const timeout = timeoutArg && Number.isFinite(parsedTimeout) && parsedTimeout > 0 ? parsedTimeout : undefined;
32941
32984
  const hasMcpArgs = args.some((arg) => arg.startsWith("--mcp-"));
32942
32985
  if (mcpName && hasAll) {
32943
32986
  logger.error("Cannot use --mcp-name and --all together. Choose one option.");
@@ -32953,7 +32996,7 @@ async function verifyMcpCommand(args) {
32953
32996
  logger.info("Verify existing configurations:");
32954
32997
  logger.info(" --mcp-name <name> Verify specific MCP server by name");
32955
32998
  logger.info(" --all Verify all configured MCP servers");
32956
- logger.info(" --timeout <ms> Connection timeout in milliseconds (default: 10000)");
32999
+ logger.info(` --timeout <ms> Connection timeout in milliseconds (default: ${DEFAULT_CONNECTION_TIMEOUT_MS})`);
32957
33000
  logger.info("");
32958
33001
  logger.info("Verify direct MCP configuration:");
32959
33002
  logger.info(" --mcp-stdio <name> <command> Verify STDIO MCP server");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentinit",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "description": "A CLI tool for managing and configuring AI coding agents",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",