refactor(plugin): remove AI slop and clean verbose comments
This commit is contained in:
@@ -21,14 +21,12 @@ import { startTmuxCheck } from "./tools"
|
|||||||
let activePluginDispose: PluginDispose | null = null
|
let activePluginDispose: PluginDispose | null = null
|
||||||
|
|
||||||
const OhMyOpenCodePlugin: Plugin = async (ctx) => {
|
const OhMyOpenCodePlugin: Plugin = async (ctx) => {
|
||||||
// Initialize config context for plugin runtime (prevents warnings from hooks)
|
|
||||||
initConfigContext("opencode", null)
|
initConfigContext("opencode", null)
|
||||||
log("[OhMyOpenCodePlugin] ENTRY - plugin loading", {
|
log("[OhMyOpenCodePlugin] ENTRY - plugin loading", {
|
||||||
directory: ctx.directory,
|
directory: ctx.directory,
|
||||||
})
|
})
|
||||||
logLegacyPluginStartupWarning()
|
logLegacyPluginStartupWarning()
|
||||||
|
|
||||||
// Detect conflicting skill plugins (e.g., opencode-skills)
|
|
||||||
const skillPluginCheck = detectExternalSkillPlugin(ctx.directory)
|
const skillPluginCheck = detectExternalSkillPlugin(ctx.directory)
|
||||||
if (skillPluginCheck.detected && skillPluginCheck.pluginName) {
|
if (skillPluginCheck.detected && skillPluginCheck.pluginName) {
|
||||||
console.warn(getSkillPluginConflictWarning(skillPluginCheck.pluginName))
|
console.warn(getSkillPluginConflictWarning(skillPluginCheck.pluginName))
|
||||||
@@ -126,7 +124,4 @@ export type {
|
|||||||
BuiltinCommandName,
|
BuiltinCommandName,
|
||||||
} from "./config"
|
} from "./config"
|
||||||
|
|
||||||
// NOTE: Do NOT export functions from main index.ts!
|
|
||||||
// OpenCode treats ALL exports as plugin instances and calls them.
|
|
||||||
// Config error utilities are available via "./shared/config-errors" for internal use only.
|
|
||||||
export type { ConfigLoadError } from "./shared/config-errors"
|
export type { ConfigLoadError } from "./shared/config-errors"
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ export async function applyCommandConfig(params: {
|
|||||||
const includeClaudeCommands = params.pluginConfig.claude_code?.commands ?? true;
|
const includeClaudeCommands = params.pluginConfig.claude_code?.commands ?? true;
|
||||||
const includeClaudeSkills = params.pluginConfig.claude_code?.skills ?? true;
|
const includeClaudeSkills = params.pluginConfig.claude_code?.skills ?? true;
|
||||||
|
|
||||||
// Detect conflicting skill plugins
|
|
||||||
const externalSkillPlugin = detectExternalSkillPlugin(params.ctx.directory);
|
const externalSkillPlugin = detectExternalSkillPlugin(params.ctx.directory);
|
||||||
if (includeClaudeSkills && externalSkillPlugin.detected) {
|
if (includeClaudeSkills && externalSkillPlugin.detected) {
|
||||||
log(getSkillPluginConflictWarning(externalSkillPlugin.pluginName!));
|
log(getSkillPluginConflictWarning(externalSkillPlugin.pluginName!));
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ import { log } from "../shared";
|
|||||||
|
|
||||||
type McpEntry = Record<string, unknown>;
|
type McpEntry = Record<string, unknown>;
|
||||||
|
|
||||||
|
function isDisabledMcpEntry(value: unknown): value is McpEntry & { enabled: false } {
|
||||||
|
return typeof value === "object" && value !== null && (value as McpEntry).enabled === false;
|
||||||
|
}
|
||||||
|
|
||||||
function captureUserDisabledMcps(
|
function captureUserDisabledMcps(
|
||||||
userMcp: Record<string, unknown> | undefined
|
userMcp: Record<string, unknown> | undefined
|
||||||
): Set<string> {
|
): Set<string> {
|
||||||
@@ -13,12 +17,7 @@ function captureUserDisabledMcps(
|
|||||||
if (!userMcp) return disabled;
|
if (!userMcp) return disabled;
|
||||||
|
|
||||||
for (const [name, value] of Object.entries(userMcp)) {
|
for (const [name, value] of Object.entries(userMcp)) {
|
||||||
if (
|
if (isDisabledMcpEntry(value)) {
|
||||||
value &&
|
|
||||||
typeof value === "object" &&
|
|
||||||
"enabled" in value &&
|
|
||||||
(value as McpEntry).enabled === false
|
|
||||||
) {
|
|
||||||
disabled.add(name);
|
disabled.add(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,8 +153,6 @@ export function createSessionHooks(args: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Model fallback hook (configurable via model_fallback config + disabled_hooks)
|
|
||||||
// This handles automatic model switching when model errors occur
|
|
||||||
const isModelFallbackConfigEnabled = pluginConfig.model_fallback ?? false
|
const isModelFallbackConfigEnabled = pluginConfig.model_fallback ?? false
|
||||||
const modelFallback = isModelFallbackConfigEnabled && isHookEnabled("model-fallback")
|
const modelFallback = isModelFallbackConfigEnabled && isHookEnabled("model-fallback")
|
||||||
? safeHook("model-fallback", () =>
|
? safeHook("model-fallback", () =>
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ export function normalizeToolArgSchemas<TDefinition extends Pick<ToolDefinition,
|
|||||||
return toolDefinition
|
return toolDefinition
|
||||||
}
|
}
|
||||||
|
|
||||||
// Schema keywords unsupported by Gemini — strip them from MCP tool schemas
|
|
||||||
const UNSUPPORTED_SCHEMA_KEYWORDS = new Set(["contentEncoding", "contentMediaType"])
|
const UNSUPPORTED_SCHEMA_KEYWORDS = new Set(["contentEncoding", "contentMediaType"])
|
||||||
|
|
||||||
function isRecord(value: unknown): value is Record<string, unknown> {
|
function isRecord(value: unknown): value is Record<string, unknown> {
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ describe("scheduleDeferredModelOverride", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test("should fall back to setTimeout when message never appears", async () => {
|
test("should fall back to setTimeout when message never appears", async () => {
|
||||||
//#given — no message inserted
|
//#given no message inserted
|
||||||
|
|
||||||
//#when
|
//#when
|
||||||
const { scheduleDeferredModelOverride } = await import("./ultrawork-db-model-override")
|
const { scheduleDeferredModelOverride } = await import("./ultrawork-db-model-override")
|
||||||
|
|||||||
Reference in New Issue
Block a user