@wanghuimvp/axon 0.4.2 → 0.5.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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Wade
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 opencode
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,131 +1,10 @@
1
- # Axon
2
-
3
- A multi-provider agentic coding CLI. Axon runs a multi-step tool loop over your codebase it reads, searches, edits, and runs commands to carry out a request with an interactive chat or a one-shot non-interactive mode.
4
-
5
- > `0.x` — interactive TUI (`axon`) and non-interactive (`axon -p`), multi-provider (Anthropic / OpenAI + OpenAI-compatible / Gemini), read + write/edit/shell tools.
6
-
7
- ## Install
8
-
9
- ```bash
10
- npm install -g @wanghuimvp/axon
11
- ```
12
-
13
- ## Interactive mode
14
-
15
- Run `axon` with no arguments to open the interactive chat:
16
-
17
- ```bash
18
- axon
19
- ```
20
-
21
- On first run without an API key, `axon` opens a short setup screen — paste a key for the active provider and it is saved to `~/.axon/config.json` (with restricted file permissions) so later runs start straight in the chat. You can also set the provider's environment variable instead (e.g. `ANTHROPIC_API_KEY`), which always takes precedence.
22
-
23
- Axon reads your project on startup — `package.json` and the first of `AGENTS.md` / `CLAUDE.md` / `README.md` — and gives the model that context.
24
-
25
- Type a request and press Enter. Axon streams its reasoning and tool calls. When it wants to write a file or run a command, you get an inline prompt:
26
-
27
- ```
28
- 🔒 write_file({"path":"NOTES.md", …})
29
- [a] allow once / [A] always this session / [d] deny
30
- ```
31
-
32
- Press `a` to allow once, `A` to allow that tool for the rest of the session, or `d` to deny (the model is told and adapts). `Ctrl+C` quits. Pass `--yolo` to skip all prompts.
33
-
34
- For one-shot, non-interactive use, see [Usage](#usage) (`axon -p`).
35
-
36
- ## Providers
37
-
38
- Axon speaks to three backends. The OpenAI-compatible provider also drives any
39
- OpenAI-protocol endpoint (DeepSeek, Qwen, Kimi, Groq, OpenRouter, ollama, LM Studio, …)
40
- by pointing `baseUrl` at it.
41
-
42
- | Provider | `provider` value | API key env | Notes |
43
- |------------|------------------|---------------------|-------|
44
- | Anthropic | `anthropic` | `ANTHROPIC_API_KEY` | Claude models |
45
- | OpenAI | `openai` | `OPENAI_API_KEY` | GPT + any OpenAI-compatible endpoint via `baseUrl` |
46
- | Gemini | `gemini` | `GEMINI_API_KEY` | Google Gemini models |
47
-
48
- Set the relevant API key in your environment before running:
49
-
50
- ```bash
51
- # macOS / Linux
52
- export OPENAI_API_KEY=sk-...
53
- # Windows (PowerShell)
54
- $env:OPENAI_API_KEY="sk-..."
55
- ```
56
-
57
- ### Select a provider/model
58
-
59
- ```bash
60
- # Per run:
61
- axon --provider openai --model gpt-4.1 -p "explain engine.ts"
62
-
63
- # Persisted:
64
- axon config set provider gemini
65
- axon config set gemini.model gemini-2.5-pro
66
- axon config get
67
- ```
68
-
69
- ### Point at an OpenAI-compatible endpoint (e.g. DeepSeek, ollama)
70
-
71
- ```bash
72
- axon config set provider openai
73
- axon config set openai.baseUrl https://api.deepseek.com/v1
74
- axon config set openai.model deepseek-chat
75
- export OPENAI_API_KEY=sk-... # the endpoint's key
76
- axon -p "summarize src/"
77
- ```
78
-
79
- For a local ollama server:
80
- ```bash
81
- axon config set openai.baseUrl http://localhost:11434/v1
82
- axon config set openai.model qwen2.5-coder
83
- export OPENAI_API_KEY=ollama # ollama ignores the key but the field must be non-empty
84
- ```
85
-
86
- ## Usage
87
-
88
- ```bash
89
- axon -p "list the TypeScript files in src and explain what engine.ts does"
90
- ```
91
-
92
- Axon will stream the model's reasoning, run read-only tools as needed (`read_file`, `list_dir`, `glob`, `grep`), and print the result.
93
-
94
- ### Options
95
-
96
- - `-p, --print <prompt>` — run one prompt non-interactively and stream the result.
97
- - `--provider <name>` — select a provider (anthropic, openai, gemini) for this run.
98
- - `--model <name>` — select a model for this run.
99
- - `--yolo` — enable the `write_file`/`edit_file`/`shell` tools without prompting (non-interactive). Off by default: these tools are not even offered to the model, so it sticks to read-only inspection.
100
- - `--version` — print the version.
101
-
102
- ### Changing files
103
-
104
- Axon can modify your workspace with `write_file`, `edit_file`, and run commands with `shell`. In non-interactive (`-p`) mode these tools are **only available with `--yolo`** — without the flag they are not offered to the model at all (and a permission gate denies them as defense-in-depth).
105
-
106
- ```bash
107
- axon --yolo -p "add a CHANGELOG.md with an initial entry, then run the tests"
108
- ```
109
-
110
- Read/search tools (`read_file`, `list_dir`, `glob`, `grep`) always run without a prompt. `write_file` and `edit_file` are confined to the project root (path-escape and symlink-escape protected). `shell` is **not** sandboxed — under `--yolo` it runs arbitrary commands and can affect anything your shell can. Only pass `--yolo` to runs you trust.
111
-
112
- ## Configuration
113
-
114
- Optional config file at `~/.axon/config.json`:
115
-
116
- ```json
117
- {
118
- "provider": "anthropic",
119
- "providers": {
120
- "anthropic": { "model": "claude-opus-4-8" },
121
- "openai": { "model": "gpt-4.1", "baseUrl": "https://api.openai.com/v1" },
122
- "gemini": { "model": "gemini-2.5-pro" }
123
- }
124
- }
125
- ```
126
-
127
- API keys are read from environment variables (`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GEMINI_API_KEY`) and never written to disk.
128
-
129
- ## License
130
-
131
- MIT
1
+ # axon
2
+
3
+ A fast, open-source AI coding agent for the terminal — a rebranded fork of [opencode](https://github.com/anomalyco/opencode) (MIT).
4
+
5
+ ```bash
6
+ npm i -g @wanghuimvp/axon
7
+ axon --help
8
+ ```
9
+
10
+ See the [project README](https://github.com/Wade-DevCode/axon) for install, usage, and configuration.
package/bin/axon.exe ADDED
@@ -0,0 +1,10 @@
1
+ echo "Error: @wanghuimvp/axon's postinstall script was not run." >&2
2
+ echo "" >&2
3
+ echo "This occurs when using --ignore-scripts during installation, or when using a" >&2
4
+ echo "package manager like pnpm that does not run postinstall scripts by default." >&2
5
+ echo "" >&2
6
+ echo "To fix this, run the postinstall script manually:" >&2
7
+ echo " cd node_modules/@wanghuimvp/axon && node postinstall.mjs" >&2
8
+ echo "" >&2
9
+ echo "Or reinstall @wanghuimvp/axon without the --ignore-scripts flag." >&2
10
+ exit 1
package/package.json CHANGED
@@ -1,63 +1,23 @@
1
- {
2
- "name": "@wanghuimvp/axon",
3
- "version": "0.4.2",
4
- "description": "Axon — a multi-provider agentic coding CLI (Anthropic, OpenAI + OpenAI-compatible endpoints, Gemini). Runs a multi-step tool loop over your codebase.",
5
- "type": "module",
6
- "bin": {
7
- "axon": "dist/cli.js"
8
- },
9
- "files": [
10
- "dist"
11
- ],
12
- "engines": {
13
- "node": ">=20"
14
- },
15
- "license": "MIT",
16
- "keywords": [
17
- "cli",
18
- "agent",
19
- "agentic",
20
- "coding",
21
- "anthropic",
22
- "claude",
23
- "ai",
24
- "assistant",
25
- "axon"
26
- ],
27
- "repository": {
28
- "type": "git",
29
- "url": "git+https://github.com/Wade-DevCode/axon.git"
30
- },
31
- "homepage": "https://github.com/Wade-DevCode/axon#readme",
32
- "bugs": {
33
- "url": "https://github.com/Wade-DevCode/axon/issues"
34
- },
35
- "publishConfig": {
36
- "access": "public"
37
- },
38
- "scripts": {
39
- "dev": "tsx src/cli.ts",
40
- "test": "vitest run",
41
- "build": "esbuild src/cli.ts --bundle --platform=node --format=esm --outfile=dist/cli.js --packages=external --jsx=automatic",
42
- "prepublishOnly": "npm test && npm run build"
43
- },
44
- "dependencies": {
45
- "@anthropic-ai/sdk": "^0.40.0",
46
- "@google/genai": "^1.52.0",
47
- "commander": "^12.0.0",
48
- "fast-glob": "^3.3.0",
49
- "ink": "^5.2.1",
50
- "ink-text-input": "^6.0.0",
51
- "openai": "^4.104.0",
52
- "react": "^18.3.1"
53
- },
54
- "devDependencies": {
55
- "@types/node": "^20.0.0",
56
- "@types/react": "^18.3.31",
57
- "esbuild": "^0.23.0",
58
- "ink-testing-library": "^4.0.0",
59
- "tsx": "^4.0.0",
60
- "typescript": "^5.5.0",
61
- "vitest": "^2.0.0"
62
- }
63
- }
1
+ {
2
+ "name": "@wanghuimvp/axon",
3
+ "bin": {
4
+ "axon": "./bin/axon.exe"
5
+ },
6
+ "scripts": {
7
+ "postinstall": "node ./postinstall.mjs"
8
+ },
9
+ "version": "0.5.0",
10
+ "license": "MIT",
11
+ "os": [
12
+ "darwin",
13
+ "linux",
14
+ "win32"
15
+ ],
16
+ "cpu": [
17
+ "arm64",
18
+ "x64"
19
+ ],
20
+ "optionalDependencies": {
21
+ "axon-windows-x64": "0.5.0"
22
+ }
23
+ }
@@ -0,0 +1,189 @@
1
+ #!/usr/bin/env node
2
+
3
+ import childProcess from "child_process"
4
+ import fs from "fs"
5
+ import os from "os"
6
+ import path from "path"
7
+ import { createRequire } from "module"
8
+ import { fileURLToPath } from "url"
9
+
10
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
11
+ const require = createRequire(import.meta.url)
12
+ const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, "package.json"), "utf8"))
13
+
14
+ const platformMap = {
15
+ darwin: "darwin",
16
+ linux: "linux",
17
+ win32: "windows",
18
+ }
19
+ const archMap = {
20
+ x64: "x64",
21
+ arm64: "arm64",
22
+ arm: "arm",
23
+ }
24
+
25
+ const platform = platformMap[os.platform()] ?? os.platform()
26
+ const arch = archMap[os.arch()] ?? os.arch()
27
+ const base = `axon-${platform}-${arch}`
28
+ const sourceBinary = platform === "windows" ? "axon.exe" : "axon"
29
+ const targetBinary = path.join(__dirname, "bin", "axon.exe")
30
+
31
+ function supportsAvx2() {
32
+ if (arch !== "x64") return false
33
+
34
+ if (platform === "linux") {
35
+ try {
36
+ return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"))
37
+ } catch {
38
+ return false
39
+ }
40
+ }
41
+
42
+ if (platform === "darwin") {
43
+ try {
44
+ const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], {
45
+ encoding: "utf8",
46
+ timeout: 1500,
47
+ })
48
+ if (result.status !== 0) return false
49
+ return (result.stdout || "").trim() === "1"
50
+ } catch {
51
+ return false
52
+ }
53
+ }
54
+
55
+ if (platform === "windows") {
56
+ const command =
57
+ '(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
58
+
59
+ for (const executable of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
60
+ try {
61
+ const result = childProcess.spawnSync(executable, ["-NoProfile", "-NonInteractive", "-Command", command], {
62
+ encoding: "utf8",
63
+ timeout: 3000,
64
+ windowsHide: true,
65
+ })
66
+ if (result.status !== 0) continue
67
+ const output = (result.stdout || "").trim().toLowerCase()
68
+ if (output === "true" || output === "1") return true
69
+ if (output === "false" || output === "0") return false
70
+ } catch {
71
+ continue
72
+ }
73
+ }
74
+ }
75
+
76
+ return false
77
+ }
78
+
79
+ function isMusl() {
80
+ if (platform !== "linux") return false
81
+
82
+ try {
83
+ if (fs.existsSync("/etc/alpine-release")) return true
84
+ } catch {
85
+ // Ignore filesystem probes that are blocked by the host.
86
+ }
87
+
88
+ try {
89
+ const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
90
+ return `${result.stdout || ""}${result.stderr || ""}`.toLowerCase().includes("musl")
91
+ } catch {
92
+ return false
93
+ }
94
+ }
95
+
96
+ function packageNames() {
97
+ const baseline = arch === "x64" && !supportsAvx2()
98
+
99
+ if (platform === "linux") {
100
+ if (isMusl()) {
101
+ if (arch === "x64")
102
+ return baseline
103
+ ? [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
104
+ : [`${base}-musl`, `${base}-baseline-musl`, base, `${base}-baseline`]
105
+ return [`${base}-musl`, base]
106
+ }
107
+
108
+ if (arch === "x64")
109
+ return baseline
110
+ ? [`${base}-baseline`, base, `${base}-baseline-musl`, `${base}-musl`]
111
+ : [base, `${base}-baseline`, `${base}-musl`, `${base}-baseline-musl`]
112
+ return [base, `${base}-musl`]
113
+ }
114
+
115
+ if (arch === "x64") return baseline ? [`${base}-baseline`, base] : [base, `${base}-baseline`]
116
+ return [base]
117
+ }
118
+
119
+ function resolveBinary(name) {
120
+ const packageJsonPath = require.resolve(`${name}/package.json`)
121
+ const binaryPath = path.join(path.dirname(packageJsonPath), "bin", sourceBinary)
122
+ if (!fs.existsSync(binaryPath)) throw new Error(`Binary not found at ${binaryPath}`)
123
+ return binaryPath
124
+ }
125
+
126
+ function installPackage(name) {
127
+ const version = packageJson.optionalDependencies?.[name]
128
+ if (!version) return
129
+
130
+ const temp = fs.mkdtempSync(path.join(os.tmpdir(), "axon-install-"))
131
+ try {
132
+ const result = childProcess.spawnSync(
133
+ "npm",
134
+ ["install", "--ignore-scripts", "--no-save", "--loglevel=error", "--prefix", temp, `${name}@${version}`],
135
+ { stdio: "inherit", windowsHide: true },
136
+ )
137
+ if (result.status !== 0) return
138
+ const packageDir = path.join(temp, "node_modules", name)
139
+ copyBinary(path.join(packageDir, "bin", sourceBinary), targetBinary)
140
+ return true
141
+ } finally {
142
+ fs.rmSync(temp, { recursive: true, force: true })
143
+ }
144
+ }
145
+
146
+ function copyBinary(source, target) {
147
+ if (!fs.existsSync(source)) throw new Error(`Binary not found at ${source}`)
148
+ fs.mkdirSync(path.dirname(target), { recursive: true })
149
+ if (fs.existsSync(target)) fs.unlinkSync(target)
150
+ try {
151
+ fs.linkSync(source, target)
152
+ } catch {
153
+ fs.copyFileSync(source, target)
154
+ }
155
+ fs.chmodSync(target, 0o755)
156
+ }
157
+
158
+ function verifyBinary() {
159
+ const result = childProcess.spawnSync(targetBinary, ["--version"], {
160
+ encoding: "utf8",
161
+ stdio: "ignore",
162
+ windowsHide: true,
163
+ })
164
+ return result.status === 0
165
+ }
166
+
167
+ function main() {
168
+ for (const name of packageNames()) {
169
+ try {
170
+ copyBinary(resolveBinary(name), targetBinary)
171
+ if (verifyBinary()) return
172
+ } catch {
173
+ if (installPackage(name) && verifyBinary()) return
174
+ }
175
+ }
176
+
177
+ throw new Error(
178
+ `It seems your package manager failed to install the right axon CLI package. Try manually installing ${packageNames()
179
+ .map((name) => JSON.stringify(name))
180
+ .join(" or ")}.`,
181
+ )
182
+ }
183
+
184
+ try {
185
+ main()
186
+ } catch (error) {
187
+ console.error(error.message)
188
+ process.exit(1)
189
+ }