clikit-plugin 0.1.2 → 0.1.6

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.
Files changed (3) hide show
  1. package/README.md +12 -13
  2. package/dist/cli.js +108 -43
  3. package/package.json +4 -3
package/README.md CHANGED
@@ -16,22 +16,21 @@ Curated agents, commands, skills, and memory system for OpenCode.
16
16
 
17
17
  ## Installation
18
18
 
19
- ### Option 1: Via npm (Recommended)
20
-
21
19
  ```bash
22
- # In your project
23
- bun add -d clikit-plugin
20
+ # Install CliKit globally for OpenCode
21
+ bun x clikit-plugin install
24
22
 
25
- # Create .opencode/index.ts
26
- echo 'import CliKitPlugin from "clikit-plugin";
27
- export default CliKitPlugin;' > .opencode/index.ts
23
+ # Restart OpenCode
28
24
  ```
29
25
 
30
- ### Option 2: Direct Copy
26
+ That's it! The plugin will be registered in `~/.config/opencode/opencode.json`.
31
27
 
32
- ```bash
33
- # Copy the built plugin to OpenCode plugin directory
34
- cp dist/index.js ~/.config/opencode/plugin/clikit-plugin.js
28
+ ## Quick Start
29
+
30
+ After installation, use these commands:
31
+
32
+ ```
33
+ /create → /plan → /start → /verify → /ship
35
34
  ```
36
35
 
37
36
  ## Configuration
@@ -80,7 +79,7 @@ Project config overrides user config.
80
79
  "session_notification": { "enabled": true },
81
80
  "truncator": { "enabled": true },
82
81
  "compaction": { "enabled": true },
83
- "swarm_enforcer": { "enabled": false }
82
+ "swarm_enforcer": { "enabled": true }
84
83
  }
85
84
  }
86
85
  ```
@@ -112,7 +111,7 @@ Project config overrides user config.
112
111
  | `session_notification` | on | Desktop notifications on idle/error (Linux/macOS/Windows) |
113
112
  | `truncator` | on | Truncates large outputs to prevent context overflow |
114
113
  | `compaction` | on | Preserves beads state + memory during context compaction |
115
- | `swarm_enforcer` | **off** | Enforces task isolation in multi-agent swarms |
114
+ | `swarm_enforcer` | on | Enforces task isolation in multi-agent swarms |
116
115
 
117
116
  ## Agents
118
117
 
package/dist/cli.js CHANGED
@@ -4,73 +4,133 @@
4
4
  // src/cli.ts
5
5
  import * as fs from "fs";
6
6
  import * as path from "path";
7
- var VERSION = "0.1.0";
8
- function getCwd() {
9
- return process.cwd();
7
+ import * as os from "os";
8
+ var PLUGIN_NAME = "clikit-plugin";
9
+ var VERSION = "0.1.4";
10
+ function getConfigDir() {
11
+ if (process.platform === "win32") {
12
+ return path.join(process.env.APPDATA || path.join(os.homedir(), "AppData", "Roaming"), "opencode");
13
+ }
14
+ return path.join(process.env.XDG_CONFIG_HOME || path.join(os.homedir(), ".config"), "opencode");
10
15
  }
11
- async function install() {
12
- const cwd = getCwd();
13
- const opencodeDir = path.join(cwd, ".opencode");
14
- console.log(`\uD83D\uDE80 Installing CliKit...
15
- `);
16
- if (!fs.existsSync(opencodeDir)) {
17
- fs.mkdirSync(opencodeDir, { recursive: true });
18
- console.log("\u2705 Created .opencode directory");
16
+ function getConfigPath() {
17
+ const configDir = getConfigDir();
18
+ const jsonPath = path.join(configDir, "opencode.json");
19
+ const jsoncPath = path.join(configDir, "opencode.jsonc");
20
+ if (fs.existsSync(jsonPath))
21
+ return jsonPath;
22
+ if (fs.existsSync(jsoncPath))
23
+ return jsoncPath;
24
+ return jsonPath;
25
+ }
26
+ function ensureConfigDir() {
27
+ const configDir = getConfigDir();
28
+ if (!fs.existsSync(configDir)) {
29
+ fs.mkdirSync(configDir, { recursive: true });
30
+ }
31
+ }
32
+ function parseConfig(configPath) {
33
+ try {
34
+ if (!fs.existsSync(configPath)) {
35
+ return {};
36
+ }
37
+ const content = fs.readFileSync(configPath, "utf-8");
38
+ const cleaned = content.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
39
+ return JSON.parse(cleaned);
40
+ } catch {
41
+ return {};
19
42
  }
20
- const indexPath = path.join(opencodeDir, "index.ts");
21
- if (!fs.existsSync(indexPath)) {
22
- fs.writeFileSync(indexPath, `import CliKitPlugin from "clikit-plugin";
23
- export default CliKitPlugin;
43
+ }
44
+ function writeConfig(configPath, config) {
45
+ ensureConfigDir();
46
+ const tmpPath = `${configPath}.tmp`;
47
+ const content = JSON.stringify(config, null, 2) + `
48
+ `;
49
+ fs.writeFileSync(tmpPath, content);
50
+ fs.renameSync(tmpPath, configPath);
51
+ }
52
+ async function install() {
53
+ console.log(`
54
+ CliKit Installer
55
+ ================
24
56
  `);
25
- console.log("\u2705 Created .opencode/index.ts");
26
- } else {
27
- console.log("\u2139\uFE0F .opencode/index.ts already exists");
57
+ console.log("[1/3] Adding CliKit plugin to OpenCode config...");
58
+ try {
59
+ ensureConfigDir();
60
+ } catch (err) {
61
+ console.error(`\u2717 Failed to create config directory: ${err}`);
62
+ return 1;
28
63
  }
29
- const configPath = path.join(opencodeDir, "clikit.config.json");
30
- if (!fs.existsSync(configPath)) {
31
- fs.writeFileSync(configPath, JSON.stringify({
32
- $schema: "https://unpkg.com/clikit-plugin/schema.json",
33
- disabled_agents: [],
34
- disabled_commands: [],
35
- agents: {},
36
- hooks: {}
37
- }, null, 2));
38
- console.log("\u2705 Created .opencode/clikit.config.json");
39
- } else {
40
- console.log("\u2139\uFE0F .opencode/clikit.config.json already exists");
64
+ const configPath = getConfigPath();
65
+ try {
66
+ const config = parseConfig(configPath) || {};
67
+ const plugins = config.plugin || [];
68
+ const filteredPlugins = plugins.filter((p) => p !== PLUGIN_NAME && !p.startsWith(`${PLUGIN_NAME}@`));
69
+ filteredPlugins.push(PLUGIN_NAME);
70
+ config.plugin = filteredPlugins;
71
+ writeConfig(configPath, config);
72
+ console.log(`\u2713 Plugin added to ${configPath}`);
73
+ } catch (err) {
74
+ console.error(`\u2717 Failed to update OpenCode config: ${err}`);
75
+ return 1;
41
76
  }
42
- const memoryDir = path.join(opencodeDir, "memory");
77
+ console.log(`
78
+ [2/3] Creating memory directories...`);
79
+ const memoryDir = path.join(getConfigDir(), "memory");
43
80
  const memorySubdirs = ["specs", "plans", "research", "reviews", "handoffs", "beads", "prds"];
44
81
  for (const subdir of memorySubdirs) {
45
82
  const dir = path.join(memoryDir, subdir);
46
83
  if (!fs.existsSync(dir)) {
47
84
  fs.mkdirSync(dir, { recursive: true });
48
- console.log(`\u2705 Created .opencode/memory/${subdir}/`);
49
85
  }
50
86
  }
87
+ console.log(`\u2713 Memory directories created in ${memoryDir}`);
51
88
  console.log(`
52
- \u2705 CliKit installed successfully!`);
89
+ [3/3] Creating CliKit config...`);
90
+ const clikitConfigPath = path.join(getConfigDir(), "clikit.config.json");
91
+ if (!fs.existsSync(clikitConfigPath)) {
92
+ const defaultConfig = {
93
+ $schema: `https://unpkg.com/${PLUGIN_NAME}@latest/schema.json`,
94
+ disabled_agents: [],
95
+ disabled_commands: [],
96
+ agents: {},
97
+ hooks: {}
98
+ };
99
+ writeConfig(clikitConfigPath, defaultConfig);
100
+ console.log(`\u2713 Config created at ${clikitConfigPath}`);
101
+ } else {
102
+ console.log(`\u2713 Config already exists at ${clikitConfigPath}`);
103
+ }
53
104
  console.log(`
54
- Next steps:`);
55
- console.log(" 1. Run: bun add -d clikit-plugin");
56
- console.log(" 2. Restart OpenCode");
105
+ \u2713 CliKit installed successfully!
106
+ `);
107
+ console.log("Available commands:");
108
+ console.log(" /create - Start new task with specification");
109
+ console.log(" /start - Begin implementing from plan");
110
+ console.log(" /plan - Create implementation plan");
111
+ console.log(" /verify - Run verification suite");
112
+ console.log(" /ship - Commit, PR, and cleanup");
113
+ console.log(" /review - Request code review");
114
+ console.log(" /debug - Debug issues");
57
115
  console.log(`
58
- Available commands: /create, /start, /plan, /ship, /verify, /review, /debug, /pr`);
116
+ Restart OpenCode to use CliKit.
117
+ `);
118
+ return 0;
59
119
  }
60
120
  function help() {
61
121
  console.log(`
62
122
  CliKit - OpenCode Plugin
63
123
 
64
124
  Usage:
65
- clikit <command>
125
+ bun x clikit-plugin <command>
66
126
 
67
127
  Commands:
68
- install Install CliKit in current project
128
+ install Install CliKit globally for OpenCode
69
129
  help Show this help message
70
130
  version Show version
71
131
 
72
132
  Examples:
73
- bunx clikit install
133
+ bun x clikit-plugin install
74
134
  `);
75
135
  }
76
136
  function version() {
@@ -79,10 +139,11 @@ function version() {
79
139
  async function main() {
80
140
  const args = process.argv.slice(2);
81
141
  const command = args[0] || "help";
142
+ let exitCode = 0;
82
143
  switch (command) {
83
144
  case "install":
84
145
  case "i":
85
- await install();
146
+ exitCode = await install();
86
147
  break;
87
148
  case "help":
88
149
  case "-h":
@@ -97,7 +158,11 @@ async function main() {
97
158
  default:
98
159
  console.error(`Unknown command: ${command}`);
99
160
  help();
100
- process.exit(1);
161
+ exitCode = 1;
101
162
  }
163
+ process.exit(exitCode);
102
164
  }
103
- main().catch(console.error);
165
+ main().catch((err) => {
166
+ console.error(err);
167
+ process.exit(1);
168
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clikit-plugin",
3
- "version": "0.1.2",
3
+ "version": "0.1.6",
4
4
  "description": "OpenCode plugin with 10 agents, 19 commands, 48 skills, 14 hooks",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -21,7 +21,8 @@
21
21
  "skill",
22
22
  "command",
23
23
  "memory",
24
- "AGENTS.md"
24
+ "AGENTS.md",
25
+ "README.md"
25
26
  ],
26
27
  "scripts": {
27
28
  "build": "bun build src/index.ts src/cli.ts --outdir dist --target bun --format esm && tsc --emitDeclarationOnly && cp src/clikit.schema.json dist/",
@@ -51,7 +52,7 @@
51
52
  },
52
53
  "homepage": "https://github.com/KiraKas-Tr/CliKit#readme",
53
54
  "dependencies": {
54
- "@opencode-ai/plugin": "1.1.64",
55
+ "@opencode-ai/plugin": "1.2.1",
55
56
  "gray-matter": "^4.0.3"
56
57
  },
57
58
  "devDependencies": {