Adopt the agents/ architecture proven on medellin.co (reference impl): - Move the content engine to a top-level agents/ dir: orchestrators, prompts, config, run.sh, admin console, shared libs. All content-pipeline literals repointed (config paths, scripts, admin, LLM-facing prompts/image.md string, configure.mjs, new-site.sh, astroagent tokenFile, .gitignore runtime block). - Every script carries a parseable @agent-manifest header: name, title, class (content|operational|runtime|plumbing), trigger, model, prompts, skills (MCP), tools, reads/writes tables. 5 content agents + 3 plumbing scripts. - New agents/catalog.mjs generates the catalog from the headers: agents/AGENTS.md (human, grouped by class) + agents/agents.json (machine manifest — a clone diffs it against a source to find missing tools/tables/MCP before running). configure.mjs regenerates the catalog on every identity stamp. No DB table, no watcher. - config.json gains paths.stateDir/newsDir; publish-tick, write-daily, and news-radar read them instead of hardcoding. - Full cut: content-pipeline/ deleted (the seed has no live crons, so no hybrid period needed). Docs updated (AGENTS.md structure + pipeline section, README paths). Clones migrating from content-pipeline/: see medellin.co's .memory/handoffs/agents-directory-migration.md for the cutover playbook (one cron set active at a time; migrate drafts/state after repointing cron). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FMQeUnUrAeexcZ7P2Hxa6G
38 lines
1.5 KiB
JavaScript
38 lines
1.5 KiB
JavaScript
import { spawn } from "node:child_process";
|
|
import { mkdirSync } from "node:fs";
|
|
import { withLock } from "./lock.mjs";
|
|
|
|
function run(cmd, args, opts = {}) {
|
|
return new Promise((resolve, reject) => {
|
|
const child = spawn(cmd, args, { stdio: "inherit", ...opts });
|
|
child.on("error", reject);
|
|
child.on("close", (code) =>
|
|
code === 0 ? resolve() : reject(new Error(`${cmd} ${args.join(" ")} exited ${code}`))
|
|
);
|
|
});
|
|
}
|
|
|
|
/** Absolute path of the global build lock. Callers that build outside buildSite()
|
|
* (e.g. console preview builds) must take THIS same lock to serialize. */
|
|
export function buildLockPath(projectRoot) {
|
|
return `${projectRoot}/agents/state/build.lock`;
|
|
}
|
|
|
|
/**
|
|
* Build the Astro app and fix ownership so Apache can serve the output.
|
|
* Serialized behind the global build lock so it never races the console's
|
|
* preview/publish builds (concurrent astro builds would OOM this box).
|
|
*/
|
|
export async function buildSite({ projectRoot, appDir }) {
|
|
const lockPath = buildLockPath(projectRoot);
|
|
mkdirSync(`${projectRoot}/agents/state`, { recursive: true });
|
|
await withLock(lockPath, async () => {
|
|
await run("npm", ["run", "build"], { cwd: `${projectRoot}/${appDir}` });
|
|
// Best-effort ownership fix (ignore failure if not running as root).
|
|
try {
|
|
await run("chown", ["-R", "www:www", `${projectRoot}/${appDir}`, `${projectRoot}/public`]);
|
|
} catch (e) {
|
|
console.warn(`[build] chown skipped: ${e.message}`);
|
|
}
|
|
});
|
|
}
|