@howone/agent-cli 0.5.0 → 0.5.1
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 +1 -16
- package/bin/index.mjs +55 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# howone CLI
|
|
2
2
|
|
|
3
|
-
`howone` 命令行(npm 包
|
|
3
|
+
`howone` 命令行(npm 包 `howone`):`init app` 生成 App 模板,`capabilities` / `skills` 查询平台能力。
|
|
4
4
|
从 create-x-studio 的 `packages/cli` 拆出,保留了原提交历史。
|
|
5
5
|
|
|
6
6
|
```bash
|
|
@@ -10,21 +10,6 @@ bun run typecheck
|
|
|
10
10
|
bun run dev -- init app my-app
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
## npm 安装
|
|
14
|
-
|
|
15
|
-
需要 Node.js 20.19+(或 22.12+)。CLI 命令本身不要求 Bun。
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
npx @howone/agent-cli@latest setup --target codex
|
|
19
|
-
npx @howone/agent-cli@latest login --api-url https://isoeax.howone.dev
|
|
20
|
-
# 或全局安装
|
|
21
|
-
npm install -g @howone/agent-cli@latest
|
|
22
|
-
howone --help
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
Skill 安装到 `~/.codex/skills/howone/` 或 `~/.claude/skills/howone/`。
|
|
26
|
-
`setup` 会替换目标目录中的同名 Skill。此包独立于 `@howone/cli` 和 `@howone/sdk`。
|
|
27
|
-
|
|
28
13
|
## Work with:用本地 Coding Agent 开发 HowOne App
|
|
29
14
|
|
|
30
15
|
```bash
|
package/bin/index.mjs
CHANGED
|
@@ -23,6 +23,58 @@ var CliError = class extends Error {
|
|
|
23
23
|
this.name = "CliError";
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/network.ts
|
|
28
|
+
async function networkFetch(url, init) {
|
|
29
|
+
const target = new URL(url);
|
|
30
|
+
if (!["http:", "https:"].includes(target.protocol) || target.username || target.password) throw new CliError("E_BAD_URL", "Use an HTTP(S) API URL without embedded credentials.");
|
|
31
|
+
try {
|
|
32
|
+
return await fetch(target, init);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
if (init?.signal?.aborted) throw error;
|
|
35
|
+
const codes = /* @__PURE__ */ new Set();
|
|
36
|
+
const seen = /* @__PURE__ */ new Set();
|
|
37
|
+
function visit(value) {
|
|
38
|
+
if (!(value instanceof Error) || seen.has(value) || seen.size >= 16) return;
|
|
39
|
+
seen.add(value);
|
|
40
|
+
const code = value.code;
|
|
41
|
+
if (typeof code === "string" && /^[A-Z][A-Z0-9_]+$/.test(code)) codes.add(code);
|
|
42
|
+
visit(value.cause);
|
|
43
|
+
if (value instanceof AggregateError) for (const child of value.errors) visit(child);
|
|
44
|
+
}
|
|
45
|
+
visit(error);
|
|
46
|
+
const has = (...values) => values.some((code) => codes.has(code));
|
|
47
|
+
let stage = "connection";
|
|
48
|
+
let hint = "Check VPN routing and whether Node.js uses the same proxy as your browser.";
|
|
49
|
+
if (has("ENOTFOUND", "EAI_AGAIN", "EAI_NONAME")) {
|
|
50
|
+
stage = "dns";
|
|
51
|
+
hint = "DNS lookup failed. Check that your VPN provides DNS for this domain. On macOS, run scutil --dns.";
|
|
52
|
+
} else if ([...codes].some((code) => /CERT|SELF_SIGNED|UNABLE_TO_VERIFY|UNABLE_TO_GET_ISSUER|^ERR_SSL_/.test(code))) {
|
|
53
|
+
stage = "tls";
|
|
54
|
+
hint = "TLS failed. Check the certificate hostname and expiry. For a trusted company CA, try NODE_USE_SYSTEM_CA=1 on supported Node versions or set NODE_EXTRA_CA_CERTS to the company CA PEM file.";
|
|
55
|
+
} else if (has("ETIMEDOUT", "UND_ERR_CONNECT_TIMEOUT", "UND_ERR_HEADERS_TIMEOUT")) hint = "Connection timed out. Check the VPN route, firewall and proxy.";
|
|
56
|
+
else if (has("ECONNREFUSED", "ECONNRESET", "UND_ERR_SOCKET", "EPIPE")) hint = "Connection refused or closed. Check that the server and any configured proxy are reachable.";
|
|
57
|
+
const method = init?.method ?? "GET";
|
|
58
|
+
const endpoint = target.origin + target.pathname;
|
|
59
|
+
const reason = [...codes].join(", ") || "no system error code reported";
|
|
60
|
+
throw new CliError("E_NETWORK", `${method} ${endpoint} failed (${stage}: ${reason}). ${hint}`, {
|
|
61
|
+
method,
|
|
62
|
+
endpoint,
|
|
63
|
+
stage,
|
|
64
|
+
codes: [...codes],
|
|
65
|
+
hint,
|
|
66
|
+
nodeVersion: process.version,
|
|
67
|
+
proxyEnvironment: [
|
|
68
|
+
"HTTPS_PROXY",
|
|
69
|
+
"HTTP_PROXY",
|
|
70
|
+
"ALL_PROXY",
|
|
71
|
+
"https_proxy",
|
|
72
|
+
"http_proxy",
|
|
73
|
+
"all_proxy"
|
|
74
|
+
].filter((key) => Boolean(process.env[key]))
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
26
78
|
function configDir() {
|
|
27
79
|
const base = process.env.XDG_CONFIG_HOME || path.join(os.homedir(), ".config");
|
|
28
80
|
return path.join(base, "howone");
|
|
@@ -136,13 +188,14 @@ var HowoneApi = class HowoneApi {
|
|
|
136
188
|
}
|
|
137
189
|
async fetch(method, apiPath, options, accept) {
|
|
138
190
|
try {
|
|
139
|
-
return await
|
|
191
|
+
return await networkFetch(this.url(apiPath, options.query), {
|
|
140
192
|
method,
|
|
141
193
|
headers: this.headers(options, accept),
|
|
142
194
|
body: options.body === void 0 ? void 0 : JSON.stringify(options.body),
|
|
143
195
|
signal: options.signal
|
|
144
196
|
});
|
|
145
197
|
} catch (error) {
|
|
198
|
+
if (error instanceof CliError) throw error;
|
|
146
199
|
throw new CliError("E_NETWORK", `Cannot reach ${this.apiUrl}: ${error instanceof Error ? error.message : String(error)}`);
|
|
147
200
|
}
|
|
148
201
|
}
|
|
@@ -1869,7 +1922,7 @@ async function callHowoneRegistryApi(apiPath, args) {
|
|
|
1869
1922
|
const headers = new Headers(args.init?.headers);
|
|
1870
1923
|
if (token) headers.set("Authorization", `Bearer ${token}`);
|
|
1871
1924
|
headers.set("Accept", args.options.stream ? "text/event-stream, application/json" : "application/json");
|
|
1872
|
-
const response = await
|
|
1925
|
+
const response = await networkFetch(url, {
|
|
1873
1926
|
...args.init,
|
|
1874
1927
|
headers
|
|
1875
1928
|
});
|