diff --git a/scripts/setup-remote.ts b/scripts/setup-remote.ts index 0812352..7dfb8cb 100644 --- a/scripts/setup-remote.ts +++ b/scripts/setup-remote.ts @@ -548,13 +548,35 @@ async function ensureActivityActionValues(pb: PocketBase): Promise { } /** - * Extend `cards.created_by_role` to include `"anonymous"` so the public - * intake route can produce Inbox cards without a session. The base set - * `["owner", "client"]` was set at first collection creation; re-running - * `getOrCreateCollection` on an existing `cards` row is a no-op, so the - * value set has to be patched explicitly here. Safe to re-run: values - * are not duplicated. + * Extend `projects` with `background_md` so the owner can keep per-project + * developer context (the shape of each app, what each section does) that + * flows into every wizard prompt. Re-runs are safe — the field is only + * added if missing. Capped at 40 000 chars; the prompt module trims it to + * 30 000 before sending it to the model. */ +async function ensureProjectBackgroundMdField(pb: PocketBase): Promise { + const projects = await pb.collections.getOne("projects"); + const have = new Set(projects.fields.map((f: { name: string }) => f.name)); + + if (have.has("background_md")) { + console.log(" = projects.background_md already present"); + return; + } + + const fields = [...(projects.fields as unknown[])]; + fields.push({ + name: "background_md", + type: "text", + required: false, + max: 40000, + presentable: false, + hidden: false, + system: false, + }); + await pb.collections.update(projects.id, { fields }); + console.log(" + projects field: background_md (max 40000)"); +} + async function ensureCardsCreatedByRoleValues(pb: PocketBase): Promise { const cards = await pb.collections.getOne("cards"); const field = cards.fields.find( @@ -1319,6 +1341,7 @@ async function main(): Promise { // Add the project/prototype kind field for Phase 6. await ensureProjectKindField(pb); + await ensureProjectBackgroundMdField(pb); // Add the per-commit summary fields used by Phase 3b's AI one-liner job. await ensureCommitSummaryFields(pb); diff --git a/src/lib/pb/types.ts b/src/lib/pb/types.ts index cd0cba3..77dbd23 100644 --- a/src/lib/pb/types.ts +++ b/src/lib/pb/types.ts @@ -61,6 +61,8 @@ export interface ProjectRecord extends BaseRecord { session_gap_minutes: number; pre_session_minutes: number; post_session_minutes: number; + /** Developer's curated context for this app, sent into every wizard prompt. */ + background_md: string; } export interface ColumnRecord extends BaseRecord {