@howone/agent-cli 0.5.0 → 0.5.2
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 +12 -17
- package/bin/index.mjs +60 -12
- package/package.json +5 -3
- package/scripts/postinstall.mjs +19 -0
- package/skills/howone/SKILL.md +27 -0
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,25 +10,10 @@ 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
|
|
31
|
-
howone login # 浏览器确认,令牌存 ~/.config/howone/credentials.json(0600)
|
|
16
|
+
howone login # 浏览器确认,令牌存 ~/.config/howone/credentials.json(0600),只保存登录凭证
|
|
32
17
|
howone apps create "记账" # 建 App 并在本地铺好模板
|
|
33
18
|
howone push -m "..." # 拿编辑锁 → 增量同步到沙箱 → 封存版本 → 预览 + 真实构建
|
|
34
19
|
howone dev # 实时同步,改一次存一次就刷新云端预览
|
|
@@ -48,3 +33,13 @@ howone workflows search "海报" && howone workflows run <app>/<workflow> --inpu
|
|
|
48
33
|
(原来在 SDK 的 `.agents/skills`,拆仓时移过来了)。沙箱里 `howone init app` 生成的工作区直接带上这一份。
|
|
49
34
|
|
|
50
35
|
`templates/vite/package.json` 里锁的 `@howone/sdk` 版本要和已发布的 SDK 一致。
|
|
36
|
+
|
|
37
|
+
## npm 安装
|
|
38
|
+
|
|
39
|
+
npm install -g @howone/agent-cli
|
|
40
|
+
|
|
41
|
+
安装和升级自动安装 Codex Skill 到 $CODEX_HOME/skills/howone,默认 ~/.codex/skills/howone。
|
|
42
|
+
本机已有 ~/.claude 目录时也安装 Claude Skill。登录只处理认证,不安装 Skill。
|
|
43
|
+
已有同路径 HowOne Skill 会被更新。其他 Skill 不受影响。
|
|
44
|
+
禁用安装脚本(如 --ignore-scripts)的环境需手动运行 howone setup --target codex。
|
|
45
|
+
Skill 安装失败不会阻止 CLI 安装,使用 setup 可重试。
|
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
|
}
|
|
@@ -636,7 +689,8 @@ function openBrowser(url) {
|
|
|
636
689
|
} catch {}
|
|
637
690
|
}
|
|
638
691
|
async function runLogin(options) {
|
|
639
|
-
const
|
|
692
|
+
const destination = options.apiUrl?.trim();
|
|
693
|
+
const connection = await resolveConnection({ apiUrl: destination && !destination.includes("://") ? `https://${destination}` : destination });
|
|
640
694
|
const api = new HowoneApi(connection.apiUrl, void 0);
|
|
641
695
|
const clientName = `${os.hostname()} (${process.platform})`;
|
|
642
696
|
const started = await api.request("POST", "/api/cli/v1/auth/device", {
|
|
@@ -660,17 +714,11 @@ async function runLogin(options) {
|
|
|
660
714
|
user: granted.user,
|
|
661
715
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
662
716
|
});
|
|
663
|
-
const skills = options.skill === false ? [] : await Promise.all(defaultSkillTargets().map(async (target) => ({
|
|
664
|
-
target,
|
|
665
|
-
dir: await installSkill(target, options.version)
|
|
666
|
-
})));
|
|
667
717
|
emit(options, {
|
|
668
718
|
user: granted.user,
|
|
669
|
-
apiUrl: connection.apiUrl
|
|
670
|
-
skills
|
|
719
|
+
apiUrl: connection.apiUrl
|
|
671
720
|
}, () => {
|
|
672
|
-
console.log(
|
|
673
|
-
for (const skill of skills) line(`skill (${skill.target})`, skill.dir);
|
|
721
|
+
console.log("Logged in as " + (granted.user.email ?? granted.user.id));
|
|
674
722
|
});
|
|
675
723
|
return;
|
|
676
724
|
} catch (error) {
|
|
@@ -1869,7 +1917,7 @@ async function callHowoneRegistryApi(apiPath, args) {
|
|
|
1869
1917
|
const headers = new Headers(args.init?.headers);
|
|
1870
1918
|
if (token) headers.set("Authorization", `Bearer ${token}`);
|
|
1871
1919
|
headers.set("Accept", args.options.stream ? "text/event-stream, application/json" : "application/json");
|
|
1872
|
-
const response = await
|
|
1920
|
+
const response = await networkFetch(url, {
|
|
1873
1921
|
...args.init,
|
|
1874
1922
|
headers
|
|
1875
1923
|
});
|
|
@@ -2222,7 +2270,7 @@ function printRootHelp() {
|
|
|
2222
2270
|
`${pc.dim("Usage")} howone <command> [options]`,
|
|
2223
2271
|
"",
|
|
2224
2272
|
pc.bold("Account"),
|
|
2225
|
-
formatCommand("login", "Log in from the browser
|
|
2273
|
+
formatCommand("login", "Log in from the browser"),
|
|
2226
2274
|
formatCommand("logout", "Revoke this machine's token"),
|
|
2227
2275
|
formatCommand("whoami", "Show the logged-in user"),
|
|
2228
2276
|
formatCommand("setup [remove]", "Install (or remove) the skill for Claude Code / Codex"),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@howone/agent-cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "HowOne CLI and agent skill installer for Codex and Claude.",
|
|
6
6
|
"type": "module",
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"files": [
|
|
14
14
|
"bin",
|
|
15
15
|
"skills",
|
|
16
|
-
"templates"
|
|
16
|
+
"templates",
|
|
17
|
+
"scripts/postinstall.mjs"
|
|
17
18
|
],
|
|
18
19
|
"exports": {
|
|
19
20
|
".": "./bin/index.mjs"
|
|
@@ -27,7 +28,8 @@
|
|
|
27
28
|
"dev": "bun src/index.ts",
|
|
28
29
|
"lint": "biome check src templates",
|
|
29
30
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
30
|
-
"test": "bun test src"
|
|
31
|
+
"test": "bun test src",
|
|
32
|
+
"postinstall": "node scripts/postinstall.mjs"
|
|
31
33
|
},
|
|
32
34
|
"dependencies": {
|
|
33
35
|
"@astrojs/cli-kit": "^0.4.1",
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs'
|
|
2
|
+
import os from 'node:os'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
import { spawnSync } from 'node:child_process'
|
|
5
|
+
import { fileURLToPath } from 'node:url'
|
|
6
|
+
|
|
7
|
+
const cli = fileURLToPath(new URL('../bin/index.mjs', import.meta.url))
|
|
8
|
+
const targets = ['codex']
|
|
9
|
+
if (existsSync(path.join(os.homedir(), '.claude'))) targets.push('claude')
|
|
10
|
+
for (const target of targets) {
|
|
11
|
+
const result = spawnSync(process.execPath, [cli, 'setup', '--target', target], {
|
|
12
|
+
encoding: 'utf8', env: process.env,
|
|
13
|
+
})
|
|
14
|
+
if (result.status !== 0) {
|
|
15
|
+
console.warn('HowOne: could not install ' + target + ' skill. Run howone setup --target ' + target + ' to retry.')
|
|
16
|
+
if (result.error) console.warn(result.error.message)
|
|
17
|
+
if (result.stderr) console.warn(result.stderr.trim())
|
|
18
|
+
} else if (result.stdout) console.log(result.stdout.trim())
|
|
19
|
+
}
|
package/skills/howone/SKILL.md
CHANGED
|
@@ -37,6 +37,33 @@ reuse them without exporting a token. Keep the user's chosen origin; explicit `-
|
|
|
37
37
|
origin. On an auth error, check `whoami` against the same origin before requesting login. On a
|
|
38
38
|
network error, report the CLI error instead of switching origins or opening an App preview.
|
|
39
39
|
|
|
40
|
+
## Login from the conversation
|
|
41
|
+
|
|
42
|
+
Before the first authenticated operation in a task (including creating an App), check
|
|
43
|
+
`howone whoami --json`, using the user's chosen `--api-url` if already specified. The user
|
|
44
|
+
does not need to know they must log in. If the CLI reports `E_AUTH_REQUIRED` or an expired
|
|
45
|
+
or invalid credential, explain briefly that authorization is needed and follow the login
|
|
46
|
+
flow below, then resume the original request. Do not stop at reporting an auth error or
|
|
47
|
+
require the user to request login separately. A DNS, TLS, routing, or server error is not
|
|
48
|
+
an auth failure; diagnose that error instead of repeatedly starting login. If already
|
|
49
|
+
authenticated in the requested environment, continue without another login.
|
|
50
|
+
|
|
51
|
+
The npm installation installs this Skill before login. Before starting login, identify the
|
|
52
|
+
HowOne environment the user wants. If they have not specified a destination in this conversation,
|
|
53
|
+
ask for its domain or URL (for example, isoeax.howone.dev). Do not silently choose the production
|
|
54
|
+
default, a previously saved environment, or the example domain. If they already specified it,
|
|
55
|
+
reuse that destination without asking again. Normalize a bare domain to an HTTPS origin; preserve
|
|
56
|
+
an explicitly requested HTTP origin for local development. Then run
|
|
57
|
+
`howone login --api-url <chosen-origin>` directly; do not require them to use a separate terminal.
|
|
58
|
+
The CLI attempts to open the system browser and prints a verification URL and device code.
|
|
59
|
+
Show that URL as a clickable link and explain that the user must confirm authorization there.
|
|
60
|
+
Keep the login process running and poll its output while awaiting confirmation; an authorization
|
|
61
|
+
pending response is normal. Do not approve the user's device authorization yourself or request
|
|
62
|
+
their password/token in chat. If browser launch fails, the printed URL still works.
|
|
63
|
+
With remote/headless execution use `--no-browser` and give the user the URL to open locally.
|
|
64
|
+
After the CLI reports success, check `whoami --api-url <same-origin> --json` and resume the task.
|
|
65
|
+
If the code expires, report it and start a new login only when the user is ready to retry.
|
|
66
|
+
|
|
40
67
|
## Rules that always apply
|
|
41
68
|
|
|
42
69
|
1. **One editor at a time.** An app is edited either here or by the HowOne in-platform agent,
|