-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplugin.ts
More file actions
41 lines (37 loc) · 1.21 KB
/
Copy pathplugin.ts
File metadata and controls
41 lines (37 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import type { Plugin } from "@opencode-ai/plugin"
import { createCaptureHooks } from "./plugin-hooks.js"
import { createSaveTrainingTool } from "./plugin-save-tool.js"
import { createDatasetEventHandler } from "./plugin-events.js"
import { PluginOptionsSchema, type DatasetPluginOptions, type DatasetSource } from "./schema.js"
import { resolveDatasetPath } from "./storage.js"
export type DatasetCaptureContext = {
readonly datasetPath: string
readonly options: DatasetPluginOptions
readonly source: DatasetSource
}
export const DatasetPlugin: Plugin = async ({ client, directory, project, worktree }, rawOptions) => {
const options = PluginOptionsSchema.parse(rawOptions ?? {})
const capture = {
datasetPath: resolveDatasetPath(directory, options.datasetPath),
options,
source: {
projectID: project.id,
directory,
worktree,
},
}
await client.app.log({
body: {
service: "opencode-dataset-plugin",
level: "info",
message: `dataset capture enabled at ${capture.datasetPath}`,
},
})
return {
tool: {
save_training_example: createSaveTrainingTool(capture),
},
...createCaptureHooks(capture),
event: createDatasetEventHandler(capture),
}
}