@autoview/cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +407 -0
- package/lib/AutoViewAgent.d.ts +109 -0
- package/lib/AutoViewAgent.js +123 -0
- package/lib/AutoViewAgent.js.map +1 -0
- package/lib/agent/emitMcpServer.d.ts +15 -0
- package/lib/agent/emitMcpServer.js +157 -0
- package/lib/agent/emitMcpServer.js.map +1 -0
- package/lib/agent/emitReport.d.ts +14 -0
- package/lib/agent/emitReport.js +85 -0
- package/lib/agent/emitReport.js.map +1 -0
- package/lib/agent/toolSurface.d.ts +130 -0
- package/lib/agent/toolSurface.js +342 -0
- package/lib/agent/toolSurface.js.map +1 -0
- package/lib/agent/verifyAgentTasks.d.ts +87 -0
- package/lib/agent/verifyAgentTasks.js +126 -0
- package/lib/agent/verifyAgentTasks.js.map +1 -0
- package/lib/cli/main.d.ts +2 -0
- package/lib/cli/main.js +295 -0
- package/lib/cli/main.js.map +1 -0
- package/lib/compiler/AutoViewInterfaceCompiler.d.ts +27 -0
- package/lib/compiler/AutoViewInterfaceCompiler.js +68 -0
- package/lib/compiler/AutoViewInterfaceCompiler.js.map +1 -0
- package/lib/constants/AutoViewFrontendTemplate.d.ts +1 -0
- package/lib/constants/AutoViewFrontendTemplate.js +46 -0
- package/lib/constants/AutoViewFrontendTemplate.js.map +1 -0
- package/lib/constants/AutoViewSystemPromptConstant.d.ts +5 -0
- package/lib/constants/AutoViewSystemPromptConstant.js +4 -0
- package/lib/constants/AutoViewSystemPromptConstant.js.map +1 -0
- package/lib/context/IAutoViewAgentContext.d.ts +60 -0
- package/lib/context/IAutoViewAgentContext.js +3 -0
- package/lib/context/IAutoViewAgentContext.js.map +1 -0
- package/lib/fromSwagger.d.ts +53 -0
- package/lib/fromSwagger.js +513 -0
- package/lib/fromSwagger.js.map +1 -0
- package/lib/generateDeterministic.d.ts +26 -0
- package/lib/generateDeterministic.js +75 -0
- package/lib/generateDeterministic.js.map +1 -0
- package/lib/index.d.ts +15 -0
- package/lib/index.js +41 -0
- package/lib/index.js.map +1 -0
- package/lib/orchestrate/orchestrateAutoView.d.ts +17 -0
- package/lib/orchestrate/orchestrateAutoView.js +491 -0
- package/lib/orchestrate/orchestrateAutoView.js.map +1 -0
- package/lib/orchestrate/orchestrateAutoViewProductPlan.d.ts +37 -0
- package/lib/orchestrate/orchestrateAutoViewProductPlan.js +109 -0
- package/lib/orchestrate/orchestrateAutoViewProductPlan.js.map +1 -0
- package/lib/orchestrate/orchestrateAutoViewRender.d.ts +133 -0
- package/lib/orchestrate/orchestrateAutoViewRender.js +943 -0
- package/lib/orchestrate/orchestrateAutoViewRender.js.map +1 -0
- package/lib/orchestrate/orchestrateAutoViewRenderDeterministic.d.ts +24 -0
- package/lib/orchestrate/orchestrateAutoViewRenderDeterministic.js +92 -0
- package/lib/orchestrate/orchestrateAutoViewRenderDeterministic.js.map +1 -0
- package/lib/orchestrate/orchestrateAutoViewReview.d.ts +48 -0
- package/lib/orchestrate/orchestrateAutoViewReview.js +328 -0
- package/lib/orchestrate/orchestrateAutoViewReview.js.map +1 -0
- package/lib/orchestrate/orchestrateAutoViewScaffold.d.ts +45 -0
- package/lib/orchestrate/orchestrateAutoViewScaffold.js +586 -0
- package/lib/orchestrate/orchestrateAutoViewScaffold.js.map +1 -0
- package/lib/orchestrate/orchestrateAutoViewSdkStudy.d.ts +26 -0
- package/lib/orchestrate/orchestrateAutoViewSdkStudy.js +85 -0
- package/lib/orchestrate/orchestrateAutoViewSdkStudy.js.map +1 -0
- package/lib/orchestrate/structures/IAutoViewProductPlan.d.ts +96 -0
- package/lib/orchestrate/structures/IAutoViewProductPlan.js +3 -0
- package/lib/orchestrate/structures/IAutoViewProductPlan.js.map +1 -0
- package/lib/orchestrate/structures/IAutoViewProductPlanApplication.d.ts +38 -0
- package/lib/orchestrate/structures/IAutoViewProductPlanApplication.js +3 -0
- package/lib/orchestrate/structures/IAutoViewProductPlanApplication.js.map +1 -0
- package/lib/orchestrate/structures/IAutoViewRenderApplication.d.ts +38 -0
- package/lib/orchestrate/structures/IAutoViewRenderApplication.js +3 -0
- package/lib/orchestrate/structures/IAutoViewRenderApplication.js.map +1 -0
- package/lib/orchestrate/structures/IAutoViewReviewApplication.d.ts +40 -0
- package/lib/orchestrate/structures/IAutoViewReviewApplication.js +3 -0
- package/lib/orchestrate/structures/IAutoViewReviewApplication.js.map +1 -0
- package/lib/orchestrate/structures/IAutoViewSdkMap.d.ts +63 -0
- package/lib/orchestrate/structures/IAutoViewSdkMap.js +3 -0
- package/lib/orchestrate/structures/IAutoViewSdkMap.js.map +1 -0
- package/lib/orchestrate/structures/IAutoViewSdkStudyApplication.d.ts +37 -0
- package/lib/orchestrate/structures/IAutoViewSdkStudyApplication.js +3 -0
- package/lib/orchestrate/structures/IAutoViewSdkStudyApplication.js.map +1 -0
- package/lib/orchestrate/utils/HistoryMessage.d.ts +10 -0
- package/lib/orchestrate/utils/HistoryMessage.js +25 -0
- package/lib/orchestrate/utils/HistoryMessage.js.map +1 -0
- package/lib/orchestrate/utils/auditFrontendRuntime.d.ts +53 -0
- package/lib/orchestrate/utils/auditFrontendRuntime.js +362 -0
- package/lib/orchestrate/utils/auditFrontendRuntime.js.map +1 -0
- package/lib/orchestrate/utils/buildDeterministicPlan.d.ts +4 -0
- package/lib/orchestrate/utils/buildDeterministicPlan.js +233 -0
- package/lib/orchestrate/utils/buildDeterministicPlan.js.map +1 -0
- package/lib/orchestrate/utils/buildDeterministicSdkMap.d.ts +22 -0
- package/lib/orchestrate/utils/buildDeterministicSdkMap.js +154 -0
- package/lib/orchestrate/utils/buildDeterministicSdkMap.js.map +1 -0
- package/lib/orchestrate/utils/cacheNodeModules.d.ts +31 -0
- package/lib/orchestrate/utils/cacheNodeModules.js +134 -0
- package/lib/orchestrate/utils/cacheNodeModules.js.map +1 -0
- package/lib/orchestrate/utils/describeEndpointPropsShape.d.ts +37 -0
- package/lib/orchestrate/utils/describeEndpointPropsShape.js +192 -0
- package/lib/orchestrate/utils/describeEndpointPropsShape.js.map +1 -0
- package/lib/orchestrate/utils/describeEndpointRequestBodyShape.d.ts +22 -0
- package/lib/orchestrate/utils/describeEndpointRequestBodyShape.js +29 -0
- package/lib/orchestrate/utils/describeEndpointRequestBodyShape.js.map +1 -0
- package/lib/orchestrate/utils/describeEndpointResponseShape.d.ts +19 -0
- package/lib/orchestrate/utils/describeEndpointResponseShape.js +30 -0
- package/lib/orchestrate/utils/describeEndpointResponseShape.js.map +1 -0
- package/lib/orchestrate/utils/executeCachedBatch.d.ts +22 -0
- package/lib/orchestrate/utils/executeCachedBatch.js +64 -0
- package/lib/orchestrate/utils/executeCachedBatch.js.map +1 -0
- package/lib/orchestrate/utils/loadShoppingFixture.d.ts +33 -0
- package/lib/orchestrate/utils/loadShoppingFixture.js +17 -0
- package/lib/orchestrate/utils/loadShoppingFixture.js.map +1 -0
- package/lib/orchestrate/utils/normalizeProductPlanPaths.d.ts +24 -0
- package/lib/orchestrate/utils/normalizeProductPlanPaths.js +77 -0
- package/lib/orchestrate/utils/normalizeProductPlanPaths.js.map +1 -0
- package/lib/orchestrate/utils/renderJsonSchema.d.ts +23 -0
- package/lib/orchestrate/utils/renderJsonSchema.js +122 -0
- package/lib/orchestrate/utils/renderJsonSchema.js.map +1 -0
- package/lib/orchestrate/utils/renderResourcePage.d.ts +36 -0
- package/lib/orchestrate/utils/renderResourcePage.js +1415 -0
- package/lib/orchestrate/utils/renderResourcePage.js.map +1 -0
- package/lib/orchestrate/utils/validateFrontendTypecheck.d.ts +109 -0
- package/lib/orchestrate/utils/validateFrontendTypecheck.js +274 -0
- package/lib/orchestrate/utils/validateFrontendTypecheck.js.map +1 -0
- package/lib/preview/renderPreview.d.ts +22 -0
- package/lib/preview/renderPreview.js +198 -0
- package/lib/preview/renderPreview.js.map +1 -0
- package/lib/typings/compiler.d.ts +39 -0
- package/lib/typings/compiler.js +3 -0
- package/lib/typings/compiler.js.map +1 -0
- package/lib/typings/events.d.ts +106 -0
- package/lib/typings/events.js +3 -0
- package/lib/typings/events.js.map +1 -0
- package/lib/typings/index.d.ts +10 -0
- package/lib/typings/index.js +27 -0
- package/lib/typings/index.js.map +1 -0
- package/lib/typings/misc.d.ts +78 -0
- package/lib/typings/misc.js +3 -0
- package/lib/typings/misc.js.map +1 -0
- package/lib/utils/ArrayUtil.d.ts +8 -0
- package/lib/utils/ArrayUtil.js +30 -0
- package/lib/utils/ArrayUtil.js.map +1 -0
- package/lib/utils/StringUtil.d.ts +11 -0
- package/lib/utils/StringUtil.js +28 -0
- package/lib/utils/StringUtil.js.map +1 -0
- package/lib/utils/classifyEndpoints.d.ts +62 -0
- package/lib/utils/classifyEndpoints.js +216 -0
- package/lib/utils/classifyEndpoints.js.map +1 -0
- package/lib/utils/endpointFilter.d.ts +26 -0
- package/lib/utils/endpointFilter.js +0 -0
- package/lib/utils/endpointFilter.js.map +1 -0
- package/lib/utils/extractFields.d.ts +85 -0
- package/lib/utils/extractFields.js +231 -0
- package/lib/utils/extractFields.js.map +1 -0
- package/lib/utils/index.d.ts +13 -0
- package/lib/utils/index.js +30 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/normalizeForNestia.d.ts +34 -0
- package/lib/utils/normalizeForNestia.js +133 -0
- package/lib/utils/normalizeForNestia.js.map +1 -0
- package/lib/utils/resourcePlan.d.ts +39 -0
- package/lib/utils/resourcePlan.js +95 -0
- package/lib/utils/resourcePlan.js.map +1 -0
- package/lib/utils/sliceDocument.d.ts +17 -0
- package/lib/utils/sliceDocument.js +114 -0
- package/lib/utils/sliceDocument.js.map +1 -0
- package/lib/utils/toEndpoints.d.ts +90 -0
- package/lib/utils/toEndpoints.js +227 -0
- package/lib/utils/toEndpoints.js.map +1 -0
- package/lib/verify/runWorkflows.d.ts +25 -0
- package/lib/verify/runWorkflows.js +366 -0
- package/lib/verify/runWorkflows.js.map +1 -0
- package/lib/verify/workflows.d.ts +53 -0
- package/lib/verify/workflows.js +107 -0
- package/lib/verify/workflows.js.map +1 -0
- package/package.json +82 -0
- package/prompts/AUTOVIEW_RENDER.md +398 -0
- package/prompts/AUTOVIEW_REVIEW.md +60 -0
- package/prompts/AUTOVIEW_SDK_STUDY.md +89 -0
- package/src/AutoViewAgent.ts +222 -0
- package/src/agent/emitMcpServer.integration.test.ts +168 -0
- package/src/agent/emitMcpServer.test.ts +51 -0
- package/src/agent/emitMcpServer.ts +178 -0
- package/src/agent/emitReport.ts +117 -0
- package/src/agent/toolSurface.test.ts +243 -0
- package/src/agent/toolSurface.ts +501 -0
- package/src/agent/verifyAgentTasks.test.ts +106 -0
- package/src/agent/verifyAgentTasks.ts +171 -0
- package/src/cli/main.ts +363 -0
- package/src/compiler/AutoViewInterfaceCompiler.ts +69 -0
- package/src/constants/AutoViewFrontendTemplate.ts +42 -0
- package/src/constants/AutoViewSystemPromptConstant.ts +6 -0
- package/src/context/IAutoViewAgentContext.ts +84 -0
- package/src/fromSwagger.test.ts +269 -0
- package/src/fromSwagger.ts +500 -0
- package/src/generateDeterministic.test.ts +39 -0
- package/src/generateDeterministic.ts +77 -0
- package/src/index.ts +30 -0
- package/src/orchestrate/orchestrateAutoView.ts +590 -0
- package/src/orchestrate/orchestrateAutoViewProductPlan.ts +121 -0
- package/src/orchestrate/orchestrateAutoViewRender.ts +1117 -0
- package/src/orchestrate/orchestrateAutoViewRenderDeterministic.ts +101 -0
- package/src/orchestrate/orchestrateAutoViewReview.ts +272 -0
- package/src/orchestrate/orchestrateAutoViewScaffold.ts +627 -0
- package/src/orchestrate/orchestrateAutoViewSdkStudy.ts +90 -0
- package/src/orchestrate/renderNavTs.test.ts +74 -0
- package/src/orchestrate/structures/IAutoViewProductPlan.ts +119 -0
- package/src/orchestrate/structures/IAutoViewProductPlanApplication.ts +41 -0
- package/src/orchestrate/structures/IAutoViewRenderApplication.ts +40 -0
- package/src/orchestrate/structures/IAutoViewReviewApplication.ts +42 -0
- package/src/orchestrate/structures/IAutoViewSdkMap.ts +72 -0
- package/src/orchestrate/structures/IAutoViewSdkStudyApplication.ts +40 -0
- package/src/orchestrate/utils/HistoryMessage.ts +41 -0
- package/src/orchestrate/utils/auditFrontendRuntime.test.ts +18 -0
- package/src/orchestrate/utils/auditFrontendRuntime.ts +454 -0
- package/src/orchestrate/utils/buildDeterministicPlan.test.ts +170 -0
- package/src/orchestrate/utils/buildDeterministicPlan.ts +289 -0
- package/src/orchestrate/utils/buildDeterministicSdkMap.test.ts +90 -0
- package/src/orchestrate/utils/buildDeterministicSdkMap.ts +169 -0
- package/src/orchestrate/utils/cacheNodeModules.ts +136 -0
- package/src/orchestrate/utils/describeEndpointPropsShape.test.ts +86 -0
- package/src/orchestrate/utils/describeEndpointPropsShape.ts +202 -0
- package/src/orchestrate/utils/describeEndpointRequestBodyShape.test.ts +87 -0
- package/src/orchestrate/utils/describeEndpointRequestBodyShape.ts +31 -0
- package/src/orchestrate/utils/describeEndpointResponseShape.test.ts +70 -0
- package/src/orchestrate/utils/describeEndpointResponseShape.ts +32 -0
- package/src/orchestrate/utils/executeCachedBatch.ts +59 -0
- package/src/orchestrate/utils/loadShoppingFixture.ts +52 -0
- package/src/orchestrate/utils/normalizeProductPlanPaths.ts +92 -0
- package/src/orchestrate/utils/renderJsonSchema.test.ts +162 -0
- package/src/orchestrate/utils/renderJsonSchema.ts +133 -0
- package/src/orchestrate/utils/renderResourcePage.test.ts +468 -0
- package/src/orchestrate/utils/renderResourcePage.ts +1624 -0
- package/src/orchestrate/utils/validateFrontendTypecheck.test.ts +32 -0
- package/src/orchestrate/utils/validateFrontendTypecheck.ts +335 -0
- package/src/preview/renderPreview.ts +273 -0
- package/src/typings/compiler.ts +47 -0
- package/src/typings/events.ts +155 -0
- package/src/typings/index.ts +10 -0
- package/src/typings/misc.ts +93 -0
- package/src/utils/ArrayUtil.ts +16 -0
- package/src/utils/StringUtil.ts +29 -0
- package/src/utils/classifyEndpoints.test.ts +86 -0
- package/src/utils/classifyEndpoints.ts +291 -0
- package/src/utils/endpointFilter.test.ts +50 -0
- package/src/utils/endpointFilter.ts +0 -0
- package/src/utils/extractFields.test.ts +82 -0
- package/src/utils/extractFields.ts +306 -0
- package/src/utils/index.ts +13 -0
- package/src/utils/normalizeForNestia.test.ts +93 -0
- package/src/utils/normalizeForNestia.ts +139 -0
- package/src/utils/resourcePlan.test.ts +104 -0
- package/src/utils/resourcePlan.ts +180 -0
- package/src/utils/sliceDocument.test.ts +85 -0
- package/src/utils/sliceDocument.ts +119 -0
- package/src/utils/toEndpoints.test.ts +251 -0
- package/src/utils/toEndpoints.ts +343 -0
- package/src/verify/runWorkflows.ts +403 -0
- package/src/verify/workflows.test.ts +117 -0
- package/src/verify/workflows.ts +154 -0
- package/template/CLAUDE.md +140 -0
- package/template/Dockerfile +31 -0
- package/template/PROMPT.md +80 -0
- package/template/SANDBOX.md +70 -0
- package/template/app/api/health/route.ts +10 -0
- package/template/app/globals.css +97 -0
- package/template/app/layout.tsx +30 -0
- package/template/app/page.tsx +19 -0
- package/template/components/AppShell.tsx +114 -0
- package/template/components/auto/CatalogGrid.tsx +159 -0
- package/template/components/auto/ConfirmButton.tsx +67 -0
- package/template/components/auto/EmbeddedCollection.tsx +144 -0
- package/template/components/auto/ResourceDashboard.tsx +104 -0
- package/template/components/auto/ResourceDetail.tsx +93 -0
- package/template/components/auto/ResourceForm.tsx +235 -0
- package/template/components/auto/ResourceIcon.tsx +88 -0
- package/template/components/auto/ResourceLanding.tsx +155 -0
- package/template/components/auto/ResourceTable.tsx +223 -0
- package/template/components/auto/formatValue.tsx +186 -0
- package/template/components/auto/types.ts +42 -0
- package/template/components/ui/badge.tsx +40 -0
- package/template/components/ui/button.tsx +57 -0
- package/template/components/ui/card.tsx +86 -0
- package/template/components/ui/dialog.tsx +119 -0
- package/template/components/ui/input.tsx +23 -0
- package/template/components/ui/label.tsx +24 -0
- package/template/components/ui/pagination.tsx +117 -0
- package/template/components/ui/select.tsx +92 -0
- package/template/components/ui/sheet.tsx +135 -0
- package/template/components/ui/skeleton.tsx +15 -0
- package/template/components/ui/table.tsx +120 -0
- package/template/components/ui/tabs.tsx +55 -0
- package/template/lib/utils.ts +35 -0
- package/template/next.config.mjs +52 -0
- package/template/package.json +46 -0
- package/template/postcss.config.js +6 -0
- package/template/scripts/start-shopping-backend.sh +56 -0
- package/template/tailwind.config.ts +96 -0
- package/template/tsconfig.json +29 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { OpenApi } from "@typia/interface";
|
|
2
|
+
import { v7 } from "uuid";
|
|
3
|
+
|
|
4
|
+
import { AutoBeAutoViewRenderPageEvent } from "../typings";
|
|
5
|
+
import { IAutoViewAgentContext } from "../context/IAutoViewAgentContext";
|
|
6
|
+
import { toEndpoints } from "../utils/toEndpoints";
|
|
7
|
+
import { IAutoViewProductPlan } from "./structures/IAutoViewProductPlan";
|
|
8
|
+
import { IAutoViewRenderOutput, screenPathToFile } from "./orchestrateAutoViewRender";
|
|
9
|
+
import { renderResourcePage } from "./utils/renderResourcePage";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Phase 4 — deterministic Render.
|
|
13
|
+
*
|
|
14
|
+
* Replaces the LLM-driven `orchestrateAutoViewRender`. For each screen it emits
|
|
15
|
+
* a thin `page.tsx` that wires the typed SDK call to a universal `Resource*`
|
|
16
|
+
* component, with the column / field metadata baked from the swagger schema (see
|
|
17
|
+
* {@link renderResourcePage}). No LLM call, no parser-retry loop, no per-page
|
|
18
|
+
* latency — the whole phase is a synchronous map. The result keeps the
|
|
19
|
+
* {@link IAutoViewRenderOutput} shape so the typecheck / review phases downstream
|
|
20
|
+
* are unchanged.
|
|
21
|
+
*
|
|
22
|
+
* "모든 엔드포인트 빡빡 + 테이블 모든 필드 빡빡 + 누락 0" is now a structural
|
|
23
|
+
* guarantee: every screen the deterministic plan produced gets a page, and every
|
|
24
|
+
* property of its row / response / request type becomes a column / row / input.
|
|
25
|
+
*/
|
|
26
|
+
export async function orchestrateAutoViewRenderDeterministic(
|
|
27
|
+
ctx: IAutoViewAgentContext,
|
|
28
|
+
props: {
|
|
29
|
+
document: OpenApi.IDocument;
|
|
30
|
+
productPlan: IAutoViewProductPlan;
|
|
31
|
+
step: number;
|
|
32
|
+
},
|
|
33
|
+
): Promise<IAutoViewRenderOutput> {
|
|
34
|
+
const endpoints = toEndpoints(props.document);
|
|
35
|
+
const total = props.productPlan.screens.length;
|
|
36
|
+
const files: Record<string, string> = {};
|
|
37
|
+
const screens: IAutoViewRenderOutput.IScreenReport[] = [];
|
|
38
|
+
|
|
39
|
+
let completed = 0;
|
|
40
|
+
for (const screen of props.productPlan.screens) {
|
|
41
|
+
const tsx = renderResourcePage(
|
|
42
|
+
screen,
|
|
43
|
+
endpoints,
|
|
44
|
+
props.document,
|
|
45
|
+
props.productPlan.screens,
|
|
46
|
+
);
|
|
47
|
+
const filePath = screenPathToFile(screen.path);
|
|
48
|
+
files[filePath] = tsx;
|
|
49
|
+
completed++;
|
|
50
|
+
|
|
51
|
+
screens.push({
|
|
52
|
+
pagePath: screen.path,
|
|
53
|
+
uiPattern: screen.uiPattern as string,
|
|
54
|
+
actor: screen.actor,
|
|
55
|
+
rationale: "deterministic",
|
|
56
|
+
attempts: 1,
|
|
57
|
+
ok: true,
|
|
58
|
+
diagnostic: "",
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
ctx.dispatch({
|
|
62
|
+
type: "autoViewRenderPage",
|
|
63
|
+
id: v7(),
|
|
64
|
+
created_at: new Date().toISOString(),
|
|
65
|
+
step: props.step,
|
|
66
|
+
total,
|
|
67
|
+
completed,
|
|
68
|
+
pagePath: screen.path,
|
|
69
|
+
uiPattern: screen.uiPattern as string,
|
|
70
|
+
attempts: 1,
|
|
71
|
+
ok: true,
|
|
72
|
+
tokenUsage: zeroTokenUsage(),
|
|
73
|
+
metric: zeroMetric(),
|
|
74
|
+
} satisfies AutoBeAutoViewRenderPageEvent);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return { files, screens };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function zeroTokenUsage(): AutoBeAutoViewRenderPageEvent["tokenUsage"] {
|
|
81
|
+
return {
|
|
82
|
+
total: 0,
|
|
83
|
+
input: { total: 0, cached: 0 },
|
|
84
|
+
output: {
|
|
85
|
+
total: 0,
|
|
86
|
+
reasoning: 0,
|
|
87
|
+
accepted_prediction: 0,
|
|
88
|
+
rejected_prediction: 0,
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function zeroMetric(): AutoBeAutoViewRenderPageEvent["metric"] {
|
|
94
|
+
return {
|
|
95
|
+
attempt: 0,
|
|
96
|
+
success: 0,
|
|
97
|
+
invalidJson: 0,
|
|
98
|
+
validationFailure: 0,
|
|
99
|
+
consent: 0,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { OpenApi } from "@typia/interface";
|
|
2
|
+
import { toEndpoints } from "../utils";
|
|
3
|
+
import { IAgenticaController } from "@agentica/core";
|
|
4
|
+
import { AutoBeAutoViewReviewEvent } from "../typings";
|
|
5
|
+
import { IPointer } from "tstl";
|
|
6
|
+
import typia, { ILlmApplication } from "typia";
|
|
7
|
+
import { v7 } from "uuid";
|
|
8
|
+
|
|
9
|
+
import { AutoViewSystemPromptConstant } from "../constants/AutoViewSystemPromptConstant";
|
|
10
|
+
import { IAutoViewAgentContext } from "../context/IAutoViewAgentContext";
|
|
11
|
+
import type { IAutoViewRenderOutput } from "./orchestrateAutoViewRender";
|
|
12
|
+
import { IAutoViewProductPlan } from "./structures/IAutoViewProductPlan";
|
|
13
|
+
import { IAutoViewReviewApplication } from "./structures/IAutoViewReviewApplication";
|
|
14
|
+
import { IAutoViewSdkMap } from "./structures/IAutoViewSdkMap";
|
|
15
|
+
import { HistoryMessage } from "./utils/HistoryMessage";
|
|
16
|
+
import type { IValidateFrontendTypecheckResult } from "./utils/validateFrontendTypecheck";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Phase 5 of the AutoView agent — UI Review.
|
|
20
|
+
*
|
|
21
|
+
* Produces the operator-facing `wiki/sdk-feedback.md` document. The review is a
|
|
22
|
+
* code-and-spec audit, not a visual one: the LLM receives the SDK map, the
|
|
23
|
+
* product plan, and the per-screen render report (rationale + attempts + ok
|
|
24
|
+
* flag + parser diagnostic when it failed), and turns that into the markdown
|
|
25
|
+
* sections defined by the system prompt.
|
|
26
|
+
*
|
|
27
|
+
* Visual verification on screenshots happens later, during the Sandbox deploy
|
|
28
|
+
* step, and feeds back into the agent through manual `wiki/sdk-feedback.md`
|
|
29
|
+
* edits.
|
|
30
|
+
*
|
|
31
|
+
* Counts of broken/recovered pages on the event are derived deterministically
|
|
32
|
+
* from the Render report — the LLM cannot lie about which screens broke.
|
|
33
|
+
* `screenshots` stays `0` until a real Playwright loop lands; the field exists
|
|
34
|
+
* on the event so downstream UIs can surface it once it does.
|
|
35
|
+
*/
|
|
36
|
+
export async function orchestrateAutoViewReview(
|
|
37
|
+
ctx: IAutoViewAgentContext,
|
|
38
|
+
props: {
|
|
39
|
+
document: OpenApi.IDocument;
|
|
40
|
+
sdkMap: IAutoViewSdkMap;
|
|
41
|
+
productPlan: IAutoViewProductPlan;
|
|
42
|
+
render: IAutoViewRenderOutput;
|
|
43
|
+
/**
|
|
44
|
+
* Result of running `tsc --noEmit` against the assembled project. The
|
|
45
|
+
* `broken` count on the Review event reflects "files with at least one
|
|
46
|
+
* typecheck error" rather than "screens whose parser retry was exhausted" —
|
|
47
|
+
* typecheck is the more honest signal of "will the external user be able to
|
|
48
|
+
* `npm run build` what we shipped them".
|
|
49
|
+
*/
|
|
50
|
+
typecheck: IValidateFrontendTypecheckResult;
|
|
51
|
+
/**
|
|
52
|
+
* Number of screens the typecheck-driven retry loop successfully recovered:
|
|
53
|
+
* pages that failed `tsc --noEmit` in the initial measurement but
|
|
54
|
+
* typechecked cleanly after at least one re-render fed the diagnostics back
|
|
55
|
+
* to the model.
|
|
56
|
+
*/
|
|
57
|
+
recovered: number;
|
|
58
|
+
step: number;
|
|
59
|
+
},
|
|
60
|
+
): Promise<{ markdown: string }> {
|
|
61
|
+
const pointer: IPointer<IAutoViewReviewApplication.IProps | null> = {
|
|
62
|
+
value: null,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const renderSummary = props.render.screens.map((s) => ({
|
|
66
|
+
pagePath: s.pagePath,
|
|
67
|
+
uiPattern: s.uiPattern,
|
|
68
|
+
actor: s.actor,
|
|
69
|
+
rationale: s.rationale,
|
|
70
|
+
attempts: s.attempts,
|
|
71
|
+
ok: s.ok,
|
|
72
|
+
diagnostic: s.diagnostic,
|
|
73
|
+
}));
|
|
74
|
+
|
|
75
|
+
await ctx.conversate({
|
|
76
|
+
source: "autoViewReview",
|
|
77
|
+
target: "writeSdkFeedback",
|
|
78
|
+
controller: createController({
|
|
79
|
+
build: (next) => {
|
|
80
|
+
pointer.value = next;
|
|
81
|
+
},
|
|
82
|
+
}),
|
|
83
|
+
enforceFunctionCall: true,
|
|
84
|
+
histories: [
|
|
85
|
+
HistoryMessage.system(AutoViewSystemPromptConstant.AUTOVIEW_REVIEW),
|
|
86
|
+
HistoryMessage.assistant`
|
|
87
|
+
Here is everything you need to audit the SDK.
|
|
88
|
+
|
|
89
|
+
## SDK map
|
|
90
|
+
|
|
91
|
+
\`\`\`json
|
|
92
|
+
${JSON.stringify(props.sdkMap, null, 2)}
|
|
93
|
+
\`\`\`
|
|
94
|
+
|
|
95
|
+
## Product plan
|
|
96
|
+
|
|
97
|
+
\`\`\`json
|
|
98
|
+
${JSON.stringify(props.productPlan, null, 2)}
|
|
99
|
+
\`\`\`
|
|
100
|
+
|
|
101
|
+
## Render report (per screen)
|
|
102
|
+
|
|
103
|
+
\`\`\`json
|
|
104
|
+
${JSON.stringify(renderSummary, null, 2)}
|
|
105
|
+
\`\`\`
|
|
106
|
+
`,
|
|
107
|
+
],
|
|
108
|
+
userMessage:
|
|
109
|
+
"Write `wiki/sdk-feedback.md`. Call `writeSdkFeedback` once with the markdown and a one-sentence summary.",
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// Count "broken" against the typecheck result: an LLM-rendered page that
|
|
113
|
+
// passed the per-screen parser retry but still fails `tsc --noEmit` is
|
|
114
|
+
// still broken from the user's perspective. Parser-only failures are
|
|
115
|
+
// captured by the placeholder pages the Render phase ships, so they
|
|
116
|
+
// also fail typecheck and are counted here.
|
|
117
|
+
const broken = props.typecheck.diagnostics.size;
|
|
118
|
+
const llmMarkdown =
|
|
119
|
+
pointer.value === null
|
|
120
|
+
? renderFallbackFeedback(props.render.screens)
|
|
121
|
+
: pointer.value.markdown;
|
|
122
|
+
// Append a deterministic endpoint-coverage report so the operator
|
|
123
|
+
// always has an objective view of which accessors landed on a
|
|
124
|
+
// screen vs. which were left out. The LLM-written markdown can drift,
|
|
125
|
+
// but the appendix is computed from the same plan and document the
|
|
126
|
+
// orchestrator already trusts.
|
|
127
|
+
const coverage = buildEndpointCoverageAppendix(
|
|
128
|
+
props.document,
|
|
129
|
+
props.productPlan,
|
|
130
|
+
);
|
|
131
|
+
const markdown = `${llmMarkdown.trimEnd()}\n\n${coverage}`;
|
|
132
|
+
|
|
133
|
+
ctx.dispatch({
|
|
134
|
+
type: "autoViewReview",
|
|
135
|
+
id: v7(),
|
|
136
|
+
created_at: new Date().toISOString(),
|
|
137
|
+
step: props.step,
|
|
138
|
+
screenshots: 0,
|
|
139
|
+
broken,
|
|
140
|
+
recovered: props.recovered,
|
|
141
|
+
sdkFeedback: markdown,
|
|
142
|
+
} satisfies AutoBeAutoViewReviewEvent);
|
|
143
|
+
|
|
144
|
+
return { markdown };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/* -------------------------------------------------------------------------- */
|
|
148
|
+
/* deterministic endpoint-coverage appendix */
|
|
149
|
+
/* -------------------------------------------------------------------------- */
|
|
150
|
+
|
|
151
|
+
function buildEndpointCoverageAppendix(
|
|
152
|
+
document: OpenApi.IDocument,
|
|
153
|
+
plan: IAutoViewProductPlan,
|
|
154
|
+
): string {
|
|
155
|
+
const allAccessors = new Set<string>();
|
|
156
|
+
for (const op of toEndpoints(document)) {
|
|
157
|
+
if (op.accessor && op.accessor.length > 0) {
|
|
158
|
+
allAccessors.add(op.accessor.join("."));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const covered = new Set<string>();
|
|
162
|
+
for (const screen of plan.screens) {
|
|
163
|
+
for (const accessor of screen.endpoints) {
|
|
164
|
+
covered.add(accessor);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
// `intentionalOmissions.target` is a free-form label, so we cannot
|
|
168
|
+
// confidently match it back to an accessor. Surface the operator's
|
|
169
|
+
// declared list separately so they can audit overlap by eye.
|
|
170
|
+
const uncovered = [...allAccessors]
|
|
171
|
+
.filter((a) => !covered.has(a))
|
|
172
|
+
.sort((a, b) => a.localeCompare(b));
|
|
173
|
+
const coveredList = [...covered].sort((a, b) => a.localeCompare(b));
|
|
174
|
+
const lines: string[] = [
|
|
175
|
+
"## Endpoint coverage (auto-generated)",
|
|
176
|
+
"",
|
|
177
|
+
`**Total SDK operations**: ${allAccessors.size} · ` +
|
|
178
|
+
`**Used by at least one screen**: ${covered.size} · ` +
|
|
179
|
+
`**Not used by any screen**: ${uncovered.length} · ` +
|
|
180
|
+
`**Intentional omissions declared**: ${plan.intentionalOmissions.length}`,
|
|
181
|
+
"",
|
|
182
|
+
"### Used in screens",
|
|
183
|
+
"",
|
|
184
|
+
];
|
|
185
|
+
if (coveredList.length === 0) {
|
|
186
|
+
lines.push("_(none)_");
|
|
187
|
+
} else {
|
|
188
|
+
for (const accessor of coveredList) lines.push(`- \`${accessor}\``);
|
|
189
|
+
}
|
|
190
|
+
lines.push("", "### Not used by any screen", "");
|
|
191
|
+
if (uncovered.length === 0) {
|
|
192
|
+
lines.push("_(none — every SDK accessor lands on at least one screen.)_");
|
|
193
|
+
} else {
|
|
194
|
+
for (const accessor of uncovered) lines.push(`- \`${accessor}\``);
|
|
195
|
+
}
|
|
196
|
+
lines.push("", "### Intentional omissions declared in the plan", "");
|
|
197
|
+
if (plan.intentionalOmissions.length === 0) {
|
|
198
|
+
lines.push("_(none declared)_");
|
|
199
|
+
} else {
|
|
200
|
+
for (const omission of plan.intentionalOmissions) {
|
|
201
|
+
lines.push(`- **${omission.target}** — ${omission.reason}`);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
lines.push("");
|
|
205
|
+
return lines.join("\n");
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/* -------------------------------------------------------------------------- */
|
|
209
|
+
/* fallback when the model fails to call `writeSdkFeedback` */
|
|
210
|
+
/* -------------------------------------------------------------------------- */
|
|
211
|
+
|
|
212
|
+
function renderFallbackFeedback(
|
|
213
|
+
screens: IAutoViewRenderOutput.IScreenReport[],
|
|
214
|
+
): string {
|
|
215
|
+
const broken = screens.filter((s) => !s.ok);
|
|
216
|
+
return [
|
|
217
|
+
"# SDK Feedback",
|
|
218
|
+
"",
|
|
219
|
+
"The Review phase model did not call `writeSdkFeedback`. Falling back",
|
|
220
|
+
"to a minimal report so the wiki entry still exists.",
|
|
221
|
+
"",
|
|
222
|
+
"## Summary",
|
|
223
|
+
"",
|
|
224
|
+
"_(LLM omitted summary.)_",
|
|
225
|
+
"",
|
|
226
|
+
"## What worked well",
|
|
227
|
+
"",
|
|
228
|
+
"None observed.",
|
|
229
|
+
"",
|
|
230
|
+
"## What's awkward",
|
|
231
|
+
"",
|
|
232
|
+
"None observed.",
|
|
233
|
+
"",
|
|
234
|
+
"## What's missing",
|
|
235
|
+
"",
|
|
236
|
+
"None observed.",
|
|
237
|
+
"",
|
|
238
|
+
"## Pages that broke",
|
|
239
|
+
"",
|
|
240
|
+
broken.length === 0
|
|
241
|
+
? "None observed."
|
|
242
|
+
: broken
|
|
243
|
+
.map(
|
|
244
|
+
(s) =>
|
|
245
|
+
`- \`${s.pagePath}\` (${s.uiPattern}) — ${s.attempts} attempts: ${s.diagnostic}`,
|
|
246
|
+
)
|
|
247
|
+
.join("\n"),
|
|
248
|
+
"",
|
|
249
|
+
].join("\n");
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/* -------------------------------------------------------------------------- */
|
|
253
|
+
/* controller wiring */
|
|
254
|
+
/* -------------------------------------------------------------------------- */
|
|
255
|
+
|
|
256
|
+
function createController(props: {
|
|
257
|
+
build: (next: IAutoViewReviewApplication.IProps) => void;
|
|
258
|
+
}): IAgenticaController.IClass {
|
|
259
|
+
const application: ILlmApplication =
|
|
260
|
+
typia.llm.application<IAutoViewReviewApplication>();
|
|
261
|
+
|
|
262
|
+
return {
|
|
263
|
+
protocol: "class",
|
|
264
|
+
name: "autoViewReview",
|
|
265
|
+
application,
|
|
266
|
+
execute: {
|
|
267
|
+
writeSdkFeedback: (next) => {
|
|
268
|
+
props.build(next);
|
|
269
|
+
},
|
|
270
|
+
} satisfies IAutoViewReviewApplication,
|
|
271
|
+
};
|
|
272
|
+
}
|