Skip to main content

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                 :::*

它实现的功能可以更加复杂(因为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.6.tar.gz (27.5 kB view hashes)

Uploaded Source

Built Distribution

conflict_rpa-0.0.6-py3-none-any.whl (18.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page