@xonovex/agent-cli-go 0.1.0 → 0.1.3

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/bin.js ADDED
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env node
2
+ import { spawn } from "node:child_process";
3
+ import { arch, platform } from "node:os";
4
+ import { dirname, join } from "node:path";
5
+ import { existsSync } from "node:fs";
6
+ import { createRequire } from "node:module";
7
+ const require = createRequire(import.meta.url);
8
+ const getPlatformPackage = () => {
9
+ const os = platform();
10
+ const cpu = arch();
11
+ const map = {
12
+ "darwin-arm64": "@xonovex/agent-cli-go-darwin-arm64",
13
+ "darwin-x64": "@xonovex/agent-cli-go-darwin-x64",
14
+ "linux-arm64": "@xonovex/agent-cli-go-linux-arm64",
15
+ "linux-x64": "@xonovex/agent-cli-go-linux-x64",
16
+ "win32-x64": "@xonovex/agent-cli-go-win32-x64",
17
+ };
18
+ return map[`${os}-${cpu}`];
19
+ };
20
+ const findBinary = () => {
21
+ const packageName = getPlatformPackage();
22
+ if (!packageName) {
23
+ console.error(`No binary available for ${platform()}-${arch()}`);
24
+ process.exit(1);
25
+ }
26
+ const binaryName = platform() === "win32" ? "agent-cli-go.exe" : "agent-cli-go";
27
+ try {
28
+ const packageJsonPath = require.resolve(`${packageName}/package.json`);
29
+ const binaryPath = join(dirname(packageJsonPath), "bin", binaryName);
30
+ if (existsSync(binaryPath)) {
31
+ return binaryPath;
32
+ }
33
+ }
34
+ catch {
35
+ // Package not found
36
+ }
37
+ console.error(`Binary not found. Install with: npm install -g @xonovex/agent-cli-go`);
38
+ process.exit(1);
39
+ };
40
+ const main = () => {
41
+ const binaryPath = findBinary();
42
+ const child = spawn(binaryPath, process.argv.slice(2), {
43
+ stdio: "inherit",
44
+ env: process.env,
45
+ });
46
+ child.on("error", (err) => {
47
+ console.error(`Failed to start: ${err.message}`);
48
+ process.exit(1);
49
+ });
50
+ child.on("close", (code) => {
51
+ process.exit(code ??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"description": "Agent wrapper CLI (Go implementation)",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -19,24 +19,26 @@
19
19
  "registry": "https://registry.npmjs.org/"
20
20
  },
21
21
  "files": [
22
- "bin",
23
- "dist/postinstall.js"
22
+ "dist/bin.js",
23
+ "dist/bin.js.map"
24
24
  ],
25
25
  "bin": {
26
- "agent-cli-go": "./bin/agent-cli-go"
26
+ "agent-cli-go": "./dist/bin.js"
27
27
  },
28
28
  "scripts": {
29
- "build": "go build -o dist/agent-cli ./cmd/agent-cli && tsc -p tsconfig.postinstall.json",
30
- "typecheck": "tsc -p tsconfig.postinstall.json --noEmit",
31
- "lint": "go vet ./... && golangci-lint run",
32
- "test": "go test ./...",
33
- "postinstall": "node -e \"try{require('./dist/postinstall.js')}catch{}\""
29
+ "build": "tsc && go build -o dist/agent-cli ./cmd/agent-cli",
30
+ "typecheck": "tsc --noEmit",
31
+ "lint": "eslint . && go vet ./... && golangci-lint run",
32
+ "test": "go test ./..."
33
+ },
34
+ "devDependencies": {
35
+ "@xonovex/ts-config-cli": "0.1.3"
34
36
  },
35
37
  "optionalDependencies": {
36
- "@xonovex/agent-cli-go-linux-x64": "0.1.0",
37
- "@xonovex/agent-cli-go-linux-arm64": "0.1.0",
38
- "@xonovex/agent-cli-go-darwin-x64": "0.1.0",
39
- "@xonovex/agent-cli-go-darwin-arm64": "0.1.0",
40
- "@xonovex/agent-cli-go-win32-x64": "0.1.0"
38
+ "@xonovex/agent-cli-go-linux-x64": "0.1.3",
39
+ "@xonovex/agent-cli-go-linux-arm64": "0.1.3",
40
+ "@xonovex/agent-cli-go-darwin-x64": "0.1.3",
41
+ "@xonovex/agent-cli-go-darwin-arm64": "0.1.3",
42
+ "@xonovex/agent-cli-go-win32-x64": "0.1.3"
41
43
  }
42
44
  }
@@ -1,80 +0,0 @@
1
- import { createRequire } from "node:module";
2
- import { arch, platform } from "node:os";
3
- import { dirname, join } from "node:path";
4
- import { existsSync, mkdirSync, symlinkSync, unlinkSync } from "node:fs";
5
- const require = createRequire(import.meta.url);
6
- const getPlatformConfig = () => {
7
- const os = platform();
8
- const cpu = arch();
9
- const platformMap = {
10
- darwin: {
11
- arm64: "@xonovex/agent-cli-go-darwin-arm64",
12
- x64: "@xonovex/agent-cli-go-darwin-x64",
13
- },
14
- linux: {
15
- arm64: "@xonovex/agent-cli-go-linux-arm64",
16
- x64: "@xonovex/agent-cli-go-linux-x64",
17
- },
18
- win32: {
19
- arm64: undefined,
20
- x64: "@xonovex/agent-cli-go-win32-x64",
21
- },
22
- };
23
- const packageName = platformMap[os]?.[cpu];
24
- if (!packageName) {
25
- return undefined;
26
- }
27
- const binaryName = os === "win32" ? "agent-cli-go.exe" : "agent-cli-go";
28
- return { packageName, binaryName };
29
- };
30
- const resolveBinaryPath = (packageName, binaryName) => {
31
- try {
32
- const packageJsonPath = require.resolve(`${packageName}/package.json`);
33
- const packageDir = dirname(packageJsonPath);
34
- const binaryPath = join(packageDir, "bin", binaryName);
35
- if (existsSync(binaryPath)) {
36
- return binaryPath;
37
- }
38
- return undefined;
39
- }
40
- catch {
41
- return undefined;
42
- }
43
- };
44
- const createSymlink = (sourcePath, targetPath) => {
45
- const targetDir = dirname(targetPath);
46
- if (!existsSync(targetDir)) {
47
- mkdirSync(targetDir, { recursive: true });
48
- }
49
- if (existsSync(targetPath)) {
50
- unlinkSync(targetPath);
51
- }
52
- symlinkSync(sourcePath, targetPath);
53
- };
54
- const main = () => {
55
- const config = getPlatformConfig();
56
- if (!config) {
57
- console.warn(`[agent-cli-go] No prebuilt binary available for ${platform()}-${arch()}. ` +
58
- "You may need to build from source.");
59
- process.exitCode = 0;
60
- return;
61
- }
62
- const binaryPath = resolveBinaryPath(config.packageName, config.binaryName);
63
- if (!binaryPath) {
64
- console.warn(`[agent-cli-go] Platform package ${config.packageName} not found. ` +
65
- "This is expected if the optional dependency was not installed.");
66
- process.exitCode = 0;
67
- return;
68
- }
69
- const packageRoot = dirname(dirname(new URL(import.meta.url).pathname));
70
- const targetPath = join(packageRoot, "bin", config.binaryName);
71
- try {
72
- createSymlink(binaryPath, targetPath);
73
- console.log(`[agent-cli-go] Linked binary: ${targetPath} -> ${binaryPath}`);
74
- }
75
- catch (error) {
76
- console.error(`[agent-cli-go] Failed to create symlink: ${error}`);
77
- process.exitCode = 1;
78
- }
79
- };
80
- main();