Inspiration

Usually, I would spend hours monitoring tasks with dread to the point that I couldn't multi task properly without feeling a sense of exhaustion when hopping to different tasks. So, the rise of MCP inspired me to ease my pain by collecting all known aspects of repetitive tasks and into a unified whole known as CopyCat.

What it does

CopyCat is a TUI utilizing rich and python prompt-toolkit to bring an interactive experience to the terminal, and uses sqlmodel, fastapi, and, mainly, strands sdk agents to monitor tasks given an appointed .git directory. CopyCat then uses git diff's to monitor code differences and if syntax errors, bugs or a potential flaw in the repository is detected, then CopyCat would use its tool calling capabilities to call the append_task() tool to generate a proposed fix, an issue summary, a unique, integer id, and a proposed shell script to mitigate the issue. Each task is stored with a default status of "pending". After viewing all collected tasks, the user can go through each one, review the shell script associated with it and use the -cs (change_status) argument to change the status of any task with its corresponding id to a status of "complete" which calls a PATCH request to the fastapi server to change its status and run its associated shell script.

How we built it

CopyCat is built as a TUI application working to capture bugs or potential leaks in amidst your development.

TUI Components: CopyCat is a TUI built on rich and prompt toolkit to display dynamic table updates as well as a neat user interface, prompt toolkit was utilized here to capture user prompts regarding the targeted path/file containing .git

Git diffs and SDK agents: After the user inputs their targeted file/directory into the prompt toolkit interface, strands sdk agents takes the file / directory and utilizes git diff to see code changes amidst development to monitor changes and if there are potential additions that can lead to information compromise such as leaving secrets in the open.

MCP tool calling: After a vulnerability is detected, the agent uses its tool calling capabilities to append a task to the agent_tasks.db database which contains an ID, status, proposed fix, issue summary and a proposed shell script.

SQLModel, fastapi and argparse: To effectively mitigate the error, we used fastapi which is ran by uvicorn using the "Start Server directly" approach in the TUI. Uvicorn opens the fastapi framework on a loopback address with a port of 8000, fastapi uses the /tasks route to return all tasks in the database including pending and completed ones. The user can then review each task and its unique id and use argparsing to change the status of a task given its ID to "complete". Which in turn, would execute the shell command proposed by the agent on the host's machine.

Challenges we ran into

During the development of CopyCat, we faced challenges that caused setbacks and delays during development 3 days before the deadline. One of the most difficult errors was getting the agent to comply properly without it appending its own given instructions as a task, this was during the time where we were implementing ollama which we then realized was tenuous. We read about the free credits in AWS bedrock and thought of using claude 3.5 sonnet bedrock instead, which worked flawlessly; however, one of the most difficult error throughout was due to the object oriented approach of CopyCat. We faced difficulties in child class inheritance, as the main file that the user runs is minimal and only relies on the backend (parent classes) located in the utils folder. This created issues in circular imports and to debug this error, we created a separate file called GLOBAL.py which contained all the globally used variables and methods that BOTH classes inherit from, this mitigated the circular import error and worked seamlessly.

Accomplishments that we're proud of

  • The interplay between FASTAPI and sqlmodel: The beautiful interaction between fastapi and sqlmodel helped block other paths that were tenuous or overly intricate in terms of task management.

  • Connected the strands agent to custom tools: The agent utilized its own tool calling methods to decide whether the error / bug is worthy of being appended to the database.

  • Implemented a modern UI/UX into the terminal: Using rich and prompt toolkit to enhance UI and UX by creating a beautiful layout where each separate container contains information for the database, readable and concise

  • Safe shell script execution context: By giving tasks an initial status of "pending", users are able to view proposed shell script fixes before running commands, in case a command may be dangerous to the host's system.

What we learned

As a TUI developer, implementing the front end was not hard, neither was the backend, but one of the most impactful things that I am proud of learning is that I overcame the complexity of SQL and fastapi, with a strict deadline 10 days before, I read about sqlmodel and fastapi and their documentation which was studied and implemented into my source code. The cause of my intimidation was due to the fact that in the previous years I always saw posts on "An easier alternative to sql", and repetitive posts were based on this. Due to this I reasoned that sql was difficult and there was no way I am going to learn about it, however, after this project, I not only overcame the perplexity but I also learned how to be able to connect sqlmodel to various sources, in this case, fastapi.

What's next for CopyCat

  • Cross platform compatibility: CopyCat is currently in version 0.0.1, meaning its fresh, in the future I plan to implement seamless windows support for most users as well as compatible shell commands for both OS's: Linux and Windows.
  • Dynamic model choosing: CopyCat will also include the option to be able to freely select agents from AWS bedrock, as a contrast to being limited to one: Claude sonnet.
  • Free ollama branch: In the future we plan to implement a separate branch for users who wish to use ollama models.

Built With

  • fastapi
  • prompt-toolkit
  • python
  • rich
  • sqlmodel
  • strands-sdk-agents
  • uvicorn
Share this project:

Updates

Submission history