@kapeta/local-cluster-service 0.54.7 → 0.54.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [0.54.8](https://github.com/kapetacom/local-cluster-service/compare/v0.54.7...v0.54.8) (2024-06-24)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * update webrouter handling after template change ([#187](https://github.com/kapetacom/local-cluster-service/issues/187)) ([1c3dffa](https://github.com/kapetacom/local-cluster-service/commit/1c3dffa0f8e44680e9dbdee0acd97bde9a3e42b8))
7
+
1
8
  ## [0.54.7](https://github.com/kapetacom/local-cluster-service/compare/v0.54.6...v0.54.7) (2024-06-21)
2
9
 
3
10
 
@@ -355,23 +355,8 @@ class StormCodegen {
355
355
  };
356
356
  });
357
357
  allFiles.push(...screenFilesConverted);
358
- const webRouters = allFiles.filter((file) => file.type === codegen_1.AIFileTypes.WEB_ROUTER);
359
- await Promise.all(webRouters.map(async (webRouter) => {
360
- const payload = {
361
- filename: webRouter.filename,
362
- template: webRouter,
363
- context: screenFilesConverted.concat([getScreenEventsFile()]),
364
- prompt: this.userPrompt,
365
- };
366
- const stream = await stormClient_1.stormClient.generateCode(payload);
367
- stream.on('data', (evt) => {
368
- this.handleTemplateFileOutput(blockUri, block.aiName, evt);
369
- });
370
- this.out.on('aborted', () => {
371
- stream.abort();
372
- });
373
- await stream.waitForDone();
374
- }));
358
+ let webRouters = allFiles.filter((file) => file.type === codegen_1.AIFileTypes.WEB_ROUTER);
359
+ webRouters = await this.processTemplates(blockUri, block.aiName, stormClient_1.stormClient.generateCode.bind(stormClient_1.stormClient), webRouters, screenFilesConverted.concat([getScreenEventsFile()]));
375
360
  // Gather the context files for implementation. These will be all be passed to the AI
376
361
  const contextFiles = relevantFiles.filter((file) => ![codegen_1.AIFileTypes.SERVICE, codegen_1.AIFileTypes.WEB_SCREEN, codegen_1.AIFileTypes.WEB_ROUTER].includes(file.type));
377
362
  // Send the service and UI templates to the AI. These will be sent one-by-one in addition to the context files
@@ -395,7 +380,6 @@ class StormCodegen {
395
380
  const filePath = (0, path_2.join)(basePath, serviceFile.filename);
396
381
  await (0, promises_1.writeFile)(filePath, serviceFile.content);
397
382
  }
398
- // Write again after modifications
399
383
  for (const webRouterFile of webRouters) {
400
384
  const filePath = (0, path_2.join)(basePath, webRouterFile.filename);
401
385
  await (0, promises_1.writeFile)(filePath, webRouterFile.content);
@@ -13,7 +13,7 @@ declare class StormClient {
13
13
  createErrorClassification(prompt: string, history?: ConversationItem[], conversationId?: string): Promise<StormStream>;
14
14
  createCodeFix(prompt: string, history?: ConversationItem[], conversationId?: string): Promise<StormStream>;
15
15
  createErrorDetails(prompt: string, history?: ConversationItem[], conversationId?: string): Promise<StormStream>;
16
- generateCode(prompt: StormFileImplementationPrompt, history?: ConversationItem[], conversationId?: string): Promise<StormStream>;
16
+ generateCode(prompt: StormFileImplementationPrompt, conversationId?: string): Promise<StormStream>;
17
17
  }
18
18
  export declare const stormClient: StormClient;
19
19
  export {};
@@ -116,10 +116,10 @@ class StormClient {
116
116
  prompt,
117
117
  });
118
118
  }
119
- generateCode(prompt, history, conversationId) {
119
+ generateCode(prompt, conversationId) {
120
120
  return this.send('/v2/code/generate', {
121
- conversationId: conversationId,
122
121
  prompt,
122
+ conversationId: conversationId,
123
123
  });
124
124
  }
125
125
  }
@@ -355,23 +355,8 @@ class StormCodegen {
355
355
  };
356
356
  });
357
357
  allFiles.push(...screenFilesConverted);
358
- const webRouters = allFiles.filter((file) => file.type === codegen_1.AIFileTypes.WEB_ROUTER);
359
- await Promise.all(webRouters.map(async (webRouter) => {
360
- const payload = {
361
- filename: webRouter.filename,
362
- template: webRouter,
363
- context: screenFilesConverted.concat([getScreenEventsFile()]),
364
- prompt: this.userPrompt,
365
- };
366
- const stream = await stormClient_1.stormClient.generateCode(payload);
367
- stream.on('data', (evt) => {
368
- this.handleTemplateFileOutput(blockUri, block.aiName, evt);
369
- });
370
- this.out.on('aborted', () => {
371
- stream.abort();
372
- });
373
- await stream.waitForDone();
374
- }));
358
+ let webRouters = allFiles.filter((file) => file.type === codegen_1.AIFileTypes.WEB_ROUTER);
359
+ webRouters = await this.processTemplates(blockUri, block.aiName, stormClient_1.stormClient.generateCode.bind(stormClient_1.stormClient), webRouters, screenFilesConverted.concat([getScreenEventsFile()]));
375
360
  // Gather the context files for implementation. These will be all be passed to the AI
376
361
  const contextFiles = relevantFiles.filter((file) => ![codegen_1.AIFileTypes.SERVICE, codegen_1.AIFileTypes.WEB_SCREEN, codegen_1.AIFileTypes.WEB_ROUTER].includes(file.type));
377
362
  // Send the service and UI templates to the AI. These will be sent one-by-one in addition to the context files
@@ -395,7 +380,6 @@ class StormCodegen {
395
380
  const filePath = (0, path_2.join)(basePath, serviceFile.filename);
396
381
  await (0, promises_1.writeFile)(filePath, serviceFile.content);
397
382
  }
398
- // Write again after modifications
399
383
  for (const webRouterFile of webRouters) {
400
384
  const filePath = (0, path_2.join)(basePath, webRouterFile.filename);
401
385
  await (0, promises_1.writeFile)(filePath, webRouterFile.content);
@@ -13,7 +13,7 @@ declare class StormClient {
13
13
  createErrorClassification(prompt: string, history?: ConversationItem[], conversationId?: string): Promise<StormStream>;
14
14
  createCodeFix(prompt: string, history?: ConversationItem[], conversationId?: string): Promise<StormStream>;
15
15
  createErrorDetails(prompt: string, history?: ConversationItem[], conversationId?: string): Promise<StormStream>;
16
- generateCode(prompt: StormFileImplementationPrompt, history?: ConversationItem[], conversationId?: string): Promise<StormStream>;
16
+ generateCode(prompt: StormFileImplementationPrompt, conversationId?: string): Promise<StormStream>;
17
17
  }
18
18
  export declare const stormClient: StormClient;
19
19
  export {};
@@ -116,10 +116,10 @@ class StormClient {
116
116
  prompt,
117
117
  });
118
118
  }
119
- generateCode(prompt, history, conversationId) {
119
+ generateCode(prompt, conversationId) {
120
120
  return this.send('/v2/code/generate', {
121
- conversationId: conversationId,
122
121
  prompt,
122
+ conversationId: conversationId,
123
123
  });
124
124
  }
125
125
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kapeta/local-cluster-service",
3
- "version": "0.54.7",
3
+ "version": "0.54.8",
4
4
  "description": "Manages configuration, ports and service discovery for locally running Kapeta systems",
5
5
  "type": "commonjs",
6
6
  "exports": {
@@ -419,28 +419,13 @@ export class StormCodegen {
419
419
  });
420
420
  allFiles.push(...screenFilesConverted);
421
421
 
422
- const webRouters = allFiles.filter((file) => file.type === AIFileTypes.WEB_ROUTER);
423
- await Promise.all(
424
- webRouters.map(async (webRouter) => {
425
- const payload = {
426
- filename: webRouter.filename,
427
- template: webRouter,
428
- context: screenFilesConverted.concat([getScreenEventsFile()]),
429
- prompt: this.userPrompt,
430
- };
431
-
432
- const stream = await stormClient.generateCode(payload);
433
-
434
- stream.on('data', (evt) => {
435
- this.handleTemplateFileOutput(blockUri, block.aiName, evt);
436
- });
437
-
438
- this.out.on('aborted', () => {
439
- stream.abort();
440
- });
441
-
442
- await stream.waitForDone();
443
- })
422
+ let webRouters = allFiles.filter((file) => file.type === AIFileTypes.WEB_ROUTER);
423
+ webRouters = await this.processTemplates(
424
+ blockUri,
425
+ block.aiName,
426
+ stormClient.generateCode.bind(stormClient),
427
+ webRouters,
428
+ screenFilesConverted.concat([getScreenEventsFile()])
444
429
  );
445
430
 
446
431
  // Gather the context files for implementation. These will be all be passed to the AI
@@ -480,7 +465,6 @@ export class StormCodegen {
480
465
  await writeFile(filePath, serviceFile.content);
481
466
  }
482
467
 
483
- // Write again after modifications
484
468
  for (const webRouterFile of webRouters) {
485
469
  const filePath = join(basePath, webRouterFile.filename);
486
470
  await writeFile(filePath, webRouterFile.content);
@@ -155,10 +155,10 @@ class StormClient {
155
155
  });
156
156
  }
157
157
 
158
- public generateCode(prompt: StormFileImplementationPrompt, history?: ConversationItem[], conversationId?: string) {
158
+ public generateCode(prompt: StormFileImplementationPrompt, conversationId?: string) {
159
159
  return this.send('/v2/code/generate', {
160
- conversationId: conversationId,
161
160
  prompt,
161
+ conversationId: conversationId,
162
162
  });
163
163
  }
164
164
  }