@howone/agent-cli 0.5.1 → 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 CHANGED
@@ -13,7 +13,7 @@ bun run dev -- init app my-app
13
13
  ## Work with:用本地 Coding Agent 开发 HowOne App
14
14
 
15
15
  ```bash
16
- howone login # 浏览器确认,令牌存 ~/.config/howone/credentials.json(0600),顺带装用户级 skill
16
+ howone login # 浏览器确认,令牌存 ~/.config/howone/credentials.json(0600),只保存登录凭证
17
17
  howone apps create "记账" # 建 App 并在本地铺好模板
18
18
  howone push -m "..." # 拿编辑锁 → 增量同步到沙箱 → 封存版本 → 预览 + 真实构建
19
19
  howone dev # 实时同步,改一次存一次就刷新云端预览
@@ -33,3 +33,13 @@ howone workflows search "海报" && howone workflows run <app>/<workflow> --inpu
33
33
  (原来在 SDK 的 `.agents/skills`,拆仓时移过来了)。沙箱里 `howone init app` 生成的工作区直接带上这一份。
34
34
 
35
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
@@ -689,7 +689,8 @@ function openBrowser(url) {
689
689
  } catch {}
690
690
  }
691
691
  async function runLogin(options) {
692
- const connection = await resolveConnection({ apiUrl: options.apiUrl });
692
+ const destination = options.apiUrl?.trim();
693
+ const connection = await resolveConnection({ apiUrl: destination && !destination.includes("://") ? `https://${destination}` : destination });
693
694
  const api = new HowoneApi(connection.apiUrl, void 0);
694
695
  const clientName = `${os.hostname()} (${process.platform})`;
695
696
  const started = await api.request("POST", "/api/cli/v1/auth/device", {
@@ -713,17 +714,11 @@ async function runLogin(options) {
713
714
  user: granted.user,
714
715
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
715
716
  });
716
- const skills = options.skill === false ? [] : await Promise.all(defaultSkillTargets().map(async (target) => ({
717
- target,
718
- dir: await installSkill(target, options.version)
719
- })));
720
717
  emit(options, {
721
718
  user: granted.user,
722
- apiUrl: connection.apiUrl,
723
- skills
719
+ apiUrl: connection.apiUrl
724
720
  }, () => {
725
- console.log(`${pc.green("Logged in")} as ${pc.bold(granted.user.email ?? granted.user.id)}`);
726
- for (const skill of skills) line(`skill (${skill.target})`, skill.dir);
721
+ console.log("Logged in as " + (granted.user.email ?? granted.user.id));
727
722
  });
728
723
  return;
729
724
  } catch (error) {
@@ -2275,7 +2270,7 @@ function printRootHelp() {
2275
2270
  `${pc.dim("Usage")} howone <command> [options]`,
2276
2271
  "",
2277
2272
  pc.bold("Account"),
2278
- formatCommand("login", "Log in from the browser and install the howone skill"),
2273
+ formatCommand("login", "Log in from the browser"),
2279
2274
  formatCommand("logout", "Revoke this machine's token"),
2280
2275
  formatCommand("whoami", "Show the logged-in user"),
2281
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.1",
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
+ }
@@ -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,