fix: restore repository runner token and implement missing syncToolSource method
Some checks failed
Deploy to OCIWP / deploy (push) Failing after 53s
Some checks failed
Deploy to OCIWP / deploy (push) Failing after 53s
This commit is contained in:
@@ -34,6 +34,46 @@ public final class ToolSourceUpdater {
|
||||
Files.writeString(targetFile, content, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
public static boolean syncToolSource(Path rootDirectory, String toolName, String title, String description,
|
||||
boolean readOnlyHint, boolean destructiveHint, boolean idempotentHint,
|
||||
String categoryKey) throws IOException {
|
||||
Path targetFile = findToolSource(rootDirectory, toolName);
|
||||
if (targetFile == null) {
|
||||
throw new IllegalArgumentException("Tool source not found: " + toolName);
|
||||
}
|
||||
|
||||
String content = Files.readString(targetFile, StandardCharsets.UTF_8);
|
||||
String originalContent = content;
|
||||
|
||||
AnnotationRange mcpRange = annotationArguments(content, "McpTool", toolName);
|
||||
if (mcpRange != null) {
|
||||
if (title != null) {
|
||||
content = replaceAttribute(content, mcpRange, "title", quote(title));
|
||||
mcpRange = annotationArguments(content, "McpTool", toolName);
|
||||
}
|
||||
if (description != null) {
|
||||
content = replaceAttribute(content, mcpRange, "description", quote(description));
|
||||
}
|
||||
}
|
||||
|
||||
AnnotationRange hintRange = annotationArguments(content, "GrowToolHint", null);
|
||||
if (hintRange != null) {
|
||||
if (categoryKey != null && !categoryKey.isBlank()) {
|
||||
content = replaceAttribute(content, hintRange, "categoryKey", quote(categoryKey));
|
||||
hintRange = annotationArguments(content, "GrowToolHint", null);
|
||||
}
|
||||
content = replaceAttribute(content, hintRange, "destructive", Boolean.toString(destructiveHint));
|
||||
hintRange = annotationArguments(content, "GrowToolHint", null);
|
||||
content = replaceAttribute(content, hintRange, "idempotent", Boolean.toString(idempotentHint));
|
||||
}
|
||||
|
||||
if (!content.equals(originalContent)) {
|
||||
Files.writeString(targetFile, content, StandardCharsets.UTF_8);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static Path findToolSource(Path rootDirectory, String toolName) throws IOException {
|
||||
try (var paths = Files.walk(rootDirectory)) {
|
||||
return paths.filter(Files::isRegularFile)
|
||||
|
||||
Reference in New Issue
Block a user