laohuang 0.3.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 +21 -0
- package/README.md +27 -0
- package/bin/laohuang.js +10 -0
- package/lib/launcher.js +133 -0
- package/package.json +36 -0
- package/vendor/laohuangcode-0.3.0-py3-none-any.whl +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 laoHuangCode contributors
|
|
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
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# laohuang
|
|
2
|
+
|
|
3
|
+
This npm package provides the `laohuang` command for
|
|
4
|
+
[laoHuangCode](https://github.com/hxr223/laoHuangCode).
|
|
5
|
+
|
|
6
|
+
It is a small Node.js launcher, not a second implementation of the agent. On
|
|
7
|
+
first run it creates an isolated Python environment in the user cache and
|
|
8
|
+
installs the bundled `laohuangcode` Python wheel. Python 3.11 or newer must
|
|
9
|
+
already be available as `python3` or `python`. Third-party Python dependencies
|
|
10
|
+
are downloaded by pip during this first launch.
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install --global laohuang
|
|
14
|
+
laohuang --version
|
|
15
|
+
laohuang
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The first interactive launch asks for DeepSeek or OpenAI, reads the API key
|
|
19
|
+
with hidden terminal input, and then asks which model to use. No API key
|
|
20
|
+
environment variable is needed.
|
|
21
|
+
|
|
22
|
+
The launcher accepts two advanced environment variables:
|
|
23
|
+
|
|
24
|
+
- `LAOHUANG_PYTHON`: run a specific Python executable and skip bootstrapping.
|
|
25
|
+
- `LAOHUANG_CACHE_HOME`: override the launcher's cache root.
|
|
26
|
+
|
|
27
|
+
See the main project README for model configuration and security details.
|
package/bin/laohuang.js
ADDED
package/lib/launcher.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
const childProcess = require("node:child_process");
|
|
2
|
+
const fs = require("node:fs");
|
|
3
|
+
const os = require("node:os");
|
|
4
|
+
const path = require("node:path");
|
|
5
|
+
|
|
6
|
+
const packageJson = require("../package.json");
|
|
7
|
+
|
|
8
|
+
function cacheDirectory(env = process.env, version = packageJson.version) {
|
|
9
|
+
let root = env.LAOHUANG_CACHE_HOME;
|
|
10
|
+
if (!root) {
|
|
11
|
+
if (process.platform === "darwin") {
|
|
12
|
+
root = path.join(os.homedir(), "Library", "Caches", "laohuang");
|
|
13
|
+
} else {
|
|
14
|
+
root = path.join(env.XDG_CACHE_HOME || path.join(os.homedir(), ".cache"), "laohuang");
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return path.join(root, `python-${version}`);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function venvPython(venvDirectory) {
|
|
21
|
+
return path.join(venvDirectory, "bin", "python");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function bundledWheelPath(version = packageJson.version) {
|
|
25
|
+
return path.join(
|
|
26
|
+
__dirname,
|
|
27
|
+
"..",
|
|
28
|
+
"vendor",
|
|
29
|
+
`laohuangcode-${version}-py3-none-any.whl`,
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function successful(result) {
|
|
34
|
+
return !result.error && result.status === 0;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function findHostPython(env, spawnSync) {
|
|
38
|
+
const candidates = env.LAOHUANG_BOOTSTRAP_PYTHON
|
|
39
|
+
? [env.LAOHUANG_BOOTSTRAP_PYTHON]
|
|
40
|
+
: ["python3", "python"];
|
|
41
|
+
const versionCheck =
|
|
42
|
+
"import sys; raise SystemExit(0 if sys.version_info >= (3, 11) else 1)";
|
|
43
|
+
|
|
44
|
+
for (const candidate of candidates) {
|
|
45
|
+
const result = spawnSync(candidate, ["-c", versionCheck], {
|
|
46
|
+
env,
|
|
47
|
+
stdio: "ignore",
|
|
48
|
+
});
|
|
49
|
+
if (successful(result)) {
|
|
50
|
+
return candidate;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
throw new Error("Python 3.11 or newer is required to run laohuang");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function runChecked(spawnSync, command, arguments_, options, description) {
|
|
57
|
+
const result = spawnSync(command, arguments_, options);
|
|
58
|
+
if (!successful(result)) {
|
|
59
|
+
if (result.error) {
|
|
60
|
+
throw new Error(`${description}: ${result.error.message}`);
|
|
61
|
+
}
|
|
62
|
+
throw new Error(`${description} (exit code ${result.status ?? "unknown"})`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function ensurePythonPackage({ env, spawnSync }) {
|
|
67
|
+
const directory = cacheDirectory(env);
|
|
68
|
+
const python = venvPython(directory);
|
|
69
|
+
const readyFile = path.join(directory, ".laohuang-ready");
|
|
70
|
+
if (fs.existsSync(python) && fs.existsSync(readyFile)) {
|
|
71
|
+
return python;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
fs.mkdirSync(path.dirname(directory), { recursive: true });
|
|
75
|
+
const hostPython = findHostPython(env, spawnSync);
|
|
76
|
+
if (!fs.existsSync(python)) {
|
|
77
|
+
runChecked(
|
|
78
|
+
spawnSync,
|
|
79
|
+
hostPython,
|
|
80
|
+
["-m", "venv", directory],
|
|
81
|
+
{ env, stdio: "inherit" },
|
|
82
|
+
"Could not create the laohuang Python environment",
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const packageSource = env.LAOHUANG_PYTHON_PACKAGE || bundledWheelPath();
|
|
87
|
+
if (!env.LAOHUANG_PYTHON_PACKAGE && !fs.existsSync(packageSource)) {
|
|
88
|
+
throw new Error(`Bundled Python wheel is missing: ${packageSource}`);
|
|
89
|
+
}
|
|
90
|
+
runChecked(
|
|
91
|
+
spawnSync,
|
|
92
|
+
python,
|
|
93
|
+
[
|
|
94
|
+
"-m",
|
|
95
|
+
"pip",
|
|
96
|
+
"install",
|
|
97
|
+
"--disable-pip-version-check",
|
|
98
|
+
"--upgrade",
|
|
99
|
+
packageSource,
|
|
100
|
+
],
|
|
101
|
+
{ env, stdio: "inherit" },
|
|
102
|
+
`Could not install ${packageSource}`,
|
|
103
|
+
);
|
|
104
|
+
fs.writeFileSync(readyFile, `${packageJson.version}\n`, { mode: 0o600 });
|
|
105
|
+
return python;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function run(
|
|
109
|
+
arguments_,
|
|
110
|
+
{
|
|
111
|
+
env = process.env,
|
|
112
|
+
spawnSync = childProcess.spawnSync,
|
|
113
|
+
} = {},
|
|
114
|
+
) {
|
|
115
|
+
const python = env.LAOHUANG_PYTHON || ensurePythonPackage({ env, spawnSync });
|
|
116
|
+
const result = spawnSync(
|
|
117
|
+
python,
|
|
118
|
+
["-m", "laohuangcode", ...arguments_],
|
|
119
|
+
{ env, stdio: "inherit" },
|
|
120
|
+
);
|
|
121
|
+
if (result.error) {
|
|
122
|
+
throw new Error(`Could not start laohuang: ${result.error.message}`);
|
|
123
|
+
}
|
|
124
|
+
return result.status ?? 1;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
module.exports = {
|
|
128
|
+
bundledWheelPath,
|
|
129
|
+
cacheDirectory,
|
|
130
|
+
ensurePythonPackage,
|
|
131
|
+
findHostPython,
|
|
132
|
+
run,
|
|
133
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "laohuang",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Node.js launcher for the laoHuangCode coding agent",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/hxr223/laoHuangCode.git",
|
|
9
|
+
"directory": "npm"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/hxr223/laoHuangCode#readme",
|
|
12
|
+
"bugs": "https://github.com/hxr223/laoHuangCode/issues",
|
|
13
|
+
"type": "commonjs",
|
|
14
|
+
"bin": {
|
|
15
|
+
"laohuang": "bin/laohuang.js"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"bin",
|
|
19
|
+
"lib",
|
|
20
|
+
"vendor",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=18"
|
|
25
|
+
},
|
|
26
|
+
"os": [
|
|
27
|
+
"darwin",
|
|
28
|
+
"linux"
|
|
29
|
+
],
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"test": "node --test"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
Binary file
|