feat(background-agent): integrate into main plugin
🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
@@ -15,7 +15,7 @@ interface ChatMessageInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface ChatMessageOutput {
|
interface ChatMessageOutput {
|
||||||
parts: Array<{ type: string; text: string }>
|
parts: Array<{ type: string; text?: string; [key: string]: unknown }>
|
||||||
[key: string]: unknown
|
[key: string]: unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,3 +11,4 @@ export { createAnthropicAutoCompactHook } from "./anthropic-auto-compact";
|
|||||||
export { createThinkModeHook } from "./think-mode";
|
export { createThinkModeHook } from "./think-mode";
|
||||||
export { createClaudeCodeHooksHook } from "./claude-code-hooks";
|
export { createClaudeCodeHooksHook } from "./claude-code-hooks";
|
||||||
export { createRulesInjectorHook } from "./rules-injector";
|
export { createRulesInjectorHook } from "./rules-injector";
|
||||||
|
export { createBackgroundNotificationHook } from "./background-notification";
|
||||||
|
|||||||
20
src/index.ts
20
src/index.ts
@@ -13,6 +13,7 @@ import {
|
|||||||
createClaudeCodeHooksHook,
|
createClaudeCodeHooksHook,
|
||||||
createAnthropicAutoCompactHook,
|
createAnthropicAutoCompactHook,
|
||||||
createRulesInjectorHook,
|
createRulesInjectorHook,
|
||||||
|
createBackgroundNotificationHook,
|
||||||
} from "./hooks";
|
} from "./hooks";
|
||||||
import {
|
import {
|
||||||
loadUserCommands,
|
loadUserCommands,
|
||||||
@@ -36,7 +37,8 @@ import {
|
|||||||
getCurrentSessionTitle,
|
getCurrentSessionTitle,
|
||||||
} from "./features/claude-code-session-state";
|
} from "./features/claude-code-session-state";
|
||||||
import { updateTerminalTitle } from "./features/terminal";
|
import { updateTerminalTitle } from "./features/terminal";
|
||||||
import { builtinTools, createOmoTask } from "./tools";
|
import { builtinTools, createOmoTask, createBackgroundTools } from "./tools";
|
||||||
|
import { BackgroundManager } from "./features/background-agent";
|
||||||
import { createBuiltinMcps } from "./mcp";
|
import { createBuiltinMcps } from "./mcp";
|
||||||
import { OhMyOpenCodeConfigSchema, type OhMyOpenCodeConfig } from "./config";
|
import { OhMyOpenCodeConfigSchema, type OhMyOpenCodeConfig } from "./config";
|
||||||
import { log } from "./shared/logger";
|
import { log } from "./shared/logger";
|
||||||
@@ -162,16 +164,27 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
|
|||||||
|
|
||||||
updateTerminalTitle({ sessionId: "main" });
|
updateTerminalTitle({ sessionId: "main" });
|
||||||
|
|
||||||
|
const backgroundManager = new BackgroundManager(
|
||||||
|
ctx.client,
|
||||||
|
path.join(ctx.directory, ".opencode", "background-tasks.json")
|
||||||
|
);
|
||||||
|
await backgroundManager.restore();
|
||||||
|
|
||||||
|
const backgroundNotificationHook = createBackgroundNotificationHook(backgroundManager);
|
||||||
|
const backgroundTools = createBackgroundTools(backgroundManager, ctx.client);
|
||||||
|
|
||||||
const omoTask = createOmoTask(ctx);
|
const omoTask = createOmoTask(ctx);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
tool: {
|
tool: {
|
||||||
...builtinTools,
|
...builtinTools,
|
||||||
|
...backgroundTools,
|
||||||
omo_task: omoTask,
|
omo_task: omoTask,
|
||||||
},
|
},
|
||||||
|
|
||||||
"chat.message": async (input, output) => {
|
"chat.message": async (input, output) => {
|
||||||
await claudeCodeHooks["chat.message"]?.(input, output)
|
await claudeCodeHooks["chat.message"]?.(input, output);
|
||||||
|
await backgroundNotificationHook["chat.message"](input, output);
|
||||||
},
|
},
|
||||||
|
|
||||||
config: async (config) => {
|
config: async (config) => {
|
||||||
@@ -197,12 +210,14 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
|
|||||||
config.agent.explore.tools = {
|
config.agent.explore.tools = {
|
||||||
...config.agent.explore.tools,
|
...config.agent.explore.tools,
|
||||||
omo_task: false,
|
omo_task: false,
|
||||||
|
background_task: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (config.agent.librarian) {
|
if (config.agent.librarian) {
|
||||||
config.agent.librarian.tools = {
|
config.agent.librarian.tools = {
|
||||||
...config.agent.librarian.tools,
|
...config.agent.librarian.tools,
|
||||||
omo_task: false,
|
omo_task: false,
|
||||||
|
background_task: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,6 +251,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
|
|||||||
|
|
||||||
event: async (input) => {
|
event: async (input) => {
|
||||||
await claudeCodeHooks.event(input);
|
await claudeCodeHooks.event(input);
|
||||||
|
await backgroundNotificationHook.event(input);
|
||||||
await todoContinuationEnforcer(input);
|
await todoContinuationEnforcer(input);
|
||||||
await contextWindowMonitor.event(input);
|
await contextWindowMonitor.event(input);
|
||||||
await directoryAgentsInjector.event(input);
|
await directoryAgentsInjector.event(input);
|
||||||
|
|||||||
@@ -22,8 +22,29 @@ import { glob } from "./glob"
|
|||||||
import { slashcommand } from "./slashcommand"
|
import { slashcommand } from "./slashcommand"
|
||||||
import { skill } from "./skill"
|
import { skill } from "./skill"
|
||||||
|
|
||||||
|
import {
|
||||||
|
createBackgroundTask,
|
||||||
|
createBackgroundStatus,
|
||||||
|
createBackgroundResult,
|
||||||
|
createBackgroundCancel,
|
||||||
|
} from "./background-task"
|
||||||
|
|
||||||
|
import type { PluginInput } from "@opencode-ai/plugin"
|
||||||
|
import type { BackgroundManager } from "../features/background-agent"
|
||||||
|
|
||||||
|
type OpencodeClient = PluginInput["client"]
|
||||||
|
|
||||||
export { createOmoTask } from "./omo-task"
|
export { createOmoTask } from "./omo-task"
|
||||||
|
|
||||||
|
export function createBackgroundTools(manager: BackgroundManager, client: OpencodeClient) {
|
||||||
|
return {
|
||||||
|
background_task: createBackgroundTask(manager),
|
||||||
|
background_status: createBackgroundStatus(manager),
|
||||||
|
background_result: createBackgroundResult(manager, client),
|
||||||
|
background_cancel: createBackgroundCancel(manager, client),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const builtinTools = {
|
export const builtinTools = {
|
||||||
lsp_hover,
|
lsp_hover,
|
||||||
lsp_goto_definition,
|
lsp_goto_definition,
|
||||||
|
|||||||
Reference in New Issue
Block a user