laohuang 0.3.2 → 0.4.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 +142 -16
- package/dist/agent.d.ts +166 -0
- package/dist/agent.js +858 -0
- package/dist/agent.js.map +1 -0
- package/dist/bash-runner.d.ts +79 -0
- package/dist/bash-runner.js +464 -0
- package/dist/bash-runner.js.map +1 -0
- package/dist/cancellation.d.ts +36 -0
- package/dist/cancellation.js +123 -0
- package/dist/cancellation.js.map +1 -0
- package/dist/cli.d.ts +117 -0
- package/dist/cli.js +1307 -0
- package/dist/cli.js.map +1 -0
- package/dist/client.d.ts +21 -0
- package/dist/client.js +17 -0
- package/dist/client.js.map +1 -0
- package/dist/commands.d.ts +123 -0
- package/dist/commands.js +660 -0
- package/dist/commands.js.map +1 -0
- package/dist/config.d.ts +51 -0
- package/dist/config.js +183 -0
- package/dist/config.js.map +1 -0
- package/dist/credentials.d.ts +12 -0
- package/dist/credentials.js +102 -0
- package/dist/credentials.js.map +1 -0
- package/dist/events.d.ts +288 -0
- package/dist/events.js +838 -0
- package/dist/events.js.map +1 -0
- package/dist/model-adapter.d.ts +138 -0
- package/dist/model-adapter.js +244 -0
- package/dist/model-adapter.js.map +1 -0
- package/dist/model-selection.d.ts +67 -0
- package/dist/model-selection.js +148 -0
- package/dist/model-selection.js.map +1 -0
- package/dist/model-stream.d.ts +128 -0
- package/dist/model-stream.js +582 -0
- package/dist/model-stream.js.map +1 -0
- package/dist/project-instructions.d.ts +99 -0
- package/dist/project-instructions.js +348 -0
- package/dist/project-instructions.js.map +1 -0
- package/dist/providers.d.ts +9 -0
- package/dist/providers.js +26 -0
- package/dist/providers.js.map +1 -0
- package/dist/routing.d.ts +170 -0
- package/dist/routing.js +669 -0
- package/dist/routing.js.map +1 -0
- package/dist/semantic-classifier.d.ts +66 -0
- package/dist/semantic-classifier.js +86 -0
- package/dist/semantic-classifier.js.map +1 -0
- package/dist/session.d.ts +162 -0
- package/dist/session.js +871 -0
- package/dist/session.js.map +1 -0
- package/dist/system-prompt.d.ts +16 -0
- package/dist/system-prompt.js +42 -0
- package/dist/system-prompt.js.map +1 -0
- package/dist/terminal/editor.d.ts +161 -0
- package/dist/terminal/editor.js +1060 -0
- package/dist/terminal/editor.js.map +1 -0
- package/dist/terminal/input.d.ts +61 -0
- package/dist/terminal/input.js +276 -0
- package/dist/terminal/input.js.map +1 -0
- package/dist/terminal/markdown.d.ts +20 -0
- package/dist/terminal/markdown.js +621 -0
- package/dist/terminal/markdown.js.map +1 -0
- package/dist/terminal/screen.d.ts +66 -0
- package/dist/terminal/screen.js +624 -0
- package/dist/terminal/screen.js.map +1 -0
- package/dist/terminal/theme.d.ts +23 -0
- package/dist/terminal/theme.js +101 -0
- package/dist/terminal/theme.js.map +1 -0
- package/dist/terminal/ui.d.ts +285 -0
- package/dist/terminal/ui.js +1815 -0
- package/dist/terminal/ui.js.map +1 -0
- package/dist/tools.d.ts +95 -0
- package/dist/tools.js +444 -0
- package/dist/tools.js.map +1 -0
- package/dist/ui-state.d.ts +51 -0
- package/dist/ui-state.js +194 -0
- package/dist/ui-state.js.map +1 -0
- package/dist/web.d.ts +56 -0
- package/dist/web.js +247 -0
- package/dist/web.js.map +1 -0
- package/package.json +24 -21
- package/bin/laohuang.js +0 -10
- package/lib/launcher.js +0 -133
- package/vendor/laohuangcode-0.3.2-py3-none-any.whl +0 -0
package/lib/launcher.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
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
|
-
};
|
|
Binary file
|