Skip to content

feat: bootstrap thin distribution#9

Merged
terisuke merged 1 commit intodevfrom
codex/issue-2-thin-distribution
Apr 3, 2026
Merged

feat: bootstrap thin distribution#9
terisuke merged 1 commit intodevfrom
codex/issue-2-thin-distribution

Conversation

@terisuke
Copy link
Copy Markdown

@terisuke terisuke commented Apr 3, 2026

Summary

  • add a thin guardrails distribution package that wraps a pinned upstream opencode runtime
  • add managed and packaged profile defaults for localhost-only server exposure and disabled sharing
  • add scenario coverage for config precedence, runtime pinning, and project-local compatibility

Philosophy

Verification

  • cd packages/opencode && bun test test/scenario/guardrails.test.ts
  • cd packages/opencode && bun typecheck

Closes #2

Copilot AI review requested due to automatic review settings April 3, 2026 02:19
@terisuke terisuke merged commit 666e1b6 into dev Apr 3, 2026
1 check passed
@terisuke terisuke deleted the codex/issue-2-thin-distribution branch April 3, 2026 02:19
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new “thin distribution” package (@opencode-ai/guardrails) that wraps the upstream OpenCode runtime with organization defaults (managed + packaged profile) and adds scenario tests to lock in config precedence and local-asset compatibility.

Changes:

  • Added packages/guardrails distribution package with wrapper CLI, packaged profile defaults, and managed config template.
  • Added scenario tests validating managed-config precedence, runtime pinning, and project-local .opencode assets compatibility.
  • Added guardrails plan documentation (ADRs + issue brief) under docs/ai-guardrails/.

Reviewed changes

Copilot reviewed 10 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/opencode/test/scenario/guardrails.test.ts Adds scenario coverage for managed config precedence, runtime pinning, and project-local assets.
packages/guardrails/README.md Documents the guardrails distribution purpose, strategy, and deployment instructions.
packages/guardrails/profile/opencode.json Packaged profile defaults (localhost-only server, share disabled, permission defaults).
packages/guardrails/profile/AGENTS.md Always-loaded profile instructions for the guardrails approach.
packages/guardrails/managed/opencode.json Managed deployment defaults mirroring the packaged profile.
packages/guardrails/package.json Declares the guardrails package, bin entrypoint, and pins the opencode dependency.
packages/guardrails/bin/opencode-guardrails Wrapper CLI that sets OPENCODE_CONFIG_DIR and delegates to the pinned opencode dependency.
docs/ai-guardrails/README.md Introduces the internal guardrails plan and artifact map.
docs/ai-guardrails/issues/001-bootstrap-thin-distribution.md Captures the bootstrap thin distribution requirements/acceptance criteria.
docs/ai-guardrails/adr/001-thin-distribution-over-deep-fork.md Records the architectural decision to prefer a thin distribution over a deep fork.
docs/ai-guardrails/adr/004-scenario-tests-before-productization.md Records the decision to add scenario tests before productization of policy surfaces.
bun.lock Adds the new guardrails workspace package to the lockfile.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


## Managed deployment

Copy [managed/opencode.json](/Users/teradakousuke/Developer/opencode/packages/guardrails/managed/opencode.json) into the system managed config directory:
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README link to managed/opencode.json is an absolute path to a local machine ("/Users/..."), which will be broken for everyone else and in GitHub rendering. Use a repository-relative link (e.g. "managed/opencode.json" or "./managed/opencode.json") instead.

Suggested change
Copy [managed/opencode.json](/Users/teradakousuke/Developer/opencode/packages/guardrails/managed/opencode.json) into the system managed config directory:
Copy [managed/opencode.json](managed/opencode.json) into the system managed config directory:

Copilot uses AI. Check for mistakes.
Comment on lines +84 to +115
await Bun.write(
path.join(dir, ".opencode", "commands", "project-local.md"),
`---
description: Project-local workflow.
---

Use the project-local command.
`,
)
await Bun.write(
path.join(dir, ".opencode", "agents", "project-review.md"),
`---
description: Project-local review helper.
mode: subagent
permission:
"*": deny
read: allow
---

Review local project context only.
`,
)
await Bun.write(
path.join(dir, ".opencode", "skills", "project-skill", "SKILL.md"),
`---
name: project-skill
description: Project-local skill.
---

# Project Skill
`,
)
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test writes files under ".opencode/commands", ".opencode/agents", and ".opencode/skills/..." but never creates those directories. In other tests, directories are created via fs.mkdir(..., { recursive: true }) before Bun.write; without that this test can throw ENOENT depending on Bun.write behavior. Create the necessary parent directories before writing these files.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

guardrails: bootstrap thin distribution

2 participants