scout-ai 2.0.0 → 2.2.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 (185) hide show
  1. checksums.yaml +4 -4
  2. data/.vimproject +135 -55
  3. data/README.md +2 -1
  4. data/VERSION +1 -1
  5. data/doc/Improvements.md +490 -148
  6. data/doc/Model.md +53 -10
  7. data/doc/StartHere.md +44 -19
  8. data/doc/developer/Architecture.md +25 -6
  9. data/doc/developer/Backends.md +207 -48
  10. data/doc/developer/ChatLifecycle.md +121 -20
  11. data/doc/developer/DelegationInternals.md +320 -34
  12. data/doc/developer/DesignPrinciples.md +205 -16
  13. data/doc/developer/PathEngine.md +628 -0
  14. data/doc/developer/PromptProcessing.md +332 -82
  15. data/doc/developer/Provenance.md +402 -44
  16. data/doc/developer/Sandbox.md +213 -0
  17. data/doc/user/BuildingAgents.md +130 -18
  18. data/doc/user/Cookbook.md +29 -8
  19. data/doc/user/CoreConcepts.md +7 -6
  20. data/doc/user/Delegation.md +166 -15
  21. data/doc/user/GettingStarted.md +20 -16
  22. data/doc/user/ManagingContext.md +155 -17
  23. data/doc/user/MultiAgentWorkflows.md +105 -15
  24. data/doc/user/Python.md +11 -1
  25. data/doc/user/RunningInference.md +90 -47
  26. data/doc/user/ToolCalling.md +134 -29
  27. data/doc/user/WritingChats.md +56 -27
  28. data/lib/scout/llm/agent/attach.rb +64 -0
  29. data/lib/scout/llm/agent/chat.rb +32 -0
  30. data/lib/scout/llm/agent/construction.rb +64 -0
  31. data/lib/scout/llm/agent/conversation.rb +304 -0
  32. data/lib/scout/llm/agent/delegate.rb +56 -238
  33. data/lib/scout/llm/agent/path/edit.rb +230 -0
  34. data/lib/scout/llm/agent/path/patch.rb +252 -0
  35. data/lib/scout/llm/agent/path/workflow_kinds.rb +175 -0
  36. data/lib/scout/llm/agent/path.rb +1777 -0
  37. data/lib/scout/llm/agent/save.rb +11 -9
  38. data/lib/scout/llm/agent/workflow.rb +79 -17
  39. data/lib/scout/llm/agent.rb +151 -27
  40. data/lib/scout/llm/ask.rb +37 -27
  41. data/lib/scout/llm/backends/anthropic.rb +1 -1
  42. data/lib/scout/llm/backends/bedrock.rb +3 -2
  43. data/lib/scout/llm/backends/default.rb +131 -32
  44. data/lib/scout/llm/backends/glm.rb +28 -1
  45. data/lib/scout/llm/backends/huggingface.rb +1 -1
  46. data/lib/scout/llm/backends/ollama.rb +1 -1
  47. data/lib/scout/llm/backends/openai.rb +7 -6
  48. data/lib/scout/llm/backends/openwebui.rb +14 -7
  49. data/lib/scout/llm/backends/relay.rb +8 -2
  50. data/lib/scout/llm/chat/agent_meta.rb +24 -60
  51. data/lib/scout/llm/chat/parse.rb +1 -1
  52. data/lib/scout/llm/chat/process/files.rb +10 -0
  53. data/lib/scout/llm/chat/process/meta.rb +5 -7
  54. data/lib/scout/llm/chat/process/tools.rb +104 -52
  55. data/lib/scout/llm/chat/prompt/epoch_tool_compactation.rb +355 -0
  56. data/lib/scout/llm/chat/prompt/inbox.rb +188 -0
  57. data/lib/scout/llm/chat/prompt/shorten_tools.rb +797 -13
  58. data/lib/scout/llm/chat/prompt/shorten_tools_epoch.rb +1 -365
  59. data/lib/scout/llm/chat/prompt/shorten_tools_epoch_increment.rb +1 -0
  60. data/lib/scout/llm/chat/prompt.rb +24 -10
  61. data/lib/scout/llm/chat/provenance/live.rb +1080 -0
  62. data/lib/scout/llm/chat/provenance/tokens.rb +386 -0
  63. data/lib/scout/llm/chat/provenance.rb +352 -626
  64. data/lib/scout/llm/chat.rb +8 -2
  65. data/lib/scout/llm/embed.rb +15 -3
  66. data/lib/scout/llm/image.rb +4 -1
  67. data/lib/scout/llm/mcp.rb +4 -2
  68. data/lib/scout/llm/request_context.rb +234 -0
  69. data/lib/scout/llm/sandbox.rb +263 -0
  70. data/lib/scout/llm/tools/call.rb +163 -42
  71. data/lib/scout/llm/tools/definition.rb +48 -0
  72. data/lib/scout/llm/tools/knowledge_base.rb +1 -0
  73. data/lib/scout/llm/tools/mcp.rb +50 -43
  74. data/lib/scout/llm/tools/workflow.rb +90 -20
  75. data/lib/scout/llm/tools.rb +14 -41
  76. data/lib/scout/model/decision/base.rb +43 -0
  77. data/lib/scout/model/decision/jev.rb +161 -0
  78. data/lib/scout/model/python/torch.rb +1 -1
  79. data/research/clear-tools-inherit.md +171 -0
  80. data/research/path-engine-dc1-dc2-dc3-fixes.md +279 -0
  81. data/research/path-kind-chat-role.md +96 -0
  82. data/research/path-kind-contract-fixes-engine.md +307 -0
  83. data/research/scout-ai-runtime-availability.md +65 -0
  84. data/research/subsys/README.md +127 -0
  85. data/research/subsys/agent-delegation.md +201 -0
  86. data/research/subsys/agent-society.md +275 -0
  87. data/research/subsys/agentworkflow.md +233 -0
  88. data/research/subsys/backends.md +221 -0
  89. data/research/subsys/chat.md +314 -0
  90. data/research/subsys/embed-image.md +244 -0
  91. data/research/subsys/entry-cli.md +253 -0
  92. data/research/subsys/model-ml.md +326 -0
  93. data/research/subsys/provenance.md +290 -0
  94. data/research/subsys/tools.md +334 -0
  95. data/scout-ai.gemspec +72 -26
  96. data/scout_commands/agent/ask +8 -7
  97. data/scout_commands/llm/abridged +40 -0
  98. data/scout_commands/llm/ask +9 -9
  99. data/scout_commands/llm/md +2 -0
  100. data/scout_commands/llm/prov +845 -80
  101. data/scout_commands/llm/word +4 -0
  102. data/share/word/reference.docx +0 -0
  103. data/test/integration/scout/model/decision/test_jev.rb +144 -0
  104. data/test/scout/llm/agent/test_attach.rb +117 -0
  105. data/test/scout/llm/agent/test_conversation.rb +407 -0
  106. data/test/scout/llm/agent/test_delegate.rb +209 -0
  107. data/test/scout/llm/agent/test_path.rb +1812 -0
  108. data/test/scout/llm/agent/test_path_edit.rb +908 -0
  109. data/test/scout/llm/agent/test_path_errors.rb +390 -0
  110. data/test/scout/llm/agent/test_path_filesystem.rb +532 -0
  111. data/test/scout/llm/agent/test_path_patch.rb +233 -0
  112. data/test/scout/llm/agent/test_path_promotion.rb +386 -0
  113. data/test/scout/llm/agent/test_path_workflow_integration.rb +665 -0
  114. data/test/scout/llm/agent/test_save.rb +70 -15
  115. data/test/scout/llm/agent/test_workflow.rb +130 -4
  116. data/test/scout/llm/backends/test_anthropic.rb +4 -4
  117. data/test/scout/llm/backends/test_bedrock.rb +4 -4
  118. data/test/scout/llm/backends/test_format_other.rb +43 -0
  119. data/test/scout/llm/backends/test_ollama.rb +2 -2
  120. data/test/scout/llm/backends/test_openwebui.rb +12 -8
  121. data/test/scout/llm/backends/test_reasoning.rb +114 -0
  122. data/test/scout/llm/chat/agent_meta_fixtures.rb +109 -22
  123. data/test/scout/llm/chat/prompt/test_epoch_tool_compactation.rb +612 -0
  124. data/test/scout/llm/chat/prov_plot_fixtures.rb +131 -0
  125. data/test/scout/llm/chat/test_agent_meta.rb +40 -80
  126. data/test/scout/llm/chat/test_agent_meta_provenance.rb +200 -28
  127. data/test/scout/llm/chat/test_agent_meta_tokens.rb +112 -7
  128. data/test/scout/llm/chat/test_agent_view.rb +178 -0
  129. data/test/scout/llm/chat/test_live_report.rb +282 -0
  130. data/test/scout/llm/chat/test_live_workload.rb +193 -0
  131. data/test/scout/llm/chat/test_parse.rb +32 -2
  132. data/test/scout/llm/chat/test_prompt.rb +411 -0
  133. data/test/scout/llm/chat/test_prov_cli.rb +708 -13
  134. data/test/scout/llm/chat/test_prov_cli_live.rb +152 -0
  135. data/test/scout/llm/chat/test_prov_plot.rb +213 -0
  136. data/test/scout/llm/chat/test_prov_timeline.rb +355 -0
  137. data/test/scout/llm/chat/test_provenance.rb +67 -22
  138. data/test/scout/llm/chat/test_provenance_index.rb +479 -0
  139. data/test/scout/llm/chat/test_society_view.rb +159 -0
  140. data/test/scout/llm/test_agent.rb +1 -1
  141. data/test/scout/llm/test_embed.rb +103 -1
  142. data/test/scout/llm/test_request_context.rb +299 -0
  143. data/test/scout/llm/test_sandbox.rb +249 -0
  144. data/test/scout/llm/tools/test_agent_pairing.rb +150 -0
  145. data/test/scout/llm/tools/test_call_delegation_conflict.rb +316 -0
  146. data/test/scout/llm/tools/test_definition.rb +332 -0
  147. data/test/scout/llm/tools/test_jobs_file.rb +211 -0
  148. data/test/scout/llm/tools/test_mcp.rb +37 -8
  149. data/test/scout/llm/tools/test_workflow.rb +45 -1
  150. data/test/scout/model/decision/test_jev.rb +453 -0
  151. data/test/scout/model/python/huggingface/causal/test_next_token.rb +7 -10
  152. data/test/scout/model/python/huggingface/test_causal.rb +11 -2
  153. data/test/scout/model/python/huggingface/test_classification.rb +5 -3
  154. data/test/scout/model/python/test_availability.rb +116 -0
  155. data/test/scout/model/python/test_torch.rb +54 -2
  156. data/test/support/availability.rb +72 -174
  157. data/test/support/fake_clients.rb +18 -9
  158. data/test/support/fixtures.rb +75 -6
  159. data/test/support/mock_backend.rb +9 -1
  160. data/test/support/test_fixtures.rb +156 -0
  161. data/test/test_helper.rb +14 -4
  162. metadata +71 -25
  163. data/research/ChatAnalyst-required-changes.md +0 -167
  164. data/research/agent-delegation-analysis.md +0 -810
  165. data/research/agent-meta-provenance-integration-plan.md +0 -622
  166. data/research/agent-workflow-analysis.md +0 -1120
  167. data/research/backends-analysis.md +0 -836
  168. data/research/chat-core-analysis.md +0 -946
  169. data/research/chatanalyst-provenance/00-baseline.md +0 -30
  170. data/research/chatanalyst-provenance/01-repo-map.md +0 -60
  171. data/research/chatanalyst-provenance/02-event-reconstruction.md +0 -55
  172. data/research/chatanalyst-provenance/03-duplication-evidence.md +0 -45
  173. data/research/chatanalyst-provenance/04-tooling-root-cause.md +0 -57
  174. data/research/chatanalyst-provenance/05-fix-plan.md +0 -46
  175. data/research/chatanalyst-provenance/07-critic-review.md +0 -25
  176. data/research/chatanalyst-provenance/final-report.md +0 -45
  177. data/research/chatanalyst-provenance/resumption.md +0 -37
  178. data/research/coding-philosophy-analysis.md +0 -928
  179. data/research/commands-analysis.md +0 -947
  180. data/research/multi-agent-patterns-analysis.md +0 -853
  181. data/research/prompt-strategies-analysis.md +0 -630
  182. data/research/prov-verbosity-fix-notes.md +0 -77
  183. data/research/provenance-analysis.md +0 -469
  184. data/research/synthesis-report.md +0 -487
  185. data/research/tools-system-analysis.md +0 -779
data/scout-ai.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: scout-ai 2.0.0 ruby lib
5
+ # stub: scout-ai 2.2.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "scout-ai".freeze
9
- s.version = "2.0.0".freeze
9
+ s.version = "2.2.0".freeze
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
@@ -37,8 +37,10 @@ Gem::Specification.new do |s|
37
37
  "doc/developer/ChatLifecycle.md",
38
38
  "doc/developer/DelegationInternals.md",
39
39
  "doc/developer/DesignPrinciples.md",
40
+ "doc/developer/PathEngine.md",
40
41
  "doc/developer/PromptProcessing.md",
41
42
  "doc/developer/Provenance.md",
43
+ "doc/developer/Sandbox.md",
42
44
  "doc/user/BuildingAgents.md",
43
45
  "doc/user/Cookbook.md",
44
46
  "doc/user/CoreConcepts.md",
@@ -52,9 +54,16 @@ Gem::Specification.new do |s|
52
54
  "doc/user/WritingChats.md",
53
55
  "lib/scout-ai.rb",
54
56
  "lib/scout/llm/agent.rb",
57
+ "lib/scout/llm/agent/attach.rb",
55
58
  "lib/scout/llm/agent/chat.rb",
59
+ "lib/scout/llm/agent/construction.rb",
60
+ "lib/scout/llm/agent/conversation.rb",
56
61
  "lib/scout/llm/agent/delegate.rb",
57
62
  "lib/scout/llm/agent/iterate.rb",
63
+ "lib/scout/llm/agent/path.rb",
64
+ "lib/scout/llm/agent/path/edit.rb",
65
+ "lib/scout/llm/agent/path/patch.rb",
66
+ "lib/scout/llm/agent/path/workflow_kinds.rb",
58
67
  "lib/scout/llm/agent/save.rb",
59
68
  "lib/scout/llm/agent/workflow.rb",
60
69
  "lib/scout/llm/ask.rb",
@@ -81,21 +90,31 @@ Gem::Specification.new do |s|
81
90
  "lib/scout/llm/chat/process/options.rb",
82
91
  "lib/scout/llm/chat/process/tools.rb",
83
92
  "lib/scout/llm/chat/prompt.rb",
93
+ "lib/scout/llm/chat/prompt/epoch_tool_compactation.rb",
94
+ "lib/scout/llm/chat/prompt/inbox.rb",
84
95
  "lib/scout/llm/chat/prompt/shorten_tools.rb",
85
96
  "lib/scout/llm/chat/prompt/shorten_tools_epoch.rb",
97
+ "lib/scout/llm/chat/prompt/shorten_tools_epoch_increment.rb",
86
98
  "lib/scout/llm/chat/provenance.rb",
99
+ "lib/scout/llm/chat/provenance/live.rb",
100
+ "lib/scout/llm/chat/provenance/tokens.rb",
87
101
  "lib/scout/llm/chat/tool_calls.rb",
88
102
  "lib/scout/llm/embed.rb",
89
103
  "lib/scout/llm/image.rb",
90
104
  "lib/scout/llm/mcp.rb",
91
105
  "lib/scout/llm/rag.rb",
106
+ "lib/scout/llm/request_context.rb",
107
+ "lib/scout/llm/sandbox.rb",
92
108
  "lib/scout/llm/tools.rb",
93
109
  "lib/scout/llm/tools/call.rb",
110
+ "lib/scout/llm/tools/definition.rb",
94
111
  "lib/scout/llm/tools/knowledge_base.rb",
95
112
  "lib/scout/llm/tools/mcp.rb",
96
113
  "lib/scout/llm/tools/workflow.rb",
97
114
  "lib/scout/llm/utils.rb",
98
115
  "lib/scout/model/base.rb",
116
+ "lib/scout/model/decision/base.rb",
117
+ "lib/scout/model/decision/jev.rb",
99
118
  "lib/scout/model/python/base.rb",
100
119
  "lib/scout/model/python/huggingface.rb",
101
120
  "lib/scout/model/python/huggingface/causal.rb",
@@ -131,34 +150,28 @@ Gem::Specification.new do |s|
131
150
  "python/tests/test_chat_agent.py",
132
151
  "python/tests/test_huggingface_eval.py",
133
152
  "python/tests/test_runner.py",
134
- "research/ChatAnalyst-required-changes.md",
135
- "research/agent-delegation-analysis.md",
136
- "research/agent-meta-provenance-integration-plan.md",
137
- "research/agent-workflow-analysis.md",
138
- "research/backends-analysis.md",
139
- "research/chat-core-analysis.md",
140
- "research/chatanalyst-provenance/00-baseline.md",
141
- "research/chatanalyst-provenance/01-repo-map.md",
142
- "research/chatanalyst-provenance/02-event-reconstruction.md",
143
- "research/chatanalyst-provenance/03-duplication-evidence.md",
144
- "research/chatanalyst-provenance/04-tooling-root-cause.md",
145
- "research/chatanalyst-provenance/05-fix-plan.md",
146
- "research/chatanalyst-provenance/07-critic-review.md",
147
- "research/chatanalyst-provenance/final-report.md",
148
- "research/chatanalyst-provenance/resumption.md",
149
- "research/coding-philosophy-analysis.md",
150
- "research/commands-analysis.md",
151
- "research/multi-agent-patterns-analysis.md",
152
- "research/prompt-strategies-analysis.md",
153
- "research/prov-verbosity-fix-notes.md",
154
- "research/provenance-analysis.md",
153
+ "research/clear-tools-inherit.md",
154
+ "research/path-engine-dc1-dc2-dc3-fixes.md",
155
+ "research/path-kind-chat-role.md",
156
+ "research/path-kind-contract-fixes-engine.md",
155
157
  "research/provenance-navigation-design.md",
156
- "research/synthesis-report.md",
157
- "research/tools-system-analysis.md",
158
+ "research/scout-ai-runtime-availability.md",
159
+ "research/subsys/README.md",
160
+ "research/subsys/agent-delegation.md",
161
+ "research/subsys/agent-society.md",
162
+ "research/subsys/agentworkflow.md",
163
+ "research/subsys/backends.md",
164
+ "research/subsys/chat.md",
165
+ "research/subsys/embed-image.md",
166
+ "research/subsys/entry-cli.md",
167
+ "research/subsys/model-ml.md",
168
+ "research/subsys/provenance.md",
169
+ "research/subsys/tools.md",
158
170
  "scout-ai.gemspec",
159
171
  "scout_commands/agent/ask",
160
172
  "scout_commands/agent/find",
161
173
  "scout_commands/agent/kb",
174
+ "scout_commands/llm/abridged",
162
175
  "scout_commands/llm/ask",
163
176
  "scout_commands/llm/json",
164
177
  "scout_commands/llm/md",
@@ -196,41 +209,73 @@ Gem::Specification.new do |s|
196
209
  "test/integration/scout/llm/test_infrastructure.rb",
197
210
  "test/integration/scout/llm/test_mcp.rb",
198
211
  "test/integration/scout/llm/tools/test_mcp.rb",
212
+ "test/integration/scout/model/decision/test_jev.rb",
199
213
  "test/integration/scout/model/test_base.rb",
214
+ "test/scout/llm/agent/test_attach.rb",
200
215
  "test/scout/llm/agent/test_chat.rb",
216
+ "test/scout/llm/agent/test_conversation.rb",
217
+ "test/scout/llm/agent/test_delegate.rb",
218
+ "test/scout/llm/agent/test_path.rb",
219
+ "test/scout/llm/agent/test_path_edit.rb",
220
+ "test/scout/llm/agent/test_path_errors.rb",
221
+ "test/scout/llm/agent/test_path_filesystem.rb",
222
+ "test/scout/llm/agent/test_path_patch.rb",
223
+ "test/scout/llm/agent/test_path_promotion.rb",
224
+ "test/scout/llm/agent/test_path_workflow_integration.rb",
201
225
  "test/scout/llm/agent/test_save.rb",
202
226
  "test/scout/llm/agent/test_workflow.rb",
203
227
  "test/scout/llm/backends/test_anthropic.rb",
204
228
  "test/scout/llm/backends/test_bedrock.rb",
229
+ "test/scout/llm/backends/test_format_other.rb",
205
230
  "test/scout/llm/backends/test_huggingface.rb",
206
231
  "test/scout/llm/backends/test_ollama.rb",
207
232
  "test/scout/llm/backends/test_openwebui.rb",
233
+ "test/scout/llm/backends/test_reasoning.rb",
208
234
  "test/scout/llm/backends/test_relay.rb",
209
235
  "test/scout/llm/chat/agent_meta_fixtures.rb",
210
236
  "test/scout/llm/chat/process/test_meta.rb",
211
237
  "test/scout/llm/chat/process/test_normalize_usage.rb",
238
+ "test/scout/llm/chat/prompt/test_epoch_tool_compactation.rb",
239
+ "test/scout/llm/chat/prov_plot_fixtures.rb",
212
240
  "test/scout/llm/chat/test_agent_meta.rb",
213
241
  "test/scout/llm/chat/test_agent_meta_provenance.rb",
214
242
  "test/scout/llm/chat/test_agent_meta_tokens.rb",
243
+ "test/scout/llm/chat/test_agent_view.rb",
244
+ "test/scout/llm/chat/test_live_report.rb",
245
+ "test/scout/llm/chat/test_live_workload.rb",
215
246
  "test/scout/llm/chat/test_parse.rb",
216
247
  "test/scout/llm/chat/test_process.rb",
248
+ "test/scout/llm/chat/test_prompt.rb",
217
249
  "test/scout/llm/chat/test_prov_cli.rb",
250
+ "test/scout/llm/chat/test_prov_cli_live.rb",
251
+ "test/scout/llm/chat/test_prov_plot.rb",
252
+ "test/scout/llm/chat/test_prov_timeline.rb",
218
253
  "test/scout/llm/chat/test_provenance.rb",
254
+ "test/scout/llm/chat/test_provenance_index.rb",
255
+ "test/scout/llm/chat/test_society_view.rb",
219
256
  "test/scout/llm/chat/test_tool_calls.rb",
220
257
  "test/scout/llm/test_agent.rb",
221
258
  "test/scout/llm/test_ask.rb",
222
259
  "test/scout/llm/test_chat.rb",
223
260
  "test/scout/llm/test_embed.rb",
224
261
  "test/scout/llm/test_rag.rb",
262
+ "test/scout/llm/test_request_context.rb",
263
+ "test/scout/llm/test_sandbox.rb",
225
264
  "test/scout/llm/test_tools.rb",
226
265
  "test/scout/llm/test_utils.rb",
266
+ "test/scout/llm/tools/test_agent_pairing.rb",
227
267
  "test/scout/llm/tools/test_call.rb",
268
+ "test/scout/llm/tools/test_call_delegation_conflict.rb",
269
+ "test/scout/llm/tools/test_definition.rb",
270
+ "test/scout/llm/tools/test_jobs_file.rb",
228
271
  "test/scout/llm/tools/test_knowledge_base.rb",
229
272
  "test/scout/llm/tools/test_mcp.rb",
230
273
  "test/scout/llm/tools/test_workflow.rb",
274
+ "test/scout/model/decision/test_jev.rb",
231
275
  "test/scout/model/python/huggingface/causal/test_next_token.rb",
232
276
  "test/scout/model/python/huggingface/test_causal.rb",
233
277
  "test/scout/model/python/huggingface/test_classification.rb",
278
+ "test/scout/model/python/test_availability.rb",
234
279
  "test/scout/model/python/test_base.rb",
235
280
  "test/scout/model/python/test_huggingface.rb",
236
281
  "test/scout/model/python/test_torch.rb",
@@ -245,11 +290,12 @@ Gem::Specification.new do |s|
245
290
  "test/support/fixtures.rb",
246
291
  "test/support/infrastructure_probes.rb",
247
292
  "test/support/mock_backend.rb",
293
+ "test/support/test_fixtures.rb",
248
294
  "test/test_helper.rb"
249
295
  ]
250
296
  s.homepage = "http://github.com/mikisvaz/scout-ai".freeze
251
297
  s.licenses = ["MIT".freeze]
252
- s.rubygems_version = "3.7.2".freeze
298
+ s.rubygems_version = "4.0.23".freeze
253
299
  s.summary = "AI gear for scouts".freeze
254
300
 
255
301
  s.specification_version = 4
@@ -81,11 +81,14 @@ elsif file
81
81
  end
82
82
 
83
83
  if chat
84
+ request_context = {main_chat: chat}
85
+
84
86
  conversation = Open.exist?(chat)? LLM.chat(chat) : Chat.setup([])
85
87
  conversation.message :tool, workflow if workflow
86
88
 
87
89
  convo_options = LLM.options conversation
88
90
  agent.start
91
+ agent.request_context = agent.request_context.nil? ? request_context : agent.request_context.merge!(request_context)
89
92
  agent.follow(Chat.setup(conversation)) if conversation.any?
90
93
  agent.current_chat.concat LLM.chat(question) if question && ! question.empty?
91
94
  imports.each{|import| agent.import import } if imports
@@ -95,13 +98,11 @@ if chat
95
98
  exit 0
96
99
  end
97
100
 
98
- # ScoutCoder: named-file rule, same as AgentWorkflow#log_agent: the agent
99
- # chat is named after the agent ('agent.chat' by default, but
100
- # worker.chat/critic.chat when the CLI is invoked for a named agent), and
101
- # the society tree is the sibling <name>.society (see
102
- # LLM::Agent.society_dir_for). Must be set before the first chat call so
103
- # the Agent#chat ensure-hook and the restart snapshot see it.
104
- agent.save_file = chat + ".files/#{agent_name || 'agent'}.chat"
101
+ # Must be set before the first chat call so the Agent#chat ensure-hook
102
+ # and the restart snapshot see it. The layout rule (agent chat named after
103
+ # the agent, society tree as sibling <name>.society) is owned by
104
+ # LLM::Agent.canonical_chat_file / LLM::Agent.society_dir_for.
105
+ agent.save_file = LLM::Agent.canonical_chat_file(chat + '.files', agent_name)
105
106
  #new = agent.ask(agent.current_chat, convo_options.merge(options.merge(return_messages: true)))
106
107
  new = agent.chat(convo_options.merge(options.merge(return_messages: true)))
107
108
  conversation += LLM.chat(question) if question
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'scout'
5
+
6
+ cmd = $previous_commands ?
7
+ "scout #{$previous_commands.any? ? "#{$previous_commands * ' '} " : ''}#{File.basename(__FILE__)}" :
8
+ $PROGRAM_NAME
9
+
10
+ options = SOPT.setup <<~EOF
11
+
12
+ Shorten a chat file by abridging tools
13
+
14
+ $ #{cmd} [<options>] <chat> <markdown>
15
+
16
+ -h--help Print this help
17
+ -l--last Format only the last interaction
18
+ EOF
19
+ if options[:help]
20
+ if defined? scout_usage
21
+ scout_usage
22
+ else
23
+ puts SOPT.doc
24
+ end
25
+ exit 0
26
+ end
27
+
28
+ help, last = IndiferentHash.process_options options, :help, :last
29
+
30
+ chat, output, _ = ARGV
31
+
32
+ raise MissingParameterException, :chat if chat.nil?
33
+
34
+ messages = Chat.parse Open.read(chat)
35
+ messages = Chat.epoch_tool_compactation(messages,
36
+ threshold: 0, full: 0, base_compacted: 20, initial_size: 20,
37
+ epochs_per_increase: nil, size_increase: nil, repeat_increase: nil,
38
+ configured_max_size: nil, compacted_growth_ratio: 0, configured_max_compacted: nil)
39
+ puts Chat.print messages
40
+
@@ -75,6 +75,8 @@ elsif file
75
75
  end
76
76
 
77
77
  if chat
78
+ request_context = {main_chat: chat}
79
+
78
80
  conversation = Open.exist?(chat)? Chat.load(chat) : Chat.setup([])
79
81
  imports.each{|import| conversation.import import } if imports
80
82
  convo_options = LLM.options conversation
@@ -88,14 +90,12 @@ if chat
88
90
  exit 0
89
91
  end
90
92
 
91
- # ScoutCoder: named-file rule (AgentWorkflow#log_agent parity): the agent
92
- # chat of this CLI conversation lands at <chat>.files/agent.chat, with the
93
- # society tree at <chat>.files/agent.society (LLM::Agent.society_dir_for).
94
- # This CLI has no agent option, so the name is always 'agent'; the
95
- # `agent_save_file` option forwarded to LLM.ask is this very value and is
96
- # honored verbatim by lib/scout/llm/ask.rb.
97
- agent_save_file = chat + '.files/agent.chat'
98
- new = LLM.ask(conversation, convo_options.merge(options.merge(return_messages: true, agent_save_file: agent_save_file)))
93
+ # The `agent_save_file` option forwarded to LLM.ask is this very value and
94
+ # is honored verbatim by lib/scout/llm/ask.rb. This CLI has no agent
95
+ # option, so the name is always 'agent'; the layout rule is owned by
96
+ # LLM::Agent.canonical_chat_file.
97
+ agent_save_file = LLM::Agent.canonical_chat_file(chat + '.files')
98
+ new = LLM.ask(conversation, convo_options.merge(options.merge(return_messages: true, agent_save_file: agent_save_file).merge(request_context: request_context)))
99
99
  Open.open(chat, mode: 'a') do |f|
100
100
  f.puts LLM.print([{role: :user, content: question}]) unless question.empty?
101
101
  f.puts LLM.print(new)
@@ -125,7 +125,7 @@ elsif inline
125
125
 
126
126
  imports.each{|import| chat.import import } if imports
127
127
 
128
- response = LLM.ask(LLM.chat(chat))
128
+ response = LLM.ask(LLM.chat(chat), request_context: request_context)
129
129
  new_file << <<-EOF
130
130
  # Response start
131
131
  #{response}
@@ -61,6 +61,8 @@ messages.each do |message|
61
61
  #{message['content']}
62
62
 
63
63
  EOF
64
+ when 'file', 'last', 'continue', 'import', 'pdf', 'image', 'attach', 'tool', 'introduce', 'agent', 'endpoint'
65
+ out.push "#{message['role']}: #{Log.fingerprint message['content']}"
64
66
  else
65
67
  next
66
68
  end