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
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "shellwords"
3
4
  require_relative "base"
4
5
  require_relative "../../storage/layout"
5
6
  require_relative "../../runtime"
@@ -15,8 +16,8 @@ module Rubik
15
16
 
16
17
  # Whole-command synopses: shared by the spine registration (usage:)
17
18
  # and the empty-args branches that print them, so the two cannot drift.
18
- USAGE_PLAN = "Kullanım: !plan <görev açıklaması>"
19
- USAGE_GOAL = "Kullanım: !goal [--steps N|-s N] <hedef açıklaması> | !goal resume | !goal list"
19
+ USAGE_PLAN = "Usage: !plan <task description>"
20
+ USAGE_GOAL = "Usage: !goal [--steps N|-s N] <goal description> | !goal resume | !goal list"
20
21
 
21
22
  # The !goal run lifecycle (start/suspend/resume/terminal mapping) is
22
23
  # the Orchestrator::GoalSession domain (issue #404); this module keeps
@@ -59,15 +60,15 @@ module Rubik
59
60
  ctx.out.puts "\n=== Proposed Plan ==="
60
61
  ctx.out.puts res[:output]
61
62
  ctx.out.puts "=====================\n"
62
- ans = ctx.ask_yes_no("[Rubik::Plan] Plan uygulansın mı?", default: "y")
63
+ ans = ctx.ask_yes_no("[Rubik::Plan] Should the plan be applied?", default: "y")
63
64
  if ["y", "yes", "evet"].include?(ans)
64
65
  ctx.out.puts "[Rubik::Act] Executing approved plan..."
65
66
  ctx.execute_free_text("Execute the following approved plan step by step:\n#{res[:output]}")
66
67
  else
67
- ctx.out.puts "[Rubik] Plan iptal edildi."
68
+ ctx.out.puts "[Rubik] Plan cancelled."
68
69
  end
69
70
  else
70
- ctx.out.puts "Plan üretilemedi: #{res[:error]}"
71
+ ctx.out.puts "Plan could not be generated: #{res[:error]}"
71
72
  end
72
73
  end
73
74
  end
@@ -85,7 +86,7 @@ module Rubik
85
86
  parsed = parse_goal_args(args)
86
87
  if !parsed[:valid]
87
88
  ctx.out.puts USAGE_GOAL
88
- ctx.out.puts "⚠️ [Rubik::Goal] --steps pozitif bir tam sayı bekliyor (örn. !goal --steps 200 <hedef>)"
89
+ ctx.out.puts "⚠️ [Rubik::Goal] --steps expects a positive integer (e.g. !goal --steps 200 <goal>)"
89
90
  next
90
91
  elsif parsed[:goal_text].empty?
91
92
  ctx.out.puts USAGE_GOAL
@@ -172,7 +173,11 @@ module Rubik
172
173
  shell.register_command("sh", description: "Execute shell command via sandbox runner") do |args, ctx|
173
174
  Base.pre_execution_apply(ctx, "command execution", "Commands")
174
175
 
175
- cmd = args.join(" ")
176
+ # CommandParser already consumed the quotes via Shellwords.split;
177
+ # rebuild a shell-safe command so `!sh grep "foo bar" file` keeps
178
+ # its single argument — both for execution and for the safety
179
+ # gate (issue #557).
180
+ cmd = Shellwords.shelljoin(args)
176
181
  ctx.guard.verify_command_safety!(cmd)
177
182
  runner = ctx.sandbox_runner || Rubik::Sandbox::Runner.new(root_dir: Dir.pwd, config: ctx.config, guard: ctx.guard)
178
183
  res = runner.run(cmd)
@@ -190,15 +195,15 @@ module Rubik
190
195
 
191
196
  if clean_args.empty? || subcmd == "status"
192
197
  enabled = Rubik::Storage::Layout.config_get(ctx.config, "sandbox.enabled", false)
193
- state_str = enabled ? "Açık (enabled)" : "Kapalı (disabled - direct safe execution)"
198
+ state_str = enabled ? "Enabled" : "Disabled - direct safe execution"
194
199
  driver_name = ctx.sandbox_runner&.driver&.name || Rubik::Storage::Layout.config_get(ctx.config, "sandbox.driver", "bwrap")
195
200
  net_str = Rubik::Storage::Layout.config_get(ctx.config, "sandbox.allow_network", false) ? "allowed" : "blocked"
196
201
 
197
- ctx.out.puts "=== Sandbox Durumu ==="
198
- ctx.out.puts "Durum: #{state_str}"
199
- ctx.out.puts "Aktif Motor: #{driver_name}"
200
- ctx.out.puts "Ağ: #{net_str}"
201
- ctx.out.puts "Kayıtlı: #{registered_keys.join(', ')}"
202
+ ctx.out.puts "=== Sandbox Status ==="
203
+ ctx.out.puts "Status: #{state_str}"
204
+ ctx.out.puts "Active Driver: #{driver_name}"
205
+ ctx.out.puts "Network: #{net_str}"
206
+ ctx.out.puts "Registered: #{registered_keys.join(', ')}"
202
207
  elsif subcmd == "on"
203
208
  res = ctx.config.set("sandbox.enabled", true, persist: scope)
204
209
  driver_res = ctx.config.set("sandbox.driver", "bwrap", persist: scope) if Rubik::Platform.linux?
@@ -212,7 +217,7 @@ module Rubik
212
217
 
213
218
  ctx.out.puts "[Sandbox] Disabled (direct safe execution active)."
214
219
  elsif registered_map.key?(subcmd)
215
- ctx.out.puts "⚠️ [Sandbox] 'bwrap' yalnızca Linux üzerinde desteklenir." if ["bwrap", "bubblewrap"].include?(subcmd) && !Rubik::Platform.linux?
220
+ ctx.out.puts "⚠️ [Sandbox] 'bwrap' is only supported on Linux." if ["bwrap", "bubblewrap"].include?(subcmd) && !Rubik::Platform.linux?
216
221
  res = ctx.config.set("sandbox.enabled", true, persist: scope)
217
222
  driver_res = ctx.config.set("sandbox.driver", subcmd, persist: scope)
218
223
  next if Base.report_persist_failure(ctx, res, scope)
@@ -220,7 +225,7 @@ module Rubik
220
225
 
221
226
  ctx.out.puts "[Sandbox] Driver set to '#{subcmd}' (enabled)."
222
227
  else
223
- ctx.out.puts "[Sandbox] Bilinmeyen alt komut veya sürücü: '#{subcmd}'. Kayıtlı sürücüler: #{registered_keys.join(', ')}"
228
+ ctx.out.puts "[Sandbox] Unknown subcommand or driver: '#{subcmd}'. Registered drivers: #{registered_keys.join(', ')}"
224
229
  end
225
230
  end
226
231
  end
@@ -17,6 +17,7 @@ module Rubik
17
17
  USAGE_AUTOAPPLY = "Usage: !autoapply <manual | on_test | on_finish | always | status> [--project|--global]"
18
18
 
19
19
  def self.register(shell)
20
+ register_snapshot_recording(shell)
20
21
  register_diff_command(shell)
21
22
  register_apply_command(shell)
22
23
  register_undo_command(shell)
@@ -24,6 +25,20 @@ module Rubik
24
25
  register_autoapply_command(shell)
25
26
  end
26
27
 
28
+ private_class_method def self.register_snapshot_recording(shell)
29
+ return unless shell.respond_to?(:buffer_manager) && shell.respond_to?(:snapshot_store)
30
+
31
+ manager = shell.buffer_manager
32
+ store = shell.snapshot_store
33
+ return unless manager.respond_to?(:snapshot_store=) && store
34
+
35
+ # The manager snapshots the post-write buffer state, so the
36
+ # !undo / !rollback commands registered below always have a
37
+ # producer (issue #544). Kept here so the dependency lives with
38
+ # the command module that advertises them.
39
+ manager.snapshot_store = store
40
+ end
41
+
27
42
  private_class_method def self.register_diff_command(shell)
28
43
  shell.register_command(
29
44
  "diff",
@@ -27,7 +27,6 @@ module Rubik
27
27
  # the wizard can make. Honest refusal beats silent escalation.
28
28
  if args.intersect?(["--session", "-s"])
29
29
  ctx.out.puts USAGE_CONNECT
30
- ctx.out.puts " !connect yalnızca kalıcı kapsamlara yazar; oturum-kapsamı için !provider add kullanın."
31
30
  ctx.out.puts " !connect writes persistent scopes only; use !provider add for a session-scoped provider."
32
31
  else
33
32
  scope, _clean = Base.parse_scope(args)
@@ -80,7 +80,7 @@ module Rubik
80
80
 
81
81
  private_class_method def self.render_diagnostics(ctx, diags)
82
82
  diags.each do |d|
83
- sev = d["severity"] == 1 ? "ERROR" : "WARN"
83
+ sev = Rubik::Tools::LSPSeverity.display(d["severity"])
84
84
  line = (d.dig("range", "start", "line") || 0) + 1
85
85
  ctx.out.puts " • [#{sev}] Line #{line}: #{d['message']}"
86
86
  end
@@ -6,13 +6,13 @@ module Rubik
6
6
  module Plugins
7
7
  # Whole-command synopsis: shared by the spine registration (usage:)
8
8
  # and the unknown-subcommand fallback branch, so the two cannot drift.
9
- USAGE_PLUGIN = "Kullanım: !plugin [list|add|remove|reload|enable|disable|info]"
9
+ USAGE_PLUGIN = "Usage: !plugin [list|add|remove|reload|enable|disable|info]"
10
10
 
11
11
  def self.register(shell)
12
12
  handler = proc do |args, ctx|
13
13
  manager = ctx.plugin_manager
14
14
  unless manager
15
- ctx.out.puts "Eklenti yöneticisi bulunamadı."
15
+ ctx.out.puts "Plugin manager not found."
16
16
  next
17
17
  end
18
18
 
@@ -37,23 +37,23 @@ module Rubik
37
37
  when "info"
38
38
  info_plugin(ctx, manager, args[1])
39
39
  else
40
- ctx.out.puts "Bilinmeyen komut: #{subcommand}. #{USAGE_PLUGIN}"
40
+ ctx.out.puts "Unknown command: #{subcommand}. #{USAGE_PLUGIN}"
41
41
  end
42
42
  end
43
43
 
44
- shell.register_command("plugin", description: "Eklenti yönetimi: list, add, remove, reload, enable, disable, info",
44
+ shell.register_command("plugin", description: "Plugin management: list, add, remove, reload, enable, disable, info",
45
45
  usage: USAGE_PLUGIN, audience: :human, &handler)
46
- shell.register_command("plugins", description: "Yüklü eklentileri listeler", usage: USAGE_PLUGIN, audience: :human) do |_args, ctx|
46
+ shell.register_command("plugins", description: "Lists installed plugins", usage: USAGE_PLUGIN, audience: :human) do |_args, ctx|
47
47
  handler.call(["list"], ctx)
48
48
  end
49
49
  end
50
50
 
51
51
  def self.list_plugins(ctx, manager, storage)
52
- ctx.out.puts "🧩 Eklentiler (Plugins)"
52
+ ctx.out.puts "🧩 Plugins"
53
53
  ctx.out.puts "======================"
54
54
 
55
55
  if manager.registered_plugins.empty? && (!storage || storage.discover_plugins.empty?)
56
- ctx.out.puts "Yüklü eklenti yok."
56
+ ctx.out.puts "No plugins installed."
57
57
  else
58
58
  manager.registered_plugins.each do |gem_name|
59
59
  component_name = "plugin_#{gem_name}"
@@ -66,7 +66,7 @@ module Rubik
66
66
  if storage
67
67
  dropins = storage.discover_plugins
68
68
  unless dropins.empty?
69
- ctx.out.puts "\n📂 Drop-in Eklentileri"
69
+ ctx.out.puts "\n📂 Drop-in Plugins"
70
70
  ctx.out.puts "======================"
71
71
  dropins.each do |meta|
72
72
  component_name = "plugin_#{meta[:name]}"
@@ -77,10 +77,10 @@ module Rubik
77
77
  end
78
78
  end
79
79
 
80
- ctx.out.puts "\n🔗 Alias Tablosu"
80
+ ctx.out.puts "\n🔗 Alias Table"
81
81
  ctx.out.puts "================"
82
82
  if manager.aliases.empty?
83
- ctx.out.puts "Kayıtlı alias yok."
83
+ ctx.out.puts "No registered aliases."
84
84
  else
85
85
  manager.aliases.each do |short, full|
86
86
  ctx.out.puts "- !#{short} -> !#{full}"
@@ -90,12 +90,12 @@ module Rubik
90
90
 
91
91
  def self.add_plugin(ctx, manager, storage, path, flags)
92
92
  unless storage
93
- ctx.out.puts "Hata: Drop-in eklenti motoru aktif değil."
93
+ ctx.out.puts "Error: Drop-in plugin engine is not active."
94
94
  return
95
95
  end
96
96
 
97
97
  unless path
98
- ctx.out.puts "Hata: Eklenti yolu belirtilmedi. Kullanım: !plugin add <path>"
98
+ ctx.out.puts "Error: Plugin path not specified. Usage: !plugin add <path>"
99
99
  return
100
100
  end
101
101
 
@@ -103,7 +103,7 @@ module Rubik
103
103
  result = storage.add_plugin(path, scope: scope)
104
104
 
105
105
  if result[:ok]
106
- ctx.out.puts "✅ Eklenti #{result[:name]} (#{scope}) başarıyla eklendi."
106
+ ctx.out.puts "✅ Plugin #{result[:name]} (#{scope}) added successfully."
107
107
 
108
108
  # Build a proper plugin_meta for load_plugin_file:
109
109
  # storage.add_plugin returns {ok, name, path, type} but
@@ -112,72 +112,72 @@ module Rubik
112
112
  # $LOAD_PATH.
113
113
  plugin_meta = build_plugin_meta(result, scope)
114
114
  if manager.load_plugin_file(plugin_meta, runtime_manager: ctx.runtime_manager)
115
- ctx.out.puts "🚀 Eklenti #{result[:name]} canlı olarak yüklendi."
115
+ ctx.out.puts "🚀 Plugin #{result[:name]} loaded live."
116
116
  else
117
- ctx.out.puts "⚠️ Eklenti #{result[:name]} dosyası kopyalandı ancak yüklenemedi."
117
+ ctx.out.puts "⚠️ Plugin #{result[:name]} file was copied but could not be loaded."
118
118
  end
119
119
  else
120
- ctx.out.puts "❌ Hata: #{result[:error]}"
120
+ ctx.out.puts "❌ Error: #{result[:error]}"
121
121
  end
122
122
  end
123
123
 
124
124
  def self.remove_plugin(ctx, manager, storage, name, flags)
125
125
  unless storage
126
- ctx.out.puts "Hata: Drop-in eklenti motoru aktif değil."
126
+ ctx.out.puts "Error: Drop-in plugin engine is not active."
127
127
  return
128
128
  end
129
129
  unless name
130
- ctx.out.puts "Hata: Eklenti adı belirtilmedi."
130
+ ctx.out.puts "Error: Plugin name not specified."
131
131
  return
132
132
  end
133
133
 
134
134
  scope = flags.include?("--global") ? :global : :project
135
135
 
136
136
  unloaded = manager.unload_plugin(name, runtime_manager: ctx.runtime_manager)
137
- ctx.out.puts "🧹 Eklenti #{name} fiber'ı sonlandırıldı (ters kayıtlar işletildi)." if unloaded
137
+ ctx.out.puts "🧹 Plugin #{name} fiber terminated (inverse records executed)." if unloaded
138
138
 
139
139
  result = storage.remove_plugin(name, scope: scope)
140
140
  if result[:ok]
141
- ctx.out.puts "🗑️ Eklenti #{name} diskten (#{scope}) silindi."
141
+ ctx.out.puts "🗑️ Plugin #{name} deleted from disk (#{scope})."
142
142
  else
143
- ctx.out.puts "⚠️ Eklenti diskten silinemedi: #{result[:error]}"
143
+ ctx.out.puts "⚠️ Plugin could not be deleted from disk: #{result[:error]}"
144
144
  end
145
145
  end
146
146
 
147
147
  def self.reload_plugin(ctx, manager, storage, name)
148
148
  unless storage
149
- ctx.out.puts "Hata: Drop-in eklenti motoru aktif değil."
149
+ ctx.out.puts "Error: Drop-in plugin engine is not active."
150
150
  return
151
151
  end
152
152
  unless name
153
- ctx.out.puts "Hata: Eklenti adı belirtilmedi."
153
+ ctx.out.puts "Error: Plugin name not specified."
154
154
  return
155
155
  end
156
156
 
157
157
  if manager.reload_plugin(name, storage: storage, runtime_manager: ctx.runtime_manager)
158
- ctx.out.puts "🔄 Eklenti #{name} başarıyla yeniden yüklendi (zero-downtime)."
158
+ ctx.out.puts "🔄 Plugin #{name} reloaded successfully (zero-downtime)."
159
159
  else
160
- ctx.out.puts "❌ Hata: Eklenti #{name} yeniden yüklenemedi."
160
+ ctx.out.puts "❌ Error: Plugin #{name} could not be reloaded."
161
161
  end
162
162
  end
163
163
 
164
164
  def self.enable_plugin(ctx, _manager, name)
165
165
  # Not implemented deeply for now, simply unpauses fiber
166
- ctx.out.puts "Eklenti #{name} etkinleştirildi (placeholder)."
166
+ ctx.out.puts "Plugin #{name} enabled (placeholder)."
167
167
  end
168
168
 
169
169
  def self.disable_plugin(ctx, _manager, name)
170
- ctx.out.puts "Eklenti #{name} devre dışı bırakıldı (placeholder)."
170
+ ctx.out.puts "Plugin #{name} disabled (placeholder)."
171
171
  end
172
172
 
173
173
  def self.info_plugin(ctx, _manager, name)
174
174
  if Rubik::Plugin::Registry.get(name)
175
175
  def_obj = Rubik::Plugin::Registry.get(name)
176
- ctx.out.puts "Eklenti: #{def_obj.name} v#{def_obj.version}"
177
- ctx.out.puts "Açıklama: #{def_obj.description}"
178
- ctx.out.puts "Bağımlılıklar (inject): #{def_obj.inject.join(', ')}"
176
+ ctx.out.puts "Plugin: #{def_obj.name} v#{def_obj.version}"
177
+ ctx.out.puts "Description: #{def_obj.description}"
178
+ ctx.out.puts "Dependencies (inject): #{def_obj.inject.join(', ')}"
179
179
  else
180
- ctx.out.puts "Eklenti bilgisi bulunamadı."
180
+ ctx.out.puts "Plugin info not found."
181
181
  end
182
182
  end
183
183
 
@@ -46,7 +46,7 @@ module Rubik
46
46
 
47
47
  def run_paste(ctx)
48
48
  ctx.request_paste!
49
- ctx.out.puts "[Rubik] Paste modu bir sonraki prompt'ta başlayacak."
49
+ ctx.out.puts "[Rubik] Paste mode will begin on the next prompt."
50
50
  end
51
51
 
52
52
  def run_replay(args, ctx)
@@ -97,7 +97,7 @@ module Rubik
97
97
  if target_id.nil?
98
98
  picked = interactive_session_pick(ctx)
99
99
  if picked == :picker_cancelled
100
- ctx.out.puts "[Rubik::Session] Resume iptal edildi."
100
+ ctx.out.puts "[Rubik::Session] Resume cancelled."
101
101
  return
102
102
  end
103
103
  target_id = picked || :latest
@@ -194,11 +194,11 @@ module Rubik
194
194
  return nil if sessions.empty?
195
195
 
196
196
  prompt = Rubik::UI::Approvals.build_prompt(ctx)
197
- prompt.select("Devam edilecek oturumu seç:") do |menu|
197
+ prompt.select("Select the session to resume:") do |menu|
198
198
  sessions.first(15).each do |s|
199
- menu.choice "#{s[:id]} · #{s[:event_count]} olay · \"#{s[:last_prompt].to_s[0, 40]}\"", s[:id]
199
+ menu.choice "#{s[:id]} · #{s[:event_count]} events · \"#{s[:last_prompt].to_s[0, 40]}\"", s[:id]
200
200
  end
201
- menu.choice "← en son oturum (:latest)", :latest
201
+ menu.choice "← latest session (:latest)", :latest
202
202
  end
203
203
  rescue Interrupt
204
204
  Rubik::REPL::InterruptHandler.restore_console_after_interrupt
@@ -383,13 +383,13 @@ module Rubik
383
383
  end
384
384
  else
385
385
  # Smart guidance for verbless input
386
- ctx.out.puts "[Rubik::Config] Geçersiz kullanım."
386
+ ctx.out.puts "[Rubik::Config] Invalid usage."
387
387
  if clean_args.size >= 2
388
- ctx.out.puts " • Ayar yapmak için : !config set #{clean_args[0]} #{clean_args[1]}"
388
+ ctx.out.puts " • To set a value: !config set #{clean_args[0]} #{clean_args[1]}"
389
389
  else
390
- ctx.out.puts " • Ayar yapmak için : !config set #{clean_args[0]} <val>"
390
+ ctx.out.puts " • To set a value: !config set #{clean_args[0]} <val>"
391
391
  end
392
- ctx.out.puts " • Değer okumak için: !config get #{clean_args[0]}"
392
+ ctx.out.puts " • To read a value: !config get #{clean_args[0]}"
393
393
  end
394
394
  end
395
395
  end
@@ -57,7 +57,7 @@ module Rubik
57
57
  cmd_meta[:handler].call(parsed.args, command_context)
58
58
  rescue Interrupt
59
59
  Rubik::REPL::InterruptHandler.restore_console_after_interrupt
60
- @output.puts "\n⚠️ [Rubik] Komut kullanıcı tarafından iptal edildi (^C)."
60
+ @output.puts "\n⚠️ [Rubik] Command cancelled by user (^C)."
61
61
  ensure
62
62
  # !goal dahil lifecycle komutları tracked dal ile aynı spinner
63
63
  # garantisini taşır (field incident 2026-10-12: !goal'ten kaçan
@@ -74,7 +74,7 @@ module Rubik
74
74
  rescue Interrupt
75
75
  cmd_interrupted = true
76
76
  Rubik::REPL::InterruptHandler.restore_console_after_interrupt
77
- @output.puts "\n⚠️ [Rubik] Komut kullanıcı tarafından iptal edildi (^C)."
77
+ @output.puts "\n⚠️ [Rubik] Command cancelled by user (^C)."
78
78
  ensure
79
79
  # A command (!plan/!goal) may leave a live spinner if it died mid-wait.
80
80
  kill_command_spinner!
@@ -99,7 +99,7 @@ module Rubik
99
99
  reap_dead_kernel_units! if respond_to?(:reap_dead_kernel_units!)
100
100
  else
101
101
  available = @commands.keys.sort.map { |c| "!#{c}" }.join(", ")
102
- @output.puts "Bilinmeyen komut: !#{parsed.command_name}. Kullanılabilir komutlar: #{available} (!help'e bakın)."
102
+ @output.puts "Unknown command: !#{parsed.command_name}. Available commands: #{available} (see !help)."
103
103
  end
104
104
  end
105
105
 
@@ -225,7 +225,7 @@ module Rubik
225
225
  return routed if routed[:provider]
226
226
 
227
227
  spec_str = routed[:spec].is_a?(Hash) ? "#{routed[:spec]['provider']}/#{routed[:spec]['name']}" : routed[:spec].to_s
228
- @output.puts "Hata: Model sağlayıcısı başlatılamadı (#{spec_str})."
228
+ @output.puts "Error: Could not initialize model provider (#{spec_str})."
229
229
  record_failed_turn!(text, "failed", "no LLM provider available (#{spec_str})", nil)
230
230
  nil
231
231
  end
@@ -314,28 +314,28 @@ module Rubik
314
314
  def drive_budget_continuations!(orchestrator, res)
315
315
  while !res[:ok] && res[:reason] == :budget_exhausted && Rubik::Storage::Layout.config_get(@config, "agent.ask_continue_on_limit", true)
316
316
  @output.puts "\n⚠️ [Rubik::Agent] #{res[:error]}"
317
- ans = ask_yes_no(" [Rubik::Agent] +20 adım ile devam edilsin mi?", default: "n")
317
+ ans = ask_yes_no(" [Rubik::Agent] Continue with +20 steps?", default: "n")
318
318
  break unless ["y", "yes", "evet"].include?(ans)
319
319
 
320
- @output.puts " [Rubik::Agent] Adım bütçesi +20 artırılıyor ve görev sürdürülüyor..."
320
+ @output.puts " [Rubik::Agent] Increasing step budget by +20 and resuming task..."
321
321
  res = orchestrator.continue_loop(20)
322
322
 
323
323
  end
324
324
  res
325
325
  end
326
326
 
327
- # Settle phase: merges the turn's tool history, then records and
328
- # reports the outcome (success render / incomplete report). theme and
329
- # md_enabled arrive from the display phase for the batch render.
327
+ # Settle phase: records the outcome FIRST, then merges the turn's tool
328
+ # history and reports the result. theme and md_enabled arrive from the
329
+ # display phase for the batch render.
330
330
  def settle_free_text_result!(text, res, orchestrator:, theme:, md_enabled:)
331
- # Plan 85 D-7 (kök neden): turn içi @history'deki tool ara adımlarını
332
- # conversation_history'ye kopyala — böylece continue'da model turn sırasındaki
333
- # bağlamı görür ve "sıfırdan keşfe" başlamaz. res[:loop_instance].history,
334
- # turn_result'ın döndürdüğü Loop örneğinin @history'sidir.
335
- merge_unseen_turn_tool_history!(res[:loop_instance])
336
-
337
331
  if res[:ok]
338
332
  record_turn_outcome!(text, res[:output].to_s, tokens: res[:tokens], streamed: res[:streamed] == true)
333
+ # Plan 85 D-7: copy in-turn tool steps into conversation_history so
334
+ # a follow-up sees them. This MUST follow record_turn_outcome! —
335
+ # its trim drops leading rows until a user row leads the window,
336
+ # so merging first evicts every tool row on a fresh/cleared window
337
+ # (issue #557). All rescue paths already use this ordering.
338
+ merge_unseen_turn_tool_history!(res[:loop_instance])
339
339
 
340
340
  # Only print the final answer when it was not already streamed
341
341
  # live; batch answers get full markdown rendering on capable TTYs.
@@ -356,8 +356,9 @@ module Rubik
356
356
  emit_turn_finished(kind: "success", prompt: text, outcome: res[:output].to_s,
357
357
  orchestrator: orchestrator, tokens: res[:tokens])
358
358
  else
359
- @output.puts "Görev tamamlanamadı: #{res[:error]}"
359
+ @output.puts "Task could not be completed: #{res[:error]}"
360
360
  record_failed_turn!(text, "incomplete", res[:error], orchestrator)
361
+ merge_unseen_turn_tool_history!(res[:loop_instance])
361
362
  end
362
363
  end
363
364
 
@@ -407,8 +408,8 @@ module Rubik
407
408
  # execute_steps yolu) işletilir — aynı @history, aynı adım bütçesi
408
409
  # (kullanıcının !steps extend'i dahil). Amaç-eşleşmesi BİREBİRDİR:
409
410
  # substring eşleşmesi yeni bir görevi yanlışlıkla resume sanabilir.
410
- RESUME_INTENTS = ["devam et", "devam", "continue", "sürdür"].freeze
411
- RESUME_PROMPT = "devam et"
411
+ RESUME_INTENTS = ["devam et", "devam", "continue", "sürdür", "resume"].freeze
412
+ RESUME_PROMPT = "continue"
412
413
  RESUME_REASON = "llm_error_recovery"
413
414
 
414
415
  def resumable_turn? = !!@resumable_turn
@@ -443,14 +444,14 @@ module Rubik
443
444
  def stash_and_announce_resume!(orchestrator)
444
445
  return unless stash_resumable_turn!(orchestrator)
445
446
 
446
- @output.puts "[Rubik] Turn duraklatıldı (adım #{orchestrator.step_count}/#{orchestrator.max_steps}). " \
447
- "'devam et' yazarsan aynı bağlam ve adım bütçesiyle sürer; başka bir şey yazarsan yeni görev olarak koşar."
447
+ @output.puts "[Rubik] Turn paused (step #{orchestrator.step_count}/#{orchestrator.max_steps}). " \
448
+ "Type 'continue' to resume with the same context and step budget; type anything else to run as a new task."
448
449
  end
449
450
 
450
451
  # Duraklatılmış turn'in yeniden koşusu: taze turn yaşam döngüsünü
451
452
  # (arming → display → settle → rescue merdiveni → ensure teardown)
452
453
  # resume sözleşmesiyle birleştirir. Kullanıcının yazdığı satır
453
- # recorder'a ve konuşma hafızasına "devam et" olarak düşer — dürüst
454
+ # recorder'a ve konuşma hafızasına "continue" olarak düşer — dürüst
454
455
  # provenance; orijinal görev metni Loop'un kendi @history'sinde
455
456
  # yaşamaya devam eder ve modele tekrar gönderilmez.
456
457
  def execute_resumed_turn!
@@ -498,7 +499,7 @@ module Rubik
498
499
  @recorder&.record("cancelled_turn",
499
500
  "question" => text.to_s.strip[0, 80],
500
501
  "reason" => "Interrupted by user (^C)")
501
- @output.puts "\n⚠️ [Rubik::Agent] Görev kullanıcı tarafından iptal edildi (^C)."
502
+ @output.puts "\n⚠️ [Rubik::Agent] Task cancelled by user (^C)."
502
503
  record_failed_turn!(text, "cancelled", "Interrupted by user (^C)", orchestrator)
503
504
  merge_failed_turn_tool_history!(orchestrator)
504
505
  end
@@ -510,7 +511,7 @@ module Rubik
510
511
  # LLM error. Sanitize before use.
511
512
  def handle_llm_client_error!(text, error, orchestrator)
512
513
  message = Rubik::Platform.safe_utf8(error.message)
513
- @output.puts "[Rubik::LLM Hatası] #{message}"
514
+ @output.puts "[Rubik::LLM Error] #{message}"
514
515
  record_failed_turn!(text, "failed", message, orchestrator)
515
516
  merge_failed_turn_tool_history!(orchestrator)
516
517
  stash_and_announce_resume!(orchestrator) unless @autonomous_turn
@@ -520,7 +521,7 @@ module Rubik
520
521
  # error path above.
521
522
  def handle_unexpected_error!(text, error, orchestrator)
522
523
  message = Rubik::Platform.safe_utf8(error.message)
523
- @output.puts "[Hata] #{error.class}: #{message}"
524
+ @output.puts "[Error] #{error.class}: #{message}"
524
525
  record_failed_turn!(text, "failed", "#{error.class}: #{message}", orchestrator)
525
526
  merge_failed_turn_tool_history!(orchestrator)
526
527
  end
@@ -575,15 +576,15 @@ module Rubik
575
576
  # interrupted WAIT; one with owned work is a cancelled TASK TREE — and
576
577
  # remaining work is named, so an incomplete cleanup is never silent.
577
578
  def task_cancellation_lines(outcome)
578
- return ["⏸️ [Rubik] Bekleme kesildi (^C) — iptal edilecek bağlı alt ajan yok."] unless outcome&.any?
579
+ return ["⏸️ [Rubik] Wait interrupted (^C) — no linked subagents to cancel."] unless outcome&.any?
579
580
 
580
- line = "🛑 [Rubik] Görev ağacı iptal edildi (^C): #{outcome.stopped.size} bağlı alt ajan durduruldu"
581
- line << ", #{outcome.queued_cancelled.size} kuyruk işi iptal edildi" unless outcome.queued_cancelled.empty?
581
+ line = "🛑 [Rubik] Task tree cancelled (^C): #{outcome.stopped.size} linked subagents stopped"
582
+ line << ", #{outcome.queued_cancelled.size} queued jobs cancelled" unless outcome.queued_cancelled.empty?
582
583
  if outcome.complete?
583
- line << "; temizlik tamamlandı."
584
+ line << "; cleanup completed."
584
585
  else
585
586
  remaining = outcome.remaining.map { |r| "#{r[:id]}:#{r[:state]}" }.join(", ")
586
- line << "; temizlik TAMAMLANMADI — kalan: #{remaining}."
587
+ line << "; cleanup INCOMPLETE — remaining: #{remaining}."
587
588
  end
588
589
  [line]
589
590
  end
@@ -197,15 +197,20 @@ module Rubik
197
197
  end
198
198
 
199
199
  def process_normal_line(line, _multiline_buffer)
200
- # Only trigger heredoc if line explicitly opens a multiline block (e.g. `<<EOF`, `!plan <<EOF`)
201
- # NEVER trigger on inline operators like `array << item` or `a << b`
202
- heredoc_match = line.match(/\A[ \t]*(?:[a-zA-Z0-9_!.-]+[ \t]+)?<<[-~]?['"]?([A-Za-z0-9_]+)['"]?[ \t]*\z/)
200
+ # Only trigger heredoc if line explicitly opens a multiline block
201
+ # (e.g. `<< EOF`, `!plan << EOF`). Whitespace after `<<` is required:
202
+ # `array <<item` is an inline append operator, not a heredoc (#557).
203
+ heredoc_match = line.match(/\A[ \t]*(?:![a-zA-Z0-9_.-]+[ \t]+)?<<[-~]?[ \t]+['"]?([A-Za-z0-9_]+)['"]?[ \t]*\z/)
203
204
  if heredoc_match && !line.strip.start_with?("#")
204
205
  delimiter = heredoc_match[1]
205
- prefix = line.sub(/<<[-~]?['"]?#{Regexp.escape(delimiter)}['"]?\s*$/, "").strip
206
+ prefix = line.sub(/<<[-~]?[ \t]+['"]?#{Regexp.escape(delimiter)}['"]?\s*$/, "").strip
206
207
  buffer = prefix.empty? ? [] : [prefix]
207
208
  { stop: false, buffer: buffer, delimiter: delimiter }
208
209
  elsif ["exit", "quit", "!exit", "!quit"].include?(line.strip.downcase)
210
+ # Design note (#557): interactive mode stops the REPL here, while
211
+ # stream mode (execute_input) sends the same tokens to the model.
212
+ # This divergence is deliberate — piped scripts use the model as
213
+ # the interpreter — so do not "align" it without a product decision.
209
214
  stop
210
215
  { stop: true, buffer: [], delimiter: nil }
211
216
  else
@@ -151,8 +151,7 @@ module Rubik
151
151
  return unless Rubik::Storage::Layout.config_get(@config, "connect.first_run_offer", true)
152
152
  return unless llm_client_pending?
153
153
 
154
- answer = ask_yes_no("Hiç model sağlayıcısı yapılandırılmamış görünüyor. Bağlantı sihirbazı çalıştırılsın mı? / " \
155
- "No LLM provider is configured yet. Run the connect wizard?", default: "n")
154
+ answer = ask_yes_no("No LLM provider is configured yet. Run the connect wizard?", default: "n")
156
155
  return unless ["y", "yes", "evet"].include?(answer.to_s.downcase)
157
156
 
158
157
  ui = Rubik::Connect::PromptUI.new(input: @input,
@@ -238,12 +238,18 @@ module Rubik
238
238
 
239
239
  def inject_subagent_notice_into_conversation_history!(notice)
240
240
  xml_payload = Rubik::Orchestrator::Subagent::Notices.history_block([notice])
241
- history = shell_state(:conversation_history)
242
- unless history
243
- history = []
244
- @shell.instance_variable_set(:@conversation_history, history)
241
+ # The bus thread injects while the turn thread may replace the whole
242
+ # history array in trim_conversation_window!. Share the standby mutex
243
+ # with that mutation so a notice is never written to a stale array
244
+ # (issue #557).
245
+ subagent_notices_mutex.synchronize do
246
+ history = shell_state(:conversation_history)
247
+ unless history
248
+ history = []
249
+ @shell.instance_variable_set(:@conversation_history, history)
250
+ end
251
+ Rubik::Prompt::ConversationRows.append_notice!(history, xml_payload)
245
252
  end
246
- Rubik::Prompt::ConversationRows.append_notice!(history, xml_payload)
247
253
  end
248
254
 
249
255
  def flush_subagent_notices!
@@ -66,7 +66,7 @@ module Rubik
66
66
  # Plan 109: koleksiyon with_collecting içinde — reaktif bir uyandırma
67
67
  # Enter'ı yapıştırılan metne boş satır eklemez.
68
68
  def read_paste_block
69
- @output.puts "[Rubik] Paste modu: metni yapıştırın, bitirmek için tek başına '.' yazın (Ctrl+C iptal)."
69
+ @output.puts "[Rubik] Paste mode: paste the text, type '.' on its own to finish (Ctrl+C to cancel)."
70
70
  lines = []
71
71
  collector = lambda do
72
72
  loop do