feat: initialize Intellecton portal repository under GitOps Covenant

This commit is contained in:
Antigravity Agent
2026-05-23 14:20:22 +00:00
commit 2c09e491f8
28 changed files with 185865 additions and 0 deletions
+67
View File
@@ -0,0 +1,67 @@
import fs from "fs";
import path from "path";
import { NextResponse } from "next/server";
let cachedFieldnotes = null;
async function getFieldnotes() {
if (cachedFieldnotes) return cachedFieldnotes;
try {
const filePath = path.join(process.cwd(), "public/consolidated_fieldnotes.json");
const data = await fs.promises.readFile(filePath, "utf8");
const parsed = JSON.parse(data);
// Drop the heavy lexical JSON representation on the server to keep memory and transfer size small
cachedFieldnotes = parsed.map((note) => ({
title: note.title,
slug: note.slug,
date: note.date,
author_slug: note.author_slug,
content_markdown: note.content_markdown || "",
}));
return cachedFieldnotes;
} catch (error) {
console.error("Error loading consolidated fieldnotes:", error);
return [];
}
}
export async function GET(request) {
const { searchParams } = new URL(request.url);
const query = searchParams.get("q") || "";
const author = searchParams.get("author") || "";
const tag = searchParams.get("tag") || "";
const notes = await getFieldnotes();
// Perform search
let filtered = notes;
if (author) {
filtered = filtered.filter((n) => n.author_slug === author);
}
if (tag) {
// Alchemical tags like 🜏, 🜁, etc.
filtered = filtered.filter((n) => n.content_markdown.includes(tag));
}
if (query) {
const lowerQuery = query.toLowerCase();
filtered = filtered.filter(
(n) =>
n.title.toLowerCase().includes(lowerQuery) ||
n.content_markdown.toLowerCase().includes(lowerQuery)
);
}
// Slice results to keep response sizes fast
const results = filtered.slice(0, 15);
return NextResponse.json({
total: filtered.length,
results,
});
}