farmon 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 (106) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +163 -0
  3. package/dist/bin/farmon.js +12 -0
  4. package/dist/bin/farmon.js.map +1 -0
  5. package/dist/execute/agents/index.js +19 -0
  6. package/dist/execute/agents/index.js.map +1 -0
  7. package/dist/execute/agents/instruction-classifier-agent.js +16 -0
  8. package/dist/execute/agents/instruction-classifier-agent.js.map +1 -0
  9. package/dist/execute/agents/mutation-agent.js +272 -0
  10. package/dist/execute/agents/mutation-agent.js.map +1 -0
  11. package/dist/execute/agents/query-agent.js +118 -0
  12. package/dist/execute/agents/query-agent.js.map +1 -0
  13. package/dist/execute/helpers/analyzers.js +8 -0
  14. package/dist/execute/helpers/analyzers.js.map +1 -0
  15. package/dist/execute/helpers/ensurers.js +1053 -0
  16. package/dist/execute/helpers/ensurers.js.map +1 -0
  17. package/dist/execute/helpers/finders.js +1454 -0
  18. package/dist/execute/helpers/finders.js.map +1 -0
  19. package/dist/execute/helpers/general.js +3736 -0
  20. package/dist/execute/helpers/general.js.map +1 -0
  21. package/dist/execute/helpers/import-helpers.js +183 -0
  22. package/dist/execute/helpers/import-helpers.js.map +1 -0
  23. package/dist/execute/helpers/parsers.js +840 -0
  24. package/dist/execute/helpers/parsers.js.map +1 -0
  25. package/dist/execute/helpers/prompt-maker.js +1163 -0
  26. package/dist/execute/helpers/prompt-maker.js.map +1 -0
  27. package/dist/execute/helpers/validators.js +40 -0
  28. package/dist/execute/helpers/validators.js.map +1 -0
  29. package/dist/execute/history/history-manager.js +1030 -0
  30. package/dist/execute/history/history-manager.js.map +1 -0
  31. package/dist/execute/history/rollback-handlers.js +2524 -0
  32. package/dist/execute/history/rollback-handlers.js.map +1 -0
  33. package/dist/execute/index.js +44 -0
  34. package/dist/execute/index.js.map +1 -0
  35. package/dist/execute/llm/call.js +103 -0
  36. package/dist/execute/llm/call.js.map +1 -0
  37. package/dist/execute/tasks/ast.js +3819 -0
  38. package/dist/execute/tasks/ast.js.map +1 -0
  39. package/dist/execute/tasks/generators.js +96 -0
  40. package/dist/execute/tasks/generators.js.map +1 -0
  41. package/dist/execute/tasks/index.js +7 -0
  42. package/dist/execute/tasks/index.js.map +1 -0
  43. package/dist/execute/tasks/mutations.js +8139 -0
  44. package/dist/execute/tasks/mutations.js.map +1 -0
  45. package/dist/execute/tasks/query.js +248 -0
  46. package/dist/execute/tasks/query.js.map +1 -0
  47. package/dist/index.js +6 -0
  48. package/dist/index.js.map +1 -0
  49. package/dist/providers/index.js +15 -0
  50. package/dist/providers/index.js.map +1 -0
  51. package/dist/providers/ollama.js +40 -0
  52. package/dist/providers/ollama.js.map +1 -0
  53. package/dist/providers/openai-compatible.js +52 -0
  54. package/dist/providers/openai-compatible.js.map +1 -0
  55. package/dist/runtime/inject.js +250 -0
  56. package/dist/runtime/inject.js.map +1 -0
  57. package/dist/schemas/agent/action.schema.js +935 -0
  58. package/dist/schemas/agent/action.schema.js.map +1 -0
  59. package/dist/schemas/agent/index.js +4 -0
  60. package/dist/schemas/agent/index.js.map +1 -0
  61. package/dist/schemas/agent/llm.schema.js +16 -0
  62. package/dist/schemas/agent/llm.schema.js.map +1 -0
  63. package/dist/schemas/agent/planner.schema.js +17 -0
  64. package/dist/schemas/agent/planner.schema.js.map +1 -0
  65. package/dist/schemas/index.js +7 -0
  66. package/dist/schemas/index.js.map +1 -0
  67. package/dist/schemas/project/context.schema.js +2 -0
  68. package/dist/schemas/project/context.schema.js.map +1 -0
  69. package/dist/schemas/project/index.js +2 -0
  70. package/dist/schemas/project/index.js.map +1 -0
  71. package/dist/schemas/runtime/index.js +4 -0
  72. package/dist/schemas/runtime/index.js.map +1 -0
  73. package/dist/schemas/runtime/injector.schema.js +11 -0
  74. package/dist/schemas/runtime/injector.schema.js.map +1 -0
  75. package/dist/schemas/runtime/runtime.schema.js +73 -0
  76. package/dist/schemas/runtime/runtime.schema.js.map +1 -0
  77. package/dist/schemas/runtime/sse.schema.js +15 -0
  78. package/dist/schemas/runtime/sse.schema.js.map +1 -0
  79. package/dist/schemas/system/index.js +2 -0
  80. package/dist/schemas/system/index.js.map +1 -0
  81. package/dist/schemas/system/logger.schema.js +56 -0
  82. package/dist/schemas/system/logger.schema.js.map +1 -0
  83. package/dist/schemas/task/index.js +9 -0
  84. package/dist/schemas/task/index.js.map +1 -0
  85. package/dist/server/app-context.js +254 -0
  86. package/dist/server/app-context.js.map +1 -0
  87. package/dist/server/config.js +22 -0
  88. package/dist/server/config.js.map +1 -0
  89. package/dist/server/error.js +22 -0
  90. package/dist/server/error.js.map +1 -0
  91. package/dist/server/event-bus.js +60 -0
  92. package/dist/server/event-bus.js.map +1 -0
  93. package/dist/server/logger.js +57 -0
  94. package/dist/server/logger.js.map +1 -0
  95. package/dist/server/run.js +265 -0
  96. package/dist/server/run.js.map +1 -0
  97. package/dist/server/sse.js +143 -0
  98. package/dist/server/sse.js.map +1 -0
  99. package/dist/ui/assets/index-C4ydQSAw.css +2 -0
  100. package/dist/ui/assets/index-Dzo7S5xs.js +85 -0
  101. package/dist/ui/favicon.svg +1 -0
  102. package/dist/ui/icons.svg +24 -0
  103. package/dist/ui/index.html +14 -0
  104. package/dist/workers/prettier.js +11 -0
  105. package/dist/workers/prettier.js.map +1 -0
  106. package/package.json +114 -0
@@ -0,0 +1,935 @@
1
+ import * as z from "zod";
2
+ export const HelpersTaskRegistry = {
3
+ // insertCode: {
4
+ // description: "insertCode",
5
+ // payload: z.object({
6
+ // filePath: z.string(),
7
+ // codeToInsert: z.string(),
8
+ // insertAt: "end",
9
+ // }),
10
+ // return: z.object({
11
+ // success: z.boolean(),
12
+ // filePath: z.string(),
13
+ // insertAt: z.string(),
14
+ // }),
15
+ // },
16
+ // enrichImport: {
17
+ // payload: z.unknown(),
18
+ // return: z.unknown(),
19
+ // },
20
+ ensureLibrary: {
21
+ description: "ensureLibrary",
22
+ payload: z.object({
23
+ projectPath: z.string(),
24
+ libraryName: z.string(),
25
+ version: z.string(),
26
+ dependencyType: "dependencies",
27
+ }),
28
+ return: z.object({ success: z.boolean(), packageJson: z.object() }),
29
+ },
30
+ ensureComponentStructure: {
31
+ description: "ensureComponentStructure",
32
+ payload: z.object({
33
+ componentPath: z.string(),
34
+ componentName: z.string(),
35
+ ensureCss: z.boolean(),
36
+ ensureIndex: z.boolean(),
37
+ createIfMissing: z.boolean(),
38
+ }),
39
+ return: z.object({
40
+ success: z.boolean(),
41
+ existing: z.array(z.string()),
42
+ repaired: z.boolean(),
43
+ }),
44
+ },
45
+ normalizeComponent: {
46
+ description: "normalizeComponent",
47
+ payload: z.object({
48
+ componentPath: z.string(),
49
+ componentName: z.string(),
50
+ ensureCss: z.boolean(),
51
+ ensureIndex: z.boolean(),
52
+ normalizeExports: z.boolean(),
53
+ }),
54
+ return: z.object({ repairedItems: z.unknown(), warnings: z.unknown() }),
55
+ },
56
+ findComponentDirectory: {
57
+ description: "findComponentDirectory",
58
+ payload: z.object({
59
+ componentName: z.string(),
60
+ caseSensitive: z.optional(z.boolean()),
61
+ returnFirst: z.optional(z.boolean()),
62
+ }),
63
+ return: z.union([
64
+ z.object({
65
+ foundComponent: {
66
+ componentName: z.string(),
67
+ componentPath: z.string(),
68
+ jsxPath: z.string(),
69
+ cssPath: z.string(),
70
+ exists: z.boolean(),
71
+ },
72
+ }),
73
+ z.object({ message: z.string() }),
74
+ ]),
75
+ },
76
+ // inferComponentName: {
77
+ // "//",description:
78
+ // payload: z.object({
79
+ // userInput: z.string(),
80
+ // filePath: z.string(),
81
+ // jsxCode: z.string(),
82
+ // stopWords: [
83
+ // "make",
84
+ // "update",
85
+ // "delete",
86
+ // "move",
87
+ // "rename",
88
+ // "extract",
89
+ // "component",
90
+ // "section",
91
+ // "add",
92
+ // "remove",
93
+ // "create",
94
+ // "change",
95
+ // "modify",
96
+ // "the",
97
+ // "a",
98
+ // "an"
99
+ // ],
100
+ // },
101
+ // return: z.object({
102
+ // componentName: z.string(),
103
+ // inferredFrom:
104
+ // | "jsx-function"
105
+ // | "jsx-arrow-function"
106
+ // | "file-path"
107
+ // | "user-input"
108
+ // | "fallback",
109
+ // },
110
+ // },
111
+ ensureStyleFile: {
112
+ description: "ensureStyleFile",
113
+ payload: z.object({
114
+ componentPath: z.string(),
115
+ componentName: z.string(),
116
+ initialStyles: "",
117
+ }),
118
+ return: z.object({ success: z.boolean(), cssPath: z.string() }),
119
+ },
120
+ findCssSelector: {
121
+ description: "findCssSelector",
122
+ payload: z.object({
123
+ ast: z.unknown(),
124
+ selector: z.string(),
125
+ findAll: z.boolean(),
126
+ }),
127
+ return: z.union([
128
+ z.object({ success: z.boolean(), matches: z.array(z.string()) }),
129
+ z.object({ success: z.boolean(), message: z.string() }),
130
+ ]),
131
+ },
132
+ resolveStyleDependencies: {
133
+ description: "resolveStyleDependencies",
134
+ payload: z.object({
135
+ cssPath: z.string(),
136
+ availableDependencyFiles: z.unknown(),
137
+ autoImport: z.boolean(),
138
+ }),
139
+ return: z.object({
140
+ resolvedDependencies: z.unknown(),
141
+ missingDependencies: z.unknown(),
142
+ insertedImports: z.unknown(),
143
+ }),
144
+ },
145
+ parseAST: {
146
+ description: "parseAST",
147
+ payload: z.object({
148
+ code: z.string(),
149
+ }),
150
+ return: z.unknown(),
151
+ },
152
+ parseCSS: {
153
+ description: "parseCSS",
154
+ payload: z.object({
155
+ cssCode: z.string(),
156
+ cssPath: z.string(),
157
+ }),
158
+ return: z.object({ ast: z.unknown(), cssCode: z.string() }),
159
+ },
160
+ parseRoutes: {
161
+ description: "parseRoutes",
162
+ payload: z.object({ ast: z.unknown() }),
163
+ return: z.union([
164
+ z.object({ routes: z.unknown() }),
165
+ z.object({ message: z.string() }),
166
+ ]),
167
+ },
168
+ parseComponentDependencies: {
169
+ description: "parseComponentDependencies",
170
+ payload: z.object({ ast: z.string() }),
171
+ return: z.object({
172
+ dependencies: { localName: z.string(), source: z.string() },
173
+ }),
174
+ },
175
+ parseProps: {
176
+ description: "parseProps",
177
+ payload: z.object({ ast: z.string() }),
178
+ return: z.object({ props: z.array(z.string()) }),
179
+ },
180
+ // parseStateUsage: {
181
+ // payload: z.string(),
182
+ // return: z.unknown(),
183
+ // },
184
+ // parseEventHandlers: {
185
+ // payload: z.string(),
186
+ // return: z.unknown(),
187
+ // },
188
+ // parseAPICalls: {
189
+ // payload: z.string(),
190
+ // return: z.unknown(),
191
+ // },
192
+ // parseTypescriptTypes: {
193
+ // payload: z.string(),
194
+ // return: z.unknown(),
195
+ // },
196
+ parseExports: {
197
+ description: "parseExports",
198
+ payload: z.object({ ast: z.string() }),
199
+ return: z.object({ exportsList: z.unknown() }),
200
+ },
201
+ parseHooksUsage: {
202
+ description: "parseHooksUsage",
203
+ payload: z.object({ ast: z.string() }),
204
+ return: z.unknown(),
205
+ },
206
+ // parseDOMHierarchy: {
207
+ // payload: z.string(),
208
+ // return: z.unknown(),
209
+ // },
210
+ // matchesSelector: {
211
+ // description: "matchesSelector",
212
+ // payload: z.object({ openingElement: z.unknown(), selector: z.string() }),
213
+ // return: z.boolean(),
214
+ // },
215
+ generateCodeFromAST: {
216
+ description: "generateCodeFromAST",
217
+ payload: z.object({
218
+ ast: z.string(),
219
+ options: z.object(),
220
+ }),
221
+ return: z.string(),
222
+ },
223
+ findImportDeclaration: {
224
+ description: "findImportDeclaration",
225
+ payload: z.object({ ast: z.unknown(), source: z.string() }),
226
+ return: z.object(),
227
+ },
228
+ buildImportDeclaration: {
229
+ description: "buildImportDeclaration",
230
+ payload: z.object({
231
+ source: z.string(),
232
+ defaultImport: z.string(),
233
+ namedImports: z.unknown(),
234
+ namespaceImport: z.unknown(),
235
+ }),
236
+ return: z.object(),
237
+ },
238
+ getImportSpecifiers: {
239
+ description: "getImportSpecifiers",
240
+ payload: z.object({
241
+ importDeclaration: z.unknown(),
242
+ }),
243
+ return: z.object({
244
+ defaultImport: z.union([z.string(), z.null()]),
245
+ namespaceImport: z.union([z.string(), z.null()]),
246
+ namedImports: z.array(z.string()),
247
+ }),
248
+ },
249
+ removeImportSpecifier: {
250
+ description: "removeImportSpecifier",
251
+ payload: z.object({
252
+ importDeclaration: z.unknown(),
253
+ name: z.string(),
254
+ }),
255
+ return: z.unknown(),
256
+ },
257
+ mergeImportDeclarations: {
258
+ description: "mergeImportDeclarations",
259
+ payload: z.object({
260
+ targetImport: z.unknown(),
261
+ sourceImport: z.unknown(),
262
+ }),
263
+ return: z.unknown(),
264
+ },
265
+ isImportUsed: {
266
+ description: "isImportUsed",
267
+ payload: z.object({
268
+ ast: z.unknown(),
269
+ name: z.string(),
270
+ }),
271
+ return: z.boolean(),
272
+ },
273
+ // Mutation tasks
274
+ // AST tasks
275
+ };
276
+ export const GenerationTaskRegistry = {
277
+ // generateComponentCode: {
278
+ // description: "generate component code",
279
+ // payload: z.object({
280
+ // prompt: z.string(),
281
+ // }),
282
+ // return: z.object({
283
+ // componentName: z.string(),
284
+ // componentCode: z.string(), // usageSnippet: "<Header />", },
285
+ // }),
286
+ // },
287
+ generateJSX: {
288
+ description: " Generates JSX markup",
289
+ payload: z.object({
290
+ userPrompt: z.string(),
291
+ }),
292
+ return: z.unknown(),
293
+ },
294
+ generateCSS: {
295
+ description: "Generates CSS styles",
296
+ payload: z.object({
297
+ userPrompt: z.string(),
298
+ }),
299
+ return: z.unknown(),
300
+ },
301
+ generateComponent: {
302
+ description: "Generates component including state, handlers, and effects. ",
303
+ payload: z.object({
304
+ userPrompt: z.string(),
305
+ }),
306
+ return: z.unknown(),
307
+ },
308
+ };
309
+ // export const AstTaskRegistry = {
310
+ // ensureImport: {
311
+ // description: "Ensures that an import exists in a file.",
312
+ // payload: z.object({
313
+ // code: z.string(),
314
+ // source: z.string(),
315
+ // importName: z.string(),
316
+ // importType: z.string(),
317
+ // alias: z.string(),
318
+ // }),
319
+ // return: z.object({ success: z.boolean(), updatedCode: z.string() }),
320
+ // },
321
+ // removeImport: {
322
+ // description: "Removes imports from a source/module.",
323
+ // payload: z.object({
324
+ // code: z.string(),
325
+ // source: z.string(),
326
+ // importName: z.string(),
327
+ // importType: z.string(),
328
+ // }),
329
+ // return: z.object({ success: z.boolean(), updatedCode: z.string() }),
330
+ // },
331
+ // optimizeImports: {
332
+ // description: "Removes unused imports from a file.",
333
+ // payload: z.object({
334
+ // code: z.string(),
335
+ // }),
336
+ // return: z.object({ success: z.boolean(), updatedCode: z.string() }),
337
+ // },
338
+ // updateComponentImports: {
339
+ // description: "update component imports",
340
+ // payload: z.object({
341
+ // componentPath: z.string(),
342
+ // operations: z.unknown(),
343
+ // }),
344
+ // return: z.object({ operationsApplied: z.unknown() }),
345
+ // },
346
+ // insertJSX: {
347
+ // description: "Inserts new JSX into a target component.",
348
+ // payload: z.object({
349
+ // code: z.string(),
350
+ // componentName: z.string(),
351
+ // targetElement: z.string(),
352
+ // jsx: z.string(),
353
+ // position: z.enum(["first", "last"]),
354
+ // }),
355
+ // return: z.object({ success: z.boolean(), updatedCode: z.string() }),
356
+ // },
357
+ // replaceJSX: {
358
+ // description: "Replaces an existing JSX element with new JSX.",
359
+ // payload: z.object({
360
+ // code: z.string(),
361
+ // componentName: z.string(),
362
+ // targetElement: z.string(),
363
+ // newJSX: z.string(),
364
+ // }),
365
+ // return: z.object({ success: z.boolean(), updatedCode: z.string() }),
366
+ // },
367
+ // removeJSX: {
368
+ // description: "Removes a JSX element from a component.",
369
+ // payload: z.object({
370
+ // code: z.string(),
371
+ // componentName: z.string(),
372
+ // targetElement: z.string(),
373
+ // }),
374
+ // return: z.object({ success: z.boolean(), updatedCode: z.string() }),
375
+ // },
376
+ // moveJSX: {
377
+ // description: "Wraps a JSX element with a parent JSX element.",
378
+ // payload: z.object({
379
+ // code: z.string(),
380
+ // componentName: z.string(),
381
+ // sourceElement: z.string(),
382
+ // destinationElement: z.string(),
383
+ // }),
384
+ // return: z.object({ success: z.boolean(), updatedCode: z.string() }),
385
+ // },
386
+ // wrapJSX: {
387
+ // description: "Moves a JSX element to a different location in the JSX tree.",
388
+ // payload: z.object({
389
+ // code: z.string(),
390
+ // componentName: z.string(),
391
+ // targetElement: z.string(),
392
+ // wrapperJSX: z.string(),
393
+ // }),
394
+ // return: z.object({ success: z.boolean(), updatedCode: z.string() }),
395
+ // },
396
+ // insertVariable: {
397
+ // description: "Inserts a new variable declaration into code.",
398
+ // payload: z.object({
399
+ // code: z.string(),
400
+ // variableName: z.string(),
401
+ // value: z.string(),
402
+ // scope: z.string(),
403
+ // functionName: z.string(),
404
+ // }),
405
+ // return: z.object({ success: z.boolean(), updatedCode: z.string() }),
406
+ // },
407
+ // updateVariable: {
408
+ // description: "Updates the value of an existing variable.",
409
+ // payload: z.object({
410
+ // code: z.string(),
411
+ // variableName: z.string(),
412
+ // newValue: z.string(),
413
+ // line: z.number(),
414
+ // }),
415
+ // return: z.object({ success: z.boolean(), updatedCode: z.string() }),
416
+ // },
417
+ // deleteVariable: {
418
+ // description: "Removes a variable declaration from code.",
419
+ // payload: z.object({
420
+ // code: z.string(),
421
+ // variableName: z.string(),
422
+ // line: z.number(),
423
+ // }),
424
+ // return: z.object({ success: z.boolean(), updatedCode: z.string() }),
425
+ // },
426
+ // };
427
+ export const MutationTaskRegistry = {
428
+ // ast tasks
429
+ ensureImport: {
430
+ description: "Ensures that an import exists in a file.",
431
+ payload: z.object({
432
+ filePath: z.string(),
433
+ source: z.string(),
434
+ importName: z.string(),
435
+ importType: z.string(),
436
+ alias: z.nullable(z.string()),
437
+ }),
438
+ return: z.object({ success: z.boolean(), filePath: z.string() }),
439
+ },
440
+ removeImport: {
441
+ description: "Removes imports from a source/module.",
442
+ payload: z.object({
443
+ filePath: z.string(),
444
+ source: z.string(),
445
+ importName: z.string(),
446
+ importType: z.string(),
447
+ }),
448
+ return: z.object({ success: z.boolean(), filePath: z.string() }),
449
+ },
450
+ optimizeImports: {
451
+ description: "Removes unused imports from a file.",
452
+ payload: z.object({
453
+ filePath: z.string(),
454
+ }),
455
+ return: z.object({ success: z.boolean(), filePath: z.string() }),
456
+ },
457
+ updateComponentImports: {
458
+ description: "update component imports",
459
+ payload: z.object({
460
+ componentPath: z.string(),
461
+ operations: z.unknown(),
462
+ }),
463
+ return: z.object({ operationsApplied: z.unknown() }),
464
+ },
465
+ insertJSX: {
466
+ description: "Inserts new JSX into a target component.",
467
+ payload: z.object({
468
+ filePath: z.string(),
469
+ componentName: z.string(),
470
+ targetElement: z.string(),
471
+ jsx: z.string(),
472
+ position: z.enum(["first", "last"]),
473
+ }),
474
+ return: z.object({ success: z.boolean(), filePath: z.string() }),
475
+ },
476
+ replaceJSX: {
477
+ description: "Replaces an existing JSX element with new JSX.",
478
+ payload: z.object({
479
+ filePath: z.string(),
480
+ componentName: z.string(),
481
+ targetElement: z.string(),
482
+ newJSX: z.string(),
483
+ }),
484
+ return: z.object({ success: z.boolean(), filePath: z.string() }),
485
+ },
486
+ removeJSX: {
487
+ description: "Removes a JSX element from a component.",
488
+ payload: z.object({
489
+ filePath: z.string(),
490
+ componentName: z.string(),
491
+ targetElement: z.string(),
492
+ }),
493
+ return: z.object({ success: z.boolean(), filePath: z.string() }),
494
+ },
495
+ moveJSX: {
496
+ description: "Wraps a JSX element with a parent JSX element.",
497
+ payload: z.object({
498
+ filePath: z.string(),
499
+ componentName: z.string(),
500
+ sourceElement: z.string(),
501
+ destinationElement: z.string(),
502
+ }),
503
+ return: z.object({ success: z.boolean(), filePath: z.string() }),
504
+ },
505
+ wrapJSX: {
506
+ description: "Moves a JSX element to a different location in the JSX tree.",
507
+ payload: z.object({
508
+ filePath: z.string(),
509
+ componentName: z.string(),
510
+ targetElement: z.string(),
511
+ wrapperJSX: z.string(),
512
+ }),
513
+ return: z.object({ success: z.boolean(), filePath: z.string() }),
514
+ },
515
+ insertVariable: {
516
+ description: "Inserts a new variable declaration into code.",
517
+ payload: z.object({
518
+ filePath: z.string(),
519
+ variableName: z.string(),
520
+ value: z.string(),
521
+ scope: z.string(),
522
+ functionName: z.string(),
523
+ }),
524
+ return: z.object({ success: z.boolean(), filePath: z.string() }),
525
+ },
526
+ updateVariable: {
527
+ description: "Updates the value of an existing variable.",
528
+ payload: z.object({
529
+ filePath: z.string(),
530
+ variableName: z.string(),
531
+ newValue: z.string(),
532
+ // line: z.number(),
533
+ }),
534
+ return: z.object({ success: z.boolean(), filePath: z.string() }),
535
+ },
536
+ deleteVariable: {
537
+ description: "Removes a variable declaration from code.",
538
+ payload: z.object({
539
+ filePath: z.string(),
540
+ variableName: z.string(),
541
+ // line: z.number(),
542
+ }),
543
+ return: z.object({ success: z.boolean(), filePath: z.string() }),
544
+ },
545
+ updateImportSource: {
546
+ description: "Updates the source of an import statement.",
547
+ payload: z.object({
548
+ filePath: z.string(),
549
+ oldSource: z.string(),
550
+ newSource: z.string(),
551
+ }),
552
+ return: z.object({
553
+ success: z.boolean(),
554
+ filePath: z.string(),
555
+ }),
556
+ },
557
+ // mutation tasks
558
+ createComponent: {
559
+ description: "Creates a new component directory and its associated files.",
560
+ payload: z.object({
561
+ componentName: z.string(),
562
+ componentCode: z.optional(z.string()),
563
+ parentDirectory: z.string(),
564
+ }),
565
+ return: z.union([
566
+ z.object({
567
+ success: z.boolean(),
568
+ componentName: z.string(),
569
+ componentDirectoryPath: z.string(),
570
+ jsxFilePath: z.string(),
571
+ cssFilePath: z.string(),
572
+ indexFilePath: z.string(),
573
+ }),
574
+ z.object({ success: z.boolean() }),
575
+ ]),
576
+ },
577
+ updateComponent: {
578
+ description: "Updates the JSX returned by an existing React component.",
579
+ payload: z.object({
580
+ componentPath: z.string(),
581
+ componentCode: z.string(),
582
+ }),
583
+ return: z.union([
584
+ z.object({
585
+ success: z.boolean(),
586
+ componentPath: z.string(),
587
+ oldComponentCode: z.string(),
588
+ newComponentCode: z.string(),
589
+ }),
590
+ z.object({ success: z.boolean() }),
591
+ ]),
592
+ },
593
+ deleteComponent: {
594
+ description: "Removes a component by moving its directory to trash.",
595
+ payload: z.object({
596
+ componentName: z.string(),
597
+ parentDirectory: z.string(),
598
+ }),
599
+ return: z.object({
600
+ success: z.boolean(),
601
+ componentDirectoryPath: z.string(),
602
+ trashPath: z.union([z.string(), z.null()]),
603
+ }),
604
+ },
605
+ moveComponent: {
606
+ description: "Moves a component directory to a different location.",
607
+ payload: z.object({
608
+ sourcePath: z.string(),
609
+ destinationPath: z.string(),
610
+ createDestination: z.boolean(),
611
+ overwrite: z.boolean(),
612
+ }),
613
+ return: z.object({
614
+ success: z.boolean(),
615
+ oldPath: z.string(),
616
+ newPath: z.string(),
617
+ }),
618
+ },
619
+ renameComponent: {
620
+ description: "Renames a component and optionally updates its code references.",
621
+ payload: z.object({
622
+ componentPath: z.string(),
623
+ newComponentName: z.string(),
624
+ updateComponentCode: z.boolean(),
625
+ }),
626
+ return: z.object({
627
+ success: z.boolean(),
628
+ oldComponentName: z.string(),
629
+ newComponentName: z.string(),
630
+ newComponentPath: z.string(),
631
+ }),
632
+ },
633
+ extractComponent: {
634
+ description: "Extracts JSX into a new standalone component.",
635
+ payload: z.object({
636
+ parentComponentPath: z.string(),
637
+ newComponentName: z.string(),
638
+ targetJSX: z.string(),
639
+ componentsDirectory: z.string(),
640
+ includeCss: z.boolean(),
641
+ }),
642
+ return: z.object({
643
+ success: z.boolean(),
644
+ componentPath: z.string(),
645
+ componentDirectoryPath: z.string(),
646
+ updatedParentPath: z.string(),
647
+ }),
648
+ },
649
+ createFile: {
650
+ description: "Creates a new file in an existing directory.",
651
+ payload: z.object({
652
+ filePath: z.string(),
653
+ content: z.string(),
654
+ }),
655
+ return: z.object({ success: z.boolean(), filePath: z.string() }),
656
+ },
657
+ deleteFile: {
658
+ description: "Removes a file by moving it to trash.",
659
+ payload: z.object({
660
+ filePath: z.string(),
661
+ }),
662
+ return: z.object({
663
+ success: z.boolean(),
664
+ filePath: z.string(),
665
+ trashPath: z.string().nullable(),
666
+ }),
667
+ },
668
+ renameFile: {
669
+ description: "Renames a component and optionally updates its code references.",
670
+ payload: z.object({
671
+ oldFilePath: z.string(),
672
+ newFilePath: z.string(),
673
+ }),
674
+ return: z.object({
675
+ success: z.boolean(),
676
+ oldFilePath: z.string(),
677
+ newFilePath: z.string(),
678
+ }),
679
+ },
680
+ moveFile: {
681
+ description: "Moves a file to another existing directory.",
682
+ payload: z.object({
683
+ fileName: z.string(),
684
+ sourcePath: z.string(),
685
+ destinationPath: z.string(),
686
+ }),
687
+ return: z.object({
688
+ success: z.boolean(),
689
+ sourcePath: z.string(),
690
+ destinationPath: z.string(),
691
+ }),
692
+ },
693
+ createDirectory: {
694
+ description: "Creates a new directory in an existing parent directory.",
695
+ payload: z.object({
696
+ directoryPath: z.string(),
697
+ }),
698
+ return: z.object({ directoryPath: z.string() }),
699
+ },
700
+ deleteDirectory: {
701
+ description: "Removes a directory by moving it to trash.",
702
+ payload: z.object({
703
+ directoryPath: z.string(),
704
+ }),
705
+ return: z.object({
706
+ success: z.boolean(),
707
+ directoryPath: z.string(),
708
+ trashPath: z.string().nullable(),
709
+ }),
710
+ },
711
+ renameDirectory: {
712
+ description: "Renames an existing directory.",
713
+ payload: z.object({
714
+ oldDirectoryPath: z.string(),
715
+ newDirectoryPath: z.string(),
716
+ }),
717
+ return: z.object({
718
+ success: z.boolean(),
719
+ oldDirectoryPath: z.string(),
720
+ newDirectoryPath: z.string(),
721
+ }),
722
+ },
723
+ moveDirectory: {
724
+ description: "Moves a directory to another existing location.",
725
+ payload: z.object({
726
+ sourcePath: z.string(),
727
+ destinationPath: z.string(),
728
+ }),
729
+ return: z.object({
730
+ success: z.boolean(),
731
+ sourcePath: z.string(),
732
+ destinationPath: z.string(),
733
+ }),
734
+ },
735
+ updateStyles: {
736
+ description: "Creates or updates CSS declarations for a selector.",
737
+ payload: z.object({
738
+ cssPath: z.string(),
739
+ selector: z.string(),
740
+ styles: z.record(z.string(), z.string()),
741
+ createIfMissing: z.boolean(),
742
+ }),
743
+ return: z.object({
744
+ success: z.boolean(),
745
+ cssCode: z.string(),
746
+ updatedCss: z.string(),
747
+ }),
748
+ },
749
+ removeStyles: {
750
+ description: "Removes CSS selectors or style declarations.",
751
+ payload: z.object({
752
+ cssPath: z.string(),
753
+ target: z.record(z.string(), z.string()),
754
+ removeAll: z.boolean(),
755
+ }),
756
+ return: z.object({
757
+ success: z.boolean(),
758
+ removed: z.boolean(),
759
+ removedCount: z.number(),
760
+ cssCode: z.string(),
761
+ updatedCss: z.string(),
762
+ }),
763
+ },
764
+ renameCssClass: {
765
+ description: "Renames a CSS class in both CSS and JSX.",
766
+ payload: z.object({
767
+ cssPath: z.string(),
768
+ componentJSXPath: z.string(),
769
+ oldClassName: z.string(),
770
+ newClassName: z.string(),
771
+ }),
772
+ return: z.object({
773
+ renamed: z.boolean(),
774
+ cssUpdated: z.boolean(),
775
+ jsxUpdated: z.boolean(),
776
+ cssCode: z.string(),
777
+ updatedCssCode: z.string(),
778
+ jsxCode: z.string(),
779
+ updatedJsxCode: z.string(),
780
+ }),
781
+ },
782
+ };
783
+ export const QueryTaskRegistry = {
784
+ readFile: {
785
+ description: "Reads the contents of a file.",
786
+ payload: z.object({
787
+ filePath: z.string(),
788
+ }),
789
+ return: z.object({
790
+ filePath: z.string(),
791
+ content: z.string(),
792
+ }),
793
+ examples: [
794
+ {
795
+ filePath: "src/App.jsx",
796
+ },
797
+ ],
798
+ },
799
+ readPackageJson: {
800
+ description: "Reads package.json.",
801
+ payload: z.object({}),
802
+ return: z.object({
803
+ filePath: z.string(),
804
+ packageJson: z.record(z.string(), z.any()),
805
+ }),
806
+ examples: [
807
+ {
808
+ projectRoot: "project root path",
809
+ },
810
+ ],
811
+ },
812
+ readReadme: {
813
+ description: "Reads README.md.",
814
+ payload: z.object({}),
815
+ return: z.object({
816
+ filePath: z.string(),
817
+ content: z.string(),
818
+ }),
819
+ },
820
+ findComponent: {
821
+ description: "Find a component in the project.",
822
+ payload: z.object({
823
+ componentName: z.string(),
824
+ }),
825
+ return: z.object({
826
+ componentName: z.string(),
827
+ filePaths: z.array(z.string()),
828
+ }),
829
+ },
830
+ searchText: {
831
+ description: "Find arbitrary text in the project. Think of it as a project-wide grep.",
832
+ payload: z.object({
833
+ text: z.string(),
834
+ }),
835
+ return: z.object({
836
+ matches: z.array(z.object({
837
+ filePath: z.string(),
838
+ lineNumber: z.number(),
839
+ line: z.string(),
840
+ })),
841
+ }),
842
+ examples: [
843
+ {
844
+ query: "useState",
845
+ },
846
+ {
847
+ query: "ProductCard", // "Where is ProductCard used?"
848
+ },
849
+ {
850
+ query: "fetch(", // "Where are API calls made?"
851
+ },
852
+ {
853
+ query: "TODO", // "Find every TODO."
854
+ },
855
+ {
856
+ query: "localStorage", // "Find all usages of localStorage."
857
+ },
858
+ {
859
+ query: "primary-button", // "Where is class 'primary-button' used?"
860
+ },
861
+ ],
862
+ },
863
+ readComponent: {
864
+ description: "Reads a component.",
865
+ payload: z.object({
866
+ componentName: z.string(),
867
+ }),
868
+ return: z.object({
869
+ componentName: z.string(),
870
+ filePath: z.string(),
871
+ content: z.string(),
872
+ }),
873
+ },
874
+ findSymbolReferences: {
875
+ description: "Finds references of a symbol.",
876
+ payload: z.object({
877
+ symbol: z.string(),
878
+ }),
879
+ return: z.object({
880
+ references: z.array(z.object({
881
+ filePath: z.string(),
882
+ lineNumber: z.number(),
883
+ line: z.string(),
884
+ })),
885
+ }),
886
+ examples: [
887
+ {
888
+ symbol: "Button",
889
+ },
890
+ ],
891
+ },
892
+ getRuntimeSnapshot: {
893
+ description: "Gets the current runtime snapshot.",
894
+ payload: z.object({}),
895
+ return: z.object({
896
+ currentRoute: z.string(),
897
+ visibleComponents: z.array(z.object({
898
+ id: z.string(),
899
+ visible: z.boolean(),
900
+ })),
901
+ viewport: z.object({
902
+ width: z.number(),
903
+ height: z.number(),
904
+ }),
905
+ }),
906
+ },
907
+ getRuntimeError: {
908
+ description: "Gets the latest runtime error.",
909
+ payload: z.object({}),
910
+ return: z.object({
911
+ error: z
912
+ .object({
913
+ type: z.enum(["error", "unhandledrejection"]),
914
+ message: z.string(),
915
+ stack: z.string().optional(),
916
+ })
917
+ .nullable(),
918
+ }),
919
+ },
920
+ listRoutes: {
921
+ description: "Gets list of all routes",
922
+ payload: z.object({}),
923
+ return: z.array(z.string()),
924
+ },
925
+ };
926
+ export const TaskRegistry = {
927
+ ...MutationTaskRegistry,
928
+ ...QueryTaskRegistry,
929
+ // ...AstTaskRegistry,
930
+ ...HelpersTaskRegistry,
931
+ // ...RuntimeTaskRegistry,
932
+ // ...RefactorTaskRegistry,
933
+ ...GenerationTaskRegistry,
934
+ };
935
+ //# sourceMappingURL=action.schema.js.map