verify-agent-note-classification.ts 987 B

123456789101112131415161718192021222324252627
  1. /**
  2. * Enforce Agent Note lifecycle/class paths and dated filenames. Structural rules
  3. * are shared with `agent-note-tree.ts`; the closed classification rules live
  4. * in `.agents/notes/README.md`.
  5. */
  6. import { existsSync } from 'node:fs'
  7. import { resolve } from 'node:path'
  8. import { walkAgentNoteTree } from './agent-note-tree.ts'
  9. const { notes, errors } = walkAgentNoteTree()
  10. // Keep the former homes unavailable so new notes cannot silently escape this tree.
  11. for (const legacyRoot of ['docs/rfc', 'docs/rfcs']) {
  12. if (existsSync(resolve(import.meta.dirname, '..', legacyRoot))) {
  13. errors.push(`legacy-path: ${legacyRoot}/ is forbidden — put Agent Notes under .agents/notes/`)
  14. }
  15. }
  16. if (errors.length === 0) {
  17. console.log(`verify-agent-note-classification: ${notes.length} Agent Note(s) checked, structure consistent.`)
  18. process.exit(0)
  19. }
  20. console.error('verify-agent-note-classification: violations found:')
  21. for (const e of errors) console.error(` ${e}`)
  22. process.exit(1)