-
Notifications
You must be signed in to change notification settings - Fork 4.6k
refactor(notify): bundle KDCO opencode-notify and remove built-in session-notification #3520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c21ad22
refactor(hooks): remove built-in session-notification subsystem
kdcokenny af15e8a
docs(agents): align root hook tier count with 51-hook inventory
kdcokenny f5a1128
feat(notify): bundle KDCO notify with ownership migration
kdcokenny 6fffacd
fix(notify): harden bundled ownership and idle suppression
kdcokenny 9f2ba4b
fix(notify): reject custom package notify owners
kdcokenny 37c4f42
fix(notify): classify npm alias notify specs as unsafe
kdcokenny aaf35b5
fix(notify): restrict recognized kdco specs to safe forms
kdcokenny 14d7002
fix(notify): allow underscore dist-tags for recognized specs
kdcokenny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #!/usr/bin/env bun | ||
| import { copyFileSync, mkdirSync, writeFileSync } from "node:fs" | ||
| import { join } from "node:path" | ||
|
|
||
| const DIST_NOTIFY_DIR = join("dist", "opencode-notify") | ||
| const SOURCE_NOTICE_PATH = join("src", "bundled-opencode-notify", "THIRD_PARTY_NOTICES.md") | ||
| const DIST_NOTICE_PATH = join(DIST_NOTIFY_DIR, "THIRD_PARTY_NOTICES.md") | ||
| const DIST_PACKAGE_PATH = join(DIST_NOTIFY_DIR, "package.json") | ||
|
|
||
| const bundledPackageJson = { | ||
| name: "@oh-my-openagent/bundled-opencode-notify", | ||
| private: true, | ||
| type: "module", | ||
| main: "./index.js", | ||
| } | ||
|
|
||
| function main(): void { | ||
| mkdirSync(DIST_NOTIFY_DIR, { recursive: true }) | ||
| writeFileSync(DIST_PACKAGE_PATH, `${JSON.stringify(bundledPackageJson, null, 2)}\n`, "utf-8") | ||
| copyFileSync(SOURCE_NOTICE_PATH, DIST_NOTICE_PATH) | ||
| } | ||
|
|
||
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Third-Party Notices — Bundled Notify Plugin | ||
|
|
||
| This directory contains the bundled notify plugin artifact shipped by `oh-my-opencode`. | ||
|
|
||
| ## KDCO `opencode-notify` | ||
|
|
||
| - Upstream project identifier: `kdco/notify` | ||
| - Usage in this package: bundled local plugin ownership target for OpenCode `plugin` registration | ||
|
|
||
| If you update bundled notify behavior, review and refresh this notice file with any additional upstream licensing requirements. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| import { afterEach, beforeEach, describe, expect, jest, test } from "bun:test" | ||
|
|
||
| import bundledNotifyPlugin from "./index" | ||
|
|
||
| interface TodoItem { | ||
| status: string | ||
| } | ||
|
|
||
| type TodoResponseMode = { | ||
| todos?: TodoItem[] | ||
| throwError?: boolean | ||
| } | ||
|
|
||
| function createMockShellExecutor(notificationCommands: string[]) { | ||
| return (cmd: TemplateStringsArray | string, ...values: unknown[]) => { | ||
| const command = typeof cmd === "string" | ||
| ? cmd | ||
| : cmd.reduce((acc, part, index) => `${acc}${part}${String(values[index] ?? "")}`, "") | ||
|
|
||
| const isLookupCommand = command.includes("command -v terminal-notifier") | ||
| const exitCode = isLookupCommand ? 1 : 0 | ||
| if (!isLookupCommand) { | ||
| notificationCommands.push(command) | ||
| } | ||
|
|
||
| const result = { stdout: "", stderr: "", exitCode } | ||
| const promise = Promise.resolve(result) as Promise<typeof result> & { | ||
| quiet: () => Promise<typeof result> | ||
| nothrow: () => Promise<typeof result> & { quiet: () => Promise<typeof result> } | ||
| } | ||
|
|
||
| promise.quiet = () => promise | ||
| promise.nothrow = () => { | ||
| const inner = Promise.resolve(result) as Promise<typeof result> & { quiet: () => Promise<typeof result> } | ||
| inner.quiet = () => inner | ||
| return inner | ||
| } | ||
|
|
||
| return promise | ||
| } | ||
| } | ||
|
|
||
| function createPluginInput(todoMode: TodoResponseMode, notificationCommands: string[]) { | ||
| return { | ||
| $: createMockShellExecutor(notificationCommands), | ||
| client: { | ||
| session: { | ||
| todo: async () => { | ||
| if (todoMode.throwError) { | ||
| throw new Error("todo fetch failed") | ||
| } | ||
|
|
||
| return { data: todoMode.todos ?? [] } | ||
| }, | ||
| }, | ||
| }, | ||
| } as Parameters<typeof bundledNotifyPlugin.server>[0] | ||
| } | ||
|
|
||
| describe("bundled-opencode-notify idle suppression", () => { | ||
| beforeEach(() => { | ||
| jest.useFakeTimers() | ||
| }) | ||
|
|
||
| afterEach(() => { | ||
| jest.clearAllTimers() | ||
| jest.useRealTimers() | ||
| }) | ||
|
|
||
| test("suppresses ready notification when todos are incomplete", async () => { | ||
| // given | ||
| const notificationCommands: string[] = [] | ||
| const hooks = await bundledNotifyPlugin.server( | ||
| createPluginInput({ todos: [{ status: "in_progress" }] }, notificationCommands), | ||
| ) | ||
|
|
||
| // when | ||
| await hooks.event?.({ event: { type: "session.idle", properties: { sessionID: "session-1" } } }) | ||
| jest.advanceTimersByTime(1500) | ||
| await Promise.resolve() | ||
| await Promise.resolve() | ||
|
|
||
| // then | ||
| expect(notificationCommands).toHaveLength(0) | ||
| }) | ||
|
|
||
| test("sends ready notification when todos are complete", async () => { | ||
| // given | ||
| const notificationCommands: string[] = [] | ||
| const hooks = await bundledNotifyPlugin.server( | ||
| createPluginInput({ todos: [{ status: "completed" }] }, notificationCommands), | ||
| ) | ||
|
|
||
| // when | ||
| await hooks.event?.({ event: { type: "session.idle", properties: { sessionID: "session-2" } } }) | ||
| jest.advanceTimersByTime(1500) | ||
| await Promise.resolve() | ||
| await Promise.resolve() | ||
|
|
||
| // then | ||
| expect(notificationCommands.length).toBeGreaterThan(0) | ||
| }) | ||
|
|
||
| test("sends ready notification when remaining todos are only blocked or deleted", async () => { | ||
| // given | ||
| const notificationCommands: string[] = [] | ||
| const hooks = await bundledNotifyPlugin.server( | ||
| createPluginInput({ | ||
| todos: [ | ||
| { status: "blocked" }, | ||
| { status: "deleted" }, | ||
| ], | ||
| }, notificationCommands), | ||
| ) | ||
|
|
||
| // when | ||
| await hooks.event?.({ event: { type: "session.idle", properties: { sessionID: "session-3" } } }) | ||
| jest.advanceTimersByTime(1500) | ||
| await Promise.resolve() | ||
| await Promise.resolve() | ||
|
|
||
| // then | ||
| expect(notificationCommands.length).toBeGreaterThan(0) | ||
| }) | ||
|
|
||
| test("suppresses ready notification when todo fetch state is unknown", async () => { | ||
| // given | ||
| const notificationCommands: string[] = [] | ||
| const hooks = await bundledNotifyPlugin.server( | ||
| createPluginInput({ throwError: true }, notificationCommands), | ||
| ) | ||
|
|
||
| // when | ||
| await hooks.event?.({ event: { type: "session.idle", properties: { sessionID: "session-4" } } }) | ||
| jest.advanceTimersByTime(1500) | ||
| await Promise.resolve() | ||
| await Promise.resolve() | ||
|
|
||
| // then | ||
| expect(notificationCommands).toHaveLength(0) | ||
| }) | ||
| }) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.