fix: resolve 25 pre-publish blockers
- postinstall.mjs: fix alias package detection - migrate-legacy-plugin-entry: dedupe + regression tests - task_system: default consistency across runtime paths - task() contract: consistent tool behavior - runtime model selection, tool cap, stale-task cancellation - recovery sanitization, context-limit gating - Ralph semantic DONE hardening, Atlas fallback persistence - native-skill description/content, skill path traversal guard - publish workflow: platform awaited via reusable workflow job - release: version edits reapplied before commit/tag - JSONC plugin migration: top-level plugin key safety - cold-cache: user fallback models skip disconnected providers - docs/version/release framing updates Verified: bun test (4599 pass), tsc --noEmit clean, bun run build clean
This commit is contained in:
@@ -2,7 +2,10 @@ import { afterEach, beforeEach, describe, expect, it } from "bun:test"
|
||||
import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"
|
||||
import { tmpdir } from "node:os"
|
||||
import { join } from "node:path"
|
||||
import { migrateLegacyPluginEntry } from "./migrate-legacy-plugin-entry"
|
||||
|
||||
async function importFreshMigrationModule(): Promise<typeof import("./migrate-legacy-plugin-entry")> {
|
||||
return import(`./migrate-legacy-plugin-entry?test=${Date.now()}-${Math.random()}`)
|
||||
}
|
||||
|
||||
describe("migrateLegacyPluginEntry", () => {
|
||||
let testDir = ""
|
||||
@@ -18,9 +21,10 @@ describe("migrateLegacyPluginEntry", () => {
|
||||
|
||||
describe("#given opencode.json contains oh-my-opencode plugin entry", () => {
|
||||
describe("#when migrating the config", () => {
|
||||
it("#then replaces oh-my-opencode with oh-my-openagent", () => {
|
||||
it("#then replaces oh-my-opencode with oh-my-openagent", async () => {
|
||||
const configPath = join(testDir, "opencode.json")
|
||||
writeFileSync(configPath, JSON.stringify({ plugin: ["oh-my-opencode@latest"] }, null, 2))
|
||||
const { migrateLegacyPluginEntry } = await importFreshMigrationModule()
|
||||
|
||||
const result = migrateLegacyPluginEntry(configPath)
|
||||
|
||||
@@ -34,9 +38,10 @@ describe("migrateLegacyPluginEntry", () => {
|
||||
|
||||
describe("#given opencode.json contains bare oh-my-opencode entry", () => {
|
||||
describe("#when migrating the config", () => {
|
||||
it("#then replaces with oh-my-openagent", () => {
|
||||
it("#then replaces with oh-my-openagent", async () => {
|
||||
const configPath = join(testDir, "opencode.json")
|
||||
writeFileSync(configPath, JSON.stringify({ plugin: ["oh-my-opencode"] }, null, 2))
|
||||
const { migrateLegacyPluginEntry } = await importFreshMigrationModule()
|
||||
|
||||
const result = migrateLegacyPluginEntry(configPath)
|
||||
|
||||
@@ -50,9 +55,10 @@ describe("migrateLegacyPluginEntry", () => {
|
||||
|
||||
describe("#given opencode.json contains pinned oh-my-opencode version", () => {
|
||||
describe("#when migrating the config", () => {
|
||||
it("#then preserves the version pin", () => {
|
||||
it("#then preserves the version pin", async () => {
|
||||
const configPath = join(testDir, "opencode.json")
|
||||
writeFileSync(configPath, JSON.stringify({ plugin: ["oh-my-opencode@3.11.0"] }, null, 2))
|
||||
const { migrateLegacyPluginEntry } = await importFreshMigrationModule()
|
||||
|
||||
const result = migrateLegacyPluginEntry(configPath)
|
||||
|
||||
@@ -65,10 +71,11 @@ describe("migrateLegacyPluginEntry", () => {
|
||||
|
||||
describe("#given opencode.json already uses oh-my-openagent", () => {
|
||||
describe("#when checking for migration", () => {
|
||||
it("#then returns false and does not modify the file", () => {
|
||||
it("#then returns false and does not modify the file", async () => {
|
||||
const configPath = join(testDir, "opencode.json")
|
||||
const original = JSON.stringify({ plugin: ["oh-my-openagent@latest"] }, null, 2)
|
||||
writeFileSync(configPath, original)
|
||||
const { migrateLegacyPluginEntry } = await importFreshMigrationModule()
|
||||
|
||||
const result = migrateLegacyPluginEntry(configPath)
|
||||
|
||||
@@ -78,9 +85,89 @@ describe("migrateLegacyPluginEntry", () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe("#given plugin entries contain both canonical and legacy values", () => {
|
||||
describe("#when migrating the config", () => {
|
||||
it("#then removes the legacy entry instead of duplicating the canonical one", async () => {
|
||||
const configPath = join(testDir, "opencode.json")
|
||||
writeFileSync(configPath, JSON.stringify({ plugin: ["oh-my-openagent", "oh-my-opencode"] }, null, 2))
|
||||
const { migrateLegacyPluginEntry } = await importFreshMigrationModule()
|
||||
|
||||
const result = migrateLegacyPluginEntry(configPath)
|
||||
|
||||
expect(result).toBe(true)
|
||||
const saved = JSON.parse(readFileSync(configPath, "utf-8")) as { plugin: string[] }
|
||||
expect(saved.plugin).toEqual(["oh-my-openagent"])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("#given unrelated strings contain the legacy package name", () => {
|
||||
describe("#when migrating the config", () => {
|
||||
it("#then rewrites only plugin entries and preserves unrelated fields", async () => {
|
||||
const configPath = join(testDir, "opencode.json")
|
||||
writeFileSync(
|
||||
configPath,
|
||||
JSON.stringify(
|
||||
{
|
||||
plugin: ["oh-my-opencode"],
|
||||
notes: "keep oh-my-opencode in this text field",
|
||||
paths: ["/tmp/oh-my-opencode/cache"],
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
)
|
||||
const { migrateLegacyPluginEntry } = await importFreshMigrationModule()
|
||||
|
||||
const result = migrateLegacyPluginEntry(configPath)
|
||||
|
||||
expect(result).toBe(true)
|
||||
const saved = JSON.parse(readFileSync(configPath, "utf-8")) as {
|
||||
plugin: string[]
|
||||
notes: string
|
||||
paths: string[]
|
||||
}
|
||||
expect(saved.plugin).toEqual(["oh-my-openagent"])
|
||||
expect(saved.notes).toBe("keep oh-my-opencode in this text field")
|
||||
expect(saved.paths).toEqual(["/tmp/oh-my-opencode/cache"])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("#given opencode.jsonc contains a nested plugin key before the top-level plugin array", () => {
|
||||
describe("#when migrating the config", () => {
|
||||
it("#then rewrites only the top-level plugin array", async () => {
|
||||
const configPath = join(testDir, "opencode.jsonc")
|
||||
writeFileSync(
|
||||
configPath,
|
||||
`{
|
||||
"nested": {
|
||||
"plugin": ["oh-my-opencode"]
|
||||
},
|
||||
"plugin": ["oh-my-opencode@latest"]
|
||||
}
|
||||
`,
|
||||
)
|
||||
const { migrateLegacyPluginEntry } = await importFreshMigrationModule()
|
||||
|
||||
const result = migrateLegacyPluginEntry(configPath)
|
||||
|
||||
expect(result).toBe(true)
|
||||
const content = readFileSync(configPath, "utf-8")
|
||||
expect(content).toContain(`"nested": {
|
||||
"plugin": ["oh-my-opencode"]
|
||||
}`)
|
||||
expect(content).toContain(`"plugin": [
|
||||
"oh-my-openagent@latest"
|
||||
]`)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("#given config file does not exist", () => {
|
||||
describe("#when attempting migration", () => {
|
||||
it("#then returns false", () => {
|
||||
it("#then returns false", async () => {
|
||||
const { migrateLegacyPluginEntry } = await importFreshMigrationModule()
|
||||
const result = migrateLegacyPluginEntry(join(testDir, "nonexistent.json"))
|
||||
|
||||
expect(result).toBe(false)
|
||||
|
||||
Reference in New Issue
Block a user