opencode-orchestrator 0.4.0 → 0.4.7

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.
@@ -2,31 +2,37 @@
2
2
 
3
3
  // scripts/postinstall.ts
4
4
  import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
5
- import { join, dirname } from "path";
5
+ import { join } from "path";
6
6
  import { homedir } from "os";
7
- import { fileURLToPath } from "url";
8
- var CONFIG_DIR = join(homedir(), ".config", "opencode");
9
- var CONFIG_FILE = join(CONFIG_DIR, "opencode.json");
10
- var PLUGIN_NAME = "opencode-orchestrator";
11
- function getPluginPath() {
12
- try {
13
- let currentDir = dirname(fileURLToPath(import.meta.url));
14
- while (true) {
15
- if (existsSync(join(currentDir, "package.json"))) {
16
- return currentDir;
17
- }
18
- const parentDir = dirname(currentDir);
19
- if (parentDir === currentDir) {
20
- break;
21
- }
22
- currentDir = parentDir;
7
+ function formatError(err, context) {
8
+ if (err instanceof Error) {
9
+ const nodeErr = err;
10
+ if (nodeErr.code === "EACCES" || nodeErr.code === "EPERM") {
11
+ return `Permission denied: Cannot ${context}. Try running as administrator.`;
12
+ }
13
+ if (nodeErr.code === "ENOENT") {
14
+ return `File not found while trying to ${context}.`;
15
+ }
16
+ if (err instanceof SyntaxError) {
17
+ return `JSON syntax error while trying to ${context}: ${err.message}.`;
18
+ }
19
+ if (nodeErr.code === "EIO") {
20
+ return `File lock error: Cannot ${context}. Please close OpenCode and try again.`;
23
21
  }
24
- return PLUGIN_NAME;
25
- } catch {
26
- return PLUGIN_NAME;
22
+ if (nodeErr.code === "ENOSPC") {
23
+ return `Disk full: Cannot ${context}. Free up disk space and try again.`;
24
+ }
25
+ if (nodeErr.code === "EROFS") {
26
+ return `Read-only filesystem: Cannot ${context}.`;
27
+ }
28
+ return `Failed to ${context}: ${err.message}`;
27
29
  }
30
+ return `Failed to ${context}: ${String(err)}`;
28
31
  }
29
- function install() {
32
+ var CONFIG_DIR = process.env.XDG_CONFIG_HOME ? join(process.env.XDG_CONFIG_HOME, "opencode") : process.platform === "win32" ? join(process.env.APPDATA || join(homedir(), "AppData", "Roaming"), "opencode") : join(homedir(), ".config", "opencode");
33
+ var CONFIG_FILE = join(CONFIG_DIR, "opencode.json");
34
+ var PLUGIN_NAME = "opencode-orchestrator";
35
+ try {
30
36
  console.log("\u{1F3AF} OpenCode Orchestrator - Installing...");
31
37
  if (!existsSync(CONFIG_DIR)) {
32
38
  mkdirSync(CONFIG_DIR, { recursive: true });
@@ -42,24 +48,19 @@ function install() {
42
48
  if (!config.plugin) {
43
49
  config.plugin = [];
44
50
  }
45
- const pluginPath = getPluginPath();
46
- const hasPlugin = config.plugin.some(
47
- (p) => p === PLUGIN_NAME || p === pluginPath || p.includes("opencode-orchestrator")
48
- );
51
+ const hasPlugin = config.plugin.some((p) => p.includes(PLUGIN_NAME));
49
52
  if (!hasPlugin) {
50
- config.plugin.push(pluginPath);
51
- writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
53
+ config.plugin.push(PLUGIN_NAME);
54
+ writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2) + "\n");
52
55
  console.log("\u2705 Plugin registered!");
53
- console.log(` Path: ${pluginPath}`);
56
+ console.log(` Name: ${PLUGIN_NAME}`);
54
57
  } else {
55
58
  console.log("\u2705 Plugin already registered.");
56
59
  }
57
60
  console.log("");
58
61
  console.log("\u{1F680} Ready! Restart OpenCode to use.");
59
62
  console.log("");
60
- console.log("Usage:");
61
- console.log(" Select 'Commander' agent or use /task command");
62
- console.log(" Commander runs until mission complete.");
63
- console.log("");
63
+ } catch (error) {
64
+ console.error(formatError(error, "register plugin"));
65
+ process.exit(0);
64
66
  }
65
- install();
@@ -4,34 +4,54 @@
4
4
  import { existsSync, readFileSync, writeFileSync } from "fs";
5
5
  import { join } from "path";
6
6
  import { homedir } from "os";
7
- var CONFIG_DIR = join(homedir(), ".config", "opencode");
7
+ function formatError(err, context) {
8
+ if (err instanceof Error) {
9
+ const nodeErr = err;
10
+ if (nodeErr.code === "EACCES" || nodeErr.code === "EPERM") {
11
+ return `Permission denied: Cannot ${context}. Try running as administrator.`;
12
+ }
13
+ if (nodeErr.code === "ENOENT") {
14
+ return `File not found while trying to ${context}.`;
15
+ }
16
+ if (err instanceof SyntaxError) {
17
+ return `JSON syntax error while trying to ${context}: ${err.message}.`;
18
+ }
19
+ if (nodeErr.code === "EIO") {
20
+ return `File lock error: Cannot ${context}. Please close OpenCode and try again.`;
21
+ }
22
+ if (nodeErr.code === "ENOSPC") {
23
+ return `Disk full: Cannot ${context}. Free up disk space and try again.`;
24
+ }
25
+ if (nodeErr.code === "EROFS") {
26
+ return `Read-only filesystem: Cannot ${context}.`;
27
+ }
28
+ return `Failed to ${context}: ${err.message}`;
29
+ }
30
+ return `Failed to ${context}: ${String(err)}`;
31
+ }
32
+ var CONFIG_DIR = process.env.XDG_CONFIG_HOME ? join(process.env.XDG_CONFIG_HOME, "opencode") : process.platform === "win32" ? join(process.env.APPDATA || join(homedir(), "AppData", "Roaming"), "opencode") : join(homedir(), ".config", "opencode");
8
33
  var CONFIG_FILE = join(CONFIG_DIR, "opencode.json");
9
- function uninstall() {
34
+ var PLUGIN_NAME = "opencode-orchestrator";
35
+ try {
10
36
  console.log("\u{1F9F9} OpenCode Orchestrator - Uninstalling...");
11
37
  if (!existsSync(CONFIG_FILE)) {
12
38
  console.log("\u2705 No config file found. Nothing to clean up.");
13
- return;
39
+ process.exit(0);
14
40
  }
15
- try {
16
- const config = JSON.parse(readFileSync(CONFIG_FILE, "utf-8"));
17
- if (!config.plugin || !Array.isArray(config.plugin)) {
18
- console.log("\u2705 No plugins registered. Nothing to clean up.");
19
- return;
20
- }
21
- const originalLength = config.plugin.length;
22
- config.plugin = config.plugin.filter(
23
- (p) => !p.includes("opencode-orchestrator")
24
- );
25
- if (config.plugin.length < originalLength) {
26
- writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
27
- console.log("\u2705 Plugin removed from OpenCode config.");
28
- } else {
29
- console.log("\u2705 Plugin was not registered. Nothing to clean up.");
30
- }
31
- } catch (error) {
32
- console.error("\u26A0\uFE0F Could not clean up config:", error);
41
+ const config = JSON.parse(readFileSync(CONFIG_FILE, "utf-8"));
42
+ if (!config.plugin || !Array.isArray(config.plugin)) {
43
+ console.log("\u2705 No plugins registered. Nothing to clean up.");
44
+ process.exit(0);
45
+ }
46
+ const originalLength = config.plugin.length;
47
+ config.plugin = config.plugin.filter((p) => !p.includes(PLUGIN_NAME));
48
+ if (config.plugin.length < originalLength) {
49
+ writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2) + "\n");
50
+ console.log("\u2705 Plugin removed from OpenCode config.");
51
+ } else {
52
+ console.log("\u2705 Plugin was not registered. Nothing to clean up.");
33
53
  }
34
- console.log("");
35
- console.log("Restart OpenCode to complete uninstallation.");
54
+ } catch (error) {
55
+ console.error(formatError(error, "clean up config"));
56
+ process.exit(0);
36
57
  }
37
- uninstall();
@@ -5,4 +5,4 @@ export declare const AGENT_NAMES: {
5
5
  readonly INSPECTOR: "inspector";
6
6
  readonly RECORDER: "recorder";
7
7
  };
8
- export type AgentName = typeof AGENT_NAMES[keyof typeof AGENT_NAMES];
8
+ export type AgentName = (typeof AGENT_NAMES)[keyof typeof AGENT_NAMES];
@@ -34,14 +34,14 @@ export declare const listBackgroundTool: {
34
34
  description: string;
35
35
  args: {
36
36
  status: import("zod").ZodOptional<import("zod").ZodEnum<{
37
- error: "error";
38
37
  running: "running";
39
38
  done: "done";
39
+ error: "error";
40
40
  all: "all";
41
41
  }>>;
42
42
  };
43
43
  execute(args: {
44
- status?: "error" | "running" | "done" | "all" | undefined;
44
+ status?: "running" | "done" | "error" | "all" | undefined;
45
45
  }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
46
46
  };
47
47
  export declare const killBackgroundTool: {
package/package.json CHANGED
@@ -1,76 +1,64 @@
1
1
  {
2
- "name": "opencode-orchestrator",
3
- "displayName": "OpenCode Orchestrator",
4
- "description": "Distributed Cognitive Architecture for OpenCode. Turns simple prompts into specialized multi-agent workflows (Planner, Coder, Reviewer).",
5
- "version": "0.4.0",
6
- "author": "agnusdei1207",
7
- "license": "MIT",
8
- "repository": {
9
- "type": "git",
10
- "url": "git+https://github.com/agnusdei1207/opencode-orchestrator.git"
11
- },
12
- "homepage": "https://github.com/agnusdei1207/opencode-orchestrator#readme",
13
- "bugs": {
14
- "url": "https://github.com/agnusdei1207/opencode-orchestrator/issues"
15
- },
16
- "keywords": [
17
- "opencode",
18
- "ai",
19
- "agent",
20
- "orchestrator",
21
- "multi-agent",
22
- "llm",
23
- "plugin",
24
- "code-generation"
25
- ],
26
- "bin": {
27
- "orchestrator": "dist/cli.js"
28
- },
29
- "main": "dist/index.js",
30
- "types": "dist/index.d.ts",
31
- "type": "module",
32
- "exports": {
33
- ".": {
34
- "types": "./dist/index.d.ts",
35
- "import": "./dist/index.js"
36
- }
37
- },
38
- "files": [
39
- "dist",
40
- "bin",
41
- "README.md",
42
- "LICENSE"
43
- ],
44
- "scripts": {
45
- "build:bin:linux-x64": "docker compose run --rm dev sh -c 'cargo build --release && cp target/release/orchestrator bin/orchestrator-linux-x64' && chmod +x bin/orchestrator-linux-x64",
46
- "build:bin:linux-arm64": "docker compose run --rm dev sh -c 'rustup target add aarch64-unknown-linux-gnu && apt-get update && apt-get install -y gcc-aarch64-linux-gnu && CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc cargo build --release --target aarch64-unknown-linux-gnu && cp target/aarch64-unknown-linux-gnu/release/orchestrator bin/orchestrator-linux-arm64' && chmod +x bin/orchestrator-linux-arm64",
47
- "build:bin": "npm run build:bin:linux-x64 && npm run build:bin:linux-arm64",
48
- "build:js": "npx esbuild src/index.ts --bundle --outfile=dist/index.js --platform=node --format=esm --packages=external && npx esbuild src/cli.ts --bundle --outfile=dist/cli.js --platform=node --format=esm --packages=external && tsc --emitDeclarationOnly && mkdir -p dist/scripts && npx esbuild scripts/postinstall.ts --bundle --outfile=dist/scripts/postinstall.js --platform=node --format=esm --packages=external && npx esbuild scripts/preuninstall.ts --bundle --outfile=dist/scripts/preuninstall.js --platform=node --format=esm --packages=external",
49
- "build": "npm run build:bin && npm run build:js",
50
- "test": "docker compose run --rm test",
51
- "release:ship": "npm publish --access public && git add -A && git commit -m \"v$(node -p \"require('./package.json').version\")\" && git tag \"v$(node -p \"require('./package.json').version\")\" && git push && git push --tags",
52
- "release:patch": "npm run build && npm run test && npm version patch --no-git-tag-version && npm run release:ship",
53
- "release:minor": "npm run build && npm run test && npm version minor --no-git-tag-version && npm run release:ship",
54
- "release:major": "npm run build && npm run test && npm version major --no-git-tag-version && npm run release:ship",
55
- "postinstall": "node dist/scripts/postinstall.js 2>/dev/null || true",
56
- "preuninstall": "node dist/scripts/preuninstall.js 2>/dev/null || true",
57
- "prepublishOnly": "npm run build:js",
58
- "dev:install": "npm run build:js && npm uninstall -g opencode-orchestrator >/dev/null 2>&1 || true && npm install -g . && echo '✅ Installed globally'",
59
- "dev:uninstall": "npm unlink -g opencode-orchestrator >/dev/null 2>&1 || true && npm uninstall -g opencode-orchestrator >/dev/null 2>&1 || true && rm -rf $(npm root -g)/opencode-orchestrator && echo '✅ Forcefully Uninstalled'",
60
- "dev:link": "npm run build:js && npm unlink -g opencode-orchestrator >/dev/null 2>&1 || true && npm unlink >/dev/null 2>&1 || true && rm -rf $(npm root -g)/opencode-orchestrator && npm link && echo '✅ Re-linked. Restart OpenCode.'",
61
- "dev:unlink": "npm unlink -g opencode-orchestrator >/dev/null 2>&1 || true && npm unlink >/dev/null 2>&1 || true && rm -rf $(npm root -g)/opencode-orchestrator && echo '✅ Unlinked and Cleaned'",
62
- "dev:reload": "npm run dev:link",
63
- "dev:build": "npm run build:js && echo '✅ Built (no link change)'",
64
- "dev:status": "echo '=== Global Link Status ===' && ls -l $(npm root -g)/opencode-orchestrator 2>/dev/null || echo 'Not found'",
65
- "util:stars": "gh api repos/agnusdei1207/opencode-orchestrator/stargazers --jq '.[].login'"
66
- },
67
- "dependencies": {
68
- "@opencode-ai/plugin": "^1.1.1",
69
- "@opencode-ai/sdk": "^1.1.14"
70
- },
71
- "devDependencies": {
72
- "@types/node": "^22.0.0",
73
- "esbuild": "^0.24.0",
74
- "typescript": "^5.7.0"
2
+ "name": "opencode-orchestrator",
3
+ "displayName": "OpenCode Orchestrator",
4
+ "description": "Distributed Cognitive Architecture for OpenCode. Turns simple prompts into specialized multi-agent workflows (Planner, Coder, Reviewer).",
5
+ "version": "0.4.7",
6
+ "author": "agnusdei1207",
7
+ "license": "MIT",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/agnusdei1207/opencode-orchestrator.git"
11
+ },
12
+ "homepage": "https://github.com/agnusdei1207/opencode-orchestrator#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/agnusdei1207/opencode-orchestrator/issues"
15
+ },
16
+ "keywords": [
17
+ "opencode",
18
+ "ai",
19
+ "agent",
20
+ "orchestrator",
21
+ "multi-agent",
22
+ "llm",
23
+ "plugin",
24
+ "code-generation"
25
+ ],
26
+ "main": "dist/index.js",
27
+ "types": "dist/index.d.ts",
28
+ "type": "module",
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/index.d.ts",
32
+ "import": "./dist/index.js"
75
33
  }
34
+ },
35
+ "files": [
36
+ "dist",
37
+ "README.md",
38
+ "LICENSE"
39
+ ],
40
+ "scripts": {
41
+ "build": "npx esbuild src/index.ts --bundle --outfile=dist/index.js --platform=node --format=esm && tsc --emitDeclarationOnly && shx mkdir -p dist/scripts && npx esbuild scripts/postinstall.ts --bundle --outfile=dist/scripts/postinstall.js --platform=node --format=esm && npx esbuild scripts/preuninstall.ts --bundle --outfile=dist/scripts/preuninstall.js --platform=node --format=esm",
42
+ "postinstall": "node dist/scripts/postinstall.js",
43
+ "preuninstall": "node dist/scripts/preuninstall.js",
44
+ "prepublishOnly": "npm run build",
45
+ "release:ship": "npm publish --access public && git add -A && git commit -m \"chore(release): v$(node -p \\\"require('./package.json').version\\\")\" && git tag -a \"v$(node -p \\\"require('./package.json').version\\\")\" -m \"v$(node -p \\\"require('./package.json').version\\\")\" && git push --follow-tags",
46
+ "release:patch": "npm run build && npm version patch && npm run release:ship",
47
+ "release:minor": "npm run build && npm version minor && npm run release:ship",
48
+ "release:major": "npm run build && npm version major && npm run release:ship",
49
+ "dev:link": "npm run build && npm unlink opencode-orchestrator || shx echo 'Not linked' && shx rm -rf $(npm root -g)/opencode-orchestrator && npm link && echo 'SUCCESS: Re-linked. Restart OpenCode.'",
50
+ "dev:unlink": "npm unlink opencode-orchestrator || shx echo 'Not linked' && shx rm -rf $(npm root -g)/opencode-orchestrator && echo 'SUCCESS: Unlinked and Cleaned'",
51
+ "dev:status": "echo '=== Global Link Status ===' && shx ls -l $(npm root -g)/opencode-orchestrator || echo 'Not linked'",
52
+ "dev:test": "node dist/scripts/postinstall.js && echo '---' && node dist/scripts/preuninstall.js"
53
+ },
54
+ "dependencies": {
55
+ "@opencode-ai/plugin": "^1.1.1",
56
+ "@opencode-ai/sdk": "^1.1.14"
57
+ },
58
+ "devDependencies": {
59
+ "@types/node": "^22.0.0",
60
+ "esbuild": "^0.24.0",
61
+ "shx": "^0.4.0",
62
+ "typescript": "^5.7.0"
63
+ }
76
64
  }
package/bin/orchestrator DELETED
Binary file
Binary file
Binary file
Binary file
package/dist/cli.js DELETED
@@ -1,48 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/cli.ts
4
- import { spawn } from "child_process";
5
- import { existsSync as existsSync2 } from "fs";
6
- import { platform as platform2, arch as arch2 } from "os";
7
-
8
- // src/utils/binary.ts
9
- import { join, dirname } from "path";
10
- import { fileURLToPath } from "url";
11
- import { platform, arch } from "os";
12
- import { existsSync } from "fs";
13
- var __dirname = dirname(fileURLToPath(import.meta.url));
14
- function getBinaryPath() {
15
- const binDir = join(__dirname, "..", "..", "bin");
16
- const os = platform();
17
- const cpu = arch();
18
- let binaryName;
19
- if (os === "win32") {
20
- binaryName = "orchestrator-windows-x64.exe";
21
- } else if (os === "darwin") {
22
- binaryName = cpu === "arm64" ? "orchestrator-macos-arm64" : "orchestrator-macos-x64";
23
- } else {
24
- binaryName = cpu === "arm64" ? "orchestrator-linux-arm64" : "orchestrator-linux-x64";
25
- }
26
- let binaryPath = join(binDir, binaryName);
27
- if (!existsSync(binaryPath)) {
28
- binaryPath = join(binDir, os === "win32" ? "orchestrator.exe" : "orchestrator");
29
- }
30
- return binaryPath;
31
- }
32
-
33
- // src/cli.ts
34
- var binary = getBinaryPath();
35
- var args = process.argv.slice(2);
36
- if (!existsSync2(binary)) {
37
- console.error(`Error: Orchestrator binary not found for your platform (${platform2()} ${arch2()})`);
38
- console.error(`Expected at: ${binary}`);
39
- process.exit(1);
40
- }
41
- var child = spawn(binary, args, { stdio: "inherit" });
42
- child.on("close", (code) => {
43
- process.exit(code || 0);
44
- });
45
- child.on("error", (err) => {
46
- console.error("Failed to start orchestrator binary:", err);
47
- process.exit(1);
48
- });