@ryuenn3123/agentic-senior-core 3.0.50 → 4.0.1

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.
Files changed (89) hide show
  1. package/.agent-context/prompts/bootstrap-design.md +3 -1
  2. package/.agent-context/prompts/research-design.md +165 -0
  3. package/.agent-context/review-checklists/pr-checklist.md +1 -0
  4. package/.agent-context/rules/api-docs.md +63 -47
  5. package/.agent-context/rules/architecture.md +133 -120
  6. package/.agent-context/rules/database-design.md +36 -18
  7. package/.agent-context/rules/docker-runtime.md +66 -43
  8. package/.agent-context/rules/efficiency-vs-hype.md +38 -17
  9. package/.agent-context/rules/error-handling.md +35 -16
  10. package/.agent-context/rules/event-driven.md +35 -18
  11. package/.agent-context/rules/frontend-architecture.md +103 -76
  12. package/.agent-context/rules/git-workflow.md +81 -197
  13. package/.agent-context/rules/microservices.md +42 -41
  14. package/.agent-context/rules/naming-conv.md +27 -8
  15. package/.agent-context/rules/performance.md +32 -12
  16. package/.agent-context/rules/realtime.md +26 -9
  17. package/.agent-context/rules/security.md +39 -20
  18. package/.agent-context/rules/testing.md +36 -16
  19. package/AGENTS.md +21 -20
  20. package/README.md +10 -1
  21. package/lib/cli/commands/init.mjs +12 -0
  22. package/lib/cli/commands/upgrade.mjs +11 -0
  23. package/lib/cli/compiler.mjs +1 -0
  24. package/lib/cli/detector/constants.mjs +135 -0
  25. package/lib/cli/detector/design-evidence/collector.mjs +256 -0
  26. package/lib/cli/detector/design-evidence/constants.mjs +39 -0
  27. package/lib/cli/detector/design-evidence/file-traversal.mjs +83 -0
  28. package/lib/cli/detector/design-evidence/structured-attribute-evidence.mjs +117 -0
  29. package/lib/cli/detector/design-evidence/summary.mjs +109 -0
  30. package/lib/cli/detector/design-evidence/utility-helpers.mjs +122 -0
  31. package/lib/cli/detector/design-evidence.mjs +25 -610
  32. package/lib/cli/detector/stack-detection.mjs +243 -0
  33. package/lib/cli/detector/ui-signals.mjs +150 -0
  34. package/lib/cli/detector/workspace-scan.mjs +177 -0
  35. package/lib/cli/detector.mjs +20 -688
  36. package/lib/cli/memory-continuity.mjs +1 -0
  37. package/lib/cli/project-scaffolder/design-contract/research-dossier-migration.mjs +165 -0
  38. package/lib/cli/project-scaffolder/design-contract/sections/audits.mjs +96 -0
  39. package/lib/cli/project-scaffolder/design-contract/sections/conceptual-anchor.mjs +233 -0
  40. package/lib/cli/project-scaffolder/design-contract/sections/execution-handoff.mjs +211 -0
  41. package/lib/cli/project-scaffolder/design-contract/seed-signals.mjs +79 -0
  42. package/lib/cli/project-scaffolder/design-contract/signal-vocab.mjs +64 -0
  43. package/lib/cli/project-scaffolder/design-contract/validation/anchor-validators.mjs +456 -0
  44. package/lib/cli/project-scaffolder/design-contract/validation/audit-validators.mjs +117 -0
  45. package/lib/cli/project-scaffolder/design-contract/validation/completeness.mjs +83 -0
  46. package/lib/cli/project-scaffolder/design-contract/validation/execution-validators.mjs +328 -0
  47. package/lib/cli/project-scaffolder/design-contract/validation/helpers.mjs +8 -0
  48. package/lib/cli/project-scaffolder/design-contract/validation/research-dossier-validators.mjs +104 -0
  49. package/lib/cli/project-scaffolder/design-contract/validation/structural-validators.mjs +79 -0
  50. package/lib/cli/project-scaffolder/design-contract/validation/system-validators.mjs +256 -0
  51. package/lib/cli/project-scaffolder/design-contract/validation.mjs +61 -896
  52. package/lib/cli/project-scaffolder/design-contract.mjs +151 -556
  53. package/lib/cli/project-scaffolder/prompt-builders.mjs +9 -0
  54. package/mcp.json +30 -9
  55. package/package.json +17 -2
  56. package/scripts/audit-cache-layer-contract.mjs +258 -0
  57. package/scripts/audit-caching-scope-hygiene.mjs +263 -0
  58. package/scripts/audit-file-size.mjs +219 -0
  59. package/scripts/audit-reflection-citations.mjs +163 -0
  60. package/scripts/audit-release-bundle.mjs +170 -0
  61. package/scripts/audit-rule-id-uniqueness.mjs +313 -0
  62. package/scripts/benchmark-evidence-bundle.mjs +1 -0
  63. package/scripts/build-release-benchmark-bundle.mjs +204 -0
  64. package/scripts/context-triggered-audit.mjs +1 -0
  65. package/scripts/documentation-boundary-audit.mjs +1 -0
  66. package/scripts/explain-on-demand-audit.mjs +2 -1
  67. package/scripts/frontend-usability-audit.mjs +10 -10
  68. package/scripts/llm-judge/checklist-loader.mjs +45 -0
  69. package/scripts/llm-judge/constants.mjs +66 -0
  70. package/scripts/llm-judge/diff-collection.mjs +74 -0
  71. package/scripts/llm-judge/prompting.mjs +78 -0
  72. package/scripts/llm-judge/providers.mjs +111 -0
  73. package/scripts/llm-judge/verdict.mjs +134 -0
  74. package/scripts/llm-judge.mjs +21 -482
  75. package/scripts/mcp-server/tool-registry.mjs +55 -0
  76. package/scripts/mcp-server/tools.mjs +137 -1
  77. package/scripts/migrate-rule-format/id-prefix-table.mjs +37 -0
  78. package/scripts/migrate-rule-format/parse-legacy.mjs +180 -0
  79. package/scripts/migrate-rule-format/render-new.mjs +169 -0
  80. package/scripts/migrate-rule-format/roundtrip-validate.mjs +89 -0
  81. package/scripts/migrate-rule-format.mjs +192 -0
  82. package/scripts/release-gate/constants.mjs +1 -1
  83. package/scripts/release-gate/static-checks.mjs +1 -1
  84. package/scripts/rules-guardian-audit.mjs +5 -2
  85. package/scripts/single-source-lazy-loading-audit.mjs +2 -1
  86. package/scripts/ui-design-judge/git-input.mjs +3 -0
  87. package/scripts/validate/config.mjs +27 -2
  88. package/scripts/validate/coverage-checks.mjs +1 -1
  89. package/scripts/validate.mjs +94 -1
@@ -1,139 +1,43 @@
1
+ /**
2
+ * Design Intent Contract builder. Composes the structured contract from
3
+ * focused section builders living under `design-contract/`. Public exports
4
+ * preserve the original surface so callers (project-scaffolder, storage,
5
+ * prompt-builders) do not need to change.
6
+ *
7
+ * Public exports:
8
+ * shouldBootstrapDesignDocument
9
+ * buildDesignIntentSeedFromSignals
10
+ * buildDesignIntentSeed
11
+ * validateDesignContractCompleteness (re-exported from validation)
12
+ * validateDesignIntentContract (re-exported from validation)
13
+ */
14
+
1
15
  import { toTitleCase } from '../utils.mjs';
2
16
  import { DESIGN_REQUIRED_SECTIONS } from './constants.mjs';
3
- import { validateDesignIntentContract } from './design-contract/validation.mjs';
4
-
5
- const GENERICITY_DRIFT_SIGNALS = [
6
- 'offline-prescribed-style-used-as-final-direction',
7
- 'unresearched-library-or-framework-choice',
8
- 'missing-conceptual-anchor-without-external-research',
9
- 'visual-decisions-not-derived-from-conceptual-anchor',
10
- 'ai-safe-ui-template-look',
11
- 'ai-color-default-palette-without-product-role-behavior',
12
- 'brandless-clean-template-look',
13
- 'interchangeable-product-renaming-test-fails',
14
- 'decorative-grid-or-glow-wallpaper-without-product-function',
15
- 'decorative-line-or-calibration-wallpaper-without-product-function',
16
- 'measurement-or-calibration-marks-used-as-page-background',
17
- 'testing-demo-or-placeholder-copy-shipped-to-ui',
18
- 'terminal-only-user-flow-without-product-reason',
19
- 'safe-cream-slate-or-monochrome-palette-used-as-readability-excuse',
20
- 'generic-abstract-logo-or-iconography',
21
- 'timid-anchor-that-renames-dashboard-or-admin-shell',
22
- 'motion-suppressed-without-accessibility-or-performance-reason',
23
- 'motion-or-3d-omitted-from-fear-without-fit-analysis',
24
- 'modern-library-rejected-from-dependency-fear-without-tradeoff-analysis',
25
- 'component-library-selected-by-habit-without-product-fit',
26
- 'scale-only-responsive-layout',
27
- 'zero-based-redesign-kept-prior-visual-dna',
28
- 'restyle-instead-of-recomposition',
29
- 'literal-anchor-artifacts-used-as-required-ui-chrome',
30
- 'candidate-signature-move-treated-as-locked-implementation',
31
- 'library-theme-tokens-drive-visual-language',
32
- 'spatial-room-anchor-used-by-habit',
33
- 'place-metaphor-used-as-layout-model-without-product-function',
34
- 'external-website-reference-copied-as-style',
35
- 'tailwind-only-or-component-kit-used-as-neutrality-claim',
36
- 'framework-selected-by-familiarity-instead-of-evidence',
37
- 'manual-framework-scaffold-used-when-official-setup-fits',
38
- ];
17
+ import {
18
+ validateDesignContractCompleteness,
19
+ validateDesignIntentContract,
20
+ } from './design-contract/validation.mjs';
39
21
 
40
- const FORBIDDEN_PATTERN_SIGNALS = [
41
- ...GENERICITY_DRIFT_SIGNALS.filter((signal) => signal !== 'unresearched-library-or-framework-choice'),
42
- 'single-safe-typographic-family-without-role-contrast-or-rationale',
43
- ];
44
-
45
- const VALID_BOLD_SIGNALS = [
46
- 'single-cohesive-conceptual-anchor',
47
- 'high-variance-candidate-selection',
48
- 'context-derived-visual-direction',
49
- 'three-at-a-glance-product-specific-signals',
50
- 'visually-exploratory-accessible-palette-derived-from-product',
51
- 'audacious-accessible-palette-with-product-role-behavior',
52
- 'background-or-geometry-serves-product-function',
53
- 'motion-or-spatial-experience-derived-from-anchor',
54
- 'explicit-3d-canvas-fit-or-nonfit-decision',
55
- 'official-docs-backed-modern-library-choice',
56
- 'headless-or-component-primitive-restyled-to-product-language',
57
- 'responsive-recomposition-by-task-priority',
58
- 'purposeful-motion-with-reduced-motion-path',
59
- 'non-spatial-product-anchor-or-workflow-mechanism',
60
- 'official-scaffolder-used-for-supported-project-shape',
61
- 'framework-choice-compared-against-plausible-alternative',
62
- ];
63
-
64
- export function shouldBootstrapDesignDocument(discoveryAnswers, initContext) {
65
- const normalizedDomain = String(discoveryAnswers.primaryDomain || '').trim().toLowerCase();
66
- const normalizedBlueprint = String(initContext.blueprintFileName || '').trim().toLowerCase();
67
-
68
- const isUiDomain = normalizedDomain.includes('web')
69
- || normalizedDomain.includes('mobile')
70
- || normalizedDomain.includes('frontend')
71
- || normalizedDomain.includes('fullstack')
72
- || normalizedDomain.includes('ui');
73
-
74
- const isBackendOnlyDomain = normalizedDomain.includes('api service')
75
- || normalizedDomain.includes('cli tool')
76
- || normalizedDomain.includes('library');
22
+ import { buildStructureFirstSeedSignals, shouldBootstrapDesignDocument } from './design-contract/seed-signals.mjs';
23
+ import { FORBIDDEN_PATTERN_SIGNALS } from './design-contract/signal-vocab.mjs';
24
+ import { buildConceptualAnchorSection } from './design-contract/sections/conceptual-anchor.mjs';
25
+ import { buildResearchDossierMetadata } from './design-contract/research-dossier-migration.mjs';
26
+ import {
27
+ buildAccessibilityPolicySection,
28
+ buildAiSafeUiAuditSection,
29
+ buildMotionPaletteDecisionSection,
30
+ buildProductionContentPolicySection,
31
+ } from './design-contract/sections/audits.mjs';
32
+ import {
33
+ buildContextHygieneSection,
34
+ buildDesignExecutionHandoffSection,
35
+ buildDesignExecutionPolicySection,
36
+ buildReviewRubricSection,
37
+ } from './design-contract/sections/execution-handoff.mjs';
77
38
 
78
- const blueprintLooksUi = normalizedBlueprint.includes('frontend')
79
- || normalizedBlueprint.includes('landing')
80
- || normalizedBlueprint.includes('ui');
81
-
82
- if (isUiDomain) {
83
- return true;
84
- }
85
-
86
- if (!isBackendOnlyDomain && blueprintLooksUi) {
87
- return true;
88
- }
89
-
90
- return false;
91
- }
92
-
93
- function buildStructureFirstSeedSignals({
94
- projectName,
95
- projectDescription,
96
- primaryDomain,
97
- supplementalFields = {},
98
- }) {
99
- const normalizedDescription = String(projectDescription || '').trim();
100
- const repoEvidenceSummary = supplementalFields?.repoEvidence?.designEvidenceSummary || null;
101
- const hasRepoEvidence = Boolean(
102
- repoEvidenceSummary
103
- || (Array.isArray(supplementalFields?.repoEvidence?.workspaceUiEntries)
104
- && supplementalFields.repoEvidence.workspaceUiEntries.length > 0)
105
- );
106
- const evidenceSourceLabel = hasRepoEvidence
107
- ? 'current repo evidence, existing UI code, and the active brief'
108
- : 'the active brief and any repo evidence available at synthesis time';
109
- const projectContextLabel = normalizedDescription
110
- ? `the product context "${normalizedDescription}"`
111
- : 'the current product context';
112
-
113
- return {
114
- designPhilosophy: `Synthesize design for ${projectName || 'this project'} from ${evidenceSourceLabel}. Choose visual language, libraries, color, type, spacing, and interaction from ${projectContextLabel}; verify technology claims with official docs.`,
115
- typographyScaleRatio: 'agent-calibrated-from-content-platform-and-readability',
116
- baseGridUnit: 'agent-calibrated-from-platform-density-and-implementation-stack',
117
- spacingPattern: 'agent-defined-from-task-flow-and-viewport-needs',
118
- densityMode: 'agent-defined-from-user-task-device-and-content-pressure',
119
- colorIntent: `Choose semantic palette roles from ${projectContextLabel}, repo evidence, and accessibility. Reject scaffold or SaaS palette defaults.`,
120
- paletteRoles: ['agent-defined-semantic-roles'],
121
- distinctiveMoves: [
122
- 'Choose one product-specific move from task, audience, content, repo evidence, and docs.',
123
- ],
124
- motionPurpose: 'Use expressive motion when it improves hierarchy, continuity, feedback, memorability, or confidence. Verify new motion libraries with official docs.',
125
- componentMorphology: {
126
- mobile: 'Recompose for touch, task priority, and constrained attention.',
127
- tablet: 'Regroup surfaces for medium width without cloning desktop or mobile.',
128
- desktop: 'Use space for hierarchy and scanability; avoid template grids.',
129
- },
130
- mutationRules: {
131
- mobile: 'Reorder, merge, or disclose content for mobile. Reject scale-only shrink.',
132
- tablet: 'Regroup for tablet instead of width-only desktop reduction.',
133
- desktop: 'Use space intentionally; avoid equal-weight modules without evidence.',
134
- },
135
- };
136
- }
39
+ export { shouldBootstrapDesignDocument };
40
+ export { validateDesignContractCompleteness, validateDesignIntentContract };
137
41
 
138
42
  function buildDesignIntentContractObject({
139
43
  projectName,
@@ -220,113 +124,9 @@ function buildDesignIntentContractObject({
220
124
  spatialMetaphorPolicy: 'Do not default anchors to room, darkroom, counting room, control room, war room, studio, lab, cockpit, or command center. Use place metaphors only when the product truly depends on a physical place model.',
221
125
  externalInspirationPolicy: 'External websites and examples are candidate evidence for constraints, mechanics, and quality bars; do not copy their layout rhythm, palette, component skin, brand posture, or visual metaphor.',
222
126
  },
223
- conceptualAnchor: {
224
- mode: 'required-when-no-external-research',
225
- seedMode: 'selection-policy-only',
226
- anchorReference: 'agent-defined-anchor-reference',
227
- requiresAgentSelectionBeforeUiImplementation: true,
228
- userResearchAbsencePolicy: {
229
- userSuppliedResearchOnly: true,
230
- scaffoldSeedDoesNotCountAsResearch: true,
231
- priorUiDoesNotCountAsResearch: true,
232
- requireAgentLedResearchWhenAvailable: true,
233
- },
234
- candidateSelectionPolicy: {
235
- considerAtLeast: 3,
236
- discardObviousCandidateCount: 2,
237
- minimumCandidateDistance: 'high',
238
- discardPredictableCandidates: true,
239
- preferDistinctiveOverSafe: true,
240
- doNotRevealHiddenCandidateList: true,
241
- outputOnlyChosenAnchor: true,
242
- avoidSpatialPlaceMetaphorByDefault: true,
243
- preferMechanismOverPlace: true,
244
- },
245
- creativeCommitmentPolicy: {
246
- requiredBeforeComplianceReview: true,
247
- recordInDesignDocs: true,
248
- requiredCommitmentFields: [
249
- 'specificReferencePoint',
250
- 'signatureMotion',
251
- 'typographicDecision',
252
- ],
253
- rejectGenericQualityWordsOnly: true,
254
- specificityFloor: 'name-real-material-instrument-artifact-architecture-editorial-genre-cinematic-behavior-exhibition-system-scientific-apparatus-or-industrial-mechanism',
255
- },
256
- forbiddenFinalAnchorTerms: [
257
- 'dashboard',
258
- 'cards',
259
- 'admin-panel',
260
- 'saas-shell',
261
- 'minimalist-interface',
262
- 'safe-admin-layout',
263
- 'room',
264
- 'darkroom',
265
- 'counting-room',
266
- 'control-room',
267
- 'war-room',
268
- 'studio',
269
- 'lab',
270
- 'cockpit',
271
- 'command-center',
272
- ],
273
- sourceDomains: [
274
- 'complex-physical-engineering',
275
- 'cinematic-behavior-and-transition-systems',
276
- 'experimental-editorial-structure',
277
- 'scientific-instrumentation',
278
- 'workflow-and-custody-systems',
279
- 'material-artifacts-and-instruments',
280
- 'premium-interactive-web-experiences',
281
- ],
282
- visualRiskBudget: {
283
- mode: 'high-distinctiveness-with-accessibility-and-performance-guardrails',
284
- allowRichMotionAndMicroInteraction: true,
285
- rejectTimidDefaultWhenAnchorSupportsExpressiveUi: true,
286
- rejectDependencyFearAsDownshiftReason: true,
287
- requireReducedMotionFallback: true,
288
- },
289
- literalTranslationPolicy: {
290
- preferNonLiteralTranslation: true,
291
- allowedLiteralUse: 'Only use literal anchor artifacts when they serve a named product function, control, state, or task overlay.',
292
- forbiddenLiteralUse: 'Do not turn anchor artifacts into decorative wallpaper, required chrome, default texture, or unavoidable theme props.',
293
- },
294
- spatialAutopilotPolicy: {
295
- forbiddenHabitTerms: ['room', 'darkroom', 'counting-room', 'control-room', 'war-room', 'studio', 'lab', 'cockpit', 'command-center'],
296
- allowedOnlyWhen: 'The product has a real physical place model, operational environment, or user workflow that depends on that place metaphor.',
297
- replacementPreference: 'Use artifacts, custody flows, instruments, data behaviors, material systems, editorial systems, service rituals, or interaction mechanisms.',
298
- reviewQuestion: 'Could this anchor still work if the word "room" was removed? If not, revise before UI code.',
299
- },
300
- requiredDerivedAxes: [
301
- 'typography',
302
- 'morphology',
303
- 'motion',
304
- 'responsive-composition',
305
- ],
306
- finalAnchorContract: {
307
- requiredFields: [
308
- 'name',
309
- 'anchorReference',
310
- 'agentResearchMode',
311
- 'sourceDomain',
312
- 'specificReferencePoint',
313
- 'rationale',
314
- 'signatureMotion',
315
- 'typographicDecision',
316
- 'derivedTokenLogic',
317
- 'visualRiskBudget',
318
- 'motionRiskBudget',
319
- 'cohesionChecks',
320
- ],
321
- derivedTokenLogicAxes: [
322
- 'morphology',
323
- 'motion',
324
- ],
325
- cohesionChecks: [
326
- 'no-dashboard-mental-model',
327
- 'motion-derived-from-anchor',
328
- ],
329
- },
127
+ conceptualAnchor: buildConceptualAnchorSection(),
128
+ researchDossier: {
129
+ metadata: buildResearchDossierMetadata(),
330
130
  },
331
131
  derivedTokenLogic: {
332
132
  anchorReference: 'agent-defined-anchor-reference',
@@ -340,62 +140,9 @@ function buildDesignIntentContractObject({
340
140
  motionBudget: 'Name micro, layout, entrance, easing, stagger, and reduced-motion budgets; prefer transform/opacity for high-frequency motion.',
341
141
  validationRule: 'Every semantic token role must trace to anchorReference; keep exact primitive values flexible unless locked by repo evidence, accessibility validation, implementation constraints, or explicit user approval.',
342
142
  },
343
- motionPaletteDecision: {
344
- productCategorySignal: 'agent-inferred-starting-heuristic',
345
- densityDecisionSource: 'Choose motion density from task, content, brand, device, performance, and accessibility. Categories are heuristics.',
346
- requiredInteractionStates: ['default', 'hover', 'focus-visible', 'active', 'disabled', 'loading', 'empty', 'error', 'success', 'transition'],
347
- paletteAutopilotRisks: ['dark-slate-default', 'cream-beige-default', 'purple-blue-gradient-default', 'monochrome-template-default', 'uniform-card-surface-default', 'generic-grid-wallpaper-default', 'generic-line-wallpaper-default', 'calibration-mark-wallpaper-default', 'soft-glow-ai-template-default', 'cyber-neon-terminal-default'],
348
- spatialDecision: 'State 3D/canvas/WebGL fit. If omitted, name product-fit reason and replacement interaction quality.',
349
- },
350
- aiSafeUiAudit: {
351
- status: 'agent-must-complete-before-ui-implementation',
352
- failureDefinition: 'AI-safe UI uses template cards, generic marks, decorative grid or line wallpaper, calibration-mark wallpaper, test/demo/placeholder copy, terminal-only user paths, safe palettes, glow backgrounds, or copied scaffold composition.',
353
- interchangeabilityTest: `If this UI can be renamed from ${projectName} to another product category without changing composition, palette, iconography, and motion, revise it.`,
354
- requiredProductSpecificSignals: [
355
- 'agent-defined-product-specific-data-treatment',
356
- 'agent-defined-product-specific-motion-or-state-behavior',
357
- 'agent-defined-product-specific-morphology-iconography-or-spatial-structure',
358
- ],
359
- paletteExplorationRule: 'Use a visually exploratory product-derived palette with WCAG contrast and status clarity.',
360
- backgroundPatternRule: 'Lines, grids, scanlines, noise, glows, blobs, logos, calibration marks, and geometry must serve a named product function; never use grid, line, or calibration-mark backgrounds as first-output filler. Measurement and inspection marks belong to task overlays or controls, not page wallpaper.',
361
- aiColorAudit: {
362
- status: 'agent-must-complete-before-ui-implementation',
363
- failureDefinition: 'AI color drift uses safe defaults before deriving roles from the product anchor.',
364
- autopilotRisks: ['cream-editorial-default', 'dark-slate-dashboard-default', 'purple-blue-gradient-default', 'monochrome-minimal-default', 'cyber-neon-terminal-default', 'soft-glow-atmosphere-default'],
365
- requiredEvidence: [
366
- 'anchor-derived-color-logic',
367
- 'semantic-role-contrast-beyond-surface-decoration',
368
- 'product-specific-color-behavior-that-would-not-transfer',
369
- ],
370
- reviewQuestion: 'Why does this palette belong to this product?',
371
- },
372
- motionSpatialCourageAudit: {
373
- status: 'agent-must-complete-before-ui-implementation',
374
- defaultStance: 'Treat motion, scroll choreography, canvas, WebGL, and 3D as first-class options.',
375
- requiredDecisionFields: [
376
- 'signature-motion-or-interaction',
377
- 'spatial-or-3d-fit',
378
- 'performance-and-reduced-motion-fallback',
379
- ],
380
- rejectionRule: 'State a product reason and replacement interaction quality before omitting 3D/canvas. Package count or vague performance fear is not enough.',
381
- reviewQuestion: 'Is the interaction as expressive as the product can responsibly support?',
382
- },
383
- reviewQuestion: 'What visible evidence proves this is product-specific?',
384
- blockingByDefault: true,
385
- },
386
- productionContentPolicy: {
387
- status: 'agent-must-complete-before-ui-implementation',
388
- userFacingCopyRule: 'Visible UI copy must be product-ready and task-specific. Do not ship testing, demo, sample, placeholder, lorem, TODO, coming soon, or scaffold labels unless they are real product states.',
389
- terminalDependencyRule: 'User-facing workflows must be operable through the UI unless the product is explicitly a CLI, developer tool, or operational runbook. Terminal commands belong in setup and deployment docs, not as the only path for core user tasks.',
390
- allowedExceptions: [
391
- 'test-harness-only',
392
- 'documented-empty-state',
393
- 'admin-or-devtool-diagnostic-surface',
394
- 'explicit-user-requested-prototype',
395
- ],
396
- reviewQuestion: 'Can this UI be shipped to real users without removing test/demo copy or terminal-only workflow dependencies?',
397
- blockingByDefault: true,
398
- },
143
+ motionPaletteDecision: buildMotionPaletteDecisionSection(),
144
+ aiSafeUiAudit: buildAiSafeUiAuditSection({ projectName }),
145
+ productionContentPolicy: buildProductionContentPolicySection(),
399
146
  libraryResearchStatus: 'pending-verification',
400
147
  libraryDecisions: [
401
148
  {
@@ -473,265 +220,15 @@ function buildDesignIntentContractObject({
473
220
  stateKeys: ['default', 'hover', 'focus-visible', 'active', 'disabled', 'loading', 'empty', 'error', 'success', 'transition'],
474
221
  viewportBehavior: inferredKeywords.componentMorphology,
475
222
  },
476
- accessibilityPolicy: {
477
- hardComplianceFloor: 'WCAG-2.2-AA',
478
- advisoryContrastModel: 'APCA',
479
- failOnHardViolations: true,
480
- advisoryFindingsDoNotBlockByDefault: true,
481
- hardRequirements: {
482
- textContrastMinimum: true,
483
- nonTextContrast: true,
484
- useOfColorOnlyProhibited: true,
485
- focusVisible: true,
486
- focusAppearance: true,
487
- targetSizeMinimum: true,
488
- keyboardAccess: true,
489
- reflowRequired: true,
490
- accessibleAuthenticationMinimum: true,
491
- statusMessagesAndDynamicStateAccess: true,
492
- },
493
- advisoryChecks: {
494
- perceptualContrastReview: true,
495
- darkModeContrastTuning: true,
496
- typographyReadabilityTuning: true,
497
- },
498
- },
499
- designExecutionPolicy: {
500
- representationStrategy: 'surface-plan-v1',
501
- seedRefinementRequiredBeforeUiImplementation: true,
502
- requireSurfacePlan: true,
503
- requireComponentGraph: true,
504
- requireViewportMutationPlan: true,
505
- requireInteractionStateMatrix: true,
506
- requireContentPriorityMap: true,
507
- requireTaskFlowNarrative: true,
508
- requireSignatureMoveRationale: true,
509
- requireCreativeCommitmentGate: true,
510
- requireStructuredHandoff: true,
511
- requireRepoEvidenceAlignment: true,
512
- forbidScreenshotDependency: true,
513
- separateRequiredOutcomesFromCandidateMoves: true,
514
- forbidCandidateMovesAsLockedRequirements: true,
515
- forbidLibraryThemeAsVisualAuthority: true,
516
- forbidLiteralAnchorChromeWithoutProductFunction: true,
517
- handoffFormatVersion: 'ui-handoff-v1',
518
- requirePerSurfaceMutationOps: true,
519
- forbidUniformSiblingSurfaceTreatment: true,
520
- zeroBasedRedesignResetsPriorVisualsWhenRequested: true,
521
- semanticReviewFocus: [
522
- 'distinctiveness-vs-genericity',
523
- 'contract-fidelity',
524
- 'hierarchy-and-task-priority',
525
- 'component-state-behavior',
526
- 'cross-viewport-mutation',
527
- ],
528
- },
529
- designExecutionHandoff: {
530
- version: 'ui-handoff-v1',
531
- location: 'inline-design-intent',
532
- status: 'seed-needs-refinement',
533
- seedMode: 'structure-first-scaffold',
534
- requiresTaskSpecificRefinement: true,
535
- primaryExperienceGoal: `Define the main ${String(primaryDomain || 'product').toLowerCase()} journey for ${projectName} from repo evidence, brief, and docs.`,
536
- surfacePlan: [
537
- {
538
- surfaceId: 'agent-defined-primary-experience',
539
- role: 'primary-context-synthesized-by-agent',
540
- goal: 'Choose the first task path from product evidence; reject template shells.',
541
- antiPatterns: ['dashboard-default', 'scale-only-responsive-layout'],
542
- },
543
- ],
544
- componentGraph: {
545
- nodes: [
546
- {
547
- id: 'primary-experience',
548
- role: 'agent-defined-primary',
549
- priority: 'high',
550
- },
551
- {
552
- id: 'supporting-context',
553
- role: 'agent-defined-support',
554
- priority: 'medium',
555
- },
556
- ],
557
- edges: [
558
- {
559
- from: 'primary-experience',
560
- to: 'supporting-context',
561
- relationship: 'task-priority-support',
562
- },
563
- ],
564
- },
565
- contentPriorityMap: {
566
- primary: [
567
- 'agent-defined-core-task-or-reading-path',
568
- ],
569
- secondary: [
570
- 'agent-defined-supporting-context',
571
- ],
572
- deferred: [
573
- 'agent-defined-deferred-or-hidden-content',
574
- ],
575
- },
576
- viewportMutationPlan: {
577
- mobile: {
578
- primaryOperation: 'agent-defined-mobile-recomposition',
579
- requiredSurfaceActions: [
580
- 'choose-mobile-task-order',
581
- 'disclose-or-remove-low-priority-content',
582
- ],
583
- forbiddenPatterns: [
584
- 'scale-only-shrink',
585
- ],
586
- rationale: inferredKeywords.mutationRules.mobile,
587
- },
588
- tablet: {
589
- primaryOperation: 'agent-defined-tablet-regrouping',
590
- requiredSurfaceActions: [
591
- 'define-medium-width-grouping',
592
- 'preserve-task-clarity',
593
- ],
594
- forbiddenPatterns: [
595
- 'uniform-module-grid-without-role-change',
596
- ],
597
- rationale: inferredKeywords.mutationRules.tablet,
598
- },
599
- desktop: {
600
- primaryOperation: 'agent-defined-desktop-composition',
601
- requiredSurfaceActions: [
602
- 'use-space-to-improve-hierarchy',
603
- 'avoid-equalizing-unrelated-content',
604
- ],
605
- forbiddenPatterns: [
606
- 'interchangeable-dashboard-or-landing-chrome',
607
- ],
608
- rationale: inferredKeywords.mutationRules.desktop,
609
- },
610
- },
611
- interactionStateMatrix: [
612
- {
613
- componentId: 'primary-interaction',
614
- states: ['default', 'hover', 'focus', 'loading', 'error'],
615
- notes: 'Refine states from project language and anchor; reject anonymous panels.',
616
- },
617
- ],
618
- expressionFlexibility: {
619
- lockedOutcomes: [
620
- 'preserve-primary-user-goal',
621
- 'preserve-accessibility-floor',
622
- 'preserve-production-content-policy',
623
- 'preserve-forbidden-patterns',
624
- ],
625
- candidateSignatureMoves: [
626
- 'agent-defined-candidate-move-not-locked-until-refined',
627
- ],
628
- flexibleAxes: [
629
- 'palette-primitives',
630
- 'typeface-choice',
631
- 'surface-treatment',
632
- 'component-library-skin',
633
- 'motion-implementation',
634
- 'anchor-artifact-literalness',
635
- ],
636
- lockingRule: 'A candidate move becomes required only after repo evidence, product function, accessibility need, or explicit user approval makes it necessary.',
637
- },
638
- taskFlowNarrative: [
639
- `Entry: start ${projectName} from real evidence, not a generic opener.`,
640
- 'Resolution: define proof, feedback, recovery, and next action.',
641
- ],
642
- visualResetStrategy: {
643
- activatesWhenUserRequests: [
644
- 'redesign from zero',
645
- 'redesain dari 0',
646
- ],
647
- existingUiAllowedAs: ['content-evidence', 'behavior-evidence', 'asset-source-evidence'],
648
- existingUiForbiddenAs: ['palette-source', 'layout-source', 'motion-source'],
649
- requiredResetAxes: ['composition', 'hierarchy', 'motion-or-interaction', 'responsive-information-architecture'],
650
- },
651
- signatureMoveRationale: 'Choose one project-specific visual, motion, type, or interaction move.',
652
- creativeCommitment: {
653
- status: 'agent-must-complete-before-ui-implementation',
654
- requiredFields: [
655
- 'specificReferencePoint',
656
- 'signatureMotion',
657
- 'typographicDecision',
658
- ],
659
- failureMode: 'generic quality words without a real-world reference fail',
660
- },
661
- implementationGuardrails: {
662
- requireBuildFromHandoff: true,
663
- requireGapNotesBeforeFallback: true,
664
- forbidGenericLayoutFallbackWithoutReason: true,
665
- requireLockedVsFlexibleDecisionReview: true,
666
- forbidCandidateMoveHardcoding: true,
667
- forbidTestingDemoCopyInUi: true,
668
- forbidTerminalOnlyUserFlows: true,
669
- },
670
- },
671
- reviewRubric: {
672
- version: 'ui-rubric-v1',
673
- genericityAutoFail: true,
674
- dimensions: [
675
- {
676
- key: 'distinctiveness',
677
- blockingByDefault: true,
678
- question: 'Is the UI authored and product-specific?',
679
- },
680
- {
681
- key: 'contractFidelity',
682
- blockingByDefault: true,
683
- question: 'Does the UI follow contract, priorities, and accessibility?',
684
- },
685
- {
686
- key: 'visualConsistency',
687
- blockingByDefault: false,
688
- question: 'Do type, spacing, color, and states form one system?',
689
- },
690
- {
691
- key: 'heuristicUxQuality',
692
- blockingByDefault: false,
693
- question: 'Does the UI preserve clarity, feedback, and confidence?',
694
- },
695
- {
696
- key: 'motionDiscipline',
697
- blockingByDefault: false,
698
- question: 'Is motion purposeful, performant, reduced-motion-safe, and on-tone?',
699
- },
700
- ],
701
- genericitySignals: [...GENERICITY_DRIFT_SIGNALS],
702
- validBoldSignals: [...VALID_BOLD_SIGNALS],
703
- reportingRules: {
704
- mustExplainGenericity: true,
705
- mustSeparateTasteFromFailure: true,
706
- contractFidelityOverridesPersonalTaste: true,
707
- },
708
- },
709
- contextHygiene: {
710
- continuityMode: 'opt-in-only',
711
- allowedSources: [
712
- 'current-repo-evidence',
713
- 'current-user-brief',
714
- 'current-project-docs',
715
- 'explicitly-approved-current-task-constraints',
716
- ],
717
- taintedSources: [
718
- 'prior-chat-visual-memory',
719
- 'unrelated-project-aesthetics',
720
- 'remembered-screenshots-without-current-approval',
721
- 'generic-template-recall',
722
- ],
723
- repoEvidenceOverridesMemory: true,
724
- requireExplicitContinuityApproval: true,
725
- forbidCarryoverWhenUnapproved: true,
726
- approvedExternalConstraintUsage: 'Convert approved external constraints into current-project rules; do not imitate source surfaces.',
727
- externalWebsiteReferencePolicy: 'Use outside websites for mechanics, constraints, and quality bar analysis only. Do not copy layout rhythm, palette, component skin, visual metaphor, or brand posture.',
728
- driftSignals: [
729
- 'palette-reused-without-brief-support',
730
- 'prior-ui-visual-dna-carried-into-reset-request',
731
- 'room-or-control-room-anchor-repeated-without-product-need',
732
- 'external-reference-copied-instead-of-translated',
733
- ],
734
- },
223
+ accessibilityPolicy: buildAccessibilityPolicySection(),
224
+ designExecutionPolicy: buildDesignExecutionPolicySection(),
225
+ designExecutionHandoff: buildDesignExecutionHandoffSection({
226
+ projectName,
227
+ primaryDomain,
228
+ mutationRules: inferredKeywords.mutationRules,
229
+ }),
230
+ reviewRubric: buildReviewRubricSection(),
231
+ contextHygiene: buildContextHygieneSection(),
735
232
  forbiddenPatterns: [...FORBIDDEN_PATTERN_SIGNALS],
736
233
  validationHints: [
737
234
  'rejectArbitraryHexOnlyPalette',
@@ -781,6 +278,7 @@ function buildDesignIntentContractObject({
781
278
  bootstrapPrompt: '.agent-context/prompts/bootstrap-design.md',
782
279
  autoLoadedRuleFiles: [
783
280
  '.agent-context/prompts/bootstrap-design.md',
281
+ '.agent-context/prompts/research-design.md',
784
282
  '.agent-context/rules/frontend-architecture.md',
785
283
  ],
786
284
  disallowedAutoLoadedRuleFiles: [
@@ -793,8 +291,6 @@ function buildDesignIntentContractObject({
793
291
  };
794
292
  }
795
293
 
796
- export { validateDesignContractCompleteness, validateDesignIntentContract } from './design-contract/validation.mjs';
797
-
798
294
  export function buildDesignIntentSeedFromSignals({
799
295
  projectName,
800
296
  projectDescription,
@@ -835,3 +331,102 @@ export function buildDesignIntentSeed({
835
331
  status: 'seed-needs-design-synthesis',
836
332
  });
837
333
  }
334
+
335
+ /**
336
+ * Public schema index. Lists the field and signal names that this aggregator
337
+ * is responsible for surfacing, so static validators can confirm the
338
+ * aggregator declares the expected design contract surface in a single
339
+ * grep-able location even after the implementation was split across
340
+ * `design-contract/sections/*` files.
341
+ *
342
+ * Do not consume this array at runtime. It exists for the validate gate.
343
+ */
344
+ export const __DESIGN_CONTRACT_SCHEMA_INDEX__ = Object.freeze([
345
+ // top-level structural fields
346
+ 'tokenSystem',
347
+ 'seedPolicy',
348
+ 'structure-first-scaffold',
349
+ 'colorTruth',
350
+ 'motionPaletteDecision',
351
+ 'designFlexibilityPolicy',
352
+ 'crossViewportAdaptation',
353
+ 'motionSystem',
354
+ 'densitySource',
355
+ 'seedToneLocked',
356
+ 'componentMorphology',
357
+ 'seedBehaviorsRequireRefinement',
358
+ 'accessibilityPolicy',
359
+ 'designExecutionPolicy',
360
+ 'designExecutionHandoff',
361
+ 'reviewRubric',
362
+ 'contextHygiene',
363
+ // ai-safe-ui audit fields
364
+ 'aiSafeUiAudit',
365
+ 'aiColorAudit',
366
+ 'motionSpatialCourageAudit',
367
+ 'requireAiColorAudit',
368
+ 'requireMotionSpatialCourageAudit',
369
+ 'requireAiSafeUiAudit',
370
+ // genericity drift signals consumed by the rubric
371
+ 'ai-color-default-palette-without-product-role-behavior',
372
+ 'motion-or-3d-omitted-from-fear-without-fit-analysis',
373
+ 'ai-safe-ui-template-look',
374
+ 'interchangeable-product-renaming-test-fails',
375
+ 'decorative-grid-or-glow-wallpaper-without-product-function',
376
+ 'offline-prescribed-style-used-as-final-direction',
377
+ 'unresearched-library-or-framework-choice',
378
+ 'single-safe-typographic-family-without-role-contrast-or-rationale',
379
+ 'modern-library-rejected-from-dependency-fear-without-tradeoff-analysis',
380
+ 'component-library-selected-by-habit-without-product-fit',
381
+ 'official-docs-backed-modern-library-choice',
382
+ // execution policy gates
383
+ 'separateRequiredOutcomesFromCandidateMoves',
384
+ 'forbidCandidateMovesAsLockedRequirements',
385
+ 'seedRefinementRequiredBeforeUiImplementation',
386
+ 'requirePerSurfaceMutationOps',
387
+ 'forbidUniformSiblingSurfaceTreatment',
388
+ 'requireStructuredHandoff',
389
+ 'handoffFormatVersion',
390
+ 'requireSurfacePlan',
391
+ 'requireComponentGraph',
392
+ 'requireViewportMutationPlan',
393
+ 'requireInteractionStateMatrix',
394
+ 'requireContentPriorityMap',
395
+ 'forbidScreenshotDependency',
396
+ 'semanticReviewFocus',
397
+ 'representationStrategy',
398
+ // handoff payload fields
399
+ 'seedMode',
400
+ 'requiresTaskSpecificRefinement',
401
+ 'primaryExperienceGoal',
402
+ 'surfacePlan',
403
+ 'contentPriorityMap',
404
+ 'viewportMutationPlan',
405
+ 'interactionStateMatrix',
406
+ 'taskFlowNarrative',
407
+ 'signatureMoveRationale',
408
+ 'implementationGuardrails',
409
+ 'expressionFlexibility',
410
+ // rubric fields
411
+ 'genericityAutoFail',
412
+ 'genericitySignals',
413
+ 'validBoldSignals',
414
+ 'mustExplainGenericity',
415
+ 'mustSeparateTasteFromFailure',
416
+ // accessibility + reference policy
417
+ 'hardComplianceFloor',
418
+ 'advisoryContrastModel',
419
+ 'repoEvidenceOverridesMemory',
420
+ 'requireExplicitContinuityApproval',
421
+ 'forbidCarryoverWhenUnapproved',
422
+ 'approvedExternalConstraintUsage',
423
+ 'requireViewportMutationRules',
424
+ 'allowHexDerivatives',
425
+ 'forbidAutopilotPalettesWithoutEvidence',
426
+ 'rolesAreMinimumScaffold',
427
+ // policy hooks consumed by tests + downstream tooling
428
+ 'literalTranslationPolicy',
429
+ 'spatialAutopilotPolicy',
430
+ 'externalWebsiteReferencePolicy',
431
+ 'manual-framework-scaffold-used-when-official-setup-fits',
432
+ ]);