0595794385
- Default export is { id, setup, server }: OpenCode 2 calls setup(ctx), OpenCode 1 (1.18.29+) calls server()
- Tools defined once in lib/tools.ts and registered for both versions (V2 with codemode: false)
- Blocking covers path args of any tool, patch/apply_patch envelopes, shell commands naming env files, grep output, and V2 permission checks
- Secret-looking values from the project's env files are replaced in every non-envsitter tool's output
- Protected files come from envsitter's path policy; example/template files stay readable
- npm run test:e2e drives the real OpenCode 1 and 2 CLIs with a scripted model
- @opencode-ai/plugin ^1.19.3, @opencode/plugin ^2.1.0 (peer >=2.0.32), envsitter ^0.1.0, TypeScript 6
BREAKING CHANGE: the named export EnvSitterGuard is now the plugin definition object; call EnvSitterGuard.server(input) instead of EnvSitterGuard(input).
16 lines
582 B
TypeScript
16 lines
582 B
TypeScript
import type { Plugin as V1Plugin } from "@opencode-ai/plugin";
|
|
import type { Plugin as V2 } from "@opencode/plugin";
|
|
|
|
import { serverV1 } from "./lib/v1.js";
|
|
import { setupV2 } from "./lib/v2.js";
|
|
|
|
// One default export serves both OpenCode majors: V2 reads `id` + `setup`, V1 (>= 1.18.29) calls `server`.
|
|
// Keep every export of this module plugin-shaped: V1 rejects modules that export anything else.
|
|
export const EnvSitterGuard: V2.Plugin & { readonly server: V1Plugin } = {
|
|
id: "envsitter-guard",
|
|
setup: setupV2,
|
|
server: serverV1,
|
|
};
|
|
|
|
export default EnvSitterGuard;
|