aisk 0.1.0__tar.gz

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.
aisk-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,113 @@
1
+ Metadata-Version: 2.4
2
+ Name: aisk
3
+ Version: 0.1.0
4
+ Summary: AI-powered terminal command assistant
5
+ Author-email: it_zhouyu <497269678@qq.com>
6
+ License: MIT
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: openai>=1.0.0
10
+
11
+ # 🚀 Ask-CLI
12
+
13
+ **让 AI 成为你的终端翻译官。** `Ask-CLI` 是一个极简的命令行工具,它可以将你的自然语言需求(中文或英文)直接转换为 macOS/Linux 终端命令。
14
+
15
+ 不再需要去 Google 或询问 ChatGPT “如何查找并杀死占用 8080 端口的进程”,只需输入:
16
+
17
+ `ask "杀死8080端口进程"`
18
+
19
+ ---
20
+
21
+ ## ✨ 特性
22
+
23
+ * **自然语言转命令**:基于大模型(默认支持通义千问 Qwen),精准生成 Shell 命令。
24
+ * **一键执行**:生成命令后,**直接按回车(Enter)** 即可执行,极致流畅。
25
+ * **安全确认**:支持按 `Esc` 或 `n` 快速取消,防止误操作。
26
+ * **高度可配置**:支持自定义 API Key、Base URL 以及模型名称。
27
+ * **极简安装**:符合 Python 标准打包规范,支持 `pip` 全局安装。
28
+
29
+ ---
30
+
31
+ ## 📦 安装
32
+
33
+ ### 1. 克隆并安装
34
+
35
+ 在本地克隆仓库后,进入项目根目录执行:
36
+
37
+ ```bash
38
+ pip install .
39
+
40
+ ```
41
+
42
+ ### 2. 配置环境变量
43
+
44
+ 为了让工具正常工作,你需要配置以下环境变量(建议添加到你的 `~/.zshrc` 或 `~/.bash_profile` 中):
45
+
46
+ ```bash
47
+ # 必填:你的 API Key
48
+ export ASK_API_KEY="your-api-key-here"
49
+
50
+ # 选填:如果你使用中转站或阿里云 DashScope
51
+ export ASK_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
52
+
53
+ # 选填:指定使用的模型名称
54
+ export ASK_MODEL_NAME="qwen-max"
55
+
56
+ ```
57
+
58
+ 最后执行 `source ~/.zshrc` 使配置生效。
59
+
60
+ ---
61
+
62
+ ## 🛠 使用说明
63
+
64
+ 直接在终端输入 `ask` 加上你的需求:
65
+
66
+ ```bash
67
+ ask "查找当前目录下大于 100M 的文件"
68
+
69
+ ```
70
+
71
+ ### 交互快捷键:
72
+
73
+ * **[Enter] 回车**:确认并立即执行推荐的命令(默认选项)。
74
+ * **[Esc] 或 [n]**:取消执行并退出。
75
+ * **其他任意键**:终止操作。
76
+
77
+ ---
78
+
79
+ ## 示例展示
80
+
81
+ ```text
82
+ 🔍 正在检索命令: 查看最近10条系统日志...
83
+
84
+ 💡 推荐命令: log show --last 10m | tail -n 10
85
+
86
+ 是否立即执行该命令? (Y/n): [用户按回车]
87
+ Yes
88
+ 🚀 正在执行...
89
+ ... (命令输出内容)
90
+
91
+ ```
92
+
93
+ ---
94
+
95
+ ## 🤝 贡献与反馈
96
+
97
+ 如果你有任何想法、Bug 反馈或想要增加新功能,欢迎提交 **Issue** 或 **Pull Request**!
98
+
99
+ 1. Fork 本仓库
100
+ 2. 创建你的特性分支 (`git checkout -b feature/AmazingFeature`)
101
+ 3. 提交你的修改 (`git commit -m 'Add some AmazingFeature'`)
102
+ 4. 推送到分支 (`git push origin feature/AmazingFeature`)
103
+ 5. 开启一个 Pull Request
104
+
105
+ ---
106
+
107
+ ## 📄 开源协议
108
+
109
+ 本项目采用 [MIT](https://www.google.com/search?q=LICENSE) 协议。
110
+
111
+ ---
112
+
113
+ > **Tip:** 如果你在使用过程中发现生成的命令不符合预期,可以尝试在描述中增加更多上下文,比如 `ask "用 brew 安装 git 并且不交互"`。
aisk-0.1.0/README.md ADDED
@@ -0,0 +1,103 @@
1
+ # 🚀 Ask-CLI
2
+
3
+ **让 AI 成为你的终端翻译官。** `Ask-CLI` 是一个极简的命令行工具,它可以将你的自然语言需求(中文或英文)直接转换为 macOS/Linux 终端命令。
4
+
5
+ 不再需要去 Google 或询问 ChatGPT “如何查找并杀死占用 8080 端口的进程”,只需输入:
6
+
7
+ `ask "杀死8080端口进程"`
8
+
9
+ ---
10
+
11
+ ## ✨ 特性
12
+
13
+ * **自然语言转命令**:基于大模型(默认支持通义千问 Qwen),精准生成 Shell 命令。
14
+ * **一键执行**:生成命令后,**直接按回车(Enter)** 即可执行,极致流畅。
15
+ * **安全确认**:支持按 `Esc` 或 `n` 快速取消,防止误操作。
16
+ * **高度可配置**:支持自定义 API Key、Base URL 以及模型名称。
17
+ * **极简安装**:符合 Python 标准打包规范,支持 `pip` 全局安装。
18
+
19
+ ---
20
+
21
+ ## 📦 安装
22
+
23
+ ### 1. 克隆并安装
24
+
25
+ 在本地克隆仓库后,进入项目根目录执行:
26
+
27
+ ```bash
28
+ pip install .
29
+
30
+ ```
31
+
32
+ ### 2. 配置环境变量
33
+
34
+ 为了让工具正常工作,你需要配置以下环境变量(建议添加到你的 `~/.zshrc` 或 `~/.bash_profile` 中):
35
+
36
+ ```bash
37
+ # 必填:你的 API Key
38
+ export ASK_API_KEY="your-api-key-here"
39
+
40
+ # 选填:如果你使用中转站或阿里云 DashScope
41
+ export ASK_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
42
+
43
+ # 选填:指定使用的模型名称
44
+ export ASK_MODEL_NAME="qwen-max"
45
+
46
+ ```
47
+
48
+ 最后执行 `source ~/.zshrc` 使配置生效。
49
+
50
+ ---
51
+
52
+ ## 🛠 使用说明
53
+
54
+ 直接在终端输入 `ask` 加上你的需求:
55
+
56
+ ```bash
57
+ ask "查找当前目录下大于 100M 的文件"
58
+
59
+ ```
60
+
61
+ ### 交互快捷键:
62
+
63
+ * **[Enter] 回车**:确认并立即执行推荐的命令(默认选项)。
64
+ * **[Esc] 或 [n]**:取消执行并退出。
65
+ * **其他任意键**:终止操作。
66
+
67
+ ---
68
+
69
+ ## 示例展示
70
+
71
+ ```text
72
+ 🔍 正在检索命令: 查看最近10条系统日志...
73
+
74
+ 💡 推荐命令: log show --last 10m | tail -n 10
75
+
76
+ 是否立即执行该命令? (Y/n): [用户按回车]
77
+ Yes
78
+ 🚀 正在执行...
79
+ ... (命令输出内容)
80
+
81
+ ```
82
+
83
+ ---
84
+
85
+ ## 🤝 贡献与反馈
86
+
87
+ 如果你有任何想法、Bug 反馈或想要增加新功能,欢迎提交 **Issue** 或 **Pull Request**!
88
+
89
+ 1. Fork 本仓库
90
+ 2. 创建你的特性分支 (`git checkout -b feature/AmazingFeature`)
91
+ 3. 提交你的修改 (`git commit -m 'Add some AmazingFeature'`)
92
+ 4. 推送到分支 (`git push origin feature/AmazingFeature`)
93
+ 5. 开启一个 Pull Request
94
+
95
+ ---
96
+
97
+ ## 📄 开源协议
98
+
99
+ 本项目采用 [MIT](https://www.google.com/search?q=LICENSE) 协议。
100
+
101
+ ---
102
+
103
+ > **Tip:** 如果你在使用过程中发现生成的命令不符合预期,可以尝试在描述中增加更多上下文,比如 `ask "用 brew 安装 git 并且不交互"`。
@@ -0,0 +1,113 @@
1
+ Metadata-Version: 2.4
2
+ Name: aisk
3
+ Version: 0.1.0
4
+ Summary: AI-powered terminal command assistant
5
+ Author-email: it_zhouyu <497269678@qq.com>
6
+ License: MIT
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: openai>=1.0.0
10
+
11
+ # 🚀 Ask-CLI
12
+
13
+ **让 AI 成为你的终端翻译官。** `Ask-CLI` 是一个极简的命令行工具,它可以将你的自然语言需求(中文或英文)直接转换为 macOS/Linux 终端命令。
14
+
15
+ 不再需要去 Google 或询问 ChatGPT “如何查找并杀死占用 8080 端口的进程”,只需输入:
16
+
17
+ `ask "杀死8080端口进程"`
18
+
19
+ ---
20
+
21
+ ## ✨ 特性
22
+
23
+ * **自然语言转命令**:基于大模型(默认支持通义千问 Qwen),精准生成 Shell 命令。
24
+ * **一键执行**:生成命令后,**直接按回车(Enter)** 即可执行,极致流畅。
25
+ * **安全确认**:支持按 `Esc` 或 `n` 快速取消,防止误操作。
26
+ * **高度可配置**:支持自定义 API Key、Base URL 以及模型名称。
27
+ * **极简安装**:符合 Python 标准打包规范,支持 `pip` 全局安装。
28
+
29
+ ---
30
+
31
+ ## 📦 安装
32
+
33
+ ### 1. 克隆并安装
34
+
35
+ 在本地克隆仓库后,进入项目根目录执行:
36
+
37
+ ```bash
38
+ pip install .
39
+
40
+ ```
41
+
42
+ ### 2. 配置环境变量
43
+
44
+ 为了让工具正常工作,你需要配置以下环境变量(建议添加到你的 `~/.zshrc` 或 `~/.bash_profile` 中):
45
+
46
+ ```bash
47
+ # 必填:你的 API Key
48
+ export ASK_API_KEY="your-api-key-here"
49
+
50
+ # 选填:如果你使用中转站或阿里云 DashScope
51
+ export ASK_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
52
+
53
+ # 选填:指定使用的模型名称
54
+ export ASK_MODEL_NAME="qwen-max"
55
+
56
+ ```
57
+
58
+ 最后执行 `source ~/.zshrc` 使配置生效。
59
+
60
+ ---
61
+
62
+ ## 🛠 使用说明
63
+
64
+ 直接在终端输入 `ask` 加上你的需求:
65
+
66
+ ```bash
67
+ ask "查找当前目录下大于 100M 的文件"
68
+
69
+ ```
70
+
71
+ ### 交互快捷键:
72
+
73
+ * **[Enter] 回车**:确认并立即执行推荐的命令(默认选项)。
74
+ * **[Esc] 或 [n]**:取消执行并退出。
75
+ * **其他任意键**:终止操作。
76
+
77
+ ---
78
+
79
+ ## 示例展示
80
+
81
+ ```text
82
+ 🔍 正在检索命令: 查看最近10条系统日志...
83
+
84
+ 💡 推荐命令: log show --last 10m | tail -n 10
85
+
86
+ 是否立即执行该命令? (Y/n): [用户按回车]
87
+ Yes
88
+ 🚀 正在执行...
89
+ ... (命令输出内容)
90
+
91
+ ```
92
+
93
+ ---
94
+
95
+ ## 🤝 贡献与反馈
96
+
97
+ 如果你有任何想法、Bug 反馈或想要增加新功能,欢迎提交 **Issue** 或 **Pull Request**!
98
+
99
+ 1. Fork 本仓库
100
+ 2. 创建你的特性分支 (`git checkout -b feature/AmazingFeature`)
101
+ 3. 提交你的修改 (`git commit -m 'Add some AmazingFeature'`)
102
+ 4. 推送到分支 (`git push origin feature/AmazingFeature`)
103
+ 5. 开启一个 Pull Request
104
+
105
+ ---
106
+
107
+ ## 📄 开源协议
108
+
109
+ 本项目采用 [MIT](https://www.google.com/search?q=LICENSE) 协议。
110
+
111
+ ---
112
+
113
+ > **Tip:** 如果你在使用过程中发现生成的命令不符合预期,可以尝试在描述中增加更多上下文,比如 `ask "用 brew 安装 git 并且不交互"`。
@@ -0,0 +1,10 @@
1
+ README.md
2
+ pyproject.toml
3
+ aisk.egg-info/PKG-INFO
4
+ aisk.egg-info/SOURCES.txt
5
+ aisk.egg-info/dependency_links.txt
6
+ aisk.egg-info/entry_points.txt
7
+ aisk.egg-info/requires.txt
8
+ aisk.egg-info/top_level.txt
9
+ ask_cli/__init__.py
10
+ ask_cli/main.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ ask = ask_cli.main:main
@@ -0,0 +1 @@
1
+ openai>=1.0.0
@@ -0,0 +1 @@
1
+ ask_cli
File without changes
@@ -0,0 +1,74 @@
1
+ import os
2
+ import sys
3
+ import tty
4
+ import termios
5
+ from openai import OpenAI
6
+
7
+ # 配置环境变量读取
8
+ API_KEY = os.getenv("ASK_API_KEY")
9
+ BASE_URL = os.getenv("ASK_BASE_URL", "https://dashscope.aliyuncs.com/compatible-mode/v1")
10
+ MODEL_NAME = os.getenv("ASK_MODEL_NAME", "qwen-max")
11
+
12
+ def get_char():
13
+ """读取单个字符,支持 Esc、回车和普通字母"""
14
+ fd = sys.stdin.fileno()
15
+ old_settings = termios.tcgetattr(fd)
16
+ try:
17
+ tty.setraw(sys.stdin.fileno())
18
+ ch = sys.stdin.read(1)
19
+ finally:
20
+ termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
21
+ return ch
22
+
23
+ def get_command(nl_input):
24
+ if not API_KEY:
25
+ return "Error: 请配置环境变量 ASK_API_KEY"
26
+
27
+ try:
28
+ client = OpenAI(api_key=API_KEY, base_url=BASE_URL)
29
+ response = client.chat.completions.create(
30
+ model=MODEL_NAME,
31
+ messages=[
32
+ {"role": "system", "content": "You are a macOS terminal expert. Return ONLY the shell command. No markdown, no explanation."},
33
+ {"role": "user", "content": nl_input}
34
+ ]
35
+ )
36
+ return response.choices[0].message.content.strip()
37
+ except Exception as e:
38
+ return f"Error: {str(e)}"
39
+
40
+ def main():
41
+ if len(sys.argv) < 2:
42
+ print("用法: ask '你的需求'")
43
+ return
44
+
45
+ user_query = " ".join(sys.argv[1:])
46
+ print(f"🔍 正在检索命令: {user_query}...")
47
+
48
+ command = get_command(user_query)
49
+
50
+ if command.startswith("Error"):
51
+ print(f"❌ {command}")
52
+ return
53
+
54
+ print(f"\n💡 推荐命令: \033[1;32m{command}\033[0m")
55
+
56
+ # 提示用户,Y 大写表示默认
57
+ print("\n是否立即执行该命令? (Y/n): ", end="", flush=True)
58
+
59
+ char = get_char()
60
+
61
+ # \r 是回车,\n 是换行。如果用户直接按回车,或者输入 y/Y,则执行
62
+ if char in ('\r', '\n', 'y', 'Y'):
63
+ print("Yes") # 回显用户的选择
64
+ print("🚀 正在执行...\n")
65
+ os.system(command)
66
+ # 如果是 Esc (ASCII 27) 或 n/N,则取消
67
+ elif char in (chr(27), 'n', 'N'):
68
+ print("No")
69
+ print("\n已取消执行。")
70
+ else:
71
+ print("\n无效输入,已跳过。")
72
+
73
+ if __name__ == "__main__":
74
+ main()
@@ -0,0 +1,18 @@
1
+ [project]
2
+ name = "aisk"
3
+ version = "0.1.0"
4
+ description = "AI-powered terminal command assistant"
5
+ readme = "README.md"
6
+ authors = [{ name = "it_zhouyu", email = "497269678@qq.com" }]
7
+ license = { text = "MIT" }
8
+ requires-python = ">=3.8"
9
+ dependencies = [
10
+ "openai>=1.0.0",
11
+ ]
12
+
13
+ [project.scripts]
14
+ ask = "ask_cli.main:main"
15
+
16
+ [build-system]
17
+ requires = ["setuptools>=61.0"]
18
+ build-backend = "setuptools.build_meta"
aisk-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+