block git

This commit is contained in:
2026-03-04 11:35:55 +00:00
parent 9cce8cf9af
commit 4e0245848e
2 changed files with 22 additions and 0 deletions

View File

@@ -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";

View File

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