opencode-workaholic 0.2.0 → 0.2.1
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.
- package/dist/cli.js +74 -0
- package/package.json +5 -2
package/dist/cli.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
// @bun
|
|
3
|
+
|
|
4
|
+
// src/cli.ts
|
|
5
|
+
import { readFileSync, writeFileSync, existsSync } from "fs";
|
|
6
|
+
import { homedir } from "os";
|
|
7
|
+
import { join } from "path";
|
|
8
|
+
var OPENCODE_CONFIG_PATH = join(homedir(), ".config/opencode/opencode.json");
|
|
9
|
+
function getConfig() {
|
|
10
|
+
if (!existsSync(OPENCODE_CONFIG_PATH)) {
|
|
11
|
+
return { plugin: [] };
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
const content = readFileSync(OPENCODE_CONFIG_PATH, "utf-8");
|
|
15
|
+
return JSON.parse(content);
|
|
16
|
+
} catch {
|
|
17
|
+
return { plugin: [] };
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function saveConfig(config) {
|
|
21
|
+
writeFileSync(OPENCODE_CONFIG_PATH, JSON.stringify(config, null, 2) + `
|
|
22
|
+
`);
|
|
23
|
+
}
|
|
24
|
+
function addPlugin(pluginName) {
|
|
25
|
+
const config = getConfig();
|
|
26
|
+
if (!config.plugin) {
|
|
27
|
+
config.plugin = [];
|
|
28
|
+
}
|
|
29
|
+
if (!config.plugin.includes(pluginName)) {
|
|
30
|
+
config.plugin.push(pluginName);
|
|
31
|
+
saveConfig(config);
|
|
32
|
+
console.log(`\u2705 Added "${pluginName}" to plugins`);
|
|
33
|
+
} else {
|
|
34
|
+
console.log(`\u2139\uFE0F "${pluginName}" is already in plugins`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function removePlugin(pluginName) {
|
|
38
|
+
const config = getConfig();
|
|
39
|
+
if (config.plugin && config.plugin.includes(pluginName)) {
|
|
40
|
+
config.plugin = config.plugin.filter((p) => p !== pluginName);
|
|
41
|
+
saveConfig(config);
|
|
42
|
+
console.log(`\u2705 Removed "${pluginName}" from plugins`);
|
|
43
|
+
} else {
|
|
44
|
+
console.log(`\u2139\uFE0F "${pluginName}" is not in plugins`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
var args = process.argv.slice(2);
|
|
48
|
+
var command = args[0];
|
|
49
|
+
switch (command) {
|
|
50
|
+
case "install":
|
|
51
|
+
addPlugin("opencode-workaholic");
|
|
52
|
+
console.log(`
|
|
53
|
+
\uD83D\uDCCC Next steps:`);
|
|
54
|
+
console.log(" 1. Restart OpenCode");
|
|
55
|
+
console.log(" 2. Run: opencode -c");
|
|
56
|
+
console.log(" 3. Verify: workaholic.start, workaholic.status, workaholic.stop");
|
|
57
|
+
break;
|
|
58
|
+
case "uninstall":
|
|
59
|
+
removePlugin("opencode-workaholic");
|
|
60
|
+
console.log(`
|
|
61
|
+
\uD83D\uDCCC Restart OpenCode to apply changes`);
|
|
62
|
+
break;
|
|
63
|
+
default:
|
|
64
|
+
console.log(`
|
|
65
|
+
opencode-workaholic CLI
|
|
66
|
+
|
|
67
|
+
Usage:
|
|
68
|
+
opencode-workaholic install Add plugin to OpenCode config
|
|
69
|
+
opencode-workaholic uninstall Remove plugin from OpenCode config
|
|
70
|
+
|
|
71
|
+
Or use directly:
|
|
72
|
+
bunx opencode-workaholic@latest install
|
|
73
|
+
`);
|
|
74
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-workaholic",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Your OpenCode becomes a workaholic. Prevents AI from ending tasks prematurely.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Roderick Qiu",
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
"type": "module",
|
|
12
12
|
"main": "./dist/index.js",
|
|
13
13
|
"types": "./dist/index.d.ts",
|
|
14
|
+
"bin": {
|
|
15
|
+
"opencode-workaholic": "./dist/cli.js"
|
|
16
|
+
},
|
|
14
17
|
"exports": {
|
|
15
18
|
".": {
|
|
16
19
|
"types": "./dist/index.d.ts",
|
|
@@ -35,7 +38,7 @@
|
|
|
35
38
|
"scripts"
|
|
36
39
|
],
|
|
37
40
|
"scripts": {
|
|
38
|
-
"build": "bun build ./src/index.ts --outdir dist --target bun && cp -r src/command dist/ && cp -r scripts dist/"
|
|
41
|
+
"build": "bun build ./src/index.ts --outdir dist --target bun && bun build ./src/cli.ts --outdir dist --target bun && cp -r src/command dist/ && cp -r scripts dist/"
|
|
39
42
|
},
|
|
40
43
|
"dependencies": {
|
|
41
44
|
"@opencode-ai/plugin": "1.0.85",
|