clacky 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.clackyrules +80 -0
- data/.rspec +3 -0
- data/.rubocop.yml +8 -0
- data/CHANGELOG.md +74 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/LICENSE.txt +21 -0
- data/README.md +272 -0
- data/Rakefile +12 -0
- data/lib/clacky/agent.rb +964 -0
- data/lib/clacky/agent_config.rb +47 -0
- data/lib/clacky/cli.rb +666 -0
- data/lib/clacky/client.rb +159 -0
- data/lib/clacky/config.rb +43 -0
- data/lib/clacky/conversation.rb +41 -0
- data/lib/clacky/hook_manager.rb +61 -0
- data/lib/clacky/progress_indicator.rb +53 -0
- data/lib/clacky/session_manager.rb +124 -0
- data/lib/clacky/thinking_verbs.rb +26 -0
- data/lib/clacky/tool_registry.rb +44 -0
- data/lib/clacky/tools/base.rb +64 -0
- data/lib/clacky/tools/edit.rb +100 -0
- data/lib/clacky/tools/file_reader.rb +79 -0
- data/lib/clacky/tools/glob.rb +93 -0
- data/lib/clacky/tools/grep.rb +169 -0
- data/lib/clacky/tools/run_project.rb +287 -0
- data/lib/clacky/tools/safe_shell.rb +397 -0
- data/lib/clacky/tools/shell.rb +305 -0
- data/lib/clacky/tools/todo_manager.rb +228 -0
- data/lib/clacky/tools/trash_manager.rb +367 -0
- data/lib/clacky/tools/web_fetch.rb +161 -0
- data/lib/clacky/tools/web_search.rb +138 -0
- data/lib/clacky/tools/write.rb +65 -0
- data/lib/clacky/utils/arguments_parser.rb +139 -0
- data/lib/clacky/utils/limit_stack.rb +80 -0
- data/lib/clacky/utils/path_helper.rb +15 -0
- data/lib/clacky/version.rb +5 -0
- data/lib/clacky.rb +38 -0
- data/sig/clacky.rbs +4 -0
- metadata +152 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 9c76e82a2f70e2bb34e98a8c81b7cf9a7c6f561d3218e32c44b4191160614279
|
|
4
|
+
data.tar.gz: b5aa7eb4906ac3737c58e17a9c64763dbf287c2b453b7dcc8d4db0ac64c6a241
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 06c9e6dcff8dd3033145fa7945820870432265ce00cbe32728e09fccc99b698c7c7431f9cf8a887c1f249c1538f6fbfbc0e10d5a506b5d89652daa315c9ae053
|
|
7
|
+
data.tar.gz: d374692b73182a5c844a3a1c528a5677bcba751063afe6b2604b037314afd6e4bfc9ef1121ebdc30acb49336a0a914b3035f46d705ad0816ef1a32371436c175
|
data/.clackyrules
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Clacky Project Rules (.clackyrules)
|
|
2
|
+
|
|
3
|
+
## Project Overview
|
|
4
|
+
This is the `clacky` Ruby gem - a command-line interface for interacting with AI models (Claude, OpenAI, etc.).
|
|
5
|
+
It provides chat functionality and autonomous AI agent capabilities with tool use.
|
|
6
|
+
|
|
7
|
+
## Project Structure
|
|
8
|
+
- `lib/clacky/` - Main gem source code
|
|
9
|
+
- `cli.rb` - Command-line interface using Thor
|
|
10
|
+
- `agent.rb` - Core AI agent with tool execution
|
|
11
|
+
- `tools/` - Built-in tools (file operations, web search, shell, etc.)
|
|
12
|
+
- `client.rb` - API client for AI models
|
|
13
|
+
- `config.rb` - Configuration management
|
|
14
|
+
- `bin/` - Development executables
|
|
15
|
+
- `spec/` - RSpec test suite
|
|
16
|
+
- `clacky.gemspec` - Gem specification
|
|
17
|
+
|
|
18
|
+
## Development Guidelines
|
|
19
|
+
|
|
20
|
+
### Code Style
|
|
21
|
+
- Follow Ruby conventions and best practices
|
|
22
|
+
- Use frozen string literals: `# frozen_string_literal: true`
|
|
23
|
+
- Keep classes focused and single-responsibility
|
|
24
|
+
- Use meaningful variable and method names
|
|
25
|
+
- Add descriptive comments for complex logic
|
|
26
|
+
|
|
27
|
+
### Architecture Patterns
|
|
28
|
+
- Tools inherit from `Clacky::Tools::Base`
|
|
29
|
+
- Each tool defines: `tool_name`, `tool_description`, `tool_category`, `tool_parameters`
|
|
30
|
+
- Agent uses React pattern (Reason-Act-Observe) for task execution
|
|
31
|
+
- Configuration is managed through `Clacky::Config`
|
|
32
|
+
- CLI commands use Thor framework
|
|
33
|
+
|
|
34
|
+
### Testing
|
|
35
|
+
- Use RSpec for testing
|
|
36
|
+
- Test files in `spec/` directory
|
|
37
|
+
- **IMPORTANT**: Always run `bundle exec rspec` to verify tests pass after making changes
|
|
38
|
+
- All tests must pass before considering a task complete
|
|
39
|
+
- Maintain good test coverage
|
|
40
|
+
- When modifying existing functionality, ensure related tests still pass
|
|
41
|
+
- When adding new features, consider adding corresponding tests
|
|
42
|
+
|
|
43
|
+
### Tool Development
|
|
44
|
+
When adding new tools:
|
|
45
|
+
1. Create class in `lib/clacky/tools/`
|
|
46
|
+
2. Inherit from `Clacky::Tools::Base`
|
|
47
|
+
3. Define required class attributes
|
|
48
|
+
4. Implement `execute` method
|
|
49
|
+
5. Add optional `format_call` and `format_result` methods
|
|
50
|
+
6. Require in `lib/clacky.rb`
|
|
51
|
+
|
|
52
|
+
### Agent Behavior
|
|
53
|
+
- TODO manager is for planning only - must execute tasks after planning
|
|
54
|
+
- Always use tools to create/modify files, don't just return code
|
|
55
|
+
- Maintain conversation context across tasks
|
|
56
|
+
- Follow cost and iteration limits
|
|
57
|
+
- Support different permission modes (confirm_all, confirm_edits, auto_approve, plan_only)
|
|
58
|
+
|
|
59
|
+
## Dependencies
|
|
60
|
+
- Ruby >= 3.1.0
|
|
61
|
+
- faraday (~> 2.0) - HTTP client
|
|
62
|
+
- thor (~> 1.3) - CLI framework
|
|
63
|
+
- tty-prompt (~> 0.23) - Interactive prompts
|
|
64
|
+
- tty-spinner (~> 0.9) - Progress indicators
|
|
65
|
+
- diffy (~> 3.4) - Text diffs
|
|
66
|
+
|
|
67
|
+
## Important Notes
|
|
68
|
+
- This gem is designed to work with OpenAI-compatible APIs
|
|
69
|
+
- Security features include safe shell execution and path validation
|
|
70
|
+
- Agent includes cost control and message compression features
|
|
71
|
+
- Built-in tools cover file operations, web search, code execution, and project management
|
|
72
|
+
|
|
73
|
+
## Execution Binary
|
|
74
|
+
- Development: `bin/clacky` (in repository)
|
|
75
|
+
- Installed gem: `clacky` command globally available
|
|
76
|
+
|
|
77
|
+
## Configuration
|
|
78
|
+
- Stores API keys and settings in user's home directory
|
|
79
|
+
- Supports multiple AI model providers
|
|
80
|
+
- Configurable through `clacky config set` command
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.5.0] - 2026-01-11
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- **Agent Mode**: Autonomous AI agent with tool execution capabilities
|
|
14
|
+
- **Built-in Tools**:
|
|
15
|
+
- `safe_shell` - Safe shell command execution with security checks
|
|
16
|
+
- `file_reader` - Read file contents
|
|
17
|
+
- `write` - Create/overwrite files with diff preview
|
|
18
|
+
- `edit` - Precise file editing with string replacement
|
|
19
|
+
- `glob` - Find files using glob patterns
|
|
20
|
+
- `grep` - Search file contents with regex
|
|
21
|
+
- `web_search` - Search the web for information
|
|
22
|
+
- `web_fetch` - Fetch and parse web pages
|
|
23
|
+
- `todo_manager` - Task planning and tracking
|
|
24
|
+
- `run_project` - Project dev server management
|
|
25
|
+
- **Session Management**: Save, resume, and list conversation sessions
|
|
26
|
+
- **Permission Modes**:
|
|
27
|
+
- `auto_approve` - Automatically execute all tools
|
|
28
|
+
- `confirm_safes` - Auto-execute safe operations, confirm risky ones
|
|
29
|
+
- `confirm_edits` - Confirm file edits only
|
|
30
|
+
- `confirm_all` - Confirm every tool execution
|
|
31
|
+
- `plan_only` - Plan without executing
|
|
32
|
+
- **Cost Control**: Track and limit API usage costs
|
|
33
|
+
- **Message Compression**: Automatic conversation history compression
|
|
34
|
+
- **Project Rules**: Support for `.clackyrules`, `.cursorrules`, and `CLAUDE.md`
|
|
35
|
+
- **Interactive Confirmations**: Preview diffs and shell commands before execution
|
|
36
|
+
- **Hook System**: Extensible event hooks for customization
|
|
37
|
+
|
|
38
|
+
### Changed
|
|
39
|
+
- Refactored architecture to support autonomous agent capabilities
|
|
40
|
+
- Enhanced CLI with agent command and session management
|
|
41
|
+
- Improved error handling and retry logic for network failures
|
|
42
|
+
- Better progress indicators during API calls and compression
|
|
43
|
+
|
|
44
|
+
### Fixed
|
|
45
|
+
- API compatibility issues with different providers
|
|
46
|
+
- Session restoration with error recovery
|
|
47
|
+
- Tool execution feedback loop
|
|
48
|
+
- Safe shell command validation
|
|
49
|
+
- Edit tool string matching and preview
|
|
50
|
+
|
|
51
|
+
## [0.1.0] - 2025-12-27
|
|
52
|
+
|
|
53
|
+
### Added
|
|
54
|
+
- Initial release of Clacky
|
|
55
|
+
- Interactive chat mode for conversations with Claude
|
|
56
|
+
- Single message mode for quick queries
|
|
57
|
+
- Configuration management for API keys
|
|
58
|
+
- Support for Claude 3.5 Sonnet model
|
|
59
|
+
- Colorful terminal output with TTY components
|
|
60
|
+
- Secure API key storage in `~/.clacky/config.yml`
|
|
61
|
+
- Multi-turn conversation support with context preservation
|
|
62
|
+
- Command-line interface powered by Thor
|
|
63
|
+
- Comprehensive test suite with RSpec
|
|
64
|
+
|
|
65
|
+
### Features
|
|
66
|
+
- `clacky chat [MESSAGE]` - Start interactive chat or send single message
|
|
67
|
+
- `clacky config set` - Configure API key
|
|
68
|
+
- `clacky config show` - Display current configuration
|
|
69
|
+
- `clacky version` - Show version information
|
|
70
|
+
- Model selection via `--model` option
|
|
71
|
+
|
|
72
|
+
[Unreleased]: https://github.com/yafeilee/clacky/compare/v0.5.0...HEAD
|
|
73
|
+
[0.5.0]: https://github.com/yafeilee/clacky/compare/v0.1.0...v0.5.0
|
|
74
|
+
[0.1.0]: https://github.com/yafeilee/clacky/releases/tag/v0.1.0
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
+
nationality, personal appearance, race, caste, color, religion, or sexual
|
|
10
|
+
identity and orientation.
|
|
11
|
+
|
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
+
diverse, inclusive, and healthy community.
|
|
14
|
+
|
|
15
|
+
## Our Standards
|
|
16
|
+
|
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
|
18
|
+
community include:
|
|
19
|
+
|
|
20
|
+
* Demonstrating empathy and kindness toward other people
|
|
21
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
22
|
+
* Giving and gracefully accepting constructive feedback
|
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
24
|
+
and learning from the experience
|
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the overall
|
|
26
|
+
community
|
|
27
|
+
|
|
28
|
+
Examples of unacceptable behavior include:
|
|
29
|
+
|
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or advances of
|
|
31
|
+
any kind
|
|
32
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
33
|
+
* Public or private harassment
|
|
34
|
+
* Publishing others' private information, such as a physical or email address,
|
|
35
|
+
without their explicit permission
|
|
36
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
+
professional setting
|
|
38
|
+
|
|
39
|
+
## Enforcement Responsibilities
|
|
40
|
+
|
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
44
|
+
or harmful.
|
|
45
|
+
|
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
49
|
+
decisions when appropriate.
|
|
50
|
+
|
|
51
|
+
## Scope
|
|
52
|
+
|
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
54
|
+
an individual is officially representing the community in public spaces.
|
|
55
|
+
Examples of representing our community include using an official email address,
|
|
56
|
+
posting via an official social media account, or acting as an appointed
|
|
57
|
+
representative at an online or offline event.
|
|
58
|
+
|
|
59
|
+
## Enforcement
|
|
60
|
+
|
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
62
|
+
reported to the community leaders responsible for enforcement at
|
|
63
|
+
[INSERT CONTACT METHOD].
|
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
65
|
+
|
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
|
67
|
+
reporter of any incident.
|
|
68
|
+
|
|
69
|
+
## Enforcement Guidelines
|
|
70
|
+
|
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
|
73
|
+
|
|
74
|
+
### 1. Correction
|
|
75
|
+
|
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
77
|
+
unprofessional or unwelcome in the community.
|
|
78
|
+
|
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
|
82
|
+
|
|
83
|
+
### 2. Warning
|
|
84
|
+
|
|
85
|
+
**Community Impact**: A violation through a single incident or series of
|
|
86
|
+
actions.
|
|
87
|
+
|
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
|
92
|
+
like social media. Violating these terms may lead to a temporary or permanent
|
|
93
|
+
ban.
|
|
94
|
+
|
|
95
|
+
### 3. Temporary Ban
|
|
96
|
+
|
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
|
98
|
+
sustained inappropriate behavior.
|
|
99
|
+
|
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
|
101
|
+
communication with the community for a specified period of time. No public or
|
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
|
104
|
+
Violating these terms may lead to a permanent ban.
|
|
105
|
+
|
|
106
|
+
### 4. Permanent Ban
|
|
107
|
+
|
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
|
111
|
+
|
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within the
|
|
113
|
+
community.
|
|
114
|
+
|
|
115
|
+
## Attribution
|
|
116
|
+
|
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
118
|
+
version 2.1, available at
|
|
119
|
+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
|
120
|
+
|
|
121
|
+
Community Impact Guidelines were inspired by
|
|
122
|
+
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
|
123
|
+
|
|
124
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
125
|
+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
|
126
|
+
[https://www.contributor-covenant.org/translations][translations].
|
|
127
|
+
|
|
128
|
+
[homepage]: https://www.contributor-covenant.org
|
|
129
|
+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
|
130
|
+
[Mozilla CoC]: https://github.com/mozilla/diversity
|
|
131
|
+
[FAQ]: https://www.contributor-covenant.org/faq
|
|
132
|
+
[translations]: https://www.contributor-covenant.org/translations
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 windy
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
# Clacky
|
|
2
|
+
|
|
3
|
+
A command-line interface for interacting with AI models. Clacky supports OpenAI-compatible APIs, making it easy to chat with various AI models directly from your terminal.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 💬 Interactive chat sessions with AI models
|
|
8
|
+
- 🤖 Autonomous AI agent with tool use capabilities
|
|
9
|
+
- 🚀 Single-message mode for quick queries
|
|
10
|
+
- 🔐 Secure API key management
|
|
11
|
+
- 📝 Multi-turn conversation support
|
|
12
|
+
- 🎨 Colorful terminal output
|
|
13
|
+
- 🌐 OpenAI-compatible API support (OpenAI, Gitee AI, DeepSeek, etc.)
|
|
14
|
+
- 🛠️ Rich built-in tools: file operations, web search, code execution, and more
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
Install the gem by executing:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
gem install clacky
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Or add it to your Gemfile:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
bundle add clacky
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
For development from source:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
git clone https://github.com/yafeilee/clacky.git
|
|
34
|
+
cd clacky
|
|
35
|
+
bundle install
|
|
36
|
+
bin/clacky
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Configuration
|
|
40
|
+
|
|
41
|
+
Before using Clacky, you need to configure your settings:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
clacky config set
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
You'll be prompted to enter:
|
|
48
|
+
- **API Key**: Your API key from any OpenAI-compatible provider
|
|
49
|
+
- **Model**: Model name (e.g., `gpt-4`, `deepseek-chat`)
|
|
50
|
+
- **Base URL**: OpenAI-compatible API endpoint (e.g., `https://api.openai.com/v1`)
|
|
51
|
+
|
|
52
|
+
To view your current configuration:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
clacky config show
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Usage
|
|
59
|
+
|
|
60
|
+
### Interactive Chat Mode
|
|
61
|
+
|
|
62
|
+
Start an interactive chat session:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
clacky chat
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Type your messages and press Enter. Type `exit` or `quit` to end the session.
|
|
69
|
+
|
|
70
|
+
### Single Message Mode
|
|
71
|
+
|
|
72
|
+
Send a single message and get a response:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
clacky chat "What is Ruby?"
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Specify Model
|
|
79
|
+
|
|
80
|
+
You can specify which model to use (overrides config):
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
clacky chat --model=gpt-4 "Hello!"
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### AI Agent Mode (Interactive)
|
|
87
|
+
|
|
88
|
+
Run an autonomous AI agent in interactive mode. The agent can use tools to complete tasks and runs in a continuous loop, allowing you to have multi-turn conversations with tool use capabilities.
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# Start interactive agent (will prompt for tasks)
|
|
92
|
+
clacky agent
|
|
93
|
+
|
|
94
|
+
# Start with an initial task, then continue interactively
|
|
95
|
+
clacky agent "Create a README.md file for my project"
|
|
96
|
+
|
|
97
|
+
# Auto-approve all tool executions
|
|
98
|
+
clacky agent --mode=auto_approve
|
|
99
|
+
|
|
100
|
+
# Work in a specific project directory
|
|
101
|
+
clacky agent --path /path/to/project
|
|
102
|
+
|
|
103
|
+
# Limit tools available to the agent
|
|
104
|
+
clacky agent --tools file_reader glob grep
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
The agent will:
|
|
108
|
+
1. Complete each task using its React (Reason-Act-Observe) cycle
|
|
109
|
+
2. Show you the results
|
|
110
|
+
3. Wait for your next instruction
|
|
111
|
+
4. Maintain conversation context across tasks
|
|
112
|
+
5. Type 'exit' or 'quit' to end the session
|
|
113
|
+
|
|
114
|
+
#### Permission Modes
|
|
115
|
+
|
|
116
|
+
- `confirm_all` (default) - Confirm every tool use
|
|
117
|
+
- `confirm_edits` - Auto-approve read-only tools, confirm edits
|
|
118
|
+
- `auto_approve` - Automatically execute all tools (use with caution)
|
|
119
|
+
- `plan_only` - Generate plan without executing
|
|
120
|
+
|
|
121
|
+
#### Agent Options
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
--path PATH # Project directory (defaults to current directory)
|
|
125
|
+
--mode MODE # Permission mode
|
|
126
|
+
--tools TOOL1 TOOL2 # Allowed tools (or "all")
|
|
127
|
+
--max-iterations N # Maximum iterations (default: 50)
|
|
128
|
+
--max-cost N # Maximum cost in USD (default: 5.0)
|
|
129
|
+
--verbose # Show detailed output
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
#### Cost Control & Memory Management
|
|
133
|
+
|
|
134
|
+
The agent includes intelligent cost control features:
|
|
135
|
+
|
|
136
|
+
- **Automatic Message Compression**: When conversation history grows beyond 30 messages, the agent automatically compresses older messages into a summary, keeping only the system prompt and the most recent 10 messages. This dramatically reduces token costs for long-running tasks (achieves ~60% compression ratio).
|
|
137
|
+
|
|
138
|
+
- **Configurable Limits**:
|
|
139
|
+
- `max_iterations`: Maximum number of agent loops (default: 50)
|
|
140
|
+
- `max_cost_usd`: Maximum total cost in USD (default: $5.00)
|
|
141
|
+
- `timeout_seconds`: Maximum execution time (default: 600s)
|
|
142
|
+
|
|
143
|
+
- **Compression Settings**:
|
|
144
|
+
- `enable_compression`: Enable/disable automatic compression (default: true)
|
|
145
|
+
- `keep_recent_messages`: Number of recent messages to preserve (default: 10)
|
|
146
|
+
- Compression triggers at: `keep_recent_messages + 20` messages
|
|
147
|
+
|
|
148
|
+
Example with custom limits:
|
|
149
|
+
```bash
|
|
150
|
+
clacky agent --max-iterations=100 --max-cost=10.0 --verbose
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### List Available Tools
|
|
154
|
+
|
|
155
|
+
View all built-in tools:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
clacky tools
|
|
159
|
+
|
|
160
|
+
# Filter by category
|
|
161
|
+
clacky tools --category file_system
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
#### Built-in Tools
|
|
165
|
+
|
|
166
|
+
- **todo_manager** - Manage TODO items for task planning and tracking
|
|
167
|
+
- **file_reader** - Read file contents
|
|
168
|
+
- **write** - Create or overwrite files
|
|
169
|
+
- **edit** - Make precise edits to existing files
|
|
170
|
+
- **glob** - Find files by pattern matching
|
|
171
|
+
- **grep** - Search file contents with regex
|
|
172
|
+
- **shell** - Execute shell commands
|
|
173
|
+
- **calculator** - Perform mathematical calculations
|
|
174
|
+
- **web_search** - Search the web for information
|
|
175
|
+
- **web_fetch** - Fetch and parse web page content
|
|
176
|
+
|
|
177
|
+
### Available Commands
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
clacky chat [MESSAGE] # Start a chat or send a single message
|
|
181
|
+
clacky agent [MESSAGE] # Run autonomous agent with tool use
|
|
182
|
+
clacky tools # List available tools
|
|
183
|
+
clacky config set # Set your API key
|
|
184
|
+
clacky config show # Show current configuration
|
|
185
|
+
clacky version # Show clacky version
|
|
186
|
+
clacky help # Show help information
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Examples
|
|
190
|
+
|
|
191
|
+
### Chat Examples
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
# Quick question
|
|
195
|
+
clacky chat "Explain closures in Ruby"
|
|
196
|
+
|
|
197
|
+
# Start interactive session
|
|
198
|
+
clacky chat
|
|
199
|
+
|
|
200
|
+
# Check version
|
|
201
|
+
clacky version
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Agent Examples
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
# Start interactive agent session
|
|
208
|
+
clacky agent
|
|
209
|
+
# Then type tasks interactively:
|
|
210
|
+
# > Create a TODO.md file with 3 example tasks
|
|
211
|
+
# > Now add more items to the TODO list
|
|
212
|
+
# > exit
|
|
213
|
+
|
|
214
|
+
# Start with initial task, then continue
|
|
215
|
+
clacky agent "Add a .gitignore file for Ruby projects"
|
|
216
|
+
# After completing, agent waits for next task
|
|
217
|
+
# > List all Ruby files
|
|
218
|
+
# > Count lines in each file
|
|
219
|
+
# > exit
|
|
220
|
+
|
|
221
|
+
# Auto-approve mode for trusted operations
|
|
222
|
+
clacky agent --mode=auto_approve --path ~/my-project
|
|
223
|
+
# > Count all lines of code
|
|
224
|
+
# > Create a summary report
|
|
225
|
+
# > exit
|
|
226
|
+
|
|
227
|
+
# Use specific tools only in interactive mode
|
|
228
|
+
clacky agent --tools file_reader glob grep
|
|
229
|
+
# > Find all TODO comments
|
|
230
|
+
# > Search for FIXME comments
|
|
231
|
+
# > exit
|
|
232
|
+
|
|
233
|
+
# Using TODO manager for complex tasks
|
|
234
|
+
clacky agent "Implement a new feature with user authentication"
|
|
235
|
+
# Agent will:
|
|
236
|
+
# 1. Use todo_manager to create a task plan
|
|
237
|
+
# 2. Add todos: "Research current auth patterns", "Design auth flow", etc.
|
|
238
|
+
# 3. Complete each todo step by step
|
|
239
|
+
# 4. Mark todos as completed as work progresses
|
|
240
|
+
# > exit
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## Development
|
|
244
|
+
|
|
245
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
246
|
+
|
|
247
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
248
|
+
|
|
249
|
+
### Testing Agent Features
|
|
250
|
+
|
|
251
|
+
After making changes to agent-related functionality (tools, system prompts, agent logic, etc.), test with this command:
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
# Test agent with a complex multi-step task using auto-approve mode
|
|
255
|
+
echo "Create a simple calculator project with index.html, style.css, and script.js files" | \
|
|
256
|
+
bin/clacky agent --mode=auto_approve --path=tmp --max-iterations=20
|
|
257
|
+
|
|
258
|
+
# Expected: Agent should plan tasks (add TODOs), execute them (create files),
|
|
259
|
+
# and track progress (mark TODOs as completed)
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## Contributing
|
|
263
|
+
|
|
264
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/clacky. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/clacky/blob/main/CODE_OF_CONDUCT.md).
|
|
265
|
+
|
|
266
|
+
## License
|
|
267
|
+
|
|
268
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
269
|
+
|
|
270
|
+
## Code of Conduct
|
|
271
|
+
|
|
272
|
+
Everyone interacting in the Clacky project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/clacky/blob/main/CODE_OF_CONDUCT.md).
|