agentinit 1.4.1 → 1.6.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.
Files changed (177) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +209 -0
  3. package/dist/agentinit-1.6.0.tgz +0 -0
  4. package/dist/agents/Agent.d.ts +110 -0
  5. package/dist/agents/Agent.d.ts.map +1 -0
  6. package/dist/agents/Agent.js +174 -0
  7. package/dist/agents/Agent.js.map +1 -0
  8. package/dist/agents/ClaudeAgent.d.ts +50 -0
  9. package/dist/agents/ClaudeAgent.d.ts.map +1 -0
  10. package/dist/agents/ClaudeAgent.js +249 -0
  11. package/dist/agents/ClaudeAgent.js.map +1 -0
  12. package/dist/agents/ClaudeDesktopAgent.d.ts +49 -0
  13. package/dist/agents/ClaudeDesktopAgent.d.ts.map +1 -0
  14. package/dist/agents/ClaudeDesktopAgent.js +143 -0
  15. package/dist/agents/ClaudeDesktopAgent.js.map +1 -0
  16. package/dist/agents/CodexCliAgent.d.ts +48 -0
  17. package/dist/agents/CodexCliAgent.d.ts.map +1 -0
  18. package/dist/agents/CodexCliAgent.js +262 -0
  19. package/dist/agents/CodexCliAgent.js.map +1 -0
  20. package/dist/agents/CursorAgent.d.ts +44 -0
  21. package/dist/agents/CursorAgent.d.ts.map +1 -0
  22. package/dist/agents/CursorAgent.js +231 -0
  23. package/dist/agents/CursorAgent.js.map +1 -0
  24. package/dist/agents/DroidAgent.d.ts +52 -0
  25. package/dist/agents/DroidAgent.d.ts.map +1 -0
  26. package/dist/agents/DroidAgent.js +228 -0
  27. package/dist/agents/DroidAgent.js.map +1 -0
  28. package/dist/agents/GeminiCliAgent.d.ts +40 -0
  29. package/dist/agents/GeminiCliAgent.d.ts.map +1 -0
  30. package/dist/agents/GeminiCliAgent.js +195 -0
  31. package/dist/agents/GeminiCliAgent.js.map +1 -0
  32. package/dist/cli.d.ts +3 -0
  33. package/dist/cli.d.ts.map +1 -0
  34. package/dist/cli.js +33365 -0
  35. package/dist/cli.js.map +1 -0
  36. package/dist/commands/apply.d.ts +2 -0
  37. package/dist/commands/apply.d.ts.map +1 -0
  38. package/dist/commands/apply.js +468 -0
  39. package/dist/commands/apply.js.map +1 -0
  40. package/dist/commands/config.d.ts +8 -0
  41. package/dist/commands/config.d.ts.map +1 -0
  42. package/dist/commands/config.js +6 -0
  43. package/dist/commands/config.js.map +1 -0
  44. package/dist/commands/detect.d.ts +6 -0
  45. package/dist/commands/detect.d.ts.map +1 -0
  46. package/dist/commands/detect.js +55 -0
  47. package/dist/commands/detect.js.map +1 -0
  48. package/dist/commands/init.d.ts +7 -0
  49. package/dist/commands/init.d.ts.map +1 -0
  50. package/dist/commands/init.js +105 -0
  51. package/dist/commands/init.js.map +1 -0
  52. package/dist/commands/mcp.d.ts +8 -0
  53. package/dist/commands/mcp.d.ts.map +1 -0
  54. package/dist/commands/mcp.js +127 -0
  55. package/dist/commands/mcp.js.map +1 -0
  56. package/dist/commands/subagents.d.ts +9 -0
  57. package/dist/commands/subagents.d.ts.map +1 -0
  58. package/dist/commands/subagents.js +6 -0
  59. package/dist/commands/subagents.js.map +1 -0
  60. package/dist/commands/sync.d.ts +7 -0
  61. package/dist/commands/sync.d.ts.map +1 -0
  62. package/dist/commands/sync.js +49 -0
  63. package/dist/commands/sync.js.map +1 -0
  64. package/dist/commands/verifyMcp.d.ts +2 -0
  65. package/dist/commands/verifyMcp.d.ts.map +1 -0
  66. package/dist/commands/verifyMcp.js +215 -0
  67. package/dist/commands/verifyMcp.js.map +1 -0
  68. package/dist/constants/index.d.ts +3 -0
  69. package/dist/constants/index.d.ts.map +1 -0
  70. package/dist/constants/index.js +3 -0
  71. package/dist/constants/index.js.map +1 -0
  72. package/dist/constants/mcp.d.ts +9 -0
  73. package/dist/constants/mcp.d.ts.map +1 -0
  74. package/dist/constants/mcp.js +28 -0
  75. package/dist/constants/mcp.js.map +1 -0
  76. package/dist/constants/tokens.d.ts +6 -0
  77. package/dist/constants/tokens.d.ts.map +1 -0
  78. package/dist/constants/tokens.js +5 -0
  79. package/dist/constants/tokens.js.map +1 -0
  80. package/dist/core/agentDetector.d.ts +9 -0
  81. package/dist/core/agentDetector.d.ts.map +1 -0
  82. package/dist/core/agentDetector.js +51 -0
  83. package/dist/core/agentDetector.js.map +1 -0
  84. package/dist/core/agentManager.d.ts +55 -0
  85. package/dist/core/agentManager.d.ts.map +1 -0
  86. package/dist/core/agentManager.js +113 -0
  87. package/dist/core/agentManager.js.map +1 -0
  88. package/dist/core/configMerger.d.ts +49 -0
  89. package/dist/core/configMerger.d.ts.map +1 -0
  90. package/dist/core/configMerger.js +180 -0
  91. package/dist/core/configMerger.js.map +1 -0
  92. package/dist/core/mcpClient.d.ts +38 -0
  93. package/dist/core/mcpClient.d.ts.map +1 -0
  94. package/dist/core/mcpClient.js +416 -0
  95. package/dist/core/mcpClient.js.map +1 -0
  96. package/dist/core/mcpFilter.d.ts +44 -0
  97. package/dist/core/mcpFilter.d.ts.map +1 -0
  98. package/dist/core/mcpFilter.js +126 -0
  99. package/dist/core/mcpFilter.js.map +1 -0
  100. package/dist/core/mcpParser.d.ts +25 -0
  101. package/dist/core/mcpParser.d.ts.map +1 -0
  102. package/dist/core/mcpParser.js +297 -0
  103. package/dist/core/mcpParser.js.map +1 -0
  104. package/dist/core/propagator.d.ts +25 -0
  105. package/dist/core/propagator.d.ts.map +1 -0
  106. package/dist/core/propagator.js +154 -0
  107. package/dist/core/propagator.js.map +1 -0
  108. package/dist/core/rulesApplicator.d.ts +29 -0
  109. package/dist/core/rulesApplicator.d.ts.map +1 -0
  110. package/dist/core/rulesApplicator.js +181 -0
  111. package/dist/core/rulesApplicator.js.map +1 -0
  112. package/dist/core/rulesParser.d.ts +41 -0
  113. package/dist/core/rulesParser.d.ts.map +1 -0
  114. package/dist/core/rulesParser.js +260 -0
  115. package/dist/core/rulesParser.js.map +1 -0
  116. package/dist/core/rulesTemplateLoader.d.ts +31 -0
  117. package/dist/core/rulesTemplateLoader.d.ts.map +1 -0
  118. package/dist/core/rulesTemplateLoader.js +75 -0
  119. package/dist/core/rulesTemplateLoader.js.map +1 -0
  120. package/dist/core/stackDetector.d.ts +16 -0
  121. package/dist/core/stackDetector.d.ts.map +1 -0
  122. package/dist/core/stackDetector.js +234 -0
  123. package/dist/core/stackDetector.js.map +1 -0
  124. package/dist/core/templateEngine.d.ts +15 -0
  125. package/dist/core/templateEngine.d.ts.map +1 -0
  126. package/dist/core/templateEngine.js +260 -0
  127. package/dist/core/templateEngine.js.map +1 -0
  128. package/dist/core/tomlGenerator.d.ts +24 -0
  129. package/dist/core/tomlGenerator.d.ts.map +1 -0
  130. package/dist/core/tomlGenerator.js +185 -0
  131. package/dist/core/tomlGenerator.js.map +1 -0
  132. package/dist/index.d.ts +21 -0
  133. package/dist/index.d.ts.map +1 -0
  134. package/dist/index.js +21 -33195
  135. package/dist/index.js.map +1 -0
  136. package/dist/lib/index.d.ts +39 -0
  137. package/dist/lib/index.d.ts.map +1 -0
  138. package/dist/lib/index.js +40 -0
  139. package/dist/lib/index.js.map +1 -0
  140. package/dist/lib/types/index.d.ts +23 -0
  141. package/dist/lib/types/index.d.ts.map +1 -0
  142. package/dist/lib/types/index.js +23 -0
  143. package/dist/lib/types/index.js.map +1 -0
  144. package/dist/lib/utils/index.d.ts +18 -0
  145. package/dist/lib/utils/index.d.ts.map +1 -0
  146. package/dist/lib/utils/index.js +21 -0
  147. package/dist/lib/utils/index.js.map +1 -0
  148. package/dist/lib/verifier/index.d.ts +22 -0
  149. package/dist/lib/verifier/index.d.ts.map +1 -0
  150. package/dist/lib/verifier/index.js +22 -0
  151. package/dist/lib/verifier/index.js.map +1 -0
  152. package/dist/registry/mcpRegistry.d.ts +12 -0
  153. package/dist/registry/mcpRegistry.d.ts.map +1 -0
  154. package/dist/registry/mcpRegistry.js +114 -0
  155. package/dist/registry/mcpRegistry.js.map +1 -0
  156. package/dist/types/index.d.ts +180 -0
  157. package/dist/types/index.d.ts.map +1 -0
  158. package/dist/types/index.js +21 -0
  159. package/dist/types/index.js.map +1 -0
  160. package/dist/types/rules.d.ts +51 -0
  161. package/dist/types/rules.d.ts.map +1 -0
  162. package/dist/types/rules.js +2 -0
  163. package/dist/types/rules.js.map +1 -0
  164. package/dist/utils/fs.d.ts +12 -0
  165. package/dist/utils/fs.d.ts.map +1 -0
  166. package/dist/utils/fs.js +91 -0
  167. package/dist/utils/fs.js.map +1 -0
  168. package/dist/utils/logger.d.ts +14 -0
  169. package/dist/utils/logger.d.ts.map +1 -0
  170. package/dist/utils/logger.js +36 -0
  171. package/dist/utils/logger.js.map +1 -0
  172. package/dist/utils/paths.d.ts +77 -0
  173. package/dist/utils/paths.d.ts.map +1 -0
  174. package/dist/utils/paths.js +140 -0
  175. package/dist/utils/paths.js.map +1 -0
  176. package/package.json +30 -6
  177. package/dist/agentinit-1.4.1.tgz +0 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,22 @@
1
+ # [1.6.0](https://github.com/agentinit/agentinit/compare/v1.5.0...v1.6.0) (2025-10-10)
2
+
3
+
4
+ ### Features
5
+
6
+ * **agents:** add Droid (Factory AI) agent support ([73e5529](https://github.com/agentinit/agentinit/commit/73e5529703af36781c06e840faf38227d2ce79ac))
7
+
8
+ # [1.5.0](https://github.com/agentinit/agentinit/compare/v1.4.1...v1.5.0) (2025-10-01)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * use npx tsc in build and fix Commander argument parsing ([4fa51f9](https://github.com/agentinit/agentinit/commit/4fa51f941c0fbeee2880850add90af038c3623cf))
14
+
15
+
16
+ ### Features
17
+
18
+ * add library API for programmatic MCP verification ([8cf70d7](https://github.com/agentinit/agentinit/commit/8cf70d7395987221eb33c6575885d07a45717df0))
19
+
1
20
  ## [1.4.1](https://github.com/agentinit/agentinit/compare/v1.4.0...v1.4.1) (2025-09-26)
2
21
 
3
22
 
package/README.md CHANGED
@@ -298,6 +298,215 @@ AgentInit includes a curated registry of popular MCPs:
298
298
  | supabase-mcp | database | Supabase integration |
299
299
  | git-mcp | version-control | Enhanced Git operations |
300
300
 
301
+ ## 📚 Library API
302
+
303
+ AgentInit can be used as a library in your Node.js/TypeScript applications for programmatic MCP server verification and management.
304
+
305
+ ### Installation
306
+
307
+ ```bash
308
+ npm install agentinit
309
+ # or
310
+ yarn add agentinit
311
+ # or
312
+ bun add agentinit
313
+ ```
314
+
315
+ ### Basic Usage
316
+
317
+ ```typescript
318
+ import { MCPVerifier, MCPServerType } from 'agentinit';
319
+
320
+ const verifier = new MCPVerifier();
321
+
322
+ const result = await verifier.verifyServer({
323
+ name: 'everything',
324
+ type: MCPServerType.STDIO,
325
+ command: 'npx',
326
+ args: ['-y', '@modelcontextprotocol/server-everything']
327
+ });
328
+
329
+ if (result.status === 'success') {
330
+ console.log(`✅ Connected to ${result.server.name}`);
331
+ console.log(`Tools: ${result.capabilities?.tools.length}`);
332
+ console.log(`Total tokens: ${result.capabilities?.totalToolTokens}`);
333
+ }
334
+ ```
335
+
336
+ ### Submodule Imports
337
+
338
+ For better tree-shaking, import from specific submodules:
339
+
340
+ ```typescript
341
+ // Import specific modules
342
+ import { MCPVerifier } from 'agentinit/verifier';
343
+ import { MCPServerType } from 'agentinit/types';
344
+ import type { MCPServerConfig, MCPVerificationResult } from 'agentinit/types';
345
+ import { countTokens, MCPParser } from 'agentinit/utils';
346
+ ```
347
+
348
+ ### Examples
349
+
350
+ #### Verify STDIO MCP Server
351
+
352
+ ```typescript
353
+ import { MCPVerifier, MCPServerType } from 'agentinit';
354
+
355
+ const verifier = new MCPVerifier(10000); // 10 second timeout
356
+
357
+ const result = await verifier.verifyServer({
358
+ name: 'filesystem',
359
+ type: MCPServerType.STDIO,
360
+ command: 'npx',
361
+ args: ['-y', '@modelcontextprotocol/server-filesystem', '/workspace'],
362
+ env: {
363
+ NODE_ENV: 'production'
364
+ }
365
+ });
366
+
367
+ if (result.status === 'success') {
368
+ result.capabilities?.tools.forEach(tool => {
369
+ const tokens = result.capabilities?.toolTokenCounts?.get(tool.name) || 0;
370
+ console.log(` • ${tool.name} (${tokens} tokens)`);
371
+ });
372
+ }
373
+ ```
374
+
375
+ #### Verify HTTP MCP Server
376
+
377
+ ```typescript
378
+ import { MCPVerifier, MCPServerType } from 'agentinit';
379
+
380
+ const result = await verifier.verifyServer({
381
+ name: 'github-api',
382
+ type: MCPServerType.HTTP,
383
+ url: 'https://api.example.com/mcp',
384
+ headers: {
385
+ 'Authorization': 'Bearer YOUR_TOKEN',
386
+ 'Content-Type': 'application/json'
387
+ }
388
+ });
389
+ ```
390
+
391
+ #### Verify Multiple Servers
392
+
393
+ ```typescript
394
+ import { MCPVerifier, MCPServerType } from 'agentinit';
395
+
396
+ const servers = [
397
+ {
398
+ name: 'everything',
399
+ type: MCPServerType.STDIO,
400
+ command: 'npx',
401
+ args: ['-y', '@modelcontextprotocol/server-everything']
402
+ },
403
+ {
404
+ name: 'api-server',
405
+ type: MCPServerType.HTTP,
406
+ url: 'https://api.example.com/mcp'
407
+ }
408
+ ];
409
+
410
+ const verifier = new MCPVerifier();
411
+ const results = await verifier.verifyServers(servers);
412
+
413
+ // Display formatted results
414
+ console.log(verifier.formatResults(results));
415
+
416
+ // Or process results programmatically
417
+ const successful = results.filter(r => r.status === 'success').length;
418
+ console.log(`${successful}/${results.length} servers verified`);
419
+ ```
420
+
421
+ #### Count Tokens
422
+
423
+ ```typescript
424
+ import { countTokens } from 'agentinit/utils';
425
+
426
+ const text = 'Hello, world!';
427
+ const tokens = countTokens(text);
428
+ console.log(`Token count: ${tokens}`);
429
+ ```
430
+
431
+ #### Parse MCP Configuration
432
+
433
+ ```typescript
434
+ import { MCPParser } from 'agentinit/utils';
435
+
436
+ const args = ['--mcp-stdio', 'test', 'node', 'server.js', '--args', 'arg1 arg2'];
437
+ const parsed = MCPParser.parseArguments(args);
438
+
439
+ console.log(parsed.servers); // Array of MCPServerConfig
440
+ ```
441
+
442
+ ### API Reference
443
+
444
+ #### MCPVerifier
445
+
446
+ **Constructor**
447
+ ```typescript
448
+ new MCPVerifier(defaultTimeout?: number)
449
+ ```
450
+
451
+ **Methods**
452
+ - `verifyServer(config: MCPServerConfig, timeout?: number): Promise<MCPVerificationResult>` - Verify a single MCP server
453
+ - `verifyServers(configs: MCPServerConfig[], timeout?: number): Promise<MCPVerificationResult[]>` - Verify multiple servers in parallel
454
+ - `formatResults(results: MCPVerificationResult[]): string` - Format verification results for display
455
+
456
+ #### Types
457
+
458
+ **MCPServerType**
459
+ ```typescript
460
+ enum MCPServerType {
461
+ STDIO = 'stdio',
462
+ HTTP = 'http',
463
+ SSE = 'sse'
464
+ }
465
+ ```
466
+
467
+ **MCPServerConfig**
468
+ ```typescript
469
+ interface MCPServerConfig {
470
+ name: string;
471
+ type: MCPServerType;
472
+
473
+ // For STDIO servers
474
+ command?: string;
475
+ args?: string[];
476
+ env?: Record<string, string>;
477
+
478
+ // For HTTP/SSE servers
479
+ url?: string;
480
+ headers?: Record<string, string>;
481
+ }
482
+ ```
483
+
484
+ **MCPVerificationResult**
485
+ ```typescript
486
+ interface MCPVerificationResult {
487
+ server: MCPServerConfig;
488
+ status: 'success' | 'error' | 'timeout';
489
+ capabilities?: MCPCapabilities;
490
+ error?: string;
491
+ connectionTime?: number;
492
+ }
493
+ ```
494
+
495
+ **MCPCapabilities**
496
+ ```typescript
497
+ interface MCPCapabilities {
498
+ tools: MCPTool[];
499
+ resources: MCPResource[];
500
+ prompts: MCPPrompt[];
501
+ serverInfo?: {
502
+ name: string;
503
+ version: string;
504
+ };
505
+ totalToolTokens?: number;
506
+ toolTokenCounts?: Map<string, number>;
507
+ }
508
+ ```
509
+
301
510
  ## 🛠️ Development
302
511
 
303
512
  ### Building from Source
Binary file
@@ -0,0 +1,110 @@
1
+ import type { AgentDefinition, MCPServerConfig, AgentDetectionResult, ConfigFileDefinition } from '../types/index.js';
2
+ import type { AppliedRules, RuleApplicationResult, RuleSection } from '../types/rules.js';
3
+ /**
4
+ * Abstract base class for AI coding agents
5
+ * Defines the common interface and behavior for all supported agents
6
+ */
7
+ export declare abstract class Agent {
8
+ protected definition: AgentDefinition;
9
+ constructor(definition: AgentDefinition);
10
+ /**
11
+ * Get the agent's unique identifier
12
+ */
13
+ get id(): string;
14
+ /**
15
+ * Get the agent's human-readable name
16
+ */
17
+ get name(): string;
18
+ /**
19
+ * Get the agent's capabilities
20
+ */
21
+ get capabilities(): import("../types/index.js").AgentCapabilities;
22
+ /**
23
+ * Get the agent's configuration files to check for presence
24
+ */
25
+ get configFiles(): ConfigFileDefinition[];
26
+ /**
27
+ * Get the agent's configuration file paths (backward compatibility)
28
+ */
29
+ get configFilePaths(): string[];
30
+ /**
31
+ * Get the native configuration path for this agent
32
+ */
33
+ get nativeConfigPath(): string;
34
+ /**
35
+ * Detect if this agent is present in the given project path
36
+ */
37
+ detectPresence(projectPath: string): Promise<AgentDetectionResult | null>;
38
+ /**
39
+ * Get the path where this agent's native MCP configuration should be written
40
+ */
41
+ getNativeMcpPath(projectPath: string): string;
42
+ /**
43
+ * Get the global configuration path for this agent
44
+ * Returns null if global configuration is not supported
45
+ */
46
+ getGlobalMcpPath(): string | null;
47
+ /**
48
+ * Check if this agent supports global configuration
49
+ */
50
+ supportsGlobalConfig(): boolean;
51
+ /**
52
+ * Apply MCP configuration to this agent's native config format
53
+ * Must be implemented by each specific agent
54
+ */
55
+ abstract applyMCPConfig(projectPath: string, servers: MCPServerConfig[]): Promise<void>;
56
+ /**
57
+ * Get existing MCP servers from this agent's configuration
58
+ * Default implementation returns empty array - should be overridden by agents that support MCP
59
+ */
60
+ getMCPServers(projectPath: string): Promise<MCPServerConfig[]>;
61
+ /**
62
+ * Apply MCP configuration to this agent's global config format
63
+ * Default implementation uses the same logic as applyMCPConfig but with global path
64
+ * Can be overridden by specific agents for different global config formats
65
+ */
66
+ applyGlobalMCPConfig(servers: MCPServerConfig[]): Promise<void>;
67
+ /**
68
+ * Filter MCP servers based on this agent's capabilities
69
+ * Can be overridden by specific agents for custom filtering logic
70
+ */
71
+ filterMCPServers(servers: MCPServerConfig[]): MCPServerConfig[];
72
+ /**
73
+ * Transform MCP servers for this agent's requirements
74
+ * Can be overridden by specific agents for custom transformation logic
75
+ */
76
+ transformMCPServers(servers: MCPServerConfig[]): MCPServerConfig[];
77
+ /**
78
+ * Apply rules configuration to this agent's config file format
79
+ * Must be implemented by each specific agent
80
+ */
81
+ abstract applyRulesConfig(configPath: string, rules: AppliedRules, existingContent: string): Promise<string>;
82
+ /**
83
+ * Extract existing rule texts from config content
84
+ * Must be implemented by each specific agent
85
+ */
86
+ abstract extractExistingRules(content: string): string[];
87
+ /**
88
+ * Extract existing rule sections from config content
89
+ * Must be implemented by each specific agent
90
+ */
91
+ abstract extractExistingSections(content: string): RuleSection[];
92
+ /**
93
+ * Generate rules content in this agent's format
94
+ * Must be implemented by each specific agent
95
+ */
96
+ abstract generateRulesContent(sections: RuleSection[]): string;
97
+ /**
98
+ * Apply rules configuration to this agent
99
+ */
100
+ applyRules(projectPath: string, rules: AppliedRules): Promise<RuleApplicationResult>;
101
+ /**
102
+ * Apply rules configuration to this agent's global config
103
+ */
104
+ applyGlobalRules(rules: AppliedRules): Promise<RuleApplicationResult>;
105
+ /**
106
+ * Get a summary of this agent
107
+ */
108
+ toString(): string;
109
+ }
110
+ //# sourceMappingURL=Agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Agent.d.ts","sourceRoot":"","sources":["../../src/agents/Agent.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,YAAY,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE1F;;;GAGG;AACH,8BAAsB,KAAK;IACzB,SAAS,CAAC,UAAU,EAAE,eAAe,CAAC;gBAE1B,UAAU,EAAE,eAAe;IAIvC;;OAEG;IACH,IAAI,EAAE,IAAI,MAAM,CAEf;IAED;;OAEG;I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,WAAW,EAAE;IAEhE;;;OAGG;IACH,QAAQ,CAAC,oBAAoB,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,MAAM;IAE9D;;OAEG;IACG,UAAU,CACd,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,qBAAqB,CAAC;IAKjC;;OAEG;IACG,gBAAgB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAiB3E;;OAEG;IACH,QAAQ,IAAI,MAAM;CAGnB"}
@@ -0,0 +1,174 @@
1
+ import { resolve } from 'path';
2
+ import { pathExists } from '../utils/fs.js';
3
+ import { getFullGlobalConfigPath } from '../utils/paths.js';
4
+ import { RulesApplicator } from '../core/rulesApplicator.js';
5
+ /**
6
+ * Abstract base class for AI coding agents
7
+ * Defines the common interface and behavior for all supported agents
8
+ */
9
+ export class Agent {
10
+ definition;
11
+ constructor(definition) {
12
+ this.definition = definition;
13
+ }
14
+ /**
15
+ * Get the agent's unique identifier
16
+ */
17
+ get id() {
18
+ return this.definition.id;
19
+ }
20
+ /**
21
+ * Get the agent's human-readable name
22
+ */
23
+ get name() {
24
+ return this.definition.name;
25
+ }
26
+ /**
27
+ * Get the agent's capabilities
28
+ */
29
+ get capabilities() {
30
+ return this.definition.capabilities;
31
+ }
32
+ /**
33
+ * Get the agent's configuration files to check for presence
34
+ */
35
+ get configFiles() {
36
+ return this.definition.configFiles;
37
+ }
38
+ /**
39
+ * Get the agent's configuration file paths (backward compatibility)
40
+ */
41
+ get configFilePaths() {
42
+ return this.definition.configFiles.map(config => config.path);
43
+ }
44
+ /**
45
+ * Get the native configuration path for this agent
46
+ */
47
+ get nativeConfigPath() {
48
+ return this.definition.nativeConfigPath;
49
+ }
50
+ /**
51
+ * Detect if this agent is present in the given project path
52
+ */
53
+ async detectPresence(projectPath) {
54
+ for (const configFile of this.configFiles) {
55
+ const fullPath = resolve(projectPath, configFile.path);
56
+ if (await pathExists(fullPath, configFile.type)) {
57
+ return {
58
+ agent: this,
59
+ configPath: fullPath
60
+ };
61
+ }
62
+ }
63
+ return null;
64
+ }
65
+ /**
66
+ * Get the path where this agent's native MCP configuration should be written
67
+ */
68
+ getNativeMcpPath(projectPath) {
69
+ return resolve(projectPath, this.nativeConfigPath);
70
+ }
71
+ /**
72
+ * Get the global configuration path for this agent
73
+ * Returns null if global configuration is not supported
74
+ */
75
+ getGlobalMcpPath() {
76
+ return getFullGlobalConfigPath(this.definition.globalConfigPath, this.definition.globalConfigPaths);
77
+ }
78
+ /**
79
+ * Check if this agent supports global configuration
80
+ */
81
+ supportsGlobalConfig() {
82
+ return this.getGlobalMcpPath() !== null;
83
+ }
84
+ /**
85
+ * Get existing MCP servers from this agent's configuration
86
+ * Default implementation returns empty array - should be overridden by agents that support MCP
87
+ */
88
+ async getMCPServers(projectPath) {
89
+ return [];
90
+ }
91
+ /**
92
+ * Apply MCP configuration to this agent's global config format
93
+ * Default implementation uses the same logic as applyMCPConfig but with global path
94
+ * Can be overridden by specific agents for different global config formats
95
+ */
96
+ async applyGlobalMCPConfig(servers) {
97
+ const globalPath = this.getGlobalMcpPath();
98
+ if (!globalPath) {
99
+ throw new Error(`Agent ${this.name} does not support global configuration`);
100
+ }
101
+ // Extract directory from global path and use it as "project path"
102
+ // This allows reusing the existing applyMCPConfig logic
103
+ const lastSlashIndex = Math.max(globalPath.lastIndexOf('/'), globalPath.lastIndexOf('\\'));
104
+ const globalDir = lastSlashIndex > 0 ? globalPath.substring(0, lastSlashIndex) : '';
105
+ // Temporarily override the native config path to point to global config
106
+ const originalNativeConfigPath = this.definition.nativeConfigPath;
107
+ const globalFileName = globalPath.substring(lastSlashIndex + 1);
108
+ this.definition.nativeConfigPath = globalFileName;
109
+ try {
110
+ await this.applyMCPConfig(globalDir, servers);
111
+ }
112
+ finally {
113
+ // Restore original native config path
114
+ this.definition.nativeConfigPath = originalNativeConfigPath;
115
+ }
116
+ }
117
+ /**
118
+ * Filter MCP servers based on this agent's capabilities
119
+ * Can be overridden by specific agents for custom filtering logic
120
+ */
121
+ filterMCPServers(servers) {
122
+ return servers.filter(server => {
123
+ switch (server.type) {
124
+ case 'stdio':
125
+ return this.capabilities.mcp.stdio;
126
+ case 'http':
127
+ return this.capabilities.mcp.http;
128
+ case 'sse':
129
+ return this.capabilities.mcp.sse;
130
+ default:
131
+ return false;
132
+ }
133
+ });
134
+ }
135
+ /**
136
+ * Transform MCP servers for this agent's requirements
137
+ * Can be overridden by specific agents for custom transformation logic
138
+ */
139
+ transformMCPServers(servers) {
140
+ // Default: no transformations
141
+ return servers;
142
+ }
143
+ /**
144
+ * Apply rules configuration to this agent
145
+ */
146
+ async applyRules(projectPath, rules) {
147
+ const applicator = new RulesApplicator();
148
+ return applicator.applyRulesToAgent(this, rules, projectPath, false);
149
+ }
150
+ /**
151
+ * Apply rules configuration to this agent's global config
152
+ */
153
+ async applyGlobalRules(rules) {
154
+ const applicator = new RulesApplicator();
155
+ if (!this.supportsGlobalConfig()) {
156
+ return {
157
+ success: false,
158
+ rulesApplied: 0,
159
+ agent: this.name,
160
+ configPath: '',
161
+ errors: [`Agent ${this.name} does not support global configuration`]
162
+ };
163
+ }
164
+ // Use empty string as project path for global config
165
+ return applicator.applyRulesToAgent(this, rules, '', true);
166
+ }
167
+ /**
168
+ * Get a summary of this agent
169
+ */
170
+ toString() {
171
+ return `${this.name} (${this.id})`;
172
+ }
173
+ }
174
+ //# sourceMappingURL=Agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Agent.js","sourceRoot":"","sources":["../../src/agents/Agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAS7D;;;GAGG;AACH,MAAM,OAAgB,KA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,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;IAC7D,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,GAAG,CAAC;IACrC,CAAC;CACF"}
@@ -0,0 +1,50 @@
1
+ import { Agent } from './Agent.js';
2
+ import type { MCPServerConfig } from '../types/index.js';
3
+ import type { AppliedRules, RuleSection } from '../types/rules.js';
4
+ /**
5
+ * Claude Code agent implementation
6
+ * Supports full MCP capabilities including stdio, HTTP, and SSE servers
7
+ * Native config: .mcp.json
8
+ * Global config: ~/.claude.json
9
+ *
10
+ * Note: Claude Code uses a unique MCP configuration format:
11
+ * - stdio servers: { command, args?, env? }
12
+ * - http servers: { type: "http", url, headers? }
13
+ * - sse servers: { type: "sse", url, headers? }
14
+ */
15
+ export declare class ClaudeAgent extends Agent {
16
+ constructor();
17
+ /**
18
+ * Apply MCP configuration to Claude's native .mcp.json format
19
+ */
20
+ applyMCPConfig(projectPath: string, servers: MCPServerConfig[]): Promise<void>;
21
+ /**
22
+ * Claude supports all MCP server types, so no filtering needed
23
+ */
24
+ filterMCPServers(servers: MCPServerConfig[]): MCPServerConfig[];
25
+ /**
26
+ * Claude doesn't need any transformations
27
+ */
28
+ transformMCPServers(servers: MCPServerConfig[]): MCPServerConfig[];
29
+ /**
30
+ * Apply rules configuration to Claude's CLAUDE.md format
31
+ */
32
+ applyRulesConfig(configPath: string, rules: AppliedRules, existingContent: string): Promise<string>;
33
+ /**
34
+ * Extract existing rule texts from CLAUDE.md content
35
+ */
36
+ extractExistingRules(content: string): string[];
37
+ /**
38
+ * Extract existing rule sections from CLAUDE.md content using ## headers
39
+ */
40
+ extractExistingSections(content: string): RuleSection[];
41
+ /**
42
+ * Generate rules content in Claude's CLAUDE.md markdown format
43
+ */
44
+ generateRulesContent(sections: RuleSection[]): string;
45
+ /**
46
+ * Get existing MCP servers from Claude's .mcp.json configuration
47
+ */
48
+ getMCPServers(projectPath: string): Promise<MCPServerConfig[]>;
49
+ }
50
+ //# sourceMappingURL=ClaudeAgent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClaudeAgent.d.ts","sourceRoot":"","sources":["../../src/agents/ClaudeAgent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,KAAK,EAAE,eAAe,EAAkC,MAAM,mBAAmB,CAAC;AACzF,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEnE;;;;;;;;;;GAUG;AACH,qBAAa,WAAY,SAAQ,KAAK;;IA2CpC;;OAEG;IACG,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAqEpF;;OAEG;IACH,gBAAgB,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,eAAe,EAAE;IAI/D;;OAEG;IACH,mBAAmB,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,eAAe,EAAE;IAIlE;;OAEG;IACG,gBAAgB,CACpB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,YAAY,EACnB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,MAAM,CAAC;IAiBlB;;OAEG;IACH,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE;IAM/C;;OAEG;IACH,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,EAAE;IAmCvD;;OAEG;IACH,oBAAoB,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,MAAM;IAiBrD;;OAEG;IACG,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;CA6CrE"}