@j-o-r/hello-dave 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/README.md +216 -56
- package/README.md.bak +481 -0
- package/README.md.bak.1774780058 +338 -0
- package/README.md.bak2 +455 -0
- package/docs.bak.1774780058/agent-manager.md +167 -0
- package/docs.bak.1774780058/agent-manager.md.bak +137 -0
- package/docs.bak.1774780058/agent-manager.md.bak2 +157 -0
- package/docs.bak.1774780058/codeserver-pattern.md +191 -0
- package/docs.bak.1774780058/path-resolution-best-practices.md +104 -0
- package/docs.bak.1774780058/project-overview.md +67 -0
- package/docs.bak.1774780058/project-overview.md.bak +67 -0
- package/docs.bak.1774780058/prompt-class.md +141 -0
- package/docs.bak.1774780058/prompt-class.md.bak +142 -0
- package/docs.bak.1774780058/tools-syntax-validation.md +121 -0
- package/docs.bak.1774780058/tools-syntax-validation.md.bak2 +125 -0
- package/docs.bak.1774780058/tools-syntax-validation.md.bak3 +125 -0
- package/docs.bak.1774780058/tools-syntax-validation.md.bak4 +106 -0
- package/docs.bak.1774780058/tools-syntax-validation.md.bak_path +106 -0
- package/docs.bak.1774780058/toolset.md +164 -0
- package/docs.bak.1774780058/toolset.md.bak +94 -0
- package/docs.bak.1774780058/toolset.md.bak3 +161 -0
- package/docs.bak.1774780058/toolset.md.bak4 +161 -0
- package/docs.bak.1774780058/toolset.md.bak5 +161 -0
- package/docs.bak.1774780058/toolset.md.bak6 +163 -0
- package/docs.bak.1774780058/toolset.md.bak_path +163 -0
- package/docs.bak.1774780058/toolset.md.bak_syntax +161 -0
- package/docs.bak.1774780058/xai-responses.md +111 -0
- package/docs.bak.1774780058/xai-responses.md.bak +107 -0
- package/docs.bak.1774780058/xai-responses.md.bak2 +107 -0
- package/docs.bak.1774780058/xai_collections.md +106 -0
- package/examples/ask_agent.js +137 -0
- package/examples/code_agent.js +149 -0
- package/examples/coderev_agent.js +136 -0
- package/examples/codeserver.sh +47 -0
- package/examples/daisy_agent.js +170 -0
- package/examples/docs_agent.js +148 -0
- package/examples/gpt_agent.js +125 -0
- package/examples/grok_agent.js +132 -0
- package/examples/grok_agent.js.bak +98 -0
- package/examples/grok_agent.js.bak.2 +99 -0
- package/examples/grok_agent.js.bak.3 +1 -0
- package/examples/grok_agent.js.bak.4 +124 -0
- package/examples/grok_agent.js.bak.5 +1 -0
- package/examples/grok_agent.js.bak.6 +1 -0
- package/examples/memory_agent.js +152 -0
- package/examples/npm_agent.js +202 -0
- package/examples/npm_agent.js.bak.3 +2 -0
- package/examples/npm_agent.js.bak.4 +205 -0
- package/examples/npm_agent.js.bak.5 +1 -0
- package/examples/npm_agent.js.bak.6 +1 -0
- package/examples/prompt_agent.js +133 -0
- package/examples/readme_agent.js +148 -0
- package/examples/spawn_agent.js +293 -0
- package/examples/test_agent.js +187 -0
- package/examples/todo_agent.js +175 -0
- package/{examples/codeDave.js → examples.bak.1774780058/code_agent.js} +40 -6
- package/{examples/CodeServer → examples.bak.1774780058/codeserver.sh} +9 -5
- package/examples.bak.1774780058/memory_agent.js +112 -0
- package/{examples/spawndave.js → examples.bak.1774780058/spawn_agent.js} +29 -6
- package/examples.bak.1774780058/test_agent.js +162 -0
- package/{examples/todoDave.js → examples.bak.1774780058/todo_agent.js} +8 -2
- package/lib/API/x.ai/responses.js +7 -9
- package/lib/AgentManager.js +3 -2
- package/lib/AgentServer.js +23 -19
- package/lib/genericToolset.js +159 -26
- package/lib/genericToolset.js.bak_syntax +402 -0
- package/lib/wsCli.js +0 -1
- package/package.json +4 -5
- package/scenarios.bak.1774780058/data/eval_node_message.json +9 -0
- package/scenarios.bak.1774780058/data/hist_oa.json +66 -0
- package/scenarios.bak.1774780058/data/o3_response1.json +96 -0
- package/scenarios.bak.1774780058/data/oa_reasoning_parse.json +112 -0
- package/scenarios.bak.1774780058/data/tool_oa.json +96 -0
- package/scenarios.bak.1774780058/data/tool_xai.json +59 -0
- package/scenarios.bak.1774780058/data/tool_xai2.json +40 -0
- package/scenarios.bak.1774780058/data/xai-response-1.json +59 -0
- package/scenarios.bak.1774780058/data/xai-response-2.json +10 -0
- package/scenarios.bak.1774780058/data/xai_reasoning_tools_resp.json +59 -0
- package/scenarios.bak.1774780058/data/xai_search_response.json +58 -0
- package/scenarios.bak.1774780058/environment.js +10 -0
- package/scenarios.bak.1774780058/example.js +17 -0
- package/scenarios.bak.1774780058/genericToolset.test.js +182 -0
- package/scenarios.bak.1774780058/grok.js +113 -0
- package/scenarios.bak.1774780058/memory-tools.js +51 -0
- package/scenarios.bak.1774780058/openai-o3.js +137 -0
- package/scenarios.bak.1774780058/openai-prompt.js +155 -0
- package/scenarios.bak.1774780058/openai-session.js +148 -0
- package/scenarios.bak.1774780058/openai.js +102 -0
- package/scenarios.bak.1774780058/prompt.js +118 -0
- package/scenarios.bak.1774780058/promptFishbowl.js +76 -0
- package/scenarios.bak.1774780058/search.brave.com.js +25 -0
- package/scenarios.bak.1774780058/sh.js +15 -0
- package/scenarios.bak.1774780058/test-wsio.js +26 -0
- package/scenarios.bak.1774780058/testToolset.js +42 -0
- package/scenarios.bak.1774780058/toolset.js +16 -0
- package/scenarios.bak.1774780058/toolset.test.js +141 -0
- package/scenarios.bak.1774780058/write_file_syntax.test.js +145 -0
- package/scenarios.bak.1774780058/write_file_validation/README.md +30 -0
- package/scenarios.bak.1774780058/write_file_validation/bad.js +3 -0
- package/scenarios.bak.1774780058/write_file_validation/good.js +4 -0
- package/scenarios.bak.1774780058/write_file_validation/test.sh +43 -0
- package/scenarios.bak.1774780058/wsClient.js +69 -0
- package/scenarios.bak.1774780058/xai_responses.integration.test.js +57 -0
- package/scenarios.bak.1774780058/xai_responses.test.js +154 -0
- package/scenarios.bak.1774780058/xaicoll.js +50 -0
- package/scenarios.bak.1774780058/xaifiles.js +48 -0
- package/types/AgentManager.d.ts +4 -3
- package/utils/syntax_check.sh +61 -0
- package/utils/test.sh +46 -0
- /package/{examples/askDave.js → examples.bak.1774780058/ask_agent.js} +0 -0
- /package/{examples/coderev.js → examples.bak.1774780058/coderev_agent.js} +0 -0
- /package/{examples/daisy.js → examples.bak.1774780058/daisy_agent.js} +0 -0
- /package/{examples/docsDave.js → examples.bak.1774780058/docs_agent.js} +0 -0
- /package/{examples/gpt.js → examples.bak.1774780058/gpt_agent.js} +0 -0
- /package/{examples/grok.js → examples.bak.1774780058/grok_agent.js} +0 -0
- /package/{examples/npmDave.js → examples.bak.1774780058/npm_agent.js} +0 -0
- /package/{examples/promptDave.js → examples.bak.1774780058/prompt_agent.js} +0 -0
- /package/{examples/readmeDave.js → examples.bak.1774780058/readme_agent.js} +0 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
## Changelog
|
|
2
|
+
|
|
3
|
+
### v0.0.4 (Upcoming - April 2026)
|
|
4
|
+
- **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.
|
|
5
|
+
- **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.
|
|
6
|
+
- **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.
|
|
7
|
+
- **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.
|
|
8
|
+
- **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).
|
|
9
|
+
- **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).
|
|
10
|
+
- **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.
|
|
11
|
+
- **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.
|
|
12
|
+
- **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.
|
|
13
|
+
- **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.
|
|
14
|
+
- **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.
|
|
15
|
+
|
|
16
|
+
### v0.0.3 (Previous - March 2026)
|
|
17
|
+
- Initial WS secrets, generic tools, AgentManager refinements.
|
|
18
|
+
- Reorganized examples to `examples/` folder (readmeDave, todoDave, etc.).
|
|
19
|
+
- Enhanced `bin/dave.js` for core utilities: spawning, WS with secrets, direct messaging.
|
|
20
|
+
- Improved xAI Grok API integration; added native tools/reasoning support.
|
|
21
|
+
- Removed heartbeat needs; direct CLI/cron support.
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Updated README.md
|
|
1
|
+
# Updated README.md with enhanced Changelog for v0.0.4 prep
|
|
2
2
|
|
|
3
3
|
# @j-o-r/hello-dave
|
|
4
4
|
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
- [Installation](#installation)
|
|
14
14
|
- [Quick Start](#quick-start)
|
|
15
15
|
- [Usage](#usage)
|
|
16
|
+
- [Startup Modes](#startup-modes)
|
|
16
17
|
- [Examples](#examples)
|
|
17
18
|
- [Development](#development)
|
|
18
19
|
- [Changelog](#changelog)
|
|
@@ -39,6 +40,7 @@ Whether you're building a code reviewer, a research assistant, or a creative col
|
|
|
39
40
|
- **Session Management**: Persistent conversations with large context windows; automatic truncation and history search.
|
|
40
41
|
- **CLI Utilities**: Core tool at `bin/dave.js` for cache management, WS connections, and interactive queries; plus agent generator.
|
|
41
42
|
- **Lightweight & TypeScript-Friendly**: ESM-only, no heavy deps; full types included.
|
|
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,32 +87,32 @@ 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
|
-
5. Generate a custom agent using the portable `
|
|
95
|
+
5. Generate a custom agent using the portable `spawn_agent` tool (CLI/WS agents + CodeServer launchers):
|
|
94
96
|
```bash
|
|
95
|
-
npx @j-o-r/hello-dave
|
|
97
|
+
npx @j-o-r/hello-dave spawn_agent
|
|
96
98
|
```
|
|
97
99
|
- Interactive: Follow prompts to create a new agent script in `bin/` (e.g., `bin/myagent.js`).
|
|
98
100
|
- Portable to any project (auto-installs deps like `@j-o-r/hello-dave`):
|
|
99
101
|
```bash
|
|
100
|
-
npx @j-o-r/hello-dave
|
|
102
|
+
npx @j-o-r/hello-dave spawn_agent --cwd ~/my-project
|
|
101
103
|
```
|
|
102
|
-
- Supports one-shot: `echo "Create code-review agent" | npx @j-o-r/hello-dave
|
|
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
107
|
`bin/dave.js` also supports cache operations like `--list` (list sessions), `--search "query"`, `--clear`, and `--inspect path/to/log.ndjson`.
|
|
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), and spawning agents. 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,47 +122,48 @@ 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 spawn_agent --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 spawn_agent --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 spawn_agent --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).
|
|
139
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.
|
|
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
|
-
- Example output: Deploys `bin/
|
|
144
|
+
- Example output: Deploys `bin/coderev_agent.js`, tests it, provides server/client usage guide.
|
|
143
145
|
|
|
144
|
-
- **WebSocket Client Mode** (with secrets for secure networking):
|
|
146
|
+
- **WebSocket Client Mode** (Utility UI for connecting to servers, with secrets for secure networking):
|
|
145
147
|
```bash
|
|
146
148
|
# Interactive connection
|
|
147
|
-
npx @j-o-r/hello-dave dave --connect ws://localhost:8080 --secret "mysecret"
|
|
149
|
+
Utility: npx @j-o-r/hello-dave dave --connect ws://localhost:8080 --secret "mysecret"
|
|
148
150
|
|
|
149
151
|
# Piped one-shot (direct CLI/cron messaging, no heartbeat needed)
|
|
150
152
|
echo "Predict the weather" | npx @j-o-r/hello-dave dave --connect ws://localhost:8080 --secret "mysecret"
|
|
151
153
|
echo "user_reset" | npx @j-o-r/hello-dave dave --connect ws://localhost:8080 --secret "mysecret"
|
|
152
154
|
```
|
|
153
155
|
|
|
154
|
-
- **Cache Management
|
|
156
|
+
- **Cache Management** (Session maintenance in .cache):
|
|
155
157
|
```bash
|
|
156
158
|
npx @j-o-r/hello-dave dave --list # List sessions
|
|
157
159
|
npx @j-o-r/hello-dave dave --search "AI agents" # Search history
|
|
158
160
|
npx @j-o-r/hello-dave dave --clear # Clear cache
|
|
161
|
+
npx @j-o-r/hello-dave dave --inspect path/to/log.ndjson # Inspect log
|
|
159
162
|
```
|
|
160
163
|
|
|
161
|
-
For custom agents, use `AgentManager` programmatically (see Examples).
|
|
164
|
+
For custom full agents (with prompts/tools/server support), use `AgentManager` programmatically (see Examples) or scripts like `examples/npm_agent.js`.
|
|
162
165
|
|
|
163
|
-
### Programmatic Usage with AgentManager
|
|
166
|
+
### Programmatic Usage with AgentManager (For Full Agents)
|
|
164
167
|
|
|
165
168
|
```javascript
|
|
166
169
|
import AgentManager from '@j-o-r/hello-dave';
|
|
@@ -177,6 +180,8 @@ agent.setup({
|
|
|
177
180
|
agent.addGenericToolcall('execute_bash_script'); // Post-setup generics
|
|
178
181
|
agent.addGenericToolcall('read_file');
|
|
179
182
|
agent.addGenericToolcall('write_file');
|
|
183
|
+
agent.addGenericToolcall('memory_recall'); // Persist/recall tasks, errors, prefs in .cache/memory.ndjson
|
|
184
|
+
agent.addGenericToolcall('memory_write'); // Optimizes loops and long-running sessions
|
|
180
185
|
|
|
181
186
|
await agent.start(); // Interactive CLI
|
|
182
187
|
// Or: await agent.start(undefined, 8000, undefined, 'Intro', 'toolName', 'desc'); // WS server
|
|
@@ -185,11 +190,154 @@ await agent.start(); // Interactive CLI
|
|
|
185
190
|
|
|
186
191
|
Direct CLI/cron: Pipe inputs to custom scripts for non-interactive use. WS supports secrets for authentication; no heartbeat required due to event-driven messaging.
|
|
187
192
|
|
|
193
|
+
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.
|
|
194
|
+
|
|
195
|
+
## Startup Modes
|
|
196
|
+
|
|
197
|
+
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, and cache management (no custom prompts/tools or --serve).
|
|
198
|
+
|
|
199
|
+
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).
|
|
200
|
+
|
|
201
|
+
### AgentManager.start() Options Explained
|
|
202
|
+
The `start()` method is the smart launcher for all modes. It accepts up to 5 arguments in order:
|
|
203
|
+
- `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.
|
|
204
|
+
- `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.
|
|
205
|
+
- `cliIntro` (string | undefined): Custom welcome message for interactive CLI mode (e.g., "NPM Agent ready. Ask about modules.").
|
|
206
|
+
- `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.
|
|
207
|
+
- `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.").
|
|
208
|
+
|
|
209
|
+
**Mode Determination**:
|
|
210
|
+
- If `serve` provided: Starts WS server (exposes tools).
|
|
211
|
+
- If `connect` provided: Starts WS client (attaches to remote, gains tools).
|
|
212
|
+
- If both: Hybrid mode (serves locally while using remote tools).
|
|
213
|
+
- If neither: Interactive CLI mode.
|
|
214
|
+
- For one-shot (non-start): Use `directCall(input)` directly (positional arg in scripts).
|
|
215
|
+
|
|
216
|
+
**Shared Notes**:
|
|
217
|
+
- `--secret [string]` (min 3 chars): Shared auth token. Servers reject mismatched clients; use the same for chains/networks.
|
|
218
|
+
- Other options: `--model [grok-4-fast-reasoning|...]`, `--temperature [-2 to +2]`, `--tokens`, `--top_p`, `--context [250000]`.
|
|
219
|
+
- Positional args ignored in WS modes (use CLI/pipes instead).
|
|
220
|
+
- No heartbeat: Event-driven responses.
|
|
221
|
+
- For multi-agent chaining, see [CodeServer pattern](docs/codeserver-pattern.md).
|
|
222
|
+
|
|
223
|
+
### 1. Direct Call (One-Shot, Positional Arg Only)
|
|
224
|
+
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.)
|
|
225
|
+
|
|
226
|
+
**CLI Example (Full Agent, e.g., npm_agent.js)**:
|
|
227
|
+
```bash
|
|
228
|
+
./examples/npm_agent.js "What modules are installed?" [--model grok-4]
|
|
229
|
+
```
|
|
230
|
+
- Input: Positional string (trimmed). If empty/missing, falls to interactive CLI or help.
|
|
231
|
+
|
|
232
|
+
**Programmatic (AgentManager)**:
|
|
233
|
+
```javascript
|
|
234
|
+
import { AgentManager } from '@j-o-r/hello-dave' ;
|
|
235
|
+
const agent = new AgentManager({ name: 'npm_agent' });
|
|
236
|
+
await agent.setup({ /* prompt, api, options, toolsetMode, contextWindow */ });
|
|
237
|
+
const response = await agent.directCall('What modules are installed?' );
|
|
238
|
+
console.log(response);
|
|
239
|
+
```
|
|
240
|
+
- Pair with `readIn()` from `@j-o-r/sh` for piped stdin detection in scripts (e.g., `echo "query" | script.js`).
|
|
241
|
+
|
|
242
|
+
**Utility (dave.js for Default Queries)**:
|
|
243
|
+
```bash
|
|
244
|
+
echo "Explain quantum computing" | npx @j-o-r/hello-dave dave --ask [--model grok-4]
|
|
245
|
+
```
|
|
246
|
+
- Triggers `directCall` on piped input.
|
|
247
|
+
|
|
248
|
+
### 2. Interactive CLI (No Positional Arg)
|
|
249
|
+
Launches ongoing conversation session with REPL-like input (multi-turn, until Ctrl+C or `Alt+d`).
|
|
250
|
+
|
|
251
|
+
**CLI Example (Full Agent)**:
|
|
252
|
+
```bash
|
|
253
|
+
./examples/npm_agent.js [--model grok-4]
|
|
254
|
+
```
|
|
255
|
+
- No positional: Starts `agent.start()` with CLI intro.
|
|
256
|
+
|
|
257
|
+
**Programmatic**:
|
|
258
|
+
```javascript
|
|
259
|
+
await agent.start(undefined, undefined, 'NPM Agent ready. Ask about modules or tools.' ); // Interactive CLI with custom intro
|
|
260
|
+
```
|
|
261
|
+
- Uses `cliIntro` for welcome message. Supports history, reset (`Alt+r`).
|
|
262
|
+
|
|
263
|
+
**Utility (dave.js)**:
|
|
264
|
+
```bash
|
|
265
|
+
npx @j-o-r/hello-dave dave --ask
|
|
266
|
+
```
|
|
267
|
+
- Default agent; no custom tools/prompts.
|
|
268
|
+
|
|
269
|
+
### 3. WS Server (--serve [port])
|
|
270
|
+
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.)
|
|
271
|
+
|
|
272
|
+
**CLI Example (Full Agent)**:
|
|
273
|
+
```bash
|
|
274
|
+
./examples/npm_agent.js --serve 8080 [--secret mysecret] [--model grok-4]
|
|
275
|
+
```
|
|
276
|
+
- Exposes `tool_call_name` (e.g., `npm_module_inspector`) for remote calls.
|
|
277
|
+
|
|
278
|
+
**Programmatic**:
|
|
279
|
+
```javascript
|
|
280
|
+
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
|
|
281
|
+
```
|
|
282
|
+
- `tool_call_name` and `tool_call_description` required for exposure. See [AgentManager docs](docs/agent-manager.md) for full server config, including reset propagation.
|
|
283
|
+
|
|
284
|
+
**Client Usage** (Connect to this server):
|
|
285
|
+
```bash
|
|
286
|
+
# Interactive
|
|
287
|
+
npx @j-o-r/hello-dave dave --connect ws://127.0.0.1:8080 --secret mysecret
|
|
288
|
+
# Or full agent: ./examples/other_agent.js --connect ws://127.0.0.1:8080 --secret mysecret
|
|
289
|
+
```
|
|
290
|
+
- Clients gain the server's tools (e.g., call `npm_module_inspector` in their prompts).
|
|
291
|
+
|
|
292
|
+
### 4. WS Client (--connect [ws_url])
|
|
293
|
+
Connects to a remote WS server as a client, gaining access to its tools, then launches interactive CLI.
|
|
294
|
+
|
|
295
|
+
**CLI Example (Full Agent)**:
|
|
296
|
+
```bash
|
|
297
|
+
./examples/npm_agent.js --connect ws://127.0.0.1:8080/ws --secret mysecret [--model grok-4]
|
|
298
|
+
```
|
|
299
|
+
- Attaches to server; uses remote tools in local sessions.
|
|
300
|
+
|
|
301
|
+
**Programmatic**:
|
|
302
|
+
```javascript
|
|
303
|
+
await agent.start(undefined, 'ws://127.0.0.1:8080/ws' , undefined, undefined, undefined ); // Client mode; secret required if server uses one
|
|
304
|
+
```
|
|
305
|
+
- After connection, interactive CLI starts. For one-shot: Pipe to script (uses `directCall` with remote tools).
|
|
306
|
+
|
|
307
|
+
**Utility (dave.js)**:
|
|
308
|
+
```bash
|
|
309
|
+
# Interactive
|
|
310
|
+
npx @j-o-r/hello-dave dave --connect ws://localhost:8080 --secret "mysecret"
|
|
311
|
+
# Piped one-shot (cron-friendly)
|
|
312
|
+
echo "Use remote NPM tool to list modules" | npx @j-o-r/hello-dave dave --connect ws://localhost:8080 --secret "mysecret"
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### 5. Hybrid (--serve [port] + --connect [ws_url])
|
|
316
|
+
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.)
|
|
317
|
+
|
|
318
|
+
**CLI Example (Full Agent)**:
|
|
319
|
+
```bash
|
|
320
|
+
./examples/npm_agent.js --serve 8081 --connect ws://otherhost:8080/ws [--secret mysecret]
|
|
321
|
+
```
|
|
322
|
+
- Local server on 8081 (exposes local tools); client to remote (uses remote tools).
|
|
323
|
+
|
|
324
|
+
**Programmatic**:
|
|
325
|
+
```javascript
|
|
326
|
+
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
|
|
327
|
+
```
|
|
328
|
+
- Custom handling for secrets (use same or per-mode). See [AgentManager docs](docs/agent-manager.md) for hybrid details and error handling.
|
|
329
|
+
|
|
330
|
+
**Notes**: Positional args ignored. Use for distributed setups (e.g., NPM agent serves locally but uses a code agent's tools remotely). Monitor with tools like `netstat` or PM2 in CodeServer.
|
|
331
|
+
|
|
332
|
+
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/).
|
|
333
|
+
|
|
188
334
|
## Examples
|
|
189
335
|
|
|
190
|
-
Example scripts (e.g., `
|
|
336
|
+
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).
|
|
191
337
|
|
|
192
|
-
- **Link to Examples Folder**: Explore [examples/](examples/) for full scripts like `
|
|
338
|
+
- **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).
|
|
339
|
+
|
|
340
|
+
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.
|
|
193
341
|
|
|
194
342
|
### Persistent Multi-Agent CodeServer Pattern
|
|
195
343
|
|
|
@@ -203,24 +351,24 @@ Benefits include seamless integration for dev sessions—agents stay online, han
|
|
|
203
351
|
# Start the CodeServer (requires PM2: npm i -g pm2)
|
|
204
352
|
./examples/CodeServer 8080 mysecret
|
|
205
353
|
|
|
206
|
-
# Connect via CLI (interactive or piped)
|
|
207
|
-
npx @j-o-r/hello-dave dave --connect ws://127.0.0.1:8080/ws --secret mysecret
|
|
354
|
+
# Connect via CLI utility (interactive or piped)
|
|
355
|
+
Utility: npx @j-o-r/hello-dave dave --connect ws://127.0.0.1:8080/ws --secret mysecret
|
|
208
356
|
# 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
|
|
209
357
|
```
|
|
210
358
|
|
|
211
359
|
Monitor with `pm2 list` and stop via `pm2 delete <name>`.
|
|
212
360
|
|
|
213
|
-
### Snippet: Spawning Agents (Portable via `bin/dave.js` --
|
|
361
|
+
### Snippet: Spawning Agents (Portable via `bin/dave.js` --spawn_agent)
|
|
214
362
|
|
|
215
|
-
`
|
|
363
|
+
`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.
|
|
216
364
|
|
|
217
|
-
Now CodeServer-aware: Can generate PM2 multi-agent launchers (e.g., 'Generate CodeServer for coderev + todo'). See updated [examples/
|
|
365
|
+
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).
|
|
218
366
|
|
|
219
|
-
**Portable**: `
|
|
367
|
+
**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`).
|
|
220
368
|
|
|
221
369
|
```javascript
|
|
222
|
-
// Core setup in
|
|
223
|
-
const agent = new AgentManager({ name: '
|
|
370
|
+
// Core setup in spawn_agent
|
|
371
|
+
const agent = new AgentManager({ name: 'spawn_agent', secret });
|
|
224
372
|
agent.setup({
|
|
225
373
|
prompt: 'You are AgentCreator... [detailed prompt for portability, validation]',
|
|
226
374
|
api: 'xai',
|
|
@@ -231,6 +379,8 @@ agent.setup({
|
|
|
231
379
|
agent.addGenericToolcall('execute_bash_script'); // For project inspection
|
|
232
380
|
agent.addGenericToolcall('read_file');
|
|
233
381
|
agent.addGenericToolcall('write_file'); // For generating bin/ scripts
|
|
382
|
+
agent.addGenericToolcall('memory_recall'); // For recalling previous generations or prefs
|
|
383
|
+
agent.addGenericToolcall('memory_write'); // For persisting agent configs or errors
|
|
234
384
|
|
|
235
385
|
await agent.start(); // Guides user to create e.g., bin/myagent.js
|
|
236
386
|
```
|
|
@@ -242,13 +392,13 @@ await agent.start(); // Guides user to create e.g., bin/myagent.js
|
|
|
242
392
|
|
|
243
393
|
```bash
|
|
244
394
|
# Interactive spawning (runs from npm without cloning; current dir)
|
|
245
|
-
npx @j-o-r/hello-dave
|
|
395
|
+
npx @j-o-r/hello-dave spawn_agent
|
|
246
396
|
|
|
247
397
|
# Portable to specific project (auto-switches cwd, installs deps if needed)
|
|
248
|
-
npx @j-o-r/hello-dave
|
|
398
|
+
npx @j-o-r/hello-dave spawn_agent --cwd ~/my-proj
|
|
249
399
|
|
|
250
400
|
# Piped one-shot for CodeServer launcher (portable, no cloning)
|
|
251
|
-
echo "Generate CodeServer launcher for coderev + tododave" | npx @j-o-r/hello-dave
|
|
401
|
+
echo "Generate CodeServer launcher for coderev + tododave" | npx @j-o-r/hello-dave spawn_agent --cwd ~/proj
|
|
252
402
|
```
|
|
253
403
|
|
|
254
404
|
### Snippet: Using xAI Grok API Integration
|
|
@@ -270,38 +420,48 @@ Detailed examples for xAI integration (e.g., advanced tool calls, reasoning) are
|
|
|
270
420
|
### Running Examples
|
|
271
421
|
|
|
272
422
|
```bash
|
|
273
|
-
# Music agent (examples/
|
|
274
|
-
chmod +x examples/
|
|
275
|
-
./examples/
|
|
423
|
+
# Music agent (examples/daisy_agent.js - full agent)
|
|
424
|
+
chmod +x examples/daisy_agent.js
|
|
425
|
+
./examples/daisy_agent.js "Generate lyrics for a pop song"
|
|
276
426
|
|
|
277
|
-
# TODO manager (examples/
|
|
278
|
-
./examples/
|
|
427
|
+
# TODO manager (examples/todo_agent.js - full agent)
|
|
428
|
+
./examples/todo_agent.js --connect ws://localhost:8080 --secret "secret"
|
|
279
429
|
|
|
280
|
-
# Server setup for networked examples
|
|
281
|
-
|
|
430
|
+
# Server setup for networked examples (use full agents, not dave utility)
|
|
431
|
+
./examples/npm_agent.js --serve 8080 # Expose as WS server
|
|
282
432
|
```
|
|
283
433
|
|
|
284
434
|
## Development
|
|
285
435
|
|
|
286
|
-
- **Scripts**: `npm test` (runs scenarios/
|
|
436
|
+
- **Scripts**: `npm test` (runs scenarios/grok_agent.js), `npm run types` (generate TypeScript defs), `npm run release` (pack for release).
|
|
287
437
|
- **Structure**: Core in `lib/` (AgentManager.js, wsCli.js, etc.), API integrations in `lib/API/`, examples in `examples/`, utils in `utils/`.
|
|
288
438
|
- **Testing**: Basic validation via `npm test`. Unit tests for xAI integration planned (see TODO).
|
|
289
|
-
- **Prep for v0.0.4**: Focus on
|
|
439
|
+
- **Prep for v0.0.4**: Focus on spawn_agent enhancements and release testing.
|
|
290
440
|
|
|
291
441
|
## Changelog
|
|
292
442
|
|
|
293
|
-
### v0.0.4 (
|
|
443
|
+
### v0.0.4 (Upcoming - April 2026)
|
|
444
|
+
- **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.
|
|
445
|
+
- **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.
|
|
446
|
+
- **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.
|
|
447
|
+
- **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.
|
|
448
|
+
- **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).
|
|
449
|
+
- **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).
|
|
450
|
+
- **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.
|
|
451
|
+
- **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.
|
|
452
|
+
- **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.
|
|
453
|
+
- **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.
|
|
454
|
+
- **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.
|
|
455
|
+
|
|
456
|
+
### v0.0.3 (Previous - March 2026)
|
|
457
|
+
- Initial WS secrets, generic tools, AgentManager refinements.
|
|
294
458
|
- Reorganized examples to `examples/` folder (readmeDave, todoDave, etc.).
|
|
295
459
|
- Enhanced `bin/dave.js` for core utilities: spawning, WS with secrets, direct messaging.
|
|
296
460
|
- Improved xAI Grok API integration; added native tools/reasoning support.
|
|
297
461
|
- Removed heartbeat needs; direct CLI/cron support.
|
|
298
462
|
- Added piped one-shot support to dave --ask.
|
|
299
|
-
- TODO alignment: High-priority items noted (release prep, spawnDave enhancements).
|
|
300
463
|
|
|
301
|
-
|
|
302
|
-
- Initial WS secrets, generic tools, AgentManager refinements.
|
|
303
|
-
|
|
304
|
-
Full history in git tags.
|
|
464
|
+
Full history in git tags (recent: cleanup toolset test, TODO status update, fixed test/README, syntax fixes, startup modes explanation).
|
|
305
465
|
|
|
306
466
|
## Contributing
|
|
307
467
|
|
|
@@ -322,11 +482,11 @@ Apache License 2.0. See [LICENSE](LICENSE) for details.
|
|
|
322
482
|
## TODO Alignment
|
|
323
483
|
|
|
324
484
|
This README aligns with high-priority items from [TODO.md](TODO.md):
|
|
325
|
-
- **v0.0.4 Prep**: Changelog
|
|
326
|
-
- **
|
|
327
|
-
-
|
|
328
|
-
-
|
|
329
|
-
-
|
|
485
|
+
- **v0.0.4 Prep**: Changelog updated with recent completions; release steps emphasized (version bump, tests, types, commit/tag, publish).
|
|
486
|
+
- **spawn_agent Enhancements**: Highlighted in Examples with portability and CodeServer awareness.
|
|
487
|
+
- **Agent Standardization and Safeguards**: Integrated into Changelog and Usage notes.
|
|
488
|
+
- xAI integration tests/examples: Deferred to post-v0.0.4 (future enhancements).
|
|
489
|
+
- Documentation tasks (e.g., AgentManager internals, WS refinements) completed in Usage/Examples/Changelog.
|
|
490
|
+
- **Status**: No high-priority pending; all tests stable. Focus shifted to release and future features like xAI files.js integration.
|
|
330
491
|
|
|
331
492
|
For full TODO, see [TODO.md](TODO.md).
|
|
332
|
-
|