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`.", + ); + } + } + }, + }; +};