@howone/agent-cli 0.5.4 → 0.5.5
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 +2 -0
- package/bin/index.mjs +121 -63
- package/package.json +1 -1
- package/skills/howone/02-develop.md +2 -0
- package/skills/howone/SKILL.md +8 -0
- package/templates/vite/.npmrc.template +2 -0
- package/templates/vite/AGENTS.md +1 -0
package/README.md
CHANGED
|
@@ -33,6 +33,8 @@ 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
|
+
模板自带无凭据的 `.npmrc`,把 `@howone/*` 指向 HowOne 私有 npm 仓库;使用者需在自己的
|
|
37
|
+
npm 配置中提供该仓库的登录凭据,CLI 不会把 token 写进项目或模板。
|
|
36
38
|
|
|
37
39
|
## npm 安装
|
|
38
40
|
|
package/bin/index.mjs
CHANGED
|
@@ -202,49 +202,54 @@ async function networkFetch(url, init) {
|
|
|
202
202
|
return await fetch(target, init);
|
|
203
203
|
} catch (error) {
|
|
204
204
|
if (init?.signal?.aborted) throw error;
|
|
205
|
-
|
|
206
|
-
const seen = /* @__PURE__ */ new Set();
|
|
207
|
-
function visit(value) {
|
|
208
|
-
if (!(value instanceof Error) || seen.has(value) || seen.size >= 16) return;
|
|
209
|
-
seen.add(value);
|
|
210
|
-
const code = value.code;
|
|
211
|
-
if (typeof code === "string" && /^[A-Z][A-Z0-9_]+$/.test(code)) codes.add(code);
|
|
212
|
-
visit(value.cause);
|
|
213
|
-
if (value instanceof AggregateError) for (const child of value.errors) visit(child);
|
|
214
|
-
}
|
|
215
|
-
visit(error);
|
|
216
|
-
const has = (...values) => values.some((code) => codes.has(code));
|
|
217
|
-
let stage = "connection";
|
|
218
|
-
let hint = "Check VPN routing and whether Node.js uses the same proxy as your browser.";
|
|
219
|
-
if (has("ENOTFOUND", "EAI_AGAIN", "EAI_NONAME")) {
|
|
220
|
-
stage = "dns";
|
|
221
|
-
hint = "DNS lookup failed. Check that your VPN provides DNS for this domain. On macOS, run scutil --dns.";
|
|
222
|
-
} else if ([...codes].some((code) => /CERT|SELF_SIGNED|UNABLE_TO_VERIFY|UNABLE_TO_GET_ISSUER|^ERR_SSL_/.test(code))) {
|
|
223
|
-
stage = "tls";
|
|
224
|
-
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.";
|
|
225
|
-
} else if (has("ETIMEDOUT", "UND_ERR_CONNECT_TIMEOUT", "UND_ERR_HEADERS_TIMEOUT")) hint = "Connection timed out. Check the VPN route, firewall and proxy.";
|
|
226
|
-
else if (has("ECONNREFUSED", "ECONNRESET", "UND_ERR_SOCKET", "EPIPE")) hint = "Connection refused or closed. Check that the server and any configured proxy are reachable.";
|
|
227
|
-
const method = init?.method ?? "GET";
|
|
228
|
-
const endpoint = target.origin + target.pathname;
|
|
229
|
-
const reason = [...codes].join(", ") || "no system error code reported";
|
|
230
|
-
throw new CliError("E_NETWORK", `${method} ${endpoint} failed (${stage}: ${reason}). ${hint}`, {
|
|
231
|
-
method,
|
|
232
|
-
endpoint,
|
|
233
|
-
stage,
|
|
234
|
-
codes: [...codes],
|
|
235
|
-
hint,
|
|
236
|
-
nodeVersion: process.version,
|
|
237
|
-
proxyEnvironment: [
|
|
238
|
-
"HTTPS_PROXY",
|
|
239
|
-
"HTTP_PROXY",
|
|
240
|
-
"ALL_PROXY",
|
|
241
|
-
"https_proxy",
|
|
242
|
-
"http_proxy",
|
|
243
|
-
"all_proxy"
|
|
244
|
-
].filter((key) => Boolean(process.env[key]))
|
|
245
|
-
});
|
|
205
|
+
throw networkError(url, init, error);
|
|
246
206
|
}
|
|
247
207
|
}
|
|
208
|
+
/** Format transport errors without exposing credentials or query strings. */
|
|
209
|
+
function networkError(url, init, error) {
|
|
210
|
+
const target = new URL(url);
|
|
211
|
+
const codes = /* @__PURE__ */ new Set();
|
|
212
|
+
const seen = /* @__PURE__ */ new Set();
|
|
213
|
+
function visit(value) {
|
|
214
|
+
if (!(value instanceof Error) || seen.has(value) || seen.size >= 16) return;
|
|
215
|
+
seen.add(value);
|
|
216
|
+
const code = value.code;
|
|
217
|
+
if (typeof code === "string" && /^[A-Z][A-Z0-9_]+$/.test(code)) codes.add(code);
|
|
218
|
+
visit(value.cause);
|
|
219
|
+
if (value instanceof AggregateError) for (const child of value.errors) visit(child);
|
|
220
|
+
}
|
|
221
|
+
visit(error);
|
|
222
|
+
const has = (...values) => values.some((code) => codes.has(code));
|
|
223
|
+
let stage = "connection";
|
|
224
|
+
let hint = "Check VPN routing and whether Node.js uses the same proxy as your browser.";
|
|
225
|
+
if (has("ENOTFOUND", "EAI_AGAIN", "EAI_NONAME")) {
|
|
226
|
+
stage = "dns";
|
|
227
|
+
hint = "DNS lookup failed. Check that your VPN provides DNS for this domain. On macOS, run scutil --dns.";
|
|
228
|
+
} else if ([...codes].some((code) => /CERT|SELF_SIGNED|UNABLE_TO_VERIFY|UNABLE_TO_GET_ISSUER|^ERR_SSL_/.test(code))) {
|
|
229
|
+
stage = "tls";
|
|
230
|
+
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.";
|
|
231
|
+
} else if (has("ETIMEDOUT", "UND_ERR_CONNECT_TIMEOUT", "UND_ERR_HEADERS_TIMEOUT")) hint = "Connection timed out. Check the VPN route, firewall and proxy.";
|
|
232
|
+
else if (has("ECONNREFUSED", "ECONNRESET", "UND_ERR_SOCKET", "EPIPE")) hint = "Connection refused or closed. Check that the server and any configured proxy are reachable.";
|
|
233
|
+
const method = init?.method ?? "GET";
|
|
234
|
+
const endpoint = target.origin + target.pathname;
|
|
235
|
+
const reason = [...codes].join(", ") || "no system error code reported";
|
|
236
|
+
return new CliError("E_NETWORK", `${method} ${endpoint} failed (${stage}: ${reason}). ${hint}`, {
|
|
237
|
+
method,
|
|
238
|
+
endpoint,
|
|
239
|
+
stage,
|
|
240
|
+
codes: [...codes],
|
|
241
|
+
hint,
|
|
242
|
+
nodeVersion: process.version,
|
|
243
|
+
proxyEnvironment: [
|
|
244
|
+
"HTTPS_PROXY",
|
|
245
|
+
"HTTP_PROXY",
|
|
246
|
+
"ALL_PROXY",
|
|
247
|
+
"https_proxy",
|
|
248
|
+
"http_proxy",
|
|
249
|
+
"all_proxy"
|
|
250
|
+
].filter((key) => Boolean(process.env[key]))
|
|
251
|
+
});
|
|
252
|
+
}
|
|
248
253
|
function configDir() {
|
|
249
254
|
const base = process.env.XDG_CONFIG_HOME || path.join(os.homedir(), ".config");
|
|
250
255
|
return path.join(base, "howone");
|
|
@@ -323,11 +328,29 @@ var HowoneApi = class HowoneApi {
|
|
|
323
328
|
return headers;
|
|
324
329
|
}
|
|
325
330
|
async request(method, apiPath, options = {}) {
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
+
const retries = options.retryNetwork ?? (/^(GET|HEAD)$/i.test(method) ? 2 : 0);
|
|
332
|
+
for (let attempt = 0;; attempt += 1) {
|
|
333
|
+
options.signal?.throwIfAborted();
|
|
334
|
+
try {
|
|
335
|
+
const response = await this.fetch(method, apiPath, options);
|
|
336
|
+
const text = await response.text().catch((error) => {
|
|
337
|
+
if (options.signal?.aborted) throw error;
|
|
338
|
+
throw networkError(this.url(apiPath, options.query), { method }, error);
|
|
339
|
+
});
|
|
340
|
+
const body = text ? parseJson(text) : null;
|
|
341
|
+
if (!response.ok) throw toApiError(response.status, body);
|
|
342
|
+
return body;
|
|
343
|
+
} catch (error) {
|
|
344
|
+
if (attempt >= retries || !isTransientNetworkError(error, options.signal)) {
|
|
345
|
+
if (attempt > 0 && error instanceof CliError && error.code === "E_NETWORK") throw new CliError(error.code, error.message, {
|
|
346
|
+
...error.details,
|
|
347
|
+
attempts: attempt + 1
|
|
348
|
+
});
|
|
349
|
+
throw error;
|
|
350
|
+
}
|
|
351
|
+
await delay(250 * 2 ** attempt);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
331
354
|
}
|
|
332
355
|
/** 读 text/event-stream,每个事件回调一次;服务端发 `event: error` 时抛错。 */
|
|
333
356
|
async stream(method, apiPath, options, onEvent) {
|
|
@@ -365,11 +388,30 @@ var HowoneApi = class HowoneApi {
|
|
|
365
388
|
signal: options.signal
|
|
366
389
|
});
|
|
367
390
|
} catch (error) {
|
|
368
|
-
if (error instanceof CliError) throw error;
|
|
391
|
+
if (options.signal?.aborted || error instanceof CliError) throw error;
|
|
369
392
|
throw new CliError("E_NETWORK", `Cannot reach ${this.apiUrl}: ${error instanceof Error ? error.message : String(error)}`);
|
|
370
393
|
}
|
|
371
394
|
}
|
|
372
395
|
};
|
|
396
|
+
const TRANSIENT_NETWORK_CODES = new Set([
|
|
397
|
+
"ECONNRESET",
|
|
398
|
+
"ETIMEDOUT",
|
|
399
|
+
"UND_ERR_CONNECT_TIMEOUT",
|
|
400
|
+
"UND_ERR_HEADERS_TIMEOUT",
|
|
401
|
+
"UND_ERR_BODY_TIMEOUT",
|
|
402
|
+
"UND_ERR_SOCKET",
|
|
403
|
+
"EPIPE",
|
|
404
|
+
"EAI_AGAIN"
|
|
405
|
+
]);
|
|
406
|
+
function isTransientNetworkError(error, signal) {
|
|
407
|
+
if (signal?.aborted || !(error instanceof CliError) || error.code !== "E_NETWORK") return false;
|
|
408
|
+
if (error.details?.stage === "tls") return false;
|
|
409
|
+
const codes = error.details?.codes;
|
|
410
|
+
return Array.isArray(codes) && codes.some((code) => typeof code === "string" && TRANSIENT_NETWORK_CODES.has(code));
|
|
411
|
+
}
|
|
412
|
+
function delay(milliseconds) {
|
|
413
|
+
return new Promise((resolve) => setTimeout(resolve, milliseconds));
|
|
414
|
+
}
|
|
373
415
|
function parseSseChunk(chunk) {
|
|
374
416
|
let event = "message";
|
|
375
417
|
const data = [];
|
|
@@ -734,20 +776,26 @@ async function syncToSandbox(input) {
|
|
|
734
776
|
const actual = sha256(Buffer.from(write.contentBase64, "base64"));
|
|
735
777
|
if (actual !== write.sha256) write.sha256 = actual;
|
|
736
778
|
}
|
|
737
|
-
const result = await input.api.request("POST", `${appPath$1(input.app)}/sync`, {
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
779
|
+
const result = await input.api.request("POST", `${appPath$1(input.app)}/sync`, {
|
|
780
|
+
retryNetwork: 2,
|
|
781
|
+
body: {
|
|
782
|
+
clientId: input.lock.clientId,
|
|
783
|
+
fenceToken: input.lock.fenceToken,
|
|
784
|
+
writes,
|
|
785
|
+
deletes: index === batches.length - 1 ? remove : []
|
|
786
|
+
}
|
|
787
|
+
});
|
|
743
788
|
dependenciesChanged ||= result.dependenciesChanged;
|
|
744
789
|
}
|
|
745
|
-
if (!batches.length && remove.length) await input.api.request("POST", `${appPath$1(input.app)}/sync`, {
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
790
|
+
if (!batches.length && remove.length) await input.api.request("POST", `${appPath$1(input.app)}/sync`, {
|
|
791
|
+
retryNetwork: 2,
|
|
792
|
+
body: {
|
|
793
|
+
clientId: input.lock.clientId,
|
|
794
|
+
fenceToken: input.lock.fenceToken,
|
|
795
|
+
writes: [],
|
|
796
|
+
deletes: remove
|
|
797
|
+
}
|
|
798
|
+
});
|
|
751
799
|
const removed = new Set(remove);
|
|
752
800
|
const uploaded = new Map(plan.upload.map((file) => [file.path, file.sha256]));
|
|
753
801
|
const next = [...remote.filter((file) => !removed.has(file.path) && !uploaded.has(file.path)), ...plan.upload.map((file) => ({
|
|
@@ -1043,6 +1091,7 @@ async function scaffoldTemplate(root) {
|
|
|
1043
1091
|
recursive: true,
|
|
1044
1092
|
filter: (source) => !path.relative(template, source).split(path.sep).includes("node_modules")
|
|
1045
1093
|
});
|
|
1094
|
+
await rename(path.join(root, ".npmrc.template"), path.join(root, ".npmrc"));
|
|
1046
1095
|
try {
|
|
1047
1096
|
await rename(path.join(root, "gitignore"), path.join(root, ".gitignore"));
|
|
1048
1097
|
} catch (error) {
|
|
@@ -2297,10 +2346,13 @@ async function installTemplateDependencies(plan, json) {
|
|
|
2297
2346
|
maxBuffer: 10 * 1024 * 1024
|
|
2298
2347
|
});
|
|
2299
2348
|
} catch (error) {
|
|
2300
|
-
throw new CliError("E_DEP_INSTALL_FAILED", "Failed to install dependencies with bun.
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2349
|
+
throw new CliError("E_DEP_INSTALL_FAILED", "Failed to install dependencies with bun. Check the install log below. For @howone/sdk 404/401/403 errors, verify the private @howone registry and credentials in your user npm config, then run bun install again. Do not put tokens in the project .npmrc.", {
|
|
2350
|
+
...error && typeof error === "object" ? {
|
|
2351
|
+
stdout: "stdout" in error ? String(error.stdout ?? "") : void 0,
|
|
2352
|
+
stderr: "stderr" in error ? String(error.stderr ?? "") : void 0
|
|
2353
|
+
} : void 0,
|
|
2354
|
+
registryHint: "https://devrepo.devcloud.cn-east-3.huaweicloud.com/artgalaxy/api/npm/"
|
|
2355
|
+
});
|
|
2304
2356
|
}
|
|
2305
2357
|
};
|
|
2306
2358
|
if (json) {
|
|
@@ -2324,10 +2376,16 @@ async function performCreateTemplate(plan, howoneContext) {
|
|
|
2324
2376
|
return !path.relative(templateDir, source).split(path.sep).includes("node_modules");
|
|
2325
2377
|
}
|
|
2326
2378
|
});
|
|
2379
|
+
await materializeTemplateNpmrc(plan.targetDir);
|
|
2327
2380
|
await restoreGitignore(plan.targetDir);
|
|
2328
2381
|
await writeHowoneEnvFile(plan, howoneContext);
|
|
2329
2382
|
await assertTemplateCopied(plan);
|
|
2330
2383
|
}
|
|
2384
|
+
async function materializeTemplateNpmrc(targetDir) {
|
|
2385
|
+
const template = path.join(targetDir, ".npmrc.template");
|
|
2386
|
+
if (!await pathExists(template)) return;
|
|
2387
|
+
await rename(template, path.join(targetDir, ".npmrc"));
|
|
2388
|
+
}
|
|
2331
2389
|
function normalizeHowoneEnv(value) {
|
|
2332
2390
|
const normalized = value?.trim().toLowerCase();
|
|
2333
2391
|
if (!normalized) return "dev";
|
package/package.json
CHANGED
|
@@ -105,3 +105,5 @@ Only after the user explicitly agreed, having seen the preview.
|
|
|
105
105
|
| `E_BUILD_FAILED` | build failed | read `details.build.log`, fix, push again |
|
|
106
106
|
| `E_SEAL_FAILED` | version rejected before build (functions, entities) | read `details`, fix, push again |
|
|
107
107
|
| `E_NOT_FOUND` | unknown app / version | re-check with `howone apps list` |
|
|
108
|
+
| `E_DEP_INSTALL_FAILED` | template dependency install failed | check the private `@howone` registry credentials in the user's npm config, then run `bun install` again; do not change the SDK version to a public npm version |
|
|
109
|
+
| `E_NETWORK` | transport failed | the CLI retries transient read/sync failures at most twice; if it still fails, inspect `details.codes`, proxy and VPN routing. `--insecure` only affects API TLS verification. Keep the existing App and query its state before repeating a mutation whose response was lost |
|
package/skills/howone/SKILL.md
CHANGED
|
@@ -13,6 +13,14 @@ human-readable output.
|
|
|
13
13
|
If `howone` is not on PATH, use `npx --yes @howone/agent-cli@<version>` with the version in
|
|
14
14
|
`.howone-cli.json` next to this file.
|
|
15
15
|
|
|
16
|
+
Before starting an app task, compare `howone --version` with `.howone-cli.json` when present.
|
|
17
|
+
If they differ, the normal `howone whoami --json` check refreshes previously installed Skills to
|
|
18
|
+
match that CLI. Read the marker again afterward. When the version differs from the instructions
|
|
19
|
+
already loaded in this session, reread this file and the relevant reference from disk. Background
|
|
20
|
+
CLI updates take effect on the next invocation; check again before resuming work after an update.
|
|
21
|
+
Do not assume an open session automatically reloads Skill files, or that version output alone
|
|
22
|
+
checks npm for updates.
|
|
23
|
+
|
|
16
24
|
## Pick the track
|
|
17
25
|
|
|
18
26
|
| The user wants to… | Read |
|
package/templates/vite/AGENTS.md
CHANGED
|
@@ -9,6 +9,7 @@ Read this file once when entering the project, follow it during implementation,
|
|
|
9
9
|
- Package manager: `bun`
|
|
10
10
|
- Common commands: `bun run dev`, `bun run typecheck`, `bun run build`
|
|
11
11
|
- The scaffold normally installs dependencies during `howone init app`. If `node_modules` is missing, run `bun install` before validation instead of treating missing binaries as code failures.
|
|
12
|
+
- `@howone/sdk` uses the private registry configured in the project `.npmrc`. If it returns 404/401/403, check that registry and user-level credentials; do not downgrade to a public npm version or add credentials to project files.
|
|
12
13
|
- Default stack: React, Vite, TypeScript, Tailwind CSS, shadcn/ui-style components, `@howone/sdk`
|
|
13
14
|
|
|
14
15
|
## Source of Truth
|