Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## OVERVIEW

OpenCode plugin (npm: `oh-my-opencode`, dual-published as `oh-my-openagent` during transition) extending Claude Code with 11 agents, 52 lifecycle hooks, 26 tools, 3-tier MCP system (built-in + .mcp.json + skill-embedded), Hashline LINE#ID edit tool, IntentGate classifier, and Claude Code compatibility. 1766 TypeScript source files, 377k LOC, 104 barrel index.ts files. Entry: `src/index.ts` → 5-step init (loadConfig → createManagers → createTools → createHooks → createPluginInterface).
OpenCode plugin (npm: `oh-my-opencode`, dual-published as `oh-my-openagent` during transition) extending Claude Code with 11 agents, 51 lifecycle hooks, 26 tools, 3-tier MCP system (built-in + .mcp.json + skill-embedded), Hashline LINE#ID edit tool, IntentGate classifier, and Claude Code compatibility. 1766 TypeScript source files, 377k LOC, 104 barrel index.ts files. Entry: `src/index.ts` → 5-step init (loadConfig → createManagers → createTools → createHooks → createPluginInterface).
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.

## STRUCTURE

Expand All @@ -14,14 +14,14 @@ oh-my-opencode/
│ ├── index.ts # Plugin entry: default export `pluginModule`, shape `{ id, server }`
│ ├── plugin-config.ts # JSONC multi-level config: user → project → defaults (Zod v4)
│ ├── agents/ # 11 agents (Sisyphus, Hephaestus, Oracle, Librarian, Explore, Atlas, Prometheus, Metis, Momus, Multimodal-Looker, Sisyphus-Junior)
│ ├── hooks/ # 52 lifecycle hooks across dedicated modules and standalone files
│ ├── hooks/ # 51 lifecycle hooks across dedicated modules and standalone files
│ ├── tools/ # 26 tools across 16 directories (includes Hashline edit with LINE#ID content hashing)
│ ├── features/ # 19 feature modules (background-agent, skill-loader, tmux, MCP-OAuth, skill-mcp-manager, etc.)
│ ├── shared/ # 170+ utility files (barrel-exported, logger → /tmp/oh-my-opencode.log)
│ ├── config/ # Zod v4 schema system (32 files)
│ ├── cli/ # CLI: install, run, doctor, mcp-oauth (Commander.js)
│ ├── mcp/ # 3 built-in remote MCPs (websearch, context7, grep_app)
│ ├── plugin/ # 10 OpenCode hook handlers + 52 hook composition
│ ├── plugin/ # 10 OpenCode hook handlers + 51 hook composition
│ ├── plugin-handlers/ # 6-phase config loading pipeline
│ └── openclaw/ # Bidirectional external integration (Discord/Telegram/webhook/command)
├── packages/ # 11 platform-specific compiled binaries (darwin/linux/windows, AVX2 + baseline variants)
Expand All @@ -37,7 +37,7 @@ pluginModule.server(input, options)
├─→ loadPluginConfig() # JSONC parse → project/user merge → Zod validate → migrate
├─→ createManagers() # TmuxSessionManager, BackgroundManager, SkillMcpManager, ConfigHandler
├─→ createTools() # SkillContext + AvailableCategories + ToolRegistry (26 tools)
├─→ createHooks() # 3-tier: Core(43) + Continuation(7) + Skill(2) = 52 hooks
├─→ createHooks() # 3-tier: Core(42) + Continuation(7) + Skill(2) = 51 hooks
└─→ createPluginInterface() # 10 OpenCode hook handlers → PluginInterface
```

Expand Down Expand Up @@ -104,7 +104,7 @@ Fields: agents (14 overridable, 21 fields each), categories (8 built-in + custom
- **Test pattern**: Bun test (`bun:test`), co-located `*.test.ts`, given/when/then style (nested describe with `#given`/`#when`/`#then` prefixes or inline `// given` / `// when` / `// then` comments)
- **CI test split**: `script/run-ci-tests.ts` auto-detects `mock.module()` usage, isolates those tests in separate processes
- **Factory pattern**: `createXXX()` for all tools, hooks, agents
- **Hook tiers**: Session (24) → Tool-Guard (14) → Transform (5) → Continuation (7) → Skill (2)
- **Hook tiers**: Session (23) → Tool-Guard (14) → Transform (5) → Continuation (7) → Skill (2)
- **Agent modes**: `primary` (respects UI model) vs `subagent` (own fallback chain) vs `all`
- **Model resolution**: 4-step: override → category-default → provider-fallback → system-default
- **Config format**: JSONC with comments, Zod v4 validation, snake_case keys
Expand Down
9 changes: 0 additions & 9 deletions assets/oh-my-opencode.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5720,15 +5720,6 @@
},
"additionalProperties": false
},
"notification": {
"type": "object",
"properties": {
"force_enable": {
"type": "boolean"
}
},
"additionalProperties": false
},
"model_capabilities": {
"type": "object",
"properties": {
Expand Down
13 changes: 13 additions & 0 deletions docs/guide/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ After you install it, you can read this [overview guide](./overview.md) to under

The published package and local binary are still `oh-my-opencode`. Inside `opencode.json`, the compatibility layer now prefers the plugin entry `oh-my-openagent`, while legacy `oh-my-opencode` entries still load with a warning. Plugin config loading recognizes both `oh-my-openagent.json[c]` and `oh-my-opencode.json[c]` during the transition. If you see a "Using legacy package name" warning from `bunx oh-my-opencode doctor`, update your `opencode.json` plugin entry from `"oh-my-opencode"` to `"oh-my-openagent"`.

## Session notification migration (KDCO)

oh-my-opencode removed built-in `session-notification` handling.

- Removed hook key: `session-notification`
- Removed config key: `notification.force_enable`

oh-my-opencode now bundles KDCO `opencode-notify` and auto-manages a single user-scope bundled notify plugin entry. No separate registry/plugin installation is required.

If your config already has recognized `kdco/notify` entries, oh-my-opencode migrates them to the bundled owner automatically. Custom/unsafe notify entries are blocked with explicit cleanup guidance to avoid duplicate owners.

`background-notification` behavior in oh-my-opencode is unchanged.

## For LLM Agents

> **IMPORTANT: Use `curl` to fetch this file, NOT WebFetch.** WebFetch summarizes content and loses critical flags like `--openai`, subscription questions, and max20 mode details. Always use:
Expand Down
19 changes: 11 additions & 8 deletions docs/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Complete reference for Oh My OpenCode plugin configuration. During the rename tr
- [Tmux Integration](#tmux-integration)
- [Git Master](#git-master)
- [Comment Checker](#comment-checker)
- [Notification](#notification)
- [Session Alerts Migration](#session-alerts-migration)
- [MCPs](#mcps)
- [LSP](#lsp)
- [Advanced](#advanced)
Expand Down Expand Up @@ -509,7 +509,7 @@ Disable built-in hooks via `disabled_hooks`:
{ "disabled_hooks": ["comment-checker"] }
```

Available hooks: `todo-continuation-enforcer`, `context-window-monitor`, `session-recovery`, `session-notification`, `comment-checker`, `grep-output-truncator`, `tool-output-truncator`, `directory-agents-injector`, `directory-readme-injector`, `empty-task-response-detector`, `think-mode`, `anthropic-context-window-limit-recovery`, `rules-injector`, `background-notification`, `auto-update-checker`, `startup-toast`, `keyword-detector`, `agent-usage-reminder`, `non-interactive-env`, `interactive-bash-session`, `compaction-context-injector`, `thinking-block-validator`, `claude-code-hooks`, `ralph-loop`, `preemptive-compaction`, `auto-slash-command`, `sisyphus-junior-notepad`, `no-sisyphus-gpt`, `start-work`, `runtime-fallback`
Available hooks: `todo-continuation-enforcer`, `context-window-monitor`, `session-recovery`, `comment-checker`, `grep-output-truncator`, `tool-output-truncator`, `directory-agents-injector`, `directory-readme-injector`, `empty-task-response-detector`, `think-mode`, `anthropic-context-window-limit-recovery`, `rules-injector`, `background-notification`, `auto-update-checker`, `startup-toast`, `keyword-detector`, `agent-usage-reminder`, `non-interactive-env`, `interactive-bash-session`, `compaction-context-injector`, `thinking-block-validator`, `claude-code-hooks`, `ralph-loop`, `preemptive-compaction`, `auto-slash-command`, `sisyphus-junior-notepad`, `no-sisyphus-gpt`, `start-work`, `runtime-fallback`

**Notes:**

Expand Down Expand Up @@ -585,15 +585,18 @@ Customize the comment quality checker:
}
```

### Notification
### Session Alerts Migration

Force-enable session notifications:
Built-in `session-notification` support was removed from oh-my-opencode.

```json
{ "notification": { "force_enable": true } }
```
- Removed hook key: `session-notification`
- Removed config key: `notification.force_enable`
- Migration automatically cleans both from legacy configs at startup
- oh-my-opencode now bundles KDCO notify and auto-registers one user-scope bundled notify plugin entry

Do not add separate `kdco/notify` entries manually. Recognized legacy `kdco/notify` entries are migrated to the bundled owner. Custom/unsafe notify entries fail loudly with cleanup guidance to prevent duplicate owners.

`force_enable` (`false`) - force session-notification even if external notification plugins are detected.
`background-notification` is unchanged because it handles parent-session reminder injection for background tasks, not notification transport.

### MCPs

Expand Down
3 changes: 2 additions & 1 deletion docs/reference/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -789,10 +789,11 @@ Hooks intercept and modify behavior at key points in the agent lifecycle across
| ---------------------------- | ------------------- | -------------------------------------------------------------------------------------------------- |
| **auto-update-checker** | Event | Checks for new versions on session creation, shows startup toast with version and Sisyphus status. |
| **background-notification** | Event | Notifies when background agent tasks complete. |
| **session-notification** | Event | OS notifications when agents go idle. Works on macOS, Linux, Windows. |
| **agent-usage-reminder** | PostToolUse + Event | Reminds you to leverage specialized agents for better results. |
| **question-label-truncator** | PreToolUse | Truncates long question labels in the Question tool UI. |

Session-level OS alerts are provided by a bundled KDCO `opencode-notify` integration managed by oh-my-opencode. Separate external `kdco/notify` plugin installs are not required.

#### Task Management

| Hook | Event | Description |
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
"./schema.json": "./dist/oh-my-opencode.schema.json"
},
"scripts": {
"build": "bun build src/index.ts --outdir dist --target bun --format esm --external @ast-grep/napi --external zod && tsc --emitDeclarationOnly && bun build src/cli/index.ts --outdir dist/cli --target bun --format esm --external @ast-grep/napi && bun run build:schema",
"build": "bun build src/index.ts --outdir dist --target bun --format esm --external @ast-grep/napi --external zod && tsc --emitDeclarationOnly && bun build src/cli/index.ts --outdir dist/cli --target bun --format esm --external @ast-grep/napi && bun build src/bundled-opencode-notify/index.ts --outdir dist/opencode-notify --target bun --format esm --external @ast-grep/napi --external zod && bun build src/shared/bundled-notify-ownership.ts --outdir dist/shared --target bun --format esm --external @ast-grep/napi --external zod && bun run build:bundled-notify && bun run build:schema",
"build:all": "bun run build && bun run build:binaries",
"build:binaries": "bun run script/build-binaries.ts",
"build:schema": "bun run script/build-schema.ts",
"build:bundled-notify": "bun run script/build-bundled-notify.ts",
"build:model-capabilities": "bun run script/build-model-capabilities.ts",
"clean": "rm -rf dist",
"prepare": "bun run build",
Expand Down
30 changes: 29 additions & 1 deletion postinstall.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// postinstall.mjs
// Runs after npm install to verify platform binary is available

import { readFileSync } from "node:fs";
import { existsSync, readFileSync } from "node:fs";
import { createRequire } from "node:module";
import { dirname } from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";
import { getPlatformPackageCandidates, getBinaryPath } from "./bin/platform.js";

const require = createRequire(import.meta.url);
Expand Down Expand Up @@ -128,6 +130,32 @@ function main() {
console.warn(` The CLI may not work on this platform.`);
// Don't fail installation - let user try anyway
}

void runBundledNotifyBootstrap();
}

async function runBundledNotifyBootstrap() {
try {
const packageRoot = dirname(fileURLToPath(import.meta.url));
const ownershipModulePath = `${packageRoot}/dist/shared/bundled-notify-ownership.js`;
Comment thread
kdcokenny marked this conversation as resolved.
if (!existsSync(ownershipModulePath)) {
return;
}

const ownershipModule = await import(pathToFileURL(ownershipModulePath).href);
if (typeof ownershipModule.ensureBundledNotifyOwnership !== "function") {
return;
}

ownershipModule.ensureBundledNotifyOwnership({
projectDirectory: process.cwd(),
packageRoot,
env: process.env,
});
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn(`⚠ oh-my-opencode bundled notify bootstrap: ${message}`);
}
}

main();
23 changes: 23 additions & 0 deletions script/build-bundled-notify.ts
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()
10 changes: 10 additions & 0 deletions src/bundled-opencode-notify/THIRD_PARTY_NOTICES.md
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.
142 changes: 142 additions & 0 deletions src/bundled-opencode-notify/index.test.ts
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)
})
})
Loading
Loading