From 64275cb90bb9317b5eb4fada30030317cb2aca4f Mon Sep 17 00:00:00 2001 From: Umar Adilov <99314948+adilovcode@users.noreply.github.com> Date: Wed, 14 Jan 2026 20:11:11 +0500 Subject: [PATCH] Removed plugins from local project dir --- .opencode/package.json | 10 +- .opencode/plugin/build.ts | 166 ---------------------------- .opencode/plugin/file-protection.ts | 27 ----- 3 files changed, 1 insertion(+), 202 deletions(-) delete mode 100644 .opencode/plugin/build.ts delete mode 100644 .opencode/plugin/file-protection.ts diff --git a/.opencode/package.json b/.opencode/package.json index d88a4d3..9e26dfe 100644 --- a/.opencode/package.json +++ b/.opencode/package.json @@ -1,9 +1 @@ -{ - "dependencies": { - "@opencode-ai/plugin": "1.0.191", - "@types/micromatch": "^4.0.10", - "axios": "^1.13.2", - "micromatch": "^4.0.8", - "zod": "^4.1.13" - } -} \ No newline at end of file +{} \ No newline at end of file diff --git a/.opencode/plugin/build.ts b/.opencode/plugin/build.ts deleted file mode 100644 index 440a224..0000000 --- a/.opencode/plugin/build.ts +++ /dev/null @@ -1,166 +0,0 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment */ -import type { Plugin } from "@opencode-ai/plugin"; -import { Axios } from "axios"; -import { promises as fs } from "fs"; -import { z } from "zod"; - -enum AppStatus { - PENDING_PROVISION = "PENDING_PROVISION", - PROVISIONING = "PROVISIONING", - RUNNING = "RUNNING", - FAILED = "FAILED", - BUSY = "BUSY", - TERMINATED = "TERMINATED", -} - -const { vmOrchestrationStatusUpdateUrl } = z - .object({ - vmOrchestrationStatusUpdateUrl: z.string(), - }) - .parse({ - vmOrchestrationStatusUpdateUrl: - process.env.TAYLORDB_VM_ORCHESTRATION_STATUS_UPDATE_URL, - }); - -const axios = new Axios({ - baseURL: vmOrchestrationStatusUpdateUrl, -}); - -const updateAppStatus = async (status: AppStatus) => { - await axios.put( - "/", - JSON.stringify({ - status, - }), - { - headers: { - "Content-Type": "application/json", - }, - } - ); -}; - -const sessionRetries: Record = {}; - -export const BuildPlugin: Plugin = async ({ client, $ }) => { - return { - event: async ({ event }) => { - const isMessagedDone = - event.type === "message.updated" && - // @ts-ignore - event.properties.info["finish"] === "stop"; - - if (!isMessagedDone) return; - - // @ts-ignore - const error = event.properties.info["error"]; - - const isAbortionError = error && error.name === "MessageAbortedError"; - - const isAnyChange = - (await $`git status --porcelain`.quiet()).stdout.toString().trim() !== - ""; - - console.log({ isAnyChange }); - - if (!isAnyChange || isAbortionError) { - await updateAppStatus(AppStatus.RUNNING); - - return; - } - - console.log("Building..."); - - const result = await $`pnpm build`.quiet().catch((error) => error); - - if (result.exitCode !== 0) { - if (!sessionRetries[event.properties.info.sessionID]) { - sessionRetries[event.properties.info.sessionID] = 1; - } else { - sessionRetries[event.properties.info.sessionID]++; - } - - if (sessionRetries[event.properties.info.sessionID] > 3) { - await updateAppStatus(AppStatus.FAILED); - - return; - } - - console.log( - `Retrying... ${sessionRetries[event.properties.info.sessionID]}` - ); - - await client.session.promptAsync({ - path: { id: event.properties.info.sessionID }, - body: { - parts: [ - { - type: "text", - text: `While building the project, the following error occurred:\n\n${result.stdout.toString()}\n\nPlease fix the error and try again.`, - }, - ], - }, - }); - } - - sessionRetries[event.properties.info.sessionID] = 1; - - try { - const packageJson = JSON.parse( - await fs.readFile("package.json", "utf-8") - ); - const [major, minor, patch] = packageJson.version - .split(".") - .map(Number); - const newVersion = `${major}.${minor}.${patch + 1}`; - - const messages = await client.session.messages({ - path: { id: event.properties.info.sessionID }, - }); - - if (!messages.data) { - return; - } - - const currentMessage = messages.data - .reverse() - .find( - (message) => - message.info.role === "user" && - message.info.summary && - message.info.summary.title - ); - - if (!currentMessage) { - return; - } - - const commitMessage = - // @ts-ignore - currentMessage.info.summary?.["title"] ?? - `feat: release version v${newVersion}`; - - packageJson.version = newVersion; - - await fs.writeFile( - "package.json", - JSON.stringify(packageJson, null, 2) - ); - - console.log("Pushing"); - await $`git add .`.quiet(); - await $`GIT_AUTHOR_NAME="Taylor AI" GIT_AUTHOR_EMAIL="ai@taylordb.io" GIT_COMMITTER_NAME="Taylor AI" GIT_COMMITTER_EMAIL="ai@taylordb.io" git commit -m ${commitMessage}`.quiet(); - await $`git tag v${newVersion}`.quiet(); - await $`git push origin main --tags`.quiet(); - } catch (error) { - console.error("Failed to push to git", error); - } - - await updateAppStatus(AppStatus.RUNNING); - }, - - "chat.message": async () => { - await updateAppStatus(AppStatus.BUSY); - }, - }; -}; diff --git a/.opencode/plugin/file-protection.ts b/.opencode/plugin/file-protection.ts deleted file mode 100644 index f511cd7..0000000 --- a/.opencode/plugin/file-protection.ts +++ /dev/null @@ -1,27 +0,0 @@ -import type { Plugin } from "@opencode-ai/plugin"; -import micromatch from "micromatch"; - -const uneditableFiles = [ - ".env", - ".env.local", - ".env.development", - ".env.production", - "**/src/lib/**.ts", - "opencode.json", - "**/.opencode/**", -]; - -export const FileProtectionPlugin: Plugin = async () => { - return { - "tool.execute.before": async (input, output) => { - if ( - input.tool === "edit" && - uneditableFiles.some((pattern) => - micromatch.isMatch(output.args.filePath, pattern) - ) - ) { - throw new Error(`Do not edit ${output.args.filePath} files`); - } - }, - }; -};