feat: add tabular Work summaries and CSV exports
Test / Tests and coverage occurred while executing withChecks step.
Intrepid/AI Engineering/pipeline/head There was a failure building this commit
build / jvm (push) Canceled after 0s
build / native (macos-15, macos-arm64) (push) Canceled after 0s
build / native (ubuntu-24.04, linux-x86_64) (push) Canceled after 0s
build / native (windows-2025, windows-x86_64) (push) Canceled after 0s

This commit is contained in:
Nilton Constantino
2026-11-16 15:59:26 +00:00
parent f296d252c6
commit a7e3a2fdfc
21 changed files with 642 additions and 5 deletions
@@ -0,0 +1,127 @@
package net.intrepid.aiengineering;
import net.intrepid.aiengineering.cli.EngineeringCli;
import net.intrepid.aiengineering.filesystem.Documents;
import net.intrepid.aiengineering.verification.VerificationService;
import net.intrepid.aiengineering.work.WorkService;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import tools.jackson.databind.JsonNode;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Map;
import java.util.TreeMap;
import static org.assertj.core.api.Assertions.*;
class ListingTest {
@TempDir Path root;
private String output;
private int cli(String... args) {
var out = new StringWriter(); var err = new StringWriter();
int code = new EngineeringCli(root).execute(new PrintWriter(out), new PrintWriter(err), args);
output = out + err.toString(); return code;
}
private String ok(String... args) { assertThat(cli(args)).as(output).isZero(); return output; }
private JsonNode json(String text) { return Documents.parseJson(text, JsonNode.class); }
private void init() { ok("init", "--name", "List project"); }
private void create(String title) { ok("work", "create", title, "--acceptance", "Verified fixture"); }
private void evidence(String work) throws Exception {
Path result = Files.writeString(root.resolve("result.txt"), "Observed fixture result\n");
ok("artifact", "add", work, "--file", result.toString(), "--purpose", "Observed fixture");
}
private Map<String, String> snapshot() throws Exception {
var result = new TreeMap<String, String>();
try (var paths = Files.walk(root.resolve(".ai-engineering"))) {
for (var path : paths.filter(Files::isRegularFile).toList()) result.put(root.relativize(path).toString(), Files.readString(path));
}
return result;
}
@Test void summariesUseRegisteredStepsAndExistingActionsWithoutChangingJsonOrFiles() throws Exception {
init(); create("Revisão, \"CLI\" | <tag>\\path\nsegunda linha"); evidence("WRK-0001");
ok("plan", "create", "WRK-0001", "--title", "First");
for (String title : new String[]{"Done", "Blocked", "Cancelled"})
ok("plan", "step", "add", "WRK-0001", "PLN-0001", "--title", title);
ok("plan", "step", "status", "WRK-0001", "PLN-0001", "TSK-0001", "COMPLETED", "--by", "fixture",
"--reason", "Observed", "--evidence", "ART-0001");
ok("plan", "step", "status", "WRK-0001", "PLN-0001", "TSK-0002", "BLOCKED", "--by", "fixture", "--reason", "Investigate");
ok("plan", "step", "status", "WRK-0001", "PLN-0001", "TSK-0003", "CANCELLED", "--by", "fixture", "--reason", "Scope review needed");
ok("plan", "create", "WRK-0001", "--title", "Second");
ok("plan", "step", "add", "WRK-0001", "PLN-0002", "--title", "Next");
ok("discussion", "add", "WRK-0001", "--kind", "QUESTION", "--text", "Which, \"scope\"?\nFollow up | detail");
ok("decision", "draft", "WRK-0001", "--title", "Pending decision");
ok("survey", "create", "WRK-0001", "--title", "Empty survey");
var before = snapshot();
var actions = new VerificationService().nextActions(root, "WRK-0001");
for (String format : new String[]{"table", "markdown", "csv"}) {
String list = ok("work", "list", "--format", format);
assertThat(list).contains("WRK-0001", "1/4", "aie discussion add WRK-0001 --help");
String status = ok("status", "--format", format);
assertThat(status).contains(list);
String next = ok("next-actions", "WRK-0001", "--format", format);
assertThat(next.replace("&#95;", "_")).contains("RESPOND", "ADD_QUESTION", "REVIEW_DECISION", "INVESTIGATE", "EXECUTE_STEP");
}
assertThat(ok("work", "list")).startsWith("| ID | Title | Status |").contains("&#124;", "&lt;tag&gt;", "&#92;path<br>segunda linha");
assertThat(ok("work", "list", "--format", "csv")).startsWith("id,title,status,archived,steps,pending_actions,validation,next_action\r\n")
.contains("\"Revisão, \"\"CLI\"\" | <tag>\\path\nsegunda linha\",OPEN,false,1/4," + actions.size() + ",valid,");
assertThat(ok("next-actions", "WRK-0001", "--format", "csv")).contains("\"DSC-0001: Which, \"\"scope\"\"?\nFollow up | detail\"");
assertThat(ok("work", "list", "--format", "table")).doesNotContain("path\nsegunda", "<br>", "&#124;");
assertThat(ok("work", "list", "--format", "json")).isEqualTo(Documents.json(new WorkService().list(root)));
assertThat(ok("status", "--format", "json")).isEqualTo(Documents.json(new VerificationService().status(root, false)));
assertThat(ok("next-actions", "WRK-0001", "--format", "json")).isEqualTo(Documents.json(actions));
assertThat(snapshot()).isEqualTo(before);
}
@Test void openFilterIncludesOpenActiveAndBlockedAcrossFormatsAndRetainsArchiveDefaults() throws Exception {
init();
for (String title : new String[]{"Open", "Active", "Blocked", "Cancelled", "Completed", "Archived"}) create(title);
ok("work", "status", "WRK-0002", "ACTIVE"); ok("work", "status", "WRK-0003", "BLOCKED");
ok("work", "status", "WRK-0004", "CANCELLED"); ok("work", "status", "WRK-0006", "CANCELLED");
ok("work", "archive", "WRK-0006", "--by", "fixture", "--reason", "Keep history");
evidence("WRK-0005");
ok("work", "complete", "WRK-0005", "--by", "fixture-human", "--human-approved", "--summary", "Fixture reviewed",
"--criterion", "1=ART-0001", "--no-integration-needed", "Disposable fixture");
var before = snapshot();
for (String format : new String[]{"table", "markdown", "csv", "json"}) {
assertThat(ok("work", "list", "--open", "--format", format)).contains("WRK-0001", "WRK-0002", "WRK-0003")
.doesNotContain("WRK-0004", "WRK-0005", "WRK-0006");
assertThat(ok("work", "list", "--format", format)).contains("WRK-0004", "WRK-0005", "WRK-0006");
assertThat(ok("status", "--format", format)).contains("WRK-0004", "WRK-0005").doesNotContain("WRK-0006");
assertThat(ok("status", "--all", "--format", format)).contains("WRK-0006");
assertThat(ok("next-actions", "--format", format)).doesNotContain("WRK-0006");
assertThat(ok("next-actions", "WRK-0006", "--format", format)).contains("REOPEN");
}
assertThat(json(ok("work", "list", "--open", "--format", "json")).size()).isEqualTo(3);
assertThat(snapshot()).isEqualTo(before);
}
@Test void emptyListingsHaveHeadersAndUnknownFormatsFailBeforeWriting() throws Exception {
init(); var before = snapshot();
assertThat(ok("work", "list", "--open", "--format", "CSV"))
.isEqualTo("id,title,status,archived,steps,pending_actions,validation,next_action\r\n");
assertThat(ok("next-actions", "--format", "csv")).isEqualTo("work_id,code,message,command\r\n");
assertThat(ok("status", "--format", "csv")).isEqualTo("id,title,status,archived,steps,pending_actions,validation,next_action\r\n");
for (String format : new String[]{"table", "markdown"}) {
assertThat(ok("work", "list", "--open", "--format", format)).contains("ID", "Title").doesNotContain("WRK-");
assertThat(ok("next-actions", "--format", format)).contains("Work", "Command").doesNotContain("WRK-");
}
assertThat(cli("work", "list", "--format", "xml")).isEqualTo(2);
assertThat(cli("work", "show", "WRK-0001", "--format", "table")).isEqualTo(2);
assertThat(cli("next-actions", "WRK-9999", "--format", "table")).isEqualTo(3);
assertThat(snapshot()).isEqualTo(before);
}
@Test void invalidPlansStayVisibleWithRepairActionAndUnavailableProgress() throws Exception {
init(); create("Repairable"); ok("plan", "create", "WRK-0001", "--title", "Broken plan");
Path path = root.resolve(".ai-engineering/works/WRK-0001-repairable/plans/PLN-0001.md");
Files.writeString(path, "not a plan\n"); var before = snapshot();
for (String format : new String[]{"table", "markdown", "csv"}) {
assertThat(ok("work", "list", "--open", "--format", format)).contains("WRK-0001", "INVALID", "unavailable", "aie work validate WRK-0001");
assertThat(ok("status", "--format", format)).contains("INVALID", "unavailable");
assertThat(ok("next-actions", "WRK-0001", "--format", format).replace("&#95;", "_")).contains("REPAIR_PROTOCOL");
}
assertThat(snapshot()).isEqualTo(before);
}
}