0.0.4 • Published 6 months ago
@radekdymacz/coder v0.0.4
Coder - AI Coding Assistant CLI
Overview
coder
is a command-line interface (CLI) tool designed as an AI coding assistant. It leverages the power of Google's Generative AI models (specifically Gemini) through the LangChain and LangGraph frameworks to provide interactive coding help and execute specific tasks.
The agent can:
- Understand and respond to user queries in an interactive session.
- Execute one-off commands.
- Interact with the local file system (list directories, view files).
- Run a limited set of safe shell commands.
Features
- Interactive Mode: Engage in a continuous conversation with the agent. Maintains history for context.
- One-Off Commands: Execute single queries directly.
- Tool Usage: Equipped with tools to:
list_directory
: List contents of a directory.view_file
: View the content of a file (or specific lines).run_command
: Execute basic, safe shell commands.write_to_file
: Create new files with specified content.find_by_name
: Recursively find files/directories matching a pattern.grep_search
: Search for text patterns within files (usesripgrep
if available).
Requirements
- Node.js: Version 18 or higher.
- npm: Included with Node.js.
ripgrep (
rg
) (Recommended forgrep_search
tool): While thegrep_search
tool includes a basic fallback to the standardgrep
command, it performs significantly better (speed, respecting.gitignore
, etc.) ifripgrep
is installed and available in your system's PATH.Installation:
- macOS (using Homebrew):
brew install ripgrep
- Debian/Ubuntu (using apt):
sudo apt update sudo apt install ripgrep
- Fedora/CentOS/RHEL (using yum/dnf):
sudo yum install ripgrep # Older systems # or sudo dnf install ripgrep # Newer systems
- Other platforms: See the ripgrep repository for more options (Windows, source builds, etc.).
- macOS (using Homebrew):
Technology Stack
- Node.js & TypeScript
- LangChain & LangGraph
- Google Generative AI (Gemini)
- Commander.js (for CLI)
- Ink & React (for interactive UI)
- Zod (for schema validation)
Setup
- Clone the repository.
- Install dependencies:
npm install
- Create a
.env
file in the root directory and add your Google API key:GOOGLE_API_KEY=YOUR_API_KEY_HERE
- Build the project:
npm run build
Usage
Interactive Mode (Default)
Start a continuous chat session with the agent:
node dist/cli.js
or
./dist/cli.js interactive
Inside the session, type your requests. Use exit
or quit
to end.
One-Off Command
Run a single query and get a response:
node dist/cli.js run "<your query here>"
Example:
node dist/cli.js run "list files in the src directory"
Publishing to npm (for Maintainers)
- Update
package.json
:- Ensure the
name
is correctly scoped (e.g.,@your-npm-username/coder
). - Increment the
version
number according to SemVer. - Verify the
bin
field points the command name (coder
) to the correct compiled entry point (dist/cli.js
). - Ensure the
files
array includesdist
,README.md
,package.json
, and any other necessary assets. - Update
description
,keywords
,author
,license
, etc. as needed.
- Ensure the
- Build: Compile the TypeScript code:
npm run build
- Login to npm: Authenticate with your npm account:
npm login
- Publish: Publish the package publicly:
# Use --access public for scoped packages (@username/package) npm publish --access public
TODO
- Add More Tools (Prioritized based on Cascade):
- High Priority (Core Functionality):
edit_file
: Modify existing files based on instructions.
- Medium Priority (Enhanced Capabilities):
read_url_content
: Fetch content from a URL.search_web
: Perform web searches via an external API.view_code_item
: View specific code structures (functions/classes).- Enhance
view_file
: Add line ranges and summaries. - Enhance
run_command
: Add non-blocking options with status checks.
- Lower Priority / Future Enhancements:
create_memory
: Implement persistent memory for context across sessions.codebase_search
: Semantic code search (requires embeddings).
- High Priority (Core Functionality):
- Implement more robust error handling in tools and agent flow.
- Add unit and integration tests.
- Improve the safety checks for the
run_command
tool. - Add configuration options (e.g., model selection, temperature).
- Enhance the agent's system prompt for better context awareness.
- Add detailed documentation for each tool.