opencode-context 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bun
2
+ export {};
3
+ //# sourceMappingURL=install.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":""}
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env bun
2
+ // @bun
3
+
4
+ // src/install.ts
5
+ import { promises as fs } from "fs";
6
+ import { join, dirname } from "path";
7
+ var CONFIG_PATH = join(process.env.HOME || "", ".config/opencode/opencode.json");
8
+ async function ensureConfigDir() {
9
+ const dir = dirname(CONFIG_PATH);
10
+ try {
11
+ await fs.access(dir);
12
+ } catch {
13
+ await fs.mkdir(dir, { recursive: true });
14
+ }
15
+ }
16
+ async function readConfig() {
17
+ try {
18
+ const content = await fs.readFile(CONFIG_PATH, "utf-8");
19
+ return JSON.parse(content);
20
+ } catch {
21
+ return { $schema: "https://opencode.ai/config.json", plugin: [] };
22
+ }
23
+ }
24
+ async function writeConfig(config) {
25
+ await fs.writeFile(CONFIG_PATH, JSON.stringify(config, null, 2) + `
26
+ `);
27
+ }
28
+ async function install() {
29
+ console.log(`Installing OpenContext plugin...
30
+ `);
31
+ await ensureConfigDir();
32
+ const config = await readConfig();
33
+ if (!config.plugin) {
34
+ config.plugin = [];
35
+ }
36
+ const pluginName = "opencode-context";
37
+ if (config.plugin.includes(pluginName)) {
38
+ console.log("\u2713 OpenContext already in plugins");
39
+ } else {
40
+ config.plugin.push(pluginName);
41
+ console.log("\u2713 Added opencontext to plugins");
42
+ }
43
+ await writeConfig(config);
44
+ console.log(`
45
+ \u2713 Installation complete!`);
46
+ console.log(`
47
+ To use:`);
48
+ console.log(" 1. Run opencode in your project");
49
+ console.log(' 2. Ask: "Find files related to auth"');
50
+ console.log(` 3. The agent will use find_files tool
51
+ `);
52
+ }
53
+ install().catch(console.error);
@@ -0,0 +1,4 @@
1
+ import { type Plugin } from "@opencode-ai/plugin";
2
+ declare const OpenContextPlugin: Plugin;
3
+ export default OpenContextPlugin;
4
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,qBAAqB,CAAC;AAaxD,QAAA,MAAM,iBAAiB,EAAE,MA0CxB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}