import type { CollectionConfig } from "payload"; import fs from "fs"; import path from "path"; import { fileURLToPath } from "url"; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); export const ContextFiles: CollectionConfig = { slug: "context-files", labels: { singular: "Context File", plural: "Context Files", }, admin: { useAsTitle: "filename", defaultColumns: ["filename", "updatedAt"], }, access: { read: () => true, // Needed for server actions to fetch context create: () => true, update: () => true, delete: () => true, }, hooks: { afterChange: [ ({ doc, operation }) => { // Potential future: sync back to disk? // For now, let's keep it simple as a CMS-first feature. }, ], }, fields: [ { name: "filename", type: "text", required: true, unique: true, admin: { description: "Exact filename (e.g. 'strategy.md'). The system uses this to identify the document during prompt generation.", }, }, { name: "content", type: "textarea", required: true, admin: { rows: 25, description: "The raw markdown/text content of the document.", style: { fontFamily: "monospace" }, }, }, ], };