samagotchi 0.4.0 → 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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +80 -1
  3. data/README.md +13 -2
  4. data/bin/chi +29 -39
  5. data/docs/cli.md +135 -73
  6. data/docs/configuration.md +15 -20
  7. data/docs/hooks.md +1 -1
  8. data/docs/memory.md +40 -0
  9. data/docs/plugins.md +50 -0
  10. data/docs/releasing.md +9 -6
  11. data/docs/sessions.md +3 -3
  12. data/lib/samagotchi/bootstrap/config_writer.rb +1 -2
  13. data/lib/samagotchi/bridge/sse_writer.rb +0 -3
  14. data/lib/samagotchi/bridge/turn_accumulator.rb +1 -0
  15. data/lib/samagotchi/bridge.rb +16 -11
  16. data/lib/samagotchi/bundles/skills/manifest.yml +10 -0
  17. data/lib/samagotchi/bundles/skills/plugin.rb +419 -0
  18. data/lib/samagotchi/bundles/system/config_modification_protocol.md +7 -8
  19. data/lib/samagotchi/bundles/system/identity.md +5 -0
  20. data/lib/samagotchi/bundles/system/manifest.yml +5 -5
  21. data/lib/samagotchi/bundles/system/memory_guide.md +26 -0
  22. data/lib/samagotchi/bundles/system/self_map.md +2 -1
  23. data/lib/samagotchi/client.rb +16 -20
  24. data/lib/samagotchi/config.rb +40 -100
  25. data/lib/samagotchi/engine.rb +50 -354
  26. data/lib/samagotchi/kernel_loop.rb +33 -44
  27. data/lib/samagotchi/live_versions.rb +7 -1
  28. data/lib/samagotchi/llm/errors.rb +17 -0
  29. data/lib/samagotchi/llm/http.rb +4 -18
  30. data/lib/samagotchi/llm/openai_chat.rb +17 -0
  31. data/lib/samagotchi/model_profile.rb +4 -10
  32. data/lib/samagotchi/note_command.rb +2 -1
  33. data/lib/samagotchi/reply_wait.rb +48 -4
  34. data/lib/samagotchi/self_report.rb +20 -2
  35. data/lib/samagotchi/send_command.rb +84 -6
  36. data/lib/samagotchi/session.rb +4 -2
  37. data/lib/samagotchi/session_manager.rb +18 -37
  38. data/lib/samagotchi/system_prompt.rb +403 -0
  39. data/lib/samagotchi/terminal_ui/attach_launcher.rb +5 -3
  40. data/lib/samagotchi/terminal_ui/attached_loop.rb +120 -83
  41. data/lib/samagotchi/terminal_ui/attached_view.rb +27 -12
  42. data/lib/samagotchi/terminal_ui/event_renderer.rb +23 -7
  43. data/lib/samagotchi/terminal_ui/formatting.rb +32 -22
  44. data/lib/samagotchi/terminal_ui/input_support.rb +3 -4
  45. data/lib/samagotchi/terminal_ui/plain_surface.rb +13 -7
  46. data/lib/samagotchi/terminal_ui/status_row.rb +81 -0
  47. data/lib/samagotchi/terminal_ui/surface.rb +1 -1
  48. data/lib/samagotchi/terminal_ui.rb +95 -690
  49. data/lib/samagotchi/thinking.rb +11 -0
  50. data/lib/samagotchi/tool_activity.rb +52 -2
  51. data/lib/samagotchi/tool_runner.rb +3 -0
  52. data/lib/samagotchi/tools/execute.rb +3 -3
  53. data/lib/samagotchi/tools/output_guardrails.rb +8 -7
  54. data/lib/samagotchi/tools/read.rb +4 -4
  55. data/lib/samagotchi/update_command.rb +2 -1
  56. data/lib/samagotchi/version.rb +1 -1
  57. data/lib/samagotchi/web/app.rb +170 -35
  58. data/lib/samagotchi/web/lan.rb +99 -0
  59. data/lib/samagotchi/web/message_parts.rb +15 -11
  60. data/lib/samagotchi/web/public/activity.js +7 -0
  61. data/lib/samagotchi/web/public/app.js +99 -54
  62. data/lib/samagotchi/web/public/chat_view.js +5 -1
  63. data/lib/samagotchi/web/public/index.html +163 -17
  64. data/lib/samagotchi/web/public/model_pick.js +136 -0
  65. data/lib/samagotchi/web/public/model_picker.js +224 -0
  66. data/lib/samagotchi/web/public/notify.js +10 -0
  67. data/lib/samagotchi/web/public/stage_model.js +110 -0
  68. data/lib/samagotchi/web/public/stage_view.js +580 -0
  69. data/lib/samagotchi/web/public/timing.js +6 -2
  70. data/lib/samagotchi/web/public/turn_events.js +9 -5
  71. data/lib/samagotchi/web/public/turn_model.js +11 -3
  72. data/lib/samagotchi/web/public/turn_view.js +74 -19
  73. data/lib/samagotchi/web/qr.rb +40 -0
  74. data/lib/samagotchi/web/server.rb +101 -11
  75. data/lib/samagotchi/web/token.rb +97 -0
  76. metadata +27 -3
  77. data/lib/samagotchi/terminal_ui/legacy_surface.rb +0 -111
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: samagotchi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Dedov
@@ -93,6 +93,20 @@ dependencies:
93
93
  - - ">="
94
94
  - !ruby/object:Gem::Version
95
95
  version: '0'
96
+ - !ruby/object:Gem::Dependency
97
+ name: rqrcode_core
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '2.0'
103
+ type: :runtime
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '2.0'
96
110
  description: chi is an agent harness for local and OpenAI-compatible models (llama.cpp,
97
111
  mlx, oMLX, hosted APIs). It runs sessions in a terminal REPL or in background workers
98
112
  you can attach to from the terminal and a web UI, keeps memories in plain files
@@ -154,6 +168,8 @@ files:
154
168
  - lib/samagotchi/bundles/loop-guard/plugin.rb
155
169
  - lib/samagotchi/bundles/mcp/manifest.yml
156
170
  - lib/samagotchi/bundles/mcp/plugin.rb
171
+ - lib/samagotchi/bundles/skills/manifest.yml
172
+ - lib/samagotchi/bundles/skills/plugin.rb
157
173
  - lib/samagotchi/bundles/source-links/hooks/source_links.rb
158
174
  - lib/samagotchi/bundles/source-links/manifest.yml
159
175
  - lib/samagotchi/bundles/source-links/source_links.md
@@ -271,6 +287,7 @@ files:
271
287
  - lib/samagotchi/session_metrics.rb
272
288
  - lib/samagotchi/session_observer.rb
273
289
  - lib/samagotchi/steer.rb
290
+ - lib/samagotchi/system_prompt.rb
274
291
  - lib/samagotchi/terminal_ui.rb
275
292
  - lib/samagotchi/terminal_ui/attach_launcher.rb
276
293
  - lib/samagotchi/terminal_ui/attached_loop.rb
@@ -279,7 +296,6 @@ files:
279
296
  - lib/samagotchi/terminal_ui/formatting.rb
280
297
  - lib/samagotchi/terminal_ui/image_input.rb
281
298
  - lib/samagotchi/terminal_ui/input_support.rb
282
- - lib/samagotchi/terminal_ui/legacy_surface.rb
283
299
  - lib/samagotchi/terminal_ui/line_reader.rb
284
300
  - lib/samagotchi/terminal_ui/live_region.rb
285
301
  - lib/samagotchi/terminal_ui/plain_surface.rb
@@ -288,6 +304,7 @@ files:
288
304
  - lib/samagotchi/terminal_ui/reline_seam.rb
289
305
  - lib/samagotchi/terminal_ui/repl_input.rb
290
306
  - lib/samagotchi/terminal_ui/screen.rb
307
+ - lib/samagotchi/terminal_ui/status_row.rb
291
308
  - lib/samagotchi/terminal_ui/surface.rb
292
309
  - lib/samagotchi/terminal_ui/thinking_line.rb
293
310
  - lib/samagotchi/text_diff.rb
@@ -335,6 +352,7 @@ files:
335
352
  - lib/samagotchi/vision_context.rb
336
353
  - lib/samagotchi/vision_support.rb
337
354
  - lib/samagotchi/web/app.rb
355
+ - lib/samagotchi/web/lan.rb
338
356
  - lib/samagotchi/web/markdown_renderer.rb
339
357
  - lib/samagotchi/web/message_parts.rb
340
358
  - lib/samagotchi/web/public/activity.js
@@ -356,6 +374,7 @@ files:
356
374
  - lib/samagotchi/web/public/index.html
357
375
  - lib/samagotchi/web/public/init_row.js
358
376
  - lib/samagotchi/web/public/model_pick.js
377
+ - lib/samagotchi/web/public/model_picker.js
359
378
  - lib/samagotchi/web/public/notify.js
360
379
  - lib/samagotchi/web/public/question_card.js
361
380
  - lib/samagotchi/web/public/route.js
@@ -363,6 +382,8 @@ files:
363
382
  - lib/samagotchi/web/public/scroll.js
364
383
  - lib/samagotchi/web/public/sentences.js
365
384
  - lib/samagotchi/web/public/sessions_list.js
385
+ - lib/samagotchi/web/public/stage_model.js
386
+ - lib/samagotchi/web/public/stage_view.js
366
387
  - lib/samagotchi/web/public/strip.js
367
388
  - lib/samagotchi/web/public/tally.js
368
389
  - lib/samagotchi/web/public/thinking_ticker.js
@@ -370,9 +391,11 @@ files:
370
391
  - lib/samagotchi/web/public/turn_events.js
371
392
  - lib/samagotchi/web/public/turn_model.js
372
393
  - lib/samagotchi/web/public/turn_view.js
394
+ - lib/samagotchi/web/qr.rb
373
395
  - lib/samagotchi/web/server.rb
374
396
  - lib/samagotchi/web/session_hub.rb
375
397
  - lib/samagotchi/web/session_summary.rb
398
+ - lib/samagotchi/web/token.rb
376
399
  - lib/samagotchi/worker.rb
377
400
  - lib/samagotchi/worker_idle_exit.rb
378
401
  homepage: https://github.com/dm1try/samagotchi
@@ -400,5 +423,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
400
423
  requirements: []
401
424
  rubygems_version: 3.6.9
402
425
  specification_version: 4
403
- summary: 'chi: a local-first coding agent with memory, sessions and a web UI'
426
+ summary: 'chi: a local-first, human-in-the-loop agent harness that learns memories
427
+ and skills as you work'
404
428
  test_files: []
@@ -1,111 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "io/console"
4
- require_relative "surface"
5
-
6
- module Samagotchi
7
- class TerminalUI
8
- # The REPL's Surface before the live region: plain output where the
9
- # cursor is. Only the activity slot is live. It redraws in place by
10
- # moving back up over the rows it drew last (ESC[nA), which works only
11
- # while nothing else writes below it. The editor slot prints a prompt
12
- # for a plain read, and clearing it erases the line Reline drew. The other
13
- # slots just print their rows, except status rows set together with the
14
- # activity rows (#set_slots): those are the activity block's last rows.
15
- class LegacySurface
16
- include Surface
17
-
18
- # @param out [IO, nil] nil writes to $stdout as it is at each write
19
- # (specs swap it after the UI is built)
20
- def initialize(out: nil)
21
- @out = out
22
- @activity_shown = false
23
- @activity_rows = 0
24
- end
25
-
26
- def commit(text)
27
- out.puts(text)
28
- end
29
-
30
- def set_slot(name, rows)
31
- check_slot!(name)
32
- case name
33
- when :activity then redraw_activity(rows)
34
- when :editor
35
- out.print(rows.join("\n"))
36
- out.flush
37
- else lay_out(rows, width: columns).each { |row| out.puts(row) }
38
- end
39
- end
40
-
41
- def set_slots(**rows_by_slot)
42
- return super unless rows_by_slot.key?(:activity)
43
-
44
- activity = rows_by_slot.delete(:activity)
45
- status = rows_by_slot.delete(:status)
46
- set_slot(:activity, Array(activity) + Array(status))
47
- super(**rows_by_slot)
48
- end
49
-
50
- def clear_slot(name)
51
- check_slot!(name)
52
- case name
53
- when :activity then erase_activity
54
- when :editor
55
- out.print("\r\e[2K")
56
- out.flush
57
- true
58
- else false
59
- end
60
- end
61
-
62
- private
63
-
64
- def out = @out || $stdout
65
-
66
- def columns
67
- IO.console&.winsize&.last || 80
68
- rescue StandardError
69
- 80
70
- end
71
-
72
- # Pad to the taller of the old and new heights, so rows left over from
73
- # a taller frame are blanked.
74
- def redraw_activity(rows)
75
- move_to_activity_origin
76
- row_count = [@activity_rows, rows.length].max
77
- padded = rows + Array.new(row_count - rows.length, "")
78
- out.print(padded.map { |text| "#{text}\e[0K" }.join("\n"))
79
- out.flush
80
- @activity_shown = true
81
- @activity_rows = row_count
82
- end
83
-
84
- def move_to_activity_origin
85
- return unless @activity_shown
86
-
87
- out.print("\e[#{@activity_rows - 1}A") if @activity_rows > 1
88
- out.print("\r")
89
- end
90
-
91
- def erase_activity
92
- return false unless @activity_shown
93
-
94
- row_count = @activity_rows
95
- row_count = 1 if row_count <= 0
96
- out.print("\e[#{row_count - 1}A") if row_count > 1
97
- out.print("\r")
98
- row_count.times do |index|
99
- out.print("\e[0K")
100
- out.print("\n") if index < row_count - 1
101
- end
102
- out.print("\e[#{row_count - 1}A") if row_count > 1
103
- out.print("\r")
104
- out.flush
105
- @activity_shown = false
106
- @activity_rows = 0
107
- true
108
- end
109
- end
110
- end
111
- end