ide-assi 0.155.0 → 0.157.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.
@@ -193327,22 +193327,30 @@ class IdeUtils
193327
193327
 
193328
193328
  static extractResponse = (response, gptServer) => {
193329
193329
 
193330
- const extractJsonSnippet = (text) => {
193331
- //return text.replace(/```[\s\S]*?```/g, '').trim();
193332
- const match = text.match(/```json([\s\S]*?)```/);
193333
- return match ? match[1].trim() : text;
193330
+ const extractSnippet = (text) => {
193331
+ // 모든 종류의 마크다운 코드 블록 (```언어명 ... ```)을 제거
193332
+ // 언어명 없는 순수 ``` 블록도 포함
193333
+ const cleanedText = text.replace(/```(?:json|jsx|[\s\S]*?)?\s*([\s\S]*?)```/g, '').trim();
193334
+
193335
+ // 혹시라도 마크다운 코드 블록 외에 순수 JSON 문자열만 남았다면 그 부분을 반환
193336
+ // (이전 로직에서 JSON 블록만 추출하는 부분은 이제 필요 없을 가능성이 높습니다,
193337
+ // `replace`에서 이미 다 제거되었기 때문입니다.)
193338
+ // 하지만, 안전을 위해 만약 JSON이 아닌 다른 텍스트가 남았을 때도 처리할 수 있도록
193339
+ // 원본 텍스트에서 ```으로 감싸진 부분을 모두 제거하는 방식으로 변경합니다.
193340
+ return cleanedText;
193334
193341
  };
193335
193342
 
193343
+
193336
193344
  let r;
193337
193345
  switch (gptServer) {
193338
193346
  case "openai":
193339
- r = extractJsonSnippet(response.content.trim());
193347
+ r = extractSnippet(response.content.trim());
193340
193348
  break;
193341
193349
  case "gemini":
193342
- r = extractJsonSnippet(response.content.trim());
193350
+ r = extractSnippet(response.content.trim());
193343
193351
  break;
193344
193352
  case "ollama":
193345
- r = extractJsonSnippet(response);
193353
+ r = extractSnippet(response);
193346
193354
  break;
193347
193355
  }
193348
193356
 
@@ -193602,57 +193610,63 @@ class IdeAi
193602
193610
 
193603
193611
  generateSourceClient = async (userPrompt) => {
193604
193612
 
193605
- this.#createModel();
193613
+ try {
193614
+ this.#createModel();
193606
193615
 
193607
- await this.#what(userPrompt);
193608
- this.#parent.addMessage("명령을 이해했습니다.");
193616
+ const what = await this.#what(userPrompt);
193617
+ this.#parent.addMessage("명령을 이해했습니다.");
193609
193618
 
193610
- const where = await this.#where(userPrompt, this.#getMenuInfo(), await this.#getTableList());
193611
- this.#parent.addMessage("대상 메뉴와 테이블을 찾았습니다.");
193612
- console.log(where);
193619
+ const where = await this.#where(userPrompt, this.#getMenuInfo(), await this.#getTableList());
193620
+ this.#parent.addMessage("대상 메뉴와 테이블을 찾았습니다.");
193621
+ console.log(where);
193613
193622
 
193614
- const columnInfo = await this.#getColumnInfo(where.table);
193623
+ const columnInfo = await this.#getColumnInfo(where.table);
193615
193624
 
193616
- const namespace = where.package;
193617
- const classPackage = "ide.assi.be." + where.package.split(".").slice(0, -1).join(".");
193625
+ const namespace = where.package;
193626
+ const classPackage = "ide.assi.be." + where.package.split(".").slice(0, -1).join(".");
193618
193627
 
193619
- //const mybatisXmlSource = await this.#generateMyBatis(userPrompt, where.package, columnInfo);
193620
- const mybatisXmlSource = await this.#generateTmplFile("/prompts/meta/BuildMyBatisMapper.txt", "mybatis.xml", {
193621
- "userPrompt": userPrompt,
193622
- "namespace": namespace,
193623
- "tableDefinitions": columnInfo
193624
- });
193625
- this.#parent.addMessage("MyBatis 소스파일을 생성했습니다.");
193628
+ //const mybatisXmlSource = await this.#generateMyBatis(userPrompt, where.package, columnInfo);
193629
+ const mybatisXmlSource = await this.#generateTmplFile("/prompts/meta/BuildMyBatisMapper.txt", "mybatis.xml", {
193630
+ "userPrompt": userPrompt,
193631
+ "namespace": namespace,
193632
+ "tableDefinitions": columnInfo
193633
+ });
193634
+ this.#parent.addMessage("MyBatis 소스파일을 생성했습니다.");
193626
193635
 
193627
193636
 
193628
- const serviceSrc = await this.#generateTmplFile("/prompts/meta/BuildService.txt", "service.java", {
193629
- userPrompt: userPrompt,
193630
- menuUrl: where.menu.url,
193631
- classPackage: classPackage + ".service",
193632
- namespace: namespace,
193633
- mybatisXmlSource: mybatisXmlSource,
193634
- });
193635
- this.#parent.addMessage("Java(Service) 소스파일을 생성했습니다.");
193636
-
193637
- const controllerSrc = await this.#generateTmplFile("/prompts/meta/BuildController.txt", "controller.java", {
193638
- userPrompt: userPrompt,
193639
- menuUrl: where.menu.url,
193640
- classPackage: classPackage + ".controller",
193641
- namespace: namespace,
193642
- serviceSource: serviceSrc,
193643
- });
193644
- this.#parent.addMessage("Java(Controller) 소스파일을 생성했습니다.");
193645
-
193646
- await this.#generateTmplFile("/prompts/meta/BuildReactJsx.txt", "react.jsx", {
193647
- userPrompt: userPrompt,
193648
- menuUrl: where.menu.url,
193649
- menuName: where.menu.name,
193650
- controllerSource: controllerSrc,
193651
- tableDefinitions: columnInfo,
193652
- });
193653
- this.#parent.addMessage("Jsx(React) 소스파일을 생성했습니다.");
193637
+ const serviceSrc = await this.#generateTmplFile("/prompts/meta/BuildService.txt", "service.java", {
193638
+ userPrompt: userPrompt,
193639
+ menuUrl: where.menu.url,
193640
+ classPackage: classPackage + ".service",
193641
+ namespace: namespace,
193642
+ mybatisXmlSource: mybatisXmlSource,
193643
+ });
193644
+ this.#parent.addMessage("Java(Service) 소스파일을 생성했습니다.");
193645
+
193646
+ const controllerSrc = await this.#generateTmplFile("/prompts/meta/BuildController.txt", "controller.java", {
193647
+ userPrompt: userPrompt,
193648
+ menuUrl: where.menu.url,
193649
+ classPackage: classPackage + ".controller",
193650
+ namespace: namespace,
193651
+ serviceSource: serviceSrc,
193652
+ });
193653
+ this.#parent.addMessage("Java(Controller) 소스파일을 생성했습니다.");
193654
+
193655
+ const jsSrc = await this.#generateTmplFile("/prompts/meta/BuildReactJsx.txt", "react.jsx", {
193656
+ userPrompt: userPrompt,
193657
+ menuUrl: where.menu.url,
193658
+ menuName: where.menu.name,
193659
+ controllerSource: controllerSrc,
193660
+ tableDefinitions: columnInfo,
193661
+ });
193662
+ this.#parent.addMessage("Jsx(React) 소스파일을 생성했습니다.");
193663
+
193664
+ await this.#generateRealFile(where);
193665
+ }
193666
+ catch (error) {
193667
+ console.log("========================");
193668
+ }
193654
193669
 
193655
- await this.#generateRealFile(where);
193656
193670
 
193657
193671
  return "OK";
193658
193672
  }
@@ -193323,22 +193323,30 @@ class IdeUtils
193323
193323
 
193324
193324
  static extractResponse = (response, gptServer) => {
193325
193325
 
193326
- const extractJsonSnippet = (text) => {
193327
- //return text.replace(/```[\s\S]*?```/g, '').trim();
193328
- const match = text.match(/```json([\s\S]*?)```/);
193329
- return match ? match[1].trim() : text;
193326
+ const extractSnippet = (text) => {
193327
+ // 모든 종류의 마크다운 코드 블록 (```언어명 ... ```)을 제거
193328
+ // 언어명 없는 순수 ``` 블록도 포함
193329
+ const cleanedText = text.replace(/```(?:json|jsx|[\s\S]*?)?\s*([\s\S]*?)```/g, '').trim();
193330
+
193331
+ // 혹시라도 마크다운 코드 블록 외에 순수 JSON 문자열만 남았다면 그 부분을 반환
193332
+ // (이전 로직에서 JSON 블록만 추출하는 부분은 이제 필요 없을 가능성이 높습니다,
193333
+ // `replace`에서 이미 다 제거되었기 때문입니다.)
193334
+ // 하지만, 안전을 위해 만약 JSON이 아닌 다른 텍스트가 남았을 때도 처리할 수 있도록
193335
+ // 원본 텍스트에서 ```으로 감싸진 부분을 모두 제거하는 방식으로 변경합니다.
193336
+ return cleanedText;
193330
193337
  };
193331
193338
 
193339
+
193332
193340
  let r;
193333
193341
  switch (gptServer) {
193334
193342
  case "openai":
193335
- r = extractJsonSnippet(response.content.trim());
193343
+ r = extractSnippet(response.content.trim());
193336
193344
  break;
193337
193345
  case "gemini":
193338
- r = extractJsonSnippet(response.content.trim());
193346
+ r = extractSnippet(response.content.trim());
193339
193347
  break;
193340
193348
  case "ollama":
193341
- r = extractJsonSnippet(response);
193349
+ r = extractSnippet(response);
193342
193350
  break;
193343
193351
  }
193344
193352
 
@@ -193598,57 +193606,63 @@ class IdeAi
193598
193606
 
193599
193607
  generateSourceClient = async (userPrompt) => {
193600
193608
 
193601
- this.#createModel();
193609
+ try {
193610
+ this.#createModel();
193602
193611
 
193603
- await this.#what(userPrompt);
193604
- this.#parent.addMessage("명령을 이해했습니다.");
193612
+ const what = await this.#what(userPrompt);
193613
+ this.#parent.addMessage("명령을 이해했습니다.");
193605
193614
 
193606
- const where = await this.#where(userPrompt, this.#getMenuInfo(), await this.#getTableList());
193607
- this.#parent.addMessage("대상 메뉴와 테이블을 찾았습니다.");
193608
- console.log(where);
193615
+ const where = await this.#where(userPrompt, this.#getMenuInfo(), await this.#getTableList());
193616
+ this.#parent.addMessage("대상 메뉴와 테이블을 찾았습니다.");
193617
+ console.log(where);
193609
193618
 
193610
- const columnInfo = await this.#getColumnInfo(where.table);
193619
+ const columnInfo = await this.#getColumnInfo(where.table);
193611
193620
 
193612
- const namespace = where.package;
193613
- const classPackage = "ide.assi.be." + where.package.split(".").slice(0, -1).join(".");
193621
+ const namespace = where.package;
193622
+ const classPackage = "ide.assi.be." + where.package.split(".").slice(0, -1).join(".");
193614
193623
 
193615
- //const mybatisXmlSource = await this.#generateMyBatis(userPrompt, where.package, columnInfo);
193616
- const mybatisXmlSource = await this.#generateTmplFile("/prompts/meta/BuildMyBatisMapper.txt", "mybatis.xml", {
193617
- "userPrompt": userPrompt,
193618
- "namespace": namespace,
193619
- "tableDefinitions": columnInfo
193620
- });
193621
- this.#parent.addMessage("MyBatis 소스파일을 생성했습니다.");
193624
+ //const mybatisXmlSource = await this.#generateMyBatis(userPrompt, where.package, columnInfo);
193625
+ const mybatisXmlSource = await this.#generateTmplFile("/prompts/meta/BuildMyBatisMapper.txt", "mybatis.xml", {
193626
+ "userPrompt": userPrompt,
193627
+ "namespace": namespace,
193628
+ "tableDefinitions": columnInfo
193629
+ });
193630
+ this.#parent.addMessage("MyBatis 소스파일을 생성했습니다.");
193622
193631
 
193623
193632
 
193624
- const serviceSrc = await this.#generateTmplFile("/prompts/meta/BuildService.txt", "service.java", {
193625
- userPrompt: userPrompt,
193626
- menuUrl: where.menu.url,
193627
- classPackage: classPackage + ".service",
193628
- namespace: namespace,
193629
- mybatisXmlSource: mybatisXmlSource,
193630
- });
193631
- this.#parent.addMessage("Java(Service) 소스파일을 생성했습니다.");
193632
-
193633
- const controllerSrc = await this.#generateTmplFile("/prompts/meta/BuildController.txt", "controller.java", {
193634
- userPrompt: userPrompt,
193635
- menuUrl: where.menu.url,
193636
- classPackage: classPackage + ".controller",
193637
- namespace: namespace,
193638
- serviceSource: serviceSrc,
193639
- });
193640
- this.#parent.addMessage("Java(Controller) 소스파일을 생성했습니다.");
193641
-
193642
- await this.#generateTmplFile("/prompts/meta/BuildReactJsx.txt", "react.jsx", {
193643
- userPrompt: userPrompt,
193644
- menuUrl: where.menu.url,
193645
- menuName: where.menu.name,
193646
- controllerSource: controllerSrc,
193647
- tableDefinitions: columnInfo,
193648
- });
193649
- this.#parent.addMessage("Jsx(React) 소스파일을 생성했습니다.");
193633
+ const serviceSrc = await this.#generateTmplFile("/prompts/meta/BuildService.txt", "service.java", {
193634
+ userPrompt: userPrompt,
193635
+ menuUrl: where.menu.url,
193636
+ classPackage: classPackage + ".service",
193637
+ namespace: namespace,
193638
+ mybatisXmlSource: mybatisXmlSource,
193639
+ });
193640
+ this.#parent.addMessage("Java(Service) 소스파일을 생성했습니다.");
193641
+
193642
+ const controllerSrc = await this.#generateTmplFile("/prompts/meta/BuildController.txt", "controller.java", {
193643
+ userPrompt: userPrompt,
193644
+ menuUrl: where.menu.url,
193645
+ classPackage: classPackage + ".controller",
193646
+ namespace: namespace,
193647
+ serviceSource: serviceSrc,
193648
+ });
193649
+ this.#parent.addMessage("Java(Controller) 소스파일을 생성했습니다.");
193650
+
193651
+ const jsSrc = await this.#generateTmplFile("/prompts/meta/BuildReactJsx.txt", "react.jsx", {
193652
+ userPrompt: userPrompt,
193653
+ menuUrl: where.menu.url,
193654
+ menuName: where.menu.name,
193655
+ controllerSource: controllerSrc,
193656
+ tableDefinitions: columnInfo,
193657
+ });
193658
+ this.#parent.addMessage("Jsx(React) 소스파일을 생성했습니다.");
193659
+
193660
+ await this.#generateRealFile(where);
193661
+ }
193662
+ catch (error) {
193663
+ console.log("========================");
193664
+ }
193650
193665
 
193651
- await this.#generateRealFile(where);
193652
193666
 
193653
193667
  return "OK";
193654
193668
  }
@@ -268,57 +268,63 @@ export class IdeAi
268
268
 
269
269
  generateSourceClient = async (userPrompt) => {
270
270
 
271
- this.#createModel();
271
+ try {
272
+ this.#createModel();
272
273
 
273
- const what = await this.#what(userPrompt);
274
- this.#parent.addMessage("명령을 이해했습니다.");
274
+ const what = await this.#what(userPrompt);
275
+ this.#parent.addMessage("명령을 이해했습니다.");
275
276
 
276
- const where = await this.#where(userPrompt, this.#getMenuInfo(), await this.#getTableList());
277
- this.#parent.addMessage("대상 메뉴와 테이블을 찾았습니다.");
278
- console.log(where);
277
+ const where = await this.#where(userPrompt, this.#getMenuInfo(), await this.#getTableList());
278
+ this.#parent.addMessage("대상 메뉴와 테이블을 찾았습니다.");
279
+ console.log(where);
279
280
 
280
- const columnInfo = await this.#getColumnInfo(where.table);
281
+ const columnInfo = await this.#getColumnInfo(where.table);
281
282
 
282
- const namespace = where.package;
283
- const classPackage = "ide.assi.be." + where.package.split(".").slice(0, -1).join(".");
283
+ const namespace = where.package;
284
+ const classPackage = "ide.assi.be." + where.package.split(".").slice(0, -1).join(".");
284
285
 
285
- //const mybatisXmlSource = await this.#generateMyBatis(userPrompt, where.package, columnInfo);
286
- const mybatisXmlSource = await this.#generateTmplFile("/prompts/meta/BuildMyBatisMapper.txt", "mybatis.xml", {
287
- "userPrompt": userPrompt,
288
- "namespace": namespace,
289
- "tableDefinitions": columnInfo
290
- });
291
- this.#parent.addMessage("MyBatis 소스파일을 생성했습니다.");
286
+ //const mybatisXmlSource = await this.#generateMyBatis(userPrompt, where.package, columnInfo);
287
+ const mybatisXmlSource = await this.#generateTmplFile("/prompts/meta/BuildMyBatisMapper.txt", "mybatis.xml", {
288
+ "userPrompt": userPrompt,
289
+ "namespace": namespace,
290
+ "tableDefinitions": columnInfo
291
+ });
292
+ this.#parent.addMessage("MyBatis 소스파일을 생성했습니다.");
292
293
 
293
294
 
294
- const serviceSrc = await this.#generateTmplFile("/prompts/meta/BuildService.txt", "service.java", {
295
- userPrompt: userPrompt,
296
- menuUrl: where.menu.url,
297
- classPackage: classPackage + ".service",
298
- namespace: namespace,
299
- mybatisXmlSource: mybatisXmlSource,
300
- });
301
- this.#parent.addMessage("Java(Service) 소스파일을 생성했습니다.");
302
-
303
- const controllerSrc = await this.#generateTmplFile("/prompts/meta/BuildController.txt", "controller.java", {
304
- userPrompt: userPrompt,
305
- menuUrl: where.menu.url,
306
- classPackage: classPackage + ".controller",
307
- namespace: namespace,
308
- serviceSource: serviceSrc,
309
- });
310
- this.#parent.addMessage("Java(Controller) 소스파일을 생성했습니다.");
311
-
312
- const jsSrc = await this.#generateTmplFile("/prompts/meta/BuildReactJsx.txt", "react.jsx", {
313
- userPrompt: userPrompt,
314
- menuUrl: where.menu.url,
315
- menuName: where.menu.name,
316
- controllerSource: controllerSrc,
317
- tableDefinitions: columnInfo,
318
- });
319
- this.#parent.addMessage("Jsx(React) 소스파일을 생성했습니다.");
295
+ const serviceSrc = await this.#generateTmplFile("/prompts/meta/BuildService.txt", "service.java", {
296
+ userPrompt: userPrompt,
297
+ menuUrl: where.menu.url,
298
+ classPackage: classPackage + ".service",
299
+ namespace: namespace,
300
+ mybatisXmlSource: mybatisXmlSource,
301
+ });
302
+ this.#parent.addMessage("Java(Service) 소스파일을 생성했습니다.");
303
+
304
+ const controllerSrc = await this.#generateTmplFile("/prompts/meta/BuildController.txt", "controller.java", {
305
+ userPrompt: userPrompt,
306
+ menuUrl: where.menu.url,
307
+ classPackage: classPackage + ".controller",
308
+ namespace: namespace,
309
+ serviceSource: serviceSrc,
310
+ });
311
+ this.#parent.addMessage("Java(Controller) 소스파일을 생성했습니다.");
312
+
313
+ const jsSrc = await this.#generateTmplFile("/prompts/meta/BuildReactJsx.txt", "react.jsx", {
314
+ userPrompt: userPrompt,
315
+ menuUrl: where.menu.url,
316
+ menuName: where.menu.name,
317
+ controllerSource: controllerSrc,
318
+ tableDefinitions: columnInfo,
319
+ });
320
+ this.#parent.addMessage("Jsx(React) 소스파일을 생성했습니다.");
321
+
322
+ await this.#generateRealFile(where);
323
+ }
324
+ catch (error) {
325
+ console.log("========================");
326
+ }
320
327
 
321
- await this.#generateRealFile(where);
322
328
 
323
329
  return "OK";
324
330
  }
@@ -23,16 +23,30 @@ export class IdeUtils
23
23
  return match ? match[1].trim() : text;
24
24
  };
25
25
 
26
+ const extractSnippet = (text) => {
27
+ // 모든 종류의 마크다운 코드 블록 (```언어명 ... ```)을 제거
28
+ // 언어명 없는 순수 ``` 블록도 포함
29
+ const cleanedText = text.replace(/```(?:json|jsx|[\s\S]*?)?\s*([\s\S]*?)```/g, '').trim();
30
+
31
+ // 혹시라도 마크다운 코드 블록 외에 순수 JSON 문자열만 남았다면 그 부분을 반환
32
+ // (이전 로직에서 JSON 블록만 추출하는 부분은 이제 필요 없을 가능성이 높습니다,
33
+ // `replace`에서 이미 다 제거되었기 때문입니다.)
34
+ // 하지만, 안전을 위해 만약 JSON이 아닌 다른 텍스트가 남았을 때도 처리할 수 있도록
35
+ // 원본 텍스트에서 ```으로 감싸진 부분을 모두 제거하는 방식으로 변경합니다.
36
+ return cleanedText;
37
+ };
38
+
39
+
26
40
  let r;
27
41
  switch (gptServer) {
28
42
  case "openai":
29
- r = extractJsonSnippet(response.content.trim());
43
+ r = extractSnippet(response.content.trim());
30
44
  break;
31
45
  case "gemini":
32
- r = extractJsonSnippet(response.content.trim());
46
+ r = extractSnippet(response.content.trim());
33
47
  break;
34
48
  case "ollama":
35
- r = extractJsonSnippet(response);
49
+ r = extractSnippet(response);
36
50
  break;
37
51
  default:
38
52
  break;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ide-assi",
3
3
  "type": "module",
4
- "version": "0.155.0",
4
+ "version": "0.157.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
@@ -268,57 +268,63 @@ export class IdeAi
268
268
 
269
269
  generateSourceClient = async (userPrompt) => {
270
270
 
271
- this.#createModel();
271
+ try {
272
+ this.#createModel();
272
273
 
273
- const what = await this.#what(userPrompt);
274
- this.#parent.addMessage("명령을 이해했습니다.");
274
+ const what = await this.#what(userPrompt);
275
+ this.#parent.addMessage("명령을 이해했습니다.");
275
276
 
276
- const where = await this.#where(userPrompt, this.#getMenuInfo(), await this.#getTableList());
277
- this.#parent.addMessage("대상 메뉴와 테이블을 찾았습니다.");
278
- console.log(where);
277
+ const where = await this.#where(userPrompt, this.#getMenuInfo(), await this.#getTableList());
278
+ this.#parent.addMessage("대상 메뉴와 테이블을 찾았습니다.");
279
+ console.log(where);
279
280
 
280
- const columnInfo = await this.#getColumnInfo(where.table);
281
+ const columnInfo = await this.#getColumnInfo(where.table);
281
282
 
282
- const namespace = where.package;
283
- const classPackage = "ide.assi.be." + where.package.split(".").slice(0, -1).join(".");
283
+ const namespace = where.package;
284
+ const classPackage = "ide.assi.be." + where.package.split(".").slice(0, -1).join(".");
284
285
 
285
- //const mybatisXmlSource = await this.#generateMyBatis(userPrompt, where.package, columnInfo);
286
- const mybatisXmlSource = await this.#generateTmplFile("/prompts/meta/BuildMyBatisMapper.txt", "mybatis.xml", {
287
- "userPrompt": userPrompt,
288
- "namespace": namespace,
289
- "tableDefinitions": columnInfo
290
- });
291
- this.#parent.addMessage("MyBatis 소스파일을 생성했습니다.");
286
+ //const mybatisXmlSource = await this.#generateMyBatis(userPrompt, where.package, columnInfo);
287
+ const mybatisXmlSource = await this.#generateTmplFile("/prompts/meta/BuildMyBatisMapper.txt", "mybatis.xml", {
288
+ "userPrompt": userPrompt,
289
+ "namespace": namespace,
290
+ "tableDefinitions": columnInfo
291
+ });
292
+ this.#parent.addMessage("MyBatis 소스파일을 생성했습니다.");
292
293
 
293
294
 
294
- const serviceSrc = await this.#generateTmplFile("/prompts/meta/BuildService.txt", "service.java", {
295
- userPrompt: userPrompt,
296
- menuUrl: where.menu.url,
297
- classPackage: classPackage + ".service",
298
- namespace: namespace,
299
- mybatisXmlSource: mybatisXmlSource,
300
- });
301
- this.#parent.addMessage("Java(Service) 소스파일을 생성했습니다.");
302
-
303
- const controllerSrc = await this.#generateTmplFile("/prompts/meta/BuildController.txt", "controller.java", {
304
- userPrompt: userPrompt,
305
- menuUrl: where.menu.url,
306
- classPackage: classPackage + ".controller",
307
- namespace: namespace,
308
- serviceSource: serviceSrc,
309
- });
310
- this.#parent.addMessage("Java(Controller) 소스파일을 생성했습니다.");
311
-
312
- const jsSrc = await this.#generateTmplFile("/prompts/meta/BuildReactJsx.txt", "react.jsx", {
313
- userPrompt: userPrompt,
314
- menuUrl: where.menu.url,
315
- menuName: where.menu.name,
316
- controllerSource: controllerSrc,
317
- tableDefinitions: columnInfo,
318
- });
319
- this.#parent.addMessage("Jsx(React) 소스파일을 생성했습니다.");
295
+ const serviceSrc = await this.#generateTmplFile("/prompts/meta/BuildService.txt", "service.java", {
296
+ userPrompt: userPrompt,
297
+ menuUrl: where.menu.url,
298
+ classPackage: classPackage + ".service",
299
+ namespace: namespace,
300
+ mybatisXmlSource: mybatisXmlSource,
301
+ });
302
+ this.#parent.addMessage("Java(Service) 소스파일을 생성했습니다.");
303
+
304
+ const controllerSrc = await this.#generateTmplFile("/prompts/meta/BuildController.txt", "controller.java", {
305
+ userPrompt: userPrompt,
306
+ menuUrl: where.menu.url,
307
+ classPackage: classPackage + ".controller",
308
+ namespace: namespace,
309
+ serviceSource: serviceSrc,
310
+ });
311
+ this.#parent.addMessage("Java(Controller) 소스파일을 생성했습니다.");
312
+
313
+ const jsSrc = await this.#generateTmplFile("/prompts/meta/BuildReactJsx.txt", "react.jsx", {
314
+ userPrompt: userPrompt,
315
+ menuUrl: where.menu.url,
316
+ menuName: where.menu.name,
317
+ controllerSource: controllerSrc,
318
+ tableDefinitions: columnInfo,
319
+ });
320
+ this.#parent.addMessage("Jsx(React) 소스파일을 생성했습니다.");
321
+
322
+ await this.#generateRealFile(where);
323
+ }
324
+ catch (error) {
325
+ console.log("========================");
326
+ }
320
327
 
321
- await this.#generateRealFile(where);
322
328
 
323
329
  return "OK";
324
330
  }
@@ -23,16 +23,30 @@ export class IdeUtils
23
23
  return match ? match[1].trim() : text;
24
24
  };
25
25
 
26
+ const extractSnippet = (text) => {
27
+ // 모든 종류의 마크다운 코드 블록 (```언어명 ... ```)을 제거
28
+ // 언어명 없는 순수 ``` 블록도 포함
29
+ const cleanedText = text.replace(/```(?:json|jsx|[\s\S]*?)?\s*([\s\S]*?)```/g, '').trim();
30
+
31
+ // 혹시라도 마크다운 코드 블록 외에 순수 JSON 문자열만 남았다면 그 부분을 반환
32
+ // (이전 로직에서 JSON 블록만 추출하는 부분은 이제 필요 없을 가능성이 높습니다,
33
+ // `replace`에서 이미 다 제거되었기 때문입니다.)
34
+ // 하지만, 안전을 위해 만약 JSON이 아닌 다른 텍스트가 남았을 때도 처리할 수 있도록
35
+ // 원본 텍스트에서 ```으로 감싸진 부분을 모두 제거하는 방식으로 변경합니다.
36
+ return cleanedText;
37
+ };
38
+
39
+
26
40
  let r;
27
41
  switch (gptServer) {
28
42
  case "openai":
29
- r = extractJsonSnippet(response.content.trim());
43
+ r = extractSnippet(response.content.trim());
30
44
  break;
31
45
  case "gemini":
32
- r = extractJsonSnippet(response.content.trim());
46
+ r = extractSnippet(response.content.trim());
33
47
  break;
34
48
  case "ollama":
35
- r = extractJsonSnippet(response);
49
+ r = extractSnippet(response);
36
50
  break;
37
51
  default:
38
52
  break;