Skip to content

Commit 710a4cc

Browse files
committed
refactor: reorganize lib/ into core/, state/, api-formats/, ui/ subdirectories
1 parent 9c6a5b8 commit 710a4cc

File tree

17 files changed

+40
-40
lines changed

17 files changed

+40
-40
lines changed

index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import type { Plugin } from "@opencode-ai/plugin"
22
import { getConfig } from "./lib/config"
33
import { Logger } from "./lib/logger"
4-
import { createJanitorContext } from "./lib/janitor"
4+
import { createJanitorContext } from "./lib/core/janitor"
55
import { checkForUpdates } from "./lib/version-checker"
66
import { createPluginState } from "./lib/state"
77
import { installFetchWrapper } from "./lib/fetch-wrapper"
88
import { createPruningTool } from "./lib/pruning-tool"
99
import { createEventHandler, createChatParamsHandler } from "./lib/hooks"
10-
import { createToolTracker } from "./lib/synth-instruction"
11-
import { loadPrompt } from "./lib/prompt"
10+
import { createToolTracker } from "./lib/api-formats/synth-instruction"
11+
import { loadPrompt } from "./lib/core/prompt"
1212

1313
const plugin: Plugin = (async (ctx) => {
1414
const { config, migrations } = getConfig(ctx)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { extractParameterKey } from "./display-utils"
1+
import { extractParameterKey } from "../ui/display-utils"
22

33
export interface DuplicateDetectionResult {
44
duplicateIds: string[] // IDs to prune (older duplicates)

lib/janitor.ts renamed to lib/core/janitor.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { z } from "zod"
2-
import type { Logger } from "./logger"
3-
import type { PruningStrategy } from "./config"
4-
import type { PluginState } from "./state"
2+
import type { Logger } from "../logger"
3+
import type { PruningStrategy } from "../config"
4+
import type { PluginState } from "../state"
55
import { buildAnalysisPrompt } from "./prompt"
6-
import { selectModel, extractModelFromSession } from "./model-selector"
7-
import { estimateTokensBatch, formatTokenCount } from "./tokenizer"
8-
import { saveSessionState } from "./state-persistence"
9-
import { ensureSessionRestored } from "./state"
6+
import { selectModel, extractModelFromSession } from "../model-selector"
7+
import { estimateTokensBatch, formatTokenCount } from "../tokenizer"
8+
import { saveSessionState } from "../state/persistence"
9+
import { ensureSessionRestored } from "../state"
1010
import {
1111
sendPruningSummary,
1212
type NotificationContext
13-
} from "./notification"
13+
} from "../ui/notification"
1414

1515
// ============================================================================
1616
// Types

lib/prompt.ts renamed to lib/core/prompt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { readFileSync } from "fs"
22
import { join } from "path"
33

44
export function loadPrompt(name: string, vars?: Record<string, string>): string {
5-
const filePath = join(__dirname, "prompts", `${name}.txt`)
5+
const filePath = join(__dirname, "..", "prompts", `${name}.txt`)
66
let content = readFileSync(filePath, "utf8").trim()
77
if (vars) {
88
for (const [key, value] of Object.entries(vars)) {

lib/fetch-wrapper/gemini.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
getAllPrunedIds,
55
fetchSessionMessages
66
} from "./types"
7-
import { injectNudgeGemini, injectSynthGemini } from "../synth-instruction"
7+
import { injectNudgeGemini, injectSynthGemini } from "../api-formats/synth-instruction"
88

99
/**
1010
* Handles Google/Gemini format (body.contents array with functionResponse parts).

lib/fetch-wrapper/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import type { PluginState } from "../state"
22
import type { Logger } from "../logger"
33
import type { FetchHandlerContext, SynthPrompts } from "./types"
4-
import type { ToolTracker } from "../synth-instruction"
4+
import type { ToolTracker } from "../api-formats/synth-instruction"
55
import type { PluginConfig } from "../config"
66
import { handleOpenAIChatAndAnthropic } from "./openai-chat"
77
import { handleGemini } from "./gemini"
88
import { handleOpenAIResponses } from "./openai-responses"
9-
import { detectDuplicates } from "../deduplicator"
9+
import { detectDuplicates } from "../core/deduplicator"
1010

1111
export type { FetchHandlerContext, FetchHandlerResult, SynthPrompts } from "./types"
1212

lib/fetch-wrapper/openai-chat.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {
55
fetchSessionMessages,
66
getMostRecentActiveSession
77
} from "./types"
8-
import { cacheToolParametersFromMessages } from "../tool-cache"
9-
import { injectNudge, injectSynth } from "../synth-instruction"
8+
import { cacheToolParametersFromMessages } from "../state/tool-cache"
9+
import { injectNudge, injectSynth } from "../api-formats/synth-instruction"
1010

1111
/**
1212
* Handles OpenAI Chat Completions format (body.messages with role='tool').

lib/fetch-wrapper/openai-responses.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {
55
fetchSessionMessages,
66
getMostRecentActiveSession
77
} from "./types"
8-
import { cacheToolParametersFromInput } from "../tool-cache"
9-
import { injectNudgeResponses, injectSynthResponses } from "../synth-instruction"
8+
import { cacheToolParametersFromInput } from "../state/tool-cache"
9+
import { injectNudgeResponses, injectSynthResponses } from "../api-formats/synth-instruction"
1010

1111
/**
1212
* Handles OpenAI Responses API format (body.input array with function_call_output items).

lib/fetch-wrapper/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { type PluginState, ensureSessionRestored } from "../state"
22
import type { Logger } from "../logger"
3-
import type { ToolTracker } from "../synth-instruction"
3+
import type { ToolTracker } from "../api-formats/synth-instruction"
44
import type { PluginConfig } from "../config"
55

66
/** The message used to replace pruned tool output content */

0 commit comments

Comments
 (0)