@design-ai/cli 4.55.0 → 4.57.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/.claude-plugin/plugin.json +109 -25
- package/CHANGELOG.md +75 -0
- package/README.ko.md +15 -32
- package/README.md +18 -31
- package/cli/bin/design-ai.mjs +1 -0
- package/cli/commands/help.mjs +7 -4
- package/cli/commands/index.mjs +292 -0
- package/cli/commands/learn-help.mjs +149 -0
- package/cli/commands/learn-print-profile.mjs +373 -0
- package/cli/commands/learn-print-restore.mjs +349 -0
- package/cli/commands/learn-print-signals.mjs +453 -0
- package/cli/commands/learn.mjs +60 -1281
- package/cli/commands/pack.mjs +7 -3
- package/cli/commands/prompt.mjs +7 -3
- package/cli/commands/search.mjs +94 -1
- package/cli/lib/dispatch.mjs +3 -0
- package/cli/lib/embedding-index.mjs +199 -0
- package/cli/lib/embedding-provider.mjs +121 -0
- package/cli/lib/embedding-rerank.mjs +52 -0
- package/cli/lib/learn-args.mjs +490 -0
- package/cli/lib/learn-backup.mjs +748 -0
- package/cli/lib/learn-curation.mjs +612 -0
- package/cli/lib/learn-eval.mjs +459 -0
- package/cli/lib/learn-profile.mjs +763 -0
- package/cli/lib/learn-select.mjs +223 -0
- package/cli/lib/learn-shared.mjs +158 -0
- package/cli/lib/learn-test-support.mjs +218 -0
- package/cli/lib/learn-usage.mjs +360 -0
- package/cli/lib/learn.mjs +83 -3694
- package/cli/lib/lexical.mjs +137 -0
- package/cli/lib/local-config.mjs +110 -0
- package/cli/lib/mcp-server.mjs +221 -13
- package/cli/lib/pack.mjs +31 -4
- package/cli/lib/prompt.mjs +42 -4
- package/cli/lib/recall.mjs +193 -0
- package/cli/lib/retrieval-index.mjs +0 -0
- package/cli/lib/search-ranked.mjs +170 -0
- package/cli/lib/search.mjs +11 -1
- package/cli/lib/signals-backlog-commands.mjs +673 -0
- package/cli/lib/signals-backlog.mjs +361 -0
- package/cli/lib/signals-eval.mjs +176 -0
- package/cli/lib/signals-readiness.mjs +247 -0
- package/cli/lib/signals-registry.mjs +377 -0
- package/cli/lib/signals-render.mjs +478 -0
- package/cli/lib/signals-shared.mjs +75 -0
- package/cli/lib/signals.mjs +16 -2337
- package/cli/lib/site-analysis.mjs +297 -0
- package/cli/lib/site-args.mjs +433 -0
- package/cli/lib/site-bundle-build.mjs +127 -0
- package/cli/lib/site-bundle-check.mjs +454 -0
- package/cli/lib/site-bundle-commands.mjs +95 -0
- package/cli/lib/site-bundle-compare.mjs +157 -0
- package/cli/lib/site-bundle-contract.mjs +79 -0
- package/cli/lib/site-bundle-files.mjs +87 -0
- package/cli/lib/site-bundle-handoff-expected.mjs +173 -0
- package/cli/lib/site-bundle-handoff-runbook-action-summary.mjs +332 -0
- package/cli/lib/site-bundle-handoff-runbook-actions.mjs +113 -0
- package/cli/lib/site-bundle-handoff-runbook-evidence-fields.mjs +164 -0
- package/cli/lib/site-bundle-handoff-runbook-evidence.mjs +334 -0
- package/cli/lib/site-bundle-handoff-runbook-format.mjs +31 -0
- package/cli/lib/site-bundle-handoff-runbook-human-lines.mjs +167 -0
- package/cli/lib/site-bundle-handoff-runbook-maps.mjs +238 -0
- package/cli/lib/site-bundle-handoff-runbook-next-step.mjs +278 -0
- package/cli/lib/site-bundle-handoff-runbook-stage-metadata.mjs +84 -0
- package/cli/lib/site-bundle-handoff-runbook.mjs +444 -0
- package/cli/lib/site-bundle-handoff-summary.mjs +183 -0
- package/cli/lib/site-bundle-handoff.mjs +271 -0
- package/cli/lib/site-bundle-readme.mjs +98 -0
- package/cli/lib/site-bundle-repair-report.mjs +143 -0
- package/cli/lib/site-bundle-repair.mjs +68 -0
- package/cli/lib/site-content.mjs +399 -0
- package/cli/lib/site-evidence.mjs +35 -0
- package/cli/lib/site-mcp-commands.mjs +28 -0
- package/cli/lib/site-mcp-probes.mjs +159 -0
- package/cli/lib/site-mcp-readiness.mjs +157 -0
- package/cli/lib/site-mcp-report.mjs +324 -0
- package/cli/lib/site-next-actions.mjs +333 -0
- package/cli/lib/site-options.mjs +104 -0
- package/cli/lib/site-prompts.mjs +332 -0
- package/cli/lib/site-starter.mjs +153 -0
- package/cli/lib/site-strings.mjs +23 -0
- package/cli/lib/site-tasks.mjs +93 -0
- package/cli/lib/site-test-support.mjs +68 -0
- package/cli/lib/site-workflow-graph.mjs +309 -0
- package/cli/lib/site-workspace.mjs +492 -0
- package/cli/lib/site.mjs +108 -6617
- package/cli/lib/skill-proposals-apply-commands.mjs +135 -0
- package/cli/lib/skill-proposals-apply-contract.mjs +750 -0
- package/cli/lib/skill-proposals-apply-plan.mjs +118 -0
- package/cli/lib/skill-proposals-generate.mjs +298 -0
- package/cli/lib/skill-proposals-render.mjs +532 -0
- package/cli/lib/skill-proposals-review.mjs +262 -0
- package/cli/lib/skill-proposals.mjs +15 -2046
- package/cli/lib/workspace-args.mjs +83 -0
- package/cli/lib/workspace-git.mjs +169 -0
- package/cli/lib/workspace-learning.mjs +483 -0
- package/cli/lib/workspace-repo.mjs +139 -0
- package/cli/lib/workspace-report.mjs +283 -0
- package/cli/lib/workspace-test-support.mjs +99 -0
- package/cli/lib/workspace.mjs +30 -1056
- package/docs/AI-LEARNING-PHASE2.md +215 -0
- package/docs/DISTRIBUTION.ko.md +35 -6
- package/docs/DISTRIBUTION.md +35 -8
- package/docs/NEXT-SURFACE-DECISION.md +125 -0
- package/docs/PRODUCT-READINESS.md +3 -3
- package/docs/RELEASE-CHECKLIST.md +20 -3
- package/docs/RELEASE-GATES.ko.md +35 -0
- package/docs/RELEASE-GATES.md +234 -0
- package/docs/ROADMAP.md +2232 -8
- package/docs/external-status.md +20 -7
- package/docs/inspection-20260630.md +169 -0
- package/docs/integrations/design-ai-mcp-server.md +35 -3
- package/docs/integrations/vscode-walkthrough.ko.md +3 -3
- package/docs/integrations/vscode-walkthrough.md +3 -3
- package/docs/reference/ant-design.md +413 -0
- package/docs/reference/awesome-design-md.md +439 -0
- package/docs/reference/mui.md +783 -0
- package/docs/reference/shadcn-ui.md +298 -0
- package/docs/site-overrides/main.html +1 -1
- package/examples/component-accordion-actions.md +5 -5
- package/examples/component-accordion-details.md +5 -5
- package/examples/component-accordion-summary.md +5 -5
- package/examples/component-accordion.md +3 -3
- package/examples/component-affix.md +1 -1
- package/examples/component-alert-dialog.md +1 -1
- package/examples/component-alert-title.md +1 -1
- package/examples/component-alert.md +3 -3
- package/examples/component-anchor.md +1 -1
- package/examples/component-app-bar.md +1 -1
- package/examples/component-aspect-ratio.md +1 -1
- package/examples/component-auto-complete.md +2 -2
- package/examples/component-avatar-group.md +5 -5
- package/examples/component-avatar.md +3 -3
- package/examples/component-back-top.md +1 -1
- package/examples/component-backdrop.md +1 -1
- package/examples/component-badge.md +3 -3
- package/examples/component-border-beam.md +3 -3
- package/examples/component-bottom-navigation.md +1 -1
- package/examples/component-box.md +1 -1
- package/examples/component-breadcrumb.md +3 -3
- package/examples/component-button-base.md +3 -3
- package/examples/component-button-group.md +2 -2
- package/examples/component-button.md +3 -3
- package/examples/component-calendar.md +2 -2
- package/examples/component-card-actions.md +1 -1
- package/examples/component-card-content.md +1 -1
- package/examples/component-card-header.md +1 -1
- package/examples/component-card-media.md +1 -1
- package/examples/component-card.md +3 -3
- package/examples/component-carousel.md +2 -2
- package/examples/component-cascader.md +1 -1
- package/examples/component-chart.md +1 -1
- package/examples/component-checkbox.md +3 -3
- package/examples/component-click-away-listener.md +1 -1
- package/examples/component-code.md +1 -1
- package/examples/component-collapsible.md +1 -1
- package/examples/component-color-picker.md +1 -1
- package/examples/component-combobox.md +1 -1
- package/examples/component-command.md +1 -1
- package/examples/component-config-provider.md +3 -3
- package/examples/component-context-menu.md +1 -1
- package/examples/component-css-baseline.md +3 -3
- package/examples/component-date-picker.md +2 -2
- package/examples/component-descriptions.md +1 -1
- package/examples/component-dialog-actions.md +1 -1
- package/examples/component-dialog-content-text.md +1 -1
- package/examples/component-dialog-content.md +1 -1
- package/examples/component-dialog-title.md +1 -1
- package/examples/component-dialog.md +2 -2
- package/examples/component-divider.md +3 -3
- package/examples/component-drawer.md +3 -3
- package/examples/component-dropdown.md +3 -3
- package/examples/component-empty.md +2 -2
- package/examples/component-fade.md +1 -1
- package/examples/component-field.md +1 -1
- package/examples/component-filled-input.md +1 -1
- package/examples/component-flex.md +1 -1
- package/examples/component-float-button.md +2 -2
- package/examples/component-form-control-label.md +1 -1
- package/examples/component-form-control.md +1 -1
- package/examples/component-form-controls.md +1 -1
- package/examples/component-form-group.md +1 -1
- package/examples/component-form-helper-text.md +1 -1
- package/examples/component-form-label.md +1 -1
- package/examples/component-form.md +2 -2
- package/examples/component-grid.md +2 -2
- package/examples/component-grow.md +1 -1
- package/examples/component-hover-card.md +1 -1
- package/examples/component-icon-button.md +1 -1
- package/examples/component-icon.md +1 -1
- package/examples/component-image-list.md +1 -1
- package/examples/component-image.md +1 -1
- package/examples/component-input-adornment.md +1 -1
- package/examples/component-input-base.md +1 -1
- package/examples/component-input-number.md +1 -1
- package/examples/component-input-otp.md +2 -2
- package/examples/component-input.md +3 -3
- package/examples/component-item.md +1 -1
- package/examples/component-label.md +1 -1
- package/examples/component-layout.md +1 -1
- package/examples/component-link.md +1 -1
- package/examples/component-list-item-avatar.md +1 -1
- package/examples/component-list-item-button.md +1 -1
- package/examples/component-list-item-icon.md +1 -1
- package/examples/component-list-item-text.md +1 -1
- package/examples/component-list-item.md +1 -1
- package/examples/component-list-subheader.md +1 -1
- package/examples/component-list.md +2 -2
- package/examples/component-masonry.md +1 -1
- package/examples/component-mentions.md +1 -1
- package/examples/component-menu-item.md +1 -1
- package/examples/component-menu-list.md +1 -1
- package/examples/component-menu.md +1 -1
- package/examples/component-menubar.md +1 -1
- package/examples/component-message.md +1 -1
- package/examples/component-mobile-stepper.md +1 -1
- package/examples/component-modal.md +5 -5
- package/examples/component-navigation-menu.md +1 -1
- package/examples/component-notification.md +1 -1
- package/examples/component-outlined-input.md +1 -1
- package/examples/component-pagination.md +3 -3
- package/examples/component-paper.md +1 -1
- package/examples/component-popconfirm.md +1 -1
- package/examples/component-popover.md +3 -3
- package/examples/component-popper.md +1 -1
- package/examples/component-progress.md +2 -2
- package/examples/component-qr-code.md +1 -1
- package/examples/component-radio.md +3 -3
- package/examples/component-rate.md +2 -2
- package/examples/component-resizable.md +1 -1
- package/examples/component-result.md +1 -1
- package/examples/component-scroll-area.md +1 -1
- package/examples/component-segmented.md +3 -3
- package/examples/component-select.md +3 -3
- package/examples/component-separator.md +1 -1
- package/examples/component-sheet.md +1 -1
- package/examples/component-sidebar.md +1 -1
- package/examples/component-skeleton.md +3 -3
- package/examples/component-slide.md +1 -1
- package/examples/component-slider.md +3 -3
- package/examples/component-snackbar-content.md +1 -1
- package/examples/component-snackbar.md +1 -1
- package/examples/component-sonner.md +1 -1
- package/examples/component-space.md +1 -1
- package/examples/component-speed-dial-action.md +1 -1
- package/examples/component-speed-dial.md +1 -1
- package/examples/component-spin.md +2 -2
- package/examples/component-spinner.md +1 -1
- package/examples/component-splitter.md +2 -2
- package/examples/component-stack.md +1 -1
- package/examples/component-statistic.md +1 -1
- package/examples/component-step-button.md +4 -4
- package/examples/component-step-connector.md +4 -4
- package/examples/component-step-content.md +1 -1
- package/examples/component-step-icon.md +1 -1
- package/examples/component-step-label.md +1 -1
- package/examples/component-step.md +2 -2
- package/examples/component-steps.md +2 -2
- package/examples/component-swipeable-drawer.md +1 -1
- package/examples/component-switch.md +3 -3
- package/examples/component-tab-scroll-button.md +5 -5
- package/examples/component-tab.md +1 -1
- package/examples/component-table-body.md +1 -1
- package/examples/component-table-cell.md +1 -1
- package/examples/component-table-container.md +1 -1
- package/examples/component-table-footer.md +1 -1
- package/examples/component-table-head.md +1 -1
- package/examples/component-table-pagination.md +1 -1
- package/examples/component-table-row.md +1 -1
- package/examples/component-table-sort-label.md +1 -1
- package/examples/component-table.md +2 -2
- package/examples/component-tabs.md +3 -3
- package/examples/component-tag-badge.md +2 -2
- package/examples/component-tag.md +1 -1
- package/examples/component-textarea-autosize.md +1 -1
- package/examples/component-textarea.md +1 -1
- package/examples/component-time-picker.md +1 -1
- package/examples/component-timeline.md +1 -1
- package/examples/component-toast.md +4 -4
- package/examples/component-toggle-button.md +1 -1
- package/examples/component-toggle.md +1 -1
- package/examples/component-toolbar.md +1 -1
- package/examples/component-tooltip.md +3 -3
- package/examples/component-tour.md +1 -1
- package/examples/component-transfer.md +1 -1
- package/examples/component-tree-select.md +1 -1
- package/examples/component-tree.md +1 -1
- package/examples/component-typography.md +2 -2
- package/examples/component-upload.md +1 -1
- package/examples/component-watermark.md +1 -1
- package/examples/component-zoom.md +1 -1
- package/knowledge/COVERAGE.md +4 -3
- package/knowledge/components/INDEX.md +202 -202
- package/knowledge/patterns/brand-references.md +72 -72
- package/package.json +1 -1
- package/tools/audit/local-ci.py +16 -1
- package/tools/audit/package-smoke.py +717 -9
- package/tools/audit/registry-smoke.py +912 -10
- package/tools/audit/release-metadata.py +47 -1
- package/tools/audit/smoke_assertions.py +998 -35
- package/tools/migrations/refs-links-to-reference-pages.py +179 -0
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
// Website Improvement workspace validation and summary helpers.
|
|
2
|
+
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
|
|
6
|
+
import { normalizeStringArray } from "./site-strings.mjs";
|
|
7
|
+
import {
|
|
8
|
+
AUDIT_CATEGORIES,
|
|
9
|
+
CHECKLIST_STATUS_OPTIONS,
|
|
10
|
+
CMS_OPTIONS,
|
|
11
|
+
DATABASE_OPTIONS,
|
|
12
|
+
DEPLOY_OPTIONS,
|
|
13
|
+
EFFORT_OPTIONS,
|
|
14
|
+
IMPACT_OPTIONS,
|
|
15
|
+
MCP_ITEMS,
|
|
16
|
+
MCP_STATUS_OPTIONS,
|
|
17
|
+
PRIORITY_OPTIONS,
|
|
18
|
+
VIEWPORT_OPTIONS,
|
|
19
|
+
} from "./site-options.mjs";
|
|
20
|
+
import {
|
|
21
|
+
IMPLEMENTATION_EVIDENCE_KEYS,
|
|
22
|
+
normalizeImplementationEvidence,
|
|
23
|
+
} from "./site-evidence.mjs";
|
|
24
|
+
import {
|
|
25
|
+
normalizeObject,
|
|
26
|
+
normalizeSiteWorkspace,
|
|
27
|
+
} from "./site-workspace.mjs";
|
|
28
|
+
|
|
29
|
+
export function addIssue(issues, level, id, message) {
|
|
30
|
+
issues.push({ level, id, message });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function assertEnumIssue(issues, value, allowed, id, label) {
|
|
34
|
+
if (!allowed.includes(value)) {
|
|
35
|
+
addIssue(issues, "fail", id, `${label} must be one of: ${allowed.join(", ")}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function validateRawWorkspace(raw) {
|
|
40
|
+
const issues = [];
|
|
41
|
+
const root = normalizeObject(raw);
|
|
42
|
+
const profile = normalizeObject(root.siteProfile);
|
|
43
|
+
const checklist = normalizeObject(root.auditChecklist);
|
|
44
|
+
const mcpReadiness = normalizeObject(root.mcpReadiness);
|
|
45
|
+
|
|
46
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
47
|
+
addIssue(issues, "fail", "workspace-object", "Workspace JSON must be an object");
|
|
48
|
+
return issues;
|
|
49
|
+
}
|
|
50
|
+
if (root.version !== 1) {
|
|
51
|
+
addIssue(issues, "fail", "workspace-version", "Workspace version must be 1");
|
|
52
|
+
}
|
|
53
|
+
if (!root.siteProfile || typeof root.siteProfile !== "object" || Array.isArray(root.siteProfile)) {
|
|
54
|
+
addIssue(issues, "fail", "site-profile", "siteProfile object is required");
|
|
55
|
+
}
|
|
56
|
+
if (!root.auditChecklist || typeof root.auditChecklist !== "object" || Array.isArray(root.auditChecklist)) {
|
|
57
|
+
addIssue(issues, "fail", "audit-checklist", "auditChecklist object is required");
|
|
58
|
+
}
|
|
59
|
+
if (!root.mcpReadiness || typeof root.mcpReadiness !== "object" || Array.isArray(root.mcpReadiness)) {
|
|
60
|
+
addIssue(issues, "fail", "mcp-readiness", "mcpReadiness object is required");
|
|
61
|
+
}
|
|
62
|
+
if (!Array.isArray(root.refactorTasks)) {
|
|
63
|
+
addIssue(issues, "fail", "refactor-tasks", "refactorTasks array is required");
|
|
64
|
+
}
|
|
65
|
+
if (root.implementationEvidence !== undefined) {
|
|
66
|
+
const evidence = normalizeObject(root.implementationEvidence);
|
|
67
|
+
if (root.implementationEvidence === null || typeof root.implementationEvidence !== "object" || Array.isArray(root.implementationEvidence)) {
|
|
68
|
+
addIssue(issues, "fail", "implementation-evidence", "implementationEvidence must be an object when provided");
|
|
69
|
+
} else {
|
|
70
|
+
for (const key of IMPLEMENTATION_EVIDENCE_KEYS) {
|
|
71
|
+
if (evidence[key] !== undefined && !Array.isArray(evidence[key])) {
|
|
72
|
+
addIssue(issues, "fail", `implementation-evidence-${key}`, `implementationEvidence.${key} must be an array`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (!String(profile.name || "").trim()) {
|
|
79
|
+
addIssue(issues, "fail", "site-name", "siteProfile.name is required");
|
|
80
|
+
}
|
|
81
|
+
if (!String(profile.liveUrl || "").trim()) {
|
|
82
|
+
addIssue(issues, "fail", "site-live-url", "siteProfile.liveUrl is required");
|
|
83
|
+
}
|
|
84
|
+
if (!Array.isArray(profile.pages) || normalizeStringArray(profile.pages).length === 0) {
|
|
85
|
+
addIssue(issues, "warn", "site-pages", "siteProfile.pages should include at least one priority page");
|
|
86
|
+
}
|
|
87
|
+
if (!Array.isArray(profile.userFlows) || normalizeStringArray(profile.userFlows).length === 0) {
|
|
88
|
+
addIssue(issues, "warn", "site-user-flows", "siteProfile.userFlows should include at least one primary user flow");
|
|
89
|
+
}
|
|
90
|
+
if (!Array.isArray(profile.viewports) || normalizeStringArray(profile.viewports).length === 0) {
|
|
91
|
+
addIssue(issues, "warn", "site-viewports", "siteProfile.viewports should include desktop, tablet, or mobile");
|
|
92
|
+
} else {
|
|
93
|
+
for (const viewport of normalizeStringArray(profile.viewports)) {
|
|
94
|
+
assertEnumIssue(issues, viewport, VIEWPORT_OPTIONS, "site-viewport-value", `Viewport '${viewport}'`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (!String(profile.repoUrl || "").trim() && !String(profile.localPath || "").trim()) {
|
|
98
|
+
addIssue(issues, "warn", "site-repo-location", "Provide siteProfile.repoUrl or siteProfile.localPath before Codex implementation handoff");
|
|
99
|
+
}
|
|
100
|
+
if (profile.deployProvider !== undefined) {
|
|
101
|
+
assertEnumIssue(issues, profile.deployProvider, DEPLOY_OPTIONS, "deploy-provider", "siteProfile.deployProvider");
|
|
102
|
+
}
|
|
103
|
+
if (profile.cms !== undefined) {
|
|
104
|
+
assertEnumIssue(issues, profile.cms, CMS_OPTIONS, "cms", "siteProfile.cms");
|
|
105
|
+
}
|
|
106
|
+
if (profile.database !== undefined) {
|
|
107
|
+
assertEnumIssue(issues, profile.database, DATABASE_OPTIONS, "database", "siteProfile.database");
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
for (const category of AUDIT_CATEGORIES) {
|
|
111
|
+
const row = normalizeObject(checklist[category.id]);
|
|
112
|
+
if (!checklist[category.id]) {
|
|
113
|
+
addIssue(issues, "warn", `audit-${category.id}`, `${category.label} audit row is missing`);
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
assertEnumIssue(issues, row.status, CHECKLIST_STATUS_OPTIONS, `audit-${category.id}-status`, `${category.label} status`);
|
|
117
|
+
if (row.findings !== undefined && !Array.isArray(row.findings)) {
|
|
118
|
+
addIssue(issues, "fail", `audit-${category.id}-findings`, `${category.label} findings must be an array`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
for (const [key, label] of MCP_ITEMS) {
|
|
123
|
+
if (mcpReadiness[key] === undefined) {
|
|
124
|
+
addIssue(issues, "warn", `mcp-${key}`, `${label} MCP readiness status is missing`);
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
assertEnumIssue(issues, mcpReadiness[key], MCP_STATUS_OPTIONS, `mcp-${key}-status`, `${label} MCP status`);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (Array.isArray(root.refactorTasks)) {
|
|
131
|
+
for (const [index, task] of root.refactorTasks.entries()) {
|
|
132
|
+
const item = normalizeObject(task);
|
|
133
|
+
const label = item.title ? `Task '${item.title}'` : `Task ${index + 1}`;
|
|
134
|
+
if (!String(item.title || "").trim()) {
|
|
135
|
+
addIssue(issues, "warn", `task-${index + 1}-title`, `${label} should include a title`);
|
|
136
|
+
}
|
|
137
|
+
if (!String(item.problem || "").trim()) {
|
|
138
|
+
addIssue(issues, "warn", `task-${index + 1}-problem`, `${label} should describe the problem`);
|
|
139
|
+
}
|
|
140
|
+
assertEnumIssue(
|
|
141
|
+
issues,
|
|
142
|
+
item.category,
|
|
143
|
+
AUDIT_CATEGORIES.map((category) => category.id),
|
|
144
|
+
`task-${index + 1}-category`,
|
|
145
|
+
`${label} category`,
|
|
146
|
+
);
|
|
147
|
+
assertEnumIssue(issues, item.impact, IMPACT_OPTIONS, `task-${index + 1}-impact`, `${label} impact`);
|
|
148
|
+
assertEnumIssue(issues, item.effort, EFFORT_OPTIONS, `task-${index + 1}-effort`, `${label} effort`);
|
|
149
|
+
assertEnumIssue(issues, item.priority, PRIORITY_OPTIONS, `task-${index + 1}-priority`, `${label} priority`);
|
|
150
|
+
if (!String(item.codexPrompt || "").trim()) {
|
|
151
|
+
addIssue(issues, "warn", `task-${index + 1}-codex-prompt`, `${label} should include a Codex implementation prompt`);
|
|
152
|
+
}
|
|
153
|
+
if (!Array.isArray(item.verification) || normalizeStringArray(item.verification).length === 0) {
|
|
154
|
+
addIssue(issues, "warn", `task-${index + 1}-verification`, `${label} should include verification steps`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return issues;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function countBy(items, keyFn, allowed = []) {
|
|
163
|
+
const counts = Object.fromEntries(allowed.map((item) => [item, 0]));
|
|
164
|
+
for (const item of items) {
|
|
165
|
+
const key = keyFn(item);
|
|
166
|
+
counts[key] = (counts[key] || 0) + 1;
|
|
167
|
+
}
|
|
168
|
+
return counts;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export function statusFromIssues(issues) {
|
|
172
|
+
if (issues.some((issue) => issue.level === "fail")) return "fail";
|
|
173
|
+
if (issues.some((issue) => issue.level === "warn")) return "warn";
|
|
174
|
+
return "pass";
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function summarizeWorkspace(workspace, issues, filePath) {
|
|
178
|
+
const auditRows = AUDIT_CATEGORIES.map((category) => ({
|
|
179
|
+
category,
|
|
180
|
+
row: workspace.auditChecklist[category.id],
|
|
181
|
+
}));
|
|
182
|
+
const mcpRows = MCP_ITEMS.map(([key, label]) => ({
|
|
183
|
+
key,
|
|
184
|
+
label,
|
|
185
|
+
status: workspace.mcpReadiness[key],
|
|
186
|
+
}));
|
|
187
|
+
const totalFindings = auditRows.reduce((sum, item) => sum + item.row.findings.length, 0);
|
|
188
|
+
const requiredMcp = mcpRows.filter((item) => item.status === "required").map((item) => item.key);
|
|
189
|
+
const evidence = normalizeImplementationEvidence(workspace.implementationEvidence);
|
|
190
|
+
const topTasks = workspace.refactorTasks
|
|
191
|
+
.slice()
|
|
192
|
+
.sort((a, b) => PRIORITY_OPTIONS.indexOf(a.priority) - PRIORITY_OPTIONS.indexOf(b.priority))
|
|
193
|
+
.slice(0, 5)
|
|
194
|
+
.map((task) => ({
|
|
195
|
+
id: task.id,
|
|
196
|
+
title: task.title,
|
|
197
|
+
priority: task.priority,
|
|
198
|
+
category: task.category,
|
|
199
|
+
impact: task.impact,
|
|
200
|
+
effort: task.effort,
|
|
201
|
+
pages: task.pages,
|
|
202
|
+
}));
|
|
203
|
+
|
|
204
|
+
return {
|
|
205
|
+
filePath,
|
|
206
|
+
valid: statusFromIssues(issues) !== "fail",
|
|
207
|
+
status: statusFromIssues(issues),
|
|
208
|
+
site: {
|
|
209
|
+
id: workspace.siteProfile.id,
|
|
210
|
+
name: workspace.siteProfile.name,
|
|
211
|
+
liveUrl: workspace.siteProfile.liveUrl,
|
|
212
|
+
repoUrl: workspace.siteProfile.repoUrl,
|
|
213
|
+
localPath: workspace.siteProfile.localPath,
|
|
214
|
+
deployProvider: workspace.siteProfile.deployProvider,
|
|
215
|
+
cms: workspace.siteProfile.cms,
|
|
216
|
+
database: workspace.siteProfile.database,
|
|
217
|
+
pages: workspace.siteProfile.pages,
|
|
218
|
+
userFlows: workspace.siteProfile.userFlows,
|
|
219
|
+
viewports: workspace.siteProfile.viewports,
|
|
220
|
+
},
|
|
221
|
+
counts: {
|
|
222
|
+
pages: workspace.siteProfile.pages.length,
|
|
223
|
+
userFlows: workspace.siteProfile.userFlows.length,
|
|
224
|
+
viewports: workspace.siteProfile.viewports.length,
|
|
225
|
+
auditCategories: AUDIT_CATEGORIES.length,
|
|
226
|
+
auditFindings: totalFindings,
|
|
227
|
+
refactorTasks: workspace.refactorTasks.length,
|
|
228
|
+
executedWork: evidence.executedWork.length,
|
|
229
|
+
verificationResults: evidence.verificationResults.length,
|
|
230
|
+
remainingRisks: evidence.remainingRisks.length,
|
|
231
|
+
nextActions: evidence.nextActions.length,
|
|
232
|
+
requiredMcp: requiredMcp.length,
|
|
233
|
+
optionalMcp: mcpRows.filter((item) => item.status === "optional").length,
|
|
234
|
+
unavailableMcp: mcpRows.filter((item) => item.status === "unavailable").length,
|
|
235
|
+
},
|
|
236
|
+
auditStatusCounts: countBy(auditRows, (item) => item.row.status, CHECKLIST_STATUS_OPTIONS),
|
|
237
|
+
mcpStatusCounts: countBy(mcpRows, (item) => item.status, MCP_STATUS_OPTIONS),
|
|
238
|
+
taskPriorityCounts: countBy(workspace.refactorTasks, (task) => task.priority, PRIORITY_OPTIONS),
|
|
239
|
+
requiredMcp,
|
|
240
|
+
topTasks,
|
|
241
|
+
issues,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export function analyzeSiteWorkspace(raw, { filePath = "workspace.json" } = {}) {
|
|
246
|
+
const issues = validateRawWorkspace(raw);
|
|
247
|
+
const workspace = normalizeSiteWorkspace(raw);
|
|
248
|
+
const summary = summarizeWorkspace(workspace, issues, filePath);
|
|
249
|
+
|
|
250
|
+
if (summary.status === "pass") {
|
|
251
|
+
addIssue(summary.issues, "pass", "workspace-ready", "Workspace is ready for report and prompt generation");
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return {
|
|
255
|
+
workspace,
|
|
256
|
+
summary: {
|
|
257
|
+
...summary,
|
|
258
|
+
status: statusFromIssues(summary.issues),
|
|
259
|
+
valid: statusFromIssues(summary.issues) !== "fail",
|
|
260
|
+
},
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export function loadSiteWorkspaceInput({
|
|
265
|
+
target = "",
|
|
266
|
+
stdin = false,
|
|
267
|
+
cwd = process.cwd(),
|
|
268
|
+
readStdin = () => readFileSync(0, "utf8"),
|
|
269
|
+
} = {}) {
|
|
270
|
+
const filePath = stdin ? "stdin" : path.resolve(cwd, target);
|
|
271
|
+
const rawText = stdin ? String(readStdin()) : readFileSync(filePath, "utf8");
|
|
272
|
+
let parsed;
|
|
273
|
+
try {
|
|
274
|
+
parsed = JSON.parse(rawText);
|
|
275
|
+
} catch (error) {
|
|
276
|
+
throw new Error(`Invalid Website Improvement workspace JSON in ${filePath}: ${error.message}`);
|
|
277
|
+
}
|
|
278
|
+
return {
|
|
279
|
+
filePath,
|
|
280
|
+
rawText,
|
|
281
|
+
raw: parsed,
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export function buildSiteReport({
|
|
286
|
+
target = "",
|
|
287
|
+
stdin = false,
|
|
288
|
+
cwd = process.cwd(),
|
|
289
|
+
readStdin,
|
|
290
|
+
} = {}) {
|
|
291
|
+
const input = loadSiteWorkspaceInput({ target, stdin, cwd, readStdin });
|
|
292
|
+
return analyzeSiteWorkspace(input.raw, { filePath: input.filePath });
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export function formatSiteJson(report) {
|
|
296
|
+
return JSON.stringify(report, null, 2);
|
|
297
|
+
}
|