Intelligence

Artifacts

Browse the repository, read documents, and manage the governance folders. Source, runtime, and infrastructure are read-only.

Repository
README.md
CONSTITUTION_COMPLIANCE_AUDIT_V1.mdREADME.md
repositories/aaf-holdings/hq01/lib/content/config.ts
1.8 KB
import fs from "node:fs";
import path from "node:path";

/**
 * Resolve the AAF workspace root — the directory HQ01 reads its operating-system
 * content from. HQ01 has no database and no API: every page renders directly
 * from markdown and yaml files found beneath this root.
 *
 * Resolution order:
 *   1. HQ01_CONTENT_ROOT environment variable (explicit override).
 *   2. The nearest ancestor of the app that looks like the AAF workspace
 *      (contains both `repositories/` and `holdings/`).
 *   3. The git repository root (two levels up from this app).
 */
function resolveContentRoot(): string {
  const override = process.env.HQ01_CONTENT_ROOT;
  if (override && fs.existsSync(override)) {
    return path.resolve(override);
  }

  let dir = process.cwd();
  for (let i = 0; i < 8; i += 1) {
    const looksLikeWorkspace =
      fs.existsSync(path.join(dir, "repositories")) &&
      fs.existsSync(path.join(dir, "holdings"));
    if (looksLikeWorkspace) return dir;

    const parent = path.dirname(dir);
    if (parent === dir) break;
    dir = parent;
  }

  // Fallback: the git repository root that contains this app.
  return path.resolve(process.cwd(), "..");
}

export const CONTENT_ROOT = resolveContentRoot();

/** The canonical git repository inside the workspace. */
export const REPO_ROOT = (() => {
  const candidate = path.join(CONTENT_ROOT, "repositories", "aaf-holdings");
  return fs.existsSync(candidate) ? candidate : CONTENT_ROOT;
})();

/** Directories never surfaced as content or artifacts. */
export const IGNORED_DIRS = new Set([
  "node_modules",
  ".git",
  ".next",
  "out",
  ".cache",
  ".turbo",
  "dist",
  "build",
]);

/** A short, presentable label for the resolved root. */
export function contentRootLabel(): string {
  return CONTENT_ROOT;
}

root · /srv/aaf