@google/gemini-cli-core 0.1.15 → 0.1.16

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 (222) hide show
  1. package/README.md +32 -0
  2. package/dist/google-gemini-cli-core-0.1.15.tgz +0 -0
  3. package/dist/src/code_assist/converter.d.ts +2 -1
  4. package/dist/src/code_assist/converter.js +2 -1
  5. package/dist/src/code_assist/converter.js.map +1 -1
  6. package/dist/src/code_assist/converter.test.js +13 -10
  7. package/dist/src/code_assist/converter.test.js.map +1 -1
  8. package/dist/src/code_assist/server.d.ts +2 -2
  9. package/dist/src/code_assist/server.js +4 -4
  10. package/dist/src/code_assist/server.js.map +1 -1
  11. package/dist/src/code_assist/server.test.js +9 -9
  12. package/dist/src/code_assist/server.test.js.map +1 -1
  13. package/dist/src/code_assist/setup.js +1 -1
  14. package/dist/src/code_assist/setup.js.map +1 -1
  15. package/dist/src/code_assist/setup.test.js +2 -2
  16. package/dist/src/code_assist/setup.test.js.map +1 -1
  17. package/dist/src/config/config.d.ts +19 -7
  18. package/dist/src/config/config.js +37 -13
  19. package/dist/src/config/config.js.map +1 -1
  20. package/dist/src/config/config.test.js +33 -0
  21. package/dist/src/config/config.test.js.map +1 -1
  22. package/dist/src/config/flashFallback.test.js +23 -47
  23. package/dist/src/config/flashFallback.test.js.map +1 -1
  24. package/dist/src/config/models.d.ts +1 -0
  25. package/dist/src/config/models.js +1 -0
  26. package/dist/src/config/models.js.map +1 -1
  27. package/dist/src/core/client.d.ts +3 -1
  28. package/dist/src/core/client.js +74 -23
  29. package/dist/src/core/client.js.map +1 -1
  30. package/dist/src/core/client.test.js +167 -21
  31. package/dist/src/core/client.test.js.map +1 -1
  32. package/dist/src/core/contentGenerator.d.ts +2 -2
  33. package/dist/src/core/contentGenerator.js.map +1 -1
  34. package/dist/src/core/coreToolScheduler.d.ts +1 -3
  35. package/dist/src/core/coreToolScheduler.js +25 -16
  36. package/dist/src/core/coreToolScheduler.js.map +1 -1
  37. package/dist/src/core/coreToolScheduler.test.js +76 -1
  38. package/dist/src/core/coreToolScheduler.test.js.map +1 -1
  39. package/dist/src/core/geminiChat.js +3 -2
  40. package/dist/src/core/geminiChat.js.map +1 -1
  41. package/dist/src/core/geminiChat.test.js +2 -2
  42. package/dist/src/core/geminiChat.test.js.map +1 -1
  43. package/dist/src/core/logger.d.ts +1 -0
  44. package/dist/src/core/logger.js +22 -8
  45. package/dist/src/core/logger.js.map +1 -1
  46. package/dist/src/core/logger.test.js +60 -9
  47. package/dist/src/core/logger.test.js.map +1 -1
  48. package/dist/src/core/nonInteractiveToolExecutor.js +11 -3
  49. package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -1
  50. package/dist/src/core/prompts.js +1 -1
  51. package/dist/src/core/tokenLimits.js +1 -0
  52. package/dist/src/core/tokenLimits.js.map +1 -1
  53. package/dist/src/core/turn.d.ts +3 -0
  54. package/dist/src/core/turn.js +3 -0
  55. package/dist/src/core/turn.js.map +1 -1
  56. package/dist/src/ide/detect-ide.d.ts +10 -0
  57. package/dist/src/ide/detect-ide.js +24 -0
  58. package/dist/src/ide/detect-ide.js.map +1 -0
  59. package/dist/src/ide/ide-client.d.ts +19 -7
  60. package/dist/src/ide/ide-client.js +100 -36
  61. package/dist/src/ide/ide-client.js.map +1 -1
  62. package/dist/src/ide/ide-installer.d.ts +15 -0
  63. package/dist/src/ide/ide-installer.js +111 -0
  64. package/dist/src/ide/ide-installer.js.map +1 -0
  65. package/dist/src/ide/ide-installer.test.d.ts +6 -0
  66. package/dist/src/ide/ide-installer.test.js +78 -0
  67. package/dist/src/ide/ide-installer.test.js.map +1 -0
  68. package/dist/src/ide/ideContext.d.ts +212 -107
  69. package/dist/src/ide/ideContext.js +45 -44
  70. package/dist/src/ide/ideContext.js.map +1 -1
  71. package/dist/src/ide/ideContext.test.js +254 -100
  72. package/dist/src/ide/ideContext.test.js.map +1 -1
  73. package/dist/src/index.d.ts +4 -0
  74. package/dist/src/index.js +4 -0
  75. package/dist/src/index.js.map +1 -1
  76. package/dist/src/mcp/oauth-provider.js +3 -3
  77. package/dist/src/mcp/oauth-provider.js.map +1 -1
  78. package/dist/src/mcp/oauth-provider.test.js +9 -8
  79. package/dist/src/mcp/oauth-provider.test.js.map +1 -1
  80. package/dist/src/mcp/oauth-utils.js +2 -2
  81. package/dist/src/mcp/oauth-utils.js.map +1 -1
  82. package/dist/src/mcp/oauth-utils.test.js +1 -1
  83. package/dist/src/mcp/oauth-utils.test.js.map +1 -1
  84. package/dist/src/services/loopDetectionService.d.ts +3 -0
  85. package/dist/src/services/loopDetectionService.js +18 -0
  86. package/dist/src/services/loopDetectionService.js.map +1 -1
  87. package/dist/src/services/loopDetectionService.test.js +90 -11
  88. package/dist/src/services/loopDetectionService.test.js.map +1 -1
  89. package/dist/src/services/shellExecutionService.js +7 -4
  90. package/dist/src/services/shellExecutionService.js.map +1 -1
  91. package/dist/src/services/shellExecutionService.test.js +11 -5
  92. package/dist/src/services/shellExecutionService.test.js.map +1 -1
  93. package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +4 -2
  94. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +80 -34
  95. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
  96. package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +6 -1
  97. package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +19 -0
  98. package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
  99. package/dist/src/telemetry/constants.d.ts +2 -1
  100. package/dist/src/telemetry/constants.js +2 -1
  101. package/dist/src/telemetry/constants.js.map +1 -1
  102. package/dist/src/telemetry/index.d.ts +2 -2
  103. package/dist/src/telemetry/index.js +2 -2
  104. package/dist/src/telemetry/index.js.map +1 -1
  105. package/dist/src/telemetry/loggers.d.ts +3 -2
  106. package/dist/src/telemetry/loggers.js +21 -5
  107. package/dist/src/telemetry/loggers.js.map +1 -1
  108. package/dist/src/telemetry/loggers.test.circular.js +2 -0
  109. package/dist/src/telemetry/loggers.test.circular.js.map +1 -1
  110. package/dist/src/telemetry/loggers.test.js +8 -3
  111. package/dist/src/telemetry/loggers.test.js.map +1 -1
  112. package/dist/src/telemetry/telemetry.test.js +2 -0
  113. package/dist/src/telemetry/telemetry.test.js.map +1 -1
  114. package/dist/src/telemetry/types.d.ts +19 -4
  115. package/dist/src/telemetry/types.js +30 -4
  116. package/dist/src/telemetry/types.js.map +1 -1
  117. package/dist/src/telemetry/uiTelemetry.test.js +3 -0
  118. package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
  119. package/dist/src/test-utils/mockWorkspaceContext.d.ts +13 -0
  120. package/dist/src/test-utils/mockWorkspaceContext.js +24 -0
  121. package/dist/src/test-utils/mockWorkspaceContext.js.map +1 -0
  122. package/dist/src/tools/edit.js +27 -3
  123. package/dist/src/tools/edit.js.map +1 -1
  124. package/dist/src/tools/edit.test.js +104 -1
  125. package/dist/src/tools/edit.test.js.map +1 -1
  126. package/dist/src/tools/glob.js +53 -17
  127. package/dist/src/tools/glob.js.map +1 -1
  128. package/dist/src/tools/glob.test.js +25 -2
  129. package/dist/src/tools/glob.test.js.map +1 -1
  130. package/dist/src/tools/grep.d.ts +1 -1
  131. package/dist/src/tools/grep.js +81 -29
  132. package/dist/src/tools/grep.js.map +1 -1
  133. package/dist/src/tools/grep.test.js +72 -5
  134. package/dist/src/tools/grep.test.js.map +1 -1
  135. package/dist/src/tools/ls.js +4 -3
  136. package/dist/src/tools/ls.js.map +1 -1
  137. package/dist/src/tools/ls.test.d.ts +6 -0
  138. package/dist/src/tools/ls.test.js +356 -0
  139. package/dist/src/tools/ls.test.js.map +1 -0
  140. package/dist/src/tools/mcp-client.js +8 -14
  141. package/dist/src/tools/mcp-client.js.map +1 -1
  142. package/dist/src/tools/mcp-client.test.js +34 -0
  143. package/dist/src/tools/mcp-client.test.js.map +1 -1
  144. package/dist/src/tools/memoryTool.d.ts +17 -2
  145. package/dist/src/tools/memoryTool.js +130 -13
  146. package/dist/src/tools/memoryTool.js.map +1 -1
  147. package/dist/src/tools/memoryTool.test.js +88 -3
  148. package/dist/src/tools/memoryTool.test.js.map +1 -1
  149. package/dist/src/tools/read-file.js +8 -6
  150. package/dist/src/tools/read-file.js.map +1 -1
  151. package/dist/src/tools/read-file.test.js +30 -2
  152. package/dist/src/tools/read-file.test.js.map +1 -1
  153. package/dist/src/tools/read-many-files.js +22 -12
  154. package/dist/src/tools/read-many-files.js.map +1 -1
  155. package/dist/src/tools/read-many-files.test.js +35 -2
  156. package/dist/src/tools/read-many-files.test.js.map +1 -1
  157. package/dist/src/tools/shell.js +8 -4
  158. package/dist/src/tools/shell.js.map +1 -1
  159. package/dist/src/tools/shell.test.js +33 -1
  160. package/dist/src/tools/shell.test.js.map +1 -1
  161. package/dist/src/tools/tool-error.d.ts +22 -0
  162. package/dist/src/tools/tool-error.js +27 -0
  163. package/dist/src/tools/tool-error.js.map +1 -0
  164. package/dist/src/tools/tool-registry.test.js +8 -0
  165. package/dist/src/tools/tool-registry.test.js.map +1 -1
  166. package/dist/src/tools/tools.d.ts +8 -0
  167. package/dist/src/tools/tools.js.map +1 -1
  168. package/dist/src/tools/write-file.js +5 -3
  169. package/dist/src/tools/write-file.js.map +1 -1
  170. package/dist/src/tools/write-file.test.js +36 -2
  171. package/dist/src/tools/write-file.test.js.map +1 -1
  172. package/dist/src/utils/bfsFileSearch.js +51 -27
  173. package/dist/src/utils/bfsFileSearch.js.map +1 -1
  174. package/dist/src/utils/bfsFileSearch.test.js +59 -0
  175. package/dist/src/utils/bfsFileSearch.test.js.map +1 -1
  176. package/dist/src/utils/editCorrector.js +2 -2
  177. package/dist/src/utils/editCorrector.js.map +1 -1
  178. package/dist/src/utils/editor.d.ts +1 -1
  179. package/dist/src/utils/editor.js +9 -0
  180. package/dist/src/utils/editor.js.map +1 -1
  181. package/dist/src/utils/editor.test.js +21 -1
  182. package/dist/src/utils/editor.test.js.map +1 -1
  183. package/dist/src/utils/fileUtils.js +12 -1
  184. package/dist/src/utils/fileUtils.js.map +1 -1
  185. package/dist/src/utils/fileUtils.test.js +29 -1
  186. package/dist/src/utils/fileUtils.test.js.map +1 -1
  187. package/dist/src/utils/flashFallback.integration.test.js +8 -0
  188. package/dist/src/utils/flashFallback.integration.test.js.map +1 -1
  189. package/dist/src/utils/memoryDiscovery.d.ts +1 -1
  190. package/dist/src/utils/memoryDiscovery.js +54 -75
  191. package/dist/src/utils/memoryDiscovery.js.map +1 -1
  192. package/dist/src/utils/memoryDiscovery.test.js +4 -3
  193. package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
  194. package/dist/src/utils/memoryImportProcessor.d.ts +19 -12
  195. package/dist/src/utils/memoryImportProcessor.js +241 -82
  196. package/dist/src/utils/memoryImportProcessor.js.map +1 -1
  197. package/dist/src/utils/memoryImportProcessor.test.js +595 -50
  198. package/dist/src/utils/memoryImportProcessor.test.js.map +1 -1
  199. package/dist/src/utils/nextSpeakerChecker.js +3 -23
  200. package/dist/src/utils/nextSpeakerChecker.js.map +1 -1
  201. package/dist/src/utils/nextSpeakerChecker.test.js +2 -2
  202. package/dist/src/utils/nextSpeakerChecker.test.js.map +1 -1
  203. package/dist/src/utils/retry.d.ts +3 -0
  204. package/dist/src/utils/retry.js.map +1 -1
  205. package/dist/src/utils/retry.test.js.map +1 -1
  206. package/dist/src/utils/secure-browser-launcher.d.ts +23 -0
  207. package/dist/src/utils/secure-browser-launcher.js +164 -0
  208. package/dist/src/utils/secure-browser-launcher.js.map +1 -0
  209. package/dist/src/utils/secure-browser-launcher.test.d.ts +6 -0
  210. package/dist/src/utils/secure-browser-launcher.test.js +149 -0
  211. package/dist/src/utils/secure-browser-launcher.test.js.map +1 -0
  212. package/dist/src/utils/summarizer.js +2 -2
  213. package/dist/src/utils/summarizer.js.map +1 -1
  214. package/dist/src/utils/workspaceContext.d.ts +47 -0
  215. package/dist/src/utils/workspaceContext.js +106 -0
  216. package/dist/src/utils/workspaceContext.js.map +1 -0
  217. package/dist/src/utils/workspaceContext.test.d.ts +6 -0
  218. package/dist/src/utils/workspaceContext.test.js +209 -0
  219. package/dist/src/utils/workspaceContext.test.js.map +1 -0
  220. package/dist/tsconfig.tsbuildinfo +1 -1
  221. package/package.json +2 -1
  222. package/dist/google-gemini-cli-core-0.1.13.tgz +0 -0
@@ -5,24 +5,12 @@
5
5
  */
6
6
  import { z } from 'zod';
7
7
  /**
8
- * Zod schema for validating a cursor position.
8
+ * Zod schema for validating a file context from the IDE.
9
9
  */
10
- export declare const CursorSchema: z.ZodObject<{
11
- line: z.ZodNumber;
12
- character: z.ZodNumber;
13
- }, "strip", z.ZodTypeAny, {
14
- line: number;
15
- character: number;
16
- }, {
17
- line: number;
18
- character: number;
19
- }>;
20
- export type Cursor = z.infer<typeof CursorSchema>;
21
- /**
22
- * Zod schema for validating an active file context from the IDE.
23
- */
24
- export declare const OpenFilesSchema: z.ZodObject<{
25
- activeFile: z.ZodString;
10
+ export declare const FileSchema: z.ZodObject<{
11
+ path: z.ZodString;
12
+ timestamp: z.ZodNumber;
13
+ isActive: z.ZodOptional<z.ZodBoolean>;
26
14
  selectedText: z.ZodOptional<z.ZodString>;
27
15
  cursor: z.ZodOptional<z.ZodObject<{
28
16
  line: z.ZodNumber;
@@ -34,141 +22,258 @@ export declare const OpenFilesSchema: z.ZodObject<{
34
22
  line: number;
35
23
  character: number;
36
24
  }>>;
37
- recentOpenFiles: z.ZodOptional<z.ZodArray<z.ZodObject<{
38
- filePath: z.ZodString;
39
- timestamp: z.ZodNumber;
40
- }, "strip", z.ZodTypeAny, {
41
- filePath: string;
42
- timestamp: number;
43
- }, {
44
- filePath: string;
45
- timestamp: number;
46
- }>, "many">>;
47
25
  }, "strip", z.ZodTypeAny, {
48
- activeFile: string;
26
+ path: string;
27
+ timestamp: number;
49
28
  cursor?: {
50
29
  line: number;
51
30
  character: number;
52
31
  } | undefined;
32
+ isActive?: boolean | undefined;
53
33
  selectedText?: string | undefined;
54
- recentOpenFiles?: {
55
- filePath: string;
56
- timestamp: number;
57
- }[] | undefined;
58
34
  }, {
59
- activeFile: string;
35
+ path: string;
36
+ timestamp: number;
60
37
  cursor?: {
61
38
  line: number;
62
39
  character: number;
63
40
  } | undefined;
41
+ isActive?: boolean | undefined;
64
42
  selectedText?: string | undefined;
65
- recentOpenFiles?: {
66
- filePath: string;
67
- timestamp: number;
68
- }[] | undefined;
69
43
  }>;
70
- export type OpenFiles = z.infer<typeof OpenFilesSchema>;
71
- /**
72
- * Zod schema for validating the 'ide/openFilesChanged' notification from the IDE.
73
- */
74
- export declare const OpenFilesNotificationSchema: z.ZodObject<{
75
- method: z.ZodLiteral<"ide/openFilesChanged">;
76
- params: z.ZodObject<{
77
- activeFile: z.ZodString;
78
- selectedText: z.ZodOptional<z.ZodString>;
79
- cursor: z.ZodOptional<z.ZodObject<{
80
- line: z.ZodNumber;
81
- character: z.ZodNumber;
82
- }, "strip", z.ZodTypeAny, {
83
- line: number;
84
- character: number;
85
- }, {
86
- line: number;
87
- character: number;
88
- }>>;
89
- recentOpenFiles: z.ZodOptional<z.ZodArray<z.ZodObject<{
90
- filePath: z.ZodString;
44
+ export type File = z.infer<typeof FileSchema>;
45
+ export declare const IdeContextSchema: z.ZodObject<{
46
+ workspaceState: z.ZodOptional<z.ZodObject<{
47
+ openFiles: z.ZodOptional<z.ZodArray<z.ZodObject<{
48
+ path: z.ZodString;
91
49
  timestamp: z.ZodNumber;
50
+ isActive: z.ZodOptional<z.ZodBoolean>;
51
+ selectedText: z.ZodOptional<z.ZodString>;
52
+ cursor: z.ZodOptional<z.ZodObject<{
53
+ line: z.ZodNumber;
54
+ character: z.ZodNumber;
55
+ }, "strip", z.ZodTypeAny, {
56
+ line: number;
57
+ character: number;
58
+ }, {
59
+ line: number;
60
+ character: number;
61
+ }>>;
92
62
  }, "strip", z.ZodTypeAny, {
93
- filePath: string;
63
+ path: string;
94
64
  timestamp: number;
65
+ cursor?: {
66
+ line: number;
67
+ character: number;
68
+ } | undefined;
69
+ isActive?: boolean | undefined;
70
+ selectedText?: string | undefined;
95
71
  }, {
96
- filePath: string;
72
+ path: string;
97
73
  timestamp: number;
74
+ cursor?: {
75
+ line: number;
76
+ character: number;
77
+ } | undefined;
78
+ isActive?: boolean | undefined;
79
+ selectedText?: string | undefined;
98
80
  }>, "many">>;
99
81
  }, "strip", z.ZodTypeAny, {
100
- activeFile: string;
101
- cursor?: {
102
- line: number;
103
- character: number;
104
- } | undefined;
105
- selectedText?: string | undefined;
106
- recentOpenFiles?: {
107
- filePath: string;
82
+ openFiles?: {
83
+ path: string;
108
84
  timestamp: number;
85
+ cursor?: {
86
+ line: number;
87
+ character: number;
88
+ } | undefined;
89
+ isActive?: boolean | undefined;
90
+ selectedText?: string | undefined;
109
91
  }[] | undefined;
110
92
  }, {
111
- activeFile: string;
112
- cursor?: {
113
- line: number;
114
- character: number;
115
- } | undefined;
116
- selectedText?: string | undefined;
117
- recentOpenFiles?: {
118
- filePath: string;
93
+ openFiles?: {
94
+ path: string;
119
95
  timestamp: number;
96
+ cursor?: {
97
+ line: number;
98
+ character: number;
99
+ } | undefined;
100
+ isActive?: boolean | undefined;
101
+ selectedText?: string | undefined;
120
102
  }[] | undefined;
103
+ }>>;
104
+ }, "strip", z.ZodTypeAny, {
105
+ workspaceState?: {
106
+ openFiles?: {
107
+ path: string;
108
+ timestamp: number;
109
+ cursor?: {
110
+ line: number;
111
+ character: number;
112
+ } | undefined;
113
+ isActive?: boolean | undefined;
114
+ selectedText?: string | undefined;
115
+ }[] | undefined;
116
+ } | undefined;
117
+ }, {
118
+ workspaceState?: {
119
+ openFiles?: {
120
+ path: string;
121
+ timestamp: number;
122
+ cursor?: {
123
+ line: number;
124
+ character: number;
125
+ } | undefined;
126
+ isActive?: boolean | undefined;
127
+ selectedText?: string | undefined;
128
+ }[] | undefined;
129
+ } | undefined;
130
+ }>;
131
+ export type IdeContext = z.infer<typeof IdeContextSchema>;
132
+ /**
133
+ * Zod schema for validating the 'ide/contextUpdate' notification from the IDE.
134
+ */
135
+ export declare const IdeContextNotificationSchema: z.ZodObject<{
136
+ method: z.ZodLiteral<"ide/contextUpdate">;
137
+ params: z.ZodObject<{
138
+ workspaceState: z.ZodOptional<z.ZodObject<{
139
+ openFiles: z.ZodOptional<z.ZodArray<z.ZodObject<{
140
+ path: z.ZodString;
141
+ timestamp: z.ZodNumber;
142
+ isActive: z.ZodOptional<z.ZodBoolean>;
143
+ selectedText: z.ZodOptional<z.ZodString>;
144
+ cursor: z.ZodOptional<z.ZodObject<{
145
+ line: z.ZodNumber;
146
+ character: z.ZodNumber;
147
+ }, "strip", z.ZodTypeAny, {
148
+ line: number;
149
+ character: number;
150
+ }, {
151
+ line: number;
152
+ character: number;
153
+ }>>;
154
+ }, "strip", z.ZodTypeAny, {
155
+ path: string;
156
+ timestamp: number;
157
+ cursor?: {
158
+ line: number;
159
+ character: number;
160
+ } | undefined;
161
+ isActive?: boolean | undefined;
162
+ selectedText?: string | undefined;
163
+ }, {
164
+ path: string;
165
+ timestamp: number;
166
+ cursor?: {
167
+ line: number;
168
+ character: number;
169
+ } | undefined;
170
+ isActive?: boolean | undefined;
171
+ selectedText?: string | undefined;
172
+ }>, "many">>;
173
+ }, "strip", z.ZodTypeAny, {
174
+ openFiles?: {
175
+ path: string;
176
+ timestamp: number;
177
+ cursor?: {
178
+ line: number;
179
+ character: number;
180
+ } | undefined;
181
+ isActive?: boolean | undefined;
182
+ selectedText?: string | undefined;
183
+ }[] | undefined;
184
+ }, {
185
+ openFiles?: {
186
+ path: string;
187
+ timestamp: number;
188
+ cursor?: {
189
+ line: number;
190
+ character: number;
191
+ } | undefined;
192
+ isActive?: boolean | undefined;
193
+ selectedText?: string | undefined;
194
+ }[] | undefined;
195
+ }>>;
196
+ }, "strip", z.ZodTypeAny, {
197
+ workspaceState?: {
198
+ openFiles?: {
199
+ path: string;
200
+ timestamp: number;
201
+ cursor?: {
202
+ line: number;
203
+ character: number;
204
+ } | undefined;
205
+ isActive?: boolean | undefined;
206
+ selectedText?: string | undefined;
207
+ }[] | undefined;
208
+ } | undefined;
209
+ }, {
210
+ workspaceState?: {
211
+ openFiles?: {
212
+ path: string;
213
+ timestamp: number;
214
+ cursor?: {
215
+ line: number;
216
+ character: number;
217
+ } | undefined;
218
+ isActive?: boolean | undefined;
219
+ selectedText?: string | undefined;
220
+ }[] | undefined;
221
+ } | undefined;
121
222
  }>;
122
223
  }, "strip", z.ZodTypeAny, {
123
- method: "ide/openFilesChanged";
224
+ method: "ide/contextUpdate";
124
225
  params: {
125
- activeFile: string;
126
- cursor?: {
127
- line: number;
128
- character: number;
226
+ workspaceState?: {
227
+ openFiles?: {
228
+ path: string;
229
+ timestamp: number;
230
+ cursor?: {
231
+ line: number;
232
+ character: number;
233
+ } | undefined;
234
+ isActive?: boolean | undefined;
235
+ selectedText?: string | undefined;
236
+ }[] | undefined;
129
237
  } | undefined;
130
- selectedText?: string | undefined;
131
- recentOpenFiles?: {
132
- filePath: string;
133
- timestamp: number;
134
- }[] | undefined;
135
238
  };
136
239
  }, {
137
- method: "ide/openFilesChanged";
240
+ method: "ide/contextUpdate";
138
241
  params: {
139
- activeFile: string;
140
- cursor?: {
141
- line: number;
142
- character: number;
242
+ workspaceState?: {
243
+ openFiles?: {
244
+ path: string;
245
+ timestamp: number;
246
+ cursor?: {
247
+ line: number;
248
+ character: number;
249
+ } | undefined;
250
+ isActive?: boolean | undefined;
251
+ selectedText?: string | undefined;
252
+ }[] | undefined;
143
253
  } | undefined;
144
- selectedText?: string | undefined;
145
- recentOpenFiles?: {
146
- filePath: string;
147
- timestamp: number;
148
- }[] | undefined;
149
254
  };
150
255
  }>;
151
- type OpenFilesSubscriber = (openFiles: OpenFiles | undefined) => void;
256
+ type IdeContextSubscriber = (ideContext: IdeContext | undefined) => void;
152
257
  /**
153
- * Creates a new store for managing the IDE's active file context.
258
+ * Creates a new store for managing the IDE's context.
154
259
  * This factory function encapsulates the state and logic, allowing for the creation
155
260
  * of isolated instances, which is particularly useful for testing.
156
261
  *
157
- * @returns An object with methods to interact with the active file context.
262
+ * @returns An object with methods to interact with the IDE context.
158
263
  */
159
264
  export declare function createIdeContextStore(): {
160
- setOpenFilesContext: (newOpenFiles: OpenFiles) => void;
161
- getOpenFilesContext: () => OpenFiles | undefined;
162
- subscribeToOpenFiles: (subscriber: OpenFilesSubscriber) => () => void;
163
- clearOpenFilesContext: () => void;
265
+ setIdeContext: (newIdeContext: IdeContext) => void;
266
+ getIdeContext: () => IdeContext | undefined;
267
+ subscribeToIdeContext: (subscriber: IdeContextSubscriber) => () => void;
268
+ clearIdeContext: () => void;
164
269
  };
165
270
  /**
166
271
  * The default, shared instance of the IDE context store for the application.
167
272
  */
168
273
  export declare const ideContext: {
169
- setOpenFilesContext: (newOpenFiles: OpenFiles) => void;
170
- getOpenFilesContext: () => OpenFiles | undefined;
171
- subscribeToOpenFiles: (subscriber: OpenFilesSubscriber) => () => void;
172
- clearOpenFilesContext: () => void;
274
+ setIdeContext: (newIdeContext: IdeContext) => void;
275
+ getIdeContext: () => IdeContext | undefined;
276
+ subscribeToIdeContext: (subscriber: IdeContextSubscriber) => () => void;
277
+ clearIdeContext: () => void;
173
278
  };
174
279
  export {};
@@ -5,93 +5,94 @@
5
5
  */
6
6
  import { z } from 'zod';
7
7
  /**
8
- * Zod schema for validating a cursor position.
8
+ * Zod schema for validating a file context from the IDE.
9
9
  */
10
- export const CursorSchema = z.object({
11
- line: z.number(),
12
- character: z.number(),
13
- });
14
- /**
15
- * Zod schema for validating an active file context from the IDE.
16
- */
17
- export const OpenFilesSchema = z.object({
18
- activeFile: z.string(),
10
+ export const FileSchema = z.object({
11
+ path: z.string(),
12
+ timestamp: z.number(),
13
+ isActive: z.boolean().optional(),
19
14
  selectedText: z.string().optional(),
20
- cursor: CursorSchema.optional(),
21
- recentOpenFiles: z
22
- .array(z.object({
23
- filePath: z.string(),
24
- timestamp: z.number(),
25
- }))
15
+ cursor: z
16
+ .object({
17
+ line: z.number(),
18
+ character: z.number(),
19
+ })
20
+ .optional(),
21
+ });
22
+ export const IdeContextSchema = z.object({
23
+ workspaceState: z
24
+ .object({
25
+ openFiles: z.array(FileSchema).optional(),
26
+ })
26
27
  .optional(),
27
28
  });
28
29
  /**
29
- * Zod schema for validating the 'ide/openFilesChanged' notification from the IDE.
30
+ * Zod schema for validating the 'ide/contextUpdate' notification from the IDE.
30
31
  */
31
- export const OpenFilesNotificationSchema = z.object({
32
- method: z.literal('ide/openFilesChanged'),
33
- params: OpenFilesSchema,
32
+ export const IdeContextNotificationSchema = z.object({
33
+ method: z.literal('ide/contextUpdate'),
34
+ params: IdeContextSchema,
34
35
  });
35
36
  /**
36
- * Creates a new store for managing the IDE's active file context.
37
+ * Creates a new store for managing the IDE's context.
37
38
  * This factory function encapsulates the state and logic, allowing for the creation
38
39
  * of isolated instances, which is particularly useful for testing.
39
40
  *
40
- * @returns An object with methods to interact with the active file context.
41
+ * @returns An object with methods to interact with the IDE context.
41
42
  */
42
43
  export function createIdeContextStore() {
43
- let openFilesContext = undefined;
44
+ let ideContextState = undefined;
44
45
  const subscribers = new Set();
45
46
  /**
46
- * Notifies all registered subscribers about the current active file context.
47
+ * Notifies all registered subscribers about the current IDE context.
47
48
  */
48
49
  function notifySubscribers() {
49
50
  for (const subscriber of subscribers) {
50
- subscriber(openFilesContext);
51
+ subscriber(ideContextState);
51
52
  }
52
53
  }
53
54
  /**
54
- * Sets the active file context and notifies all registered subscribers of the change.
55
- * @param newOpenFiles The new active file context from the IDE.
55
+ * Sets the IDE context and notifies all registered subscribers of the change.
56
+ * @param newIdeContext The new IDE context from the IDE.
56
57
  */
57
- function setOpenFilesContext(newOpenFiles) {
58
- openFilesContext = newOpenFiles;
58
+ function setIdeContext(newIdeContext) {
59
+ ideContextState = newIdeContext;
59
60
  notifySubscribers();
60
61
  }
61
62
  /**
62
- * Clears the active file context and notifies all registered subscribers of the change.
63
+ * Clears the IDE context and notifies all registered subscribers of the change.
63
64
  */
64
- function clearOpenFilesContext() {
65
- openFilesContext = undefined;
65
+ function clearIdeContext() {
66
+ ideContextState = undefined;
66
67
  notifySubscribers();
67
68
  }
68
69
  /**
69
- * Retrieves the current active file context.
70
- * @returns The `OpenFiles` object if a file is active; otherwise, `undefined`.
70
+ * Retrieves the current IDE context.
71
+ * @returns The `IdeContext` object if a file is active; otherwise, `undefined`.
71
72
  */
72
- function getOpenFilesContext() {
73
- return openFilesContext;
73
+ function getIdeContext() {
74
+ return ideContextState;
74
75
  }
75
76
  /**
76
- * Subscribes to changes in the active file context.
77
+ * Subscribes to changes in the IDE context.
77
78
  *
78
- * When the active file context changes, the provided `subscriber` function will be called.
79
+ * When the IDE context changes, the provided `subscriber` function will be called.
79
80
  * Note: The subscriber is not called with the current value upon subscription.
80
81
  *
81
- * @param subscriber The function to be called when the active file context changes.
82
+ * @param subscriber The function to be called when the IDE context changes.
82
83
  * @returns A function that, when called, will unsubscribe the provided subscriber.
83
84
  */
84
- function subscribeToOpenFiles(subscriber) {
85
+ function subscribeToIdeContext(subscriber) {
85
86
  subscribers.add(subscriber);
86
87
  return () => {
87
88
  subscribers.delete(subscriber);
88
89
  };
89
90
  }
90
91
  return {
91
- setOpenFilesContext,
92
- getOpenFilesContext,
93
- subscribeToOpenFiles,
94
- clearOpenFilesContext,
92
+ setIdeContext,
93
+ getIdeContext,
94
+ subscribeToIdeContext,
95
+ clearIdeContext,
95
96
  };
96
97
  }
97
98
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ideContext.js","sourceRoot":"","sources":["../../../src/ide/ideContext.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;CACtB,CAAC,CAAC;AAGH;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,C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