@howone/agent-cli 0.5.1 → 0.5.3
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 +29 -1
- package/bin/index.mjs +198 -17
- package/package.json +6 -3
- package/scripts/postinstall.mjs +19 -0
- package/skills/howone/SKILL.md +27 -0
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)
|
|
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,31 @@ 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 可重试。
|
|
46
|
+
|
|
47
|
+
## 自动更新
|
|
48
|
+
|
|
49
|
+
npm 全局安装的 CLI 在命令成功结束后,后台每天检查一次 npm `latest` 稳定版。
|
|
50
|
+
有新版时,自动更新同一安装位置的 `@howone/agent-cli`,并通过安装脚本更新 Skill。
|
|
51
|
+
本次命令继续使用原版本,下次启动使用新版;登录凭证和 App 文件不变。
|
|
52
|
+
检查和更新失败不会阻断命令,也不会污染 `--json` 输出。
|
|
53
|
+
|
|
54
|
+
设置 `HOWONE_AUTO_UPDATE=0` 可关闭自动更新。CI、源码开发、npx 临时运行和无写权限的
|
|
55
|
+
系统级安装跳过自动更新;不会请求 sudo,也不会更改 npm 的全局 registry 配置。
|
|
56
|
+
此功能需先手动安装包含它的新版 CLI,旧版不会自行获得更新能力。
|
|
57
|
+
|
|
58
|
+
## 临时跳过 API 证书校验
|
|
59
|
+
|
|
60
|
+
`howone login --api-url https://isoeax.howone.dev --insecure` 显式跳过本次命令的
|
|
61
|
+
目标 API 证书校验,并在 stderr 显示警告。该设置不保存,后续命令需要再次指定。
|
|
62
|
+
默认仍校验证书;优先修复公司 CA 或服务端证书链。该参数不会影响 npm 自动更新,
|
|
63
|
+
不允许把跳过校验的请求重定向到其他地址,也不会修改系统或 Node 的全局 TLS 设置。
|
package/bin/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { execFile, spawn } from "node:child_process";
|
|
4
|
-
import { appendFile, chmod, cp, lstat, mkdir, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
4
|
+
import { access, appendFile, chmod, cp, lstat, mkdir, readFile, readdir, realpath, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { promisify } from "node:util";
|
|
@@ -11,9 +11,155 @@ import { copy, emptyDir, ensureDir, pathExists } from "fs-extra/esm";
|
|
|
11
11
|
import pc from "picocolors";
|
|
12
12
|
import validatePackageName from "validate-npm-package-name";
|
|
13
13
|
import yargsParser from "yargs-parser";
|
|
14
|
-
import { existsSync, watch } from "node:fs";
|
|
15
|
-
import os from "node:os";
|
|
16
14
|
import { createHash, randomUUID } from "node:crypto";
|
|
15
|
+
import { constants, existsSync, watch } from "node:fs";
|
|
16
|
+
import os from "node:os";
|
|
17
|
+
//#region src/auto-update.ts
|
|
18
|
+
const execFileAsync$2 = promisify(execFile);
|
|
19
|
+
const PACKAGE = "@howone/agent-cli";
|
|
20
|
+
const REGISTRY = "https://registry.npmjs.org/";
|
|
21
|
+
const DAY = 1440 * 60 * 1e3;
|
|
22
|
+
const LOCK_TTL = 600 * 1e3;
|
|
23
|
+
const WORKER_ARG = "--internal-auto-update";
|
|
24
|
+
function globalInstallPrefix(root, platform = process.platform) {
|
|
25
|
+
if (path.basename(root) !== "agent-cli" || path.basename(path.dirname(root)) !== "@howone") return null;
|
|
26
|
+
const modules = path.dirname(path.dirname(root));
|
|
27
|
+
if (path.basename(modules) !== "node_modules") return null;
|
|
28
|
+
const parent = path.dirname(modules);
|
|
29
|
+
if (platform === "win32") {
|
|
30
|
+
if (path.basename(parent) === "_npx" || parent.includes(`${path.sep}_npx${path.sep}`)) return null;
|
|
31
|
+
return parent;
|
|
32
|
+
}
|
|
33
|
+
return path.basename(parent) === "lib" ? path.dirname(parent) : null;
|
|
34
|
+
}
|
|
35
|
+
function autoUpdateEnabled(env = process.env) {
|
|
36
|
+
return env.HOWONE_AUTO_UPDATE !== "0" && !env.CI && !env.npm_lifecycle_event && !env.npm_execpath?.includes("npx");
|
|
37
|
+
}
|
|
38
|
+
/** Only a completed command starts the detached updater; stdout/JSON stays untouched. */
|
|
39
|
+
function scheduleAutoUpdate(root) {
|
|
40
|
+
if (!autoUpdateEnabled() || !globalInstallPrefix(root)) return;
|
|
41
|
+
process.once("exit", (code) => {
|
|
42
|
+
if (code !== 0) return;
|
|
43
|
+
try {
|
|
44
|
+
const child = spawn(process.execPath, [path.join(root, "bin", "index.mjs"), WORKER_ARG], {
|
|
45
|
+
detached: true,
|
|
46
|
+
stdio: "ignore",
|
|
47
|
+
windowsHide: true
|
|
48
|
+
});
|
|
49
|
+
child.on("error", () => {});
|
|
50
|
+
child.unref();
|
|
51
|
+
} catch {}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function newerStable(latest, current) {
|
|
55
|
+
if (!/^\d+\.\d+\.\d+$/.test(latest) || !/^\d+\.\d+\.\d+$/.test(current)) return false;
|
|
56
|
+
const a = latest.split(".").map(Number);
|
|
57
|
+
const b = current.split(".").map(Number);
|
|
58
|
+
for (let i = 0; i < 3; i++) if (a[i] !== b[i]) return (a[i] ?? 0) > (b[i] ?? 0);
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
async function npmCommand() {
|
|
62
|
+
if (process.platform === "win32") {
|
|
63
|
+
const candidates = [path.join(path.dirname(process.execPath), "node_modules", "npm", "bin", "npm-cli.js"), ...(process.env.PATH ?? "").split(path.delimiter).map((dir) => path.join(dir, "node_modules", "npm", "bin", "npm-cli.js"))];
|
|
64
|
+
for (const candidate of candidates) if (await stat(candidate).then((s) => s.isFile()).catch(() => false)) return {
|
|
65
|
+
executable: process.execPath,
|
|
66
|
+
args: [candidate]
|
|
67
|
+
};
|
|
68
|
+
throw new Error("npm is not available");
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
executable: "npm",
|
|
72
|
+
args: []
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
async function runAutoUpdate(options) {
|
|
76
|
+
const prefix = globalInstallPrefix(options.root);
|
|
77
|
+
if (!prefix || !autoUpdateEnabled(options.env)) return;
|
|
78
|
+
if (await realpath(options.root) !== path.resolve(options.root)) return;
|
|
79
|
+
const launcher = process.platform === "win32" ? path.join(prefix, "howone.cmd") : path.join(prefix, "bin", "howone");
|
|
80
|
+
if (process.platform === "win32") {
|
|
81
|
+
if (!(await stat(launcher)).isFile()) return;
|
|
82
|
+
} else if (await realpath(launcher) !== path.join(options.root, "bin", "index.mjs")) return;
|
|
83
|
+
await Promise.all([
|
|
84
|
+
options.root,
|
|
85
|
+
path.dirname(path.dirname(options.root)),
|
|
86
|
+
process.platform === "win32" ? prefix : path.join(prefix, "bin")
|
|
87
|
+
].map((dir) => access(dir, constants.W_OK)));
|
|
88
|
+
const key = createHash("sha256").update(prefix).digest("hex").slice(0, 16);
|
|
89
|
+
const cacheDir = options.cacheDir ?? path.join(process.env.XDG_CACHE_HOME || path.join(os.homedir(), ".cache"), "howone", "updates");
|
|
90
|
+
await mkdir(cacheDir, {
|
|
91
|
+
recursive: true,
|
|
92
|
+
mode: 448
|
|
93
|
+
});
|
|
94
|
+
const stateFile = path.join(cacheDir, `${key}.json`);
|
|
95
|
+
const lock = path.join(cacheDir, `${key}.lock`);
|
|
96
|
+
const now = options.now ?? Date.now();
|
|
97
|
+
const lockStat = await stat(lock).catch(() => null);
|
|
98
|
+
if (lockStat && now - lockStat.mtimeMs > LOCK_TTL) await rm(lock, {
|
|
99
|
+
recursive: true,
|
|
100
|
+
force: true
|
|
101
|
+
});
|
|
102
|
+
try {
|
|
103
|
+
await mkdir(lock);
|
|
104
|
+
} catch (error) {
|
|
105
|
+
if (error.code === "EEXIST") return;
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
const previous = await readFile(stateFile, "utf8").then(JSON.parse).catch(() => null);
|
|
110
|
+
if (previous?.checkedAt && now - previous.checkedAt < DAY) return;
|
|
111
|
+
await writeFile(stateFile, JSON.stringify({ checkedAt: now }), { mode: 384 });
|
|
112
|
+
const npm = options.runNpm ? null : await npmCommand();
|
|
113
|
+
const runNpm = options.runNpm ?? (async (args) => {
|
|
114
|
+
const { stdout } = await execFileAsync$2(npm.executable, [...npm.args, ...args], {
|
|
115
|
+
timeout: args[0] === "view" ? 2e4 : 18e4,
|
|
116
|
+
maxBuffer: 1024 * 1024,
|
|
117
|
+
windowsHide: true,
|
|
118
|
+
env: {
|
|
119
|
+
...process.env,
|
|
120
|
+
HOWONE_AUTO_UPDATE: "0"
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
return stdout;
|
|
124
|
+
});
|
|
125
|
+
const registryArgs = [`--registry=${REGISTRY}`, `--@howone:registry=${REGISTRY}`];
|
|
126
|
+
const latest = JSON.parse(await runNpm([
|
|
127
|
+
"view",
|
|
128
|
+
`${PACKAGE}@latest`,
|
|
129
|
+
"version",
|
|
130
|
+
"--json",
|
|
131
|
+
...registryArgs,
|
|
132
|
+
"--fetch-retries=0",
|
|
133
|
+
"--fetch-timeout=15000"
|
|
134
|
+
]));
|
|
135
|
+
if (typeof latest !== "string" || !newerStable(latest, options.currentVersion)) return;
|
|
136
|
+
await runNpm([
|
|
137
|
+
"install",
|
|
138
|
+
"--global",
|
|
139
|
+
"--prefix",
|
|
140
|
+
prefix,
|
|
141
|
+
`${PACKAGE}@${latest}`,
|
|
142
|
+
...registryArgs,
|
|
143
|
+
"--engine-strict",
|
|
144
|
+
"--ignore-scripts=false",
|
|
145
|
+
"--no-audit",
|
|
146
|
+
"--no-fund",
|
|
147
|
+
"--fetch-retries=0",
|
|
148
|
+
"--fetch-timeout=30000"
|
|
149
|
+
]);
|
|
150
|
+
await writeFile(stateFile, JSON.stringify({
|
|
151
|
+
checkedAt: now,
|
|
152
|
+
updatedTo: latest
|
|
153
|
+
}), { mode: 384 });
|
|
154
|
+
} finally {
|
|
155
|
+
await rm(lock, {
|
|
156
|
+
recursive: true,
|
|
157
|
+
force: true
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const isAutoUpdateWorker = () => process.argv[2] === WORKER_ARG;
|
|
162
|
+
//#endregion
|
|
17
163
|
//#region src/errors.ts
|
|
18
164
|
var CliError = class extends Error {
|
|
19
165
|
constructor(code, message, details) {
|
|
@@ -25,10 +171,34 @@ var CliError = class extends Error {
|
|
|
25
171
|
};
|
|
26
172
|
//#endregion
|
|
27
173
|
//#region src/network.ts
|
|
174
|
+
let insecureOrigin;
|
|
175
|
+
let insecureDispatcher;
|
|
176
|
+
/** Explicit command-local exception; never changes Node's global TLS settings. */
|
|
177
|
+
function configureInsecureTls(apiUrl) {
|
|
178
|
+
insecureOrigin = new URL(apiUrl).origin;
|
|
179
|
+
}
|
|
28
180
|
async function networkFetch(url, init) {
|
|
29
181
|
const target = new URL(url);
|
|
30
182
|
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
183
|
try {
|
|
184
|
+
if (target.protocol === "https:" && target.origin === insecureOrigin) {
|
|
185
|
+
const { Agent, EnvHttpProxyAgent, fetch: insecureFetch } = await import("undici");
|
|
186
|
+
const hasProxy = [
|
|
187
|
+
"http_proxy",
|
|
188
|
+
"HTTP_PROXY",
|
|
189
|
+
"https_proxy",
|
|
190
|
+
"HTTPS_PROXY"
|
|
191
|
+
].some((key) => process.env[key]);
|
|
192
|
+
insecureDispatcher ??= hasProxy ? new EnvHttpProxyAgent({
|
|
193
|
+
connect: { rejectUnauthorized: false },
|
|
194
|
+
requestTls: { rejectUnauthorized: false }
|
|
195
|
+
}) : new Agent({ connect: { rejectUnauthorized: false } });
|
|
196
|
+
return await insecureFetch(target, {
|
|
197
|
+
...init,
|
|
198
|
+
redirect: "error",
|
|
199
|
+
dispatcher: insecureDispatcher
|
|
200
|
+
});
|
|
201
|
+
}
|
|
32
202
|
return await fetch(target, init);
|
|
33
203
|
} catch (error) {
|
|
34
204
|
if (init?.signal?.aborted) throw error;
|
|
@@ -689,7 +859,8 @@ function openBrowser(url) {
|
|
|
689
859
|
} catch {}
|
|
690
860
|
}
|
|
691
861
|
async function runLogin(options) {
|
|
692
|
-
const
|
|
862
|
+
const destination = options.apiUrl?.trim();
|
|
863
|
+
const connection = await resolveConnection({ apiUrl: destination && !destination.includes("://") ? `https://${destination}` : destination });
|
|
693
864
|
const api = new HowoneApi(connection.apiUrl, void 0);
|
|
694
865
|
const clientName = `${os.hostname()} (${process.platform})`;
|
|
695
866
|
const started = await api.request("POST", "/api/cli/v1/auth/device", {
|
|
@@ -713,17 +884,11 @@ async function runLogin(options) {
|
|
|
713
884
|
user: granted.user,
|
|
714
885
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
715
886
|
});
|
|
716
|
-
const skills = options.skill === false ? [] : await Promise.all(defaultSkillTargets().map(async (target) => ({
|
|
717
|
-
target,
|
|
718
|
-
dir: await installSkill(target, options.version)
|
|
719
|
-
})));
|
|
720
887
|
emit(options, {
|
|
721
888
|
user: granted.user,
|
|
722
|
-
apiUrl: connection.apiUrl
|
|
723
|
-
skills
|
|
889
|
+
apiUrl: connection.apiUrl
|
|
724
890
|
}, () => {
|
|
725
|
-
console.log(
|
|
726
|
-
for (const skill of skills) line(`skill (${skill.target})`, skill.dir);
|
|
891
|
+
console.log("Logged in as " + (granted.user.email ?? granted.user.id));
|
|
727
892
|
});
|
|
728
893
|
return;
|
|
729
894
|
} catch (error) {
|
|
@@ -1506,11 +1671,24 @@ const execFileAsync = promisify(execFile);
|
|
|
1506
1671
|
const DEFAULT_PROJECT_NAME = "howone-app";
|
|
1507
1672
|
const TEMPLATES = ["vite"];
|
|
1508
1673
|
const TEMPLATE_ALIASES = { vite: "vite" };
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1674
|
+
if (isAutoUpdateWorker()) runAutoUpdate({
|
|
1675
|
+
root: path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."),
|
|
1676
|
+
currentVersion: packageJson.version
|
|
1677
|
+
}).catch(() => {});
|
|
1678
|
+
else {
|
|
1679
|
+
scheduleAutoUpdate(path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."));
|
|
1680
|
+
main().catch((error) => {
|
|
1681
|
+
handleFatalError(error, process.argv.includes("--json"));
|
|
1682
|
+
});
|
|
1683
|
+
}
|
|
1512
1684
|
async function main() {
|
|
1513
1685
|
const command = parseCommand(process.argv.slice(2));
|
|
1686
|
+
if (command.options.insecure && !command.options.help && !command.options.version) {
|
|
1687
|
+
const destination = command.options.apiUrl?.trim();
|
|
1688
|
+
const connection = await resolveConnection({ apiUrl: destination && !destination.includes("://") ? `https://${destination}` : destination });
|
|
1689
|
+
configureInsecureTls(connection.apiUrl);
|
|
1690
|
+
console.error(`Warning: --insecure disables TLS certificate verification for ${new URL(connection.apiUrl).origin} for this command only.`);
|
|
1691
|
+
}
|
|
1514
1692
|
if (command.options.version) {
|
|
1515
1693
|
console.log(packageJson.version);
|
|
1516
1694
|
return;
|
|
@@ -1618,7 +1796,8 @@ function parseCommand(args) {
|
|
|
1618
1796
|
"skill",
|
|
1619
1797
|
"browser",
|
|
1620
1798
|
"fresh",
|
|
1621
|
-
"wait"
|
|
1799
|
+
"wait",
|
|
1800
|
+
"insecure"
|
|
1622
1801
|
],
|
|
1623
1802
|
default: {
|
|
1624
1803
|
build: true,
|
|
@@ -1668,6 +1847,7 @@ function parseCommand(args) {
|
|
|
1668
1847
|
prompt: typeof parsed.prompt === "string" ? parsed.prompt : void 0,
|
|
1669
1848
|
region: typeof parsed.region === "string" ? parsed.region : void 0,
|
|
1670
1849
|
apiUrl: typeof parsed["api-url"] === "string" ? parsed["api-url"] : void 0,
|
|
1850
|
+
insecure: Boolean(parsed.insecure),
|
|
1671
1851
|
token: typeof parsed.token === "string" ? parsed.token : void 0,
|
|
1672
1852
|
stream: Boolean(parsed.stream),
|
|
1673
1853
|
status: typeof parsed.status === "string" ? parsed.status : void 0,
|
|
@@ -2275,7 +2455,7 @@ function printRootHelp() {
|
|
|
2275
2455
|
`${pc.dim("Usage")} howone <command> [options]`,
|
|
2276
2456
|
"",
|
|
2277
2457
|
pc.bold("Account"),
|
|
2278
|
-
formatCommand("login", "Log in from the browser
|
|
2458
|
+
formatCommand("login", "Log in from the browser"),
|
|
2279
2459
|
formatCommand("logout", "Revoke this machine's token"),
|
|
2280
2460
|
formatCommand("whoami", "Show the logged-in user"),
|
|
2281
2461
|
formatCommand("setup [remove]", "Install (or remove) the skill for Claude Code / Codex"),
|
|
@@ -2312,6 +2492,7 @@ function printRootHelp() {
|
|
|
2312
2492
|
formatCommand("-v, --version", "Show version"),
|
|
2313
2493
|
formatCommand("--app <app>", "Which app (default: the pulled directory you are in)"),
|
|
2314
2494
|
formatCommand("--json", "Machine-readable output (for agents and CI)"),
|
|
2495
|
+
formatCommand("--insecure", "Skip API TLS certificate verification for this command only"),
|
|
2315
2496
|
"",
|
|
2316
2497
|
pc.bold("Examples"),
|
|
2317
2498
|
` ${pc.cyan("howone login")}`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@howone/agent-cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
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,13 +28,15 @@
|
|
|
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",
|
|
34
36
|
"@clack/prompts": "^1.3.0",
|
|
35
37
|
"fs-extra": "^11.3.4",
|
|
36
38
|
"picocolors": "^1.1.1",
|
|
39
|
+
"undici": "^6.27.0",
|
|
37
40
|
"validate-npm-package-name": "^7.0.2",
|
|
38
41
|
"yargs-parser": "^22.0.0"
|
|
39
42
|
},
|
|
@@ -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,
|