@j-o-r/hello-dave 0.0.3 → 0.0.4

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 (119) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +216 -56
  3. package/README.md.bak +481 -0
  4. package/README.md.bak.1774780058 +338 -0
  5. package/README.md.bak2 +455 -0
  6. package/docs.bak.1774780058/agent-manager.md +167 -0
  7. package/docs.bak.1774780058/agent-manager.md.bak +137 -0
  8. package/docs.bak.1774780058/agent-manager.md.bak2 +157 -0
  9. package/docs.bak.1774780058/codeserver-pattern.md +191 -0
  10. package/docs.bak.1774780058/path-resolution-best-practices.md +104 -0
  11. package/docs.bak.1774780058/project-overview.md +67 -0
  12. package/docs.bak.1774780058/project-overview.md.bak +67 -0
  13. package/docs.bak.1774780058/prompt-class.md +141 -0
  14. package/docs.bak.1774780058/prompt-class.md.bak +142 -0
  15. package/docs.bak.1774780058/tools-syntax-validation.md +121 -0
  16. package/docs.bak.1774780058/tools-syntax-validation.md.bak2 +125 -0
  17. package/docs.bak.1774780058/tools-syntax-validation.md.bak3 +125 -0
  18. package/docs.bak.1774780058/tools-syntax-validation.md.bak4 +106 -0
  19. package/docs.bak.1774780058/tools-syntax-validation.md.bak_path +106 -0
  20. package/docs.bak.1774780058/toolset.md +164 -0
  21. package/docs.bak.1774780058/toolset.md.bak +94 -0
  22. package/docs.bak.1774780058/toolset.md.bak3 +161 -0
  23. package/docs.bak.1774780058/toolset.md.bak4 +161 -0
  24. package/docs.bak.1774780058/toolset.md.bak5 +161 -0
  25. package/docs.bak.1774780058/toolset.md.bak6 +163 -0
  26. package/docs.bak.1774780058/toolset.md.bak_path +163 -0
  27. package/docs.bak.1774780058/toolset.md.bak_syntax +161 -0
  28. package/docs.bak.1774780058/xai-responses.md +111 -0
  29. package/docs.bak.1774780058/xai-responses.md.bak +107 -0
  30. package/docs.bak.1774780058/xai-responses.md.bak2 +107 -0
  31. package/docs.bak.1774780058/xai_collections.md +106 -0
  32. package/examples/ask_agent.js +137 -0
  33. package/examples/code_agent.js +149 -0
  34. package/examples/coderev_agent.js +136 -0
  35. package/examples/codeserver.sh +47 -0
  36. package/examples/daisy_agent.js +170 -0
  37. package/examples/docs_agent.js +148 -0
  38. package/examples/gpt_agent.js +125 -0
  39. package/examples/grok_agent.js +132 -0
  40. package/examples/grok_agent.js.bak +98 -0
  41. package/examples/grok_agent.js.bak.2 +99 -0
  42. package/examples/grok_agent.js.bak.3 +1 -0
  43. package/examples/grok_agent.js.bak.4 +124 -0
  44. package/examples/grok_agent.js.bak.5 +1 -0
  45. package/examples/grok_agent.js.bak.6 +1 -0
  46. package/examples/memory_agent.js +152 -0
  47. package/examples/npm_agent.js +202 -0
  48. package/examples/npm_agent.js.bak.3 +2 -0
  49. package/examples/npm_agent.js.bak.4 +205 -0
  50. package/examples/npm_agent.js.bak.5 +1 -0
  51. package/examples/npm_agent.js.bak.6 +1 -0
  52. package/examples/prompt_agent.js +133 -0
  53. package/examples/readme_agent.js +148 -0
  54. package/examples/spawn_agent.js +293 -0
  55. package/examples/test_agent.js +187 -0
  56. package/examples/todo_agent.js +175 -0
  57. package/{examples/codeDave.js → examples.bak.1774780058/code_agent.js} +40 -6
  58. package/{examples/CodeServer → examples.bak.1774780058/codeserver.sh} +9 -5
  59. package/examples.bak.1774780058/memory_agent.js +112 -0
  60. package/{examples/spawndave.js → examples.bak.1774780058/spawn_agent.js} +29 -6
  61. package/examples.bak.1774780058/test_agent.js +162 -0
  62. package/{examples/todoDave.js → examples.bak.1774780058/todo_agent.js} +8 -2
  63. package/lib/API/x.ai/responses.js +7 -9
  64. package/lib/AgentManager.js +3 -2
  65. package/lib/AgentServer.js +23 -19
  66. package/lib/genericToolset.js +159 -26
  67. package/lib/genericToolset.js.bak_syntax +402 -0
  68. package/lib/wsCli.js +0 -1
  69. package/package.json +4 -5
  70. package/scenarios.bak.1774780058/data/eval_node_message.json +9 -0
  71. package/scenarios.bak.1774780058/data/hist_oa.json +66 -0
  72. package/scenarios.bak.1774780058/data/o3_response1.json +96 -0
  73. package/scenarios.bak.1774780058/data/oa_reasoning_parse.json +112 -0
  74. package/scenarios.bak.1774780058/data/tool_oa.json +96 -0
  75. package/scenarios.bak.1774780058/data/tool_xai.json +59 -0
  76. package/scenarios.bak.1774780058/data/tool_xai2.json +40 -0
  77. package/scenarios.bak.1774780058/data/xai-response-1.json +59 -0
  78. package/scenarios.bak.1774780058/data/xai-response-2.json +10 -0
  79. package/scenarios.bak.1774780058/data/xai_reasoning_tools_resp.json +59 -0
  80. package/scenarios.bak.1774780058/data/xai_search_response.json +58 -0
  81. package/scenarios.bak.1774780058/environment.js +10 -0
  82. package/scenarios.bak.1774780058/example.js +17 -0
  83. package/scenarios.bak.1774780058/genericToolset.test.js +182 -0
  84. package/scenarios.bak.1774780058/grok.js +113 -0
  85. package/scenarios.bak.1774780058/memory-tools.js +51 -0
  86. package/scenarios.bak.1774780058/openai-o3.js +137 -0
  87. package/scenarios.bak.1774780058/openai-prompt.js +155 -0
  88. package/scenarios.bak.1774780058/openai-session.js +148 -0
  89. package/scenarios.bak.1774780058/openai.js +102 -0
  90. package/scenarios.bak.1774780058/prompt.js +118 -0
  91. package/scenarios.bak.1774780058/promptFishbowl.js +76 -0
  92. package/scenarios.bak.1774780058/search.brave.com.js +25 -0
  93. package/scenarios.bak.1774780058/sh.js +15 -0
  94. package/scenarios.bak.1774780058/test-wsio.js +26 -0
  95. package/scenarios.bak.1774780058/testToolset.js +42 -0
  96. package/scenarios.bak.1774780058/toolset.js +16 -0
  97. package/scenarios.bak.1774780058/toolset.test.js +141 -0
  98. package/scenarios.bak.1774780058/write_file_syntax.test.js +145 -0
  99. package/scenarios.bak.1774780058/write_file_validation/README.md +30 -0
  100. package/scenarios.bak.1774780058/write_file_validation/bad.js +3 -0
  101. package/scenarios.bak.1774780058/write_file_validation/good.js +4 -0
  102. package/scenarios.bak.1774780058/write_file_validation/test.sh +43 -0
  103. package/scenarios.bak.1774780058/wsClient.js +69 -0
  104. package/scenarios.bak.1774780058/xai_responses.integration.test.js +57 -0
  105. package/scenarios.bak.1774780058/xai_responses.test.js +154 -0
  106. package/scenarios.bak.1774780058/xaicoll.js +50 -0
  107. package/scenarios.bak.1774780058/xaifiles.js +48 -0
  108. package/types/AgentManager.d.ts +4 -3
  109. package/utils/syntax_check.sh +61 -0
  110. package/utils/test.sh +46 -0
  111. /package/{examples/askDave.js → examples.bak.1774780058/ask_agent.js} +0 -0
  112. /package/{examples/coderev.js → examples.bak.1774780058/coderev_agent.js} +0 -0
  113. /package/{examples/daisy.js → examples.bak.1774780058/daisy_agent.js} +0 -0
  114. /package/{examples/docsDave.js → examples.bak.1774780058/docs_agent.js} +0 -0
  115. /package/{examples/gpt.js → examples.bak.1774780058/gpt_agent.js} +0 -0
  116. /package/{examples/grok.js → examples.bak.1774780058/grok_agent.js} +0 -0
  117. /package/{examples/npmDave.js → examples.bak.1774780058/npm_agent.js} +0 -0
  118. /package/{examples/promptDave.js → examples.bak.1774780058/prompt_agent.js} +0 -0
  119. /package/{examples/readmeDave.js → examples.bak.1774780058/readme_agent.js} +0 -0
@@ -0,0 +1,338 @@
1
+ # @j-o-r/hello-dave
2
+
3
+ [![npm version](https://badge.fury.io/js/%40j-o-r%2Fhello-dave.svg)](https://www.npmjs.com/package/%40j-o-r%2Fhello-dave)
4
+ [![Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
5
+ [![Node.js >=20](https://img.shields.io/badge/Node.js-%3E=20-green.svg)](https://nodejs.org/)
6
+
7
+ ## Table of Contents
8
+
9
+ - [Description](#description)
10
+ - [Features](#features)
11
+ - [Installation](#installation)
12
+ - [Quick Start](#quick-start)
13
+ - [Usage](#usage)
14
+ - [Examples](#examples)
15
+ - [Development](#development)
16
+ - [Changelog](#changelog)
17
+ - [Contributing](#contributing)
18
+ - [License](#license)
19
+ - [TODO Alignment](#todo-alignment)
20
+
21
+ ## Description
22
+
23
+ **@j-o-r/hello-dave** is a lightweight, ESM-only Node.js framework for building intelligent AI agents powered by large language models (LLMs) such as xAI Grok, Anthropic Claude, or OpenAI GPT. It simplifies the creation of custom agents with features like the central `AgentManager` class, WebSocket-based client/server support for networked agents, seamless tool integration (e.g., bash execution, web search), customizable system prompts, and robust session management supporting large context windows (up to millions of tokens).
24
+
25
+ The framework emphasizes ease of use, allowing developers and non-experts alike to rapidly prototype and deploy specialized agents. Core integrations include unified xAI Grok API access, WebSocket (WS) networking with secret-based authentication, and direct CLI/cron messaging (no heartbeat/ping mechanism required). Example scripts like `readmeDave`, `todoDave`, and others have been reorganized into the `examples/` folder for clarity.
26
+
27
+ Whether you're building a code reviewer, a research assistant, or a creative collaborator, `@j-o-r/hello-dave` abstracts away API complexities, providing a unified interface across providers. It's alpha-stage but production-ready for personal projects, with persistence for sessions and logs in NDJSON format.
28
+
29
+ ## Features
30
+
31
+ - **Unified LLM Access**: Seamless integration with xAI Grok API, Anthropic Claude, and OpenAI GPT via a single API.
32
+ - **AgentManager Class**: Core orchestrator for prompts, tools, sessions, and interactions (CLI, direct calls, WebSocket).
33
+ - **Tool Integration**: Built-in tools for bash scripting, web search, JavaScript execution, and more; easily extensible.
34
+ - **WebSocket Networking with Secrets**: Agents can act as servers or clients with optional secret authentication, enabling secure distributed agent networks across machines.
35
+ - **Direct CLI/Cron Messaging**: Simplified interactions without needing heartbeat mechanisms—ideal for scheduled tasks.
36
+ - **Customizable Prompts**: Tailor agent behavior with system prompts for specialized tasks (e.g., music production, code analysis).
37
+ - **Session Management**: Persistent conversations with large context windows; automatic truncation and history search.
38
+ - **CLI Utilities**: Core tool at `bin/dave.js` for cache management, WS connections, and interactive queries; plus agent generator.
39
+ - **Lightweight & TypeScript-Friendly**: ESM-only, no heavy deps; full types included.
40
+ - **Memory Tools**: Generic tools `memory_recall` and `memory_write` for persisting and recalling tasks, errors, and preferences in `.cache/memory.ndjson`, optimizing loops and long-running agent sessions (available in `toolsetMode: 'auto'`).
41
+
42
+ ## Installation
43
+
44
+ Install as a dependency in your Node.js project (requires Node.js >= 20 with `"type": "module"` in `package.json`):
45
+
46
+ ```bash
47
+ npm install @j-o-r/hello-dave
48
+ ```
49
+
50
+ For global access to CLI tools (including `dave` from `bin/dave.js`):
51
+
52
+ ```bash
53
+ npm install -g @j-o-r/hello-dave
54
+ ```
55
+
56
+ Set your API keys via environment variables (only set what you need):
57
+ - `XAIKEY` for xAI Grok
58
+ - `ANTHKEY` for Anthropic Claude
59
+ - `OPENAIKEY` for OpenAI GPT
60
+ - `BRAVESEARCHKEY` for web search (optional)
61
+
62
+ Create a cache directory for sessions:
63
+ ```bash
64
+ mkdir .cache
65
+ ```
66
+
67
+ ## Quick Start
68
+
69
+ 1. Set an API key (e.g., for Grok):
70
+ ```bash
71
+ export XAIKEY=your_xai_api_key
72
+ ```
73
+
74
+ 2. Use the core CLI utility `bin/dave.js` for interactive queries or management:
75
+ ```bash
76
+ npx @j-o-r/hello-dave dave --ask
77
+ ```
78
+ - Launches an interactive agent session. Use `Alt+d` to exit, `Alt+r` to reset.
79
+ - Example: Ask questions about anything; it uses xAI Grok by default with web search and X search tools.
80
+
81
+ 3. For one-shot queries via piped input:
82
+ ```bash
83
+ echo "Explain quantum computing" | npx @j-o-r/hello-dave dave --ask --model grok-4
84
+ ```
85
+ - Provides a direct response using the specified model (e.g., `--model grok-4`).
86
+
87
+ 4. Connect to a WebSocket server (e.g., for networked agents):
88
+ ```bash
89
+ npx @j-o-r/hello-dave dave --connect ws://localhost:8080 --secret your_secret
90
+ ```
91
+
92
+ 5. Generate a custom agent using the portable `spawn_agent` tool (CLI/WS agents + CodeServer launchers):
93
+ ```bash
94
+ npx @j-o-r/hello-dave spawn_agent
95
+ ```
96
+ - Interactive: Follow prompts to create a new agent script in `bin/` (e.g., `bin/myagent.js`).
97
+ - Portable to any project (auto-installs deps like `@j-o-r/hello-dave`):
98
+ ```bash
99
+ npx @j-o-r/hello-dave spawn_agent --cwd ~/my-project
100
+ ```
101
+ - Supports one-shot: `echo "Create code-review agent" | npx @j-o-r/hello-dave spawn_agent --cwd ~/proj`.
102
+ - Aligns with CodeServer pattern for multi-agent setups (see Usage/Examples).
103
+
104
+ `bin/dave.js` also supports cache operations like `--list` (list sessions), `--search "query"`, `--clear`, and `--inspect path/to/log.ndjson`.
105
+
106
+ ## Usage
107
+
108
+ ### Core CLI via `bin/dave.js`
109
+
110
+ `bin/dave.js` provides essential utilities and examples for agent spawning, WS interactions, and basic querying. Key commands:
111
+
112
+ - **Ask Mode** (Interactive or Piped One-Shot):
113
+ ```bash
114
+ # Interactive
115
+ npx @j-o-r/hello-dave dave --ask --model grok-4 --temperature 0.2
116
+
117
+ # Piped one-shot
118
+ echo "What is quantum computing?" | npx @j-o-r/hello-dave dave --ask --model grok-4
119
+ ```
120
+ - Note: Piped input triggers a direct response via `directCall`; without pipe, it launches an interactive CLI session.
121
+ - `--model` option works for both modes (e.g., `grok-4`, `grok-4-1-fast-reasoning`).
122
+ - Uses `AgentManager` with xAI Grok API integration, adds tools like `web_search`, `x_search`, `open_link`, `send_email`, `history_search`.
123
+ - System prompt emphasizes brief, direct responses with step-by-step reasoning.
124
+
125
+ - **SpawnDave Mode** (Portable Agent Creator with --cwd Support):
126
+ ```bash
127
+ # Interactive in current project
128
+ npx @j-o-r/hello-dave spawn_agent --model grok-4-fast-reasoning --temperature 0.7
129
+
130
+ # Portable to another project (switches cwd, auto-deps)
131
+ npx @j-o-r/hello-dave spawn_agent --cwd ../other-proj
132
+
133
+ # One-shot for quick generation
134
+ echo "name=coderev desc=Git diff analyzer tools=read_file execute_bash_script web_search" | npx @j-o-r/hello-dave spawn_agent --cwd ~/my-proj
135
+ ```
136
+ - Creates production-ready CLI/WS agents (`bin/<name>.js`) supporting CLI, server (`--serve`), client (`--connect`), and hybrid modes.
137
+ - Generates multi-agent CodeServer launchers (`examples/<Name>Server`) using PM2 for persistent networked setups (main server + sub-agents).
138
+ - **Portable**: Runs via `npx` anywhere—no local install needed. Auto-inspects project, installs `@j-o-r/hello-dave @j-o-r/sh` if missing, validates ESM code (`node --check`), tests deployment.
139
+ - Aligns with CodeServer pattern: Self-contained Bash launchers for PM2-managed multi-agents (e.g., code review + TODO + NPM agents).
140
+ - Requires `XAIKEY`; uses online repo docs (https://codeberg.org/duin/hello-dave) for portability.
141
+ - Example output: Deploys `bin/coderev_agent.js`, tests it, provides server/client usage guide.
142
+
143
+ - **WebSocket Client Mode** (with secrets for secure networking):
144
+ ```bash
145
+ # Interactive connection
146
+ npx @j-o-r/hello-dave dave --connect ws://localhost:8080 --secret "mysecret"
147
+
148
+ # Piped one-shot (direct CLI/cron messaging, no heartbeat needed)
149
+ echo "Predict the weather" | npx @j-o-r/hello-dave dave --connect ws://localhost:8080 --secret "mysecret"
150
+ echo "user_reset" | npx @j-o-r/hello-dave dave --connect ws://localhost:8080 --secret "mysecret"
151
+ ```
152
+
153
+ - **Cache Management**:
154
+ ```bash
155
+ npx @j-o-r/hello-dave dave --list # List sessions
156
+ npx @j-o-r/hello-dave dave --search "AI agents" # Search history
157
+ npx @j-o-r/hello-dave dave --clear # Clear cache
158
+ ```
159
+
160
+ For custom agents, use `AgentManager` programmatically (see Examples).
161
+
162
+ ### Programmatic Usage with AgentManager
163
+
164
+ ```javascript
165
+ import AgentManager from '@j-o-r/hello-dave';
166
+
167
+ const agent = new AgentManager({ name: 'MyAgent', secret: 'optional_secret' });
168
+ agent.setup({
169
+ prompt: 'You are a helpful assistant...',
170
+ api: 'xai', // Uses unified xAI Grok API access
171
+ options: { model: 'grok-4', temperature: 0.7, tools: [{ type: 'web_search' }] },
172
+ toolsetMode: 'auto',
173
+ contextWindow: 500000
174
+ });
175
+
176
+ agent.addGenericToolcall('execute_bash_script'); // Post-setup generics
177
+ agent.addGenericToolcall('read_file');
178
+ agent.addGenericToolcall('write_file');
179
+ agent.addGenericToolcall('memory_recall'); // Persist/recall tasks, errors, prefs in .cache/memory.ndjson
180
+ agent.addGenericToolcall('memory_write'); // Optimizes loops and long-running sessions
181
+
182
+ await agent.start(); // Interactive CLI
183
+ // Or: await agent.start(undefined, 8000, undefined, 'Intro', 'toolName', 'desc'); // WS server
184
+ // Or: const response = await agent.directCall('Query'); // One-shot
185
+ ```
186
+
187
+ Direct CLI/cron: Pipe inputs to custom scripts for non-interactive use. WS supports secrets for authentication; no heartbeat required due to event-driven messaging.
188
+
189
+ The `memory_recall` and `memory_write` tools, available when `toolsetMode: 'auto'`, enable agents to persist and recall tasks, errors, and preferences in `.cache/memory.ndjson`. This optimizes iterative loops and long-running sessions by maintaining state across interactions without relying solely on session history.
190
+
191
+ ## Examples
192
+
193
+ Example scripts (e.g., `readme_agent.js` for README management, `todo_agent.js` for task handling, `spawn_agent.js` for agent creation) are now organized in the `examples/` folder. These demonstrate specialized agents using `AgentManager`, xAI Grok API integration, and tools. **Note**: Agent names and filenames follow lowercase naming rules per [docs/agent-manager.md](docs/agent-manager.md) (regex `/^[a-z_0-9_]{2,}$/` for safety in folders, tools, and filesystems—no uppercase, hyphens, or specials).
194
+
195
+ - **Link to Examples Folder**: Explore [examples/](examples/) for full scripts like `daisy_agent.js` (music agent), `code_agent.js` (code review), `npm_agent.js` (NPM inspector).
196
+
197
+ In custom agents, consider adding `memory_recall` and `memory_write` tools to enable state persistence for complex workflows, such as tracking progress in multi-step tasks or storing user preferences across sessions.
198
+
199
+ ### Persistent Multi-Agent CodeServer Pattern
200
+
201
+ The `examples/CodeServer` script provides a persistent multi-agent setup using PM2 to manage long-running processes. It starts a main code agent as a WebSocket server on a specified port, with sub-agents (for TODO, README, NPM, and docs tasks) attached as clients. This pattern enables a networked ecosystem of specialized agents that maintain state across sessions, ideal for extended development workflows where context persistence and task delegation are key.
202
+
203
+ Benefits include seamless integration for dev sessions—agents stay online, handling queries via WS without restarts, supporting large context windows and tool calls. For full details, see [docs/codeserver-pattern.md](docs/codeserver-pattern.md).
204
+
205
+ **Usage:**
206
+
207
+ ```bash
208
+ # Start the CodeServer (requires PM2: npm i -g pm2)
209
+ ./examples/CodeServer 8080 mysecret
210
+
211
+ # Connect via CLI (interactive or piped)
212
+ npx @j-o-r/hello-dave dave --connect ws://127.0.0.1:8080/ws --secret mysecret
213
+ # Or for one-shot: echo "Review this code" | npx @j-o-r/hello-dave dave --connect ws://127.0.0.1:8080/ws --secret mysecret
214
+ ```
215
+
216
+ Monitor with `pm2 list` and stop via `pm2 delete <name>`.
217
+
218
+ ### Snippet: Spawning Agents (Portable via `bin/dave.js` --spawn_agent)
219
+
220
+ `spawn_agent` uses `AgentManager` to interactively generate new agent scripts, now fully aware of WebSocket server/client modes and the CodeServer multi-agent pattern for networked setups.
221
+
222
+ Now CodeServer-aware: Can generate PM2 multi-agent launchers (e.g., 'Generate CodeServer for coderev + todo'). See updated [examples/spawn_agent.js](examples/spawn_agent.js) and [docs/codeserver-pattern.md](docs/codeserver-pattern.md).
223
+
224
+ **Portable**: `spawn_agent` is fully portable—no local docs/examples needed. Uses online repo links (https://codeberg.org/duin/hello-dave). Works in any project via `npx` (auto-deps with `--cwd`).
225
+
226
+ ```javascript
227
+ // Core setup in spawn_agent
228
+ const agent = new AgentManager({ name: 'spawn_agent', secret });
229
+ agent.setup({
230
+ prompt: 'You are AgentCreator... [detailed prompt for portability, validation]',
231
+ api: 'xai',
232
+ options: { model: 'grok-4-fast-reasoning', tools: [{ type: 'web_search' }], reasoning: { effort: 'high' } },
233
+ toolsetMode: 'auto',
234
+ contextWindow: 500000
235
+ });
236
+ agent.addGenericToolcall('execute_bash_script'); // For project inspection
237
+ agent.addGenericToolcall('read_file');
238
+ agent.addGenericToolcall('write_file'); // For generating bin/ scripts
239
+ agent.addGenericToolcall('memory_recall'); // For recalling previous generations or prefs
240
+ agent.addGenericToolcall('memory_write'); // For persisting agent configs or errors
241
+
242
+ await agent.start(); // Guides user to create e.g., bin/myagent.js
243
+ ```
244
+
245
+ - Validates generated ESM code with `node --check` and tool rules (xAI natives pre-setup, generics post-setup).
246
+ - Ensures absolute imports for portability.
247
+
248
+ **Example Usage:**
249
+
250
+ ```bash
251
+ # Interactive spawning (runs from npm without cloning; current dir)
252
+ npx @j-o-r/hello-dave spawn_agent
253
+
254
+ # Portable to specific project (auto-switches cwd, installs deps if needed)
255
+ npx @j-o-r/hello-dave spawn_agent --cwd ~/my-proj
256
+
257
+ # Piped one-shot for CodeServer launcher (portable, no cloning)
258
+ echo "Generate CodeServer launcher for coderev + tododave" | npx @j-o-r/hello-dave spawn_agent --cwd ~/proj
259
+ ```
260
+
261
+ ### Snippet: Using xAI Grok API Integration
262
+
263
+ The unified xAI Grok API access supports options like reasoning and tools:
264
+
265
+ ```javascript
266
+ // In AgentManager setup
267
+ const options = {
268
+ model: 'grok-4-1-fast-reasoning',
269
+ temperature: 0.8,
270
+ tools: [{ type: 'web_search' }, { type: 'x_search', from_date: '2024-01-01' }], // Native xAI tools
271
+ reasoning: { effort: 'medium', summary: 'auto' } // Chain-of-thought support
272
+ };
273
+ ```
274
+
275
+ Detailed examples for xAI integration (e.g., advanced tool calls, reasoning) are planned (see TODO).
276
+
277
+ ### Running Examples
278
+
279
+ ```bash
280
+ # Music agent (examples/daisy_agent.js)
281
+ chmod +x examples/daisy_agent.js
282
+ ./examples/daisy_agent.js "Generate lyrics for a pop song"
283
+
284
+ # TODO manager (examples/todo_agent.js)
285
+ ./examples/todo_agent.js --connect ws://localhost:8080 --secret "secret"
286
+
287
+ # Server setup for networked examples
288
+ npx @j-o-r/hello-dave dave --ask --serve 8080 # Expose as WS server
289
+ ```
290
+
291
+ ## Development
292
+
293
+ - **Scripts**: `npm test` (runs scenarios/grok_agent.js), `npm run types` (generate TypeScript defs), `npm run release` (pack for release).
294
+ - **Structure**: Core in `lib/` (AgentManager.js, wsCli.js, etc.), API integrations in `lib/API/`, examples in `examples/`, utils in `utils/`.
295
+ - **Testing**: Basic validation via `npm test`. Unit tests for xAI integration planned (see TODO).
296
+ - **Prep for v0.0.4**: Focus on spawnDave enhancements and release testing.
297
+
298
+ ## Changelog
299
+
300
+ ### v0.0.4 (Prep - March 2026)
301
+ - Reorganized examples to `examples/` folder (readmeDave, todoDave, etc.).
302
+ - Enhanced `bin/dave.js` for core utilities: spawning, WS with secrets, direct messaging.
303
+ - Improved xAI Grok API integration; added native tools/reasoning support.
304
+ - Removed heartbeat needs; direct CLI/cron support.
305
+ - Added piped one-shot support to dave --ask.
306
+ - TODO alignment: High-priority items noted (release prep, spawnDave enhancements).
307
+
308
+ ### v0.0.3 (Previous)
309
+ - Initial WS secrets, generic tools, AgentManager refinements.
310
+
311
+ Full history in git tags.
312
+
313
+ ## Contributing
314
+
315
+ Contributions are welcome! Fork the repo at [https://codeberg.org/duin/hello-dave](https://codeberg.org/duin/hello-dave), create a feature branch, and submit a pull request.
316
+
317
+ 1. Install deps: `npm install`
318
+ 2. Self dep `npm run link-self`
319
+ 3. Run tests: `npm test`
320
+ 4. Generate types: `npm run types`
321
+ 5. Report issues: [https://codeberg.org/duin/hello-dave/issues](https://codeberg.org/duin/hello-dave/issues)
322
+
323
+ Follow the [Code of Conduct](CODE_OF_CONDUCT.md) and Apache-2.0 license.
324
+
325
+ ## License
326
+
327
+ Apache License 2.0. See [LICENSE](LICENSE) for details.
328
+
329
+ ## TODO Alignment
330
+
331
+ This README aligns with high-priority items from [TODO.md](TODO.md):
332
+ - **v0.0.4 Prep**: Changelog snippet added; release testing emphasized in Development.
333
+ - **spawnDave Enhancements**: Highlighted in Examples with portability notes.
334
+ - xAI integration tests/examples: Deferred to later (general enhancements).
335
+ - Documentation tasks (e.g., AgentManager internals) integrated into Usage/Examples.
336
+ - Deferred: Other xAI features to later; focus on core release and spawnDave.
337
+
338
+ For full TODO, see [TODO.md](TODO.md).