diff --git a/.opencode/plugin/dev-server-hmr.ts b/.opencode/plugin/dev-server-hmr.ts index d8d1786..fde96f1 100644 --- a/.opencode/plugin/dev-server-hmr.ts +++ b/.opencode/plugin/dev-server-hmr.ts @@ -1,5 +1,6 @@ import type { Plugin } from "@opencode-ai/plugin"; import { Axios } from "axios"; +import { promises as fs } from "fs"; import { z } from "zod"; const { vmOrchestrationStatusUpdateUrl } = z @@ -16,17 +17,17 @@ const axios = new Axios({ }); const updateAppStatus = async (status: "Errored" | "Active" | "Pending") => { - await axios.put( - "/", - JSON.stringify({ - status, - }), - { - headers: { - "Content-Type": "application/json", - }, - } - ); + // await axios.put( + // "/", + // JSON.stringify({ + // status, + // }), + // { + // headers: { + // "Content-Type": "application/json", + // }, + // } + // ); }; export const DevServerHMRPlugin: Plugin = async ({ client, $ }) => { @@ -64,12 +65,45 @@ export const DevServerHMRPlugin: Plugin = async ({ client, $ }) => { }); } + 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 session = await client.session.get({ + path: { id: event.properties.sessionID }, + }); + + const commitMessage = + session.data?.title ?? `feat: release version v${newVersion}`; + + await $`git config user.name "Taylor AI"`; + await $`git config user.email "ai@taylordb.io"`; + await $`git add .`; + await $`git commit -m ${commitMessage}`; + await $`git tag v${newVersion}`; + await $`git push origin main --tags`; + + packageJson.version = newVersion; + + await fs.writeFile( + "package.json", + JSON.stringify(packageJson, null, 2) + ); + } catch (error) { + console.error("Failed to push to git", error); + } + await updateAppStatus("Active"); console.log("CHANGE STATUS TO ACTIVE"); }, - "chat.message": async (input, output) => { + "chat.message": async () => { await updateAppStatus("Pending"); console.log("CHANGE STATUS TO PENDING");