File size: 2,880 Bytes
391c43e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/**
 * Project Brief — canonical schema for the Describe-mode setup flow.
 *
 * Filled progressively as the setup agent converses with the user.
 * Serialized into .PROMPT.md when the project is created.
 */

import type { ProjectRuntime } from '@/lib/vfs/types';

// --- Brief schema ---

export interface ProjectBrief {
  /** Project name (1–50 chars). */
  name?: string;

  /** Semantic project type — what the user is building, not a technical category. */
  type?: string;

  /** Page list for website-type projects. */
  pages?: string[];

  /** CSS framework / styling approach. */
  styling?: BriefStyling;

  /** Server-side capabilities inferred from user's stated needs. */
  capabilities?: BriefCapabilities;

  /** Tone, vibe, aesthetic direction — freeform. */
  direction?: string;

  /** Runtime engine. Usually inferred by the agent. */
  runtime?: ProjectRuntime;

  /** VFS template ID to scaffold from (e.g. 'blank', 'contact-landing'). */
  template?: string;

  /** Open-ended notes that don't fit other fields. */
  notes?: string;

  /** LLMs may add fields not in this schema — preserve them. */
  [key: string]: unknown;
}

export type BriefStyling = 'tailwind' | 'pure-css' | 'bulma' | 'bootstrap' | string;

export interface BriefCapabilities {
  /** Needs server/edge functions (contact form, API, etc.). */
  serverFunctions?: boolean;
  /** Needs a database. */
  database?: boolean;
  /** Needs user authentication. */
  auth?: boolean;
  /** Needs scheduled tasks. */
  scheduledTasks?: boolean;
  /** Freeform capability notes the schema doesn't cover. */
  other?: string[];
  /** LLMs may add capabilities not in this schema — preserve them. */
  [key: string]: unknown;
}

// --- Pending decisions tracker ---

export interface PendingDecision {
  /** Short label (e.g. "Project name", "Typography"). */
  label: string;
}

// --- Spec sections (substantive context for .DESIGN.md) ---

export interface SpecSection {
  /** Section heading (e.g. "Target audience", "Content"). */
  heading: string;
  /** Prose content under this heading. */
  content: string;
}

// --- Brief state (includes metadata the sidebar needs) ---

export interface BriefState {
  brief: ProjectBrief;
  pending: PendingDecision[];
  /** Approximate total decisions the agent is tracking. */
  totalDecisions: number;
  /** How many have been resolved. */
  resolvedCount: number;
  /** Accumulated spec sections for .DESIGN.md. */
  spec: SpecSection[];
}

/** Check if the brief has the minimum required fields for project creation. */
export function isBriefReady(brief: ProjectBrief): boolean {
  return !!(brief.name && brief.runtime && brief.template);
}

/** Initial empty state. */
export function createEmptyBriefState(): BriefState {
  return {
    brief: {},
    pending: [],
    totalDecisions: 0,
    resolvedCount: 0,
    spec: [],
  };
}