feat(schema): projects.background_md for per-project context
Phase 8c Task 1. Optional text field on projects, max 40000 chars. The prompt module caps at 30000 with a truncation marker. Empty documents produce byte-identical prompts to today — the test in Task 4 locks that in.
This commit is contained in:
parent
1bead98f00
commit
7df7074806
2 changed files with 31 additions and 6 deletions
|
|
@ -548,13 +548,35 @@ async function ensureActivityActionValues(pb: PocketBase): Promise<void> {
|
|||
}
|
||||
|
||||
/**
|
||||
* 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<void> {
|
||||
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<void> {
|
||||
const cards = await pb.collections.getOne("cards");
|
||||
const field = cards.fields.find(
|
||||
|
|
@ -1319,6 +1341,7 @@ async function main(): Promise<void> {
|
|||
|
||||
// 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);
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue