rubik 0.13.0 → 0.14.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.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/ATTRIBUTION.md +1 -1
  3. data/CHANGELOG.md +34 -1
  4. data/lib/rubik/ast/c_extractor.rb +1 -1
  5. data/lib/rubik/ast/graph.rb +38 -57
  6. data/lib/rubik/ast/graph_extensions.rb +57 -15
  7. data/lib/rubik/ast/ruby_extractor.rb +4 -0
  8. data/lib/rubik/ast/treesitter/c_walker.rb +11 -3
  9. data/lib/rubik/buffer/manager.rb +33 -11
  10. data/lib/rubik/buffer/snapshot.rb +23 -3
  11. data/lib/rubik/cli/connect.rb +3 -5
  12. data/lib/rubik/config/defaults.rb +3 -7
  13. data/lib/rubik/config/env_guard.rb +43 -0
  14. data/lib/rubik/config/schema.rb +7 -1
  15. data/lib/rubik/config/secret_policy.rb +6 -5
  16. data/lib/rubik/config.rb +1 -1
  17. data/lib/rubik/connect/models_dev.rb +9 -0
  18. data/lib/rubik/connect/probes.rb +9 -2
  19. data/lib/rubik/connect/wizard.rb +108 -56
  20. data/lib/rubik/context/repo_context_reader.rb +8 -4
  21. data/lib/rubik/llm/chunk_assembler.rb +12 -1
  22. data/lib/rubik/llm/formatter.rb +14 -0
  23. data/lib/rubik/llm/provider_key.rb +32 -0
  24. data/lib/rubik/llm/registry.rb +18 -2
  25. data/lib/rubik/llm/router.rb +19 -1
  26. data/lib/rubik/llm/session_header.rb +128 -0
  27. data/lib/rubik/llm/sse_parser.rb +57 -10
  28. data/lib/rubik/lsp/client.rb +11 -5
  29. data/lib/rubik/lsp/transport.rb +17 -7
  30. data/lib/rubik/mcp/transport/stdio.rb +42 -4
  31. data/lib/rubik/orchestrator/continuation_manager.rb +14 -5
  32. data/lib/rubik/orchestrator/goal_ledger/ledger.rb +18 -2
  33. data/lib/rubik/orchestrator/goal_ledger/observation_projection.rb +13 -4
  34. data/lib/rubik/orchestrator/goal_ledger/validator.rb +46 -7
  35. data/lib/rubik/orchestrator/goal_ledger/verifier.rb +8 -1
  36. data/lib/rubik/orchestrator/goal_session.rb +4 -4
  37. data/lib/rubik/orchestrator/loop.rb +8 -11
  38. data/lib/rubik/orchestrator/provider_resolver.rb +29 -6
  39. data/lib/rubik/orchestrator/step_executor.rb +17 -2
  40. data/lib/rubik/orchestrator/subagent/instance.rb +24 -1
  41. data/lib/rubik/orchestrator/subagent/notices.rb +1 -1
  42. data/lib/rubik/orchestrator/subagent/reaper.rb +21 -2
  43. data/lib/rubik/orchestrator/subagent/start_gate.rb +1 -1
  44. data/lib/rubik/orchestrator/subagent/step_runner.rb +7 -7
  45. data/lib/rubik/orchestrator/subagent/supervisor.rb +10 -3
  46. data/lib/rubik/orchestrator/turn_executor/user_channel.rb +27 -5
  47. data/lib/rubik/orchestrator/turn_executor.rb +24 -8
  48. data/lib/rubik/platform/filesystem.rb +52 -24
  49. data/lib/rubik/plugin/storage.rb +20 -0
  50. data/lib/rubik/prompt/context_builder.rb +2 -1
  51. data/lib/rubik/repair/loop.rb +22 -2
  52. data/lib/rubik/repl/commands/agent_context.rb +1 -1
  53. data/lib/rubik/repl/commands/agent_execution.rb +20 -15
  54. data/lib/rubik/repl/commands/buffer.rb +15 -0
  55. data/lib/rubik/repl/commands/connect.rb +0 -1
  56. data/lib/rubik/repl/commands/lsp.rb +1 -1
  57. data/lib/rubik/repl/commands/plugins.rb +31 -31
  58. data/lib/rubik/repl/commands/session.rb +5 -5
  59. data/lib/rubik/repl/commands/workspace.rb +4 -4
  60. data/lib/rubik/repl/input_execution.rb +30 -29
  61. data/lib/rubik/repl/input_loop.rb +9 -4
  62. data/lib/rubik/repl/lifecycle.rb +1 -2
  63. data/lib/rubik/repl/notice_router.rb +11 -5
  64. data/lib/rubik/repl/paste_support.rb +1 -1
  65. data/lib/rubik/repl/prompt_grace.rb +3 -3
  66. data/lib/rubik/repl/shell.rb +10 -2
  67. data/lib/rubik/repl/turn_recorder.rb +14 -3
  68. data/lib/rubik/runtime/context.rb +33 -27
  69. data/lib/rubik/runtime/manager.rb +23 -15
  70. data/lib/rubik/sandbox/driver/bubblewrap.rb +58 -8
  71. data/lib/rubik/sandbox/driver/process.rb +32 -1
  72. data/lib/rubik/sandbox/runner.rb +9 -1
  73. data/lib/rubik/security/classifier/classifier.rb +147 -13
  74. data/lib/rubik/security/classifier/commands/docker.yaml +1 -1
  75. data/lib/rubik/security/classifier/commands/git.yaml +27 -1
  76. data/lib/rubik/security/classifier/commands/sed.yaml +3 -3
  77. data/lib/rubik/security/classifier/database.rb +2 -2
  78. data/lib/rubik/security/command_gate.rb +8 -1
  79. data/lib/rubik/security/redactor.rb +62 -19
  80. data/lib/rubik/session/recorder.rb +13 -18
  81. data/lib/rubik/session/replayer.rb +29 -7
  82. data/lib/rubik/storage/store.rb +19 -5
  83. data/lib/rubik/tools/builtins/exec.rb +1 -1
  84. data/lib/rubik/tools/builtins/files.rb +8 -12
  85. data/lib/rubik/tools/builtins/grep.rb +3 -2
  86. data/lib/rubik/tools/builtins/lsp.rb +31 -7
  87. data/lib/rubik/tools/builtins/show_file.rb +1 -1
  88. data/lib/rubik/tools/builtins/synthesis.rb +4 -4
  89. data/lib/rubik/tools/result_normalizer.rb +1 -1
  90. data/lib/rubik/ui/banner.rb +3 -3
  91. data/lib/rubik/ui/dialog.rb +10 -7
  92. data/lib/rubik/ui/diff_viewer.rb +4 -4
  93. data/lib/rubik/ui/frame.rb +13 -3
  94. data/lib/rubik/ui/markdown_stream.rb +8 -2
  95. data/lib/rubik/ui/panel.rb +11 -11
  96. data/lib/rubik/ui/renderer.rb +6 -6
  97. data/lib/rubik/ui/spinner.rb +1 -1
  98. data/lib/rubik/ui/statusline.rb +3 -3
  99. data/lib/rubik/ui/theme.rb +1 -1
  100. data/lib/rubik/version.rb +1 -1
  101. metadata +4 -1
@@ -69,9 +69,19 @@ module Rubik
69
69
  ellipsis = theme.glyph(:ellipsis)
70
70
  return str if display_width(str) <= max
71
71
 
72
- "#{str[0...(max - display_width(ellipsis))]}#{ellipsis}"
73
- rescue ArgumentError
74
- str[0...max]
72
+ # Slice by accumulated display cells, not characters: a CJK/emoji run
73
+ # sliced by character count can still overrun the frame (#559).
74
+ budget = [max - display_width(ellipsis), 0].max
75
+ kept = +""
76
+ used = 0
77
+ str.each_char do |chr|
78
+ width = display_width(chr)
79
+ break if used + width > budget
80
+
81
+ kept << chr
82
+ used += width
83
+ end
84
+ "#{kept}#{ellipsis}"
75
85
  end
76
86
 
77
87
  # East-Asian wide + common emoji blocks that render two columns wide
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "tty-markdown"
4
+ require_relative "capability"
4
5
 
5
6
  module Rubik
6
7
  module UI
@@ -56,9 +57,14 @@ module Rubik
56
57
  # command output). Falls back to the raw text when styling is off.
57
58
  def self.render_document(text, theme, enabled: true)
58
59
  return text if text.nil? || text.empty?
59
- return text unless enabled && theme.color?
60
60
 
61
- TTY::Markdown.parse(text, color: :always)
61
+ # Strip OSC/CSI from model text before it reaches the terminal (or
62
+ # TTY::Markdown, which preserves those sequences). The streaming
63
+ # instance path already strips per line; batch must match (#559).
64
+ safe_text = Rubik::UI::Capability.strip_ansi(text)
65
+ return safe_text unless enabled && theme.color?
66
+
67
+ TTY::Markdown.parse(safe_text, color: :always)
62
68
  end
63
69
 
64
70
  private
@@ -23,11 +23,11 @@ module Rubik
23
23
  def render(shell, theme)
24
24
  fibers = shell.runtime_manager&.fibers || {}
25
25
  if fibers.empty?
26
- shell.output.puts "Kayıtlı fiber/ajan yok."
26
+ shell.output.puts "No registered fiber/agent."
27
27
  return
28
28
  end
29
29
 
30
- shell.output.puts "=== Ajan / Fiber Panosu ==="
30
+ shell.output.puts "=== Agent / Fiber Panel ==="
31
31
  rows = fibers.values.sort_by { |f| STATE_ORDER[f.state] || 99 }
32
32
  rows.each do |fiber|
33
33
  shell.output.puts detail_line(fiber, theme)
@@ -50,9 +50,9 @@ module Rubik
50
50
  inst = fiber.instance
51
51
  if inst.respond_to?(:step_count)
52
52
  depth = fiber.sub_context ? " · Ω#{fiber.sub_context.disposable_count}" : ""
53
- "adım #{inst.step_count}/#{inst.max_steps}#{depth}"
53
+ "step #{inst.step_count}/#{inst.max_steps}#{depth}"
54
54
  elsif fiber.state == :failed
55
- "hata: #{fiber.last_error&.message.to_s[0, 50]}"
55
+ "error: #{fiber.last_error&.message.to_s[0, 50]}"
56
56
  else
57
57
  deps = fiber.inject
58
58
  deps.empty? ? "-" : "coeffects: #{deps.join(', ')}"
@@ -62,8 +62,8 @@ module Rubik
62
62
  def select_fiber(shell, rows, _theme)
63
63
  prompt = Approvals.build_prompt(shell)
64
64
  choices = rows.map { |f| { name: "#{STATE_GLYPHS[f.state]} #{f.name}", value: f } }
65
- choices << { name: "← çıkış", value: nil }
66
- prompt.select("Detay için fiber seç:") do |menu|
65
+ choices << { name: "← exit", value: nil }
66
+ prompt.select("Select a fiber for details:") do |menu|
67
67
  choices.each { |c| menu.choice c[:name], c[:value] }
68
68
  end
69
69
  rescue Interrupt
@@ -77,15 +77,15 @@ module Rubik
77
77
  inst = fiber.instance
78
78
  shell.output.puts
79
79
  shell.output.puts theme.paint("── #{fiber.name} ──", :bold)
80
- shell.output.puts " Durum : #{STATE_GLYPHS[fiber.state]} #{fiber.state}"
80
+ shell.output.puts " State : #{STATE_GLYPHS[fiber.state]} #{fiber.state}"
81
81
  shell.output.puts " Coeffects : #{fiber.inject.join(', ')}"
82
- shell.output.puts " Ω derinliği : #{fiber.sub_context ? fiber.sub_context.disposable_count : 0}"
82
+ shell.output.puts " Ω depth : #{fiber.sub_context ? fiber.sub_context.disposable_count : 0}"
83
83
  if inst.respond_to?(:step_count)
84
- shell.output.puts " Adım : #{inst.step_count}/#{inst.max_steps}"
84
+ shell.output.puts " Step : #{inst.step_count}/#{inst.max_steps}"
85
85
  shell.output.puts " Token : #{inst.total_tokens.inspect}" if inst.respond_to?(:total_tokens)
86
86
  end
87
- shell.output.puts " Son hata : #{fiber.last_error&.message}" if fiber.last_error
88
- shell.output.puts theme.paint(" (enter ile panoya dön)", :dim)
87
+ shell.output.puts " Last error : #{fiber.last_error&.message}" if fiber.last_error
88
+ shell.output.puts theme.paint(" (press enter to return to the panel)", :dim)
89
89
  end
90
90
 
91
91
  def interactive?(shell)
@@ -142,13 +142,13 @@ module Rubik
142
142
 
143
143
  status = (step_info[:status] || :ok).to_sym
144
144
  duration = step_info[:duration_ms] || 0.0
145
- output = step_info[:output].to_s
145
+ output = Rubik::UI::Capability.strip_ansi(step_info[:output].to_s)
146
146
  branch = "#{@theme.glyph(:branch)} "
147
147
 
148
148
  if status != :ok
149
- err = step_info[:error]
150
- err = output.lines.first.to_s.strip if err.nil? || err.to_s.empty?
151
- err = "Command failed" if err.to_s.empty?
149
+ err = Rubik::UI::Capability.strip_ansi(step_info[:error].to_s)
150
+ err = output.lines.first.to_s.strip if err.empty?
151
+ err = "Command failed" if err.empty?
152
152
  if err.start_with?("Security blocked:") || output.start_with?("Security blocked:")
153
153
  sec_line = output.lines.first.to_s.strip
154
154
  hint = output[/!(?:allow-cmd|allow-dir)\s+[^\n]+/]&.strip
@@ -176,8 +176,8 @@ module Rubik
176
176
  return nil if level < Rubik::REPL::StepFormatter::LEVEL_VERBOSE
177
177
  return nil if step_info[:streamed] == true
178
178
 
179
- first_line = @legacy.thought_first_line(step_info[:content])
180
- return nil if first_line.nil? || first_line.empty?
179
+ first_line = Rubik::UI::Capability.strip_ansi(@legacy.thought_first_line(step_info[:content]).to_s)
180
+ return nil if first_line.empty?
181
181
 
182
182
  " #{@theme.paint("#{@theme.glyph(:thought)} #{first_line}", :thought)}"
183
183
  end
@@ -110,7 +110,7 @@ module Rubik
110
110
  def current_message(verb, step_part, elapsed)
111
111
  seconds = elapsed.to_i
112
112
  suffix = seconds.positive? ? " · #{seconds}s" : ""
113
- "#{@theme.paint(verb, :accent)}#{step_part}#{suffix} (ctrl+c: kes)"
113
+ "#{@theme.paint(verb, :accent)}#{step_part}#{suffix} (ctrl+c: interrupt)"
114
114
  end
115
115
 
116
116
  def next_verb
@@ -76,15 +76,15 @@ module Rubik
76
76
 
77
77
  def dirty_segment(shell, theme)
78
78
  count = shell.buffer_manager&.dirty? ? (shell.buffer_manager.dirty_files&.size || 0) : 0
79
- count.zero? ? "temiz" : "#{count} #{theme.glyph(:dirty)}"
79
+ count.zero? ? "clean" : "#{count} #{theme.glyph(:dirty)}"
80
80
  end
81
81
 
82
82
  def sandbox_segment(shell)
83
83
  if Rubik::Storage::Layout.config_get(shell.config, "sandbox.enabled", false)
84
- net_str = Rubik::Storage::Layout.config_get(shell.config, "sandbox.allow_network", false) ? "ağ-açık" : "izole"
84
+ net_str = Rubik::Storage::Layout.config_get(shell.config, "sandbox.allow_network", false) ? "network-open" : "isolated"
85
85
  "#{shell.sandbox_runner&.driver&.name || 'sandbox'}:#{net_str}"
86
86
  else
87
- "kapalı"
87
+ "off"
88
88
  end
89
89
  end
90
90
 
@@ -49,7 +49,7 @@ module Rubik
49
49
  }.freeze
50
50
 
51
51
  DEFAULT_SPINNER_VERBS = [
52
- "Düşünüyor", "Kavuruyor", "Karıştırıyor", "Damıtıyor", "Biçimlendiriyor", "Harmanlıyor", "Tarıyor", "Planlıyor", "Doğruluyor", "Tamamlıyor"
52
+ "Thinking", "Roasting", "Stirring", "Distilling", "Formatting", "Blending", "Sifting", "Planning", "Verifying", "Completing"
53
53
  ].freeze
54
54
 
55
55
  attr_reader :pastel, :glyphs, :spinner_verbs
data/lib/rubik/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rubik
4
- VERSION = "0.13.0"
4
+ VERSION = "0.14.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubik
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Özgür Ulukır
@@ -292,6 +292,7 @@ files:
292
292
  - lib/rubik/config.rb
293
293
  - lib/rubik/config/deep_ops.rb
294
294
  - lib/rubik/config/defaults.rb
295
+ - lib/rubik/config/env_guard.rb
295
296
  - lib/rubik/config/env_loader.rb
296
297
  - lib/rubik/config/model_catalog.rb
297
298
  - lib/rubik/config/pruner.rb
@@ -336,8 +337,10 @@ files:
336
337
  - lib/rubik/llm/openai.rb
337
338
  - lib/rubik/llm/openai_compatible.rb
338
339
  - lib/rubik/llm/provider.rb
340
+ - lib/rubik/llm/provider_key.rb
339
341
  - lib/rubik/llm/registry.rb
340
342
  - lib/rubik/llm/router.rb
343
+ - lib/rubik/llm/session_header.rb
341
344
  - lib/rubik/llm/sse_parser.rb
342
345
  - lib/rubik/log.rb
343
346
  - lib/rubik/lsp.rb