block git
This commit is contained in:
@@ -67,6 +67,10 @@
|
|||||||
source = ./opencode/tool;
|
source = ./opencode/tool;
|
||||||
recursive = true;
|
recursive = true;
|
||||||
};
|
};
|
||||||
|
"opencode/plugin" = {
|
||||||
|
source = ./opencode/plugin;
|
||||||
|
recursive = true;
|
||||||
|
};
|
||||||
"opencode/oh-my-opencode.json".text =
|
"opencode/oh-my-opencode.json".text =
|
||||||
builtins.toJSON {
|
builtins.toJSON {
|
||||||
"$schema" = "https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/master/assets/oh-my-opencode.schema.json";
|
"$schema" = "https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/master/assets/oh-my-opencode.schema.json";
|
||||||
|
|||||||
18
profiles/opencode/plugin/block-git.ts
Normal file
18
profiles/opencode/plugin/block-git.ts
Normal 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`.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user