Feat: Update ToolScaffolder to generate dynamic tool names and auto-inject YAML config

This commit is contained in:
jade
2026-07-06 17:47:55 +09:00
parent f35827bef4
commit 5d25a23aac

View File

@@ -94,6 +94,8 @@ public class ToolScaffolder {
""".formatted(BASE_PACKAGE, baseName); """.formatted(BASE_PACKAGE, baseName);
Files.writeString(dtoDir.resolve(baseName + "Res.java"), resContent); Files.writeString(dtoDir.resolve(baseName + "Res.java"), resContent);
String toolName = baseName.toLowerCase();
// Generate Service // Generate Service
String serviceContent = """ String serviceContent = """
package %s.service; package %s.service;
@@ -112,7 +114,7 @@ public class ToolScaffolder {
public class %sService extends AbstractMcpToolService { public class %sService extends AbstractMcpToolService {
@McpFunction( @McpFunction(
name = "execute", name = "%s",
description = "%s", description = "%s",
prompt = "%s", prompt = "%s",
mappingId = "%s" mappingId = "%s"
@@ -130,6 +132,7 @@ public class ToolScaffolder {
routingType, routingType,
group, group,
baseName, baseName,
toolName,
description, description,
description + " 해줘.", description + " 해줘.",
interfaceId, interfaceId,
@@ -140,6 +143,24 @@ public class ToolScaffolder {
Files.writeString(serviceDir.resolve(baseName + "Service.java"), serviceContent); Files.writeString(serviceDir.resolve(baseName + "Service.java"), serviceContent);
// Append to YAML if exists
Path yamlPath = Paths.get(moduleName, "src/main/resources", "application-local.yml");
if (Files.exists(yamlPath)) {
String yamlContent = Files.readString(yamlPath);
if (yamlContent.contains("functions:")) {
String newFunctionYaml = """
%s:
description: "%s"
prompt: "%s"
mappingId: "%s"
""".formatted(toolName, description, description + " 해줘.", interfaceId);
yamlContent = yamlContent.replaceFirst("functions:", "functions:" + newFunctionYaml);
Files.writeString(yamlPath, yamlContent);
System.out.println("[YAML] " + yamlPath + " (함수 설정 자동 등록됨)");
}
}
System.out.println("\n========================================="); System.out.println("\n=========================================");
System.out.println("✅ Scaffolding Complete!"); System.out.println("✅ Scaffolding Complete!");
System.out.println("========================================="); System.out.println("=========================================");