-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.ts
More file actions
55 lines (46 loc) · 1.69 KB
/
plugin.ts
File metadata and controls
55 lines (46 loc) · 1.69 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import type { Plugin } from "@opencode-ai/plugin";
import { install, getGlobalConfigPath, getPackageVersion, type Scope } from "./src/installer.ts";
import { join } from "node:path";
const plugin: Plugin = async ({ directory }) => ({
config: async () => {
const version = await getPackageVersion();
const globalConfigPath = getGlobalConfigPath();
const globalVersionMarker = join(globalConfigPath, "skills", "intellisearch", ".version");
const isGlobalInstall = directory === globalConfigPath ||
directory.startsWith(globalConfigPath + "/") ||
directory.startsWith(globalConfigPath + "\\");
let scope: Scope;
if (isGlobalInstall) {
scope = "global";
} else {
try {
const globalVersion = (await Bun.file(globalVersionMarker).text()).trim();
if (globalVersion === version) {
return;
}
} catch {
// Global not installed, proceed with local
}
scope = "local";
}
const marker = scope === "global"
? globalVersionMarker
: join(directory, ".opencode", "skills", "intellisearch", ".version");
try {
const installedVersion = (await Bun.file(marker).text()).trim();
if (installedVersion === version) {
return;
}
} catch {
// Not installed, proceed
}
const result = await install(scope, directory);
console.log(`\nOpenCode IntelliSearch installed ${scope === "global" ? "globally" : "locally"}:`);
console.log(` Skill: ${result.skillPath}`);
console.log(` Command: ${result.commandPath}`);
if (result.migrated) {
console.log(` Migrated: opencode.json → .opencode/opencode.json`);
}
},
});
export default plugin;