feat(scripts): build the folder OpenCode loads from /etc #269
No reviewers
Labels
No labels
bug
cannot reproduce
duplicate
enhancement
help wanted
invalid
need info
need triage
need verification
not a bug
question
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
claudiomaradonna/agent-foundry!269
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/opencode-system-directory"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
Agent Foundry reaches a repository only by adoption, which copies the
policy, skills, subagents, and hooks into it, so every change to the
source needs a
foundry-upgradein each repository. An operator wholaunches OpenCode bots through Azkaban on repositories that must stay
free of agent files can instead mount one read-only folder at
/etc/opencode, OpenCode's system directory on Linux. This adds a buildthat lays the foundry out as that folder, as a first form loaded from
outside the repository, with a shared part laid out so Claude Code and
Codex can join later as targets of their own.
Closes #268
What changed
scripts/build-form.sh <target> <commit> <folder>builds from onecommit of the source. The target
sharedwritesskills/and, besideit,
agent-foundry/with the policy, briefs, scripts, templates, hooks,and the commit built. The target
opencode, with--mount(
/etc/opencodeunless given), addsopencode.json, whoseinstructionsname the policy, a location file, and the project'sAGENTS.local.md, plus the subagent adapters and the hook plugins.The source's
AGENTS.md, skills, and adapters stay as they are. Thepassages that differ for a mounted folder live in
scripts/forms/shared/, each beside the source text it replaces, andthe build fails, naming the passage, when the commit no longer holds
that text once. In the built policy the project's facts come from the
project's own
AGENTS.mdor git-ignoredAGENTS.local.md; the projectkeeps
.plans/and.worktrees/out of Git its own way, and an agentthat finds them not ignored stops; reviewers read the policy and briefs
from the folder;
foundry-upgradeis left out, since a newer sourcearrives by a rebuild.
A rebuild replaces only an earlier build, listed in a manifest at the
folder's root, and refuses any other non-empty folder untouched. The
build refuses a commit holding a symbolic link among the files it reads.
docs/INSTALL.mdgains the section Folder for OpenCode's systemdirectory, which the README's Quick start points to.
How to verify
Base
mainat7f979bd, branchfeat/opencode-system-directoryat249629c. Build the folder from a clone:Expected: the build prints
built opencode of 249629c...and the commitfile holds that hash;
~/agent-foundry-forms/opencodeholdsopencode.json,agents/,plugins/,lib/,skills/, andagent-foundry/.Untested here, the run on OpenCode:
opencodeis not on theworkstation the change was made on. Mounted read-only at
/etc/opencodeon OpenCode 2.x, in a repository holding no foundry file, a session is
expected to quote the policy without a tool call, list the skills
without
foundry-upgrade, launch each subagent, and refuse an edit inthe main checkout with "main-checkout guard:". The checks and their
expected results are in
docs/INSTALL.md§ Checking a mounted folder;whether the system directory loads
agents/andplugins/, and pluginsimporting
lib/from beside them, is what that run settles.Checks run on
249629c:bash tests/verify-agent-config.sh, 391 testspassed with none skipped;
bash tests/check-work-folder.sh, 46 passed;.agents/hooks/shellcheck.sh repo, 53 files clean;prettier --check '**/*.md';scripts/verify-agent-config.sh, valid intemplate state;
git diff --check main. The new areatests/agent-config/build-form.sh, 29 tests, fails onmainwhere itcalls the script the change adds;
opencode-plugins.shpasses on bothrevisions with the shared Node runner moved into
lib.sh.Considerations
scripts/forms/is a second version of a fewpassages of
AGENTS.mdand two skills; the area fails when thesource's passage changes, so its replacement is read again.
awkrules ofevals/install-policy.shthat strip the template state, set aside sothat file stays untouched here.
docs/INSTALL.mdsays Bash 4 or later, where an empty array underset -uneeds 4.4; and--mounttakes only a plain absolute path,which excludes macOS and Windows system directories. Both were set
aside as low.
directory is a rule the agent follows, in the built
run-sandboxedstep and the location file, not a mechanism.
https://claude.ai/code/session_012wUN2eKSj9s2vRHJdFPNk3
Command failed
The agent did not complete this command, so nothing came of it. A person should look at this thread.
The run failed at step "aoe_purge". The operator reads the job logs in the Windmill editor, or finds the run with:
wmill job list --path f/agents/bot_commands