@j-o-r/hello-dave 0.0.4 → 0.0.5
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.
- package/CHANGELOG.md +28 -17
- package/README.md +160 -51
- package/README.md.bak +106 -64
- package/README.md.bak2 +194 -118
- package/bin/dave.js +33 -22
- package/examples/gpt_agent.js +3 -6
- package/lib/ToolSet.js +4 -1
- package/lib/index.js +5 -1
- package/package.json +3 -3
- package/types/index.d.ts +3 -1
- package/examples/coderev_agent.js +0 -136
- package/examples/grok_agent.js.bak +0 -98
- package/examples/grok_agent.js.bak.2 +0 -99
- package/examples/grok_agent.js.bak.3 +0 -1
- package/examples/grok_agent.js.bak.4 +0 -124
- package/examples/grok_agent.js.bak.5 +0 -1
- package/examples/grok_agent.js.bak.6 +0 -1
- package/examples/npm_agent.js.bak.3 +0 -2
- package/examples/npm_agent.js.bak.4 +0 -205
- package/examples/npm_agent.js.bak.5 +0 -1
- package/examples/npm_agent.js.bak.6 +0 -1
- /package/{examples → bin}/spawn_agent.js +0 -0
package/README.md.bak2
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# Updated README.md: v0.0.5 Released; --spawn Flag & CodeServer Enhancements
|
|
2
|
+
|
|
1
3
|
# @j-o-r/hello-dave
|
|
2
4
|
|
|
3
5
|
[](https://www.npmjs.com/package/%40j-o-r%2Fhello-dave)
|
|
@@ -25,7 +27,7 @@
|
|
|
25
27
|
|
|
26
28
|
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.
|
|
27
29
|
|
|
28
|
-
Whether
|
|
30
|
+
Whether youre 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. Its alpha-stage but production-ready for personal projects, with persistence for sessions and logs in NDJSON format.
|
|
29
31
|
|
|
30
32
|
## Features
|
|
31
33
|
|
|
@@ -36,9 +38,9 @@ Whether you're building a code reviewer, a research assistant, or a creative col
|
|
|
36
38
|
- **Direct CLI/Cron Messaging**: Simplified interactions without needing heartbeat mechanisms—ideal for scheduled tasks.
|
|
37
39
|
- **Customizable Prompts**: Tailor agent behavior with system prompts for specialized tasks (e.g., music production, code analysis).
|
|
38
40
|
- **Session Management**: Persistent conversations with large context windows; automatic truncation and history search.
|
|
39
|
-
- **CLI Utilities**: Core tool at `bin/dave.js` for cache management, WS connections, and
|
|
41
|
+
- **CLI Utilities**: Core tool at `bin/dave.js` for cache management, WS connections, interactive queries, spawning agents, and CodeServer launches; plus agent generator.
|
|
40
42
|
- **Lightweight & TypeScript-Friendly**: ESM-only, no heavy deps; full types included.
|
|
41
|
-
- **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:
|
|
43
|
+
- **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`).
|
|
42
44
|
|
|
43
45
|
## Installation
|
|
44
46
|
|
|
@@ -72,11 +74,11 @@ mkdir .cache
|
|
|
72
74
|
export XAIKEY=your_xai_api_key
|
|
73
75
|
```
|
|
74
76
|
|
|
75
|
-
2. Use the core CLI utility `bin/dave.js` for interactive queries or management:
|
|
77
|
+
2. Use the core CLI utility `bin/dave.js` (not a full agent) for interactive queries or management:
|
|
76
78
|
```bash
|
|
77
79
|
npx @j-o-r/hello-dave dave --ask
|
|
78
80
|
```
|
|
79
|
-
- Launches an interactive agent session. Use `Alt+d` to exit, `Alt+r` to reset.
|
|
81
|
+
- Launches an interactive agent session using default Grok tools. Use `Alt+d` to exit, `Alt+r` to reset.
|
|
80
82
|
- Example: Ask questions about anything; it uses xAI Grok by default with web search and X search tools.
|
|
81
83
|
|
|
82
84
|
3. For one-shot queries via piped input:
|
|
@@ -85,9 +87,9 @@ mkdir .cache
|
|
|
85
87
|
```
|
|
86
88
|
- Provides a direct response using the specified model (e.g., `--model grok-4`).
|
|
87
89
|
|
|
88
|
-
4. Connect to a WebSocket server (
|
|
90
|
+
4. Connect to a WebSocket server using the CLI utility (for UI access to servers):
|
|
89
91
|
```bash
|
|
90
|
-
npx @j-o-r/hello-dave dave --connect ws://localhost:8080 --secret your_secret
|
|
92
|
+
Utility: npx @j-o-r/hello-dave dave --connect ws://localhost:8080 --secret your_secret
|
|
91
93
|
```
|
|
92
94
|
|
|
93
95
|
5. Generate a custom agent using the portable `spawn_agent` tool (CLI/WS agents + CodeServer launchers):
|
|
@@ -102,15 +104,15 @@ mkdir .cache
|
|
|
102
104
|
- Supports one-shot: `echo "Create code-review agent" | npx @j-o-r/hello-dave spawn_agent --cwd ~/proj`.
|
|
103
105
|
- Aligns with CodeServer pattern for multi-agent setups (see Usage/Examples).
|
|
104
106
|
|
|
105
|
-
`bin/dave.js` also supports cache operations like `--list` (list sessions), `--search "query"`, `--clear`, and `--inspect path/to/log.ndjson`.
|
|
107
|
+
`bin/dave.js` also supports cache operations like `--list` (list sessions), `--search "query"`, `--clear`, and `--inspect path/to/log.ndjson`. For multi-agent clusters, use `--code` (see Usage).
|
|
106
108
|
|
|
107
109
|
## Usage
|
|
108
110
|
|
|
109
|
-
### Core CLI via `bin/dave.js`
|
|
111
|
+
### Core CLI Utility via `bin/dave.js` (Not a Full Agent)
|
|
110
112
|
|
|
111
|
-
`bin/dave.js`
|
|
113
|
+
`bin/dave.js` is a CLI utility for session maintenance, WS client connections (UI for servers), spawning agents, and launching CodeServer clusters. It does NOT support custom prompts/tools or server mode (--serve). For full agents with customization, use examples like `npm_agent.js` or programmatic `AgentManager`. Key functions:
|
|
112
114
|
|
|
113
|
-
- **Ask Mode** (Interactive or Piped One-Shot):
|
|
115
|
+
- **Ask Mode** (Interactive or Piped One-Shot, using default Grok agent):
|
|
114
116
|
```bash
|
|
115
117
|
# Interactive
|
|
116
118
|
npx @j-o-r/hello-dave dave --ask --model grok-4 --temperature 0.2
|
|
@@ -120,19 +122,19 @@ mkdir .cache
|
|
|
120
122
|
```
|
|
121
123
|
- Note: Piped input triggers a direct response via `directCall`; without pipe, it launches an interactive CLI session.
|
|
122
124
|
- `--model` option works for both modes (e.g., `grok-4`, `grok-4-1-fast-reasoning`).
|
|
123
|
-
- Uses `AgentManager` with xAI Grok API integration, adds tools like `web_search`, `x_search`, `open_link`, `send_email`, `history_search`.
|
|
125
|
+
- Uses default `AgentManager` with xAI Grok API integration, adds tools like `web_search`, `x_search`, `open_link`, `send_email`, `history_search`.
|
|
124
126
|
- System prompt emphasizes brief, direct responses with step-by-step reasoning.
|
|
125
127
|
|
|
126
128
|
- **SpawnDave Mode** (Portable Agent Creator with --cwd Support):
|
|
127
129
|
```bash
|
|
128
130
|
# Interactive in current project
|
|
129
|
-
npx @j-o-r/hello-dave
|
|
131
|
+
npx @j-o-r/hello-dave dave --spawn --model grok-4-fast-reasoning --temperature 0.7
|
|
130
132
|
|
|
131
133
|
# Portable to another project (switches cwd, auto-deps)
|
|
132
|
-
npx @j-o-r/hello-dave
|
|
134
|
+
npx @j-o-r/hello-dave dave --spawn --cwd ../other-proj
|
|
133
135
|
|
|
134
136
|
# One-shot for quick generation
|
|
135
|
-
echo "name=coderev desc=Git diff analyzer tools=read_file execute_bash_script web_search" | npx @j-o-r/hello-dave
|
|
137
|
+
echo "name=coderev desc=Git diff analyzer tools=read_file execute_bash_script web_search" | npx @j-o-r/hello-dave dave --spawn --cwd ~/my-proj
|
|
136
138
|
```
|
|
137
139
|
- Creates production-ready CLI/WS agents (`bin/<name>.js`) supporting CLI, server (`--serve`), client (`--connect`), and hybrid modes.
|
|
138
140
|
- Generates multi-agent CodeServer launchers (`examples/<Name>Server`) using PM2 for persistent networked setups (main server + sub-agents).
|
|
@@ -140,27 +142,49 @@ mkdir .cache
|
|
|
140
142
|
- Aligns with CodeServer pattern: Self-contained Bash launchers for PM2-managed multi-agents (e.g., code review + TODO + NPM agents).
|
|
141
143
|
- Requires `XAIKEY`; uses online repo docs (https://codeberg.org/duin/hello-dave) for portability.
|
|
142
144
|
- Example output: Deploys `bin/coderev_agent.js`, tests it, provides server/client usage guide.
|
|
145
|
+
- **Usage Examples**:
|
|
146
|
+
- Interactive: `npx @j-o-r/hello-dave dave --spawn` (follow prompts to create agent).
|
|
147
|
+
- One-shot with prompt: `npx @j-o-r/hello-dave dave --spawn "Create a music lyrics generator agent"`.
|
|
148
|
+
- Piped input: `echo "Create a code-review agent with git diff tools" | npx @j-o-r/hello-dave dave --spawn`.
|
|
143
149
|
|
|
144
|
-
- **WebSocket Client Mode** (with secrets for secure networking):
|
|
150
|
+
- **WebSocket Client Mode** (Utility UI for connecting to servers, with secrets for secure networking):
|
|
145
151
|
```bash
|
|
146
152
|
# Interactive connection
|
|
147
|
-
npx @j-o-r/hello-dave dave --connect ws://localhost:8080 --secret "mysecret"
|
|
153
|
+
Utility: npx @j-o-r/hello-dave dave --connect ws://localhost:8080 --secret "mysecret"
|
|
148
154
|
|
|
149
155
|
# Piped one-shot (direct CLI/cron messaging, no heartbeat needed)
|
|
150
156
|
echo "Predict the weather" | npx @j-o-r/hello-dave dave --connect ws://localhost:8080 --secret "mysecret"
|
|
151
157
|
echo "user_reset" | npx @j-o-r/hello-dave dave --connect ws://localhost:8080 --secret "mysecret"
|
|
152
158
|
```
|
|
153
159
|
|
|
154
|
-
- **
|
|
160
|
+
- **CodeServer Launch Mode** (One-Command Multi-Agent Cluster via PM2; Utility Only, No --serve):
|
|
161
|
+
```bash
|
|
162
|
+
# Global (requires global install)
|
|
163
|
+
dave --code 8080 --secret mysecret
|
|
164
|
+
|
|
165
|
+
# Portable via npx (no local install needed)
|
|
166
|
+
npx @j-o-r/hello-dave dave --code 8080 --secret mysecret
|
|
167
|
+
```
|
|
168
|
+
- Launches `examples/codeserver.sh` with the provided port (1024-65535) and secret (min 3 chars), starting a PM2-managed CodeServer cluster.
|
|
169
|
+
- Cluster setup: Main `code_agent.js` as WS server on the port (exposes code tools); client agents (`todo_agent.js`, `readme_agent.js`, `npm_agent.js`, `docs_agent.js`, `test_agent.js`, `memory_agent.js`) connect as clients, gaining access to the servers tools.
|
|
170
|
+
- Requires PM2 installed globally: `npm i -g pm2`.
|
|
171
|
+
- **Portability Preference**: For maximum shell portability across environments, run the script directly: `./examples/codeserver.sh 8080 mysecret`. The `--code` flag is a Node.js wrapper for convenience in global/npx usage, auto-resolving paths.
|
|
172
|
+
- Monitors processes with PM2 prefix (e.g., `project_code_agent_8080`). Stop via `pm2 delete project_*_8080`.
|
|
173
|
+
- Aligns with Startup Modes (utility launch only; no direct --serve in dave.js—use full agents for servers).
|
|
174
|
+
- Connect to the cluster: `npx @j-o-r/hello-dave dave --connect ws://127.0.0.1:8080 --secret mysecret` (interactive or piped).
|
|
175
|
+
- **Enhanced Documentation**: The `--code` flag provides a convenient wrapper around `examples/codeserver.sh`, which is the preferred method for direct shell execution in scripts or CI/CD pipelines due to its self-contained nature (no Node.js dependency). The script handles PM2 process management, cleanup, and absolute path resolution for portability.
|
|
176
|
+
|
|
177
|
+
- **Cache Management** (Session maintenance in .cache):
|
|
155
178
|
```bash
|
|
156
179
|
npx @j-o-r/hello-dave dave --list # List sessions
|
|
157
180
|
npx @j-o-r/hello-dave dave --search "AI agents" # Search history
|
|
158
181
|
npx @j-o-r/hello-dave dave --clear # Clear cache
|
|
182
|
+
npx @j-o-r/hello-dave dave --inspect path/to/log.ndjson # Inspect log
|
|
159
183
|
```
|
|
160
184
|
|
|
161
|
-
For custom agents, use `AgentManager` programmatically (see Examples).
|
|
185
|
+
For custom full agents (with prompts/tools/server support), use `AgentManager` programmatically (see Examples) or scripts like `examples/npm_agent.js`.
|
|
162
186
|
|
|
163
|
-
### Programmatic Usage with AgentManager
|
|
187
|
+
### Programmatic Usage with AgentManager (For Full Agents)
|
|
164
188
|
|
|
165
189
|
```javascript
|
|
166
190
|
import AgentManager from '@j-o-r/hello-dave';
|
|
@@ -191,122 +215,148 @@ The `memory_recall` and `memory_write` tools, available when `toolsetMode: 'auto
|
|
|
191
215
|
|
|
192
216
|
## Startup Modes
|
|
193
217
|
|
|
194
|
-
This section
|
|
218
|
+
This section unifies the startup modes for full agents (e.g., `examples/npm_agent.js`) and the programmatic `AgentManager.start(serve, connect, cliIntro, tool_call_name, tool_call_description)`. These modes are standardized across agents generated by `spawn_agent` and align with the [AgentManager docs](docs/agent-manager.md). The CLI utility `bin/dave.js` supports only interactive ask, WS client connect, spawn_agent, cache management, and CodeServer launch via --code (no custom prompts/tools or --serve; utility-only).
|
|
195
219
|
|
|
196
|
-
|
|
197
|
-
For single responses via positional query. Ideal for scripts/cron.
|
|
220
|
+
All modes are cron-friendly with no heartbeat/ping required—agents respond directly to event-driven inputs. In WS modes (--serve, --connect, hybrid), positional arguments are ignored; use interactive CLI or piped inputs for messaging. Agent names and tool names must follow the strict lowercase naming rules: `/^[a-z_0-9_]{2,}$/` (no uppercase, hyphens, or specials) for filesystem/tool safety—see [AgentManager docs](docs/agent-manager.md).
|
|
198
221
|
|
|
199
|
-
**
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
222
|
+
**Note on dave.js --code**: This utility flag launches a multi-agent CodeServer cluster via PM2 (shell portability preferred via direct `examples/codeserver.sh`), aligning with hybrid WS patterns but without direct --serve support in the utility itself. Use full agents for standalone servers.
|
|
223
|
+
|
|
224
|
+
### AgentManager.start() Options Explained
|
|
225
|
+
The `start()` method is the smart launcher for all modes. It accepts up to 5 arguments in order:
|
|
226
|
+
- `serve` (number | undefined): Port for WS **server** mode (e.g., 8080). Exposes the agent as a remote tool via `ws://127.0.0.1:[port]/ws`. Requires `--secret` for client authentication. Runs indefinitely until Ctrl+C. See [AgentManager docs](docs/agent-manager.md) for server config.
|
|
227
|
+
- `connect` (string | undefined): WS URL for **client** mode (e.g., `ws://127.0.0.1:8080/ws`). Connects to a remote server to gain access to its tools. Launches interactive CLI after connection.
|
|
228
|
+
- `cliIntro` (string | undefined): Custom welcome message for interactive CLI mode (e.g., "NPM Agent ready. Ask about modules.").
|
|
229
|
+
- `tool_call_name` (string | undefined): **Required for server mode**. The tool name this agent exposes (must match naming regex `/^[a-z_0-9_]{2,}$/`). E.g., `npm_module_inspector`. Used when clients attach.
|
|
230
|
+
- `tool_call_description` (string | undefined): **Required for server mode**. Detailed description of the exposed tool (e.g., "Inspects NPM modules in node_modules/ using bash and cache.").
|
|
231
|
+
|
|
232
|
+
**Mode Determination**:
|
|
233
|
+
- If `serve` provided: Starts WS server (exposes tools).
|
|
234
|
+
- If `connect` provided: Starts WS client (attaches to remote, gains tools).
|
|
235
|
+
- If both: Hybrid mode (serves locally while using remote tools).
|
|
236
|
+
- If neither: Interactive CLI mode.
|
|
237
|
+
- For one-shot (non-start): Use `directCall(input)` directly (positional arg in scripts).
|
|
203
238
|
|
|
204
|
-
**
|
|
239
|
+
**Shared Notes**:
|
|
240
|
+
- `--secret [string]` (min 3 chars): Shared auth token. Servers reject mismatched clients; use the same for chains/networks.
|
|
241
|
+
- Other options: `--model [grok-4-fast-reasoning|...]`, `--temperature [-2 to +2]`, `--tokens`, `--top_p`, `--context [250000]`.
|
|
242
|
+
- Positional args ignored in WS modes (use CLI/pipes instead).
|
|
243
|
+
- No heartbeat: Event-driven responses.
|
|
244
|
+
- For multi-agent chaining, see [CodeServer pattern](docs/codeserver-pattern.md).
|
|
245
|
+
|
|
246
|
+
### 1. Direct Call (One-Shot, Positional Arg Only)
|
|
247
|
+
For single responses via positional query. Ideal for scripts/cron jobs. Bypasses CLI/WS; uses `agent.directCall(input)`. (Not available in `dave` utility for custom agents; use full agents or `--ask` for defaults.)
|
|
248
|
+
|
|
249
|
+
**CLI Example (Full Agent, e.g., npm_agent.js)**:
|
|
205
250
|
```bash
|
|
206
|
-
|
|
251
|
+
./examples/npm_agent.js "What modules are installed?" [--model grok-4]
|
|
207
252
|
```
|
|
253
|
+
- Input: Positional string (trimmed). If empty/missing, falls to interactive CLI or help.
|
|
208
254
|
|
|
209
|
-
**Programmatic (AgentManager)
|
|
255
|
+
**Programmatic (AgentManager)**:
|
|
210
256
|
```javascript
|
|
211
|
-
import AgentManager from '@j-o-r/hello-dave';
|
|
212
|
-
const agent = new AgentManager({ name: '
|
|
213
|
-
await agent.setup({ /*
|
|
214
|
-
const response = await agent.directCall('What modules are installed?');
|
|
257
|
+
import { AgentManager } from '@j-o-r/hello-dave' ;
|
|
258
|
+
const agent = new AgentManager({ name: 'npm_agent' });
|
|
259
|
+
await agent.setup({ /* prompt, api, options, toolsetMode, contextWindow */ });
|
|
260
|
+
const response = await agent.directCall('What modules are installed?' );
|
|
215
261
|
console.log(response);
|
|
216
262
|
```
|
|
263
|
+
- Pair with `readIn()` from `@j-o-r/sh` for piped stdin detection in scripts (e.g., `echo "query" | script.js`).
|
|
217
264
|
|
|
218
|
-
|
|
219
|
-
Launches ongoing conversation session.
|
|
220
|
-
|
|
221
|
-
**npm_agent.js:**
|
|
265
|
+
**Utility (dave.js for Default Queries)**:
|
|
222
266
|
```bash
|
|
223
|
-
|
|
267
|
+
echo "Explain quantum computing" | npx @j-o-r/hello-dave dave --ask [--model grok-4]
|
|
224
268
|
```
|
|
269
|
+
- Triggers `directCall` on piped input.
|
|
270
|
+
|
|
271
|
+
### 2. Interactive CLI (No Positional Arg)
|
|
272
|
+
Launches ongoing conversation session with REPL-like input (multi-turn, until Ctrl+C or `Alt+d`).
|
|
225
273
|
|
|
226
|
-
**
|
|
274
|
+
**CLI Example (Full Agent)**:
|
|
227
275
|
```bash
|
|
228
|
-
|
|
276
|
+
./examples/npm_agent.js [--model grok-4]
|
|
229
277
|
```
|
|
278
|
+
- No positional: Starts `agent.start()` with CLI intro.
|
|
230
279
|
|
|
231
|
-
**Programmatic
|
|
280
|
+
**Programmatic**:
|
|
232
281
|
```javascript
|
|
233
|
-
await agent.start(); // Interactive CLI
|
|
282
|
+
await agent.start(undefined, undefined, 'NPM Agent ready. Ask about modules or tools.' ); // Interactive CLI with custom intro
|
|
234
283
|
```
|
|
284
|
+
- Uses `cliIntro` for welcome message. Supports history, reset (`Alt+r`).
|
|
235
285
|
|
|
236
|
-
|
|
237
|
-
Starts WS server at `ws://127.0.0.1:[port]/ws` for remote tool access. Runs indefinitely.
|
|
238
|
-
|
|
239
|
-
**Explanations:**
|
|
240
|
-
- `--serve [port]`: Listen port (e.g., 8080). Exposes agent's tools (e.g., 'npm_module_inspector') to clients.
|
|
241
|
-
|
|
242
|
-
**npm_agent.js:**
|
|
286
|
+
**Utility (dave.js)**:
|
|
243
287
|
```bash
|
|
244
|
-
|
|
288
|
+
npx @j-o-r/hello-dave dave --ask
|
|
245
289
|
```
|
|
290
|
+
- Default agent; no custom tools/prompts.
|
|
291
|
+
|
|
292
|
+
### 3. WS Server (--serve [port])
|
|
293
|
+
Starts a WebSocket server at `ws://127.0.0.1:[port]/ws` to expose the agent as a remote tool for clients. Runs indefinitely. (Not supported in `dave` utility.)
|
|
246
294
|
|
|
247
|
-
**
|
|
295
|
+
**CLI Example (Full Agent)**:
|
|
248
296
|
```bash
|
|
249
|
-
|
|
297
|
+
./examples/npm_agent.js --serve 8080 [--secret mysecret] [--model grok-4]
|
|
250
298
|
```
|
|
299
|
+
- Exposes `tool_call_name` (e.g., `npm_module_inspector`) for remote calls.
|
|
251
300
|
|
|
252
|
-
**Programmatic
|
|
301
|
+
**Programmatic**:
|
|
253
302
|
```javascript
|
|
254
|
-
await agent.start(undefined,
|
|
303
|
+
await agent.start(8080, undefined, undefined, 'npm_module_inspector' , 'NPM modules expert using bash and cache in node_modules/.' ); // Server on 8080; secret optional but recommended
|
|
255
304
|
```
|
|
305
|
+
- `tool_call_name` and `tool_call_description` required for exposure. See [AgentManager docs](docs/agent-manager.md) for full server config, including reset propagation.
|
|
256
306
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
### 4. WS Client (--connect [ws_url])
|
|
260
|
-
Connects to remote server for tool access; launches interactive CLI.
|
|
261
|
-
|
|
262
|
-
**Explanations:**
|
|
263
|
-
- `--connect [ws_url]`: URL (e.g., ws://127.0.0.1:8080/ws). Gains remote tools.
|
|
264
|
-
|
|
265
|
-
**npm_agent.js:**
|
|
307
|
+
**Client Usage** (Connect to this server):
|
|
266
308
|
```bash
|
|
267
|
-
|
|
309
|
+
# Interactive
|
|
310
|
+
npx @j-o-r/hello-dave dave --connect ws://127.0.0.1:8080 --secret mysecret
|
|
311
|
+
# Or full agent: ./examples/other_agent.js --connect ws://127.0.0.1:8080 --secret mysecret
|
|
268
312
|
```
|
|
313
|
+
- Clients gain the servers tools (e.g., call `npm_module_inspector` in their prompts).
|
|
314
|
+
|
|
315
|
+
### 4. WS Client (--connect [ws_url])
|
|
316
|
+
Connects to a remote WS server as a client, gaining access to its tools, then launches interactive CLI.
|
|
269
317
|
|
|
270
|
-
**
|
|
318
|
+
**CLI Example (Full Agent)**:
|
|
271
319
|
```bash
|
|
272
|
-
|
|
320
|
+
./examples/npm_agent.js --connect ws://127.0.0.1:8080/ws --secret mysecret [--model grok-4]
|
|
273
321
|
```
|
|
322
|
+
- Attaches to server; uses remote tools in local sessions.
|
|
274
323
|
|
|
275
|
-
**Programmatic
|
|
324
|
+
**Programmatic**:
|
|
276
325
|
```javascript
|
|
277
|
-
await agent.start('ws://
|
|
326
|
+
await agent.start(undefined, 'ws://127.0.0.1:8080/ws' , undefined, undefined, undefined ); // Client mode; secret required if server uses one
|
|
278
327
|
```
|
|
328
|
+
- After connection, interactive CLI starts. For one-shot: Pipe to script (uses `directCall` with remote tools).
|
|
279
329
|
|
|
280
|
-
|
|
281
|
-
Serves tools locally while using remote ones.
|
|
282
|
-
|
|
283
|
-
**Explanations:**
|
|
284
|
-
- Combines `--serve` and `--connect`; ignores positional args.
|
|
285
|
-
|
|
286
|
-
**npm_agent.js:**
|
|
330
|
+
**Utility (dave.js)**:
|
|
287
331
|
```bash
|
|
288
|
-
|
|
332
|
+
# Interactive
|
|
333
|
+
npx @j-o-r/hello-dave dave --connect ws://localhost:8080 --secret "mysecret"
|
|
334
|
+
# Piped one-shot (cron-friendly)
|
|
335
|
+
echo "Use remote NPM tool to list modules" | npx @j-o-r/hello-dave dave --connect ws://localhost:8080 --secret "mysecret"
|
|
289
336
|
```
|
|
290
337
|
|
|
291
|
-
|
|
338
|
+
### 5. Hybrid (--serve [port] + --connect [ws_url])
|
|
339
|
+
Serves tools locally (on local port) while connecting as a client to a remote server (gains remote tools). No positional arg; launches interactive CLI. Ideal for agent chains/networks. (Not supported in `dave` utility.)
|
|
340
|
+
|
|
341
|
+
**CLI Example (Full Agent)**:
|
|
292
342
|
```bash
|
|
293
|
-
|
|
343
|
+
./examples/npm_agent.js --serve 8081 --connect ws://otherhost:8080/ws [--secret mysecret]
|
|
294
344
|
```
|
|
345
|
+
- Local server on 8081 (exposes local tools); client to remote (uses remote tools).
|
|
295
346
|
|
|
296
|
-
**Programmatic
|
|
297
|
-
|
|
347
|
+
**Programmatic**:
|
|
348
|
+
```javascript
|
|
349
|
+
await agent.start(8081, 'ws://otherhost:8080/ws' , 'Hybrid NPM Agent ready.' , 'npm_module_inspector' , 'Hybrid NPM inspector with remote access.' ); // Hybrid; secret for both if needed
|
|
350
|
+
```
|
|
351
|
+
- Custom handling for secrets (use same or per-mode). See [AgentManager docs](docs/agent-manager.md) for hybrid details and error handling.
|
|
298
352
|
|
|
299
|
-
|
|
300
|
-
- `--secret [string]`: Min 3-char auth token. Servers reject mismatched clients; use same for chains.
|
|
301
|
-
- Other: `--model [grok-4-fast-reasoning|...]`, `--temperature [-2 to +2]`, `--tokens`, `--top_p`, `--context [250000]`.
|
|
302
|
-
- Positional ignored in WS modes; no heartbeat—event-driven.
|
|
303
|
-
- For multi-agent examples, see [examples/](examples/) and [docs/codeserver-pattern.md](docs/codeserver-pattern.md).
|
|
353
|
+
**Notes**: Positional args ignored. Use for distributed setups (e.g., NPM agent serves locally but uses a code agents tools remotely). Monitor with tools like `netstat` or PM2 in CodeServer.
|
|
304
354
|
|
|
305
|
-
This completes
|
|
355
|
+
This section completes the unified documentation for startup modes, aligned with `npm_agent.js` help output and `AgentManager` API. For more, see [docs/agent-manager.md](docs/agent-manager.md) and [examples/](examples/).
|
|
306
356
|
|
|
307
357
|
## Examples
|
|
308
358
|
|
|
309
|
-
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).
|
|
359
|
+
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 full 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).
|
|
310
360
|
|
|
311
361
|
- **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).
|
|
312
362
|
|
|
@@ -314,28 +364,34 @@ In custom agents, consider adding `memory_recall` and `memory_write` tools to en
|
|
|
314
364
|
|
|
315
365
|
### Persistent Multi-Agent CodeServer Pattern
|
|
316
366
|
|
|
317
|
-
The `examples/
|
|
367
|
+
The `examples/codeserver.sh` 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, docs, test, and memory 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.
|
|
318
368
|
|
|
319
369
|
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).
|
|
320
370
|
|
|
321
|
-
**Usage:**
|
|
371
|
+
**Usage (Prefer Shell Portability):**
|
|
322
372
|
|
|
323
373
|
```bash
|
|
324
|
-
#
|
|
325
|
-
./examples/
|
|
374
|
+
# Direct shell launch (portable, no Node.js wrapper needed; requires PM2: npm i -g pm2)
|
|
375
|
+
./examples/codeserver.sh 8080 mysecret
|
|
326
376
|
|
|
327
|
-
#
|
|
328
|
-
|
|
329
|
-
|
|
377
|
+
# Convenience via dave.js utility (global or npx)
|
|
378
|
+
dave --code 8080 --secret mysecret
|
|
379
|
+
npx @j-o-r/hello-dave dave --code 8080 --secret mysecret
|
|
330
380
|
```
|
|
331
381
|
|
|
332
|
-
Monitor with `pm2 list` and stop via `pm2 delete <name
|
|
382
|
+
Monitor with `pm2 list` and stop via `pm2 delete <name>` (e.g., `pm2 delete project_*_8080`).
|
|
333
383
|
|
|
334
|
-
|
|
384
|
+
**Connect via CLI utility (interactive or piped):**
|
|
385
|
+
```bash
|
|
386
|
+
Utility: npx @j-o-r/hello-dave dave --connect ws://127.0.0.1:8080/ws --secret mysecret
|
|
387
|
+
# 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
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
### Snippet: Spawning Agents (Portable via `bin/dave.js` --spawn)
|
|
335
391
|
|
|
336
392
|
`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.
|
|
337
393
|
|
|
338
|
-
Now CodeServer-aware: Can generate PM2 multi-agent launchers (e.g.,
|
|
394
|
+
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).
|
|
339
395
|
|
|
340
396
|
**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`).
|
|
341
397
|
|
|
@@ -365,13 +421,13 @@ await agent.start(); // Guides user to create e.g., bin/myagent.js
|
|
|
365
421
|
|
|
366
422
|
```bash
|
|
367
423
|
# Interactive spawning (runs from npm without cloning; current dir)
|
|
368
|
-
npx @j-o-r/hello-dave
|
|
424
|
+
npx @j-o-r/hello-dave dave --spawn
|
|
369
425
|
|
|
370
426
|
# Portable to specific project (auto-switches cwd, installs deps if needed)
|
|
371
|
-
npx @j-o-r/hello-dave
|
|
427
|
+
npx @j-o-r/hello-dave dave --spawn --cwd ~/my-proj
|
|
372
428
|
|
|
373
429
|
# Piped one-shot for CodeServer launcher (portable, no cloning)
|
|
374
|
-
echo "Generate CodeServer launcher for coderev + tododave" | npx @j-o-r/hello-dave
|
|
430
|
+
echo "Generate CodeServer launcher for coderev + tododave" | npx @j-o-r/hello-dave dave --spawn --cwd ~/proj
|
|
375
431
|
```
|
|
376
432
|
|
|
377
433
|
### Snippet: Using xAI Grok API Integration
|
|
@@ -393,15 +449,15 @@ Detailed examples for xAI integration (e.g., advanced tool calls, reasoning) are
|
|
|
393
449
|
### Running Examples
|
|
394
450
|
|
|
395
451
|
```bash
|
|
396
|
-
# Music agent (examples/daisy_agent.js)
|
|
452
|
+
# Music agent (examples/daisy_agent.js - full agent)
|
|
397
453
|
chmod +x examples/daisy_agent.js
|
|
398
454
|
./examples/daisy_agent.js "Generate lyrics for a pop song"
|
|
399
455
|
|
|
400
|
-
# TODO manager (examples/todo_agent.js)
|
|
456
|
+
# TODO manager (examples/todo_agent.js - full agent)
|
|
401
457
|
./examples/todo_agent.js --connect ws://localhost:8080 --secret "secret"
|
|
402
458
|
|
|
403
|
-
# Server setup for networked examples
|
|
404
|
-
|
|
459
|
+
# Server setup for networked examples (use full agents, not dave utility)
|
|
460
|
+
./examples/npm_agent.js --serve 8080 # Expose as WS server
|
|
405
461
|
```
|
|
406
462
|
|
|
407
463
|
## Development
|
|
@@ -409,22 +465,41 @@ npx @j-o-r/hello-dave dave --ask --serve 8080 # Expose as WS server
|
|
|
409
465
|
- **Scripts**: `npm test` (runs scenarios/grok_agent.js), `npm run types` (generate TypeScript defs), `npm run release` (pack for release).
|
|
410
466
|
- **Structure**: Core in `lib/` (AgentManager.js, wsCli.js, etc.), API integrations in `lib/API/`, examples in `examples/`, utils in `utils/`.
|
|
411
467
|
- **Testing**: Basic validation via `npm test`. Unit tests for xAI integration planned (see TODO).
|
|
412
|
-
- **Prep for v0.0.
|
|
468
|
+
- **Prep for v0.0.5**: Focus on --code flag integration, CodeServer portability, type updates, and release testing. Documentation for --spawn and --code flags enhanced and marked complete.
|
|
413
469
|
|
|
414
470
|
## Changelog
|
|
415
471
|
|
|
416
|
-
### v0.0.
|
|
472
|
+
### v0.0.5 (Released - May 2026)
|
|
473
|
+
- **Release Complete**: Updated package.json to version "0.0.5". Full test suite passed 100% (no regressions). Types generated and verified. Git tagged and published.
|
|
474
|
+
- **WebSocket Export Refinements**: lib/index.js now exports `wsCli` and `wsIO` for seamless programmatic access and integration (e.g., in bin/dave.js using package imports instead of relative paths). Improves modularity for consumers without breaking existing APIs.
|
|
475
|
+
- **CodeServer Enhancements**: Added --code flag to bin/dave.js for one-command CodeServer launch (global/npx portable). Launches examples/codeserver.sh for PM2-managed multi-agent cluster (code_agent server + todo/readme/npm/docs/test/memory clients). Emphasizes shell script portability; aligns with Startup Modes (utility only, no --serve).
|
|
476
|
+
- **Spawn Flag Documentation**: Enhanced --spawn in bin/dave.js for launching examples/spawn_agent.js. Added usage examples for interactive, one-shot (--spawn "prompt"), and piped input. Integrated into Quick Start and Usage sections.
|
|
477
|
+
- **CLI Usage Section**: Confirmed and enhanced documentation for --code flag, preferring direct execution of examples/codeserver.sh for shell portability. Added dedicated examples and notes under Core CLI Utility.
|
|
478
|
+
- **Package Alignment**: Bumped package.json to version "0.0.5" in preparation for release; regenerated types to include new exports and flag support.
|
|
479
|
+
- **Prep Notes**: Git clean performed; full tests/types/docs verified post-updates. Focus on CodeServer integration and portability testing complete. v0.0.5 prep marked as complete.
|
|
480
|
+
|
|
481
|
+
### v0.0.4 (Previous - April 2026)
|
|
482
|
+
- **Release Preparation Complete**: Updated package.json to version "0.0.4" (pending final commit/tag). Full test suite passed 100% (no regressions in genericToolset.test.js or other scenarios). Types generated and verified.
|
|
483
|
+
- **Agent Standardization**: All 12 example agents (e.g., code_agent.js, readme_agent.js, test_agent.js) now follow unified npm_agent.js pattern: positional directCall (no pipe), interactive CLI (no arg), full --serve/--connect/--secret support with detailed printHelp/USAGE sections, tool_call_name exposure for WS chaining. Syntax validated across all.
|
|
484
|
+
- **Prompt Safeguards**: Added STRICT NO-CODING RULE to non-coding agents (e.g., todo_agent.js, readme_agent.js, docs_agent.js, prompt_agent.js) to prevent misuse of tools like execute_code, write_file, syntax_check. Matches todo_agent.js style; verified no regressions.
|
|
485
|
+
- **Memory Protocol Enhancements**: Updated prompts (e.g., spawn_agent.js, test_agent.js) to mandate memory_recall/write FIRST/LAST for tasks/errors/prefs/decisions, reducing token burn and enabling human handoff. Integrated into workflows for iterative testing and agent generation.
|
|
486
|
+
- **File Renames and Cleanup**: Renamed all examples/ files to *_agent.js (e.g., codedave.js → code_agent.js); updated references in README.md, docs/, TODO.md, package.json. Removed all old "Dave/dave" references (grep -r confirmed zero remnants).
|
|
487
|
+
- **NPM Agent Improvements**: Enhanced prompt with Dependency Strategy (prefer installed modules/native JS/Bash, suggest new deps only as last resort). Added full npm ls -a scanning for subdeps; strict no-installs policy. Vague query handling improved (e.g., auto-cache for tests).
|
|
488
|
+
- **Startup Modes Documentation**: Finalized "## Startup Modes" section in README.md with 5 unified modes (Direct Call, CLI, Server, Client, Hybrid), AgentManager.start() explanations, CLI/programmatic examples, and links to docs/agent-manager.md. Aligned with all agent help outputs.
|
|
489
|
+
- **Test Agent Enhancements**: test_agent.js standardized; prompt updated for Test class usage in scenarios/*.test.js (e.g., toolset.test.js generation/validation). Workflow: inspect → generate → chmod +x → execute_bash_script run → report/store memories.
|
|
490
|
+
- **WS Client Refinements**: lib/wsCli.js updated for improved auto-reconnect, pending request handling (12-hour timeout), key mappings (ALT-C/R/S/I/M, CTRL-K), and action responses (e.g., server_reset, sessionlist). Clipboard copy via xclip; better error logging.
|
|
491
|
+
- **TODO Alignment**: High-priority items cleared (e.g., explain startup modes, agent standardization, prompt updates). No high-priority pending; project reviewed stable as of April 02, 2026.
|
|
492
|
+
- **Other**: Reorganized examples/ folder; enhanced spawn_agent portability (npx --cwd, auto-deps, online repo awareness). Git ahead by 1 commit (cleanup toolset test); ready for v0.0.4 tag/publish.
|
|
493
|
+
|
|
494
|
+
### v0.0.3 (Previous - March 2026)
|
|
495
|
+
- Initial WS secrets, generic tools, AgentManager refinements.
|
|
417
496
|
- Reorganized examples to `examples/` folder (readmeDave, todoDave, etc.).
|
|
418
497
|
- Enhanced `bin/dave.js` for core utilities: spawning, WS with secrets, direct messaging.
|
|
419
498
|
- Improved xAI Grok API integration; added native tools/reasoning support.
|
|
420
499
|
- Removed heartbeat needs; direct CLI/cron support.
|
|
421
500
|
- Added piped one-shot support to dave --ask.
|
|
422
|
-
- TODO alignment: High-priority items noted (release prep, spawn_agent enhancements).
|
|
423
|
-
|
|
424
|
-
### v0.0.3 (Previous)
|
|
425
|
-
- Initial WS secrets, generic tools, AgentManager refinements.
|
|
426
501
|
|
|
427
|
-
Full history in git tags.
|
|
502
|
+
Full history in git tags (recent: cleanup toolset test, TODO status update, fixed test/README, syntax fixes, startup modes explanation).
|
|
428
503
|
|
|
429
504
|
## Contributing
|
|
430
505
|
|
|
@@ -445,11 +520,12 @@ Apache License 2.0. See [LICENSE](LICENSE) for details.
|
|
|
445
520
|
## TODO Alignment
|
|
446
521
|
|
|
447
522
|
This README aligns with high-priority items from [TODO.md](TODO.md):
|
|
448
|
-
- **v0.0.
|
|
449
|
-
- **
|
|
450
|
-
-
|
|
451
|
-
-
|
|
452
|
-
-
|
|
453
|
-
-
|
|
523
|
+
- **v0.0.5 Prep**: Changelog updated for --code flag and CodeServer enhancements; release steps emphasized (version bump to 0.0.5, tests, types, commit/tag, publish). Prep notes expanded for portability and utility alignment. Marked complete.
|
|
524
|
+
- **CodeServer TODOs**: Related tasks marked complete (e.g., --code flag implementation/docs, preference for codeserver.sh portability). No high-priority pending; sub-tasks on testing/alternatives deprioritized.
|
|
525
|
+
- **spawn_agent Enhancements**: Highlighted in Examples with portability and CodeServer awareness. --spawn flag docs enhanced with examples.
|
|
526
|
+
- **Agent Standardization and Safeguards**: Integrated into Changelog and Usage notes (from v0.0.4).
|
|
527
|
+
- xAI integration tests/examples: Deferred to post-v0.0.5 (future enhancements).
|
|
528
|
+
- Documentation tasks (e.g., AgentManager internals, WS refinements) completed in Usage/Examples/Changelog.
|
|
529
|
+
- **Status**: No high-priority pending; all tests stable. Focus shifted to v0.0.5 release and future features like xAI files.js integration.
|
|
454
530
|
|
|
455
531
|
For full TODO, see [TODO.md](TODO.md).
|