feat: add AI feature package revisions
This commit is contained in:
@@ -87,9 +87,16 @@ public final class Eip4Cli {
|
||||
printAiHelp(out);
|
||||
return 0;
|
||||
}
|
||||
if (!"auto-develop".equals(args[1])) {
|
||||
return fail(err, "Unknown ai command: " + args[1]);
|
||||
}
|
||||
return switch (args[1]) {
|
||||
case "auto-develop" -> runAiAutoDevelop(args, out, err);
|
||||
case "feature-package" -> runAiFeaturePackage(args, out, err);
|
||||
case "revision" -> runAiRevision(args, out, err);
|
||||
default -> fail(err, "Unknown ai command: " + args[1]);
|
||||
};
|
||||
}
|
||||
|
||||
private int runAiAutoDevelop(String[] args, PrintStream out, PrintStream err)
|
||||
throws IOException, InterruptedException {
|
||||
Options options = Options.parse(args, 2);
|
||||
ObjectNode request = buildAutoDevelopRequest(options);
|
||||
String baseUrl = baseUrl(options);
|
||||
@@ -97,8 +104,42 @@ public final class Eip4Cli {
|
||||
"POST",
|
||||
endpoint(baseUrl, "/api/ai/features/auto-develop"),
|
||||
request);
|
||||
return writeJsonResponse(response, options, out, err, "AI auto-develop failed", true);
|
||||
}
|
||||
|
||||
private int runAiFeaturePackage(String[] args, PrintStream out, PrintStream err)
|
||||
throws IOException, InterruptedException {
|
||||
Options options = Options.parse(args, 2);
|
||||
String taskId = requiredPart(options.single("task-id"), "task-id");
|
||||
String changeSetId = requiredPart(options.single("change-set-id"), "change-set-id");
|
||||
Eip4HttpResponse response = httpClient.send(
|
||||
"POST",
|
||||
endpoint(baseUrl(options), "/api/ai/tasks/" + taskId
|
||||
+ "/change-sets/" + changeSetId + "/feature-package"),
|
||||
null);
|
||||
return writeJsonResponse(response, options, out, err, "AI feature-package failed", false);
|
||||
}
|
||||
|
||||
private int runAiRevision(String[] args, PrintStream out, PrintStream err)
|
||||
throws IOException, InterruptedException {
|
||||
Options options = Options.parse(args, 2);
|
||||
String taskId = requiredPart(options.single("task-id"), "task-id");
|
||||
String packageId = requiredPart(options.single("package-id"), "package-id");
|
||||
ObjectNode request = objectMapper.createObjectNode();
|
||||
request.put("note", options.single("note") == null ? "" : options.single("note"));
|
||||
Eip4HttpResponse response = httpClient.send(
|
||||
"POST",
|
||||
endpoint(baseUrl(options), "/api/ai/tasks/" + taskId
|
||||
+ "/feature-packages/" + packageId + "/revisions"),
|
||||
request);
|
||||
return writeJsonResponse(response, options, out, err, "AI revision failed", false);
|
||||
}
|
||||
|
||||
private int writeJsonResponse(Eip4HttpResponse response, Options options, PrintStream out, PrintStream err,
|
||||
String failureMessage, boolean autoDevelopSummary)
|
||||
throws IOException {
|
||||
if (!response.successful()) {
|
||||
err.println("AI auto-develop failed");
|
||||
err.println(failureMessage);
|
||||
err.println("status: " + response.statusCode());
|
||||
err.println(response.body());
|
||||
return 2;
|
||||
@@ -117,7 +158,11 @@ public final class Eip4Cli {
|
||||
}
|
||||
Files.writeString(outputPath, formatted + System.lineSeparator(), StandardCharsets.UTF_8);
|
||||
out.println("Wrote run result: " + outputPath.toAbsolutePath());
|
||||
printAutoDevelopSummary(body, out);
|
||||
if (autoDevelopSummary) {
|
||||
printAutoDevelopSummary(body, out);
|
||||
} else {
|
||||
printGenericSummary(body, out);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -207,6 +252,14 @@ public final class Eip4Cli {
|
||||
}
|
||||
}
|
||||
|
||||
private void printGenericSummary(JsonNode body, PrintStream out) {
|
||||
out.println("id: " + text(body, "id"));
|
||||
out.println("status: " + text(body, "status"));
|
||||
out.println("taskId: " + text(body, "taskId"));
|
||||
out.println("changeSetId: " + text(body, "changeSetId"));
|
||||
out.println("packageId: " + text(body, "packageId"));
|
||||
}
|
||||
|
||||
private String text(JsonNode node, String field) {
|
||||
JsonNode value = node.path(field);
|
||||
return value.isMissingNode() || value.isNull() ? "" : value.asText();
|
||||
@@ -261,8 +314,10 @@ public final class Eip4Cli {
|
||||
out.println("""
|
||||
Usage:
|
||||
eip4 ai auto-develop [options]
|
||||
eip4 ai feature-package --task-id ID --change-set-id ID [--base-url URL] [--output FILE]
|
||||
eip4 ai revision --task-id ID --package-id ID [--note TEXT] [--base-url URL] [--output FILE]
|
||||
|
||||
Required:
|
||||
Required for auto-develop:
|
||||
--objective TEXT
|
||||
--feature-name NAME
|
||||
--table-name TABLE
|
||||
@@ -271,6 +326,14 @@ public final class Eip4Cli {
|
||||
--menu-name NAME
|
||||
--field column:label:type[:length][:required]
|
||||
|
||||
Required for feature-package:
|
||||
--task-id ID
|
||||
--change-set-id ID
|
||||
|
||||
Required for revision:
|
||||
--task-id ID
|
||||
--package-id ID
|
||||
|
||||
Optional:
|
||||
--base-url URL
|
||||
--max-repair-attempts N
|
||||
|
||||
Reference in New Issue
Block a user