feat(secrets): repository secrets and variables injected into agent shells and terminals

Add a GitHub Actions-style store for secrets and variables so tests can read
credentials from the environment without .env files in the repo.

- secrets table keyed by kind, repo (NULL for global) and environment;
  secrets are encrypted with encryptSecret and write-only, variables are plain
  text. Names follow GitHub's rules and reject Manager-reserved names.
- Global (/api/secrets, /api/variables) and repo
  (/api/repos/:id/secrets|variables) routes.
- The trusted .ocm/project.json gains environment and env fields that map
  names to ${{ secrets.X }} / ${{ vars.X }} expressions. Both are part of the
  trust hash; files without them hash as before, so existing trust survives.
- RepoEnvService.resolveForDirectory resolves the repo and approved mapping
  for any directory, including worktrees outside the repo folder, with
  environment > repo > global precedence. It never throws.
- /api/internal/shell-env replaces /git-credentials/gh-env and feeds the
  ocm-gh-env plugin, the sandbox shell plan and TerminalService.create.
- The plugin masks injected secret values as *** in completed tool results.
- The sandbox shell plan is now the only source of the guest environment: the
  plugin pins OCM_SANDBOX_FORWARD_ENV and the shim forwards only those names.
This commit is contained in:
Chris Scott authored and Chris Scott committed 2026-10-23 22:59:57 -04:00
1 parent b431c121a2
commit e0331b43bf
47 files changed
+2073 -156

No files matched your search

@@ -655,7 +655,7 @@ describe('ocm-manager plugin', () => {
it('rejects non-allow-listed routes without calling the API', async () => {
const tool = await loadTool(configHome)
const deniedRoutes = [
['GET', '/git-credentials/gh-env'],
['GET', '/shell-env'],
['POST', '/sandbox/shell'],
['GET', '/repos/0/mirror/head'],
['POST', '/notifications/send'],
@@ -707,7 +707,7 @@ describe('ocm-manager plugin', () => {
const tool = await loadTool(configHome)
await expect(
runTool(tool, { action: 'request', params: { method: 'GET', path: '/repos/x/../../git-credentials/gh-env' } }),
runTool(tool, { action: 'request', params: { method: 'GET', path: '/repos/x/../../shell-env' } }),
).rejects.toThrow(/is not an allowed OpenCode Manager route/)
expect(fetchMock).not.toHaveBeenCalled()
})