A tool to rpa in your shell
Project description
Conflict RPA
____ ____ ____ _
/ ___| _ \| _ \ / \
| | | |_) | |_) / _ \
| |___| _ <| __/ ___ \
\____|_| \_\_| /_/ \_\
- 一个应用在
bash/zsh/powershell
上的python包,利用GPT 实现与thefuck略有不同的效果,尤其是解决一些类似于依赖冲突这样不费脑子但是很费时间的问题。 - 功能可以概括为两类
- 通过修正bash 指令或者代码使其运行不出现报错
- 将自然语言转化为bash指令直到正确执行
- Warning 因为该工具确实会自动执行额外的操作,(虽然没有遇到过) 目前难以排除他会执行一些恶性操作的风险。以此为免责声明。
安装
建议python>=3.10
pip install conflict_rpa
conflict_rpa
# 进行相关配置
# source ~/.bashrc 或重启bash
crpa
- 源码安装
pip install --upgrade pip setuptools
pip install .
source ~/.bashrc或重启bash以生效
运行
crpa -h
- 第一次执行时需要用户填入
OPENAI API
配置
功能
命令行纠错
➜ git coomot -am
git: 'coomot' is not a git command. See 'git --help'.
The most similar command is
commit
➜ crpa
# after a sequence of analysis logs
程序执行成功
bash命令“ git config --global user.email "you@example.com"
git config --global user.name "Your Name"; git commit -am 'your commit message'
被修改的文件: []
执行结果:
[main 242105a] your commit message 11 files changed, 843 insertions(+), 863 deletions(-) rewrite README.md (100%)
代码纠错
- 在
test
文件夹下做了一些代码修复样例 - 纠错过程中会修改原始文件,但会保留所有被修改文件的备份
*.bak
➜ python test/test_for_multifile/main.py
Traceback (most recent call last):
File "test/test_for_multifile/main.py", line 1, in <module>
from test.test_for_multifile.count import count
ModuleNotFoundError: No module named 'test.test_for_multifile'
➜ crpa
# after a sequence of analysis logs
程序执行成功
bash命令“ export PYTHONPATH=$(pwd)/test; python test/test_for_multifile/main.py; export PYTHONPATH=$(pwd); python test/test_for_multifile/main.py
被修改的文件: ['test/test_for_multifile/main.py', 'test/test_for_multifile/count.py']
执行结果:
3 3
原始文件
# count.py
def count(a: int, b: int):
assert isinstance(a, str)
return a + b
# main.py
from test.test_for_multifile.count import count
print(count(1, 2))
修改后文件
# count.py
def count(a: int, b: int):
assert isinstance(a, int)
return a + b
# main.py
from count import count
print(count(1, 2))
自动执行教程
如果从 stackoverflow
, github
, CSDN
上找到一些教程链接,可能是关于如何安装新项目或者修改配置的bash指令,那么就可以试试这个功能
➜ crpa -l https://github.com/danielmiessler/fabric
此网站的信息: fabric: An open-source framework for augmenting humans using AI
环境需求: Ensure you have at least python3.10 installed on your operating system.
将执行以下指令:
* cd .
* git clone https://github.com/danielmiessler/fabric.git
* cd fabric
* pipx install . # 因为有操作系统信息,所以这里会直接执行wsl命令
* fabric --help
Do you want to continue? (yes/no): # 你可以检验一下命令是否正确之后顺序执行
必须承认,现在LLM的能力还没有达到能够完美完成大量操作的地步。以下给出另一个调用方法。从教程中复制指令列,来缩小让crpa
自动执行的范围
➜ crpa -t <<EOF
{你想要贴入的教程,这样可以多行粘贴}
EOF
这里的自动化执行在很多时候都有一些小问题,比如你需要提前 git clone
文件,预先安装docker
等等。祝你好运。
自然语言命令
在实现以上功能之后,这个工具可以实现进一步的功能——实现自然语言交互! 这确实是在设计之外的事情
➜ crpa -i 查询当前端口占用
# after a sequence of analysis logs
程序执行成功
bash命令 sudo netstat -tuln
被修改的文件: []
执行结果:
Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State udp 0 0 127.0.0.1:323 0.0.0.0:* udp6 0 0 ::1:323 :::*
其实也可以这样调用:
➜ 查询当前端口占用
# 一段报错
➜ crpa
# after a sequence of analysis logs
程序执行成功
bash命令 sudo netstat -tuln
被修改的文件: []
执行结果:
Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State udp 0 0 127.0.0.1:323 0.0.0.0:* udp6 0 0 ::1:323 :::*
它实现的功能可以更加复杂(因为bash确实又很多很神奇的指令)
➜ crpa -i 抓取github trending 中的所有链接到log
# after a sequence of analysis logs
程序执行成功
bash命令 curl -s https://github.com/trending | grep -Eo '<a [^>]+>' | grep -Eo 'href="[^"]+"' | awk -F'"' '{print $2}' > log
被修改的文件: []
执行结果:
log 中的内容
#start-of-content
https://github.com/
https://github.com/features/actions
https://github.com/features/packages
https://github.com/features/security
https://github.com/features/codespaces
# 等等
好像也可以产生一些可执行的文件?
➜ crpa -i 产生一个可以打印出 ASCII艺术字符格式的"CRPA" 的python脚本
bash命令 pip install pyfiglet; echo 'import pyfiglet'
print(pyfiglet.figlet_format("CRPA"))' > print_crpa.py && python3 print_crpa.py
被修改的文件: []
执行结果:
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Requirement already satisfied: pyfiglet in python3.10/site-packages (1.0.2) ____ ____ ____ _ / ___| _ \| _ \ / \ | | | |_) | |_) / _ \ | |___| _ <| __/ ___ \ \____|_| \_\_| /_/ \_\
产生了一个叫做print_crpa.py
的脚本,帮你装好了库
import pyfiglet
print(pyfiglet.figlet_format("CRPA"))
于是它可以打印出最上方的艺术字
祝您玩得愉快,就在刚刚,它帮我解决了提交冲突,感谢这个工具,希望它也对你有用
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
conflict_rpa-0.0.7.tar.gz
(27.3 kB
view hashes)
Built Distribution
Close
Hashes for conflict_rpa-0.0.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e19d11181941de044507cdc1040668574938b3624e9e6fc181aeb7fb894f321 |
|
MD5 | 7f296a1f954e962f4a3f0e2f940f2290 |
|
BLAKE2b-256 | 6c1d60bd7aaeb67d0141c64291bf03e39b899c291c0e3bea96387337c3e44006 |