scout-ai 1.2.3 → 2.0.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.
- checksums.yaml +4 -4
- data/.vimproject +138 -50
- data/README.md +171 -290
- data/Rakefile +17 -1
- data/VERSION +1 -1
- data/doc/Improvements.md +325 -0
- data/doc/StartHere.md +110 -0
- data/doc/developer/Architecture.md +126 -0
- data/doc/developer/Backends.md +199 -0
- data/doc/developer/ChatLifecycle.md +183 -0
- data/doc/developer/DelegationInternals.md +295 -0
- data/doc/developer/DesignPrinciples.md +245 -0
- data/doc/developer/PromptProcessing.md +292 -0
- data/doc/developer/Provenance.md +317 -0
- data/doc/user/BuildingAgents.md +345 -0
- data/doc/user/Cookbook.md +333 -0
- data/doc/user/CoreConcepts.md +181 -0
- data/doc/user/Delegation.md +191 -0
- data/doc/user/GettingStarted.md +159 -0
- data/doc/user/ManagingContext.md +163 -0
- data/doc/user/MultiAgentWorkflows.md +256 -0
- data/doc/user/Python.md +159 -0
- data/doc/user/RunningInference.md +200 -0
- data/doc/user/ToolCalling.md +193 -0
- data/doc/user/WritingChats.md +197 -0
- data/lib/scout/llm/agent/chat.rb +61 -11
- data/lib/scout/llm/agent/delegate.rb +274 -65
- data/lib/scout/llm/agent/iterate.rb +2 -2
- data/lib/scout/llm/agent/save.rb +273 -0
- data/lib/scout/llm/agent/workflow.rb +164 -0
- data/lib/scout/llm/agent.rb +86 -61
- data/lib/scout/llm/ask.rb +62 -17
- data/lib/scout/llm/backends/anthropic.rb +9 -2
- data/lib/scout/llm/backends/bedrock.rb +15 -3
- data/lib/scout/llm/backends/default.rb +183 -99
- data/lib/scout/llm/backends/glm.rb +58 -0
- data/lib/scout/llm/backends/huggingface.rb +196 -26
- data/lib/scout/llm/backends/ollama.rb +13 -1
- data/lib/scout/llm/backends/openai.rb +0 -2
- data/lib/scout/llm/backends/openwebui.rb +20 -13
- data/lib/scout/llm/backends/relay.rb +22 -22
- data/lib/scout/llm/backends/responses.rb +1 -1
- data/lib/scout/llm/chat/agent_meta.rb +264 -0
- data/lib/scout/llm/chat/annotation.rb +39 -10
- data/lib/scout/llm/chat/parse.rb +28 -6
- data/lib/scout/llm/chat/persist.rb +25 -0
- data/lib/scout/llm/chat/process/clear.rb +41 -6
- data/lib/scout/llm/chat/process/files.rb +21 -6
- data/lib/scout/llm/chat/process/meta.rb +421 -34
- data/lib/scout/llm/chat/process/options.rb +21 -1
- data/lib/scout/llm/chat/process/tools.rb +56 -15
- data/lib/scout/llm/chat/process.rb +4 -0
- data/lib/scout/llm/chat/prompt/shorten_tools.rb +125 -0
- data/lib/scout/llm/chat/prompt/shorten_tools_epoch.rb +365 -0
- data/lib/scout/llm/chat/prompt.rb +48 -0
- data/lib/scout/llm/chat/provenance.rb +775 -0
- data/lib/scout/llm/chat/tool_calls.rb +76 -0
- data/lib/scout/llm/chat.rb +18 -2
- data/lib/scout/llm/embed.rb +11 -3
- data/lib/scout/llm/image.rb +86 -0
- data/lib/scout/llm/mcp.rb +10 -2
- data/lib/scout/llm/rag.rb +3 -3
- data/lib/scout/llm/tools/call.rb +160 -11
- data/lib/scout/llm/tools/knowledge_base.rb +1 -1
- data/lib/scout/llm/tools/workflow.rb +32 -16
- data/lib/scout/model/python/huggingface/causal.rb +23 -5
- data/lib/scout/model/python/huggingface.rb +2 -1
- data/lib/scout-ai.rb +1 -0
- data/python/README.md +197 -14
- data/python/scout_ai/huggingface/eval.py +245 -34
- data/python/tests/test_huggingface_eval.py +58 -0
- data/research/ChatAnalyst-required-changes.md +167 -0
- data/research/agent-delegation-analysis.md +810 -0
- data/research/agent-meta-provenance-integration-plan.md +622 -0
- data/research/agent-workflow-analysis.md +1120 -0
- data/research/backends-analysis.md +836 -0
- data/research/chat-core-analysis.md +946 -0
- data/research/chatanalyst-provenance/00-baseline.md +30 -0
- data/research/chatanalyst-provenance/01-repo-map.md +60 -0
- data/research/chatanalyst-provenance/02-event-reconstruction.md +55 -0
- data/research/chatanalyst-provenance/03-duplication-evidence.md +45 -0
- data/research/chatanalyst-provenance/04-tooling-root-cause.md +57 -0
- data/research/chatanalyst-provenance/05-fix-plan.md +46 -0
- data/research/chatanalyst-provenance/07-critic-review.md +25 -0
- data/research/chatanalyst-provenance/final-report.md +45 -0
- data/research/chatanalyst-provenance/resumption.md +37 -0
- data/research/coding-philosophy-analysis.md +928 -0
- data/research/commands-analysis.md +947 -0
- data/research/multi-agent-patterns-analysis.md +853 -0
- data/research/prompt-strategies-analysis.md +630 -0
- data/research/prov-verbosity-fix-notes.md +77 -0
- data/research/provenance-analysis.md +469 -0
- data/research/provenance-navigation-design.md +640 -0
- data/research/synthesis-report.md +487 -0
- data/research/tools-system-analysis.md +779 -0
- data/scout-ai.gemspec +100 -11
- data/scout_commands/agent/ask +13 -3
- data/scout_commands/agent/kb +2 -0
- data/scout_commands/llm/ask +11 -4
- data/scout_commands/llm/md +76 -0
- data/scout_commands/llm/process_queries +48 -0
- data/scout_commands/llm/prov +602 -0
- data/scout_commands/llm/word +71 -0
- data/scout_commands/workflow/mcp +43 -0
- data/share/word/reference.docx +0 -0
- data/test/etc/AI/mock.yaml +11 -0
- data/test/fixtures/backends/anthropic.json +19 -0
- data/test/fixtures/backends/anthropic_tool_use.json +24 -0
- data/test/fixtures/backends/bedrock.json +8 -0
- data/test/fixtures/backends/bedrock_embedding.json +3 -0
- data/test/fixtures/backends/bedrock_tool_use.json +17 -0
- data/test/fixtures/backends/ollama.json +16 -0
- data/test/fixtures/backends/ollama_tool_call.json +27 -0
- data/test/fixtures/backends/openai_chat.json +21 -0
- data/test/fixtures/backends/openai_chat_tool_call.json +31 -0
- data/test/fixtures/backends/responses.json +33 -0
- data/test/fixtures/backends/responses_tool_call.json +28 -0
- data/test/integration/README.md +32 -0
- data/test/integration/scout/llm/backends/test_endpoints.rb +34 -0
- data/test/integration/scout/llm/backends/test_openwebui.rb +61 -0
- data/test/integration/scout/llm/backends/test_relay.rb +52 -0
- data/test/integration/scout/llm/test_infrastructure.rb +74 -0
- data/test/{scout → integration/scout}/llm/test_mcp.rb +1 -1
- data/test/integration/scout/llm/tools/test_mcp.rb +42 -0
- data/test/integration/scout/model/test_base.rb +91 -0
- data/test/scout/llm/agent/test_chat.rb +8 -2
- data/test/scout/llm/agent/test_save.rb +413 -0
- data/test/scout/llm/agent/test_workflow.rb +110 -0
- data/test/scout/llm/backends/test_anthropic.rb +93 -10
- data/test/scout/llm/backends/test_bedrock.rb +118 -2
- data/test/scout/llm/backends/test_huggingface.rb +137 -42
- data/test/scout/llm/backends/test_ollama.rb +70 -20
- data/test/scout/llm/backends/test_openwebui.rb +42 -40
- data/test/scout/llm/backends/test_relay.rb +4 -2
- data/test/scout/llm/chat/agent_meta_fixtures.rb +131 -0
- data/test/scout/llm/chat/process/test_meta.rb +518 -0
- data/test/scout/llm/chat/process/test_normalize_usage.rb +183 -0
- data/test/scout/llm/chat/test_agent_meta.rb +357 -0
- data/test/scout/llm/chat/test_agent_meta_provenance.rb +467 -0
- data/test/scout/llm/chat/test_agent_meta_tokens.rb +594 -0
- data/test/scout/llm/chat/test_parse.rb +70 -15
- data/test/scout/llm/chat/test_prov_cli.rb +274 -0
- data/test/scout/llm/chat/test_provenance.rb +240 -0
- data/test/scout/llm/chat/test_tool_calls.rb +38 -0
- data/test/scout/llm/test_agent.rb +13 -36
- data/test/scout/llm/test_ask.rb +75 -52
- data/test/scout/llm/test_chat.rb +107 -13
- data/test/scout/llm/test_embed.rb +48 -0
- data/test/scout/llm/test_rag.rb +23 -16
- data/test/scout/llm/test_tools.rb +12 -1
- data/test/scout/llm/tools/test_knowledge_base.rb +0 -1
- data/test/scout/llm/tools/test_mcp.rb +5 -3
- data/test/scout/llm/tools/test_workflow.rb +23 -2
- data/test/scout/model/python/huggingface/causal/test_next_token.rb +11 -5
- data/test/scout/model/python/huggingface/test_causal.rb +9 -3
- data/test/scout/model/python/huggingface/test_classification.rb +11 -2
- data/test/scout/model/python/test_torch.rb +2 -0
- data/test/scout/model/python/torch/test_helpers.rb +4 -0
- data/test/scout/model/test_base.rb +4 -2
- data/test/support/availability.rb +231 -0
- data/test/support/fake_clients.rb +138 -0
- data/test/support/fixtures.rb +21 -0
- data/test/support/infrastructure_probes.rb +136 -0
- data/test/support/mock_backend.rb +215 -0
- data/test/test_helper.rb +32 -2
- metadata +99 -10
- data/doc/Agent.md +0 -327
- data/doc/Chat.md +0 -458
- data/doc/LLM.md +0 -340
- data/doc/RAG.md +0 -129
- data/scout_commands/documenter +0 -148
- data/test/scout/llm/backends/test_openai.rb +0 -192
- data/test/scout/llm/backends/test_responses.rb +0 -238
- data/test/scout/llm/test_parse.rb +0 -98
|
@@ -0,0 +1,947 @@
|
|
|
1
|
+
> **Disclaimer:** This is an architectural investigation, not normative
|
|
2
|
+
> documentation. It was produced during a documentation-revamp effort and may
|
|
3
|
+
> be outdated relative to the current codebase. Treat it as supporting
|
|
4
|
+
> reference material. For maintained documentation, see
|
|
5
|
+
> [../../doc/](../../doc/).
|
|
6
|
+
>
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# CLI Commands: LLM / Agent / Chat System
|
|
10
|
+
|
|
11
|
+
> **Scope:** Every command under `scout_commands/` that relates to the
|
|
12
|
+
> LLM, agent, chat, or MCP system. Each command is documented for purpose,
|
|
13
|
+
> arguments/options, usage examples, library APIs called, and an assessment
|
|
14
|
+
> of its currency (current vs. deprecated/outdated).
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Command Inventory (Quick-Reference Table)
|
|
19
|
+
|
|
20
|
+
| Command | Path | Purpose | Last Commit | Status |
|
|
21
|
+
|---|---|---|---|---|
|
|
22
|
+
| `scout-ai llm ask` | `scout_commands/llm/ask` | Ask an LLM a single question (with file/chat/template support) | 2026-05-19 | ✅ Current |
|
|
23
|
+
| `scout-ai llm info` | `scout_commands/llm/info` | Inspect chat provenance graph, jobs, tokens, flow visualization | 2026-07-20 | ✅ Current (recommended) |
|
|
24
|
+
| `scout-ai llm prov` | `scout_commands/llm/prov` | Print hierarchical provenance tree with token totals | 2026-07-30 | ⚠️ Superseded by `info` |
|
|
25
|
+
| `scout-ai llm json` | `scout_commands/llm/json` | Convert between JSON and Chat format | 2026-03-23 | ✅ Current |
|
|
26
|
+
| `scout-ai llm md` | `scout_commands/llm/md` | Format a chat as Markdown (user/assistant turns) | 2026-07-15 | ✅ Current |
|
|
27
|
+
| `scout-ai llm word` | `scout_commands/llm/word` | Convert chat to `.docx` via pandoc with custom styles | 2026-07-07 | ✅ Current |
|
|
28
|
+
| `scout-ai llm template` | `scout_commands/llm/template` | List available question templates | 2025-01-29 | ✅ Current (simple) |
|
|
29
|
+
| `scout-ai llm process` | `scout_commands/llm/process` | Batch-process JSON question files from a directory queue | 2025-10-28 | ⚠️ Legacy queue processor |
|
|
30
|
+
| `scout-ai llm process_queries` | `scout_commands/llm/process_queries` | Batch-process JSON message+option files from a directory queue | 2026-04-22 | ⚠️ Legacy queue processor |
|
|
31
|
+
| `scout-ai llm server` | `scout_commands/llm/server` | Sinatra web server for the offline chat notebook UI | 2025-08-20 | ✅ Current |
|
|
32
|
+
| `scout-ai agent ask` | `scout_commands/agent/ask` | Ask a named LLM agent (full agent loop with tools) | 2026-07-19 | ✅ Current |
|
|
33
|
+
| `scout-ai agent find` | `scout_commands/agent/find` | Resolve and print the path of a named agent | 2026-03-23 | ✅ Current |
|
|
34
|
+
| `scout-ai agent kb` | `scout_commands/agent/kb` | Launch the Scout KB browser scoped to an agent's KB | 2025-03-26 | ✅ Current (thin wrapper) |
|
|
35
|
+
| `scout-ai workflow mcp` | `scout_commands/workflow/mcp` | Expose a workflow as an MCP (Model Context Protocol) service | 2026-03-26 | ✅ Current |
|
|
36
|
+
| `scout-ai documenter` | `scout_commands/documenter` | Auto-generate documentation for a library topic using an LLM agent | 2025-08-04 | ⚠️ Early prototype |
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Per-Command Detailed Documentation
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
### 1. `scout-ai llm ask`
|
|
45
|
+
|
|
46
|
+
**File:** `scout_commands/llm/ask`
|
|
47
|
+
|
|
48
|
+
**Purpose:** Ask an LLM model a question. Supports context injection from
|
|
49
|
+
STDIN or files, template-based prompting, multi-turn conversations (via chat
|
|
50
|
+
files), inline question answering in source files, and workflow tool
|
|
51
|
+
attachment.
|
|
52
|
+
|
|
53
|
+
**Arguments:**
|
|
54
|
+
|
|
55
|
+
| Argument/Option | Type | Description |
|
|
56
|
+
|---|---|---|
|
|
57
|
+
| `[<question>]` | positional (string) | The question text. Combined from `ARGV * " "`. |
|
|
58
|
+
| `-t, --template*` | string | Use a template (file path, or name from `Scout.questions` / `Scout.chats`). Template may contain `???` placeholder for the question. |
|
|
59
|
+
| `-c, --chat*` | string (path) | Follow a conversation file. Appends response to the file. |
|
|
60
|
+
| `-i, --imports*` | string (comma-separated) | Chat files to import into the conversation. |
|
|
61
|
+
| `-in, --inline*` | string (path) | Process inline `# ask:` comments in the given file, inserting responses. |
|
|
62
|
+
| `-f, --file*` | string (path) | Incorporate file content at the start of the question (wrapped in `<file>` tag). |
|
|
63
|
+
| `-w, --workflow*` | string | Add a workflow as a tool available to the LLM. |
|
|
64
|
+
| `-m, --model*` | string | Model to use (overrides endpoint config). |
|
|
65
|
+
| `-e, --endpoint*` | string | Endpoint to use (looks up `Scout.etc.AI[endpoint].yaml`). |
|
|
66
|
+
| `-b, --backend*` | string | Backend to use (`openai`, `anthropic`, `responses`, `ollama`). |
|
|
67
|
+
| `-d, --dry_run` | flag | Print the conversation without calling the LLM. |
|
|
68
|
+
|
|
69
|
+
**Usage Examples:**
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Simple question
|
|
73
|
+
scout-ai llm ask "What is the capital of France?"
|
|
74
|
+
|
|
75
|
+
# Ask with a file for context
|
|
76
|
+
scout-ai llm ask -f report.txt "Summarize this report"
|
|
77
|
+
|
|
78
|
+
# Use STDIN with '...' placeholder
|
|
79
|
+
echo "Some context" | scout-ai llm ask "Based on this: ..., explain X"
|
|
80
|
+
|
|
81
|
+
# Multi-turn conversation
|
|
82
|
+
scout-ai llm ask -c conversation.chat "Follow up question"
|
|
83
|
+
|
|
84
|
+
# Use a template
|
|
85
|
+
scout-ai llm ask -t code_review "src/app.rb"
|
|
86
|
+
|
|
87
|
+
# Inline questions in a file (processes # ask: comments)
|
|
88
|
+
scout-ai llm ask --inline source.rb
|
|
89
|
+
|
|
90
|
+
# Dry run (preview the prompt)
|
|
91
|
+
scout-ai llm ask -d -f data.json "Analyze this data"
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**Library APIs Called:**
|
|
95
|
+
|
|
96
|
+
| API | Source File |
|
|
97
|
+
|---|---|
|
|
98
|
+
| `LLM.chat(question)` | `lib/scout/llm/chat.rb:27` |
|
|
99
|
+
| `LLM.ask(conversation, options)` | `lib/scout/llm/ask.rb:12` |
|
|
100
|
+
| `LLM.options(conversation)` | `lib/scout/llm/chat/process/options.rb:20` |
|
|
101
|
+
| `LLM.print(messages)` | `lib/scout/llm/chat/parse.rb:143` |
|
|
102
|
+
| `LLM.purge(messages)` | `lib/scout/llm/chat/process/clear.rb:42` |
|
|
103
|
+
| `Chat.setup([])` | `lib/scout/llm/chat.rb` |
|
|
104
|
+
| `Scout.questions[template]` | Scout Path API |
|
|
105
|
+
| `Scout.chats[template]`, `Scout.chats.system[template]` | Scout Path API |
|
|
106
|
+
|
|
107
|
+
**Context Injection Logic:**
|
|
108
|
+
1. If the question contains `...`, replaces it with STDIN (or file content).
|
|
109
|
+
2. If `--file` is given (without `...`), prepends file content wrapped in
|
|
110
|
+
`<file basename=...>[[[ ... ]]]</file>`.
|
|
111
|
+
3. Template resolution order: filesystem path → `Scout.questions` →
|
|
112
|
+
`Scout.chats.system` → `Scout.chats`. If template contains `???`,
|
|
113
|
+
substitutes the question; otherwise appends as `user:` turn.
|
|
114
|
+
|
|
115
|
+
**Notes:**
|
|
116
|
+
- When using `--inline`, the command scans the file for `# ask: ...` comment
|
|
117
|
+
blocks, sends each to the LLM, and inserts responses between `# Response
|
|
118
|
+
start` / `# Response end` markers.
|
|
119
|
+
- The `--chat` mode loads existing conversation, appends the new question,
|
|
120
|
+
calls `LLM.ask`, and appends both user message and response to the file.
|
|
121
|
+
- Uses `$0` renaming for display via `$previous_commands`.
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
### 2. `scout-ai llm info`
|
|
126
|
+
|
|
127
|
+
**File:** `scout_commands/llm/info`
|
|
128
|
+
|
|
129
|
+
**Purpose:** Inspect the chat, jobs, agent logs, and token trace behind a
|
|
130
|
+
Scout-AI chat. Discovers the full provenance graph (imports, job results,
|
|
131
|
+
dependencies, agent logs), reports token usage, and optionally produces a
|
|
132
|
+
provenance flow diagram (text, Graphviz DOT, or rendered SVG/PNG/PDF).
|
|
133
|
+
|
|
134
|
+
**Arguments:**
|
|
135
|
+
|
|
136
|
+
| Argument/Option | Type | Description |
|
|
137
|
+
|---|---|---|
|
|
138
|
+
| `<chat>` | positional (string) | Chat file to inspect. Also accepted via `-c`. |
|
|
139
|
+
| `-c, --chat*` | string | Chat file to inspect (same as positional). |
|
|
140
|
+
| `-f, --flow` | flag | Print a compact provenance flow (numbered nodes + edges). |
|
|
141
|
+
| `--dot*` | string (path) | Write the flow as Graphviz DOT to the given file. |
|
|
142
|
+
| `--plot*` | string (path) | Render the flow as SVG, PNG, or PDF (requires `dot` CLI). |
|
|
143
|
+
|
|
144
|
+
**Usage Examples:**
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
# Basic inspection (chats, jobs, tokens, warnings)
|
|
148
|
+
scout-ai llm info conversation.chat
|
|
149
|
+
|
|
150
|
+
# Compact flow view
|
|
151
|
+
scout-ai llm info -f conversation.chat
|
|
152
|
+
|
|
153
|
+
# Generate DOT file
|
|
154
|
+
scout-ai llm info --dot flow.dot conversation.chat
|
|
155
|
+
|
|
156
|
+
# Render to PDF
|
|
157
|
+
scout-ai llm info --plot flow.pdf conversation.chat
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**Library APIs Called:**
|
|
161
|
+
|
|
162
|
+
| API | Source File |
|
|
163
|
+
|---|---|
|
|
164
|
+
| `Chat.load(path)` | `lib/scout/llm/chat/process/meta.rb` |
|
|
165
|
+
| `Chat.trace_chats(chats)` | `lib/scout/llm/chat/process/meta.rb` |
|
|
166
|
+
| `Chat.find_file(content, path)` | `lib/scout/llm/chat/process/files.rb` |
|
|
167
|
+
| `chat.role_messages(role)` | `lib/scout/llm/chat/annotation.rb` |
|
|
168
|
+
| `chat.jobs` / `chat.job_paths` | `lib/scout/llm/chat/process/meta.rb` |
|
|
169
|
+
| `Step.load(path)` | Scout Step API |
|
|
170
|
+
| `job.dependencies`, `job.done?`, `job.type` | Scout Step API |
|
|
171
|
+
| `job.file('log')` | Scout Step API |
|
|
172
|
+
| `job.info[:workflow]`, `job.info[:task_name]` | Scout Step API |
|
|
173
|
+
| `Scout.chats[input].find` | Scout Path API |
|
|
174
|
+
|
|
175
|
+
**Key Design Features:**
|
|
176
|
+
- **No monkey-patching** — uses library APIs directly (unlike `prov`).
|
|
177
|
+
- **Job deduplication** — canonical identity by `[workflow, task, basename]`
|
|
178
|
+
so `~/.scout` and `~/.rbbt` mirrors of the same job appear once.
|
|
179
|
+
- **Import discovery** — follows `import`/`continue`/`last` role messages.
|
|
180
|
+
- **Token accounting** — sums `pt`/`ct`/`tt` from direct inference entries
|
|
181
|
+
only (entries without `:job` key), matching `Backend::Default#update_meta`.
|
|
182
|
+
- **Flow visualization** — nodes (chat/agent/job), edges (import/result/
|
|
183
|
+
dependency/log), token annotations, Graphviz shapes/colors per type.
|
|
184
|
+
- **Warnings** — records and reports load failures gracefully.
|
|
185
|
+
|
|
186
|
+
**Output Format (default):**
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
Chats
|
|
190
|
+
=====
|
|
191
|
+
~/.scout/var/.../conversation.chat
|
|
192
|
+
messages=15 user=5 assistant=5 meta=5
|
|
193
|
+
jobs=~/.scout/var/jobs/.../ask
|
|
194
|
+
|
|
195
|
+
Jobs
|
|
196
|
+
====
|
|
197
|
+
~/.scout/var/jobs/.../ask
|
|
198
|
+
Agent/Worker/ask
|
|
199
|
+
logs=3 dependencies=2
|
|
200
|
+
|
|
201
|
+
Token usage
|
|
202
|
+
-----------
|
|
203
|
+
Root chat: prompt=1500 completion=800 total=2300
|
|
204
|
+
All traced chats: prompt=5000 completion=3000 total=8000
|
|
205
|
+
Trace records: 45
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
**Flow Output (with `-f`):**
|
|
209
|
+
|
|
210
|
+
```
|
|
211
|
+
Flow
|
|
212
|
+
====
|
|
213
|
+
[ 1] Job Agent/Worker/ask 2.3k a1b2c3d4
|
|
214
|
+
[ 2] Chat conversation 1.5k e5f6g7h8
|
|
215
|
+
|
|
216
|
+
[ 1] --result --> [ 2]
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
**Assessment:** ✅ **Current and well-maintained.** This is the recommended
|
|
220
|
+
command for provenance inspection. It does NOT use monkey-patching, correctly
|
|
221
|
+
references all current library APIs, and was last updated 2026-07-20. Artifact
|
|
222
|
+
07's assessment that `info` is NOT outdated is **confirmed**.
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
### 3. `scout-ai llm prov`
|
|
227
|
+
|
|
228
|
+
**File:** `scout_commands/llm/prov`
|
|
229
|
+
|
|
230
|
+
**Purpose:** Examine the provenance of a chat. Prints a hierarchical, indented
|
|
231
|
+
tree showing jobs, agent logs, and dependencies with token totals at each node.
|
|
232
|
+
|
|
233
|
+
**Arguments:**
|
|
234
|
+
|
|
235
|
+
| Argument/Option | Type | Description |
|
|
236
|
+
|---|---|---|
|
|
237
|
+
| `<filename>` | positional (string) | Chat file or job path to examine. |
|
|
238
|
+
| `-h, --help` | flag | Print help. |
|
|
239
|
+
|
|
240
|
+
**Usage Examples:**
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
scout-ai llm prov conversation.chat
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
**Library APIs Called:**
|
|
247
|
+
|
|
248
|
+
| API | Source File | Note |
|
|
249
|
+
|---|---|---|
|
|
250
|
+
| `LLM.chat(filename)` | `lib/scout/llm/chat.rb` | ✅ Direct call |
|
|
251
|
+
| `Step.load(job)` | Scout Step API | ✅ Direct call |
|
|
252
|
+
| `Chat.trace_chats` | `lib/scout/llm/chat/process/meta.rb` | ⚠️ **Redefined** via monkey-patch |
|
|
253
|
+
| `Chat.token_totals` | (library) | ⚠️ **Redefined** via monkey-patch |
|
|
254
|
+
| `Chat.provenance` | — | ⚠️ **New** monkey-patch (not in library) |
|
|
255
|
+
| `Chat.provenance_chat_files` | — | ⚠️ **New** monkey-patch |
|
|
256
|
+
| `Chat.tokens` | — | ⚠️ **New** monkey-patch |
|
|
257
|
+
| `Chat.job_agent_chat_files` | `lib/scout/llm/chat/process/meta.rb` | ⚠️ **Redefined** via monkey-patch |
|
|
258
|
+
| `Step#agent_chats` | — | ⚠️ **New** monkey-patch |
|
|
259
|
+
|
|
260
|
+
**Output Format:**
|
|
261
|
+
|
|
262
|
+
```
|
|
263
|
+
job total=1.2k prompt=800 cont=400 ~/.scout/var/jobs/.../ask
|
|
264
|
+
chat total=500 prompt=300 cont=200 agent.chat
|
|
265
|
+
job total=700 prompt=500 cont=200 ~/.scout/var/jobs/.../subtask
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
**Assessment:** ⚠️ **Superseded by `info`.** Still functional, but:
|
|
269
|
+
- Relies on runtime monkey-patches that redefine library methods.
|
|
270
|
+
- No import discovery.
|
|
271
|
+
- No job deduplication (`~/.scout` and `~/.rbbt` mirrors appear twice).
|
|
272
|
+
- No flow visualization or DOT/plot output.
|
|
273
|
+
- No JSON/machine-readable output.
|
|
274
|
+
- **Hardcoded fallback path:** `~/git/workflows/SC26/chats/network_usecase/3.1.themes`
|
|
275
|
+
(line: `filename ||= "~/git/workflows/SC26/chats/network_usecase/3.1.themes"`).
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
### 4. `scout-ai llm json`
|
|
280
|
+
|
|
281
|
+
**File:** `scout_commands/llm/json`
|
|
282
|
+
|
|
283
|
+
**Purpose:** Translate chats to and from JSON format. Reads a file as either
|
|
284
|
+
JSON or Chat format and outputs the opposite format.
|
|
285
|
+
|
|
286
|
+
**Arguments:**
|
|
287
|
+
|
|
288
|
+
| Argument/Option | Type | Description |
|
|
289
|
+
|---|---|---|
|
|
290
|
+
| `<filename>` | positional (string) | Input file to convert. |
|
|
291
|
+
| `-c, --chat` | flag | Load input as Chat format (output will be JSON). |
|
|
292
|
+
| `-j, --json` | flag | Load input as JSON format (output will be Chat). **Default.** |
|
|
293
|
+
| `-o, --output*` | string (path) | Save to file instead of printing to STDOUT. |
|
|
294
|
+
|
|
295
|
+
**Usage Examples:**
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
# Convert JSON chat to Chat format
|
|
299
|
+
scout-ai llm json -j input.json
|
|
300
|
+
|
|
301
|
+
# Convert Chat format to JSON
|
|
302
|
+
scout-ai llm json -c conversation.chat
|
|
303
|
+
|
|
304
|
+
# Save to file
|
|
305
|
+
scout-ai llm json -c conversation.chat -o output.json
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
**Library APIs Called:**
|
|
309
|
+
|
|
310
|
+
| API | Source File |
|
|
311
|
+
|---|---|
|
|
312
|
+
| `LLM.chat(filename)` | `lib/scout/llm/chat.rb` |
|
|
313
|
+
| `LLM.print(messages)` | `lib/scout/llm/chat/parse.rb` |
|
|
314
|
+
| `Chat.setup(json_hash)` | `lib/scout/llm/chat.rb` |
|
|
315
|
+
| `Open.json(filename)` | Scout Open API |
|
|
316
|
+
|
|
317
|
+
**Assessment:** ✅ **Current.** Simple, straightforward converter. Note: using
|
|
318
|
+
both `-c` and `-j` simultaneously raises a `ParameterException`.
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
### 5. `scout-ai llm md`
|
|
323
|
+
|
|
324
|
+
**File:** `scout_commands/llm/md`
|
|
325
|
+
|
|
326
|
+
**Purpose:** Format a chat file as Markdown with emoji headers for user and
|
|
327
|
+
assistant turns.
|
|
328
|
+
|
|
329
|
+
**Arguments:**
|
|
330
|
+
|
|
331
|
+
| Argument/Option | Type | Description |
|
|
332
|
+
|---|---|---|
|
|
333
|
+
| `<chat>` | positional (string) | Chat file to format. |
|
|
334
|
+
| `<markdown>` | positional (string, optional) | Output Markdown file path. If omitted, prints to STDOUT. |
|
|
335
|
+
| `-l, --last` | flag | Format only the last user/assistant interaction. |
|
|
336
|
+
|
|
337
|
+
**Usage Examples:**
|
|
338
|
+
|
|
339
|
+
```bash
|
|
340
|
+
# Print to stdout
|
|
341
|
+
scout-ai llm md conversation.chat
|
|
342
|
+
|
|
343
|
+
# Save to file
|
|
344
|
+
scout-ai llm md conversation.chat output.md
|
|
345
|
+
|
|
346
|
+
# Only the last exchange
|
|
347
|
+
scout-ai llm md -l conversation.chat output.md
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
**Library APIs Called:**
|
|
351
|
+
|
|
352
|
+
| API | Source File |
|
|
353
|
+
|---|---|
|
|
354
|
+
| `Chat.parse(text)` | `lib/scout/llm/chat/parse.rb` |
|
|
355
|
+
| `Open.read(chat)` | Scout Open API |
|
|
356
|
+
|
|
357
|
+
**Output Format:**
|
|
358
|
+
|
|
359
|
+
```markdown
|
|
360
|
+
---
|
|
361
|
+
# 👤 User
|
|
362
|
+
---
|
|
363
|
+
|
|
364
|
+
What is Ruby?
|
|
365
|
+
|
|
366
|
+
---
|
|
367
|
+
# 🤖 Assistant
|
|
368
|
+
---
|
|
369
|
+
|
|
370
|
+
Ruby is a dynamic, object-oriented programming language...
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
**Assessment:** ✅ **Current.** Clean, simple formatter. Filters only `user`
|
|
374
|
+
and `assistant` roles; ignores `system`, `tool`, `meta`, etc.
|
|
375
|
+
|
|
376
|
+
---
|
|
377
|
+
|
|
378
|
+
### 6. `scout-ai llm word`
|
|
379
|
+
|
|
380
|
+
**File:** `scout_commands/llm/word`
|
|
381
|
+
|
|
382
|
+
**Purpose:** Convert a chat file to a Word `.docx` document using pandoc,
|
|
383
|
+
with custom paragraph styles for user blocks.
|
|
384
|
+
|
|
385
|
+
**Arguments:**
|
|
386
|
+
|
|
387
|
+
| Argument/Option | Type | Description |
|
|
388
|
+
|---|---|---|
|
|
389
|
+
| `<chat>` | positional (string) | Chat file to convert. |
|
|
390
|
+
| `<word>` | positional (string, optional) | Output `.docx` path. Defaults to `<chat>.docx`. |
|
|
391
|
+
| `-r, --reference*` | string (path) | Custom `reference.docx` for pandoc styling. Defaults to `Scout.share.word["reference.docx"]`. |
|
|
392
|
+
| `-l, --last` | flag | Format only the last user/assistant interaction. |
|
|
393
|
+
|
|
394
|
+
**Usage Examples:**
|
|
395
|
+
|
|
396
|
+
```bash
|
|
397
|
+
# Basic conversion
|
|
398
|
+
scout-ai llm word conversation.chat
|
|
399
|
+
|
|
400
|
+
# Specify output file
|
|
401
|
+
scout-ai llm word conversation.chat report.docx
|
|
402
|
+
|
|
403
|
+
# Use custom reference doc
|
|
404
|
+
scout-ai llm word -r my-reference.docx conversation.chat report.docx
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
**Library APIs Called:**
|
|
408
|
+
|
|
409
|
+
| API | Source File |
|
|
410
|
+
|---|---|
|
|
411
|
+
| `Chat.parse(text)` | `lib/scout/llm/chat/parse.rb` |
|
|
412
|
+
| `Scout.share.word["reference.docx"]` | Scout Path API |
|
|
413
|
+
| `CMD.cmd(:pandoc, ...)` | Scout CMD API |
|
|
414
|
+
| `TmpFile.with_file(...)` | Scout TmpFile API |
|
|
415
|
+
|
|
416
|
+
**Notes:**
|
|
417
|
+
- Requires the `pandoc` CLI to be installed.
|
|
418
|
+
- User messages are wrapped in `::: {custom-style="UserBlock"}` blocks.
|
|
419
|
+
- Assistant messages are output as-is (no wrapper).
|
|
420
|
+
|
|
421
|
+
**Assessment:** ✅ **Current.** External dependency: pandoc.
|
|
422
|
+
|
|
423
|
+
---
|
|
424
|
+
|
|
425
|
+
### 7. `scout-ai llm template`
|
|
426
|
+
|
|
427
|
+
**File:** `scout_commands/llm/template`
|
|
428
|
+
|
|
429
|
+
**Purpose:** List all available question templates.
|
|
430
|
+
|
|
431
|
+
**Arguments:** None beyond `--help`.
|
|
432
|
+
|
|
433
|
+
**Usage Examples:**
|
|
434
|
+
|
|
435
|
+
```bash
|
|
436
|
+
scout-ai llm template
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
**Library APIs Called:**
|
|
440
|
+
|
|
441
|
+
| API | Source File |
|
|
442
|
+
|---|---|
|
|
443
|
+
| `Scout.questions.glob_all("*")` | Scout Path API |
|
|
444
|
+
|
|
445
|
+
**Assessment:** ✅ **Current.** Minimal one-liner command. Lists all files
|
|
446
|
+
found under the `Scout.questions` path collection.
|
|
447
|
+
|
|
448
|
+
---
|
|
449
|
+
|
|
450
|
+
### 8. `scout-ai llm process`
|
|
451
|
+
|
|
452
|
+
**File:** `scout_commands/llm/process`
|
|
453
|
+
|
|
454
|
+
**Purpose:** Batch-process JSON question files from a directory queue.
|
|
455
|
+
Continuously polls a directory for `*.json` files, each containing
|
|
456
|
+
`{"question": "...", "model": "...", ...}`, sends each to the LLM, writes
|
|
457
|
+
the reply to `<directory>/reply/<id>.json`, and removes the input file.
|
|
458
|
+
|
|
459
|
+
**Arguments:**
|
|
460
|
+
|
|
461
|
+
| Argument/Option | Type | Description |
|
|
462
|
+
|---|---|---|
|
|
463
|
+
| `[<directory>]` | positional (string) | Directory to poll. Defaults to `Scout.var.ask`. |
|
|
464
|
+
|
|
465
|
+
**Usage Examples:**
|
|
466
|
+
|
|
467
|
+
```bash
|
|
468
|
+
# Start processing from default directory
|
|
469
|
+
scout-ai llm process
|
|
470
|
+
|
|
471
|
+
# Process from a specific queue directory
|
|
472
|
+
scout-ai llm process /path/to/queue
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
**Library APIs Called:**
|
|
476
|
+
|
|
477
|
+
| API | Source File |
|
|
478
|
+
|---|---|
|
|
479
|
+
| `LLM.ask(question, options)` | `lib/scout/llm/ask.rb` |
|
|
480
|
+
| `Scout.var.ask` | Scout Path API |
|
|
481
|
+
| `require 'scout/llm/backends/relay'` | Backend relay module |
|
|
482
|
+
|
|
483
|
+
**Assessment:** ⚠️ **Legacy queue processor.** This is an older pattern for
|
|
484
|
+
asynchronous LLM processing. The `require 'scout/llm/backends/relay'`
|
|
485
|
+
suggests it was designed for a relay/backend model. The infinite loop with
|
|
486
|
+
`sleep 1` makes it a daemon-like process. Still functional but represents an
|
|
487
|
+
earlier architecture. Last meaningful update: 2025-10-28.
|
|
488
|
+
|
|
489
|
+
---
|
|
490
|
+
|
|
491
|
+
### 9. `scout-ai llm process_queries`
|
|
492
|
+
|
|
493
|
+
**File:** `scout_commands/llm/process_queries`
|
|
494
|
+
|
|
495
|
+
**Purpose:** Similar to `process` but handles files containing `[messages,
|
|
496
|
+
options]` tuples (an array of two elements) rather than `{"question":
|
|
497
|
+
"..."}`. Processes each query by calling `LLM.ask(messages, options.merge(process:
|
|
498
|
+
id))`.
|
|
499
|
+
|
|
500
|
+
**Arguments:**
|
|
501
|
+
|
|
502
|
+
| Argument/Option | Type | Description |
|
|
503
|
+
|---|---|---|
|
|
504
|
+
| `[<directory>]` | positional (string) | Directory to poll. Defaults to `Scout.var.query`. |
|
|
505
|
+
|
|
506
|
+
**Usage Examples:**
|
|
507
|
+
|
|
508
|
+
```bash
|
|
509
|
+
scout-ai llm process_queries /path/to/queue
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
**Library APIs Called:**
|
|
513
|
+
|
|
514
|
+
| API | Source File |
|
|
515
|
+
|---|---|
|
|
516
|
+
| `LLM.ask(messages, options)` | `lib/scout/llm/ask.rb` |
|
|
517
|
+
| `Scout.var.query` | Scout Path API |
|
|
518
|
+
| `require 'scout/llm/backends/relay'` | Backend relay module |
|
|
519
|
+
|
|
520
|
+
**Assessment:** ⚠️ **Legacy queue processor.** A variant of `process` with a
|
|
521
|
+
different JSON schema (`[messages, options]` vs. `{question:, ...}`). More
|
|
522
|
+
recently updated (2026-04-22) but still represents the queue-based async
|
|
523
|
+
processing pattern. The `process: id` option suggests it registers the
|
|
524
|
+
processing ID with the backend.
|
|
525
|
+
|
|
526
|
+
---
|
|
527
|
+
|
|
528
|
+
### 10. `scout-ai llm server`
|
|
529
|
+
|
|
530
|
+
**File:** `scout_commands/llm/server`
|
|
531
|
+
|
|
532
|
+
**Purpose:** A Sinatra-based web server that provides a chat notebook UI for
|
|
533
|
+
browsing, editing, and running chat files stored under `./chats`. Serves an
|
|
534
|
+
embedded HTML/JS frontend and provides REST API endpoints for file management
|
|
535
|
+
and LLM execution.
|
|
536
|
+
|
|
537
|
+
**Configuration:**
|
|
538
|
+
|
|
539
|
+
| Env Var | Default | Description |
|
|
540
|
+
|---|---|---|
|
|
541
|
+
| `SCOUT_BIND` | `127.0.0.1` | Bind address. |
|
|
542
|
+
| `SCOUT_PORT` | `4567` | Port number. |
|
|
543
|
+
|
|
544
|
+
**API Endpoints:**
|
|
545
|
+
|
|
546
|
+
| Method | Route | Description |
|
|
547
|
+
|---|---|---|
|
|
548
|
+
| GET | `/` | Serve the chat HTML UI (`share/server/chat.html`). |
|
|
549
|
+
| GET | `/chat.js` | Serve the client JavaScript (`share/server/chat.js`). |
|
|
550
|
+
| GET | `/list` | List all files under `./chats` (excludes dotfiles). |
|
|
551
|
+
| GET | `/load?path=<rel>` | Load a chat file's content. |
|
|
552
|
+
| POST | `/save` | Save a chat file. Body: `{path, content}`. |
|
|
553
|
+
| POST | `/run` | Run a chat through the LLM. Body: `{path, content?, convo_options?, options?}`. |
|
|
554
|
+
| GET | `/ping` | Health check. |
|
|
555
|
+
|
|
556
|
+
**Usage Examples:**
|
|
557
|
+
|
|
558
|
+
```bash
|
|
559
|
+
# Start server in a directory with a chats/ subdirectory
|
|
560
|
+
mkdir -p chats
|
|
561
|
+
scout-ai llm server
|
|
562
|
+
|
|
563
|
+
# Custom bind/port
|
|
564
|
+
SCOUT_BIND=0.0.0.0 SCOUT_PORT=8080 scout-ai llm server
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
**Library APIs Called:**
|
|
568
|
+
|
|
569
|
+
| API | Source File |
|
|
570
|
+
|---|---|
|
|
571
|
+
| `LLM.chat(file_text)` / `LLM.chat(full)` | `lib/scout/llm/chat.rb` |
|
|
572
|
+
| `LLM.ask(conversation, options)` | `lib/scout/llm/ask.rb` |
|
|
573
|
+
| `LLM.print(messages)` | `lib/scout/llm/chat/parse.rb` |
|
|
574
|
+
| `Scout.share['server']['chat.html']` | Scout Path API |
|
|
575
|
+
| `Scout.share['server']['chat.js']` | Scout Path API |
|
|
576
|
+
|
|
577
|
+
**Security Features:**
|
|
578
|
+
- Path sanitization: strips leading slashes, rejects `..` traversal, ensures
|
|
579
|
+
resolved path is inside `CHATS_DIR`.
|
|
580
|
+
- Dotfile filtering: hides files/directories with path segments starting with `.`.
|
|
581
|
+
|
|
582
|
+
**Assessment:** ✅ **Current.** A functional web UI backend. Has a fallback
|
|
583
|
+
simulated reply if LLM is not available. Error responses include diagnostics
|
|
584
|
+
(backtrace, conversation preview). External dependency: `sinatra`.
|
|
585
|
+
|
|
586
|
+
---
|
|
587
|
+
|
|
588
|
+
### 11. `scout-ai agent ask`
|
|
589
|
+
|
|
590
|
+
**File:** `scout_commands/agent/ask`
|
|
591
|
+
|
|
592
|
+
**Purpose:** Ask a named LLM agent. Unlike `llm ask` which does a single LLM
|
|
593
|
+
call, this loads a full agent (with system prompt, tools, workflows,
|
|
594
|
+
knowledge base) and runs the agent loop.
|
|
595
|
+
|
|
596
|
+
**Arguments:**
|
|
597
|
+
|
|
598
|
+
| Argument/Option | Type | Description |
|
|
599
|
+
|---|---|---|
|
|
600
|
+
| `<agent_name>` | positional (string) | Name of the agent to load (resolved by `LLM::Agent.load_agent`). |
|
|
601
|
+
| `[question]` | positional (string) | The question text. Combined from remaining `ARGV`. |
|
|
602
|
+
| `-l, --log*` | integer | Log level. |
|
|
603
|
+
| `-t, --template*` | string | Use a template (same logic as `llm ask`). |
|
|
604
|
+
| `-c, --chat*` | string (path) | Follow a conversation file. |
|
|
605
|
+
| `-m, --model*` | string | Model to use. |
|
|
606
|
+
| `-e, --endpoint*` | string | Endpoint to use. |
|
|
607
|
+
| `-f, --file*` | string (path) | Incorporate file content. |
|
|
608
|
+
| `-w, --workflow*` | string | Add an additional workflow as a tool. |
|
|
609
|
+
| `-wt, --workflow_tasks*` | string | Export specific tasks from the workflow to the agent. |
|
|
610
|
+
| `-i, --imports*` | string (comma-separated) | Chat files to import. |
|
|
611
|
+
|
|
612
|
+
**Usage Examples:**
|
|
613
|
+
|
|
614
|
+
```bash
|
|
615
|
+
# Ask the AGI agent
|
|
616
|
+
scout-ai agent ask AGI "Analyze this codebase"
|
|
617
|
+
|
|
618
|
+
# Ask with a conversation file
|
|
619
|
+
scout-ai agent ask -c session.chat Worker "Process this data"
|
|
620
|
+
|
|
621
|
+
# Ask with a file for context
|
|
622
|
+
scout-ai agent ask -f input.txt Searcher "Find relevant information"
|
|
623
|
+
|
|
624
|
+
# Specify model/endpoint
|
|
625
|
+
scout-ai agent ask -m gpt-4o -e production AGI "Complex task"
|
|
626
|
+
```
|
|
627
|
+
|
|
628
|
+
**Library APIs Called:**
|
|
629
|
+
|
|
630
|
+
| API | Source File |
|
|
631
|
+
|---|---|
|
|
632
|
+
| `LLM::Agent.load_agent(agent_name)` | `lib/scout/llm/agent.rb:152` |
|
|
633
|
+
| `agent.start(chat)` | `lib/scout/llm/agent.rb` |
|
|
634
|
+
| `agent.ask(chat, options)` | `lib/scout/llm/agent.rb` |
|
|
635
|
+
| `agent.current_chat` | `lib/scout/llm/agent.rb` |
|
|
636
|
+
| `agent.import(file)` | `lib/scout/llm/agent.rb` |
|
|
637
|
+
| `agent.chat` | `lib/scout/llm/agent.rb` |
|
|
638
|
+
| `LLM.chat(question)` | `lib/scout/llm/chat.rb` |
|
|
639
|
+
| `LLM.options(conversation)` | `lib/scout/llm/chat/process/options.rb` |
|
|
640
|
+
| `LLM.print(messages)` | `lib/scout/llm/chat/parse.rb` |
|
|
641
|
+
| `LLM.purge(messages)` | `lib/scout/llm/chat/process/clear.rb` |
|
|
642
|
+
| `LLM.tag('file', file, name)` | `lib/scout/llm/chat/process/files.rb` |
|
|
643
|
+
| `Scout.questions`, `Scout.chats` | Scout Path API |
|
|
644
|
+
|
|
645
|
+
**Key Differences from `llm ask`:**
|
|
646
|
+
- Uses `LLM::Agent.load_agent` to load a full agent definition (system prompt,
|
|
647
|
+
tools, workflow, KB).
|
|
648
|
+
- The agent manages its own chat loop (multi-turn with tool calls).
|
|
649
|
+
- Sets `agent.other_options[:endpoint]` and `[:model]` for override.
|
|
650
|
+
- The inline mode uses `LLM.tag` (not `Chat.tag`) for file references.
|
|
651
|
+
- The default (no chat, no inline) mode calls `agent.chat` which runs the full
|
|
652
|
+
agent loop and prints the final conversation.
|
|
653
|
+
|
|
654
|
+
**Assessment:** ✅ **Current.** Last updated 2026-07-19 (fixed bug with
|
|
655
|
+
endpoint/model options). Well-maintained and the primary entry point for
|
|
656
|
+
agent-based interactions.
|
|
657
|
+
|
|
658
|
+
---
|
|
659
|
+
|
|
660
|
+
### 12. `scout-ai agent find`
|
|
661
|
+
|
|
662
|
+
**File:** `scout_commands/agent/find`
|
|
663
|
+
|
|
664
|
+
**Purpose:** Find (resolve) an agent by name and print its path.
|
|
665
|
+
|
|
666
|
+
**Arguments:**
|
|
667
|
+
|
|
668
|
+
| Argument/Option | Type | Description |
|
|
669
|
+
|---|---|---|
|
|
670
|
+
| `<agent_name>` | positional (string) | Name of the agent to find. |
|
|
671
|
+
|
|
672
|
+
**Usage Examples:**
|
|
673
|
+
|
|
674
|
+
```bash
|
|
675
|
+
scout-ai agent find AGI
|
|
676
|
+
# Output: ~/.scout/var/Agent/AGI (or wherever the agent is defined)
|
|
677
|
+
```
|
|
678
|
+
|
|
679
|
+
**Library APIs Called:**
|
|
680
|
+
|
|
681
|
+
| API | Source File |
|
|
682
|
+
|---|---|
|
|
683
|
+
| `LLM.load_agent(agent_name, options)` | `lib/scout/llm/agent.rb:8` (delegates to `LLM::Agent.load_agent`) |
|
|
684
|
+
|
|
685
|
+
**Assessment:** ✅ **Current.** Simple utility for resolving agent paths.
|
|
686
|
+
|
|
687
|
+
---
|
|
688
|
+
|
|
689
|
+
### 13. `scout-ai agent kb`
|
|
690
|
+
|
|
691
|
+
**File:** `scout_commands/agent/kb`
|
|
692
|
+
|
|
693
|
+
**Purpose:** Launch the Scout knowledge base browser, scoped to a specific
|
|
694
|
+
agent's KB directory. This is a thin wrapper that delegates to the main
|
|
695
|
+
`scout kb` command.
|
|
696
|
+
|
|
697
|
+
**Arguments:**
|
|
698
|
+
|
|
699
|
+
| Argument/Option | Type | Description |
|
|
700
|
+
|---|---|---|
|
|
701
|
+
| `<agent>` | positional (string) | Agent name. The KB is resolved from `Scout.var.Agent[agent].knowledge_base`. |
|
|
702
|
+
| `[args...]` | remaining args | Passed through to the `scout kb` command. |
|
|
703
|
+
|
|
704
|
+
**Usage Examples:**
|
|
705
|
+
|
|
706
|
+
```bash
|
|
707
|
+
# Open KB browser for AGI agent's knowledge base
|
|
708
|
+
scout-ai agent kb AGI
|
|
709
|
+
```
|
|
710
|
+
|
|
711
|
+
**Library APIs Called:**
|
|
712
|
+
|
|
713
|
+
| API | Source File |
|
|
714
|
+
|---|---|
|
|
715
|
+
| `Scout.var.Agent[agent]` | Scout Path API |
|
|
716
|
+
| `Scout.bin.scout.find` | Scout Path API (loads the main scout binary) |
|
|
717
|
+
|
|
718
|
+
**How It Works:**
|
|
719
|
+
1. Resolves `agent_dir = Scout.var.Agent[agent]`.
|
|
720
|
+
2. If additional arguments are given, appends `--knowledge_base`, the KB path,
|
|
721
|
+
and the current log level to `ARGV`.
|
|
722
|
+
3. Prepends `kb` to `ARGV`.
|
|
723
|
+
4. Loads and executes the main `scout` binary (delegation pattern).
|
|
724
|
+
|
|
725
|
+
**Assessment:** ✅ **Current.** Thin wrapper using Scout's standard delegation
|
|
726
|
+
pattern (`load Scout.bin.scout.find`).
|
|
727
|
+
|
|
728
|
+
---
|
|
729
|
+
|
|
730
|
+
### 14. `scout-ai workflow mcp`
|
|
731
|
+
|
|
732
|
+
**File:** `scout_commands/workflow/mcp`
|
|
733
|
+
|
|
734
|
+
**Purpose:** Run a Scout workflow as an MCP (Model Context Protocol) service
|
|
735
|
+
over stdio. This exposes workflow tasks as MCP tools that can be called by
|
|
736
|
+
MCP-compatible clients (e.g., Claude Desktop, other MCP consumers).
|
|
737
|
+
|
|
738
|
+
**Arguments:**
|
|
739
|
+
|
|
740
|
+
| Argument/Option | Type | Description |
|
|
741
|
+
|---|---|---|
|
|
742
|
+
| `<workflow>` | positional (string) | Name of the workflow to export. |
|
|
743
|
+
| `[task_name]*` | positional (string, repeatable) | Specific tasks to export. If none given, exports explicitly exported tasks. If no tasks are explicitly exported, exports all tasks. |
|
|
744
|
+
|
|
745
|
+
**Usage Examples:**
|
|
746
|
+
|
|
747
|
+
```bash
|
|
748
|
+
# Export a workflow as MCP (all tasks)
|
|
749
|
+
scout-ai workflow mcp MyWorkflow
|
|
750
|
+
|
|
751
|
+
# Export specific tasks only
|
|
752
|
+
scout-ai workflow mcp MyWorkflow task1 task2
|
|
753
|
+
```
|
|
754
|
+
|
|
755
|
+
**Library APIs Called:**
|
|
756
|
+
|
|
757
|
+
| API | Source File |
|
|
758
|
+
|---|---|
|
|
759
|
+
| `Workflow.require_workflow(name)` | Scout Workflow API |
|
|
760
|
+
| `workflow.mcp_stdio(*task_names)` | `lib/scout/llm/mcp.rb:30` |
|
|
761
|
+
|
|
762
|
+
**How It Works:**
|
|
763
|
+
1. Requires the named workflow (loads its `workflow.rb`).
|
|
764
|
+
2. Calls `workflow.mcp_stdio(*task_names)` which starts an MCP server on stdio,
|
|
765
|
+
exposing the selected tasks as MCP tools.
|
|
766
|
+
|
|
767
|
+
**Assessment:** ✅ **Current.** Integrates with the MCP standard for tool
|
|
768
|
+
exposure. Clean implementation delegating to the library's `mcp_stdio` method.
|
|
769
|
+
|
|
770
|
+
---
|
|
771
|
+
|
|
772
|
+
### 15. `scout-ai documenter`
|
|
773
|
+
|
|
774
|
+
**File:** `scout_commands/documenter`
|
|
775
|
+
|
|
776
|
+
**Purpose:** Automatically generate technical documentation for a Scout
|
|
777
|
+
library topic by analyzing Ruby source files and their corresponding test
|
|
778
|
+
files using an LLM agent.
|
|
779
|
+
|
|
780
|
+
**Arguments:**
|
|
781
|
+
|
|
782
|
+
| Argument/Option | Type | Description |
|
|
783
|
+
|---|---|---|
|
|
784
|
+
| `<topic>` | positional (string) | The topic name (e.g., `chat`, `agent`, `llm`). |
|
|
785
|
+
|
|
786
|
+
**Usage Examples:**
|
|
787
|
+
|
|
788
|
+
```bash
|
|
789
|
+
scout-ai documenter chat
|
|
790
|
+
scout-ai documenter agent
|
|
791
|
+
```
|
|
792
|
+
|
|
793
|
+
**Library APIs Called:**
|
|
794
|
+
|
|
795
|
+
| API | Source File |
|
|
796
|
+
|---|---|
|
|
797
|
+
| `LLM::Agent.new` | `lib/scout/llm/agent.rb` |
|
|
798
|
+
| `documenter.start_chat.system(...)` | Agent chat API |
|
|
799
|
+
| `documenter.start_chat.file(...)` | Agent chat API |
|
|
800
|
+
| `documenter.start_chat.user(...)` | Agent chat API |
|
|
801
|
+
| `documenter.start` | Agent API |
|
|
802
|
+
| `documenter.file(...)` | Agent API |
|
|
803
|
+
| `documenter.respond` | Agent API |
|
|
804
|
+
| `documenter.user(...)` | Agent API |
|
|
805
|
+
| `documenter.chat` | Agent API |
|
|
806
|
+
| `Scout.lib.scout.glob(...)` | Scout Path API |
|
|
807
|
+
| `Scout.scout_commands.glob(...)` | Scout Path API |
|
|
808
|
+
| `Scout.doc.lib.scout[topic + '.md']` | Scout Path API (output location) |
|
|
809
|
+
|
|
810
|
+
**How It Works:**
|
|
811
|
+
1. Locates source files matching `lib/scout/<topic>*` and corresponding test
|
|
812
|
+
files (via `source_to_test` substitution `./lib/` → `./test/`).
|
|
813
|
+
2. Creates an `LLM::Agent` with a documentation-author system prompt.
|
|
814
|
+
3. Feeds the main source + test file and asks for initial documentation.
|
|
815
|
+
4. For each subtopic, feeds the subtopic's source + test files and asks for
|
|
816
|
+
subtopic documentation.
|
|
817
|
+
5. Aggregates all subtopic docs and asks the agent to produce a comprehensive
|
|
818
|
+
main documentation.
|
|
819
|
+
6. Revises each subtopic doc in light of the main documentation.
|
|
820
|
+
7. Writes outputs to `Scout.doc.lib.scout[topic + '.md']` and
|
|
821
|
+
`Scout.doc.lib.scout[topic][subtopic + '.md']`.
|
|
822
|
+
|
|
823
|
+
**Assessment:** ⚠️ **Early prototype.** Last updated 2025-08-04 ("first
|
|
824
|
+
version"). The two-pass approach (generate → aggregate → revise) is
|
|
825
|
+
interesting but:
|
|
826
|
+
- No options for output directory, model selection, or dry-run.
|
|
827
|
+
- Assumes a fixed file layout (`lib/scout/<topic>*` and `test/` mirroring).
|
|
828
|
+
- Relies on `LLM::Agent` API that may have evolved since.
|
|
829
|
+
- No error handling for missing source files.
|
|
830
|
+
- The system prompt is hardcoded in the script.
|
|
831
|
+
|
|
832
|
+
---
|
|
833
|
+
|
|
834
|
+
## Summary: Current vs. Deprecated/Outdated
|
|
835
|
+
|
|
836
|
+
### ✅ Current and Recommended
|
|
837
|
+
|
|
838
|
+
| Command | Notes |
|
|
839
|
+
|---|---|
|
|
840
|
+
| `llm ask` | Primary LLM question command. Well-maintained. |
|
|
841
|
+
| `llm info` | **Recommended** provenance inspector. No monkey-patching, full feature set. |
|
|
842
|
+
| `llm json` | Simple format converter. |
|
|
843
|
+
| `llm md` | Chat → Markdown formatter. |
|
|
844
|
+
| `llm word` | Chat → Word converter (requires pandoc). |
|
|
845
|
+
| `llm template` | Lists templates. |
|
|
846
|
+
| `llm server` | Web UI backend (requires sinatra). |
|
|
847
|
+
| `agent ask` | Primary agent interaction command. |
|
|
848
|
+
| `agent find` | Agent path resolver. |
|
|
849
|
+
| `agent kb` | Agent KB browser wrapper. |
|
|
850
|
+
| `workflow mcp` | MCP service exporter. |
|
|
851
|
+
|
|
852
|
+
### ⚠️ Superseded or Legacy
|
|
853
|
+
|
|
854
|
+
| Command | Issue |
|
|
855
|
+
|---|---|
|
|
856
|
+
| `llm prov` | **Superseded by `llm info`.** Uses monkey-patches, lacks imports/dedup/flow. Has hardcoded fallback path. |
|
|
857
|
+
| `llm process` | Legacy queue-based async processor. Older architecture. |
|
|
858
|
+
| `llm process_queries` | Legacy queue-based async processor (variant schema). |
|
|
859
|
+
| `documenter` | Early prototype (2025-08-04, "first version"). No options, no error handling. |
|
|
860
|
+
|
|
861
|
+
---
|
|
862
|
+
|
|
863
|
+
## Issues Found
|
|
864
|
+
|
|
865
|
+
### 1. Hardcoded Path in `llm prov`
|
|
866
|
+
|
|
867
|
+
**File:** `scout_commands/llm/prov`, near the end:
|
|
868
|
+
|
|
869
|
+
```ruby
|
|
870
|
+
filename ||= "~/git/workflows/SC26/chats/network_usecase/3.1.themes"
|
|
871
|
+
```
|
|
872
|
+
|
|
873
|
+
This is a developer-specific fallback path that will be confusing or broken
|
|
874
|
+
for other users. Should be removed or changed to raise an error if no filename
|
|
875
|
+
is provided.
|
|
876
|
+
|
|
877
|
+
### 2. Monkey-Patching in `llm prov`
|
|
878
|
+
|
|
879
|
+
The `prov` command redefines `Chat.trace_chats`, `Chat.token_totals`,
|
|
880
|
+
`Chat.job_agent_chat_files`, and adds `Chat.provenance`,
|
|
881
|
+
`Chat.provenance_chat_files`, `Chat.tokens`, and `Step#agent_chats` at
|
|
882
|
+
runtime. This diverges from the library API and creates maintenance risk.
|
|
883
|
+
The `info` command achieves the same results without monkey-patching.
|
|
884
|
+
|
|
885
|
+
### 3. `llm process` and `process_queries` Use Relay Backend
|
|
886
|
+
|
|
887
|
+
Both commands explicitly `require 'scout/llm/backends/relay'`. This backend
|
|
888
|
+
may not be the standard path for current LLM operations. The infinite-loop
|
|
889
|
+
daemon pattern is dated compared to Scout's workflow-based job execution
|
|
890
|
+
model.
|
|
891
|
+
|
|
892
|
+
### 4. `documenter` Has No Options
|
|
893
|
+
|
|
894
|
+
The documenter command accepts only a topic positional argument. There is no
|
|
895
|
+
way to specify output directory, model, endpoint, agent configuration, or
|
|
896
|
+
dry-run mode. The system prompt and documentation strategy are entirely
|
|
897
|
+
hardcoded.
|
|
898
|
+
|
|
899
|
+
### 5. `documenter` Source-Test File Mapping
|
|
900
|
+
|
|
901
|
+
The `source_to_test` method assumes a rigid `./lib/` → `./test/` path mapping
|
|
902
|
+
with `test_` prefix on filenames. This will not work for all project
|
|
903
|
+
layouts.
|
|
904
|
+
|
|
905
|
+
### 6. `llm server` Fall-back Behavior
|
|
906
|
+
|
|
907
|
+
The `/run` endpoint falls back to a simulated reply (`"assistant: (simulated
|
|
908
|
+
reply)\n"`) when no LLM is defined. This could be confusing in production
|
|
909
|
+
use—users may not realize their LLM configuration is missing.
|
|
910
|
+
|
|
911
|
+
### 7. `agent ask` Inline Mode: `break if post.empty?` vs `break if question.empty?`
|
|
912
|
+
|
|
913
|
+
The `agent ask` inline mode uses `break if post.empty?` (checking the
|
|
914
|
+
remainder after the match), while `llm ask` uses `break if question.empty?`
|
|
915
|
+
(checking the matched question). This is a subtle behavioral difference that
|
|
916
|
+
could cause the last section of a file to be skipped in one but not the
|
|
917
|
+
other.
|
|
918
|
+
|
|
919
|
+
### 8. `agent kb` Lacks `require 'scout-ai'`
|
|
920
|
+
|
|
921
|
+
The `agent kb` command does not explicitly `require 'scout-ai'` at the top
|
|
922
|
+
(though it relies on `Scout.var.Agent`). It may work because the parent
|
|
923
|
+
`scout-ai` process already loaded the library, but this is an implicit
|
|
924
|
+
dependency.
|
|
925
|
+
|
|
926
|
+
---
|
|
927
|
+
|
|
928
|
+
## `info` vs. `prov`: Final Verdict
|
|
929
|
+
|
|
930
|
+
The research artifact 07 states that `info` is NOT outdated and is in fact
|
|
931
|
+
the more modern command. **This is confirmed.**
|
|
932
|
+
|
|
933
|
+
| Criterion | `info` | `prov` |
|
|
934
|
+
|---|---|---|
|
|
935
|
+
| Last meaningful update | 2026-07-20 | 2026-07-30 (but monkey-patches remain) |
|
|
936
|
+
| Uses library API directly | ✅ | ❌ (monkey-patches) |
|
|
937
|
+
| Import discovery | ✅ | ❌ |
|
|
938
|
+
| Job deduplication | ✅ | ❌ |
|
|
939
|
+
| Flow visualization (text) | ✅ (`-f`) | ❌ |
|
|
940
|
+
| Graphviz DOT/SVG/PNG/PDF | ✅ (`--dot`, `--plot`) | ❌ |
|
|
941
|
+
| Warnings on load failures | ✅ | ❌ |
|
|
942
|
+
| Hardcoded paths | ❌ (none) | ✅ (`~/git/workflows/SC26/...`) |
|
|
943
|
+
| Machine-readable output | Partial (DOT is text) | ❌ |
|
|
944
|
+
|
|
945
|
+
**Recommendation:** `info` should be documented as the primary provenance
|
|
946
|
+
command. `prov` should be marked as deprecated/superseded in user-facing
|
|
947
|
+
documentation, though it remains functional.
|