Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
26 changes: 14 additions & 12 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { Plugin } from "@opencode-ai/plugin"
import { getConfig } from "./lib/config"
import { Logger } from "./lib/logger"
import { Janitor } from "./lib/janitor"
import { createJanitorContext } from "./lib/core/janitor"
import { checkForUpdates } from "./lib/version-checker"
import { createPluginState } from "./lib/state"
import { installFetchWrapper } from "./lib/fetch-wrapper"
import { createPruningTool } from "./lib/pruning-tool"
import { createEventHandler, createChatParamsHandler } from "./lib/hooks"
import { createToolTracker } from "./lib/synth-instruction"
import { loadPrompt } from "./lib/prompt"
import { createToolTracker } from "./lib/api-formats/synth-instruction"
import { loadPrompt } from "./lib/core/prompt"

const plugin: Plugin = (async (ctx) => {
const { config, migrations } = getConfig(ctx)
Expand All @@ -26,16 +26,18 @@ const plugin: Plugin = (async (ctx) => {
const logger = new Logger(config.debug)
const state = createPluginState()

const janitor = new Janitor(
const janitorCtx = createJanitorContext(
ctx.client,
state,
logger,
config.protectedTools,
config.model,
config.showModelErrorToasts,
config.strictModelSelection,
config.pruning_summary,
ctx.directory
{
protectedTools: config.protectedTools,
model: config.model,
showModelErrorToasts: config.showModelErrorToasts ?? true,
strictModelSelection: config.strictModelSelection ?? false,
pruningSummary: config.pruning_summary,
workingDirectory: ctx.directory
}
)

// Create tool tracker and load prompts for synthetic instruction injection
Expand Down Expand Up @@ -85,10 +87,10 @@ const plugin: Plugin = (async (ctx) => {
}

return {
event: createEventHandler(ctx.client, janitor, logger, config, toolTracker),
event: createEventHandler(ctx.client, janitorCtx, logger, config, toolTracker),
"chat.params": createChatParamsHandler(ctx.client, state, logger),
tool: config.strategies.onTool.length > 0 ? {
prune: createPruningTool(ctx.client, janitor, config, toolTracker),
prune: createPruningTool(ctx.client, janitorCtx, config, toolTracker),
} : undefined,
}
}) satisfies Plugin
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface ConfigResult {
const defaultConfig: PluginConfig = {
enabled: true,
debug: false,
protectedTools: ['task', 'todowrite', 'todoread', 'prune'],
protectedTools: ['task', 'todowrite', 'todoread', 'prune', 'batch'],
showModelErrorToasts: true,
strictModelSelection: false,
pruning_summary: 'detailed',
Expand Down
Loading