Skip to content

Multi-purpose, cross-platform task automation and execution Python tool, supporting AutoGen multi-agents, for AI/LLM and other kinds of tasks. Created by David Joffe @davidjoffe. This is 'beta but stable'. Not open source. NOTE: For some tasks this tool may modify files. Use with caution, in a "sandbox" copy of your files first always.

License

Notifications You must be signed in to change notification settings

djsoftware1/runai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

runai: DJ Software Task Execution and Automation Framework

A kind of integrated 'AI extension' of your terminal or command prompt

General AI/LLM-driven task execution and automation tool for tasks such as code refactoring (or many other tasks, including non-coding-related tasks), supporting AutoGen.

Use also straight from VS Code and Cursor terminal:

runai screenshot by David Joffe and icon symbol

Cross-platform: Integrates into command-line for Windows command prompt, git bash, Linux, or macOS terminal.

Supports either OpenAI, or your own custom AI instances (for example your own LiteLLM server(s)).

Example:

runai -t "Write a Python script that can check daily for updated exchange rate for USD, EUR"

Use -t "task" to specify task to be done.

Help and Examples - Getting Started

runai -h Show full main usage help

runai --version Show version

runai --showsettings Just show settings and exit

Example:

runai --gpt3 -t "Repeat the word coffee five times"`

Common settings quick-reference

runai -h  show full help  --showsettings  just show settings  --version  show version number  --dryrun 
      -t "TASK"  task instructions for LLM to do  -tf "TaskFile" task file to load (default autotasks.txt)
      -m "MODEL" select model  -3 use gpt-3  -4 use gpt-4  --o1-mini  --o1-preview
      -f "FOLDER"  set work-folder   subcommands (refactor,build,create,createfrom,modify) ...
      -i "InputFile" to batch-run task on all lines, with substitution. default=input.txt
USAGE: runai (or python main.py) [taskfile] [targetfolder] [settings.py]

You can use "--showsettings" to just check the settings before run! For example:

runai --showsettings refactor -w main.py

Subcommands Help

  • create: Create new file(s) mode: runai create

  • refactor: Refactor existing files mode: runai refactor

Use runai __subcommand__ -h to show usage help for subcommands (create,refactor,build,createfrom,modify)

runai create -h
=> usage: main.py create [-h] [-o OUT [OUT ...]]

runai refactor -h
=> usage: runai refactor [-h] [-r FIND_REGEX] [--find-text FIND_TEXT]
   [-w WILDCARDS [WILDCARDS ...]][--replace-with REPLACE_WITH] [-s SEND [SEND ...]]

Try a simple test like this to see if it's working:

runai -4 -t "Hi, can you help me?"

Selecting Model

Options for selecting the model to use:

   -4 or --gpt4 - use gpt4
   -3 or --gpt3 - use gpt3
   -m "model" OR --model "modeL" - use "model"
   --o1-mini - use o1-mini
   --o1-preview - use o1-preview

Example: runai -3 -t "Write a short story about cats"

Note: For some tasks, this tool can modify files, so use with caution. Always backup all your data first, work in a 'sandbox' copy, and check all ch ananges. Test things first. Use at own risk.

License and Terms of Use

  • Free to use for personal, non-commercial use only. For commercial use and organizations (such as government institutions), a support and licensing fee required.
  • Not open source.
  • License, EULA and disclaimers

Installation

First, either download runai (as a zip), or clone this GitHub repo: $ git clone https://github.com/djsoftware1/runai

Then install requirements (you may use an env, though may be useful to install globally to more easily run "runai" from anywhere on command line):

pip install -r requirements.txt

To run:

$ runai

Or (old way): python main.py

If you follow the instructions here to add this to your system PATH, then you can just type "runai" from anywhere. (Otherwise, use "./runai" or a full path to run.)

If using OpenAI, then place your configuration with API key in OAI_CONFIG_LIST

PATH Setup

runai "works best" if you optionally add to your system PATH - then you can just type "runai" on the command line from any folder to run - potentially very powerful.

On Windows you can use the system Environment Variables dialog to add runai to PATH. (git bash should automatically 'inherit' this for its PATH.)

For Linux/macOS (or also git bash), add a line like this in e.g. your .bashrc or zshrc startup file to add it to PATH on bash startup:

    export PATH="/c/src/runai:$PATH"

(If, for example, you did 'git clone' this project into your, say, "/c/src" folder.)

("runai" is just a small wrapper for 'python main.py'.)

Simple Test

Try a simple test like this to see if it's working:

    runai -4 -t "Hi, can you help me ?"

Show Settings and Exit

runai --showsettings

OR e.g. with a task settings:

runai --showsettings refactor -w "*.cpp" "*.h"

runai -t mytask.txt --showsettings refactor -w "*.cpp" "*.h"

# Straight-forward non-AI replace:
runai  refactor -w "main.py" -r "findme" --replace-with "foo"

etc.

Task files and autotask.txt

By default, it looks for a file named "autotask.txt" in the folder you run it, and if found, automatically loads the task from that file.

Or, you can specify a task file with "-tf" or "--taskfile" (or task string with -t).

If no autotask found, and no task or taskfile passed as parameter, it will ask for a task.

Custom LiteLLM Server:

It is recommended to use a separate Python environment for litellm to avoid dependency issues.

# Optional if want to run local AI server:
$ pip install litellm (or: python3 -m pip install litellm)

And possibly also:

$ pip install litellm[proxy]

Then e.g. 'ollama pull codellama' and 'litellm --model ollama/codellama'

Some kinds of tasks don't require AI at all, and are just done locally, e.g. a refactor straightforward regex replace.

Multi-line input replacements

If feeding an input list, you can use "{$1}" in the task string to replace it with the line contents, for example if your input lines are:

Vec2d
Vec3d
Matrix4d

You can use e.g. "Generate a class called {$1} with implementation" etc.

The special variable "{$line}" can be replaced with the original line number of the input file.

  • {$line} Replace with current input line number in task string for multi-line input
  • {$date} Replace with current date (UTC) in task string
  • {$time} Replace with current time (UTC) in task string
  • {$datetime} Replace with current date and time (UTC) in task string (YYYY-MM-DD HH-MM-SS)

To try force use of GPT3, GPT4, o1-mini or other preferred model:

OpenAI/AutoGen tasks: Provided your OAI_CONFIG_LIST is set up correctly with GPT3 and GPT4 you can use the command-line parameters described above under the 'Help' section to select any preferred model.

Design thoughts on main task types:

Main Task Types:

  1. Code Generation

    • Add new code, such as classes, functions, or entire modules.
    • Example: Automatically generate a new Vec3d class in vec3d.h/cpp files.
  2. Code Enhancement

    • Extend existing files by adding new functionalities, methods, or classes.
    • Implement stubs or abstract methods.
    • Example: Add new methods to an existing class or implement TODOs.
  3. Code Refactoring

    • Modify existing code to improve structure, performance, readability, or maintainability without changing its external behavior.
    • Example: Refactor specific patterns, optimize algorithms, or update to newer syntax.
# Use "--showsetttings" to just check the settings before run
runai --showsettings refactor -w main.py
runai refactor -w src/MyFile.cpp

runai --showsettings refactor -w "*.cpp" "*.h"
runai refactor -w "*.cpp" "*.h"

runai refactor -w src/MyFile.cpp

  1. Build and Test Automation

    • Compile code, run build processes, and execute automated tests.
    • Analyze build logs and test reports for errors or warnings.
    • Example: Run unit tests, integration tests, and analyze results.
  2. Code Analysis and Linting

    • Perform static code analysis for potential issues.
    • Enforce coding standards and style guides.
    • Example: Run linters and format code according to PEP 8 for Python.
  3. Documentation Generation

    • Auto-generate documentation from code comments and docstrings.
    • Keep documentation in sync with code changes.
    • Example: Generate API documentation using tools like Doxygen or Sphinx.
  4. Dependency Management

    • Update or manage external libraries and dependencies.
    • Ensure compatibility and security of dependencies.
    • Example: Update packages to the latest versions while ensuring compatibility.
  5. Version Control Operations

    • Automate commits, merges, branches, and other version control operations.
    • Handle version tagging and release management.
    • Example: Auto-commit changes after successful tests and linting.
  6. Deployment and Release Automation

    • Automate the deployment of code to production or staging environments.
    • Manage release cycles and deployment schedules.
    • Example: Automatically deploy code to a staging server after passing CI/CD pipelines.

Examples

    runai -4 -tf /c/runai/tasks/copyright/task.txt -f ./cppcode_folder/ -s /c/runai/tasks/copyright/settings.py refactor -w "*.cpp"

About

Multi-purpose automation framework, optionally with AutoGen multi-agents, for AI/LLM and other task automation, created by David Joffe @davidjoffe (beta/early dev)

Other potential names: dj-runAI, or djrun, or perhaps 'dj-run-tasks' (to reflect that not all tasks are AI-based).

Copyright

This project Copyright (C) David Joffe and DJ Software 2023-2025

"DJ Software" is just short for "David Joffe Software", and is a name I created to place some of my software under (and of 1. a potential entity, and 2. of this GitHub organization "djsoftware1" I created for DJ Software).

See also djoffe.com/dj-software/

  • David Joffe

About

Multi-purpose, cross-platform task automation and execution Python tool, supporting AutoGen multi-agents, for AI/LLM and other kinds of tasks. Created by David Joffe @davidjoffe. This is 'beta but stable'. Not open source. NOTE: For some tasks this tool may modify files. Use with caution, in a "sandbox" copy of your files first always.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages