From da0fa83f6c67d7a61e7013ae793ea4f99342e691 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Sun, 24 May 2026 17:17:31 +0900 Subject: [PATCH] test(prompts-core): audit opencode coupling Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- .../test/opencode-coupling-audit.test.ts | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 packages/prompts-core/test/opencode-coupling-audit.test.ts diff --git a/packages/prompts-core/test/opencode-coupling-audit.test.ts b/packages/prompts-core/test/opencode-coupling-audit.test.ts new file mode 100644 index 000000000..4205fdc92 --- /dev/null +++ b/packages/prompts-core/test/opencode-coupling-audit.test.ts @@ -0,0 +1,42 @@ +import { describe, expect, test } from "bun:test" +import { readdir, readFile } from "node:fs/promises" +import { dirname, join } from "node:path" +import { fileURLToPath } from "node:url" + +const SOURCE_DIR = join(dirname(fileURLToPath(import.meta.url)), "../src") + +describe("opencode coupling audit", () => { + test("#given prompts-core source #then no file imports @opencode-ai packages", async () => { + const offenders = await findOpenCodeImports(SOURCE_DIR) + + expect(offenders).toEqual([]) + }) +}) + +async function findOpenCodeImports(sourceDir: string): Promise { + const files = await collectTypeScriptFiles(sourceDir) + const offenders: string[] = [] + + for (const filePath of files) { + const source = await readFile(filePath, "utf8") + if (source.includes("@opencode-ai")) offenders.push(filePath) + } + + return offenders +} + +async function collectTypeScriptFiles(directory: string): Promise { + const entries = await readdir(directory, { withFileTypes: true }) + const files: string[] = [] + + for (const entry of entries) { + const entryPath = join(directory, entry.name) + if (entry.isDirectory()) { + files.push(...(await collectTypeScriptFiles(entryPath))) + } else if (entry.isFile() && entry.name.endsWith(".ts")) { + files.push(entryPath) + } + } + + return files +}