@xonovex/agent-cli-go 0.1.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.
- package/README.md +98 -0
- package/dist/postinstall.js +80 -0
- package/package.json +42 -0
package/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# tool-agent-cli-go
|
|
2
|
+
|
|
3
|
+
Unified CLI for running AI coding agents with multiple model providers and sandbox options. Go implementation.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
go build -o agent-cli ./cmd/agent-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Run with default agent (Claude)
|
|
15
|
+
./agent-cli run
|
|
16
|
+
|
|
17
|
+
# Run with specific agent
|
|
18
|
+
./agent-cli run -a claude
|
|
19
|
+
./agent-cli run -a opencode
|
|
20
|
+
|
|
21
|
+
# Run with sandbox
|
|
22
|
+
./agent-cli run -s bwrap
|
|
23
|
+
./agent-cli run -s docker
|
|
24
|
+
./agent-cli run -s nix
|
|
25
|
+
|
|
26
|
+
# Run with worktree
|
|
27
|
+
./agent-cli run --worktree-branch feature/my-feature
|
|
28
|
+
|
|
29
|
+
# Run with terminal wrapper
|
|
30
|
+
./agent-cli run -t tmux
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Commands
|
|
34
|
+
|
|
35
|
+
### run
|
|
36
|
+
|
|
37
|
+
Run an AI coding agent.
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
Options:
|
|
41
|
+
-a, --agent <type> Agent: claude, opencode (default: claude)
|
|
42
|
+
-p, --provider <name> Model provider for the agent
|
|
43
|
+
-s, --sandbox <method> Sandbox: none, bwrap, docker, compose, nix (default: none)
|
|
44
|
+
-w, --work-dir <dir> Working directory
|
|
45
|
+
--worktree-branch <branch> Create worktree with branch
|
|
46
|
+
-t, --terminal <wrapper> Terminal wrapper: tmux
|
|
47
|
+
-c, --config <file> Load configuration from file
|
|
48
|
+
-n, --dry-run Show configuration without executing
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### completion
|
|
52
|
+
|
|
53
|
+
Generate shell completion script.
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# Bash
|
|
57
|
+
source <(./agent-cli completion bash)
|
|
58
|
+
|
|
59
|
+
# Zsh
|
|
60
|
+
./agent-cli completion zsh > "${fpath[1]}/_agent-cli"
|
|
61
|
+
|
|
62
|
+
# Fish
|
|
63
|
+
./agent-cli completion fish | source
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Configuration
|
|
67
|
+
|
|
68
|
+
Create a config file (YAML or JSON):
|
|
69
|
+
|
|
70
|
+
```yaml
|
|
71
|
+
sandbox:
|
|
72
|
+
method: bwrap
|
|
73
|
+
network: true
|
|
74
|
+
bindPaths:
|
|
75
|
+
- /home/user/projects
|
|
76
|
+
agent: claude
|
|
77
|
+
provider: anthropic
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Load with:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
./agent-cli run -c config.yaml
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Testing
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# Unit tests
|
|
90
|
+
go test ./...
|
|
91
|
+
|
|
92
|
+
# Integration tests
|
|
93
|
+
go test -tags=integration ./...
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## License
|
|
97
|
+
|
|
98
|
+
MIT
|
|
@@ -0,0 +1,80 @@
|
|
|
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();
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xonovex/agent-cli-go",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Agent wrapper CLI (Go implementation)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Xonovex",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/xonovex/platform.git",
|
|
11
|
+
"directory": "packages/cli/agent-cli-go"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/xonovex/platform/issues"
|
|
15
|
+
},
|
|
16
|
+
"homepage": "https://github.com/xonovex/platform/tree/main/packages/cli/agent-cli-go#readme",
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public",
|
|
19
|
+
"registry": "https://registry.npmjs.org/"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"bin",
|
|
23
|
+
"dist/postinstall.js"
|
|
24
|
+
],
|
|
25
|
+
"bin": {
|
|
26
|
+
"agent-cli-go": "./bin/agent-cli-go"
|
|
27
|
+
},
|
|
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{}\""
|
|
34
|
+
},
|
|
35
|
+
"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"
|
|
41
|
+
}
|
|
42
|
+
}
|