fix(notify): harden bundled ownership and idle suppression

This commit is contained in:
Kenny
2026-04-19 14:34:13 +08:00
parent f5a11281f8
commit 6fffacd4fc
7 changed files with 144 additions and 36 deletions
@@ -98,6 +98,35 @@ describe("ensureBundledNotifyOwnership", () => {
expect(readConfig(userConfigPath).plugin).toEqual(["oh-my-openagent", canonicalEntry])
})
test("does not classify unrelated notify-like plugin names as unsafe", () => {
// given
const userConfigPath = join(userConfigDir, "opencode.json")
writeFileSync(userConfigPath, JSON.stringify({ plugin: ["team-notify-center", "oh-my-openagent"] }, null, 2) + "\n")
// when
const result = ensureBundledNotifyOwnership({ projectDirectory: projectDir, packageRoot })
// then
expect(result.changedUserConfig).toBe(true)
expect(readConfig(userConfigPath).plugin).toEqual(["team-notify-center", "oh-my-openagent", canonicalEntry])
})
test("migrates stale bundled dist/opencode-notify file URL to canonical bundled entry", () => {
// given
const userConfigPath = join(userConfigDir, "opencode.json")
const stalePackageRoot = join(rootDir, "package-old")
mkdirSync(join(stalePackageRoot, "dist", "opencode-notify"), { recursive: true })
const staleBundledEntry = getBundledNotifyCanonicalEntry(stalePackageRoot)
writeFileSync(userConfigPath, JSON.stringify({ plugin: [staleBundledEntry, "oh-my-openagent"] }, null, 2) + "\n")
// when
const result = ensureBundledNotifyOwnership({ projectDirectory: projectDir, packageRoot })
// then
expect(result.changedUserConfig).toBe(true)
expect(readConfig(userConfigPath).plugin).toEqual(["oh-my-openagent", canonicalEntry])
})
test("removes project recognized notify and adds bundled user owner", () => {
// given
const projectConfigPath = join(projectDir, ".opencode", "opencode.json")