From 9c59092d9ca39b59d1b6347625b0ff7187188958 Mon Sep 17 00:00:00 2001 From: matevip Date: Sat, 25 Apr 2026 09:56:19 +0800 Subject: [PATCH] =?UTF-8?q?feat(wiki):=20PR-6=20skeleton=20=E2=80=94=20DTO?= =?UTF-8?q?s=20for=20structured=20eager=20output?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/vip/mate/wiki/dto/GeneratedPage.java | 28 +++++++++++++++++ .../java/vip/mate/wiki/dto/RouteResult.java | 30 +++++++++++++++++++ .../vip/mate/wiki/dto/RoutedPageMeta.java | 14 +++++++++ 3 files changed, 72 insertions(+) create mode 100644 mateclaw-server/src/main/java/vip/mate/wiki/dto/GeneratedPage.java create mode 100644 mateclaw-server/src/main/java/vip/mate/wiki/dto/RouteResult.java create mode 100644 mateclaw-server/src/main/java/vip/mate/wiki/dto/RoutedPageMeta.java diff --git a/mateclaw-server/src/main/java/vip/mate/wiki/dto/GeneratedPage.java b/mateclaw-server/src/main/java/vip/mate/wiki/dto/GeneratedPage.java new file mode 100644 index 00000000..87c6693f --- /dev/null +++ b/mateclaw-server/src/main/java/vip/mate/wiki/dto/GeneratedPage.java @@ -0,0 +1,28 @@ +package vip.mate.wiki.dto; + +import java.util.List; + +/** + * RFC-051 PR-6 (skeleton): structured create/merge output. + *

+ * Replaces the legacy {@code ---FILE---} block protocol used by + * {@code WikiBatchCreateParser}. {@code evidenceChunkIds} is optional and + * intended for the on-demand compile path so per-page citations bind to + * the chunks the prompt actually consumed. + *

+ * Fields are ordered to mirror the existing prompt template so the + * follow-up Spring-AI {@code BeanOutputConverter} swap is a one-shot + * replace of the parser, not a prompt rewrite. + */ +public record GeneratedPage( + String slug, + String title, + String summary, + String pageType, + String content, + List evidenceChunkIds +) { + public GeneratedPage { + if (evidenceChunkIds == null) evidenceChunkIds = List.of(); + } +} diff --git a/mateclaw-server/src/main/java/vip/mate/wiki/dto/RouteResult.java b/mateclaw-server/src/main/java/vip/mate/wiki/dto/RouteResult.java new file mode 100644 index 00000000..f5c0cbfd --- /dev/null +++ b/mateclaw-server/src/main/java/vip/mate/wiki/dto/RouteResult.java @@ -0,0 +1,30 @@ +package vip.mate.wiki.dto; + +import java.util.List; + +/** + * RFC-051 PR-6 (skeleton): structured route-phase output. + *

+ * Today {@code processChunkTwoPhase} parses the route LLM's free-form JSON + * with a hand-rolled extractor, which fails on weak models that emit + * trailing commentary or mismatched braces. The follow-up wiring will use + * Spring AI {@code BeanOutputConverter} so the prompt and the + * parser share one schema. + *

+ * Defining the type up-front (PR-6 partial) lets the prompt rewrite, parser + * swap, and call-site change land in one cohesive PR without renames. + * + * @param create new pages the router proposes (slug + title + summary) + * @param update slugs of existing pages that should absorb this chunk + */ +public record RouteResult(List create, List update) { + + public RouteResult { + if (create == null) create = List.of(); + if (update == null) update = List.of(); + } + + public boolean isEmpty() { + return create.isEmpty() && update.isEmpty(); + } +} diff --git a/mateclaw-server/src/main/java/vip/mate/wiki/dto/RoutedPageMeta.java b/mateclaw-server/src/main/java/vip/mate/wiki/dto/RoutedPageMeta.java new file mode 100644 index 00000000..09f4c7fc --- /dev/null +++ b/mateclaw-server/src/main/java/vip/mate/wiki/dto/RoutedPageMeta.java @@ -0,0 +1,14 @@ +package vip.mate.wiki.dto; + +/** + * RFC-051 PR-6 (skeleton): one entry of {@link RouteResult#create()}. + *

+ * {@code purposeHint} is optional; when populated by the router it feeds + * the create-page prompt's framing. + */ +public record RoutedPageMeta(String slug, String title, String summary, String purposeHint) { + + public RoutedPageMeta(String slug, String title, String summary) { + this(slug, title, summary, null); + } +}