ruby_coded 0.3.0 → 0.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 458d56c13426096bb1d553aad86f7d2502a94022cc53de44ca7c74ab48cf2b5a
4
- data.tar.gz: 128c5c97ccf42e93a7671ad5641d85c3f0c80f425c74506f0f22f7a4d4e95652
3
+ metadata.gz: 45aa4262fb573ca03510db92e2d3bd9795136b935fe7ffe8ba02821a570b107b
4
+ data.tar.gz: ed299052fcaa75af5a03951d18fbae6021fccd2463d28f73ea7f57cacdca28d7
5
5
  SHA512:
6
- metadata.gz: a244f39012eb45e2396f61a94fb2b14f23ffd1269c4b235a1ea7ce456763cd674f13e51c4cc3584f95ab4d15517ce63aaff1c113848b2ff467aae70606770726
7
- data.tar.gz: b1ba816f5deb3e7051764602bb2bb3afcac031af219f6523eb1d54f021d77fc97844068952c914a2d7f1bd441f62968141678ec09b169bf6d855cbed3f1c0848
6
+ metadata.gz: f06c04df1359024f169e00185535ab2f8be8f24a6eee94f3f231c130dc31d385a48163072a843330ac83a79060e553d94a59dc4224e5a93679066894d5642e81
7
+ data.tar.gz: 66e264de72737cbe9b3158267faf941de67156c2e05b855e7cf679ca640ceb3ecaa16c15f694aa5c2e549578004b8851aeb2ed7513a358bcb8396603eb217f34
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.1] - 2026-06-28
4
+
5
+ ### Added
6
+
7
+ - **Git integration tool**: New git tool for common git workflows in projects (status, diff, add, commit) backed by a shared `GitBaseTool`.
8
+
9
+ ### Changed
10
+
11
+ - **Agent mode enabled by default**: Sessions now start in Agent mode automatically instead of requiring manual activation.
12
+
3
13
  ## [0.3.0] - 2026-04-24
4
14
 
5
15
  ### Added
data/README.md CHANGED
@@ -82,6 +82,10 @@ When agent mode is active, the model has access to these tools:
82
82
  | `create_directory` | Confirm | Create a new directory |
83
83
  | `delete_path` | Dangerous | Delete a file or directory |
84
84
  | `run_command` | Dangerous | Execute a shell command |
85
+ | `git_status` | Safe | Show repository status |
86
+ | `git_diff` | Safe | Show staged or unstaged diff |
87
+ | `git_add` | Confirm | Stage files or all changes |
88
+ | `git_commit` | Confirm | Create a local git commit with a message |
85
89
 
86
90
  Safe tools run without asking. Confirm and dangerous tools show the operation details and wait for your approval (`y` to approve, `n` to reject, `a` to approve all remaining).
87
91
 
@@ -37,6 +37,7 @@ module RubyCoded
37
37
  @fallback_from_model = fallback_from_model
38
38
  apply_plugin_extensions!
39
39
  build_components!
40
+ enable_default_agent_mode!
40
41
  announce_model_fallback
41
42
  end
42
43
 
@@ -123,6 +124,12 @@ module RubyCoded
123
124
  )
124
125
  end
125
126
 
127
+ def enable_default_agent_mode!
128
+ return if @llm_bridge.agentic_mode
129
+
130
+ @llm_bridge.toggle_agentic_mode!(true)
131
+ end
132
+
126
133
  def apply_selected_model
127
134
  selected = @state.selected_model
128
135
  return @state.exit_model_select! unless selected
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "git_base_tool"
4
+
5
+ module RubyCoded
6
+ module Tools
7
+ # Stage specific files or all current changes in the git repository.
8
+ class GitAddTool < GitBaseTool
9
+ description "Stage files in the git repository. Provide paths or set all to true to stage everything."
10
+ risk :confirm
11
+
12
+ params do
13
+ array :paths, of: :string,
14
+ description: "Relative file paths to stage",
15
+ required: false
16
+ boolean :all, description: "Stage all tracked and untracked changes", required: false
17
+ end
18
+
19
+ def execute(paths: nil, all: false)
20
+ return stage_all if all
21
+
22
+ stage_paths(paths)
23
+ end
24
+
25
+ private
26
+
27
+ def stage_all
28
+ result = run_git_command("add", "--all")
29
+ return result if result.is_a?(Hash)
30
+
31
+ "Staged all changes.\n#{result}"
32
+ end
33
+
34
+ def stage_paths(paths)
35
+ normalized_paths = Array(paths).map(&:to_s).reject(&:empty?)
36
+ return { error: "Provide at least one path or set all to true." } if normalized_paths.empty?
37
+
38
+ invalid = invalid_paths(normalized_paths)
39
+ return { error: "Paths are outside the project directory: #{invalid.join(", ")}" } unless invalid.empty?
40
+
41
+ result = run_git_command("add", *normalized_paths)
42
+ return result if result.is_a?(Hash)
43
+
44
+ "Staged paths: #{normalized_paths.join(", ")}\n#{result}"
45
+ end
46
+
47
+ def invalid_paths(normalized_paths)
48
+ normalized_paths.filter_map do |path|
49
+ validated = validate_path!(path)
50
+ path if validated.is_a?(Hash)
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "open3"
4
+ require "shellwords"
5
+ require_relative "base_tool"
6
+
7
+ module RubyCoded
8
+ module Tools
9
+ # Shared helpers for git-specific tools.
10
+ class GitBaseTool < BaseTool
11
+ GIT_ENV = {
12
+ "GIT_EDITOR" => "true",
13
+ "EDITOR" => "true",
14
+ "VISUAL" => "true",
15
+ "GIT_PAGER" => "cat",
16
+ "PAGER" => "cat"
17
+ }.freeze
18
+
19
+ MAX_OUTPUT_CHARS = 5000
20
+
21
+ def git_repo?
22
+ Dir.exist?(File.join(@project_root, ".git"))
23
+ end
24
+
25
+ def ensure_git_repo!
26
+ return nil if git_repo?
27
+
28
+ { error: "Not a git repository: #{@project_root}" }
29
+ end
30
+
31
+ def run_git_command(*)
32
+ repo_error = ensure_git_repo!
33
+ return repo_error if repo_error
34
+
35
+ stdout, stderr, status = Open3.capture3(GIT_ENV, "git", *, chdir: @project_root)
36
+ format_git_result(stdout, stderr, status)
37
+ rescue Errno::ENOENT => e
38
+ { error: "Git executable not found: #{e.message}" }
39
+ rescue StandardError => e
40
+ { error: "Git command failed: #{e.message}" }
41
+ end
42
+
43
+ def format_git_result(stdout, stderr, status)
44
+ output = String.new
45
+ output << stdout unless stdout.empty?
46
+ output << "\nSTDERR:\n#{stderr}" unless stderr.empty?
47
+ output = output.strip
48
+ output = "(no output)" if output.empty?
49
+ output = truncate_output(output)
50
+
51
+ return output if status.success?
52
+
53
+ { error: output }
54
+ end
55
+
56
+ def truncate_output(output)
57
+ return output if output.length <= MAX_OUTPUT_CHARS
58
+
59
+ "#{output[0, MAX_OUTPUT_CHARS]}...(truncated, #{output.length} total characters)"
60
+ end
61
+
62
+ def shell_join(parts)
63
+ parts.map { |part| Shellwords.escape(part.to_s) }.join(" ")
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "git_base_tool"
4
+
5
+ module RubyCoded
6
+ module Tools
7
+ # Create a non-interactive git commit.
8
+ class GitCommitTool < GitBaseTool
9
+ description "Create a git commit with a message. Supports staging all changes first if requested."
10
+ risk :confirm
11
+
12
+ params do
13
+ string :message, description: "Commit message"
14
+ boolean :add_all, description: "Stage all changes before committing", required: false
15
+ end
16
+
17
+ def execute(message:, add_all: false)
18
+ msg = message.to_s.strip
19
+ return { error: "Commit message cannot be empty." } if msg.empty?
20
+
21
+ if add_all
22
+ add_result = run_git_command("add", "--all")
23
+ return add_result if add_result.is_a?(Hash)
24
+ end
25
+
26
+ result = run_git_command("commit", "-m", msg)
27
+ return enhance_commit_error(result) if result.is_a?(Hash)
28
+
29
+ prefix = add_all ? "Staged all changes and created commit." : "Created commit."
30
+ "#{prefix}\n#{result}"
31
+ end
32
+
33
+ private
34
+
35
+ def enhance_commit_error(result)
36
+ message = result[:error].to_s
37
+
38
+ return { error: "Nothing to commit. Working tree clean or no staged changes." } if message.include?("nothing to commit")
39
+ return { error: "Git user identity is not configured. Set user.name and user.email before committing." } if message.include?("Author identity unknown")
40
+
41
+ result
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "git_base_tool"
4
+
5
+ module RubyCoded
6
+ module Tools
7
+ # Show git diff output for the project repository.
8
+ class GitDiffTool < GitBaseTool
9
+ description "Show git diff output for the project repository. By default shows unstaged changes."
10
+ risk :safe
11
+
12
+ params do
13
+ boolean :staged, description: "Show staged changes instead of unstaged changes", required: false
14
+ end
15
+
16
+ def execute(staged: false)
17
+ args = ["diff"]
18
+ args << "--cached" if staged
19
+ run_git_command(*args)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "git_base_tool"
4
+
5
+ module RubyCoded
6
+ module Tools
7
+ # Show the current git working tree status.
8
+ class GitStatusTool < GitBaseTool
9
+ description "Show the current git working tree status for the project repository"
10
+ risk :safe
11
+
12
+ def execute
13
+ run_git_command("status", "--short", "--branch")
14
+ end
15
+ end
16
+ end
17
+ end
@@ -7,6 +7,10 @@ require_relative "edit_file_tool"
7
7
  require_relative "create_directory_tool"
8
8
  require_relative "delete_path_tool"
9
9
  require_relative "run_command_tool"
10
+ require_relative "git_status_tool"
11
+ require_relative "git_diff_tool"
12
+ require_relative "git_add_tool"
13
+ require_relative "git_commit_tool"
10
14
 
11
15
  module RubyCoded
12
16
  module Tools
@@ -14,7 +18,9 @@ module RubyCoded
14
18
  class Registry
15
19
  READONLY_TOOL_CLASSES = [
16
20
  ReadFileTool,
17
- ListDirectoryTool
21
+ ListDirectoryTool,
22
+ GitStatusTool,
23
+ GitDiffTool
18
24
  ].freeze
19
25
 
20
26
  TOOL_CLASSES = [
@@ -23,7 +29,11 @@ module RubyCoded
23
29
  EditFileTool,
24
30
  CreateDirectoryTool,
25
31
  DeletePathTool,
26
- RunCommandTool
32
+ RunCommandTool,
33
+ GitStatusTool,
34
+ GitDiffTool,
35
+ GitAddTool,
36
+ GitCommitTool
27
37
  ].freeze
28
38
 
29
39
  def initialize(project_root:)
@@ -12,6 +12,13 @@ module RubyCoded
12
12
 
13
13
  TIMEOUT_SECONDS = 30
14
14
  MAX_OUTPUT_CHARS = 5000
15
+ COMMAND_ENV = {
16
+ "GIT_EDITOR" => "true",
17
+ "EDITOR" => "true",
18
+ "VISUAL" => "true",
19
+ "GIT_PAGER" => "cat",
20
+ "PAGER" => "cat"
21
+ }.freeze
15
22
 
16
23
  params do
17
24
  string :command, description: "The shell command to execute"
@@ -35,7 +42,7 @@ module RubyCoded
35
42
  private
36
43
 
37
44
  def run_with_timeout(command)
38
- stdin, stdout_io, stderr_io, wait_thr = Open3.popen3(command, chdir: @project_root)
45
+ stdin, stdout_io, stderr_io, wait_thr = Open3.popen3(COMMAND_ENV, command, chdir: @project_root)
39
46
  stdin.close
40
47
 
41
48
  unless wait_thr.join(TIMEOUT_SECONDS)
@@ -15,6 +15,9 @@ module RubyCoded
15
15
  - The user will be asked to confirm destructive operations (write, edit, delete).
16
16
  - When listing directories, start with the project root to orient yourself.
17
17
  - Be concise in your explanations but thorough in your actions.
18
+ - Git workflows are allowed when the user asks for them. Prefer dedicated git tools for status, diff, add, and commit.
19
+ - For git commits, always use a non-interactive commit message and never rely on opening an editor.
20
+ - Do not push, pull, fetch, rebase, or perform other remote/history-rewriting git actions unless the user explicitly asks.
18
21
 
19
22
  Efficiency:
20
23
  - You have a budget of %<max_write_rounds>d write/edit/delete tool calls that auto-resets when reached, and a hard limit of %<max_total_rounds>d total tool calls per request.
@@ -2,7 +2,7 @@
2
2
 
3
3
  # This module contains the version of the RubyCoded gem
4
4
  module RubyCoded
5
- VERSION = "0.3.0"
5
+ VERSION = "0.3.1"
6
6
 
7
7
  def self.gem_version
8
8
  Gem::Version.new(VERSION).freeze
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_coded
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cesar Rodriguez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-04-24 00:00:00.000000000 Z
11
+ date: 2026-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -204,6 +204,11 @@ files:
204
204
  - lib/ruby_coded/tools/create_directory_tool.rb
205
205
  - lib/ruby_coded/tools/delete_path_tool.rb
206
206
  - lib/ruby_coded/tools/edit_file_tool.rb
207
+ - lib/ruby_coded/tools/git_add_tool.rb
208
+ - lib/ruby_coded/tools/git_base_tool.rb
209
+ - lib/ruby_coded/tools/git_commit_tool.rb
210
+ - lib/ruby_coded/tools/git_diff_tool.rb
211
+ - lib/ruby_coded/tools/git_status_tool.rb
207
212
  - lib/ruby_coded/tools/list_directory_tool.rb
208
213
  - lib/ruby_coded/tools/plan_system_prompt.rb
209
214
  - lib/ruby_coded/tools/read_file_tool.rb