diff --git a/scripts/setup-remote.ts b/scripts/setup-remote.ts index a33e601..41a87ee 100644 --- a/scripts/setup-remote.ts +++ b/scripts/setup-remote.ts @@ -235,6 +235,50 @@ async function ensureCommitSummaryFields(pb: PocketBase): Promise { * * Re-runs are safe: fields are not duplicated. */ +/** + * Add the `brief`, `transcript`, `size_band` fields used by Phase 4b's intake. + * + * `brief` is the JSON object the client confirmed in the wizard, kept verbatim + * after re-parsing through the same parseBrief whitelist. `transcript` is the + * question-and-answer pairs. `size_band` is derived in code from the + * decomposition, never taken from the model's output. + * + * Re-runs are safe: fields are not duplicated. + */ +async function ensureCardIntakeFields(pb: PocketBase): Promise { + const cards = await pb.collections.getOne("cards"); + const have = new Set(cards.fields.map((f: { name: string }) => f.name)); + + const additions = [ + { name: "brief", type: "json", required: false, maxSize: 200_000 }, + { name: "transcript", type: "json", required: false, maxSize: 200_000 }, + { + name: "size_band", + type: "select", + required: false, + maxSelect: 1, + values: ["small", "medium", "large"], + }, + ]; + + const fields = [...(cards.fields as unknown[])]; + let changed = false; + + for (const field of additions) { + if (!have.has(field.name)) { + fields.push({ ...field, presentable: false, hidden: false, system: false }); + changed = true; + } + } + + if (changed) { + await pb.collections.update(cards.id, { fields }); + console.log(" + cards fields: brief, transcript, size_band"); + } else { + console.log(" = card intake fields already present"); + } +} + async function ensureCardNarrativeFields(pb: PocketBase): Promise { const cards = await pb.collections.getOne("cards"); const have = new Set(cards.fields.map((f: { name: string }) => f.name)); @@ -862,6 +906,9 @@ async function main(): Promise { // Add the AI-generated card narrative fields used by Phase 3c. await ensureCardNarrativeFields(pb); + // Add the intake wizard's fields (brief, transcript, size_band) for Phase 4b. + await ensureCardIntakeFields(pb); + console.log("Done."); } diff --git a/src/lib/pb/types.ts b/src/lib/pb/types.ts index 7c89a20..19d8384 100644 --- a/src/lib/pb/types.ts +++ b/src/lib/pb/types.ts @@ -87,6 +87,11 @@ export interface CardRecord extends BaseRecord { narrative_version: number; /** Fingerprint of the commit set the narrative was written from. */ narrative_shas: string; + /** The intake brief, when this card came from the wizard. */ + brief: unknown; + /** The interview question-and-answer pairs. */ + transcript: unknown; + size_band: "small" | "medium" | "large" | ""; } export interface SubtaskRecord extends BaseRecord {