refactor(install): prefer native plugin install across targets (#609)
Some checks failed
CI / pr-title (push) Has been cancelled
CI / test (push) Has been cancelled
Release PR / release-pr (push) Has been cancelled
Release PR / publish-cli (push) Has been cancelled

Co-authored-by: John Cavanaugh <cavanaug@users.noreply.github.com>
This commit is contained in:
Trevin Chow
2026-04-20 18:47:07 -07:00
committed by GitHub
parent 9497a00d90
commit c2d60b47be
104 changed files with 7073 additions and 7068 deletions

View File

@@ -1,4 +1,4 @@
import { describe, expect, test } from "bun:test"
import { afterEach, describe, expect, test } from "bun:test"
import { promises as fs } from "fs"
import path from "path"
import os from "os"
@@ -11,7 +11,6 @@ describe("detectInstalledTools", () => {
// Create directories for some tools
await fs.mkdir(path.join(tempHome, ".codex"), { recursive: true })
await fs.mkdir(path.join(tempHome, ".codeium", "windsurf"), { recursive: true })
await fs.mkdir(path.join(tempHome, ".gemini"), { recursive: true })
await fs.mkdir(path.join(tempHome, ".copilot"), { recursive: true })
@@ -21,10 +20,6 @@ describe("detectInstalledTools", () => {
expect(codex?.detected).toBe(true)
expect(codex?.reason).toContain(".codex")
const windsurf = results.find((t) => t.name === "windsurf")
expect(windsurf?.detected).toBe(true)
expect(windsurf?.reason).toContain(".codeium/windsurf")
const gemini = results.find((t) => t.name === "gemini")
expect(gemini?.detected).toBe(true)
expect(gemini?.reason).toContain(".gemini")
@@ -50,7 +45,7 @@ describe("detectInstalledTools", () => {
const results = await detectInstalledTools(tempHome, tempCwd)
expect(results.length).toBe(10)
expect(results.length).toBe(8)
for (const tool of results) {
expect(tool.detected).toBe(false)
expect(tool.reason).toBe("not found")
@@ -64,14 +59,49 @@ describe("detectInstalledTools", () => {
await fs.mkdir(path.join(tempHome, ".config", "opencode"), { recursive: true })
await fs.mkdir(path.join(tempHome, ".factory"), { recursive: true })
await fs.mkdir(path.join(tempHome, ".pi"), { recursive: true })
await fs.mkdir(path.join(tempHome, ".openclaw"), { recursive: true })
const results = await detectInstalledTools(tempHome, tempCwd)
expect(results.find((t) => t.name === "opencode")?.detected).toBe(true)
expect(results.find((t) => t.name === "droid")?.detected).toBe(true)
expect(results.find((t) => t.name === "pi")?.detected).toBe(true)
expect(results.find((t) => t.name === "openclaw")?.detected).toBe(true)
})
describe("opencode OPENCODE_CONFIG_DIR", () => {
const originalEnv = process.env.OPENCODE_CONFIG_DIR
afterEach(() => {
if (originalEnv === undefined) {
delete process.env.OPENCODE_CONFIG_DIR
} else {
process.env.OPENCODE_CONFIG_DIR = originalEnv
}
})
test("detects opencode at OPENCODE_CONFIG_DIR when set, even if ~/.config/opencode is absent", async () => {
const tempHome = await fs.mkdtemp(path.join(os.tmpdir(), "detect-opencode-env-home-"))
const tempCwd = await fs.mkdtemp(path.join(os.tmpdir(), "detect-opencode-env-cwd-"))
const customRoot = await fs.mkdtemp(path.join(os.tmpdir(), "detect-opencode-env-root-"))
// Ensure no ~/.config/opencode exists under the sandbox home.
process.env.OPENCODE_CONFIG_DIR = customRoot
const results = await detectInstalledTools(tempHome, tempCwd)
const opencode = results.find((t) => t.name === "opencode")
expect(opencode?.detected).toBe(true)
expect(opencode?.reason).toContain(customRoot)
})
test("opencode is not detected when OPENCODE_CONFIG_DIR points at a missing directory", async () => {
const tempHome = await fs.mkdtemp(path.join(os.tmpdir(), "detect-opencode-missing-home-"))
const tempCwd = await fs.mkdtemp(path.join(os.tmpdir(), "detect-opencode-missing-cwd-"))
const missingRoot = path.join(os.tmpdir(), `detect-opencode-missing-${Date.now()}-${Math.random()}`)
process.env.OPENCODE_CONFIG_DIR = missingRoot
const results = await detectInstalledTools(tempHome, tempCwd)
expect(results.find((t) => t.name === "opencode")?.detected).toBe(false)
})
})
test("detects copilot from project-specific skills without generic .github false positives", async () => {