@4onstudios/iris-agent 0.1.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 (216) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +690 -0
  3. package/dist/api/acp/acpServer.d.ts +23 -0
  4. package/dist/api/acp/acpServer.js +814 -0
  5. package/dist/api/acp/index.d.ts +2 -0
  6. package/dist/api/acp/index.js +2 -0
  7. package/dist/api/acp/irisClient.d.ts +58 -0
  8. package/dist/api/acp/irisClient.js +214 -0
  9. package/dist/api/agent.d.ts +14 -0
  10. package/dist/api/agent.js +4171 -0
  11. package/dist/api/backendService.d.ts +4 -0
  12. package/dist/api/backendService.js +14 -0
  13. package/dist/api/core/agent/host/AgentContract.d.ts +82 -0
  14. package/dist/api/core/agent/host/AgentContract.js +1 -0
  15. package/dist/api/core/agent/host/AgentRegistry.d.ts +24 -0
  16. package/dist/api/core/agent/host/AgentRegistry.js +125 -0
  17. package/dist/api/core/agent/host/defaultRegistry.d.ts +15 -0
  18. package/dist/api/core/agent/host/defaultRegistry.js +46 -0
  19. package/dist/api/core/agent/host/externalAgentLifecycle.d.ts +65 -0
  20. package/dist/api/core/agent/host/externalAgentLifecycle.js +117 -0
  21. package/dist/api/core/agent/host/hostSessionManager.d.ts +111 -0
  22. package/dist/api/core/agent/host/hostSessionManager.js +352 -0
  23. package/dist/api/core/agent/host/index.d.ts +5 -0
  24. package/dist/api/core/agent/host/index.js +5 -0
  25. package/dist/api/core/agent/index.d.ts +87 -0
  26. package/dist/api/core/agent/index.js +1024 -0
  27. package/dist/api/core/agent/publicContracts.d.ts +35 -0
  28. package/dist/api/core/agent/publicContracts.js +103 -0
  29. package/dist/api/core/agent/tools/applyDiff.d.ts +51 -0
  30. package/dist/api/core/agent/tools/applyDiff.js +131 -0
  31. package/dist/api/core/agent/tools/backgroundTasks.d.ts +240 -0
  32. package/dist/api/core/agent/tools/backgroundTasks.js +313 -0
  33. package/dist/api/core/agent/tools/createDirectory.d.ts +43 -0
  34. package/dist/api/core/agent/tools/createDirectory.js +77 -0
  35. package/dist/api/core/agent/tools/deleteFile.d.ts +37 -0
  36. package/dist/api/core/agent/tools/deleteFile.js +66 -0
  37. package/dist/api/core/agent/tools/editFile.d.ts +73 -0
  38. package/dist/api/core/agent/tools/editFile.js +173 -0
  39. package/dist/api/core/agent/tools/executeCommand.d.ts +59 -0
  40. package/dist/api/core/agent/tools/executeCommand.js +250 -0
  41. package/dist/api/core/agent/tools/fileContent.d.ts +54 -0
  42. package/dist/api/core/agent/tools/fileContent.js +227 -0
  43. package/dist/api/core/agent/tools/findDefinition.d.ts +72 -0
  44. package/dist/api/core/agent/tools/findDefinition.js +109 -0
  45. package/dist/api/core/agent/tools/findReferences.d.ts +86 -0
  46. package/dist/api/core/agent/tools/findReferences.js +135 -0
  47. package/dist/api/core/agent/tools/formatDocument.d.ts +67 -0
  48. package/dist/api/core/agent/tools/formatDocument.js +90 -0
  49. package/dist/api/core/agent/tools/getCodeActions.d.ts +77 -0
  50. package/dist/api/core/agent/tools/getCodeActions.js +97 -0
  51. package/dist/api/core/agent/tools/getCodeCompletion.d.ts +77 -0
  52. package/dist/api/core/agent/tools/getCodeCompletion.js +174 -0
  53. package/dist/api/core/agent/tools/getCodeContext.d.ts +14 -0
  54. package/dist/api/core/agent/tools/getCodeContext.js +282 -0
  55. package/dist/api/core/agent/tools/getSignatureHelp.d.ts +61 -0
  56. package/dist/api/core/agent/tools/getSignatureHelp.js +85 -0
  57. package/dist/api/core/agent/tools/getSymbols.d.ts +50 -0
  58. package/dist/api/core/agent/tools/getSymbols.js +164 -0
  59. package/dist/api/core/agent/tools/getSymbolsLSP.d.ts +58 -0
  60. package/dist/api/core/agent/tools/getSymbolsLSP.js +147 -0
  61. package/dist/api/core/agent/tools/getTypeInfo.d.ts +70 -0
  62. package/dist/api/core/agent/tools/getTypeInfo.js +84 -0
  63. package/dist/api/core/agent/tools/getWorkspaceInfo.d.ts +80 -0
  64. package/dist/api/core/agent/tools/getWorkspaceInfo.js +281 -0
  65. package/dist/api/core/agent/tools/getWorkspaceSymbols.d.ts +53 -0
  66. package/dist/api/core/agent/tools/getWorkspaceSymbols.js +97 -0
  67. package/dist/api/core/agent/tools/grepSearch.d.ts +100 -0
  68. package/dist/api/core/agent/tools/grepSearch.js +211 -0
  69. package/dist/api/core/agent/tools/languageModelToolsIntegration.d.ts +13 -0
  70. package/dist/api/core/agent/tools/languageModelToolsIntegration.js +22 -0
  71. package/dist/api/core/agent/tools/listDirectory.d.ts +66 -0
  72. package/dist/api/core/agent/tools/listDirectory.js +161 -0
  73. package/dist/api/core/agent/tools/mcpTools.d.ts +48 -0
  74. package/dist/api/core/agent/tools/mcpTools.js +442 -0
  75. package/dist/api/core/agent/tools/queryKnowledgeGraph.d.ts +120 -0
  76. package/dist/api/core/agent/tools/queryKnowledgeGraph.js +306 -0
  77. package/dist/api/core/agent/tools/readFile.d.ts +92 -0
  78. package/dist/api/core/agent/tools/readFile.js +337 -0
  79. package/dist/api/core/agent/tools/renameFile.d.ts +49 -0
  80. package/dist/api/core/agent/tools/renameFile.js +86 -0
  81. package/dist/api/core/agent/tools/renameSymbol.d.ts +70 -0
  82. package/dist/api/core/agent/tools/renameSymbol.js +106 -0
  83. package/dist/api/core/agent/tools/runTerminalCommand.d.ts +72 -0
  84. package/dist/api/core/agent/tools/runTerminalCommand.js +69 -0
  85. package/dist/api/core/agent/tools/searchFiles.d.ts +82 -0
  86. package/dist/api/core/agent/tools/searchFiles.js +280 -0
  87. package/dist/api/core/agent/tools/terminalAutoApprove.d.ts +3 -0
  88. package/dist/api/core/agent/tools/terminalAutoApprove.js +676 -0
  89. package/dist/api/core/agent/tools/treeTraversal.d.ts +60 -0
  90. package/dist/api/core/agent/tools/treeTraversal.js +217 -0
  91. package/dist/api/core/agent/tools/webSearch.d.ts +37 -0
  92. package/dist/api/core/agent/tools/webSearch.js +80 -0
  93. package/dist/api/core/agent/tools/writeFile.d.ts +59 -0
  94. package/dist/api/core/agent/tools/writeFile.js +97 -0
  95. package/dist/api/core/agent/utils/capturedWorkspaceMutationBridge.d.ts +12 -0
  96. package/dist/api/core/agent/utils/capturedWorkspaceMutationBridge.js +67 -0
  97. package/dist/api/core/agent/utils/diffUtils.d.ts +14 -0
  98. package/dist/api/core/agent/utils/diffUtils.js +39 -0
  99. package/dist/api/core/agent/utils/environmentSnapshot.d.ts +42 -0
  100. package/dist/api/core/agent/utils/environmentSnapshot.js +213 -0
  101. package/dist/api/core/agent/utils/errorRecovery.d.ts +49 -0
  102. package/dist/api/core/agent/utils/errorRecovery.js +229 -0
  103. package/dist/api/core/agent/utils/multimodalTokenLimiter.d.ts +8 -0
  104. package/dist/api/core/agent/utils/multimodalTokenLimiter.js +238 -0
  105. package/dist/api/core/agent/utils/openRouterModelSettings.d.ts +12 -0
  106. package/dist/api/core/agent/utils/openRouterModelSettings.js +34 -0
  107. package/dist/api/core/agent/utils/pathRecovery.d.ts +1 -0
  108. package/dist/api/core/agent/utils/pathRecovery.js +29 -0
  109. package/dist/api/core/agent/utils/repoMapIndex.d.ts +3 -0
  110. package/dist/api/core/agent/utils/repoMapIndex.js +197 -0
  111. package/dist/api/core/agent/utils/skillsDiscovery.d.ts +10 -0
  112. package/dist/api/core/agent/utils/skillsDiscovery.js +50 -0
  113. package/dist/api/core/agent/utils/toolCallBudget.d.ts +9 -0
  114. package/dist/api/core/agent/utils/toolCallBudget.js +55 -0
  115. package/dist/api/core/agent/utils/toolLifecycle.d.ts +30 -0
  116. package/dist/api/core/agent/utils/toolLifecycle.js +361 -0
  117. package/dist/api/core/agent/utils/toolResultSafetyProcessor.d.ts +12 -0
  118. package/dist/api/core/agent/utils/toolResultSafetyProcessor.js +57 -0
  119. package/dist/api/core/agent/utils/workspaceMutationBridge.d.ts +13 -0
  120. package/dist/api/core/agent/utils/workspaceMutationBridge.js +149 -0
  121. package/dist/api/core/agent/utils/workspacePathGuard.d.ts +7 -0
  122. package/dist/api/core/agent/utils/workspacePathGuard.js +79 -0
  123. package/dist/api/core/containers/chat/toolResultSerialization.d.ts +8 -0
  124. package/dist/api/core/containers/chat/toolResultSerialization.js +71 -0
  125. package/dist/api/core/library/BrowserManager.d.ts +11 -0
  126. package/dist/api/core/library/BrowserManager.js +66 -0
  127. package/dist/api/core/library/desktopWorkspace.d.ts +1 -0
  128. package/dist/api/core/library/desktopWorkspace.js +3 -0
  129. package/dist/api/core/library/extensionManager.d.ts +10 -0
  130. package/dist/api/core/library/extensionManager.js +27 -0
  131. package/dist/api/core/library/knowledgeGraph.d.ts +268 -0
  132. package/dist/api/core/library/knowledgeGraph.js +989 -0
  133. package/dist/api/core/library/languageModelTools.d.ts +141 -0
  134. package/dist/api/core/library/languageModelTools.js +207 -0
  135. package/dist/api/core/library/localRuntime.d.ts +23 -0
  136. package/dist/api/core/library/localRuntime.js +144 -0
  137. package/dist/api/core/library/lsp/coreLsp.d.ts +367 -0
  138. package/dist/api/core/library/lsp/coreLsp.js +2076 -0
  139. package/dist/api/core/library/lsp/protocol.d.ts +25 -0
  140. package/dist/api/core/library/lsp/protocol.js +1 -0
  141. package/dist/api/core/library/lsp/serverManager.d.ts +37 -0
  142. package/dist/api/core/library/lsp/serverManager.js +427 -0
  143. package/dist/api/core/library/mcpServerProvider.d.ts +69 -0
  144. package/dist/api/core/library/mcpServerProvider.js +152 -0
  145. package/dist/api/core/library/mcpSettings.d.ts +20 -0
  146. package/dist/api/core/library/mcpSettings.js +131 -0
  147. package/dist/api/core/library/patternMatcher.d.ts +66 -0
  148. package/dist/api/core/library/patternMatcher.js +284 -0
  149. package/dist/api/core/library/regexEscape.d.ts +4 -0
  150. package/dist/api/core/library/regexEscape.js +4 -0
  151. package/dist/api/core/library/runtimeEventBus.d.ts +27 -0
  152. package/dist/api/core/library/runtimeEventBus.js +78 -0
  153. package/dist/api/core/library/safetyMiddleware.d.ts +98 -0
  154. package/dist/api/core/library/safetyMiddleware.js +215 -0
  155. package/dist/api/core/library/tauri.d.ts +71 -0
  156. package/dist/api/core/library/tauri.js +222 -0
  157. package/dist/api/core/library/tauriImport.d.ts +5 -0
  158. package/dist/api/core/library/tauriImport.js +7 -0
  159. package/dist/api/core/library/terminalAutoApproveSettings.d.ts +32 -0
  160. package/dist/api/core/library/terminalAutoApproveSettings.js +529 -0
  161. package/dist/api/core/library/workspaceIdentity.d.ts +10 -0
  162. package/dist/api/core/library/workspaceIdentity.js +49 -0
  163. package/dist/api/core/library/workspaceSummary.d.ts +19 -0
  164. package/dist/api/core/library/workspaceSummary.js +35 -0
  165. package/dist/api/core/skills/agent-customization/SKILL.md +27 -0
  166. package/dist/api/core/skills/bug-fix/SKILL.md +21 -0
  167. package/dist/api/core/skills/create-pr/SKILL.md +32 -0
  168. package/dist/api/core/skills/dev-server/SKILL.md +20 -0
  169. package/dist/api/core/skills/fix-suggestions/SKILL.md +21 -0
  170. package/dist/api/core/skills/github-search/SKILL.md +21 -0
  171. package/dist/api/core/skills/github-summary/SKILL.md +25 -0
  172. package/dist/api/core/skills/integration-tests/SKILL.md +29 -0
  173. package/dist/api/core/skills/pr-comments/SKILL.md +23 -0
  174. package/dist/api/core/skills/project-setup/SKILL.md +20 -0
  175. package/dist/api/core/skills/search-integration/SKILL.md +19 -0
  176. package/dist/api/core/skills/search-results/SKILL.md +19 -0
  177. package/dist/api/core/skills/typescript-upgrade/SKILL.md +21 -0
  178. package/dist/api/data/runStore.d.ts +46 -0
  179. package/dist/api/data/runStore.js +244 -0
  180. package/dist/api/helpers/agentUtils.d.ts +11 -0
  181. package/dist/api/helpers/agentUtils.js +23 -0
  182. package/dist/api/helpers/modelTokenLimits.d.ts +2 -0
  183. package/dist/api/helpers/modelTokenLimits.js +158 -0
  184. package/dist/api/helpers/observationalMemory.d.ts +10 -0
  185. package/dist/api/helpers/observationalMemory.js +36 -0
  186. package/dist/api/helpers/promptBudget.d.ts +30 -0
  187. package/dist/api/helpers/promptBudget.js +216 -0
  188. package/dist/api/helpers/resolveImageMessageParts.d.ts +9 -0
  189. package/dist/api/helpers/resolveImageMessageParts.js +140 -0
  190. package/dist/api/helpers/slashCommands.d.ts +31 -0
  191. package/dist/api/helpers/slashCommands.js +129 -0
  192. package/dist/api/helpers/tokenUsage.d.ts +19 -0
  193. package/dist/api/helpers/tokenUsage.js +81 -0
  194. package/dist/api/routes/fileRoutes.d.ts +2 -0
  195. package/dist/api/routes/fileRoutes.js +108 -0
  196. package/dist/api/routes/lspDocumentRoutes.d.ts +4 -0
  197. package/dist/api/routes/lspDocumentRoutes.js +84 -0
  198. package/dist/api/routes/lspHierarchyRoutes.d.ts +4 -0
  199. package/dist/api/routes/lspHierarchyRoutes.js +122 -0
  200. package/dist/api/routes/lspPositionRoutes.d.ts +4 -0
  201. package/dist/api/routes/lspPositionRoutes.js +263 -0
  202. package/dist/api/routes/lspQueryRoutes.d.ts +4 -0
  203. package/dist/api/routes/lspQueryRoutes.js +679 -0
  204. package/dist/api/routes/lspResolveRoutes.d.ts +4 -0
  205. package/dist/api/routes/lspResolveRoutes.js +143 -0
  206. package/dist/api/routes/lspSemanticDocumentRoutes.d.ts +4 -0
  207. package/dist/api/routes/lspSemanticDocumentRoutes.js +98 -0
  208. package/dist/api/routes/semanticRoutes.d.ts +2 -0
  209. package/dist/api/routes/semanticRoutes.js +126 -0
  210. package/dist/cli.d.ts +8 -0
  211. package/dist/cli.js +160 -0
  212. package/dist/index.d.ts +1 -0
  213. package/dist/index.js +1 -0
  214. package/dist/server.d.ts +2 -0
  215. package/dist/server.js +38 -0
  216. package/package.json +100 -0
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Get Symbols Tool (LSP-based)
3
+ * Uses Language Server Protocol to extract symbols from a file
4
+ * More accurate than regex-based parsing
5
+ */
6
+ type ParsedSymbol = {
7
+ name: string;
8
+ kind: string;
9
+ line: number;
10
+ character: number;
11
+ endLine: number;
12
+ endCharacter: number;
13
+ detail?: string;
14
+ children?: ParsedSymbol[];
15
+ };
16
+ type FlatSymbol = {
17
+ name: string;
18
+ kind: string;
19
+ line: number;
20
+ detail?: string;
21
+ };
22
+ type SymbolsByKind = Record<string, FlatSymbol[]>;
23
+ type GetSymbolsLSPParams = {
24
+ filePath: string;
25
+ };
26
+ type GetSymbolsLSPResult = {
27
+ success: true;
28
+ filePath: string;
29
+ totalSymbols: number;
30
+ hierarchical: ParsedSymbol[];
31
+ flat: FlatSymbol[];
32
+ byKind: SymbolsByKind;
33
+ summary: Array<{
34
+ kind: string;
35
+ count: number;
36
+ }>;
37
+ } | {
38
+ success: false;
39
+ message?: string;
40
+ error?: string;
41
+ filePath: string;
42
+ };
43
+ declare const getSymbolsLSPTool: {
44
+ name: string;
45
+ description: string;
46
+ parameters: {
47
+ type: string;
48
+ properties: {
49
+ filePath: {
50
+ type: string;
51
+ description: string;
52
+ };
53
+ };
54
+ required: string[];
55
+ };
56
+ execute({ filePath }: GetSymbolsLSPParams): Promise<GetSymbolsLSPResult>;
57
+ };
58
+ export default getSymbolsLSPTool;
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Get Symbols Tool (LSP-based)
3
+ * Uses Language Server Protocol to extract symbols from a file
4
+ * More accurate than regex-based parsing
5
+ */
6
+ import { coreLsp } from "../../library/lsp/coreLsp.js";
7
+ import fs from "fs/promises";
8
+ const getSymbolsLSPTool = {
9
+ name: "getSymbolsLSP",
10
+ description: `Get all symbols (functions, classes, variables, types) from a file using LSP.
11
+ Provides accurate symbol information including:
12
+ - Symbol name and kind (function, class, variable, etc.)
13
+ - Exact location (line, character)
14
+ - Hierarchical structure (nested symbols)
15
+ - More accurate than regex-based parsing
16
+
17
+ Use this for:
18
+ - Understanding file structure
19
+ - Finding all functions/classes
20
+ - Navigation and code exploration
21
+ - Refactoring preparation`,
22
+ parameters: {
23
+ type: "object",
24
+ properties: {
25
+ filePath: {
26
+ type: "string",
27
+ description: "Absolute path to the file to analyze",
28
+ },
29
+ },
30
+ required: ["filePath"],
31
+ },
32
+ async execute({ filePath }) {
33
+ try {
34
+ // Verify file exists
35
+ await fs.access(filePath);
36
+ // Get document symbols from LSP
37
+ const symbolsResult = await coreLsp.getDocumentSymbols(filePath);
38
+ const symbols = symbolsResult;
39
+ if (!symbols || symbols.length === 0) {
40
+ return {
41
+ success: false,
42
+ message: `No symbols found in ${filePath}`,
43
+ filePath,
44
+ };
45
+ }
46
+ // Convert symbol kinds to readable names
47
+ const symbolKindNames = {
48
+ 1: "File",
49
+ 2: "Module",
50
+ 3: "Namespace",
51
+ 4: "Package",
52
+ 5: "Class",
53
+ 6: "Method",
54
+ 7: "Property",
55
+ 8: "Field",
56
+ 9: "Constructor",
57
+ 10: "Enum",
58
+ 11: "Interface",
59
+ 12: "Function",
60
+ 13: "Variable",
61
+ 14: "Constant",
62
+ 15: "String",
63
+ 16: "Number",
64
+ 17: "Boolean",
65
+ 18: "Array",
66
+ 19: "Object",
67
+ 20: "Key",
68
+ 21: "Null",
69
+ 22: "EnumMember",
70
+ 23: "Struct",
71
+ 24: "Event",
72
+ 25: "Operator",
73
+ 26: "TypeParameter",
74
+ };
75
+ // Parse symbols recursively
76
+ const parseSymbol = (symbol) => {
77
+ const range = symbol.range || symbol.location?.range;
78
+ const selectionRange = symbol.selectionRange || range;
79
+ if (!range || !selectionRange) {
80
+ throw new Error("Symbol is missing range information");
81
+ }
82
+ const parsed = {
83
+ name: symbol.name,
84
+ kind: symbolKindNames[symbol.kind] || `Unknown(${symbol.kind})`,
85
+ line: selectionRange.start.line + 1, // Convert to 1-based
86
+ character: selectionRange.start.character + 1,
87
+ endLine: range.end.line + 1,
88
+ endCharacter: range.end.character + 1,
89
+ detail: symbol.detail || undefined,
90
+ };
91
+ // Parse children recursively
92
+ if (symbol.children && symbol.children.length > 0) {
93
+ parsed.children = symbol.children.map(parseSymbol);
94
+ }
95
+ return parsed;
96
+ };
97
+ const parsedSymbols = symbols.map(parseSymbol);
98
+ // Flatten symbols for summary (without children)
99
+ const flattenSymbols = (symbols, prefix = "") => {
100
+ const result = [];
101
+ for (const symbol of symbols) {
102
+ const fullName = prefix ? `${prefix}.${symbol.name}` : symbol.name;
103
+ result.push({
104
+ name: fullName,
105
+ kind: symbol.kind,
106
+ line: symbol.line,
107
+ detail: symbol.detail,
108
+ });
109
+ if (symbol.children) {
110
+ result.push(...flattenSymbols(symbol.children, fullName));
111
+ }
112
+ }
113
+ return result;
114
+ };
115
+ const flatSymbols = flattenSymbols(parsedSymbols);
116
+ // Group by kind
117
+ const symbolsByKind = {};
118
+ flatSymbols.forEach((symbol) => {
119
+ if (!symbolsByKind[symbol.kind]) {
120
+ symbolsByKind[symbol.kind] = [];
121
+ }
122
+ symbolsByKind[symbol.kind].push(symbol);
123
+ });
124
+ return {
125
+ success: true,
126
+ filePath,
127
+ totalSymbols: flatSymbols.length,
128
+ hierarchical: parsedSymbols,
129
+ flat: flatSymbols,
130
+ byKind: symbolsByKind,
131
+ summary: Object.keys(symbolsByKind).map((kind) => ({
132
+ kind,
133
+ count: symbolsByKind[kind].length,
134
+ })),
135
+ };
136
+ }
137
+ catch (error) {
138
+ const err = error;
139
+ return {
140
+ success: false,
141
+ error: err.message,
142
+ filePath,
143
+ };
144
+ }
145
+ },
146
+ };
147
+ export default getSymbolsLSPTool;
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Get Type Information Tool
3
+ * Uses LSP to retrieve type information for a symbol at a specific position
4
+ */
5
+ type HoverRange = {
6
+ start: {
7
+ line: number;
8
+ character: number;
9
+ };
10
+ end: {
11
+ line: number;
12
+ character: number;
13
+ };
14
+ };
15
+ type MarkupContent = {
16
+ value?: string;
17
+ };
18
+ type HoverInfo = {
19
+ contents: string | MarkupContent | Array<string | MarkupContent>;
20
+ range?: HoverRange;
21
+ };
22
+ type GetTypeInfoParams = {
23
+ filePath: string;
24
+ line: number;
25
+ character: number;
26
+ };
27
+ type GetTypeInfoResult = {
28
+ success: true;
29
+ filePath: string;
30
+ position: {
31
+ line: number;
32
+ character: number;
33
+ };
34
+ range?: HoverRange;
35
+ typeInfo: string;
36
+ raw: HoverInfo;
37
+ } | {
38
+ success: false;
39
+ message?: string;
40
+ error?: string;
41
+ filePath: string;
42
+ position: {
43
+ line: number;
44
+ character: number;
45
+ };
46
+ };
47
+ declare const getTypeInfoTool: {
48
+ name: string;
49
+ description: string;
50
+ parameters: {
51
+ type: string;
52
+ properties: {
53
+ filePath: {
54
+ type: string;
55
+ description: string;
56
+ };
57
+ line: {
58
+ type: string;
59
+ description: string;
60
+ };
61
+ character: {
62
+ type: string;
63
+ description: string;
64
+ };
65
+ };
66
+ required: string[];
67
+ };
68
+ execute({ filePath, line, character, }: GetTypeInfoParams): Promise<GetTypeInfoResult>;
69
+ };
70
+ export default getTypeInfoTool;
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Get Type Information Tool
3
+ * Uses LSP to retrieve type information for a symbol at a specific position
4
+ */
5
+ import { coreLsp } from "../../library/lsp/coreLsp.js";
6
+ import fs from "fs/promises";
7
+ const getTypeInfoTool = {
8
+ name: "getTypeInfo",
9
+ description: `Get type information and documentation for a symbol at a specific position in a file.
10
+ Returns hover information including type definitions, function signatures, and documentation.
11
+ Requires line and character position (1-based indexing).
12
+
13
+ Use this when you need to:
14
+ - Understand what type a variable has
15
+ - See function signatures and parameters
16
+ - Read inline documentation
17
+ - Understand API contracts`,
18
+ parameters: {
19
+ type: "object",
20
+ properties: {
21
+ filePath: {
22
+ type: "string",
23
+ description: "Absolute path to the file",
24
+ },
25
+ line: {
26
+ type: "number",
27
+ description: "Line number (1-based) where the symbol is located",
28
+ },
29
+ character: {
30
+ type: "number",
31
+ description: "Character position (1-based) within the line",
32
+ },
33
+ },
34
+ required: ["filePath", "line", "character"],
35
+ },
36
+ async execute({ filePath, line, character, }) {
37
+ try {
38
+ // Verify file exists
39
+ await fs.access(filePath);
40
+ // Get hover information from LSP
41
+ const hoverInfo = (await coreLsp.getHover(filePath, line, character));
42
+ if (!hoverInfo || !hoverInfo.contents) {
43
+ return {
44
+ success: false,
45
+ message: `No type information available at ${filePath}:${line}:${character}`,
46
+ filePath,
47
+ position: { line, character },
48
+ };
49
+ }
50
+ // Extract content (can be string or MarkupContent)
51
+ let content = "";
52
+ if (typeof hoverInfo.contents === "string") {
53
+ content = hoverInfo.contents;
54
+ }
55
+ else if (!Array.isArray(hoverInfo.contents) &&
56
+ hoverInfo.contents.value) {
57
+ content = hoverInfo.contents.value;
58
+ }
59
+ else if (Array.isArray(hoverInfo.contents)) {
60
+ content = hoverInfo.contents
61
+ .map((c) => (typeof c === "string" ? c : c.value || ""))
62
+ .join("\n\n");
63
+ }
64
+ return {
65
+ success: true,
66
+ filePath,
67
+ position: { line, character },
68
+ range: hoverInfo.range,
69
+ typeInfo: content,
70
+ raw: hoverInfo,
71
+ };
72
+ }
73
+ catch (error) {
74
+ const err = error;
75
+ return {
76
+ success: false,
77
+ error: err.message,
78
+ filePath,
79
+ position: { line, character },
80
+ };
81
+ }
82
+ },
83
+ };
84
+ export default getTypeInfoTool;
@@ -0,0 +1,80 @@
1
+ import { z } from "zod";
2
+ type WorkspaceInfoParams = {
3
+ workspacePath?: string;
4
+ includeTree?: boolean;
5
+ maxDepth?: number;
6
+ };
7
+ type GitInfo = {
8
+ isGitRepo: boolean;
9
+ branch?: string;
10
+ remote?: string;
11
+ rootPath?: string;
12
+ hasUncommittedChanges?: boolean;
13
+ uncommittedFiles?: number;
14
+ };
15
+ type PackageInfo = {
16
+ name?: string;
17
+ version?: string;
18
+ description?: string;
19
+ dependencies: string[];
20
+ devDependencies: string[];
21
+ scripts: string[];
22
+ };
23
+ type TreeNode = {
24
+ name: string;
25
+ path: string;
26
+ type: "directory" | "file";
27
+ depth: number;
28
+ children: TreeNode[];
29
+ };
30
+ type TreeStats = {
31
+ totalNodes: number;
32
+ totalFiles: number;
33
+ totalDirectories: number;
34
+ maxDepth: number;
35
+ };
36
+ type WorkspaceInfoResult = {
37
+ success: true;
38
+ workspacePath: string;
39
+ workspaceName: string;
40
+ projectTypes: string[];
41
+ fileCount: number;
42
+ dirCount: number;
43
+ git: GitInfo | null;
44
+ package: PackageInfo | null;
45
+ directoryTree: TreeNode | null;
46
+ treeStats: TreeStats | null;
47
+ } | {
48
+ success: false;
49
+ error: string;
50
+ };
51
+ /**
52
+ * Tool for getting workspace information
53
+ * @param {Object} params - The parameters for getting workspace info
54
+ * @param {string} [params.workspacePath] - The path to the workspace
55
+ * @param {boolean} [params.includeTree] - Whether to include directory tree
56
+ * @param {number} [params.maxDepth] - Maximum depth for directory tree
57
+ * @returns {Promise<Object>} Object containing workspace information or error
58
+ */
59
+ export declare function getWorkspaceInfo({ workspacePath, includeTree, maxDepth, }: WorkspaceInfoParams): Promise<WorkspaceInfoResult>;
60
+ /**
61
+ * Tool metadata for agent system
62
+ */
63
+ export declare const getWorkspaceInfoTool: {
64
+ description: string;
65
+ parameters: z.ZodObject<{
66
+ workspacePath: z.ZodOptional<z.ZodString>;
67
+ includeTree: z.ZodDefault<z.ZodBoolean>;
68
+ maxDepth: z.ZodDefault<z.ZodNumber>;
69
+ }, "strip", z.ZodTypeAny, {
70
+ maxDepth?: number;
71
+ workspacePath?: string;
72
+ includeTree?: boolean;
73
+ }, {
74
+ maxDepth?: number;
75
+ workspacePath?: string;
76
+ includeTree?: boolean;
77
+ }>;
78
+ execute: typeof getWorkspaceInfo;
79
+ };
80
+ export default getWorkspaceInfoTool;