Files
command-center/agent/extensions/trunk-law.js
T
Frank 9d983f892d Feat: trunk-law extension scopes fleet git rules to ~/Projects sessions
before_agent_start handler appends the trunk-based git law to the system
prompt only when cwd is under ~/Projects/. Hard cwd scope because every
context-file provider resolves at or below the repo root - an ancestor
AGENTS.md is never loaded by descendant repos. Verified live: quote probe
fires under serverAppConfig, silent in /tmp and ~/.omp. Fires for subagent
sessions too (shared cwd). Changelog entry added.
2026-10-18 14:43:06 -07:00

39 lines
2.0 KiB
JavaScript

// trunk-law.js — fleet git law for repositories under ~/Projects/.
//
// Hard cwd scope: sessions outside ~/Projects get an untouched system prompt.
// The rule text mirrors ~/.omp/omp-docs (command-center), AGENTS.md
// § Trunk-based SDLC (operator decision 2026-10-18): single-dev repos, no
// develop branch, PRs directly on main. This extension is the delivery
// mechanism because every context-file provider (AGENTS.md walk-up, .omp
// dirs, CLAUDE.md) resolves at or below the repo root — a file in
// ~/Projects/ itself is never loaded by ancestors' sessions.
//
// before_agent_start receives the current base system prompt and may return
// a replacement; returning undefined leaves it untouched. The appended text
// is constant, so provider prompt caching is unaffected after the first
// request. Fires for subagent sessions too (they share the session cwd).
const ROOT = "/home/blank/Projects/";
const RULES = [
"",
"",
"# Fleet git law — trunk-based (injected because cwd is under ~/Projects/)",
"- `main` is the only long-lived branch: no `develop`, no release branches, no back-merges.",
"- Before every work item: `git fetch`, then branch off the freshest `origin/main`. If main moves underneath you, merge it into your branch — never rebase.",
"- Pull requests target `main` directly; merge with `--no-ff` so feature arcs stay visible.",
"- Never merge a PR without an explicit, current OK from Frank.",
"- Releases: tag `vX.Y.Z` straight on `main`; tags are the deploy markers machines pull to.",
"- This law supersedes git-flow text still living in repo-local AGENTS.md/docs (e.g. serverAppConfigs) until Frank changes it.",
].join("\n");
export default function trunkLaw(pi) {
pi.on("before_agent_start", async (event, ctx) => {
const cwd = (ctx && ctx.cwd) || "";
if (cwd !== ROOT.slice(0, -1) && !cwd.startsWith(ROOT)) return;
const base = event.systemPrompt;
if (Array.isArray(base)) return { systemPrompt: [...base, RULES] };
return { systemPrompt: (base || "") + RULES };
});
}