report-empty-hosted-frontmatter.mjs
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd
feat(calendar): enforce agent context tiers in retrieval AP…
Human
minor
⚠ breaking
2 days ago
| 1 | #!/usr/bin/env node |
| 2 | /** |
| 3 | * Lists vault-relative paths where stored frontmatter JSON parses to an empty object. |
| 4 | * Read-only. Same env as verify-hosted-hub-api.mjs (KNOWTATION_HUB_TOKEN, KNOWTATION_HUB_API, KNOWTATION_HUB_VAULT_ID). |
| 5 | * |
| 6 | * KNOWTATION_HUB_TOKEN='...' node scripts/report-empty-hosted-frontmatter.mjs |
| 7 | * KNOWTATION_HUB_TOKEN_FILE=~/.config/knowtation/hub_jwt.txt node scripts/report-empty-hosted-frontmatter.mjs |
| 8 | */ |
| 9 | |
| 10 | import fs from 'fs'; |
| 11 | import path from 'path'; |
| 12 | import { fileURLToPath } from 'url'; |
| 13 | import dotenv from 'dotenv'; |
| 14 | import { materializeListFrontmatter } from '../hub/gateway/note-facets.mjs'; |
| 15 | |
| 16 | const __dirname = path.dirname(fileURLToPath(import.meta.url)); |
| 17 | const repoRoot = path.resolve(__dirname, '..'); |
| 18 | dotenv.config({ path: path.join(repoRoot, '.env') }); |
| 19 | |
| 20 | function resolveToken() { |
| 21 | let t = process.env.KNOWTATION_HUB_TOKEN || process.env.HUB_JWT || ''; |
| 22 | const fp = (process.env.KNOWTATION_HUB_TOKEN_FILE || '').trim(); |
| 23 | if (!t && fp) { |
| 24 | const expanded = fp.startsWith('~') ? path.join(process.env.HOME || '', fp.slice(1)) : fp; |
| 25 | t = fs.readFileSync(expanded, 'utf8').trim(); |
| 26 | } |
| 27 | return t; |
| 28 | } |
| 29 | |
| 30 | const token = resolveToken(); |
| 31 | const apiBase = (process.env.KNOWTATION_HUB_API || 'https://knowtation-gateway.netlify.app').replace(/\/$/, ''); |
| 32 | const vaultId = process.env.KNOWTATION_HUB_VAULT_ID || 'default'; |
| 33 | |
| 34 | async function main() { |
| 35 | if (!token) { |
| 36 | console.error('Set KNOWTATION_HUB_TOKEN (or HUB_JWT).'); |
| 37 | process.exit(1); |
| 38 | } |
| 39 | const res = await fetch(`${apiBase}/api/v1/notes?limit=500&offset=0`, { |
| 40 | headers: { |
| 41 | Accept: 'application/json', |
| 42 | Authorization: 'Bearer ' + token, |
| 43 | 'X-Vault-Id': vaultId, |
| 44 | }, |
| 45 | }); |
| 46 | const text = await res.text(); |
| 47 | if (!res.ok) { |
| 48 | console.error(res.status, text.slice(0, 400)); |
| 49 | process.exit(1); |
| 50 | } |
| 51 | const data = JSON.parse(text); |
| 52 | const notes = Array.isArray(data.notes) ? data.notes : []; |
| 53 | const emptyPaths = []; |
| 54 | for (const n of notes) { |
| 55 | const fm = materializeListFrontmatter(n.frontmatter); |
| 56 | if (Object.keys(fm).length === 0) emptyPaths.push(n.path || '(no path)'); |
| 57 | } |
| 58 | console.log('total_notes', notes.length); |
| 59 | console.log('empty_frontmatter_paths', emptyPaths.length); |
| 60 | emptyPaths.forEach((p) => console.log(p)); |
| 61 | } |
| 62 | |
| 63 | main().catch((e) => { |
| 64 | console.error(e); |
| 65 | process.exit(1); |
| 66 | }); |
File History
2 commits
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd
feat(calendar): enforce agent context tiers in retrieval AP…
Human
minor
⚠
2 days ago
sha256:9103f98c89257ed2b01c237cea895dabb3e85ea337dccb1161c175e4422355b6
docs: accept Calendar Events v0 spec with Phase 0 security …
Human
2 days ago