travel-agent-cli 0.2.1 → 0.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "travel-agent-cli",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "AI 驱动的旅行目的地推荐 Agent - 命令行工具(集成 FlyAI 旅行搜索)",
5
5
  "bin": {
6
6
  "travel-agent": "bin/cli.js",
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "travel-agent"
7
- version = "0.1.0"
7
+ version = "0.2.1"
8
8
  description = "AI-powered travel destination recommendation agent"
9
9
  authors = [{ name = "Your Name", email = "your.email@example.com" }]
10
10
  readme = "README.md"
@@ -1,104 +1,98 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
3
  * npm 安装后执行的脚本
4
- * 检查依赖并提示用户
4
+ * 安装 Python 依赖
5
5
  */
6
6
 
7
7
  const { execSync } = require('child_process');
8
8
  const fs = require('fs');
9
9
  const path = require('path');
10
10
 
11
- const projectRoot = path.join(__dirname, '..');
12
- const venvPath = path.join(projectRoot, 'venv');
11
+ const packagePath = path.join(__dirname, '..');
12
+ const pythonDir = path.join(packagePath, 'python');
13
13
 
14
14
  console.log('╭───────────────────────────────────────────────────────────────╮');
15
- console.log('│ travel-agent-cli 安装后检查... │');
15
+ console.log('│ travel-agent-cli 正在安装 Python 依赖... │');
16
16
  console.log('╰───────────────────────────────────────────────────────────────╯\n');
17
17
 
18
18
  // 检查 Python
19
- function checkPython() {
19
+ function findPython() {
20
20
  try {
21
- const version = execSync('python3 --version', { encoding: 'utf8' }).trim();
22
- console.log(`✓ Python: ${version}`);
23
- return true;
21
+ execSync('python3 --version', { stdio: 'ignore' });
22
+ return 'python3';
24
23
  } catch (e) {
25
24
  try {
26
- const version = execSync('python --version', { encoding: 'utf8' }).trim();
27
- console.log(`✓ Python: ${version}`);
28
- return true;
25
+ execSync('python --version', { stdio: 'ignore' });
26
+ return 'python';
29
27
  } catch (e2) {
30
- console.error('✗ Python: 未找到');
31
- console.error('\n请先安装 Python 3.10+:');
32
- console.error(' macOS: brew install python@3.10');
33
- console.error(' Linux: sudo apt install python3.10');
34
- console.error(' Windows: https://www.python.org/downloads/');
35
- return false;
28
+ return null;
36
29
  }
37
30
  }
38
31
  }
39
32
 
40
- // 检查 pip
41
- function checkPip() {
42
- try {
43
- const version = execSync('pip3 --version', { encoding: 'utf8' }).trim();
44
- console.log(`✓ pip: 已安装`);
45
- return true;
46
- } catch (e) {
47
- try {
48
- const version = execSync('pip --version', { encoding: 'utf8' }).trim();
49
- console.log(`✓ pip: 已安装`);
50
- return true;
51
- } catch (e2) {
52
- console.error('✗ pip: 未找到');
53
- console.error(' 安装:https://pip.pypa.io/en/stable/installation/');
54
- return false;
55
- }
33
+ // 安装依赖
34
+ function installDependencies() {
35
+ const pythonCmd = findPython();
36
+
37
+ if (!pythonCmd) {
38
+ console.error('\n⚠ 警告:未找到 Python');
39
+ console.error('请先安装 Python 3.10+');
40
+ console.error(' macOS: brew install python@3.10');
41
+ console.error(' Linux: sudo apt install python3.10');
42
+ console.error(' Windows: https://www.python.org/downloads/');
43
+ return false;
56
44
  }
57
- }
58
45
 
59
- // 检查虚拟环境
60
- function checkVenv() {
61
- if (fs.existsSync(venvPath)) {
62
- console.log(`✓ 虚拟环境:已存在`);
63
- return true;
46
+ console.log(`使用 Python: ${pythonCmd}\n`);
47
+
48
+ // 检查 pyproject.toml 是否存在
49
+ const pyprojectPath = path.join(pythonDir, 'pyproject.toml');
50
+ if (!fs.existsSync(pyprojectPath)) {
51
+ console.error(`⚠ 未找到 pyproject.toml`);
52
+ return false;
64
53
  }
65
- console.log(`○ 虚拟环境:未创建(首次运行会自动创建)`);
66
- return false;
67
- }
68
54
 
69
- // 检查 Playwright
70
- function checkPlaywright() {
71
55
  try {
72
- execSync('python3 -m playwright --version', { encoding: 'utf8', stdio: 'ignore' });
73
- console.log(`✓ Playwright: 已安装`);
56
+ // 使用 pip install -e 安装可编辑模式
57
+ console.log('正在安装 Python 依赖...');
58
+ execSync(`${pythonCmd} -m pip install -e "${pythonDir}"`, {
59
+ stdio: 'inherit',
60
+ env: { ...process.env, PIP_NO_INPUT: '1' }
61
+ });
62
+ console.log('\n✓ Python 依赖安装完成\n');
74
63
  return true;
75
64
  } catch (e) {
76
- console.log(`○ Playwright: 未安装(按需使用)`);
65
+ console.error('\n⚠ Python 依赖安装失败');
66
+ console.error('\n手动安装:');
67
+ console.error(` ${pythonCmd} -m pip install -e "${pythonDir}"`);
77
68
  return false;
78
69
  }
79
70
  }
80
71
 
81
- console.log('依赖检查:\n');
82
- checkPython();
83
- checkPip();
84
- checkVenv();
85
- checkPlaywright();
72
+ // 主函数
73
+ function main() {
74
+ const success = installDependencies();
86
75
 
87
- console.log('\n╭───────────────────────────────────────────────────────────────╮');
88
- console.log('│ 快速开始 │');
89
- console.log('╰───────────────────────────────────────────────────────────────╯\n');
76
+ if (success) {
77
+ console.log('╭───────────────────────────────────────────────────────────────╮');
78
+ console.log('│ 安装完成!快速开始: │');
79
+ console.log('╰───────────────────────────────────────────────────────────────╯\n');
80
+
81
+ console.log('1. 初始化配置:');
82
+ console.log(' travel-agent config --init\n');
90
83
 
91
- console.log('1. 初始化配置:');
92
- console.log(' travel-agent config --init\n');
84
+ console.log('2. 配置 LLM API Key:');
85
+ console.log(' 编辑 .env 文件,填入你的 API Key\n');
93
86
 
94
- console.log('2. 配置 LLM API Key:');
95
- console.log(' 编辑 .env 文件,填入你的 API Key\n');
87
+ console.log('3. 查看支持的模型:');
88
+ console.log(' travel-agent model list\n');
96
89
 
97
- console.log('3. 查看支持的模型:');
98
- console.log(' travel-agent model list\n');
90
+ console.log('4. 运行工作流:');
91
+ console.log(' travel-agent run -k "海岛游"\n');
99
92
 
100
- console.log('4. 运行工作流:');
101
- console.log(' travel-agent run -k "海岛游"\n');
93
+ console.log('更多帮助:');
94
+ console.log(' travel-agent --help\n');
95
+ }
96
+ }
102
97
 
103
- console.log('更多帮助:');
104
- console.log(' travel-agent --help\n');
98
+ main();