ai-world-sdk 1.5.1 → 1.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.
@@ -88,7 +88,7 @@ function parseUserIdsList(raw) {
88
88
  });
89
89
  }
90
90
  function registerAdminCommands(program) {
91
- const admin = program.command('admin');
91
+ const admin = program.command('admin').description('管理员功能(用户 / 角色 / 数据库)');
92
92
  const user = admin.command('user');
93
93
  user
94
94
  .command('list')
@@ -61,7 +61,7 @@ function parsePositiveInt(raw, flag) {
61
61
  return n;
62
62
  }
63
63
  function registerChromeCommands(program) {
64
- const chrome = program.command('chrome');
64
+ const chrome = program.command('chrome').description('Chrome 扩展管理');
65
65
  chrome
66
66
  .command('list')
67
67
  .option('--page <n>', '页码')
@@ -19,6 +19,10 @@ function parseEntries(entries) {
19
19
  }
20
20
  function registerConfigCommands(program) {
21
21
  const cfg = program.command('config');
22
+ cfg.command('file').action(() => {
23
+ const path = config_1.CONFIG_FILE;
24
+ (0, output_1.output)({ path }, 'json');
25
+ });
22
26
  cfg
23
27
  .command('set')
24
28
  .argument('<entries...>', 'key=value pairs')
@@ -41,9 +45,17 @@ function registerConfigCommands(program) {
41
45
  if (!(0, config_1.isValidKey)(key)) {
42
46
  throw new Error(`Invalid config key: ${key}. Valid keys: ${(0, config_1.getValidKeys)().join(', ')}`);
43
47
  }
44
- const value = (0, config_1.getConfigValue)(key);
48
+ const saved = (0, config_1.getConfigValue)(key);
49
+ const effective = (0, config_1.getEffectiveValue)(key);
45
50
  const format = (0, utils_1.getFormat)(program);
46
- (0, output_1.output)({ key, value: value ?? null }, format);
51
+ const result = { key, value: effective };
52
+ if (saved !== undefined && saved === effective) {
53
+ result.source = 'config';
54
+ }
55
+ else if (saved === undefined && effective !== null) {
56
+ result.source = 'default';
57
+ }
58
+ (0, output_1.output)(result, format);
47
59
  }
48
60
  catch (e) {
49
61
  (0, utils_1.handleError)(e, 'config get');
@@ -52,12 +64,28 @@ function registerConfigCommands(program) {
52
64
  cfg.command('list').action(() => {
53
65
  try {
54
66
  const format = (0, utils_1.getFormat)(program);
55
- const data = (0, config_1.readConfig)();
67
+ const saved = (0, config_1.readConfig)();
68
+ const effective = (0, config_1.getEffectiveConfig)();
69
+ const merged = {};
70
+ for (const [key, val] of Object.entries(effective)) {
71
+ const hasSaved = saved[key] !== undefined;
72
+ merged[key] = {
73
+ value: val,
74
+ source: key === 'token'
75
+ ? (saved.token ? 'config' : (process.env.DEBUG_TOKEN ? 'env' : 'none'))
76
+ : (hasSaved ? 'config' : (val !== null ? 'default' : 'none')),
77
+ };
78
+ }
56
79
  if (format === 'table') {
57
- (0, output_1.output)(data, 'table');
80
+ const rows = Object.entries(merged).map(([k, v]) => ({
81
+ key: k,
82
+ value: k === 'token' && v.value ? v.value.slice(0, 20) + '...' : (v.value ?? ''),
83
+ source: v.source,
84
+ }));
85
+ (0, output_1.output)(rows, 'table');
58
86
  }
59
87
  else {
60
- (0, output_1.outputJSON)(data);
88
+ (0, output_1.outputJSON)(merged);
61
89
  }
62
90
  }
63
91
  catch (e) {
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function registerHelpCommand(program: Command): void;
@@ -0,0 +1,257 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerHelpCommand = registerHelpCommand;
4
+ const COMMAND_DETAILS = {
5
+ login: {
6
+ desc: '登录 AI World 平台(浏览器 OAuth 或直接设置 token)',
7
+ usage: 'ai-world login [--token <jwt>] [--timeout <ms>]',
8
+ examples: [
9
+ 'ai-world login # 浏览器 OAuth 登录',
10
+ 'ai-world login --token eyJhbG... # 直接设置 token',
11
+ ],
12
+ },
13
+ logout: {
14
+ desc: '退出登录,清除本地缓存的 token',
15
+ usage: 'ai-world logout',
16
+ },
17
+ me: {
18
+ desc: '查看当前登录用户信息(ID、姓名、邮箱、角色等)',
19
+ usage: 'ai-world me [--format table]',
20
+ },
21
+ status: {
22
+ desc: '检查当前认证状态,显示 token 是否有效',
23
+ usage: 'ai-world status',
24
+ },
25
+ version: {
26
+ desc: '显示当前 CLI 版本号,并检查是否有新版本可用',
27
+ usage: 'ai-world version',
28
+ examples: [
29
+ 'ai-world version',
30
+ '# 输出: {"current":"1.5.3","latest":"1.5.3","updateAvailable":false}',
31
+ ],
32
+ },
33
+ config: {
34
+ desc: '管理 CLI 默认配置(base-url / provider / endpoint / model 等)',
35
+ usage: 'ai-world config <set|get|list|reset>',
36
+ examples: [
37
+ 'ai-world config set base-url=https://aiworld.local:8000',
38
+ 'ai-world config set provider=volcengine endpoint=doubao model=doubao-1-5-pro-32k-250115',
39
+ 'ai-world config get provider',
40
+ 'ai-world config list',
41
+ 'ai-world config reset # 重置所有配置',
42
+ 'ai-world config reset provider # 重置单个配置项',
43
+ ],
44
+ },
45
+ text: {
46
+ desc: '文本生成 —— 调用 LLM 进行对话或流式输出',
47
+ usage: 'ai-world text <generate|stream>',
48
+ examples: [
49
+ 'ai-world text generate --prompt "介绍 AI World"',
50
+ 'ai-world text stream --prompt "讲个故事" --provider volcengine --endpoint doubao --model doubao-1-5-pro-32k-250115',
51
+ ],
52
+ },
53
+ model: {
54
+ desc: '检查指定模型在给定 provider/endpoint 下是否可用',
55
+ usage: 'ai-world model check --model <id> --provider <name> --endpoint <type>',
56
+ examples: [
57
+ 'ai-world model check --model doubao-1-5-pro-32k-250115 --provider volcengine --endpoint doubao',
58
+ ],
59
+ },
60
+ image: {
61
+ desc: '图像生成 —— 支持 doubao / gemini / openai 三种提供商',
62
+ usage: 'ai-world image generate --provider <name> --prompt <text> [--output <file>]',
63
+ examples: [
64
+ 'ai-world image generate --provider doubao --prompt "一只可爱的猫" --output cat.png',
65
+ 'ai-world image generate --provider gemini --prompt "sunset" --output sunset.png',
66
+ 'ai-world image generate --provider openai --prompt "abstract art" --model dall-e-3',
67
+ ],
68
+ },
69
+ video: {
70
+ desc: '视频生成、状态查询、下载和视频理解',
71
+ usage: 'ai-world video <generate|status|download|understand>',
72
+ examples: [
73
+ 'ai-world video generate --provider doubao --prompt "猫在走路"',
74
+ 'ai-world video status <taskId> --provider doubao',
75
+ 'ai-world video download <taskId> --output video.mp4',
76
+ 'ai-world video understand --model <id> --video-url <url> --prompt "描述这个视频"',
77
+ ],
78
+ },
79
+ resource: {
80
+ desc: '资源管理(带 ACL 访问控制)—— 上传、下载、分享、权限设置',
81
+ usage: 'ai-world resource <upload|list|get|download|share|unshare|set-access|delete>',
82
+ examples: [
83
+ 'ai-world resource upload ./file.pdf /docs/file.pdf --access public',
84
+ 'ai-world resource list --scope my',
85
+ 'ai-world resource download 42 --output ./local.pdf',
86
+ 'ai-world resource share 42 --users 1,2,3',
87
+ ],
88
+ },
89
+ versioned: {
90
+ desc: '版本化资源管理 —— 带版本号的文件存储',
91
+ usage: 'ai-world versioned <upload|list|versions|get|download|delete>',
92
+ examples: [
93
+ 'ai-world versioned upload ./model.bin --name my-model --version 1.0.0',
94
+ 'ai-world versioned list',
95
+ 'ai-world versioned versions my-model',
96
+ 'ai-world versioned download my-model latest --output ./model.bin',
97
+ ],
98
+ },
99
+ skill: {
100
+ desc: 'Agent 技能管理 —— 上传、下载、查看技能包',
101
+ usage: 'ai-world skill <list|get|upload|download|delete|md>',
102
+ examples: [
103
+ 'ai-world skill list',
104
+ 'ai-world skill get my-skill',
105
+ 'ai-world skill md my-skill # 查看 SKILL.md 内容',
106
+ 'ai-world skill upload my-skill ./skill.zip',
107
+ 'ai-world skill download my-skill -o skill.zip',
108
+ ],
109
+ },
110
+ plugin: {
111
+ desc: '插件管理 —— 部署、启用/禁用、重启、查看日志',
112
+ usage: 'ai-world plugin <list|get|ids|create|enable|disable|reload|restart|logs|status|delete>',
113
+ examples: [
114
+ 'ai-world plugin list',
115
+ 'ai-world plugin ids --enabled-only',
116
+ 'ai-world plugin get my-plugin',
117
+ 'ai-world plugin enable my-plugin',
118
+ 'ai-world plugin logs my-plugin --lines 50',
119
+ 'ai-world plugin create ./dist.zip --plugin-id my-plugin --name "我的插件"',
120
+ ],
121
+ },
122
+ admin: {
123
+ desc: '管理员功能 —— 用户管理、角色权限、数据库操作',
124
+ usage: 'ai-world admin <user|role|db>',
125
+ examples: [
126
+ 'ai-world admin user list',
127
+ 'ai-world admin user set-role 2 --role-id 1',
128
+ 'ai-world admin role list',
129
+ 'ai-world admin db tables',
130
+ 'ai-world admin db schema users',
131
+ 'ai-world admin db exec-sql --sql "SELECT COUNT(*) FROM users"',
132
+ ],
133
+ },
134
+ stats: {
135
+ desc: '统计与数据看板 —— 调用量、趋势、插件访问',
136
+ usage: 'ai-world stats <dashboard|plugin-access|ai-calls|ai-trend|...>',
137
+ examples: [
138
+ 'ai-world stats dashboard',
139
+ 'ai-world stats ai-calls --provider volcengine',
140
+ 'ai-world stats ai-trend --period weekly --days 30',
141
+ 'ai-world stats plugin-access-summary',
142
+ ],
143
+ },
144
+ shared: {
145
+ desc: '共享资源 —— 全平台可见的公共文件',
146
+ usage: 'ai-world shared <upload|list|get|download|update|delete>',
147
+ examples: [
148
+ 'ai-world shared upload ./data.csv --name "示例数据"',
149
+ 'ai-world shared list --search "模型"',
150
+ 'ai-world shared download 10 --output ./out.csv',
151
+ ],
152
+ },
153
+ chrome: {
154
+ desc: 'Chrome 扩展管理 —— 上传、下载、查看浏览器插件',
155
+ usage: 'ai-world chrome <list|get|create|download|delete>',
156
+ examples: [
157
+ 'ai-world chrome list',
158
+ 'ai-world chrome create --extension-id my-ext --name "扩展" --zip ./ext.zip',
159
+ 'ai-world chrome download my-ext --output ext.zip',
160
+ ],
161
+ },
162
+ };
163
+ function printFullHelp(program) {
164
+ const ver = program.version();
165
+ console.log(`
166
+ AI World CLI v${ver}
167
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
168
+
169
+ 用法: ai-world [全局选项] <命令> [子命令] [参数]
170
+
171
+ 全局选项:
172
+ --base-url <url> 后端地址(默认从配置读取)
173
+ --token <token> JWT 认证 token
174
+ --plugin-id <id> 插件 ID(默认 user_{user_id})
175
+ --format <fmt> 输出格式: json(默认)| table
176
+ --debug 启用调试输出
177
+ -V, --version 显示版本号
178
+ -h, --help 显示帮助
179
+
180
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
181
+ 命令列表:
182
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
183
+
184
+ 认证:
185
+ login 登录 AI World(浏览器 OAuth / token)
186
+ logout 退出登录
187
+ me 查看当前用户信息
188
+ status 检查认证状态
189
+
190
+ 配置:
191
+ config 管理默认配置(set / get / list / reset)
192
+ version 显示版本号并检查更新
193
+
194
+ AI 能力:
195
+ text 文本生成(对话、流式输出)
196
+ model 模型可用性检查
197
+ image 图像生成(doubao / gemini / openai)
198
+ video 视频生成、查询、下载、理解
199
+
200
+ 平台管理:
201
+ resource 资源管理(带 ACL 访问控制)
202
+ versioned 版本化资源管理
203
+ skill Agent 技能管理
204
+ plugin 插件管理(部署 / 启停 / 日志)
205
+ shared 共享资源
206
+ chrome Chrome 扩展管理
207
+
208
+ 管理员:
209
+ admin 用户 / 角色 / 数据库管理
210
+ stats 统计与数据看板
211
+
212
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
213
+ 提示: 使用 "ai-world help <命令>" 查看具体命令详情
214
+ 使用 "ai-world <命令> --help" 查看子命令帮助
215
+ `);
216
+ }
217
+ function printCommandHelp(cmdName, program) {
218
+ const detail = COMMAND_DETAILS[cmdName];
219
+ if (!detail) {
220
+ const sub = program.commands.find((c) => c.name() === cmdName);
221
+ if (sub) {
222
+ sub.outputHelp();
223
+ }
224
+ else {
225
+ console.error(`未知命令: ${cmdName}\n运行 "ai-world help" 查看所有可用命令`);
226
+ process.exitCode = 1;
227
+ }
228
+ return;
229
+ }
230
+ console.log(`
231
+ 命令: ${cmdName}
232
+ 描述: ${detail.desc}
233
+ 用法: ${detail.usage}
234
+ `);
235
+ if (detail.examples && detail.examples.length > 0) {
236
+ console.log('示例:');
237
+ for (const ex of detail.examples) {
238
+ console.log(` ${ex}`);
239
+ }
240
+ console.log('');
241
+ }
242
+ console.log(`运行 "ai-world ${cmdName} --help" 查看完整参数列表`);
243
+ }
244
+ function registerHelpCommand(program) {
245
+ program
246
+ .command('help')
247
+ .description('显示帮助信息')
248
+ .argument('[command]', '要查看的命令名称')
249
+ .action((cmdName) => {
250
+ if (!cmdName) {
251
+ printFullHelp(program);
252
+ }
253
+ else {
254
+ printCommandHelp(cmdName, program);
255
+ }
256
+ });
257
+ }
@@ -64,7 +64,7 @@ function stripB64ForLog(obj) {
64
64
  return copy;
65
65
  }
66
66
  function registerImageCommands(program) {
67
- const image = program.command('image');
67
+ const image = program.command('image').description('图像生成(doubao / gemini / openai)');
68
68
  image
69
69
  .command('generate')
70
70
  .requiredOption('--provider <name>', 'doubao, gemini, or openai')
@@ -180,6 +180,7 @@ function registerImageCommands(program) {
180
180
  });
181
181
  }
182
182
  catch (err) {
183
+ console.log('----image generate error', err, new Error().stack);
183
184
  (0, utils_1.handleError)(err, commandName);
184
185
  }
185
186
  });
@@ -17,7 +17,7 @@ function collectOpts(cmd) {
17
17
  return o;
18
18
  }
19
19
  function registerModelCommands(program) {
20
- const modelCmd = program.command('model');
20
+ const modelCmd = program.command('model').description('模型可用性检查');
21
21
  modelCmd
22
22
  .command('check')
23
23
  .requiredOption('--model <id>', 'Model id')
@@ -17,7 +17,7 @@ function collectOpts(cmd) {
17
17
  return o;
18
18
  }
19
19
  function registerPluginCommands(program) {
20
- const plugin = program.command('plugin');
20
+ const plugin = program.command('plugin').description('插件管理(启用 / 禁用 / 部署 / 日志)');
21
21
  plugin
22
22
  .command('list')
23
23
  .option('--page <n>', '', (v) => parseInt(v, 10))
@@ -61,7 +61,7 @@ function registerPluginCommands(program) {
61
61
  plugin
62
62
  .command('get')
63
63
  .argument('<plugin-id>')
64
- .action(async (pluginId, cmd) => {
64
+ .action(async (pluginId, _opts, cmd) => {
65
65
  const commandName = 'plugin get';
66
66
  try {
67
67
  const o = collectOpts(cmd);
@@ -109,7 +109,7 @@ function registerPluginCommands(program) {
109
109
  plugin
110
110
  .command(subName)
111
111
  .argument('<plugin-id>')
112
- .action(async (pluginId, cmd) => {
112
+ .action(async (pluginId, _opts, cmd) => {
113
113
  const commandName = `plugin ${subName}`;
114
114
  try {
115
115
  const o = collectOpts(cmd);
@@ -131,7 +131,7 @@ function registerPluginCommands(program) {
131
131
  plugin
132
132
  .command('restart')
133
133
  .argument('<plugin-id>')
134
- .action(async (pluginId, cmd) => {
134
+ .action(async (pluginId, _opts, cmd) => {
135
135
  const commandName = 'plugin restart';
136
136
  try {
137
137
  const o = collectOpts(cmd);
@@ -216,7 +216,7 @@ function registerPluginCommands(program) {
216
216
  plugin
217
217
  .command('delete')
218
218
  .argument('<plugin-id>')
219
- .action(async (pluginId, cmd) => {
219
+ .action(async (pluginId, _opts, cmd) => {
220
220
  const commandName = 'plugin delete';
221
221
  try {
222
222
  const o = collectOpts(cmd);
@@ -237,7 +237,7 @@ function registerPluginCommands(program) {
237
237
  plugin
238
238
  .command('status')
239
239
  .argument('<plugin-id>')
240
- .action(async (pluginId, cmd) => {
240
+ .action(async (pluginId, _opts, cmd) => {
241
241
  const commandName = 'plugin status';
242
242
  try {
243
243
  const o = collectOpts(cmd);
@@ -81,7 +81,7 @@ function parsePositiveInt(raw, flag) {
81
81
  return n;
82
82
  }
83
83
  function registerSharedCommands(program) {
84
- const shared = program.command('shared');
84
+ const shared = program.command('shared').description('共享资源(上传 / 下载 / 搜索)');
85
85
  shared
86
86
  .command('upload')
87
87
  .argument('<local-file>', '本地文件路径')
@@ -51,7 +51,7 @@ function collectOpts(cmd) {
51
51
  return o;
52
52
  }
53
53
  function registerSkillCommands(program) {
54
- const skill = program.command('skill');
54
+ const skill = program.command('skill').description('Agent 技能管理(上传 / 下载 / 查看)');
55
55
  skill
56
56
  .command('list')
57
57
  .option('--page <n>', '', (v) => parseInt(v, 10))
@@ -88,7 +88,7 @@ function registerSkillCommands(program) {
88
88
  skill
89
89
  .command('get')
90
90
  .argument('<skill-name>')
91
- .action(async (skillName, cmd) => {
91
+ .action(async (skillName, _opts, cmd) => {
92
92
  const commandName = 'skill get';
93
93
  try {
94
94
  const o = collectOpts(cmd);
@@ -165,7 +165,7 @@ function registerSkillCommands(program) {
165
165
  skill
166
166
  .command('delete')
167
167
  .argument('<skill-name>')
168
- .action(async (skillName, cmd) => {
168
+ .action(async (skillName, _opts, cmd) => {
169
169
  const commandName = 'skill delete';
170
170
  try {
171
171
  const o = collectOpts(cmd);
@@ -186,7 +186,7 @@ function registerSkillCommands(program) {
186
186
  skill
187
187
  .command('md')
188
188
  .argument('<skill-name>')
189
- .action(async (skillName, cmd) => {
189
+ .action(async (skillName, _opts, cmd) => {
190
190
  const commandName = 'skill md';
191
191
  try {
192
192
  const o = collectOpts(cmd);
@@ -37,7 +37,7 @@ function parsePeriod(raw) {
37
37
  throw err;
38
38
  }
39
39
  function registerStatsCommands(program) {
40
- const stats = program.command('stats');
40
+ const stats = program.command('stats').description('统计与数据看板');
41
41
  stats
42
42
  .command('plugin-access')
43
43
  .option('--user-id <n>', '用户 ID', (v) => parseInt(v, 10))
@@ -47,7 +47,7 @@ async function prepareContext(program, cmd) {
47
47
  };
48
48
  }
49
49
  function registerTextCommands(program) {
50
- const text = program.command('text');
50
+ const text = program.command('text').description('文本生成(对话、流式输出)');
51
51
  text
52
52
  .command('generate')
53
53
  .requiredOption('--prompt <text>', 'Prompt text')
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function registerVersionCommand(program: Command): void;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerVersionCommand = registerVersionCommand;
4
+ const output_1 = require("../output");
5
+ const utils_1 = require("../utils");
6
+ const config_1 = require("../config");
7
+ async function getLatestVersion(baseUrl) {
8
+ try {
9
+ const response = await fetch(`${baseUrl}/api/sdk/latest-version`);
10
+ if (!response.ok)
11
+ return null;
12
+ const data = await response.json();
13
+ return data.version || null;
14
+ }
15
+ catch {
16
+ return null;
17
+ }
18
+ }
19
+ function compareVersions(current, latest) {
20
+ const a = current.split('.').map(Number);
21
+ const b = latest.split('.').map(Number);
22
+ for (let i = 0; i < 3; i++) {
23
+ if ((a[i] || 0) < (b[i] || 0))
24
+ return -1;
25
+ if ((a[i] || 0) > (b[i] || 0))
26
+ return 1;
27
+ }
28
+ return 0;
29
+ }
30
+ function registerVersionCommand(program) {
31
+ program
32
+ .command('version')
33
+ .description('显示版本号并检查更新')
34
+ .action(async () => {
35
+ try {
36
+ const currentVersion = require('../../../package.json').version;
37
+ const auth = (0, config_1.resolveAuth)({});
38
+ const latest = await getLatestVersion(auth.baseUrl);
39
+ const result = {
40
+ current: currentVersion,
41
+ };
42
+ if (latest) {
43
+ result.latest = latest;
44
+ const cmp = compareVersions(currentVersion, latest);
45
+ if (cmp < 0) {
46
+ result.updateAvailable = true;
47
+ result.updateCommand = 'npm install -g ai-world-sdk';
48
+ }
49
+ else {
50
+ result.updateAvailable = false;
51
+ }
52
+ }
53
+ else {
54
+ result.latest = null;
55
+ result.updateAvailable = null;
56
+ }
57
+ (0, output_1.outputJSON)(result);
58
+ }
59
+ catch (e) {
60
+ (0, utils_1.handleError)(e, 'version');
61
+ }
62
+ });
63
+ }
@@ -53,7 +53,7 @@ function collectOpts(cmd) {
53
53
  return o;
54
54
  }
55
55
  function registerVideoCommands(program) {
56
- const video = program.command('video');
56
+ const video = program.command('video').description('视频生成、状态查询、下载、理解');
57
57
  video
58
58
  .command('generate')
59
59
  .requiredOption('--provider <name>', 'doubao or openai')
@@ -1,3 +1,5 @@
1
+ export declare const CONFIG_DIR: string;
2
+ export declare const CONFIG_FILE: string;
1
3
  declare const VALID_KEYS: readonly ["base-url", "token", "plugin-id", "provider", "endpoint", "model", "format"];
2
4
  export type ConfigKey = (typeof VALID_KEYS)[number];
3
5
  export interface CLIConfig {
@@ -13,7 +15,9 @@ export declare function isValidKey(key: string): key is ConfigKey;
13
15
  export declare function getValidKeys(): readonly string[];
14
16
  export declare function readConfig(): CLIConfig;
15
17
  export declare function writeConfig(config: CLIConfig): void;
18
+ export declare function getEffectiveConfig(): Record<string, string | null>;
16
19
  export declare function getConfigValue(key: ConfigKey): string | undefined;
20
+ export declare function getEffectiveValue(key: ConfigKey): string | null;
17
21
  export declare function setConfigValues(entries: Record<string, string>): void;
18
22
  export declare function resetConfig(key?: string): void;
19
23
  export interface ResolvedAuth {
@@ -33,11 +33,14 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.CONFIG_FILE = exports.CONFIG_DIR = void 0;
36
37
  exports.isValidKey = isValidKey;
37
38
  exports.getValidKeys = getValidKeys;
38
39
  exports.readConfig = readConfig;
39
40
  exports.writeConfig = writeConfig;
41
+ exports.getEffectiveConfig = getEffectiveConfig;
40
42
  exports.getConfigValue = getConfigValue;
43
+ exports.getEffectiveValue = getEffectiveValue;
41
44
  exports.setConfigValues = setConfigValues;
42
45
  exports.resetConfig = resetConfig;
43
46
  exports.resolveAuth = resolveAuth;
@@ -45,8 +48,8 @@ exports.resolveDefaults = resolveDefaults;
45
48
  const fs = __importStar(require("fs"));
46
49
  const path = __importStar(require("path"));
47
50
  const os = __importStar(require("os"));
48
- const CONFIG_DIR = path.join(os.homedir(), '.ai-world');
49
- const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
51
+ exports.CONFIG_DIR = path.join(os.homedir(), '.ai-world');
52
+ exports.CONFIG_FILE = path.join(exports.CONFIG_DIR, 'config.json');
50
53
  const VALID_KEYS = [
51
54
  'base-url',
52
55
  'token',
@@ -64,8 +67,8 @@ function getValidKeys() {
64
67
  }
65
68
  function readConfig() {
66
69
  try {
67
- if (fs.existsSync(CONFIG_FILE)) {
68
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf-8'));
70
+ if (fs.existsSync(exports.CONFIG_FILE)) {
71
+ return JSON.parse(fs.readFileSync(exports.CONFIG_FILE, 'utf-8'));
69
72
  }
70
73
  }
71
74
  catch {
@@ -74,14 +77,42 @@ function readConfig() {
74
77
  return {};
75
78
  }
76
79
  function writeConfig(config) {
77
- if (!fs.existsSync(CONFIG_DIR)) {
78
- fs.mkdirSync(CONFIG_DIR, { recursive: true });
80
+ if (!fs.existsSync(exports.CONFIG_DIR)) {
81
+ fs.mkdirSync(exports.CONFIG_DIR, { recursive: true });
79
82
  }
80
- fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2), 'utf-8');
83
+ fs.writeFileSync(exports.CONFIG_FILE, JSON.stringify(config, null, 2), 'utf-8');
84
+ }
85
+ const DEFAULTS = {
86
+ 'base-url': 'https://aiworld.local:8000',
87
+ 'plugin-id': 'cli',
88
+ provider: 'kunpo',
89
+ endpoint: 'openai',
90
+ model: 'deepseek/deepseek-v4-pro',
91
+ format: 'json',
92
+ };
93
+ function getEffectiveConfig() {
94
+ const config = readConfig();
95
+ const result = {};
96
+ for (const key of VALID_KEYS) {
97
+ if (key === 'token') {
98
+ result[key] = config.token || process.env.DEBUG_TOKEN || null;
99
+ }
100
+ else {
101
+ result[key] = config[key] || DEFAULTS[key] || null;
102
+ }
103
+ }
104
+ return result;
81
105
  }
82
106
  function getConfigValue(key) {
83
107
  return readConfig()[key];
84
108
  }
109
+ function getEffectiveValue(key) {
110
+ const config = readConfig();
111
+ if (key === 'token') {
112
+ return config.token || process.env.DEBUG_TOKEN || null;
113
+ }
114
+ return config[key] || DEFAULTS[key] || null;
115
+ }
85
116
  function setConfigValues(entries) {
86
117
  const config = readConfig();
87
118
  for (const [key, value] of Object.entries(entries)) {
@@ -119,15 +150,15 @@ function resolveAuth(opts) {
119
150
  pluginId: opts.pluginId ||
120
151
  process.env.PLUGIN_ID ||
121
152
  config['plugin-id'] ||
122
- null,
153
+ 'cli',
123
154
  };
124
155
  }
125
156
  function resolveDefaults(opts) {
126
157
  const config = readConfig();
127
158
  return {
128
- provider: opts.provider || config.provider,
129
- endpoint: opts.endpoint || config.endpoint,
130
- model: opts.model || config.model,
159
+ provider: opts.provider || config.provider || 'kunpo',
160
+ endpoint: opts.endpoint || config.endpoint || 'openai',
161
+ model: opts.model || config.model || 'deepseek/deepseek-v4-pro',
131
162
  format: opts.format || config.format || 'json',
132
163
  };
133
164
  }
package/dist/cli/index.js CHANGED
@@ -1,7 +1,81 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
3
36
  Object.defineProperty(exports, "__esModule", { value: true });
4
- process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
37
+ process.env.__AI_WORLD_CLI__ = '1';
38
+ const tls = __importStar(require("tls"));
39
+ const undici_1 = require("undici");
40
+ const localCA = `-----BEGIN CERTIFICATE-----
41
+ MIIFBDCCA2ygAwIBAgIRAIQTUXqwRwvkfn2rfwg0tIgwDQYJKoZIhvcNAQELBQAw
42
+ gZkxHjAcBgNVBAoTFW1rY2VydCBkZXZlbG9wbWVudCBDQTE3MDUGA1UECwwubGln
43
+ aHRnYW1lMkBndWFuZ3NodTJkZU1hYy1taW5pLmxvY2FsICjlhYnmnZ8yKTE+MDwG
44
+ A1UEAww1bWtjZXJ0IGxpZ2h0Z2FtZTJAZ3VhbmdzaHUyZGVNYWMtbWluaS5sb2Nh
45
+ bCAo5YWJ5p2fMikwHhcNMjUxMjMxMDcwNDQwWhcNMzUxMjMxMDcwNDQwWjCBmTEe
46
+ MBwGA1UEChMVbWtjZXJ0IGRldmVsb3BtZW50IENBMTcwNQYDVQQLDC5saWdodGdh
47
+ bWUyQGd1YW5nc2h1MmRlTWFjLW1pbmkubG9jYWwgKOWFieadnzIpMT4wPAYDVQQD
48
+ DDVta2NlcnQgbGlnaHRnYW1lMkBndWFuZ3NodTJkZU1hYy1taW5pLmxvY2FsICjl
49
+ hYnmnZ8yKTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBAK0ebf/92MLt
50
+ Hm6DdzoeOZm60H9mbYbUm2qon/hWTA1MsIo1fiSTKUsPT4Ni/3Gag1PDtqRy4o7p
51
+ IQL+Z0YplKWMWXpIR+kAp08+WmDgYeD6UXd05W9WEJg5lLDMhwHwGOxV2YGPkikW
52
+ gAtDbLVmDvZlHmbLJQTNJFFrxdNgcHSTwmS8lia+yiN4gNVMunjaifLvf7bSBF+a
53
+ yG5B4mibjKmVyvuw37KyUOdiELeTHR53ltYLOoDi6Sm5YX93B2JoXnAq/8cKscDl
54
+ lsNEcf0o2ed3TkPYbnj0Kqgb7C8twkaeB6Lh7aZJwHT2+lfeJaPs9DHKCMZ1d2zm
55
+ g4AamFS9GDMwm5G+h42iiV9Z7Y+iHRyRu+rCAWBQRaA5kfnjHGf4UnZyGl44TULt
56
+ WD3DIeizQAq0KFBkWGZOx62jJqsmvpUrSPOWab+THEfzYvJ4crk9xOGPDFv83EKq
57
+ bo6XX1vWR4VZE8UuBduUSKCN3RDi0Bt+CedU076P51L3fYo5wz48bQIDAQABo0Uw
58
+ QzAOBgNVHQ8BAf8EBAMCAgQwEgYDVR0TAQH/BAgwBgEB/wIBADAdBgNVHQ4EFgQU
59
+ f5hRENsTrcW0I1D1/EGb4IgSaDUwDQYJKoZIhvcNAQELBQADggGBAE8GD1vD5kdk
60
+ T7a/f8Phzv1QpG7WrHKo5QWFApcjajGbsK/CriyPJ9Ym+xZJ1IGaZc/CotYOqIuX
61
+ ClFzlL1jm4T8LeEwju5m06ZbKAS2i1qU9YlqWZ0lGWe+x8+lvZR628e8rvVb+zAp
62
+ wRBtrJZLSV4bhLj9fjRrEWZd8sJHUHzkETsXd7SD+fe+oSorlQ7B4A2VRBPf0JUF
63
+ 5QfU8Fv2Mb4mXoFkZK//iR/J27EwR8F0waGfS7Sc+cJGS1uo00cIVNLQBszd4b5h
64
+ KvE2EwOZIKldOaEp0Rl/kmKGYHIuAGfl0Dvd8VlUfnXP3/vgXJtJ3cX5hDBMQ1s9
65
+ padi0/W8fnu3E3Z922ceUpPkslXEGHBMGUoVDylt8QbOuKgjdmnEYLbB3yL2L7v1
66
+ ENtBjVDV0WKXXmrXYYc8sGuNGE7NUSrry/m1u6J/muhH4NmWSJ0PcDQAPOdXZ4l5
67
+ juLQfci27z5waIj0SrBJ7abmmQE/D1y7k528dXH/whu0HlIDnM7zQQ==
68
+ -----END CERTIFICATE-----
69
+ `;
70
+ const allCA = [...tls.rootCertificates, localCA];
71
+ const customAgent = new undici_1.Agent({
72
+ connect: {
73
+ ca: allCA,
74
+ },
75
+ });
76
+ globalThis.fetch = function (input, init) {
77
+ return (0, undici_1.fetch)(input, { ...init, dispatcher: customAgent });
78
+ };
5
79
  const commander_1 = require("commander");
6
80
  const utils_1 = require("./utils");
7
81
  const program = new commander_1.Command();
@@ -11,9 +85,10 @@ program
11
85
  .version(require('../../package.json').version)
12
86
  .option('--base-url <url>', '后端地址')
13
87
  .option('--token <token>', 'JWT token')
14
- .option('--plugin-id <id>', '插件 ID')
15
- .option('--format <fmt>', '输出格式: json | table', 'json')
88
+ .option('--format <fmt>', '输出格式: json | table')
16
89
  .option('--debug', '启用调试输出');
90
+ const help_1 = require("./commands/help");
91
+ const version_1 = require("./commands/version");
17
92
  const auth_1 = require("./commands/auth");
18
93
  const config_cmd_1 = require("./commands/config-cmd");
19
94
  const text_1 = require("./commands/text");
@@ -28,6 +103,8 @@ const admin_1 = require("./commands/admin");
28
103
  const stats_1 = require("./commands/stats");
29
104
  const shared_1 = require("./commands/shared");
30
105
  const chrome_1 = require("./commands/chrome");
106
+ (0, help_1.registerHelpCommand)(program);
107
+ (0, version_1.registerVersionCommand)(program);
31
108
  (0, auth_1.registerAuthCommands)(program);
32
109
  (0, config_cmd_1.registerConfigCommands)(program);
33
110
  (0, text_1.registerTextCommands)(program);
@@ -1,3 +1,4 @@
1
+ import { Command } from 'commander';
1
2
  export interface CLIError {
2
3
  error: true;
3
4
  code: string;
@@ -20,4 +21,4 @@ export declare function resolvePluginIdDefault(auth: {
20
21
  token: string | null;
21
22
  pluginId: string | null;
22
23
  }): Promise<string | null>;
23
- export declare function getFormat(program: any): string;
24
+ export declare function getFormat(program: Command): string;
package/dist/cli/utils.js CHANGED
@@ -69,7 +69,7 @@ function handleError(err, command) {
69
69
  cliError.code = 'NOT_FOUND';
70
70
  process.exitCode = 1;
71
71
  }
72
- else if (err.message.includes('ECONNREFUSED') || err.message.includes('ENOTFOUND') || err.message.includes('ETIMEDOUT')) {
72
+ else if (err.message.includes('ECONNREFUSED') || err.message.includes('ENOTFOUND') || err.message.includes('ETIMEDOUT') || err.message.includes('fetch failed')) {
73
73
  cliError.code = 'NETWORK_ERROR';
74
74
  cliError.details = { suggestion: '请检查 base-url 是否正确,后端服务是否运行中' };
75
75
  process.exitCode = 1;
@@ -115,6 +115,7 @@ function requireOption(value, name) {
115
115
  }
116
116
  function initSDK(auth) {
117
117
  const { sdkConfig } = require('../index');
118
+ sdkConfig.setCliMode(true);
118
119
  sdkConfig.setBaseUrl(auth.baseUrl);
119
120
  if (auth.token)
120
121
  sdkConfig.setToken(auth.token);
@@ -122,26 +123,7 @@ function initSDK(auth) {
122
123
  sdkConfig.setPluginId(auth.pluginId);
123
124
  }
124
125
  async function resolvePluginIdDefault(auth) {
125
- if (auth.pluginId)
126
- return auth.pluginId;
127
- if (!auth.token)
128
- return null;
129
- try {
130
- initSDK(auth);
131
- const { AuthClient } = require('../index');
132
- const client = new AuthClient();
133
- const user = await client.getCurrentUserInfo();
134
- if (user && user.id) {
135
- const defaultId = `user_${user.id}`;
136
- const { setConfigValues } = require('./config');
137
- setConfigValues({ 'plugin-id': defaultId });
138
- return defaultId;
139
- }
140
- }
141
- catch {
142
- // can't resolve, return null
143
- }
144
- return null;
126
+ return 'cli';
145
127
  }
146
128
  function getFormat(program) {
147
129
  const opts = program.opts();
package/dist/config.d.ts CHANGED
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * 注意: {VERSION} 占位符会在构建时被替换为实际版本号
11
11
  */
12
- export declare const SDK_SIGNATURE = "AI_WORLD_SDK_V:1.5.1";
12
+ export declare const SDK_SIGNATURE = "AI_WORLD_SDK_V:1.5.5";
13
13
  /**
14
14
  * 版本兼容性错误
15
15
  */
@@ -34,8 +34,9 @@ declare class SDKConfig {
34
34
  private _authenticated;
35
35
  private _authCheckPromise;
36
36
  private _currentUser;
37
- readonly sdkSignature = "AI_WORLD_SDK_V:1.5.1";
38
- readonly sdkVersion = "1.5.1";
37
+ private _cliMode;
38
+ readonly sdkSignature = "AI_WORLD_SDK_V:1.5.5";
39
+ readonly sdkVersion = "1.5.5";
39
40
  constructor();
40
41
  /**
41
42
  * Set global base URL
@@ -72,6 +73,7 @@ declare class SDKConfig {
72
73
  * 设置调试模式
73
74
  */
74
75
  setDebug(enabled: boolean): void;
76
+ setCliMode(enabled: boolean): void;
75
77
  /**
76
78
  * Get debug mode
77
79
  * 获取调试模式状态
package/dist/config.js CHANGED
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.sdkConfig = exports.VersionCompatibilityError = exports.SDK_SIGNATURE = void 0;
8
8
  // SDK 版本号(构建时自动从 package.json 更新)
9
9
  // 此版本号会在运行 npm run build 时自动从 package.json 读取并更新
10
- const SDK_VERSION = "1.5.1";
10
+ const SDK_VERSION = "1.5.5";
11
11
  /**
12
12
  * SDK 特征码 - 用于在构建后的 JS 文件中识别 SDK 版本
13
13
  * 格式: AI_WORLD_SDK_V:版本号
@@ -15,7 +15,7 @@ const SDK_VERSION = "1.5.1";
15
15
  *
16
16
  * 注意: {VERSION} 占位符会在构建时被替换为实际版本号
17
17
  */
18
- exports.SDK_SIGNATURE = "AI_WORLD_SDK_V:1.5.1";
18
+ exports.SDK_SIGNATURE = "AI_WORLD_SDK_V:1.5.5";
19
19
  /**
20
20
  * 版本兼容性错误
21
21
  */
@@ -38,6 +38,7 @@ class SDKConfig {
38
38
  this._authenticated = null; // null = 未检查
39
39
  this._authCheckPromise = null;
40
40
  this._currentUser = null;
41
+ this._cliMode = false;
41
42
  this.sdkSignature = exports.SDK_SIGNATURE;
42
43
  this.sdkVersion = SDK_VERSION;
43
44
  // 在全局对象上注册 SDK 版本信息(用于后端扫描检测)
@@ -177,6 +178,9 @@ class SDKConfig {
177
178
  setDebug(enabled) {
178
179
  this._debug = enabled;
179
180
  }
181
+ setCliMode(enabled) {
182
+ this._cliMode = enabled;
183
+ }
180
184
  /**
181
185
  * Get debug mode
182
186
  * 获取调试模式状态
@@ -216,7 +220,9 @@ class SDKConfig {
216
220
  async _performAuthCheck() {
217
221
  if (!this._token) {
218
222
  this._authenticated = false;
219
- console.warn('[ai-world-sdk] 未检测到登录 token,请先登录。Vite 项目请在 vite.config 中添加 aiWorldPlugin()');
223
+ if (!this._cliMode && typeof process !== 'undefined' && !process.env?.__AI_WORLD_CLI__) {
224
+ console.warn('[ai-world-sdk] 未检测到登录 token,请先登录。Vite 项目请在 vite.config 中添加 aiWorldPlugin()');
225
+ }
220
226
  return false;
221
227
  }
222
228
  const baseUrl = this._baseUrl || (typeof window !== 'undefined' ? window.location.origin : '');
@@ -257,7 +263,9 @@ class SDKConfig {
257
263
  }
258
264
  this._authenticated = false;
259
265
  this._token = null;
260
- console.warn('[ai-world-sdk] Token 已过期或无效,请重新登录');
266
+ if (!this._cliMode && typeof process !== 'undefined' && !process.env?.__AI_WORLD_CLI__) {
267
+ console.warn('[ai-world-sdk] Token 已过期或无效,请重新登录');
268
+ }
261
269
  return false;
262
270
  }
263
271
  catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-world-sdk",
3
- "version": "1.5.1",
3
+ "version": "1.5.5",
4
4
  "description": "TypeScript SDK for AI World Platform - Chat Models, Image Generation, and Video Generation",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -83,6 +83,7 @@
83
83
  "@ai-sdk/openai": "^3.0.28",
84
84
  "@openrouter/ai-sdk-provider": "^2.3.1",
85
85
  "ai": "^6.0.85",
86
- "commander": "^14.0.3"
86
+ "commander": "^14.0.3",
87
+ "undici": "^8.1.0"
87
88
  }
88
89
  }
@@ -257,8 +257,11 @@ for await (const chunk of stream.textStream) {
257
257
 
258
258
  - `ai-world` 命令行工具,所有 SDK 功能的命令行模式
259
259
  - 安装: `npm install -g ai-world-sdk` 或 `npx ai-world-sdk`
260
- - 认证: `ai-world auth login` 或环境变量 `DEBUG_TOKEN`
260
+ - 认证: `ai-world login` 或环境变量 `DEBUG_TOKEN`
261
261
  - 输出: 默认 JSON(AI Agent 友好),支持 `--format table`
262
+ - 默认值: plugin-id=`cli`,provider=`kunpo`,endpoint=`openai`,model=`deepseek/deepseek-v4-pro`
263
+ - 版本检查: `ai-world version`(从后端读取最新版本)
264
+ - 帮助: `ai-world help` / `ai-world help <command>`(中文详细说明)
262
265
  - 完整命令参考 → `docs/cli-commands.md`
263
266
 
264
267
  #### 快速开始
@@ -268,10 +271,10 @@ for await (const chunk of stream.textStream) {
268
271
  npm install -g ai-world-sdk
269
272
 
270
273
  # 登录
271
- ai-world auth login
274
+ ai-world login
272
275
 
273
- # 配置默认值
274
- ai-world config set provider=api2img endpoint=openai model=gpt-4o-mini
276
+ # 配置默认值(可选,默认 kunpo/openai/deepseek-v4-pro)
277
+ ai-world config set provider=kunpo endpoint=openai model=deepseek/deepseek-v4-pro
275
278
 
276
279
  # 文本生成
277
280
  ai-world text generate --prompt "你好"
@@ -281,6 +284,9 @@ ai-world text stream --prompt "请介绍人工智能"
281
284
 
282
285
  # 查看插件列表
283
286
  ai-world plugin list --format table
287
+
288
+ # 版本检查
289
+ ai-world version
284
290
  ```
285
291
 
286
292
  ### 常见错误 → `docs/common-mistakes.md`
@@ -1,25 +1,40 @@
1
1
  # AI World CLI 命令参考
2
2
 
3
- ## auth — 认证管理
3
+ ## 认证管理(顶层命令)
4
4
 
5
5
  ```bash
6
- ai-world auth login [--token <jwt>] # 交互式登录或直接设置 token
7
- ai-world auth logout # 退出登录(清除缓存)
8
- ai-world auth me # 当前用户信息
9
- ai-world auth status # 认证状态检查
6
+ ai-world login [--token <jwt>] # 交互式登录或直接设置 token
7
+ ai-world logout # 退出登录(清除缓存)
8
+ ai-world me # 当前用户信息
9
+ ai-world status # 认证状态检查
10
+ ```
11
+
12
+ ## version — 版本检查
13
+
14
+ ```bash
15
+ ai-world version # 显示当前版本,从后端检查更新
16
+ ```
17
+
18
+ ## help — 帮助
19
+
20
+ ```bash
21
+ ai-world help # 显示所有命令详细说明(中文)
22
+ ai-world help <command> # 显示特定命令的使用方法和示例
10
23
  ```
11
24
 
12
25
  ## config — 配置管理
13
26
 
14
27
  ```bash
15
- ai-world config set <key=value...> # 批量设置,如 provider=api2img endpoint=openai
16
- ai-world config get <key> # 查看某个配置
17
- ai-world config list # 查看所有配置
28
+ ai-world config set <key=value...> # 批量设置,如 provider=kunpo endpoint=openai
29
+ ai-world config get <key> # 查看某个配置(含值和来源 source)
30
+ ai-world config list # 查看所有配置(含 effective value 和 source)
18
31
  ai-world config reset [key] # 重置配置(不指定则全部重置)
19
32
  ```
20
33
 
21
34
  可配置项:`base-url`、`token`、`plugin-id`、`provider`、`endpoint`、`model`、`format`
22
35
 
36
+ 默认值:`base-url`=`https://aiworld.local:8000`、`plugin-id`=`cli`、`provider`=`kunpo`、`endpoint`=`openai`、`model`=`deepseek/deepseek-v4-pro`、`format`=`json`
37
+
23
38
  ## text — 文本生成
24
39
 
25
40
  ```bash
@@ -18,7 +18,7 @@ npx ai-world <command>
18
18
  ### 方式一:交互式登录(人类用户)
19
19
 
20
20
  ```bash
21
- ai-world auth login
21
+ ai-world login
22
22
  ```
23
23
 
24
24
  自动打开浏览器完成飞书 OAuth 登录,token 保存到 `~/.ai-world/config.json`。
@@ -26,7 +26,7 @@ ai-world auth login
26
26
  ### 方式二:直接设置 token(AI Agent)
27
27
 
28
28
  ```bash
29
- ai-world auth login --token <your-jwt-token>
29
+ ai-world login --token <your-jwt-token>
30
30
  ```
31
31
 
32
32
  ### 方式三:环境变量(AI Agent 推荐)
@@ -42,11 +42,7 @@ export PLUGIN_ID=my-plugin
42
42
  1. 命令行参数:`--token`、`--base-url`、`--plugin-id`
43
43
  2. 环境变量:`DEBUG_TOKEN`、`AI_WORLD_BASE_URL`、`PLUGIN_ID`
44
44
  3. 本地配置文件:`~/.ai-world/config.json`
45
- 4. 默认值:base-url 默认 `https://aiworld.local:8000`;plugin-id 默认 `user_{user_id}`
46
-
47
- ### plugin-id 默认值
48
-
49
- 当未指定 plugin-id 时,CLI 在认证后自动调用 `/api/auth/me` 获取用户 ID,使用 `user_{user_id}` 作为默认值(如用户 ID 为 1 则 `user_1`)。
45
+ 4. 默认值:base-url=`https://aiworld.local:8000`,plugin-id=`cli`,provider=`kunpo`,endpoint=`openai`,model=`deepseek/deepseek-v4-pro`
50
46
 
51
47
  ## 全局选项
52
48
 
@@ -66,12 +62,12 @@ export PLUGIN_ID=my-plugin
66
62
 
67
63
  ```bash
68
64
  # 批量设置默认值
69
- ai-world config set provider=api2img endpoint=openai model=gpt-4o-mini base-url=https://aiworld.local:8000
65
+ ai-world config set provider=kunpo endpoint=openai model=deepseek/deepseek-v4-pro
70
66
 
71
- # 查看所有配置
67
+ # 查看所有配置(显示 key、effective value、source)
72
68
  ai-world config list
73
69
 
74
- # 查看单个配置
70
+ # 查看单个配置(显示值和来源)
75
71
  ai-world config get provider
76
72
 
77
73
  # 重置配置
@@ -81,6 +77,8 @@ ai-world config reset provider # 重置单项
81
77
 
82
78
  可配置项:`base-url`、`token`、`plugin-id`、`provider`、`endpoint`、`model`、`format`
83
79
 
80
+ `config list` 输出包含 `source` 字段(`config`=用户设置值 / `default`=内置默认值 / `env`=环境变量)。
81
+
84
82
  ## 输出格式
85
83
 
86
84
  ### JSON(默认)— AI Agent 友好
@@ -126,14 +124,29 @@ $ ai-world plugin list --format table
126
124
 
127
125
  退出码:`0` 成功、`1` 一般错误、`2` 参数错误、`3` 认证错误、`4` 权限错误。
128
126
 
127
+ ## 版本检查
128
+
129
+ ```bash
130
+ ai-world version
131
+ ```
132
+
133
+ 从后端 `/api/sdk/latest-version` 获取最新版本号并与当前版本比对,输出是否有更新。
134
+
135
+ ## 帮助
136
+
137
+ ```bash
138
+ ai-world help # 打印所有命令详情(中文描述)
139
+ ai-world help text # 查看特定命令帮助
140
+ ```
141
+
129
142
  ## AI Agent 典型使用流程
130
143
 
131
144
  ```bash
132
145
  # 1. 设置认证
133
- ai-world auth login --token $JWT_TOKEN
146
+ ai-world login --token $JWT_TOKEN
134
147
 
135
- # 2. 配置默认值
136
- ai-world config set provider=api2img endpoint=openai model=gpt-4o-mini
148
+ # 2. 配置默认值(可选,默认 kunpo/openai/deepseek-v4-pro)
149
+ ai-world config set provider=kunpo endpoint=openai model=deepseek/deepseek-v4-pro
137
150
 
138
151
  # 3. 文本生成
139
152
  ai-world text generate --prompt "分析以下代码..."
@@ -151,4 +164,7 @@ ai-world skill download my-skill --output my-skill.zip
151
164
 
152
165
  # 7. 查看统计
153
166
  ai-world stats dashboard
167
+
168
+ # 8. 查看版本
169
+ ai-world version
154
170
  ```