diff --git a/scripts/setup-remote.ts b/scripts/setup-remote.ts index f7921f8..d302560 100644 --- a/scripts/setup-remote.ts +++ b/scripts/setup-remote.ts @@ -182,6 +182,47 @@ async function ensureProjectIngestFields(pb: PocketBase): Promise { } } +/** + * Add the `summary`, `summary_version`, `summary_attempts` fields to commits. + * + * Stored alongside each generated one-liner: + * - summary_version — which PROMPT_VERSION produced it, so a stale summary + * can be detected and re-generated rather than served to a client as if it + * were current. + * - summary_attempts — consecutive failures. A message that trips the + * provider every time must not be retried forever on every ingest, so + * summarise.ts caps it. + * + * Re-runs are safe: fields are not duplicated. + */ +async function ensureCommitSummaryFields(pb: PocketBase): Promise { + const commits = await pb.collections.getOne("commits"); + const have = new Set(commits.fields.map((f: { name: string }) => f.name)); + + const additions = [ + { name: "summary", type: "text", required: false, max: 500 }, + { name: "summary_version", type: "number", required: false, onlyInt: true }, + { name: "summary_attempts", type: "number", required: false, onlyInt: true }, + ]; + + const fields = [...(commits.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(commits.id, { fields }); + console.log(" + commits fields: summary, summary_version, summary_attempts"); + } else { + console.log(" = commit summary fields already present"); + } +} + async function ensureCardNumbers(pb: PocketBase): Promise { const cards = await pb.collections.getOne("cards"); const have = new Set(cards.fields.map((f: { name: string }) => f.name)); @@ -772,6 +813,9 @@ async function main(): Promise { // collection already exists from earlier migrations). await ensureProjectIngestFields(pb); + // Add the per-commit summary fields used by Phase 3b's AI one-liner job. + await ensureCommitSummaryFields(pb); + // Add the card number field and backfill existing cards. await ensureCardNumbers(pb); diff --git a/src/lib/pb/types.ts b/src/lib/pb/types.ts index 2d16d0d..ba3fcdd 100644 --- a/src/lib/pb/types.ts +++ b/src/lib/pb/types.ts @@ -124,6 +124,12 @@ export interface CommitRecord extends BaseRecord { card: string; link_source: CommitLinkSource; url: string; + /** Plain-English one-liner. Empty when not yet generated or generation failed. */ + summary: string; + /** PROMPT_VERSION this summary was written under. */ + summary_version: number; + /** Consecutive failed attempts. Capped so a poison message stops retrying. */ + summary_attempts: number; } export interface ActivityRecord extends Omit {