fix(notify): allow underscore dist-tags for recognized specs

This commit is contained in:
Kenny
2026-04-19 16:41:10 +08:00
parent aaf35b572e
commit 14d700237c
2 changed files with 27 additions and 1 deletions
@@ -96,6 +96,32 @@ describe("ensureBundledNotifyOwnership", () => {
expect(readConfig(userConfigPath).plugin).toEqual(["oh-my-openagent", canonicalEntry])
})
test("rewrites recognized external notify with underscore dist-tag to bundled owner", () => {
// given
const userConfigPath = join(userConfigDir, "opencode.json")
writeFileSync(userConfigPath, JSON.stringify({ plugin: ["kdco/notify@release_candidate", "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("rewrites npm-prefixed recognized notify with underscore dist-tag to bundled owner", () => {
// given
const userConfigPath = join(userConfigDir, "opencode.json")
writeFileSync(userConfigPath, JSON.stringify({ plugin: ["npm:kdco/notify@release_candidate", "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("rewrites recognized tuple notify in user config when tuple options are empty", () => {
// given
const userConfigPath = join(userConfigDir, "opencode.json")
+1 -1
View File
@@ -76,7 +76,7 @@ function isRecognizedExternalNotifyId(entry: string): boolean {
if (versionSuffix.includes("/")) return false
if (versionSuffix.includes("\\")) return false
return /^[a-z0-9.*+!~^<>=| -]+$/i.test(versionSuffix)
return /^[a-z0-9_.*+!~^<>=| -]+$/i.test(versionSuffix)
})
}