From 09bb29d5d9c62e238ea6f3ce22d2eb3ab01682d7 Mon Sep 17 00:00:00 2001 From: DesertBoss Date: Tue, 3 Feb 2026 21:53:31 +0200 Subject: [PATCH 1/3] fix: frontmatter parsing support for windows - improved frontmatter parsing with BOM and newline support for windows support --- src/parsing/frontmatter.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/parsing/frontmatter.ts b/src/parsing/frontmatter.ts index 2189ff9..4abec57 100644 --- a/src/parsing/frontmatter.ts +++ b/src/parsing/frontmatter.ts @@ -5,7 +5,7 @@ import YAML from "yaml"; */ export function parseFrontmatter(content: string): Record { - const match = content.match(/^---\n([\s\S]*?)\n---/); + const match = content.replace(/^\uFEFF/, '').match(/^---\r?\n([\s\S]*?)\r?\n---/); if (!match) return {}; try { return YAML.parse(match[1]) ?? {}; @@ -15,6 +15,6 @@ export function parseFrontmatter(content: string): Record { } export function getTemplateBody(content: string): string { - const match = content.match(/^---\n[\s\S]*?\n---\n([\s\S]*)$/); + const match = content.replace(/^\uFEFF/, '').match(/^---\r?\n[\s\S]*?\r?\n---\r?\n([\s\S]*)$/); return match ? match[1].trim() : content.trim(); } From 3293267cdbf20f62f77ddb2c05574c0a5ae808ff Mon Sep 17 00:00:00 2001 From: DesertBoss Date: Tue, 3 Feb 2026 21:54:30 +0200 Subject: [PATCH 2/3] fix: command directory path Add Windows support and update command directory paths --- src/commands/manifest.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/commands/manifest.ts b/src/commands/manifest.ts index 386c05a..a7f8a9c 100644 --- a/src/commands/manifest.ts +++ b/src/commands/manifest.ts @@ -13,10 +13,10 @@ import { export async function buildManifest(): Promise> { const manifest: Record = {}; - const home = Bun.env.HOME ?? ""; + const home = Bun.env.HOME ?? Bun.env.USERPROFILE ?? ""; const dirs = [ - `${home}/.config/opencode/command`, - `${Bun.env.PWD ?? "."}/.opencode/command`, + `${home}/.config/opencode/commands`, + `${Bun.env.PWD ?? "."}/.opencode/commands`, ]; for (const dir of dirs) { From 59b9ef879eba58ad87ef769c851a5c93d5244013 Mon Sep 17 00:00:00 2001 From: DesertBoss Date: Tue, 3 Feb 2026 21:57:26 +0200 Subject: [PATCH 3/3] feat: add logging configuration option Add optional logging configuration to enable/disable subtask2 logging --- src/core/plugin.ts | 3 ++- src/types.ts | 1 + src/utils/config.ts | 1 + src/utils/logger.ts | 3 +++ 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/core/plugin.ts b/src/core/plugin.ts index bc6be89..94c6242 100644 --- a/src/core/plugin.ts +++ b/src/core/plugin.ts @@ -14,13 +14,14 @@ import { handleSessionIdle } from "../hooks/session-idle-hook"; */ export const createPlugin: Plugin = async ctx => { - clearLog(); const configs = await buildManifest(); const pluginConfig = await loadConfig(); setConfigs(configs); setPluginConfig(pluginConfig); + clearLog(); + // Use the v1 client from OpenCode - it has internal fetch configured properly // The internal HTTP client (client.client) can be used for undocumented endpoints setClient(ctx.client); diff --git a/src/types.ts b/src/types.ts index 7b07494..f183a8c 100644 --- a/src/types.ts +++ b/src/types.ts @@ -28,6 +28,7 @@ export interface CommandConfig { export interface Subtask2Config { replace_generic: boolean; generic_return?: string; + logging?: boolean; } export interface SubtaskPart { diff --git a/src/utils/config.ts b/src/utils/config.ts index 6dc59a8..f6d8a07 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -56,6 +56,7 @@ function isValidConfig(obj: unknown): obj is Subtask2Config { typeof cfg.generic_return !== "string" ) return false; + if (typeof cfg.logging !== "boolean") return false; return true; } diff --git a/src/utils/logger.ts b/src/utils/logger.ts index da9d0ac..4bd8189 100644 --- a/src/utils/logger.ts +++ b/src/utils/logger.ts @@ -1,5 +1,6 @@ import * as fs from "fs"; import * as path from "path"; +import { getPluginConfig } from "../core/state"; const LOG_DIR = path.join(process.cwd(), ".logs"); const LOG_FILE = path.join(LOG_DIR, "subtask2.log"); @@ -13,6 +14,8 @@ function ensureInitialized(): boolean { if (initialized) return true; try { + const config = getPluginConfig(); + if (!config || config.logging === false) return false; if (!fs.existsSync(LOG_DIR)) { fs.mkdirSync(LOG_DIR, { recursive: true }); }