@j-o-r/hello-dave 0.0.5 → 0.0.7
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 +13 -26
- package/README.md +161 -522
- package/README.md.bak +144 -449
- package/{examples → agents}/ask_agent.js +5 -5
- package/{examples → agents}/codeserver.sh +14 -14
- package/{examples → agents}/daisy_agent.js +5 -5
- package/{examples → agents}/docs_agent.js +5 -5
- package/{examples → agents}/gpt_agent.js +5 -5
- package/{examples → agents}/grok_agent.js +5 -5
- package/agents/memory_agent.js +263 -0
- package/{examples → agents}/npm_agent.js +5 -5
- package/{examples → agents}/prompt_agent.js +5 -5
- package/agents/spawn_agent.js +137 -0
- package/{examples → agents}/test_agent.js +6 -8
- package/{examples → agents}/todo_agent.js +5 -5
- package/bin/codeDave +58 -0
- package/bin/dave.js +114 -96
- package/lib/AgentClient.js +111 -67
- package/lib/AgentManager.js +111 -80
- package/lib/AgentServer.js +144 -104
- package/lib/Cli.js +126 -93
- package/lib/Prompt.js +38 -5
- package/lib/Session.js +102 -79
- package/lib/ToolSet.js +79 -60
- package/lib/fafs.js +54 -19
- package/lib/genericToolset.js +109 -213
- package/lib/wsCli.js +50 -19
- package/lib/wsIO.js +11 -17
- package/package.json +2 -2
- package/types/AgentClient.d.ts +69 -35
- package/types/AgentManager.d.ts +50 -56
- package/types/AgentServer.d.ts +63 -16
- package/types/Cli.d.ts +56 -10
- package/types/Prompt.d.ts +36 -4
- package/types/Session.d.ts +23 -9
- package/types/ToolSet.d.ts +49 -32
- package/types/fafs.d.ts +68 -25
- package/types/wsCli.d.ts +14 -0
- package/types/wsIO.d.ts +9 -5
- package/utils/search_sessions.sh +100 -53
- package/README.md.backup +0 -269
- package/README.md.bak.1774780058 +0 -338
- package/README.md.bak2 +0 -531
- package/bin/spawn_agent.js +0 -293
- package/docs.bak.1774780058/agent-manager.md +0 -167
- package/docs.bak.1774780058/agent-manager.md.bak +0 -137
- package/docs.bak.1774780058/agent-manager.md.bak2 +0 -157
- package/docs.bak.1774780058/codeserver-pattern.md +0 -191
- package/docs.bak.1774780058/path-resolution-best-practices.md +0 -104
- package/docs.bak.1774780058/project-overview.md +0 -67
- package/docs.bak.1774780058/project-overview.md.bak +0 -67
- package/docs.bak.1774780058/prompt-class.md +0 -141
- package/docs.bak.1774780058/prompt-class.md.bak +0 -142
- package/docs.bak.1774780058/tools-syntax-validation.md +0 -121
- package/docs.bak.1774780058/tools-syntax-validation.md.bak2 +0 -125
- package/docs.bak.1774780058/tools-syntax-validation.md.bak3 +0 -125
- package/docs.bak.1774780058/tools-syntax-validation.md.bak4 +0 -106
- package/docs.bak.1774780058/tools-syntax-validation.md.bak_path +0 -106
- package/docs.bak.1774780058/toolset.md +0 -164
- package/docs.bak.1774780058/toolset.md.bak +0 -94
- package/docs.bak.1774780058/toolset.md.bak3 +0 -161
- package/docs.bak.1774780058/toolset.md.bak4 +0 -161
- package/docs.bak.1774780058/toolset.md.bak5 +0 -161
- package/docs.bak.1774780058/toolset.md.bak6 +0 -163
- package/docs.bak.1774780058/toolset.md.bak_path +0 -163
- package/docs.bak.1774780058/toolset.md.bak_syntax +0 -161
- package/docs.bak.1774780058/xai-responses.md +0 -111
- package/docs.bak.1774780058/xai-responses.md.bak +0 -107
- package/docs.bak.1774780058/xai-responses.md.bak2 +0 -107
- package/docs.bak.1774780058/xai_collections.md +0 -106
- package/examples/memory_agent.js +0 -152
- package/examples.bak.1774780058/ask_agent.js +0 -114
- package/examples.bak.1774780058/code_agent.js +0 -149
- package/examples.bak.1774780058/coderev_agent.js +0 -72
- package/examples.bak.1774780058/codeserver.sh +0 -47
- package/examples.bak.1774780058/daisy_agent.js +0 -177
- package/examples.bak.1774780058/docs_agent.js +0 -119
- package/examples.bak.1774780058/gpt_agent.js +0 -109
- package/examples.bak.1774780058/grok_agent.js +0 -98
- package/examples.bak.1774780058/memory_agent.js +0 -112
- package/examples.bak.1774780058/npm_agent.js +0 -175
- package/examples.bak.1774780058/prompt_agent.js +0 -112
- package/examples.bak.1774780058/readme_agent.js +0 -144
- package/examples.bak.1774780058/spawn_agent.js +0 -263
- package/examples.bak.1774780058/test_agent.js +0 -162
- package/examples.bak.1774780058/todo_agent.js +0 -138
- package/lib/genericToolset.js.bak_syntax +0 -402
- package/scenarios.bak.1774780058/data/eval_node_message.json +0 -9
- package/scenarios.bak.1774780058/data/hist_oa.json +0 -66
- package/scenarios.bak.1774780058/data/o3_response1.json +0 -96
- package/scenarios.bak.1774780058/data/oa_reasoning_parse.json +0 -112
- package/scenarios.bak.1774780058/data/tool_oa.json +0 -96
- package/scenarios.bak.1774780058/data/tool_xai.json +0 -59
- package/scenarios.bak.1774780058/data/tool_xai2.json +0 -40
- package/scenarios.bak.1774780058/data/xai-response-1.json +0 -59
- package/scenarios.bak.1774780058/data/xai-response-2.json +0 -10
- package/scenarios.bak.1774780058/data/xai_reasoning_tools_resp.json +0 -59
- package/scenarios.bak.1774780058/data/xai_search_response.json +0 -58
- package/scenarios.bak.1774780058/environment.js +0 -10
- package/scenarios.bak.1774780058/example.js +0 -17
- package/scenarios.bak.1774780058/genericToolset.test.js +0 -182
- package/scenarios.bak.1774780058/grok.js +0 -113
- package/scenarios.bak.1774780058/memory-tools.js +0 -51
- package/scenarios.bak.1774780058/openai-o3.js +0 -137
- package/scenarios.bak.1774780058/openai-prompt.js +0 -155
- package/scenarios.bak.1774780058/openai-session.js +0 -148
- package/scenarios.bak.1774780058/openai.js +0 -102
- package/scenarios.bak.1774780058/prompt.js +0 -118
- package/scenarios.bak.1774780058/promptFishbowl.js +0 -76
- package/scenarios.bak.1774780058/search.brave.com.js +0 -25
- package/scenarios.bak.1774780058/sh.js +0 -15
- package/scenarios.bak.1774780058/test-wsio.js +0 -26
- package/scenarios.bak.1774780058/testToolset.js +0 -42
- package/scenarios.bak.1774780058/toolset.js +0 -16
- package/scenarios.bak.1774780058/toolset.test.js +0 -141
- package/scenarios.bak.1774780058/write_file_syntax.test.js +0 -145
- package/scenarios.bak.1774780058/write_file_validation/README.md +0 -30
- package/scenarios.bak.1774780058/write_file_validation/bad.js +0 -3
- package/scenarios.bak.1774780058/write_file_validation/good.js +0 -4
- package/scenarios.bak.1774780058/write_file_validation/test.sh +0 -43
- package/scenarios.bak.1774780058/wsClient.js +0 -69
- package/scenarios.bak.1774780058/xai_responses.integration.test.js +0 -57
- package/scenarios.bak.1774780058/xai_responses.test.js +0 -154
- package/scenarios.bak.1774780058/xaicoll.js +0 -50
- package/scenarios.bak.1774780058/xaifiles.js +0 -48
- /package/{examples → agents}/code_agent.js +0 -0
- /package/{examples → agents}/readme_agent.js +0 -0
package/README.md
CHANGED
|
@@ -1,601 +1,240 @@
|
|
|
1
|
-
#
|
|
1
|
+
# hello-dave
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
[](https://www.npmjs.com/package/%40j-o-r%2Fhello-dave)
|
|
6
|
-
[](https://opensource.org/licenses/Apache-2.0)
|
|
3
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
7
4
|
[](https://nodejs.org/)
|
|
5
|
+
[](https://codeberg.org/duin/hello-dave)
|
|
6
|
+
[](https://pm2.keymetrics.io/)
|
|
8
7
|
|
|
9
8
|
## Table of Contents
|
|
10
9
|
|
|
11
10
|
- [Description](#description)
|
|
12
11
|
- [Features](#features)
|
|
12
|
+
- [Folder Structure](#folder-structure)
|
|
13
13
|
- [Installation](#installation)
|
|
14
|
-
- [Quick Start](#quick-start)
|
|
15
14
|
- [Usage](#usage)
|
|
16
|
-
- [
|
|
17
|
-
- [Examples](#examples)
|
|
15
|
+
- [Usage Examples](#usage-examples)
|
|
18
16
|
- [Development](#development)
|
|
19
|
-
- [Changelog](#changelog)
|
|
20
17
|
- [Contributing](#contributing)
|
|
21
18
|
- [License](#license)
|
|
22
|
-
- [TODO Alignment](#todo-alignment)
|
|
23
19
|
|
|
24
20
|
## Description
|
|
25
21
|
|
|
26
|
-
|
|
27
|
-
|
|
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.
|
|
22
|
+
**hello-dave** is an ESM (ECMAScript Modules) toolkit for building AI agents with unified access to endpoints from Grok (xAI), OpenAI, and Anthropic. It provides CLI tools for interacting with agents locally or via WebSocket servers, along with pre-built agent scripts for various tasks like code generation, documentation, testing, and more.
|
|
29
23
|
|
|
30
|
-
|
|
24
|
+
The project emphasizes modular agent management, tool integration (e.g., web search, file operations), and session handling with memory and caching. With v0.0.8, enhanced portability allows spawning agents in isolated environments like `/tmp` while maintaining tool functionality relative to the current working directory (CWD).
|
|
31
25
|
|
|
32
26
|
## Features
|
|
33
27
|
|
|
34
|
-
- **Unified
|
|
35
|
-
- **
|
|
36
|
-
- **
|
|
37
|
-
- **WebSocket
|
|
38
|
-
- **
|
|
39
|
-
- **
|
|
40
|
-
- **
|
|
41
|
-
- **
|
|
42
|
-
- **
|
|
43
|
-
|
|
28
|
+
- **Unified API Access**: Seamless integration with xAI (Grok), OpenAI, and Anthropic models.
|
|
29
|
+
- **CLI Tools**: `dave` for querying agents, `agentDave` for spawning servers, `codeDave` for code servers.
|
|
30
|
+
- **Agent Scripts**: Specialized agents for code, docs, npm, todo, readme, memory, and more.
|
|
31
|
+
- **WebSocket Support**: Connect to remote agent servers for interactive or one-shot interactions.
|
|
32
|
+
- **Toolsets**: Built-in tools for search, file I/O, email, and custom toolcalls.
|
|
33
|
+
- **Session Management**: Cache history, search sessions, reset, and inspect logs.
|
|
34
|
+
- **ESM-First**: Modern Node.js modules with TypeScript definitions.
|
|
35
|
+
- **Portable Agent Spawning**: `spawn_agent.js` enables creating and deploying agents anywhere (project dirs or fresh `/tmp`). Supports auto-deploy in existing projects (detects `./agents/*.js`), manual code+bash in isolated setups. Tools adapt to CWD for portability. Hybrid modes combine server/client for chaining. See [docs/prompt/spawn_agent.md](docs/prompt/spawn_agent.md) for blueprint and validation.
|
|
36
|
+
- **Multi-Agent Clusters**: PM2-powered CodeServer for scalable, clustered agent deployments (e.g., code_agent + todo_agent). Defaults to port 9000/secret '123'. See [docs/multi-agent-clusters.md](docs/multi-agent-clusters.md) for configuration.
|
|
37
|
+
|
|
38
|
+
## Folder Structure
|
|
39
|
+
|
|
40
|
+
- **bin/**: Executables for CLI tools.
|
|
41
|
+
- `dave.js`: Main CLI for asking agents or connecting to WebSocket servers.
|
|
42
|
+
- `spawn_agent.js`: Spawns agent instances (binary: `agentDave`).
|
|
43
|
+
- `codeDave`: Launches code servers (via PM2 clusters). References [docs/multi-agent-clusters.md](docs/multi-agent-clusters.md) for setup and scaling.
|
|
44
|
+
|
|
45
|
+
- **agents/**: Agent scripts (`*_agent.js`) for specific tasks. These can be run directly with `node agents/<script>.js`.
|
|
46
|
+
- `ask_agent.js`: General query agent.
|
|
47
|
+
- `code_agent.js`: Code generation and execution agent (serves as main server in code clusters).
|
|
48
|
+
- `daisy_agent.js`: Specialized agent (details in script).
|
|
49
|
+
- `docs_agent.js`: Documentation-focused agent.
|
|
50
|
+
- `gpt_agent.js`: OpenAI GPT integration agent.
|
|
51
|
+
- `grok_agent.js`: xAI Grok-specific agent.
|
|
52
|
+
- `memory_agent.js`: Agent with enhanced memory and context handling.
|
|
53
|
+
- `npm_agent.js`: NPM package management agent.
|
|
54
|
+
- `prompt_agent.js`: Prompt engineering and testing agent.
|
|
55
|
+
- `readme_agent.js`: README.md management agent.
|
|
56
|
+
- `spawn_agent.js`: Agent spawner (also in bin/). Creates portable CLI/WS agents + PM2 launchers. Validates/tests/deploys to `./agents/<name>.js`. Supports hybrid server/client modes. Portable to `/tmp` (tools follow CWD). Blueprint: [docs/prompt/spawn_agent.md](docs/prompt/spawn_agent.md).
|
|
57
|
+
- `test_agent.js`: Testing and validation agent.
|
|
58
|
+
- `todo_agent.js`: TODO list and task management agent.
|
|
59
|
+
- `codeserver.sh`: Shell script for launching PM2-based code server clusters (uses agents above). See [docs/multi-agent-clusters.md](docs/multi-agent-clusters.md).
|
|
60
|
+
|
|
61
|
+
- **lib/**: Core library modules (e.g., `index.js`, `wsCli.js`, `wsIO.js`, API integrations).
|
|
62
|
+
- **scenarios/**: Test and example scenarios (e.g., toolset tests, integration scripts).
|
|
63
|
+
- **types/**: TypeScript definitions.
|
|
64
|
+
- **utils/**: Utility scripts (e.g., session management, testing).
|
|
65
|
+
- **docs/**: Additional documentation, including agent blueprints (e.g., [prompt/spawn_agent.md](docs/prompt/spawn_agent.md)) and multi-agent guides (e.g., [multi-agent-clusters.md](docs/multi-agent-clusters.md)).
|
|
66
|
+
- **release/**: Build artifacts.
|
|
67
|
+
|
|
68
|
+
Other files: `package.json`, `CHANGELOG.md`, `TODO.md`, `LICENSE`.
|
|
44
69
|
|
|
45
70
|
## Installation
|
|
46
71
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
```bash
|
|
50
|
-
npm install @j-o-r/hello-dave
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
For global access to CLI tools (including `dave` from `bin/dave.js` and `createAgent`):
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
npm install -g @j-o-r/hello-dave
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
Set your API keys via environment variables (only set what you need):
|
|
60
|
-
- `XAIKEY` for xAI Grok
|
|
61
|
-
- `ANTHKEY` for Anthropic Claude
|
|
62
|
-
- `OPENAIKEY` for OpenAI GPT
|
|
63
|
-
- `BRAVESEARCHKEY` for web search (optional)
|
|
72
|
+
1. **Prerequisites**: Node.js >= 20. PM2 for multi-agent clusters: `npm install -g pm2`.
|
|
64
73
|
|
|
65
|
-
|
|
66
|
-
```bash
|
|
67
|
-
mkdir .cache
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
## Quick Start
|
|
71
|
-
|
|
72
|
-
1. Set an API key (e.g., for Grok):
|
|
73
|
-
```bash
|
|
74
|
-
export XAIKEY=your_xai_api_key
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
2. Use the core CLI utility `bin/dave.js` (not a full agent) for interactive queries or management:
|
|
74
|
+
2. **Local Development**:
|
|
78
75
|
```bash
|
|
79
|
-
|
|
76
|
+
git clone https://codeberg.org/duin/hello-dave.git
|
|
77
|
+
cd hello-dave
|
|
78
|
+
npm install
|
|
80
79
|
```
|
|
81
|
-
- Launches an interactive agent session using default Grok tools. Use `Alt+d` to exit, `Alt+r` to reset.
|
|
82
|
-
- Example: Ask questions about anything; it uses xAI Grok by default with web search and X search tools.
|
|
83
80
|
|
|
84
|
-
3.
|
|
81
|
+
3. **Global CLI Installation** (for `dave`, `agentDave`, `codeDave`):
|
|
85
82
|
```bash
|
|
86
|
-
|
|
83
|
+
npm install -g .
|
|
84
|
+
# Or link for dev: npm run link-self
|
|
87
85
|
```
|
|
88
|
-
- Provides a direct response using the specified model (e.g., `--model grok-4`).
|
|
89
86
|
|
|
90
|
-
4.
|
|
91
|
-
```bash
|
|
92
|
-
npx @j-o-r/hello-dave dave --connect ws://localhost:8080 --secret your_secret
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
5. Generate a custom agent using the portable `createAgent` CLI tool (CLI/WS agents + CodeServer launchers; equivalent to `dave --spawn`):
|
|
96
|
-
```bash
|
|
97
|
-
npx @j-o-r/hello-dave createAgent
|
|
98
|
-
```
|
|
99
|
-
- Interactive: Follow prompts to create a new agent script in `bin/` (e.g., `bin/myagent.js`).
|
|
100
|
-
- Portable to any project (auto-installs deps like `@j-o-r/hello-dave`; runs via npx anywhere—no local install needed):
|
|
101
|
-
```bash
|
|
102
|
-
npx @j-o-r/hello-dave createAgent --cwd ~/my-project
|
|
103
|
-
```
|
|
104
|
-
- Supports one-shot: `echo "Create code-review agent" | npx @j-o-r/hello-dave createAgent --cwd ~/proj`.
|
|
105
|
-
- Aligns with CodeServer pattern for multi-agent setups (see Usage/Examples). Use `dave --spawn` as a convenience alias within this package.
|
|
106
|
-
|
|
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).
|
|
87
|
+
4. **API Keys**: Set environment variables (e.g., `XAIKEY` for xAI, `OPENAI_API_KEY` for OpenAI).
|
|
108
88
|
|
|
109
89
|
## Usage
|
|
110
90
|
|
|
111
|
-
###
|
|
112
|
-
|
|
113
|
-
`bin/dave.js` is a CLI utility for session maintenance, WS client connections (UI for servers), spawning agents (via `--spawn`, alias for `createAgent`), 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:
|
|
114
|
-
|
|
115
|
-
- **Ask Mode** (Interactive or Piped One-Shot, using default Grok agent):
|
|
116
|
-
```bash
|
|
117
|
-
# Interactive
|
|
118
|
-
npx @j-o-r/hello-dave dave --ask --model grok-4 --temperature 0.2
|
|
119
|
-
|
|
120
|
-
# Piped one-shot
|
|
121
|
-
echo "What is quantum computing?" | npx @j-o-r/hello-dave dave --ask --model grok-4
|
|
122
|
-
```
|
|
123
|
-
- Note: Piped input triggers a direct response via `directCall`; without pipe, it launches an interactive CLI session.
|
|
124
|
-
- `--model` option works for both modes (e.g., `grok-4`, `grok-4-1-fast-reasoning`).
|
|
125
|
-
- Uses default `AgentManager` with xAI Grok API integration, adds tools like `web_search`, `x_search`, `open_link`, `send_email`, `history_search`.
|
|
126
|
-
- System prompt emphasizes brief, direct responses with step-by-step reasoning.
|
|
127
|
-
|
|
128
|
-
- **SpawnDave Mode** (Portable Agent Creator with --cwd Support; Convenience Alias for `createAgent`):
|
|
129
|
-
```bash
|
|
130
|
-
# Interactive in current project
|
|
131
|
-
npx @j-o-r/hello-dave dave --spawn --model grok-4-fast-reasoning --temperature 0.7
|
|
132
|
-
|
|
133
|
-
# Portable to another project (switches cwd, auto-deps)
|
|
134
|
-
npx @j-o-r/hello-dave dave --spawn --cwd ../other-proj
|
|
135
|
-
|
|
136
|
-
# One-shot for quick generation
|
|
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
|
|
138
|
-
```
|
|
139
|
-
- Creates production-ready CLI/WS agents (`bin/<name>.js`) supporting CLI, server (`--serve`), client (`--connect`), and hybrid modes.
|
|
140
|
-
- Generates multi-agent CodeServer launchers (`examples/<Name>Server`) using PM2 for persistent networked setups (main server + sub-agents).
|
|
141
|
-
- **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.
|
|
142
|
-
- Aligns with CodeServer pattern: Self-contained Bash launchers for PM2-managed multi-agents (e.g., code review + TODO + NPM agents).
|
|
143
|
-
- Requires `XAIKEY`; uses online repo docs (https://codeberg.org/duin/hello-dave) for portability.
|
|
144
|
-
- Example output: Deploys `bin/coderev_agent.js`, tests it, provides server/client usage guide.
|
|
145
|
-
- **Note**: `dave --spawn` is a convenience wrapper around the full `createAgent` tool (see below). Use `createAgent` directly for standalone/portable access without the dave utility.
|
|
146
|
-
|
|
147
|
-
- **WebSocket Client Mode** (Utility UI for connecting to servers, with secrets for secure networking):
|
|
148
|
-
```bash
|
|
149
|
-
# Interactive connection
|
|
150
|
-
npx @j-o-r/hello-dave dave --connect ws://localhost:8080 --secret "mysecret"
|
|
151
|
-
|
|
152
|
-
# Piped one-shot (direct CLI/cron messaging, no heartbeat needed)
|
|
153
|
-
echo "Predict the weather" | npx @j-o-r/hello-dave dave --connect ws://localhost:8080 --secret "mysecret"
|
|
154
|
-
echo "user_reset" | npx @j-o-r/hello-dave dave --connect ws://localhost:8080 --secret "mysecret"
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
- **CodeServer Launch Mode** (One-Command Multi-Agent Cluster via PM2; Utility Only, No --serve):
|
|
158
|
-
```bash
|
|
159
|
-
# Global (requires global install)
|
|
160
|
-
dave --code 8080 --secret mysecret
|
|
161
|
-
|
|
162
|
-
# Portable via npx (no local install needed)
|
|
163
|
-
npx @j-o-r/hello-dave dave --code 8080 --secret mysecret
|
|
164
|
-
```
|
|
165
|
-
- Launches `examples/codeserver.sh` with the provided port (1024-65535) and secret (min 3 chars), starting a PM2-managed CodeServer cluster.
|
|
166
|
-
- 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.
|
|
167
|
-
- Requires PM2 installed globally: `npm i -g pm2`.
|
|
168
|
-
- **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.
|
|
169
|
-
- Monitors processes with PM2 prefix (e.g., `project_code_agent_8080`). Stop via `pm2 delete project_*_8080`.
|
|
170
|
-
- Aligns with Startup Modes (utility launch only; no direct --serve in dave.js—use full agents for servers).
|
|
171
|
-
- Connect to the cluster: `npx @j-o-r/hello-dave dave --connect ws://127.0.0.1:8080 --secret mysecret` (interactive or piped).
|
|
172
|
-
- **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.
|
|
173
|
-
|
|
174
|
-
- **Cache Management** (Session maintenance in .cache):
|
|
175
|
-
```bash
|
|
176
|
-
npx @j-o-r/hello-dave dave --list # List sessions
|
|
177
|
-
npx @j-o-r/hello-dave dave --search "AI agents" # Search history
|
|
178
|
-
npx @j-o-r/hello-dave dave --clear # Clear cache
|
|
179
|
-
npx @j-o-r/hello-dave dave --inspect path/to/log.ndjson # Inspect log
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
For custom full agents (with prompts/tools/server support), use `AgentManager` programmatically (see Examples) or scripts like `examples/npm_agent.js`.
|
|
183
|
-
|
|
184
|
-
### createAgent CLI Tool (Portable Agent Generator; Full Agent Script)
|
|
185
|
-
|
|
186
|
-
The `createAgent` command (mapped to `examples/spawn_agent.js` in package.json) is a full-featured agent for generating custom agents. It supports all Startup Modes (Direct Call, Interactive CLI, WS Server, WS Client, Hybrid) and is highly portable—run via `npx @j-o-r/hello-dave createAgent` anywhere without local installation. It auto-installs dependencies (`@j-o-r/hello-dave @j-o-r/sh`) in the target project, validates generated code, and tests deployments. Use `dave --spawn` as a convenience alias within this package.
|
|
187
|
-
|
|
188
|
-
**Full Modes (Aligned with Startup Modes)**:
|
|
189
|
-
- **Direct Call (One-Shot, Positional Arg Only)**: For single generations via positional prompt. Ideal for scripts/cron.
|
|
190
|
-
```bash
|
|
191
|
-
# Portable one-shot (no local install)
|
|
192
|
-
npx @j-o-r/hello-dave createAgent "Create a code-review agent with git diff tools"
|
|
193
|
-
# With options
|
|
194
|
-
npx @j-o-r/hello-dave createAgent "Generate music agent" --model grok-4-fast-reasoning --temperature 0.7 --cwd ~/my-proj
|
|
195
|
-
```
|
|
196
|
-
- Input: Positional string (trimmed). Triggers `directCall` for quick agent creation. Outputs generated script (e.g., `bin/coderev_agent.js`), validates with `node --check`, and tests via execution.
|
|
197
|
-
|
|
198
|
-
- **Interactive CLI (No Positional Arg)**: Launches ongoing conversation for guided agent creation.
|
|
199
|
-
```bash
|
|
200
|
-
# Interactive (current dir)
|
|
201
|
-
npx @j-o-r/hello-dave createAgent
|
|
202
|
-
# Portable to another project
|
|
203
|
-
npx @j-o-r/hello-dave createAgent --cwd ../other-proj --model grok-4
|
|
204
|
-
```
|
|
205
|
-
- Follows conversational prompts: name (lowercase /^[a-z_0-9_]{2,}$/), description, tools, prompt, etc. Generates, deploys, and tests the agent.
|
|
91
|
+
### CLI Tools
|
|
206
92
|
|
|
207
|
-
- **
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
-
|
|
93
|
+
- **dave**: Interact with agents locally or remotely.
|
|
94
|
+
- Local query: `dave --ask "Predict the weather"`
|
|
95
|
+
- One-shot remote: `echo "Hello" | dave --connect 'ws://127.0.0.1:8080' --secret '123'`
|
|
96
|
+
- Interactive remote: `dave --connect 'ws://127.0.0.1:8080' --secret '123'`
|
|
97
|
+
- Other: `dave --list` (sessions), `dave --clear` (cache), `dave --help`.
|
|
212
98
|
|
|
213
|
-
- **
|
|
99
|
+
- **agentDave**: Spawn an agent server (powered by `spawn_agent.js`).
|
|
214
100
|
```bash
|
|
215
|
-
|
|
101
|
+
agentDave --serve 8080 --secret '123' # Starts WebSocket server
|
|
216
102
|
```
|
|
217
|
-
- Uses remote tools (e.g., from CodeServer) during generation. Portable via npx.
|
|
218
103
|
|
|
219
|
-
- **
|
|
104
|
+
- **codeDave**: Launch a PM2 code server cluster.
|
|
220
105
|
```bash
|
|
221
|
-
|
|
106
|
+
codeDave 8080 --secret '123' # Or: dave --code 8080 --secret '123'
|
|
222
107
|
```
|
|
223
|
-
- Ideal for networked setups; generates agents with access to remote capabilities.
|
|
224
|
-
|
|
225
|
-
**Shared Options** (Apply to All Modes):
|
|
226
|
-
- `--model [grok-4-fast-reasoning|...]`: LLM model (default: grok-4-fast-reasoning).
|
|
227
|
-
- `--temperature [float] (-2 to +2)`: Creativity level.
|
|
228
|
-
- `--tokens [number]`: Max output tokens.
|
|
229
|
-
- `--top_p [float]`: Nucleus sampling.
|
|
230
|
-
- `--context [number] (default: 250000)`: Context window size.
|
|
231
|
-
- `--cwd [path]`: Target directory for generation (auto-switches, installs deps if needed; portable).
|
|
232
|
-
- `--secret [string] (min 3 chars)`: For WS modes (shared auth token).
|
|
233
108
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
**Integration with dave --spawn**: Within this package, `dave --spawn` provides a simple wrapper (e.g., handles input parsing), but `createAgent` is the primary, standalone tool for broader use.
|
|
237
|
-
|
|
238
|
-
### Programmatic Usage with AgentManager (For Full Agents)
|
|
239
|
-
|
|
240
|
-
```javascript
|
|
241
|
-
import AgentManager from '@j-o-r/hello-dave';
|
|
242
|
-
|
|
243
|
-
const agent = new AgentManager({ name: 'MyAgent', secret: 'optional_secret' });
|
|
244
|
-
agent.setup({
|
|
245
|
-
prompt: 'You are a helpful assistant...',
|
|
246
|
-
api: 'xai', // Uses unified xAI Grok API access
|
|
247
|
-
options: { model: 'grok-4', temperature: 0.7, tools: [{ type: 'web_search' }] },
|
|
248
|
-
toolsetMode: 'auto',
|
|
249
|
-
contextWindow: 500000
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
agent.addGenericToolcall('execute_bash_script'); // Post-setup generics
|
|
253
|
-
agent.addGenericToolcall('read_file');
|
|
254
|
-
agent.addGenericToolcall('write_file');
|
|
255
|
-
agent.addGenericToolcall('memory_recall'); // Persist/recall tasks, errors, prefs in .cache/memory.ndjson
|
|
256
|
-
agent.addGenericToolcall('memory_write'); // Optimizes loops and long-running sessions
|
|
257
|
-
|
|
258
|
-
await agent.start(); // Interactive CLI
|
|
259
|
-
// Or: await agent.start(undefined, 8000, undefined, 'Intro', 'toolName', 'desc'); // WS server
|
|
260
|
-
// Or: const response = await agent.directCall('Query'); // One-shot
|
|
261
|
-
```
|
|
109
|
+
### Running Agents
|
|
262
110
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
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.
|
|
266
|
-
|
|
267
|
-
## Startup Modes
|
|
268
|
-
|
|
269
|
-
This section unifies the startup modes for full agents (e.g., `examples/npm_agent.js`, `createAgent`) and the programmatic `AgentManager.start(serve, connect, cliIntro, tool_call_name, tool_call_description)`. These modes are standardized across agents generated by `createAgent` 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 (via --spawn), cache management, and CodeServer launch via --code (no custom prompts/tools or --serve; utility-only).
|
|
270
|
-
|
|
271
|
-
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).
|
|
272
|
-
|
|
273
|
-
**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.
|
|
274
|
-
|
|
275
|
-
**Note on createAgent**: As a full agent, it supports all modes below. Use for portable generation in any project.
|
|
276
|
-
|
|
277
|
-
### AgentManager.start() Options Explained
|
|
278
|
-
The `start()` method is the smart launcher for all modes. It accepts up to 5 arguments in order:
|
|
279
|
-
- `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.
|
|
280
|
-
- `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.
|
|
281
|
-
- `cliIntro` (string | undefined): Custom welcome message for interactive CLI mode (e.g., "NPM Agent ready. Ask about modules.").
|
|
282
|
-
- `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.
|
|
283
|
-
- `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.").
|
|
284
|
-
|
|
285
|
-
**Mode Determination**:
|
|
286
|
-
- If `serve` provided: Starts WS server (exposes tools).
|
|
287
|
-
- If `connect` provided: Starts WS client (attaches to remote, gains tools).
|
|
288
|
-
- If both: Hybrid mode (serves locally while using remote tools).
|
|
289
|
-
- If neither: Interactive CLI mode.
|
|
290
|
-
- For one-shot (non-start): Use `directCall(input)` directly (positional arg in scripts).
|
|
291
|
-
|
|
292
|
-
**Shared Notes**:
|
|
293
|
-
- `--secret [string]` (min 3 chars): Shared auth token. Servers reject mismatched clients; use the same for chains/networks.
|
|
294
|
-
- Other options: `--model [grok-4-fast-reasoning|...]`, `--temperature [-2 to +2]`, `--tokens`, `--top_p`, `--context [250000]`.
|
|
295
|
-
- Positional args ignored in WS modes (use CLI/pipes instead).
|
|
296
|
-
- No heartbeat: Event-driven responses.
|
|
297
|
-
- For multi-agent chaining, see [CodeServer pattern](docs/codeserver-pattern.md).
|
|
298
|
-
|
|
299
|
-
### 1. Direct Call (One-Shot, Positional Arg Only)
|
|
300
|
-
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.)
|
|
301
|
-
|
|
302
|
-
**CLI Example (Full Agent, e.g., npm_agent.js or createAgent)**:
|
|
111
|
+
Run agent scripts directly:
|
|
303
112
|
```bash
|
|
304
|
-
|
|
305
|
-
|
|
113
|
+
node agents/spawn_agent.js --serve 8080 --secret '123' # Spawn server
|
|
114
|
+
node agents/code_agent.js --connect 'ws://127.0.0.1:8080' --secret '123' # Client mode
|
|
306
115
|
```
|
|
307
|
-
- Input: Positional string (trimmed). If empty/missing, falls to interactive CLI or help.
|
|
308
116
|
|
|
309
|
-
|
|
310
|
-
```javascript
|
|
311
|
-
import { AgentManager } from '@j-o-r/hello-dave' ;
|
|
312
|
-
const agent = new AgentManager({ name: 'npm_agent' });
|
|
313
|
-
await agent.setup({ /* prompt, api, options, toolsetMode, contextWindow */ });
|
|
314
|
-
const response = await agent.directCall('What modules are installed?' );
|
|
315
|
-
console.log(response);
|
|
316
|
-
```
|
|
317
|
-
- Pair with `readIn()` from `@j-o-r/sh` for piped stdin detection in scripts (e.g., `echo "query" | script.js`).
|
|
117
|
+
For full options, see script headers or run with `--help`.
|
|
318
118
|
|
|
319
|
-
|
|
320
|
-
```bash
|
|
321
|
-
echo "Explain quantum computing" | npx @j-o-r/hello-dave dave --ask [--model grok-4]
|
|
322
|
-
```
|
|
323
|
-
- Triggers `directCall` on piped input.
|
|
324
|
-
|
|
325
|
-
### 2. Interactive CLI (No Positional Arg)
|
|
326
|
-
Launches ongoing conversation session with REPL-like input (multi-turn, until Ctrl+C or `Alt+d`).
|
|
327
|
-
|
|
328
|
-
**CLI Example (Full Agent)**:
|
|
329
|
-
```bash
|
|
330
|
-
npx @j-o-r/hello-dave createAgent [--model grok-4]
|
|
331
|
-
./examples/npm_agent.js [--model grok-4]
|
|
332
|
-
```
|
|
333
|
-
- No positional: Starts `agent.start()` with CLI intro.
|
|
119
|
+
### Programmatic Usage
|
|
334
120
|
|
|
335
|
-
|
|
121
|
+
Import and use in your Node.js app:
|
|
336
122
|
```javascript
|
|
337
|
-
|
|
123
|
+
import { AgentManager } from '@j-o-r/hello-dave';
|
|
124
|
+
// Setup and run agent...
|
|
338
125
|
```
|
|
339
|
-
- Uses `cliIntro` for welcome message. Supports history, reset (`Alt+r`).
|
|
340
126
|
|
|
341
|
-
|
|
342
|
-
```bash
|
|
343
|
-
npx @j-o-r/hello-dave dave --ask
|
|
344
|
-
```
|
|
345
|
-
- Default agent; no custom tools/prompts.
|
|
346
|
-
|
|
347
|
-
### 3. WS Server (--serve [port])
|
|
348
|
-
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.)
|
|
349
|
-
|
|
350
|
-
**CLI Example (Full Agent)**:
|
|
351
|
-
```bash
|
|
352
|
-
npx @j-o-r/hello-dave createAgent --serve 8080 [--secret mysecret] [--model grok-4]
|
|
353
|
-
./examples/npm_agent.js --serve 8080 [--secret mysecret] [--model grok-4]
|
|
354
|
-
```
|
|
355
|
-
- Exposes `tool_call_name` (e.g., `npm_module_inspector` or `spawn_agent` for createAgent) for remote calls.
|
|
127
|
+
### spawn_agent.js Specifics (v0.0.8 Portability Ready)
|
|
356
128
|
|
|
357
|
-
**
|
|
358
|
-
```javascript
|
|
359
|
-
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
|
|
360
|
-
```
|
|
361
|
-
- `tool_call_name` and `tool_call_description` required for exposure. See [AgentManager docs](docs/agent-manager.md) for full server config, including reset propagation.
|
|
362
|
-
|
|
363
|
-
**Client Usage** (Connect to this server):
|
|
364
|
-
```bash
|
|
365
|
-
# Interactive
|
|
366
|
-
npx @j-o-r/hello-dave dave --connect ws://127.0.0.1:8080 --secret mysecret
|
|
367
|
-
# Or full agent: ./examples/other_agent.js --connect ws://127.0.0.1:8080 --secret mysecret
|
|
368
|
-
```
|
|
369
|
-
- Clients gain the servers tools (e.g., call `npm_module_inspector` in their prompts).
|
|
129
|
+
`spawn_agent.js` (executable as `agentDave`) creates and deploys portable agents in CLI, WebSocket server, client, or **hybrid** modes (server + client for tool chaining). It fetches live prompts from [docs/prompt/spawn_agent.md](docs/prompt/spawn_agent.md) and validates new agents via blueprint (temp files, syntax checks, grep for modes/tools).
|
|
370
130
|
|
|
371
|
-
|
|
372
|
-
|
|
131
|
+
- **Modes**:
|
|
132
|
+
- **Direct (One-Shot)**: Positional input, e.g., `node agents/spawn_agent.js "Create a tester"`.
|
|
133
|
+
- **Interactive CLI**: No input; runs REPL-like session.
|
|
134
|
+
- **Server**: `--serve <port>` – Exposes as remote tool (e.g., for other agents to call `spawn_agent`).
|
|
135
|
+
- **Client**: `--connect <ws_url>` – Connects to remote server for tool access.
|
|
136
|
+
- **Hybrid**: `--serve <port> --connect <ws_url>` – Serves locally while using remote tools.
|
|
373
137
|
|
|
374
|
-
**
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
```
|
|
379
|
-
- Attaches to server; uses remote tools in local sessions.
|
|
138
|
+
- **Portability**:
|
|
139
|
+
- **In Project**: Auto-deploys to `./agents/<name>.js` if `./agents/*.js` exist (uses existing structure).
|
|
140
|
+
- **Fresh /tmp**: Manual code generation + bash setup (e.g., `mkdir /tmp/myproj/agents; cd /tmp/myproj; node spawn_agent.js ...`). Tools (e.g., `read_file`) follow CWD, ensuring isolation without fixed paths.
|
|
141
|
+
- Works in any dir; no repo deps beyond Node.js + npm installs.
|
|
380
142
|
|
|
381
|
-
**
|
|
382
|
-
```javascript
|
|
383
|
-
await agent.start(undefined, 'ws://127.0.0.1:8080/ws' , undefined, undefined, undefined ); // Client mode; secret required if server uses one
|
|
384
|
-
```
|
|
385
|
-
- After connection, interactive CLI starts. For one-shot: Pipe to script (uses `directCall` with remote tools).
|
|
143
|
+
- **Custom Tools**: Specify in prompt, e.g., "name=coderev, tools=read_file,web_search,execute_bash_script".
|
|
386
144
|
|
|
387
|
-
|
|
388
|
-
```bash
|
|
389
|
-
# Interactive
|
|
390
|
-
npx @j-o-r/hello-dave dave --connect ws://localhost:8080 --secret "mysecret"
|
|
391
|
-
# Piped one-shot (cron-friendly)
|
|
392
|
-
echo "Use remote NPM tool to list modules" | npx @j-o-r/hello-dave dave --connect ws://localhost:8080 --secret "mysecret"
|
|
393
|
-
```
|
|
145
|
+
For validation/testing: See blueprint in [docs/prompt/spawn_agent.md](docs/prompt/spawn_agent.md) (includes bash examples like `node agents/NEW_AGENT.js --help` or server connect tests).
|
|
394
146
|
|
|
395
|
-
###
|
|
396
|
-
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.)
|
|
147
|
+
### CodeServer & PM2 Multi-Agent (v0.0.8)
|
|
397
148
|
|
|
398
|
-
|
|
399
|
-
```bash
|
|
400
|
-
npx @j-o-r/hello-dave createAgent --serve 8081 --connect ws://otherhost:8080/ws [--secret mysecret]
|
|
401
|
-
./examples/npm_agent.js --serve 8081 --connect ws://otherhost:8080/ws [--secret mysecret]
|
|
402
|
-
```
|
|
403
|
-
- Local server on 8081 (exposes local tools); client to remote (uses remote tools).
|
|
149
|
+
CodeServer (via `bin/codeDave` or `agents/codeserver.sh`) launches scalable, PM2-clustered multi-agent environments for collaborative tasks (e.g., code generation + task management). It deploys agents like `code_agent`, `todo_agent`, and `readme_agent` on a WebSocket server, enabling chaining and load balancing.
|
|
404
150
|
|
|
405
|
-
**
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
```
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
This
|
|
414
|
-
|
|
415
|
-
## Examples
|
|
416
|
-
|
|
417
|
-
Example scripts (e.g., `readme_agent.js` for README management, `todo_agent.js` for task handling, `spawn_agent.js` for agent creation via `createAgent`) 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).
|
|
418
|
-
|
|
419
|
-
- **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).
|
|
420
|
-
|
|
421
|
-
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.
|
|
422
|
-
|
|
423
|
-
### Persistent Multi-Agent CodeServer Pattern
|
|
424
|
-
|
|
425
|
-
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.
|
|
426
|
-
|
|
427
|
-
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).
|
|
428
|
-
|
|
429
|
-
**Usage (Prefer Shell Portability):**
|
|
430
|
-
|
|
431
|
-
```bash
|
|
432
|
-
# Direct shell launch (portable, no Node.js wrapper needed; requires PM2: npm i -g pm2)
|
|
433
|
-
./examples/codeserver.sh 8080 mysecret
|
|
434
|
-
|
|
435
|
-
# Convenience via dave.js utility (global or npx)
|
|
436
|
-
dave --code 8080 --secret mysecret
|
|
437
|
-
npx @j-o-r/hello-dave dave --code 8080 --secret mysecret
|
|
438
|
-
```
|
|
439
|
-
|
|
440
|
-
Monitor with `pm2 list` and stop via `pm2 delete <name>` (e.g., `pm2 delete project_*_8080`).
|
|
441
|
-
|
|
442
|
-
**Connect via CLI utility (interactive or piped):**
|
|
443
|
-
```bash
|
|
444
|
-
npx @j-o-r/hello-dave dave --connect ws://127.0.0.1:8080/ws --secret mysecret
|
|
445
|
-
# 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
|
|
446
|
-
```
|
|
447
|
-
|
|
448
|
-
### Snippet: Spawning Agents (Portable via `createAgent` or `dave --spawn`)
|
|
449
|
-
|
|
450
|
-
`createAgent` (examples/spawn_agent.js) uses `AgentManager` to interactively or programmatically generate new agent scripts, fully aware of WebSocket server/client modes and the CodeServer multi-agent pattern for networked setups. It supports all Startup Modes and is portable via npx.
|
|
451
|
-
|
|
452
|
-
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).
|
|
453
|
-
|
|
454
|
-
**Portable**: `createAgent` runs anywhere via `npx`—no local docs/examples needed. Uses online repo links (https://codeberg.org/duin/hello-dave). Auto-deps with `--cwd`. `dave --spawn` is a convenience alias for use within this package.
|
|
455
|
-
|
|
456
|
-
```javascript
|
|
457
|
-
// Core setup in createAgent (examples/spawn_agent.js)
|
|
458
|
-
const agent = new AgentManager({ name: 'spawn_agent', secret });
|
|
459
|
-
agent.setup({
|
|
460
|
-
prompt: 'You are AgentCreator... [detailed prompt for portability, validation]',
|
|
461
|
-
api: 'xai',
|
|
462
|
-
options: { model: 'grok-4-fast-reasoning', tools: [{ type: 'web_search' }], reasoning: { effort: 'high' } },
|
|
463
|
-
toolsetMode: 'auto',
|
|
464
|
-
contextWindow: 500000
|
|
465
|
-
});
|
|
466
|
-
agent.addGenericToolcall('execute_bash_script'); // For project inspection
|
|
467
|
-
agent.addGenericToolcall('read_file');
|
|
468
|
-
agent.addGenericToolcall('write_file'); // For generating bin/ scripts
|
|
469
|
-
agent.addGenericToolcall('memory_recall'); // For recalling previous generations or prefs
|
|
470
|
-
agent.addGenericToolcall('memory_write'); // For persisting agent configs or errors
|
|
471
|
-
|
|
472
|
-
await agent.start(); // Guides user to create e.g., bin/myagent.js
|
|
473
|
-
```
|
|
474
|
-
|
|
475
|
-
- Validates generated ESM code with `node --check` and tool rules (xAI natives pre-setup, generics post-setup).
|
|
476
|
-
- Ensures absolute imports for portability.
|
|
477
|
-
|
|
478
|
-
**Example Usage (Portable Agent Generation & CodeServer)**:
|
|
479
|
-
|
|
480
|
-
```bash
|
|
481
|
-
# Interactive spawning (runs from npm without cloning; current dir)
|
|
482
|
-
npx @j-o-r/hello-dave createAgent
|
|
483
|
-
# Or via dave alias: npx @j-o-r/hello-dave dave --spawn
|
|
484
|
-
|
|
485
|
-
# Portable to specific project (auto-switches cwd, installs deps if needed)
|
|
486
|
-
npx @j-o-r/hello-dave createAgent --cwd ~/my-proj --model grok-4-fast-reasoning
|
|
151
|
+
- **Defaults**: Port 9000, secret '123' (customizable via args).
|
|
152
|
+
- **Prerequisites**: Install PM2 globally (`npm install -g pm2`).
|
|
153
|
+
- **Quickstart**:
|
|
154
|
+
```bash
|
|
155
|
+
codeDave 9000 --secret 123 # Launches PM2 cluster on ws://127.0.0.1:9000/ws
|
|
156
|
+
pm2 list # Verify processes (e.g., code_agent, todo_agent instances)
|
|
157
|
+
echo "task" | bin/dave.js --connect ws://127.0.0.1:9000/ws --secret 123 # One-shot query to cluster
|
|
158
|
+
```
|
|
159
|
+
This starts the cluster, lists running agents, and sends a test task (response routed to available agents).
|
|
487
160
|
|
|
488
|
-
|
|
489
|
-
echo "Create a code-review agent: name=coderev, desc=Git diff analyzer, tools=read_file execute_bash_script web_search" | npx @j-o-r/hello-dave createAgent --cwd ~/proj
|
|
161
|
+
- **Scaling & Management**: Use PM2 commands (e.g., `pm2 scale <app> 4`, `pm2 stop all`). For ecosystem config, PM2 JSON files, or agent orchestration, see the [full guide in docs/multi-agent-clusters.md](docs/multi-agent-clusters.md).
|
|
490
162
|
|
|
491
|
-
|
|
492
|
-
npx @j-o-r/hello-dave createAgent "Generate CodeServer launcher for coderev + tododave + npmdave" --cwd ~/proj
|
|
493
|
-
# Outputs self-contained Bash script (e.g., examples/CodeServer.sh) for PM2-managed cluster
|
|
494
|
-
```
|
|
163
|
+
- **Integration**: Combine with `spawn_agent.js` for dynamic agent addition to clusters (e.g., spawn new agents and connect via `--connect ws://127.0.0.1:9000/ws`).
|
|
495
164
|
|
|
496
|
-
|
|
497
|
-
- **CodeServer Integration**: If prompted (e.g., "multi-agent setup"), generates PM2 launchers like `examples/<Custom>Server.sh` (main server + sub-agents). Portable and self-contained; run directly or via `dave --code`.
|
|
165
|
+
## Usage Examples
|
|
498
166
|
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
167
|
+
- **Direct Spawn (Project)**:
|
|
168
|
+
```bash
|
|
169
|
+
cd hello-dave # Or any project with ./agents/
|
|
170
|
+
node agents/spawn_agent.js "Create code-review agent: name=coderev, desc=Git diff analyzer, tools=read_file,execute_bash_script,web_search"
|
|
171
|
+
# Deploys to ./agents/coderev_agent.js; test: node agents/coderev_agent.js "Review this diff"
|
|
172
|
+
```
|
|
502
173
|
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
174
|
+
- **/tmp Workflow (Portable, Fresh Setup)**:
|
|
175
|
+
```bash
|
|
176
|
+
mkdir -p /tmp/myportable/agents
|
|
177
|
+
cd /tmp/myportable
|
|
178
|
+
# Copy or fetch spawn_agent.js (e.g., curl from repo or npm install @j-o-r/hello-dave)
|
|
179
|
+
npm init -y && npm i @j-o-r/hello-dave @j-o-r/sh
|
|
180
|
+
node spawn_agent.js "Create todo agent: name=todo, desc=Task manager, tools=read_file,write_file"
|
|
181
|
+
# Deploys to ./agents/todo_agent.js; tools use /tmp/myportable as CWD
|
|
182
|
+
node agents/todo_agent.js --serve 8081 --secret abc # Test server mode
|
|
183
|
+
```
|
|
512
184
|
|
|
513
|
-
|
|
185
|
+
- **Hybrid Mode with Custom Tools**:
|
|
186
|
+
```bash
|
|
187
|
+
node agents/spawn_agent.js --serve 8081 --connect ws://127.0.0.1:8080/ws --secret abc "Spawn a docs agent with custom email tool"
|
|
188
|
+
# Serves on 8081 (exposes new agent), connects to 8080 (gains remote tools like email)
|
|
189
|
+
# Test: In another term, node agents/spawn_agent.js --connect ws://127.0.0.1:8081/ws --secret abc "Use the new docs agent"
|
|
190
|
+
```
|
|
514
191
|
|
|
515
|
-
|
|
192
|
+
- **Spawn a Server**:
|
|
193
|
+
```bash
|
|
194
|
+
node agents/spawn_agent.js --serve 8080 --secret '123'
|
|
195
|
+
# Then connect: echo "Task" | dave --connect 'ws://127.0.0.1:8080' --secret '123'
|
|
196
|
+
```
|
|
516
197
|
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
198
|
+
- **Launch Code Cluster** (includes multiple agents):
|
|
199
|
+
```bash
|
|
200
|
+
node agents/codeserver.sh 9000 '123' # Or use codeDave 9000 --secret 123
|
|
201
|
+
# Connects code_agent, todo_agent, readme_agent, etc., to the server on ws://127.0.0.1:9000/ws.
|
|
202
|
+
# Test: pm2 list; echo "Optimize this code" | dave --connect ws://127.0.0.1:9000/ws --secret 123
|
|
203
|
+
# For advanced config: See [docs/multi-agent-clusters.md](docs/multi-agent-clusters.md).
|
|
204
|
+
```
|
|
521
205
|
|
|
522
|
-
|
|
523
|
-
|
|
206
|
+
- **Local Agent Query** (no server):
|
|
207
|
+
```bash
|
|
208
|
+
dave --ask --model 'grok-4-1-fast-reasoning' "Write a function"
|
|
209
|
+
```
|
|
524
210
|
|
|
525
|
-
|
|
526
|
-
|
|
211
|
+
- **Custom Agent**:
|
|
212
|
+
```bash
|
|
213
|
+
node agents/docs_agent.js --connect 'ws://127.0.0.1:8080' --secret '123'
|
|
214
|
+
```
|
|
527
215
|
|
|
528
|
-
|
|
529
|
-
npx @j-o-r/hello-dave createAgent "Create a docs agent"
|
|
530
|
-
```
|
|
216
|
+
See `scenarios/` for more test scenarios.
|
|
531
217
|
|
|
532
218
|
## Development
|
|
533
219
|
|
|
534
|
-
- **
|
|
535
|
-
- **
|
|
536
|
-
- **
|
|
537
|
-
- **
|
|
538
|
-
|
|
539
|
-
## Changelog
|
|
540
|
-
|
|
541
|
-
### v0.0.5 (Released - May 2026)
|
|
542
|
-
- **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.
|
|
543
|
-
- **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.
|
|
544
|
-
- **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).
|
|
545
|
-
- **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.
|
|
546
|
-
- **createAgent Bin Promotion**: Documented `createAgent` CLI (package.json bin mapping to examples/spawn_agent.js) as primary portable tool for agent generation. Added full Usage section with modes (interactive/one-shot/WS server/client/hybrid), options (--model etc.), and portability emphasis (npx anywhere, auto-deps). Linked as standalone equivalent to dave --spawn (convenience alias). Updated Quick Start/Examples/Startup Modes with createAgent examples; fixed direct calls from spawn_agent to createAgent.
|
|
547
|
-
- **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.
|
|
548
|
-
- **Package Alignment**: Bumped package.json to version "0.0.5" in preparation for release; regenerated types to include new exports and flag support.
|
|
549
|
-
- **Prep Notes**: Git clean performed; full tests/types/docs verified post-updates. Focus on CodeServer integration, portability testing, and createAgent docs complete. v0.0.5 docs marked as complete.
|
|
550
|
-
|
|
551
|
-
### v0.0.4 (Previous - April 2026)
|
|
552
|
-
- **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.
|
|
553
|
-
- **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.
|
|
554
|
-
- **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.
|
|
555
|
-
- **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.
|
|
556
|
-
- **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).
|
|
557
|
-
- **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).
|
|
558
|
-
- **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.
|
|
559
|
-
- **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.
|
|
560
|
-
- **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.
|
|
561
|
-
- **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.
|
|
562
|
-
- **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.
|
|
563
|
-
|
|
564
|
-
### v0.0.3 (Previous - March 2026)
|
|
565
|
-
- Initial WS secrets, generic tools, AgentManager refinements.
|
|
566
|
-
- Reorganized examples to `examples/` folder (readmeDave, todoDave, etc.).
|
|
567
|
-
- Enhanced `bin/dave.js` for core utilities: spawning, WS with secrets, direct messaging.
|
|
568
|
-
- Improved xAI Grok API integration; added native tools/reasoning support.
|
|
569
|
-
- Removed heartbeat needs; direct CLI/cron support.
|
|
570
|
-
- Added piped one-shot support to dave --ask.
|
|
571
|
-
|
|
572
|
-
Full history in git tags (recent: cleanup toolset test, TODO status update, fixed test/README, syntax fixes, startup modes explanation).
|
|
220
|
+
- **Build Types**: `npm run types`
|
|
221
|
+
- **Test**: `npm run tests` (runs `utils/test.sh`)
|
|
222
|
+
- **Release**: `npm run release` then `npm run publish`
|
|
223
|
+
- **Local Linking**: `npm run link-self` / `npm run unlink-self`
|
|
573
224
|
|
|
574
|
-
|
|
225
|
+
Use `git status` and `ls` to inspect changes. Ensure ESM compatibility.
|
|
575
226
|
|
|
576
|
-
|
|
227
|
+
## Contributing
|
|
577
228
|
|
|
578
|
-
|
|
579
|
-
2. Self dep `npm run link-self`
|
|
580
|
-
3. Run tests: `npm test`
|
|
581
|
-
4. Generate types: `npm run types`
|
|
582
|
-
5. Report issues: [https://codeberg.org/duin/hello-dave/issues](https://codeberg.org/duin/hello-dave/issues)
|
|
229
|
+
Contributions welcome! Fork the repo, create a branch, and submit a pull request to https://codeberg.org/duin/hello-dave.
|
|
583
230
|
|
|
584
|
-
|
|
231
|
+
- Report bugs: https://codeberg.org/duin/hello-dave/issues
|
|
232
|
+
- Follow Apache-2.0 license.
|
|
585
233
|
|
|
586
234
|
## License
|
|
587
235
|
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
## TODO Alignment
|
|
591
|
-
|
|
592
|
-
This README aligns with high-priority items from [TODO.md](TODO.md):
|
|
593
|
-
- **v0.0.5 Prep**: Changelog updated for --code flag, CodeServer enhancements, and bin/createAgent promotion; release steps emphasized (version bump to 0.0.5, tests, types, commit/tag, publish). Prep notes expanded for portability and utility alignment. Marked complete.
|
|
594
|
-
- **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.
|
|
595
|
-
- **createAgent / spawn_agent Enhancements**: Fully documented as primary bin tool with modes, options, portability (npx/auto-deps), and CodeServer support. Linked to dave --spawn alias. Examples/Quick Start updated.
|
|
596
|
-
- **Agent Standardization and Safeguards**: Integrated into Changelog and Usage notes (from v0.0.4).
|
|
597
|
-
- xAI integration tests/examples: Deferred to post-v0.0.5 (future enhancements).
|
|
598
|
-
- Documentation tasks (e.g., AgentManager internals, WS refinements) completed in Usage/Examples/Changelog.
|
|
599
|
-
- **Status**: No high-priority pending; all tests stable. v0.0.5 docs complete. Focus shifted to release and future features like xAI files.js integration.
|
|
236
|
+
This project is licensed under the Apache-2.0 License - see the [LICENSE](LICENSE) file for details.
|
|
600
237
|
|
|
601
|
-
|
|
238
|
+
---
|
|
239
|
+
*Repository: https://codeberg.org/duin/hello-dave*
|
|
240
|
+
---
|