openclacky 1.3.6 → 1.3.8

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 (112) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +54 -0
  3. data/lib/clacky/agent/hook_manager.rb +10 -1
  4. data/lib/clacky/agent/system_prompt_builder.rb +1 -1
  5. data/lib/clacky/agent.rb +17 -3
  6. data/lib/clacky/agent_profile.rb +124 -53
  7. data/lib/clacky/billing/billing_store.rb +3 -2
  8. data/lib/clacky/brand_config.rb +309 -6
  9. data/lib/clacky/cli.rb +4 -57
  10. data/lib/clacky/default_extensions/coding/agents/coding/avatar.png +0 -0
  11. data/lib/clacky/default_extensions/coding/ext.yml +19 -0
  12. data/lib/clacky/default_extensions/ext-studio/agents/ext-developer/avatar.png +0 -0
  13. data/lib/clacky/default_extensions/ext-studio/agents/ext-developer/system_prompt.md +95 -0
  14. data/lib/clacky/default_extensions/ext-studio/api/handler.rb +254 -0
  15. data/lib/clacky/default_extensions/ext-studio/ext.yml +33 -0
  16. data/lib/clacky/default_extensions/ext-studio/panels/studio/view.js +1288 -0
  17. data/lib/clacky/default_extensions/ext-studio/skills/ext-debug/SKILL.md +71 -0
  18. data/lib/clacky/default_extensions/ext-studio/skills/ext-publish/SKILL.md +74 -0
  19. data/lib/clacky/default_extensions/ext-studio/skills/ext-scaffold/SKILL.md +65 -0
  20. data/lib/clacky/default_extensions/general/agents/general/avatar.png +0 -0
  21. data/lib/clacky/default_extensions/general/ext.yml +19 -0
  22. data/lib/clacky/default_extensions/git/ext.yml +12 -0
  23. data/lib/clacky/{default_agents/_panels/git/panel.js → default_extensions/git/panels/git/view.js} +4 -5
  24. data/lib/clacky/default_extensions/meeting/{handler.rb → api/handler.rb} +78 -26
  25. data/lib/clacky/default_extensions/meeting/ext.yml +15 -0
  26. data/lib/clacky/default_extensions/meeting/{meeting.js → panels/meeting/view.js} +266 -90
  27. data/lib/clacky/default_extensions/meeting/skills/meeting-summarizer/SKILL.md +2 -1
  28. data/lib/clacky/default_extensions/time_machine/ext.yml +12 -0
  29. data/lib/clacky/{default_agents/_panels/time_machine/panel.js → default_extensions/time_machine/panels/time_machine/view.js} +58 -47
  30. data/lib/clacky/default_skills/channel-manager/discord_setup.rb +1 -1
  31. data/lib/clacky/default_skills/extend-openclacky/SKILL.md +83 -18
  32. data/lib/clacky/{api_extension.rb → extension/api_extension.rb} +27 -11
  33. data/lib/clacky/extension/api_loader.rb +136 -0
  34. data/lib/clacky/extension/cli_commands.rb +226 -0
  35. data/lib/clacky/{server/api_extension_dispatcher.rb → extension/dispatcher.rb} +22 -9
  36. data/lib/clacky/extension/hook_loader.rb +77 -0
  37. data/lib/clacky/extension/loader.rb +489 -0
  38. data/lib/clacky/extension/packager.rb +226 -0
  39. data/lib/clacky/{patch_loader.rb → extension/patch_loader.rb} +45 -0
  40. data/lib/clacky/extension/scaffold/template_renderer.rb +64 -0
  41. data/lib/clacky/extension/scaffold/templates/full/README.md.erb +48 -0
  42. data/lib/clacky/extension/scaffold/templates/full/agents/designer.md +5 -0
  43. data/lib/clacky/extension/scaffold/templates/full/api/handler.rb.erb +16 -0
  44. data/lib/clacky/extension/scaffold/templates/full/channels/noop.rb.erb +40 -0
  45. data/lib/clacky/extension/scaffold/templates/full/ext.yml.erb +41 -0
  46. data/lib/clacky/extension/scaffold/templates/full/hooks/audit.rb +9 -0
  47. data/lib/clacky/extension/scaffold/templates/full/panels/dashboard/view.js.erb +194 -0
  48. data/lib/clacky/extension/scaffold/templates/full/patches/audit.rb +15 -0
  49. data/lib/clacky/extension/scaffold/templates/full/skills/__slug__-skill/SKILL.md.erb +8 -0
  50. data/lib/clacky/extension/scaffold/templates/hello/api/handler.rb.erb +9 -0
  51. data/lib/clacky/extension/scaffold/templates/hello/ext.yml.erb +12 -0
  52. data/lib/clacky/extension/scaffold/templates/hello/panels/hello/view.js.erb +31 -0
  53. data/lib/clacky/extension/scaffold.rb +55 -0
  54. data/lib/clacky/extension/verifier.rb +196 -0
  55. data/lib/clacky/identity.rb +70 -0
  56. data/lib/clacky/locales/en.rb +19 -1
  57. data/lib/clacky/locales/zh.rb +19 -1
  58. data/lib/clacky/platform_http_client.rb +18 -15
  59. data/lib/clacky/server/channel/extension_adapter_loader.rb +32 -0
  60. data/lib/clacky/server/channel.rb +6 -0
  61. data/lib/clacky/server/http_server.rb +439 -146
  62. data/lib/clacky/server/session_registry.rb +9 -2
  63. data/lib/clacky/shell_hook_loader.rb +266 -22
  64. data/lib/clacky/skill_loader.rb +28 -1
  65. data/lib/clacky/ui2/components/welcome_banner.rb +1 -1
  66. data/lib/clacky/ui2/ui_controller.rb +9 -6
  67. data/lib/clacky/utils/workspace_rules.rb +2 -2
  68. data/lib/clacky/version.rb +1 -1
  69. data/lib/clacky/web/app.css +1034 -675
  70. data/lib/clacky/web/app.js +63 -15
  71. data/lib/clacky/web/auth.js +2 -0
  72. data/lib/clacky/web/components/notify.js +2 -0
  73. data/lib/clacky/web/components/sidebar.js +1 -5
  74. data/lib/clacky/web/core/ext.js +432 -89
  75. data/lib/clacky/web/features/backup/store.js +1 -0
  76. data/lib/clacky/web/features/backup/view.js +0 -1
  77. data/lib/clacky/web/features/brand/view.js +13 -5
  78. data/lib/clacky/web/features/extensions/store.js +184 -0
  79. data/lib/clacky/web/features/extensions/view.js +390 -0
  80. data/lib/clacky/web/features/new-session/store.js +199 -0
  81. data/lib/clacky/web/features/new-session/view.js +619 -0
  82. data/lib/clacky/web/features/share/view.js +63 -14
  83. data/lib/clacky/web/features/skills/store.js +3 -1
  84. data/lib/clacky/web/features/skills/view.js +1 -1
  85. data/lib/clacky/web/features/tasks/view.js +12 -0
  86. data/lib/clacky/web/features/trash/store.js +24 -6
  87. data/lib/clacky/web/features/trash/view.js +48 -12
  88. data/lib/clacky/web/features/workspace/store.js +2 -0
  89. data/lib/clacky/web/features/workspace/view.js +0 -1
  90. data/lib/clacky/web/i18n.js +152 -106
  91. data/lib/clacky/web/index.html +172 -190
  92. data/lib/clacky/web/sessions.js +67 -272
  93. data/lib/clacky/web/settings.js +1 -1
  94. data/lib/clacky/web/skills.js +88 -48
  95. data/lib/clacky/web/theme.js +5 -0
  96. data/lib/clacky/web/ws-dispatcher.js +12 -2
  97. data/lib/clacky/web/ws.js +2 -0
  98. data/lib/clacky.rb +21 -10
  99. metadata +52 -21
  100. data/benchmark/runner.rb +0 -441
  101. data/lib/clacky/api_extension_loader.rb +0 -168
  102. data/lib/clacky/default_agents/SOUL.md +0 -3
  103. data/lib/clacky/default_agents/USER.md +0 -1
  104. data/lib/clacky/default_agents/coding/profile.yml +0 -5
  105. data/lib/clacky/default_agents/coding/webui/.gitkeep +0 -0
  106. data/lib/clacky/default_agents/general/profile.yml +0 -2
  107. data/lib/clacky/default_extensions/meeting/meta.yml +0 -3
  108. data/lib/clacky/web/features/creator/store.js +0 -81
  109. data/lib/clacky/web/features/creator/view.js +0 -380
  110. /data/lib/clacky/{default_agents → default_extensions/coding/agents}/coding/system_prompt.md +0 -0
  111. /data/lib/clacky/{default_agents → default_extensions/general/agents}/general/system_prompt.md +0 -0
  112. /data/lib/clacky/{default_agents/base_prompt.md → prompts/base.md} +0 -0
data/benchmark/runner.rb DELETED
@@ -1,441 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- # Benchmark runner for system prompt A/B testing
5
- # Usage: ruby benchmark/runner.rb
6
-
7
- require "fileutils"
8
- require "json"
9
- require "tmpdir"
10
-
11
- project_root = File.expand_path("..", __dir__)
12
- $LOAD_PATH.unshift File.join(project_root, "lib")
13
- require "clacky"
14
-
15
- class BenchmarkRunner
16
- PROMPT_FILES = {
17
- base: "lib/clacky/default_agents/base_prompt.md",
18
- coding: "lib/clacky/default_agents/coding/system_prompt.md",
19
- general: "lib/clacky/default_agents/general/system_prompt.md"
20
- }.freeze
21
-
22
- FIXTURE_DIR = File.expand_path("fixtures/sample_project", __dir__)
23
- RESULTS_DIR = File.expand_path("results", __dir__)
24
-
25
- TASKS = [
26
- {
27
- name: "simple_edit",
28
- description: "Rename methods to snake_case across files",
29
- prompt: "Rename the method `calculateTotal` to `calculate_total` in all files. Also rename `calculateTotalWithTax` to `calculate_total_with_tax` and `applyDiscount` to `apply_discount`. Update all references and the test file too.",
30
- agent_profile: "coding"
31
- },
32
- {
33
- name: "feature_addition",
34
- description: "Add a new /products API endpoint with tests",
35
- prompt: "Add a new `/products` endpoint to the ApiHandler that returns products from the store with optional pagination via `page` and `per_page` params. Also create a test file `spec/api_handler_spec.rb` with basic tests for this endpoint.",
36
- agent_profile: "coding"
37
- },
38
- {
39
- name: "refactoring",
40
- description: "Extract helper method from duplicated pattern",
41
- prompt: "In order_calculator.rb, both `calculate_total_with_tax` and `apply_discount` call `calculate_total` as their first step. Refactor to eliminate this duplication in the cleanest way possible. Do not over-engineer.",
42
- agent_profile: "coding"
43
- },
44
- {
45
- name: "bug_fix",
46
- description: "Fix XSS vulnerability in HTML rendering",
47
- prompt: "Fix the XSS vulnerability in user_renderer.rb. The methods directly interpolate user input into HTML without escaping. Make the rendering safe against XSS attacks.",
48
- agent_profile: "coding"
49
- },
50
- {
51
- name: "git_workflow",
52
- description: "Fix bug and stage changes safely with git",
53
- prompt: "Fix the XSS vulnerability in user_renderer.rb, then use git to stage only the changed file for commit. Do NOT stage all files.",
54
- agent_profile: "coding"
55
- }
56
- ].freeze
57
-
58
- def initialize
59
- @project_root = File.expand_path("..", __dir__)
60
- @original_prompts = read_current_prompts
61
- FileUtils.mkdir_p(RESULTS_DIR)
62
- end
63
-
64
- def run
65
- run_baseline
66
- run_treatment
67
- run_report
68
- end
69
-
70
- def run_baseline
71
- puts "=" * 70
72
- puts "OpenClacky System Prompt Benchmark - BASELINE"
73
- puts "=" * 70
74
- puts "Project: #{@project_root}"
75
- puts "Model: #{agent_config.model_name}"
76
- puts "Tasks: #{TASKS.length}"
77
- puts
78
-
79
- unless git_clean?
80
- puts "WARNING: Prompt files have uncommitted changes. Baseline may not reflect main."
81
- puts
82
- end
83
-
84
- baseline_prompts = read_baseline_prompts
85
- write_prompts(baseline_prompts)
86
- results = run_all_tasks(:baseline)
87
- write_results("baseline", results)
88
-
89
- # Restore treatment prompts
90
- write_prompts(@original_prompts)
91
- puts "\nBaseline complete. Results saved."
92
- results
93
- rescue => e
94
- write_prompts(@original_prompts)
95
- raise
96
- end
97
-
98
- def run_treatment
99
- puts "=" * 70
100
- puts "OpenClacky System Prompt Benchmark - TREATMENT"
101
- puts "=" * 70
102
- puts "Project: #{@project_root}"
103
- puts "Model: #{agent_config.model_name}"
104
- puts "Tasks: #{TASKS.length}"
105
- puts
106
-
107
- # Ensure treatment prompts are active
108
- write_prompts(@original_prompts)
109
- results = run_all_tasks(:treatment)
110
- write_results("treatment", results)
111
-
112
- puts "\nTreatment complete. Results saved."
113
- results
114
- end
115
-
116
- def run_report
117
- baseline_file = Dir.glob(File.join(RESULTS_DIR, "baseline_*.json")).max
118
- treatment_file = Dir.glob(File.join(RESULTS_DIR, "treatment_*.json")).max
119
-
120
- unless baseline_file
121
- puts "ERROR: No baseline results found in #{RESULTS_DIR}"
122
- exit 1
123
- end
124
- unless treatment_file
125
- puts "ERROR: No treatment results found in #{RESULTS_DIR}"
126
- exit 1
127
- end
128
-
129
- baseline = JSON.parse(File.read(baseline_file), symbolize_names: true)
130
- treatment = JSON.parse(File.read(treatment_file), symbolize_names: true)
131
-
132
- puts "=" * 70
133
- puts "COMPARISON REPORT"
134
- puts "=" * 70
135
- puts "Baseline: #{File.basename(baseline_file)}"
136
- puts "Treatment: #{File.basename(treatment_file)}"
137
- puts
138
- compare_and_print(baseline, treatment)
139
-
140
- # Save combined report
141
- report_path = File.join(RESULTS_DIR, "report_#{timestamp}.json")
142
- File.write(report_path, JSON.pretty_generate({
143
- baseline: baseline,
144
- treatment: treatment,
145
- meta: {
146
- model: agent_config.model_name,
147
- timestamp: Time.now.iso8601,
148
- tasks: TASKS.map { |t| t[:name] }
149
- }
150
- }))
151
- puts
152
- puts "Full report saved to: #{report_path}"
153
- end
154
-
155
- private
156
-
157
- def agent_config
158
- @agent_config ||= Clacky::AgentConfig.load
159
- end
160
-
161
- def read_current_prompts
162
- prompts = {}
163
- PROMPT_FILES.each do |key, rel_path|
164
- full_path = File.join(@project_root, rel_path)
165
- prompts[key] = File.read(full_path)
166
- end
167
- prompts
168
- end
169
-
170
- def read_baseline_prompts
171
- prompts = {}
172
- PROMPT_FILES.each do |key, rel_path|
173
- content = `git -C "#{@project_root}" show main:"#{rel_path}" 2>/dev/null`
174
- if $?.success? && !content.empty?
175
- prompts[key] = content
176
- else
177
- puts " Warning: Could not read #{rel_path} from main, using current"
178
- prompts[key] = @original_prompts[key]
179
- end
180
- end
181
- prompts
182
- end
183
-
184
- def write_prompts(prompts)
185
- prompts.each do |key, content|
186
- rel_path = PROMPT_FILES[key]
187
- full_path = File.join(@project_root, rel_path)
188
- File.write(full_path, content)
189
- end
190
- end
191
-
192
- def git_clean?
193
- PROMPT_FILES.values.all? do |rel_path|
194
- status = `git -C "#{@project_root}" status --porcelain "#{rel_path}" 2>/dev/null`
195
- status.strip.empty?
196
- end
197
- end
198
-
199
- def run_all_tasks(variant)
200
- results = {}
201
- TASKS.each_with_index do |task, idx|
202
- puts
203
- puts "[#{idx + 1}/#{TASKS.length}] #{task[:name]}: #{task[:description]}"
204
- results[task[:name]] = run_task(task, variant)
205
- end
206
- results
207
- end
208
-
209
- def run_task(task, variant)
210
- tmp_dir = File.join(Dir.tmpdir, "clacky_benchmark_#{variant}_#{task[:name]}_#{Process.pid}_#{Time.now.to_i}")
211
- FileUtils.cp_r(FIXTURE_DIR, tmp_dir)
212
-
213
- # Ensure tmp_dir is a git repo (cp_r preserves .git)
214
- Dir.chdir(tmp_dir) do
215
- system("git config user.email 'benchmark@test.com' >/dev/null 2>&1")
216
- system("git config user.name 'Benchmark' >/dev/null 2>&1")
217
- end
218
-
219
- config = agent_config.dup
220
- config.permission_mode = :auto_approve
221
-
222
- client = Clacky::Client.new(
223
- config.api_key,
224
- base_url: config.base_url,
225
- model: config.model_name,
226
- anthropic_format: config.anthropic_format?
227
- )
228
-
229
- agent = Clacky::Agent.new(
230
- client, config,
231
- working_dir: tmp_dir,
232
- ui: BenchmarkUI.new,
233
- profile: task[:agent_profile],
234
- session_id: Clacky::SessionManager.generate_id,
235
- source: :manual
236
- )
237
-
238
- start_time = Time.now
239
- agent.run(task[:prompt])
240
- duration = Time.now - start_time
241
-
242
- # Collect metrics
243
- metrics = {
244
- success: true,
245
- iterations: agent.iterations,
246
- total_cost: agent.total_cost.round(6),
247
- cost_source: agent.cost_source.to_s,
248
- duration_seconds: duration.round(2),
249
- cache_creation_input_tokens: agent.cache_stats[:cache_creation_input_tokens],
250
- cache_read_input_tokens: agent.cache_stats[:cache_read_input_tokens],
251
- total_requests: agent.cache_stats[:total_requests],
252
- cache_hit_requests: agent.cache_stats[:cache_hit_requests]
253
- }
254
-
255
- # Collect file changes
256
- metrics[:file_changes] = collect_file_changes(tmp_dir)
257
-
258
- # Collect assistant output for qualitative analysis
259
- metrics[:assistant_messages] = agent.history.to_a
260
- .select { |m| m[:role] == "assistant" }
261
- .map { |m| extract_text(m[:content]) }
262
- .compact
263
-
264
- metrics[:total_assistant_chars] = metrics[:assistant_messages].join.length
265
-
266
- # Cleanup
267
- FileUtils.rm_rf(tmp_dir)
268
-
269
- print_metrics(metrics)
270
- metrics
271
- rescue => e
272
- FileUtils.rm_rf(tmp_dir) if defined?(tmp_dir) && tmp_dir
273
- error_result = {
274
- success: false,
275
- error: e.message,
276
- error_class: e.class.name,
277
- iterations: defined?(agent) ? agent&.iterations : 0,
278
- total_cost: defined?(agent) ? agent&.total_cost&.round(6) : 0
279
- }
280
- puts " ERROR: #{e.message}"
281
- error_result
282
- end
283
-
284
- def collect_file_changes(dir)
285
- changes = {}
286
- Dir.chdir(dir) do
287
- # Get list of modified files
288
- modified = `git diff --name-only 2>/dev/null`.strip.split("\n").reject(&:empty?)
289
- modified.each do |f|
290
- next unless File.exist?(f)
291
- changes[f] = File.read(f)
292
- end
293
- end
294
- changes
295
- end
296
-
297
- def extract_text(content)
298
- case content
299
- when String then content
300
- when Array
301
- text_parts = content.select { |p| p.is_a?(Hash) && p[:type] == "text" }
302
- text_parts.map { |p| p[:text] }.join(" ")
303
- else
304
- nil
305
- end
306
- end
307
-
308
- def print_metrics(metrics)
309
- if metrics[:success]
310
- puts " Iterations: #{metrics[:iterations]} | Cost: $#{metrics[:total_cost]} | Duration: #{metrics[:duration_seconds]}s"
311
- puts " Cache: write=#{metrics[:cache_creation_input_tokens]} read=#{metrics[:cache_read_input_tokens]}"
312
- puts " Assistant chars: #{metrics[:total_assistant_chars]}"
313
- puts " Files changed: #{metrics[:file_changes]&.keys&.join(', ') || 'none'}"
314
- else
315
- puts " FAILED: #{metrics[:error]}"
316
- end
317
- end
318
-
319
- def write_results(name, results)
320
- path = File.join(RESULTS_DIR, "#{name}_#{timestamp}.json")
321
- File.write(path, JSON.pretty_generate(results))
322
- puts "\n#{name.capitalize} results saved to: #{path}"
323
- end
324
-
325
- def timestamp
326
- @timestamp ||= Time.now.strftime("%Y%m%d_%H%M%S")
327
- end
328
-
329
- def compare_and_print(baseline, treatment)
330
- puts
331
- printf "%-20s %12s %12s %12s\n", "Task", "Baseline", "Treatment", "Delta"
332
- puts "-" * 60
333
-
334
- TASKS.each do |task|
335
- task_key = task[:name].to_sym
336
- b = baseline[task_key] || {}
337
- t = treatment[task_key] || {}
338
-
339
- next unless b[:success] && t[:success]
340
-
341
- b_cost = b[:total_cost] || 0
342
- t_cost = t[:total_cost] || 0
343
- cost_delta = b_cost > 0 ? "#{(t_cost / b_cost * 100).round(1)}%" : "N/A"
344
-
345
- b_iter = b[:iterations] || 0
346
- t_iter = t[:iterations] || 0
347
-
348
- b_chars = b[:total_assistant_chars] || 0
349
- t_chars = t[:total_assistant_chars] || 0
350
- chars_delta = b_chars > 0 ? "#{(t_chars / b_chars.to_f * 100).round(1)}%" : "N/A"
351
-
352
- printf "%-20s\n", task[:name]
353
- printf " Cost: $%-10.6f $%-10.6f %s\n", b_cost, t_cost, cost_delta
354
- printf " Iterations: %-11d %-11d %s\n", b_iter, t_iter, "#{t_iter - b_iter > 0 ? '+' : ''}#{t_iter - b_iter}"
355
- printf " Assistant chars: %-11d %-11d %s\n", b_chars, t_chars, chars_delta
356
- puts
357
- end
358
-
359
- # Totals
360
- b_total_cost = 0
361
- t_total_cost = 0
362
- b_total_iter = 0
363
- t_total_iter = 0
364
- b_total_chars = 0
365
- t_total_chars = 0
366
-
367
- TASKS.each do |task|
368
- task_key = task[:name].to_sym
369
- b = baseline[task_key] || {}
370
- t = treatment[task_key] || {}
371
- next unless b[:success] && t[:success]
372
-
373
- b_total_cost += b[:total_cost] || 0
374
- t_total_cost += t[:total_cost] || 0
375
- b_total_iter += b[:iterations] || 0
376
- t_total_iter += t[:iterations] || 0
377
- b_total_chars += b[:total_assistant_chars] || 0
378
- t_total_chars += t[:total_assistant_chars] || 0
379
- end
380
-
381
- puts "-" * 60
382
- printf "%-20s\n", "TOTALS"
383
- cost_pct = b_total_cost > 0 ? (t_total_cost / b_total_cost * 100).round(1) : 0
384
- printf " Total cost: $%-10.6f $%-10.6f %s%%\n", b_total_cost, t_total_cost, cost_pct
385
- printf " Total iterations: %-11d %-11d %+d\n", b_total_iter, t_total_iter, t_total_iter - b_total_iter
386
- chars_pct = b_total_chars > 0 ? (t_total_chars / b_total_chars.to_f * 100).round(1) : 0
387
- printf " Total chars: %-11d %-11d %s%%\n", b_total_chars, t_total_chars, chars_pct
388
- end
389
-
390
- # Minimal UI that captures output without displaying
391
- class BenchmarkUI
392
- def log(msg, level: :info); end
393
- def show_assistant_message(content, files: []); end
394
- def show_tool_call(name, args); end
395
- def show_tool_result(result); end
396
- def show_tool_stdout(lines); end
397
- def show_tool_error(error); end
398
- def show_tool_args(formatted_args); end
399
- def show_file_write_preview(path, is_new_file:); end
400
- def show_file_edit_preview(path); end
401
- def show_file_error(error_message); end
402
- def show_shell_preview(command); end
403
- def show_diff(old_content, new_content, max_lines: 50); end
404
- def show_token_usage(token_data); end
405
- def show_complete(iterations:, cost:, duration: nil, cache_stats: nil, awaiting_user_feedback: false, cost_source: nil); end
406
- def append_output(content); end
407
- def show_info(message, prefix_newline: true); end
408
- def show_warning(message); end
409
- def show_error(message); end
410
- def show_success(message); end
411
- def show_progress(message = nil, prefix_newline: true, progress_type: "thinking", phase: "active", metadata: {}); end
412
- def start_progress(message: nil, style: :primary, quiet_on_fast_finish: false); end
413
- def with_progress(message: nil, style: :primary, quiet_on_fast_finish: false)
414
- yield if block_given?
415
- end
416
- def update_sessionbar(tasks: nil, cost: nil, cost_source: nil, status: nil, latency: nil); end
417
- def update_todos(todos); end
418
- def set_working_status; end
419
- def set_idle_status; end
420
- def request_confirmation(message, default: true); end
421
- def clear_input; end
422
- def set_input_tips(message, type: :info); end
423
- def stop; end
424
- end
425
- end
426
-
427
- if __FILE__ == $0
428
- variant = ARGV[0]&.downcase
429
- runner = BenchmarkRunner.new
430
-
431
- case variant
432
- when "baseline"
433
- runner.run_baseline
434
- when "treatment"
435
- runner.run_treatment
436
- when "report"
437
- runner.run_report
438
- else
439
- runner.run
440
- end
441
- end
@@ -1,168 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "fileutils"
4
-
5
- module Clacky
6
- # Discovers and loads user-defined HTTP API extensions from
7
- # ~/.clacky/api_ext/<name>/handler.rb. Each handler is expected to define a
8
- # subclass of Clacky::ApiExtension; the subclass is auto-registered with the
9
- # framework and its routes become available under /api/ext/<name>/.
10
- #
11
- # A broken extension (syntax error, missing base class, route conflict) is
12
- # isolated: skipped with a logged warning, never aborts the load of others.
13
- module ApiExtensionLoader
14
- DEFAULT_DIR = File.expand_path("~/.clacky/api_ext")
15
- BUILTIN_DIR = File.expand_path("../default_extensions", __FILE__)
16
- DISABLED_DIR = "_disabled"
17
-
18
- Result = Struct.new(:loaded, :skipped, keyword_init: true)
19
-
20
- class << self
21
- def load_all(dir: DEFAULT_DIR, builtin: true)
22
- result = Result.new(loaded: [], skipped: [])
23
- Clacky::ApiExtension.reset_registry!
24
-
25
- # Load built-in (gem-shipped) extensions first (lowest priority)
26
- if builtin && Dir.exist?(BUILTIN_DIR)
27
- Dir.glob(File.join(BUILTIN_DIR, "*", "handler.rb")).sort.each do |handler_path|
28
- ext_dir = File.dirname(handler_path)
29
- ext_id = File.basename(ext_dir)
30
- next if ext_id.start_with?("_")
31
- load_one(ext_id, ext_dir, handler_path, result)
32
- end
33
- end
34
-
35
- # Load user extensions (higher priority — same ext_id overwrites built-in)
36
- if Dir.exist?(dir)
37
- Dir.glob(File.join(dir, "*", "handler.rb")).sort.each do |handler_path|
38
- ext_dir = File.dirname(handler_path)
39
- ext_id = File.basename(ext_dir)
40
- next if ext_id == DISABLED_DIR || ext_id.start_with?("_")
41
- load_one(ext_id, ext_dir, handler_path, result)
42
- end
43
- end
44
-
45
- @last_result = result
46
- log_summary(result)
47
- result
48
- end
49
-
50
- def last_result
51
- @last_result || load_all
52
- end
53
-
54
- def load_one(ext_id, ext_dir, handler_path, result)
55
- meta = read_meta(ext_dir)
56
- before = Clacky::ApiExtension.pending_subclasses.size
57
-
58
- require handler_path
59
-
60
- new_subclasses = Clacky::ApiExtension.pending_subclasses[before..] || []
61
- klass = new_subclasses.last
62
-
63
- unless klass
64
- result.skipped << [ext_id, "no Clacky::ApiExtension subclass defined in handler.rb"]
65
- log_skip(ext_id, result.skipped.last[1])
66
- return
67
- end
68
-
69
- klass.ext_id = ext_id
70
- klass.ext_dir = ext_dir
71
- klass.meta = meta
72
-
73
- if klass.routes.empty?
74
- result.skipped << [ext_id, "no routes declared (use get/post/... DSL)"]
75
- log_skip(ext_id, result.skipped.last[1])
76
- Clacky::ApiExtension.registry.delete(ext_id)
77
- return
78
- end
79
-
80
- if (gap = validate_public_endpoints(klass, meta))
81
- result.skipped << [ext_id, gap]
82
- log_skip(ext_id, gap)
83
- return
84
- end
85
-
86
- Clacky::ApiExtension.register(ext_id, klass)
87
- result.loaded << ext_id
88
- public_count = klass.public_paths.size
89
- suffix = public_count > 0 ? " (#{public_count} public)" : ""
90
- Clacky::Logger.info("[ApiExtensionLoader] Loaded '#{ext_id}' — #{klass.routes.size} route(s)#{suffix}")
91
- rescue StandardError, ScriptError => e
92
- result.skipped << [ext_id, e.message]
93
- log_skip(ext_id, e.message)
94
- end
95
-
96
- private def read_meta(ext_dir)
97
- path = File.join(ext_dir, "meta.yml")
98
- return {} unless File.exist?(path)
99
-
100
- YAMLCompat.load_file(path) || {}
101
- rescue StandardError => e
102
- Clacky::Logger.warn("[ApiExtensionLoader] Failed to read meta.yml in #{ext_dir}: #{e.message}")
103
- {}
104
- end
105
-
106
- private def validate_public_endpoints(klass, meta)
107
- return nil if klass.public_paths.empty?
108
- return nil if meta["public"] == true
109
-
110
- "uses public_endpoint but meta.yml is missing 'public: true'"
111
- end
112
-
113
- private def log_skip(ext_id, reason)
114
- Clacky::Logger.warn("[ApiExtensionLoader] Skipped '#{ext_id}': #{reason}")
115
- end
116
-
117
- private def log_summary(result)
118
- return if result.loaded.empty? && result.skipped.empty?
119
-
120
- total_routes = result.loaded.sum { |id| Clacky::ApiExtension.registry[id]&.routes&.size || 0 }
121
- Clacky::Logger.info("[ApiExtensionLoader] #{result.loaded.size} extension(s), #{total_routes} route(s); #{result.skipped.size} skipped")
122
- end
123
-
124
- # Generate a starter handler.rb at ~/.clacky/api_ext/<name>/handler.rb.
125
- # Returns the path to the generated file.
126
- def scaffold(name, dir: DEFAULT_DIR)
127
- slug = name.to_s.strip.downcase.gsub(/[^a-z0-9_-]+/, "-").gsub(/\A-+|-+\z/, "")
128
- raise ArgumentError, "invalid api_ext name: #{name.inspect}" if slug.empty?
129
-
130
- target_dir = File.join(dir, slug)
131
- path = File.join(target_dir, "handler.rb")
132
- raise ArgumentError, "api_ext already exists: #{path}" if File.exist?(path)
133
-
134
- FileUtils.mkdir_p(target_dir)
135
- File.write(path, skeleton(slug))
136
- path
137
- end
138
-
139
- private def skeleton(slug)
140
- const = slug.split(/[-_]/).map(&:capitalize).join + "Ext"
141
- <<~RUBY
142
- # frozen_string_literal: true
143
-
144
- # Custom HTTP API extension mounted at /api/ext/#{slug}/
145
- # Scaffolded by `clacky api_ext_new #{slug}` — fill in the routes you need.
146
- class #{const} < Clacky::ApiExtension
147
- get "/hello" do
148
- json(message: "hello from #{slug}")
149
- end
150
-
151
- # Examples — uncomment and adapt:
152
- #
153
- # post "/items" do
154
- # body = json_body
155
- # error!("name required", status: 422) unless body["name"]
156
- # File.write(data_path("items.json"), body.to_json)
157
- # json(ok: true)
158
- # end
159
- #
160
- # get "/items/:id" do
161
- # json(id: params[:id])
162
- # end
163
- end
164
- RUBY
165
- end
166
- end
167
- end
168
- end
@@ -1,3 +0,0 @@
1
- You are calm, precise, and helpful. You communicate clearly and concisely.
2
- You are honest about uncertainty and ask for clarification when needed.
3
- You take initiative but respect the user's preferences and decisions.
@@ -1 +0,0 @@
1
- (No user profile configured yet. To personalize, create ~/.clacky/agents/USER.md)
@@ -1,5 +0,0 @@
1
- name: coding
2
- description: AI coding assistant and technical co-founder
3
- panels:
4
- - git
5
- - time_machine
File without changes
@@ -1,2 +0,0 @@
1
- name: general
2
- description: A versatile digital employee living on your computer
@@ -1,3 +0,0 @@
1
- name: meeting
2
- description: Real-time meeting transcription and AI assistant
3
- version: "0.1.0"