@yosai/cli 0.2.1-test.0 → 0.2.1-test.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/dist/cli.js +2 -1
- package/dist/commands/doctor.js +10 -5
- package/dist/commands/login.js +14 -9
- package/dist/commands/ping.js +5 -3
- package/dist/commands/version.js +4 -2
- package/dist/config.js +22 -7
- package/dist/endpoints.js +28 -1
- package/dist/openapis-client.js +7 -3
- package/dist/skills/yos/SKILL.md +3 -3
- package/dist/skills/yos-install/SKILL.md +8 -7
- package/dist/skills/yos-shared/SKILL.md +7 -7
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -25,7 +25,8 @@ export function renderHelp() {
|
|
|
25
25
|
'',
|
|
26
26
|
'环境变量(均优先于配置文件,便于 CI 免落盘):',
|
|
27
27
|
' YOS_API_KEY 访问令牌',
|
|
28
|
-
'
|
|
28
|
+
' YOS_ENV 服务环境(prod / test / dev;缺省生产)',
|
|
29
|
+
' YOS_ENDPOINT 自定义服务地址(CI / 本地联调,一般无需设置)',
|
|
29
30
|
' YOS_CONFIG_DIR 配置目录(缺省 ~/.config/yos)',
|
|
30
31
|
'',
|
|
31
32
|
'示例:',
|
package/dist/commands/doctor.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { register } from '../cli.js';
|
|
2
2
|
import { loadConfig, maskKey, resolveEndpoint, resolveKey } from '../config.js';
|
|
3
|
+
import { envLabel } from '../endpoints.js';
|
|
3
4
|
import { CliError, EXIT } from '../errors.js';
|
|
4
5
|
import { formatIdentity, OpenApisClient } from '../openapis-client.js';
|
|
5
6
|
import { print, printJson } from '../output.js';
|
|
@@ -15,15 +16,16 @@ register({
|
|
|
15
16
|
async run({ flags }) {
|
|
16
17
|
const checks = [];
|
|
17
18
|
const config = loadConfig();
|
|
19
|
+
const endpoint = resolveEndpoint(config);
|
|
18
20
|
checks.push({
|
|
19
21
|
name: '配置文件',
|
|
20
22
|
ok: config !== null,
|
|
21
23
|
detail: config ? '已找到' : '未找到,请执行 yos login',
|
|
22
24
|
});
|
|
23
25
|
checks.push({
|
|
24
|
-
name: '
|
|
26
|
+
name: '服务环境',
|
|
25
27
|
ok: true,
|
|
26
|
-
detail: `${
|
|
28
|
+
detail: `${envLabel(endpoint)}(来自 ${endpointSource(config)})`,
|
|
27
29
|
});
|
|
28
30
|
let key = null;
|
|
29
31
|
try {
|
|
@@ -39,7 +41,7 @@ register({
|
|
|
39
41
|
}
|
|
40
42
|
else {
|
|
41
43
|
try {
|
|
42
|
-
const identity = await new OpenApisClient(`${
|
|
44
|
+
const identity = await new OpenApisClient(`${endpoint}/open-apis`, key).whoami();
|
|
43
45
|
checks.push({ name: '服务连通', ok: true, detail: `身份 ${formatIdentity(identity)}` });
|
|
44
46
|
}
|
|
45
47
|
catch (e) {
|
|
@@ -58,7 +60,7 @@ register({
|
|
|
58
60
|
checks.push({
|
|
59
61
|
name: 'CLI 版本',
|
|
60
62
|
ok: meta !== null,
|
|
61
|
-
detail: meta ? `${meta.version}
|
|
63
|
+
detail: meta ? `${meta.version}(环境=${envLabel(endpoint)})` : 'unknown(未找到 package.json)',
|
|
62
64
|
});
|
|
63
65
|
const state = loadVersionState();
|
|
64
66
|
checks.push({
|
|
@@ -83,7 +85,10 @@ function endpointSource(config) {
|
|
|
83
85
|
if (process.env.YOS_ENDPOINT) {
|
|
84
86
|
return 'YOS_ENDPOINT';
|
|
85
87
|
}
|
|
86
|
-
|
|
88
|
+
if (process.env.YOS_ENV) {
|
|
89
|
+
return 'YOS_ENV';
|
|
90
|
+
}
|
|
91
|
+
return config?.endpoint || config?.env ? '配置文件' : '内置缺省';
|
|
87
92
|
}
|
|
88
93
|
function skillSyncDetail(meta, state, skillDirs) {
|
|
89
94
|
if (skillDirs.length === 0) {
|
package/dist/commands/login.js
CHANGED
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
import { register } from '../cli.js';
|
|
2
|
-
import { loadConfig, maskKey,
|
|
3
|
-
import {
|
|
2
|
+
import { loadConfig, maskKey, resolveEndpoint, saveConfig } from '../config.js';
|
|
3
|
+
import { envLabel, envNameOf } from '../endpoints.js';
|
|
4
4
|
import { UsageError } from '../errors.js';
|
|
5
5
|
import { formatIdentity, OpenApisClient } from '../openapis-client.js';
|
|
6
6
|
import { print } from '../output.js';
|
|
7
7
|
import { readHiddenLine } from '../prompt.js';
|
|
8
8
|
register({
|
|
9
9
|
name: 'login',
|
|
10
|
-
description: '
|
|
11
|
-
usage: 'yos login [--endpoint <url>] [--key <key>]',
|
|
10
|
+
description: '配置访问令牌与服务环境(校验身份后保存)',
|
|
11
|
+
usage: 'yos login [--env <name>] [--endpoint <url>] [--key <key>]',
|
|
12
12
|
group: '基础',
|
|
13
13
|
options: {
|
|
14
|
+
env: { type: 'string' },
|
|
14
15
|
endpoint: { type: 'string' },
|
|
15
16
|
key: { type: 'string' },
|
|
16
17
|
},
|
|
17
18
|
paramNotes: [
|
|
18
|
-
['--
|
|
19
|
+
['--env', '服务环境(prod / test / dev;缺省读 YOS_ENV,再缺省生产)'],
|
|
20
|
+
['--endpoint', '自定义服务地址(本地联调等;优先于 --env)'],
|
|
19
21
|
['--key', '访问令牌(40 位小写 hex,缺省读 YOS_API_KEY,否则交互输入)'],
|
|
20
22
|
],
|
|
21
23
|
async run({ flags }) {
|
|
22
24
|
const config = loadConfig();
|
|
23
|
-
const endpoint =
|
|
24
|
-
|
|
25
|
+
const endpoint = resolveEndpoint(config, {
|
|
26
|
+
endpoint: flags.endpoint,
|
|
27
|
+
env: flags.env,
|
|
28
|
+
});
|
|
25
29
|
const key = flags.key
|
|
26
30
|
?? process.env.YOS_API_KEY
|
|
27
31
|
?? await readHiddenLine('请粘贴访问令牌(输入不回显,客户端「个人设置-访问令牌」页创建并复制): ');
|
|
@@ -29,7 +33,8 @@ register({
|
|
|
29
33
|
throw new UsageError('令牌格式不正确(应为 40 位小写 hex)', '请在客户端「个人设置-访问令牌」页创建并复制完整令牌');
|
|
30
34
|
}
|
|
31
35
|
const identity = await new OpenApisClient(`${endpoint}/open-apis`, key).whoami();
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
const envName = envNameOf(endpoint);
|
|
37
|
+
saveConfig({ ...config, env: envName ?? undefined, endpoint: envName ? undefined : endpoint, apiKey: key });
|
|
38
|
+
print(`已保存配置:环境=${envLabel(endpoint)},key=${maskKey(key)},身份 ${formatIdentity(identity)}`);
|
|
34
39
|
},
|
|
35
40
|
});
|
package/dist/commands/ping.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { register } from '../cli.js';
|
|
2
2
|
import { loadConfig, resolveEndpoint, resolveKey } from '../config.js';
|
|
3
|
+
import { envNameOf } from '../endpoints.js';
|
|
3
4
|
import { CliError, EXIT } from '../errors.js';
|
|
4
5
|
import { formatIdentity, OpenApisClient } from '../openapis-client.js';
|
|
5
6
|
import { print, printErr, printJson } from '../output.js';
|
|
@@ -9,14 +10,15 @@ register({
|
|
|
9
10
|
usage: 'yos ping [--json]',
|
|
10
11
|
group: '基础',
|
|
11
12
|
options: { json: { type: 'boolean' } },
|
|
12
|
-
paramNotes: [['--json', '结构化输出(ok /
|
|
13
|
+
paramNotes: [['--json', '结构化输出(ok / env / userCode / userName / error)']],
|
|
13
14
|
async run({ flags }) {
|
|
14
15
|
const config = loadConfig();
|
|
15
16
|
const endpoint = resolveEndpoint(config);
|
|
17
|
+
const env = envNameOf(endpoint) ?? endpoint;
|
|
16
18
|
try {
|
|
17
19
|
const identity = await new OpenApisClient(`${endpoint}/open-apis`, resolveKey(config)).whoami();
|
|
18
20
|
if (flags.json) {
|
|
19
|
-
printJson({ ok: true,
|
|
21
|
+
printJson({ ok: true, env, userCode: identity.userCode, userName: identity.userName });
|
|
20
22
|
}
|
|
21
23
|
else {
|
|
22
24
|
print(`✓ 连接成功,令牌有效:身份 ${formatIdentity(identity)}`);
|
|
@@ -26,7 +28,7 @@ register({
|
|
|
26
28
|
catch (e) {
|
|
27
29
|
const failure = e instanceof CliError ? e : new CliError(String(e), EXIT.BUSINESS);
|
|
28
30
|
if (flags.json) {
|
|
29
|
-
printJson({ ok: false,
|
|
31
|
+
printJson({ ok: false, env, error: failure.message });
|
|
30
32
|
}
|
|
31
33
|
else {
|
|
32
34
|
printErr(`错误: ${failure.message}`);
|
package/dist/commands/version.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { register } from '../cli.js';
|
|
2
2
|
import { loadConfig, resolveEndpoint } from '../config.js';
|
|
3
|
+
import { envNameOf } from '../endpoints.js';
|
|
3
4
|
import { BusinessError } from '../errors.js';
|
|
4
5
|
import { compareVersions, detectGlobalInstall, fetchLatestVersion, readPackageMeta } from '../npm-meta.js';
|
|
5
6
|
import { print, printJson } from '../output.js';
|
|
@@ -18,10 +19,11 @@ register({
|
|
|
18
19
|
const meta = readPackageMeta();
|
|
19
20
|
const version = meta?.version ?? 'unknown';
|
|
20
21
|
const endpoint = resolveEndpoint(loadConfig());
|
|
22
|
+
const env = envNameOf(endpoint) ?? endpoint;
|
|
21
23
|
if (!flags.check) {
|
|
22
24
|
if (flags.json) {
|
|
23
25
|
const installedGlobally = meta ? (await detectGlobalInstall(meta)).global : false;
|
|
24
|
-
printJson({ version, installedGlobally,
|
|
26
|
+
printJson({ version, installedGlobally, env });
|
|
25
27
|
}
|
|
26
28
|
else {
|
|
27
29
|
print(`yos CLI ${version}`);
|
|
@@ -34,7 +36,7 @@ register({
|
|
|
34
36
|
const latest = await fetchLatestVersion(meta.name);
|
|
35
37
|
const outdated = compareVersions(meta.version, latest) < 0;
|
|
36
38
|
if (flags.json) {
|
|
37
|
-
printJson({ version, latest, outdated, installedGlobally: (await detectGlobalInstall(meta)).global,
|
|
39
|
+
printJson({ version, latest, outdated, installedGlobally: (await detectGlobalInstall(meta)).global, env });
|
|
38
40
|
return;
|
|
39
41
|
}
|
|
40
42
|
print(outdated
|
package/dist/config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { homedir } from 'node:os';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
-
import { DEFAULT_ENDPOINT } from './endpoints.js';
|
|
4
|
+
import { DEFAULT_ENDPOINT, DEFAULT_ENV, endpointOfEnv } from './endpoints.js';
|
|
5
5
|
import { UsageError } from './errors.js';
|
|
6
6
|
export function configDir() {
|
|
7
7
|
return process.env.YOS_CONFIG_DIR ?? join(homedir(), '.config', 'yos');
|
|
@@ -35,12 +35,26 @@ export function resolveKey(config) {
|
|
|
35
35
|
}
|
|
36
36
|
throw new UsageError('未配置访问令牌', '请执行 `yos login` 或设置环境变量 YOS_API_KEY');
|
|
37
37
|
}
|
|
38
|
-
export function resolveEndpoint(config) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
export function resolveEndpoint(config, flags) {
|
|
39
|
+
if (flags?.endpoint) {
|
|
40
|
+
return normalizeEndpoint(flags.endpoint);
|
|
41
|
+
}
|
|
42
|
+
if (flags?.env) {
|
|
43
|
+
return endpointOfEnv(flags.env);
|
|
44
|
+
}
|
|
45
|
+
if (process.env.YOS_ENDPOINT) {
|
|
46
|
+
return normalizeEndpoint(process.env.YOS_ENDPOINT);
|
|
47
|
+
}
|
|
48
|
+
if (process.env.YOS_ENV) {
|
|
49
|
+
return endpointOfEnv(process.env.YOS_ENV);
|
|
50
|
+
}
|
|
51
|
+
if (config?.endpoint) {
|
|
52
|
+
return normalizeEndpoint(config.endpoint);
|
|
53
|
+
}
|
|
54
|
+
if (config?.env) {
|
|
55
|
+
return endpointOfEnv(config.env);
|
|
42
56
|
}
|
|
43
|
-
return
|
|
57
|
+
return DEFAULT_ENDPOINT;
|
|
44
58
|
}
|
|
45
59
|
export function normalizeEndpoint(endpoint) {
|
|
46
60
|
return endpoint.replace(/\/+$/, '');
|
|
@@ -49,7 +63,8 @@ export function maskKey(key) {
|
|
|
49
63
|
return key.length <= 12 ? '****' : `${key.slice(0, 8)}****${key.slice(-4)}`;
|
|
50
64
|
}
|
|
51
65
|
export function updateConfig(patch) {
|
|
52
|
-
const
|
|
66
|
+
const existing = loadConfig();
|
|
67
|
+
const merged = existing ? { ...existing, ...patch } : { env: DEFAULT_ENV, ...patch };
|
|
53
68
|
saveConfig(merged);
|
|
54
69
|
return merged;
|
|
55
70
|
}
|
package/dist/endpoints.js
CHANGED
|
@@ -1 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
import { UsageError } from './errors.js';
|
|
2
|
+
export const ENVIRONMENTS = {
|
|
3
|
+
prod: { url: 'https://yos-bff.linkduoo.com', label: '生产' },
|
|
4
|
+
test: { url: 'https://yos-bff-test.linkduoo.com', label: '测试' },
|
|
5
|
+
dev: { url: 'http://localhost:8080', label: '开发' },
|
|
6
|
+
};
|
|
7
|
+
export const DEFAULT_ENV = 'prod';
|
|
8
|
+
export const DEFAULT_ENDPOINT = ENVIRONMENTS[DEFAULT_ENV].url;
|
|
9
|
+
export function endpointOfEnv(env) {
|
|
10
|
+
const found = ENVIRONMENTS[env];
|
|
11
|
+
if (!found) {
|
|
12
|
+
throw new UsageError(`无法识别的环境:${env}`, `可用环境:${Object.keys(ENVIRONMENTS).join(' / ')}`);
|
|
13
|
+
}
|
|
14
|
+
return found.url;
|
|
15
|
+
}
|
|
16
|
+
export function envNameOf(endpoint) {
|
|
17
|
+
const normalized = endpoint.replace(/\/+$/, '');
|
|
18
|
+
for (const [name, env] of Object.entries(ENVIRONMENTS)) {
|
|
19
|
+
if (env.url === normalized) {
|
|
20
|
+
return name;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
export function envLabel(endpoint) {
|
|
26
|
+
const name = envNameOf(endpoint);
|
|
27
|
+
return name ? ENVIRONMENTS[name].label : endpoint;
|
|
28
|
+
}
|
package/dist/openapis-client.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readFile, stat } from 'node:fs/promises';
|
|
2
2
|
import { basename } from 'node:path';
|
|
3
|
+
import { envLabel } from './endpoints.js';
|
|
3
4
|
import { AuthError, BusinessError, NetworkError } from './errors.js';
|
|
4
5
|
export const MAX_UPLOAD_SIZE_BYTES = 20 * 1024 * 1024;
|
|
5
6
|
export function formatIdentity(identity) {
|
|
@@ -38,11 +39,14 @@ export class OpenApisClient {
|
|
|
38
39
|
});
|
|
39
40
|
}
|
|
40
41
|
catch (e) {
|
|
41
|
-
throw new NetworkError(`无法连接 YOS
|
|
42
|
+
throw new NetworkError(`无法连接 YOS 服务(${envLabelOfBase(this.base)}),原因:${e.message}`);
|
|
42
43
|
}
|
|
43
44
|
return parseEnvelope(response);
|
|
44
45
|
}
|
|
45
46
|
}
|
|
47
|
+
function envLabelOfBase(base) {
|
|
48
|
+
return envLabel(base.replace(/\/open-apis$/, ''));
|
|
49
|
+
}
|
|
46
50
|
async function parseEnvelope(response) {
|
|
47
51
|
if (response.status === 401) {
|
|
48
52
|
let reason = '访问令牌无效或已过期';
|
|
@@ -57,7 +61,7 @@ async function parseEnvelope(response) {
|
|
|
57
61
|
throw new AuthError(`鉴权失败:${reason}`);
|
|
58
62
|
}
|
|
59
63
|
if (response.status === 404) {
|
|
60
|
-
throw new NetworkError(`HTTP 404:服务端不存在该接口(${response.url})`, '
|
|
64
|
+
throw new NetworkError(`HTTP 404:服务端不存在该接口(${response.url})`, '确认服务端已部署开放接口通道;环境配置有误时用 yos login 重新指定');
|
|
61
65
|
}
|
|
62
66
|
let payload;
|
|
63
67
|
try {
|
|
@@ -106,7 +110,7 @@ export async function uploadKnowledgeFile(endpoint, apiKey, filePath, kbCode, pa
|
|
|
106
110
|
});
|
|
107
111
|
}
|
|
108
112
|
catch (e) {
|
|
109
|
-
throw new NetworkError(`无法连接 YOS
|
|
113
|
+
throw new NetworkError(`无法连接 YOS 服务(${envLabel(endpoint)}),原因:${e.message}`);
|
|
110
114
|
}
|
|
111
115
|
return parseEnvelope(response);
|
|
112
116
|
}
|
package/dist/skills/yos/SKILL.md
CHANGED
|
@@ -10,7 +10,7 @@ YOS 是企业 AI 底座:公司知识、会议录音、帮助手册等能力都
|
|
|
10
10
|
## 0. 开工前先确认环境(30 秒)
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
|
-
yos doctor # 七项 ✓ 才继续:配置文件 /
|
|
13
|
+
yos doctor # 七项 ✓ 才继续:配置文件 / 服务环境 / 访问令牌 / 服务连通(回显身份)/ Skill 安装 / CLI 版本 / Skill 同步
|
|
14
14
|
yos ping # 只要探活,退出码即结论(0 通 / 3 网络 / 4 鉴权)
|
|
15
15
|
```
|
|
16
16
|
|
|
@@ -50,8 +50,8 @@ yos ping # 只要探活,退出码即结论(0 通 / 3 网络 / 4 鉴
|
|
|
50
50
|
|
|
51
51
|
1. 用户在 YOS 客户端「个人设置-访问令牌」页创建并复制令牌(40 位小写 hex)
|
|
52
52
|
2. `yos login` 交互粘贴(不回显);Agent 代执行时用 `yos login --key <令牌>`(注意令牌会进入 shell 历史,优先让用户自己在终端执行,或用 `YOS_API_KEY`)
|
|
53
|
-
3. 配置文件 `~/.config/yos/config.json`(0600
|
|
54
|
-
4.
|
|
53
|
+
3. 配置文件 `~/.config/yos/config.json`(0600)。环境变量**优先于配置文件**:`YOS_CONFIG_DIR`(换配置目录)、`YOS_API_KEY`(换令牌)、`YOS_ENV`(换服务环境,如 test)
|
|
54
|
+
4. 服务环境缺省生产,切换用 `yos login --env test`(临时可用 `YOS_ENV=test`);`yos doctor` 会显示当前生效环境及其来源。开发者本地调试用 `--env dev`(指向本机 8080 起的服务),其他自定义地址用 `--endpoint <url>` / `YOS_ENDPOINT`,一般无需使用
|
|
55
55
|
5. 退出码 4 = 令牌无效/已吊销/已过期 → 引导重新 `yos login`,不要反复重试同一命令
|
|
56
56
|
|
|
57
57
|
## 4. 常用编排(已实测)
|
|
@@ -60,15 +60,15 @@ yos login --key '<40 位令牌>'
|
|
|
60
60
|
3. 成功输出(原样回给用户即可,`key` 已是掩码):
|
|
61
61
|
|
|
62
62
|
```
|
|
63
|
-
|
|
63
|
+
已保存配置:环境=生产,key=xxxxxxxx****xxxx,身份 张三(U00000001)
|
|
64
64
|
```
|
|
65
65
|
|
|
66
66
|
关键语义:
|
|
67
67
|
|
|
68
68
|
- `login` 会**先调服务端校验身份再落盘**,校验失败不写配置 → 报网络或令牌错时无需清理"半成品"配置,改对参数重跑即可
|
|
69
|
-
-
|
|
69
|
+
- 服务环境缺省为生产。切换环境用 `yos login --env test`(临时切换可先 `export YOS_ENV=test`);地址由 CLI 内置映射,无需关心。不指定时沿用已保存的环境
|
|
70
70
|
- 配置文件 `~/.config/yos/config.json`(目录 0700、文件 0600)
|
|
71
|
-
- CI/容器可完全跳过 `login`:`export YOS_API_KEY=<令牌>`、`export
|
|
71
|
+
- CI/容器可完全跳过 `login`:`export YOS_API_KEY=<令牌>`、`export YOS_ENV=test` 指定服务环境(两者都优先于配置文件);`YOS_CONFIG_DIR` 可换配置目录(多环境隔离用)
|
|
72
72
|
|
|
73
73
|
## 4. 安装内置 Skill 到 AI 工具
|
|
74
74
|
|
|
@@ -110,11 +110,11 @@ yos kb list --json # 端到端实跑一条只读命令收尾
|
|
|
110
110
|
|
|
111
111
|
```
|
|
112
112
|
✓ 配置文件: 已找到
|
|
113
|
-
✓
|
|
113
|
+
✓ 服务环境: 生产(来自 内置缺省)
|
|
114
114
|
✓ 访问令牌: xxxxxxxx****xxxx
|
|
115
115
|
✓ 服务连通: 身份 张三(U00000001)
|
|
116
116
|
✓ Skill 安装: ~/.claude/skills
|
|
117
|
-
✓ CLI 版本: 0.2.0
|
|
117
|
+
✓ CLI 版本: 0.2.0(环境=生产)
|
|
118
118
|
✗ Skill 同步: 缺少版本状态(Skill 目录 1 个),执行 yos update 重同步
|
|
119
119
|
```
|
|
120
120
|
|
|
@@ -148,7 +148,7 @@ ls ~/.claude/skills | grep -E '^yos' # 先看要删哪些,
|
|
|
148
148
|
| `npm error code E404` / `'@yosai/cli' is not in this registry` | 包名拼错、该版本尚未发布到 npmjs,或 npm 镜像未同步 | 核对包名 `@yosai/cli`;已发布仍 404 多为镜像未同步,加 `--registry=https://registry.npmjs.org` 重试;仍有问题联系维护者 |
|
|
149
149
|
| `npm error code EACCES`(写全局目录失败) | npm 全局前缀指向了 root 目录 | 让用户同意后再改前缀:`npm config set prefix ~/.npm-global`,把 `~/.npm-global/bin` 加进 PATH,重开终端重装。**不要 sudo** |
|
|
150
150
|
| `错误: 令牌格式不正确(应为 40 位小写 hex)` + `提示: 请在客户端「个人设置-访问令牌」页创建并复制完整令牌` | 令牌长度不对 / 大写 / 粘了空格或前缀 | 让用户重新整段复制(40 位、仅 `0-9a-f`);不要让用户逐字补 |
|
|
151
|
-
| `错误: 无法连接 YOS
|
|
151
|
+
| `错误: 无法连接 YOS 服务(生产),原因:fetch failed` | 服务不可达(环境选错、网络受限、服务异常) | 先 `yos doctor` 看「服务环境」项确认环境与来源;环境选错用 `yos login --env <环境>` 重配;网络问题找运维确认 |
|
|
152
152
|
| `未配置访问令牌` + `请执行 yos login 或设置环境变量 YOS_API_KEY` | 没配置也没 env | 回第 3 步 |
|
|
153
153
|
| `错误: 未发现已安装的 Agent 技能目录` | 本机没有已知的 AI 工具 Skill 目录 | `yos skill install --target <该工具 skills 目录>`,见第 4 步 |
|
|
154
154
|
| `yos --version` 无输出或报未知命令 | 装的是 0.2.0 之前的旧版本(旧版没有 version/update 命令) | 先 `npm install -g @yosai/cli@latest` 升到最新版(≥0.2.0),之后即可用 `yos version` / `yos update` |
|
|
@@ -159,4 +159,5 @@ ls ~/.claude/skills | grep -E '^yos' # 先看要删哪些,
|
|
|
159
159
|
- 让用户从 `yos` skill(总入口)开始使用;命令细节看各领域 skill:`yos-kb`(知识库管理)、`yos-retrieval`(检索与引用)、`yos-transcript`(录音转写)、`yos-support`(帮助/版本/反馈)、`yos-shared`(共享约定)
|
|
160
160
|
- 本机可用能力:28 个领域命令(kb 4 / docs 11 / retrieve 5 / support 6 / transcript 2)+ `yos tool` 兜底通道,覆盖知识库检索与管理、文档上传下载、会议转写查询、帮助手册、客户端版本与反馈;新建与删除知识库不在 CLI 内,需到 YOS 客户端手动操作
|
|
161
161
|
- 边界(别过度承诺):不能实时控制转写、不能申请/变更权限、反馈不带附件、只能看到当前令牌归属用户可见的数据
|
|
162
|
-
- 排查建议:任何失败先跑 `yos doctor`;退出码 `4` 一律重新登录,`3`
|
|
162
|
+
- 排查建议:任何失败先跑 `yos doctor`;退出码 `4` 一律重新登录,`3` 先看「服务环境」项与网络
|
|
163
|
+
|
|
@@ -17,11 +17,11 @@ yos doctor # 七项全 ✓ 才能继续;任一项 ✗ 按下方「未登
|
|
|
17
17
|
|
|
18
18
|
```
|
|
19
19
|
✓ 配置文件: 已找到
|
|
20
|
-
✓
|
|
20
|
+
✓ 服务环境: 生产(来自 内置缺省)
|
|
21
21
|
✓ 访问令牌: xxxxxxxx****xxxx
|
|
22
22
|
✓ 服务连通: 身份 张三(U00000001)
|
|
23
23
|
✓ Skill 安装: ~/.claude/skills, ~/.qoder-cn/skills
|
|
24
|
-
✓ CLI 版本: 0.2.0
|
|
24
|
+
✓ CLI 版本: 0.2.0(环境=生产)
|
|
25
25
|
✓ Skill 同步: 与 CLI 一致(2 个目录)
|
|
26
26
|
```
|
|
27
27
|
|
|
@@ -30,14 +30,14 @@ yos doctor # 七项全 ✓ 才能继续;任一项 ✗ 按下方「未登
|
|
|
30
30
|
| `command not found: yos` | CLI 未安装或全局 bin 不在 PATH,按 `yos-install` skill 引导安装(`npm install -g @yosai/cli` → `yos login` → 验证),不要继续猜命令 |
|
|
31
31
|
| `✗ 配置文件: 未找到,请执行 yos login` | 执行 `yos login --key <令牌>`(令牌由用户在 YOS 客户端「个人设置-访问令牌」页创建并复制,40 位小写 hex) |
|
|
32
32
|
| `✗ 访问令牌: 未配置访问令牌` | 同上;CI/容器可改为设置环境变量 `YOS_API_KEY` |
|
|
33
|
-
| `✗ 服务连通: ...` | 看错误类型:网络不可达(退出码 3)→
|
|
33
|
+
| `✗ 服务连通: ...` | 看错误类型:网络不可达(退出码 3)→ 检查服务环境与网络;鉴权失败(4)→ 令牌失效,重新 `yos login` |
|
|
34
34
|
| `✗ Skill 安装: 尚未安装,执行 yos skill install` | 执行 `yos skill install`,未探测到目录时 `--target ~/.claude/skills` |
|
|
35
35
|
|
|
36
36
|
配置细节(排障时才需要):
|
|
37
37
|
|
|
38
|
-
- 配置文件 `~/.config/yos/config.json`(目录 0700、文件 0600),字段 `{
|
|
39
|
-
- 环境变量优先级:`YOS_API_KEY` > 配置文件 `apiKey`;`
|
|
40
|
-
-
|
|
38
|
+
- 配置文件 `~/.config/yos/config.json`(目录 0700、文件 0600),字段 `{env, apiKey, installedSkillDirs}`;本地联调等自定义地址场景存 `endpoint` 字段替代 `env`
|
|
39
|
+
- 环境变量优先级:`YOS_API_KEY` > 配置文件 `apiKey`;`YOS_ENV` > 配置文件 `env`;`YOS_CONFIG_DIR` 覆盖配置目录(测试隔离用)
|
|
40
|
+
- 服务环境缺省生产,切换用 `yos login --env test`(临时用 `YOS_ENV=test`);开发者本地调试用 `--env dev`(指向本机 8080 起的服务);其他自定义地址用 `--endpoint <url>` / `YOS_ENDPOINT`,一般无需使用;`yos doctor` 的「服务环境」项显示当前环境与来源
|
|
41
41
|
- 令牌格式先本地校验:`yos login` 粘贴了非 40 位小写 hex 会直接报 `错误: 令牌格式不正确(应为 40 位小写 hex)`,不会落盘
|
|
42
42
|
|
|
43
43
|
**安全**:绝不把令牌写进命令历史可见的日志、代码仓库或对用户的回复里;`--key` 传令牌仅用于无交互场景,回复中一律用掩码形式(`xxxxxxxx****xxxx`)。
|
|
@@ -86,7 +86,7 @@ CLI 对两套编码原样透出不做映射。遇到 cortex 侧编码时:可
|
|
|
86
86
|
| 0 | 成功 | — | 继续 |
|
|
87
87
|
| 1 | 业务失败(服务端拒绝/资源不存在) | `工具执行失败:知识库不存在:KB不存在`<br>`节点类型不符:ND... 实际是文档,本操作要求文件夹` | 按文案修参数,不要盲目重试 |
|
|
88
88
|
| 2 | 参数/用法错误(CLI 本地拦截,未发请求) | `错误: 缺少 --kind`<br>`提示: 用法: yos retrieve neighbors <target> --kind <值> ...` | 照 `提示:` 里的用法改写 |
|
|
89
|
-
| 3 | 网络错误/服务不可达 | `错误: fetch failed
|
|
89
|
+
| 3 | 网络错误/服务不可达 | `错误: 无法连接 YOS 服务(生产),原因:fetch failed` | 确认服务环境与网络连通,`yos ping` 复测 |
|
|
90
90
|
| 4 | 鉴权失败 | `错误: 鉴权失败...`<br>`提示: 请执行 \`yos login\` 重新配置访问令牌` | 令牌无效/吊销/过期 → 让用户重新创建后 `yos login` |
|
|
91
91
|
|
|
92
92
|
`1` 与 `2` 的关键差别:**2 根本没发请求**,改法一定写在 `提示:` 里;**1 是服务端结论**,文案里带具体编码,直接引用给用户。
|