From 4e0245848e552c7506562128960039ed4a183a48 Mon Sep 17 00:00:00 2001 From: Christoph Schmatzler Date: Wed, 4 Mar 2026 11:35:55 +0000 Subject: [PATCH] block git --- profiles/opencode.nix | 4 ++++ profiles/opencode/plugin/block-git.ts | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 profiles/opencode/plugin/block-git.ts diff --git a/profiles/opencode.nix b/profiles/opencode.nix index bbc097f..4f01b5d 100644 --- a/profiles/opencode.nix +++ b/profiles/opencode.nix @@ -67,6 +67,10 @@ source = ./opencode/tool; recursive = true; }; + "opencode/plugin" = { + source = ./opencode/plugin; + recursive = true; + }; "opencode/oh-my-opencode.json".text = builtins.toJSON { "$schema" = "https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/master/assets/oh-my-opencode.schema.json"; diff --git a/profiles/opencode/plugin/block-git.ts b/profiles/opencode/plugin/block-git.ts new file mode 100644 index 0000000..acafd04 --- /dev/null +++ b/profiles/opencode/plugin/block-git.ts @@ -0,0 +1,18 @@ +import type { Plugin } from "@opencode-ai/plugin"; + +const GIT_PATTERN = /(?:^|[;&|]\s*|&&\s*|\|\|\s*|\$\(\s*|`\s*)git\s/; + +export const BlockGitPlugin: Plugin = async () => { + return { + "tool.execute.before": async (input, output) => { + if (input.tool === "bash") { + const command = output.args.command as string; + if (GIT_PATTERN.test(command)) { + throw new Error( + "This project uses jj, only use `jj` commands, not `git`.", + ); + } + } + }, + }; +};