Feat: trunk-law extension scopes fleet git rules to ~/Projects #9

Closed
dank wants to merge 1 commits from feat/trunk-law-extension into main
2 changed files with 42 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
// 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 };
});
}
+4
View File
@@ -11,6 +11,10 @@ timestamp: 2026-08-28
# Bundle Change Log
## 2026-10-18 — Trunk law propagated to ~/Projects repos via extension
New tracked extension `agent/extensions/trunk-law.js`: a `before_agent_start` handler that appends the trunk-based git law to the system prompt **only when the session cwd is under `~/Projects/`** (hard-scoped; verified live with quote-the-prompt probes: fires under `serverAppConfig`, silent in `/tmp` and `~/.omp`). This was the only mechanism that works — every context-file provider (AGENTS.md walk-up, `.omp/` dirs, CLAUDE.md) resolves at or below the repo root, so a hypothetical `~/Projects/AGENTS.md` is never loaded by ancestor sessions. Subagent sessions inherit the cwd and get the law too. Note: repo-local git-flow text (serverAppConfigs' AGENTS.md) contradicts it until that repo is updated; the injected law declares precedence explicitly.
## 2026-10-18 — SDLC switched to trunk-based development
`develop` retired by operator decision (single-dev repo; the branch bought nothing and cost a back-merge every release). New law in AGENTS.md § *Trunk-based SDLC*: branch off the freshest `origin/main` before every work item, PRs target `main` directly, `--no-ff` merges, tags `vX.Y.Z` straight on main. No back-merges, no release branches. The last back-merge (`527596a`) lands with this switch; the managed skill `gitflow-back-merge-plumbing` is now historical.